We don't define types which are usually documented on "real" NT platforms in the NDK aynmore, but instead in the ARMDDK.h. This also avoids many ndk-from-ddk cross-header issues.

Added x86-only guards around certain structures and functions which are non-portable. Also guarded certain inline functions.
Added some more ARM structures, and filled out the KPRCB.
Created ARM-specific headers when required.
We can now have a buildable ARM kernel, minus a couple of compile errors.

svn path=/trunk/; revision=32178
This commit is contained in:
ReactOS Portable Systems Group 2008-02-07 06:40:42 +00:00
parent d54c5304b2
commit 46c6129581
14 changed files with 266 additions and 128 deletions

View file

@ -297,9 +297,6 @@ typedef enum _SECURITY_LOGON_TYPE
#ifdef _X86_
#define HARDWARE_PTE HARDWARE_PTE_X86
#define PHARDWARE_PTE PHARDWARE_PTE_X86
#else
#define HARDWARE_PTE ULONG
#define PHARDWARE_PTE PULONG
#endif
#define IO_CHECK_CREATE_PARAMETERS 0x0200

View file

@ -5570,9 +5570,9 @@ KeGetCurrentProcessorNumber(VOID)
#elif defined(_M_ARM)
//
// NT-ARM is not documented, need NDK
// NT-ARM is not documented, need DDK-ARM
//
#include <arm/ketypes.h>
#include <armddk.h>
#else
#error Unknown architecture

View file

