diff --git a/Makefile b/Makefile
index f14c939..b0cb2d9 100644
--- a/Makefile
+++ b/Makefile
@@ -192,20 +192,25 @@ $(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 &
- @ndisasm $(BINDIR)/kaleid -o 0x00100000 -b 64 > loader_disasm64.asm
- @ndisasm $(BINDIR)/kaleid -o 0x00100000 -b 32 > loader_disasm32.asm
+ @qemu-system-x86_64 -m 5G -mem-prealloc -hda build/bin/disk.img \
+ -d cpu_reset,guest_errors,pcall,int 2> qemu.log &
.PHONY: test32
test32: all
@qemu-system-i386 -hda build/bin/disk.img -d cpu_reset,guest_errors,pcall,int 2> qemu.log &
- @ndisasm $(BINDIR)/kaleid -o 0x00100000 -b 64 > loader_disasm64.asm
- @ndisasm $(BINDIR)/kaleid -o 0x00100000 -b 32 > loader_disasm32.asm
.PHONY: debug
debug: all
- @qemu-system-x86_64 -m 5G -hda build/bin/disk.img -d cpu_reset,guest_errors,pcall,int -s -S 2> qemu.log &
- @ndisasm $(BINDIR)/kaleid -o 0x00100000 -b 64 > loader_disasm64.asm
- @ndisasm $(BINDIR)/kaleid -o 0x00100000 -b 32 > loader_disasm32.asm
+ @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
+
+.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 -S 2> qemu.log &
+ @ndisasm $(BINDIR)/kaleid -o 0x00100000 -b 64 > kaleid64_disasm.asm
+ @ndisasm $(BINDIR)/kaleid -o 0x00100000 -b 32 > kaleid32_disasm.asm
.PHONY: install_mbr
install_mbr: $(BINDIR)/disk.img $(MBRDIR)/grub.cfg
diff --git a/kaleid/include/kernel/cpu.h b/kaleid/include/kernel/cpu.h
index 73dbb75..29ebc8f 100644
--- a/kaleid/include/kernel/cpu.h
+++ b/kaleid/include/kernel/cpu.h
@@ -31,13 +31,6 @@
// -------------------------------------------------------------------------- //
-#define KeCPUID(in, a, b, c, d) asm("cpuid" \
- : "=a" (a), "=b" (b), "=c" (c), "=d" (d) \
- : "a" (in) \
- );
-
-// -------------------------------------------------------------------------- //
-
// CPU features masks
enum {
FEAT_ECX_SSE3 = 1 << 0,
diff --git a/kaleid/include/kernel/mm.h b/kaleid/include/kernel/mm.h
index a15a2fa..22c4346 100644
--- a/kaleid/include/kernel/mm.h
+++ b/kaleid/include/kernel/mm.h
@@ -22,7 +22,9 @@
// along with OS/K. If not, see . //
//----------------------------------------------------------------------------//
+#ifndef _KALKERN_BASE_H
#include
+#endif
#define MINIMUM_RAM_SIZE 16 // Mio, the minimum RAM size.
@@ -32,7 +34,6 @@
#define NVS_ZONE 4 // Dunno
#define BADRAM_ZONE 5 // Invalid zone because material problem...
#define MAX_ENTRIES 2048 // Max number of memory map entries
-
// -------------------------------------------------------------------------- //
typedef struct MemoryMap_t MemoryMap_t;
@@ -80,7 +81,7 @@ struct GdtPtr_t
//
// Initializes the memory map structure
//
-error_t MmInitMemoryMap(void);
+void MmInitMemoryMap(void);
//
// Returns the size of the first available memory zone
diff --git a/kaleid/kernel/init/init.c b/kaleid/kernel/init/init.c
index 8a5b9ba..c70fde2 100644
--- a/kaleid/kernel/init/init.c
+++ b/kaleid/kernel/init/init.c
@@ -30,6 +30,18 @@
#include
#include
+void func(void)
+{
+ void* p = NULL;
+ KernLog("%p ", (void*)&p);
+
+ for (int i = 0; i < 50; i++) { ; }
+
+ func();
+}
+
+
+
//
// BootInfo_t initialization. It is necessary because grub will potentially be
// wiped since it is below 1MB.... And we must reorganize all that stuff.
@@ -116,8 +128,6 @@ extern void pstest(void);
//
noreturn void BtStartKern(multiboot_info_t *mbInfo, int mbMagic)
{
- error_t mapBad;
-
// We're not ready to deal with interrupts
KeDisableIRQs();
@@ -131,20 +141,23 @@ noreturn void BtStartKern(multiboot_info_t *mbInfo, int mbMagic)
KernLog("%c%c%c OS/K\n\n", 219, 219, 219);
KalAlwaysAssert(mbMagic == MULTIBOOT_BOOTLOADER_MAGIC);
- KernLog("[Init] Kernel successfully loaded at %p with %x magic\n\n",
+
+ KernLog("[Init] Kernel successfully loaded at %p with %x magic\n"
+ " and it uses %d Kio\n\n",
BtGetBootInfo(btldr).kernelAddr,
- mbMagic
+ mbMagic,
+ (BtGetBootInfo(btldr).kernelEndAddr - BtGetBootInfo(btldr).kernelAddr)
+ / KB
);
//Memory mapping
- if ((mapBad = MmInitMemoryMap()))
- KeStartPanic("[Init] The memory map failed to initialize. Error : %d",
- mapBad
- );
+ MmInitMemoryMap();
MmInitHeap();
PsInitSched();
+ func();
+
//Buffer_t *buf = BOpenLineBuf(NULL, BS_WRONLY, 80, 24, 1, NULL);
//error_t rc = BPrintOnBuf(buf, "%+#05x", 0xcafeb00b);
//if(rc)KernLog("error\n");
diff --git a/kaleid/kernel/mm/gdt.c b/kaleid/kernel/mm/gdt.c
index e4e5ef3..06cbc15 100644
--- a/kaleid/kernel/mm/gdt.c
+++ b/kaleid/kernel/mm/gdt.c
@@ -28,18 +28,7 @@
GdtEntry_t gdtEntries[5];
GdtPtr_t gdtPtr;
-void MmInitGdt(void)
-{
- gdtPtr.limit = (sizeof(GdtEntry_t) * 5) - 1;
- gdtPtr.base = (uint)(ullong)&gdtEntries;
-
-
- /* XXX set TSS register */
-
- //MmLoadGdt(&gdtPtr);
-}
-
-static void MmSetGdtEntry(int index, uint base, uint limit, uchar access,
+static void SetGdtEntry(int index, uint base, uint limit, uchar access,
uchar granularity)
{
gdtEntries[index].lowBase = (base & 0xFFFF);
@@ -53,3 +42,17 @@ static void MmSetGdtEntry(int index, uint base, uint limit, uchar access,
gdtEntries[index].access = access;
}
+
+
+void MmInitGdt(void)
+{
+ gdtPtr.limit = (sizeof(GdtEntry_t) * 5) - 1;
+ gdtPtr.base = (uint)(ullong)&gdtEntries;
+
+
+ /* XXX set TSS register */
+
+ //MmLoadGdt(&gdtPtr);
+}
+
+
diff --git a/kaleid/kernel/mm/map.c b/kaleid/kernel/mm/map.c
index c19c04f..8507bd7 100644
--- a/kaleid/kernel/mm/map.c
+++ b/kaleid/kernel/mm/map.c
@@ -26,14 +26,26 @@
#include
#include
-
+// Initializes globally the memory map
MemoryMap_t memoryMap = { 0 };
+static error_t InitMemoryMap(void);
+
//
// Initilization of the memory map, and computation of the available ram size
//
-error_t MmInitMemoryMap(void)
+void MmInitMemoryMap(void)
+{
+ error_t rc;
+
+ if ((rc = InitMemoryMap()))
+ KeStartPanic("[Init] The memory map failed to initialize. Error : %d",
+ rc
+ );
+}
+
+static error_t InitMemoryMap(void)
{
multiboot_memory_map_t *currentEntry;
multiboot_memory_map_t *mapEnd;