1
0
mirror of https://gitlab.os-k.eu/os-k-team/os-k.git synced 2023-08-25 14:03:10 +02:00

Some cosmetic changes

This commit is contained in:
Adrien Bourmault 2019-05-22 18:15:23 +02:00
parent f0d6580ff5
commit b80c912a34
10 changed files with 202 additions and 143 deletions

View File

@ -204,7 +204,8 @@ $(KOBJDIR)/%.o: %.c | $(KOBJDIR)
@echo ${CL2}[$@] ${CL}Compiled.${CL3}
test: all
@qemu-system-x86_64 -cpu core2duo -soundhw pcspk -s -rtc base=localtime -m $(ram) -hda $(BUILDDIR)/bin/disk.img \
@qemu-system-x86_64 -vga std -cpu core2duo -soundhw pcspk -s \
-rtc base=localtime -m $(ram) -hda $(BUILDDIR)/bin/disk.img \
-d cpu_reset,guest_errors,pcall,int 2> $(BUILDDIR)/qemu.log &
test32: all

View File

@ -29,8 +29,8 @@ MB_ALIGN equ 1 << 0 ; Ask to align loaded modules on page bounda
MB_MEMINFO equ 1 << 1 ; Ask to provide memory map
MB_VIDEOINFO equ 1 << 2 ; Ask to provide video infos
MB_VIDEO_MODE equ 0x1 ; Text mode
MB_VIDEO_WIDTH equ 80
MB_VIDEO_HEIGHT equ 24
MB_VIDEO_WIDTH equ 132
MB_VIDEO_HEIGHT equ 60
MB_VIDEO_DEPTH equ 0x0
MB_HEADER_MAGIC equ 0x1badb002
MB_GRUB_MAGIC equ 0x2badb002

View File

@ -35,6 +35,7 @@ void IoStartSpeaker(int);
void IoQuietSpeaker(void);
void IoDoBeep(void);
void IoDoTone(uint tone, uint time);
void IoDoBeepNoIdt(void);
void IoDoStarWars(void);

View File

