mirror of
https://github.com/reactos/reactos.git
synced 2025-04-28 01:11:35 +00:00
Cleanup code for easier porting to other architectures
svn path=/trunk/; revision=26180
This commit is contained in:
parent
87d76d8d95
commit
acad1159c3
17 changed files with 73 additions and 16 deletions
|
@ -1010,7 +1010,10 @@ ExpInitializeExecutive(IN ULONG Cpu,
|
|||
#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
|
||||
}
|
||||
|
|
|
@ -36,7 +36,11 @@ KiHaltProcessorDpcRoutine(IN PKDPC Dpc,
|
|||
while (TRUE)
|
||||
{
|
||||
KfRaiseIrql(SYNCH_LEVEL);
|
||||
#if defined(_M_X86)
|
||||
Ke386HaltProcessor();
|
||||
#else
|
||||
HalProcessorIdle();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1895,7 +1895,16 @@ NtFlushInstructionCache (
|
|||
{
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -105,6 +105,7 @@ extern PULONG KiInterruptTemplateObject;
|
|||
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 KGDTENTRY KiBootGdt[];
|
|||
extern KDESCRIPTOR KiGdtDescriptor;
|
||||
extern KDESCRIPTOR KiIdtDescriptor;
|
||||
extern KTSS KiBootTss;
|
||||
#endif
|
||||
extern UCHAR P0BootStack[];
|
||||
extern UCHAR KiDoubleFaultStack[];
|
||||
extern FAST_MUTEX KernelAddressSpaceLock;
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
#define DR_ACTIVE_MASK 0x10
|
||||
#define DR_REG_MASK 0x4F
|
||||
|
||||
#ifdef _M_IX86
|
||||
//
|
||||
// Sanitizes a selector
|
||||
//
|
||||
|
@ -85,6 +86,7 @@ Ke386SanitizeDr(IN PVOID DrAddress,
|
|||
return ((Mode == KernelMode) ? DrAddress :
|
||||
(DrAddress <= MM_HIGHEST_USER_ADDRESS) ? DrAddress : 0);
|
||||
}
|
||||
#endif /* _M_IX86 */
|
||||
|
||||
//
|
||||
// Enters a Guarded Region
|
||||
|
|
|
@ -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 @@ 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)
|
||||
#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, TrapFrame) == KTHREAD_TRAP_FRAME);
|
|||
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, IDR) == KPCR_IDR);
|
|||
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(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);
|
||||
|
||||
/* 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);
|
||||
#endif
|
||||
|
||||
#endif /* INCLUDE_INTERNAL_NTOSKRNL_H */
|
||||
|
|
|
@ -1400,7 +1400,7 @@ IoAllocateDriverObjectExtension(IN PDRIVER_OBJECT DriverObject,
|
|||
}
|
||||
|
||||
/* Release the lock */
|
||||
KfLowerIrql(OldIrql);
|
||||
KeLowerIrql(OldIrql);
|
||||
|
||||
/* Check if insertion failed */
|
||||
if (!Inserted)
|
||||
|
@ -1446,7 +1446,7 @@ IoGetDriverObjectExtension(IN PDRIVER_OBJECT DriverObject,
|
|||
}
|
||||
|
||||
/* Release lock */
|
||||
KfLowerIrql(OldIrql);
|
||||
KeLowerIrql(OldIrql);
|
||||
|
||||
/* Return nothing or the extension */
|
||||
if (!DriverExtensions) return NULL;
|
||||
|
|
|
@ -321,6 +321,7 @@ KiRosPrepareForSystemStartup(IN ULONG Dummy,
|
|||
IN PROS_LOADER_PARAMETER_BLOCK LoaderBlock)
|
||||
{
|
||||
PLOADER_PARAMETER_BLOCK NtLoaderBlock;
|
||||
#if defined(_M_IX86)
|
||||
PKTSS Tss;
|
||||
PKGDTENTRY TssEntry;
|
||||
|
||||
|
@ -337,6 +338,7 @@ KiRosPrepareForSystemStartup(IN ULONG Dummy,
|
|||
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 @@ KiRosPrepareForSystemStartup(IN ULONG Dummy,
|
|||
MmFreeLdrLastKrnlPhysAddr = MmFreeLdrLastKernelAddress -
|
||||
KSEG0_BASE + 0x200000;
|
||||
|
||||
#if defined(_M_IX86)
|
||||
/* Set up the VDM Data */
|
||||
NtEarlyInitVdm();
|
||||
#endif
|
||||
|
||||
/* Convert the loader block */
|
||||
KiRosFrldrLpbToNtLpb(KeRosLoaderBlock, &NtLoaderBlock);
|
||||
|
|
|
@ -151,7 +151,7 @@ KeIpiGenericCall(IN PKIPI_BROADCAST_WORKER Function,
|
|||
|
||||
/* 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);
|
||||
|
|
|
@ -157,7 +157,9 @@ KeInitializeProcess(IN OUT PKPROCESS Process,
|
|||
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);
|
||||
|
|
|
@ -461,7 +461,9 @@ KeStartThread(IN OUT PKTHREAD Thread)
|
|||
|
||||
/* 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 @@ KeInitThread(IN OUT PKTHREAD Thread,
|
|||
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 @@ KeInitThread(IN OUT PKTHREAD Thread,
|
|||
}
|
||||
}
|
||||
_SEH_END;
|
||||
#else
|
||||
Status = STATUS_SUCCESS;
|
||||
#endif
|
||||
|
||||
/* Set the Thread to initalized */
|
||||
Thread->State = Initialized;
|
||||
|
|
|
@ -406,7 +406,7 @@ MmInsertRmap(PFN_TYPE Page, PEPROCESS Process,
|
|||
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();
|
||||
|
|
|
@ -22,7 +22,7 @@ POBJECT_DIRECTORY ObpTypeDirectoryObject;
|
|||
/* 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),
|
||||
|
|
|
@ -109,6 +109,7 @@ PspGetOrSetContextKernelRoutine(IN PKAPC Apc,
|
|||
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 @@ PspGetOrSetContextKernelRoutine(IN PKAPC Apc,
|
|||
|
||||
/* Notify the Native API that we are done */
|
||||
KeSetEvent(Event, IO_NO_INCREMENT, FALSE);
|
||||
#else
|
||||
DPRINT1("PspGetOrSetContextKernelRoutine() not implemented!");
|
||||
for (;;);
|
||||
#endif
|
||||
}
|
||||
|
||||
/* PUBLIC FUNCTIONS **********************************************************/
|
||||
|
|
|
@ -74,7 +74,7 @@ PspUserThreadStartup(IN PKSTART_ROUTINE StartRoutine,
|
|||
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 @@ PspCreateThread(OUT PHANDLE ThreadHandle,
|
|||
}
|
||||
|
||||
/* 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,
|
||||
|
|
Loading…
Reference in a new issue