os-k/boot/loader/loader.asm

73 lines
3.5 KiB
NASM
Raw Normal View History

2019-01-16 11:04:44 +01:00
;=----------------------------------------------------------------------------=;
; GNU GPL OS/K ;
; ;
; Desc: Kernel (second stage) Loader for OS/K ;
; (x86_64 architecture only) ;
2019-02-06 15:34:39 +01:00
; ;
; ;
; Copyright © 2018-2019 The OS/K Team ;
; ;
; This file is part of OS/K. ;
; ;
; OS/K is free software: you can redistribute it and/or modify ;
; it under the terms of the GNU General Public License as published by ;
; the Free Software Foundation, either version 3 of the License, or ;
; (at your option) any later version. ;
; ;
; OS/K is distributed in the hope that it will be useful, ;
; but WITHOUT ANY WARRANTY; without even the implied warranty of ;
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;
; GNU General Public License for more details. ;
; ;
; You should have received a copy of the GNU General Public License ;
; along with OS/K. If not, see <https://www.gnu.org/licenses/>. ;
2019-01-16 11:04:44 +01:00
;=----------------------------------------------------------------------------=;
2019-01-17 14:09:08 +01:00
%define DEBUG
2019-02-12 14:58:26 +01:00
[BITS 32]
[global _start]
[ORG 0x100000] ; Where GRUB loads us.
2019-02-12 14:58:26 +01:00
%include "boot/loader/multiboot.inc"
2019-02-12 14:58:26 +01:00
_start:
mov ax, cs ; correcting cs after the horrible far jump
mov ds, ax ; hm... And ds too
mov es, ax ; And es because it is jealous
;mov [Bootdrv], dl
2019-02-12 14:58:26 +01:00
xor dl, dl
jmp 0x0000:main ; pas sûr
2019-02-12 14:58:26 +01:00
MB_header:
align 4
dd MB_HEADER_MAGIC
dd MB_HEADER_FLAGS
dd CHECKSUM
dd MB_header ; Header address
dd _start ; Address of code entry point
dd 00 ; (end of code) not necessary
dd 00 ; (bss) not necessary
dd MB_start ; entry address GRUB will start at
2019-02-12 14:58:26 +01:00
MB_start:
mov esp, KERNEL_STACK ; Setup the stack
push 0 ; Reset EFLAGS
2019-02-12 14:58:26 +01:00
popf
push eax ; 2nd argument is magic number
push ebx ; 1st argument multiboot info pointer
call main
add esp, 8 ; Cleanup 8 bytes pushed as arguments
jmp Die
2019-01-16 11:04:44 +01:00
;; BEGIN OF THE HOLE -------------------------------------------------------- ;;
2019-01-16 11:04:44 +01:00
Die:
cli
hlt ; die nooooow
;jmp 0xF000:0xFFF0
jmp $
;; END OF THE HOLE ---------------------------------------------------------- ;;
2019-01-16 11:04:44 +01:00
main:
jmp Die