summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--Makefile10
-rw-r--r--Readme.md7
-rw-r--r--bootloader/Makefile3
-rw-r--r--bootloader/bootloader.asm28
-rw-r--r--bootloader/clearScreenIntBios.asm30
-rw-r--r--bootloader/printIntBios.asm27
-rw-r--r--bootloader/resetCursorPosIntBios.asm21
-rw-r--r--kernel/Makefile5
9 files changed, 122 insertions, 10 deletions
diff --git a/.gitignore b/.gitignore
index 2fee82c..cddf862 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,3 @@
*.bin
+PiegOS
Untracked
diff --git a/Makefile b/Makefile
index d57ab2f..02b8066 100644
--- a/Makefile
+++ b/Makefile
@@ -1,11 +1,11 @@
-PiegOS: bootloader/bootloader.bin
- cp $< ./$@
+PiegOS: kernel/kernel.bin
+ cp kernel/kernel.bin ./PiegOS
-bootloader/bootloader.bin: bootloader/Makefile
- cd bootloader && make
+kernel/kernel.bin:
+ cd kernel/ && make
clean:
- cd bootloader && make clean
+ cd kernel && make clean
rm PiegOS
diff --git a/Readme.md b/Readme.md
index 4ba7f66..522082c 100644
--- a/Readme.md
+++ b/Readme.md
@@ -17,8 +17,11 @@
##Comment utilisé le Noyaux Générer ?
-> Un fichier PiegOS est créer à la racine du projet si la compilation c'est bien déroulée. Il n'y a plus qu'à le copier sur un support ou
-à le lancer dans une machine virtuelle.
+> Un fichier PiegOS est créer à la racine du projet aprés l'éxécution de make. Il n'y a plus qu'à charger ce fichier à l'aide d'un chargeur d'amorçage (Grub, LILO etc..).
+
+##Notes
+
+> Le bootloader n'est présent qu'à titre informatif. Pour le lancer, il suffit de le placer au premier secteur du support de boot.
##Suite en construction...
diff --git a/bootloader/Makefile b/bootloader/Makefile
index 9cb2ec5..7fb8173 100644
--- a/bootloader/Makefile
+++ b/bootloader/Makefile
@@ -1,8 +1,7 @@
-
bootloader.bin: bootloader.asm
- nasm -f bin -o $@ $^
+ nasm -f bin -o $@ $<
clean:
rm bootloader.bin
diff --git a/bootloader/bootloader.asm b/bootloader/bootloader.asm
index 25b9a46..f1bb48a 100644
--- a/bootloader/bootloader.asm
+++ b/bootloader/bootloader.asm
@@ -4,10 +4,36 @@
;Save the first adress with a label to complete the MBR at the end.
start:
+;Include bios routines and jump to skip including code
+jmp skipInc
+%include "clearScreenIntBios.asm"
+%include "printIntBios.asm"
+skipInc:
+
;Init CPU registers
-mov ax, 0x0C70 ;Put bootloader adress in ax register
+mov ax, 0x07C0 ;Put bootloader adress in ax register
mov ds, ax ;Init data segment
+;Init stack from 0x80000 to 0x8f000
+mov ax, 0x8000
+mov ss, ax ;Set stack segment
+mov ax, 0x0f00
+mov sp, ax ;Set stack offset
+
+;Clear the screen
+call clearScreenIntBios
+
+;Print msg
+mov si, helloBootloader ;load msg in si register
+call printIntBios ;print the msg
+
+;Pause here !
+infiniteLoop:
+ jmp infiniteLoop
+
+;Define data
+helloBootloader db "PiegOS bootloader successfully running !", 0
+
;Complete the MBR with nothing
times 510 - ($ - start) db 0x0
diff --git a/bootloader/clearScreenIntBios.asm b/bootloader/clearScreenIntBios.asm
new file mode 100644
index 0000000..4739430
--- /dev/null
+++ b/bootloader/clearScreenIntBios.asm
@@ -0,0 +1,30 @@
+clearScreenIntBios:
+
+ ;Save registers
+ push ax
+ push bx
+ push cx
+ push dx
+
+ mov ax, 0x0600 ;Clear
+ mov bx, 0x0F00 ;Color black behind white foreground
+
+ mov cx, 0x0000 ;Top left corner
+ mov dx, 0x5050 ;Bottom right corner 80x80
+
+ int 0x10 ;Clear the screen
+
+ ;Restore registers
+ pop dx
+ pop cx
+ pop bx
+ pop ax
+
+ ;Reset Cursor Position
+ call resetCursorPosIntBios
+
+ ;Back to previous task
+ ret
+
+;Include resetCursorPosIntBios
+%include "resetCursorPosIntBios.asm"
diff --git a/bootloader/printIntBios.asm b/bootloader/printIntBios.asm
new file mode 100644
index 0000000..2a6c735
--- /dev/null
+++ b/bootloader/printIntBios.asm
@@ -0,0 +1,27 @@
+printIntBios:
+
+ ;Save registers
+ push ax
+ push bx
+
+ ;Print loop
+ .loop:
+
+ mov ah, 0x0E ;Use 0xE bios service for teletype print
+ lodsb ;Load char in al and inc SI register
+ cmp al, 0x0 ;Check if we print all the chain
+ je .end ;If yes go to end
+
+ mov bl, 0x0F ;Else set color register
+
+ int 0x10 ;And print the character
+
+ jmp .loop ;Go to the next character
+ .end:
+
+ ;Restore registers
+ pop bx
+ pop ax
+
+ ;Back to previous task
+ ret
diff --git a/bootloader/resetCursorPosIntBios.asm b/bootloader/resetCursorPosIntBios.asm
new file mode 100644
index 0000000..18cb0d2
--- /dev/null
+++ b/bootloader/resetCursorPosIntBios.asm
@@ -0,0 +1,21 @@
+resetCursorPosIntBios:
+
+ ;Save registers
+ push ax
+ push bx
+ push dx
+
+ mov ax, 0x0200 ;Move cursor interrupt
+ mov bx, 0x0000 ; X position
+ mov dx, 0x0000 ; Y Position
+
+ ;Call 0x10 interrupt service
+ int 0x10
+
+ ;Restore registers
+ pop dx
+ pop bx
+ pop ax
+
+ ;Back to previous task
+ ret
diff --git a/kernel/Makefile b/kernel/Makefile
new file mode 100644
index 0000000..0550f6d
--- /dev/null
+++ b/kernel/Makefile
@@ -0,0 +1,5 @@
+kernel.bin:
+ touch kernel.bin
+
+clean:
+ rm kernel.bin