📄 oeminit.c
字号:
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//
// Use of this source code is subject to the terms of the Microsoft end-user
// license agreement (EULA) under which you licensed this SOFTWARE PRODUCT.
// If you did not accept the terms of the EULA, you are not authorized to use
// this source code. For a copy of the EULA, please see the LICENSE.RTF on your
// install media.
//
/*++
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:
Abstract:
This file implements the NK kernel interfaces for firmware interrupt
support on the CEPC.
Functions:
Notes:
--*/
#include <windows.h>
#include <oal.h>
#include <nkintr.h>
/*
@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.Windows CE Kernel OEM Interface> <f HookInterrupt>
<f InterruptInitialize>
*/
extern DWORD MainMemoryEndAddress;
VOID PCIInitBusInfo (void);
DWORD OEMPowerManagerInit(void);
void InitClock(void);
void x86InitMemory (void);
static void x86InitRomChain (void);
void x86InitPICs(void);
extern const BOOL g_fSupportHwDbg;
extern DWORD dwNKDrWatsonSize; // Must change this to enable Kernel Watson support
// must be multiple of PAGE_SIZE
BOOL g_fPostInit;
void OEMInit()
{
// initialize interrupts
OALIntrInit ();
// Initialize PCI bus information
PCIInitBusInfo ();
// start KITL
OALKitlStart ();
#ifdef DEBUG
// Instead of calling OEMWriteDebugString directly, call through exported
// function pointer. This will allow these messages to be seen if debug
// message output is redirected to Ethernet or the parallel port. Otherwise,
// lpWriteDebugStringFunc == OEMWriteDebugString.
lpWriteDebugStringFunc(TEXT("CEPC Firmware Init\r\n"));
#endif
OEMPowerManagerInit();
// initialize PIC
x86InitPICs();
// initialize clock
InitClock();
// initialize memory (detect extra ram, MTRR/PAT etc.)
x86InitMemory ();
// initialize pKDIoControl is hardware debugging is supported
if (g_fSupportHwDbg) {
pKDIoControl = OEMKDIoControl;
}
// Reserve 128kB memory for Watson Dumps
dwNKDrWatsonSize = (128 * 1024);
x86InitRomChain();
#ifdef DEBUG
lpWriteDebugStringFunc(TEXT("Firmware Init Done.\r\n"));
#endif
}
BOOL x86IoCtlPostInit (
UINT32 code, VOID *lpInBuf, UINT32 nInBufSize, VOID *lpOutBuf,
UINT32 nOutBufSize, UINT32 *lpBytesReturned
) {
// Critical sections to be initialized
extern CRITICAL_SECTION RTC_critsect;
// Initialize critical sections
InitializeCriticalSection(&RTC_critsect);
g_fPostInit = TRUE;
return TRUE;
}
#include "pehdr.h"
#include "romldr.h"
#include "romxip.h"
/*
Initialize the rom chain
*/
#define NOT_FIXEDUP (DWORD*)-1
extern ROMChain_t *OEMRomChain;
DWORD *pdwXIPLoc = NOT_FIXEDUP;
static void x86InitRomChain (void)
{
// Added for MultiXIP stuff
static ROMChain_t s_pNextRom[MAX_ROM] = {0};
DWORD dwRomCount = 0;
DWORD dwChainCount = 0;
DWORD * pdwCurXIP;
DWORD dwNumXIPs;
PXIPCHAIN_ENTRY pChainEntry = NULL;
#ifdef DEBUG
TCHAR szXIPName[XIP_NAMELEN];
int i; // loop ctr
#endif
#ifdef DEBUG
lpWriteDebugStringFunc(TEXT("Looking for rom chain\n"));
#endif
if(pdwXIPLoc == NOT_FIXEDUP){
#ifdef DEBUG
lpWriteDebugStringFunc(TEXT("Rom chain NOT found\n"));
#endif
return; // no chain or not fixed up properly
}
#ifdef DEBUG
lpWriteDebugStringFunc(TEXT("Rom chain found\n"));
#endif
// set the top bit to mark it as a virtual address
pdwCurXIP = (DWORD*)(((DWORD)pdwXIPLoc) | 0x80000000);
// first DWORD is number of XIPs
dwNumXIPs = (*pdwCurXIP);
if(dwNumXIPs > MAX_ROM){
lpWriteDebugStringFunc(TEXT("ERROR: Number of XIPs exceeds MAX\n"));
return;
}
pChainEntry = (PXIPCHAIN_ENTRY)(pdwCurXIP + 1);
while(dwChainCount < dwNumXIPs)
{
if ((pChainEntry->usFlags & ROMXIP_OK_TO_LOAD) && // flags indicates valid XIP
*(LPDWORD)(((DWORD)(pChainEntry->pvAddr)) + ROM_SIGNATURE_OFFSET) == ROM_SIGNATURE)
{
s_pNextRom[dwRomCount].pTOC = *(ROMHDR **)(((DWORD)(pChainEntry->pvAddr)) + ROM_SIGNATURE_OFFSET + 4);
s_pNextRom[dwRomCount].pNext = NULL;
#ifdef DEBUG
lpWriteDebugStringFunc( _T("XIP found: ") );
for (i = 0; (i< (XIP_NAMELEN-1)) && (pChainEntry->szName[i] != '\0'); ++i)
{
szXIPName[i] = (TCHAR)pChainEntry->szName[i];
}
szXIPName[i] = TEXT('\0');
lpWriteDebugStringFunc( szXIPName );
lpWriteDebugStringFunc( _T("\n") );
#endif
if (dwRomCount != 0)
{
s_pNextRom[dwRomCount-1].pNext = &s_pNextRom[dwRomCount];
}
else
{
OEMRomChain = s_pNextRom;
}
dwRomCount++;
}
else
{
lpWriteDebugStringFunc( _T("Invalid XIP found\n") );
}
++pChainEntry;
dwChainCount++;
}
#ifdef DEBUG
{
ROMChain_t *pchain = OEMRomChain;
lpWriteDebugStringFunc( _T("chain contents...\n") );
while(pchain){
lpWriteDebugStringFunc( _T("found item\n") );
pchain = pchain->pNext;
}
}
#endif
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -