mirror of
https://gitlab.os-k.eu/os-k-team/os-k.git
synced 2023-08-25 14:03:10 +02:00
Work on DebugLog in a different buffer
This commit is contained in:
parent
2d7da323ec
commit
4bf7b5c9ca
@ -111,7 +111,7 @@ void BtDoSanityChecks(uint mbMagic) {
|
|||||||
if (!(mbMagic == MULTIBOOT_BOOTLOADER_MAGIC))
|
if (!(mbMagic == MULTIBOOT_BOOTLOADER_MAGIC))
|
||||||
KeStartPanic("Magic number %x is incorrect\n", mbMagic);
|
KeStartPanic("Magic number %x is incorrect\n", mbMagic);
|
||||||
|
|
||||||
DebugLog("\t Kernel successfully loaded at %p\n",
|
DebugLog("Kernel successfully loaded at %p\n",
|
||||||
BtLoaderInfo.kernelAddr);
|
BtLoaderInfo.kernelAddr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -88,6 +88,10 @@ noreturn void BtStartKern(multiboot_info_t *mbInfo, uint mbMagic, void *codeSeg)
|
|||||||
PsInitSched();
|
PsInitSched();
|
||||||
|
|
||||||
// Command line (kernel mode)
|
// Command line (kernel mode)
|
||||||
|
KernLog("Copyright (C) 2018-2020 The OS/K Team\n"
|
||||||
|
"This program comes with ABSOLUTELY NO WARRANTY.\n"
|
||||||
|
"This is free software, type `ver' for details.\n");
|
||||||
|
|
||||||
ShStartShell();
|
ShStartShell();
|
||||||
|
|
||||||
//KeCrashSystem();
|
//KeCrashSystem();
|
||||||
|
@ -121,7 +121,7 @@ static inline void IoInitRSDP(void)
|
|||||||
if (rsdp->legacy.revision == 1 || rsdp->legacy.revision >= 3)
|
if (rsdp->legacy.revision == 1 || rsdp->legacy.revision >= 3)
|
||||||
KeStartPanic("Invalid ACPI Revision : %d", rsdp->legacy.revision);
|
KeStartPanic("Invalid ACPI Revision : %d", rsdp->legacy.revision);
|
||||||
|
|
||||||
KernLog("\tACPI Revision %d (OEM %s)\n",
|
DebugLog("ACPI Revision %d (OEM %s)\n",
|
||||||
(uint)rsdp->legacy.revision,
|
(uint)rsdp->legacy.revision,
|
||||||
rsdp->legacy.OEMID
|
rsdp->legacy.OEMID
|
||||||
);
|
);
|
||||||
@ -153,14 +153,14 @@ static inline void IoInitRXSDT(void)
|
|||||||
KeStartPanic("Invalid RSDT checksum : %d vs 0", checksum);
|
KeStartPanic("Invalid RSDT checksum : %d vs 0", checksum);
|
||||||
|
|
||||||
if (IoACPIVersion == 1) {
|
if (IoACPIVersion == 1) {
|
||||||
KernLog("\tACPI Root System Table %s (%s) length %d [%p]\n",
|
DebugLog("ACPI Root System Table %s (%s) length %d [%p]\n",
|
||||||
rxsdt->signature,
|
rxsdt->signature,
|
||||||
rxsdt->OEMID,
|
rxsdt->OEMID,
|
||||||
rxsdt->length,
|
rxsdt->length,
|
||||||
rxsdt
|
rxsdt
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
KernLog("\tACPI Extended System Table %s (%s) length %d [%p]\n",
|
DebugLog("ACPI Extended System Table %s (%s) length %d [%p]\n",
|
||||||
rxsdt->signature,
|
rxsdt->signature,
|
||||||
rxsdt->OEMID,
|
rxsdt->OEMID,
|
||||||
rxsdt->length,
|
rxsdt->length,
|
||||||
@ -187,7 +187,7 @@ static inline void IoSearchAcpiTables(void)
|
|||||||
entries = (xrsdt->length - sizeof(xrsdt)) / 8;
|
entries = (xrsdt->length - sizeof(xrsdt)) / 8;
|
||||||
}
|
}
|
||||||
|
|
||||||
KernLog("\tACPI detected %d entries\n", entries);
|
DebugLog("ACPI detected %d entries\n", entries);
|
||||||
|
|
||||||
curInt = &(xrsdt->sdtTablePtr);
|
curInt = &(xrsdt->sdtTablePtr);
|
||||||
curLong = &(xrsdt->sdtTablePtr);
|
curLong = &(xrsdt->sdtTablePtr);
|
||||||
@ -203,7 +203,7 @@ static inline void IoSearchAcpiTables(void)
|
|||||||
if (MmIsBusyZone(table)) {
|
if (MmIsBusyZone(table)) {
|
||||||
checksum = DoChecksum(table, (size_t)table->length, 0, 0);
|
checksum = DoChecksum(table, (size_t)table->length, 0, 0);
|
||||||
if (!checksum) {
|
if (!checksum) {
|
||||||
KernLog("\tACPI System Table %s (OEM %s) length %d [%p]\n",
|
DebugLog("ACPI System Table %s (OEM %s) length %d [%p]\n",
|
||||||
table->signature,
|
table->signature,
|
||||||
table->OEMID,
|
table->OEMID,
|
||||||
table->length,
|
table->length,
|
||||||
@ -221,12 +221,6 @@ static inline void IoSearchAcpiTables(void)
|
|||||||
//
|
//
|
||||||
void IoInitAcpi(void)
|
void IoInitAcpi(void)
|
||||||
{
|
{
|
||||||
if (BtFirmwareInfo.romValid)
|
|
||||||
KernLog("\tRom Table is valid at %p\n", BtFirmwareInfo.romTable);
|
|
||||||
|
|
||||||
if (BtFirmwareInfo.apmValid)
|
|
||||||
KernLog("\tApm Table is valid at %p\n", BtFirmwareInfo.apmTable);
|
|
||||||
|
|
||||||
// MAP ACPI PAGES
|
// MAP ACPI PAGES
|
||||||
|
|
||||||
// Search the zone where the start address is
|
// Search the zone where the start address is
|
||||||
|
@ -176,6 +176,9 @@ error_t IoInitVGABuffer(void)
|
|||||||
static char bvgabufsrc[1 * MB];
|
static char bvgabufsrc[1 * MB];
|
||||||
static Buffer_t bvgabufstruct;
|
static Buffer_t bvgabufstruct;
|
||||||
|
|
||||||
|
static char bdbgbufsrc[1 * MB];
|
||||||
|
static Buffer_t bdbgbufstruct;
|
||||||
|
|
||||||
BStdOut = &bvgabufstruct;
|
BStdOut = &bvgabufstruct;
|
||||||
|
|
||||||
BOpenTermBufEx(&BStdOut,
|
BOpenTermBufEx(&BStdOut,
|
||||||
@ -186,7 +189,15 @@ error_t IoInitVGABuffer(void)
|
|||||||
|
|
||||||
BEnableAutoScroll(BStdOut);
|
BEnableAutoScroll(BStdOut);
|
||||||
|
|
||||||
BStdDbg = BStdOut;
|
BStdDbg = &bdbgbufstruct;
|
||||||
|
|
||||||
|
BOpenTermBufEx(&BStdDbg,
|
||||||
|
bdbgbufsrc, BS_WRONLY,
|
||||||
|
BtVideoInfo.framebufferWidth,
|
||||||
|
BtVideoInfo.framebufferHeight,
|
||||||
|
10, NULL);
|
||||||
|
|
||||||
|
BEnableAutoScroll(BStdDbg);
|
||||||
|
|
||||||
return EOK;
|
return EOK;
|
||||||
}
|
}
|
||||||
|
@ -44,7 +44,7 @@ void KeGetCpuInfos(void)
|
|||||||
CpuInfo.frequency = KeGetCpuFrequency();
|
CpuInfo.frequency = KeGetCpuFrequency();
|
||||||
}
|
}
|
||||||
|
|
||||||
DebugLog("\tCPU %s %#d MHz detected with features %#x\n",
|
DebugLog("CPU %s %#d MHz detected with features %#x\n",
|
||||||
CpuInfo.vendorStr,
|
CpuInfo.vendorStr,
|
||||||
(long)(CpuInfo.frequency / 1000.0),
|
(long)(CpuInfo.frequency / 1000.0),
|
||||||
CpuInfo.featureFlag
|
CpuInfo.featureFlag
|
||||||
|
@ -27,6 +27,7 @@
|
|||||||
#include <ke/idt.h>
|
#include <ke/idt.h>
|
||||||
#include <io/vga.h>
|
#include <io/vga.h>
|
||||||
#include <io/spkr.h>
|
#include <io/spkr.h>
|
||||||
|
#include <ke/time.h>
|
||||||
|
|
||||||
IdtEntry_t idt[256] = { 0 };
|
IdtEntry_t idt[256] = { 0 };
|
||||||
IdtPtr_t _KeIdtPtr;
|
IdtPtr_t _KeIdtPtr;
|
||||||
@ -183,7 +184,7 @@ void KeSetupIDT(void)
|
|||||||
// Load IDT
|
// Load IDT
|
||||||
KeLoadIDT();
|
KeLoadIDT();
|
||||||
//DebugLog("\tInterrupt table initialized at %p\n", _KeIdtPtr.base);
|
//DebugLog("\tInterrupt table initialized at %p\n", _KeIdtPtr.base);
|
||||||
KernLog("\tInterrupts activated\n");
|
DebugLog("Interrupts activated\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
@ -308,8 +309,10 @@ void _KeHandleISR(ISRFrame_t *regs)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bprintf(BStdOut, "[ISR 0x%x] %s\n", regs->intNo, "Unknown ISR Exception");
|
bprintf(BStdDbg, "[%d]\tISR 0x%x %s\n",
|
||||||
BStdOut->flusher(BStdOut);
|
KeGetTicks(),
|
||||||
|
regs->intNo,
|
||||||
|
"Unknown ISR Exception");
|
||||||
KeSendEOItoPIC(regs->intNo);
|
KeSendEOItoPIC(regs->intNo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,6 +24,7 @@
|
|||||||
|
|
||||||
#include <lib/buf.h>
|
#include <lib/buf.h>
|
||||||
#include <kernel.h>
|
#include <kernel.h>
|
||||||
|
#include <ke/time.h>
|
||||||
|
|
||||||
//
|
//
|
||||||
// Prints formatted string on standard output
|
// Prints formatted string on standard output
|
||||||
@ -49,6 +50,7 @@ void DebugLog(const char *fmt, ...)
|
|||||||
va_list ap;
|
va_list ap;
|
||||||
|
|
||||||
va_start(ap, fmt);
|
va_start(ap, fmt);
|
||||||
|
BPrintOnBuf(BStdDbg, "[%d]\t", KeGetTicks());
|
||||||
BPrintOnBufV(BStdDbg, fmt, ap);
|
BPrintOnBufV(BStdDbg, fmt, ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
}
|
}
|
||||||
|
@ -132,7 +132,7 @@ void KeEnablePIT(void)
|
|||||||
// Setting up the IRQ line
|
// Setting up the IRQ line
|
||||||
KeUnmaskIRQ(0);
|
KeUnmaskIRQ(0);
|
||||||
|
|
||||||
DebugLog("\tPIT activated with period %d ms\n", 1000/PIT_FREQUENCY);
|
DebugLog("PIT activated with period %d ms\n", 1000/PIT_FREQUENCY);
|
||||||
|
|
||||||
KeRestoreIRQs(flags);
|
KeRestoreIRQs(flags);
|
||||||
KeEnableNMI();
|
KeEnableNMI();
|
||||||
|
@ -213,7 +213,7 @@ void KeEnableRTC(void)
|
|||||||
KeEnableNMI();
|
KeEnableNMI();
|
||||||
|
|
||||||
srand(KeGetTimeStamp()); // Initializes the kernel number generator
|
srand(KeGetTimeStamp()); // Initializes the kernel number generator
|
||||||
DebugLog("\tRTC interrupt frequency set to %d Hz\n",
|
DebugLog("RTC interrupt frequency set to %d Hz\n",
|
||||||
32768 >> (RTC_RATE - 1));
|
32768 >> (RTC_RATE - 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -63,10 +63,10 @@ void MmInitGdt(void)
|
|||||||
tss.ist3 = (ulong)memalign(4*KB, 4*KB) + 4*KB; // ISR STACK
|
tss.ist3 = (ulong)memalign(4*KB, 4*KB) + 4*KB; // ISR STACK
|
||||||
tss.iomap_base = sizeof(tss);
|
tss.iomap_base = sizeof(tss);
|
||||||
|
|
||||||
/* KernLog("\tISR Stacks initialized : Rescue %p, Normal %p, %p\n", */
|
DebugLog("ISR Stacks initialized : Rescue %p, Normal %p, %p\n",
|
||||||
/* tss.ist1, */
|
tss.ist1,
|
||||||
/* tss.ist2, */
|
tss.ist2,
|
||||||
/* tss.ist3); */
|
tss.ist3);
|
||||||
|
|
||||||
memmove(&gdt[2], &tssDesc, sizeof(TssDescriptor_t));
|
memmove(&gdt[2], &tssDesc, sizeof(TssDescriptor_t));
|
||||||
|
|
||||||
|
@ -99,7 +99,7 @@ static error_t InitMemoryMap(void)
|
|||||||
if (memoryMap.freeRamSize < MINIMUM_RAM_SIZE)
|
if (memoryMap.freeRamSize < MINIMUM_RAM_SIZE)
|
||||||
return ENOMEM;
|
return ENOMEM;
|
||||||
|
|
||||||
KernLog("\tAvailable RAM size : %u MB\n",
|
DebugLog("Available RAM size : %u MB\n",
|
||||||
memoryMap.freeRamSize / MB);
|
memoryMap.freeRamSize / MB);
|
||||||
|
|
||||||
return EOK;
|
return EOK;
|
||||||
|
@ -71,7 +71,7 @@ void MmInitPaging(void)
|
|||||||
ulong lastDirectoryAddr = 0;
|
ulong lastDirectoryAddr = 0;
|
||||||
ulong phDirSize = 0;
|
ulong phDirSize = 0;
|
||||||
|
|
||||||
KernLog("\tActivating paging...\n");
|
DebugLog("Activating paging...\n");
|
||||||
|
|
||||||
// Maximum PHYSICAL address in memory
|
// Maximum PHYSICAL address in memory
|
||||||
ulong phRamSize = memoryMap.freeRamSize + memoryMap.nonfreeRamSize;
|
ulong phRamSize = memoryMap.freeRamSize + memoryMap.nonfreeRamSize;
|
||||||
@ -171,21 +171,21 @@ void MmInitPaging(void)
|
|||||||
MmPT[index] = (ulong)curAddrPT | PRESENT;
|
MmPT[index] = (ulong)curAddrPT | PRESENT;
|
||||||
MmPhysicalPageTable[xedni] = (ulong)curAddrPT;
|
MmPhysicalPageTable[xedni] = (ulong)curAddrPT;
|
||||||
MmStackGuards[0] = (ulong)curAddrPT;
|
MmStackGuards[0] = (ulong)curAddrPT;
|
||||||
//DebugLog("\tStack Guard at %p\n", curAddrPT);
|
DebugLog("Stack Guard at %p\n", curAddrPT);
|
||||||
}
|
}
|
||||||
else if ((ulong)curAddrPT ==
|
else if ((ulong)curAddrPT ==
|
||||||
(ulong)BtLoaderInfo.kernelEndAddr) {
|
(ulong)BtLoaderInfo.kernelEndAddr) {
|
||||||
MmPT[index] = (ulong)curAddrPT | PRESENT;
|
MmPT[index] = (ulong)curAddrPT | PRESENT;
|
||||||
MmPhysicalPageTable[xedni] = (ulong)curAddrPT;
|
MmPhysicalPageTable[xedni] = (ulong)curAddrPT;
|
||||||
MmStackGuards[1] = (ulong)curAddrPT;
|
MmStackGuards[1] = (ulong)curAddrPT;
|
||||||
//DebugLog("\tStack Guard at %p\n", curAddrPT);
|
DebugLog("Stack Guard at %p\n", curAddrPT);
|
||||||
}
|
}
|
||||||
// SECTION .TEXT PROTECTION
|
// SECTION .TEXT PROTECTION
|
||||||
else if ((ulong)curAddrPT >= (ulong)&_text
|
else if ((ulong)curAddrPT >= (ulong)&_text
|
||||||
&& (ulong)curAddrPT <= (ulong)&_text_end) {
|
&& (ulong)curAddrPT <= (ulong)&_text_end) {
|
||||||
MmPT[index] = (ulong)curAddrPT | PRESENT;
|
MmPT[index] = (ulong)curAddrPT | PRESENT;
|
||||||
MmPhysicalPageTable[xedni] = (ulong)curAddrPT;
|
MmPhysicalPageTable[xedni] = (ulong)curAddrPT;
|
||||||
//DebugLog("\tSection .text at %p\n", curAddrPT);
|
DebugLog("Section .text at %p\n", curAddrPT);
|
||||||
}
|
}
|
||||||
// SECTION .DATA PROTECTION
|
// SECTION .DATA PROTECTION
|
||||||
else if ((ulong)curAddrPT >= (ulong)&_data
|
else if ((ulong)curAddrPT >= (ulong)&_data
|
||||||
@ -195,14 +195,14 @@ void MmInitPaging(void)
|
|||||||
| READWRITE
|
| READWRITE
|
||||||
| NX;
|
| NX;
|
||||||
MmPhysicalPageTable[xedni] = (ulong)curAddrPT;
|
MmPhysicalPageTable[xedni] = (ulong)curAddrPT;
|
||||||
//DebugLog("\tSection .data at %p\n", curAddrPT);
|
DebugLog("Section .data at %p\n", curAddrPT);
|
||||||
}
|
}
|
||||||
// SECTION .RODATA PROTECTION
|
// SECTION .RODATA PROTECTION
|
||||||
else if ((ulong)curAddrPT >= (ulong)&_rodata
|
else if ((ulong)curAddrPT >= (ulong)&_rodata
|
||||||
&& (ulong)curAddrPT <= (ulong)&_rodata_end) {
|
&& (ulong)curAddrPT <= (ulong)&_rodata_end) {
|
||||||
MmPT[index] = (ulong)curAddrPT | PRESENT | NX;
|
MmPT[index] = (ulong)curAddrPT | PRESENT | NX;
|
||||||
MmPhysicalPageTable[xedni] = (ulong)curAddrPT;
|
MmPhysicalPageTable[xedni] = (ulong)curAddrPT;
|
||||||
//DebugLog("\tSection .rodata at %p\n", curAddrPT);
|
DebugLog("Section .rodata at %p\n", curAddrPT);
|
||||||
}
|
}
|
||||||
// While we're inside the kernel pages
|
// While we're inside the kernel pages
|
||||||
else if ((ulong)curAddrPT <= MmPhysLastKernAddress) {
|
else if ((ulong)curAddrPT <= MmPhysLastKernAddress) {
|
||||||
@ -219,7 +219,7 @@ void MmInitPaging(void)
|
|||||||
MmLoadPML4((void *)MmPageMapLevel4);
|
MmLoadPML4((void *)MmPageMapLevel4);
|
||||||
MmEnableWriteProtect();
|
MmEnableWriteProtect();
|
||||||
|
|
||||||
DebugLog("\tPage table size : %u MB\n", (lastDirectoryAddr - firstDirectoryAddr + phDirSize)/MB);
|
DebugLog("Page table size : %u MB\n", (lastDirectoryAddr - firstDirectoryAddr + phDirSize)/MB);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -307,6 +307,8 @@ void PsInitSched(void)
|
|||||||
PsUnlockSched();
|
PsUnlockSched();
|
||||||
|
|
||||||
PsInitialized = true;
|
PsInitialized = true;
|
||||||
|
|
||||||
|
DebugLog("Scheduler initialized\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
// Desc: Kernel shell //
|
// Desc: Kernel shell //
|
||||||
// //
|
// //
|
||||||
// //
|
// //
|
||||||
// Copyright © 2018-2019 The OS/K Team //
|
// Copyright © 2018-2020 The OS/K Team //
|
||||||
// //
|
// //
|
||||||
// This file is part of OS/K. //
|
// This file is part of OS/K. //
|
||||||
// //
|
// //
|
||||||
@ -166,7 +166,7 @@ error_t CmdVersion(int argc, char **argv, char *cmdline)
|
|||||||
CN
|
CN
|
||||||
);
|
);
|
||||||
|
|
||||||
KernLog("Copyright (C) 2018-2019 The OS/K Team\n\n");
|
KernLog("Copyright (C) 2018-2020 The OS/K Team\n\n");
|
||||||
KernLog("This program is free software, released under the\n");
|
KernLog("This program is free software, released under the\n");
|
||||||
KernLog("terms of the GNU GPL version 3 or later as published\n");
|
KernLog("terms of the GNU GPL version 3 or later as published\n");
|
||||||
KernLog("by the Free Software Foundation.\n");
|
KernLog("by the Free Software Foundation.\n");
|
||||||
|
Loading…
Reference in New Issue
Block a user