Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@ qemu-system-i386 -cdrom gratos.x86.grub.iso
- [x] try to implement `memory dumping` and `debug` in the last "mini-shell" subject
- [ ] KFS-4 (gratOS:0.4.0):
- [ ] Mandatory:
- [ ] Registers cleaning
- [ ] Stack saving
- [x] Registers cleaning
- [x] Stack saving
- [x] Hardware Interrupts
- [ ] Software Interrupts
- [x] A Interrupts Descriptor Table
Expand Down
2 changes: 1 addition & 1 deletion src/driver/shell/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
mod debug;
pub mod debug;
mod hexdump;

use super::console::{self, NUMBER_OF_REGULAR_TTY};
Expand Down
9 changes: 7 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@ use crate::{
driver::{
console::{self, FG_RED, FG_RESET, RESET},
keyboard::ps2::KEYBOARD,
pic, shell,
pic,
shell::{self, debug::print_stack},
},
power::halt,
power::{clean_registers::clean_registers, halt},
};
use core::{
arch::{asm, global_asm},
Expand All @@ -30,7 +31,11 @@ use core::{
fn panic(info: &PanicInfo) -> ! {
println!("{RESET}{FG_RED}");
println!("{info}");
print_stack(128);
print!("{FG_RESET}");
unsafe {
clean_registers();
}
halt::halt();
}

Expand Down
16 changes: 16 additions & 0 deletions src/power/clean_registers.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
use core::arch::asm;

pub unsafe fn clean_registers() {
unsafe {
asm!(
"xor eax, eax",
"xor ebx, ebx",
"xor ecx, ecx",
"xor edx, edx",
"xor esi, esi",
"xor edi, edi",
"xor ebp, ebp",
options(nomem, nostack, preserves_flags)
);
}
}
1 change: 1 addition & 0 deletions src/power/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
pub mod clean_registers;
pub mod halt;
pub mod reboot;
pub mod shutdown;