Fix build on recent versions of Rust nightly.

master
James T. Martin 2022-05-19 16:02:38 -07:00
parent 021a4a897e
commit 154eff1208
Signed by: james
GPG Key ID: 4B7F3DA9351E577C
8 changed files with 66 additions and 62 deletions

92
Cargo.lock generated
View File

@ -1,16 +1,12 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
[[package]]
name = "autocfg"
version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a"
version = 3
[[package]]
name = "bit_field"
version = "0.9.0"
name = "autocfg"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ed8765909f9009617974ab6b7d332625b320b33c326b1e9321382ef1999b5d56"
checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa"
[[package]]
name = "bit_field"
@ -20,15 +16,14 @@ checksum = "dcb6dd1c2376d2e096796e234a70e17e94cc2d5d54ff8ce42b28cef1d0d359a4"
[[package]]
name = "bitflags"
version = "1.2.1"
version = "1.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693"
checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
[[package]]
name = "bootproof"
version = "0.1.0"
dependencies = [
"compiler_builtins",
"log",
"num-integer",
"pc-screen-font",
@ -38,29 +33,24 @@ dependencies = [
[[package]]
name = "cfg-if"
version = "0.1.10"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822"
[[package]]
name = "compiler_builtins"
version = "0.1.39"
source = "git+https://github.com/rust-lang/compiler-builtins#e6fd1b272ff4cc34810e20126ffe17888a708f39"
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]]
name = "log"
version = "0.4.11"
version = "0.4.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4fabed175da42fed1fa0746b0ea71f412aa9d35e76e95e59b192c64b9dc2bf8b"
checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e"
dependencies = [
"cfg-if",
]
[[package]]
name = "num-integer"
version = "0.1.44"
version = "0.1.45"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d2cc698a63b549a70bc047073d2949cce27cd1c7b0a4a862d08a8031bc2801db"
checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9"
dependencies = [
"autocfg",
"num-traits",
@ -68,9 +58,9 @@ dependencies = [
[[package]]
name = "num-traits"
version = "0.2.14"
version = "0.2.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9a64b1ec5cda2586e284722486d802acf1f7dbdc623e2bfc57e65ca1cd099290"
checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd"
dependencies = [
"autocfg",
]
@ -85,31 +75,37 @@ dependencies = [
[[package]]
name = "proc-macro2"
version = "1.0.24"
version = "1.0.39"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1e0704ee1a7e00d7bb417d0770ea303c1bccbabf0ef1667dae92b5967f5f8a71"
checksum = "c54b25569025b7fc9651de43004ae593a75ad88543b17178aa5e1b9c4f15f56f"
dependencies = [
"unicode-xid",
"unicode-ident",
]
[[package]]
name = "quote"
version = "1.0.8"
version = "1.0.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "991431c3519a3f36861882da93630ce66b52918dcf1b8e2fd66b397fc96f28df"
checksum = "a1feb54ed693b93a84e14094943b84b7c4eae204c512b7ccb95ab0c66d278ad1"
dependencies = [
"proc-macro2",
]
[[package]]
name = "syn"
version = "1.0.58"
name = "rustversion"
version = "1.0.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cc60a3d73ea6594cd712d830cc1f0390fd71542d8c8cd24e70cc54cdfd5e05d5"
checksum = "f2cc38e8fa666e2de3c4aba7edeb5ffc5246c1c2ed0e3d17e560aeeba736b23f"
[[package]]
name = "syn"
version = "1.0.95"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fbaf6116ab8924f39d52792136fb74fd60a80194cf1b1c6ffa6453eef1c3f942"
dependencies = [
"proc-macro2",
"quote",
"unicode-xid",
"unicode-ident",
]
[[package]]
@ -118,14 +114,14 @@ version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bad643914094137d475641b6bab89462505316ec2ce70907ad20102d28a79ab8"
dependencies = [
"bit_field 0.10.1",
"bit_field",
]
[[package]]
name = "uefi"
version = "0.7.0"
version = "0.16.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bf8b4606744665c071d73d84b4ba9763b464f3500b73d8e2f13ef6f31c99f1be"
checksum = "705535cf386e4b033cc7acdea55ec8710f3dde2f07457218791aac35c83be21f"
dependencies = [
"bitflags",
"log",
@ -135,9 +131,9 @@ dependencies = [
[[package]]
name = "uefi-macros"
version = "0.3.3"
version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3dcca10ca861f34a320d178f3fdb29ffbf05087fc2c70d2a99860e3329bee1a8"
checksum = "0b9917831bc5abb78c2e6a0f4fba2be165105ed53d288718c999e0efbd433bb7"
dependencies = [
"proc-macro2",
"quote",
@ -145,17 +141,25 @@ dependencies = [
]
[[package]]
name = "unicode-xid"
version = "0.2.1"
name = "unicode-ident"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564"
checksum = "d22af068fba1eb5edcb4aea19d382b2a3deb4c8f9d475c589b6ada9e0fd493ee"
[[package]]
name = "volatile"
version = "0.4.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e3ca98349dda8a60ae74e04fd90c7fb4d6a4fbe01e6d3be095478aa0b76f6c0c"
[[package]]
name = "x86_64"
version = "0.13.1"
version = "0.14.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5d74944372d63f31dd39fce1ef8036143484ff4cd4efcd743ef50135839de4e7"
checksum = "958cd5cb28e720db2f59ee9dc4235b5f82a183d079fb0e6caf43ad074cfdc66a"
dependencies = [
"bit_field 0.9.0",
"bit_field",
"bitflags",
"rustversion",
"volatile",
]

View File

@ -7,11 +7,8 @@ repository = "https://github.com/jamestmartin/bootproof"
license = "GPL-3.0+"
publish = false
[dependencies]
compiler_builtins = { git = "https://github.com/rust-lang/compiler-builtins" }
[dependencies.log]
version = "0.4.11"
version = "0.4.17"
default-features = false
[dependencies.pc-screen-font]
@ -19,11 +16,11 @@ git = "https://github.com/jamestmartin/pc-screen-font"
rev = "aa3d7a09ee5d0ee632676fbbabea8fcaf570b83d"
[dependencies.num-integer]
version = "0.1.44"
version = "0.1.45"
default-features = false
[target.'cfg(target_os = "uefi")'.dependencies]
uefi = "0.7"
uefi = "0.16"
[target.'cfg(target_arch = "x86_64")'.dependencies]
x86_64 = "0.13"
x86_64 = "0.14.9"

View File

@ -1,4 +1,4 @@
use x86_64::instructions::segmentation::{load_ss, set_cs};
use x86_64::instructions::segmentation::{Segment, SS, CS};
use x86_64::structures::gdt::{Descriptor, DescriptorFlags, GlobalDescriptorTable};
static mut GDT: GlobalDescriptorTable = GlobalDescriptorTable::new();
@ -17,7 +17,7 @@ pub fn load() {
GDT.add_entry(Descriptor::user_data_segment());
let ss = GDT.add_entry(kernel_data_segment());
GDT.load();
set_cs(cs);
load_ss(ss);
CS::set_reg(cs);
SS::set_reg(ss);
}
}

View File

@ -9,6 +9,6 @@ pub fn load() {
}
}
extern "x86-interrupt" fn breakpoint_handler(_: &mut InterruptStackFrame) {
extern "x86-interrupt" fn breakpoint_handler(_: InterruptStackFrame) {
log::info!("Breakpoint reached!");
}

View File

@ -1,6 +1,8 @@
pub mod gdt;
pub mod idt;
use core::arch::asm;
/// This macro exists because the x86_64 library uses `llvm_asm!`, which I have disabled.
/// When the library ever uses plain `asm!` or a function, I will use its version instead.
#[cfg(target_arch="x86_64")]

View File

@ -1,5 +1,7 @@
use crate::driver::tty::Tty;
use core::arch::asm;
/// A TTY attached via a serial port.
///
/// Serial ports don't commonly exist on physical devices anymore,

View File

@ -11,7 +11,6 @@
#![feature(abi_efiapi)]
// Required by nightly when defining a global allocator.
#![feature(alloc_error_handler)]
#![feature(asm)]
// Used to conveniently define x86 interrupt handling routines.
#![feature(abi_x86_interrupt)]
#![feature(generic_associated_types)]
@ -164,7 +163,7 @@ fn efi_main(handle: Handle, st_boot: SystemTable<Boot>) -> Status {
// so we have to leave extra space in the memory map for those allocations.
// 1024 is a number that I came up with by repeatedly testing numbers
// until the kernel stopped crashing.
mmap_buf.resize(bs.memory_map_size() + 1024, 0);
mmap_buf.resize(bs.memory_map_size().map_size + 1024, 0);
// First we read the memory map so that the runtime allocator
// can decide how much space it needs to allocate for its own data structures
@ -176,13 +175,13 @@ fn efi_main(handle: Handle, st_boot: SystemTable<Boot>) -> Status {
let mut allocator;
{
let mut mmap = bs.memory_map(mmap_buf.as_mut_slice())
.expect_success("Failed to exit the UEFI boot services.").1;
.expect("Failed to exit the UEFI boot services.").1;
allocator = StandardAllocator::new(&mut mmap);
}
// Actually exit UEFI boot services!
let (st, mut mmap) = st_boot.exit_boot_services(handle, mmap_buf.as_mut_slice())
.expect_success("Failed to exit the UEFI boot services.");
.expect("Failed to exit the UEFI boot services.");
// We now populate the allocator with the final memory map.
// Before we were just allocating space for data structures,

View File

@ -17,7 +17,7 @@ pub struct UefiAllocator {
impl UefiAllocator {
pub fn new(st: SystemTable<Boot>) -> UefiAllocator {
UefiAllocator { st: st }
UefiAllocator { st }
}
}
@ -28,12 +28,12 @@ unsafe impl GlobalAlloc for UefiAllocator {
self.st.boot_services()
.allocate_pages(AllocateType::AnyPages, MemoryType::LOADER_DATA,
num_integer::div_ceil(layout.size(), PAGE_SIZE))
.expect("Failed to allocate memory!").unwrap()
.expect("Failed to allocate memory!")
as *mut u8
}
unsafe fn dealloc(&self, ptr: *mut u8, layout: Layout) {
self.st.boot_services().free_pages(ptr as u64, num_integer::div_ceil(layout.size(), PAGE_SIZE))
.expect("Failed to free memory!").unwrap();
.expect("Failed to free memory!");
}
}