⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 nkppc.h

📁 windows ce 3.00 嵌入式操作系统源代码
💻 H
📖 第 1 页 / 共 2 页
字号:
    ULONG CR0 : 4;
} CondR, *PCondR;

//
// Define Fixed Point Exception Register (XER) fields
//

typedef struct _XER {
    ULONG Rsv : 29;     // 31..3 Reserved
    ULONG CA  : 1;      // 2     Carry
    ULONG OV  : 1;      // 1     Overflow
    ULONG SO  : 1;      // 0     Summary Overflow
} XER, *PXER;

//
// Define Floating Point Status/Control Register (FPSCR) fields
//

typedef struct _FPSCR {
    ULONG RN     : 2;   // 31..30 Rounding control
    ULONG NI     : 1;   // 29     Non-IEEE mode
    ULONG XE     : 1;   // 28     Inexact exception Enable
    ULONG ZE     : 1;   // 27     Zero divide exception Enable
    ULONG UE     : 1;   // 26     Underflow exception Enable
    ULONG OE     : 1;   // 25     Overflow exception Enable
    ULONG VE     : 1;   // 24     Invalid operation exception Enable
    ULONG VXCVI  : 1;   // 23     Invalid op exception (integer convert)
    ULONG VXSQRT : 1;   // 22     Invalid op exception (square root)
    ULONG VXSOFT : 1;   // 21     Invalid op exception (software request)
    ULONG Res1   : 1;   // 20     reserved
    ULONG FU     : 1;   // 19     Result Unordered or NaN
    ULONG FE     : 1;   // 18     Result Equal or zero
    ULONG FG     : 1;   // 17     Result Greater than or positive
    ULONG FL     : 1;   // 16     Result Less than or negative
    ULONG C      : 1;   // 15     Result Class descriptor
    ULONG FI     : 1;   // 14     Fraction Inexact
    ULONG FR     : 1;   // 13     Fraction Rounded
    ULONG VXVC   : 1;   // 12     Invalid op exception (compare)
    ULONG VXIMZ  : 1;   // 11     Invalid op exception (infinity * 0)
    ULONG VXZDZ  : 1;   // 10     Invalid op exception (0 / 0)
    ULONG VXIDI  : 1;   // 9      Invalid op exception (infinity / infinity)
    ULONG VXISI  : 1;   // 8      Invalid op exception (infinity - infinity)
    ULONG VXSNAN : 1;   // 7      Invalid op exception (signalling NaN)
    ULONG XX     : 1;   // 6      Inexact exception
    ULONG ZX     : 1;   // 5      Zero divide exception
    ULONG UX     : 1;   // 4      Underflow exception
    ULONG OX     : 1;   // 3      Overflow exception
    ULONG VX     : 1;   // 2      Invalid operation exception summary
    ULONG FEX    : 1;   // 1      Enabled Exception summary
    ULONG FX     : 1;   // 0      Exception summary
} FPSCR, *PFPSCR;

// end_nthal

//
// Define PowerPC exception handling structures and function prototypes.
//
// These are adopted without change from the MIPS implementation.
//

//
// Function table entry structure definition.
//

typedef struct _RUNTIME_FUNCTION {
    ULONG BeginAddress;
    ULONG EndAddress;
    PEXCEPTION_ROUTINE ExceptionHandler;
    PVOID HandlerData;
    ULONG PrologEndAddress;
} RUNTIME_FUNCTION, *PRUNTIME_FUNCTION;

//
// Scope table structure definition.
//

typedef struct _SCOPE_TABLE {
    ULONG Count;
    struct
    {
        ULONG BeginAddress;
        ULONG EndAddress;
        ULONG HandlerAddress;
        ULONG JumpTarget;
    } ScopeRecord[1];
} SCOPE_TABLE, *PSCOPE_TABLE;

//
// Runtime Library function prototypes.
//

VOID
RtlCaptureContext (
    OUT PCONTEXT ContextRecord
    );

PRUNTIME_FUNCTION
RtlLookupFunctionEntry (
    IN ULONG ControlPc
    );

ULONG
RtlVirtualUnwind (
    IN ULONG ControlPc,
    IN PRUNTIME_FUNCTION FunctionEntry,
    IN OUT PCONTEXT ContextRecord,
    OUT PBOOLEAN InFunction,
    OUT PULONG EstablisherFrame
    );

//
// Define C structured exception handing function prototypes.
//

struct _EXCEPTION_POINTERS;

typedef
LONG
(*EXCEPTION_FILTER) (
    struct _EXCEPTION_POINTERS *ExceptionPointers
    );

typedef
VOID
(*TERMINATION_HANDLER) (
    BOOLEAN is_abnormal
    );

// end_winnt

#define retValue ctx.Gpr3
#define ARG0    ctx.Gpr3
#define SetThreadIP(pth, addr) ((pth)->ctx.Iar = (ULONG)(addr))
#define GetThreadIP(pth) ((pth)->ctx.Iar)

/* Macros for handling stack shrinkage. */
#define STK_SLACK_SPACE	232

#define MDTestStack(pth)    (((pth)->ctx.Gpr1 < 0x80000000  \
        && ((pth)->dwStackBound>>VA_PAGE) 						\
        	< (((pth)->ctx.Gpr1-STK_SLACK_SPACE)>>VA_PAGE))  	\
        ? (pth)->dwStackBound : 0)

#define MDShrinkStack(pth)  ((pth)->dwStackBound += PAGE_SIZE)

