Subversion Repositories Kolibri OS

Rev

Blame | Last modification | View Log | Download | RSS feed

  1.  
  2. #define ACPI_NAME_SIZE                  4
  3. #define ACPI_OEM_ID_SIZE                6
  4. #define ACPI_OEM_TABLE_ID_SIZE          8
  5.  
  6. typedef struct __attribute__((packed))
  7. {
  8.     u8_t    type;
  9.     u8_t    len;
  10. }acpi_madt_hdr_t;
  11.  
  12. typedef struct __attribute__((packed))
  13. {
  14.     acpi_madt_hdr_t header;
  15.  
  16.     u8_t  apic_processor_id;
  17.     u8_t  id;
  18.     struct {
  19.         u32_t enabled   :  1;
  20.         u32_t           : 31;
  21.     } flags;
  22. }acpi_madt_lapic_t;
  23.  
  24. typedef struct __attribute__((packed))
  25. {
  26.     acpi_madt_hdr_t header;
  27.  
  28.     u8_t    id;             /* APIC id            */
  29.     u8_t    _rsvd_3;
  30.  
  31.     u32_t   address;        /* physical address       */
  32.     u32_t   irq_base;       /* global irq number base */
  33. }acpi_madt_ioapic_t;
  34.  
  35. typedef enum {
  36.     conform_polarity = 0,
  37.     active_high = 1,
  38.     reserved_polarity = 2,
  39.     active_low = 3
  40. }polarity_t ;
  41.  
  42. typedef enum  {
  43.     conform_trigger = 0,
  44.     edge = 1,
  45.     reserved_trigger = 2,
  46.     level = 3
  47. }trigger_mode_t;
  48.  
  49. typedef struct __attribute__((packed))
  50. {
  51.     acpi_madt_hdr_t header;
  52.  
  53.     u8_t    src_bus;        /* source bus, fixed 0=ISA  */
  54.     u8_t    src_irq;        /* source bus irq       */
  55.     u32_t   dest;           /* global irq number        */
  56.     union {
  57.         u16_t   flags;      /* irq flags */
  58.         struct {
  59.             u16_t  polarity      : 2;
  60.             u16_t  trigger_mode  : 2;
  61.             u16_t  reserved      : 12;
  62.         } x;
  63.     };
  64. }acpi_madt_irq_t;
  65.  
  66. static inline polarity_t irq_get_polarity(acpi_madt_irq_t *irq)
  67. {   return (polarity_t) irq->x.polarity; }
  68.  
  69. static inline trigger_mode_t irq_get_trigger_mode(acpi_madt_irq_t *irq)
  70. {   return (trigger_mode_t) irq->x.trigger_mode; }
  71.  
  72.  
  73. typedef struct __attribute__((packed))
  74. {
  75.     acpi_madt_hdr_t header;
  76.  
  77.     union {
  78.         u16_t       flags;
  79.         struct {
  80.             u16_t polarity     : 2;
  81.             u16_t trigger_mode : 2;
  82.             u16_t reserved     : 12;
  83.         } x;
  84.     };
  85.     u32_t       irq;
  86.  
  87. }acpi_madt_nmi_t;
  88.  
  89. static inline polarity_t nmi_get_polarity(acpi_madt_nmi_t *nmi)
  90. {   return (polarity_t) nmi->x.polarity; }
  91.  
  92. static inline trigger_mode_t nmi_get_trigger_mode(acpi_madt_nmi_t *nmi)
  93. {   return (trigger_mode_t) nmi->x.trigger_mode; }
  94.  
  95. typedef struct __attribute__((packed))
  96. {
  97.     acpi_madt_hdr_t header;
  98.  
  99.     u8_t  apic_processor_id;
  100.  
  101.     union {
  102.         u16_t       flags;
  103.         struct {
  104.             u16_t polarity     : 2;
  105.             u16_t trigger_mode : 2;
  106.             u16_t reserved     : 12;
  107.         } x;
  108.     };
  109.     u8_t lint;
  110.  
  111. }acpi_lapic_nmi_t;
  112.  
  113. static inline polarity_t lapic_nmi_get_polarity(acpi_lapic_nmi_t *nmi)
  114. {   return (polarity_t) nmi->x.polarity; }
  115.  
  116. static inline trigger_mode_t lapic_nmi_get_trigger_mode(acpi_lapic_nmi_t *nmi)
  117. {   return (trigger_mode_t) nmi->x.trigger_mode; }
  118.  
  119.  
  120. typedef struct __attribute__((packed))
  121. {
  122.     u32_t           sig;
  123.     u32_t           len;
  124.     u8_t            rev;
  125.     u8_t            csum;
  126.     char            oem_id[ACPI_OEM_ID_SIZE];
  127.     char            oem_tid[ACPI_OEM_TABLE_ID_SIZE];
  128.     u32_t           oem_rev;
  129.     u32_t           creator_id;
  130.     u32_t           creator_rev;
  131. }acpi_thead_t;
  132.  
  133.  
  134. typedef struct __attribute__((packed))
  135. {
  136.     acpi_thead_t    header;
  137.     u32_t           local_apic_addr;
  138.     u32_t           apic_flags;
  139.     u8_t            data[0];
  140. } acpi_madt_t;
  141.  
  142. typedef struct  __attribute__((packed))
  143. {
  144.     acpi_thead_t    header;
  145.     u32_t           ptrs[0];
  146. }acpi_rsdt_t;
  147.  
  148. typedef struct  __attribute__((packed))
  149. {
  150.     acpi_thead_t    header;
  151.     u64_t           ptrs[0];
  152. }acpi_xsdt_t;
  153.  
  154. typedef struct
  155. {
  156.     u32_t           sig[2];
  157.     u8_t            csum;
  158.     char            oemid[6];
  159.     u8_t            rev;
  160.     u32_t           rsdt_ptr;
  161.     u32_t           rsdt_len;
  162.     u64_t           xsdt_ptr;
  163.     u8_t            xcsum;
  164.     u8_t            _rsvd_33[3];
  165. }acpi_rsdp_t;
  166.  
  167. typedef struct __attribute__((packed))
  168. {
  169.     u8_t            SpaceId;            /* Address space where struct or register exists */
  170.     u8_t            BitWidth;           /* Size in bits of given register */
  171.     u8_t            BitOffset;          /* Bit offset within the register */
  172.     u8_t            AccessWidth;        /* Minimum Access size (ACPI 3.0) */
  173.     u64_t           Address;            /* 64-bit address of struct or register */
  174.  
  175. } acpi_address_t;
  176.  
  177. typedef struct __attribute__((packed))
  178. {
  179.     acpi_thead_t    Header;             /* Common ACPI table header */
  180.     u32_t           Facs;               /* 32-bit physical address of FACS */
  181.     u32_t           Dsdt;               /* 32-bit physical address of DSDT */
  182.     u8_t            Model;              /* System Interrupt Model (ACPI 1.0) - not used in ACPI 2.0+ */
  183.     u8_t            PreferredProfile;   /* Conveys preferred power management profile to OSPM. */
  184.     u16_t           SciInterrupt;       /* System vector of SCI interrupt */
  185.     u32_t           SmiCommand;         /* 32-bit Port address of SMI command port */
  186.     u8_t            AcpiEnable;         /* Value to write to smi_cmd to enable ACPI */
  187.     u8_t            AcpiDisable;        /* Value to write to smi_cmd to disable ACPI */
  188.     u8_t            S4BiosRequest;      /* Value to write to SMI CMD to enter S4BIOS state */
  189.     u8_t            PstateControl;      /* Processor performance state control*/
  190.     u32_t           Pm1aEventBlock;     /* 32-bit Port address of Power Mgt 1a Event Reg Blk */
  191.     u32_t           Pm1bEventBlock;     /* 32-bit Port address of Power Mgt 1b Event Reg Blk */
  192.     u32_t           Pm1aControlBlock;   /* 32-bit Port address of Power Mgt 1a Control Reg Blk */
  193.     u32_t           Pm1bControlBlock;   /* 32-bit Port address of Power Mgt 1b Control Reg Blk */
  194.     u32_t           Pm2ControlBlock;    /* 32-bit Port address of Power Mgt 2 Control Reg Blk */
  195.     u32_t           PmTimerBlock;       /* 32-bit Port address of Power Mgt Timer Ctrl Reg Blk */
  196.     u32_t           Gpe0Block;          /* 32-bit Port address of General Purpose Event 0 Reg Blk */
  197.     u32_t           Gpe1Block;          /* 32-bit Port address of General Purpose Event 1 Reg Blk */
  198.     u8_t            Pm1EventLength;     /* Byte Length of ports at Pm1xEventBlock */
  199.     u8_t            Pm1ControlLength;   /* Byte Length of ports at Pm1xControlBlock */
  200.     u8_t            Pm2ControlLength;   /* Byte Length of ports at Pm2ControlBlock */
  201.     u8_t            PmTimerLength;      /* Byte Length of ports at PmTimerBlock */
  202.     u8_t            Gpe0BlockLength;    /* Byte Length of ports at Gpe0Block */
  203.     u8_t            Gpe1BlockLength;    /* Byte Length of ports at Gpe1Block */
  204.     u8_t            Gpe1Base;           /* Offset in GPE number space where GPE1 events start */
  205.     u8_t            CstControl;         /* Support for the _CST object and C States change notification */
  206.     u16_t           C2Latency;          /* Worst case HW latency to enter/exit C2 state */
  207.     u16_t           C3Latency;          /* Worst case HW latency to enter/exit C3 state */
  208.     u16_t           FlushSize;          /* Processor's memory cache line width, in bytes */
  209.     u16_t           FlushStride;        /* Number of flush strides that need to be read */
  210.     u8_t            DutyOffset;         /* Processor duty cycle index in processor's P_CNT reg*/
  211.     u8_t            DutyWidth;          /* Processor duty cycle value bit width in P_CNT register.*/
  212.     u8_t            DayAlarm;           /* Index to day-of-month alarm in RTC CMOS RAM */
  213.     u8_t            MonthAlarm;         /* Index to month-of-year alarm in RTC CMOS RAM */
  214.     u8_t            Century;            /* Index to century in RTC CMOS RAM */
  215.     u16_t           BootFlags;          /* IA-PC Boot Architecture Flags. See Table 5-10 for description */
  216.     u8_t            Reserved;           /* Reserved, must be zero */
  217.     u32_t           Flags;              /* Miscellaneous flag bits (see below for individual flags) */
  218.     acpi_address_t  ResetRegister;      /* 64-bit address of the Reset register */
  219.     u8_t            ResetValue;         /* Value to write to the ResetRegister port to reset the system */
  220.     u8_t            Reserved4[3];       /* Reserved, must be zero */
  221.     u64_t           XFacs;              /* 64-bit physical address of FACS */
  222.     u64_t           XDsdt;              /* 64-bit physical address of DSDT */
  223.     acpi_address_t  XPm1aEventBlock;    /* 64-bit Extended Power Mgt 1a Event Reg Blk address */
  224.     acpi_address_t  XPm1bEventBlock;    /* 64-bit Extended Power Mgt 1b Event Reg Blk address */
  225.     acpi_address_t  XPm1aControlBlock;  /* 64-bit Extended Power Mgt 1a Control Reg Blk address */
  226.     acpi_address_t  XPm1bControlBlock;  /* 64-bit Extended Power Mgt 1b Control Reg Blk address */
  227.     acpi_address_t  XPm2ControlBlock;   /* 64-bit Extended Power Mgt 2 Control Reg Blk address */
  228.     acpi_address_t  XPmTimerBlock;      /* 64-bit Extended Power Mgt Timer Ctrl Reg Blk address */
  229.     acpi_address_t  XGpe0Block;         /* 64-bit Extended General Purpose Event 0 Reg Blk address */
  230.     acpi_address_t  XGpe1Block;         /* 64-bit Extended General Purpose Event 1 Reg Blk address */
  231. } acpi_fadt_t;
  232.  
  233.  
  234. #define OS_BASE                          0x80000000
  235.  
  236. #define ACPI_HI_RSDP_WINDOW_START        (OS_BASE+0x000E0000)
  237. #define ACPI_HI_RSDP_WINDOW_END          (OS_BASE+0x00100000)
  238. #define ACPI_RSDP_CHECKSUM_LENGTH        20
  239. #define ACPI_RSDP_XCHECKSUM_LENGTH       36
  240.  
  241. #define ACPI_MADT_SIGN                   0x43495041
  242.  
  243. #define  addr_offset(addr, off) \
  244.     (addr_t)((addr_t)(addr) + (addr_t)(off))
  245.  
  246. #define  ACPI_ADDR(x) \
  247.     (addr_t)((addr_t)(x)+OS_BASE)
  248.  
  249. #define acpi_remap(x)      (x)
  250.  
  251.