println works

This commit is contained in:
2025-02-20 22:59:24 +00:00
parent ee8de361dc
commit 34b960c20a
18 changed files with 816 additions and 44 deletions
+32 -26
View File
@@ -3,10 +3,13 @@
use core::arch::asm;
use limine::request::{FramebufferRequest, RequestsEndMarker, RequestsStartMarker};
use lib_serial::{serial_println, serial_read};
use lib_ascii::{println, WRITER};
use limine::request::{RequestsEndMarker, RequestsStartMarker};
use limine::BaseRevision;
use lib_example;
use lib_framebuffer;
/// Sets the base revision to the latest revision supported by the crate.
/// See specification for further info.
@@ -16,10 +19,6 @@ use lib_example;
#[link_section = ".requests"]
static BASE_REVISION: BaseRevision = BaseRevision::new();
#[used]
#[link_section = ".requests"]
static FRAMEBUFFER_REQUEST: FramebufferRequest = FramebufferRequest::new();
/// Define the stand and end markers for Limine requests.
#[used]
#[link_section = ".requests_start_marker"]
@@ -28,41 +27,48 @@ static _START_MARKER: RequestsStartMarker = RequestsStartMarker::new();
#[link_section = ".requests_end_marker"]
static _END_MARKER: RequestsEndMarker = RequestsEndMarker::new();
extern "C" {
pub fn add(x: i32, y: i32) -> i32;
}
#[no_mangle]
unsafe extern "C" fn kmain() -> ! {
// All limine requests must also be referenced in a called function, otherwise they may be
// removed by the linker.
assert!(BASE_REVISION.is_supported());
lib_example::add_nums(1, 2);
add(1, 2);
if let Some(framebuffer_response) = FRAMEBUFFER_REQUEST.get_response() {
if let Some(framebuffer) = framebuffer_response.framebuffers().next() {
for i in 0..100_u64 {
// Calculate the pixel offset using the framebuffer information we obtained above.
// We skip `i` scanlines (pitch is provided in bytes) and add `i * 4` to skip `i` pixels forward.
let pixel_offset = i * framebuffer.pitch() + i * 4;
// Write 0xFFFFFFFF to the provided pixel offset to fill it white.
*(framebuffer.addr().add(pixel_offset as usize) as *mut u32) = 0xFFFFFFFF;
}
}
if let Err(_) = lib_serial::init() {
loop {}
}
let dimensions = lib_ascii::screensize_chars();
let dimensions2 = lib_framebuffer::screensize_px();
println!("Hello World!");
println!("Dimensions: {}x{} (px)", dimensions2.0, dimensions2.1);
println!("Dimensions: {}x{} (chars)", dimensions.0, dimensions.1);
println!("
$$$$$$$$\\ $$\\
$$ _____| $$ |
$$ | $$$$$$\\ $$\\ $$\\ $$$$$$$\\ $$$$$$$ | $$$$$$\\ $$\\ $$\\
$$$$$\\ $$ __$$\\ $$ | $$ |$$ __$$\\ $$ __$$ |$$ __$$\\ $$ | $$ |
$$ __|$$ / $$ |$$ | $$ |$$ | $$ |$$ / $$ |$$ | \\__|$$ | $$ |
$$ | $$ | $$ |$$ | $$ |$$ | $$ |$$ | $$ |$$ | $$ | $$ |
$$ | \\$$$$$$ |\\$$$$$$ |$$ | $$ |\\$$$$$$$ |$$ | \\$$$$$$$ |
\\__| \\______/ \\______/ \\__| \\__| \\_______|\\__| \\____$$ |
$$$$$$\\ $$$$$$\\ $$\\ $$\\ $$\\ $$\\ $$ |
$$ __$$\\ $$ __$$\\ $$ | $$ |$$$$ | \\$$$$$$ |
$$ / $$ |$$ / \\__| $$ | $$ |\\_$$ | \\______/
$$ | $$ |\\$$$$$$\\ \\$$\\ $$ | $$ |
$$ | $$ | \\____$$\\ \\$$\\$$ / $$ |
$$ | $$ |$$\\ $$ | \\$$$ / $$ |
$$$$$$ |\\$$$$$$ | \\$ / $$$$$$\\
\\______/ \\______/ \\_/ \\______|
");
hcf();
}
#[panic_handler]
fn rust_panic(_info: &core::panic::PanicInfo) -> ! {
hcf();
// loop {}
}
fn hcf() -> ! {