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
0d4f3125
Verified
Commit
0d4f3125
authored
1 year ago
by
Jacob Lorentzon
Browse files
Options
Downloads
Patches
Plain Diff
Use Once<SchemeId> for debug:, simplify other Once.
parent
27d35095
No related branches found
Branches containing commit
No related tags found
1 merge request
!246
Refactor int_like! macro
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/scheme/debug.rs
+10
-11
10 additions, 11 deletions
src/scheme/debug.rs
with
10 additions
and
11 deletions
src/scheme/debug.rs
+
10
−
11
View file @
0d4f3125
...
...
@@ -10,17 +10,12 @@ use crate::syscall::scheme::Scheme;
use
crate
::
syscall
::
usercopy
::
UserSliceRo
;
use
crate
::
syscall
::
usercopy
::
UserSliceWo
;
static
SCHEME_ID
:
Atomic
SchemeId
=
AtomicSchemeId
::
default
();
static
SCHEME_ID
:
Once
<
SchemeId
>
=
Once
::
new
();
static
NEXT_ID
:
AtomicUsize
=
AtomicUsize
::
new
(
0
);
/// Input queue
static
INPUT
:
Once
<
WaitQueue
<
u8
>>
=
Once
::
new
();
/// Initialize input queue, called if needed
fn
init_input
()
->
WaitQueue
<
u8
>
{
WaitQueue
::
new
()
}
static
INPUT
:
WaitQueue
<
u8
>
=
WaitQueue
::
new
();
#[derive(Clone,
Copy)]
struct
Handle
{
...
...
@@ -43,13 +38,17 @@ fn handles_mut() -> RwLockWriteGuard<'static, BTreeMap<usize, Handle>> {
/// Add to the input queue
pub
fn
debug_input
(
data
:
u8
)
{
INPUT
.
call_once
(
init_input
)
.
send
(
data
);
INPUT
.send
(
data
);
}
// Notify readers of input updates
pub
fn
debug_notify
()
{
let
Some
(
scheme_id
)
=
SCHEME_ID
.get
()
.copied
()
else
{
return
;
};
for
(
id
,
_handle
)
in
handles
()
.iter
()
{
event
::
trigger
(
SCHEME_ID
.load
(
Ordering
::
SeqCst
)
,
*
id
,
EVENT_READ
);
event
::
trigger
(
scheme_id
,
*
id
,
EVENT_READ
);
}
}
...
...
@@ -57,7 +56,7 @@ pub struct DebugScheme;
impl
DebugScheme
{
pub
fn
new
(
scheme_id
:
SchemeId
)
->
Self
{
SCHEME_ID
.
store
(
scheme_id
,
Ordering
::
SeqCst
);
SCHEME_ID
.
call_once
(||
scheme_id
);
Self
}
}
...
...
@@ -131,7 +130,7 @@ impl crate::scheme::KernelScheme for DebugScheme {
*
handles
.get
(
&
id
)
.ok_or
(
Error
::
new
(
EBADF
))
?
};
INPUT
.call_once
(
init_input
)
INPUT
.receive_into_user
(
buf
,
handle
.flags
&
O_NONBLOCK
!=
O_NONBLOCK
,
"DebugScheme::read"
)
}
...
...
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