Author: hpoussin
Date: Tue Mar 27 00:28:13 2007
New Revision: 26180
URL:
http://svn.reactos.org/svn/reactos?rev=26180&view=rev
Log:
Cleanup code for easier porting to other architectures
Modified:
trunk/reactos/ntoskrnl/ex/init.c
trunk/reactos/ntoskrnl/ex/shutdown.c
trunk/reactos/ntoskrnl/ex/sysinfo.c
trunk/reactos/ntoskrnl/include/internal/arch/ke.h
trunk/reactos/ntoskrnl/include/internal/arch/mm.h
trunk/reactos/ntoskrnl/include/internal/ke.h
trunk/reactos/ntoskrnl/include/internal/ke_x.h
trunk/reactos/ntoskrnl/include/internal/ntoskrnl.h
trunk/reactos/ntoskrnl/io/iomgr/driver.c
trunk/reactos/ntoskrnl/ke/freeldr.c
trunk/reactos/ntoskrnl/ke/ipi.c
trunk/reactos/ntoskrnl/ke/procobj.c
trunk/reactos/ntoskrnl/ke/thrdobj.c
trunk/reactos/ntoskrnl/mm/rmap.c
trunk/reactos/ntoskrnl/ob/obname.c
trunk/reactos/ntoskrnl/ps/debug.c
trunk/reactos/ntoskrnl/ps/thread.c
Modified: trunk/reactos/ntoskrnl/ex/init.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ex/init.c?rev=261…
==============================================================================
--- trunk/reactos/ntoskrnl/ex/init.c (original)
+++ trunk/reactos/ntoskrnl/ex/init.c Tue Mar 27 00:28:13 2007
@@ -1010,7 +1010,10 @@
#elif defined(_PPC_) // <3 Arty
SharedUserData->ImageNumberLow = IMAGE_FILE_MACHINE_POWERPC;
SharedUserData->ImageNumberHigh = IMAGE_FILE_MACHINE_POWERPC;
-#elif
+#elif defined(_MIPS_)
+ SharedUserData->ImageNumberLow = IMAGE_FILE_MACHINE_R4000;
+ SharedUserData->ImageNumberHigh = IMAGE_FILE_MACHINE_R4000;
+#else
#error "Unsupported ReactOS Target"
#endif
}
Modified: trunk/reactos/ntoskrnl/ex/shutdown.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ex/shutdown.c?rev…
==============================================================================
--- trunk/reactos/ntoskrnl/ex/shutdown.c (original)
+++ trunk/reactos/ntoskrnl/ex/shutdown.c Tue Mar 27 00:28:13 2007
@@ -36,7 +36,11 @@
while (TRUE)
{
KfRaiseIrql(SYNCH_LEVEL);
+#if defined(_M_X86)
Ke386HaltProcessor();
+#else
+ HalProcessorIdle();
+#endif
}
}
Modified: trunk/reactos/ntoskrnl/ex/sysinfo.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ex/sysinfo.c?rev=…
==============================================================================
--- trunk/reactos/ntoskrnl/ex/sysinfo.c (original)
+++ trunk/reactos/ntoskrnl/ex/sysinfo.c Tue Mar 27 00:28:13 2007
@@ -1895,7 +1895,16 @@
{
PAGED_CODE();
+#if defined(_M_IX86)
__wbinvd();
+#elif defined(_M_PPC)
+#error Needs to be implemented for PPC architecture!
+#elif defined(_M_MIPS)
+ DPRINT1("NtFlushInstructionCache() is not implemented\n");
+ for (;;);
+#else
+#error Unknown architecture
+#endif
return STATUS_SUCCESS;
}
Modified: trunk/reactos/ntoskrnl/include/internal/arch/ke.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/include/internal/…
==============================================================================
--- trunk/reactos/ntoskrnl/include/internal/arch/ke.h (original)
+++ trunk/reactos/ntoskrnl/include/internal/arch/ke.h Tue Mar 27 00:28:13 2007
@@ -21,6 +21,10 @@
#ifdef _M_IX86
#include "../i386/ke.h"
+#elif defined(_M_PPC)
+#include "../powerpc/ke.h"
+#elif defined(_M_MIPS)
+#include "../mips/ke.h"
#else
#error "Unknown processor"
#endif
Modified: trunk/reactos/ntoskrnl/include/internal/arch/mm.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/include/internal/…
==============================================================================
--- trunk/reactos/ntoskrnl/include/internal/arch/mm.h (original)
+++ trunk/reactos/ntoskrnl/include/internal/arch/mm.h Tue Mar 27 00:28:13 2007
@@ -21,6 +21,10 @@
#ifdef _M_IX86
#include <internal/i386/mm.h>
+#elif defined(_M_PPC)
+#include <internal/powerpc/ke.h>
+#elif defined(_M_MIPS)
+#include <internal/mips/ke.h>
#else
#error "Unknown processor"
#endif
Modified: trunk/reactos/ntoskrnl/include/internal/ke.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/include/internal/…
==============================================================================
--- trunk/reactos/ntoskrnl/include/internal/ke.h (original)
+++ trunk/reactos/ntoskrnl/include/internal/ke.h Tue Mar 27 00:28:13 2007
@@ -105,6 +105,7 @@
extern PULONG KiInterruptTemplateDispatch;
extern PULONG KiInterruptTemplate2ndDispatch;
extern ULONG KiUnexpectedEntrySize;
+#ifdef _M_IX86
extern PVOID Ki386IopmSaveArea;
extern ULONG KeI386EFlagsAndMaskV86;
extern ULONG KeI386EFlagsOrMaskV86;
@@ -114,6 +115,7 @@
extern KDESCRIPTOR KiGdtDescriptor;
extern KDESCRIPTOR KiIdtDescriptor;
extern KTSS KiBootTss;
+#endif
extern UCHAR P0BootStack[];
extern UCHAR KiDoubleFaultStack[];
extern FAST_MUTEX KernelAddressSpaceLock;
Modified: trunk/reactos/ntoskrnl/include/internal/ke_x.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/include/internal/…
==============================================================================
--- trunk/reactos/ntoskrnl/include/internal/ke_x.h (original)
+++ trunk/reactos/ntoskrnl/include/internal/ke_x.h Tue Mar 27 00:28:13 2007
@@ -13,6 +13,7 @@
#define DR_ACTIVE_MASK 0x10
#define DR_REG_MASK 0x4F
+#ifdef _M_IX86
//
// Sanitizes a selector
//
@@ -85,6 +86,7 @@
return ((Mode == KernelMode) ? DrAddress :
(DrAddress <= MM_HIGHEST_USER_ADDRESS) ? DrAddress : 0);
}
+#endif /* _M_IX86 */
//
// Enters a Guarded Region
Modified: trunk/reactos/ntoskrnl/include/internal/ntoskrnl.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/include/internal/…
==============================================================================
--- trunk/reactos/ntoskrnl/include/internal/ntoskrnl.h (original)
+++ trunk/reactos/ntoskrnl/include/internal/ntoskrnl.h Tue Mar 27 00:28:13 2007
@@ -22,7 +22,7 @@
#undef PsGetCurrentProcess
#define PsGetCurrentProcess _PsGetCurrentProcess
-#include "i386/intrin_i.h"
+#include "arch/intrin_i.h"
#include "ke.h"
#include "i386/mm.h"
#include "i386/fpu.h"
@@ -281,7 +281,7 @@
* Use IsPointerOffset to test whether a pointer should be interpreted as an offset
* or as a pointer
*/
-#if defined(_X86_) || defined(_M_AMD64)
+#if defined(_X86_) || defined(_M_AMD64) || defined(_MIPS_)
/* for x86 and x86-64 the MSB is 1 so we can simply test on that */
#define IsPointerOffset(Ptr) ((LONG_PTR)(Ptr) >= 0)
@@ -309,11 +309,6 @@
C_ASSERT(FIELD_OFFSET(KTHREAD, CallbackStack) == KTHREAD_CALLBACK_STACK);
C_ASSERT(FIELD_OFFSET(KTHREAD, ApcState.Process) == KTHREAD_APCSTATE_PROCESS);
C_ASSERT(FIELD_OFFSET(KPROCESS, DirectoryTableBase) == KPROCESS_DIRECTORY_TABLE_BASE);
-C_ASSERT(FIELD_OFFSET(KPROCESS, IopmOffset) == KPROCESS_IOPM_OFFSET);
-C_ASSERT(FIELD_OFFSET(KPROCESS, LdtDescriptor) == KPROCESS_LDT_DESCRIPTOR0);
-C_ASSERT(FIELD_OFFSET(KV86M_TRAP_FRAME, SavedExceptionStack) ==
TF_SAVED_EXCEPTION_STACK);
-C_ASSERT(FIELD_OFFSET(KV86M_TRAP_FRAME, regs) == TF_REGS);
-C_ASSERT(FIELD_OFFSET(KV86M_TRAP_FRAME, orig_ebp) == TF_ORIG_EBP);
//C_ASSERT(FIELD_OFFSET(KPCR, Tib.ExceptionList) == KPCR_EXCEPTION_LIST);
//C_ASSERT(FIELD_OFFSET(KPCR, Self) == KPCR_SELF);
C_ASSERT(FIELD_OFFSET(KPCR, IRR) == KPCR_IRR);
@@ -321,9 +316,18 @@
C_ASSERT(FIELD_OFFSET(KPCR, Irql) == KPCR_IRQL);
C_ASSERT(FIELD_OFFSET(KIPCR, PrcbData) + FIELD_OFFSET(KPRCB, CurrentThread) ==
KPCR_CURRENT_THREAD);
C_ASSERT(FIELD_OFFSET(KIPCR, PrcbData) + FIELD_OFFSET(KPRCB, NpxThread) ==
KPCR_NPX_THREAD);
+C_ASSERT(FIELD_OFFSET(KIPCR, PrcbData) + FIELD_OFFSET(KPRCB, DpcStack) ==
KPCR_PRCB_DPC_STACK);
+C_ASSERT(sizeof(FX_SAVE_AREA) == SIZEOF_FX_SAVE_AREA);
+
+/* Platform specific checks */
+#ifdef _M_IX86
+C_ASSERT(FIELD_OFFSET(KPROCESS, IopmOffset) == KPROCESS_IOPM_OFFSET);
+C_ASSERT(FIELD_OFFSET(KPROCESS, LdtDescriptor) == KPROCESS_LDT_DESCRIPTOR0);
+C_ASSERT(FIELD_OFFSET(KV86M_TRAP_FRAME, SavedExceptionStack) ==
TF_SAVED_EXCEPTION_STACK);
+C_ASSERT(FIELD_OFFSET(KV86M_TRAP_FRAME, regs) == TF_REGS);
+C_ASSERT(FIELD_OFFSET(KV86M_TRAP_FRAME, orig_ebp) == TF_ORIG_EBP);
C_ASSERT(FIELD_OFFSET(KTSS, Esp0) == KTSS_ESP0);
C_ASSERT(FIELD_OFFSET(KTSS, IoMapBase) == KTSS_IOMAPBASE);
-C_ASSERT(FIELD_OFFSET(KIPCR, PrcbData) + FIELD_OFFSET(KPRCB, DpcStack) ==
KPCR_PRCB_DPC_STACK);
-C_ASSERT(sizeof(FX_SAVE_AREA) == SIZEOF_FX_SAVE_AREA);
+#endif
#endif /* INCLUDE_INTERNAL_NTOSKRNL_H */
Modified: trunk/reactos/ntoskrnl/io/iomgr/driver.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/io/iomgr/driver.c…
==============================================================================
--- trunk/reactos/ntoskrnl/io/iomgr/driver.c (original)
+++ trunk/reactos/ntoskrnl/io/iomgr/driver.c Tue Mar 27 00:28:13 2007
@@ -1400,7 +1400,7 @@
}
/* Release the lock */
- KfLowerIrql(OldIrql);
+ KeLowerIrql(OldIrql);
/* Check if insertion failed */
if (!Inserted)
@@ -1446,7 +1446,7 @@
}
/* Release lock */
- KfLowerIrql(OldIrql);
+ KeLowerIrql(OldIrql);
/* Return nothing or the extension */
if (!DriverExtensions) return NULL;
Modified: trunk/reactos/ntoskrnl/ke/freeldr.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ke/freeldr.c?rev=…
==============================================================================
--- trunk/reactos/ntoskrnl/ke/freeldr.c (original)
+++ trunk/reactos/ntoskrnl/ke/freeldr.c Tue Mar 27 00:28:13 2007
@@ -321,6 +321,7 @@
IN PROS_LOADER_PARAMETER_BLOCK LoaderBlock)
{
PLOADER_PARAMETER_BLOCK NtLoaderBlock;
+#if defined(_M_IX86)
PKTSS Tss;
PKGDTENTRY TssEntry;
@@ -337,6 +338,7 @@
TssEntry->BaseLow = (USHORT)((ULONG_PTR)Tss & 0xFFFF);
TssEntry->HighWord.Bytes.BaseMid = (UCHAR)((ULONG_PTR)Tss >> 16);
TssEntry->HighWord.Bytes.BaseHi = (UCHAR)((ULONG_PTR)Tss >> 24);
+#endif
/* Save pointer to ROS Block */
KeRosLoaderBlock = LoaderBlock;
@@ -351,8 +353,10 @@
MmFreeLdrLastKrnlPhysAddr = MmFreeLdrLastKernelAddress -
KSEG0_BASE + 0x200000;
+#if defined(_M_IX86)
/* Set up the VDM Data */
NtEarlyInitVdm();
+#endif
/* Convert the loader block */
KiRosFrldrLpbToNtLpb(KeRosLoaderBlock, &NtLoaderBlock);
Modified: trunk/reactos/ntoskrnl/ke/ipi.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ke/ipi.c?rev=2618…
==============================================================================
--- trunk/reactos/ntoskrnl/ke/ipi.c (original)
+++ trunk/reactos/ntoskrnl/ke/ipi.c Tue Mar 27 00:28:13 2007
@@ -151,7 +151,7 @@
/* Raise to DPC level if required */
OldIrql = KeGetCurrentIrql();
- if (OldIrql <= DISPATCH_LEVEL) KfRaiseIrql(DISPATCH_LEVEL);
+ if (OldIrql < DISPATCH_LEVEL) OldIrql = KfRaiseIrql(DISPATCH_LEVEL);
/* Acquire the IPI lock */
KefAcquireSpinLockAtDpcLevel(&KiIpiLock);
Modified: trunk/reactos/ntoskrnl/ke/procobj.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ke/procobj.c?rev=…
==============================================================================
--- trunk/reactos/ntoskrnl/ke/procobj.c (original)
+++ trunk/reactos/ntoskrnl/ke/procobj.c Tue Mar 27 00:28:13 2007
@@ -157,7 +157,9 @@
Process->QuantumReset = 6;
Process->DirectoryTableBase = *DirectoryTableBase;
Process->AutoAlignment = Enable;
+#if defined(_M_IX86)
Process->IopmOffset = KiComputeIopmOffset(IO_ACCESS_MAP_NONE);
+#endif
/* Initialize the lists */
InitializeListHead(&Process->ThreadListHead);
Modified: trunk/reactos/ntoskrnl/ke/thrdobj.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ke/thrdobj.c?rev=…
==============================================================================
--- trunk/reactos/ntoskrnl/ke/thrdobj.c (original)
+++ trunk/reactos/ntoskrnl/ke/thrdobj.c Tue Mar 27 00:28:13 2007
@@ -461,7 +461,9 @@
/* Setup static fields from parent */
Thread->DisableBoost = Process->DisableBoost;
+#if defined(_M_IX86)
Thread->Iopl = Process->Iopl;
+#endif
Thread->Quantum = Process->QuantumReset;
Thread->QuantumReset = Process->QuantumReset;
Thread->SystemAffinityActive = FALSE;
@@ -815,6 +817,7 @@
KERNEL_STACK_SIZE);
MmUpdatePageDir((PEPROCESS)Process, (PVOID)Thread, sizeof(ETHREAD));
+#if defined(_M_IX86)
/* Enter SEH to avoid crashes due to user mode */
Status = STATUS_SUCCESS;
_SEH_TRY
@@ -840,6 +843,9 @@
}
}
_SEH_END;
+#else
+ Status = STATUS_SUCCESS;
+#endif
/* Set the Thread to initalized */
Thread->State = Initialized;
Modified: trunk/reactos/ntoskrnl/mm/rmap.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/rmap.c?rev=261…
==============================================================================
--- trunk/reactos/ntoskrnl/mm/rmap.c (original)
+++ trunk/reactos/ntoskrnl/mm/rmap.c Tue Mar 27 00:28:13 2007
@@ -406,7 +406,7 @@
new_entry->Address = Address;
new_entry->Process = (PEPROCESS)Process;
#ifdef DBG
-#ifdef _GNUC_
+#ifdef __GNUC__
new_entry->Caller = __builtin_return_address(0);
#else
new_entry->Caller = _ReturnAddress();
Modified: trunk/reactos/ntoskrnl/ob/obname.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ob/obname.c?rev=2…
==============================================================================
--- trunk/reactos/ntoskrnl/ob/obname.c (original)
+++ trunk/reactos/ntoskrnl/ob/obname.c Tue Mar 27 00:28:13 2007
@@ -22,7 +22,7 @@
/* DOS Device Prefix \??\ and \?? */
ALIGNEDNAME ObpDosDevicesShortNamePrefix =
{{L'\\',L'?',L'?',L'\\'}};
ALIGNEDNAME ObpDosDevicesShortNameRoot =
{{L'\\',L'?',L'?',L'\0'}};
-UNICODE_STRING ObpDosDevicesShortName =
+static UNICODE_STRING ObpDosDevicesShortName =
{
sizeof(ObpDosDevicesShortNamePrefix),
sizeof(ObpDosDevicesShortNamePrefix),
Modified: trunk/reactos/ntoskrnl/ps/debug.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ps/debug.c?rev=26…
==============================================================================
--- trunk/reactos/ntoskrnl/ps/debug.c (original)
+++ trunk/reactos/ntoskrnl/ps/debug.c Tue Mar 27 00:28:13 2007
@@ -109,6 +109,7 @@
IN OUT PVOID* SystemArgument1,
IN OUT PVOID* SystemArgument2)
{
+#if defined(_M_IX86)
PGET_SET_CTX_CONTEXT GetSetContext;
PKEVENT Event;
PCONTEXT Context;
@@ -150,6 +151,10 @@
/* Notify the Native API that we are done */
KeSetEvent(Event, IO_NO_INCREMENT, FALSE);
+#else
+ DPRINT1("PspGetOrSetContextKernelRoutine() not implemented!");
+ for (;;);
+#endif
}
/* PUBLIC FUNCTIONS **********************************************************/
Modified: trunk/reactos/ntoskrnl/ps/thread.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ps/thread.c?rev=2…
==============================================================================
--- trunk/reactos/ntoskrnl/ps/thread.c (original)
+++ trunk/reactos/ntoskrnl/ps/thread.c Tue Mar 27 00:28:13 2007
@@ -74,7 +74,7 @@
KiInitializeUserApc(NULL,
(PVOID)((ULONG_PTR)Thread->Tcb.InitialStack -
sizeof(KTRAP_FRAME) -
- sizeof(FX_SAVE_AREA)),
+ SIZEOF_FX_SAVE_AREA),
PspSystemDllEntryPoint,
NULL,
PspSystemDllBase,
@@ -320,8 +320,16 @@
}
/* Set the Start Addresses */
+#if defined(_M_IX86)
Thread->StartAddress = (PVOID)ThreadContext->Eip;
Thread->Win32StartAddress = (PVOID)ThreadContext->Eax;
+#elif defined(_M_PPC)
+#error Not implemented yet for PPC architecture!
+#elif defined(_M_MIPS)
+ for (;;);
+#else
+#error Unknown architecture
+#endif
/* Let the kernel intialize the Thread */
Status = KeInitThread(&Thread->Tcb,