[hal] Add a mini-HAL static library

Mostly the same thing as the real one, except interrupts and DMA

svn path=/trunk/; revision=45809
This commit is contained in:
Hervé Poussineau 2010-03-03 21:56:52 +00:00
parent ba539d0eb0
commit 02f31de4d1
15 changed files with 123 additions and 0 deletions

View file

@ -196,6 +196,7 @@ HalpDispatchV86Opcode(IN PKTRAP_FRAME TrapFrame)
/* V86 TRAP HANDLERS **********************************************************/
#ifndef _MINIHAL_
VOID
FASTCALL
DECLSPEC_NORETURN
@ -234,6 +235,7 @@ HalpTrap06()
longjmp(HalpSavedContext, 1);
UNREACHABLE;
}
#endif
/* V8086 ENTER ****************************************************************/
@ -497,6 +499,7 @@ HalpMapRealModeMemory(VOID)
HalpFlushTLB();
}
#ifndef _MINIHAL_
VOID
NTAPI
HalpSwitchToRealModeTrapHandlers(VOID)
@ -517,6 +520,7 @@ HalpSwitchToRealModeTrapHandlers(VOID)
//
KeRegisterInterruptHandler(6, HalpTrap06);
}
#endif
VOID
NTAPI
@ -626,6 +630,7 @@ HalpUnmapRealModeMemory(VOID)
HalpFlushTLB();
}
#ifndef _MINIHAL_
BOOLEAN
NTAPI
HalpBiosDisplayReset(VOID)
@ -695,5 +700,6 @@ HalpBiosDisplayReset(VOID)
__writeeflags(Flags);
return TRUE;
}
#endif
/* EOF */

View file

@ -27,8 +27,10 @@ HalpRegisterKdSupportFunctions(VOID)
KdReleasePciDeviceforDebugging = HalpReleasePciDeviceForDebugging;
/* Register memory functions */
#ifndef _MINIHAL_
KdMapPhysicalMemory64 = HalpMapPhysicalMemory64;
KdUnmapVirtualAddress = HalpUnmapVirtualAddress;
#endif
/* Register ACPI stub */
KdCheckPowerButton = HalpCheckPowerButton;

View file

@ -702,6 +702,7 @@ PPCI_REGISTRY_INFO_INTERNAL
NTAPI
HalpQueryPciRegistryInfo(VOID)
{
#ifndef _MINIHAL_
WCHAR NameBuffer[8];
OBJECT_ATTRIBUTES ObjectAttributes;
UNICODE_STRING KeyName, ConfigName, IdentName;
@ -924,6 +925,9 @@ HalpQueryPciRegistryInfo(VOID)
/* Return it */
return PciRegistryInfo;
#else
return NULL;
#endif
}
VOID

View file

@ -14,6 +14,7 @@
/* GLOBALS *******************************************************************/
#ifndef _MINIHAL_
CHAR ClassTable[3922] =
{
0x43, 0x20, 0x30, 0x30, 0x20, 0x20, 0x55, 0x6E, 0x63, 0x6C, 0x61, 0x73, 0x73, 0x69, 0x66, 0x69,
@ -40415,3 +40416,4 @@ CHAR VendorTable[642355] =
0x20, 0x49, 0x6C, 0x6C, 0x65, 0x67, 0x61, 0x6C, 0x20, 0x56, 0x65, 0x6E, 0x64, 0x6F, 0x72, 0x20,
0x49, 0x44, 0x00,
};
#endif

View file

