ReactOS  0.4.15-dev-1070-ge1a01de
halinit.c
Go to the documentation of this file.
1 /*
2  * PROJECT: ReactOS HAL
3  * LICENSE: GPL - See COPYING in the top level directory
4  * FILE: hal/halppc/generic/halinit.c
5  * PURPOSE: HAL Entrypoint and Initialization
6  * PROGRAMMERS: Alex Ionescu (alex.ionescu@reactos.org)
7  */
8 
9 /* INCLUDES ******************************************************************/
10 
11 #include <hal.h>
12 #define NDEBUG
13 #include <debug.h>
14 
15 /* GLOBALS *******************************************************************/
16 
19 
20 /* PRIVATE FUNCTIONS *********************************************************/
21 
22 VOID
23 NTAPI
25 {
26  PCHAR CommandLine;
27 
28  /* Make sure we have a loader block and command line */
29  if ((LoaderBlock) && (LoaderBlock->LoadOptions))
30  {
31  /* Read the command line */
32  CommandLine = LoaderBlock->LoadOptions;
33 
34  /* Check if PCI is locked */
35  if (strstr(CommandLine, "PCILOCK")) HalpPciLockSettings = TRUE;
36 
37  /* Check for initial breakpoint */
38  if (strstr(CommandLine, "BREAK")) DbgBreakPoint();
39  }
40 }
41 
42 /* FUNCTIONS *****************************************************************/
43 
44 /*
45  * @implemented
46  */
47 BOOLEAN
48 NTAPI
50  IN PLOADER_PARAMETER_BLOCK LoaderBlock)
51 {
52  KIRQL CurIrql;
53  PKPRCB Prcb = KeGetCurrentPrcb();
54 
55  DbgPrint("Prcb: %x BuildType %x\n", Prcb, Prcb->BuildType);
56 
57  /* Check the boot phase */
58  if (!BootPhase)
59  {
60  /* Phase 0... save bus type */
61  HalpBusType = LoaderBlock->u.I386.MachineType & 0xFF;
62 
63  /* Get command-line parameters */
64  HalpGetParameters(LoaderBlock);
65 
66  /* Checked HAL requires checked kernel */
67 #if DBG
68  if (!(Prcb->BuildType & PRCB_BUILD_DEBUG))
69  {
70  /* No match, bugcheck */
71  KeBugCheckEx(MISMATCHED_HAL, 2, Prcb->BuildType, 1, 0);
72  }
73 #else
74  /* Release build requires release HAL */
75  if (Prcb->BuildType & PRCB_BUILD_DEBUG)
76  {
77  /* No match, bugcheck */
78  KeBugCheckEx(MISMATCHED_HAL, 2, Prcb->BuildType, 0, 0);
79  }
80 #endif
81 
82 #ifdef CONFIG_SMP
83  /* SMP HAL requires SMP kernel */
85  {
86  /* No match, bugcheck */
87  KeBugCheckEx(MISMATCHED_HAL, 2, Prcb->BuildType, 0, 0);
88  }
89 #endif
90 
91  /* Validate the PRCB */
92  if (Prcb->MajorVersion != PRCB_MAJOR_VERSION)
93  {
94  /* Validation failed, bugcheck */
95  KeBugCheckEx(MISMATCHED_HAL, 1, Prcb->MajorVersion, 1, 0);
96  }
97 
98  /* Initialize the PICs */
99  HalpInitPICs();
100 
101  /* Force initial PIC state */
102  KeRaiseIrql(KeGetCurrentIrql(), &CurIrql);
103 
104  /* Initialize the clock */
106 
107  /* Setup busy waiting */
108  //HalpCalibrateStallExecution();
109 
110  /* Fill out the dispatch tables */
113  HalInitPnpDriver = NULL; // FIXME: TODO
115  HalGetInterruptTranslator = NULL; // FIXME: TODO
116 
117  /* Initialize the hardware lock (CMOS) */
119  }
120  else if (BootPhase == 1)
121  {
122  /* Initialize the default HAL stubs for bus handling functions */
124 
125 #if 0
126  /* Enable the clock interrupt */
127  ((PKIPCR)KeGetPcr())->IDT[0x30].ExtendedOffset =
128  (USHORT)(((ULONG_PTR)HalpClockInterrupt >> 16) & 0xFFFF);
129  ((PKIPCR)KeGetPcr())->IDT[0x30].Offset =
131 #endif
133 
134  /* Initialize DMA. NT does this in Phase 0 */
135  HalpInitDma();
136  }
137 
138  /* All done, return */
139  return TRUE;
140 }
141 
142 /*
143  * @unimplemented
144  */
145 VOID
146 NTAPI
148 {
149  /* Initialize PCI bus. */
151 
152  /* FIXME: This is done in ReactOS MP HAL only*/
153  //HaliReconfigurePciInterrupts();
154 
155  /* FIXME: Report HAL Usage to kernel */
156 }
157 
158 /* EOF */
#define KeGetCurrentIrql()
Definition: env_spec_w32.h:706
signed char * PCHAR
Definition: retypes.h:7
#define HalGetDmaAdapter
Definition: haltypes.h:291
#define IN
Definition: typedefs.h:39
BOOLEAN NTAPI HalEnableSystemInterrupt(IN ULONG Vector, IN KIRQL Irql, IN KINTERRUPT_MODE InterruptMode)
Definition: pic.c:295
#define KeRaiseIrql(irql, oldIrql)
Definition: env_spec_w32.h:597
#define DbgPrint
Definition: loader.c:25
VOID NTAPI HalpInitNonBusHandler(VOID)
Definition: bus.c:120
#define TRUE
Definition: types.h:120
char * strstr(char *String1, char *String2)
Definition: utclib.c:653
FORCEINLINE struct _KPRCB * KeGetCurrentPrcb(VOID)
Definition: ketypes.h:1063
struct _KIPCR * PKIPCR
#define HalGetInterruptTranslator
Definition: haltypes.h:292
NTSTATUS NTAPI HaliQuerySystemInformation(IN HAL_QUERY_INFORMATION_CLASS InformationClass, IN ULONG BufferSize, IN OUT PVOID Buffer, OUT PULONG ReturnedLength)
Definition: sysinfo.c:19
#define HalQuerySystemInformation
Definition: haltypes.h:283
BOOLEAN HalpPciLockSettings
Definition: halinit.c:18
void DbgBreakPoint()
Definition: mach.c:553
VOID NTAPI HalpGetParameters(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: halinit.c:21
#define PRCB_BUILD_DEBUG
Definition: ketypes.h:242
#define HalSetSystemInformation
Definition: haltypes.h:284
#define KeGetPcr()
Definition: ke.h:25
VOID NTAPI HalReportResourceUsage(VOID)
Definition: halinit.c:147
UCHAR KIRQL
Definition: env_spec_w32.h:591
NTSTATUS(* NTAPI)(IN PFILE_FULL_EA_INFORMATION EaBuffer, IN ULONG EaLength, OUT PULONG ErrorOffset)
Definition: IoEaTest.cpp:117
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
VOID HalpInitDma(VOID)
Definition: dma.c:121
NTSTATUS NTAPI HaliSetSystemInformation(IN HAL_SET_INFORMATION_CLASS InformationClass, IN ULONG BufferSize, IN OUT PVOID Buffer)
Definition: sysinfo.c:31
FORCEINLINE VOID KeInitializeSpinLock(_Out_ PKSPIN_LOCK SpinLock)
Definition: kefuncs.h:238
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
VOID NTAPI HalpInitPICs(VOID)
Definition: irql.c:80
Definition: utils.h:177
VOID NTAPI HalpInitializePciBus(VOID)
Definition: pci.c:770
ULONG HalpBusType
Definition: bus.c:17
#define CLOCK2_LEVEL
Definition: env_spec_w32.h:700
VOID HalpInitializeClock(VOID)
Definition: timer.c:54
UCHAR BuildType
Definition: ketypes.h:599
VOID HalpClockInterrupt(VOID)
Definition: timer.c:30
PDMA_ADAPTER NTAPI HalpGetDmaAdapter(IN PVOID Context, IN PDEVICE_DESCRIPTION DeviceDescription, OUT PULONG NumberOfMapRegisters)
Definition: dma.c:790
unsigned short USHORT
Definition: pedump.c:61
#define PRCB_BUILD_UNIPROCESSOR
Definition: ketypes.h:243
USHORT MajorVersion
Definition: ketypes.h:598
KSPIN_LOCK HalpSystemHardwareLock
Definition: cmos.c:18
unsigned int ULONG
Definition: retypes.h:1
#define ULONG_PTR
Definition: config.h:101
BOOLEAN NTAPI HalInitSystem(IN ULONG BootPhase, IN PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: halinit.c:43
#define HalInitPnpDriver
Definition: haltypes.h:289
#define PRCB_MAJOR_VERSION
Definition: ketypes.h:241
VOID NTAPI KeBugCheckEx(_In_ ULONG BugCheckCode, _In_ ULONG_PTR BugCheckParameter1, _In_ ULONG_PTR BugCheckParameter2, _In_ ULONG_PTR BugCheckParameter3, _In_ ULONG_PTR BugCheckParameter4)
Definition: rtlcompat.c:108
HALP_HOOKS HalpHooks
Definition: halinit.c:17