Compare commits
1 Commits
e6b231488d
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| 386d64ddd5 |
7
Cargo.lock
generated
7
Cargo.lock
generated
@@ -2,6 +2,12 @@
|
|||||||
# It is not intended for manual editing.
|
# It is not intended for manual editing.
|
||||||
version = 4
|
version = 4
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "ascii"
|
||||||
|
version = "1.1.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "d92bec98840b8f03a5ff5413de5293bfcd8bf96467cf5452609f939ec6f5de16"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "bios"
|
name = "bios"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
@@ -10,5 +16,6 @@ version = "0.1.0"
|
|||||||
name = "oxide"
|
name = "oxide"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"ascii",
|
||||||
"bios",
|
"bios",
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ members = ["deps/bios", "members/oxide"]
|
|||||||
bios = { path = "deps/bios" }
|
bios = { path = "deps/bios" }
|
||||||
|
|
||||||
[profile.release]
|
[profile.release]
|
||||||
opt-level = "z"
|
|
||||||
codegen-units = 1
|
codegen-units = 1
|
||||||
lto = "fat"
|
lto = "fat"
|
||||||
panic = "abort"
|
panic = "abort"
|
||||||
|
|||||||
@@ -10,4 +10,5 @@ test = false
|
|||||||
bench = false
|
bench = false
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
ascii = { version = "1.1.0", default-features = false }
|
||||||
bios = { workspace = true }
|
bios = { workspace = true }
|
||||||
|
|||||||
@@ -16,11 +16,16 @@
|
|||||||
/// Triggers a linker failure if this reaches that phase
|
/// Triggers a linker failure if this reaches that phase
|
||||||
#[panic_handler]
|
#[panic_handler]
|
||||||
fn panic(_info: &PanicInfo) -> ! {
|
fn panic(_info: &PanicInfo) -> ! {
|
||||||
unsafe extern "C" {
|
// 2026-02-21: Officially the end of panicless OxideOS, did you know `Debug for str` has panic
|
||||||
static __PANIC_HANDLER_WAS_LINKED__DO_NOT_DEFINE: extern "C" fn() -> !;
|
// code paths :pensive:. At least compile ones, maybe runtime impossible but still not compiled
|
||||||
}
|
// away.
|
||||||
|
unsafe { asm!("ud2", "hlt", options(noreturn)) };
|
||||||
|
|
||||||
unsafe { __PANIC_HANDLER_WAS_LINKED__DO_NOT_DEFINE() };
|
// unsafe extern "C" {
|
||||||
|
// static __PANIC_HANDLER_WAS_LINKED__DO_NOT_DEFINE: extern "C" fn() -> !;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// unsafe { __PANIC_HANDLER_WAS_LINKED__DO_NOT_DEFINE() };
|
||||||
}
|
}
|
||||||
|
|
||||||
use core::{arch::asm, fmt::Write as _, hint::black_box, panic::PanicInfo};
|
use core::{arch::asm, fmt::Write as _, hint::black_box, panic::PanicInfo};
|
||||||
@@ -49,15 +54,13 @@ extern "C" fn start(boot_info: &bif::FixedPart) -> ! {
|
|||||||
vt.set_color(VgaColor::new(ColorNibble::BLUE, ColorNibble::GREEN));
|
vt.set_color(VgaColor::new(ColorNibble::BLUE, ColorNibble::GREEN));
|
||||||
vt.put_at(10, 5);
|
vt.put_at(10, 5);
|
||||||
vt.slide();
|
vt.slide();
|
||||||
vt.print_n(boot_info as *const _ as usize as u32);
|
|
||||||
vt.write(b"testinggg\ntags:\n");
|
vt.write(b"testinggg\ntags:\n");
|
||||||
|
|
||||||
let tags = bif::TagsIter::new(boot_info);
|
let tags = bif::TagsIter::new(boot_info);
|
||||||
for tag in tags {
|
for tag in tags {
|
||||||
sleep_short();
|
sleep_short();
|
||||||
|
|
||||||
vt.print_n(tag.typ());
|
let _ = write!(&mut vt, "{}: ", tag.typ());
|
||||||
vt.write(b": ");
|
|
||||||
let Some(tag) = tag.tag() else {
|
let Some(tag) = tag.tag() else {
|
||||||
vt.write(b"unknown tag\n");
|
vt.write(b"unknown tag\n");
|
||||||
continue;
|
continue;
|
||||||
|
|||||||
@@ -54,6 +54,8 @@ pub mod bif {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub mod types {
|
pub mod types {
|
||||||
|
use ascii::AsciiStr;
|
||||||
|
|
||||||
macro tagset($taggedvis:vis $taggedname:ident { $( $typname:ident ($typn:expr) { $($typprop:ident : $typpropty:ty),* $(,)? } ),* $(,)? }) {
|
macro tagset($taggedvis:vis $taggedname:ident { $( $typname:ident ($typn:expr) { $($typprop:ident : $typpropty:ty),* $(,)? } ),* $(,)? }) {
|
||||||
$(
|
$(
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
@@ -71,14 +73,14 @@ pub mod bif {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// All these AsciiStr are actually CStr's
|
||||||
tagset! { pub TagTagged {
|
tagset! { pub TagTagged {
|
||||||
|
|
||||||
Terminate(0) {},
|
Terminate(0) {},
|
||||||
BootCommandLine(1) {
|
BootCommandLine(1) {
|
||||||
string: [u8],
|
string: AsciiStr,
|
||||||
},
|
},
|
||||||
BootLoaderName(2) {
|
BootLoaderName(2) {
|
||||||
string: [u8],
|
string: AsciiStr,
|
||||||
},
|
},
|
||||||
BasicMemoryInformation(4) {
|
BasicMemoryInformation(4) {
|
||||||
mem_lower: u32,
|
mem_lower: u32,
|
||||||
@@ -89,6 +91,42 @@ pub mod bif {
|
|||||||
partition: u32,
|
partition: u32,
|
||||||
sub_partition: u32,
|
sub_partition: u32,
|
||||||
},
|
},
|
||||||
|
MemoryMap(6) {
|
||||||
|
entry_size: u32,
|
||||||
|
entry_version: u32,
|
||||||
|
entries: [u8], // "varies"?
|
||||||
|
},
|
||||||
|
FramebufferInfo(8) {
|
||||||
|
addr: u64,
|
||||||
|
pitch: u32,
|
||||||
|
width: u32,
|
||||||
|
height: u32,
|
||||||
|
bpp: u8,
|
||||||
|
typ: u8,
|
||||||
|
_reserved: u8,
|
||||||
|
color_info: [u8],
|
||||||
|
},
|
||||||
|
ELFSymbols(9) {
|
||||||
|
num: u16,
|
||||||
|
entsize: u16,
|
||||||
|
shndx: u16,
|
||||||
|
_reserved: u16,
|
||||||
|
section_headers: [u8], // "varies"?
|
||||||
|
},
|
||||||
|
APMTable(10) {
|
||||||
|
version: u16,
|
||||||
|
cseg: u16,
|
||||||
|
offset: u32,
|
||||||
|
cseg_16: u16,
|
||||||
|
dseg: u16,
|
||||||
|
flags: u16,
|
||||||
|
cseg_len: u16,
|
||||||
|
cseg_16_len: u16,
|
||||||
|
dseg_len: u16,
|
||||||
|
},
|
||||||
|
ACPIoldRSDP(14) {
|
||||||
|
rsdpv1_old: [u8],
|
||||||
|
},
|
||||||
ImageLoadBasePhyAddr(21) {
|
ImageLoadBasePhyAddr(21) {
|
||||||
load_base_addr: u32,
|
load_base_addr: u32,
|
||||||
},
|
},
|
||||||
@@ -155,13 +193,18 @@ pub mod bif {
|
|||||||
}
|
}
|
||||||
|
|
||||||
typ_match!(match typ {
|
typ_match!(match typ {
|
||||||
|
Terminate
|
||||||
BasicMemoryInformation
|
BasicMemoryInformation
|
||||||
BIOSBootDevice
|
BIOSBootDevice
|
||||||
Terminate
|
APMTable
|
||||||
ImageLoadBasePhyAddr
|
ImageLoadBasePhyAddr
|
||||||
} fat {
|
} fat {
|
||||||
BootCommandLine
|
BootCommandLine
|
||||||
BootLoaderName
|
BootLoaderName
|
||||||
|
MemoryMap
|
||||||
|
FramebufferInfo
|
||||||
|
ELFSymbols
|
||||||
|
ACPIoldRSDP
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -54,18 +54,6 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn print_n(&mut self, n: u32) {
|
|
||||||
const BASE: u32 = 10;
|
|
||||||
|
|
||||||
if n == 0 {
|
|
||||||
// TODO: print a 0 if no recursion in the future
|
|
||||||
} else {
|
|
||||||
let digit = (n % BASE) as u8;
|
|
||||||
self.print_n(n / 10);
|
|
||||||
self.write(&[b'0' + digit]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn write(&mut self, data: &[u8]) {
|
pub fn write(&mut self, data: &[u8]) {
|
||||||
const BAD_CHAR_COL: VgaColor = VgaColor::new(ColorNibble::WHITE, ColorNibble::RED);
|
const BAD_CHAR_COL: VgaColor = VgaColor::new(ColorNibble::WHITE, ColorNibble::RED);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user