diff --git a/Makefile b/Makefile index cb4500f..37b89cd 100644 --- a/Makefile +++ b/Makefile @@ -28,7 +28,7 @@ ASM=nasm LD=ld ASMFLAGS=-f elf64 -LDFLAGS= -melf_x86_64 +LDFLAGS=-melf_x86_64 #Folders MBRDIR=boot/grub @@ -58,7 +58,7 @@ l_objects=./build/obj/kaleid/crtlib/memory.o \ #Color codes CL='\033[0;32m' -CL2='\033[1;31m' +CL2='\033[1;36m' CL3='\033[0m' NC='\033[1;37m' @@ -108,12 +108,16 @@ make_disk: @$(MBRDIR)/create_disk.sh $(BINDIR)/disk.img @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 32 > loader_disasm32.asm +<<<<<<< HEAD test32: kernel loader 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 @@ -121,13 +125,22 @@ test32: 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 & +======= +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 32 > loader_disasm32.asm boot: make_disk boot.mbr @echo ${CL2}[[boot]]${CL} Terminated without error.${CL3} -all: boot kernel loader +all: boot kaleid @echo ${CL2}[[all]]${CL} Terminated without error.${CL3} link: diff --git a/Readme.md b/Readme.md index bf2f16d..566c708 100644 --- a/Readme.md +++ b/Readme.md @@ -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 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 +``` diff --git a/boot/grub/grub-install.sh b/boot/grub/grub-install.sh index 44d591f..cd76028 100755 --- a/boot/grub/grub-install.sh +++ b/boot/grub/grub-install.sh @@ -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} ## Mount +if [ -e $2/boot ]  +then + sudo umount $2 > /dev/null +fi sudo mount /dev/loop1 $2 > /dev/null echo ${CL2}[grub-install.sh]${NC} Installing grub... \(grub-install\)${CL3} diff --git a/boot/grub/umount.sh b/boot/grub/umount.sh index 78bfa66..0948aba 100755 --- a/boot/grub/umount.sh +++ b/boot/grub/umount.sh @@ -29,7 +29,8 @@ CL3='\033[0m' NC='\033[1;37m' set -e #exit if error -sleep 3 +sync +sleep 1 echo ${CL2}[umount.sh]${NC} Unmounting volume... \(umount\)${CL3} sudo umount $1 echo ${CL2}[umount.sh]${NC} Unmounting image... \(losetup\)${CL3} diff --git a/boot/loader/cpu/cpu.inc b/boot/loader/cpu/cpu.inc index 1dc5158..8b92819 100644 --- a/boot/loader/cpu/cpu.inc +++ b/boot/loader/cpu/cpu.inc @@ -55,3 +55,9 @@ tritemporize: loop .looping pop rcx ret + + +; ---------------------------------------------------------------------------- ; +; Returns the CPU Vendor String.pointer in eax ; +; ---------------------------------------------------------------------------- ; +cpu_vendor diff --git a/boot/loader/cpu/cpuid.inc b/boot/loader/cpu/cpu32.inc similarity index 100% rename from boot/loader/cpu/cpuid.inc rename to boot/loader/cpu/cpu32.inc diff --git a/boot/loader/loader.asm b/boot/loader/loader.asm index 8e30929..0ddf7b6 100644 --- a/boot/loader/loader.asm +++ b/boot/loader/loader.asm @@ -25,7 +25,7 @@ %include "boot/loader/multiboot/header.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/io/terminal.inc" %include "boot/loader/cpu/cpu.inc" @@ -69,7 +69,7 @@ Error: call write32 pop esi jmp Die -ERGO : db 219, 219, 219, " Error " +ERGO : db "A", 219, 219, " Error " CODE : db "00" db 0x0 ; ---------------------------------------------------------------------------- ; @@ -117,7 +117,7 @@ lbegin: call write32 pop esi - call disable_cursor + ;call disable_cursor lgdt [GDT64.pointer] jmp GDT64.code:_loader64 ; SWITCH diff --git a/boot/loader/multiboot/header.inc b/boot/loader/multiboot/header.inc index be4e105..337d168 100644 --- a/boot/loader/multiboot/header.inc +++ b/boot/loader/multiboot/header.inc @@ -25,7 +25,7 @@ ;; MULTIBOOT HEADER 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_HEADER_MAGIC equ 0x1badb002 MB_GRUB_MAGIC equ 0x2badb002 diff --git a/boot/grub/include/multiboot.h b/kaleid/include/multiboot/multiboot.h similarity index 99% rename from boot/grub/include/multiboot.h rename to kaleid/include/multiboot/multiboot.h index b181607..2c93a2a 100644 --- a/boot/grub/include/multiboot.h +++ b/kaleid/include/multiboot/multiboot.h @@ -245,7 +245,7 @@ struct multiboot_tag_mmap multiboot_uint32_t size; multiboot_uint32_t entry_size; multiboot_uint32_t entry_version; - struct multiboot_mmap_entry entries[0]; + struct multiboot_mmap_entry entries[0]; }; struct multiboot_vbe_info_block @@ -389,7 +389,7 @@ struct multiboot_tag_efi_mmap multiboot_uint32_t descr_size; multiboot_uint32_t descr_vers; multiboot_uint8_t efi_mmap[0]; -}; +}; struct multiboot_tag_efi32_ih { diff --git a/kaleid/kernel/init/init.c b/kaleid/kernel/init/init.c index 961e55d..bda40a5 100644 --- a/kaleid/kernel/init/init.c +++ b/kaleid/kernel/init/init.c @@ -21,13 +21,14 @@ // You should have received a copy of the GNU General Public License // // along with OS/K. If not, see . // //----------------------------------------------------------------------------// - +#include #include #include // // Entry point of the Kaleid kernel // + noreturn void StartKern(void *mbInfo, int mbMagic) { (void)mbInfo; @@ -41,9 +42,9 @@ noreturn void StartKern(void *mbInfo, int mbMagic) *vga++ = 'AA'; // Kernel terminals - InitTerms(); + //InitTerms(); // We're out - StartPanic("Goodbye World :("); + //StartPanic("Goodbye World :("); }