Overhaul of dependencies, inluding x86_64 0.9.2 breaking changes

This commit is contained in:
guillaume didier 2020-02-19 15:08:24 +01:00
parent 1d4ca06c96
commit da4204f655
7 changed files with 28 additions and 71 deletions

58
Cargo.lock generated
View File

@ -1,13 +1,5 @@
# This file is automatically @generated by Cargo. # This file is automatically @generated by Cargo.
# It is not intended for manual editing. # It is not intended for manual editing.
[[package]]
name = "array-init"
version = "0.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"nodrop 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]] [[package]]
name = "bit_field" name = "bit_field"
version = "0.9.0" version = "0.9.0"
@ -20,12 +12,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]] [[package]]
name = "bitflags" name = "bitflags"
version = "1.2.0" version = "1.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]] [[package]]
name = "bootloader" name = "bootloader"
version = "0.8.2" version = "0.8.6"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"bit_field 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", "bit_field 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)",
@ -37,26 +29,21 @@ version = "0.1.0"
dependencies = [ dependencies = [
"polling_serial 0.1.0", "polling_serial 0.1.0",
"vga_buffer 0.1.0", "vga_buffer 0.1.0",
"x86_64 0.7.5 (registry+https://github.com/rust-lang/crates.io-index)", "x86_64 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
[[package]]
name = "cast"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]] [[package]]
name = "dendrobates_tinctoreus_azureus" name = "dendrobates_tinctoreus_azureus"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"bootloader 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)", "bootloader 0.8.6 (registry+https://github.com/rust-lang/crates.io-index)",
"cache_utils 0.1.0", "cache_utils 0.1.0",
"lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"linked_list_allocator 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)", "linked_list_allocator 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)",
"polling_serial 0.1.0", "polling_serial 0.1.0",
"vga_buffer 0.1.0", "vga_buffer 0.1.0",
"volatile 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", "volatile 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
"x86_64 0.7.5 (registry+https://github.com/rust-lang/crates.io-index)", "x86_64 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
[[package]] [[package]]
@ -69,24 +56,19 @@ dependencies = [
[[package]] [[package]]
name = "linked_list_allocator" name = "linked_list_allocator"
version = "0.6.4" version = "0.6.6"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"spin 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", "spin 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
[[package]]
name = "nodrop"
version = "0.1.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]] [[package]]
name = "polling_serial" name = "polling_serial"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"spin 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", "spin 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)",
"x86_64 0.7.5 (registry+https://github.com/rust-lang/crates.io-index)", "x86_64 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
[[package]] [[package]]
@ -94,11 +76,6 @@ name = "spin"
version = "0.5.2" version = "0.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "ux"
version = "0.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]] [[package]]
name = "vga_buffer" name = "vga_buffer"
version = "0.1.0" version = "0.1.0"
@ -115,27 +92,20 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]] [[package]]
name = "x86_64" name = "x86_64"
version = "0.7.5" version = "0.9.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"array-init 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
"bit_field 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "bit_field 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
"bitflags 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
"cast 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
"ux 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
[metadata] [metadata]
"checksum array-init 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "23589ecb866b460d3a0f1278834750268c607e8e28a1b982c907219f3178cd72"
"checksum bit_field 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a165d606cf084741d4ac3a28fb6e9b1eb0bd31f6cd999098cfddb0b2ab381dc0" "checksum bit_field 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a165d606cf084741d4ac3a28fb6e9b1eb0bd31f6cd999098cfddb0b2ab381dc0"
"checksum bit_field 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ed8765909f9009617974ab6b7d332625b320b33c326b1e9321382ef1999b5d56" "checksum bit_field 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ed8765909f9009617974ab6b7d332625b320b33c326b1e9321382ef1999b5d56"
"checksum bitflags 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8a606a02debe2813760609f57a64a2ffd27d9fdf5b2f133eaca0b248dd92cdd2" "checksum bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693"
"checksum bootloader 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)" = "abfbe6cdea6367860818facc8e4a184f003cb83d7d004acaaf57baebf1949da0" "checksum bootloader 0.8.6 (registry+https://github.com/rust-lang/crates.io-index)" = "37b4577f46430d7dd1f16fa13a3aab5e3b57fe9ce7ff4378aa6b184e268eb60e"
"checksum cast 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "926013f2860c46252efceabb19f4a6b308197505082c609025aa6706c011d427"
"checksum lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" "checksum lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
"checksum linked_list_allocator 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)" = "47314ec1d29aa869ee7cb5a5be57be9b1055c56567d59c3fb6689926743e0bea" "checksum linked_list_allocator 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)" = "47de1a43fad0250ee197e9e124e5b5deab3d7b39d4428ae8a6d741ceb340c362"
"checksum nodrop 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)" = "2f9667ddcc6cc8a43afc9b7917599d7216aa09c463919ea32c59ed6cac8bc945"
"checksum spin 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" "checksum spin 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d"
"checksum ux 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "88dfeb711b61ce620c0cb6fd9f8e3e678622f0c971da2a63c4b3e25e88ed012f"
"checksum volatile 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "6af0edf5b4faacc31fc51159244d78d65ec580f021afcef7bd53c04aeabc7f29" "checksum volatile 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "6af0edf5b4faacc31fc51159244d78d65ec580f021afcef7bd53c04aeabc7f29"
"checksum x86_64 0.7.5 (registry+https://github.com/rust-lang/crates.io-index)" = "997837f3913aac8f67164683258756d712376849906c8d609f844084bc03ef84" "checksum x86_64 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7467ff985c75f098f9897ea693141dbb25c8a5ceaf91e4a28ab705765932efb6"

