Undo test
This commit is contained in:
parent
e3d7b77544
commit
eac19a8ac7
BIN
bin/disk.img
BIN
bin/disk.img
Binary file not shown.
BIN
bin/mbr.bin
BIN
bin/mbr.bin
Binary file not shown.
BIN
obj/boot/mbr.bin
BIN
obj/boot/mbr.bin
Binary file not shown.
|
@ -415,5 +415,5 @@ ErrorNo64:
|
|||
Die:
|
||||
cli
|
||||
hlt ; die nooooow
|
||||
retf ; For conveniance '-'
|
||||
retf
|
||||
KERNEL:
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
%define BUFFER_OFF 0x0000
|
||||
|
||||
;; SECOND STAGE LOADER "SEGMENT"
|
||||
%define LOAD_SEG 0x0000 ; (LOAD_SEG << 4) + LOAD_OFF = 0x030000
|
||||
%define LOAD_SEG 0x0000 ; (LOAD_SEG << 4) + LOAD_OFF = 0x001000
|
||||
%define LOAD_OFF 0x1000
|
||||
|
||||
[BITS 16] ; Ensure 16-bit code (because fuck UEFI)
|
||||
|
@ -60,6 +60,18 @@ _start:
|
|||
jmp BOOT_SEG:$+5 ; Fix the cs:ip registers with a vaudou magical trip
|
||||
|
||||
bootstrap:
|
||||
jmp bootstrapper
|
||||
|
||||
;; LOVELY DATA
|
||||
FileNotFound db "FStage ERR : NO LOADER", 0 ; File was not found
|
||||
DiskError db "FStage ERR : DISK", 0 ; Error while reading from the disk
|
||||
UserData dw 0 ; Start of the data sectors
|
||||
Bootdrv db 0 ; Boot Bootdrv number
|
||||
filename db "LOADER BIN" ; Filename
|
||||
|
||||
|
||||
;; GO !
|
||||
bootstrapper:
|
||||
mov ax, BOOT_SEG ; Set segments to the location of the bootloader
|
||||
mov ds, ax
|
||||
mov es, ax
|
||||
|
@ -98,8 +110,8 @@ loadRoot:
|
|||
mov al, byte [fats] ; Location of root dir = (fats * fatSectors) + reservedSectors
|
||||
mul word [fatSectors] ; multiply by the sectors used
|
||||
add ax, word [reservedSectors] ; increase ax by the reserved sectors
|
||||
mov word [userData], ax ; Start of user data = startOfRoot + numberOfRoot
|
||||
add word [userData], cx ; Add the size and location of the root directory
|
||||
mov word [UserData], ax ; Start of user data = startOfRoot + numberOfRoot
|
||||
add word [UserData], cx ; Add the size and location of the root directory
|
||||
|
||||
mov di, BUFFER_SEG ; Set the extra segment to the disk buffer
|
||||
mov es, di
|
||||
|
@ -123,7 +135,7 @@ searchRoot:
|
|||
loop searchRoot ; Continue to search for the file
|
||||
|
||||
;; ERROR...
|
||||
mov si, fileNotFound ; Could not find the file
|
||||
mov si, FileNotFound ; Could not find the file
|
||||
call print
|
||||
|
||||
;; REBOOT
|
||||
|
@ -196,11 +208,11 @@ readClusters:
|
|||
.clusterLoop:
|
||||
xor bh, bh
|
||||
xor dx, dx
|
||||
push ax ; Get the cluster start = (cluster - 2) * sectorsPerCluster + userData
|
||||
push ax ; Get the cluster start = (cluster - 2) * sectorsPerCluster + UserData
|
||||
sub ax, 2 ; Subtract 2
|
||||
mov bl, byte [sectorsPerCluster] ; Sectors per cluster is a byte value
|
||||
mul bx ; multiply (cluster - 2) * sectorsPerCluster
|
||||
add ax, word [userData] ; add the userData
|
||||
add ax, word [UserData] ; add the UserData
|
||||
xor ch, ch
|
||||
mov cl, byte [sectorsPerCluster] ; Sectors to read
|
||||
call readSectors ; Read the sectors
|
||||
|
@ -287,7 +299,7 @@ readSectors:
|
|||
int 0x13 ; Call int 13h (BIOS disk I/O)
|
||||
dec di ; Decrease read attempt counter
|
||||
jnz .attemptRead ; Try to read the sector again
|
||||
mov si, diskError ; Error reading the disk :/
|
||||
mov si, DiskError ; Error reading the disk :/
|
||||
call print
|
||||
jmp reboot
|
||||
.readOk:
|
||||
|
@ -328,13 +340,6 @@ print:
|
|||
.done:
|
||||
ret
|
||||
|
||||
;; LOVELY DATA
|
||||
fileNotFound db "FStage ERR : NO LOADER", 0 ; File was not found
|
||||
diskError db "FStage ERR : DISK", 0 ; Error while reading from the disk
|
||||
userData dw 0 ; Start of the data sectors
|
||||
Bootdrv db 0 ; Boot Bootdrv number
|
||||
filename db "LOADER BIN" ; Filename
|
||||
|
||||
;; END
|
||||
times 510 - ($ - $$) db 0 ; Pad remainder of boot sector with zeros
|
||||
dw 0xaa55 ; Boot signature
|
||||
|
|
Loading…
Reference in New Issue