/* Query & set thread's kernel vs. user mode state */
#define KERNEL_MODE     0
#define USER_MODE       1
#define SR_MODE_BITS    14
#define GetThreadMode(pth) (((pth)->ctx.Msr >> SR_MODE_BITS) & 1)
#define SetThreadMode(pth, mode) \
        ((pth)->ctx.Msr = ((pth)->ctx.Msr&(~(1<<SR_MODE_BITS))) | ((mode&1)<<SR_MODE_BITS))

/* Query & set kernel vs. user mode state via Context */
#define GetContextMode(pctx) (((pctx)->Msr >> SR_MODE_BITS) & 1)
#define SetContextMode(pctx, mode)	\
		((pctx)->Msr = ((pctx)->Msr&(~(1<<SR_MODE_BITS))) | ((mode&1)<<SR_MODE_BITS))


#include "mem_ppc.h"



struct KDataStruct {
	LPDWORD	lpvTls;			/* 0x000 Current thread local storage pointer */
    HANDLE ahSys[NUM_SYS_HANDLES]; /* 0x004 If this moves, change kapi.h */
    char    bResched;       /* 0x084 reschedule flag */
    char    cNest;       	/* 0x085 kernel exception nesting level */
    char	pad;			/* 0x086 alignment padding (must never be used) */
    char	pad2;			/* 0x087 alignment padding (must never be used) */
    ulong   cMsec;          /* 0x088 # of milliseconds since boot */
    ulong   cDMsec;         /* 0x08c # of mSec since last TimerCallBack */
	ACCESSKEY akyCur;       /* 0x090 current access key */
	PTHREAD	pCurThd;		/* 0x094 ptr to current THREAD struct */
	DWORD	dwPad;		    /* 0x098 was process breakpoint */
	ulong	handleBase;		/* 0x09c handle table base address */

	PSECTION aSections[64]; /* 0x0a0 section table for virtual memory */
	LPEVENT alpeIntrEvents[SYSINTR_MAX_DEVICES];/* 0x1a0 */
	LPVOID  alpvIntrData[SYSINTR_MAX_DEVICES];  /* 0x220 */
    char    bPowerOff;      /* 0x2a0 TRUE during "power off" processing */
    char    bProfileOn;     /* 0x2a1 TRUE if profiling enabled */
    char	bPad[2];		/* 0x2a2 */
    ulong	pAPIReturn;		/* 0x2a4 direct API call return for kernel mode */
	PPROCESS pCurPrc;		/* 0x2a8 ptr to current PROCESS struct */
    long	kGP;			/* 0x2ac kernel's Global Data pointer */
    ulong 	kMSR;		    /* 0x2b0 base kernel MSR */
    uchar   kPFNMap[KPFN_CNT];      /* 0x2b4 - 0x2d4 KVA to Physical Mappings */

	char    bReserved[0x2fc-0x2d4]; /* 0x2d4 - Processor specific reserved */
	DWORD	dwInDebugger;	/* 0x2fc - !0 when in debugger */
	DWORD   aInfo[32];      /* 0x300 - misc. kernel info */
	DWORD	dwKCRes;		/* 0x380 */
							/* 0x384 - 0x390 - ununsed */
	                        /* 0x390 - low memory interrupt handlers */
	                        /* 0x800 - end */
};  /* KDataStruct */

#define KData  (*(struct KDataStruct *)(KPAGE_BASE+0x800))
#define VKData  (*(volatile struct KDataStruct *)(KPAGE_BASE+0x800))

#define hCurThread          (KData.ahSys[SH_CURTHREAD])
#define hCurProc            (KData.ahSys[SH_CURPROC])
#define pCurThread          (KData.pCurThd)
#define pCurProc            (KData.pCurPrc)
#define ReschedFlag         (KData.bResched)
#define PowerOffFlag        (KData.bPowerOff)
#define ProfileFlag         (KData.bProfileOn)
#define CurAKey             (KData.akyCur)
#define SectionTable        (KData.aSections)
#define InSysCall()         (KData.cNest != 1)
#define MustReschedule()    (*(ulong*)&KData.bResched == 1)
#define IntrEvents          (KData.alpeIntrEvents)
#define IntrData            (KData.alpvIntrData)
#define KPlpvTls            (KData.lpvTls)
#define KInfoTable          (KData.aInfo)
#define DIRECT_RETURN       (KData.pAPIReturn)
#define BaseMSR             (KData.kMSR)
#define KPfnMap             (KData.kPFNMap)
#define KCResched			(KData.dwKCRes)
#define	InDebugger			(KData.dwInDebugger)

ERRFALSE(AddrCurMSec == offsetof(struct KDataStruct, cMsec)+KPAGE_BASE+0x800);
ERRFALSE(AddrDiffMSec == offsetof(struct KDataStruct, cDMsec)+KPAGE_BASE+0x800);
#undef DiffMSec
#define DiffMSec (KData.cDMsec)
#undef CurMSec
#define CurMSec (KData.cMsec)

extern void INTERRUPTS_ON(void);
extern void INTERRUPTS_OFF(void);

extern void *InterlockedPopList(void *pHead);
extern void *InterlockedPushList(void *pHead, void *pItem);

// Defines for CPU specific IDs.
#define THISCPUID IMAGE_FILE_MACHINE_POWERPC
#define PROCESSOR_ARCHITECTURE PROCESSOR_ARCHITECTURE_PPC
extern DWORD CEProcessorType;
extern WORD ProcessorLevel;
extern WORD ProcessorRevision;

#endif // defined(PPC)

#endif // _NKPPC_

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -