Guest User

HAL Detection

a guest
Nov 27th, 2013
249
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.31 KB | None | 0 0
  1. bool acpi = false, apic = false, hpet = false;
  2.  
  3. /* Try to parse the ACPI tables */
  4. rsdp_t *rddp = find_rsdp();
  5. if (rsdp)
  6. {
  7.     acpi = true;
  8.  
  9.     < Parse the HPET table >
  10.  
  11.     if (There is an HPET)
  12.     {
  13.         hpet = true;
  14.     }
  15.    
  16.     < Parse the MADT >
  17.  
  18.     if (There are multiple processors and APICs)
  19.     {
  20.         goto mp;
  21.     }
  22.     else if (There is an APIC, but not multiple processors)
  23.     {
  24.         apic = true;
  25.         goto up;
  26.     }
  27. }
  28.  
  29. /* Try to parse the MP tables */
  30. mp_table_ptr_t *mp_table_ptr = find_mp_table_ptr();
  31. if (mp_table_ptr)
  32. {
  33.     goto mp;
  34. }
  35.  
  36. /* If there's no ACPI or MP tables, we're uniprocessor, but use CPUID to detect an APIC */
  37. < Detect an APIC >
  38. if (There is an APIC)
  39. {
  40.     apic = true;
  41. }
  42.  
  43. /* Uniprocessor HAL */
  44. up:
  45.     if (acpi)
  46.     {
  47.         if (apic)
  48.         {
  49.             if (hpet)
  50.             {
  51.                 < Load the ACPI APIC and HPET HAL >
  52.             }
  53.             else
  54.             {
  55.                 < Load the ACPI APIC and APIC timer HAL >
  56.             }
  57.         }
  58.         else
  59.         {
  60.             < Load the ACPI 8259 and PIT HAL >
  61.         }
  62.     }
  63.     else
  64.     {
  65.         if (apic)
  66.         {
  67.             < Load the legacy APIC and APIC timer HAL >
  68.         }
  69.         else
  70.         {
  71.             < Load the legacy 8259 and PIT HAL >
  72.         }
  73.     }
  74. /* Multiprocessor */
  75. mp:
  76.     if (acpi)
  77.     {
  78.         if (hpet)
  79.         {
  80.             < Load the ACPI APIC and HPET HAL >
  81.         }
  82.         else
  83.         {
  84.             < Load the ACPI APIC and APIC timer HAL >
  85.         }
  86.     }
  87.     else
  88.     {
  89.         < Load the legacy APIC and APIC timer HAL >
  90.     }
Advertisement
Add Comment
Please, Sign In to add comment