Created
March 5, 2022 00:10
-
-
Save agrif/578c04bc9928c3b4809ff87c63cf14d9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #![no_std] | |
| #![no_main] | |
| #![feature(asm_sym)] | |
| #![feature(naked_functions)] | |
| use blue_loader_stage3::{realmode, realmode_asm}; | |
| extern "sysv64" { | |
| static REALMODE_IMAGE: &'static [u8]; | |
| static mut REALMODE: &'static mut [u8]; | |
| static mut BSS: &'static mut [u8]; | |
| } | |
| fn blue() { | |
| unsafe { | |
| // blue | |
| core::arch::asm!( | |
| "mov edi, 0xb8000", | |
| "mov rcx, 500", | |
| "mov rax, 0x1F201F201F201F20", | |
| "rep stosq", | |
| ); | |
| } | |
| } | |
| pub fn printc(c: u8) { | |
| unsafe { | |
| realmode::WORK[0] = c; | |
| realmode::WORK[1] = 0x0e; | |
| realmode_asm!( | |
| "push ebx", | |
| "mov ax, [{work}]", | |
| "mov ebx, 7", | |
| "int 0x10", | |
| "pop ebx", | |
| ); | |
| } | |
| } | |
| pub fn inform(s: &[u8]) { | |
| for &c in s { | |
| printc(c); | |
| } | |
| } | |
| #[link_section = ".startup"] | |
| #[no_mangle] | |
| extern "cdecl" fn _start() -> ! { | |
| // move realmode section to true home, zero bss | |
| unsafe { | |
| REALMODE.copy_from_slice(REALMODE_IMAGE); | |
| BSS.fill(0); | |
| } | |
| inform(b"BLUEloader/3\r\n"); | |
| panic!("end of stage3"); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment