Issue with length of loader.bin, and can't load kernel for now

This commit is contained in:
Adrien Bourmault 2018-12-23 17:52:55 +01:00
parent f3f9489167
commit b952d9d900
8 changed files with 58 additions and 26 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -33,6 +33,15 @@
%define volumeLabel bp+0x2b ; Volume Label
%define fatTypeLabel bp+0x36 ; File system type
;; DISK BUFFER "SEGMENT"
%define BUFFER_SEG 0x07c0 ; (BUFFER_SEG << 4) + BUFFER_OFF = 0x07C00
%define BUFFER_OFF 0x0000
;; SECOND STAGE LOADER "SEGMENT"
%define LOAD_SEG LONG_SELECTOR-GDT64 ; (LOAD_SEG << 4) + LOAD_OFF = 0x070000
%define LOAD_OFF Kernel
[BITS 16]
[ORG 0x1000]
@ -41,14 +50,9 @@ mov ds, ax ; hm... And ds too
mov es, ax ; And es because it is jealous
mov [Bootdrv], dl
xor dl, dl
jmp 0x0000:main
;; DATA
Bootdrv db 0
VGA_HEIGHT dq 0
VIDEO_MODE dw 0
;; GDT WITH DOC
GDT64:
NULL_SELECTOR: ;; null selector within 64 bits
@ -128,7 +132,9 @@ GDT64:
%include "boot/loader16.inc"
main:
;; compatibility check
push si
mov si, Init
call PrintB
pop si
@ -137,8 +143,10 @@ main:
push si
mov si, Pass
call PrintB
pop si
;; Enabling A20
push si
mov si, EnA20
call PrintB
pop si
@ -148,11 +156,12 @@ main:
push si
mov si, Pass
call PrintB
pop si
;; DISABLING CURSOR BLINKING AND GETTING INFOS
call get_dimensions
call disable_cursor
;;GO GDT64
cli ; disable interrupts
lgdt [GDT64]
@ -171,11 +180,16 @@ main:
push dword [VIDEO_MODE]
push dword [VGA_HEIGHT]
jmp (CODE_SELECTOR-GDT64):main32
ErrorNo64:
mov si, NoLongMode
call PrintB
Die:
cli
hlt ; die nooooow
jmp 0xF000:0xFFF0
[BITS 32]
VIDEO_MODE32 dw 0
VGA_HEIGHT32 dw 0
main32:
pop dword [VGA_HEIGHT32]
pop dword [VIDEO_MODE32]
@ -238,18 +252,31 @@ main32:
%include "boot/loader64.inc"
;; DATA
txt db 0x09, " Switching to Long Mode... ", 0
Init db "Booting OS/K !", 0x0D, 0x0A, 0x0D, 0x0A, 0x09, " Checking CPUID...",0
Reinit db "Booting OS/K !", 0x0D, 0x0A, 0x0D, 0x0A, 0
CPUIDD db 0x09, " Checking CPUID...", 0
EnA20 db 0x09, " Enabling A20 line...", 0
NoLongMode db 0x0A, 0x0D, "ERROR : Your computer is not designed for x64 OS", 0
KernSearch db 0x09, " Loading the Kernel in RAM...", 0
txt db 0x09, " Switching to Long Mode... ", 0
Reinit db "Booting OS/K !", 0x0D, 0x0A, 0x0D, 0x0A, 0
Pass db " OK", 0x0A, 0x0D, 0
msg db "The system is now in x64 mode. Is this not beautiful ?", 0x0A, 0x0D, 0
NoLongMode db 0x0A, 0x0D, "ERROR : Your computer is not designed for x64 OS", 0
FileNotFound db "Second Stage Error : The Kernel was not found.", 0x0A, 0x0D, 0
DiskError db "Second Stage Error : The Disk has crashed.", 0x0A, 0x0D, 0
filename db "KERNEL BIN"
Bootdrv db 0
UserData dw 0
VGA_HEIGHT dq 0
VIDEO_MODE dw 0
VIDEO_MODE32 dw 0
VGA_HEIGHT32 dw 0
NextTRAM dq 0x0B8000 ; Last position of cursor
VIDEO_MODE64 dq 0
VGA_HEIGHT64 dq 0
VGA_X dq 0x0
msg db "The system is now in x64 mode. Is this not beautiful ?", 0x0A, 0x0D, 0
VGA_X dq 0
main64:
pop qword [VGA_HEIGHT64]
@ -276,6 +303,14 @@ main64:
mov esi, EnA20
call write
mov bl, 0x0A
mov esi, Pass
call write
mov bl, 0x0F
mov esi, KernSearch
call write
mov bl, 0x0A
mov esi, Pass
call write
@ -291,14 +326,9 @@ main64:
mov bl, 0x0D
mov esi, msg
call write
jmp Die
[BITS 16]
ErrorNo64:
mov si, NoLongMode
call PrintB
Die:
cli
hlt ; die nooooow
jmp 0xF000:0xFFF0
; times 1024 nop
; XXX ;
; It seems impossible to have an executable > 2.0 kB...

View File

@ -7,6 +7,7 @@
; Desc: Kernel (second stage) Loader for OS/K INCLUDED FUNCTIONS ;
; (x86_64 architecture only) ;
;=----------------------------------------------------------------------------=;
[BITS 16]
disable_cursor:

View File

@ -7,6 +7,7 @@
; Desc: Bootsector for OS/K INCLUDED FUNCTIONS ;
; (x86_64 architecture only) ;
;=----------------------------------------------------------------------------=;
[BITS 16]
read_clusters:
;---------------------------------------------------;
@ -100,7 +101,7 @@ read_sectors:
shl ah, 1
or cl, ah ; Now cx is set with respective track and sector numbers
mov dl, byte [Bootdrv] ; Set correct Bootdrv for int 13h
mov di, 5 ; Try five times to read the sector because i love 5
mov di, 21 ; Try five times to read the sector because i love 21
.attempt_read:
mov ax, 0x0201 ; Read Sectors func of int 13h, read one sector
int 0x13 ; Call int 13h (BIOS disk I/O)