@ -58,12 +58,25 @@ void IoDoTone(uint tone, uint time)
IoQuietSpeaker();
}
static void IoDoToneNoIdt(uint tone, uint time)
{
extern void temporize(void);
IoStartSpeaker(tone);
for (int i = 0; i < 100; i++) temporize();
IoQuietSpeaker();
}
void IoDoBeep(void)
{
if (KeIdtIsInitialized)
IoDoTone(1000, 100);
}
void IoDoBeepNoIdt(void)
{
IoDoToneNoIdt(1000, 100);
}
void IoDoStarWars(void)
{
size_t i;

View File

@ -27,6 +27,7 @@
#include <ke/idt.h>
#include <io/vga.h>
#include <mm/mm.h>
#include <io/spkr.h>
IdtEntry_t idt[256] = { 0 };
IdtPtr_t _KeIdtPtr;
@ -338,7 +339,9 @@ static void DoubleFaultHandler(ISRFrame_t *regs)
void KeBrkDumpRegisters(ISRFrame_t *regs)
{
bprintf(BStdOut, "\n\n"
IoDoBeepNoIdt();
bprintf(BStdOut, "\n\n"
"%C RIP: %#016lx RSP: %#016lx RBP: %#016lx\n\n"
@ -382,7 +385,7 @@ void KeBrkDumpRegisters(ISRFrame_t *regs)
regs->r15,
regs->rflags,
regs->rflags
);
);
BStdOut->flusher(BStdOut);
}

View File

@ -51,7 +51,7 @@ noreturn void KeStartPanic(const char *fmt, ...)
{
va_list ap;
bprintf(BStdOut, "%C\nPANIC\n\a", VGA_COLOR_LIGHT_RED);
bprintf(BStdOut, "%C\nPANIC\n", VGA_COLOR_LIGHT_RED);
KeDisableIRQs();
KeCurProc = NULL;

View File

@ -25,6 +25,7 @@
#include <mm/mm.h>
#include <init/boot.h>
#include <init/mboot.h>
#include <io/vga.h>
// Initializes globally the memory map
MemoryMap_t memoryMap = { 0 };
@ -174,29 +175,55 @@ void *MmGetFirstAvailZone(void *start) {
}
void MmPrintMemoryMap(void) {
char *avStr = "";
char avStr[15];
extern int shcol;
for (uint i=0; i < memoryMap.length; i++) {
switch (memoryMap.entry[i].type) {
case AVAILABLE_ZONE: avStr="Available";
case AVAILABLE_ZONE: snprintf(avStr, 15, "%CAvailable%C",
VGA_COLOR_GREEN,
shcol);
break;
case RESERVED_ZONE: avStr="Reserved";
case RESERVED_ZONE: snprintf(avStr, 15, "%CReserved %C",
VGA_COLOR_RED,
shcol);
break;
case ACPI_ZONE: avStr="ACPI ";
case ACPI_ZONE: snprintf(avStr, 15, "%CACPI %C",
VGA_COLOR_LIGHT_BROWN,
shcol);
break;
case NVS_ZONE: avStr="NVS ";
case NVS_ZONE: snprintf(avStr, 15, "%CNVS %C",
VGA_COLOR_LIGHT_BROWN,
shcol);
break;
case BADRAM_ZONE: avStr="Bad Ram";
case BADRAM_ZONE: snprintf(avStr, 15, "%CBAD RAM %C",
VGA_COLOR_LIGHT_RED,
shcol);
break;
default:;
}
ulong len = memoryMap.entry[i].length;
KernLog("mem zone: %lp\t%s\twith length: %4luMB + %4luKB + %4luB\n",
KernLog("%Cmem zone:%C %lp %s %Cwith length:%C %4lu%CMB"
"+%C%4lu%CKB+%C%4lu%CB\n",
VGA_COLOR_DARK_GREY,
shcol,
memoryMap.entry[i].addr, avStr,
_ADDR_TO_MB(len), _ADDR_TO_KB(len), _ADDR_TO_B(len)
VGA_COLOR_DARK_GREY,
shcol,
_ADDR_TO_MB(len),
VGA_COLOR_DARK_GREY,
shcol,
_ADDR_TO_KB(len),
VGA_COLOR_DARK_GREY,
shcol,
_ADDR_TO_B(len),
VGA_COLOR_DARK_GREY,
shcol
);
}
KernLog("\n");
}

View File

@ -120,11 +120,12 @@ void MmReloadPaging(void)
extern MemoryMap_t memoryMap;
ulong phRamSize = memoryMap.freeRamSize + memoryMap.nonfreeRamSize;
for (volatile ulong i = 0; i < 512 * NB_4K; i++) {
// STACK GUARD PAGE
if ((ulong)(i*KPAGESIZE) == (ulong)BtLoaderInfo.stackEndAddr) {
MmPT[i] = ((ulong)(i*KPAGESIZE));
MmStackGuards[0] = i;
MmStackGuards[0] = ((ulong)(i*KPAGESIZE));
continue;
}
@ -136,7 +137,7 @@ void MmReloadPaging(void)
// STACK GARD PAGE
if ((ulong)(i*KPAGESIZE) == (ulong)BtLoaderInfo.kernelEndAddr) {
MmPT[i] = ((ulong)(i*KPAGESIZE));
MmStackGuards[1] = i;
MmStackGuards[1] = ((ulong)(i*KPAGESIZE));
continue;
}
@ -157,8 +158,15 @@ void MmReloadPaging(void)
MmPD[i] = ((ulong)(i* UPAGESIZE)) | MF_PRESENT | MF_READWRITE | MF_HUGE;
}
DebugLog("Paging tables reloaded at %p, %p\n", &MmPD, &MmPT);
DebugLog("Stack Guards at %p, %p\n", MmStackGuards[0], MmStackGuards[1]);
for (volatile int i = 0; i < RAM_MAX; i++) {
MmPDP[i] = (ulong)(&MmPD[i*512])| MF_PRESENT | MF_READWRITE;
}
MmPML4[0] = (ulong)(&MmPDP[0])| MF_PRESENT | MF_READWRITE;
MmLoadPML4((void *)MmPML4);
DebugLog("\tPaging tables initialized at %p, %p\n", &MmPD, &MmPT);
DebugLog("\tStack Guards at %p, %p\n", MmStackGuards[0], MmStackGuards[1]);
}
// Returns the rank of the Stack Guards

View File

@ -24,45 +24,25 @@
#include "shell.h"
error_t CmdArgs(int argc, char **argv, char *cmdline)
{
int i;
KernLog("cmdline: '%s'\nargc: %d\n", cmdline, argc);
for (i = 0; i < argc; i++) {
KernLog("argv[%d]: '%s'\n", i, argv[i]);
}
return EOK;
}
error_t CmdBeep(int argc, char **argv, char *cmdline)
{
IoDoBeep();
return EOK;
}
error_t CmdStarWars(int argc, char **argv, char *cmdline)
{
IoDoStarWars();
return EOK;
}
error_t CmdQuit(int argc, char **argv, char *cmdline)
{
PoShutdown();
return EOK;
}
error_t CmdHelp(int argc, char **argv, char *cmdline)
{
uint i, count = 0;
Command_t *cmd;
if (argc == 1) {
KernLog("List of all shell built-ins:\n");
for (cmd = cmdtable; cmd->name != NULL; cmd++, count++) {
KernLog("\t%s", cmd->name);
for (i = strlen(cmd->name)/4; i<3; i++) {
KernLog("\t");
}
KernLog("%s\n", cmd->help);
}
KernLog("End of list; %u commands total\n", count);
}
return EOK;
}
error_t CmdClear(int argc, char **argv, char *cmdline)
{
BLockBuf(BStdOut);
@ -75,69 +55,6 @@ error_t CmdClear(int argc, char **argv, char *cmdline)
return EOK;
}
error_t CmdDate(int argc, char **argv, char *cmdline)
{
KernLog("%.10s\n", KeFormatCurTime());
return EOK;
}
error_t CmdTime(int argc, char **argv, char *cmdline)
{
KernLog("%s\n", &KeFormatCurTime()[13]);
return EOK;
}
error_t CmdMemMap(int argc, char **argv, char *cmdline)
{
MmPrintMemoryMap();
return EOK;
}
extern void pstest(void);
error_t CmdPsTest(int argc, char **argv, char *cmdline)
{
// pstest();
return EOK;
}
error_t CmdDie(int argc, char **argv, char *cmdline)
{
*(char *)NULL += 1;
return EOK;
}
error_t CmdPF(int argc, char **argv, char *cmdline)
{
/* if (argc != 2) */
/* return EINVAL; */
/* ulong address = atoul(argv[1]); */
/* KernLog("print: %s, %d\n", argv[1], address); */
/* *((char*)address) += 1; */
for (int i = 0; i < 32; i++) {
KernLog("%dGB ", i);
*((char*)(i*GB)) = 1;
}
return EOK;
}
error_t CmdArgs(int argc, char **argv, char *cmdline)
{
int i;
KernLog("cmdline: '%s'\nargc: %d\n", cmdline, argc);
for (i = 0; i < argc; i++) {
KernLog("argv[%d]: '%s'\n", i, argv[i]);
}
return EOK;
}
error_t CmdColor(int argc, char **argv, char *cmdline)
{
int col = 0;
@ -180,8 +97,67 @@ error_t CmdColor(int argc, char **argv, char *cmdline)
return EOK;
}
void MmInitPaging(void);
void MmReloadPaging(void);
error_t CmdDate(int argc, char **argv, char *cmdline)
{
KernLog("%.10s\n", KeFormatCurTime());
return EOK;
}
error_t CmdDie(int argc, char **argv, char *cmdline)
{
*(char *)NULL += 1;
return EOK;
}
error_t CmdHelp(int argc, char **argv, char *cmdline)
{
uint i, count = 0;
Command_t *cmd;
if (argc == 1) {
KernLog("List of all shell built-ins:\n");
for (cmd = cmdtable; cmd->name != NULL; cmd++, count++) {
KernLog("\t%s", cmd->name);
for (i = strlen(cmd->name)/4; i<3; i++) {
KernLog("\t");
}
KernLog("%C%s%C\n", VGA_COLOR_DARK_GREY, cmd->help, shcol);
}
KernLog("End of list; %u commands total\n", count);
}
return EOK;
}
error_t CmdMemMap(int argc, char **argv, char *cmdline)
{
MmPrintMemoryMap();
return EOK;
}
error_t CmdMemUsage(int argc, char **argv, char *cmdline);
error_t CmdPF(int argc, char **argv, char *cmdline)
{
for (int i = 0; i < 32; i++) {
KernLog("%dGB ", i);
*((char*)(i*GB)) = 1;
}
return EOK;
}
error_t CmdPsTest(int argc, char **argv, char *cmdline)
{
// pstest();
return EOK;
}
error_t CmdQuit(int argc, char **argv, char *cmdline)
{
PoShutdown();
return EOK;
}
error_t CmdReloadPage(int argc, char **argv, char *cmdline)
{
@ -189,8 +165,6 @@ error_t CmdReloadPage(int argc, char **argv, char *cmdline)
return EOK;
}
extern void KeStartShell(void);
error_t CmdShell(int argc, char **argv, char *cmdline)
{
KeStartShell();
@ -212,17 +186,44 @@ error_t CmdStackUnderflow(int argc, char **argv, char *cmdline)
return EOK;
}
error_t CmdMemUsage(int argc, char **argv, char *cmdline);
error_t CmdStarWars(int argc, char **argv, char *cmdline)
{
IoDoStarWars();
return EOK;
}
error_t CmdTest(int argc, char **argv, char *cmdline)
{
KernLog("%s\n", &KeFormatCurTime()[13]);
return EOK;
}
error_t CmdTime(int argc, char **argv, char *cmdline)
{
KernLog("%s\n", &KeFormatCurTime()[13]);
return EOK;
}
error_t CmdVersion(int argc, char **argv, char *cmdline)
{
KernLog("OS/K version %s (x86-64)\n", _KALEID_VERSION);
KernLog("Copyright (C) 2018-2019 The OS/K Team\n");
KernLog("License GNU GPL version 3 "
"or later, see <http://gnu.org/licenses/gpl.html>\n");
KernLog("This is free software; you are "
"free to change and redistribute it.\n");
KernLog("There is NO WARRANTY, to the extent permitted by law.\n\n");
int CH = VGA_COLOR_LIGHT_BLUE;
int CN = shcol;
KernLog("OS/K version %C%s (x86-64)%C\n",
CH,
_KALEID_VERSION,
CN
);
KernLog("Copyright (C) 2018-2019 The OS/K Team\n\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("by the Free Software Foundation.\n");
KernLog("You are free to change and redistribute it.\n");
KernLog("There is NO WARRANTY, to the extent permitted by law.\n");
KernLog("See <http://gnu.org/licenses/gpl.html>\n\n");
return EOK;
}
@ -236,19 +237,20 @@ Command_t cmdtable[] =
{ "color", CmdColor, "Change shell text color" },
{ "date", CmdDate, "Print date" },
{ "die", CmdDie, "Die painfully" },
{ "exit", CmdQuit, "Initiate shutdown" },
{ "help", CmdHelp, "Show this message" },
{ "rpag", CmdReloadPage, "Reload the pages directory" },
{ "march", CmdStarWars, "Play the Imperial March"},
{ "mmap", CmdMemMap, "Show memory map" },
{ "musage", CmdMemUsage, "Show memory statistics" },
{ "pfault", CmdPF, "Provoke a PF. Usage : pfault <address>" },
{ "pstest", CmdPsTest, "Scheduler test routine" },
{ "exit", CmdQuit, "Initiate shutdown" },
{ "quit", CmdQuit, "Alias for 'exit'" },
{ "rpag", CmdReloadPage, "Reload the pages directory" },
{ "shell", CmdShell, "Start a new shell (nested)", },
{ "stkov", CmdStackOverflow, "Provoke a stack overflow" },
{ "stkun", CmdStackUnderflow, "Provoke a stack underflow" },
{ "stkun", CmdStackUnderflow, "Provoke a stack underflow" },
{ "march", CmdStarWars, "Play the Imperial March"},
{ "time", CmdTime, "Print time" },
{ "test", CmdTime, "Undocumented (various tests)" },
{ "ver", CmdVersion, "Version and legal infos" },
{ NULL, NULL, NULL }
};

View File

@ -35,8 +35,12 @@
#include <io/vga.h>
#include <po/shtdwn.h>
extern void IoScrollDown(void);
extern void IoScrollUp(void);
void IoScrollDown(void);
void IoScrollUp(void);
void KeStartShell(void);
void pstest(void);
void MmInitPaging(void);
void MmReloadPaging(void);
extern int shcol;
extern int shargc;