- give apic hal its own halinit_apic
- give minihal an own halinit_mini.c containing function stubs
- move HalInitializeProcessor to halinit.c and add hal specific function HalpInitProcessor
- get rid of all the #ifndef _MINIHAL_ in halinit.c and move the file to lib_hal_generic
- improve the hal version/build check
- Update spec file for amd64

svn path=/trunk/; revision=53625
This commit is contained in:
Timo Kreuzer 2011-09-07 18:25:43 +00:00
parent 2f5ccca699
commit f85bf4380d
9 changed files with 204 additions and 74 deletions

View file

@ -27,12 +27,13 @@
@ stdcall HalAllocateCommonBuffer(ptr long ptr long) @ stdcall HalAllocateCommonBuffer(ptr long ptr long)
@ stdcall HalAllocateCrashDumpRegisters(ptr ptr) @ stdcall HalAllocateCrashDumpRegisters(ptr ptr)
@ stdcall HalAssignSlotResources(ptr ptr ptr ptr long long long ptr) @ stdcall HalAssignSlotResources(ptr ptr ptr ptr long long long ptr)
@ stdcall HalBeginSystemInterrupt(long long ptr) @ stdcall -arch=i386,arm HalBeginSystemInterrupt(long long ptr)
@ stdcall HalCalibratePerformanceCounter(ptr long long) @ stdcall HalCalibratePerformanceCounter(ptr long long)
;@ stdcall -arch=x86_64 HalCallBios()
@ stdcall HalDisableSystemInterrupt(long long) @ stdcall HalDisableSystemInterrupt(long long)
@ stdcall HalDisplayString(str) @ stdcall HalDisplayString(str)
@ stdcall HalEnableSystemInterrupt(long long long) @ stdcall HalEnableSystemInterrupt(long long long)
@ stdcall HalEndSystemInterrupt(long long) @ stdcall -arch=i386,arm HalEndSystemInterrupt(long long)
@ stdcall HalFlushCommonBuffer(long long long long long) @ stdcall HalFlushCommonBuffer(long long long long long)
@ stdcall HalFreeCommonBuffer(ptr long long long ptr long) @ stdcall HalFreeCommonBuffer(ptr long long long ptr long)
@ stdcall HalGetAdapter(ptr ptr) @ stdcall HalGetAdapter(ptr ptr)
@ -41,18 +42,22 @@
@ stdcall HalGetEnvironmentVariable(str long str) @ stdcall HalGetEnvironmentVariable(str long str)
@ fastcall -arch=arm HalGetInterruptSource() @ fastcall -arch=arm HalGetInterruptSource()
@ stdcall HalGetInterruptVector(long long long long ptr ptr) @ stdcall HalGetInterruptVector(long long long long ptr ptr)
@ stdcall -arch=i386 HalHandleNMI(ptr) ;@ stdcall -arch=x86_64 HalHandleMcheck()
@ stdcall -arch=i386,x86_64 HalHandleNMI(ptr)
@ stdcall HalInitSystem(long ptr) @ stdcall HalInitSystem(long ptr)
@ stdcall HalInitializeProcessor(long ptr) @ stdcall HalInitializeProcessor(long ptr)
;@ stdcall -arch=x86_64 HalIsHyperThreadingEnabled()
@ stdcall HalMakeBeep(long) @ stdcall HalMakeBeep(long)
@ stdcall HalProcessorIdle() @ stdcall HalProcessorIdle()
@ stdcall HalPutDmaAdapter(ptr) @ stdcall -arch=i386 HalPutDmaAdapter(ptr)
@ stdcall HalQueryDisplayParameters(ptr ptr ptr ptr) @ stdcall HalQueryDisplayParameters(ptr ptr ptr ptr)
@ stdcall HalQueryRealTimeClock(ptr) @ stdcall HalQueryRealTimeClock(ptr)
@ stdcall HalReadDmaCounter(ptr) @ stdcall HalReadDmaCounter(ptr)
@ stdcall HalReportResourceUsage() @ stdcall HalReportResourceUsage()
@ stdcall HalRequestIpi(long) @ stdcall HalRequestIpi(long)
@ stdcall HalReturnToFirmware(long) @ stdcall HalReturnToFirmware(long)
;@ stdcall -arch=x86_64 HalSendNMI()
;@ stdcall -arch=x86_64 HalSendSoftwareInterrupt()
@ stdcall HalSetBusData(long long long ptr long) @ stdcall HalSetBusData(long long long ptr long)
@ stdcall HalSetBusDataByOffset(long long long ptr long long) @ stdcall HalSetBusDataByOffset(long long long ptr long long)
@ stdcall HalSetDisplayParameters(long long) @ stdcall HalSetDisplayParameters(long long)
@ -65,6 +70,7 @@
@ stdcall HalStopProfileInterrupt(long) @ stdcall HalStopProfileInterrupt(long)
@ fastcall -arch=arm HalSweepIcache() @ fastcall -arch=arm HalSweepIcache()
@ fastcall -arch=arm HalSweepDcache() @ fastcall -arch=arm HalSweepDcache()
;@ stdcall -arch=x86_64 HalSystemVectorDispatchEntry()
@ stdcall HalTranslateBusAddress(long long long long ptr ptr) @ stdcall HalTranslateBusAddress(long long long long ptr ptr)
@ stdcall IoFlushAdapterBuffers(ptr ptr ptr ptr long long) @ stdcall IoFlushAdapterBuffers(ptr ptr ptr ptr long long)
@ stdcall IoFreeAdapterChannel(ptr) @ stdcall IoFreeAdapterChannel(ptr)
@ -98,3 +104,6 @@
@ stdcall -arch=i386,arm WRITE_PORT_ULONG(ptr long) @ stdcall -arch=i386,arm WRITE_PORT_ULONG(ptr long)
@ stdcall -arch=i386,arm WRITE_PORT_USHORT(ptr long) @ stdcall -arch=i386,arm WRITE_PORT_USHORT(ptr long)
@ stdcall -arch=x86_64 HalInitializeBios(long ptr) @ stdcall -arch=x86_64 HalInitializeBios(long ptr)
;@ stdcall -arch=x86_64 x86BiosExecuteInterrupt()
;@ stdcall -arch=x86_64 x86BiosInitializeBiosEx()
;@ stdcall -arch=x86_64 x86BiosTranslateAddress()

