Disable x86 specific bits on other architectures.

This commit is contained in:
Ali Mashtizadeh 2023-10-23 22:25:45 -04:00
parent 7756f5e80c
commit 3cf6f55b95
2 changed files with 19 additions and 0 deletions

View File

@ -127,7 +127,9 @@ DispatchCommand(char *buf)
if (strcmp(argv[0], "help") == 0) { if (strcmp(argv[0], "help") == 0) {
Cmd_Help(argc, (const char **)argv); Cmd_Help(argc, (const char **)argv);
} else if (strcmp(argv[0], "bkpt") == 0) { } else if (strcmp(argv[0], "bkpt") == 0) {
#if defined(__x86_64__)
asm volatile("int3"); asm volatile("int3");
#endif
} else if (strcmp(argv[0], "exit") == 0) { } else if (strcmp(argv[0], "exit") == 0) {
Cmd_Exit(argc, (const char **)argv); Cmd_Exit(argc, (const char **)argv);
} else if (strcmp(argv[0], "#") == 0) { } else if (strcmp(argv[0], "#") == 0) {

View File

@ -21,9 +21,11 @@ Console consoles;
void void
Console_Init() Console_Init()
{ {
#if defined(__x86_64__)
VGA_Init(); VGA_Init();
Serial_Init(); Serial_Init();
DebugConsole_Init(); DebugConsole_Init();
#endif
Console_Puts("Castor Operating System\n"); Console_Puts("Castor Operating System\n");
@ -40,7 +42,9 @@ Console_Init()
void void
Console_LateInit() Console_LateInit()
{ {
#if defined(__x86_64__)
Serial_LateInit(); Serial_LateInit();
#endif
} }
char char
@ -56,6 +60,7 @@ Console_Getc()
} }
Spinlock_Unlock(&consoles.keyLock); Spinlock_Unlock(&consoles.keyLock);
#if defined(__x86_64__)
// Support serial debugging if interrupts are disabled // Support serial debugging if interrupts are disabled
if (Serial_HasData()) { if (Serial_HasData()) {
char key = Serial_Getc(); char key = Serial_Getc();
@ -68,6 +73,7 @@ Console_Getc()
return key; return key;
} }
} }
#endif
} }
} }
@ -84,6 +90,13 @@ Console_EnqueueKey(char key)
Spinlock_Unlock(&consoles.keyLock); Spinlock_Unlock(&consoles.keyLock);
} }
#if !defined(__x86_64__)
void
Panic(const char *str)
{
}
#endif
void void
Console_Gets(char *str, size_t n) Console_Gets(char *str, size_t n)
{ {
@ -131,9 +144,11 @@ void
Console_Putc(char ch) Console_Putc(char ch)
{ {
Spinlock_Lock(&consoleLock); Spinlock_Lock(&consoleLock);
#if defined(__x86_64__)
VGA_Putc(ch); VGA_Putc(ch);
Serial_Putc(ch); Serial_Putc(ch);
DebugConsole_Putc(ch); DebugConsole_Putc(ch);
#endif
Spinlock_Unlock(&consoleLock); Spinlock_Unlock(&consoleLock);
} }
@ -141,9 +156,11 @@ void
Console_Puts(const char *str) Console_Puts(const char *str)
{ {
Spinlock_Lock(&consoleLock); Spinlock_Lock(&consoleLock);
#if defined(__x86_64__)
VGA_Puts(str); VGA_Puts(str);
Serial_Puts(str); Serial_Puts(str);
DebugConsole_Puts(str); DebugConsole_Puts(str);
#endif
Spinlock_Unlock(&consoleLock); Spinlock_Unlock(&consoleLock);
} }