x86_64 build now compiles :)
[tpg/acess2.git] / Kernel / arch / x86_64 / include / arch.h
index 0dc9927..c353089 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,21 +28,25 @@ 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 char   BOOL;
+
+#define __ASM__        __asm__ __volatile__
 
-typedef volatile int    tSpinlock;
-#define IS_LOCKED(lockptr)      (!!(*(tSpinlock*)lockptr))
-#define LOCK(lockptr)   do {int v=1;\
-       while(v)\
-       __asm__ __volatile__("lock xchgl %%eax, (%%rdi)":"=a"(v):"a"(1),"D"(lockptr));\
-       }while(0)
-#define RELEASE(lockptr)       __asm__ __volatile__("lock andl $0, (%%rdi)"::"D"(lockptr));
-#define HALT()  __asm__ __volatile__ ("hlt")
+// === MACROS ===
+/**
+ * \brief Halt the CPU
+ */
+#define        HALT()  __asm__ __volatile__ ("hlt")
+/**
+ * \brief Fire a magic breakpoint (bochs)
+ */
+#define        MAGIC_BREAK()   __asm__ __volatile__ ("xchg %bx, %bx")
 
 // Systemcall Registers
 // TODO: Fix this structure
@@ -64,5 +72,29 @@ typedef struct sSyscallRegs
        Uint    Resvd5[1];      // SS   
 }      tSyscallRegs;
 
+/**
+ * \brief Short Spinlock structure
+ */
+struct sShortSpinlock {
+       #if STACKED_LOCKS == 2
+       volatile void   *Lock;  //!< Lock value
+       #else
+       volatile int    Lock;   //!< Lock value
+       #endif
+       
+       #if LOCK_DISABLE_INTS
+        int    IF;     //!< Interrupt state on call to SHORTLOCK
+       #endif
+       #if STACKED_LOCKS
+        int    Depth;
+       #endif
+};
+
+// === FUNCTIONS ===
+extern int     IS_LOCKED(struct sShortSpinlock *Lock);
+extern int     CPU_HAS_LOCK(struct sShortSpinlock *Lock);
+extern void    SHORTLOCK(struct sShortSpinlock *Lock);
+extern void    SHORTREL(struct sShortSpinlock *Lock);
+
 #endif
 

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