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:
|
Die:
|
||||||
cli
|
cli
|
||||||
hlt ; die nooooow
|
hlt ; die nooooow
|
||||||
retf ; For conveniance '-'
|
retf
|
||||||
KERNEL:
|
KERNEL:
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
; Authors: spectral` ;
|
; Authors: spectral` ;
|
||||||
; NeoX ;
|
; NeoX ;
|
||||||
; ;
|
; ;
|
||||||
; Desc: Bootsector for OS/K ;
|
; Desc: Bootsector for OS/K ;
|
||||||
; (x86_64 architecture only) ;
|
; (x86_64 architecture only) ;
|
||||||
;=----------------------------------------------------------------------------=;
|
;=----------------------------------------------------------------------------=;
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@
|
||||||
%define BUFFER_OFF 0x0000
|
%define BUFFER_OFF 0x0000
|
||||||
|
|
||||||
;; SECOND STAGE LOADER "SEGMENT"
|
;; 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
|
%define LOAD_OFF 0x1000
|
||||||
|
|
||||||
[BITS 16] ; Ensure 16-bit code (because fuck UEFI)
|
[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
|
jmp BOOT_SEG:$+5 ; Fix the cs:ip registers with a vaudou magical trip
|
||||||
|
|
||||||
bootstrap:
|
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 ax, BOOT_SEG ; Set segments to the location of the bootloader
|
||||||
mov ds, ax
|
mov ds, ax
|
||||||
mov es, ax
|
mov es, ax
|
||||||
|
@ -98,8 +110,8 @@ loadRoot:
|
||||||
mov al, byte [fats] ; Location of root dir = (fats * fatSectors) + reservedSectors
|
mov al, byte [fats] ; Location of root dir = (fats * fatSectors) + reservedSectors
|
||||||
mul word [fatSectors] ; multiply by the sectors used
|
mul word [fatSectors] ; multiply by the sectors used
|
||||||
add ax, word [reservedSectors] ; increase ax by the reserved sectors
|
add ax, word [reservedSectors] ; increase ax by the reserved sectors
|
||||||
mov word [userData], ax ; Start of user data = startOfRoot + numberOfRoot
|
mov word [UserData], ax ; Start of user data = startOfRoot + numberOfRoot
|
||||||
add word [userData], cx ; Add the size and location of the root directory
|
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 di, BUFFER_SEG ; Set the extra segment to the disk buffer
|
||||||
mov es, di
|
mov es, di
|
||||||
|
@ -123,7 +135,7 @@ searchRoot:
|
||||||
loop searchRoot ; Continue to search for the file
|
loop searchRoot ; Continue to search for the file
|
||||||
|
|
||||||
;; ERROR...
|
;; ERROR...
|
||||||
mov si, fileNotFound ; Could not find the file
|
mov si, FileNotFound ; Could not find the file
|
||||||
call print
|
call print
|
||||||
|
|
||||||
;; REBOOT
|
;; REBOOT
|
||||||
|
@ -196,11 +208,11 @@ readClusters:
|
||||||
.clusterLoop:
|
.clusterLoop:
|
||||||
xor bh, bh
|
xor bh, bh
|
||||||
xor dx, dx
|
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
|
sub ax, 2 ; Subtract 2
|
||||||
mov bl, byte [sectorsPerCluster] ; Sectors per cluster is a byte value
|
mov bl, byte [sectorsPerCluster] ; Sectors per cluster is a byte value
|
||||||
mul bx ; multiply (cluster - 2) * sectorsPerCluster
|
mul bx ; multiply (cluster - 2) * sectorsPerCluster
|
||||||
add ax, word [userData] ; add the userData
|
add ax, word [UserData] ; add the UserData
|
||||||
xor ch, ch
|
xor ch, ch
|
||||||
mov cl, byte [sectorsPerCluster] ; Sectors to read
|
mov cl, byte [sectorsPerCluster] ; Sectors to read
|
||||||
call readSectors ; Read the sectors
|
call readSectors ; Read the sectors
|
||||||
|
@ -287,7 +299,7 @@ readSectors:
|
||||||
int 0x13 ; Call int 13h (BIOS disk I/O)
|
int 0x13 ; Call int 13h (BIOS disk I/O)
|
||||||
dec di ; Decrease read attempt counter
|
dec di ; Decrease read attempt counter
|
||||||
jnz .attemptRead ; Try to read the sector again
|
jnz .attemptRead ; Try to read the sector again
|
||||||
mov si, diskError ; Error reading the disk :/
|
mov si, DiskError ; Error reading the disk :/
|
||||||
call print
|
call print
|
||||||
jmp reboot
|
jmp reboot
|
||||||
.readOk:
|
.readOk:
|
||||||
|
@ -328,13 +340,6 @@ print:
|
||||||
.done:
|
.done:
|
||||||
ret
|
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
|
;; END
|
||||||
times 510 - ($ - $$) db 0 ; Pad remainder of boot sector with zeros
|
times 510 - ($ - $$) db 0 ; Pad remainder of boot sector with zeros
|
||||||
dw 0xaa55 ; Boot signature
|
dw 0xaa55 ; Boot signature
|
||||||
|
|
Loading…
Reference in New Issue