@ -23,19 +23,6 @@ Author:
// Dependencies
//
//
// IRQLs
//
#define PASSIVE_LEVEL 0
#define LOW_LEVEL 0
#define APC_LEVEL 1
#define DISPATCH_LEVEL 2
#define IPI_LEVEL 7
#define POWER_LEVEL 7
#define PROFILE_LEVEL 8
#define HIGH_LEVEL 8
#define SYNCH_LEVEL (IPI_LEVEL - 1)
//
// IPI Types
//
@ -62,19 +49,6 @@ Author:
//
#define KSEG0_BASE 0x80000000
//
// FIXME: mmtypes.h?
//
#define KIPCR 0xFFFFF000
#define USPCR 0x7FFF0000
#define PCR ((volatile KPCR * const)USPCR)
#define USERPCR ((volatile KPCR * const)KIPCR)
//
// Synchronization-level IRQL
//
#define SYNCH_LEVEL DISPATCH_LEVEL
//
// Trap Frame Definition
//
@ -106,75 +80,23 @@ typedef struct _KTRAP_FRAME
ULONG FpExtra[8];
} KTRAP_FRAME, *PKTRAP_FRAME;
//
// Processor Control Region
// On ARM, it's actually readable from user-mode, much like KUSER_SHARED_DATA
//
#ifdef NTOS_MODE_USER
#define PKINTERRUPT_ROUTINE PVOID // Hack!
#endif
typedef struct _KPCR
{
ULONG MinorVersion;
ULONG MajorVersion;
PKINTERRUPT_ROUTINE InterruptRoutine[64];
PVOID XcodeDispatch;
ULONG FirstLevelDcacheSize;
ULONG FirstLevelDcacheFillSize;
ULONG FirstLevelIcacheSize;
ULONG FirstLevelIcacheFillSize;
ULONG SecondLevelDcacheSize;
ULONG SecondLevelDcacheFillSize;
ULONG SecondLevelIcacheSize;
ULONG SecondLevelIcacheFillSize;
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;
UCHAR IrqlMask[64];
UCHAR IrqlTable[64];
UCHAR CurrentIrql;
KAFFINITY SetMember;
struct _KTHREAD *CurrentThread;
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;
} KPCR, *PKPCR;
#ifndef NTOS_MODE_USER
//
// Stub
// Exception Frame Definition
//
typedef struct _KFLOATING_SAVE
typedef struct _KEXCEPTION_FRAME
{
ULONG Reserved;
} KFLOATING_SAVE, *PKFLOATING_SAVE;
ULONG PlaceHolder;
} KEXCEPTION_FRAME, *PKEXCEPTION_FRAME;
//
// Processor State
//
typedef struct _KPROCESSOR_STATE
{
struct _CONTEXT ContextFrame;
} KPROCESSOR_STATE, *PKPROCESSOR_STATE;
//
// Processor Region Control Block
@ -187,9 +109,110 @@ typedef struct _KPRCB
struct _KTHREAD *NextThread;
struct _KTHREAD *IdleThread;
UCHAR Number;
//
// TODO
//
UCHAR Reserved;
USHORT BuildType;
KAFFINITY SetMember;
KPROCESSOR_STATE ProcessorState;
ULONG KernelReserved[16];
ULONG HalReserved[16];
KSPIN_LOCK_QUEUE LockQueue[LockQueueMaximumLock];
struct _KTHREAD *NpxThread;
ULONG InterruptCount;
ULONG KernelTime;
ULONG UserTime;
ULONG DpcTime;
ULONG DebugDpcTime;
ULONG InterruptTime;
ULONG AdjustDpcThreshold;
ULONG PageColor;
UCHAR SkipTick;
UCHAR DebuggerSavedIRQL;
UCHAR NodeColor;
UCHAR Spare1;
ULONG NodeShiftedColor;
struct _KNODE *ParentNode;
ULONG MultiThreadProcessorSet;
struct _KPRCB *MultiThreadSetMaster;
ULONG SecondaryColorMask;
LONG Sleeping;
ULONG CcFastReadNoWait;
ULONG CcFastReadWait;
ULONG CcFastReadNotPossible;
ULONG CcCopyReadNoWait;
ULONG CcCopyReadWait;
ULONG CcCopyReadNoWaitMiss;
ULONG KeAlignmentFixupCount;
ULONG SpareCounter0;
ULONG KeDcacheFlushCount;
ULONG KeExceptionDispatchCount;
ULONG KeFirstLevelTbFills;
ULONG KeIcacheFlushCount;
ULONG KeSecondLevelTbFills;
ULONG KeSystemCalls;
volatile ULONG IoReadOperationCount;
volatile ULONG IoWriteOperationCount;
volatile ULONG IoOtherOperationCount;
LARGE_INTEGER IoReadTransferCount;
LARGE_INTEGER IoWriteTransferCount;
LARGE_INTEGER IoOtherTransferCount;
PP_LOOKASIDE_LIST PPLookasideList[16];
PP_LOOKASIDE_LIST PPNPagedLookasideList[32];
PP_LOOKASIDE_LIST PPPagedLookasideList[32];
volatile ULONG PacketBarrier;
volatile ULONG ReverseStall;
PVOID IpiFrame;
volatile PVOID CurrentPacket[3];
volatile ULONG TargetSet;
volatile PKIPI_WORKER WorkerRoutine;
volatile ULONG IpiFrozen;
volatile ULONG RequestSummary;
volatile struct _KPRCB *SignalDone;
struct _KDPC_DATA DpcData[2];
PVOID DpcStack;
ULONG MaximumDpcQueueDepth;
ULONG DpcRequestRate;
ULONG MinimumDpcRate;
volatile UCHAR DpcInterruptRequested;
volatile UCHAR DpcThreadRequested;
volatile UCHAR DpcRoutineActive;
volatile UCHAR DpcThreadActive;
ULONG PrcbLock;
ULONG DpcLastCount;
volatile ULONG TimerHand;
volatile ULONG TimerRequest;
PVOID DpcThread;
KEVENT DpcEvent;
UCHAR ThreadDpcEnable;
volatile BOOLEAN QuantumEnd;
volatile UCHAR IdleSchedule;
LONG DpcSetEventRequest;
LONG TickOffset;
KDPC CallDpc;
LIST_ENTRY WaitListHead;
ULONG ReadySummary;
ULONG QueueIndex;
LIST_ENTRY DispatcherReadyListHead[32];
SINGLE_LIST_ENTRY DeferredReadyListHead;
PVOID ChainedInterruptList;
LONG LookasideIrpFloat;
volatile LONG MmPageFaultCount;
volatile LONG MmCopyOnWriteCount;
volatile LONG MmTransitionCount;
volatile LONG MmCacheTransitionCount;
volatile LONG MmDemandZeroCount;
volatile LONG MmPageReadCount;
volatile LONG MmPageReadIoCount;
volatile LONG MmCacheReadCount;
volatile LONG MmCacheIoCount;
volatile LONG MmDirtyPagesWriteCount;
volatile LONG MmDirtyWriteIoCount;
volatile LONG MmMappedPagesWriteCount;
volatile LONG MmMappedWriteIoCount;
CHAR VendorString[13];
ULONG MHz;
ULONG FeatureBits;
volatile LARGE_INTEGER IsrTime;
PROCESSOR_POWER_STATE PowerState;
} KPRCB, *PKPRCB;
//

View file

