mirror of
https://github.com/ApfelTeeSaft/reactos.git
synced 2026-09-03 04:13:31 +00:00
All remaining changes from the PPC branch. Not well tested yet. Many things
are indeed still stubs or WIP code. Some people have been interested in helping out from some time and I'm sorry I haven't been able to do this merge finally for a while. svn path=/trunk/; revision=29407
This commit is contained in:
@@ -9327,6 +9327,35 @@ KeRaiseIrqlToSynchLevel(
|
||||
#define KeLowerIrql(a) KfLowerIrql(a)
|
||||
#define KeRaiseIrql(a,b) *(b) = KfRaiseIrql(a)
|
||||
|
||||
#elif defined(__PowerPC__)
|
||||
|
||||
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
|
||||
|
||||
NTKERNELAPI
|
||||
|
||||
@@ -28,6 +28,9 @@
|
||||
#ifndef KJK_INTRIN_PPC_H_
|
||||
#define KJK_INTRIN_PPC_H_
|
||||
|
||||
//#define PPC_QUAL static __inline__ __attribute__((always_inline))
|
||||
#define PPC_QUAL extern __inline__
|
||||
|
||||
#ifndef __GNUC__
|
||||
#error Unsupported compiler
|
||||
#endif
|
||||
@@ -50,98 +53,98 @@
|
||||
|
||||
#if (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) > 40100
|
||||
|
||||
static __inline__ __attribute__((always_inline)) char _InterlockedCompareExchange8(volatile char * const Destination, const char Exchange, const char Comperand)
|
||||
PPC_QUAL char _InterlockedCompareExchange8(volatile char * const Destination, const char Exchange, const char Comperand)
|
||||
{
|
||||
return __sync_val_compare_and_swap(Destination, Comperand, Exchange);
|
||||
}
|
||||
|
||||
static __inline__ __attribute__((always_inline)) short _InterlockedCompareExchange16(volatile short * const Destination, const short Exchange, const short Comperand)
|
||||
PPC_QUAL short _InterlockedCompareExchange16(volatile short * const Destination, const short Exchange, const short Comperand)
|
||||
{
|
||||
return __sync_val_compare_and_swap(Destination, Comperand, Exchange);
|
||||
}
|
||||
|
||||
static __inline__ __attribute__((always_inline)) long _InterlockedCompareExchange(volatile long * const Destination, const long Exchange, const long Comperand)
|
||||
PPC_QUAL long _InterlockedCompareExchange(volatile long * const Destination, const long Exchange, const long Comperand)
|
||||
{
|
||||
return __sync_val_compare_and_swap(Destination, Comperand, Exchange);
|
||||
}
|
||||
|
||||
static __inline__ __attribute__((always_inline)) long long _InterlockedCompareExchange64(volatile long long * const Destination, const long long Exchange, const long long Comperand)
|
||||
PPC_QUAL long long _InterlockedCompareExchange64(volatile long long * const Destination, const long long Exchange, const long long Comperand)
|
||||
{
|
||||
return __sync_val_compare_and_swap(Destination, Comperand, Exchange);
|
||||
}
|
||||
|
||||
static __inline__ __attribute__((always_inline)) void * _InterlockedCompareExchangePointer(void * volatile * const Destination, void * const Exchange, void * const Comperand)
|
||||
PPC_QUAL void * _InterlockedCompareExchangePointer(void * volatile * const Destination, void * const Exchange, void * const Comperand)
|
||||
{
|
||||
return __sync_val_compare_and_swap(Destination, Comperand, Exchange);
|
||||
}
|
||||
|
||||
static __inline__ __attribute__((always_inline)) long _InterlockedExchange(volatile long * const Target, const long Value)
|
||||
PPC_QUAL long _InterlockedExchange(volatile long * const Target, const long Value)
|
||||
{
|
||||
/* NOTE: __sync_lock_test_and_set would be an acquire barrier, so we force a full barrier */
|
||||
__sync_synchronize();
|
||||
return __sync_lock_test_and_set(Target, Value);
|
||||
}
|
||||
|
||||
static __inline__ __attribute__((always_inline)) void * _InterlockedExchangePointer(void * volatile * const Target, void * const Value)
|
||||
PPC_QUAL void * _InterlockedExchangePointer(void * volatile * const Target, void * const Value)
|
||||
{
|
||||
/* NOTE: ditto */
|
||||
__sync_synchronize();
|
||||
return __sync_lock_test_and_set(Target, Value);
|
||||
}
|
||||
|
||||
static __inline__ __attribute__((always_inline)) long _InterlockedExchangeAdd(volatile long * const Addend, const long Value)
|
||||
PPC_QUAL long _InterlockedExchangeAdd(volatile long * const Addend, const long Value)
|
||||
{
|
||||
return __sync_fetch_and_add(Addend, Value);
|
||||
}
|
||||
|
||||
static __inline__ __attribute__((always_inline)) char _InterlockedAnd8(volatile char * const value, const char mask)
|
||||
PPC_QUAL char _InterlockedAnd8(volatile char * const value, const char mask)
|
||||
{
|
||||
return __sync_fetch_and_and(value, mask);
|
||||
}
|
||||
|
||||
static __inline__ __attribute__((always_inline)) short _InterlockedAnd16(volatile short * const value, const short mask)
|
||||
PPC_QUAL short _InterlockedAnd16(volatile short * const value, const short mask)
|
||||
{
|
||||
return __sync_fetch_and_and(value, mask);
|
||||
}
|
||||
|
||||
static __inline__ __attribute__((always_inline)) long _InterlockedAnd(volatile long * const value, const long mask)
|
||||
PPC_QUAL long _InterlockedAnd(volatile long * const value, const long mask)
|
||||
{
|
||||
return __sync_fetch_and_and(value, mask);
|
||||
}
|
||||
|
||||
static __inline__ __attribute__((always_inline)) char _InterlockedOr8(volatile char * const value, const char mask)
|
||||
PPC_QUAL char _InterlockedOr8(volatile char * const value, const char mask)
|
||||
{
|
||||
return __sync_fetch_and_or(value, mask);
|
||||
}
|
||||
|
||||
static __inline__ __attribute__((always_inline)) short _InterlockedOr16(volatile short * const value, const short mask)
|
||||
PPC_QUAL short _InterlockedOr16(volatile short * const value, const short mask)
|
||||
{
|
||||
return __sync_fetch_and_or(value, mask);
|
||||
}
|
||||
|
||||
static __inline__ __attribute__((always_inline)) long _InterlockedOr(volatile long * const value, const long mask)
|
||||
PPC_QUAL long _InterlockedOr(volatile long * const value, const long mask)
|
||||
{
|
||||
return __sync_fetch_and_or(value, mask);
|
||||
}
|
||||
|
||||
static __inline__ __attribute__((always_inline)) char _InterlockedXor8(volatile char * const value, const char mask)
|
||||
PPC_QUAL char _InterlockedXor8(volatile char * const value, const char mask)
|
||||
{
|
||||
return __sync_fetch_and_xor(value, mask);
|
||||
}
|
||||
|
||||
static __inline__ __attribute__((always_inline)) short _InterlockedXor16(volatile short * const value, const short mask)
|
||||
PPC_QUAL short _InterlockedXor16(volatile short * const value, const short mask)
|
||||
{
|
||||
return __sync_fetch_and_xor(value, mask);
|
||||
}
|
||||
|
||||
static __inline__ __attribute__((always_inline)) long _InterlockedXor(volatile long * const value, const long mask)
|
||||
PPC_QUAL long _InterlockedXor(volatile long * const value, const long mask)
|
||||
{
|
||||
return __sync_fetch_and_xor(value, mask);
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
static __inline__ __attribute__((always_inline)) char _InterlockedCompareExchange8(volatile char * const Destination, const char Exchange, const char Comperand)
|
||||
PPC_QUAL char _InterlockedCompareExchange8(volatile char * const Destination, const char Exchange, const char Comperand)
|
||||
{
|
||||
char retval = Comperand;
|
||||
__asm__ __volatile__ (
|
||||
@@ -158,7 +161,7 @@ static __inline__ __attribute__((always_inline)) char _InterlockedCompareExchang
|
||||
return retval;
|
||||
}
|
||||
|
||||
static __inline__ __attribute__((always_inline)) short _InterlockedCompareExchange16(volatile short * const Destination, const short Exchange, const short Comperand)
|
||||
PPC_QUAL short _InterlockedCompareExchange16(volatile short * const Destination, const short Exchange, const short Comperand)
|
||||
{
|
||||
short retval = Comperand;
|
||||
__asm__ __volatile__ (
|
||||
@@ -169,13 +172,30 @@ static __inline__ __attribute__((always_inline)) short _InterlockedCompareExchan
|
||||
" sthcx. %3,0,%1\n"
|
||||
" bne- 1b\n"
|
||||
"2: isync"
|
||||
: "=b" (retval)
|
||||
: "b" (Destination), "r" (Comperand), "r" (Exchange)
|
||||
: "cr0", "memory");
|
||||
: "=r" (retval)
|
||||
: "r" (Destination), "r" (Comperand), "r" (Exchange)
|
||||
: "memory");
|
||||
return retval;
|
||||
}
|
||||
|
||||
static __inline__ __attribute__((always_inline)) long long _InterlockedCompareExchange64(volatile long long * const Destination, const long long Exchange, const long long Comperand)
|
||||
PPC_QUAL long _InterlockedCompareExchange(volatile long * const Destination, const long Exchange, const long Comperand)
|
||||
{
|
||||
short retval = Comperand;
|
||||
__asm__ __volatile__ (
|
||||
"sync\n"
|
||||
"1: lwarx %0,0,%1\n"
|
||||
" subf. %0,%2,%0\n"
|
||||
" bne 2f\n"
|
||||
" stwcx. %3,0,%1\n"
|
||||
" bne- 1b\n"
|
||||
"2: isync"
|
||||
: "=r" (retval)
|
||||
: "r" (Destination), "r" (Comperand), "r" (Exchange)
|
||||
: "memory");
|
||||
return retval;
|
||||
}
|
||||
|
||||
PPC_QUAL long long _InterlockedCompareExchange64(volatile long long * const Destination, const long long Exchange, const long long Comperand)
|
||||
{
|
||||
unsigned long lo32Retval = (unsigned long)((Comperand >> 0) & 0xFFFFFFFF);
|
||||
long hi32Retval = (unsigned long)((Comperand >> 32) & 0xFFFFFFFF);
|
||||
@@ -209,13 +229,13 @@ static __inline__ __attribute__((always_inline)) long long _InterlockedCompareEx
|
||||
}
|
||||
}
|
||||
|
||||
static __inline__ __attribute__((always_inline)) void * _InterlockedCompareExchangePointer(void * volatile * const Destination, void * const Exchange, void * const Comperand)
|
||||
PPC_QUAL void * _InterlockedCompareExchangePointer(void * volatile * const Destination, void * const Exchange, void * const Comperand)
|
||||
{
|
||||
return (void *)_InterlockedCompareExchange
|
||||
((long *)Destination, (long) Exchange, (long) Comperand);
|
||||
}
|
||||
|
||||
static __inline__ __attribute__((always_inline)) long _InterlockedExchange(volatile long * const Target, const long Value)
|
||||
PPC_QUAL long _InterlockedExchange(volatile long * const Target, const long Value)
|
||||
{
|
||||
long retval;
|
||||
__asm__ __volatile__ (
|
||||
@@ -229,7 +249,7 @@ static __inline__ __attribute__((always_inline)) long _InterlockedExchange(volat
|
||||
return retval;
|
||||
}
|
||||
|
||||
static __inline__ __attribute__((always_inline)) void * _InterlockedExchangePointer(void * volatile * const Target, void * const Value)
|
||||
PPC_QUAL void * _InterlockedExchangePointer(void * volatile * const Target, void * const Value)
|
||||
{
|
||||
void * retval;
|
||||
__asm__ __volatile__ (
|
||||
@@ -243,7 +263,7 @@ static __inline__ __attribute__((always_inline)) void * _InterlockedExchangePoin
|
||||
return retval;
|
||||
}
|
||||
|
||||
static __inline__ __attribute__((always_inline)) long _InterlockedExchangeAdd(volatile long * const Addend, const long Value)
|
||||
PPC_QUAL long _InterlockedExchangeAdd(volatile long * const Addend, const long Value)
|
||||
{
|
||||
long x;
|
||||
long y = *Addend;
|
||||
@@ -259,7 +279,7 @@ static __inline__ __attribute__((always_inline)) long _InterlockedExchangeAdd(vo
|
||||
return y;
|
||||
}
|
||||
|
||||
static __inline__ __attribute__((always_inline)) char _InterlockedAnd8(volatile char * const value, const char mask)
|
||||
PPC_QUAL char _InterlockedAnd8(volatile char * const value, const char mask)
|
||||
{
|
||||
char x;
|
||||
char y;
|
||||
@@ -276,7 +296,7 @@ static __inline__ __attribute__((always_inline)) char _InterlockedAnd8(volatile
|
||||
return y;
|
||||
}
|
||||
|
||||
static __inline__ __attribute__((always_inline)) short _InterlockedAnd16(volatile short * const value, const short mask)
|
||||
PPC_QUAL short _InterlockedAnd16(volatile short * const value, const short mask)
|
||||
{
|
||||
short x;
|
||||
short y;
|
||||
@@ -293,7 +313,7 @@ static __inline__ __attribute__((always_inline)) short _InterlockedAnd16(volatil
|
||||
return y;
|
||||
}
|
||||
|
||||
static __inline__ __attribute__((always_inline)) long _InterlockedAnd(volatile long * const value, const long mask)
|
||||
PPC_QUAL long _InterlockedAnd(volatile long * const value, const long mask)
|
||||
{
|
||||
long x;
|
||||
long y;
|
||||
@@ -310,7 +330,7 @@ static __inline__ __attribute__((always_inline)) long _InterlockedAnd(volatile l
|
||||
return y;
|
||||
}
|
||||
|
||||
static __inline__ __attribute__((always_inline)) char _InterlockedOr8(volatile char * const value, const char mask)
|
||||
PPC_QUAL char _InterlockedOr8(volatile char * const value, const char mask)
|
||||
{
|
||||
char x;
|
||||
char y;
|
||||
@@ -327,7 +347,7 @@ static __inline__ __attribute__((always_inline)) char _InterlockedOr8(volatile c
|
||||
return y;
|
||||
}
|
||||
|
||||
static __inline__ __attribute__((always_inline)) short _InterlockedOr16(volatile short * const value, const short mask)
|
||||
PPC_QUAL short _InterlockedOr16(volatile short * const value, const short mask)
|
||||
{
|
||||
short x;
|
||||
short y;
|
||||
@@ -344,7 +364,7 @@ static __inline__ __attribute__((always_inline)) short _InterlockedOr16(volatile
|
||||
return y;
|
||||
}
|
||||
|
||||
static __inline__ __attribute__((always_inline)) long _InterlockedOr(volatile long * const value, const long mask)
|
||||
PPC_QUAL long _InterlockedOr(volatile long * const value, const long mask)
|
||||
{
|
||||
long x;
|
||||
long y;
|
||||
@@ -361,7 +381,7 @@ static __inline__ __attribute__((always_inline)) long _InterlockedOr(volatile lo
|
||||
return y;
|
||||
}
|
||||
|
||||
static __inline__ __attribute__((always_inline)) char _InterlockedXor8(volatile char * const value, const char mask)
|
||||
PPC_QUAL char _InterlockedXor8(volatile char * const value, const char mask)
|
||||
{
|
||||
char x;
|
||||
char y;
|
||||
@@ -378,7 +398,7 @@ static __inline__ __attribute__((always_inline)) char _InterlockedXor8(volatile
|
||||
return y;
|
||||
}
|
||||
|
||||
static __inline__ __attribute__((always_inline)) short _InterlockedXor16(volatile short * const value, const short mask)
|
||||
PPC_QUAL short _InterlockedXor16(volatile short * const value, const short mask)
|
||||
{
|
||||
short x;
|
||||
short y;
|
||||
@@ -395,7 +415,7 @@ static __inline__ __attribute__((always_inline)) short _InterlockedXor16(volatil
|
||||
return y;
|
||||
}
|
||||
|
||||
static __inline__ __attribute__((always_inline)) long _InterlockedXor(volatile long * const value, const long mask)
|
||||
PPC_QUAL long _InterlockedXor(volatile long * const value, const long mask)
|
||||
{
|
||||
long x;
|
||||
long y;
|
||||
@@ -412,7 +432,7 @@ static __inline__ __attribute__((always_inline)) long _InterlockedXor(volatile l
|
||||
return y;
|
||||
}
|
||||
|
||||
static __inline__ __attribute__((always_inline)) unsigned char _interlockedbittestandreset(volatile long * const a, const long b)
|
||||
PPC_QUAL unsigned char _interlockedbittestandreset(volatile long * const a, const long b)
|
||||
{
|
||||
long x;
|
||||
long y;
|
||||
@@ -430,7 +450,7 @@ static __inline__ __attribute__((always_inline)) unsigned char _interlockedbitte
|
||||
return (y & ~mask) != 0;
|
||||
}
|
||||
|
||||
static __inline__ __attribute__((always_inline)) unsigned char _interlockedbittestandset(volatile long * const a, const long b)
|
||||
PPC_QUAL unsigned char _interlockedbittestandset(volatile long * const a, const long b)
|
||||
{
|
||||
long x;
|
||||
long y;
|
||||
@@ -449,12 +469,12 @@ static __inline__ __attribute__((always_inline)) unsigned char _interlockedbitte
|
||||
}
|
||||
#endif
|
||||
|
||||
static __inline__ __attribute__((always_inline)) long _InterlockedDecrement(volatile long * const lpAddend)
|
||||
PPC_QUAL long _InterlockedDecrement(volatile long * const lpAddend)
|
||||
{
|
||||
return _InterlockedExchangeAdd(lpAddend, -1) - 1;
|
||||
}
|
||||
|
||||
static __inline__ __attribute__((always_inline)) long _InterlockedIncrement(volatile long * const lpAddend)
|
||||
PPC_QUAL long _InterlockedIncrement(volatile long * const lpAddend)
|
||||
{
|
||||
return _InterlockedExchangeAdd(lpAddend, 1) + 1;
|
||||
}
|
||||
@@ -463,34 +483,34 @@ static __inline__ __attribute__((always_inline)) long _InterlockedIncrement(vola
|
||||
/* NOTE: we don't set a memory clobber in the __stosX functions because Visual C++ doesn't */
|
||||
/* Note that the PPC store multiple operations may raise an exception in LE
|
||||
* mode */
|
||||
static __inline__ __attribute__((always_inline)) void __stosb(unsigned char * Dest, const unsigned char Data, unsigned long Count)
|
||||
PPC_QUAL void __stosb(unsigned char * Dest, const unsigned char Data, unsigned long Count)
|
||||
{
|
||||
memset(Dest, Data, Count);
|
||||
}
|
||||
|
||||
static __inline__ __attribute__((always_inline)) void __stosw(unsigned short * Dest, const unsigned short Data, unsigned long Count)
|
||||
PPC_QUAL void __stosw(unsigned short * Dest, const unsigned short Data, unsigned long Count)
|
||||
{
|
||||
while(Count--)
|
||||
*Dest++ = Data;
|
||||
}
|
||||
|
||||
static __inline__ __attribute__((always_inline)) void __stosd(unsigned long * Dest, const unsigned long Data, unsigned long Count)
|
||||
PPC_QUAL void __stosd(unsigned long * Dest, const unsigned long Data, unsigned long Count)
|
||||
{
|
||||
while(Count--)
|
||||
*Dest++ = Data;
|
||||
}
|
||||
|
||||
static __inline__ __attribute__((always_inline)) void __movsb(unsigned char * Destination, const unsigned char * Source, unsigned long Count)
|
||||
PPC_QUAL void __movsb(unsigned char * Destination, const unsigned char * Source, unsigned long Count)
|
||||
{
|
||||
memcpy(Destination, Source, Count);
|
||||
}
|
||||
|
||||
static __inline__ __attribute__((always_inline)) void __movsw(unsigned short * Destination, const unsigned short * Source, unsigned long Count)
|
||||
PPC_QUAL void __movsw(unsigned short * Destination, const unsigned short * Source, unsigned long Count)
|
||||
{
|
||||
memcpy(Destination, Source, Count * sizeof(*Source));
|
||||
}
|
||||
|
||||
static __inline__ __attribute__((always_inline)) void __movsd(unsigned long * Destination, const unsigned long * Source, unsigned long Count)
|
||||
PPC_QUAL void __movsd(unsigned long * Destination, const unsigned long * Source, unsigned long Count)
|
||||
{
|
||||
memcpy(Destination, Source, Count * sizeof(*Source));
|
||||
}
|
||||
@@ -499,25 +519,25 @@ static __inline__ __attribute__((always_inline)) void __movsd(unsigned long * De
|
||||
/*** FS segment addressing ***/
|
||||
/* On PowerPC, r13 points to TLS data, including the TEB at 0(r13) from what I
|
||||
* can tell */
|
||||
static __inline__ __attribute__((always_inline)) void __writefsbyte(const unsigned long Offset, const unsigned char Data)
|
||||
PPC_QUAL void __writefsbyte(const unsigned long Offset, const unsigned char Data)
|
||||
{
|
||||
char *addr;
|
||||
__asm__("\tadd %0,13,%1\n\tstb %2,0(%0)" : "=r" (addr) : "r" (Offset), "r" (Data));
|
||||
}
|
||||
|
||||
static __inline__ __attribute__((always_inline)) void __writefsword(const unsigned long Offset, const unsigned short Data)
|
||||
PPC_QUAL void __writefsword(const unsigned long Offset, const unsigned short Data)
|
||||
{
|
||||
char *addr;
|
||||
__asm__("\tadd %0,13,%1\n\tsth %2,0(%0)" : "=r" (addr) : "r" (Offset), "r" (Data));
|
||||
}
|
||||
|
||||
static __inline__ __attribute__((always_inline)) void __writefsdword(const unsigned long Offset, const unsigned long Data)
|
||||
PPC_QUAL void __writefsdword(const unsigned long Offset, const unsigned long Data)
|
||||
{
|
||||
char *addr;
|
||||
__asm__("\tadd %0,13,%1\n\tstw %2,0(%0)" : "=r" (addr) : "r" (Offset), "r" (Data));
|
||||
}
|
||||
|
||||
static __inline__ __attribute__((always_inline)) unsigned char __readfsbyte(const unsigned long Offset)
|
||||
PPC_QUAL unsigned char __readfsbyte(const unsigned long Offset)
|
||||
{
|
||||
unsigned short result;
|
||||
__asm__("\tadd 7,13,%1\n"
|
||||
@@ -528,7 +548,7 @@ static __inline__ __attribute__((always_inline)) unsigned char __readfsbyte(cons
|
||||
return result;
|
||||
}
|
||||
|
||||
static __inline__ __attribute__((always_inline)) unsigned short __readfsword(const unsigned long Offset)
|
||||
PPC_QUAL unsigned short __readfsword(const unsigned long Offset)
|
||||
{
|
||||
unsigned short result;
|
||||
__asm__("\tadd 7,13,%1\n"
|
||||
@@ -539,7 +559,7 @@ static __inline__ __attribute__((always_inline)) unsigned short __readfsword(con
|
||||
return result;
|
||||
}
|
||||
|
||||
static __inline__ __attribute__((always_inline)) unsigned long __readfsdword(const unsigned long Offset)
|
||||
PPC_QUAL unsigned long __readfsdword(const unsigned long Offset)
|
||||
{
|
||||
unsigned long result;
|
||||
__asm__("\tadd 7,13,%1\n"
|
||||
@@ -550,41 +570,41 @@ static __inline__ __attribute__((always_inline)) unsigned long __readfsdword(con
|
||||
return result;
|
||||
}
|
||||
|
||||
static __inline__ __attribute__((always_inline)) void __incfsbyte(const unsigned long Offset)
|
||||
PPC_QUAL void __incfsbyte(const unsigned long Offset)
|
||||
{
|
||||
__writefsbyte(Offset, __readfsbyte(Offset)+1);
|
||||
}
|
||||
|
||||
static __inline__ __attribute__((always_inline)) void __incfsword(const unsigned long Offset)
|
||||
PPC_QUAL void __incfsword(const unsigned long Offset)
|
||||
{
|
||||
__writefsword(Offset, __readfsword(Offset)+1);
|
||||
}
|
||||
|
||||
static __inline__ __attribute__((always_inline)) void __incfsdword(const unsigned long Offset)
|
||||
PPC_QUAL void __incfsdword(const unsigned long Offset)
|
||||
{
|
||||
__writefsdword(Offset, __readfsdword(Offset)+1);
|
||||
}
|
||||
|
||||
/* NOTE: the bizarre implementation of __addfsxxx mimics the broken Visual C++ behavior */
|
||||
/* PPC Note: Not sure about the bizarre behavior. We'll try to emulate it later */
|
||||
static __inline__ __attribute__((always_inline)) void __addfsbyte(const unsigned long Offset, const unsigned char Data)
|
||||
PPC_QUAL void __addfsbyte(const unsigned long Offset, const unsigned char Data)
|
||||
{
|
||||
__writefsbyte(Offset, __readfsbyte(Offset) + Data);
|
||||
}
|
||||
|
||||
static __inline__ __attribute__((always_inline)) void __addfsword(const unsigned long Offset, const unsigned short Data)
|
||||
PPC_QUAL void __addfsword(const unsigned long Offset, const unsigned short Data)
|
||||
{
|
||||
__writefsword(Offset, __readfsword(Offset) + Data);
|
||||
}
|
||||
|
||||
static __inline__ __attribute__((always_inline)) void __addfsdword(const unsigned long Offset, const unsigned int Data)
|
||||
PPC_QUAL void __addfsdword(const unsigned long Offset, const unsigned int Data)
|
||||
{
|
||||
__writefsdword(Offset, __readfsdword(Offset) + Data);
|
||||
}
|
||||
|
||||
|
||||
/*** Bit manipulation ***/
|
||||
static __inline__ __attribute__((always_inline)) unsigned char _BitScanForward(unsigned long * const Index, const unsigned long Mask)
|
||||
PPC_QUAL unsigned char _BitScanForward(unsigned long * const Index, const unsigned long Mask)
|
||||
{
|
||||
if(Mask == 0) return 0;
|
||||
else {
|
||||
@@ -601,7 +621,7 @@ static __inline__ __attribute__((always_inline)) unsigned char _BitScanForward(
|
||||
}
|
||||
|
||||
/* Thanks http://www.jjj.de/bitwizardry/files/bithigh.h */
|
||||
static __inline__ __attribute__((always_inline)) unsigned char _BitScanReverse(unsigned long * const Index, const unsigned long Mask)
|
||||
PPC_QUAL unsigned char _BitScanReverse(unsigned long * const Index, const unsigned long Mask)
|
||||
{
|
||||
unsigned long check = 16, checkmask;
|
||||
if(Mask == 0) return 0;
|
||||
@@ -621,82 +641,82 @@ static __inline__ __attribute__((always_inline)) unsigned char _BitScanReverse(
|
||||
}
|
||||
|
||||
/* NOTE: again, the bizarre implementation follows Visual C++ */
|
||||
static __inline__ __attribute__((always_inline)) unsigned char _bittest(const long * const a, const long b)
|
||||
PPC_QUAL unsigned char _bittest(const long * const a, const long b)
|
||||
{
|
||||
return ((*a) & (1<<b)) != 0;
|
||||
}
|
||||
|
||||
static __inline__ __attribute__((always_inline)) unsigned char _bittestandcomplement(long * const a, const long b)
|
||||
PPC_QUAL unsigned char _bittestandcomplement(long * const a, const long b)
|
||||
{
|
||||
unsigned char ret = ((*a) & (1<<b)) != 0;
|
||||
(*a) ^= (1<<b);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static __inline__ __attribute__((always_inline)) unsigned char _bittestandreset(long * const a, const long b)
|
||||
PPC_QUAL unsigned char _bittestandreset(long * const a, const long b)
|
||||
{
|
||||
unsigned char ret = ((*a) & (1<<b)) != 0;
|
||||
(*a) &= ~(1<<b);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static __inline__ __attribute__((always_inline)) unsigned char _bittestandset(long * const a, const long b)
|
||||
PPC_QUAL unsigned char _bittestandset(long * const a, const long b)
|
||||
{
|
||||
unsigned char ret = ((*a) & (1<<b)) != 0;
|
||||
(*a) |= (1<<b);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static __inline__ __attribute__((always_inline)) unsigned char _rotl8(const unsigned char value, const unsigned char shift)
|
||||
PPC_QUAL unsigned char _rotl8(const unsigned char value, const unsigned char shift)
|
||||
{
|
||||
return (value << shift) | (value >> (8-shift));
|
||||
}
|
||||
|
||||
static __inline__ __attribute__((always_inline)) unsigned short _rotl16(const unsigned short value, const unsigned char shift)
|
||||
PPC_QUAL unsigned short _rotl16(const unsigned short value, const unsigned char shift)
|
||||
{
|
||||
return (value << shift) | (value >> (16-shift));
|
||||
}
|
||||
|
||||
static __inline__ __attribute__((always_inline)) unsigned char _rotr8(const unsigned char value, const unsigned char shift)
|
||||
PPC_QUAL unsigned char _rotr8(const unsigned char value, const unsigned char shift)
|
||||
{
|
||||
return (value >> shift) | (value << (8-shift));
|
||||
}
|
||||
|
||||
static __inline__ __attribute__((always_inline)) unsigned short _rotr16(const unsigned short value, const unsigned char shift)
|
||||
PPC_QUAL unsigned short _rotr16(const unsigned short value, const unsigned char shift)
|
||||
{
|
||||
return (value >> shift) | (value << (16-shift));
|
||||
}
|
||||
|
||||
static __inline__ __attribute__((always_inline)) unsigned long long __ll_lshift(const unsigned long long Mask, int Bit)
|
||||
PPC_QUAL unsigned long long __ll_lshift(const unsigned long long Mask, int Bit)
|
||||
{
|
||||
return Mask << Bit;
|
||||
}
|
||||
|
||||
static __inline__ __attribute__((always_inline)) long long __ll_rshift(const long long Mask, const int Bit)
|
||||
PPC_QUAL long long __ll_rshift(const long long Mask, const int Bit)
|
||||
{
|
||||
return Mask >> Bit;
|
||||
}
|
||||
|
||||
static __inline__ __attribute__((always_inline)) unsigned long long __ull_rshift(const unsigned long long Mask, int Bit)
|
||||
PPC_QUAL unsigned long long __ull_rshift(const unsigned long long Mask, int Bit)
|
||||
{
|
||||
return Mask >> Bit;
|
||||
}
|
||||
|
||||
|
||||
/*** 64-bit math ***/
|
||||
static __inline__ __attribute__((always_inline)) long long __emul(const int a, const int b)
|
||||
PPC_QUAL long long __emul(const int a, const int b)
|
||||
{
|
||||
return a * b;
|
||||
}
|
||||
|
||||
static __inline__ __attribute__((always_inline)) unsigned long long __emulu(const unsigned int a, const unsigned int b)
|
||||
PPC_QUAL unsigned long long __emulu(const unsigned int a, const unsigned int b)
|
||||
{
|
||||
return a * b;
|
||||
}
|
||||
|
||||
|
||||
/*** Port I/O ***/
|
||||
static __inline__ __attribute__((always_inline)) unsigned char __inbyte(const unsigned short Port)
|
||||
PPC_QUAL unsigned char __inbyte(const unsigned short Port)
|
||||
{
|
||||
int ret;
|
||||
__asm__(
|
||||
@@ -711,7 +731,7 @@ static __inline__ __attribute__((always_inline)) unsigned char __inbyte(const un
|
||||
return ret;
|
||||
}
|
||||
|
||||
static __inline__ __attribute__((always_inline)) unsigned short __inword(const unsigned short Port)
|
||||
PPC_QUAL unsigned short __inword(const unsigned short Port)
|
||||
{
|
||||
int ret;
|
||||
__asm__(
|
||||
@@ -726,7 +746,7 @@ static __inline__ __attribute__((always_inline)) unsigned short __inword(const u
|
||||
return ret;
|
||||
}
|
||||
|
||||
static __inline__ __attribute__((always_inline)) unsigned long __indword(const unsigned short Port)
|
||||
PPC_QUAL unsigned long __indword(const unsigned short Port)
|
||||
{
|
||||
int ret;
|
||||
__asm__(
|
||||
@@ -741,28 +761,28 @@ static __inline__ __attribute__((always_inline)) unsigned long __indword(const u
|
||||
return ret;
|
||||
}
|
||||
|
||||
static __inline__ __attribute__((always_inline)) void __inbytestring(unsigned short Port, unsigned char * Buffer, unsigned long Count)
|
||||
PPC_QUAL void __inbytestring(unsigned short Port, unsigned char * Buffer, unsigned long Count)
|
||||
{
|
||||
while(Count--) {
|
||||
*Buffer++ = __inbyte(Port);
|
||||
}
|
||||
}
|
||||
|
||||
static __inline__ __attribute__((always_inline)) void __inwordstring(unsigned short Port, unsigned short * Buffer, unsigned long Count)
|
||||
PPC_QUAL void __inwordstring(unsigned short Port, unsigned short * Buffer, unsigned long Count)
|
||||
{
|
||||
while(Count--) {
|
||||
*Buffer++ = __inword(Port);
|
||||
}
|
||||
}
|
||||
|
||||
static __inline__ __attribute__((always_inline)) void __indwordstring(unsigned short Port, unsigned long * Buffer, unsigned long Count)
|
||||
PPC_QUAL void __indwordstring(unsigned short Port, unsigned long * Buffer, unsigned long Count)
|
||||
{
|
||||
while(Count--) {
|
||||
*Buffer++ = __indword(Port);
|
||||
}
|
||||
}
|
||||
|
||||
static __inline__ __attribute__((always_inline)) void __outbyte(unsigned short const Port, const unsigned char Data)
|
||||
PPC_QUAL void __outbyte(unsigned short const Port, const unsigned char Data)
|
||||
{
|
||||
__asm__(
|
||||
"mfmsr 5\n\t"
|
||||
@@ -778,7 +798,7 @@ static __inline__ __attribute__((always_inline)) void __outbyte(unsigned short c
|
||||
);
|
||||
}
|
||||
|
||||
static __inline__ __attribute__((always_inline)) void __outword(unsigned short const Port, const unsigned short Data)
|
||||
PPC_QUAL void __outword(unsigned short const Port, const unsigned short Data)
|
||||
{
|
||||
__asm__(
|
||||
"mfmsr 5\n\t"
|
||||
@@ -794,7 +814,7 @@ static __inline__ __attribute__((always_inline)) void __outword(unsigned short c
|
||||
);
|
||||
}
|
||||
|
||||
static __inline__ __attribute__((always_inline)) void __outdword(unsigned short const Port, const unsigned long Data)
|
||||
PPC_QUAL void __outdword(unsigned short const Port, const unsigned long Data)
|
||||
{
|
||||
__asm__(
|
||||
"mfmsr 5\n\t"
|
||||
@@ -810,7 +830,7 @@ static __inline__ __attribute__((always_inline)) void __outdword(unsigned short
|
||||
);
|
||||
}
|
||||
|
||||
static __inline__ __attribute__((always_inline)) void __outbytestring(unsigned short const Port, const unsigned char * const Buffer, const unsigned long Count)
|
||||
PPC_QUAL void __outbytestring(unsigned short const Port, const unsigned char * const Buffer, const unsigned long Count)
|
||||
{
|
||||
unsigned long count = Count;
|
||||
const unsigned char *buffer = Buffer;
|
||||
@@ -819,7 +839,7 @@ static __inline__ __attribute__((always_inline)) void __outbytestring(unsigned s
|
||||
}
|
||||
}
|
||||
|
||||
static __inline__ __attribute__((always_inline)) void __outwordstring(unsigned short const Port, const unsigned short * const Buffer, const unsigned long Count)
|
||||
PPC_QUAL void __outwordstring(unsigned short const Port, const unsigned short * const Buffer, const unsigned long Count)
|
||||
{
|
||||
unsigned long count = Count;
|
||||
const unsigned short *buffer = Buffer;
|
||||
@@ -828,7 +848,7 @@ static __inline__ __attribute__((always_inline)) void __outwordstring(unsigned s
|
||||
}
|
||||
}
|
||||
|
||||
static __inline__ __attribute__((always_inline)) void __outdwordstring(unsigned short const Port, const unsigned long * const Buffer, const unsigned long Count)
|
||||
PPC_QUAL void __outdwordstring(unsigned short const Port, const unsigned long * const Buffer, const unsigned long Count)
|
||||
{
|
||||
unsigned long count = Count;
|
||||
const unsigned long *buffer = Buffer;
|
||||
@@ -839,13 +859,13 @@ static __inline__ __attribute__((always_inline)) void __outdwordstring(unsigned
|
||||
|
||||
|
||||
/*** System information ***/
|
||||
static __inline__ __attribute__((always_inline)) void __cpuid(int CPUInfo[], const int InfoType)
|
||||
PPC_QUAL void __cpuid(int CPUInfo[], const int InfoType)
|
||||
{
|
||||
unsigned long lo32;
|
||||
__asm__("mfpvr" : "=b" (lo32));
|
||||
}
|
||||
|
||||
static __inline__ __attribute__((always_inline)) unsigned long long __rdtsc(void)
|
||||
PPC_QUAL unsigned long long __rdtsc(void)
|
||||
{
|
||||
unsigned long lo32;
|
||||
__asm__("mfdec %0" : "=b" (lo32));
|
||||
@@ -855,19 +875,19 @@ static __inline__ __attribute__((always_inline)) unsigned long long __rdtsc(void
|
||||
|
||||
/*** Interrupts ***/
|
||||
/* Finally decided to do this by enabling single step trap */
|
||||
static __inline__ __attribute__((always_inline)) void __debugbreak(void)
|
||||
PPC_QUAL void __debugbreak(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
static __inline__ __attribute__((always_inline)) void __int2c(void)
|
||||
PPC_QUAL void __int2c(void)
|
||||
{
|
||||
/* Not sure yet */
|
||||
}
|
||||
|
||||
#ifndef _ENABLE_DISABLE_DEFINED
|
||||
#define _ENABLE_DISABLE_DEFINED
|
||||
static __inline__ __attribute__((always_inline)) void _disable(void)
|
||||
PPC_QUAL void _disable(void)
|
||||
{
|
||||
__asm__ __volatile__("mfmsr 0\n\t" \
|
||||
"li 8,0x7fff\n\t" \
|
||||
@@ -875,7 +895,7 @@ static __inline__ __attribute__((always_inline)) void _disable(void)
|
||||
"mtmsr 0\n\t");
|
||||
}
|
||||
|
||||
static __inline__ __attribute__((always_inline)) void _enable(void)
|
||||
PPC_QUAL void _enable(void)
|
||||
{
|
||||
__asm__ __volatile__("mfmsr 0\n\t" \
|
||||
"lis 8,0x8000@ha\n\t" \
|
||||
@@ -884,14 +904,14 @@ static __inline__ __attribute__((always_inline)) void _enable(void)
|
||||
}
|
||||
|
||||
/*** Protected memory management ***/
|
||||
static __inline__ __attribute__((always_inline)) unsigned long __readsdr1(void)
|
||||
PPC_QUAL unsigned long __readsdr1(void)
|
||||
{
|
||||
unsigned long value;
|
||||
__asm__("mfsdr1 %0" : "=b" (value));
|
||||
return value;
|
||||
}
|
||||
|
||||
static __inline__ __attribute__((always_inline)) void __writesdr1(const unsigned long long Data)
|
||||
PPC_QUAL void __writesdr1(const unsigned long long Data)
|
||||
{
|
||||
__asm__("mtsdr1 %0" : : "b" (Data));
|
||||
}
|
||||
@@ -899,14 +919,14 @@ static __inline__ __attribute__((always_inline)) void __writesdr1(const unsigned
|
||||
/*** System operations ***/
|
||||
/* This likely has a different meaning from the X86 equivalent. We'll keep
|
||||
* the name cause it fits */
|
||||
static __inline__ __attribute__((always_inline)) unsigned long long __readmsr()
|
||||
PPC_QUAL unsigned long long __readmsr()
|
||||
{
|
||||
unsigned long temp;
|
||||
__asm__("mfmsr %0" : "=b" (temp));
|
||||
return temp;
|
||||
}
|
||||
|
||||
static __inline__ __attribute__((always_inline)) void __writemsr(const unsigned long Value)
|
||||
PPC_QUAL void __writemsr(const unsigned long Value)
|
||||
{
|
||||
__asm__("mtmsr %0" : : "b" (Value));
|
||||
}
|
||||
@@ -917,7 +937,7 @@ static __inline__ __attribute__((always_inline)) void __writemsr(const unsigned
|
||||
* We've reloaded anything in the data or instruction cache that might have
|
||||
* changed in real ram.
|
||||
*/
|
||||
static __inline__ __attribute__((always_inline)) void __wbinvd(void)
|
||||
PPC_QUAL void __wbinvd(void)
|
||||
{
|
||||
__asm__("eieio\n\t"
|
||||
"dcs\n\t"
|
||||
@@ -926,7 +946,7 @@ static __inline__ __attribute__((always_inline)) void __wbinvd(void)
|
||||
}
|
||||
#endif
|
||||
|
||||
static __inline__ __attribute__((always_inline)) long _InterlockedAddLargeStatistic(volatile long long * const Addend, const long Value)
|
||||
PPC_QUAL long _InterlockedAddLargeStatistic(volatile long long * const Addend, const long Value)
|
||||
{
|
||||
#if 0
|
||||
__asm__
|
||||
|
||||
@@ -2021,7 +2021,7 @@ typedef struct _ACL_SIZE_INFORMATION {
|
||||
} ACL_SIZE_INFORMATION;
|
||||
|
||||
/* FIXME: add more machines */
|
||||
#if defined(_X86_) || defined(unix)
|
||||
#if defined(_X86_) || defined(unix) && !defined(__PowerPC__)
|
||||
#define SIZE_OF_80387_REGISTERS 80
|
||||
#define CONTEXT_i386 0x10000
|
||||
#define CONTEXT_i486 0x10000
|
||||
@@ -2077,7 +2077,8 @@ typedef struct _CONTEXT {
|
||||
#define CONTEXT_INTEGER 4L
|
||||
#define CONTEXT_DEBUG_REGISTERS 8L
|
||||
#define CONTEXT_FULL (CONTEXT_CONTROL|CONTEXT_FLOATING_POINT|CONTEXT_INTEGER)
|
||||
typedef struct _CONTEXT {
|
||||
typedef struct _FLOATING_SAVE_AREA
|
||||
{
|
||||
double Fpr0;
|
||||
double Fpr1;
|
||||
double Fpr2;
|
||||
@@ -2111,6 +2112,10 @@ typedef struct _CONTEXT {
|
||||
double Fpr30;
|
||||
double Fpr31;
|
||||
double Fpscr;
|
||||
} FLOATING_SAVE_AREA;
|
||||
|
||||
typedef struct _CONTEXT {
|
||||
FLOATING_SAVE_AREA FloatSave;
|
||||
DWORD Gpr0;
|
||||
DWORD Gpr1;
|
||||
DWORD Gpr2;
|
||||
@@ -4101,6 +4106,11 @@ static __inline__ struct _TEB * NtCurrentTeb(void)
|
||||
return __readfsdword_winnt(0x18);
|
||||
}
|
||||
#endif
|
||||
#elif defined(_M_PPC)
|
||||
static __inline__ struct _TEB * NtCurrentTeb(void)
|
||||
{
|
||||
return __readfsdword_winnt(0x18);
|
||||
}
|
||||
#endif
|
||||
|
||||
#elif defined(__WATCOMC__)
|
||||
|
||||
Reference in New Issue
Block a user