cfwaltna.c
来自「WinCE 3.0 BSP, 包含Inter SA1110, Intel_815」· C语言 代码 · 共 257 行
C
257 行
/*++
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.
Copyright (c) 1995, 1996, 1997 Microsoft Corporation
Module Name:
cfwaltna.c
Abstract:
This file implements the Windows CE kernel interfaces for Altoona.
Notes:
--*/
#include <windows.h>
#include <nkintr.h>
#include <altoona.h>
#include <hal.h>
#include <bldver.h>
extern ULONG Timer2ISR(void);
extern void InitClockTimer2(void);
void InitDebugEther(void);
/*
** Interrupt ID arrays
*/
UCHAR IMAP_Sys2Aln[SYSINTR_MAX];
UCHAR IMAP_Aln2Sys[ALNINTR_MAX];
/*
@doc EXTERNAL KERNEL HAL
@module cfwaltna.c - Altoona HW Support |
OEM support Functions for the Altoona set top box.
@xref <f OEMInit> <f OEMInterruptEnable> <f OEMInterruptDisable>
<f OEMInterruptDone> <l HAL Overview.Pegasus Kernel OEM Interface>
@topic Windows CE Kernel OEM Interface |
This defines the HAL layer - OEM and platform dependent pieces of
code which we expect the OEM to deliver to us. There are three pieces
of OEM deliverable code - the bootstrap loader & monitor (for
debugging), the HAL portions which are interfaces between the kernel
and the firmware, and the driver interface. This topic covers just
the HAL portion.
The philosophy is to keep the HAL layer as simple as possible. The
HAL should not be confused with the machine or CPU independence. HAL
is specific for a particular CPU and platform. It includes interfaces
for the following devices:<nl>
Real Time Clock<nl>
Interval Timer (used for the scheduler operation) <nl>
Interrupt handlers and support <nl>
Note that it does not include abstractions for devices like the DMA
controller etc. since the kernel does not use one. Also note that the
list could change for different CPU's and platforms - for instance,
some chips might include a lot of peripheral devices (like the
interval timer) on the CPU chip itself, removing the need for a
separate interface for them.
The interfaces for the real time clock and interval timer are still
being developed. But they should in general be extremely simple and
straightforward. For details on the interrupt support model in the
kernel look at <l Interrupt Support Overview.Kernel Interrupt Support>
@xref <l Interrupt Support Overview.Kernel Interrupt Support>
<f OEMInit> <f OEMInterruptEnable> <f OEMInterruptDisable>
<f OEMInterruptDone> <f HookInterrupt>
*/
#if CE_MAJOR_VER < 3
unsigned long OEMClockFreq = CPU_CLOCK_FRQUENCY;
#endif
/*
@func void | OEMInit | Initialize Hardware Interfaces
@rdesc none
@comm OEMInit is called by the kernel after it has performed minimal
initialization. Interrupts are disabled and the kernel is not
ready to handle exceptions. The only kernel service available
to this function is <f HookInterrupt>. This should be used to
install ISR's for all the hardware interrupts to be handled by
the firmware. Note that ISR's must be installed for any interrupt
that is to be routed to a device driver - otherwise the
<f InterruptInitialize> call from the driver will fail.
@xref <l Overview.Pegasus Kernel OEM Interface> <f HookInterrupt>
<f InterruptInitialize>
*/
void OEMInit()
{
extern LPDWORD pTOC;
LPDWORD pLog;
// Initialize debug Ethernet hardware and configure kernel services over
// Ethernet (debug messages, CESH, kernel debugger, etc.).
InitDebugEther();
OEMParallelPortInit();
InitClockTimer2();
InitBusInfo();
InitInterrupts();
HookInterrupt(4, (void *)Timer2ISR);
/*
Ensure that OS doesn't detect previous boot's registry shadow.
This platform doesn't "sleep" and therefore it should never find
anything. Unfortunately the TOC structure isn't exported.
*/
pLog = (LPDWORD) (pTOC[6] | 0x20000000);
pLog[0] = 0;
pLog[1] = 0;
pLog[2] = 0;
}
/*
@func BOOL | OEMInterruptEnable | Enable a hardware interrupt
@rdesc Returns TRUE if valid interrupt ID or FALSE if invalid ID.
@comm This function is called by the Kernel when a device driver
calls <f InterruptInitialize>. The system is not preemptible when this
function is called.
@xref <l Overview.Pegasus Kernel OEM Interface> <f InterruptInitialize>
*/
BOOL OEMInterruptEnable (
DWORD SysInt, // @parm Interrupt ID to be enabled. See
// <l Interrupt ID's.Interrupt ID's> for a list of possble values.
LPVOID pvData, // @parm ptr to data passed in in the <f InterruptInitialize> call
DWORD cbData // @parm Size of data pointed to be <p pvData>
)
{
UCHAR IntLine = 0;
BOOL bRet = FALSE;
INTERRUPTS_OFF();
IntLine = IMAP_Sys2Aln[SysInt];
if (IntLine <= ALNINTR_IRQ15) // ISA interrupts.
{
PICEnableInterrupt(IntLine, TRUE);
bRet = TRUE;
}
else if (IntLine <= ALNINTR_PCI_ERR) // CPU/PCI mastering interrupts.
{
SYSEnableInterrupt(IntLine-MASTERINTR_VECTOR, TRUE);
bRet = TRUE;
}
#ifdef NOTDEF
else if(SysInt == SYSINTR_VMINI) // VMINI.
{
bRet = TRUE;
}
#endif // NOTDEF.
INTERRUPTS_ON();
return(bRet);
}
/*
@func void | OEMInterruptDisable | Disable a hardware interrupt
@rdesc none
@comm OEMInterruptDisable is called by the Kernel when a device driver
calls <f InterruptDisable>. The system is not preemtible when this
function is called.
@xref <l Overview.Pegasus Kernel OEM Interface> <f InterruptDisable>
*/
void OEMInterruptDisable(
DWORD SysInt // @parm Interrupt ID to be disabled. See <t Interrupt ID's>
// for the list of possible values.
)
{
UCHAR IntLine = 0;
INTERRUPTS_OFF();
IntLine = IMAP_Sys2Aln[SysInt];
if (IntLine <= ALNINTR_IRQ15)
{
PICEnableInterrupt(IntLine, FALSE);
}
else if (IntLine <= ALNINTR_PCI_ERR)
{
SYSEnableInterrupt(IntLine-MASTERINTR_VECTOR, FALSE);
}
INTERRUPTS_ON();
}
/*
@func BOOL | OEMInterruptDone | Signal completion of interrupt processing
@rdesc none
@comm OEMInterruptDone is called by the Kernel when a device driver
calls <f InterruptDone>. The system is not preemtible when this
function is called.
@xref <l Overview.Kernel Interrupt Support> <f InterruptDone>
*/
void OEMInterruptDone(
DWORD SysInt // @parm Interrupt ID. See <t Interrupt ID's>
// for the list of possible values.
)
{
UCHAR IntLine = 0;
INTERRUPTS_OFF();
IntLine = IMAP_Sys2Aln[SysInt];
if (IntLine <= ALNINTR_IRQ15)
{
PICEnableInterrupt(IntLine, TRUE);
}
else if (IntLine <= ALNINTR_PCI_ERR)
{
SYSDoneInterrupt(IntLine-MASTERINTR_VECTOR);
}
INTERRUPTS_ON();
}
BOOL OEMGetExtensionDRAM(LPDWORD lpMemStart, LPDWORD lpMemLen)
{
return FALSE; /* no extension DRAM */
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?