Add fb request
This commit is contained in:
parent
ac8aa25e38
commit
a2540962da
88
Cargo.lock
generated
88
Cargo.lock
generated
@ -9,7 +9,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "94476c7ef97af4c4d998b3f422c1b01d5211aad57c80ed200baf148d1f1efab6"
|
||||
dependencies = [
|
||||
"bit_field",
|
||||
"bitflags 2.9.0",
|
||||
"bitflags",
|
||||
"log",
|
||||
]
|
||||
|
||||
@ -25,33 +25,12 @@ version = "0.10.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "dc827186963e592360843fb5ba4b973e145841266c1357f7180c43526f2e5b61"
|
||||
|
||||
[[package]]
|
||||
name = "bitflags"
|
||||
version = "1.3.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
|
||||
|
||||
[[package]]
|
||||
name = "bitflags"
|
||||
version = "2.9.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5c8214115b7bf84099f1309324e63141d4c5d7cc26862f97a0a857dbefe165bd"
|
||||
|
||||
[[package]]
|
||||
name = "conquer-once"
|
||||
version = "0.3.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7c6d3a9775a69f6d1fe2cc888999b67ed30257d3da4d2af91984e722f2ec918a"
|
||||
dependencies = [
|
||||
"conquer-util",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "conquer-util"
|
||||
version = "0.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e763eef8846b13b380f37dfecda401770b0ca4e56e95170237bd7c25c7db3582"
|
||||
|
||||
[[package]]
|
||||
name = "critical-section"
|
||||
version = "1.2.0"
|
||||
@ -84,12 +63,6 @@ version = "0.4.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b7ac824320a75a52197e8f2d787f6a38b6718bb6897a35142d749af3c0e8f4fe"
|
||||
|
||||
[[package]]
|
||||
name = "font8x8"
|
||||
version = "0.3.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "875488b8711a968268c7cf5d139578713097ca4635a76044e8fe8eedf831d07e"
|
||||
|
||||
[[package]]
|
||||
name = "gila"
|
||||
version = "0.3.0"
|
||||
@ -101,7 +74,6 @@ dependencies = [
|
||||
"once_cell",
|
||||
"spin",
|
||||
"talc",
|
||||
"vga",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -110,7 +82,7 @@ version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6e6cb7fd182815ec1ea9e26061418ac37c3eebea47a14e773c563533f277bcef"
|
||||
dependencies = [
|
||||
"bitflags 2.9.0",
|
||||
"bitflags",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -129,15 +101,6 @@ version = "0.4.27"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "13dc2df351e3202783a1fe0d44375f7295ffb4049267b0f3018346dc122a1d94"
|
||||
|
||||
[[package]]
|
||||
name = "num-traits"
|
||||
version = "0.2.19"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841"
|
||||
dependencies = [
|
||||
"autocfg",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "once_cell"
|
||||
version = "1.21.3"
|
||||
@ -172,12 +135,6 @@ dependencies = [
|
||||
"proc-macro2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rustversion"
|
||||
version = "1.0.20"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "eded382c5f5f786b989652c49544c4877d9f015cc22e145a5ea8ea66c2921cd2"
|
||||
|
||||
[[package]]
|
||||
name = "scopeguard"
|
||||
version = "1.2.0"
|
||||
@ -193,15 +150,6 @@ dependencies = [
|
||||
"lock_api",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "spinning_top"
|
||||
version = "0.2.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5b9eb1a2f4c41445a3a0ff9abc5221c5fcd28e1f13cd7c0397706f9ac938ddb0"
|
||||
dependencies = [
|
||||
"lock_api",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "2.0.101"
|
||||
@ -227,35 +175,3 @@ name = "unicode-ident"
|
||||
version = "1.0.18"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5a5f39404a5da50712a4c1eecf25e90dd62b613502b7e925fd4e4d19b5c96512"
|
||||
|
||||
[[package]]
|
||||
name = "vga"
|
||||
version = "0.2.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a5dd163a9cf938e0406e1ee29e3b71ac7d8f5ffe6c1321fe74797ebef1299bc6"
|
||||
dependencies = [
|
||||
"bitflags 1.3.2",
|
||||
"conquer-once",
|
||||
"font8x8",
|
||||
"num-traits",
|
||||
"spinning_top",
|
||||
"x86_64",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "volatile"
|
||||
version = "0.4.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "442887c63f2c839b346c192d047a7c87e73d0689c9157b00b53dcc27dd5ea793"
|
||||
|
||||
[[package]]
|
||||
name = "x86_64"
|
||||
version = "0.14.13"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c101112411baafbb4bf8d33e4c4a80ab5b02d74d2612331c61e8192fc9710491"
|
||||
dependencies = [
|
||||
"bit_field",
|
||||
"bitflags 2.9.0",
|
||||
"rustversion",
|
||||
"volatile",
|
||||
]
|
||||
|
@ -12,9 +12,6 @@ once_cell = { version = "1.20.3", default-features = false, features = ["alloc",
|
||||
spin = "0.10.0"
|
||||
talc = "4.4.2"
|
||||
|
||||
[target.'cfg(target_arch = "x86_64")'.dependencies]
|
||||
vga = "0.2.9"
|
||||
|
||||
[lib]
|
||||
name = "gila"
|
||||
path = "src/lib/lib.rs"
|
||||
|
@ -3,5 +3,5 @@ timeout: 5
|
||||
/Gila
|
||||
protocol: limine
|
||||
kernel_path: boot():/boot/kernel
|
||||
cmdline: -loglevel=INFO -logdev=display,serial
|
||||
cmdline: -loglevel=Trace -logdev=display,serial
|
||||
module_path: boot():/boot/initramfs.tar.lzma
|
||||
|
@ -55,7 +55,7 @@ pub unsafe fn port_write_u8(port: u16, data: u8) {
|
||||
in("dx") port,
|
||||
in("al") data,
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub unsafe fn port_write_u16(port: u16, data: u16) {
|
||||
|
@ -4,31 +4,4 @@
|
||||
#![allow(dead_code)]
|
||||
#![allow(unused_variables)]
|
||||
|
||||
use vga;
|
||||
|
||||
pub struct TextDisplay {
|
||||
writer: vga::writers::Text80x25,
|
||||
column: usize,
|
||||
row: usize,
|
||||
}
|
||||
|
||||
impl Default for TextDisplay {
|
||||
fn default() -> Self {
|
||||
Self::new()
|
||||
}
|
||||
}
|
||||
|
||||
impl TextDisplay {
|
||||
pub const fn new() -> Self {
|
||||
TextDisplay {
|
||||
writer: vga::writers::Text80x25::new(),
|
||||
column: 0,
|
||||
row: 0,
|
||||
}
|
||||
}
|
||||
pub fn writeline(text: &str, colors: vga::colors::TextModeColor) {}
|
||||
|
||||
pub fn write(text: &str, colors: vga::colors::TextModeColor) {}
|
||||
}
|
||||
|
||||
pub static TEXT_DISPLAY: TextDisplay = TextDisplay::new();
|
||||
|
@ -17,9 +17,7 @@ impl LogSubscriber for Serialport {
|
||||
}
|
||||
|
||||
impl Serialport {
|
||||
pub fn new(port: u16) -> Self {
|
||||
Serialport {
|
||||
port
|
||||
}
|
||||
pub fn new(port: u16) -> Self {
|
||||
Serialport { port }
|
||||
}
|
||||
}
|
@ -25,3 +25,10 @@ pub static RSDP_REQUEST: RsdpRequest = limine::request::RsdpRequest::new();
|
||||
#[used]
|
||||
#[unsafe(link_section = ".requests")]
|
||||
pub static MODULE_REQUEST: ModuleRequest = limine::request::ModuleRequest::new();
|
||||
#[used]
|
||||
#[unsafe(link_section = ".requests")]
|
||||
pub static ADDRESS_REQUEST: ExecutableAddressRequest =
|
||||
limine::request::ExecutableAddressRequest::new();
|
||||
#[used]
|
||||
#[unsafe(link_section = ".requests")]
|
||||
pub static FRAMEBUFFER_REQUEST: FramebufferRequest = limine::request::FramebufferRequest::new();
|
||||
|
@ -4,7 +4,6 @@
|
||||
use core::fmt::Write;
|
||||
|
||||
use crate::memory::alloc;
|
||||
|
||||
use alloc::boxed::*;
|
||||
use alloc::string::*;
|
||||
use alloc::vec::*;
|
||||
@ -41,14 +40,13 @@ impl Logger {
|
||||
/// Calling log will sequentially acquire lock on all logging subscribers
|
||||
/// to write to them with a formatted log message.
|
||||
pub fn log(&self, level: LogLevel, msg: &str) {
|
||||
|
||||
// Nobody is EVER allowed to call log with the Disabled log level. It is a placeholder.
|
||||
if level == LogLevel::Disabled {
|
||||
// Nothing
|
||||
} else if level >= self.level {
|
||||
} else if level <= self.level {
|
||||
for sub in &self.subscriber {
|
||||
let mut message = String::new();
|
||||
writeln!(&mut message, "{level:?}: {msg}").unwrap();
|
||||
writeln!(&mut message, "{level:?}:\t {msg}").unwrap();
|
||||
sub.lock().write(&message);
|
||||
}
|
||||
}
|
||||
@ -57,12 +55,12 @@ impl Logger {
|
||||
|
||||
#[derive(PartialEq, Eq, PartialOrd, Ord, Debug)]
|
||||
pub enum LogLevel {
|
||||
Disabled,
|
||||
Critical,
|
||||
Error,
|
||||
Warning,
|
||||
Info,
|
||||
Trace,
|
||||
Disabled = 0,
|
||||
Critical = 1,
|
||||
Error = 2,
|
||||
Warning = 3,
|
||||
Info = 4,
|
||||
Trace = 5,
|
||||
}
|
||||
|
||||
impl TryFrom<u8> for LogLevel {
|
||||
|
@ -21,7 +21,7 @@ use spin::mutex::Mutex;
|
||||
|
||||
use crate::boot::*;
|
||||
use crate::log::*;
|
||||
use crate::memory::alloc::{format, string::*, vec, boxed};
|
||||
use crate::memory::alloc::{boxed, format, string::*, vec};
|
||||
use crate::params::*;
|
||||
|
||||
#[unsafe(no_mangle)]
|
||||
@ -56,7 +56,10 @@ unsafe extern "C" fn main() -> ! {
|
||||
// Append display console to log subs
|
||||
}
|
||||
if log_device_list.contains(&"serial") {
|
||||
LOGGER.lock().subscriber.push(Mutex::new(boxed::Box::new(qemu_serial)));
|
||||
LOGGER
|
||||
.lock()
|
||||
.subscriber
|
||||
.push(Mutex::new(boxed::Box::new(qemu_serial)));
|
||||
}
|
||||
log(LogLevel::Info, "Boot: Configured kernel logging devices.")
|
||||
}
|
||||
@ -77,26 +80,31 @@ unsafe extern "C" fn main() -> ! {
|
||||
),
|
||||
);
|
||||
}
|
||||
if let Some(address_response) = ADDRESS_REQUEST.get_response() {
|
||||
log(
|
||||
LogLevel::Trace,
|
||||
&format!(
|
||||
"Boot: Kernel address: 0x{:0x}",
|
||||
address_response.physical_base()
|
||||
),
|
||||
)
|
||||
}
|
||||
if let Some(module_response) = MODULE_REQUEST.get_response() {
|
||||
log(
|
||||
LogLevel::Info,
|
||||
&format!(
|
||||
"Boot: Kernel modules count: {}",
|
||||
module_response.modules().len()
|
||||
)
|
||||
),
|
||||
);
|
||||
log(
|
||||
LogLevel::Info,
|
||||
"Boot: Kernel modules list:"
|
||||
);
|
||||
for module in module_response.modules() {
|
||||
log(
|
||||
LogLevel::Info,
|
||||
&format!(
|
||||
"\t{}",
|
||||
String::from_utf8_lossy(module.path().to_bytes())
|
||||
if !module_response.modules().is_empty() {
|
||||
log(LogLevel::Info, "Boot: Kernel modules list:");
|
||||
for module in module_response.modules() {
|
||||
log(
|
||||
LogLevel::Info,
|
||||
&format!("\t{}", String::from_utf8_lossy(module.path().to_bytes())),
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
log(
|
||||
@ -105,6 +113,18 @@ unsafe extern "C" fn main() -> ! {
|
||||
);
|
||||
log(LogLevel::Info, "Boot: Trans Rights!");
|
||||
|
||||
if let Some(framebuffer_response) = FRAMEBUFFER_REQUEST.get_response() {
|
||||
let fb = framebuffer_response.framebuffers().next().unwrap();
|
||||
log(
|
||||
LogLevel::Info,
|
||||
"Boot: Framebuffer response received. Display enabled."
|
||||
);
|
||||
log(
|
||||
LogLevel::Trace,
|
||||
&format!("Boot: Framebuffer dimensions: {}x{}, {}", fb.width(), fb.height(), fb.bpp())
|
||||
);
|
||||
}
|
||||
|
||||
let _smp_response = MP_REQUEST.get_response();
|
||||
match _smp_response {
|
||||
None => log(
|
||||
@ -126,8 +146,14 @@ unsafe extern "C" fn main() -> ! {
|
||||
let _rsdp_response = RSDP_REQUEST.get_response();
|
||||
|
||||
loop {
|
||||
unsafe {
|
||||
arch::current::asm::halt();
|
||||
for _i in 0..100000000 {
|
||||
unsafe {
|
||||
core::arch::asm!("nop");
|
||||
}
|
||||
}
|
||||
log(
|
||||
LogLevel::Trace,
|
||||
"Heartbeat"
|
||||
)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user