Ignore:
Timestamp:
Jun 22, 2017, 3:13:14 PM (5 years ago)
Author:
max@…
Message:

Parse RSDP->RSDT->MADT, and get the LAPIC PA.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/hal/x86_64/hal_acpi.h

    r35 r39  
    33 *
    44 * Copyright (c) 2017 Maxime Villard
     5 * Inspired by ACPICA.
    56 *
    67 * This file is part of ALMOS-MKH.
     
    2021 */
    2122
     23/*
     24 * Copyright (C) 2000 - 2017, Intel Corp.
     25 * All rights reserved.
     26 *
     27 * Redistribution and use in source and binary forms, with or without
     28 * modification, are permitted provided that the following conditions
     29 * are met:
     30 * 1. Redistributions of source code must retain the above copyright
     31 *    notice, this list of conditions, and the following disclaimer,
     32 *    without modification.
     33 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
     34 *    substantially similar to the "NO WARRANTY" disclaimer below
     35 *    ("Disclaimer") and any redistribution must be conditioned upon
     36 *    including a substantially similar Disclaimer requirement for further
     37 *    binary redistribution.
     38 * 3. Neither the names of the above-listed copyright holders nor the names
     39 *    of any contributors may be used to endorse or promote products derived
     40 *    from this software without specific prior written permission.
     41 *
     42 * Alternatively, this software may be distributed under the terms of the
     43 * GNU General Public License ("GPL") version 2 as published by the Free
     44 * Software Foundation.
     45 *
     46 * NO WARRANTY
     47 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
     48 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
     49 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
     50 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
     51 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     52 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     53 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     54 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
     55 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
     56 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     57 * POSSIBILITY OF SUCH DAMAGES.
     58 */
     59
    2260void hal_acpi_init();
    2361
     
    2866#define ACPI_OEM_ID_SIZE        6
    2967
     68#define ACPI_NAME_SIZE  4
     69
     70/* Sizes for ACPI table headers */
     71#define ACPI_OEM_ID_SIZE                6
     72#define ACPI_OEM_TABLE_ID_SIZE  8
     73
     74
     75/*******************************************************************************
     76 * RSDP - Root System Description Pointer (Signature is "RSD PTR ")
     77 *        Version 2
     78 ******************************************************************************/
     79
    3080struct acpi_table_rsdp {
    31         char Signature[8];               /* ACPI signature, contains "RSD PTR " */
    32         uint8_t Checksum;                /* ACPI 1.0 checksum */
    33         char OemId[ACPI_OEM_ID_SIZE];    /* OEM identification */
    34         uint8_t Revision;                /* Must be (0) for ACPI 1.0 or (2) for ACPI 2.0+ */
    35         uint32_t RsdtPhysicalAddress;    /* 32-bit physical address of the RSDT */
    36         uint32_t Length;                 /* Table length in bytes, including header (ACPI 2.0+) */
    37         uint64_t XsdtPhysicalAddress;    /* 64-bit physical address of the XSDT (ACPI 2.0+) */
    38         uint8_t ExtendedChecksum;        /* Checksum of entire table (ACPI 2.0+) */
    39         uint8_t Reserved[3];             /* Reserved, must be zero */
     81        char Signature[8];            /* ACPI signature, contains "RSD PTR " */
     82        uint8_t Checksum;             /* ACPI 1.0 checksum */
     83        char OemId[ACPI_OEM_ID_SIZE]; /* OEM identification */
     84        uint8_t Revision;             /* Must be (0) for ACPI 1.0 or (2) for ACPI 2.0+ */
     85        uint32_t RsdtPhysicalAddress; /* 32-bit physical address of the RSDT */
     86        uint32_t Length;              /* Table length in bytes, including header (ACPI 2.0+) */
     87        uint64_t XsdtPhysicalAddress; /* 64-bit physical address of the XSDT (ACPI 2.0+) */
     88        uint8_t ExtendedChecksum;     /* Checksum of entire table (ACPI 2.0+) */
     89        uint8_t Reserved[3];          /* Reserved, must be zero */
    4090} __packed;
     91typedef struct acpi_table_rsdp  rsdp_t;
    4192
    42 typedef struct acpi_table_rsdp  rsdp_t;
     93/*******************************************************************************
     94 * Master ACPI Table Header. This common header is used by all ACPI tables
     95 * except the RSDP and FACS.
     96 ******************************************************************************/
     97
     98struct acpi_table_header {
     99        char Signature[ACPI_NAME_SIZE];          /* ASCII table signature */
     100        uint32_t Length;                         /* Length of table in bytes, including this header */
     101        uint8_t Revision;                        /* ACPI Specification minor version number */
     102        uint8_t Checksum;                        /* To make sum of entire table == 0 */
     103        char OemId[ACPI_OEM_ID_SIZE];            /* ASCII OEM identification */
     104        char OemTableId[ACPI_OEM_TABLE_ID_SIZE]; /* ASCII OEM table identification */
     105        uint32_t OemRevision;                    /* OEM revision number */
     106        char AslCompilerId[ACPI_NAME_SIZE];      /* ASCII ASL compiler vendor ID */
     107        uint32_t AslCompilerRevision;            /* ASL compiler version */
     108} __packed;
     109typedef struct acpi_table_header        header_t;
     110
     111/*******************************************************************************
     112 * RSDT - Root System Description Tables
     113 *        Version 1
     114 ******************************************************************************/
     115
     116struct acpi_table_rsdt {
     117        header_t Header;              /* Common ACPI table header */
     118    uint32_t TableOffsetEntry[1]; /* Array of pointers to ACPI tables */
     119} __packed;
     120typedef struct acpi_table_rsdt  rsdt_t;
     121
     122/*******************************************************************************
     123 * Common subtable headers
     124 ******************************************************************************/
     125
     126struct acpi_subtable_header {
     127        uint8_t Type;
     128        uint8_t Length;
     129} __packed;
     130typedef struct acpi_subtable_header     subheader_t;
     131
     132/*******************************************************************************
     133 * MADT - Multiple APIC Description Table
     134 *        Version 3
     135 ******************************************************************************/
     136
     137struct acpi_table_madt {
     138        header_t Header;  /* Common ACPI table header */
     139        uint32_t Address; /* Physical address of local APIC */
     140        uint32_t Flags;
     141} __packed;
     142typedef struct acpi_table_madt  madt_t;
     143
     144/*******************************************************************************
     145 * MADT structures
     146 ******************************************************************************/
     147
     148enum AcpiMadtType {
     149        ACPI_MADT_TYPE_LOCAL_APIC            = 0,
     150        ACPI_MADT_TYPE_IO_APIC               = 1,
     151        ACPI_MADT_TYPE_INTERRUPT_OVERRIDE    = 2,
     152        ACPI_MADT_TYPE_NMI_SOURCE            = 3,
     153        ACPI_MADT_TYPE_LOCAL_APIC_NMI        = 4,
     154        ACPI_MADT_TYPE_LOCAL_APIC_OVERRIDE   = 5,
     155        ACPI_MADT_TYPE_IO_SAPIC              = 6,
     156        ACPI_MADT_TYPE_LOCAL_SAPIC           = 7,
     157        ACPI_MADT_TYPE_INTERRUPT_SOURCE      = 8,
     158        ACPI_MADT_TYPE_LOCAL_X2APIC          = 9,
     159        ACPI_MADT_TYPE_LOCAL_X2APIC_NMI      = 10,
     160        ACPI_MADT_TYPE_GENERIC_INTERRUPT     = 11,
     161        ACPI_MADT_TYPE_GENERIC_DISTRIBUTOR   = 12,
     162        ACPI_MADT_TYPE_GENERIC_MSI_FRAME     = 13,
     163        ACPI_MADT_TYPE_GENERIC_REDISTRIBUTOR = 14,
     164        ACPI_MADT_TYPE_GENERIC_TRANSLATOR    = 15,
     165        ACPI_MADT_TYPE_RESERVED              = 16  /* 16 and greater are reserved */
     166};
     167
     168struct acpi_madt_local_apic {
     169        subheader_t Header;
     170        uint8_t ProcessorId; /* ACPI processor id */
     171        uint8_t Id;          /* Processor's local APIC id */
     172        uint32_t LapicFlags;
     173} __packed;
     174typedef struct acpi_madt_local_apic     madt_lapic_t;
     175
     176struct acpi_madt_local_apic_override {
     177        subheader_t Header;
     178        uint16_t Reserved; /* Reserved, must be zero */
     179        uint64_t Address;  /* APIC physical address */
     180} __packed;
     181typedef struct acpi_madt_local_apic_override madt_lapic_override;
     182
Note: See TracChangeset for help on using the changeset viewer.