From eac19a8ac75835544102ac0d18f003d2246095c8 Mon Sep 17 00:00:00 2001 From: Adrien Bourmault Date: Sat, 22 Dec 2018 12:19:17 +0100 Subject: [PATCH] Undo test --- bin/disk.img | Bin 18944000 -> 18944000 bytes bin/mbr.bin | Bin 512 -> 512 bytes obj/boot/mbr.bin | Bin 512 -> 512 bytes src/boot/loader.s | 2 +- src/boot/mbr.s | 35 ++++++++++++++++++++--------------- 5 files changed, 21 insertions(+), 16 deletions(-) diff --git a/bin/disk.img b/bin/disk.img index f3694b61487be2e3062ae0c781299c4cc660c9c0..17391ceca4bee3b7f9703c5264dbc1c996e041b9 100644 GIT binary patch delta 3103 zcmd^AYj_mp8U1EA37Z=`*$pueE+@qRK|w2WX^W&5QX&`ul@OE!OUs~EW00tb(omyE zDm6g15b+A4h=|wN3JOD%YP1R>YC*h4QKzg@)SxlYtnW9oA^WF)`lrv+?(>}QJ@dZr zH{Z;>=Ojzk-kiEbuwuL~Iy&-#F}m-T<{tI?>zg~asFeCW+mv~1yXqU*Ta&vqr&_I? zJv60C89l4i%H=t^^VQaL_05KwA$85zp_I{b>l+_CcClKyy~roMoq4`070EN^$;KVY zYK!696<%PTesEWK$~9lxvsB~`V`$ScqgP7Pguu2b5z}{OL%{6j8;1{Unz_1kb*WOD zB?i<7ex*LWQVmmMRH-UcLA7dxx-c?r<5^}`pN_h(X@A8YI`)`m(V%V@_D9TvgJNRFE2O+_A>UH&Pp0UorYj zN|l1Iq%Nr-Uz6y&vnzL&EK4frEmtLm?(U98i_sE&cB(Gx=8{6MT)0o)Hb2~$pJohd ztUh3L)au>KlM1pVY*R;4l~dFii#4U&4I!nR8JY*}2Q{Cpd73=9aJMHYk1u>gLVmEv zr|NuOLO!T@rd_D_`h`bR>^&i8_wkN4`ixDh$s3zlGi=k+{hO@1l;W^Y){3w%+G@?VDtB7zriU#<(($Fm5@oz( zO|{llgsnoIFWhIf$Oa`pt33Kh^x>wUW$)G_TqS~?Ac8&WE3@n(J-oV@W%oa-Yl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^_nOc$s*Gc$IjK zc%68Im`}V(EFj(@-X<0j?-1`2<-{UlF|mYrk6219Bi<*L6CV&C5*5Tp#K*)Z#0p|1 z@hP#2_>8C|Ruf*LidaK@PE-?Xi7$wC#CoEJ*g$+qY$U!Sz9wpkO~g0EW?~CbM|?|s zM|@BGK>SE-CAJaUi5TNMf^>iAWjnh5T}SH!aoPbTo@9EBt#M_36q3N+DV*}_L2xm wq$ElbEs2rDN?ejSiCYpc=^*JSNsuH;k|fEJ6iFw^X_C&8R7sk#3^08E0x6v$y#N3J diff --git a/bin/mbr.bin b/bin/mbr.bin index 8445126d03679477e6e97158fd8f641a0641b2e2..22e6c40695b06699ef7fafef7bcf5c149e32f56b 100644 GIT binary patch delta 129 zcmV-{0Dk{~1b_sPLjvnJlfnTv9Js&-j@XXC`nUiFj?laS5c|CV90<~M7>E{d0FhrR z25tZW4sHOEj}{nl0J#eQ^QLqtgTNra0005UhtcBbzC{3$y*~nQ0FnM10&W148v$n) jZ~(sr0Js4H%@cDFFyze>Pj&LXTmX}p0V)Lm00330TBWzhLT$>{M9X8?iFRRD7AFZBQb diff --git a/obj/boot/mbr.bin b/obj/boot/mbr.bin index 8445126d03679477e6e97158fd8f641a0641b2e2..22e6c40695b06699ef7fafef7bcf5c149e32f56b 100644 GIT binary patch delta 129 zcmV-{0Dk{~1b_sPLjvnJlfnTv9Js&-j@XXC`nUiFj?laS5c|CV90<~M7>E{d0FhrR z25tZW4sHOEj}{nl0J#eQ^QLqtgTNra0005UhtcBbzC{3$y*~nQ0FnM10&W148v$n) jZ~(sr0Js4H%@cDFFyze>Pj&LXTmX}p0V)Lm00330TBWzhLT$>{M9X8?iFRRD7AFZBQb diff --git a/src/boot/loader.s b/src/boot/loader.s index 698dd1a..c1e7c40 100644 --- a/src/boot/loader.s +++ b/src/boot/loader.s @@ -415,5 +415,5 @@ ErrorNo64: Die: cli hlt ; die nooooow - retf ; For conveniance '-' + retf KERNEL: diff --git a/src/boot/mbr.s b/src/boot/mbr.s index 9bbb40f..ce718a2 100644 --- a/src/boot/mbr.s +++ b/src/boot/mbr.s @@ -4,7 +4,7 @@ ; Authors: spectral` ; ; NeoX ; ; ; -; Desc: Bootsector for OS/K ; +; Desc: Bootsector for OS/K ; ; (x86_64 architecture only) ; ;=----------------------------------------------------------------------------=; @@ -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