Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
24d5e34
Implement PMM, paging manager and VMM (wip)
krustowski Aug 20, 2025
622da45
Disable a portion of paging setup in asm
krustowski Aug 20, 2025
9e5bbf6
Adjust the init procedures to new memory mgmt (wip)
krustowski Aug 20, 2025
4379d6c
Use CR3 physical address directly
krustowski Aug 20, 2025
e944131
Tidy up a bit
krustowski Aug 20, 2025
2c496db
Refactor framebuf mapping
krustowski Aug 20, 2025
6536add
Add the page walker implementation(s), minor refactor
krustowski Aug 20, 2025
3d4813a
Add new hidden kernel shell cmd to walk mem pages
krustowski Aug 20, 2025
55e9258
Clean the assembly stub
krustowski Aug 21, 2025
cc2750a
start of multiboot parsing improvement DOESNT COMPILE BTW!
mikikichi Aug 22, 2025
1b23093
Fix syntax
krustowski Aug 22, 2025
45dd6f7
Start of multiboot parsing
mikikichi Aug 23, 2025
9e97e4c
wip parser
mikikichi Aug 25, 2025
c94245d
Merge branch 'master' into mikilabs
krustowski Aug 25, 2025
c053810
Fix errors
krustowski Aug 25, 2025
4567cdc
wip small changes
mikikichi Aug 26, 2025
a657685
stash of wip code
mikikichi Aug 31, 2025
702cc33
Merge branch 'master' into mikilabs
mikikichi Aug 31, 2025
4796102
merged with main
mikikichi Aug 31, 2025
0181fe8
huge init system refactor wip
mikikichi Sep 1, 2025
81ae488
wip print refactor and init refactor
mikikichi Sep 3, 2025
d01cd87
wip, printing result macro works
mikikichi Sep 10, 2025
03ebb6a
almost done wip
mikikichi Sep 13, 2025
583ffa2
result macro functional
mikikichi Sep 17, 2025
0d18ac9
wip
mikikichi Oct 2, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ compile_kernel:
@cp target/kernel_graphics/x86_64-r2/release/kernel.elf iso/boot/kernel_graphics.elf

build_iso:
@grub-mkrescue \
@grub2-mkrescue \
-o r2.iso iso/ \
--modules="multiboot2 video video_bochs video_cirrus gfxterm all_video"

Expand All @@ -46,12 +46,6 @@ build_floppy:
fat.img
@echo "Hello from floppy!" > /tmp/hello.txt
@mcopy -i fat.img /tmp/hello.txt ::HELLO.TXT
@mcopy -i fat.img ./print.bin ::PRINT.BIN
@mcopy -i fat.img ./print.elf ::PRINT.ELF
@mcopy -i fat.img ./go.elf ::GO.ELF
@mcopy -i fat.img ./sh.elf ::SH.ELF
@mcopy -i fat.img ./icmpresp.elf ::ICMPRESP.ELF
@mcopy -i fat.img ./garn.elf ::GARN.ELF

#
# RUN
Expand Down
154 changes: 3 additions & 151 deletions iso/boot/boot.asm
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,6 @@ align 4096
;dma:
; resb 4096

pml4_table:
resq 512
pdpt_table:
resq 512
pd_table:
resq 512
pt_table:
resq 512

p4_table:
resb 4096
p3_table:
Expand Down Expand Up @@ -91,11 +82,6 @@ global p4_table
global p3_table
global p2_table

global p3_fb_table
global p2_fb_table
global p1_fb_table
global p1_fb_table_2

global gdt_start
global gdt_end
global gdt_descriptor
Expand Down Expand Up @@ -216,29 +202,12 @@ idt_start:
times 256 dq 0
idt_end:

;
;
;

section .data

FB_P1_TABLES:
dq p1_fb_table_0
dq p1_fb_table_1
dq p1_fb_table_2
dq p1_fb_table_3

;
; Page Tables Zeroing & Mapping
;

section .text

%define FB_PHYS 0xFD000000
%define FB_VIRT 0xFFFFFF8000000000
%define PAGE_COUNT 4096
%define PAGE_FLAGS 0b11

zero_table:
mov ecx, 512
xor eax, eax
Expand All @@ -257,9 +226,6 @@ set_up_page_tables:
lea edi, [p3_table]
call zero_table

lea edi, [p3_fb_table]
call zero_table

lea edi, [p2_table]
call zero_table

Expand Down Expand Up @@ -324,8 +290,11 @@ set_up_page_tables:

inc ecx
cmp ecx, 4
cmp ecx, 1
jne .map_1gib

ret

; Allow CPL=3 access at 0x600_000--0x800_000

mov eax, 0x600000
Expand All @@ -340,123 +309,6 @@ set_up_page_tables:

ret

; Identity-map