View file

@ -13,6 +13,7 @@ list(APPEND HAL_GENERIC_SOURCE
generic/display.c generic/display.c
generic/dma.c generic/dma.c
generic/drive.c generic/drive.c
generic/halinit.c
generic/memory.c generic/memory.c
generic/misc.c generic/misc.c
generic/reboot.c generic/reboot.c
@ -56,8 +57,6 @@ target_link_libraries(lib_hal_acpi lib_hal_generic)
list(APPEND HAL_UP_SOURCE list(APPEND HAL_UP_SOURCE
generic/spinlock.c generic/spinlock.c
generic/halinit.c
up/halinit_up.c
up/processor.c) up/processor.c)
list(APPEND HAL_PIC_SOURCE list(APPEND HAL_PIC_SOURCE
@ -65,12 +64,14 @@ list(APPEND HAL_PIC_SOURCE
generic/timer.c generic/timer.c
generic/systimer.S generic/systimer.S
generic/trap.S generic/trap.S
up/halinit_up.c
up/pic.c) up/pic.c)
list(APPEND HAL_APIC_SOURCE list(APPEND HAL_APIC_SOURCE
apic/apic.c apic/apic.c
apic/apictimer.c apic/apictimer.c
apic/apictrap.S apic/apictrap.S
apic/halinit_apic.c
apic/rtctimer.c apic/rtctimer.c
apic/tsc.c apic/tsc.c
apic/tsccal.S) apic/tsccal.S)
@ -98,7 +99,7 @@ if(ARCH MATCHES i386)
generic/sysinfo.c generic/sysinfo.c
generic/timer.c generic/timer.c
generic/usage.c generic/usage.c
up/halinit_up.c up/halinit_mini.c
up/pic.c up/pic.c
up/processor.c) up/processor.c)
@ -157,7 +158,6 @@ elseif(ARCH MATCHES amd64)
${HAL_ACPI_SOURCE} ${HAL_ACPI_SOURCE}
${HAL_APIC_SOURCE} ${HAL_APIC_SOURCE}
generic/spinlock.c generic/spinlock.c
generic/halinit.c
amd64/x86bios.c amd64/x86bios.c
amd64/halinit.c amd64/halinit.c
amd64/processor.c amd64/processor.c

