您的位置:首页 > 其它

wince中断体系重要文件nkintr.h分析

2008-11-11 11:17 225 查看
刚才无意中看到了nkintr.h这个文件,以前不知道为什么这么懒惰,经常看他出现也没有打开它来分析一下。

现在来亡羊补牢吧。

首先来看他自己的介绍吧

/*++

THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF

ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO

THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A

PARTICULAR PURPOSE.

Module Name:

nkintr.h

Abstract:

This file contains the data structures, macros and function prototypes

used by the NK interrupt support and by firmware to register device

interrupt information with the kernel.

Notes:

--*/



/*

@doc EXTERNAL KERNEL HAL

@type Interrupt ID's | Interrupt id's defined in the system

@comm The kernel defines several well known interrupt ID's, which are

used by the standard system software. It also defines a range of ID's

which OEM's can use to define any custom platform specific interrupt

ID's which only their installed device drivers understand. These

interrupt ID's are passed in as parameters to a lot of the interrupt

support functions - see the cross reference section for the entire

list. The reason for defining these ID's to is isolate the kernel from

knowing about platform specific hardware interrupt numbers - the mapping

from hardware interrupt numbers to these well known InterruptID's is

done by the OEM specific ISR's.

Predefined system values are:<nl>

@flag SYSINTR_NOP | When returned from the ISR, this value causes the

kernel to complete processing of the exception handler without doing

anything else.

@flag SYSINTR_RESCHED | When returned from an ISR, this causes the kernel

to go into the reschedule routine. Typically used to signal that

a scheduler timer event just went off.

@flag SYSINTR_BREAK | Should be returned from an ISR when the halt button

has been depressed.

@flag SYSINTR_KEYBOARD | Keyboard driver interrupt

@flag SYSINTR_TOUCH | Touch panel interrupt

@flag SYSINTR_ADC | ADC

@flag SYSINTR_POWER | Power

@flag SYSINTR_SERIAL | Serial port

@flag SYSINTR_AUDIO | Audio

@flag SYSINTR_RADIO | Radio

@flag SYSINTR_PARALLEL | Parallel Port

@flag SYSINTR_PCMCIA_STATE | PCMCIA state

@flag SYSINTR_PCMCIA_EDGE | PCMCIA edge

@flag SYSINTR_PCMCIA_LEVEL | PCMCIA level

@flag SYSINTR_TOUCH_CHANGED | Touch panel changed interrupt

@flag SYSINTR_OEMBASE | Beyond this OEM's can define custom ID's

@flag SYSINTR_MAXIMUM | End of valid ID's



@xref <l Overview.Kernel Interrupt Support> <f InterruptInitialize>

<f InterruptDone> <f InterruptDisable> <f OEMInterruptDone>

<f OEMInterruptDisable> <f OEMInterruptEnable>

*/

=====================开始看一些以往在BSP源码里面经常出现的宏定义====================

//---这个在中断体系里经常看到

#define SYSINTR_UNDEFINED (-1) // SysIntr not defined for IRQ<->SYSINTR mapping

#define SYSINTR_NOP 0 /* no processing required 有中断,但没有产生中断线程*/

//SYSINTR_RESCHED中断是由请求 OS 重新调度的计时器到期引起的。

#define SYSINTR_RESCHED 1 /* set "reschedule flag" */

#define SYSINTR_BREAK 2 /* break into debugger */

#define SYSINTR_CHAIN 3 /* continue to next handler */

// SYSINTR_DEVICES is the base for any non-OAL system interrupts-不使用在BSP

#define SYSINTR_DEVICES 8

#define SYSINTR_PROFILE (SYSINTR_DEVICES+1) // System Profiling

#define SYSINTR_TIMING (SYSINTR_DEVICES+2) // Latency Analysis

#define SYSINTR_RTC_ALARM (SYSINTR_DEVICES+5)// real-time clock alarm

#define SYSINTR_NETWORK_SHARED (SYSINTR_DEVICES+6)//Combined interrupts fornetwork

#define SYSINTR_VMINI (SYSINTR_DEVICES+7) // VMini RX interrupt.

//--系统中断设置为从16开始,不知道这是什么原因了#define SYSINTR_DEVICES 8

// SYSINTR_FIRMWARE is the base for any interrupts defined in the OAL

#define SYSINTR_FIRMWARE (SYSINTR_DEVICES+8)

//--这里设置中断最大器件数是64,但是SYSINTR_MAXIMUM=72 干什么呢?

#define SYSINTR_MAX_DEVICES 64

#define SYSINTR_MAXIMUM (SYSINTR_DEVICES+SYSINTR_MAX_DEVICES)

====================以下代码不知道在哪里用到了,现在暂时不分析,以后再说了===========================

/*

Wake source IDs are used as parameters to kernel IOCTLs, including:

- IOCTL_HAL_ENABLE_WAKE

- IOCTL_HAL_DISABLE_WAKE

- IOCTL_HAL_GET_WAKE_SOURCE

Wake source IDs may be SysIntr values, Microsoft-defined reserved values,

or OEM-defined values. ID ranges are:

1 - (SYSWAKE_BASE - 1): The interrupt associated with a SysIntr is the

wake source. In practice these will never exceed

SYSINTR_MAXIMUM.

SYSWAKE_BASE - (SYSWAKE_OEMBASE - 1): Microsoft-defined wake source IDs.

Unused values in this range are reserved for future

use.

SYSWAKE_OEMBASE - (SYSWAKE_MAXIMUM - 1): OEM-defined wake source IDs. These

wake sources are platform specific.

The kernel will return SYSWAKE_UNKNOWN if it cannot determine why the system

resumed from suspend.

*/