@ -31,8 +31,10 @@ VOID
NTAPI
HalDisplayString(IN PCH String)
{
#ifndef _MINIHAL_
/* Call the Inbv driver */
InbvDisplayString(String);
#endif
}
/*

View file

@ -75,11 +75,15 @@
#define NDEBUG
#include <debug.h>
#ifndef _MINIHAL_
static KEVENT HalpDmaLock;
static LIST_ENTRY HalpDmaAdapterList;
static PADAPTER_OBJECT HalpEisaAdapter[8];
#endif
static BOOLEAN HalpEisaDma;
#ifndef _MINIHAL_
static PADAPTER_OBJECT HalpMasterAdapter;
#endif
static const ULONG_PTR HalpEisaPortPage[8] = {
FIELD_OFFSET(DMA_PAGE, Channel0),
@ -92,6 +96,7 @@ static const ULONG_PTR HalpEisaPortPage[8] = {
FIELD_OFFSET(DMA_PAGE, Channel7)
};
#ifndef _MINIHAL_
static DMA_OPERATIONS HalpDmaOperations = {
sizeof(DMA_OPERATIONS),
(PPUT_DMA_ADAPTER)HalPutDmaAdapter,
@ -111,6 +116,7 @@ static DMA_OPERATIONS HalpDmaOperations = {
NULL /*(PBUILD_SCATTER_GATHER_LIST)HalBuildScatterGatherList*/,
NULL /*(PBUILD_MDL_FROM_SCATTER_GATHER_LIST)HalBuildMdlFromScatterGatherList*/
};
#endif
#define MAX_MAP_REGISTERS 64
@ -118,6 +124,7 @@ static DMA_OPERATIONS HalpDmaOperations = {
/* FUNCTIONS *****************************************************************/
#ifndef _MINIHAL_
VOID
HalpInitDma(VOID)
{
@ -154,6 +161,7 @@ HalpInitDma(VOID)
*/
HalGetDmaAdapter = HalpGetDmaAdapter;
}
#endif
/**
* @name HalpGetAdapterMaximumPhysicalAddress
@ -185,6 +193,7 @@ HalpGetAdapterMaximumPhysicalAddress(IN PADAPTER_OBJECT AdapterObject)
return HighestAddress;
}
#ifndef _MINIHAL_
/**
* @name HalpGrowMapBuffers
*
@ -428,6 +437,7 @@ HalpDmaAllocateChildAdapter(IN ULONG NumberOfMapRegisters,
return AdapterObject;
}
#endif
/**
* @name HalpDmaInitializeEisaAdapter
@ -564,6 +574,7 @@ HalpDmaInitializeEisaAdapter(IN PADAPTER_OBJECT AdapterObject,
return TRUE;
}
#ifndef _MINIHAL_
/**
* @name HalGetAdapter
*
@ -896,6 +907,7 @@ HalFreeCommonBuffer(IN PADAPTER_OBJECT AdapterObject,
Length,
CacheEnabled ? MmCached : MmNonCached);
}
#endif
/**
* @name HalpDmaGetDmaAlignment
@ -984,6 +996,7 @@ HalReadDmaCounter(IN PADAPTER_OBJECT AdapterObject)
return Count;
}
#ifndef _MINIHAL_
/**
* @name HalpGrowMapBufferWorker
*
@ -1893,6 +1906,7 @@ IoMapTransfer(IN PADAPTER_OBJECT AdapterObject,
*/
return PhysicalAddress;
}
#endif
/**
* @name HalFlushCommonBuffer

View file

@ -91,8 +91,10 @@ HalInitSystem(IN ULONG BootPhase,
KeBugCheckEx(MISMATCHED_HAL, 1, Prcb->MajorVersion, 1, 0);
}
#ifndef _MINIHAL_
/* Initialize the PICs */
HalpInitializePICs(TRUE);
#endif
/* Force initial PIC state */
KfRaiseIrql(KeGetCurrentIrql());
@ -107,9 +109,17 @@ HalInitSystem(IN ULONG BootPhase,
HalQuerySystemInformation = HaliQuerySystemInformation;
HalSetSystemInformation = HaliSetSystemInformation;
HalInitPnpDriver = NULL; // FIXME: TODO
#ifndef _MINIHAL_
HalGetDmaAdapter = HalpGetDmaAdapter;
#else
HalGetDmaAdapter = NULL;
#endif
HalGetInterruptTranslator = NULL; // FIXME: TODO
#ifndef _MINIHAL_
HalResetDisplay = HalpBiosDisplayReset;
#else
HalResetDisplay = NULL;
#endif
HalHaltSystem = HaliHaltSystem;
/* Register IRQ 2 */
@ -125,8 +135,10 @@ HalInitSystem(IN ULONG BootPhase,
/* Setup busy waiting */
HalpCalibrateStallExecution();
#ifndef _MINIHAL_
/* Initialize the clock */
HalpInitializeClock();
#endif
/*
* We could be rebooting with a pending profile interrupt,
@ -142,6 +154,7 @@ HalInitSystem(IN ULONG BootPhase,
/* Initialize bus handlers */
HalpInitBusHandler();
#ifndef _MINIHAL_
/* Enable IRQ 0 */
HalpEnableInterruptHandler(IDT_DEVICE,
0,
@ -160,6 +173,7 @@ HalInitSystem(IN ULONG BootPhase,
/* Initialize DMA. NT does this in Phase 0 */
HalpInitDma();
#endif
/* Do some HAL-specific initialization */
HalpInitPhase1();

View file

@ -28,6 +28,7 @@ HalpCheckPowerButton(VOID)
return;
}
#ifndef _MINIHAL_
PVOID
NTAPI
HalpMapPhysicalMemory64(IN PHYSICAL_ADDRESS PhysicalAddress,
@ -51,6 +52,7 @@ HalpUnmapVirtualAddress(IN PVOID VirtualAddress,
//
MmUnmapIoSpace(VirtualAddress, NumberPages << PAGE_SHIFT);
}
#endif
VOID
NTAPI
@ -122,6 +124,7 @@ VOID
NTAPI
HalHandleNMI(IN PVOID NmiInfo)
{
#ifndef _MINIHAL_
SYSTEM_CONTROL_PORT_B_REGISTER SystemControl;
//
@ -202,6 +205,7 @@ HalHandleNMI(IN PVOID NmiInfo)
// Halt the system
//
InbvDisplayString("\n*** The system has halted ***\n");
#endif
//
// Enter the debugger if possible

View file

@ -14,6 +14,7 @@
/* GLOBALS ********************************************************************/
#ifndef _MINIHAL_
/*
* This table basically keeps track of level vs edge triggered interrupts.
* Windows has 250+ entries, but it seems stupid to replicate that since the PIC
@ -1335,3 +1336,28 @@ HalpDispatchInterrupt2(VOID)
}
}
#else
KIRQL
NTAPI
KeGetCurrentIrql(VOID)
{
return PASSIVE_LEVEL;
}
VOID
FASTCALL
KfLowerIrql(
IN KIRQL OldIrql)
{
}
KIRQL
FASTCALL
KfRaiseIrql(
IN KIRQL NewIrql)
{
return NewIrql;
}
#endif

View file

@ -98,8 +98,10 @@ HalReturnToFirmware(IN FIRMWARE_REENTRY Action)
case HalHaltRoutine:
case HalRebootRoutine:
#ifndef _MINIHAL_
/* Acquire the display */
InbvAcquireDisplayOwnership();
#endif
/* Call the internal reboot function */
HalpReboot();

View file

@ -329,6 +329,7 @@ AndItsNotYou:
ret
.endfunc
#ifndef _MINIHAL_
.globl _KeStallExecutionProcessor@4
.func KeStallExecutionProcessor@4
_KeStallExecutionProcessor@4:
@ -359,6 +360,7 @@ Done:
/* Return */
ret 4
.endfunc
#endif
.global _KeQueryPerformanceCounter@4
.func KeQueryPerformanceCounter@4

View file

@ -109,6 +109,7 @@ HalpInitializeClock(VOID)
HalpCurrentRollOver = RollOver;
}
#ifndef _MINIHAL_
VOID
FASTCALL
HalpClockInterruptHandler(IN PKTRAP_FRAME TrapFrame)
@ -160,6 +161,7 @@ HalpProfileInterruptHandler(IN PKTRAP_FRAME TrapFrame)
/* Spurious, just end the interrupt */
KiEoiHelper(TrapFrame);
}
#endif
/* PUBLIC FUNCTIONS ***********************************************************/

View file

@ -63,6 +63,7 @@ HalpRegisterVector(IN UCHAR Flags,
HalpIDTUsage[SystemVector].BusReleativeVector = BusVector;
}
#ifndef _MINIHAL_
VOID
NTAPI
HalpEnableInterruptHandler(IN UCHAR Flags,
@ -87,6 +88,7 @@ HalpEnableInterruptHandler(IN UCHAR Flags,
/* Enable the interrupt */
HalEnableSystemInterrupt(SystemVector, Irql, Mode);
}
#endif
/*
* @unimplemented

View file

@ -35,4 +35,41 @@
<pch>hal.h</pch>
</directory>
</module>
<module name="mini_hal" type="objectlibrary">
<include>include</include>
<include base="ntoskrnl">include</include>
<define name="_NTHAL_" />
<define name="_NTSYSTEM_" />
<define name="_MINIHAL_" />
<directory name="generic">
<directory name="bus">
<file>bushndlr.c</file>
<file>isabus.c</file>
<file>halbus.c</file>
<file>pcibus.c</file>
<file>pcidata.c</file>
<file>sysbus.c</file>
</directory>
<file>beep.c</file>
<file>bios.c</file>
<file>cmos.c</file>
<file>dma.c</file>
<file>display.c</file>
<file>drive.c</file>
<file>misc.c</file>
<file>pic.c</file>
<file>portio.c</file>
<file>processor.c</file>
<file>profil.c</file>
<file>reboot.c</file>
<file>spinlock.c</file>
<file>sysinfo.c</file>
<file>systimer.S</file>
<file>timer.c</file>
<file>usage.c</file>
</directory>
<directory name="up">
<file>halinit_up.c</file>
</directory>
</module>
</group>

View file

@ -17,8 +17,12 @@
#undef _NTHAL_
#undef DECLSPEC_IMPORT
#define DECLSPEC_IMPORT
#ifndef _MINIHAL_
#undef NTSYSAPI
#define NTSYSAPI __declspec(dllimport)
#else
#undef _NTSYSTEM_
#endif
/* IFS/DDK/NDK Headers */
#include <ntifs.h>