This commit is contained in:
Adrien Bourmault 2019-03-11 14:15:40 +01:00
commit 57f83d0a6c
10 changed files with 63 additions and 15 deletions

View File

@ -28,7 +28,7 @@
ASM=nasm ASM=nasm
LD=ld LD=ld
ASMFLAGS=-f elf64 ASMFLAGS=-f elf64
LDFLAGS= -melf_x86_64 LDFLAGS=-melf_x86_64
#Folders #Folders
MBRDIR=boot/grub MBRDIR=boot/grub
@ -58,7 +58,7 @@ l_objects=./build/obj/kaleid/crtlib/memory.o \
#Color codes #Color codes
CL='\033[0;32m' CL='\033[0;32m'
CL2='\033[1;31m' CL2='\033[1;36m'
CL3='\033[0m' CL3='\033[0m'
NC='\033[1;37m' NC='\033[1;37m'
@ -108,12 +108,16 @@ make_disk:
@$(MBRDIR)/create_disk.sh $(BINDIR)/disk.img @$(MBRDIR)/create_disk.sh $(BINDIR)/disk.img
@echo ${CL2}[make_disk]${CL} OK${CL3} @echo ${CL2}[make_disk]${CL} OK${CL3}
test: kernel loader
qemu-system-x86_64 -hda build/bin/disk.img -d cpu_reset,guest_errors,pcall,int -enable-kvm 2> qemu.log & kaleid: kernel loader
test: kaleid
@qemu-system-x86_64 -hda build/bin/disk.img -d cpu_reset,guest_errors,pcall,int -enable-kvm 2> qemu.log &
@ndisasm $(BINDIR)/kaleid -o 0x00100000 -b 64 > loader_disasm64.asm @ndisasm $(BINDIR)/kaleid -o 0x00100000 -b 64 > loader_disasm64.asm
@ndisasm $(BINDIR)/kaleid -o 0x00100000 -b 32 > loader_disasm32.asm @ndisasm $(BINDIR)/kaleid -o 0x00100000 -b 32 > loader_disasm32.asm
<<<<<<< HEAD
test32: kernel loader test32: kernel loader
qemu-system-i386 -hda build/bin/disk.img -d cpu_reset,guest_errors,pcall,int -enable-kvm 2> qemu.log & qemu-system-i386 -hda build/bin/disk.img -d cpu_reset,guest_errors,pcall,int -enable-kvm 2> qemu.log &
@ndisasm $(BINDIR)/kaleid -o 0x00100000 -b 64 > loader_disasm64.asm @ndisasm $(BINDIR)/kaleid -o 0x00100000 -b 64 > loader_disasm64.asm
@ -121,13 +125,22 @@ test32: kernel loader
debug: kernel loader debug: kernel loader
qemu-system-x86_64 -hda build/bin/disk.img -d cpu_reset,guest_errors,pcall,int -s -S -enable-kvm 2> qemu.log & qemu-system-x86_64 -hda build/bin/disk.img -d cpu_reset,guest_errors,pcall,int -s -S -enable-kvm 2> qemu.log &
=======
test32: kaleid
@qemu-system-i386 -hda build/bin/disk.img -d cpu_reset,guest_errors,pcall,int -enable-kvm 2> qemu.log &
@ndisasm $(BINDIR)/kaleid -o 0x00100000 -b 64 > loader_disasm64.asm
@ndisasm $(BINDIR)/kaleid -o 0x00100000 -b 32 > loader_disasm32.asm
debug: kaleid
@qemu-system-x86_64 -hda build/bin/disk.img -d cpu_reset,guest_errors,pcall,int -s -S -enable-kvm 2> qemu.log &
>>>>>>> master
@ndisasm $(BINDIR)/kaleid -o 0x00100000 -b 64 > loader_disasm64.asm @ndisasm $(BINDIR)/kaleid -o 0x00100000 -b 64 > loader_disasm64.asm
@ndisasm $(BINDIR)/kaleid -o 0x00100000 -b 32 > loader_disasm32.asm @ndisasm $(BINDIR)/kaleid -o 0x00100000 -b 32 > loader_disasm32.asm
boot: make_disk boot.mbr boot: make_disk boot.mbr
@echo ${CL2}[[boot]]${CL} Terminated without error.${CL3} @echo ${CL2}[[boot]]${CL} Terminated without error.${CL3}
all: boot kernel loader all: boot kaleid
@echo ${CL2}[[all]]${CL} Terminated without error.${CL3} @echo ${CL2}[[all]]${CL} Terminated without error.${CL3}
link: link:

View File

