mirror of
https://github.com/phil-opp/blog_os.git
synced 2025-12-16 22:37:49 +00:00
Compare commits
41 Commits
722093e2c4
...
569232322e
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
569232322e | ||
|
|
34195ec8b7 | ||
|
|
27b56832c1 | ||
|
|
48dfc6d027 | ||
|
|
e9e75e759e | ||
|
|
9799487962 | ||
|
|
a7c5741ab5 | ||
|
|
65d8ef5478 | ||
|
|
c6c0e1a7f0 | ||
|
|
c407c26224 | ||
|
|
d43aa8aebf | ||
|
|
2049f23abb | ||
|
|
0dab4b7ec2 | ||
|
|
3e814722d0 | ||
|
|
5b088bffeb | ||
|
|
e9ca6b83c4 | ||
|
|
62b2c8a0b5 | ||
|
|
1d0aa17531 | ||
|
|
dc03bde076 | ||
|
|
3a988748de | ||
|
|
e8f6e7300d | ||
|
|
889ceba24a | ||
|
|
1489b0aa06 | ||
|
|
08831b4ba1 | ||
|
|
3d94346f43 | ||
|
|
f19372d58a | ||
|
|
e4b3ed6d42 | ||
|
|
b1aec7eb66 | ||
|
|
e2a3e76a32 | ||
|
|
16bbb8f972 | ||
|
|
430e2143f8 | ||
|
|
86ffa24e8e | ||
|
|
d849a7dea5 | ||
|
|
bb2c57e1b4 | ||
|
|
18fd90b7a7 | ||
|
|
d83ab74e53 | ||
|
|
caa829db01 | ||
|
|
168dc5c2be | ||
|
|
a6141e8d2e | ||
|
|
df0c0b5783 | ||
|
|
c27eb1da9c |
4
Cargo.lock
generated
4
Cargo.lock
generated
@@ -31,9 +31,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "bootloader"
|
||||
version = "0.9.30"
|
||||
version = "0.9.31"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8a9c8b93781debeb5bc44a12adc4be812aa9feb659d60eeafcd7e9bedb549561"
|
||||
checksum = "974e79cf1b0b737839f01330fb5393095daf1124d52693696494e32523ae9ef5"
|
||||
|
||||
[[package]]
|
||||
name = "lazy_static"
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
name = "blog_os"
|
||||
version = "0.1.0"
|
||||
authors = ["Philipp Oppermann <dev@phil-opp.com>"]
|
||||
edition = "2018"
|
||||
edition = "2024"
|
||||
|
||||
[[test]]
|
||||
name = "should_panic"
|
||||
|
||||
@@ -2,10 +2,10 @@ use alloc::alloc::{GlobalAlloc, Layout};
|
||||
use core::ptr::null_mut;
|
||||
use linked_list_allocator::LockedHeap;
|
||||
use x86_64::{
|
||||
structures::paging::{
|
||||
mapper::MapToError, FrameAllocator, Mapper, Page, PageTableFlags, Size4KiB,
|
||||
},
|
||||
VirtAddr,
|
||||
structures::paging::{
|
||||
FrameAllocator, Mapper, Page, PageTableFlags, Size4KiB, mapper::MapToError,
|
||||
},
|
||||
};
|
||||
|
||||
pub const HEAP_START: usize = 0x_4444_4444_0000;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use lazy_static::lazy_static;
|
||||
use x86_64::VirtAddr;
|
||||
use x86_64::structures::gdt::{Descriptor, GlobalDescriptorTable, SegmentSelector};
|
||||
use x86_64::structures::tss::TaskStateSegment;
|
||||
use x86_64::VirtAddr;
|
||||
|
||||
pub const DOUBLE_FAULT_IST_INDEX: u16 = 0;
|
||||
|
||||
@@ -41,7 +41,7 @@ struct Selectors {
|
||||
}
|
||||
|
||||
pub fn init() {
|
||||
use x86_64::instructions::segmentation::{Segment, CS};
|
||||
use x86_64::instructions::segmentation::{CS, Segment};
|
||||
use x86_64::instructions::tables::load_tss;
|
||||
|
||||
GDT.0.load();
|
||||
|
||||
@@ -80,7 +80,7 @@ extern "x86-interrupt" fn timer_interrupt_handler(_stack_frame: InterruptStackFr
|
||||
}
|
||||
|
||||
extern "x86-interrupt" fn keyboard_interrupt_handler(_stack_frame: InterruptStackFrame) {
|
||||
use pc_keyboard::{layouts, DecodedKey, HandleControl, Keyboard, ScancodeSet1};
|
||||
use pc_keyboard::{DecodedKey, HandleControl, Keyboard, ScancodeSet1, layouts};
|
||||
use spin::Mutex;
|
||||
use x86_64::instructions::port::Port;
|
||||
|
||||
|
||||
@@ -74,7 +74,7 @@ pub fn hlt_loop() -> ! {
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
use bootloader::{entry_point, BootInfo};
|
||||
use bootloader::{BootInfo, entry_point};
|
||||
|
||||
#[cfg(test)]
|
||||
entry_point!(test_kernel_main);
|
||||
|
||||
@@ -8,7 +8,7 @@ extern crate alloc;
|
||||
|
||||
use alloc::{boxed::Box, rc::Rc, vec, vec::Vec};
|
||||
use blog_os::println;
|
||||
use bootloader::{entry_point, BootInfo};
|
||||
use bootloader::{BootInfo, entry_point};
|
||||
use core::panic::PanicInfo;
|
||||
|
||||
entry_point!(kernel_main);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use bootloader::bootinfo::{MemoryMap, MemoryRegionType};
|
||||
use x86_64::{
|
||||
structures::paging::{FrameAllocator, OffsetPageTable, PageTable, PhysFrame, Size4KiB},
|
||||
PhysAddr, VirtAddr,
|
||||
structures::paging::{FrameAllocator, OffsetPageTable, PageTable, PhysFrame, Size4KiB},
|
||||
};
|
||||
|
||||
/// Initialize a new OffsetPageTable.
|
||||
@@ -11,8 +11,10 @@ use x86_64::{
|
||||
/// `physical_memory_offset`. Also, this function must be only called once
|
||||
/// to avoid aliasing `&mut` references (which is undefined behavior).
|
||||
pub unsafe fn init(physical_memory_offset: VirtAddr) -> OffsetPageTable<'static> {
|
||||
unsafe {
|
||||
let level_4_table = active_level_4_table(physical_memory_offset);
|
||||
OffsetPageTable::new(level_4_table, physical_memory_offset)
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns a mutable reference to the active level 4 table.
|
||||
@@ -30,7 +32,7 @@ unsafe fn active_level_4_table(physical_memory_offset: VirtAddr) -> &'static mut
|
||||
let virt = physical_memory_offset + phys.as_u64();
|
||||
let page_table_ptr: *mut PageTable = virt.as_mut_ptr();
|
||||
|
||||
&mut *page_table_ptr // unsafe
|
||||
unsafe { &mut *page_table_ptr }
|
||||
}
|
||||
|
||||
/// A FrameAllocator that always returns `None`.
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
use blog_os::println;
|
||||
use core::panic::PanicInfo;
|
||||
|
||||
#[no_mangle] // don't mangle the name of this function
|
||||
#[unsafe(no_mangle)] // don't mangle the name of this function
|
||||
pub extern "C" fn _start() -> ! {
|
||||
test_main();
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ extern crate alloc;
|
||||
|
||||
use alloc::{boxed::Box, vec::Vec};
|
||||
use blog_os::allocator::HEAP_SIZE;
|
||||
use bootloader::{entry_point, BootInfo};
|
||||
use bootloader::{BootInfo, entry_point};
|
||||
use core::panic::PanicInfo;
|
||||
|
||||
entry_point!(main);
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
#![no_std]
|
||||
#![no_main]
|
||||
|
||||
use blog_os::{exit_qemu, serial_print, serial_println, QemuExitCode};
|
||||
use blog_os::{QemuExitCode, exit_qemu, serial_print, serial_println};
|
||||
use core::panic::PanicInfo;
|
||||
|
||||
#[no_mangle]
|
||||
#[unsafe(no_mangle)]
|
||||
pub extern "C" fn _start() -> ! {
|
||||
should_fail();
|
||||
serial_println!("[test did not panic]");
|
||||
|
||||
@@ -2,12 +2,12 @@
|
||||
#![no_main]
|
||||
#![feature(abi_x86_interrupt)]
|
||||
|
||||
use blog_os::{exit_qemu, serial_print, serial_println, QemuExitCode};
|
||||
use blog_os::{QemuExitCode, exit_qemu, serial_print, serial_println};
|
||||
use core::panic::PanicInfo;
|
||||
use lazy_static::lazy_static;
|
||||
use x86_64::structures::idt::{InterruptDescriptorTable, InterruptStackFrame};
|
||||
|
||||
#[no_mangle]
|
||||
#[unsafe(no_mangle)]
|
||||
pub extern "C" fn _start() -> ! {
|
||||
serial_print!("stack_overflow::stack_overflow...\t");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user