From 3cf6f55b9520bbcffbf9eae0ade25ed4a070156d Mon Sep 17 00:00:00 2001 From: Ali Mashtizadeh Date: Mon, 23 Oct 2023 22:25:45 -0400 Subject: [PATCH] Disable x86 specific bits on other architectures. --- bin/shell/shell.c | 2 ++ sys/dev/console.c | 17 +++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/bin/shell/shell.c b/bin/shell/shell.c index 5928559..4bacee9 100644 --- a/bin/shell/shell.c +++ b/bin/shell/shell.c @@ -127,7 +127,9 @@ DispatchCommand(char *buf) if (strcmp(argv[0], "help") == 0) { Cmd_Help(argc, (const char **)argv); } else if (strcmp(argv[0], "bkpt") == 0) { +#if defined(__x86_64__) asm volatile("int3"); +#endif } else if (strcmp(argv[0], "exit") == 0) { Cmd_Exit(argc, (const char **)argv); } else if (strcmp(argv[0], "#") == 0) { diff --git a/sys/dev/console.c b/sys/dev/console.c index 9a09dc7..cdc3d8e 100644 --- a/sys/dev/console.c +++ b/sys/dev/console.c @@ -21,9 +21,11 @@ Console consoles; void Console_Init() { +#if defined(__x86_64__) VGA_Init(); Serial_Init(); DebugConsole_Init(); +#endif Console_Puts("Castor Operating System\n"); @@ -40,7 +42,9 @@ Console_Init() void Console_LateInit() { +#if defined(__x86_64__) Serial_LateInit(); +#endif } char @@ -56,6 +60,7 @@ Console_Getc() } Spinlock_Unlock(&consoles.keyLock); +#if defined(__x86_64__) // Support serial debugging if interrupts are disabled if (Serial_HasData()) { char key = Serial_Getc(); @@ -68,6 +73,7 @@ Console_Getc() return key; } } +#endif } } @@ -84,6 +90,13 @@ Console_EnqueueKey(char key) Spinlock_Unlock(&consoles.keyLock); } +#if !defined(__x86_64__) +void +Panic(const char *str) +{ +} +#endif + void Console_Gets(char *str, size_t n) { @@ -131,9 +144,11 @@ void Console_Putc(char ch) { Spinlock_Lock(&consoleLock); +#if defined(__x86_64__) VGA_Putc(ch); Serial_Putc(ch); DebugConsole_Putc(ch); +#endif Spinlock_Unlock(&consoleLock); } @@ -141,9 +156,11 @@ void Console_Puts(const char *str) { Spinlock_Lock(&consoleLock); +#if defined(__x86_64__) VGA_Puts(str); Serial_Puts(str); DebugConsole_Puts(str); +#endif Spinlock_Unlock(&consoleLock); }