View file

@ -0,0 +1,53 @@
/* $Id: halinit_up.c 53529 2011-09-02 14:45:19Z tkreuzer $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* FILE: ntoskrnl/hal/x86/halinit.c
* PURPOSE: Initalize the x86 hal
* PROGRAMMER: David Welch (welch@cwcom.net)
* UPDATE HISTORY:
* 11/06/98: Created
*/
/* INCLUDES *****************************************************************/
#include <hal.h>
#define NDEBUG
#include <debug.h>
VOID
NTAPI
ApicInitializeLocalApic(ULONG Cpu);
/* FUNCTIONS ***************************************************************/
VOID
NTAPI
HalpInitProcessor(
IN ULONG ProcessorNumber,
IN PLOADER_PARAMETER_BLOCK LoaderBlock)
{
DPRINT1("ApicInitializeProcessor(%ld)\n", ProcessorNumber);
/* Initialize the local APIC for this cpu */
ApicInitializeLocalApic(ProcessorNumber);
/* Initialize the timer */
//ApicInitializeTimer(ProcessorNumber);
}
VOID
HalpInitPhase0(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
{
}
VOID
HalpInitPhase1(VOID)
{
/* Initialize DMA. NT does this in Phase 0 */
HalpInitDma();
}
/* EOF */

View file

@ -41,6 +41,27 @@ HalpGetParameters(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
/* FUNCTIONS *****************************************************************/ /* FUNCTIONS *****************************************************************/
VOID
NTAPI
HalInitializeProcessor(
IN ULONG ProcessorNumber,
IN PLOADER_PARAMETER_BLOCK LoaderBlock)
{
/* Hal specific initialization for this cpu */
HalpInitProcessor(ProcessorNumber, LoaderBlock);
/* Set default stall count */
KeGetPcr()->StallScaleFactor = INITIAL_STALL_COUNT;
/* Update the interrupt affinity and processor mask */
InterlockedBitTestAndSet((PLONG)&HalpActiveProcessors, ProcessorNumber);
InterlockedBitTestAndSet((PLONG)&HalpDefaultInterruptAffinity,
ProcessorNumber);
/* Register routines for KDCOM */
HalpRegisterKdSupportFunctions();
}
/* /*
* @implemented * @implemented
*/ */
@ -61,48 +82,25 @@ HalInitSystem(IN ULONG BootPhase,
/* Get command-line parameters */ /* Get command-line parameters */
HalpGetParameters(LoaderBlock); HalpGetParameters(LoaderBlock);
/* Checked HAL requires checked kernel */ /* Check for PRCB version mismatch */
#if DBG
if (!(Prcb->BuildType & PRCB_BUILD_DEBUG))
{
/* No match, bugcheck */
KeBugCheckEx(MISMATCHED_HAL, 2, Prcb->BuildType, 1, 0);
}
#else
/* Release build requires release HAL */
if (Prcb->BuildType & PRCB_BUILD_DEBUG)
{
/* No match, bugcheck */
KeBugCheckEx(MISMATCHED_HAL, 2, Prcb->BuildType, 0, 0);
}
#endif
#ifdef CONFIG_SMP
/* SMP HAL requires SMP kernel */
if (Prcb->BuildType & PRCB_BUILD_UNIPROCESSOR)
{
/* No match, bugcheck */
KeBugCheckEx(MISMATCHED_HAL, 2, Prcb->BuildType, 0, 0);
}
#endif
/* Validate the PRCB */
if (Prcb->MajorVersion != PRCB_MAJOR_VERSION) if (Prcb->MajorVersion != PRCB_MAJOR_VERSION)
{ {
/* Validation failed, bugcheck */ /* No match, bugcheck */
KeBugCheckEx(MISMATCHED_HAL, 1, Prcb->MajorVersion, 1, 0); KeBugCheckEx(MISMATCHED_HAL, 1, Prcb->MajorVersion, PRCB_MAJOR_VERSION, 0);
}
/* Checked/free HAL requires checked/free kernel */
if (Prcb->BuildType != HAL_BUILD_TYPE)
{
/* No match, bugcheck */
KeBugCheckEx(MISMATCHED_HAL, 2, Prcb->BuildType, HAL_BUILD_TYPE, 0);
} }
#ifndef _MINIHAL_
/* Initialize ACPI */ /* Initialize ACPI */
HalpSetupAcpiPhase0(LoaderBlock); HalpSetupAcpiPhase0(LoaderBlock);
/* Initialize the PICs */ /* Initialize the PICs */
HalpInitializePICs(TRUE); HalpInitializePICs(TRUE);
#endif
/* Force initial PIC state */
KfRaiseIrql(KeGetCurrentIrql());
/* Initialize CMOS lock */ /* Initialize CMOS lock */
KeInitializeSpinLock(&HalpSystemHardwareLock); KeInitializeSpinLock(&HalpSystemHardwareLock);
@ -114,17 +112,10 @@ HalInitSystem(IN ULONG BootPhase,
HalQuerySystemInformation = HaliQuerySystemInformation; HalQuerySystemInformation = HaliQuerySystemInformation;
HalSetSystemInformation = HaliSetSystemInformation; HalSetSystemInformation = HaliSetSystemInformation;
HalInitPnpDriver = HaliInitPnpDriver; HalInitPnpDriver = HaliInitPnpDriver;
#ifndef _MINIHAL_
HalGetDmaAdapter = HalpGetDmaAdapter; HalGetDmaAdapter = HalpGetDmaAdapter;
#else
HalGetDmaAdapter = NULL;
#endif
HalGetInterruptTranslator = NULL; // FIXME: TODO HalGetInterruptTranslator = NULL; // FIXME: TODO
#ifndef _MINIHAL_
HalResetDisplay = HalpBiosDisplayReset; HalResetDisplay = HalpBiosDisplayReset;
#else
HalResetDisplay = NULL;
#endif
HalHaltSystem = HaliHaltSystem; HalHaltSystem = HaliHaltSystem;
/* Register IRQ 2 */ /* Register IRQ 2 */
@ -140,10 +131,8 @@ HalInitSystem(IN ULONG BootPhase,
/* Setup busy waiting */ /* Setup busy waiting */
HalpCalibrateStallExecution(); HalpCalibrateStallExecution();
#ifndef _MINIHAL_
/* Initialize the clock */ /* Initialize the clock */
HalpInitializeClock(); HalpInitializeClock();
#endif
/* /*
* We could be rebooting with a pending profile interrupt, * We could be rebooting with a pending profile interrupt,

View file

@ -36,7 +36,7 @@
<file>bussupp.c</file> <file>bussupp.c</file>
</directory> </directory>
<directory name="up"> <directory name="up">
<file>halinit_up.c</file> <file>halinit_mini.c</file>
<file>pic.c</file> <file>pic.c</file>
<file>processor.c</file> <file>processor.c</file>
</directory> </directory>

View file

@ -21,6 +21,12 @@
#define REGISTERCALL __attribute__((regparm(3))) #define REGISTERCALL __attribute__((regparm(3)))
#endif #endif
#ifdef CONFIG_SMP
#define HAL_BUILD_TYPE (DBG ? PRCB_BUILD_DEBUG : 0)
#else
#define HAL_BUILD_TYPE ((DBG ? PRCB_BUILD_DEBUG : 0) | PRCB_BUILD_UNIPROCESSOR)
#endif
typedef struct _HAL_BIOS_FRAME typedef struct _HAL_BIOS_FRAME
{ {
ULONG SegSs; ULONG SegSs;
@ -836,8 +842,18 @@ HalpDebugPciDumpBus(
IN PPCI_COMMON_CONFIG PciData IN PPCI_COMMON_CONFIG PciData
); );
VOID
NTAPI
HalpInitProcessor(
IN ULONG ProcessorNumber,
IN PLOADER_PARAMETER_BLOCK LoaderBlock
);
#ifdef _M_AMD64 #ifdef _M_AMD64
#define KfLowerIrql KeLowerIrql #define KfLowerIrql KeLowerIrql
#define KiEnterInterruptTrap(TrapFrame) /* We do all neccessary in asm code */
#define KiEoiHelper() return
#define HalBeginSystemInterrupt(Irql, Vector, OldIrql) TRUE
#ifndef CONFIG_SMP #ifndef CONFIG_SMP
/* On UP builds, spinlocks don't exist at IRQL >= DISPATCH */ /* On UP builds, spinlocks don't exist at IRQL >= DISPATCH */
#define KiAcquireSpinLock(SpinLock) #define KiAcquireSpinLock(SpinLock)

View file

@ -0,0 +1,75 @@
/* $Id: halinit_up.c 53529 2011-09-02 14:45:19Z tkreuzer $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* FILE: ntoskrnl/hal/x86/halinit.c
* PURPOSE: Initalize the x86 hal
* PROGRAMMER: David Welch (welch@cwcom.net)
* UPDATE HISTORY:
* 11/06/98: Created
*/
/* INCLUDES *****************************************************************/
#include <hal.h>
#define NDEBUG
#include <debug.h>
/* FUNCTIONS ***************************************************************/
VOID
NTAPI
HalpInitProcessor(
IN ULONG ProcessorNumber,
IN PLOADER_PARAMETER_BLOCK LoaderBlock)
{
}
VOID
HalpInitPhase0(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
{
}
VOID
HalpInitPhase1(VOID)
{
}
NTSTATUS
NTAPI
HalpSetupAcpiPhase0(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
{
return STATUS_SUCCESS;
}
VOID
NTAPI
HalpInitializePICs(IN BOOLEAN EnableInterrupts)
{
}
PDMA_ADAPTER
NTAPI
HalpGetDmaAdapter(
IN PVOID Context,
IN PDEVICE_DESCRIPTION DeviceDescription,
OUT PULONG NumberOfMapRegisters)
{
return NULL;
}
BOOLEAN
NTAPI
HalpBiosDisplayReset(VOID)
{
return FALSE;
}
VOID
NTAPI
INIT_FUNCTION
HalpInitializeClock(VOID)
{
}
/* EOF */

View file

@ -17,6 +17,16 @@
/* FUNCTIONS ***************************************************************/ /* FUNCTIONS ***************************************************************/
VOID
NTAPI
HalpInitProcessor(
IN ULONG ProcessorNumber,
IN PLOADER_PARAMETER_BLOCK LoaderBlock)
{
/* Set default IDR */
KeGetPcr()->IDR = 0xFFFFFFFB;
}
VOID VOID
HalpInitPhase0(IN PLOADER_PARAMETER_BLOCK LoaderBlock) HalpInitPhase0(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
{ {
@ -26,7 +36,6 @@ HalpInitPhase0(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
VOID VOID
HalpInitPhase1(VOID) HalpInitPhase1(VOID)
{ {
#ifndef _MINIHAL_
/* Enable IRQ 0 */ /* Enable IRQ 0 */
HalpEnableInterruptHandler(IDT_DEVICE, HalpEnableInterruptHandler(IDT_DEVICE,
0, 0,
@ -45,7 +54,6 @@ HalpInitPhase1(VOID)
/* Initialize DMA. NT does this in Phase 0 */ /* Initialize DMA. NT does this in Phase 0 */
HalpInitDma(); HalpInitDma();
#endif
} }
/* EOF */ /* EOF */

View file

@ -28,26 +28,6 @@ HaliHaltSystem(VOID)
/* FUNCTIONS *****************************************************************/ /* FUNCTIONS *****************************************************************/
/*
* @implemented
*/
VOID
NTAPI
HalInitializeProcessor(IN ULONG ProcessorNumber,
IN PLOADER_PARAMETER_BLOCK LoaderBlock)
{
/* Set default IDR and stall count */
KeGetPcr()->IDR = 0xFFFFFFFB;
KeGetPcr()->StallScaleFactor = INITIAL_STALL_COUNT;
/* Update the interrupt affinity and processor mask */
InterlockedBitTestAndSet((PLONG)&HalpActiveProcessors, ProcessorNumber);
InterlockedBitTestAndSet((PLONG)&HalpDefaultInterruptAffinity,
ProcessorNumber);
/* Register routines for KDCOM */
HalpRegisterKdSupportFunctions();
}
/* /*
* @implemented * @implemented