diff options
| author | salmonik <salmonik@tuta.io> | 2026-07-31 16:01:46 +0200 |
|---|---|---|
| committer | salmonik <salmonik@tuta.io> | 2026-07-31 16:01:46 +0200 |
| commit | ba667148af04963f5d70c647511ea1fad1add21d (patch) | |
| tree | 06f8faf9128d4d1fc48bbe90b5f50cf65a2e9022 /shell | |
| parent | docs: CONTEXT.md — paging adoption, heap growth, shell additions (diff) | |
| download | rs-dos-ba667148af04963f5d70c647511ea1fad1add21d.tar.gz rs-dos-ba667148af04963f5d70c647511ea1fad1add21d.zip | |
power: proper shutdown via UEFI ResetSystem (ACPI S5)
- uefi.rs: full EFI_RUNTIME_SERVICES layout with reset_system at index 10
(spec order); EfiResetSystem type + RESET_* constants
- power.rs: stash the runtime-services table pre-EBS; poweroff() calls
ResetSystem(EfiResetShutdown) — still callable after ExitBootServices
because we never call SetVirtualAddressMap, so the pointers keep
working with physical addresses; falls back to the hlt loop
- shell: 'poweroff' and 'exit' shut the machine down (QEMU exits),
'halt' keeps the plain hlt loop
Diffstat (limited to 'shell')
| -rw-r--r-- | shell/src/lib.rs | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/shell/src/lib.rs b/shell/src/lib.rs index 4d5ba9c..5cab122 100644 --- a/shell/src/lib.rs +++ b/shell/src/lib.rs | |||
| @@ -40,7 +40,8 @@ pub fn run() -> ! { | |||
| 40 | "help" => cmd_help(), | 40 | "help" => cmd_help(), |
| 41 | "echo" => cmd_echo(args), | 41 | "echo" => cmd_echo(args), |
| 42 | "clear" => cmd_clear(), | 42 | "clear" => cmd_clear(), |
| 43 | "halt" | "poweroff" | "exit" => cmd_halt(), | 43 | "halt" => cmd_halt(), |
| 44 | "poweroff" | "exit" => cmd_poweroff(), | ||
| 44 | "hello" => { | 45 | "hello" => { |
| 45 | gop_println!("World!"); | 46 | gop_println!("World!"); |
| 46 | serial_println!("World!"); | 47 | serial_println!("World!"); |
| @@ -123,10 +124,11 @@ fn cmd_help() { | |||
| 123 | gop_println!(" mem — show memory info"); | 124 | gop_println!(" mem — show memory info"); |
| 124 | gop_println!(" mmap — dump the UEFI memory map"); | 125 | gop_println!(" mmap — dump the UEFI memory map"); |
| 125 | gop_println!(" stress — stress-test heap/page allocators"); | 126 | gop_println!(" stress — stress-test heap/page allocators"); |
| 126 | gop_println!(" halt — halt the system"); | 127 | gop_println!(" halt — halt the system (hlt loop)"); |
| 127 | gop_println!(" exit — alias for halt"); | 128 | gop_println!(" poweroff — shut down via ACPI (ResetSystem)"); |
| 129 | gop_println!(" exit — alias for poweroff"); | ||
| 128 | serial_println!("available commands:"); | 130 | serial_println!("available commands:"); |
| 129 | serial_println!(" help, echo, clear, hello, info, mem, mmap, stress, halt, exit"); | 131 | serial_println!(" help, echo, clear, hello, info, mem, mmap, stress, halt, poweroff, exit"); |
| 130 | } | 132 | } |
| 131 | 133 | ||
| 132 | fn cmd_echo(args: &str) { | 134 | fn cmd_echo(args: &str) { |
| @@ -359,11 +361,13 @@ fn cmd_stress(args: &str) { | |||
| 359 | fn cmd_halt() -> ! { | 361 | fn cmd_halt() -> ! { |
| 360 | gop_println!("halting..."); | 362 | gop_println!("halting..."); |
| 361 | serial_println!("halting..."); | 363 | serial_println!("halting..."); |
| 362 | loop { | 364 | rsnix::power::halt() |
| 363 | unsafe { | 365 | } |
| 364 | core::arch::asm!("cli; hlt"); | 366 | |
| 365 | } | 367 | fn cmd_poweroff() -> ! { |
| 366 | } | 368 | gop_println!("shutting down..."); |
| 369 | serial_println!("shutting down..."); | ||
| 370 | rsnix::power::poweroff() | ||
| 367 | } | 371 | } |
| 368 | 372 | ||
| 369 | // --------------------------------------------------------------------------- | 373 | // --------------------------------------------------------------------------- |
