x86_64 fixes
authorJohn Hodge <[email protected]>
Sat, 30 Oct 2010 13:22:18 +0000 (21:22 +0800)
committerJohn Hodge <[email protected]>
Sat, 30 Oct 2010 13:22:18 +0000 (21:22 +0800)
- Changed register output to %llx instead of %x
- Changed SPINLOCK technique
- Fiddling with scheduling

Kernel/Makefile.BuildNum.x86_64
Kernel/arch/x86_64/errors.c
Kernel/arch/x86_64/include/arch.h
Kernel/arch/x86_64/lib.c
Kernel/arch/x86_64/proc.c
Kernel/lib.c

index 9f1d290..6fe9298 100644 (file)
@@ -38,17 +38,17 @@ void Error_Handler(tRegs *Regs)
        
        Log("CPU Error %x, Code: 0x%x", Regs->IntNum, Regs->ErrorCode);
        Log(" - %s", csaERROR_NAMES[Regs->IntNum]);
-       Log(" CS:RIP = 0x%04x:%016x", Regs->CS, Regs->RIP);
-       Log(" SS:RSP = 0x%04x:%016x", Regs->SS, Regs->RSP);
-       Log(" RFLAGS = 0x%016x", Regs->RFlags);
+       Log(" CS:RIP = 0x%04x:%016llx", Regs->CS, Regs->RIP);
+       Log(" SS:RSP = 0x%04x:%016llx", Regs->SS, Regs->RSP);
+       Log(" RFLAGS = 0x%016llx", Regs->RFlags);
        
-       Log(" RAX %016x RCX %016x RDX %016x RBX %016x",
+       Log(" RAX %016llx RCX %016llx RDX %016llx RBX %016llx",
                Regs->RAX, Regs->RCX, Regs->RDX, Regs->RBX);
-       Log(" RSP %016x RBP %016x RSI %016x RDI %016x",
+       Log(" RSP %016llx RBP %016llx RSI %016llx RDI %016llx",
                Regs->RSP, Regs->RBP, Regs->RSP, Regs->RDI);
-       Log(" R8  %016x R9  %016x R10 %016x R11 %016x",
+       Log(" R8  %016llx R9  %016llx R10 %016llx R11 %016llx",
                Regs->R8, Regs->R9, Regs->R10, Regs->R11);
-       Log(" R12 %016x R13 %016x R14 %016x R15 %016x",
+       Log(" R12 %016llx R13 %016llx R14 %016llx R15 %016llx",
                Regs->R12, Regs->R13, Regs->R14, Regs->R15);
        Log(" FS %04x GS %04x", Regs->FS, Regs->GS);
        
@@ -57,9 +57,9 @@ void Error_Handler(tRegs *Regs)
        __asm__ __volatile__ ("mov %%cr0, %0":"=r"(cr));
        Warning(" CR0 0x%08x", cr);
        __asm__ __volatile__ ("mov %%cr2, %0":"=r"(cr));
-       Warning(" CR2 0x%08x", cr);
+       Warning(" CR2 0x%016llx", cr);
        __asm__ __volatile__ ("mov %%cr3, %0":"=r"(cr));
-       Warning(" CR3 0x%08x", cr);
+       Warning(" CR3 0x%016llx", cr);
        __asm__ __volatile__ ("mov %%cr4, %0":"=r"(cr));
        Warning(" CR4 0x%08x", cr);
        
index c353089..0e5cb61 100644 (file)
@@ -10,6 +10,9 @@
 #define KERNEL_BASE    0xFFFFFFFF##80000000
 #define BITS   64
 
+#define STACKED_LOCKS  0
+#define LOCK_DISABLE_INTS      1
+
 //#define INT_MAX      0x7FFFFFFF
 //#define UINT_MAX     0xFFFFFFFF
 
index f7f38c8..f20753b 100644 (file)
@@ -58,7 +58,7 @@ void SHORTLOCK(struct sShortSpinlock *Lock)
        
        #if LOCK_DISABLE_INTS
        // Save interrupt state and clear interrupts
-       __ASM__ ("pushf;\n\tpop %0\n\tcli" : "=a"(IF));
+       __ASM__ ("pushf;\n\tpop %%rax\n\tcli" : "=a"(IF));
        IF &= 0x200;    // AND out all but the interrupt flag
        #endif
        
index 1d1513b..9abcc63 100644 (file)
@@ -736,6 +736,8 @@ void Proc_Scheduler(int CPU)
        // If the spinlock is set, let it complete
        if(IS_LOCKED(&glThreadListLock))        return;
        
+       //LogF("Scheduler: CPU = %i\n", CPU);
+       
        // Get current thread
        thread = gaCPUs[CPU].Current;
        
@@ -761,12 +763,13 @@ void Proc_Scheduler(int CPU)
        // Error Check
        if(thread == NULL) {
                thread = gaCPUs[CPU].IdleThread;
-               Warning("Hmm... Threads_GetNextToRun returned NULL, I don't think this should happen.\n");
+               //Warning("Hmm... Threads_GetNextToRun returned NULL, I don't think this should happen.\n");
+               //LogF("Zzzzz.\n");
                return;
        }
        
        #if DEBUG_TRACE_SWITCH
-       Log("Switching to task %i, CR3 = 0x%x, RIP = %p",
+       LogF("Switching to task %i, CR3 = 0x%x, RIP = %p",
                thread->TID,
                thread->MemState.CR3,
                thread->SavedState.RIP
index b13d2e4..3a4f31f 100644 (file)
@@ -283,6 +283,14 @@ int vsnprintf(char *__s, size_t __maxlen, const char *__format, va_list args)
                        GETVAL();
                        itoa(p, val, 10, minSize, pad);
                        goto printString;
+               case 'X':
+                       #if BITS == 64
+                       isLongLong = 1; // TODO: Handle non-x86 64-bit archs
+                       #endif
+                       GETVAL();
+                       itoa(p, val, 16, minSize, pad);
+                       goto printString;
+                       
                case 'x':
                        GETVAL();
                        itoa(p, val, 16, minSize, pad);

UCC git Repository :: git.ucc.asn.au