Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
tapasco
tapasco
Commits
ff00160f
Unverified
Commit
ff00160f
authored
Mar 18, 2022
by
zyno42
Browse files
Fix `tapasco-debug` for `snafu` crate version bump to 0.7.0
parent
d5379853
Changes
3
Hide whitespace changes
Inline
Side-by-side
runtime/examples/Rust/tapasco-debug/src/app.rs
View file @
ff00160f
...
...
@@ -65,11 +65,11 @@ impl<'a> App<'a> {
trace!
(
"Creating new App for Tapasco state"
);
// Get Tapasco Loadable Linux Kernel Module
let
tlkm
=
TLKM
::
new
()
.context
(
TLKMInit
{})
?
;
let
tlkm
=
TLKM
::
new
()
.context
(
TLKMInit
Snafu
{})
?
;
// Allocate the device with the given ID
let
tlkm_device
=
tlkm
.device_alloc
(
device_id
,
&
HashMap
::
new
())
.context
(
TLKMInit
{})
?
;
.context
(
TLKMInit
Snafu
{})
?
;
// For some access modes we need to take some special care to use them
let
access_mode_str
=
match
access_mode
{
...
...
@@ -84,7 +84,7 @@ impl<'a> App<'a> {
// // Change device access to exclusive to be able to acquire PEs
// tlkm_device
// .change_access(tapasco::tlkm::tlkm_access::TlkmAccessExclusive)
// .context(DeviceInit {})?;
// .context(DeviceInit
Snafu
{})?;
// "Debug"
//}
AccessMode
::
Unsafe
{}
=>
{
...
...
@@ -109,7 +109,7 @@ impl<'a> App<'a> {
]);
let
title
=
format!
(
"TaPaSCo Debugger - {} Mode"
,
access_mode_str
);
let
tlkm_version
=
tlkm
.version
()
.context
(
TLKMInit
{})
?
;
let
tlkm_version
=
tlkm
.version
()
.context
(
TLKMInit
Snafu
{})
?
;
let
platform_base
=
tlkm_device
.status
()
.platform_base
...
...
@@ -137,7 +137,7 @@ impl<'a> App<'a> {
// Warning: casting to usize can panic! On a <32-bit system..
let
pe
=
tlkm_device
.acquire_pe_without_job
(
pe
.id
as
usize
)
.context
(
DeviceInit
{})
?
;
.context
(
DeviceInit
Snafu
{})
?
;
// TODO: There is no way to check that you really got the PE that you wanted
// so I have to use this workaround to set it at the ID of the PE struct which
// confusingly is NOT the pe.id from above which is stored at type_id inside the PE.
...
...
runtime/examples/Rust/tapasco-debug/src/main.rs
View file @
ff00160f
...
...
@@ -63,7 +63,7 @@ fn init() -> Result<()> {
}
=
Opt
::
from_args
();
// Specify the Access Mode as subcommand and setup the App and UI
ui
::
setup
(
&
mut
app
::
App
::
new
(
device_id
,
subcommand
)
.context
(
App
{})
?
)
.context
(
UI
{})
ui
::
setup
(
&
mut
app
::
App
::
new
(
device_id
,
subcommand
)
.context
(
App
Snafu
{})
?
)
.context
(
UI
Snafu
{})
}
fn
main
()
{
...
...
runtime/examples/Rust/tapasco-debug/src/ui.rs
View file @
ff00160f
...
...
@@ -47,26 +47,26 @@ enum Event<I, H> {
pub
fn
setup
(
app
:
&
mut
App
)
->
Result
<
()
>
{
// Raw mode disables some common terminal functions that are unnecessary in the TUI environment
enable_raw_mode
()
.context
(
Crossterm
{})
?
;
enable_raw_mode
()
.context
(
Crossterm
Snafu
{})
?
;
// Enter the Alternate Screen, so we don't break terminal history (it's like opening vim)
let
mut
stdout
=
stdout
();
execute!
(
stdout
,
EnterAlternateScreen
)
.context
(
Crossterm
{})
?
;
execute!
(
stdout
,
EnterAlternateScreen
)
.context
(
Crossterm
Snafu
{})
?
;
// Initialize Crossterm backend
let
backend
=
CrosstermBackend
::
new
(
stdout
);
let
mut
terminal
=
Terminal
::
new
(
backend
)
.context
(
Crossterm
{})
?
;
let
mut
terminal
=
Terminal
::
new
(
backend
)
.context
(
Crossterm
Snafu
{})
?
;
// Clear the Alternate Screen if someone left it dirty
terminal
.clear
()
.context
(
Crossterm
{})
?
;
terminal
.clear
()
.context
(
Crossterm
Snafu
{})
?
;
// Save the result of the main loop to return it after tearing down the backend
let
result
=
run_event_loop
(
app
,
&
mut
terminal
);
// Leave Alternate Screen to shut down cleanly regardless of the result
disable_raw_mode
()
.context
(
Crossterm
{})
?
;
execute!
(
terminal
.backend_mut
(),
LeaveAlternateScreen
)
.context
(
Crossterm
{})
?
;
terminal
.show_cursor
()
.context
(
Crossterm
{})
?
;
disable_raw_mode
()
.context
(
Crossterm
Snafu
{})
?
;
execute!
(
terminal
.backend_mut
(),
LeaveAlternateScreen
)
.context
(
Crossterm
Snafu
{})
?
;
terminal
.show_cursor
()
.context
(
Crossterm
Snafu
{})
?
;
// Return the result of the main loop after restoring the previous terminal state in order to
// not be stuck in the Alternate Screen / or Raw Mode which would make a `reset` of the shell
...
...
@@ -100,7 +100,7 @@ fn run_event_loop<B: Backend>(app: &mut App, terminal: &mut Terminal<B>) -> Resu
draw
(
app
,
terminal
)
?
;
// Handle events
match
rx
.recv
()
.context
(
ReceiveInput
{})
?
{
match
rx
.recv
()
.context
(
ReceiveInput
Snafu
{})
?
{
// Match key pressed events
Event
::
Input
(
event
)
=>
{
trace!
(
"Input event: {:?}"
,
event
);
...
...
@@ -216,7 +216,7 @@ fn draw<B: Backend>(app: &mut App, terminal: &mut Terminal<B>) -> Result<()> {
2
=>
draw_tab_bitstream_and_device_info
(
f
,
app
,
tabs_chunks
[
2
]),
_
=>
{},
}
})
.context
(
Crossterm
{})
?
;
})
.context
(
Crossterm
Snafu
{})
?
;
Ok
(())
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment