Advertisement
Guest User

Untitled

a guest
Jun 10th, 2012
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 3.04 KB | None | 0 0
  1. /*
  2.  *  mp.h
  3.  *  MultiProcessor Specification
  4.  */
  5.  
  6. #ifndef __MP_H
  7. #define __MP_H
  8.  
  9. #include <os/system.h>
  10. #include <types.h>
  11.  
  12. #define MP_FPS_SIGNATURE            "_MP_"
  13. #define MP_FPS_SIGNATURE_LENGTH     4
  14. #define MP_FPS_PARAGRAPHS           1
  15. #define FpsLengthToParagraphs(x)    ((x) >> 4)
  16. #define FpsParagraphToLength(x)     ((x) << 4)
  17.  
  18. enum {
  19.     MP_SPEC_REV_0,
  20.     MP_SPEC_REV_1,
  21.     MP_SPEC_REV_2,
  22.     MP_SPEC_REV_3,
  23.     MP_SPEC_REV_4
  24. };
  25.  
  26. #define MP_SUPPORTED_REVISION       MP_SPEC_REV_4
  27.  
  28. #define MP_CT_SIGNATURE             "PCMP"
  29. #define MP_CT_SIGNATURE_LENGTH      4
  30. #define MP_FPS_INFO_A_CT_PRESENT    0
  31. #define MP_FPS_INFO_A_MP_PRESENT    1
  32.  
  33. enum {
  34.     MP_ET_PROCESSOR,                            // Processor
  35.     MP_ET_BUS,                                  // Bus
  36.     MP_ET_IOAPIC,                               // IO/APIC
  37.     MP_ET_IOIA,                                 // IO/Interrupt Assignment
  38.     MP_ET_LIA,                                  // IO/Local Interrupt Assignment
  39.     EP_ET_COUNT
  40. };
  41.  
  42. #define MP_CPU_FLAG_UNUSABLE        0x01        // Unusable core, do not attempt to initialize
  43. #define MP_CPU_FLAG_BOOTSTRAP       0x02        // Bootstrap core
  44.  
  45. #define MP_IOAPIC_FLAG_UNUSABLE     0x01        // Unusable IOAPIC
  46.  
  47. typedef struct _FloatingPointerStructure {
  48.     char        signature[4];
  49.     uint32      configurationTable;             // This is a pointer
  50.     uint8       length;
  51.     uint8       specRev;
  52.     uint8       checksum;
  53.     uint8       infoA;
  54.     uint8       infoB;
  55.     uint8       infoC;                          // Reserved
  56.     uint8       infoD;                          // Reserved
  57.     uint8       infoE;                          // Reserved
  58. } PACKED FloatingPointerStructure;
  59.  
  60. typedef struct _MPConfigurationTable {
  61.     char        signature[4];
  62.     uint16      baseTableLength;
  63.     uint8       specRev;
  64.     uint8       checksum;
  65.     char        oemId[8];
  66.     char        productId[12];
  67.     uint32      oemTable;                       // This is a pointer
  68.     uint16      oemTableSize;
  69.     uint16      entryCount;
  70.     uint32      lapicAddress;
  71.     uint16      extendedTableLength;
  72.     uint8       extendedTableChecksum;
  73.     uint8       reserved;
  74. } PACKED MPConfigurationTable;
  75.  
  76. typedef struct _MPProcessorEntry {
  77.     uint8       type;
  78.     uint8       lapicId;
  79.     uint8       lapicVersion;
  80.     uint8       cpuFlags;
  81.     uint32      cpuSignature;
  82.     uint32      featureFlags;                   // CPUID of this core
  83.     uint32      reserved1;
  84.     uint32      reserved2;
  85. } PACKED MPProcessorEntry;
  86.  
  87. typedef struct _MPBusEntry {
  88.     uint8       type;
  89.     uint8       id;
  90.     char        busType[6];
  91. } PACKED MPBusEntry;
  92.  
  93. typedef struct _MPIOAPICEntry {
  94.     uint8       type;
  95.     uint8       id;
  96.     uint8       version;
  97.     uint8       flags;
  98.     uint32      address;
  99. } PACKED MPIOAPICEntry;
  100.  
  101. typedef struct _MPIOIAEntry {
  102.     uint8       type;
  103.     uint8       interruptType;
  104.     uint16      flags;
  105.     uint8       sourceBusId;
  106.     uint8       sourceBusIrq;
  107.     uint8       destIOAPICId;
  108.     uint8       destIOAPICINTIN;
  109. } PACKED MPIOIAEntry;
  110.  
  111. typedef struct _MPLIAEntry {
  112.     uint8       type;
  113.     uint8       interruptType;
  114.     uint16      flags;
  115.     uint8       sourceBusId;
  116.     uint8       sourceBusIrq;
  117.     uint8       destLAPICId;
  118.     uint8       destLAPICINTIN;
  119. } MPLIAEntry;
  120.  
  121. typedef union _MPEntry {
  122.     uint8               type;
  123.     MPProcessorEntry    processor;
  124.     MPBusEntry          bus;
  125.     MPIOAPICEntry       ioapic;
  126.     MPIOIAEntry         ioia;
  127.     MPLIAEntry          lia;
  128. } PACKED MPEntry;
  129.  
  130. MPConfigurationTable* MpGetConfigurationTable(void);
  131. paddr MpGetLocalAPICAddress(MPConfigurationTable* mpct);
  132. uint16 MpGetEntryCount(MPConfigurationTable* mpct);
  133. MPEntry* MpGetEntry(MPConfigurationTable* mpct, uint16 index);
  134.  
  135. #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement