aboutsummaryrefslogtreecommitdiff
path: root/.old
diff options
context:
space:
mode:
authorczjstmax <jstmaxlol@disroot.org>2026-02-23 23:18:48 +0100
committerczjstmax <jstmaxlol@disroot.org>2026-02-23 23:18:48 +0100
commit2420e3f52b62580af9cdd661fb441733e437daf9 (patch)
treea2854d70e7297e9bff879c5dc358dfb95d263fab /.old
parent6fc0fd2fd64388e32c4ec1cefa2ad8e1e43fdb5a (diff)
lots of changes. restructured repository. switched to limine.
Signed-off-by: czjstmax <jstmaxlol@disroot.org>
Diffstat (limited to '.old')
-rw-r--r--.old/Makefile17
-rw-r--r--.old/boot.asm134
-rw-r--r--.old/boot_s2.asm23
3 files changed, 174 insertions, 0 deletions
diff --git a/.old/Makefile b/.old/Makefile
new file mode 100644
index 0000000..9e63e3f
--- /dev/null
+++ b/.old/Makefile
@@ -0,0 +1,17 @@
+all:
+ # assemble bootloader
+ nasm -f bin src/boot.asm -o build/boot.bin
+ nasm -f elf32 src/boot_s2.asm -o build/boot_s2.o
+ # compile kernel
+ gcc -m32 -ffreestanding -nostdlib -c src/krn/mkern.c -o build/mkernel.o
+ # link
+ ld -m elf_i386 -T src/linker.ld -nostdlib -o build/s2.elf build/boot_s2.o build/mkernel.o
+ objcopy -O binary build/s2.elf build/s2.bin
+ # make .img
+ cat build/boot.bin build/s2.bin > build/mullos.img
+ # qemu test
+ qemu-system-x86_64 -drive format=raw,file=build/mullos.img
+
+clean:
+ rm -vf build/*
+
diff --git a/.old/boot.asm b/.old/boot.asm
new file mode 100644
index 0000000..011c00f
--- /dev/null
+++ b/.old/boot.asm
@@ -0,0 +1,134 @@
+; boot.asm - stage 1
+
+[bits 16]
+[org 0x7C00]
+
+start:
+ xor ax, ax
+ mov ds, ax
+ mov es, ax
+ mov ss, ax
+
+ ; clear screen by big scrollup
+ mov ah, 0x06 ; scrollup function
+ mov al, 0 ; al contains the n of lines to scroll (0 is clearall)
+ mov bh, 0x07 ; 'attribute byte' 0x07 is white on black
+ mov cx, 0x0000 ; upper-left corner
+ mov dx, 0x184F ; bottom-right corner
+
+ int 0x10 ; call
+ ; set cursor position back to default
+ mov ah, 0x02 ; set cur pos function
+ ; position parameters:
+ mov bh, 0x00 ; page number (0)
+ mov dh, 0x00 ; row
+ mov dl, 0x00 ; col
+
+ int 0x10 ; call
+
+ mov si, msg1 ; print msg1
+ call print_string
+
+ mov ah, 0x02 ; set cur pos function
+ ; position parameters:
+ mov bh, 0x00 ; page number (0)
+ mov dh, 0x01 ; row
+ mov dl, 0x00 ; col
+
+ int 0x10 ; call
+
+ mov si, msg2 ; print msg2
+ call print_string
+
+ mov ah, 0x02 ; set cur pos function
+ ; position parameters:
+ mov bh, 0x00 ; page number (0)
+ mov dh, 0x02 ; row
+ mov dl, 0x00 ; col
+
+ int 0x10 ; call
+
+ mov si, msg3
+ call print_string
+
+ mov ah, 0x02 ; set cur pos function
+ ; position parameters:
+ mov bh, 0x00 ; page number (0)
+ mov dh, 0x03 ; row
+ mov dl, 0x00 ; col
+
+ int 0x10 ; call
+
+load_stage2:
+ mov ax, 0x0000
+ mov es, ax
+ mov bx, 0x1000
+ ; load stage2 from disk - first sector at 0x1000
+ mov bx, 0x1000 ; load address
+ mov dh, 0
+ mov ch, 0
+ mov cl, 2 ; sector 2
+ mov al, 20 ; sectors to read
+ mov ah, 0x02
+
+ int 0x13
+ jc halt
+
+ ; GDT for protected mode
+gdt_start:
+ dq 0
+ dq 0x00CF9A000000FFFF ; code
+ dq 0x00CF92000000FFFF ; data
+ gdt_end:
+
+gdt_descriptor:
+ dw gdt_end - gdt_start -1
+ dd gdt_start
+
+ ; enable protected mode cleanly and transfer to 32-bit stub
+ cli
+ lgdt [gdt_descriptor]
+
+ mov eax, cr0
+ or eax, 1
+ mov cr0, eax
+
+ ; far jump reloads CS with selector 0x08 and enters protected mode
+ jmp 0x08:pm_entry
+
+ ; 32-bit entry point
+ [bits 32]
+pm_entry:
+ ; reload data segment registers with data selector (0x10)
+ mov ax, 0x10
+ mov ds, ax
+ mov es, ax
+ mov fs, ax
+ mov gs, ax
+ mov ss, ax
+
+ mov esp, 0x90000 ; setup stack
+
+ mov eax, 0x1000 ; jump to linear address 0x1000 (which wloud be where s2.bin was loaded)
+ jmp eax
+
+halt:
+ hlt
+ jmp halt
+
+print_string:
+ lodsb
+ cmp al, 0
+ je .done
+ mov ah, 0x0E
+ int 0x10
+ jmp print_string
+.done:
+ ret
+
+msg1 db `mull_bootloader hath bespoken unto thee:\n`, 0
+msg2 db `\"behold, \'O user! mull_kernel doth now commence its solemn journey!\"\n`, 0
+msg3 db `trying to kernel kernel :3`, 0
+
+times 510-($-$$) db 0
+dw 0xAA55
diff --git a/.old/boot_s2.asm b/.old/boot_s2.asm
new file mode 100644
index 0000000..b974827
--- /dev/null
+++ b/.old/boot_s2.asm
@@ -0,0 +1,23 @@
+; boot_stage2.asm - stage2
+[bits 32]
+
+global _start
+extern kmain
+
+section .text
+
+_start:
+ ; reload segments
+ mov ax, 0x10
+ mov ds, ax
+ mov es, ax
+ mov ss, ax
+ mov fs, ax
+ mov gs, ax
+ mov esp, 0x90000 ; stack
+
+ mov dword [0xB8000], 0x07410741
+ call kmain
+
+ hlt
+