Just learned SysV ABI calling conventions and clean-up stuff

This commit is contained in:
Adrien Bourmault 2019-03-12 22:11:00 +01:00
parent f836157c90
commit 32c7c99bc2
7 changed files with 19 additions and 26 deletions

View File

@ -23,11 +23,12 @@
; along with OS/K. If not, see <https://www.gnu.org/licenses/>. ; ; along with OS/K. If not, see <https://www.gnu.org/licenses/>. ;
;=----------------------------------------------------------------------------=; ;=----------------------------------------------------------------------------=;
[global temporize] global temporize
[global bitemporize] global bitemporize
[global tritemporize] global tritemporize
[BITS 64] [BITS 64]
[section .text]
temporize: temporize:
push rcx push rcx

View File

@ -24,6 +24,7 @@
;=----------------------------------------------------------------------------=; ;=----------------------------------------------------------------------------=;
[BITS 32] [BITS 32]
[section .text]
; ---------------------------------------------------------------------------- ; ; ---------------------------------------------------------------------------- ;
; Checks if the CPU is compatible with 64-bits operating systems ; ; Checks if the CPU is compatible with 64-bits operating systems ;

View File

@ -22,7 +22,9 @@
; You should have received a copy of the GNU General Public License ; ; You should have received a copy of the GNU General Public License ;
; along with OS/K. If not, see <https://www.gnu.org/licenses/>. ; ; along with OS/K. If not, see <https://www.gnu.org/licenses/>. ;
;=----------------------------------------------------------------------------=; ;=----------------------------------------------------------------------------=;
[global testf]
[BITS 64]
[section .text]
;;VIDEO ;;VIDEO
%define TRAM 0xB8000 ; [T]ext[RAM] %define TRAM 0xB8000 ; [T]ext[RAM]
@ -30,16 +32,12 @@
%define VGA_HEIGHT 80 %define VGA_HEIGHT 80
;; GLOBAL DATA ;; GLOBAL DATA
NextTRAM dq 0xB8000 ; Last position of cursor NextTRAM dq 0xB8000 ; Last position of cursor
NextTRAM32 dq 0xB8000 ; Last position of cursor NextTRAM32 dq 0xB8000 ; Last position of cursor
VGA_X32 dq 0 VGA_X32 dq 0
VGA_HEIGHT64 dq VGA_HEIGHT VGA_HEIGHT64 dq VGA_HEIGHT
VGA_X dq 0 VGA_X dq 0
;; TEXT
[BITS 64]
testf: testf:
push rsi push rsi

View File

@ -31,9 +31,10 @@
%include "boot/loader/cpu/cpu.inc" %include "boot/loader/cpu/cpu.inc"
%include "boot/loader/mem/structures.inc" %include "boot/loader/mem/structures.inc"
[BITS 32] global MB_start
[global MB_start] extern StartKern
[BITS 32]
[section .multiboot] [section .multiboot]
;; MAGNIFICENT MULTIBOOT HEADER FOR GRUB ------------------------------------ ;; ;; MAGNIFICENT MULTIBOOT HEADER FOR GRUB ------------------------------------ ;;
@ -50,8 +51,8 @@ MB_start:
mov esp, KERNEL_STACK ; Setup the stack mov esp, KERNEL_STACK ; Setup the stack
push 0 ; Reset EFLAGS push 0 ; Reset EFLAGS
popf popf
push eax ; 2nd argument is magic number mov [mbInfo], ebx
push ebx ; 1st argument multiboot info pointer mov [mbMagic], eax
mov ecx, eax ; For debug mov ecx, eax ; For debug
call _loader call _loader
add esp, 8 ; Cleanup arguments "A la MIPS" add esp, 8 ; Cleanup arguments "A la MIPS"
@ -100,12 +101,6 @@ mbInfo dq 0
mbMagic dq 0 mbMagic dq 0
lbegin: lbegin:
pop ebx ; 1st argument multiboot info pointer
mov [mbInfo], ebx
pop eax ; 2nd argument is magic number
mov [mbMagic], eax
call clear ; Clear the screen call clear ; Clear the screen
;; BEGIN OF CHECKLIST ;; BEGIN OF CHECKLIST
@ -160,10 +155,8 @@ _loader64:
;; Launch the kernel ! ;; Launch the kernel !
call tritemporize ; Let time to see call tritemporize ; Let time to see
extern StartKern mov rdi, [mbInfo]
mov rsi, [mbMagic]
mov rsi, [mbInfo]
mov rdi, [mbMagic]
call StartKern call StartKern
;; We must never reach this point ------------------------------------------- ;; ;; We must never reach this point ------------------------------------------- ;;

View File

@ -24,7 +24,7 @@
;=----------------------------------------------------------------------------=; ;=----------------------------------------------------------------------------=;
[BITS 32] [BITS 32]
[section .text]
; ---------------------------------------------------------------------------- ; ; ---------------------------------------------------------------------------- ;
; Constructor for the page tables in protected mode ; ; Constructor for the page tables in protected mode ;
; ---------------------------------------------------------------------------- ; ; ---------------------------------------------------------------------------- ;

View File

@ -24,7 +24,7 @@
;=----------------------------------------------------------------------------=; ;=----------------------------------------------------------------------------=;
[BITS 32] [BITS 32]
section .rodata [section .rodata]
;; GDT WITH DOC ;; GDT WITH DOC
ALIGN 4096 ALIGN 4096
GDT64: GDT64:
@ -44,7 +44,7 @@ GDT64:
dq GDT64 dq GDT64
;; EMPTY PAGE TABLES (identity of the first 1GiB) ;; EMPTY PAGE TABLES (identity of the first 1GiB)
section .bss [section .bss]
ALIGN 4096 ALIGN 4096
PML4_table: PML4_table:
resb 4096 resb 4096

View File

@ -40,6 +40,6 @@ noreturn void StartKern(void *mbInfo, int mbMagic)
InitTerms(); InitTerms();
// We're out // We're out
StartPanic("We had\n *mbInfo : %p\n mbMagic : %x\n\nGoodbye World :(", mbInfo, mbMagic); StartPanic("We had\n *mbInfo : %p\n mbMagic : %p\n\nGoodbye World :(", mbInfo, mbMagic);
} }