@ -453,19 +453,21 @@ NTSYSCALLAPI
NTSTATUS
NTAPI
NtSetIntervalProfile(
ULONG Interval,
KPROFILE_SOURCE ClockSource
IN ULONG Interval,
IN KPROFILE_SOURCE ClockSource
);
#ifdef _M_IX86
NTSYSCALLAPI
NTSTATUS
NTAPI
NtSetLdtEntries(
ULONG Selector1,
LDT_ENTRY LdtEntry1,
ULONG Selector2,
LDT_ENTRY LdtEntry2
IN ULONG Selector1,
IN LDT_ENTRY LdtEntry1,
IN ULONG Selector2,
IN LDT_ENTRY LdtEntry2
);
#endif
NTSYSCALLAPI
NTSTATUS
@ -659,19 +661,21 @@ NTSYSAPI
NTSTATUS
NTAPI
ZwSetIntervalProfile(
ULONG Interval,
KPROFILE_SOURCE ClockSource
IN ULONG Interval,
IN KPROFILE_SOURCE ClockSource
);
#ifdef _M_IX86
NTSYSAPI
NTSTATUS
NTAPI
ZwSetLdtEntries(
ULONG Selector1,
LDT_ENTRY LdtEntry1,
ULONG Selector2,
LDT_ENTRY LdtEntry2
IN ULONG Selector1,
IN LDT_ENTRY LdtEntry1,
IN ULONG Selector2,
IN LDT_ENTRY LdtEntry2
);
#endif
NTSYSAPI
NTSTATUS

View file