@ -13,3 +13,26 @@ For structure of the sources, see [ProjectTree](ProjectTree)
Note that every file within OS/K is written using spaces for tabulation, with each Note that every file within OS/K is written using spaces for tabulation, with each
tabulation being 4 spaces long. tabulation being 4 spaces long.
#### Compile from sources
To compile this project from sources, you must first install the dependencies
```
apt update && apt upgrade
apt install grub-pc dosfstools make nasm
```
You also need to have the [x86-64 ELF gcc cross-compiler](https://www.os-k.eu/build-tools/cross-cc.tar.xz) in `/opt/cross-cc`.
To compile for the first time, you must compile the whole project, in order to build the loop disk image :
```
make all
```
After that, you can use this to compile the kernel only :
```
make kaleid
```

View File

@ -38,6 +38,10 @@ sudo losetup /dev/loop1 $1 -o 1048576 > /dev/null #mounting the logical partitio
echo ${CL2}[grub-install.sh]${NC} Mounting volume... \(mount\)${CL3} echo ${CL2}[grub-install.sh]${NC} Mounting volume... \(mount\)${CL3}
## Mount ## Mount
if [ -e $2/boot ] 
then
sudo umount $2 > /dev/null
fi
sudo mount /dev/loop1 $2 > /dev/null sudo mount /dev/loop1 $2 > /dev/null
echo ${CL2}[grub-install.sh]${NC} Installing grub... \(grub-install\)${CL3} echo ${CL2}[grub-install.sh]${NC} Installing grub... \(grub-install\)${CL3}

View File

@ -29,7 +29,8 @@ CL3='\033[0m'
NC='\033[1;37m' NC='\033[1;37m'
set -e #exit if error set -e #exit if error
sleep 3 sync
sleep 1
echo ${CL2}[umount.sh]${NC} Unmounting volume... \(umount\)${CL3} echo ${CL2}[umount.sh]${NC} Unmounting volume... \(umount\)${CL3}
sudo umount $1 sudo umount $1
echo ${CL2}[umount.sh]${NC} Unmounting image... \(losetup\)${CL3} echo ${CL2}[umount.sh]${NC} Unmounting image... \(losetup\)${CL3}

View File

@ -55,3 +55,9 @@ tritemporize:
loop .looping loop .looping
pop rcx pop rcx
ret ret
; ---------------------------------------------------------------------------- ;
; Returns the CPU Vendor String.pointer in eax ;
; ---------------------------------------------------------------------------- ;
cpu_vendor

View File

@ -25,7 +25,7 @@
%include "boot/loader/multiboot/header.inc" %include "boot/loader/multiboot/header.inc"
%include "boot/loader/multiboot/check.inc" %include "boot/loader/multiboot/check.inc"
%include "boot/loader/cpu/cpuid.inc" %include "boot/loader/cpu/cpu32.inc"
%include "boot/loader/mem/management.inc" %include "boot/loader/mem/management.inc"
%include "boot/loader/io/terminal.inc" %include "boot/loader/io/terminal.inc"
%include "boot/loader/cpu/cpu.inc" %include "boot/loader/cpu/cpu.inc"
@ -69,7 +69,7 @@ Error:
call write32 call write32
pop esi pop esi
jmp Die jmp Die
ERGO : db 219, 219, 219, " Error " ERGO : db "A", 219, 219, " Error "
CODE : db "00" CODE : db "00"
db 0x0 db 0x0
; ---------------------------------------------------------------------------- ; ; ---------------------------------------------------------------------------- ;
@ -117,7 +117,7 @@ lbegin:
call write32 call write32
pop esi pop esi
call disable_cursor ;call disable_cursor
lgdt [GDT64.pointer] lgdt [GDT64.pointer]
jmp GDT64.code:_loader64 ; SWITCH jmp GDT64.code:_loader64 ; SWITCH

View File

@ -25,7 +25,7 @@
;; MULTIBOOT HEADER ;; MULTIBOOT HEADER
MB_AOUT_KLUDGE equ 0 << 16 ; if we are not an ELF executable 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_ALIGN equ 1 << 0 ; Ask to align loaded modules on page boundaries
MB_MEMINFO equ 1 << 1 ; Ask to provide memory map MB_MEMINFO equ 1 << 1 ; Ask to provide memory map
MB_HEADER_MAGIC equ 0x1badb002 MB_HEADER_MAGIC equ 0x1badb002
MB_GRUB_MAGIC equ 0x2badb002 MB_GRUB_MAGIC equ 0x2badb002

View File

@ -21,13 +21,14 @@
// 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/>. //
//----------------------------------------------------------------------------// //----------------------------------------------------------------------------//
#include <multiboot/multiboot.h>
#include <kernel/term.h> #include <kernel/term.h>
#include <kernel/panic.h> #include <kernel/panic.h>
// //
// Entry point of the Kaleid kernel // Entry point of the Kaleid kernel
// //
noreturn void StartKern(void *mbInfo, int mbMagic) noreturn void StartKern(void *mbInfo, int mbMagic)
{ {
(void)mbInfo; (void)mbInfo;
@ -41,9 +42,9 @@ noreturn void StartKern(void *mbInfo, int mbMagic)
*vga++ = 'AA'; *vga++ = 'AA';
// Kernel terminals // Kernel terminals
InitTerms(); //InitTerms();
// We're out // We're out
StartPanic("Goodbye World :("); //StartPanic("Goodbye World :(");
} }