View File

@ -24,7 +24,7 @@ test-success-exit-code = 33 # (0x10 << 1) | 1
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies] [dependencies]
x86_64 = "0.7.5" x86_64 = "0.9.2"
vga_buffer = { path = "vga_buffer" } vga_buffer = { path = "vga_buffer" }
polling_serial = { path = "polling_serial" } polling_serial = { path = "polling_serial" }
volatile = "0.2.6" volatile = "0.2.6"

View File

@ -9,4 +9,4 @@ edition = "2018"
[dependencies] [dependencies]
polling_serial = { path = "../polling_serial" } polling_serial = { path = "../polling_serial" }
vga_buffer = { path = "../vga_buffer" } vga_buffer = { path = "../vga_buffer" }
x86_64 = "0.7.5" x86_64 = "0.9.2"

View File

@ -7,7 +7,7 @@ edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies] [dependencies]
x86_64 = "0.7.5" x86_64 = "0.9.2"
spin = "0.5.2" spin = "0.5.2"
[dependencies.lazy_static] [dependencies.lazy_static]

View File

@ -1,5 +1,3 @@
use alloc::alloc::{GlobalAlloc, Layout};
use core::ptr::null_mut;
use polling_serial::serial_println; use polling_serial::serial_println;
use x86_64::{ use x86_64::{
structures::paging::{ structures::paging::{
@ -11,22 +9,10 @@ use x86_64::{
pub const HEAP_START: usize = 0x4444_4444_0000; pub const HEAP_START: usize = 0x4444_4444_0000;
pub const HEAP_SIZE: usize = 0x1 << 20; // 1MB Heap pub const HEAP_SIZE: usize = 0x1 << 20; // 1MB Heap
pub struct Dummy;
unsafe impl GlobalAlloc for Dummy {
unsafe fn alloc(&self, _layout: Layout) -> *mut u8 {
null_mut()
}
unsafe fn dealloc(&self, _ptr: *mut u8, _layout: Layout) {
panic!("dealloc should never be called");
}
}
pub fn init_heap( pub fn init_heap(
mapper: &mut impl Mapper<Size4KiB>, mapper: &mut impl Mapper<Size4KiB>,
frame_allocator: &mut impl FrameAllocator<Size4KiB>, frame_allocator: &mut impl FrameAllocator<Size4KiB>,
) -> Result<(), MapToError> { ) -> Result<(), MapToError<Size4KiB>> {
let page_range = { let page_range = {
let heap_start = VirtAddr::new(HEAP_START as u64); let heap_start = VirtAddr::new(HEAP_START as u64);
let heap_end = heap_start + HEAP_SIZE as u64 - 1u64; let heap_end = heap_start + HEAP_SIZE as u64 - 1u64;
@ -40,10 +26,7 @@ pub fn init_heap(
.allocate_frame() .allocate_frame()
.ok_or(MapToError::FrameAllocationFailed)?; .ok_or(MapToError::FrameAllocationFailed)?;
let flags = PageTableFlags::PRESENT | PageTableFlags::WRITABLE; let flags = PageTableFlags::PRESENT | PageTableFlags::WRITABLE;
unsafe { mapper.map_to(page, frame, flags, frame_allocator)?.flush() }; mapper.map_to(page, frame, flags, frame_allocator)?.flush();
if i == 0 {
serial_println!("Mapped {:?} at {:?}", page, frame);
}
} }
unsafe { unsafe {

View File

@ -32,7 +32,7 @@ extern "x86-interrupt" fn breakpoint_handler(stack_frame: &mut InterruptStackFra
x86_64::instructions::bochs_breakpoint(); x86_64::instructions::bochs_breakpoint();
} }
extern "x86-interrupt" fn double_fault_handler(sf: &mut InterruptStackFrame, e: u64) { extern "x86-interrupt" fn double_fault_handler(sf: &mut InterruptStackFrame, e: u64) -> ! {
// LLVM bug causing misaligned stacks when error codes are present. // LLVM bug causing misaligned stacks when error codes are present.
// This code realigns the stack and then grabs the correct values by doing some pointer arithmetic // This code realigns the stack and then grabs the correct values by doing some pointer arithmetic
let stack_frame: &mut InterruptStackFrame; let stack_frame: &mut InterruptStackFrame;

View File

@ -1,6 +1,7 @@
use x86_64::{ use x86_64::{
structures::paging::{ structures::paging::{
FrameAllocator, Mapper, OffsetPageTable, Page, PageTable, PhysFrame, Size4KiB, FrameAllocator, Mapper, OffsetPageTable, Page, PageTable, PhysFrame, Size4KiB,
UnusedPhysFrame,
}, },
PhysAddr, VirtAddr, PhysAddr, VirtAddr,
}; };
@ -45,9 +46,11 @@ pub fn create_example_mapping(
use x86_64::structures::paging::PageTableFlags as Flags; use x86_64::structures::paging::PageTableFlags as Flags;
let frame = PhysFrame::containing_address(PhysAddr::new(0xb8000)); let frame = PhysFrame::containing_address(PhysAddr::new(0xb8000));
let not_really_unused_frame = unsafe { UnusedPhysFrame::new(frame) };
let flags = Flags::PRESENT | Flags::WRITABLE; let flags = Flags::PRESENT | Flags::WRITABLE;
let map_to_result = unsafe { mapper.map_to(page, frame, flags, frame_allocator) }; let map_to_result =
unsafe { mapper.map_to(page, not_really_unused_frame, flags, frame_allocator) };
map_to_result.expect("map_to failed").flush(); map_to_result.expect("map_to failed").flush();
} }
@ -79,13 +82,14 @@ impl BootInfoFrameAllocator {
// transform to an iterator of frame start addresses // transform to an iterator of frame start addresses
let frame_addresses = addr_ranges.flat_map(|r| r.step_by(4096)); let frame_addresses = addr_ranges.flat_map(|r| r.step_by(4096));
// create `PhysFrame` types from the start addresses // create `PhysFrame` types from the start addresses
frame_addresses.map(|addr| PhysFrame::containing_address(PhysAddr::new(addr))) let frames = frame_addresses.map(|addr| PhysFrame::containing_address(PhysAddr::new(addr)));
frames
} }
} }
unsafe impl FrameAllocator<Size4KiB> for BootInfoFrameAllocator { unsafe impl FrameAllocator<Size4KiB> for BootInfoFrameAllocator {
fn allocate_frame(&mut self) -> Option<PhysFrame> { fn allocate_frame(&mut self) -> Option<UnusedPhysFrame> {
let frame = self.usable_frames().nth(self.next); let frame = self.usable_frames().nth(self.next);
self.next += 1; self.next += 1;
frame frame.map(|f| unsafe { UnusedPhysFrame::new(f) })
} }
} }