diff --git a/.gitignore b/.gitignore
index 9b168cc..49d6ef7 100644
--- a/.gitignore
+++ b/.gitignore
@@ -12,6 +12,7 @@ qemu.log
*.obj
*.elf
*.S
+build/obj/*/*/*/[^.]*
# CNAME STUFF
*.yml
@@ -54,6 +55,7 @@ build/bin/s**
*.hex
*.bin
*.img
+build/bin/[^.]*
# Debug files
*.dSYM/
diff --git a/Makefile b/Makefile
index d0bec82..b2f06ba 100644
--- a/Makefile
+++ b/Makefile
@@ -42,8 +42,9 @@ tests:
#Programs
ASM=nasm
-ASMFLAGS=
-BOOTFLAGS=-f bin
+LD=ld
+ASMFLAGS=-f elf64
+LDFLAGS= -melf_x86_64
#Folders
MBRDIR=boot/grub
@@ -51,6 +52,8 @@ LOADERDIR=boot/loader
OBJDIR=build/obj
BINDIR=build/bin
+l_objects=./build/obj/kaleid/crtlib/memory.o ./build/obj/kaleid/crtlib/rand.o ./build/obj/kaleid/crtlib/string.o ./build/obj/kaleid/crtlib/ultoa.o ./build/obj/kaleid/crtlib/strtol.o ./build/obj/kaleid/crtlib/utoa.o ./build/obj/kaleid/crtlib/status.o ./build/obj/kaleid/crtlib/atoul.o ./build/obj/kaleid/crtlib/atol.o ./build/obj/kaleid/crtlib/itoa.o ./build/obj/kaleid/crtlib/ltoa.o ./build/obj/kaleid/crtlib/atou.o ./build/obj/kaleid/crtlib/arith.o ./build/obj/kaleid/crtlib/atoi.o ./build/obj/kaleid/extras/prog.o ./build/obj/kaleid/extras/argv.o ./build/obj/kaleid/kernel/init/table.o ./build/obj/kaleid/kernel/init/init.o ./build/obj/kaleid/kernel/io/vga.o ./build/obj/kaleid/kernel/io/cursor.o ./build/obj/kaleid/kernel/io/term.o ./build/obj/kaleid/kernel/ke/panic.o ./build/obj/boot/loader.o
+
#Color codes
CL='\033[0;32m'
CL2='\033[1;31m'
@@ -65,17 +68,19 @@ boot.mbr: $(BINDIR)/disk.img $(MBRDIR)/grub.cfg
@rmdir $(BINDIR)/disk
boot.loader.asm: $(LOADERDIR)/loader.asm
- @echo ${CL2}[boot.loader.asm]${NC} Making loader.bin...${CL3}
- @$(ASM) $(BOOTFLAGS) $(LOADERDIR)/loader.asm -o $(OBJDIR)/boot/loader.bin > /dev/null
+ @echo ${CL2}[boot.loader.asm]${NC} Making loader...${CL3}
+ @$(ASM) $(ASMFLAGS) $(LOADERDIR)/loader.asm -o $(OBJDIR)/boot/loader.o > /dev/null
@echo ${CL2}[boot.loader.asm]${CL} OK${CL3}
-loader: boot.loader.asm
+loader: boot.loader.asm link copykernel
+
+copykernel:
@mkdir -p $(BINDIR)/disk
- @echo ${CL2}[loader]${NC} Constructing kernel loader...${CL3}
+ @echo ${CL2}[disk]${NC} Integrating kernel...${CL3}
@$(MBRDIR)/mount.sh $(BINDIR)/disk.img $(BINDIR)/disk
- @cp $(OBJDIR)/boot/loader.bin $(BINDIR)/disk/boot/loader.bin
+ @cp $(BINDIR)/kaleid $(BINDIR)/disk/boot/kaleid
@$(MBRDIR)/umount.sh $(BINDIR)/disk
- @echo ${CL2}[loader]${CL} OK${CL3}
+ @echo ${CL2}[disk]${CL} OK${CL3}
@rmdir $(BINDIR)/disk
make_disk:
@@ -85,20 +90,27 @@ make_disk:
testloader: loader
@qemu-system-x86_64 -hda build/bin/disk.img -d cpu_reset,guest_errors,pcall,int -enable-kvm 2> qemu.log &
- @ndisasm $(OBJDIR)/boot/loader.bin -b 32 > loader_dism.asm
+ @ndisasm $(OBJDIR)/boot/loader -b 32 > loader_dism.asm
testloader32: loader
@qemu-system-i386 -hda build/bin/disk.img -d cpu_reset,guest_errors,pcall,int -enable-kvm 2> qemu.log &
- @ndisasm $(OBJDIR)/boot/loader.bin -b 32 > loader_dism.asm
+ @ndisasm $(OBJDIR)/boot/loader -b 32 > loader_dism.asm
debugloader: loader
@qemu-system-x86_64 -hda build/bin/disk.img -d cpu_reset,guest_errors,pcall,int -s -S -enable-kvm 2> qemu.log &
- @ndisasm $(OBJDIR)/boot/loader.bin -b 32 > loader_dism.asm
-
+ @ndisasm $(OBJDIR)/boot/loader -b 32 > loader_dism.asm
boot: make_disk boot.mbr loader
@echo ${CL2}[[boot]]${CL} Terminated without error.${CL3}
-all: boot kernel
+all: kernel boot
@echo ${CL2}[[all]]${CL} Terminated without error.${CL3}
+link:
+ @$(LD) $(LDFLAGS) -T build/kernel.ld $(l_objects) -o $(OBJDIR)/boot/kaleid.x86_64
+ @x86_64-elf-objcopy -I elf64-x86-64 -O elf32-i386 $(OBJDIR)/boot/kaleid.x86_64 $(BINDIR)/kaleid
+
+clean:
+ rm -Rf $(BINDIR)/*
+ rm -Rf $(OBJDIR)/*/*/*/*.o
+
diff --git a/Makefile.in b/Makefile.in
index 38ded8c..a791b0a 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -106,7 +106,7 @@ kernel: common
COMPILE_KERNEL(io/cursor)
COMPILE_KERNEL(io/term)
COMPILE_KERNEL(io/vga)
- LINK_KERNEL(kaleid-kernel.elf)
+ //LINK_KERNEL(kaleid-kernel.elf)
//----------------------------------------------------------------------------#
diff --git a/boot/grub/grub.cfg b/boot/grub/grub.cfg
index 878c1b8..4efc73e 100755
--- a/boot/grub/grub.cfg
+++ b/boot/grub/grub.cfg
@@ -27,6 +27,6 @@ set timeout=5
set default=0 #Set the default menu entry
menuentry "OS/K (pre-pre-alpha 0.0.1)" {
- multiboot /boot/loader.bin # The multiboot command replaces the kernel command
+ multiboot /boot/kaleid # The multiboot command replaces the kernel command
boot
}
diff --git a/boot/loader/cpu/cpu.inc b/boot/loader/cpu/cpu.inc
index b875758..1dc5158 100644
--- a/boot/loader/cpu/cpu.inc
+++ b/boot/loader/cpu/cpu.inc
@@ -44,3 +44,14 @@ bitemporize:
loop .looping
pop rcx
ret
+
+tritemporize:
+ push rcx
+ mov rcx, 20
+.looping:
+ push rcx
+ call bitemporize
+ pop rcx
+ loop .looping
+ pop rcx
+ ret
diff --git a/boot/loader/cpu/cpuid.inc b/boot/loader/cpu/cpuid.inc
index 7dabd42..c67fb08 100644
--- a/boot/loader/cpu/cpuid.inc
+++ b/boot/loader/cpu/cpuid.inc
@@ -44,7 +44,7 @@ Is64Bits:
jz .no_64 ; If it's not set, there is no long mode
ret
.no_64:
- mov ax, "01" ; ERROR 01 : 64bits unsupported
+ mov ax, "03" ; ERROR 03 : 64bits unsupported
jmp Error
; ---------------------------------------------------------------------------- ;
diff --git a/boot/loader/elf/elf.c b/boot/loader/elf/elf.c
deleted file mode 100644
index fe48cde..0000000
--- a/boot/loader/elf/elf.c
+++ /dev/null
@@ -1,26 +0,0 @@
-//=--------------------------------------------------------------------------=//
-// GNU GPL OS/K //
-// //
-// Desc: ELF64 Parser and Loader //
-// (x86_64 architecture only) //
-// //
-// //
-// 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 . //
-//=--------------------------------------------------------------------------=//
-
-int stub;
diff --git a/boot/loader/fs/fat.asm b/boot/loader/fs/fat.asm
deleted file mode 100644
index 978d7ed..0000000
--- a/boot/loader/fs/fat.asm
+++ /dev/null
@@ -1,33 +0,0 @@
-;=----------------------------------------------------------------------------=;
-; GNU GPL OS/K ;
-; ;
-; Desc: Basic File Allocation Table Long mode Driver ;
-; (x86_64 architecture only) ;
-; ;
-; ;
-; 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 . ;
-;=----------------------------------------------------------------------------=;
-
-[BITS 64]
-
-;; GLOBAL DATA
-UserData dw 0
-
-;; TEXT
-
-nop
diff --git a/boot/loader/io/terminal.inc b/boot/loader/io/terminal.inc
index 77fcadb..1037c10 100644
--- a/boot/loader/io/terminal.inc
+++ b/boot/loader/io/terminal.inc
@@ -25,23 +25,27 @@
;;VIDEO
-%define TRAM 0x0B8000 ; [T]ext[RAM]
-%define VRAM 0x0A0000 ; [V]ideo[RAM]
+%define TRAM 0xB8000 ; [T]ext[RAM]
+%define VRAM 0xA0000 ; [V]ideo[RAM]
+%define VGA_HEIGHT 80
;; GLOBAL DATA
-NextTRAM dq 0xB8000 ; Last position of cursor
-VGA_HEIGHT64 dq 80
+NextTRAM dq 0xB8000 ; Last position of cursor
+NextTRAM32 dq 0xB8000 ; Last position of cursor
+VGA_X32 dq 0
+VGA_HEIGHT64 dq VGA_HEIGHT
VGA_X dq 0
;; TEXT
[BITS 64]
-clear:
+
;-----------------------------------------------------------------------;
; x64/LM Clear Text Screen Function ;
;-----------------------------------------------------------------------;
+clear:
mov qword [NextTRAM], TRAM
mov edi, TRAM
push rsi
@@ -49,35 +53,36 @@ clear:
push rcx
mov ah, 0
mov al, 0
- mov rcx, 0x4000 ; traditionnal value
- rep stosw ; fill screen with al while cx > 0
+ mov rcx, 0x4000 ; traditionnal value
+ rep stosw ; fill screen with al while cx > 0
pop rcx
pop rsi
pop rdi
ret
-write:
+
;-----------------------------------------------------------------------;
; x64/LM Text Printing Functions ;
; bl : color code ;
; esi : string address ;
;-----------------------------------------------------------------------;
- mov edi, [NextTRAM] ; TRAM ADDRESS
+write:
+ mov edi, [NextTRAM] ; TRAM ADDRESS
push rsi
push rdi
.pLoop:
lodsb
- cmp al, 0 ; while @al, i.e. while we're not hitting '\0'
+ cmp al, 0 ; while @al, i.e. while we're not hitting '\0'
je .pEnd
- cmp al, 0x0A ; LF
+ cmp al, 0x0A ; LF
je .lf
- cmp al, 0x0D ; CR
+ cmp al, 0x0D ; CR
je .cr
- stosb ; text subpixel
+ stosb ; text subpixel
mov al, bl
- stosb ; color subpixel
- add qword [NextTRAM], 0x2 ; Cursor moving
- add qword [VGA_X], 0x2 ; coord + 2 because 2 subpixels
+ stosb ; color subpixel
+ add qword [NextTRAM], 0x2 ; Cursor moving
+ add qword [VGA_X], 0x2 ; coord + 2 because 2 subpixels
jmp .pLoop
.pEnd:
pop rdi
@@ -85,15 +90,15 @@ write:
ret
.lf:
mov rax, [VGA_HEIGHT64]
- add [NextTRAM], rax ; Cursor moving
+ add [NextTRAM], rax ; Cursor moving
add [NextTRAM], rax
- add edi, eax ; Address moving
+ add edi, eax ; Address moving
add edi, eax
jmp .pLoop
.cr:
push rax
mov rax, qword [VGA_X]
- sub qword [NextTRAM], rax ; pos = X + Y * VGA_HEIGHT64. Donc pos - X = début de ligne
+ sub qword [NextTRAM], rax ; pos = X + Y * VGA_HEIGHT64. Donc pos - X = début de ligne
sub edi, edx
mov qword [VGA_X], 0
pop rax
@@ -108,19 +113,63 @@ dump:
; bl : color code ;
; esi : buffer address ;
;-----------------------------------------------------------------------;
- mov edi, [NextTRAM] ; TRAM ADDRESS
+ mov edi, [NextTRAM] ; TRAM ADDRESS
push rsi
push rdi
push rcx
mov rcx, 512
.pLoop:
lodsb
- stosb ; text subpixel
+ stosb ; text subpixel
mov al, bl
- stosb ; color subpixel
+ stosb ; color subpixel
loop .pLoop
pop rcx
pop rdi
pop rsi
- add qword [NextTRAM], 1000 ; Cursor moving : 1120 = 80 * 2 * 7 lignes
+ add qword [NextTRAM], 1000 ; Cursor moving : 1120 = 80 * 2 * 7 lignes
ret
+
+[BITS 32]
+;-----------------------------------------------------------------------;
+; x32 Text Printing Functions ;
+; bl : color code ;
+; esi : string address ;
+;-----------------------------------------------------------------------;
+write32:
+ mov edi, TRAM ; TRAM ADDRESS
+ push esi
+ push edi
+.pLoop:
+ lodsb
+ cmp al, 0 ; while @al, i.e. while we're not hitting '\0'
+ je .pEnd
+ stosb ; text subpixel
+ mov al, bl
+ stosb ; color subpixel
+ jmp .pLoop
+.pEnd:
+ pop edi
+ pop esi
+ ret
+
+disable_cursor:
+ pushf
+ push eax
+ push edx
+
+ mov dx, 0x3D4
+ mov al, 0xA ; low cursor shape register
+ out dx, al
+
+ inc dx
+ mov al, 0x20 ; bits 6-7 unused, bit 5 disables the cursor, bits 0-4 control the cursor shape
+ out dx, al
+
+ pop edx
+ pop eax
+ popf
+
+ ret
+
+[BITS 64]
diff --git a/boot/loader/loader.asm b/boot/loader/loader.asm
index d421bd0..ef67137 100644
--- a/boot/loader/loader.asm
+++ b/boot/loader/loader.asm
@@ -1,7 +1,7 @@
;=----------------------------------------------------------------------------=;
; GNU GPL OS/K ;
; ;
-; Desc: Kernel (second stage) Loader for OS/K ;
+; Desc: Kernel Loader for OS/K ;
; (x86_64 architecture only) ;
; ;
; ;
@@ -23,36 +23,29 @@
; along with OS/K. If not, see . ;
;=----------------------------------------------------------------------------=;
-%define DEBUG
+%include "boot/loader/multiboot/header.inc"
+%include "boot/loader/multiboot/check.inc"
+%include "boot/loader/cpu/cpuid.inc"
+%include "boot/loader/mem/management.inc"
+%include "boot/loader/io/terminal.inc"
+%include "boot/loader/cpu/cpu.inc"
+%include "boot/loader/mem/structures.inc"
[BITS 32]
-[global _start]
-[ORG 0x100000] ; Where GRUB loads us.
+[global MB_start]
-%include "boot/loader/multiboot/header.inc"
-
-;; NORMAL ENTRY POINT, BUT A LITTLE BIT UNUSED SINCE WE NEVER USE IT BECAUSE...
-_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
- xor dl, dl
- jmp 0x0000:_loader ; pas sûr
+[section .multiboot]
;; MAGNIFICENT MULTIBOOT HEADER FOR GRUB ------------------------------------ ;;
MB_header:
- align 4
+ 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
-;; MULTIBOOT POINT ENTRY FOR GRUB ------------------------------------------- ;;
+[section .text]
+
+;;MULTIBOOT POINT ENTRY FOR GRUB ------------------------------------------- ;;
MB_start:
mov esp, KERNEL_STACK ; Setup the stack
push 0 ; Reset EFLAGS
@@ -65,30 +58,29 @@ MB_start:
jmp Die ; Aufwiedersehen
;; THE HOLES ---------------------------------------------------------------- ;;
-
; ---------------------------------------------------------------------------- ;
; Prints 'ERR:XX' where 'XX' is the str in AX ;
; ---------------------------------------------------------------------------- ;
Error:
- mov dword [0xb8000], 0x4f524f45
- mov dword [0xb8004], 0x4f3a4f52
- mov dword [0xb8008], 0x4f204f20
- mov byte [0xb800a], al
- mov byte [0xb800c], ah
- mov byte [0xb800d], 0x4f
+ mov word [CODE], ax
+ push esi
+ mov bl, 0x0c
+ mov esi, ERGO
+ call write32
+ pop esi
jmp Die
-
+ERGO : db 219, 219, 219, " Error "
+CODE : db "00"
+ db 0x0
; ---------------------------------------------------------------------------- ;
; Kills the mind of your computer to get it prostrated ;
; ---------------------------------------------------------------------------- ;
Die:
cli
hlt ; die nooooow
- ;jmp 0xF000:0xFFF0
jmp $
;; THE CODE ----------------------------------------------------------------- ;;
-
; ---------------------------------------------------------------------------- ;
; _loader ;
; ;
@@ -103,10 +95,7 @@ Die:
_loader:
jmp lbegin
-%include "boot/loader/multiboot/check.inc"
-%include "boot/loader/cpu/cpuid.inc"
-%include "boot/loader/mem/structures.inc"
-%include "boot/loader/mem/management.inc"
+LOGO: db 219, 219, 219, " OS/K", 0
lbegin:
call MB_check
@@ -118,18 +107,24 @@ lbegin:
call Setup_paging
call Go64
+ push esi
+ mov bl, 0x0E
+ mov esi, LOGO
+ call write32
+ pop esi
+
+ call disable_cursor
+
lgdt [GDT64.pointer]
- jmp GDT64.code:l64
+ jmp GDT64.code:_loader64
[BITS 64]
-%include "boot/loader/io/terminal.inc"
-%include "boot/loader/io/ata.inc"
-%include "boot/loader/cpu/cpu.inc"
-Salut db 0x09, " Booting OS/K ", 0x09, 0x0A, 0x0D, 0x0
-ReadAttempt db 0x09, " Attempt to read a sector with ATA commands...", 0
-l64:
+Salut db "Now in x64 long mode", 0x0A, 0x0D, 0x0
+GoKernel db "Launching Kernel...", 0
+
+_loader64:
;; Some cleanup
mov ax, 0
mov ss, ax
@@ -138,6 +133,10 @@ l64:
mov fs, ax
mov gs, ax
+ call bitemporize
+
+ mov qword [NextTRAM], TRAM+80*4
+
;; Hello world
mov bl, 0x0A
mov esi, Salut
@@ -145,16 +144,14 @@ l64:
;; Read ATA
mov bl, 0x0F
- mov esi, ReadAttempt
+ mov esi, GoKernel
call write
- call temporize
+ ;mov ecx, 4000
+ call tritemporize
+ extern StartKern
+ jmp StartKern
- ;; Reading a sector of the disk
- mov bl, 1
- mov bh, 1
- call ata_read
-
jmp Die
diff --git a/boot/loader/mem/management.inc b/boot/loader/mem/management.inc
index 57f86d7..876d2fe 100644
--- a/boot/loader/mem/management.inc
+++ b/boot/loader/mem/management.inc
@@ -31,25 +31,25 @@
Setup_paging:
;; Map the first PML4 entry to PDP table
mov eax, PDP_table
- or eax, 0b11 ; present + writable
+ or eax, 1 << 1 | 1 << 0 ; present + writable
mov [PML4_table], eax
;; Map the first PDP entry to PD table
mov eax, PD_table
- or eax, 0b11 ; present + writable
+ or eax, 1 << 1 | 1 << 0 ; present + writable
mov [PDP_table], eax
;; Map each PD entry to a 'huge' 2MiB page
- mov ecx, 0 ; counter variable
+ mov ecx, 0x0 ; counter variable
.map_p2_table:
;; map ecx-th PD entry to a huge page that starts at address 2MiB*ecx
mov eax, 0x200000
- mul ecx ; start address of ecx-th page
- or eax, 0b10000011 ; present + writable + huge
+ mul ecx ; start address of ecx-th page
+ or eax, 1 << 7 | 1 << 1 | 1 << 0 ; present + writable + huge
mov [PD_table + ecx * 8], eax
inc ecx
- cmp ecx, 512 ; if counter == 512, the whole PD table is mapped
- jne .map_p2_table ; else map the next entry
+ cmp ecx, 512 ; PD table is mapped if 512
+ jne .map_p2_table ; else map the next entry
ret
@@ -61,24 +61,24 @@ Go64:
;; Registering paging
mov eax, PML4_table
- mov cr3, eax ; Load PML4 to cr3
+ mov cr3, eax ; Load PML4 to cr3
mov eax, cr4
or eax, 1 << 5
- mov cr4, eax ; Enable PAE
+ mov cr4, eax ; Enable PAE
;; Activate long mode
- mov ecx, 0xC0000080 ; address of MSR
- rdmsr ; read MSR
- or eax, 1 << 8 ; LME = 1. (Long Mode Enable)
- wrmsr ; write MSR
+ mov ecx, 0xC0000080 ; Address of MSR
+ rdmsr ; Read MSR
+ or eax, 1 << 8 ; LME = 1. (Long Mode Enable)
+ wrmsr ; Write MSR
;; Enable paging
mov eax, cr0
- or eax, 1 << 31 ; make MSR bit 31 (PG = Paging) to 1 :
- ; |1|000000000000000000000000000000
- ; |
- ; `------ Paging bit
+ or eax, 1 << 31 ; Make MSR bit 31 (PG = Paging) to 1 :
+ ; |1|000000000000000000000000000000
+ ; |
+ ; `------ Paging bit
mov cr0, eax
jmp .end
nop
@@ -93,16 +93,16 @@ Go64:
; ---------------------------------------------------------------------------- ;
CheckA20:
pushad
- mov edi,0x112345 ;odd megabyte address.
- mov esi,0x012345 ;even megabyte address.
- mov [esi],esi ;making sure that both addresses contain diffrent values.
- mov [edi],edi ;(if A20 line is cleared the two pointers would point to the address 0x012345 that would contain 0x112345 (edi))
- cmpsd ;compare addresses to see if the're equivalent.
+ mov edi, 0x112345 ; Odd megabyte address.
+ mov esi, 0x012345 ; Even megabyte address.
+ mov [esi],esi ; Making sure that both addresses contain diffrent values.
+ mov [edi],edi ; (if A20 line is cleared the two pointers would point to the address 0x012345 that would contain 0x112345 (edi))
+ cmpsd ; Compare addresses to see if the're equivalent.
popad
- jne .A20_on ;if not equivalent , A20 line is set.
+ jne .A20_on ; If not equivalent , A20 line is set.
jmp .A20_err
.A20_on:
ret
.A20_err:
- mov ax, "03" ; ERROR 03 : A20 line failed
+ mov ax, "04" ; ERROR 04 : A20 line failed
jmp Error
diff --git a/boot/loader/mem/structures.inc b/boot/loader/mem/structures.inc
index e1be0bd..4b92e56 100644
--- a/boot/loader/mem/structures.inc
+++ b/boot/loader/mem/structures.inc
@@ -24,7 +24,7 @@
;=----------------------------------------------------------------------------=;
[BITS 32]
-
+section .rodata
;; GDT WITH DOC
ALIGN 4096
GDT64:
@@ -44,6 +44,7 @@ GDT64:
dq GDT64
;; EMPTY PAGE TABLES (identity of the first 1GiB)
+section .bss
ALIGN 4096
PML4_table:
resb 4096
@@ -51,3 +52,4 @@ PDP_table:
resb 4096
PD_table:
resb 4096
+
diff --git a/boot/loader/multiboot/header.inc b/boot/loader/multiboot/header.inc
index 8688c28..be4e105 100644
--- a/boot/loader/multiboot/header.inc
+++ b/boot/loader/multiboot/header.inc
@@ -24,11 +24,11 @@
;=----------------------------------------------------------------------------=;
;; MULTIBOOT HEADER
-MB_AOUT_KLUDGE equ 1 << 16 ; We are not an ELF executable
-MB_ALIGN equ 1 << 0 ; Ask to align loaded modules on page boundaries
+MB_AOUT_KLUDGE equ 0 << 16 ; if we are not an ELF executable
+MB_ALIGN equ 0 << 0 ; Ask to align loaded modules on page boundaries
MB_MEMINFO equ 1 << 1 ; Ask to provide memory map
MB_HEADER_MAGIC equ 0x1badb002
MB_GRUB_MAGIC equ 0x2badb002
-MB_HEADER_FLAGS equ MB_AOUT_KLUDGE|MB_ALIGN|MB_MEMINFO
+MB_HEADER_FLAGS equ 0x0 ; MB_AOUT_KLUDGE|MB_ALIGN|MB_MEMINFO
CHECKSUM equ -(MB_HEADER_MAGIC + MB_HEADER_FLAGS)
KERNEL_STACK equ 0x00200000 ; Stack starts at the 2mb address & grows down
diff --git a/build/obj/kaleid/common/.placeholder b/build/bin/.placeholder
similarity index 100%
rename from build/obj/kaleid/common/.placeholder
rename to build/bin/.placeholder
diff --git a/build/bin/comm-test b/build/bin/comm-test
deleted file mode 100755
index ea0cd8f..0000000
Binary files a/build/bin/comm-test and /dev/null differ
diff --git a/build/kernel.ld b/build/kernel.ld
index 34408e0..ea46357 100644
--- a/build/kernel.ld
+++ b/build/kernel.ld
@@ -1,44 +1,68 @@
-ENTRY(StartKern)
-SECTIONS
-{
- . = 1M;
+/*----------------------------------------------------------------------------//
+// GNU GPL OS/K //
+// //
+// Desc: OS/K KERNEL LINKER //
+// (x86_64 architecture only) //
+// //
+// //
+// 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 . //
+//----------------------------------------------------------------------------*/
- .text : AT(ADDR(.text) - 1M)
+
+ENTRY(MB_start) /* the name of the entry label */
+
+SECTIONS {
+ . = 0x00100000; /* the code should be loaded at 1 MB */
+
+ .boot ALIGN (0x1000) : /* align at 4 KB */
{
- _code = .;
- *(.text)
- *(.rodata*)
- . = ALIGN(4096);
+ *(.multiboot)
}
- .data : AT(ADDR(.data) - 1M)
- {
- _data = .;
- *(.data)
- . = ALIGN(4096);
- }
+ .text ALIGN (0x1000) : /* align at 4 KB */
+ {
+ *(.text) /* all text sections from all files */
+ }
- .eh_frame : AT(ADDR(.eh_frame) - 1M)
- {
- _ehframe = .;
- *(.eh_frame)
- . = ALIGN(4096);
- }
+ .data ALIGN (0x1000) :
+ {
+ _data = .;
+ *(.data)
+ }
- .bss : AT(ADDR(.bss) - 1M)
- {
- _bss = .;
- *(.bss)
+ .eh_frame ALIGN (0x1000) :
+ {
+ _ehframe = .;
+ *(.eh_frame)
+ }
- *(COMMON)
- . = ALIGN(4096);
- }
+ .bss ALIGN (0x1000) : /* align at 4 KB */
+ {
+ *(.bss) /* all bss sections from all files */
+ }
- _end = .;
+ .rodata ALIGN (0x1000) : /* align at 4 KB */
+ {
+ *(.rodata) /* all rodata sections from all files */
+ }
- /DISCARD/ :
- {
+ /DISCARD/ :
+ {
*(.comment)
- }
+ }
}
-
diff --git a/build/obj/kaleid/crtlib/.placeholder b/build/obj/boot/.placeholder
similarity index 100%
rename from build/obj/kaleid/crtlib/.placeholder
rename to build/obj/boot/.placeholder
diff --git a/build/obj/boot/loader.bin b/build/obj/boot/loader.bin
deleted file mode 100644
index aa06194..0000000
Binary files a/build/obj/boot/loader.bin and /dev/null differ
diff --git a/build/obj/boot/mbr.bin b/build/obj/boot/mbr.bin
deleted file mode 100644
index 37ff74f..0000000
Binary files a/build/obj/boot/mbr.bin and /dev/null differ
diff --git a/build/obj/kaleid/common/test/.paceholder b/build/obj/kaleid/common/test/.placeholder
similarity index 100%
rename from build/obj/kaleid/common/test/.paceholder
rename to build/obj/kaleid/common/test/.placeholder
diff --git a/build/obj/kaleid/crtlib/test/.paceholder b/build/obj/kaleid/crtlib/test/.placeholder
similarity index 100%
rename from build/obj/kaleid/crtlib/test/.paceholder
rename to build/obj/kaleid/crtlib/test/.placeholder
diff --git a/boot/loader/io/ata.inc b/kaleid/kernel/io/ata.inc
similarity index 98%
rename from boot/loader/io/ata.inc
rename to kaleid/kernel/io/ata.inc
index c37cfc6..9802449 100644
--- a/boot/loader/io/ata.inc
+++ b/kaleid/kernel/io/ata.inc
@@ -139,7 +139,6 @@ still_going:
mov dx, 0x1f0 ; Data port - data comes in and out of here.
rep insw
pop rdi
-%ifdef DEBUG
mov bl, 0x0F
mov esi, buffer
call dump
@@ -147,11 +146,6 @@ still_going:
mov esi, ended
call write
add qword [NextTRAM], 120 ; Cursor moving : 1120 = 80 * 2 * 7 lignes
-%else
- mov bl, 0x0A
- mov esi, Pass
- call write
-%endif
pop rdx
pop rcx
pop rbx