2005-06-18 14:30:09 +00:00
|
|
|
/*
|
2007-10-19 23:21:45 +00:00
|
|
|
*
|
2005-06-18 14:30:09 +00:00
|
|
|
*/
|
|
|
|
|
2010-02-26 11:43:19 +00:00
|
|
|
#pragma once
|
2005-06-18 14:30:09 +00:00
|
|
|
|
2011-09-07 18:25:43 +00:00
|
|
|
#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
|
|
|
|
|
2024-01-20 14:26:59 +00:00
|
|
|
/* Don't include this in freeloader */
|
|
|
|
#ifndef _BLDR_
|
|
|
|
extern KIRQL HalpIrqlSynchLevel;
|
|
|
|
|
|
|
|
#undef SYNCH_LEVEL
|
|
|
|
#define SYNCH_LEVEL HalpIrqlSynchLevel
|
|
|
|
#endif
|
|
|
|
|
2010-01-26 19:41:31 +00:00
|
|
|
typedef struct _HAL_BIOS_FRAME
|
|
|
|
{
|
|
|
|
ULONG SegSs;
|
|
|
|
ULONG Esp;
|
|
|
|
ULONG EFlags;
|
|
|
|
ULONG SegCs;
|
|
|
|
ULONG Eip;
|
|
|
|
PKTRAP_FRAME TrapFrame;
|
|
|
|
ULONG CsLimit;
|
|
|
|
ULONG CsBase;
|
|
|
|
ULONG CsFlags;
|
|
|
|
ULONG SsLimit;
|
|
|
|
ULONG SsBase;
|
|
|
|
ULONG SsFlags;
|
|
|
|
ULONG Prefix;
|
|
|
|
} HAL_BIOS_FRAME, *PHAL_BIOS_FRAME;
|
|
|
|
|
2010-01-28 20:45:45 +00:00
|
|
|
typedef
|
|
|
|
VOID
|
2015-09-15 10:35:49 +00:00
|
|
|
(__cdecl *PHAL_SW_INTERRUPT_HANDLER)(
|
2010-01-28 20:45:45 +00:00
|
|
|
VOID
|
|
|
|
);
|
|
|
|
|
|
|
|
typedef
|
|
|
|
VOID
|
2010-07-26 21:32:38 +00:00
|
|
|
(FASTCALL *PHAL_SW_INTERRUPT_HANDLER_2ND_ENTRY)(
|
2010-01-28 20:45:45 +00:00
|
|
|
IN PKTRAP_FRAME TrapFrame
|
|
|
|
);
|
|
|
|
|
2006-11-29 22:12:50 +00:00
|
|
|
#define HAL_APC_REQUEST 0
|
|
|
|
#define HAL_DPC_REQUEST 1
|
2005-06-18 14:30:09 +00:00
|
|
|
|
2017-11-06 18:40:21 +00:00
|
|
|
/* HAL profiling offsets in KeGetPcr()->HalReserved[] */
|
|
|
|
#define HAL_PROFILING_INTERVAL 0
|
|
|
|
#define HAL_PROFILING_MULTIPLIER 1
|
|
|
|
|
2009-10-29 19:58:41 +00:00
|
|
|
/* Usage flags */
|
|
|
|
#define IDT_REGISTERED 0x01
|
|
|
|
#define IDT_LATCHED 0x02
|
2010-04-01 20:46:55 +00:00
|
|
|
#define IDT_READ_ONLY 0x04
|
2009-10-29 19:58:41 +00:00
|
|
|
#define IDT_INTERNAL 0x11
|
|
|
|
#define IDT_DEVICE 0x21
|
|
|
|
|
2023-11-19 23:51:33 +00:00
|
|
|
#ifdef _M_AMD64
|
|
|
|
#define HALP_LOW_STUB_SIZE_IN_PAGES 5
|
|
|
|
#else
|
|
|
|
#define HALP_LOW_STUB_SIZE_IN_PAGES 3
|
|
|
|
#endif
|
|
|
|
|
2006-11-27 19:26:31 +00:00
|
|
|
/* Conversion functions */
|
|
|
|
#define BCD_INT(bcd) \
|
|
|
|
(((bcd & 0xF0) >> 4) * 10 + (bcd & 0x0F))
|
|
|
|
#define INT_BCD(int) \
|
|
|
|
(UCHAR)(((int / 10) << 4) + (int % 10))
|
2010-01-08 04:31:19 +00:00
|
|
|
|
2010-01-24 23:30:43 +00:00
|
|
|
typedef
|
|
|
|
BOOLEAN
|
2015-09-15 23:03:42 +00:00
|
|
|
(NTAPI *PHAL_DISMISS_INTERRUPT)(
|
2010-01-24 23:30:43 +00:00
|
|
|
IN KIRQL Irql,
|
|
|
|
IN ULONG Irq,
|
|
|
|
OUT PKIRQL OldIrql
|
|
|
|
);
|
|
|
|
|
|
|
|
BOOLEAN
|
2015-09-15 23:03:42 +00:00
|
|
|
NTAPI
|
2010-01-24 23:30:43 +00:00
|
|
|
HalpDismissIrqGeneric(
|
|
|
|
IN KIRQL Irql,
|
|
|
|
IN ULONG Irq,
|
|
|
|
OUT PKIRQL OldIrql
|
|
|
|
);
|
|
|
|
|
|
|
|
BOOLEAN
|
2015-09-15 23:03:42 +00:00
|
|
|
NTAPI
|
2010-01-24 23:30:43 +00:00
|
|
|
HalpDismissIrq15(
|
|
|
|
IN KIRQL Irql,
|
|
|
|
IN ULONG Irq,
|
|
|
|
OUT PKIRQL OldIrql
|
|
|
|
);
|
|
|
|
|
|
|
|
BOOLEAN
|
2015-09-15 23:03:42 +00:00
|
|
|
NTAPI
|
2010-01-24 23:30:43 +00:00
|
|
|
HalpDismissIrq13(
|
|
|
|
IN KIRQL Irql,
|
|
|
|
IN ULONG Irq,
|
|
|
|
OUT PKIRQL OldIrql
|
|
|
|
);
|
|
|
|
|
|
|
|
BOOLEAN
|
2015-09-15 23:03:42 +00:00
|
|
|
NTAPI
|
2010-01-24 23:30:43 +00:00
|
|
|
HalpDismissIrq07(
|
|
|
|
IN KIRQL Irql,
|
|
|
|
IN ULONG Irq,
|
|
|
|
OUT PKIRQL OldIrql
|
|
|
|
);
|
|
|
|
|
[HAL]: Rewrite IRQL handling. Alex's original code (lately translated to C) was a copy of the MicroChannel (MCA), Checked-Build HAL, an unexplained choice considering MCA is not supported or even available anymore. Windows, on machines with a PIC, uses a mechanism called Lazy IRQL, in which the PIC is only programmed "lazily", meaning that lowering and raising the IRQL does not actually change the interrupt mask. Therefore, lower priority interrupts will still come in at high IRQL. At this point, the HAL will detect this, only now mask the PICs, and lie that the lower interrupt was "spurious", while setting a pending bit. When the IRQL is lowered, the bit is detected, and a software/delayed "INT" is done with the correct IRQ vector number. More details are available in the typical resources.
[HAL]: Implement support for Level interrupts, which are used by certain EISA cards, and more particularly, all PCI hardware. Level interrupts were not previously handled correctly, being treated as edge/latched interrupts instead.
[NTOS/HAL]: Remove VDM Alert KPCR hack (which was buggy). Now the PKTRAP_FRAME is passed as a parameter to HalpEndSoftwareInterrupt/HalEndSystemInterrupt. This also removes the HalpNestedTrap ASM hack, since the call can now be done in C.
[PERF]: On real machines, writing the PIC mask is a relatively expensive I/O operation, and IRQL lower/raise can happen hundreds of times a second. Lazy IRQL provides an important optimization.
[PERF]: Correctly handling level interrupts as level interrupts allows for faster, and more efficient, IRQ handling.
svn path=/trunk/; revision=45320
2010-01-29 21:10:33 +00:00
|
|
|
BOOLEAN
|
2015-09-15 23:03:42 +00:00
|
|
|
NTAPI
|
[HAL]: Rewrite IRQL handling. Alex's original code (lately translated to C) was a copy of the MicroChannel (MCA), Checked-Build HAL, an unexplained choice considering MCA is not supported or even available anymore. Windows, on machines with a PIC, uses a mechanism called Lazy IRQL, in which the PIC is only programmed "lazily", meaning that lowering and raising the IRQL does not actually change the interrupt mask. Therefore, lower priority interrupts will still come in at high IRQL. At this point, the HAL will detect this, only now mask the PICs, and lie that the lower interrupt was "spurious", while setting a pending bit. When the IRQL is lowered, the bit is detected, and a software/delayed "INT" is done with the correct IRQ vector number. More details are available in the typical resources.
[HAL]: Implement support for Level interrupts, which are used by certain EISA cards, and more particularly, all PCI hardware. Level interrupts were not previously handled correctly, being treated as edge/latched interrupts instead.
[NTOS/HAL]: Remove VDM Alert KPCR hack (which was buggy). Now the PKTRAP_FRAME is passed as a parameter to HalpEndSoftwareInterrupt/HalEndSystemInterrupt. This also removes the HalpNestedTrap ASM hack, since the call can now be done in C.
[PERF]: On real machines, writing the PIC mask is a relatively expensive I/O operation, and IRQL lower/raise can happen hundreds of times a second. Lazy IRQL provides an important optimization.
[PERF]: Correctly handling level interrupts as level interrupts allows for faster, and more efficient, IRQ handling.
svn path=/trunk/; revision=45320
2010-01-29 21:10:33 +00:00
|
|
|
HalpDismissIrqLevel(
|
|
|
|
IN KIRQL Irql,
|
|
|
|
IN ULONG Irq,
|
|
|
|
OUT PKIRQL OldIrql
|
|
|
|
);
|
|
|
|
|
|
|
|
BOOLEAN
|
2015-09-15 23:03:42 +00:00
|
|
|
NTAPI
|
[HAL]: Rewrite IRQL handling. Alex's original code (lately translated to C) was a copy of the MicroChannel (MCA), Checked-Build HAL, an unexplained choice considering MCA is not supported or even available anymore. Windows, on machines with a PIC, uses a mechanism called Lazy IRQL, in which the PIC is only programmed "lazily", meaning that lowering and raising the IRQL does not actually change the interrupt mask. Therefore, lower priority interrupts will still come in at high IRQL. At this point, the HAL will detect this, only now mask the PICs, and lie that the lower interrupt was "spurious", while setting a pending bit. When the IRQL is lowered, the bit is detected, and a software/delayed "INT" is done with the correct IRQ vector number. More details are available in the typical resources.
[HAL]: Implement support for Level interrupts, which are used by certain EISA cards, and more particularly, all PCI hardware. Level interrupts were not previously handled correctly, being treated as edge/latched interrupts instead.
[NTOS/HAL]: Remove VDM Alert KPCR hack (which was buggy). Now the PKTRAP_FRAME is passed as a parameter to HalpEndSoftwareInterrupt/HalEndSystemInterrupt. This also removes the HalpNestedTrap ASM hack, since the call can now be done in C.
[PERF]: On real machines, writing the PIC mask is a relatively expensive I/O operation, and IRQL lower/raise can happen hundreds of times a second. Lazy IRQL provides an important optimization.
[PERF]: Correctly handling level interrupts as level interrupts allows for faster, and more efficient, IRQ handling.
svn path=/trunk/; revision=45320
2010-01-29 21:10:33 +00:00
|
|
|
HalpDismissIrq15Level(
|
|
|
|
IN KIRQL Irql,
|
|
|
|
IN ULONG Irq,
|
|
|
|
OUT PKIRQL OldIrql
|
|
|
|
);
|
|
|
|
|
|
|
|
BOOLEAN
|
2015-09-15 23:03:42 +00:00
|
|
|
NTAPI
|
[HAL]: Rewrite IRQL handling. Alex's original code (lately translated to C) was a copy of the MicroChannel (MCA), Checked-Build HAL, an unexplained choice considering MCA is not supported or even available anymore. Windows, on machines with a PIC, uses a mechanism called Lazy IRQL, in which the PIC is only programmed "lazily", meaning that lowering and raising the IRQL does not actually change the interrupt mask. Therefore, lower priority interrupts will still come in at high IRQL. At this point, the HAL will detect this, only now mask the PICs, and lie that the lower interrupt was "spurious", while setting a pending bit. When the IRQL is lowered, the bit is detected, and a software/delayed "INT" is done with the correct IRQ vector number. More details are available in the typical resources.
[HAL]: Implement support for Level interrupts, which are used by certain EISA cards, and more particularly, all PCI hardware. Level interrupts were not previously handled correctly, being treated as edge/latched interrupts instead.
[NTOS/HAL]: Remove VDM Alert KPCR hack (which was buggy). Now the PKTRAP_FRAME is passed as a parameter to HalpEndSoftwareInterrupt/HalEndSystemInterrupt. This also removes the HalpNestedTrap ASM hack, since the call can now be done in C.
[PERF]: On real machines, writing the PIC mask is a relatively expensive I/O operation, and IRQL lower/raise can happen hundreds of times a second. Lazy IRQL provides an important optimization.
[PERF]: Correctly handling level interrupts as level interrupts allows for faster, and more efficient, IRQ handling.
svn path=/trunk/; revision=45320
2010-01-29 21:10:33 +00:00
|
|
|
HalpDismissIrq13Level(
|
|
|
|
IN KIRQL Irql,
|
|
|
|
IN ULONG Irq,
|
|
|
|
OUT PKIRQL OldIrql
|
|
|
|
);
|
|
|
|
|
|
|
|
BOOLEAN
|
2015-09-15 23:03:42 +00:00
|
|
|
NTAPI
|
[HAL]: Rewrite IRQL handling. Alex's original code (lately translated to C) was a copy of the MicroChannel (MCA), Checked-Build HAL, an unexplained choice considering MCA is not supported or even available anymore. Windows, on machines with a PIC, uses a mechanism called Lazy IRQL, in which the PIC is only programmed "lazily", meaning that lowering and raising the IRQL does not actually change the interrupt mask. Therefore, lower priority interrupts will still come in at high IRQL. At this point, the HAL will detect this, only now mask the PICs, and lie that the lower interrupt was "spurious", while setting a pending bit. When the IRQL is lowered, the bit is detected, and a software/delayed "INT" is done with the correct IRQ vector number. More details are available in the typical resources.
[HAL]: Implement support for Level interrupts, which are used by certain EISA cards, and more particularly, all PCI hardware. Level interrupts were not previously handled correctly, being treated as edge/latched interrupts instead.
[NTOS/HAL]: Remove VDM Alert KPCR hack (which was buggy). Now the PKTRAP_FRAME is passed as a parameter to HalpEndSoftwareInterrupt/HalEndSystemInterrupt. This also removes the HalpNestedTrap ASM hack, since the call can now be done in C.
[PERF]: On real machines, writing the PIC mask is a relatively expensive I/O operation, and IRQL lower/raise can happen hundreds of times a second. Lazy IRQL provides an important optimization.
[PERF]: Correctly handling level interrupts as level interrupts allows for faster, and more efficient, IRQ handling.
svn path=/trunk/; revision=45320
2010-01-29 21:10:33 +00:00
|
|
|
HalpDismissIrq07Level(
|
|
|
|
IN KIRQL Irql,
|
|
|
|
IN ULONG Irq,
|
|
|
|
OUT PKIRQL OldIrql
|
|
|
|
);
|
|
|
|
|
|
|
|
VOID
|
2015-09-15 10:35:49 +00:00
|
|
|
__cdecl
|
[HAL]: Rewrite IRQL handling. Alex's original code (lately translated to C) was a copy of the MicroChannel (MCA), Checked-Build HAL, an unexplained choice considering MCA is not supported or even available anymore. Windows, on machines with a PIC, uses a mechanism called Lazy IRQL, in which the PIC is only programmed "lazily", meaning that lowering and raising the IRQL does not actually change the interrupt mask. Therefore, lower priority interrupts will still come in at high IRQL. At this point, the HAL will detect this, only now mask the PICs, and lie that the lower interrupt was "spurious", while setting a pending bit. When the IRQL is lowered, the bit is detected, and a software/delayed "INT" is done with the correct IRQ vector number. More details are available in the typical resources.
[HAL]: Implement support for Level interrupts, which are used by certain EISA cards, and more particularly, all PCI hardware. Level interrupts were not previously handled correctly, being treated as edge/latched interrupts instead.
[NTOS/HAL]: Remove VDM Alert KPCR hack (which was buggy). Now the PKTRAP_FRAME is passed as a parameter to HalpEndSoftwareInterrupt/HalEndSystemInterrupt. This also removes the HalpNestedTrap ASM hack, since the call can now be done in C.
[PERF]: On real machines, writing the PIC mask is a relatively expensive I/O operation, and IRQL lower/raise can happen hundreds of times a second. Lazy IRQL provides an important optimization.
[PERF]: Correctly handling level interrupts as level interrupts allows for faster, and more efficient, IRQ handling.
svn path=/trunk/; revision=45320
2010-01-29 21:10:33 +00:00
|
|
|
HalpHardwareInterruptLevel(
|
|
|
|
VOID
|
|
|
|
);
|
|
|
|
|
2010-06-07 15:34:35 +00:00
|
|
|
//
|
|
|
|
// Hack Flags
|
|
|
|
//
|
|
|
|
#define HALP_REVISION_FROM_HACK_FLAGS(x) ((x) >> 24)
|
|
|
|
#define HALP_REVISION_HACK_FLAGS(x) ((x) >> 12)
|
|
|
|
#define HALP_HACK_FLAGS(x) ((x) & 0xFFF)
|
|
|
|
|
2010-06-07 15:09:44 +00:00
|
|
|
//
|
|
|
|
// Feature flags
|
|
|
|
//
|
|
|
|
#define HALP_CARD_FEATURE_FULL_DECODE 0x0001
|
|
|
|
|
|
|
|
//
|
|
|
|
// Match Flags
|
|
|
|
//
|
|
|
|
#define HALP_CHECK_CARD_REVISION_ID 0x10000
|
|
|
|
#define HALP_CHECK_CARD_SUBVENDOR_ID 0x20000
|
|
|
|
#define HALP_CHECK_CARD_SUBSYSTEM_ID 0x40000
|
|
|
|
|
2010-01-01 15:09:14 +00:00
|
|
|
//
|
|
|
|
// Mm PTE/PDE to Hal PTE/PDE
|
|
|
|
//
|
|
|
|
#define HalAddressToPde(x) (PHARDWARE_PTE)MiAddressToPde(x)
|
|
|
|
#define HalAddressToPte(x) (PHARDWARE_PTE)MiAddressToPte(x)
|
2011-06-24 23:04:13 +00:00
|
|
|
|
2009-10-29 19:58:41 +00:00
|
|
|
typedef struct _IDTUsageFlags
|
|
|
|
{
|
|
|
|
UCHAR Flags;
|
|
|
|
} IDTUsageFlags;
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
KIRQL Irql;
|
|
|
|
UCHAR BusReleativeVector;
|
|
|
|
} IDTUsage;
|
|
|
|
|
|
|
|
typedef struct _HalAddressUsage
|
|
|
|
{
|
|
|
|
struct _HalAddressUsage *Next;
|
|
|
|
CM_RESOURCE_TYPE Type;
|
|
|
|
UCHAR Flags;
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
ULONG Start;
|
|
|
|
ULONG Length;
|
|
|
|
} Element[];
|
|
|
|
} ADDRESS_USAGE, *PADDRESS_USAGE;
|
|
|
|
|
2005-06-18 14:30:09 +00:00
|
|
|
/* adapter.c */
|
2008-11-29 23:16:39 +00:00
|
|
|
PADAPTER_OBJECT NTAPI HalpAllocateAdapterEx(ULONG NumberOfMapRegisters,BOOLEAN IsMaster, BOOLEAN Dma32BitAddresses);
|
2007-10-19 23:21:45 +00:00
|
|
|
|
2009-10-29 19:58:41 +00:00
|
|
|
/* sysinfo.c */
|
2021-05-11 15:13:14 +00:00
|
|
|
CODE_SEG("INIT")
|
2009-10-29 19:58:41 +00:00
|
|
|
VOID
|
|
|
|
NTAPI
|
|
|
|
HalpRegisterVector(IN UCHAR Flags,
|
|
|
|
IN ULONG BusVector,
|
|
|
|
IN ULONG SystemVector,
|
|
|
|
IN KIRQL Irql);
|
|
|
|
|
2021-05-11 15:13:14 +00:00
|
|
|
CODE_SEG("INIT")
|
2009-10-29 19:58:41 +00:00
|
|
|
VOID
|
|
|
|
NTAPI
|
|
|
|
HalpEnableInterruptHandler(IN UCHAR Flags,
|
|
|
|
IN ULONG BusVector,
|
|
|
|
IN ULONG SystemVector,
|
|
|
|
IN KIRQL Irql,
|
|
|
|
IN PVOID Handler,
|
|
|
|
IN KINTERRUPT_MODE Mode);
|
|
|
|
|
2010-01-21 12:51:13 +00:00
|
|
|
/* pic.c */
|
|
|
|
VOID NTAPI HalpInitializePICs(IN BOOLEAN EnableInterrupts);
|
2015-09-15 10:35:49 +00:00
|
|
|
VOID __cdecl HalpApcInterrupt(VOID);
|
|
|
|
VOID __cdecl HalpDispatchInterrupt(VOID);
|
2018-02-18 11:50:54 +00:00
|
|
|
PHAL_SW_INTERRUPT_HANDLER __cdecl HalpDispatchInterrupt2(VOID);
|
2010-07-26 21:32:38 +00:00
|
|
|
DECLSPEC_NORETURN VOID FASTCALL HalpApcInterrupt2ndEntry(IN PKTRAP_FRAME TrapFrame);
|
|
|
|
DECLSPEC_NORETURN VOID FASTCALL HalpDispatchInterrupt2ndEntry(IN PKTRAP_FRAME TrapFrame);
|
2005-06-18 14:30:09 +00:00
|
|
|
|
2015-08-29 16:45:00 +00:00
|
|
|
/* profil.c */
|
|
|
|
extern BOOLEAN HalpProfilingStopped;
|
|
|
|
|
2010-01-26 21:41:05 +00:00
|
|
|
/* timer.c */
|
2021-05-11 15:13:14 +00:00
|
|
|
CODE_SEG("INIT") VOID NTAPI HalpInitializeClock(VOID);
|
2015-09-15 10:35:49 +00:00
|
|
|
VOID __cdecl HalpClockInterrupt(VOID);
|
2024-02-24 10:05:12 +00:00
|
|
|
VOID __cdecl HalpClockIpi(VOID);
|
2015-09-15 10:35:49 +00:00
|
|
|
VOID __cdecl HalpProfileInterrupt(VOID);
|
2006-11-27 19:26:31 +00:00
|
|
|
|
2020-06-02 23:14:16 +00:00
|
|
|
typedef struct _HALP_ROLLOVER
|
|
|
|
{
|
|
|
|
ULONG RollOver;
|
|
|
|
ULONG Increment;
|
|
|
|
} HALP_ROLLOVER, *PHALP_ROLLOVER;
|
|
|
|
|
2009-10-10 18:22:56 +00:00
|
|
|
VOID
|
|
|
|
NTAPI
|
|
|
|
HalpCalibrateStallExecution(VOID);
|
|
|
|
|
2005-06-18 14:30:09 +00:00
|
|
|
/* pci.c */
|
|
|
|
VOID HalpInitPciBus (VOID);
|
|
|
|
|
|
|
|
/* dma.c */
|
2021-05-11 15:13:14 +00:00
|
|
|
CODE_SEG("INIT") VOID HalpInitDma (VOID);
|
2005-06-18 14:30:09 +00:00
|
|
|
|
|
|
|
/* Non-generic initialization */
|
2006-09-30 03:33:50 +00:00
|
|
|
VOID HalpInitPhase0 (PLOADER_PARAMETER_BLOCK LoaderBlock);
|
2006-08-25 00:46:41 +00:00
|
|
|
VOID HalpInitPhase1(VOID);
|
2005-06-18 14:30:09 +00:00
|
|
|
|
2010-01-01 16:37:34 +00:00
|
|
|
VOID
|
|
|
|
NTAPI
|
|
|
|
HalpFlushTLB(VOID);
|
|
|
|
|
2006-11-29 22:12:50 +00:00
|
|
|
//
|
|
|
|
// KD Support
|
|
|
|
//
|
|
|
|
VOID
|
|
|
|
NTAPI
|
|
|
|
HalpCheckPowerButton(
|
|
|
|
VOID
|
|
|
|
);
|
|
|
|
|
2021-05-11 15:13:14 +00:00
|
|
|
CODE_SEG("INIT")
|
2006-11-29 22:12:50 +00:00
|
|
|
VOID
|
|
|
|
NTAPI
|
|
|
|
HalpRegisterKdSupportFunctions(
|
|
|
|
VOID
|
|
|
|
);
|
|
|
|
|
2021-05-11 15:13:14 +00:00
|
|
|
CODE_SEG("INIT")
|
2006-11-29 22:12:50 +00:00
|
|
|
NTSTATUS
|
|
|
|
NTAPI
|
|
|
|
HalpSetupPciDeviceForDebugging(
|
|
|
|
IN PVOID LoaderBlock,
|
|
|
|
IN OUT PDEBUG_DEVICE_DESCRIPTOR PciDevice
|
|
|
|
);
|
|
|
|
|
2021-05-11 15:13:14 +00:00
|
|
|
CODE_SEG("INIT")
|
2006-11-29 22:12:50 +00:00
|
|
|
NTSTATUS
|
|
|
|
NTAPI
|
|
|
|
HalpReleasePciDeviceForDebugging(
|
|
|
|
IN OUT PDEBUG_DEVICE_DESCRIPTOR PciDevice
|
|
|
|
);
|
|
|
|
|
|
|
|
//
|
|
|
|
// Memory routines
|
|
|
|
//
|
2017-12-17 16:37:43 +00:00
|
|
|
ULONG64
|
2011-09-15 10:46:02 +00:00
|
|
|
NTAPI
|
|
|
|
HalpAllocPhysicalMemory(
|
|
|
|
IN PLOADER_PARAMETER_BLOCK LoaderBlock,
|
2017-12-17 16:37:43 +00:00
|
|
|
IN ULONG64 MaxAddress,
|
2011-09-15 10:46:02 +00:00
|
|
|
IN PFN_NUMBER PageCount,
|
|
|
|
IN BOOLEAN Aligned
|
|
|
|
);
|
|
|
|
|
2018-02-04 15:59:21 +00:00
|
|
|
PVOID
|
|
|
|
NTAPI
|
|
|
|
HalpMapPhysicalMemory64Vista(
|
|
|
|
IN PHYSICAL_ADDRESS PhysicalAddress,
|
|
|
|
IN PFN_COUNT PageCount,
|
|
|
|
IN BOOLEAN FlushCurrentTLB
|
|
|
|
);
|
|
|
|
|
|
|
|
VOID
|
|
|
|
NTAPI
|
|
|
|
HalpUnmapVirtualAddressVista(
|
|
|
|
IN PVOID VirtualAddress,
|
|
|
|
IN PFN_COUNT NumberPages,
|
|
|
|
IN BOOLEAN FlushCurrentTLB
|
|
|
|
);
|
|
|
|
|
2006-11-29 22:12:50 +00:00
|
|
|
PVOID
|
|
|
|
NTAPI
|
|
|
|
HalpMapPhysicalMemory64(
|
|
|
|
IN PHYSICAL_ADDRESS PhysicalAddress,
|
2012-03-28 12:15:54 +00:00
|
|
|
IN PFN_COUNT PageCount
|
2006-11-29 22:12:50 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
VOID
|
|
|
|
NTAPI
|
|
|
|
HalpUnmapVirtualAddress(
|
|
|
|
IN PVOID VirtualAddress,
|
2012-03-28 12:15:54 +00:00
|
|
|
IN PFN_COUNT NumberPages
|
2006-11-29 22:12:50 +00:00
|
|
|
);
|
|
|
|
|
2005-06-18 14:30:09 +00:00
|
|
|
/* sysinfo.c */
|
2020-11-05 20:56:05 +00:00
|
|
|
NTSTATUS
|
|
|
|
NTAPI
|
|
|
|
HaliHandlePCIConfigSpaceAccess(
|
|
|
|
_In_ BOOLEAN IsRead,
|
|
|
|
_In_ ULONG Port,
|
|
|
|
_In_ ULONG Length,
|
|
|
|
_Inout_ PULONG Buffer
|
|
|
|
);
|
|
|
|
|
2006-11-27 19:26:31 +00:00
|
|
|
NTSTATUS
|
|
|
|
NTAPI
|
|
|
|
HaliQuerySystemInformation(
|
|
|
|
IN HAL_QUERY_INFORMATION_CLASS InformationClass,
|
|
|
|
IN ULONG BufferSize,
|
|
|
|
IN OUT PVOID Buffer,
|
|
|
|
OUT PULONG ReturnedLength
|
|
|
|
);
|
|
|
|
|
|
|
|
NTSTATUS
|
|
|
|
NTAPI
|
|
|
|
HaliSetSystemInformation(
|
|
|
|
IN HAL_SET_INFORMATION_CLASS InformationClass,
|
|
|
|
IN ULONG BufferSize,
|
|
|
|
IN OUT PVOID Buffer
|
|
|
|
);
|
2005-06-18 14:30:09 +00:00
|
|
|
|
2007-12-15 17:15:48 +00:00
|
|
|
//
|
|
|
|
// BIOS Routines
|
|
|
|
//
|
|
|
|
BOOLEAN
|
|
|
|
NTAPI
|
|
|
|
HalpBiosDisplayReset(
|
|
|
|
VOID
|
|
|
|
);
|
|
|
|
|
2010-02-26 00:07:22 +00:00
|
|
|
VOID
|
|
|
|
FASTCALL
|
|
|
|
HalpExitToV86(
|
|
|
|
PKTRAP_FRAME TrapFrame
|
|
|
|
);
|
|
|
|
|
|
|
|
VOID
|
2015-09-15 10:35:49 +00:00
|
|
|
__cdecl
|
2010-02-26 00:07:22 +00:00
|
|
|
HalpRealModeStart(
|
|
|
|
VOID
|
|
|
|
);
|
|
|
|
|
- Stub out DbgKdWriteVirtualMemoryApi, DbgKdReadPhysicalMemoryApi, DbgKdWritePhysicalMemoryApi, DbgKdWriteBreakPointExApi, DbgKdRestoreBreakPointExApi, DbgKdSearchMemoryApi and DbgKdFillMemoryApi cases more properly.
- Fail on physical memory write like we do for read too.
- Don't handle OldVlm1/2 as they appear to be deprecated and unhandled in Windows.
- Implement HalHaltSystem to halt execution in a portable way. Default to xHalHaltSystem, a simple infinite loop, if we get called before HAL has initialized. Use this in KiBugCheckDebugBreak and the system shutdown handler instead of x86/AMD64/ARM intrinsics.
- Don't try to halt the CPU if KeBugCheck has been called 3 times or more -- if this happens, something has gone very wrong, and we shouldn't try to do anything special. Just loop infinitely.
- Fix KiBugCheckDebugBreak -- it shouldn't halt execution when called for the first chance as bugcheck callbacks have not been invoked at this point (nor has the BSOD been displayed). Use SEH to protect against a crash instead of checking KdDebuggerNotPresent as the debugger, if it is present, *could* disconnect while the trap is being handled. Also, don't halt execution if the debugger handled the breakpoint, just break again.
- Don't call MmMapIoSpace from HalpReboot! The reboot might take place at elevated IRQL (as high as HIGH_LEVEL if called from KeBugCheck), and thus can't use any Mm support routines. Use a PTE from the reserved HAL region and map it ourselves instead as done in the BIOS call code.
- Acquire the display ownership in HalReturnToFirmware in case the caller hasn't done so (as done in the KD reboot routine, for example).
- Just include ntndk.h in hal.h instead of including 6 NDK headers (which turns into more than half of the NDK anyway since those headers include other NDK headers).
- Crashing and rebooting from KD now works properly.
svn path=/trunk/; revision=43380
2009-10-11 20:16:45 +00:00
|
|
|
//
|
|
|
|
// Processor Halt Routine
|
|
|
|
//
|
|
|
|
VOID
|
|
|
|
NTAPI
|
|
|
|
HaliHaltSystem(
|
|
|
|
VOID
|
|
|
|
);
|
|
|
|
|
2009-10-29 19:58:41 +00:00
|
|
|
//
|
2010-09-25 07:22:40 +00:00
|
|
|
// CMOS Routines
|
2009-10-29 19:58:41 +00:00
|
|
|
//
|
2021-05-11 15:13:14 +00:00
|
|
|
CODE_SEG("INIT")
|
2009-10-29 19:58:41 +00:00
|
|
|
VOID
|
|
|
|
NTAPI
|
|
|
|
HalpInitializeCmos(
|
|
|
|
VOID
|
|
|
|
);
|
|
|
|
|
2020-07-25 13:31:02 +00:00
|
|
|
_Requires_lock_held_(HalpSystemHardwareLock)
|
2010-09-25 07:22:40 +00:00
|
|
|
UCHAR
|
|
|
|
NTAPI
|
|
|
|
HalpReadCmos(
|
|
|
|
IN UCHAR Reg
|
|
|
|
);
|
|
|
|
|
2020-07-25 13:31:02 +00:00
|
|
|
_Requires_lock_held_(HalpSystemHardwareLock)
|
2010-09-25 07:22:40 +00:00
|
|
|
VOID
|
|
|
|
NTAPI
|
|
|
|
HalpWriteCmos(
|
|
|
|
IN UCHAR Reg,
|
|
|
|
IN UCHAR Value
|
|
|
|
);
|
|
|
|
|
2009-10-29 19:58:41 +00:00
|
|
|
//
|
|
|
|
// Spinlock for protecting CMOS access
|
|
|
|
//
|
2020-07-25 13:31:02 +00:00
|
|
|
_Acquires_lock_(HalpSystemHardwareLock)
|
2009-10-29 19:58:41 +00:00
|
|
|
VOID
|
|
|
|
NTAPI
|
2011-09-07 10:14:48 +00:00
|
|
|
HalpAcquireCmosSpinLock(
|
2009-10-29 19:58:41 +00:00
|
|
|
VOID
|
|
|
|
);
|
|
|
|
|
2020-07-25 13:31:02 +00:00
|
|
|
_Releases_lock_(HalpSystemHardwareLock)
|
2009-10-29 19:58:41 +00:00
|
|
|
VOID
|
|
|
|
NTAPI
|
|
|
|
HalpReleaseCmosSpinLock(
|
|
|
|
VOID
|
|
|
|
);
|
|
|
|
|
2017-12-17 08:51:37 +00:00
|
|
|
VOID
|
|
|
|
NTAPI
|
|
|
|
HalpInitializeLegacyPICs(
|
|
|
|
VOID
|
|
|
|
);
|
|
|
|
|
2011-06-24 23:04:13 +00:00
|
|
|
NTSTATUS
|
2010-03-31 20:58:42 +00:00
|
|
|
NTAPI
|
|
|
|
HalpOpenRegistryKey(
|
|
|
|
IN PHANDLE KeyHandle,
|
|
|
|
IN HANDLE RootKey,
|
|
|
|
IN PUNICODE_STRING KeyName,
|
2011-06-24 23:04:13 +00:00
|
|
|
IN ACCESS_MASK DesiredAccess,
|
2010-03-31 20:58:42 +00:00
|
|
|
IN BOOLEAN Create
|
|
|
|
);
|
|
|
|
|
2021-05-11 15:13:14 +00:00
|
|
|
CODE_SEG("INIT")
|
2010-04-01 19:42:07 +00:00
|
|
|
VOID
|
|
|
|
NTAPI
|
|
|
|
HalpGetNMICrashFlag(
|
|
|
|
VOID
|
|
|
|
);
|
|
|
|
|
2021-05-11 15:13:14 +00:00
|
|
|
CODE_SEG("INIT")
|
2010-04-01 20:46:55 +00:00
|
|
|
BOOLEAN
|
|
|
|
NTAPI
|
|
|
|
HalpGetDebugPortTable(
|
|
|
|
VOID
|
|
|
|
);
|
|
|
|
|
2021-05-11 15:13:14 +00:00
|
|
|
CODE_SEG("INIT")
|
2010-04-01 20:46:55 +00:00
|
|
|
VOID
|
|
|
|
NTAPI
|
|
|
|
HalpReportSerialNumber(
|
|
|
|
VOID
|
|
|
|
);
|
|
|
|
|
2021-05-11 15:13:14 +00:00
|
|
|
CODE_SEG("INIT")
|
2010-04-01 20:46:55 +00:00
|
|
|
NTSTATUS
|
|
|
|
NTAPI
|
|
|
|
HalpMarkAcpiHal(
|
|
|
|
VOID
|
|
|
|
);
|
|
|
|
|
2021-05-11 15:13:14 +00:00
|
|
|
CODE_SEG("INIT")
|
2010-04-01 20:46:55 +00:00
|
|
|
VOID
|
|
|
|
NTAPI
|
|
|
|
HalpBuildAddressMap(
|
|
|
|
VOID
|
|
|
|
);
|
|
|
|
|
2021-05-11 15:13:14 +00:00
|
|
|
CODE_SEG("INIT")
|
2010-04-01 19:42:07 +00:00
|
|
|
VOID
|
|
|
|
NTAPI
|
|
|
|
HalpReportResourceUsage(
|
|
|
|
IN PUNICODE_STRING HalName,
|
|
|
|
IN INTERFACE_TYPE InterfaceType
|
|
|
|
);
|
|
|
|
|
2021-05-11 15:13:14 +00:00
|
|
|
CODE_SEG("INIT")
|
2010-04-01 20:46:55 +00:00
|
|
|
ULONG
|
|
|
|
NTAPI
|
|
|
|
HalpIs16BitPortDecodeSupported(
|
|
|
|
VOID
|
|
|
|
);
|
|
|
|
|
2010-04-02 06:28:43 +00:00
|
|
|
NTSTATUS
|
|
|
|
NTAPI
|
|
|
|
HalpQueryAcpiResourceRequirements(
|
|
|
|
OUT PIO_RESOURCE_REQUIREMENTS_LIST *Requirements
|
|
|
|
);
|
|
|
|
|
2010-01-26 21:41:05 +00:00
|
|
|
VOID
|
|
|
|
FASTCALL
|
|
|
|
KeUpdateSystemTime(
|
|
|
|
IN PKTRAP_FRAME TrapFrame,
|
|
|
|
IN ULONG Increment,
|
|
|
|
IN KIRQL OldIrql
|
|
|
|
);
|
|
|
|
|
2024-02-24 10:05:12 +00:00
|
|
|
VOID
|
|
|
|
NTAPI
|
|
|
|
KeUpdateRunTime(
|
|
|
|
_In_ PKTRAP_FRAME TrapFrame,
|
|
|
|
_In_ KIRQL Irql);
|
|
|
|
|
2021-05-11 15:13:14 +00:00
|
|
|
CODE_SEG("INIT")
|
[HAL]: Bus support in the HAL actually creates a further wedge between the different x86 HALs: There are actually two dinstinct implementations. On the ACPI HAL, the system is assumed not to have things like special ISA, MCA, EISA buses, and a PCI driver is used in combination with the ACPI Interface for PCI Bus support. On non-ACPI systems, the legacy "Bus Handler" library is used, and the HAL provides a core set of CMOS, EISA, ISA, MCA and PCI bus handlers, each with their own routines and specific code. Additionally, PCI IRQ Routing and other PCI bus internals are handled directly by the HAL -- on the ACPI HAL, the PCI Bus support is implemented through a "Fake"/static bus handler, just to keep the functions shared. On ReactOS, both the ACPI and non-ACPI HAL were currently using a mix of both HAL bus handling types, mostly implemented the "ACPI way" (with a fake PCI bus handler and such).
As a result, none of the Hal*Bus HALDISPATCH routines were implemented, which bus drivers expect to find when they're not on ACPI systems (ReactOS today). eVb's new PCI driver was crashing, for example.
Furthermore, legacy systems suffer, because the ACPI HAL Bus routines (that we currently have) expect perfect ACPI-style-compliant systems, not the legacy crap from the early 90ies. This works fine in VMs and new hardware, but old hardware is left behind.
This patch basically corrects the first part of the problem, by making the bus handling support separate between ACPI and non-ACPI HALs. For now, the code remains 100% the same in functionality between both.
However, I have started adding the first few elements:
[HAL]: Implement HalRegisterBusHandler HALDISPATCH routine.
[HAL]: On legacy HALs, register the CMOS, ISA, SYSTEM handlers.
[HAL]: Add cmosbus.c. Stub all bus-specific bus handler routines in the xxxbus.c files.
No real functionality change occurs with this patch, yet.
svn path=/trunk/; revision=47649
2010-06-07 01:09:41 +00:00
|
|
|
VOID
|
|
|
|
NTAPI
|
|
|
|
HalpInitBusHandlers(
|
|
|
|
VOID
|
|
|
|
);
|
|
|
|
|
2010-09-10 21:46:13 +00:00
|
|
|
NTSTATUS
|
|
|
|
NTAPI
|
|
|
|
HaliInitPnpDriver(
|
|
|
|
VOID
|
|
|
|
);
|
|
|
|
|
2021-05-11 15:13:14 +00:00
|
|
|
CODE_SEG("INIT")
|
2010-09-10 21:46:13 +00:00
|
|
|
VOID
|
|
|
|
NTAPI
|
|
|
|
HalpDebugPciDumpBus(
|
2022-05-26 13:40:17 +00:00
|
|
|
IN PBUS_HANDLER BusHandler,
|
|
|
|
IN PCI_SLOT_NUMBER PciSlot,
|
2010-09-11 09:01:58 +00:00
|
|
|
IN ULONG i,
|
|
|
|
IN ULONG j,
|
|
|
|
IN ULONG k,
|
|
|
|
IN PPCI_COMMON_CONFIG PciData
|
2010-09-10 21:46:13 +00:00
|
|
|
);
|
|
|
|
|
2011-09-07 18:25:43 +00:00
|
|
|
VOID
|
|
|
|
NTAPI
|
|
|
|
HalpInitProcessor(
|
|
|
|
IN ULONG ProcessorNumber,
|
|
|
|
IN PLOADER_PARAMETER_BLOCK LoaderBlock
|
|
|
|
);
|
|
|
|
|
2020-07-25 13:31:02 +00:00
|
|
|
#if defined(SARCH_PC98)
|
|
|
|
BOOLEAN
|
|
|
|
NTAPI
|
|
|
|
HalpDismissIrq08(
|
|
|
|
_In_ KIRQL Irql,
|
|
|
|
_In_ ULONG Irq,
|
|
|
|
_Out_ PKIRQL OldIrql
|
|
|
|
);
|
|
|
|
|
|
|
|
BOOLEAN
|
|
|
|
NTAPI
|
|
|
|
HalpDismissIrq08Level(
|
|
|
|
_In_ KIRQL Irql,
|
|
|
|
_In_ ULONG Irq,
|
|
|
|
_Out_ PKIRQL OldIrql
|
|
|
|
);
|
|
|
|
|
|
|
|
VOID
|
|
|
|
NTAPI
|
|
|
|
HalpInitializeClockPc98(VOID);
|
|
|
|
|
|
|
|
extern ULONG PIT_FREQUENCY;
|
|
|
|
#endif /* SARCH_PC98 */
|
|
|
|
|
2018-02-11 18:21:01 +00:00
|
|
|
VOID
|
|
|
|
NTAPI
|
|
|
|
HalInitializeBios(
|
2020-02-09 21:19:54 +00:00
|
|
|
_In_ ULONG Phase,
|
2018-02-11 18:21:01 +00:00
|
|
|
_In_ PLOADER_PARAMETER_BLOCK LoaderBlock
|
|
|
|
);
|
|
|
|
|
2023-07-20 19:44:44 +00:00
|
|
|
#ifdef _M_AMD64
|
2008-09-03 00:44:50 +00:00
|
|
|
#define KfLowerIrql KeLowerIrql
|
2011-09-07 18:25:43 +00:00
|
|
|
#define KiEnterInterruptTrap(TrapFrame) /* We do all neccessary in asm code */
|
2008-09-03 00:44:50 +00:00
|
|
|
#endif // _M_AMD64
|
|
|
|
|
2010-01-01 21:07:22 +00:00
|
|
|
extern BOOLEAN HalpNMIInProgress;
|
|
|
|
|
2009-10-29 19:58:41 +00:00
|
|
|
extern ADDRESS_USAGE HalpDefaultIoSpace;
|
|
|
|
|
2006-11-27 19:26:31 +00:00
|
|
|
extern KSPIN_LOCK HalpSystemHardwareLock;
|
2005-06-18 14:30:09 +00:00
|
|
|
|
2009-10-29 19:58:41 +00:00
|
|
|
extern PADDRESS_USAGE HalpAddressUsageList;
|
|
|
|
|
2010-01-26 21:41:05 +00:00
|
|
|
extern LARGE_INTEGER HalpPerfCounter;
|
2010-04-01 20:46:55 +00:00
|
|
|
|
|
|
|
extern KAFFINITY HalpActiveProcessors;
|
|
|
|
|
|
|
|
extern BOOLEAN HalDisableFirmwareMapper;
|
|
|
|
extern PWCHAR HalHardwareIdString;
|
|
|
|
extern PWCHAR HalName;
|
2010-06-07 20:35:02 +00:00
|
|
|
|
|
|
|
extern KAFFINITY HalpDefaultInterruptAffinity;
|
|
|
|
|
2011-08-24 15:57:18 +00:00
|
|
|
extern IDTUsageFlags HalpIDTUsageFlags[MAXIMUM_IDTVECTOR+1];
|
2010-06-07 20:35:02 +00:00
|
|
|
|
2011-09-10 18:58:01 +00:00
|
|
|
extern const USHORT HalpBuildType;
|