ReactOS  0.4.14-dev-1276-g8aa58c1
halinit.c
Go to the documentation of this file.
1 /*
2  * PROJECT: ReactOS HAL
3  * LICENSE: BSD - See COPYING.ARM in the top level directory
4  * FILE: hal/halarm/generic/halinit.c
5  * PURPOSE: HAL Entrypoint and Initialization
6  * PROGRAMMERS: ReactOS Portable Systems Group
7  */
8 
9 /* INCLUDES *******************************************************************/
10 
11 #include <hal.h>
12 #define NDEBUG
13 #include <debug.h>
14 
15 /* GLOBALS ********************************************************************/
16 
17 /* PRIVATE FUNCTIONS **********************************************************/
18 
19 VOID
20 NTAPI
22 {
23  PCHAR CommandLine;
24 
25  /* Make sure we have a loader block and command line */
26  if ((LoaderBlock) && (LoaderBlock->LoadOptions))
27  {
28  /* Read the command line */
29  CommandLine = LoaderBlock->LoadOptions;
30 
31  /* Check for initial breakpoint */
32  if (strstr(CommandLine, "BREAK")) DbgBreakPoint();
33  }
34 }
35 
36 /* FUNCTIONS ******************************************************************/
37 
38 /*
39  * @implemented
40  */
41 BOOLEAN
42 NTAPI
44  IN PLOADER_PARAMETER_BLOCK LoaderBlock)
45 {
46  PKPRCB Prcb = KeGetCurrentPrcb();
47 
48  /* Check the boot phase */
49  if (!BootPhase)
50  {
51  /* Get command-line parameters */
52  HalpGetParameters(LoaderBlock);
53 
54  /* Checked HAL requires checked kernel */
55 #if DBG
56  if (!(Prcb->BuildType & PRCB_BUILD_DEBUG))
57  {
58  /* No match, bugcheck */
59  KeBugCheckEx(MISMATCHED_HAL, 2, Prcb->BuildType, 1, 0);
60  }
61 #else
62  /* Release build requires release HAL */
63  if (Prcb->BuildType & PRCB_BUILD_DEBUG)
64  {
65  /* No match, bugcheck */
66  KeBugCheckEx(MISMATCHED_HAL, 2, Prcb->BuildType, 0, 0);
67  }
68 #endif
69 
70 #ifdef CONFIG_SMP
71  /* SMP HAL requires SMP kernel */
73  {
74  /* No match, bugcheck */
75  KeBugCheckEx(MISMATCHED_HAL, 2, Prcb->BuildType, 0, 0);
76  }
77 #endif
78 
79  /* Validate the PRCB */
80  if (Prcb->MajorVersion != PRCB_MAJOR_VERSION)
81  {
82  /* Validation failed, bugcheck */
83  KeBugCheckEx(MISMATCHED_HAL, 1, Prcb->MajorVersion, 1, 0);
84  }
85 
86  /* Initialize interrupts */
88 
89  /* Force initial PIC state */
91 
92  /* Fill out the dispatch tables */
93  //HalQuerySystemInformation = NULL; // FIXME: TODO;
94  //HalSetSystemInformation = NULL; // FIXME: TODO;
95  //HalInitPnpDriver = NULL; // FIXME: TODO
96  //HalGetDmaAdapter = NULL; // FIXME: TODO;
97  //HalGetInterruptTranslator = NULL; // FIXME: TODO
98  //HalResetDisplay = NULL; // FIXME: TODO;
99  //HalHaltSystem = NULL; // FIXME: TODO;
100 
101  /* Setup I/O space */
102  //HalpDefaultIoSpace.Next = HalpAddressUsageList;
103  //HalpAddressUsageList = &HalpDefaultIoSpace;
104 
105  /* Setup busy waiting */
106  //HalpCalibrateStallExecution();
107 
108  /* Initialize the clock */
110 
111  /* Setup time increments to 10ms and 1ms */
112  HalpCurrentTimeIncrement = 100000;
113  HalpNextTimeIncrement = 100000;
115  KeSetTimeIncrement(100000, 10000);
116 
117  /*
118  * We could be rebooting with a pending profile interrupt,
119  * so clear it here before interrupts are enabled
120  */
122 
123  /* Do some HAL-specific initialization */
124  HalpInitPhase0(LoaderBlock);
125  }
126  else if (BootPhase == 1)
127  {
128  /* Enable timer interrupt */
130  0,
132  CLOCK2_LEVEL,
134  Latched);
135 #if 0
136  /* Enable IRQ 8 */
138  0,
142  Latched);
143 #endif
144  /* Initialize DMA. NT does this in Phase 0 */
145  //HalpInitDma();
146 
147  /* Do some HAL-specific initialization */
148  HalpInitPhase1();
149  }
150 
151  /* All done, return */
152  return TRUE;
153 }
154 
155 #include <internal/kd.h>
156 ULONG
157 DbgPrintEarly(const char *fmt, ...)
158 {
159  va_list args;
160  unsigned int i;
161  char Buffer[1024];
162  PCHAR String = Buffer;
163 
164  va_start(args, fmt);
165  i = vsprintf(Buffer, fmt, args);
166  va_end(args);
167 
168  /* Output the message */
169  while (*String != 0)
170  {
171  if (*String == '\n')
172  {
173  KdPortPutByteEx(NULL, '\r');
174  }
176  String++;
177  }
178 
179  return STATUS_SUCCESS;
180 }
181 
182 /* EOF */
#define KeGetCurrentIrql()
Definition: env_spec_w32.h:706
signed char * PCHAR
Definition: retypes.h:7
#define IN
Definition: typedefs.h:39
#define TRUE
Definition: types.h:120
VOID NTAPI KeSetTimeIncrement(IN ULONG MaxIncrement, IN ULONG MinIncrement)
Definition: ntoskrnl.c:42
char * strstr(char *String1, char *String2)
Definition: utclib.c:653
#define PRIMARY_VECTOR_BASE
Definition: halp.h:16
FORCEINLINE struct _KPRCB * KeGetCurrentPrcb(VOID)
Definition: ketypes.h:1063
static WCHAR String[]
Definition: stringtable.c:55
void DbgBreakPoint()
Definition: mach.c:553
VOID NTAPI HalpGetParameters(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: halinit.c:21
Definition: match.c:390
#define PRCB_BUILD_DEBUG
Definition: ketypes.h:242
ULONG DbgPrintEarly(const char *fmt,...)
Definition: halinit.c:157
VOID HalpInitPhase1(VOID)
Definition: halinit_up.c:26
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
VOID HalpInitializeInterrupts(VOID)
Definition: pic.c:93
NTSTATUS(* NTAPI)(IN PFILE_FULL_EA_INFORMATION EaBuffer, IN ULONG EaLength, OUT PULONG ErrorOffset)
Definition: IoEaTest.cpp:117
#define va_end(ap)
Definition: acmsvcex.h:90
unsigned char BOOLEAN
VOID HalpProfileInterrupt(VOID)
smooth NULL
Definition: ftsmooth.c:416
char * va_list
Definition: acmsvcex.h:78
Definition: bufpool.h:45
VOID NTAPI KdPortPutByteEx(PCPPORT PortInformation, UCHAR ByteToSend)
VOID HalpInitPhase0(PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: halinit_mp.c:31
KIRQL FASTCALL KfRaiseIrql(IN KIRQL NewIrql)
Definition: pic.c:187
VOID NTAPI HalpEnableInterruptHandler(IN UCHAR Flags, IN ULONG BusVector, IN ULONG SystemVector, IN KIRQL Irql, IN PVOID Handler, IN KINTERRUPT_MODE Mode)
Definition: usage.c:49
ULONG HalpNextTimeIncrement
Definition: timer.c:25
#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
#define PROFILE_LEVEL
Definition: env_spec_w32.h:698
ULONG HalpCurrentTimeIncrement
Definition: timer.c:25
#define PRCB_BUILD_UNIPROCESSOR
Definition: ketypes.h:243
int __cdecl vsprintf(char *_Dest, const char *_Format, va_list _Args)
Definition: sprintf.c:733
#define va_start(ap, A)
Definition: acmsvcex.h:91
USHORT MajorVersion
Definition: ketypes.h:598
ULONG HalpNextIntervalCount
Definition: timer.c:25
unsigned int ULONG
Definition: retypes.h:1
VOID NTAPI HalStopProfileInterrupt(IN KPROFILE_SOURCE ProfileSource)
Definition: profil.c:22
#define IDT_DEVICE
Definition: halp.h:22
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34
return STATUS_SUCCESS
Definition: btrfs.c:2938
BOOLEAN NTAPI HalInitSystem(IN ULONG BootPhase, IN PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: halinit.c:43
#define args
Definition: format.c:66
Definition: dsound.c:943
#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:107