[XDK]
[reactos.git] / include / reactos / arm / armddk.h
index 71e228f..80f49db 100644 (file)
@@ -1,6 +1,14 @@
 #ifndef _ARMDDK_
 #define _ARMDDK_
 
+//
+// Page size
+//
+#ifndef PAGE_SIZE
+#define PAGE_SIZE 0x1000
+#endif
+
+#ifndef _WINNT_H
 //
 // IRQLs
 //
 #define IPI_LEVEL                         29
 #define POWER_LEVEL                       30
 #define HIGH_LEVEL                        31
+#endif
 
 //
 // FIXME: mmtypes.h?
 //
-#define KIPCR                   0xFFFFF000
-#define KI_USER_SHARED_DATA     0xFFFFE000
+#define KIP0PCRADDRESS          0xFFDFF000
+#define KI_USER_SHARED_DATA     0xFFDF0000
 #define USPCR                   0x7FFF0000
-#define PCR                     ((volatile KPCR * const)KIPCR)
+#define PCR                     ((KPCR * const)KIP0PCRADDRESS)
 #define USERPCR                 ((volatile KPCR * const)USPCR)
+#define KeGetPcr()              PCR
+#ifndef _WINNT_H
+#define SharedUserData          ((KUSER_SHARED_DATA * const)KI_USER_SHARED_DATA)
+
+//
+// Address space layout
+//
+extern PVOID MmHighestUserAddress;
+extern PVOID MmSystemRangeStart;
+extern ULONG_PTR MmUserProbeAddress;
+#define MM_HIGHEST_USER_ADDRESS           MmHighestUserAddress
+#define MM_SYSTEM_RANGE_START             MmSystemRangeStart
+#define MM_USER_PROBE_ADDRESS             MmUserProbeAddress
+#define MM_LOWEST_USER_ADDRESS            (PVOID)0x10000
+#define MM_LOWEST_SYSTEM_ADDRESS          (PVOID)0xC0800000
 
 //
 // Maximum IRQs
 //
 #define MAXIMUM_VECTOR          16
 
+#define KERNEL_STACK_SIZE                   12288
+#define KERNEL_LARGE_STACK_SIZE             61440
+#define KERNEL_LARGE_STACK_COMMIT           12288
+
 //
-// Just read it from the PCR
+// Used to contain PFNs and PFN counts
 //
-#define KeGetCurrentProcessorNumber()  (int)PCR->Number
-#define KeGetCurrentIrql()             PCR->CurrentIrql
-#define _KeGetCurrentThread()          PCR->CurrentThread
-#define _KeGetPreviousMode()           PCR->CurrentThread->PreviousMode
-#define _KeIsExecutingDpc()            (PCR->DpcRoutineActive != 0)
-#define KeGetCurrentThread()           _KeGetCurrentThread()
-#define KeGetPreviousMode()            _KeGetPreviousMode()
-#define KeGetDcacheFillSize()          PCR->DcacheFillSize
+//typedef ULONG PFN_COUNT;
+//typedef ULONG PFN_NUMBER, *PPFN_NUMBER;
+//typedef LONG SPFN_NUMBER, *PSPFN_NUMBER;
 
 //
 // Stub
@@ -50,71 +73,106 @@ typedef struct _KFLOATING_SAVE
     ULONG Reserved;
 } KFLOATING_SAVE, *PKFLOATING_SAVE;
 
+/* The following flags control the contents of the CONTEXT structure. */
+#define CONTEXT_ARM    0x0000040
+#define CONTEXT_CONTROL         (CONTEXT_ARM | 0x00000001L)
+#define CONTEXT_INTEGER         (CONTEXT_ARM | 0x00000002L)
+#define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_INTEGER)
+
+typedef struct _CONTEXT {
+       /* The flags values within this flag control the contents of
+          a CONTEXT record.
+
+          If the context record is used as an input parameter, then
+          for each portion of the context record controlled by a flag
+          whose value is set, it is assumed that that portion of the
+          context record contains valid context. If the context record
+          is being used to modify a thread's context, then only that
+          portion of the threads context will be modified.
+
+          If the context record is used as an IN OUT parameter to capture
+          the context of a thread, then only those portions of the thread's
+          context corresponding to set flags will be returned.
+
+          The context record is never used as an OUT only parameter. */
+
+       ULONG ContextFlags;
+
+       /* This section is specified/returned if the ContextFlags word contains
+          the flag CONTEXT_INTEGER. */
+       ULONG R0;
+       ULONG R1;
+       ULONG R2;
+       ULONG R3;
+       ULONG R4;
+       ULONG R5;
+       ULONG R6;
+       ULONG R7;
+       ULONG R8;
+       ULONG R9;
+       ULONG R10;
+       ULONG R11;
+       ULONG R12;
+
+       ULONG Sp;
+       ULONG Lr;
+       ULONG Pc;
+       ULONG Psr;
+} CONTEXT;
+#endif
+
 //
 // Processor Control Region
-// On ARM, it's actually readable from user-mode, much like KUSER_SHARED_DATA
 //
 #ifdef _WINNT_H