// wake source ranges

#define SYSWAKE_BASE 1024

#define SYSWAKE_OEMBASE 2048

#define SYSWAKE_MAXIMUM 4096

// kernel returns this value if it doesn't know why the system resumed

#define SYSWAKE_UNKNOWN ((DWORD) (-1))

// MS-defined wake sources

#define SYSWAKE_PCCARD_STATUS_CHANGE (SYSWAKE_BASE + 0) // any pcmcia socket status change

#define SYSWAKE_RING_INDICATE (SYSWAKE_BASE + 1) // ring indicate on any uart

#define SYSWAKE_WAKE_ON_LAN (SYSWAKE_BASE + 2) // wake-on-lan from any network device

#define SYSWAKE_POWER_BUTTON (SYSWAKE_BASE + 3) // primary suspend/resume button pressed

#define OEM_DEBUG_READ_NODATA (-1)

#define OEM_DEBUG_COM_ERROR (-2)

// Defs for SetKernelCommDev

#define KERNEL_SVC_DBGMSG 0

#define KERNEL_SVC_PPSH 1

#define KERNEL_SVC_KDBG 2

#define KERNEL_COMM_SERIAL 0

#define KERNEL_COMM_PARALLEL 1

#define KERNEL_COMM_ETHER 2



#ifndef ASM_ONLY

/** Kernel functions exported to OEM routines */

extern BOOL HookInterrupt(int hwIntNumber, FARPROC pfnHandler);

extern BOOL UnhookInterrupt(int hwInterruptNumber, FARPROC pfnHandler);

extern DWORD NKCallIntChain(BYTE irq);

extern BOOL NKIsSysIntrValid (DWORD idInt);

extern BOOL NKSetInterruptEvent (DWORD idInt);

//

// Interrupt enable/disable. INTERRUPTS_ON() and INTERRUPTS_OFF() set the

// interrupt mask explicitly. INTERRUPTS_ENABLE() will return the boolean TRUE

// if the interrupts are currently enabled. A boolean parameter of FALSE

// disables interrupts and a boolean parameter of TRUE enables interrupts.

//

extern void INTERRUPTS_ON(void);

extern void INTERRUPTS_OFF(void);

extern BOOL INTERRUPTS_ENABLE(BOOL fEnable);

extern BOOL (*KSystemTimeToFileTime)(LPSYSTEMTIME, LPFILETIME);

extern BOOL (*KFileTimeToSystemTime)(const FILETIME *lpft, LPSYSTEMTIME lpst);

extern LONG (*KCompareFileTime)(LPFILETIME, LPFILETIME);

extern BOOL SetKernelCommDev(UCHAR Service, UCHAR CommDevice);

====================以下代码是BSP里面的重要OEM函数:难怪OEM函数的名字是不能改变的===================

// Function pointers used for kernel debug services. Initially, these all point to

// the OEMxxx functions. If kernel services are redirected via SetKernelCommDev,

// these function pointers may be modified. For example, if you set up PPSH and

// debug messages to run over serial, call lpWriteDebugStringFunc to get the

// necessary formatting so that the PPSH app can decode the strings.

extern void (* lpWriteDebugStringFunc)(unsigned short *str);

extern int (* lpReadDebugByteFunc)(void);

extern void (* lpWriteDebugByteFunc)(BYTE ch);

extern void (* lpParallelPortSendByteFunc)(BYTE ch);

extern int (* lpParallelPortGetByteFunc)(void);

/** CoreDll functions exported to OEM Drivers (not HAL) */

BOOL SetInterruptEvent(DWORD idInt);

BOOL CeSetPowerOnEvent (HANDLE hEvt); // used to set event in power handler

/** OEM supplied functions */

extern void OEMInit(void);

extern BOOL OEMInterruptEnable(DWORD idInt, LPVOID pvData, DWORD cbData);

extern void OEMInterruptDisable(DWORD idInt);

extern void OEMInterruptDone(DWORD idInt);

extern BOOL OEMGetRealTime(LPSYSTEMTIME lpst);

extern BOOL OEMSetRealTime(LPSYSTEMTIME lpst);

extern BOOL OEMSetAlarmTime(LPSYSTEMTIME lpst);

extern void OEMPowerOff(void);

/** OEM supplied debug support functions */

extern void OEMInitDebugSerial(void);

extern void OEMWriteDebugString(unsigned short *str);

extern void OEMWriteDebugLED(WORD wIndex, DWORD dwPattern);

extern int OEMReadDebugByte(void);

extern void OEMWriteDebugByte(BYTE ch);

extern void OEMClearDebugCommError(void);

extern int OEMParallelPortGetByte(void);

extern void OEMParallelPortSendByte(BYTE ch);

/** OEM supplied extension memory probe routine */

//-----如下结构体在哪里用到了?

typedef struct _MEMORY_SECTION {

DWORD dwFlags;

DWORD dwStart;

DWORD dwLen;

} MEMORY_SECTION, *PMEMORY_SECTION;

BOOL OEMGetExtensionDRAM(LPDWORD lpMemStart, LPDWORD lpMemLen);

extern DWORD (*pNKEnumExtensionDRAM)(PMEMORY_SECTION pMemSections, DWORD cMemSections);

/** OEM supplied data */

extern unsigned long OEMClockFreq; /* Timer clock frequency in Hertz */





哈哈,比较精简,主要是看代码就可以了。

wogoyixikexie@gliet 2008-11-11 于广州

转载请表明wogoyixikexie@gliet桂林电子科技大学一系科协,如有错误,希望能够指出。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: