ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

halinit.c
Go to the documentation of this file.
00001 /*
00002  * PROJECT:         ReactOS HAL
00003  * LICENSE:         BSD - See COPYING.ARM in the top level directory
00004  * FILE:            hal/halarm/generic/halinit.c
00005  * PURPOSE:         HAL Entrypoint and Initialization
00006  * PROGRAMMERS:     ReactOS Portable Systems Group
00007  */
00008 
00009 /* INCLUDES *******************************************************************/
00010 
00011 #include <hal.h>
00012 #define NDEBUG
00013 #include <debug.h>
00014 
00015 /* GLOBALS ********************************************************************/
00016 
00017 /* PRIVATE FUNCTIONS **********************************************************/
00018 
00019 VOID
00020 NTAPI
00021 HalpGetParameters(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
00022 {
00023     PCHAR CommandLine;
00024 
00025     /* Make sure we have a loader block and command line */
00026     if ((LoaderBlock) && (LoaderBlock->LoadOptions))
00027     {
00028         /* Read the command line */
00029         CommandLine = LoaderBlock->LoadOptions;
00030 
00031         /* Check for initial breakpoint */
00032         if (strstr(CommandLine, "BREAK")) DbgBreakPoint();
00033     }
00034 }
00035 
00036 /* FUNCTIONS ******************************************************************/
00037 
00038 /*
00039  * @implemented
00040  */
00041 BOOLEAN
00042 NTAPI
00043 HalInitSystem(IN ULONG BootPhase,
00044               IN PLOADER_PARAMETER_BLOCK LoaderBlock)
00045 {
00046     PKPRCB Prcb = KeGetCurrentPrcb();
00047 
00048     /* Check the boot phase */
00049     if (!BootPhase)
00050     {
00051         /* Get command-line parameters */
00052         HalpGetParameters(LoaderBlock);
00053 
00054         /* Checked HAL requires checked kernel */
00055 #if DBG
00056         if (!(Prcb->BuildType & PRCB_BUILD_DEBUG))
00057         {
00058             /* No match, bugcheck */
00059             KeBugCheckEx(MISMATCHED_HAL, 2, Prcb->BuildType, 1, 0);
00060         }
00061 #else
00062         /* Release build requires release HAL */
00063         if (Prcb->BuildType & PRCB_BUILD_DEBUG)
00064         {
00065             /* No match, bugcheck */
00066             KeBugCheckEx(MISMATCHED_HAL, 2, Prcb->BuildType, 0, 0);
00067         }
00068 #endif
00069 
00070 #ifdef CONFIG_SMP
00071         /* SMP HAL requires SMP kernel */
00072         if (Prcb->BuildType & PRCB_BUILD_UNIPROCESSOR)
00073         {
00074             /* No match, bugcheck */
00075             KeBugCheckEx(MISMATCHED_HAL, 2, Prcb->BuildType, 0, 0);
00076         }
00077 #endif
00078 
00079         /* Validate the PRCB */
00080         if (Prcb->MajorVersion != PRCB_MAJOR_VERSION)
00081         {
00082             /* Validation failed, bugcheck */
00083             KeBugCheckEx(MISMATCHED_HAL, 1, Prcb->MajorVersion, 1, 0);
00084         }
00085         
00086         /* Initialize interrupts */
00087         HalpInitializeInterrupts();
00088 
00089         /* Force initial PIC state */
00090         KfRaiseIrql(KeGetCurrentIrql());
00091 
00092         /* Fill out the dispatch tables */
00093         //HalQuerySystemInformation = NULL; // FIXME: TODO;
00094         //HalSetSystemInformation = NULL; // FIXME: TODO;
00095         //HalInitPnpDriver = NULL; // FIXME: TODO
00096         //HalGetDmaAdapter = NULL; // FIXME: TODO;
00097         //HalGetInterruptTranslator = NULL;  // FIXME: TODO
00098         //HalResetDisplay = NULL; // FIXME: TODO;
00099         //HalHaltSystem = NULL; // FIXME: TODO;
00100 
00101         /* Setup I/O space */
00102         //HalpDefaultIoSpace.Next = HalpAddressUsageList;
00103         //HalpAddressUsageList = &HalpDefaultIoSpace;
00104 
00105         /* Setup busy waiting */
00106         //HalpCalibrateStallExecution();
00107 
00108         /* Initialize the clock */
00109         HalpInitializeClock();
00110 
00111         /* Setup time increments to 10ms and 1ms */
00112         HalpCurrentTimeIncrement = 100000;
00113         HalpNextTimeIncrement = 100000;
00114         HalpNextIntervalCount = 0;
00115         KeSetTimeIncrement(100000, 10000);
00116 
00117         /*
00118          * We could be rebooting with a pending profile interrupt,
00119          * so clear it here before interrupts are enabled
00120          */
00121         HalStopProfileInterrupt(ProfileTime);
00122 
00123         /* Do some HAL-specific initialization */
00124         HalpInitPhase0(LoaderBlock);
00125     }
00126     else if (BootPhase == 1)
00127     {
00128         /* Enable timer interrupt */
00129         HalpEnableInterruptHandler(IDT_DEVICE,
00130                                    0,
00131                                    PRIMARY_VECTOR_BASE,
00132                                    CLOCK2_LEVEL,
00133                                    HalpClockInterrupt,
00134                                    Latched);
00135 #if 0
00136         /* Enable IRQ 8 */
00137         HalpEnableInterruptHandler(IDT_DEVICE,
00138                                    0,
00139                                    PRIMARY_VECTOR_BASE + 8,
00140                                    PROFILE_LEVEL,
00141                                    HalpProfileInterrupt,
00142                                    Latched);
00143 #endif
00144         /* Initialize DMA. NT does this in Phase 0 */
00145         //HalpInitDma();
00146 
00147         /* Do some HAL-specific initialization */
00148         HalpInitPhase1();
00149     }
00150 
00151     /* All done, return */
00152     return TRUE;
00153 }
00154 
00155 #include <internal/kd.h>
00156 ULONG
00157 DbgPrintEarly(const char *fmt, ...)
00158 {
00159     va_list args;
00160     unsigned int i;
00161     char Buffer[1024];
00162     PCHAR String = Buffer;
00163 
00164     va_start(args, fmt);
00165     i = vsprintf(Buffer, fmt, args);
00166     va_end(args);
00167     
00168     /* Output the message */
00169     while (*String != 0)
00170     {
00171         if (*String == '\n')
00172         {
00173             KdPortPutByteEx(NULL, '\r');
00174         }
00175         KdPortPutByteEx(NULL, *String);
00176         String++;
00177     }
00178     
00179     return STATUS_SUCCESS;
00180 }
00181 
00182 /* EOF */

Generated on Sun May 27 2012 04:28:40 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.