-typedef
-VOID
-(*PKINTERRUPT_ROUTINE)(VOID);
+#define KIRQL ULONG
 #endif
+
+typedef struct _NT_TIB_KPCR {
+       struct _EXCEPTION_REGISTRATION_RECORD *ExceptionList;
+       PVOID StackBase;
+       PVOID StackLimit;
+       PVOID SubSystemTib;
+       _ANONYMOUS_UNION union {
+               PVOID FiberData;
+               ULONG Version;
+       } DUMMYUNIONNAME;
+       PVOID ArbitraryUserPointer;
+       struct _NT_TIB_KPCR *Self;
+} NT_TIB_KPCR,*PNT_TIB_KPCR;
+
 typedef struct _KPCR
 {
-    ULONG MinorVersion;
-    ULONG MajorVersion;
-    PKINTERRUPT_ROUTINE InterruptRoutine[MAXIMUM_VECTOR];
-    PVOID XcodeDispatch;
-    ULONG FirstLevelDcacheSize;
-    ULONG FirstLevelDcacheFillSize;
-    ULONG FirstLevelIcacheSize;
-    ULONG FirstLevelIcacheFillSize;
-    ULONG SecondLevelDcacheSize;
-    ULONG SecondLevelDcacheFillSize;
-    ULONG SecondLevelIcacheSize;
-    ULONG SecondLevelIcacheFillSize;
+    union
+    {
+        NT_TIB_KPCR NtTib;
+        struct
+        {
+            struct _EXCEPTION_REGISTRATION_RECORD *Used_ExceptionList; // Unused
+            PVOID Used_StackBase; // Unused
+            PVOID PerfGlobalGroupMask;
+            PVOID TssCopy; // Unused
+            ULONG ContextSwitches;
+            KAFFINITY SetMemberCopy; // Unused
+            PVOID Used_Self;
+        };
+    };
+    struct _KPCR *Self;
     struct _KPRCB *Prcb;
-    struct _TEB *Teb;
-    PVOID TlsArray;
-    ULONG DcacheFillSize;
-    ULONG IcacheAlignment;
-    ULONG IcacheFillSize;
-    ULONG ProcessorId;
-    ULONG ProfileInterval;
-    ULONG ProfileCount;
-    ULONG StallExecutionCount;
-    ULONG StallScaleFactor;
-    CCHAR Number;
-    PVOID DataBusError;
-    PVOID InstructionBusError;
-    ULONG CachePolicy;
-    ULONG AlignedCachePolicy;
-    UCHAR IrqlMask[HIGH_LEVEL + 1];
-    ULONG IrqlTable[HIGH_LEVEL + 1];
-    UCHAR CurrentIrql;
+    KIRQL Irql;
+    ULONG IRR; // Unused
+    ULONG IrrActive; // Unused
+    ULONG IDR; // Unused
+    PVOID KdVersionBlock;
+    PVOID IDT; // Unused
+    PVOID GDT; // Unused
+    PVOID TSS; // Unused
+    USHORT MajorVersion;
+    USHORT MinorVersion;
     KAFFINITY SetMember;
-    struct _KTHREAD *CurrentThread;
-    ULONG ReservedVectors;
-    KAFFINITY NotMember;
-    ULONG SystemReserved[6];
-    ULONG DcacheAlignment;
-    ULONG HalReserved[64];
-    BOOLEAN FirstLevelActive;
-    BOOLEAN DpcRoutineActive;
-    ULONG CurrentPid;
-    BOOLEAN OnInterruptStack;
-    PVOID SavedInitialStack;
-    PVOID SavedStackLimit;
-    PVOID SystemServiceDispatchStart;
-    PVOID SystemServiceDispatchEnd;
-    PVOID InterruptStack;
-    PVOID PanicStack;
-    PVOID BadVaddr;
-    PVOID InitialStack;
-    PVOID StackLimit;
-    ULONG QuantumEnd;
-    PVOID PerfGlobalGroupMask;
-    ULONG ContextSwitches;
+    ULONG StallScaleFactor;
+    UCHAR SpareUnused;
+    UCHAR Number;
 } KPCR, *PKPCR;
 
 //
@@ -123,9 +181,15 @@ typedef struct _KPCR
 FORCEINLINE
 struct _TEB* NtCurrentTeb(VOID)
 {
-    return (struct _TEB*)USERPCR->Teb;
+    return (struct _TEB*)USERPCR->Used_Self;
 }
 
+NTSYSAPI
+struct _KTHREAD*
+NTAPI
+KeGetCurrentThread(VOID);
+
+#ifndef _WINNT_H
 //
 // IRQL Support on ARM is similar to MIPS/ALPHA
 //
@@ -164,5 +228,12 @@ VOID
 HalSweepIcache(
     VOID
 );
+#endif
 
+//
+// Intrinsics
+//
+#define InterlockedDecrement _InterlockedDecrement
+#define InterlockedIncrement _InterlockedIncrement
+#define InterlockedExchange  _InterlockedExchange
 #endif