1
0
mirror of https://gitlab.os-k.eu/os-k-team/os-k.git synced 2023-08-25 14:03:10 +02:00
This commit is contained in:
Adrien Bourmault 2019-03-29 10:29:05 +01:00
parent 5322ec0717
commit 929b399f33
6 changed files with 66 additions and 39 deletions

View File

@ -192,20 +192,25 @@ $(KOBJDIR)/kernel/sched.o: $(KERNELDIR)/kernel/proc/sched.c $(KERNELDIR)/include
.PHONY: test .PHONY: test
test: all 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 -mem-prealloc -hda build/bin/disk.img \
@ndisasm $(BINDIR)/kaleid -o 0x00100000 -b 64 > loader_disasm64.asm -d cpu_reset,guest_errors,pcall,int 2> qemu.log &
@ndisasm $(BINDIR)/kaleid -o 0x00100000 -b 32 > loader_disasm32.asm
.PHONY: test32 .PHONY: test32
test32: all test32: all
@qemu-system-i386 -hda build/bin/disk.img -d cpu_reset,guest_errors,pcall,int 2> qemu.log & @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 .PHONY: debug
debug: all 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 & @qemu-system-x86_64 -m 64M -hda build/bin/disk.img -no-reboot \
@ndisasm $(BINDIR)/kaleid -o 0x00100000 -b 64 > loader_disasm64.asm -no-shutdown -mem-path memdump.bin -mem-prealloc -d cpu_reset,guest_errors,pcall,int 2> qemu.log &
@ndisasm $(BINDIR)/kaleid -o 0x00100000 -b 32 > loader_disasm32.asm @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 .PHONY: install_mbr
install_mbr: $(BINDIR)/disk.img $(MBRDIR)/grub.cfg install_mbr: $(BINDIR)/disk.img $(MBRDIR)/grub.cfg

View File

@ -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 // CPU features masks
enum { enum {
FEAT_ECX_SSE3 = 1 << 0, FEAT_ECX_SSE3 = 1 << 0,

View File

@ -22,7 +22,9 @@
// along with OS/K. If not, see <https://www.gnu.org/licenses/>. // // along with OS/K. If not, see <https://www.gnu.org/licenses/>. //
//----------------------------------------------------------------------------// //----------------------------------------------------------------------------//
#ifndef _KALKERN_BASE_H
#include <kernel/base.h> #include <kernel/base.h>
#endif
#define MINIMUM_RAM_SIZE 16 // Mio, the minimum RAM size. #define MINIMUM_RAM_SIZE 16 // Mio, the minimum RAM size.
@ -32,7 +34,6 @@
#define NVS_ZONE 4 // Dunno #define NVS_ZONE 4 // Dunno
#define BADRAM_ZONE 5 // Invalid zone because material problem... #define BADRAM_ZONE 5 // Invalid zone because material problem...
#define MAX_ENTRIES 2048 // Max number of memory map entries #define MAX_ENTRIES 2048 // Max number of memory map entries
// -------------------------------------------------------------------------- // // -------------------------------------------------------------------------- //
typedef struct MemoryMap_t MemoryMap_t; typedef struct MemoryMap_t MemoryMap_t;
@ -80,7 +81,7 @@ struct GdtPtr_t
// //
// Initializes the memory map structure // Initializes the memory map structure
// //
error_t MmInitMemoryMap(void); void MmInitMemoryMap(void);
// //
// Returns the size of the first available memory zone // Returns the size of the first available memory zone

View File

@ -30,6 +30,18 @@
#include <kernel/buf.h> #include <kernel/buf.h>
#include <kernel/mm.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 // BootInfo_t initialization. It is necessary because grub will potentially be
// wiped since it is below 1MB.... And we must reorganize all that stuff. // 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) noreturn void BtStartKern(multiboot_info_t *mbInfo, int mbMagic)
{ {
error_t mapBad;
// We're not ready to deal with interrupts // We're not ready to deal with interrupts
KeDisableIRQs(); 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); KernLog("%c%c%c OS/K\n\n", 219, 219, 219);
KalAlwaysAssert(mbMagic == MULTIBOOT_BOOTLOADER_MAGIC); 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, BtGetBootInfo(btldr).kernelAddr,
mbMagic mbMagic,
(BtGetBootInfo(btldr).kernelEndAddr - BtGetBootInfo(btldr).kernelAddr)
/ KB
); );
//Memory mapping //Memory mapping
if ((mapBad = MmInitMemoryMap())) MmInitMemoryMap();
KeStartPanic("[Init] The memory map failed to initialize. Error : %d",
mapBad
);
MmInitHeap(); MmInitHeap();
PsInitSched(); PsInitSched();
func();
//Buffer_t *buf = BOpenLineBuf(NULL, BS_WRONLY, 80, 24, 1, NULL); //Buffer_t *buf = BOpenLineBuf(NULL, BS_WRONLY, 80, 24, 1, NULL);
//error_t rc = BPrintOnBuf(buf, "%+#05x", 0xcafeb00b); //error_t rc = BPrintOnBuf(buf, "%+#05x", 0xcafeb00b);
//if(rc)KernLog("error\n"); //if(rc)KernLog("error\n");

View File

@ -28,18 +28,7 @@
GdtEntry_t gdtEntries[5]; GdtEntry_t gdtEntries[5];
GdtPtr_t gdtPtr; GdtPtr_t gdtPtr;
void MmInitGdt(void) static void SetGdtEntry(int index, uint base, uint limit, uchar access,
{
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,
uchar granularity) uchar granularity)
{ {
gdtEntries[index].lowBase = (base & 0xFFFF); gdtEntries[index].lowBase = (base & 0xFFFF);
@ -53,3 +42,17 @@ static void MmSetGdtEntry(int index, uint base, uint limit, uchar access,
gdtEntries[index].access = 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);
}

View File

@ -26,14 +26,26 @@
#include <kernel/term.h> #include <kernel/term.h>
#include <kernel/mboot.h> #include <kernel/mboot.h>
// Initializes globally the memory map
MemoryMap_t memoryMap = { 0 }; MemoryMap_t memoryMap = { 0 };
static error_t InitMemoryMap(void);
// //
// Initilization of the memory map, and computation of the available ram size // 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 *currentEntry;
multiboot_memory_map_t *mapEnd; multiboot_memory_map_t *mapEnd;