clean-up
This commit is contained in:
parent
5322ec0717
commit
929b399f33
21
Makefile
21
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
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -22,7 +22,9 @@
|
|||
// along with OS/K. If not, see <https://www.gnu.org/licenses/>. //
|
||||
//----------------------------------------------------------------------------//
|
||||
|
||||
#ifndef _KALKERN_BASE_H
|
||||
#include <kernel/base.h>
|
||||
#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
|
||||
|
|
|
@ -30,6 +30,18 @@
|
|||
#include <kernel/buf.h>
|
||||
#include <kernel/mm.h>
|
||||
|
||||
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");
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -26,14 +26,26 @@
|
|||
#include <kernel/term.h>
|
||||
#include <kernel/mboot.h>
|
||||
|
||||
|
||||
// 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;
|
||||
|
|
Loading…
Reference in New Issue