Skip to content

Commit 7ee51ff

Browse files
Add shutdown command.
1 parent 163b3e3 commit 7ee51ff

File tree

5 files changed

+50
-16
lines changed

5 files changed

+50
-16
lines changed

CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@
22

33
## Unreleased changes
44

5-
* Switch to neotron-common-bios 0.9
5+
* Switch to neotron-common-bios 0.11
6+
* Added "Shutdown" command
7+
* Added ANSI decoder for colour changes (SGI) and cursor position support
8+
* Added 'standard input' support for applications
9+
* Use new compare-and-swap BIOS API to implement mutexes, instead of `static mut`
610

711
## v0.4.0
812

Cargo.lock

Lines changed: 15 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ panic = "abort"
4141
panic = "abort"
4242

4343
[dependencies]
44-
neotron-common-bios = { version = "0.11.0-alpha", git = "https://github.com/neotron-compute/neotron-common-bios", branch = "extra-functions" }
44+
neotron-common-bios = "0.11"
4545
pc-keyboard = "0.7"
4646
r0 = "1.0"
4747
heapless = "0.7"

src/commands/hardware.rs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,18 @@ pub static LSHW_ITEM: menu::Item<Ctx> = menu::Item {
1111
help: Some("List all the BIOS hardware"),
1212
};
1313

14+
pub static SHUTDOWN_ITEM: menu::Item<Ctx> = menu::Item {
15+
item_type: menu::ItemType::Callback {
16+
function: shutdown,
17+
parameters: &[
18+
menu::Parameter::Named { parameter_name: "reboot", help: Some("Reboot after shutting down") },
19+
menu::Parameter::Named { parameter_name: "bootloader", help: Some("Reboot into the bootloader after shutting down") }
20+
],
21+
},
22+
command: "shutdown",
23+
help: Some("Shutdown the system"),
24+
};
25+
1426
/// Called when the "lshw" command is executed.
1527
fn lshw(_menu: &menu::Menu<Ctx>, _item: &menu::Item<Ctx>, _args: &[&str], _ctx: &mut Ctx) {
1628
let api = API.get();
@@ -104,3 +116,19 @@ fn lshw(_menu: &menu::Menu<Ctx>, _item: &menu::Item<Ctx>, _args: &[&str], _ctx:
104116
osprintln!(" None");
105117
}
106118
}
119+
120+
/// Called when the "shutdown" command is executed.
121+
fn shutdown(_menu: &menu::Menu<Ctx>, item: &menu::Item<Ctx>, args: &[&str], _ctx: &mut Ctx) {
122+
let api = API.get();
123+
124+
if let Ok(Some(_)) = menu::argument_finder(item, args, "reboot") {
125+
osprintln!("Rebooting...");
126+
(api.power_control)(bios::PowerMode::Reset);
127+
} else if let Ok(Some(_)) = menu::argument_finder(item, args, "bootloader") {
128+
osprintln!("Rebooting into bootloader...");
129+
(api.power_control)(bios::PowerMode::Bootloader);
130+
} else {
131+
osprintln!("Shutting down...");
132+
(api.power_control)(bios::PowerMode::Off);
133+
}
134+
}

src/commands/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ pub static OS_MENU: menu::Menu<Ctx> = menu::Menu {
3131
&screen::FILL_ITEM,
3232
&screen::MANDEL_ITEM,
3333
&input::KBTEST_ITEM,
34+
&hardware::SHUTDOWN_ITEM,
3435
],
3536
entry: None,
3637
exit: None,

0 commit comments

Comments
 (0)