Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
OpenSK
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
koenigl2
OpenSK
Commits
fdfe5882
Commit
fdfe5882
authored
5 years ago
by
tamaf96
Browse files
Options
Downloads
Patches
Plain Diff
unsafe fix for missing syscalls::yieldk_for()
parent
ffc7fd52
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/main.rs
+2
-3
2 additions, 3 deletions
src/main.rs
src/usb_ctap_hid.rs
+13
-5
13 additions, 5 deletions
src/usb_ctap_hid.rs
with
15 additions
and
8 deletions
src/main.rs
+
2
−
3
View file @
fdfe5882
...
@@ -44,7 +44,6 @@ use libtock::buttons::ButtonState;
...
@@ -44,7 +44,6 @@ use libtock::buttons::ButtonState;
use
libtock
::
console
::
Console
;
use
libtock
::
console
::
Console
;
use
libtock
::
leds
::
LedsDriver
;
use
libtock
::
leds
::
LedsDriver
;
use
libtock
::
result
::
TockResult
;
use
libtock
::
result
::
TockResult
;
use
libtock
::
syscalls
;
use
libtock
::
timer
;
use
libtock
::
timer
;
#[cfg(feature
=
"debug_ctap"
)]
#[cfg(feature
=
"debug_ctap"
)]
use
libtock
::
timer
::
Timer
;
use
libtock
::
timer
::
Timer
;
...
@@ -363,7 +362,7 @@ fn check_user_presence(cid: ChannelID) -> Result<(), Ctap2StatusCode> {
...
@@ -363,7 +362,7 @@ fn check_user_presence(cid: ChannelID) -> Result<(), Ctap2StatusCode> {
let
keepalive_alarm
=
keepalive
.set_alarm
(
KEEPALIVE_DELAY
)
.unwrap
();
let
keepalive_alarm
=
keepalive
.set_alarm
(
KEEPALIVE_DELAY
)
.unwrap
();
// Wait for a button touch or an alarm.
// Wait for a button touch or an alarm.
syscalls
::
yieldk_for
(||
button_touched
.get
()
||
keepalive_expired
.get
());
usb_ctap_hid
::
yieldk_for
(||
button_touched
.get
()
||
keepalive_expired
.get
());
// Cleanup alarm callback.
// Cleanup alarm callback.
match
keepalive
.stop_alarm
(
keepalive_alarm
)
{
match
keepalive
.stop_alarm
(
keepalive_alarm
)
{
...
@@ -403,4 +402,4 @@ fn check_user_presence(cid: ChannelID) -> Result<(), Ctap2StatusCode> {
...
@@ -403,4 +402,4 @@ fn check_user_presence(cid: ChannelID) -> Result<(), Ctap2StatusCode> {
}
else
{
}
else
{
Err
(
Ctap2StatusCode
::
CTAP2_ERR_USER_ACTION_TIMEOUT
)
Err
(
Ctap2StatusCode
::
CTAP2_ERR_USER_ACTION_TIMEOUT
)
}
}
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
src/usb_ctap_hid.rs
+
13
−
5
View file @
fdfe5882
...
@@ -81,7 +81,7 @@ pub fn recv(buf: &mut [u8; 64]) -> bool {
...
@@ -81,7 +81,7 @@ pub fn recv(buf: &mut [u8; 64]) -> bool {
return
false
;
return
false
;
}
}
syscalls
::
yieldk_for
(||
done
.get
());
yieldk_for
(||
done
.get
());
true
true
}
}
...
@@ -104,7 +104,7 @@ pub fn send(buf: &mut [u8; 64]) -> bool {
...
@@ -104,7 +104,7 @@ pub fn send(buf: &mut [u8; 64]) -> bool {
return
false
;
return
false
;
}
}
syscalls
::
yieldk_for
(||
done
.get
());
yieldk_for
(||
done
.get
());
true
true
}
}
...
@@ -154,7 +154,7 @@ pub fn send_or_recv(buf: &mut [u8; 64]) -> SendOrRecvStatus {
...
@@ -154,7 +154,7 @@ pub fn send_or_recv(buf: &mut [u8; 64]) -> SendOrRecvStatus {
return
SendOrRecvStatus
::
Error
;
return
SendOrRecvStatus
::
Error
;
}
}
syscalls
::
yieldk_for
(||
status
.get
()
.is_some
());
yieldk_for
(||
status
.get
()
.is_some
());
status
.get
()
.unwrap
()
status
.get
()
.unwrap
()
}
}
...
@@ -261,7 +261,7 @@ fn recv_with_timeout_detail(
...
@@ -261,7 +261,7 @@ fn recv_with_timeout_detail(
return
Some
(
SendOrRecvStatus
::
Error
);
return
Some
(
SendOrRecvStatus
::
Error
);
}
}
syscalls
::
yieldk_for
(||
status
.get
()
.is_some
()
||
timeout_expired
.get
());
yieldk_for
(||
status
.get
()
.is_some
()
||
timeout_expired
.get
());
// Cleanup alarm callback.
// Cleanup alarm callback.
match
timeout
.stop_alarm
(
timeout_alarm
)
{
match
timeout
.stop_alarm
(
timeout_alarm
)
{
...
@@ -362,7 +362,7 @@ fn send_or_recv_with_timeout_detail(
...
@@ -362,7 +362,7 @@ fn send_or_recv_with_timeout_detail(
return
Some
(
SendOrRecvStatus
::
Error
);
return
Some
(
SendOrRecvStatus
::
Error
);
}
}
syscalls
::
yieldk_for
(||
status
.get
()
.is_some
()
||
timeout_expired
.get
());
yieldk_for
(||
status
.get
()
.is_some
()
||
timeout_expired
.get
());
// Cleanup alarm callback.
// Cleanup alarm callback.
match
timeout
.stop_alarm
(
timeout_alarm
)
{
match
timeout
.stop_alarm
(
timeout_alarm
)
{
...
@@ -411,3 +411,11 @@ fn send_or_recv_with_timeout_detail(
...
@@ -411,3 +411,11 @@ fn send_or_recv_with_timeout_detail(
status
.get
()
status
.get
()
}
}
pub
(
crate
)
fn
yieldk_for
<
F
:
Fn
()
->
bool
>
(
cond
:
F
)
{
while
!
cond
()
{
unsafe
{
syscalls
::
raw
::
yieldk
();
}
}
}
\ No newline at end of file
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