Closed commitcompanion closed 1 month ago
Of course, the code would be implemented differently.
another example code:#[no_mangle] unsafe extern "C" fn _start() -> ! { assert!(BASE_REVISION.is_supported());
let vga_buffer = 0xb8000 as *mut u8;
let message = b"Hello, world!";
let color = 0x07; // white text on black background
for (i, &byte) in message.iter().enumerate() {
*vga_buffer.offset(i as isize * 2) = byte;
*vga_buffer.offset(i as isize * 2 + 1) = color;
}
hcf();
}
You can't write to the VGA text mode buffer like that. Firstly, there is no identity mapping with base revision 1 (which is the default if you just use BaseRevision::new()
), and secondly, Limine does not guarantee that text mode will exist, and does not provide it at all (and for example, if you're on UEFI, it's just plain unavailable).
Thank you! But why the kernel just reboots? If the debugger detects nothing, and there is an error it should halt the cpu. But the vm reboots.
It reboots as a result of a triple fault, which occurs when the CPU fails to invoke the double fault exception handler. A double fault exception is an exception raised when the CPU fails to invoke an exception handler. Since you're accessing unmapped memory (the VGA memory att 0xb8000) the CPU raises a page fault exception, and since you did not install an IDT the CPU can't handle the exception resulting in a chain of exceptions I described above.
Is there a library or method that is compatible with the template?
What do you mean by that? Writing to the VGA text buffer will never be supported with Limine. However, the Limine creators do have another package, flanterm, that provides a simple terminal interface.
and flantterm works in a freestanding binary?
Yes. That's the only place it works.
can i use the flanterm_bindings crate?
1.It is possible to edit the file so that no funktionality is inside and the cpu stops. (File 1) main.rs.txt 2.When a new funktionality is build in the kernel will not boot: Rust:
[no_mangle]
unsafe extern "C" fn _start() -> ! { // All limine requests must also be referenced in a called function, otherwise they may be // removed by the linker. assert!(BASE_REVISION.is_supported());
}
Is it right that normaqly the cpu should stop if an error happend? and not that limine or the kernel are rebooting ? why it works with the example code?
Thank you for answers!
Ps: the vga print code is from the https://os.phil-opp.com/minimal-rust-kernel/ guide, because its smaler than the other methods to do something like this. If there would be an error, cargo would say it or the code will do nothing and the cpu halts