Make a new layout for the OS, rebrand to XunilOS

This commit is contained in:
csd4ni3l
2026-03-14 11:33:01 +01:00
parent eeb1c6c701
commit 8308a7ae32
20 changed files with 67 additions and 62 deletions

View File

@@ -11,7 +11,7 @@ $(call USER_VARIABLE,KARCH,x86_64)
# Default user QEMU flags. These are appended to the QEMU command calls.
$(call USER_VARIABLE,QEMUFLAGS,-m 2G)
override IMAGE_NAME := NeumannOS-$(KARCH)
override IMAGE_NAME := XunilOS-$(KARCH)
.PHONY: all
all: $(IMAGE_NAME).iso

View File

@@ -1,5 +1,5 @@
# NeumannOS
NeumannOS is an OS written from scratch, named after the famous mathematician, physicist, computer scientist and engineer Neumann János Lajos.
# XunilOS
XunilOS is an OS made from scratch in Rust.
The repo is based on the limine-rust-template.

View File

View File

View File

View File

View File

View File

View File

@@ -0,0 +1,53 @@
use limine::framebuffer::Framebuffer as LimineFramebuffer;
const MAX_BACKBUFFER_PIXELS: usize = 1920 * 1080;
static mut BACK_BUFFER: [u32; MAX_BACKBUFFER_PIXELS] = [0; MAX_BACKBUFFER_PIXELS];
pub struct Framebuffer {
addr: *mut u32,
back_buffer: *mut u32,
width: usize,
height: usize,
pitch: usize,
back_buffer_len: usize,
}
impl Framebuffer {
pub fn new(limine_fb: &LimineFramebuffer) -> Framebuffer {
let width = limine_fb.width() as usize;
let height = limine_fb.height() as usize;
let pitch = limine_fb.pitch() as usize / 4;
let needed = pitch.saturating_mul(height);
let back_buffer_len = core::cmp::min(needed, MAX_BACKBUFFER_PIXELS);
Framebuffer {
addr: limine_fb.addr().cast::<u32>(),
back_buffer: core::ptr::addr_of_mut!(BACK_BUFFER).cast::<u32>(),
width,
height,
pitch,
back_buffer_len,
}
}
pub fn put_pixel(&mut self, x: usize, y: usize, color: u32) {
if x >= self.width || y >= self.height {
return;
}
let idx = y.saturating_mul(self.pitch).saturating_add(x);
if idx >= self.back_buffer_len {
return;
}
unsafe {
*self.back_buffer.add(idx) = color;
}
}
pub fn swap(&mut self) {
unsafe {
core::ptr::copy_nonoverlapping(self.back_buffer, self.addr, self.back_buffer_len);
}
}
}

View File

@@ -1,63 +1,12 @@
use limine::framebuffer::Framebuffer as LimineFramebuffer;
use crate::utils::math::PI;
use micromath::F32Ext;
use crate::driver::framebuffer::Framebuffer;
const MAX_BACKBUFFER_PIXELS: usize = 1920 * 1080;
static mut BACK_BUFFER: [u32; MAX_BACKBUFFER_PIXELS] = [0; MAX_BACKBUFFER_PIXELS];
const PI: f32 = 3.1415926535897;
pub fn rgb(r: u8, g: u8, b: u8) -> u32 {
((r as u32) << 16) | ((g as u32) << 8) | (b as u32)
}
pub struct Framebuffer {
addr: *mut u32,
back_buffer: *mut u32,
width: usize,
height: usize,
pitch: usize,
back_buffer_len: usize,
}
impl Framebuffer {
pub fn new(limine_fb: &LimineFramebuffer) -> Framebuffer {
let width = limine_fb.width() as usize;
let height = limine_fb.height() as usize;
let pitch = limine_fb.pitch() as usize / 4;
let needed = pitch.saturating_mul(height);
let back_buffer_len = core::cmp::min(needed, MAX_BACKBUFFER_PIXELS);
Framebuffer {
addr: limine_fb.addr().cast::<u32>(),
back_buffer: core::ptr::addr_of_mut!(BACK_BUFFER).cast::<u32>(),
width,
height,
pitch,
back_buffer_len,
}
}
pub fn put_pixel(&mut self, x: usize, y: usize, color: u32) {
if x >= self.width || y >= self.height {
return;
}
let idx = y.saturating_mul(self.pitch).saturating_add(x);
if idx >= self.back_buffer_len {
return;
}
unsafe {
*self.back_buffer.add(idx) = color;
}
}
pub fn swap(&mut self) {
unsafe {
core::ptr::copy_nonoverlapping(self.back_buffer, self.addr, self.back_buffer_len);
}
}
}
pub fn line(framebuffer: &mut Framebuffer, mut x0: i64, mut y0: i64, x1: i64, y1: i64, color: u32) {
let mut dx = x1 - x0;
let mut dy = y1 - y0;

View File

5
kernel/src/driver/mod.rs Normal file
View File

@@ -0,0 +1,5 @@
pub mod framebuffer;
pub mod graphics;
pub mod font_render;
pub mod keyboard;
pub mod timer;

View File

View File

@@ -6,9 +6,10 @@ use core::arch::asm;
use limine::BaseRevision;
use limine::request::{FramebufferRequest, RequestsEndMarker, RequestsStartMarker};
pub mod utils;
pub mod driver;
use crate::utils::graphics::{Framebuffer, circle_filled, circle_outline, rectangle_filled, rectangle_outline, rgb, triangle_outline};
use crate::driver::graphics::{circle_filled, circle_outline, rectangle_filled, rectangle_outline, rgb, triangle_outline};
use crate::driver::framebuffer::Framebuffer;
/// Sets the base revision to the latest revision supported by the crate.
/// See specification for further info.

View File

0
kernel/src/mm/heap.rs Normal file
View File

0
kernel/src/panic.rs Normal file
View File

View File

@@ -1 +0,0 @@
pub const PI: f32 = 3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679; // we are just a bit accurate (the library definitely needs this btw)

View File

@@ -1,2 +0,0 @@
pub mod math;
pub mod graphics;

View File

@@ -2,7 +2,7 @@
timeout: 3
# The entry name that will be displayed in the boot menu.
/Limine NeumannOS
/Limine XunilOS
# We use the Limine boot protocol.
protocol: limine