Fixes to x86_64 - Fixed MM_phys corrupting memory (forgot to initialise bitmap pointers)
[tpg/acess2.git] / Kernel / arch / x86_64 / include / arch.h
index e076b08..d419234 100644 (file)
@@ -5,10 +5,14 @@
 #ifndef _ARCH_H_
 #define _ARCH_H_
 
-#include <stdint.h>
-#define KERNEL_BASE    0xFFFF8000##00000000
+//#include <stdint.h>
+//#define KERNEL_BASE  0xFFFF8000##00000000
+#define KERNEL_BASE    0xFFFFFFFF##80000000
 #define BITS   64
 
+//#define INT_MAX      0x7FFFFFFF
+//#define UINT_MAX     0xFFFFFFFF
+
 // === Core Types ===
 typedef signed char    Sint8;
 typedef unsigned char  Uint8;
@@ -24,44 +28,47 @@ typedef signed long long int        Sint64;
 typedef unsigned long long int Uint64;
 #endif
 
+typedef Sint64 Sint;
 typedef Uint64 Uint;
 typedef Uint64 tPAddr;
 typedef Uint64 tVAddr;
 
-//typedef unsigned int size_t;
 typedef Uint64 size_t;
 
 typedef volatile int    tSpinlock;
 #define IS_LOCKED(lockptr)      (!!(*(tSpinlock*)lockptr))
-#define LOCK(lockptr)   do {int v=1;\
+#define _LOCK(lockptr,action)   do {int v=1;\
        while(v)\
-       __asm__ __volatile__("lock xchgl %%eax, (%%edi)":"=a"(v):"a"(1),"D"(lockptr));\
+       __asm__ __volatile__("lock xchgl %0, (%2)":"=r"(v):"r"(1),"r"(lockptr));\
+       if(v)   action;\
        }while(0)
-#define RELEASE(lockptr)       __asm__ __volatile__("lock andl $0, (%%edi)"::"D"(lockptr));
+#define TIGHTLOCK(lockptr)   _LOCK(lockptr, __asm__ __volatile__ ("hlt"));
+#define LOCK(lockptr)   _LOCK(lockptr, Threads_Yield());
+#define RELEASE(lockptr)       __asm__ __volatile__("lock andl $0, (%0)"::"r"(lockptr));
 #define HALT()  __asm__ __volatile__ ("hlt")
 
 // Systemcall Registers
+// TODO: Fix this structure
 typedef struct sSyscallRegs
 {
-       Uint    Arg4, Arg5;     // RDI, RSI
-       Uint    Arg6;   // RBP
-       Uint    Resvd2[1];      // Kernel RSP
-       union {
-               Uint    Arg1;
-               Uint    Error;
-       };      // RBX
-       union {
-               Uint    Arg3;
-               Uint    RetHi;  // High 64 bits of ret
-       };      // RDX
-       Uint    Arg2;   // RCX
        union {
-               Uint    Num;
-               Uint    Return;
+               Uint    Num;
+               Uint    Return;
        };      // RAX
-       Uint    Resvd3[5];      // Int, Err, rip, CS, ...
-       Uint    StackPointer;   // RSP
-       Uint    Resvd4[1];      // SS   
+       Uint    Arg4;   // RCX
+       Uint    Arg3;   // RDX
+       Uint    Error;  // RBX
+       Uint    Resvd1[2];      // Kernel RSP, RBP
+       Uint    Arg2;   // RSI
+       Uint    Arg1;   // RDI
+       Uint    Arg5;   // R8
+       Uint    Arg6;   // R9
+       Uint    Resvd2[6];      // R10 - R15
+       Uint    Resvd3[5];      // IntNum, ErrCode, RIP, CS, RFLAGS
+       
+       Uint    Resvd4[5];      // Int, Err, rip, CS, ...
+       Uint    StackPointer;   // RSP
+       Uint    Resvd5[1];      // SS   
 }      tSyscallRegs;
 
 #endif

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