Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
K
kernel
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
redox-os
kernel
Commits
962836aa
Commit
962836aa
authored
8 years ago
by
Jeremy Soller
Browse files
Options
Downloads
Patches
Plain Diff
Do not block on IRQ read, add more debugging to RTL8168/9
parent
9c3a06b8
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
scheme/irq.rs
+10
-24
10 additions, 24 deletions
scheme/irq.rs
with
10 additions
and
24 deletions
scheme/irq.rs
+
10
−
24
View file @
962836aa
use
core
::{
mem
,
str
};
use
core
::
sync
::
atomic
::{
AtomicUsize
,
ATOMIC_USIZE_INIT
,
Ordering
};
use
spin
::
{
Mutex
,
Once
}
;
use
spin
::
Mutex
;
use
arch
::
interrupt
::
irq
::
acknowledge
;
use
context
;
use
sync
::
WaitCondition
;
use
syscall
::
error
::
*
;
use
syscall
::
flag
::
EVENT_READ
;
use
syscall
::
scheme
::
Scheme
;
...
...
@@ -14,22 +13,11 @@ pub static IRQ_SCHEME_ID: AtomicUsize = ATOMIC_USIZE_INIT;
/// IRQ queues
static
ACKS
:
Mutex
<
[
usize
;
16
]
>
=
Mutex
::
new
([
0
;
16
]);
static
COUNTS
:
Mutex
<
[
usize
;
16
]
>
=
Mutex
::
new
([
0
;
16
]);
static
WAITS
:
Once
<
[
WaitCondition
;
16
]
>
=
Once
::
new
();
fn
init_waits
()
->
[
WaitCondition
;
16
]
{
[
WaitCondition
::
new
(),
WaitCondition
::
new
(),
WaitCondition
::
new
(),
WaitCondition
::
new
(),
WaitCondition
::
new
(),
WaitCondition
::
new
(),
WaitCondition
::
new
(),
WaitCondition
::
new
(),
WaitCondition
::
new
(),
WaitCondition
::
new
(),
WaitCondition
::
new
(),
WaitCondition
::
new
(),
WaitCondition
::
new
(),
WaitCondition
::
new
(),
WaitCondition
::
new
(),
WaitCondition
::
new
()
]
}
/// Add to the input queue
#[no_mangle]
pub
extern
fn
irq_trigger
(
irq
:
u8
)
{
COUNTS
.lock
()[
irq
as
usize
]
+=
1
;
WAITS
.call_once
(
init_waits
)[
irq
as
usize
]
.notify
();
context
::
event
::
trigger
(
IRQ_SCHEME_ID
.load
(
Ordering
::
SeqCst
),
irq
as
usize
,
EVENT_READ
,
mem
::
size_of
::
<
usize
>
());
}
...
...
@@ -59,17 +47,15 @@ impl Scheme for IrqScheme {
fn
read
(
&
self
,
file
:
usize
,
buffer
:
&
mut
[
u8
])
->
Result
<
usize
>
{
// Ensures that the length of the buffer is larger than the size of a usize
if
buffer
.len
()
>=
mem
::
size_of
::
<
usize
>
()
{
loop
{
let
ack
=
ACKS
.lock
()[
file
];
let
current
=
COUNTS
.lock
()[
file
];
if
ack
!=
current
{
// Safe if the length of the buffer is larger than the size of a usize
assert!
(
buffer
.len
()
>=
mem
::
size_of
::
<
usize
>
());
unsafe
{
*
(
buffer
.as_mut_ptr
()
as
*
mut
usize
)
=
current
;
}
return
Ok
(
mem
::
size_of
::
<
usize
>
());
}
else
{
WAITS
.call_once
(
init_waits
)[
file
]
.wait
();
}
let
ack
=
ACKS
.lock
()[
file
];
let
current
=
COUNTS
.lock
()[
file
];
if
ack
!=
current
{
// Safe if the length of the buffer is larger than the size of a usize
assert!
(
buffer
.len
()
>=
mem
::
size_of
::
<
usize
>
());
unsafe
{
*
(
buffer
.as_mut_ptr
()
as
*
mut
usize
)
=
current
;
}
Ok
(
mem
::
size_of
::
<
usize
>
())
}
else
{
Ok
(
0
)
}
}
else
{
Err
(
Error
::
new
(
EINVAL
))
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment