From 8cf063d3bf8fef38cc87d9d6b722d74a7bc4bd0a Mon Sep 17 00:00:00 2001 From: Adrien Bourmault Date: Fri, 8 Mar 2019 21:15:10 +0100 Subject: [PATCH 01/12] Enabling cursor blinking --- boot/loader/loader.asm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/boot/loader/loader.asm b/boot/loader/loader.asm index 8e30929..c1cd9ac 100644 --- a/boot/loader/loader.asm +++ b/boot/loader/loader.asm @@ -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 From 815b2ac47909ad8676667f87057aac2517aaafca Mon Sep 17 00:00:00 2001 From: Adrien Bourmault Date: Fri, 8 Mar 2019 21:56:01 +0100 Subject: [PATCH 02/12] from multiboot to kernel --- boot/loader/multiboot/header.inc | 2 +- {boot/grub/include => kaleid/include/multiboot}/multiboot.h | 4 ++-- kaleid/kernel/init/init.c | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) rename {boot/grub/include => kaleid/include/multiboot}/multiboot.h (99%) 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 c50108a..5dbbdcd 100644 --- a/kaleid/kernel/init/init.c +++ b/kaleid/kernel/init/init.c @@ -21,14 +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* multibooot_info, int multiboot_magic) +noreturn void StartKern(void* mbt, unsigned int mb_magic) { // We're not ready to deal with interrupts DisableIRQs(); From ec33a70acd6b528fca446074c524467f99fe6eea Mon Sep 17 00:00:00 2001 From: Adrien Bourmault Date: Sat, 9 Mar 2019 20:40:32 +0100 Subject: [PATCH 03/12] Changing color because red is for errors --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 0dc4347..1c96a8d 100644 --- a/Makefile +++ b/Makefile @@ -41,7 +41,7 @@ l_objects=./build/obj/kaleid/crtlib/memory.o ./build/obj/kaleid/crtlib/rand.o ./ #Color codes CL='\033[0;32m' -CL2='\033[1;31m' +CL2='\033[1;36m' CL3='\033[0m' NC='\033[1;37m' From 476b30fb20306057d1848fa78a4c4964faa7af72 Mon Sep 17 00:00:00 2001 From: Adrien Bourmault Date: Sat, 9 Mar 2019 20:44:36 +0100 Subject: [PATCH 04/12] Enhancing speed for compilation --- boot/grub/umount.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/boot/grub/umount.sh b/boot/grub/umount.sh index 78bfa66..cf8035b 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 +#sleep 3 +sync echo ${CL2}[umount.sh]${NC} Unmounting volume... \(umount\)${CL3} sudo umount $1 echo ${CL2}[umount.sh]${NC} Unmounting image... \(losetup\)${CL3} From 2b8ebc6c573ea4cb88eda0ffe31172ffd4ab4b3b Mon Sep 17 00:00:00 2001 From: Adrien Bourmault Date: Sat, 9 Mar 2019 21:46:09 +0100 Subject: [PATCH 05/12] little reorganization --- boot/loader/cpu/cpu.inc | 6 ++++++ boot/loader/cpu/{cpuid.inc => cpu32.inc} | 0 boot/loader/loader.asm | 4 ++-- 3 files changed, 8 insertions(+), 2 deletions(-) rename boot/loader/cpu/{cpuid.inc => cpu32.inc} (100%) 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 c1cd9ac..ed1b828 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" @@ -152,7 +152,7 @@ _loader64: call tritemporize ; Let time to see extern StartKern - jmp StartKern + ;jmp StartKern ;; We must never reach this point ------------------------------------------- ;; jmp Die From 94f51b9f12d9c775cce86162a85ce00a39bc592a Mon Sep 17 00:00:00 2001 From: Adrien Bourmault Date: Sat, 9 Mar 2019 21:47:35 +0100 Subject: [PATCH 06/12] little reorganization --- boot/loader/loader.asm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/boot/loader/loader.asm b/boot/loader/loader.asm index ed1b828..0ddf7b6 100644 --- a/boot/loader/loader.asm +++ b/boot/loader/loader.asm @@ -152,7 +152,7 @@ _loader64: call tritemporize ; Let time to see extern StartKern - ;jmp StartKern + jmp StartKern ;; We must never reach this point ------------------------------------------- ;; jmp Die From 3317fe0db568e08ffb19254c43568a87c446e106 Mon Sep 17 00:00:00 2001 From: Adrien Bourmault Date: Sat, 9 Mar 2019 22:22:57 +0100 Subject: [PATCH 07/12] Update Readme.md --- Readme.md | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/Readme.md b/Readme.md index bf2f16d..950387d 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 [OS/K 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 +``` From f4e9072e6e01c662f2331f6373ea7bc3871764f1 Mon Sep 17 00:00:00 2001 From: Adrien Bourmault Date: Sat, 9 Mar 2019 22:29:30 +0100 Subject: [PATCH 08/12] makefile update --- Makefile | 6 ++++-- boot/loader/loader.asm | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 1c96a8d..2662a08 100644 --- a/Makefile +++ b/Makefile @@ -91,13 +91,15 @@ make_disk: @$(MBRDIR)/create_disk.sh $(BINDIR)/disk.img @echo ${CL2}[make_disk]${CL} OK${CL3} -test: kernel loader +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 -test32: kernel loader +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 diff --git a/boot/loader/loader.asm b/boot/loader/loader.asm index 0ddf7b6..ed1b828 100644 --- a/boot/loader/loader.asm +++ b/boot/loader/loader.asm @@ -152,7 +152,7 @@ _loader64: call tritemporize ; Let time to see extern StartKern - jmp StartKern + ;jmp StartKern ;; We must never reach this point ------------------------------------------- ;; jmp Die From 5167e15b6d0b1a20f8593d427ca8dd2b98a6ea38 Mon Sep 17 00:00:00 2001 From: Adrien Bourmault Date: Sat, 9 Mar 2019 22:29:42 +0100 Subject: [PATCH 09/12] makefile update --- boot/loader/loader.asm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/boot/loader/loader.asm b/boot/loader/loader.asm index ed1b828..0ddf7b6 100644 --- a/boot/loader/loader.asm +++ b/boot/loader/loader.asm @@ -152,7 +152,7 @@ _loader64: call tritemporize ; Let time to see extern StartKern - ;jmp StartKern + jmp StartKern ;; We must never reach this point ------------------------------------------- ;; jmp Die From fba9a3fc7717d1b3f8bd649f07cbdefa26041f5a Mon Sep 17 00:00:00 2001 From: Adrien Bourmault Date: Sat, 9 Mar 2019 22:30:33 +0100 Subject: [PATCH 10/12] makefile update --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 2662a08..9383282 100644 --- a/Makefile +++ b/Makefile @@ -104,7 +104,7 @@ test32: kaleid @ndisasm $(BINDIR)/kaleid -o 0x00100000 -b 64 > loader_disasm64.asm @ndisasm $(BINDIR)/kaleid -o 0x00100000 -b 32 > loader_disasm32.asm -debug: kernel loader +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 & @ndisasm $(BINDIR)/kaleid -o 0x00100000 -b 64 > loader_disasm64.asm @ndisasm $(BINDIR)/kaleid -o 0x00100000 -b 32 > loader_disasm32.asm @@ -112,7 +112,7 @@ debug: kernel loader 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: From d92266ae34d5776668499027fe285ac6b1db2088 Mon Sep 17 00:00:00 2001 From: Adrien Bourmault Date: Mon, 11 Mar 2019 13:25:34 +0100 Subject: [PATCH 11/12] Update Readme.md --- Readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Readme.md b/Readme.md index 950387d..566c708 100644 --- a/Readme.md +++ b/Readme.md @@ -23,7 +23,7 @@ apt update && apt upgrade apt install grub-pc dosfstools make nasm ``` -You also need to have the [OS/K cross-compiler](https://www.os-k.eu/build-tools/cross-cc.tar.xz) in `/opt/cross-cc`. +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 : From df32ae0a1a7236efc31bc26e0ff42840969899e1 Mon Sep 17 00:00:00 2001 From: Adrien Bourmault Date: Mon, 11 Mar 2019 14:12:23 +0100 Subject: [PATCH 12/12] stuff --- Makefile | 2 +- boot/grub/grub-install.sh | 4 ++++ boot/grub/umount.sh | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 9383282..7403716 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 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 cf8035b..0948aba 100755 --- a/boot/grub/umount.sh +++ b/boot/grub/umount.sh @@ -29,8 +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}