@ -4106,21 +4106,10 @@ static __inline__ struct _TEB * NtCurrentTeb(void)
#elif _M_ARM
//
// NT-ARM is not documented, need NDK
// NT-ARM is not documented
//
#define NTOS_MODE_USER
#include <arm/ketypes.h>
#include <armddk.h>
//
// FIXME: Move _M_ARM stuff away from here
// *** AND NOT IN THE NDK! NDK IS ONLY FOR OFFICIALLY OBTAINABLE/EXISTING NT
//
FORCEINLINE
struct _TEB* NtCurrentTeb(VOID)
{
return (struct _TEB*)USERPCR->Teb;
}
#else
static __inline__ struct _TEB * NtCurrentTeb(void)
{

View file

@ -0,0 +1,103 @@
#ifndef _ARMDDK_
#define _ARMDDK_
//
// IRQLs
//
#define PASSIVE_LEVEL 0
#define LOW_LEVEL 0
#define APC_LEVEL 1
#define DISPATCH_LEVEL 2
#define IPI_LEVEL 7
#define POWER_LEVEL 7
#define PROFILE_LEVEL 8
#define HIGH_LEVEL 8
#define SYNCH_LEVEL (IPI_LEVEL - 1)
//
// FIXME: mmtypes.h?
//
#define KIPCR 0xFFFFF000
#define USPCR 0x7FFF0000
#define PCR ((volatile KPCR * const)USPCR)
#define USERPCR ((volatile KPCR * const)KIPCR)
//
// Stub
//
typedef struct _KFLOATING_SAVE
{
ULONG Reserved;
} KFLOATING_SAVE, *PKFLOATING_SAVE;
//
// Processor Control Region
// On ARM, it's actually readable from user-mode, much like KUSER_SHARED_DATA
//
#ifdef _WINNT_H
#define PKINTERRUPT_ROUTINE PVOID // Hack!
#endif
typedef struct _KPCR
{
ULONG MinorVersion;
ULONG MajorVersion;
PKINTERRUPT_ROUTINE InterruptRoutine[64];
PVOID XcodeDispatch;
ULONG FirstLevelDcacheSize;
ULONG FirstLevelDcacheFillSize;
ULONG FirstLevelIcacheSize;
ULONG FirstLevelIcacheFillSize;
ULONG SecondLevelDcacheSize;
ULONG SecondLevelDcacheFillSize;
ULONG SecondLevelIcacheSize;
ULONG SecondLevelIcacheFillSize;
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;
UCHAR IrqlMask[64];
UCHAR IrqlTable[64];
UCHAR CurrentIrql;
KAFFINITY SetMember;
struct _KTHREAD *CurrentThread;
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;
} KPCR, *PKPCR;
//
// Get the current TEB
//
FORCEINLINE
struct _TEB* NtCurrentTeb(VOID)
{
return (struct _TEB*)USERPCR->Teb;
}
#endif

View file

@ -25,6 +25,10 @@
#include "../powerpc/intrin_i.h"
#elif defined(_M_MIPS)
#include "../mips/intrin_i.h"
#elif defined(_M_ARM)
//
// Not sure we'll need ARM internal intrinsics
//
#else
#error "Unknown processor"
#endif

View file

@ -25,6 +25,8 @@
#include "../powerpc/ke.h"
#elif defined(_M_MIPS)
#include "../mips/ke.h"
#elif defined(_M_ARM)
#include "../arm/ke.h"
#else
#error "Unknown processor"
#endif

View file

@ -22,9 +22,11 @@
#ifdef _M_IX86
#include <internal/i386/mm.h>
#elif defined(_M_PPC)
#include <internal/powerpc/ke.h>
#include <internal/powerpc/mm.h>
#elif defined(_M_MIPS)
#include <internal/mips/ke.h>
#include <internal/mips/mm.h>
#elif defined(_M_ARM)
#include <internal/arm/mm.h>
#else
#error "Unknown processor"
#endif

View file

@ -0,0 +1 @@

View file

@ -0,0 +1 @@

View file

@ -837,11 +837,16 @@ KiInitializeMachineType(
VOID
);
//
// We need to do major portability work
//
#ifdef _M_IX86
VOID
NTAPI
KiFlushNPXState(
IN FLOATING_SAVE_AREA *SaveArea
);
#endif
VOID
NTAPI

View file

@ -350,6 +350,7 @@ FORCEINLINE
VOID
KiRundownThread(IN PKTHREAD Thread)
{
#if defined(_M_IX86) || defined(_M_AMD64)
/* Check if this is the NPX Thread */
if (KeGetCurrentPrcb()->NpxThread == Thread)
{
@ -357,6 +358,7 @@ KiRundownThread(IN PKTHREAD Thread)
KeGetCurrentPrcb()->NpxThread = NULL;
KeArchFnInit();
}
#endif
}
FORCEINLINE
@ -1552,6 +1554,11 @@ KeFlushProcessTb(VOID)
/* Flush the TLB by resetting CR3 */
#ifdef _M_PPC
__asm__("sync\n\tisync\n\t");
#elif _M_ARM
//
// We need to implement this!
//
ASSERTMSG("Need ARM flush routine\n", FALSE);
#else
__writecr3(__readcr3());
#endif

View file

@ -280,7 +280,7 @@ DefaultQueryInfoBufferCheck(ULONG Class,
* Use IsPointerOffset to test whether a pointer should be interpreted as an offset
* or as a pointer
*/
#if defined(_X86_) || defined(_M_AMD64) || defined(_MIPS_) || defined(_PPC_)
#if defined(_X86_) || defined(_M_AMD64) || defined(_MIPS_) || defined(_PPC_) || defined(_ARM_)
/* for x86 and x86-64 the MSB is 1 so we can simply test on that */
#define IsPointerOffset(Ptr) ((LONG_PTR)(Ptr) >= 0)
@ -310,10 +310,10 @@ C_ASSERT(FIELD_OFFSET(KTHREAD, ApcState.Process) == KTHREAD_APCSTATE_PROCESS);
C_ASSERT(FIELD_OFFSET(KPROCESS, DirectoryTableBase) == KPROCESS_DIRECTORY_TABLE_BASE);
//C_ASSERT(FIELD_OFFSET(KPCR, Tib.ExceptionList) == KPCR_EXCEPTION_LIST);
//C_ASSERT(FIELD_OFFSET(KPCR, Self) == KPCR_SELF);
#ifdef _M_IX86
C_ASSERT(FIELD_OFFSET(KPCR, IRR) == KPCR_IRR);
C_ASSERT(FIELD_OFFSET(KPCR, IDR) == KPCR_IDR);
C_ASSERT(FIELD_OFFSET(KPCR, Irql) == KPCR_IRQL);
#ifdef _M_IX86
C_ASSERT(FIELD_OFFSET(KIPCR, PrcbData) + FIELD_OFFSET(KPRCB, CurrentThread) == KPCR_CURRENT_THREAD);
C_ASSERT(FIELD_OFFSET(KIPCR, PrcbData) + FIELD_OFFSET(KPRCB, NextThread) == KPCR_PRCB_NEXT_THREAD);
C_ASSERT(FIELD_OFFSET(KIPCR, PrcbData) + FIELD_OFFSET(KPRCB, NpxThread) == KPCR_NPX_THREAD);