forked from AbleOS/ableos
b
This commit is contained in:
parent
a33ecf8d93
commit
93a29060e5
|
@ -1,15 +1,35 @@
|
||||||
use x86_64::instructions::hlt;
|
use x86_64::{
|
||||||
use bootloader::BootInfo;
|
instructions::hlt,
|
||||||
|
{structures::paging::Page, VirtAddr},
|
||||||
|
};
|
||||||
|
|
||||||
|
use bootloader::{entry_point, BootInfo};
|
||||||
|
|
||||||
pub mod drivers;
|
pub mod drivers;
|
||||||
pub mod gdt;
|
pub mod gdt;
|
||||||
pub mod init;
|
pub mod init;
|
||||||
pub mod interrupts;
|
pub mod interrupts;
|
||||||
pub mod memory;
|
pub mod memory;
|
||||||
// #[no_mangle]
|
|
||||||
// pub extern "C" fn _start(boot_info: &'static BootInfo) -> ! {
|
entry_point![start];
|
||||||
// crate::kmain::kernel_main(boot_info);
|
#[no_mangle]
|
||||||
// // sloop();
|
pub fn start(boot_info: &'static BootInfo) -> ! {
|
||||||
// }
|
let phys_mem_offset = VirtAddr::new(boot_info.physical_memory_offset);
|
||||||
|
|
||||||
|
let mut mapper = unsafe { memory::init(phys_mem_offset) };
|
||||||
|
let mut frame_allocator =
|
||||||
|
unsafe { memory::BootInfoFrameAllocator::init(&boot_info.memory_map) };
|
||||||
|
|
||||||
|
let page = Page::containing_address(VirtAddr::new(0xdeadbeaf000));
|
||||||
|
memory::create_example_mapping(page, &mut mapper, &mut frame_allocator);
|
||||||
|
|
||||||
|
let page_ptr: *mut u64 = page.start_address().as_mut_ptr();
|
||||||
|
unsafe { page_ptr.offset(400).write_volatile(0xf021_f077_f065_804e) };
|
||||||
|
|
||||||
|
crate::kmain::kernel_main();
|
||||||
|
|
||||||
|
// sloop();
|
||||||
|
}
|
||||||
|
|
||||||
#[allow(unused)]
|
#[allow(unused)]
|
||||||
pub fn shutdown() -> ! {
|
pub fn shutdown() -> ! {
|
||||||
|
|
|
@ -12,10 +12,8 @@ use crate::{
|
||||||
relib::math::rand::{linearshift::LinearShiftRegister, prand::PRand, RAND_HANDLE, RNG},
|
relib::math::rand::{linearshift::LinearShiftRegister, prand::PRand, RAND_HANDLE, RNG},
|
||||||
serial_print, serial_println,
|
serial_print, serial_println,
|
||||||
};
|
};
|
||||||
use bootloader::{entry_point, BootInfo};
|
|
||||||
use lazy_static::lazy_static;
|
|
||||||
|
|
||||||
use x86_64::{structures::paging::Page, VirtAddr};
|
use lazy_static::lazy_static;
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
#[allow(unconditional_recursion)]
|
#[allow(unconditional_recursion)]
|
||||||
|
@ -30,9 +28,9 @@ lazy_static! {
|
||||||
pub static ref KEY_BUFFER_POINTER: u8 = 0;
|
pub static ref KEY_BUFFER_POINTER: u8 = 0;
|
||||||
}
|
}
|
||||||
// Defines the entry point
|
// Defines the entry point
|
||||||
entry_point![kernel_main];
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub fn kernel_main(boot_info: &'static BootInfo) -> ! {
|
pub fn kernel_main() -> ! {
|
||||||
init::init();
|
init::init();
|
||||||
|
|
||||||
GraphicsBuffer::draw();
|
GraphicsBuffer::draw();
|
||||||
|
@ -62,18 +60,6 @@ pub fn kernel_main(boot_info: &'static BootInfo) -> ! {
|
||||||
// x.dump_flags();
|
// x.dump_flags();
|
||||||
}
|
}
|
||||||
|
|
||||||
let phys_mem_offset = VirtAddr::new(boot_info.physical_memory_offset);
|
|
||||||
|
|
||||||
let mut mapper = unsafe { memory::init(phys_mem_offset) };
|
|
||||||
let mut frame_allocator =
|
|
||||||
unsafe { memory::BootInfoFrameAllocator::init(&boot_info.memory_map) };
|
|
||||||
|
|
||||||
let page = Page::containing_address(VirtAddr::new(0xdeadbeaf000));
|
|
||||||
memory::create_example_mapping(page, &mut mapper, &mut frame_allocator);
|
|
||||||
|
|
||||||
let page_ptr: *mut u64 = page.start_address().as_mut_ptr();
|
|
||||||
unsafe { page_ptr.offset(400).write_volatile(0xf021_f077_f065_804e) };
|
|
||||||
|
|
||||||
// stack_overflow();
|
// stack_overflow();
|
||||||
// crate::arch::shutdown();
|
// crate::arch::shutdown();
|
||||||
sloop()
|
sloop()
|
||||||
|
|
Loading…
Reference in a new issue