diff --git a/Makefile b/Makefile index 983840b..b3653f9 100644 --- a/Makefile +++ b/Makefile @@ -47,6 +47,7 @@ OBJDIR=build/obj KOBJDIR=build/obj/kaleid LOBJDIR=build/obj/boot BINDIR=build/bin +BUILDDIR=build #Color codes CL='\033[0;32m' @@ -192,23 +193,23 @@ $(KOBJDIR)/kernel/sched.o: $(KERNELDIR)/kernel/proc/sched.c $(KERNELDIR)/include .PHONY: test test: all - @qemu-system-x86_64 -m 5G -mem-prealloc -hda build/bin/disk.img \ - -d cpu_reset,guest_errors,pcall,int 2> qemu.log & + @qemu-system-x86_64 -m 5G -hda $(BUILDDIR)/bin/disk.img \ + -d cpu_reset,guest_errors,pcall,int 2> $(BUILDDIR)/qemu.log & .PHONY: test32 test32: all - @qemu-system-i386 -hda build/bin/disk.img -d cpu_reset,guest_errors,pcall,int 2> qemu.log & + @qemu-system-i386 -hda $(BUILDDIR)/bin/disk.img -d cpu_reset,guest_errors,pcall,int 2> $(BUILDDIR)/qemu.log & .PHONY: debug debug: all - @qemu-system-x86_64 -m 64M -hda build/bin/disk.img -no-reboot \ - -no-shutdown -mem-path memdump.bin -mem-prealloc -d cpu_reset,guest_errors,pcall,int 2> qemu.log & - @ndisasm $(BINDIR)/kaleid -o 0x00100000 -b 64 > kaleid64_disasm.asm - @ndisasm $(BINDIR)/kaleid -o 0x00100000 -b 32 > kaleid32_disasm.asm + @qemu-system-x86_64 -m 64M -hda $(BUILDDIR)/bin/disk.img -no-reboot \ + -no-shutdown -d cpu_reset,guest_errors,pcall,int 2> $(BUILDDIR)/qemu.log & + @ndisasm $(BINDIR)/kaleid -o 0x00100000 -b 64 > $(BUILDDIR)/kaleid64_disasm.asm + @ndisasm $(BINDIR)/kaleid -o 0x00100000 -b 32 > $(BUILDDIR)/kaleid32_disasm.asm .PHONY: gdb gdb: all - @qemu-system-x86_64 -m 64M -hda build/bin/disk.img -no-reboot \ - -no-shutdown -mem-path memdump.bin -d cpu_reset,guest_errors,pcall,int -s 2> qemu.log & + @qemu-system-x86_64 -m 64M -hda $(BUILDDIR)/bin/disk.img -no-reboot \ + -no-shutdown -d cpu_reset,guest_errors,pcall,int -s 2> $(BUILDDIR)/qemu.log & @ndisasm $(BINDIR)/kaleid -o 0x00100000 -b 64 > kaleid64_disasm.asm @ndisasm $(BINDIR)/kaleid -o 0x00100000 -b 32 > kaleid32_disasm.asm @gdb \ @@ -241,7 +242,7 @@ $(BINDIR)/kaleid: $(LOBJDIR)/kaleid.x86_64 $(LOBJDIR)/kaleid.x86_64: $(kal_kern_obj) $(kal_com_obj) $(LOBJDIR)/loader.o @echo ${CL2}[$@] ${NC}Linking kernel objects...${CL3} - @$(LD) $(LDFLAGS) -T build/kernel.ld \ + @$(LD) $(LDFLAGS) -T $(BUILDDIR)/kernel.ld \ $(LOBJDIR)/loader.o \ $(KOBJDIR)/*.o \ $(KOBJDIR)/kernel/*.o \ diff --git a/ProjectTree b/ProjectTree index 5c54708..9daa4e3 100644 --- a/ProjectTree +++ b/ProjectTree @@ -88,6 +88,7 @@ │   │   ├── strtol.o │   │   ├── ultoa.o │   │   └── utoa.o +│   ├── grub.log │   └── kernel.ld ├── kaleid │   ├── crtlib @@ -162,13 +163,8 @@ ├── AUTHORS ├── ChangeLog ├── COPYING -├── grub.log -├── kaleid32_disasm.asm -├── kaleid64_disasm.asm ├── Makefile -├── memdump.bin ├── ProjectTree -├── qemu.log └── Readme.md -28 directories, 118 files +28 directories, 114 files diff --git a/boot/grub/grub-install.sh b/boot/grub/grub-install.sh index d89d6eb..81f2690 100755 --- a/boot/grub/grub-install.sh +++ b/boot/grub/grub-install.sh @@ -47,7 +47,7 @@ sudo mount /dev/loop1 $2 > /dev/null echo ${CL2}[grub-install.sh]${NC} Installing grub... \(grub-install\)${CL3} ## Install grub sudo grub-install -V -sudo grub-install --target=i386-pc --debug --root-directory=$2 --boot-directory=$2/boot --no-floppy --modules="part_msdos biosdisk fat multiboot configfile" /dev/loop0 2> grub.log +sudo grub-install --target=i386-pc --debug --root-directory=$2 --boot-directory=$2/boot --no-floppy --modules="part_msdos biosdisk fat multiboot configfile" /dev/loop0 2> build/grub.log echo ${CL2}[grub-install.sh]${NC} Copying grub.cfg sudo cp $3 $2/boot/grub/grub.cfg > /dev/null diff --git a/kaleid/include/kernel/base.h b/kaleid/include/kernel/base.h index 84f961d..42622ee 100644 --- a/kaleid/include/kernel/base.h +++ b/kaleid/include/kernel/base.h @@ -187,6 +187,9 @@ extern volatile Processor_t cpuTable[NCPUS]; static inline void _##pref##Set##name(type __val) \ { KeGetCurCPU().field = __val; } +#define BARRIER() do{\ + asm volatile("": : :"memory");__sync_synchronize();}while(0) + //------------------------------------------// // Needed by basically everyone diff --git a/kaleid/include/kernel/mm.h b/kaleid/include/kernel/mm.h index 22c4346..c06bd8d 100644 --- a/kaleid/include/kernel/mm.h +++ b/kaleid/include/kernel/mm.h @@ -83,6 +83,11 @@ struct GdtPtr_t // void MmInitMemoryMap(void); +// +// Initializes the memory map structure +// +void MmPrintMemoryMap(void); + // // Returns the size of the first available memory zone // from the start address pointer diff --git a/kaleid/kernel/init/init.c b/kaleid/kernel/init/init.c index 9ab181e..4f6c16f 100644 --- a/kaleid/kernel/init/init.c +++ b/kaleid/kernel/init/init.c @@ -113,9 +113,6 @@ void BtInitBootInfo(multiboot_info_t *mbi) extern void pstest(void); extern error_t IoInitVGABuffer(void); -#define BARRIER() do{\ - asm volatile("": : :"memory");__sync_synchronize();}while(0) - // // Entry point of the Kaleid kernel // @@ -133,7 +130,7 @@ noreturn void BtStartKern(multiboot_info_t *mbInfo, int mbMagic) IoInitVGABuffer(); // Hello world - KernLog("%c%c%c OS/K\n\n", 219, 219, 219); + KernLog("%c%c%c OS/K\n \n", 219, 219, 219); KalAlwaysAssert(mbMagic == MULTIBOOT_BOOTLOADER_MAGIC); diff --git a/kaleid/kernel/mm/map.c b/kaleid/kernel/mm/map.c index 30bc0f6..022dd57 100644 --- a/kaleid/kernel/mm/map.c +++ b/kaleid/kernel/mm/map.c @@ -172,3 +172,30 @@ void *MmGetFirstAvailZone(void *start) { return current; } + +void MmPrintMemoryMap(void) { + char *avStr = ""; + + for (int i=0; i < memoryMap.length; i++) { + + switch (memoryMap.entry[i].type) { + case AVAILABLE_ZONE: avStr="Available"; + break; + case RESERVED_ZONE: avStr="Reserved"; + break; + case ACPI_ZONE: avStr="ACPI"; + break; + case NVS_ZONE: avStr="NVS"; + break; + case BADRAM_ZONE: avStr="Bad Ram"; + break; + default:; + } + + KernLog("Mem zone : %p\t%s\twith length: %d Kio\n", + memoryMap.entry[i].addr, + avStr, + memoryMap.entry[i].length / KB + ); + } +}