From 771a05678e15c895d62ab8cd00b658f9135804cc Mon Sep 17 00:00:00 2001 From: Art Yerkes Date: Sat, 24 Jun 2006 21:34:12 +0000 Subject: [PATCH] ReactOS PowerPC WIP. This will be edited and merged, and likely shrunk. Hacks will be removed and indeed your favorite assembly snippet will eventually not be just 'blr', so please *don't panic*. svn path=/branches/powerpc/; revision=22592 --- reactos/Makefile | 8 +- reactos/ReactOS-ppc.rbuild | 15 +- reactos/boot/freeldr/bootsect/ofwboot.s | 15 +- .../boot/freeldr/freeldr/arch/powerpc/mboot.c | 7 +- reactos/boot/freeldr/freeldr/drivemap.c | 2 + .../boot/freeldr/freeldr/include/freeldr.h | 2 + reactos/hal/hal/hal.c | 9 +- reactos/include/ddk/ndis.h | 1 - reactos/include/ddk/winddk.h | 220 +++++++++++++++++- reactos/include/ndk/mmtypes.h | 7 + reactos/include/ndk/powerpc/ketypes.h | 44 +++- reactos/include/ndk/pstypes.h | 4 + reactos/include/reactos/debug.h | 2 +- reactos/include/reactos/elf/machine.h | 4 + reactos/include/reactos/libs/pseh/setjmp.h | 7 + reactos/include/reactos/probe.h | 4 + reactos/include/winnt.h | 21 +- reactos/lib/kjs/ksrc/longjmp.S | 9 +- reactos/lib/kjs/ksrc/setjmp.S | 9 +- reactos/lib/pseh/pseh.rbuild | 16 +- reactos/lib/rossym/find.c | 4 + reactos/lib/rtl/heap.c | 2 + reactos/lib/rtl/nls.c | 4 +- reactos/ntoskrnl/ex/init.c | 4 + reactos/ntoskrnl/ex/power.c | 2 + reactos/ntoskrnl/ex/sysinfo.c | 3 +- reactos/ntoskrnl/include/internal/arch/ke.h | 2 + reactos/ntoskrnl/include/internal/arch/mm.h | 2 + reactos/ntoskrnl/include/internal/arch/ps.h | 3 + reactos/ntoskrnl/include/internal/ex.h | 6 + reactos/ntoskrnl/include/internal/ntoskrnl.h | 9 +- .../ntoskrnl/include/internal/powerpc/ke.h | 46 +++- reactos/ntoskrnl/io/pnpmgr.c | 18 +- reactos/ntoskrnl/kd/kdmain.c | 4 + reactos/ntoskrnl/kd/wrappers/gdbstub.c | 22 ++ reactos/ntoskrnl/ke/apc.c | 4 + reactos/ntoskrnl/ke/bug.c | 6 + reactos/ntoskrnl/ke/clock.c | 4 + reactos/ntoskrnl/ke/dpc.c | 2 +- reactos/ntoskrnl/ke/ipi.c | 8 + reactos/ntoskrnl/ke/kthread.c | 2 + reactos/ntoskrnl/ke/main.c | 1 - reactos/ntoskrnl/ke/process.c | 4 + reactos/ntoskrnl/ke/profile.c | 2 + reactos/ntoskrnl/mm/pagefile.c | 4 + reactos/ntoskrnl/ntoskrnl.def | 1 + reactos/ntoskrnl/ntoskrnl.rbuild | 5 + reactos/ntoskrnl/ps/debug.c | 4 + reactos/ntoskrnl/ps/idle.c | 4 + reactos/ntoskrnl/ps/psmgr.c | 4 + 50 files changed, 547 insertions(+), 45 deletions(-) diff --git a/reactos/Makefile b/reactos/Makefile index 8ec2925c90c..8b555f9227c 100644 --- a/reactos/Makefile +++ b/reactos/Makefile @@ -376,7 +376,13 @@ $(ROS_AUTOMAKE): $(RBUILD_TARGET) $(PREAUTO) $(XMLBUILDFILES) $(ECHO_RBUILD) $(Q)$(RBUILD_TARGET) $(ROS_RBUILDFLAGS) mingw -world: all bootcd livecd +world: all + $(MAKE) KDBG=$(KDBG) DBG=$(DBG) \ + ROS_AUTOMAKE=$(ROS_AUTOMAKE) \ + ROS_INSTALL=$(ROS_INSTALL) \ + ROS_INTERMEDIATE=$(ROS_INTERMEDIATE) \ + ROS_OUTPUT=$(ROS_OUTPUT) \ + bootcd livecd universe: $(MAKE) KDBG=1 DBG=1 \ diff --git a/reactos/ReactOS-ppc.rbuild b/reactos/ReactOS-ppc.rbuild index 418405a912e..1b0f1b52a22 100644 --- a/reactos/ReactOS-ppc.rbuild +++ b/reactos/ReactOS-ppc.rbuild @@ -18,14 +18,14 @@ - + extern - -v + @@ -41,18 +41,15 @@ - -Wpointer-arith . include - include/reactos - include/libs - include/drivers - include/subsys - include/ndk - include include/crt include/ddk + include/GL + include/ndk + include/reactos + include/reactos/libs diff --git a/reactos/boot/freeldr/bootsect/ofwboot.s b/reactos/boot/freeldr/bootsect/ofwboot.s index d367382829d..ac9b039b8e2 100644 --- a/reactos/boot/freeldr/bootsect/ofwboot.s +++ b/reactos/boot/freeldr/bootsect/ofwboot.s @@ -6,6 +6,7 @@ _start: .long 0 .long 0 + .globl _begin _begin: sync isync @@ -19,16 +20,18 @@ _begin: mtmsr %r0 isync - bl setup_bats - - li %r8,0x3030 - mtmsr %r8 - /* Store ofw call addr */ mr %r21,%r5 lis %r10,0xe00000@ha stw %r5,ofw_call_addr - _start@l(%r10) + bl setup_bats + + li %r8,0x3030 + mtmsr %r8 + + bl ofw_print_regs + lis %r4,_binary_freeldr_tmp_end@ha addi %r4,%r4,_binary_freeldr_tmp_end@l lis %r3,_binary_freeldr_tmp_start@ha @@ -61,7 +64,7 @@ _begin: lis %r3,call_ofw@ha addi %r3,%r3,call_ofw - _start - b call_freeldr + blr /* * lifted from ppc/boot/openfirmware/misc.S diff --git a/reactos/boot/freeldr/freeldr/arch/powerpc/mboot.c b/reactos/boot/freeldr/freeldr/arch/powerpc/mboot.c index 23997df7c78..4e17e0a2718 100644 --- a/reactos/boot/freeldr/freeldr/arch/powerpc/mboot.c +++ b/reactos/boot/freeldr/freeldr/arch/powerpc/mboot.c @@ -12,6 +12,11 @@ #define NDEBUG #include +int xstrnicmp( const char *a, const char *b, int n ) { + while( n-- && *a && (*a++ == *b++) ); + return *a - *b; +} + /* Base Addres of Kernel in Physical Memory */ #define KERNEL_BASE_PHYS 0x200000 @@ -131,7 +136,7 @@ FrLdrGetKernelBase(VOID) while ((p = strchr(p, '/')) != NULL) { /* Find "/3GB" */ - if (!strnicmp(p + 1, "3GB", 3)) { + if (!xstrnicmp(p + 1, "3GB", 3)) { /* Make sure there's nothing following it */ if (p[4] == ' ' || p[4] == 0) { diff --git a/reactos/boot/freeldr/freeldr/drivemap.c b/reactos/boot/freeldr/freeldr/drivemap.c index a10a5cc1e24..af886a87d0f 100644 --- a/reactos/boot/freeldr/freeldr/drivemap.c +++ b/reactos/boot/freeldr/freeldr/drivemap.c @@ -171,6 +171,7 @@ ULONG DriveMapGetBiosDriveNumber(PCSTR DeviceName) VOID DriveMapInstallInt13Handler(PDRIVE_MAP_LIST DriveMap) { +#ifdef _M_IX86 ULONG* RealModeIVT = (ULONG*)0x00000000; USHORT* BiosLowMemorySize = (USHORT*)0x00000413; @@ -202,6 +203,7 @@ VOID DriveMapInstallInt13Handler(PDRIVE_MAP_LIST DriveMap) RealModeIVT[0x13] = DriveMapHandlerSegOff; CacheInvalidateCacheData(); +#endif DriveMapInstalled = TRUE; } diff --git a/reactos/boot/freeldr/freeldr/include/freeldr.h b/reactos/boot/freeldr/freeldr/include/freeldr.h index c2cf1e122f0..6f178403d25 100644 --- a/reactos/boot/freeldr/freeldr/include/freeldr.h +++ b/reactos/boot/freeldr/freeldr/include/freeldr.h @@ -61,6 +61,8 @@ #include #include #include +#elif defined(_PPC_) +#include #endif /* misc files */ #include diff --git a/reactos/hal/hal/hal.c b/reactos/hal/hal/hal.c index 995a1df1d89..f793201f511 100644 --- a/reactos/hal/hal/hal.c +++ b/reactos/hal/hal/hal.c @@ -836,13 +836,14 @@ KeQueryPerformanceCounter( } #undef KeRaiseIrql -VOID -NTAPI +NTOSAPI +KIRQL +DDKAPI KeRaiseIrql( - KIRQL NewIrql, - PKIRQL OldIrql) + IN KIRQL NewIrql) { UNIMPLEMENTED; + return 0; } diff --git a/reactos/include/ddk/ndis.h b/reactos/include/ddk/ndis.h index 55516be51af..865be83e3d3 100644 --- a/reactos/include/ddk/ndis.h +++ b/reactos/include/ddk/ndis.h @@ -4126,7 +4126,6 @@ typedef struct _NDIS_INTERRUPT { KEVENT DpcsCompletedEvent; } NDIS_INTERRUPT, *PNDIS_INTERRUPT; - typedef enum _NDIS_WORK_ITEM_TYPE { NdisWorkItemRequest, NdisWorkItemSend, diff --git a/reactos/include/ddk/winddk.h b/reactos/include/ddk/winddk.h index ee3e711a152..81108472062 100644 --- a/reactos/include/ddk/winddk.h +++ b/reactos/include/ddk/winddk.h @@ -5268,9 +5268,189 @@ KfReleaseSpinLock( #define KeGetDcacheFillSize() 1L -#endif /* _X86_ */ +#elif defined(_PPC_) + +typedef ULONG PFN_NUMBER, *PPFN_NUMBER; + +#define PASSIVE_LEVEL 0 +#define LOW_LEVEL 0 +#define APC_LEVEL 1 +#define DISPATCH_LEVEL 2 +#define PROFILE_LEVEL 27 +#define CLOCK1_LEVEL 28 +#define CLOCK2_LEVEL 28 +#define IPI_LEVEL 29 +#define SYNCH_LEVEL (IPI_LEVEL-1) +#define POWER_LEVEL 30 +#define HIGH_LEVEL 31 + +extern NTOSAPI PVOID MmHighestUserAddress; +extern NTOSAPI PVOID MmSystemRangeStart; +extern NTOSAPI 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)0xC0C00000 + +#define KI_USER_SHARED_DATA 0xffdf0000 +#define SharedUserData ((KUSER_SHARED_DATA * CONST) KI_USER_SHARED_DATA) + +#define EFLAG_SIGN 0x8000 +#define EFLAG_ZERO 0x4000 +#define EFLAG_SELECT (EFLAG_SIGN | EFLAG_ZERO) + +#define RESULT_NEGATIVE ((EFLAG_SIGN & ~EFLAG_ZERO) & EFLAG_SELECT) +#define RESULT_ZERO ((~EFLAG_SIGN & EFLAG_ZERO) & EFLAG_SELECT) +#define RESULT_POSITIVE ((~EFLAG_SIGN & ~EFLAG_ZERO) & EFLAG_SELECT) + +typedef struct _KPCR_TIB { + PVOID ExceptionList; /* 00 */ + PVOID StackBase; /* 04 */ + PVOID StackLimit; /* 08 */ + PVOID SubSystemTib; /* 0C */ + _ANONYMOUS_UNION union { + PVOID FiberData; /* 10 */ + DWORD Version; /* 10 */ + } DUMMYUNIONNAME; + PVOID ArbitraryUserPointer; /* 14 */ + struct _KPCR_TIB *Self; /* 18 */ +} KPCR_TIB, *PKPCR_TIB; /* 1C */ + +#define PCR_MINOR_VERSION 1 +#define PCR_MAJOR_VERSION 1 + +typedef struct _KPCR { + KPCR_TIB Tib; /* 00 */ + struct _KPCR *Self; /* 1C */ + struct _KPRCB *Prcb; /* 20 */ + KIRQL Irql; /* 24 */ + ULONG IRR; /* 28 */ + ULONG IrrActive; /* 2C */ + ULONG IDR; /* 30 */ + PVOID KdVersionBlock; /* 34 */ + PUSHORT IDT; /* 38 */ + PUSHORT GDT; /* 3C */ + struct _KTSS *TSS; /* 40 */ + USHORT MajorVersion; /* 44 */ + USHORT MinorVersion; /* 46 */ + KAFFINITY SetMember; /* 48 */ + ULONG StallScaleFactor; /* 4C */ + UCHAR SpareUnused; /* 50 */ + UCHAR Number; /* 51 */ +} KPCR, *PKPCR; /* 54 */ + +#if !defined(__INTERLOCKED_DECLARED) +#define __INTERLOCKED_DECLARED + +NTOSAPI +LONG +DDKFASTAPI +InterlockedIncrement( + IN PLONG VOLATILE Addend); + +NTOSAPI +LONG +DDKFASTAPI +InterlockedDecrement( + IN PLONG VOLATILE Addend); + +NTOSAPI +LONG +DDKFASTAPI +InterlockedCompareExchange( + IN OUT PLONG VOLATILE Destination, + IN LONG Exchange, + IN LONG Comparand); + +NTOSAPI +LONG +DDKFASTAPI +InterlockedExchange( + IN OUT PLONG VOLATILE Target, + IN LONG Value); + +NTOSAPI +LONG +DDKFASTAPI +InterlockedExchangeAdd( + IN OUT PLONG VOLATILE Addend, + IN LONG Value); + +/* + * PVOID + * InterlockedExchangePointer( + * IN OUT PVOID VOLATILE *Target, + * IN PVOID Value) + */ +#define InterlockedExchangePointer(Target, Value) \ + ((PVOID) InterlockedExchange((PLONG) Target, (LONG) Value)) + +/* + * PVOID + * InterlockedCompareExchangePointer( + * IN OUT PVOID *Destination, + * IN PVOID Exchange, + * IN PVOID Comparand) + */ +#define InterlockedCompareExchangePointer(Destination, Exchange, Comparand) \ + ((PVOID) InterlockedCompareExchange((PLONG) Destination, (LONG) Exchange, (LONG) Comparand)) + +#endif /* !__INTERLOCKED_DECLARED */ + +NTOSAPI +VOID +DDKFASTAPI +KefAcquireSpinLockAtDpcLevel( + IN PKSPIN_LOCK SpinLock); + +NTOSAPI +VOID +DDKFASTAPI +KefReleaseSpinLockFromDpcLevel( + IN PKSPIN_LOCK SpinLock); + +NTHALAPI +KIRQL +DDKFASTAPI +KfAcquireSpinLock( + IN PKSPIN_LOCK SpinLock); + +NTHALAPI +VOID +DDKFASTAPI +KfReleaseSpinLock( + IN PKSPIN_LOCK SpinLock, + IN KIRQL NewIrql); + +#define KeAcquireSpinLockAtDpcLevel(SpinLock) KefAcquireSpinLockAtDpcLevel(SpinLock) +#define KeReleaseSpinLockFromDpcLevel(SpinLock) KefReleaseSpinLockFromDpcLevel(SpinLock) +#define KeAcquireSpinLock(a,b) *(b) = KfAcquireSpinLock(a) +#define KeReleaseSpinLock(a,b) KfReleaseSpinLock(a,b) + +#define RtlCopyMemoryNonTemporal RtlCopyMemory +#define KeGetDcacheFillSize() 1L + +typedef enum _INTERLOCKED_RESULT { + ResultNegative = -1, + ResultZero = 0, + ResultPositive = 1 +} INTERLOCKED_RESULT; +typedef struct _KFLOATING_SAVE { + ULONG Fr[32]; +} KFLOATING_SAVE, *PKFLOATING_SAVE; + +static __inline +ULONG +DDKAPI +KeGetCurrentProcessorNumber(VOID) +{ + return 0; // XXX arty fixme +} +#endif /* _X86_ */ /* ** Utillity functions @@ -8653,6 +8833,15 @@ KeMemoryBarrier( #endif } +#elif defined(_PPC_) + +static __inline +VOID +KeMemoryBarrier( + VOID) +{ +} + #endif NTOSAPI @@ -8959,6 +9148,35 @@ KeRaiseIrqlToSynchLevel( #define KeLowerIrql(a) KfLowerIrql(a) #define KeRaiseIrql(a,b) *(b) = KfRaiseIrql(a) +#elif defined(_PPC_) + +NTHALAPI +VOID +FASTCALL +KfLowerIrql( + IN KIRQL NewIrql); + +NTHALAPI +KIRQL +FASTCALL +KfRaiseIrql( + IN KIRQL NewIrql); + +NTHALAPI +KIRQL +DDKAPI +KeRaiseIrqlToDpcLevel( + VOID); + +NTHALAPI +KIRQL +DDKAPI +KeRaiseIrqlToSynchLevel( + VOID); + +#define KeLowerIrql(a) KfLowerIrql(a) +#define KeRaiseIrql(a,b) *(b) = KfRaiseIrql(a) + #else NTOSAPI diff --git a/reactos/include/ndk/mmtypes.h b/reactos/include/ndk/mmtypes.h index 3ff541be0d5..7d2682ba22e 100644 --- a/reactos/include/ndk/mmtypes.h +++ b/reactos/include/ndk/mmtypes.h @@ -207,6 +207,7 @@ typedef struct _SECTION_IMAGE_INFORMATION // // PTE Structures // +#ifndef _M_PPC typedef struct _MMPTE { union @@ -221,6 +222,12 @@ typedef struct _MMPTE MMPTE_LIST List; }; } MMPTE, *PMMPTE; +#else +typedef struct _MMPTE +{ + ULONG Long; +} MMPTE, *PMMPTE; +#endif // // Section Information structure diff --git a/reactos/include/ndk/powerpc/ketypes.h b/reactos/include/ndk/powerpc/ketypes.h index 739fb7ae854..548c261962e 100644 --- a/reactos/include/ndk/powerpc/ketypes.h +++ b/reactos/include/ndk/powerpc/ketypes.h @@ -31,6 +31,45 @@ Author: #define IPI_FREEZE 3 #define IPI_PACKET_READY 4 #define IPI_SYNCH_REQUEST 10 +#define MAXIMUM_VECTOR 0x100 + +#ifndef ROUND_UP +#define ROUND_UP(x,y) (((x) + ((y)-1)) & ~((y)-1)) +#endif + +typedef double DOUBLE; + +typedef struct _FX_SAVE_AREA { + ULONG Fr[32]; +} FX_SAVE_AREA; + +typedef struct _LDT_ENTRY { + USHORT LimitLow; + USHORT BaseLow; + union + { + struct + { + UCHAR BaseMid; + UCHAR Flags1; + UCHAR Flags2; + UCHAR BaseHi; + } Bytes; + struct + { + ULONG BaseMid : 8; + ULONG Type : 5; + ULONG Dpl : 2; + ULONG Pres : 1; + ULONG LimitHi : 4; + ULONG Sys : 1; + ULONG Reserved_0 : 1; + ULONG Default_Big : 1; + ULONG Granularity : 1; + ULONG BaseHi : 8; + } Bits; + } HighWord; +} LDT_ENTRY; // // Trap Frame Definition @@ -42,7 +81,7 @@ typedef struct _KTRAP_FRAME UCHAR PreviousMode; UCHAR SavedApcStateIndex; UCHAR SavedKernelApcDisable; - UCHAR ExceptionRecord[ROUND_UP(sizeof(EXCEPTION_RECORD), ULONGLONG]; + UCHAR ExceptionRecord[ROUND_UP(sizeof(EXCEPTION_RECORD), sizeof(ULONGLONG))]; ULONG FILL2; ULONG Gpr0; ULONG Gpr1; @@ -403,7 +442,8 @@ typedef struct _KIPCR // // TSS Definition // -typedef struct _KTSS, KTSS, *PKTSS; +typedef struct _KTSS { +} KTSS, *PKTSS; // // PowerPC Exception Frame diff --git a/reactos/include/ndk/pstypes.h b/reactos/include/ndk/pstypes.h index 954e1c5ad2a..942d0ae7ddf 100644 --- a/reactos/include/ndk/pstypes.h +++ b/reactos/include/ndk/pstypes.h @@ -1117,7 +1117,11 @@ typedef struct _EPROCESS #endif union { +#ifdef _M_IX86 HARDWARE_PTE_X86 PagedirectoryPte; +#else + HARDWARE_PTE_PPC PagedirectoryPte; +#endif ULONGLONG Filler; }; ULONG Session; diff --git a/reactos/include/reactos/debug.h b/reactos/include/reactos/debug.h index a668913b79f..7e99d2ce07e 100644 --- a/reactos/include/reactos/debug.h +++ b/reactos/include/reactos/debug.h @@ -125,7 +125,7 @@ RtlAssert( #elif defined(_M_MIPS) #define ASM_BREAKPOINT "\nbreak\n" #else -#error Unsupported architecture. +#define ASM_BREAKPOINT "\ntwi 1\n" #endif #ifndef KEBUGCHECK diff --git a/reactos/include/reactos/elf/machine.h b/reactos/include/reactos/elf/machine.h index 27d7e494ebd..a570b1c4adf 100644 --- a/reactos/include/reactos/elf/machine.h +++ b/reactos/include/reactos/elf/machine.h @@ -5,6 +5,10 @@ #define _REACTOS_ELF_MACHINE_IS_TARGET #include #undef _REACTOS_ELF_MACHINE_IS_TARGET +#elif defined(_M_PPC) +#define _REACTOS_ELF_MACHINE_IS_TARGET +#include +#undef _REACTOS_ELF_MACHINE_IS_TARGET #else #error Unsupported target architecture #endif diff --git a/reactos/include/reactos/libs/pseh/setjmp.h b/reactos/include/reactos/libs/pseh/setjmp.h index c7096b4f73c..575c7cfd143 100644 --- a/reactos/include/reactos/libs/pseh/setjmp.h +++ b/reactos/include/reactos/libs/pseh/setjmp.h @@ -34,6 +34,13 @@ typedef struct __SEHJmpBuf unsigned long JB_Edi; } _SEHJmpBuf_t[1]; +#elif defined(_M_PPC) +typedef struct __SEHJmpBuf +{ + unsigned long R[32]; + unsigned long LR, CTR; +} +_SEHJmpBuf_t[1]; #endif #ifdef __cplusplus diff --git a/reactos/include/reactos/probe.h b/reactos/include/reactos/probe.h index 04e83369ab6..e13dfa8d40d 100644 --- a/reactos/include/reactos/probe.h +++ b/reactos/include/reactos/probe.h @@ -5,6 +5,10 @@ #error Header intended for use by NTOSKRNL/WIN32K only! #endif +#if defined(_M_PPC) +extern ULONG_PTR MmUserProbeAddress; +#endif + static const UNICODE_STRING __emptyUnicodeString = {0}; static const LARGE_INTEGER __emptyLargeInteger = {{0, 0}}; static const ULARGE_INTEGER __emptyULargeInteger = {{0, 0}}; diff --git a/reactos/include/winnt.h b/reactos/include/winnt.h index bfaab02e6ef..f793c8d7e4f 100644 --- a/reactos/include/winnt.h +++ b/reactos/include/winnt.h @@ -1838,6 +1838,9 @@ typedef struct _CONTEXT { DWORD Dr6; DWORD Dr7; } CONTEXT; +typedef struct _FLOATING_SAVE_AREA { + DWORD Fr[32]; +} FLOATING_SAVE_AREA; #elif defined(_ALPHA_) #define CONTEXT_ALPHA 0x20000 #define CONTEXT_CONTROL (CONTEXT_ALPHA|1L) @@ -3699,16 +3702,21 @@ typedef struct _OBJECT_TYPE_LIST { static __inline__ PVOID GetCurrentFiber(void) { +#ifdef _X86_ void* ret; __asm__ __volatile__ ( "movl %%fs:0x10,%0" : "=r" (ret) /* allow use of reg eax,ebx,ecx,edx,esi,edi */ ); return ret; +#elif defined(_PPC_) + return NULL; +#endif } static __inline__ struct _TEB * NtCurrentTeb(void) { +#ifdef _X86_ struct _TEB *ret; __asm__ __volatile__ ( @@ -3718,6 +3726,9 @@ static __inline__ struct _TEB * NtCurrentTeb(void) ); return ret; +#elif defined(_PPC_) + return NULL; +#endif } #elif defined(__WATCOMC__) @@ -3778,13 +3789,14 @@ InterlockedBitTestAndSet(IN LONG *Base, IN LONG Bit) { LONG OldBit; - +#ifdef _M_IX86 __asm__ __volatile__("lock " "btsl %2,%1\n\t" "sbbl %0,%0\n\t" :"=r" (OldBit),"=m" (*Base) :"Ir" (Bit) : "memory"); +#endif return OldBit; } @@ -3793,19 +3805,24 @@ InterlockedBitTestAndReset(IN LONG *Base, IN LONG Bit) { LONG OldBit; - +#ifdef _M_IX86 __asm__ __volatile__("lock " "btrl %2,%1\n\t" "sbbl %0,%0\n\t" :"=r" (OldBit),"=m" (*Base) :"Ir" (Bit) : "memory"); +#endif return OldBit; } #endif +#ifdef _M_IX86 #define YieldProcessor() __asm__ __volatile__("pause"); +#elif defined(_M_PPC) +#define YieldProcessor() __asm__("ori 0,0,0"); +#endif #if defined(_AMD64_) #if defined(_M_AMD64) diff --git a/reactos/lib/kjs/ksrc/longjmp.S b/reactos/lib/kjs/ksrc/longjmp.S index f998344ae06..7cb15cfee9d 100644 --- a/reactos/lib/kjs/ksrc/longjmp.S +++ b/reactos/lib/kjs/ksrc/longjmp.S @@ -38,7 +38,8 @@ * return PC */ -.globl _longjmp +#ifdef _M_IX86 + .globl _longjmp _longjmp: pushl %ebp movl %esp,%ebp @@ -69,4 +70,8 @@ _longjmp: */ jmpl *20(%ecx) - +#else + .globl _longjmp +_longjmp: + blr +#endif diff --git a/reactos/lib/kjs/ksrc/setjmp.S b/reactos/lib/kjs/ksrc/setjmp.S index 885908e5ec4..2d310dc348b 100644 --- a/reactos/lib/kjs/ksrc/setjmp.S +++ b/reactos/lib/kjs/ksrc/setjmp.S @@ -37,7 +37,8 @@ * ptr to jmp_buf * return PC */ -.globl _setjmp +#ifdef _M_IX86 + .globl _setjmp _setjmp: pushl %ebp movl %esp,%ebp @@ -56,4 +57,8 @@ _setjmp: xorl %eax,%eax /* return 0 the first time */ leave ret - +#else + .globl _setjmp +_setjmp: + blr +#endif diff --git a/reactos/lib/pseh/pseh.rbuild b/reactos/lib/pseh/pseh.rbuild index 15e96420ebe..29ae4563ae5 100644 --- a/reactos/lib/pseh/pseh.rbuild +++ b/reactos/lib/pseh/pseh.rbuild @@ -1,8 +1,16 @@ - - framebased.asm - setjmp.asm - + + + framebased.asm + setjmp.asm + + + + + framebased.s + setjmp.s + + framebased.c diff --git a/reactos/lib/rossym/find.c b/reactos/lib/rossym/find.c index 6f18c356248..8487f9d5174 100644 --- a/reactos/lib/rossym/find.c +++ b/reactos/lib/rossym/find.c @@ -104,7 +104,11 @@ RosSymGetAddressInformation(PROSSYM_INFO RosSymInfo, if (RosSymInfo->Symbols == NULL || RosSymInfo->SymbolsCount == 0 || RosSymInfo->Strings == NULL || RosSymInfo->StringsLength == 0) { +#ifdef _X86_ __asm__("int $3\n"); +#elif defined(_PPC_) +__asm__("twi 0,0,0\n"); +#endif DPRINT1("Uninitialized RosSymInfo\n"); return FALSE; } diff --git a/reactos/lib/rtl/heap.c b/reactos/lib/rtl/heap.c index d420a85a7f7..d9d0cf1601f 100644 --- a/reactos/lib/rtl/heap.c +++ b/reactos/lib/rtl/heap.c @@ -962,6 +962,7 @@ int HEAP_IsInsideHeap( void DumpStackFrames ( PULONG Frame, ULONG FrameCount ) { +#ifdef _M_IX86 ULONG i=0; DbgPrint("Frames: "); @@ -983,6 +984,7 @@ void DumpStackFrames ( PULONG Frame, ULONG FrameCount ) DbgPrint(" "); } DbgPrint("\n"); +#endif } /*********************************************************************** diff --git a/reactos/lib/rtl/nls.c b/reactos/lib/rtl/nls.c index 9923dbcde5f..6789b249c7c 100644 --- a/reactos/lib/rtl/nls.c +++ b/reactos/lib/rtl/nls.c @@ -365,7 +365,7 @@ RtlResetRtlTranslations(IN PNLSTABLEINFO NlsTable) DPRINT("RtlResetRtlTranslations() called\n"); /* Set ANSI data */ - NlsAnsiToUnicodeTable = NlsTable->AnsiTableInfo.MultiByteTable; + NlsAnsiToUnicodeTable = (void *)NlsTable->AnsiTableInfo.MultiByteTable; NlsUnicodeToAnsiTable = NlsTable->AnsiTableInfo.WideCharTable; NlsDbcsUnicodeToAnsiTable = (PWCHAR)NlsTable->AnsiTableInfo.WideCharTable; NlsMbCodePageTag = (NlsTable->AnsiTableInfo.DBCSCodePage != 0); @@ -374,7 +374,7 @@ RtlResetRtlTranslations(IN PNLSTABLEINFO NlsTable) DPRINT("Ansi codepage %hu\n", NlsAnsiCodePage); /* Set OEM data */ - NlsOemToUnicodeTable = NlsTable->OemTableInfo.MultiByteTable; + NlsOemToUnicodeTable = (void *)NlsTable->OemTableInfo.MultiByteTable; NlsUnicodeToOemTable = NlsTable->OemTableInfo.WideCharTable; NlsDbcsUnicodeToOemTable = (PWCHAR)NlsTable->OemTableInfo.WideCharTable; NlsMbOemCodePageTag = (NlsTable->OemTableInfo.DBCSCodePage != 0); diff --git a/reactos/ntoskrnl/ex/init.c b/reactos/ntoskrnl/ex/init.c index f9c1e11f275..d81ee305ead 100644 --- a/reactos/ntoskrnl/ex/init.c +++ b/reactos/ntoskrnl/ex/init.c @@ -73,7 +73,9 @@ InitSystemSharedUserPage (PCSZ ParameterLine) * The shared user page has been zeroed-out right after creation. * There is NO need to do this again. */ +#ifdef _M_IX86 Ki386SetProcessorFeatures(); +#endif /* Set the Version Data */ SharedUserData->NtProductType = NtProductWinNt; @@ -238,6 +240,7 @@ VOID STDCALL ExecuteRuntimeAsserts(VOID) { +#ifdef _M_IX86 /* * Fail at runtime if someone has changed various structures without * updating the offsets used for the assembler code. @@ -265,6 +268,7 @@ ExecuteRuntimeAsserts(VOID) ASSERT(FIELD_OFFSET(KTSS, Esp0) == KTSS_ESP0); ASSERT(FIELD_OFFSET(KTSS, IoMapBase) == KTSS_IOMAPBASE); ASSERT(sizeof(FX_SAVE_AREA) == SIZEOF_FX_SAVE_AREA); +#endif } __inline diff --git a/reactos/ntoskrnl/ex/power.c b/reactos/ntoskrnl/ex/power.c index 3dd62dbc351..acdc62ce4da 100644 --- a/reactos/ntoskrnl/ex/power.c +++ b/reactos/ntoskrnl/ex/power.c @@ -36,7 +36,9 @@ KiHaltProcessorDpcRoutine(IN PKDPC Dpc, while (TRUE) { KfRaiseIrql(SYNCH_LEVEL); +#ifdef _M_IX86 Ke386HaltProcessor(); +#endif } } diff --git a/reactos/ntoskrnl/ex/sysinfo.c b/reactos/ntoskrnl/ex/sysinfo.c index b9dc72c3e8e..9dd9a196eb0 100644 --- a/reactos/ntoskrnl/ex/sysinfo.c +++ b/reactos/ntoskrnl/ex/sysinfo.c @@ -1646,8 +1646,9 @@ NtFlushInstructionCache ( ) { PAGED_CODE(); - +#ifdef _M_IX86 __asm__("wbinvd\n"); +#endif return STATUS_SUCCESS; } diff --git a/reactos/ntoskrnl/include/internal/arch/ke.h b/reactos/ntoskrnl/include/internal/arch/ke.h index 8cdcf9cde0f..d71629ca3ad 100644 --- a/reactos/ntoskrnl/include/internal/arch/ke.h +++ b/reactos/ntoskrnl/include/internal/arch/ke.h @@ -21,6 +21,8 @@ #ifdef _M_IX86 #include "../i386/ke.h" +#elif defined(_M_PPC) +#include "../powerpc/ke.h" #else #error "Unknown processor" #endif diff --git a/reactos/ntoskrnl/include/internal/arch/mm.h b/reactos/ntoskrnl/include/internal/arch/mm.h index aded673559b..ba71467d381 100644 --- a/reactos/ntoskrnl/include/internal/arch/mm.h +++ b/reactos/ntoskrnl/include/internal/arch/mm.h @@ -21,6 +21,8 @@ #ifdef _M_IX86 #include +#elif defined(_M_PPC) +#include #else #error "Unknown processor" #endif diff --git a/reactos/ntoskrnl/include/internal/arch/ps.h b/reactos/ntoskrnl/include/internal/arch/ps.h index c10edcb32aa..014124ff353 100644 --- a/reactos/ntoskrnl/include/internal/arch/ps.h +++ b/reactos/ntoskrnl/include/internal/arch/ps.h @@ -4,6 +4,9 @@ #ifdef _M_IX86 #define KiArchContextSwitch KiSwapContext #define KiArchInitThreadWithContext Ke386InitThreadWithContext +#elif defined(_M_PPC) +#define KiArchContextSwitch KiSwapContext +#define KiArchInitThreadWithContext KePPCInitThreadWithContext #else #error "Unknown processor" #endif diff --git a/reactos/ntoskrnl/include/internal/ex.h b/reactos/ntoskrnl/include/internal/ex.h index 8eb5cfb18cb..ff149a03a10 100644 --- a/reactos/ntoskrnl/include/internal/ex.h +++ b/reactos/ntoskrnl/include/internal/ex.h @@ -16,6 +16,7 @@ extern POBJECT_TYPE ExEventPairObjectType; EX_HANDLE_ENTRY_AUDITONCLOSE))) /* Note: we only use a spinlock on SMP. On UP, we cli/sti intead */ +#ifdef _M_IX86 #ifndef CONFIG_SMP #define ExAcquireResourceLock(l, i) { \ (void)i; \ @@ -25,6 +26,11 @@ extern POBJECT_TYPE ExEventPairObjectType; #else #define ExAcquireResourceLock(l, i) KeAcquireSpinLock(l, i); #define ExReleaseResourceLock(l, i) KeReleaseSpinLock(l, i); +#endif /* CONFIG_SMP */ +#elif defined(_M_PPC) /* _M_IX86 */ +/* XXX arty fixme */ +#define ExAcquireResourceLock(l,i) KeAcquireSpinLock(l,i); +#define ExReleaseResourceLock(l,i) KeReleaseSpinLock(l,i); #endif /* INITIALIZATION FUNCTIONS *************************************************/ diff --git a/reactos/ntoskrnl/include/internal/ntoskrnl.h b/reactos/ntoskrnl/include/internal/ntoskrnl.h index 65b6e2b7c9a..2fa20e46260 100644 --- a/reactos/ntoskrnl/include/internal/ntoskrnl.h +++ b/reactos/ntoskrnl/include/internal/ntoskrnl.h @@ -12,9 +12,15 @@ #ifdef _NTOSKRNL_ #include "ke.h" +#ifdef _M_IX86 #include "i386/mm.h" #include "i386/fpu.h" #include "i386/v86m.h" +#elif defined(_M_PPC) +#include "powerpc/mm.h" +#else +#error "Unknown CPU" +#endif #include "ob.h" #include "mm.h" #include "ps.h" @@ -247,7 +253,8 @@ DefaultQueryInfoBufferCheck(UINT Class, /* on Itanium if the 24 most significant bits are set, we're not dealing with offsets anymore. */ #define IsPointerOffset(Ptr) (((ULONG_PTR)(Ptr) & 0xFFFFFF0000000000ULL) == 0) - +#elif defined(_PPC_) +#define IsPointerOffset(Ptr) ((LONG_PTR)(Ptr) >= 0) #else #error IsPointerOffset() needs to be defined for this architecture #endif diff --git a/reactos/ntoskrnl/include/internal/powerpc/ke.h b/reactos/ntoskrnl/include/internal/powerpc/ke.h index a2973609ff5..cfa14164b9e 100644 --- a/reactos/ntoskrnl/include/internal/powerpc/ke.h +++ b/reactos/ntoskrnl/include/internal/powerpc/ke.h @@ -126,11 +126,53 @@ __asm__ __volatile__("mfmsr 0\n\t" \ #define KePPCHaltProcessor() ; -#endif /* __ASM__ */ - #define KeArchEraseFlags() #define KeArchDisableInterrupts() KePPCDisableInterrupts() +static __inline struct _KPRCB * KeGetCurrentPrcb( + VOID) +{ + ULONG Value = 0; + return (struct _KPRCB *) Value; +} + +static __inline KIRQL KeGetCurrentIrql( + VOID) +{ + return PASSIVE_LEVEL; +} + +VOID +STDCALL +KePPCInitThreadWithContext( + PKTHREAD Thread, + PKSYSTEM_ROUTINE SystemRoutine, + PKSTART_ROUTINE StartRoutine, + PVOID StartContext, + PCONTEXT Context); + +VOID +STDCALL +KeApplicationProcessorInitDispatcher( + VOID); + +VOID +STDCALL +KeCreateApplicationProcessorIdleThread( + ULONG Id); + +#ifdef _NTOSKRNL_ /* FIXME: Move flags above to NDK instead of here */ +VOID +STDCALL +KiThreadStartup(PKSYSTEM_ROUTINE SystemRoutine, + PKSTART_ROUTINE StartRoutine, + PVOID StartContext, + BOOLEAN UserThread, + KTRAP_FRAME TrapFrame); +#endif + +#endif /* __ASM__ */ + #endif /* __NTOSKRNL_INCLUDE_INTERNAL_POWERPC_KE_H */ /* EOF */ diff --git a/reactos/ntoskrnl/io/pnpmgr.c b/reactos/ntoskrnl/io/pnpmgr.c index 7863df2dc78..0f836ffd812 100644 --- a/reactos/ntoskrnl/io/pnpmgr.c +++ b/reactos/ntoskrnl/io/pnpmgr.c @@ -775,6 +775,7 @@ IopInitiatePnpIrp(PDEVICE_OBJECT DeviceObject, return Status; } +ULONG TreeTraverse = 0; NTSTATUS IopTraverseDeviceTreeNode(PDEVICETREE_TRAVERSE_CONTEXT Context) @@ -782,6 +783,10 @@ IopTraverseDeviceTreeNode(PDEVICETREE_TRAVERSE_CONTEXT Context) PDEVICE_NODE ParentDeviceNode; PDEVICE_NODE ChildDeviceNode; NTSTATUS Status; + ULONG Indent = TreeTraverse; + + while( Indent-- ) DbgPrint(" "); + DPRINT1("Checking device node 0x%x\n", Context->DeviceNode); /* Copy context data so we don't overwrite it in subsequent calls to this function */ ParentDeviceNode = Context->DeviceNode; @@ -793,6 +798,8 @@ IopTraverseDeviceTreeNode(PDEVICETREE_TRAVERSE_CONTEXT Context) return Status; } + TreeTraverse++; + /* Traversal of all children nodes */ for (ChildDeviceNode = ParentDeviceNode->Child; ChildDeviceNode != NULL; @@ -804,10 +811,19 @@ IopTraverseDeviceTreeNode(PDEVICETREE_TRAVERSE_CONTEXT Context) Status = IopTraverseDeviceTreeNode(Context); if (!NT_SUCCESS(Status)) { - return Status; + Indent = TreeTraverse; + while( Indent-- ) DbgPrint(" "); + DPRINT1("Device node 0x%x done (bad)\n", Context->DeviceNode); + TreeTraverse--; + return Status; } } + Indent = TreeTraverse; + while( Indent-- ) DbgPrint(" "); + DPRINT1("Device node 0x%x done (good)\n", Context->DeviceNode); + + TreeTraverse--; return Status; } diff --git a/reactos/ntoskrnl/kd/kdmain.c b/reactos/ntoskrnl/kd/kdmain.c index 88b5e0424f1..126914d1fc6 100644 --- a/reactos/ntoskrnl/kd/kdmain.c +++ b/reactos/ntoskrnl/kd/kdmain.c @@ -198,7 +198,11 @@ KeEnterKernelDebugger(VOID) KdEnteredDebugger = TRUE; /* Halt the CPU */ +#ifdef _M_IX86 for (;;) Ke386HaltProcessor(); +#elif defined(_M_PPC) + for (;;); +#endif } /* diff --git a/reactos/ntoskrnl/kd/wrappers/gdbstub.c b/reactos/ntoskrnl/kd/wrappers/gdbstub.c index 64047de09b3..8c6c174dd35 100644 --- a/reactos/ntoskrnl/kd/wrappers/gdbstub.c +++ b/reactos/ntoskrnl/kd/wrappers/gdbstub.c @@ -129,6 +129,7 @@ typedef struct _CPU_REGISTER static CPU_REGISTER GspRegisters[NUMREGS] = { +#ifdef _M_IX86 { 4, FIELD_OFFSET(KTRAP_FRAME, Eax), FIELD_OFFSET(CONTEXT, Eax), TRUE }, { 4, FIELD_OFFSET(KTRAP_FRAME, Ecx), FIELD_OFFSET(CONTEXT, Ecx), TRUE }, { 4, FIELD_OFFSET(KTRAP_FRAME, Edx), FIELD_OFFSET(CONTEXT, Edx), FALSE }, @@ -145,6 +146,7 @@ static CPU_REGISTER GspRegisters[NUMREGS] = { 4, FIELD_OFFSET(KTRAP_FRAME, SegEs), FIELD_OFFSET(CONTEXT, SegEs), TRUE }, { 4, FIELD_OFFSET(KTRAP_FRAME, SegFs), FIELD_OFFSET(CONTEXT, SegFs), TRUE }, { 4, FIELD_OFFSET(KTRAP_FRAME, SegGs), FIELD_OFFSET(CONTEXT, SegGs), TRUE } +#endif }; static PCHAR GspThreadStates[DeferredReady+1] = @@ -563,8 +565,12 @@ GspLong2Hex(PCHAR *Address, static LONG GspGetEspFromTrapFrame(PKTRAP_FRAME TrapFrame) { +#ifdef _M_IX86 return KeGetPreviousMode() == KernelMode ? (LONG) &TrapFrame->HardwareEsp : (LONG)TrapFrame->HardwareEsp; +#elif defined(_M_PPC) + return 0; +#endif } @@ -613,12 +619,14 @@ GspGetRegisters(PCHAR Address, case ESP: Value = (ULONG_PTR) (KernelStack + 8); break; +#ifdef _M_IX86 case CS: Value = KGDT_R0_CODE; break; case DS: Value = KGDT_R0_DATA; break; +#endif default: Value = 0; break; @@ -1332,12 +1340,16 @@ KdpGdbEnterDebuggerException(PEXCEPTION_RECORD ExceptionRecord, DPRINT("Thread %p acquired mutex\n", PsGetCurrentThread()); /* Disable hardware debugging while we are inside the stub */ +#ifdef _M_IX86 #if defined(__GNUC__) __asm__("movl %0,%%db7" : /* no output */ : "r" (0)); #elif defined(_MSC_VER) __asm mov eax, 0 __asm mov dr7, eax #else #error Unknown compiler for inline assembler +#endif +#elif defined(_M_PPC) + /* XXX arty fixme */ #endif GspUnloadBreakpoints(TrapFrame); @@ -1373,6 +1385,7 @@ KdpGdbEnterDebuggerException(PEXCEPTION_RECORD ExceptionRecord, ptr = GspMem2Hex((PCHAR) &Esp, ptr, 4, 0); *ptr++ = ';'; +#ifdef _M_IX86 *ptr++ = HexChars[EBP]; *ptr++ = ':'; ptr = GspMem2Hex((PCHAR) &TrapFrame->Ebp, ptr, 4, 0); /* FP */ @@ -1382,6 +1395,7 @@ KdpGdbEnterDebuggerException(PEXCEPTION_RECORD ExceptionRecord, *ptr++ = ':'; ptr = GspMem2Hex((PCHAR) &TrapFrame->Eip, ptr, 4, 0); /* PC */ *ptr++ = ';'; +#endif *ptr = '\0'; @@ -1558,12 +1572,16 @@ KdpGdbEnterDebuggerException(PEXCEPTION_RECORD ExceptionRecord, Context->EFlags |= 0x100; } +#ifdef _M_IX86 #if defined(__GNUC__) asm volatile ("movl %%db6, %0\n" : "=r" (dr6_) : ); #elif defined(_MSC_VER) __asm mov eax, dr6 __asm mov dr6_, eax; #else #error Unknown compiler for inline assembler +#endif +#elif defined(_M_PPC) + /* XXX arty fixme */ #endif if (!(dr6_ & 0x4000)) { @@ -1581,12 +1599,16 @@ KdpGdbEnterDebuggerException(PEXCEPTION_RECORD ExceptionRecord, } } GspLoadBreakpoints(TrapFrame); +#ifdef _M_IX86 #if defined(__GNUC__) asm volatile ("movl %0, %%db6\n" : : "r" (0)); #elif defined(_MSC_VER) __asm mov eax, 0 __asm mov dr6, eax; #else #error Unknown compiler for inline assembler +#endif +#elif defined(_M_PPC) + /* XXX arty fixme */ #endif if (NULL != GspDbgThread) diff --git a/reactos/ntoskrnl/ke/apc.c b/reactos/ntoskrnl/ke/apc.c index a367aeeb04f..4f02df5d3f1 100644 --- a/reactos/ntoskrnl/ke/apc.c +++ b/reactos/ntoskrnl/ke/apc.c @@ -908,8 +908,10 @@ KiInitializeUserApc(IN PKEXCEPTION_FRAME ExceptionFrame, DPRINT("KiInitializeUserApc(TrapFrame %x/%x)\n", TrapFrame, KeGetCurrentThread()->TrapFrame); +#ifdef _M_IX86 /* Don't deliver APCs in V86 mode */ if (TrapFrame->EFlags & X86_EFLAGS_VM) return; +#endif /* Save the full context */ Context.ContextFlags = CONTEXT_FULL | CONTEXT_DEBUG_REGISTERS; @@ -928,9 +930,11 @@ KiInitializeUserApc(IN PKEXCEPTION_FRAME ExceptionFrame, &Context, sizeof(CONTEXT)); +#ifdef _M_IX86 /* Run at APC dispatcher */ TrapFrame->Eip = (ULONG)KeUserApcDispatcher; TrapFrame->HardwareEsp = Stack; +#endif /* Setup the stack */ *(PULONG_PTR)(Stack + 0 * sizeof(ULONG_PTR)) = (ULONG_PTR)NormalRoutine; diff --git a/reactos/ntoskrnl/ke/bug.c b/reactos/ntoskrnl/ke/bug.c index d471ca40773..b6c09d56a91 100644 --- a/reactos/ntoskrnl/ke/bug.c +++ b/reactos/ntoskrnl/ke/bug.c @@ -35,7 +35,9 @@ static LIST_ENTRY BugcheckCallbackListHead = {NULL,NULL}; static LIST_ENTRY BugcheckReasonCallbackListHead = {NULL,NULL}; static ULONG InBugCheck; static PRTL_MESSAGE_RESOURCE_DATA KiBugCodeMessages; +#ifdef _M_IX86 static ULONG KeBugCheckCount = 1; +#endif /* FUNCTIONS *****************************************************************/ @@ -298,6 +300,7 @@ KeBugCheckWithTf(ULONG BugCheckCode, ULONG BugCheckParameter4, PKTRAP_FRAME Tf) { +#ifdef _M_IX86 KIRQL OldIrql; BOOLEAN GotExtendedCrashInfo = FALSE; PVOID Address = 0; @@ -469,6 +472,9 @@ KeBugCheckWithTf(ULONG BugCheckCode, /* Halt this CPU now */ for (;;) Ke386HaltProcessor(); +#elif defined(_M_PPC) + for (;;); +#endif } /* diff --git a/reactos/ntoskrnl/ke/clock.c b/reactos/ntoskrnl/ke/clock.c index 29a27cd84a7..7a5171b23cc 100644 --- a/reactos/ntoskrnl/ke/clock.c +++ b/reactos/ntoskrnl/ke/clock.c @@ -260,6 +260,7 @@ KeUpdateRunTime( CurrentThread = Prcb->CurrentThread; CurrentProcess = CurrentThread->ApcState.Process; +#ifdef _M_IX86 /* * Cs bit 0 is always set for user mode if we are in protected mode. * V86 mode is counted as user time. @@ -288,6 +289,7 @@ KeUpdateRunTime( Prcb->KernelTime++; } } +#endif #if 0 DpcLastCount = Prcb->DpcLastCount; @@ -341,6 +343,7 @@ KeUpdateSystemTime( * FUNCTION: Handles a timer interrupt */ { +#ifdef _M_IX86 LARGE_INTEGER Time; ASSERT(KeGetCurrentIrql() == PROFILE_LEVEL); @@ -378,6 +381,7 @@ KeUpdateSystemTime( * Queue a DPC that will expire timers */ KeInsertQueueDpc(&KiExpireTimerDpc, (PVOID)TrapFrame->Eip, 0); +#endif } /* diff --git a/reactos/ntoskrnl/ke/dpc.c b/reactos/ntoskrnl/ke/dpc.c index 5ca1616d96c..40b8f84ef9d 100644 --- a/reactos/ntoskrnl/ke/dpc.c +++ b/reactos/ntoskrnl/ke/dpc.c @@ -441,7 +441,7 @@ KiQuantumEnd(VOID) /* Set DPC Event if requested */ if (Prcb->DpcSetEventRequest) { - KeSetEvent(&Prcb->DpcEvent, 0, 0); + KeSetEvent((void *)&Prcb->DpcEvent, 0, 0); } /* Check if Quantum expired */ diff --git a/reactos/ntoskrnl/ke/ipi.c b/reactos/ntoskrnl/ke/ipi.c index a43593a0faf..e95d5becf79 100644 --- a/reactos/ntoskrnl/ke/ipi.c +++ b/reactos/ntoskrnl/ke/ipi.c @@ -33,7 +33,9 @@ KiIpiSendRequest(KAFFINITY TargetSet, ULONG IpiRequest) if (TargetSet & Current) { Pcr = (PKPCR)(KPCR_BASE + i * PAGE_SIZE); +#ifdef _M_IX86 Ke386TestAndSetBit(IpiRequest, &Pcr->Prcb->IpiFrozen); +#endif HalRequestIpi(i); } } @@ -48,8 +50,10 @@ KiIpiServiceRoutine(IN PKTRAP_FRAME TrapFrame, IN PVOID ExceptionFrame) { #ifdef DBG +#ifdef _M_IX86 LARGE_INTEGER StartTime, CurrentTime, Frequency; ULONG Count = 5; +#endif #endif PKPRCB Prcb; @@ -59,6 +63,7 @@ KiIpiServiceRoutine(IN PKTRAP_FRAME TrapFrame, Prcb = KeGetCurrentPrcb(); +#ifdef _M_IX86 if (Ke386TestAndClearBit(IPI_APC, &Prcb->IpiFrozen)) { HalRequestSoftwareInterrupt(APC_LEVEL); @@ -111,6 +116,7 @@ KiIpiServiceRoutine(IN PKTRAP_FRAME TrapFrame, } (void)InterlockedExchangePointer(&Prcb->SignalDone, NULL); } +#endif DPRINT("KiIpiServiceRoutine done\n"); return TRUE; } @@ -140,11 +146,13 @@ KiIpiSendPacket(KAFFINITY TargetSet, VOID (STDCALL*WorkerRoutine)(PVOID), PVOID { Prcb = ((PKPCR)(KPCR_BASE + i * PAGE_SIZE))->Prcb; while(0 != InterlockedCompareExchangeUL(&Prcb->SignalDone, (LONG)CurrentPrcb, 0)); +#ifdef _M_IX86 Ke386TestAndSetBit(IPI_SYNCH_REQUEST, &Prcb->IpiFrozen); if (Processor != CurrentPrcb->SetMember) { HalRequestIpi(i); } +#endif } } if (TargetSet & CurrentPrcb->SetMember) diff --git a/reactos/ntoskrnl/ke/kthread.c b/reactos/ntoskrnl/ke/kthread.c index 145e6b65dff..f49054c156b 100644 --- a/reactos/ntoskrnl/ke/kthread.c +++ b/reactos/ntoskrnl/ke/kthread.c @@ -885,7 +885,9 @@ KeInitializeThread(PKPROCESS Process, Thread->UserAffinity = Process->Affinity; Thread->DisableBoost = Process->DisableBoost; Thread->AutoAlignment = Process->AutoAlignment; +#ifdef _M_IX86 Thread->Iopl = Process->Iopl; +#endif /* Set the Thread to initalized */ Thread->State = Initialized; diff --git a/reactos/ntoskrnl/ke/main.c b/reactos/ntoskrnl/ke/main.c index 01cfd818b5e..d76371f5f76 100644 --- a/reactos/ntoskrnl/ke/main.c +++ b/reactos/ntoskrnl/ke/main.c @@ -18,7 +18,6 @@ #define BUILD_OSCSDVERSION(major, minor) (((major & 0xFF) << 8) | (minor & 0xFF)) - ULONG NtMajorVersion = 5; ULONG NtMinorVersion = 0; ULONG NtOSCSDVersion = BUILD_OSCSDVERSION(4, 0); diff --git a/reactos/ntoskrnl/ke/process.c b/reactos/ntoskrnl/ke/process.c index 8631d2fc47d..faa1f067474 100644 --- a/reactos/ntoskrnl/ke/process.c +++ b/reactos/ntoskrnl/ke/process.c @@ -133,7 +133,9 @@ KeInitializeProcess(PKPROCESS Process, Process->QuantumReset = 6; Process->DirectoryTableBase = DirectoryTableBase; Process->AutoAlignment = TRUE; +#ifdef _M_IX86 Process->IopmOffset = 0xFFFF; +#endif Process->State = ProcessInMemory; /* Initialize the Thread List */ @@ -176,8 +178,10 @@ NTAPI KiSwapProcess(PKPROCESS NewProcess, PKPROCESS OldProcess) { +#ifdef _M_IX86 DPRINT("Switching CR3 to: %x\n", NewProcess->DirectoryTableBase.u.LowPart); Ke386SetPageTableDirectory(NewProcess->DirectoryTableBase.u.LowPart); +#endif } /* diff --git a/reactos/ntoskrnl/ke/profile.c b/reactos/ntoskrnl/ke/profile.c index 1ebea2378d7..787d078fb0f 100644 --- a/reactos/ntoskrnl/ke/profile.c +++ b/reactos/ntoskrnl/ke/profile.c @@ -226,6 +226,7 @@ KiParseProfileList(IN PKTRAP_FRAME TrapFrame, IN KPROFILE_SOURCE Source, IN PLIST_ENTRY ListHead) { +#ifdef _M_IX86 PULONG BucketValue; PKPROFILE Profile; @@ -248,6 +249,7 @@ KiParseProfileList(IN PKTRAP_FRAME TrapFrame, /* Increment the value */ ++BucketValue; } +#endif } /* diff --git a/reactos/ntoskrnl/mm/pagefile.c b/reactos/ntoskrnl/mm/pagefile.c index 26f72f86202..084fa794b8c 100644 --- a/reactos/ntoskrnl/mm/pagefile.c +++ b/reactos/ntoskrnl/mm/pagefile.c @@ -548,6 +548,7 @@ MmDumpToPagingFile(ULONG BugCode, Headers->Type = MmCoreDumpType; if (TrapFrame != NULL) { +#ifdef _M_IX86 if (!(TrapFrame->EFlags & (1 << 17))) { memcpy(&Headers->TrapFrame, TrapFrame, @@ -555,8 +556,11 @@ MmDumpToPagingFile(ULONG BugCode, } else { +#endif memcpy(&Headers->TrapFrame, TrapFrame, sizeof(KTRAP_FRAME)); +#ifdef _M_IX86 } +#endif } Headers->BugCheckCode = BugCode; Headers->BugCheckParameters[0] = BugCodeParameter1; diff --git a/reactos/ntoskrnl/ntoskrnl.def b/reactos/ntoskrnl/ntoskrnl.def index 6d1ebd1bad4..7bd853f31fd 100644 --- a/reactos/ntoskrnl/ntoskrnl.def +++ b/reactos/ntoskrnl/ntoskrnl.def @@ -1510,3 +1510,4 @@ wcsspn wcsstr wcstombs wctomb +KeDumpStackFrames@4 \ No newline at end of file diff --git a/reactos/ntoskrnl/ntoskrnl.rbuild b/reactos/ntoskrnl/ntoskrnl.rbuild index 3992b2f3e36..a19bac88af9 100644 --- a/reactos/ntoskrnl/ntoskrnl.rbuild +++ b/reactos/ntoskrnl/ntoskrnl.rbuild @@ -44,6 +44,11 @@ v86m_sup.S vdm.c + + + + main_asm.S + apc.c bug.c diff --git a/reactos/ntoskrnl/ps/debug.c b/reactos/ntoskrnl/ps/debug.c index c8fbb779f24..05773f80c2c 100644 --- a/reactos/ntoskrnl/ps/debug.c +++ b/reactos/ntoskrnl/ps/debug.c @@ -56,12 +56,14 @@ PspGetOrSetContextKernelRoutine(PKAPC Apc, Event = &GetSetContext->Event; Mode = GetSetContext->Mode; +#ifdef _M_IX86 if (TrapFrame->SegCs == KGDT_R0_CODE && Mode != KernelMode) { GetSetContext->Status = STATUS_ACCESS_DENIED; } else { +#endif /* Check if it's a set or get */ if (*SystemArgument1) { /* Get the Context */ @@ -71,7 +73,9 @@ PspGetOrSetContextKernelRoutine(PKAPC Apc, KeContextToTrapFrame(Context, NULL, TrapFrame, Context->ContextFlags, Mode); } GetSetContext->Status = STATUS_SUCCESS; +#ifdef _M_IX86 } +#endif /* Notify the Native API that we are done */ KeSetEvent(Event, IO_NO_INCREMENT, FALSE); diff --git a/reactos/ntoskrnl/ps/idle.c b/reactos/ntoskrnl/ps/idle.c index 2b1d39c51b7..fe43e7b3346 100644 --- a/reactos/ntoskrnl/ps/idle.c +++ b/reactos/ntoskrnl/ps/idle.c @@ -45,7 +45,11 @@ PsIdleThreadMain(PVOID Context) NtYieldExecution(); +#ifdef _M_IX86 Ke386HaltProcessor(); +#elif defined(_M_PPC) + for(;;); +#endif } } diff --git a/reactos/ntoskrnl/ps/psmgr.c b/reactos/ntoskrnl/ps/psmgr.c index d1b32f6d16c..49f52c9a310 100644 --- a/reactos/ntoskrnl/ps/psmgr.c +++ b/reactos/ntoskrnl/ps/psmgr.c @@ -199,7 +199,9 @@ PsInitProcessManagment(VOID) RtlZeroMemory(PsIdleProcess, sizeof(EPROCESS)); PsIdleProcess->Pcb.Affinity = 0xFFFFFFFF; +#ifdef _M_IX86 PsIdleProcess->Pcb.IopmOffset = 0xffff; +#endif PsIdleProcess->Pcb.BasePriority = PROCESS_PRIORITY_IDLE; PsIdleProcess->Pcb.QuantumReset = 6; InitializeListHead(&PsIdleProcess->Pcb.ThreadListHead); @@ -243,7 +245,9 @@ PsInitProcessManagment(VOID) #else PsInitialSystemProcess->Pcb.Affinity = KeActiveProcessors; #endif +#ifdef _M_IX86 PsInitialSystemProcess->Pcb.IopmOffset = 0xffff; +#endif PsInitialSystemProcess->Pcb.BasePriority = PROCESS_PRIORITY_NORMAL; PsInitialSystemProcess->Pcb.QuantumReset = 6; InitializeListHead(&PsInitialSystemProcess->Pcb.ThreadListHead); -- 2.17.1