Undid that

This commit is contained in:
2024-01-02 16:41:22 +01:00
parent 726247a4f2
commit da52676e78
14 changed files with 10 additions and 213 deletions
-98
View File
@@ -1,98 +0,0 @@
[org 0x7c00]
[bits 16]
[global start]
start:
; Setup
xor ax, ax
mov es, ax
mov ds, ax
mov bp, 0x7c00
mov sp, bp
; Save drive number
mov byte [driveNumber], dl
; Print boot message
mov si, bootMsg
call print
mov dl, byte [driveNumber]
call printHex
mov si, newline
call print
; Read filetable from disk
mov bx, FILETAB_LOC ; Filetable location in memory
mov es, bx
xor bx, bx
mov ah, 2 ; Read from disk
mov al, 1 ; Read 1 sector (512B)
mov dl, byte [driveNumber] ; Drive number
mov ch, 0 ; Cylinder
mov dh, 0 ; Head
mov cl, 2 ; Sector
int 0x13 ; INT 0x13 - Disk operations
jc readFail ; CF will be set if the read fails
; Read filetable from disk
mov bx, KERNEL_LOC ; Filetable location in memory
mov es, bx
xor bx, bx
mov ah, 2 ; Read from disk
mov al, 4 ; Read 4 sectors (2kB)
mov dl, byte [driveNumber] ; Drive number
mov ch, 0 ; Cylinder
mov dh, 0 ; Head
mov cl, 3 ; Sector
int 0x13 ; INT 0x13 - Disk operations
jc readFail ; CF will be set if the read fails
; Setup segmentation
mov ax, KERNEL_LOC
mov ds, ax
mov es, ax
mov fs, ax
mov gs, ax
; Setup stack
mov bp, 0xffff
mov sp, bp
mov ax, 0x9000
mov ss, ax
mov bl, byte [driveNumber]
; Setup video mode
mov ax, 0x0003
int 0x10
mov ah, 0x0b
mov bx, 0x0001
int 0x10
; Far jump to the kernel (never returns)
jmp KERNEL_LOC:0x0000
readFail:
mov si, diskErrorMsg
call print
cli
hlt
%include "./src/lib/print.asm"
driveNumber: db 0
bootMsg: db ENDL, "Booting kern.", ENDL, "Booting from drive ", 0
diskErrorMsg: db "Disk Error!", ENDL, 0
FILETAB_LOC equ 0x1000
KERNEL_LOC equ 0x2000
times 510-($-$$) db 0
dw 0xaa55
-22
View File
@@ -1,22 +0,0 @@
; ------------------
; Simple Filetable
; ------------------
;
; 16 Byte entries
; 0-9 - Filename
; 10-12 - File extension (type)
; 13 - Number of filetable entries
; 14 - Starting Sector
; 15 - Filesize in sectors (n * 512)
;
; ------------------
filetable:
; db 'all',0,0,0,0,0,0,0,'txt',0,1,7 ; all - start: 1, size: 7
db 'boot',0,0,0,0,0,0, 'bin',0,1,1 ; boot.bin - start: 1, size: 1
db 'filetable',0, 'txt',0,2,1 ; filetable.txt - start: 2, size: 1
db 'kernel',0,0,0,0, 'bin',0,3,4 ; kernel.bin - start: 3, size: 4
db 'calc',0,0,0,0,0,0, 'bin',0,7,1 ; calc.bin - start: 7, size: 1
db 'edit',0,0,0,0,0,0, 'bin',0,8,4 ; edit.bin - start: 8, size: 2
times 512-($-$$) db 0
+7 -7
View File
@@ -1,8 +1,8 @@
#!/bin/bash
# Create ./build dir if it doesn't exist
if !(test -d ././build); then
mkdir ././build
if !(test -d ./build); then
mkdir ./build
echo "Created ./build/ directory!"
fi
@@ -11,16 +11,16 @@ nasm -fbin src/boot.asm -o ./build/boot.bin
nasm -fbin src/filetable.asm -o ./build/filetable.bin
# Kernel
# nasm -fbin src/kernel.asm -o ./build/kernel.bin
nasm -fbin src/kernel.asm -o ./build/kernel.bin
# Programs
# nasm -fbin src/fs/calc.asm -o ./build/calc.bin
# nasm -fbin src/fs/edit.asm -o ./build/edit.bin
nasm -fbin src/fs/calc.asm -o ./build/calc.bin
nasm -fbin src/fs/edit.asm -o ./build/edit.bin
# cat ./build/calc.bin ./build/edit.bin > ./build/files.bin
cat ./build/calc.bin ./build/edit.bin > ./build/files.bin
# Final binary
cat ./build/boot.bin ./build/filetable.bin > ./build/temp.bin
cat ./build/boot.bin ./build/filetable.bin ./build/kernel.bin ./build/files.bin > ./build/temp.bin
dd if=/dev/zero of=./build/kern.iso bs=512 count=2880
dd if=./build/temp.bin of=./build/kern.iso conv=notrunc
rm -rf ./build/**.bin
-32
View File
@@ -1,32 +0,0 @@
#!/bin/bash
# Create ./build dir if it doesn't exist
if !(test -d ././build); then
mkdir ././build
echo "Created ./build/ directory!"
fi
# Bootloader
nasm -fbin src/boot.asm -o ./build/boot.bin
nasm -fbin src/filetable.asm -o ./build/filetable.bin
# Kernel
nasm -fbin src/kernel.asm -o ./build/kernel.bin
# Programs
nasm -fbin src/fs/calc.asm -o ./build/calc.bin
nasm -fbin src/fs/edit.asm -o ./build/edit.bin
cat ./build/calc.bin ./build/edit.bin > ./build/files.bin
# Final binary
cat ./build/boot.bin ./build/filetable.bin ./build/kernel.bin ./build/files.bin > ./build/temp.bin
dd if=/dev/zero of=./build/kern.iso bs=512 count=2880
dd if=./build/temp.bin of=./build/kern.iso conv=notrunc
rm -rf ./build/**.bin
echo "Built kern.iso!"
# Run QEMU
echo "Running QEMU..."
qemu-system-x86_64 -drive format=raw,file="./build/kern.iso",index=0,media=disk -m 256M
-1
View File
@@ -1 +0,0 @@
rm -rf build/*
+3 -53
View File
@@ -2,8 +2,6 @@
[bits 16]
[global start]
%define ENDL 0x0A, 0x0D
start:
; Setup
xor ax, ax
@@ -19,7 +17,7 @@ start:
mov si, bootMsg
call print
mov dl, byte [driveNumber]
call printHexByte
call printHex
mov si, newline
call print
@@ -86,61 +84,13 @@ readFail:
cli
hlt
;
; Prints a string
; si - Pointer to NULL terminated string
;
print:
pusha
mov ah, 0x0e
mov bl, 0x1f
mov bh, 0
.loop:
lodsb ; Load [si] into al; Increment si
or al, al
jz .done
int 0x10
jmp .loop
.done:
popa
ret
;
; Prints a hex byte
; dl - Hex byte
;
printHexByte:
pusha
xor cx, cx
mov bh, 0
mov bl, 0x1f ; White on blue
.loop:
mov al, dl
and al, 0xF0
ror al, 4
add al, '0'
cmp al, '9'
jle .hexNum
add al, 7
.hexNum:
mov ah, 0x0e
int 0x10
inc cx
cmp cx, 2
je .done
ror dl, 4
jmp .loop
.done:
popa
ret
%include "./src/lib/print.asm"
driveNumber: db 0
bootMsg: db ENDL, "Booting kern.", ENDL, "Booting from drive 0x", 0
bootMsg: db ENDL, "Booting kern.", ENDL, "Booting from drive ", 0
diskErrorMsg: db "Disk Error!", ENDL, 0
newline: db ENDL
FILETAB_LOC equ 0x1000
KERNEL_LOC equ 0x2000