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 volumeLabel bp+0x2b ; Volume Label
%define fatTypeLabel bp+0x36 ; File system type %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] [BITS 16]
[ORG 0x1000] [ORG 0x1000]
@ -41,14 +50,9 @@ mov ds, ax ; hm... And ds too
mov es, ax ; And es because it is jealous mov es, ax ; And es because it is jealous
mov [Bootdrv], dl mov [Bootdrv], dl
xor dl, dl
jmp 0x0000:main jmp 0x0000:main
;; DATA
Bootdrv db 0
VGA_HEIGHT dq 0
VIDEO_MODE dw 0
;; GDT WITH DOC ;; GDT WITH DOC
GDT64: GDT64:
NULL_SELECTOR: ;; null selector within 64 bits NULL_SELECTOR: ;; null selector within 64 bits
@ -128,7 +132,9 @@ GDT64:
%include "boot/loader16.inc" %include "boot/loader16.inc"
main: main:
;; compatibility check ;; compatibility check
push si
mov si, Init mov si, Init
call PrintB call PrintB
pop si pop si
@ -137,8 +143,10 @@ main:
push si push si
mov si, Pass mov si, Pass
call PrintB call PrintB
pop si
;; Enabling A20 ;; Enabling A20
push si
mov si, EnA20 mov si, EnA20
call PrintB call PrintB
pop si pop si
@ -148,6 +156,7 @@ main:
push si push si
mov si, Pass mov si, Pass
call PrintB call PrintB
pop si
;; DISABLING CURSOR BLINKING AND GETTING INFOS ;; DISABLING CURSOR BLINKING AND GETTING INFOS
call get_dimensions call get_dimensions
@ -172,10 +181,15 @@ main:
push dword [VGA_HEIGHT] push dword [VGA_HEIGHT]
jmp (CODE_SELECTOR-GDT64):main32 jmp (CODE_SELECTOR-GDT64):main32
[BITS 32] ErrorNo64:
VIDEO_MODE32 dw 0 mov si, NoLongMode
VGA_HEIGHT32 dw 0 call PrintB
Die:
cli
hlt ; die nooooow
jmp 0xF000:0xFFF0
[BITS 32]
main32: main32:
pop dword [VGA_HEIGHT32] pop dword [VGA_HEIGHT32]
pop dword [VIDEO_MODE32] pop dword [VIDEO_MODE32]
@ -238,18 +252,31 @@ main32:
%include "boot/loader64.inc" %include "boot/loader64.inc"
;; DATA ;; DATA
txt db 0x09, " Switching to Long Mode... ", 0
Init db "Booting OS/K !", 0x0D, 0x0A, 0x0D, 0x0A, 0x09, " Checking CPUID...",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 CPUIDD db 0x09, " Checking CPUID...", 0
EnA20 db 0x09, " Enabling A20 line...", 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 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 NextTRAM dq 0x0B8000 ; Last position of cursor
VIDEO_MODE64 dq 0 VIDEO_MODE64 dq 0
VGA_HEIGHT64 dq 0 VGA_HEIGHT64 dq 0
VGA_X dq 0x0 VGA_X dq 0
msg db "The system is now in x64 mode. Is this not beautiful ?", 0x0A, 0x0D, 0
main64: main64:
pop qword [VGA_HEIGHT64] pop qword [VGA_HEIGHT64]
@ -280,6 +307,14 @@ main64:
mov esi, Pass mov esi, Pass
call write call write
mov bl, 0x0F
mov esi, KernSearch
call write
mov bl, 0x0A
mov esi, Pass
call write
mov bl, 0x0F mov bl, 0x0F
mov esi, txt mov esi, txt
call write call write
@ -294,11 +329,6 @@ main64:
jmp Die jmp Die
[BITS 16] ; times 1024 nop
ErrorNo64: ; XXX ;
mov si, NoLongMode ; It seems impossible to have an executable > 2.0 kB...
call PrintB
Die:
cli
hlt ; die nooooow
jmp 0xF000:0xFFF0

View File

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

View File

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