; mov eax, p1_page_tables
; or eax, PAGE_FLAGS
; mov [p2_table + 1 * 8], eax
; mov dword [p2_table + 1 * 8 + 4], 0

; mov eax, p1_page_tables_2
; or eax, PAGE_FLAGS
; mov [p2_table + 2 * 8], eax
; mov dword [p2_table + 2 * 8 + 4], 0

; xor ecx, 0
;.map_self:
; mov eax, 0x131000
; add eax, ecx
; or eax, PAGE_FLAGS
; mov edi, p1_page_tables
; mov ebx, ecx
; shr ebx, 12
; shl ebx, 3
; add edi, ebx

; mov [edi], eax
; mov dword [edi + 4], 0

; add ecx, 0x1000
; cmp ecx, 0x80000
; jb .map_self

;.map_self_2:
; mov eax, 0x13e000
; add eax, ecx
; or eax, PAGE_FLAGS
; mov edi, p1_page_tables_2
; mov ebx, ecx
; shr ebx, 12
; shl ebx, 3
; add edi, ebx

; mov [edi], eax
; mov dword [edi + 4], 0

; add ecx, 0x1000
; cmp ecx, 0x40000
; jb .map_self_2

; Framebuffer init

mov eax, p3_fb_table
or eax, PAGE_FLAGS
mov [p4_table + 511 * 8], eax
mov dword [p4_table + 511 * 8 + 4], 0

mov eax, p2_fb_table
or eax, PAGE_FLAGS
mov [p3_fb_table + 0 * 8], eax
mov dword [p3_fb_table + 0 * 8 + 4], 0

mov eax, p1_fb_table_0
or eax, PAGE_FLAGS
mov [p2_fb_table + 0 * 8], eax
mov dword [p2_fb_table + 0 * 8 + 4], 0

mov eax, p1_fb_table_1
or eax, PAGE_FLAGS
mov [p2_fb_table + 1 * 8], eax
mov dword [p2_fb_table + 1 * 8 + 4], 0

mov eax, p1_fb_table_2
or eax, PAGE_FLAGS
mov [p2_fb_table + 2 * 8], eax
mov dword [p2_fb_table + 2 * 8 + 4], 0

mov eax, p1_fb_table_3
or eax, PAGE_FLAGS
mov [p2_fb_table + 3 * 8], eax
mov dword [p2_fb_table + 3 * 8 + 4], 0

; Framebuffer P1 pages

xor ecx, ecx
xor esi, esi
.map_fb_dynamic:
mov eax, FB_PHYS
add eax, ecx
or eax, PAGE_FLAGS

mov ebx, esi
shl ebx, 3
mov edi, [FB_P1_TABLES + ebx]

mov ebx, ecx
shr ebx, 12
and ebx, 511
shl ebx, 3

add edi, ebx
mov [edi], eax
mov dword [edi + 4], 0

add ecx, 0x1000
cmp ecx, PAGE_COUNT * 0x1000
jae .done_fb_map

; Switch to next p1 table every 512 pages
mov ebx, ecx
shr ebx, 12
and ebx, 511
cmp ebx, 0
jne .map_fb_dynamic
inc esi
cmp esi, (PAGE_COUNT + 511) / 512
jae .done_fb_map
jmp .map_fb_dynamic

.done_fb_map:
ret

enable_paging:
Expand Down
5 changes: 5 additions & 0 deletions iso/boot/grub/grub.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ menuentry "rou2exOS Rusted Edition (text mode)" {
boot
}

menuentry "rou2exOS Rusted Edition (text debug mode)" {
multiboot2 /boot/kernel_text.elf debug
boot
}

menuentry "rou2exOS Rusted Edition (graphics)" {
multiboot2 /boot/kernel_graphics.elf grafix
boot
Expand Down
4 changes: 4 additions & 0 deletions linker.ld
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ SECTIONS {
KEEP(*(.multiboot2_header))
}

__kernel_start = .;

.text : {
*(.text.entry)
*(.text*)
Expand Down Expand Up @@ -63,6 +65,8 @@ SECTIONS {
p1_fb_table_2 = .; . = . + 4K;
p1_fb_table_3 = .; . = . + 4K;

__kernel_end = .;

. = 0x650000;
.user_task : {
*(.user_task*)
Expand Down
4 changes: 2 additions & 2 deletions src/debug.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use core::fmt::{self, Write};
use spin::Mutex;
use crate::{clear_screen, error, printb};
use crate::{clear_screen, error, printb, println};

const DEBUG_LOG_SIZE: usize = 8192;

Expand Down Expand Up @@ -74,7 +74,7 @@ macro_rules! debugn {
let mut buf = [0u8; 20];
let s = $crate::debug::u64_to_dec_str($n as u64, &mut buf);
log.append(s);
}
}
}};
}

Expand Down
Loading