vaseboot/include/VasEBoot/acpi.h

248 lines
7.1 KiB
C

/*
* VasEBoot -- GRand Unified Bootloader
* Copyright (C) 2009 Free Software Foundation, Inc.
*
* VasEBoot is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* VasEBoot is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with VasEBoot. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef VasEBoot_ACPI_HEADER
#define VasEBoot_ACPI_HEADER 1
#ifndef VasEBoot_DSDT_TEST
#include <VasEBoot/types.h>
#include <VasEBoot/err.h>
#else
#define VasEBoot_PACKED __attribute__ ((packed))
#endif
#define VasEBoot_RSDP_SIGNATURE "RSD PTR "
#define VasEBoot_RSDP_SIGNATURE_SIZE 8
struct VasEBoot_acpi_rsdp_v10
{
VasEBoot_uint8_t signature[VasEBoot_RSDP_SIGNATURE_SIZE];
VasEBoot_uint8_t checksum;
VasEBoot_uint8_t oemid[6];
VasEBoot_uint8_t revision;
VasEBoot_uint32_t rsdt_addr;
} VasEBoot_PACKED;
struct VasEBoot_acpi_rsdp_v20
{
struct VasEBoot_acpi_rsdp_v10 rsdpv1;
VasEBoot_uint32_t length;
VasEBoot_uint64_t xsdt_addr;
VasEBoot_uint8_t checksum;
VasEBoot_uint8_t reserved[3];
} VasEBoot_PACKED;
struct VasEBoot_acpi_table_header
{
VasEBoot_uint8_t signature[4];
VasEBoot_uint32_t length;
VasEBoot_uint8_t revision;
VasEBoot_uint8_t checksum;
VasEBoot_uint8_t oemid[6];
VasEBoot_uint8_t oemtable[8];
VasEBoot_uint32_t oemrev;
VasEBoot_uint8_t creator_id[4];
VasEBoot_uint32_t creator_rev;
} VasEBoot_PACKED;
#define VasEBoot_ACPI_FADT_SIGNATURE "FACP"
struct VasEBoot_acpi_fadt
{
struct VasEBoot_acpi_table_header hdr;
VasEBoot_uint32_t facs_addr;
VasEBoot_uint32_t dsdt_addr;
VasEBoot_uint8_t somefields1[20];
VasEBoot_uint32_t pm1a;
VasEBoot_uint8_t somefields2[8];
VasEBoot_uint32_t pmtimer;
VasEBoot_uint8_t somefields3[32];
VasEBoot_uint32_t flags;
VasEBoot_uint8_t somefields4[16];
VasEBoot_uint64_t facs_xaddr;
VasEBoot_uint64_t dsdt_xaddr;
VasEBoot_uint8_t somefields5[96];
} VasEBoot_PACKED;
#define VasEBoot_ACPI_MADT_SIGNATURE "APIC"
struct VasEBoot_acpi_madt_entry_header
{
VasEBoot_uint8_t type;
VasEBoot_uint8_t len;
};
struct VasEBoot_acpi_madt
{
struct VasEBoot_acpi_table_header hdr;
VasEBoot_uint32_t lapic_addr;
VasEBoot_uint32_t flags;
struct VasEBoot_acpi_madt_entry_header entries[0];
};
enum
{
VasEBoot_ACPI_MADT_ENTRY_TYPE_LAPIC = 0,
VasEBoot_ACPI_MADT_ENTRY_TYPE_IOAPIC = 1,
VasEBoot_ACPI_MADT_ENTRY_TYPE_INTERRUPT_OVERRIDE = 2,
VasEBoot_ACPI_MADT_ENTRY_TYPE_LAPIC_NMI = 4,
VasEBoot_ACPI_MADT_ENTRY_TYPE_SAPIC = 6,
VasEBoot_ACPI_MADT_ENTRY_TYPE_LSAPIC = 7,
VasEBoot_ACPI_MADT_ENTRY_TYPE_PLATFORM_INT_SOURCE = 8
};
struct VasEBoot_acpi_madt_entry_lapic
{
struct VasEBoot_acpi_madt_entry_header hdr;
VasEBoot_uint8_t acpiid;
VasEBoot_uint8_t apicid;
VasEBoot_uint32_t flags;
};
struct VasEBoot_acpi_madt_entry_ioapic
{
struct VasEBoot_acpi_madt_entry_header hdr;
VasEBoot_uint8_t id;
VasEBoot_uint8_t pad;
VasEBoot_uint32_t address;
VasEBoot_uint32_t global_sys_interrupt;
};
struct VasEBoot_acpi_madt_entry_interrupt_override
{
struct VasEBoot_acpi_madt_entry_header hdr;
VasEBoot_uint8_t bus;
VasEBoot_uint8_t source;
VasEBoot_uint32_t global_sys_interrupt;
VasEBoot_uint16_t flags;
} VasEBoot_PACKED;
struct VasEBoot_acpi_madt_entry_lapic_nmi
{
struct VasEBoot_acpi_madt_entry_header hdr;
VasEBoot_uint8_t acpiid;
VasEBoot_uint16_t flags;
VasEBoot_uint8_t lint;
} VasEBoot_PACKED;
struct VasEBoot_acpi_madt_entry_sapic
{
struct VasEBoot_acpi_madt_entry_header hdr;
VasEBoot_uint8_t id;
VasEBoot_uint8_t pad;
VasEBoot_uint32_t global_sys_interrupt_base;
VasEBoot_uint64_t addr;
};
struct VasEBoot_acpi_madt_entry_lsapic
{
struct VasEBoot_acpi_madt_entry_header hdr;
VasEBoot_uint8_t cpu_id;
VasEBoot_uint8_t id;
VasEBoot_uint8_t eid;
VasEBoot_uint8_t pad[3];
VasEBoot_uint32_t flags;
VasEBoot_uint32_t cpu_uid;
VasEBoot_uint8_t cpu_uid_str[0];
};
struct VasEBoot_acpi_madt_entry_platform_int_source
{
struct VasEBoot_acpi_madt_entry_header hdr;
VasEBoot_uint16_t flags;
VasEBoot_uint8_t inttype;
VasEBoot_uint8_t cpu_id;
VasEBoot_uint8_t cpu_eid;
VasEBoot_uint8_t sapic_vector;
VasEBoot_uint32_t global_sys_int;
VasEBoot_uint32_t src_flags;
};
enum
{
VasEBoot_ACPI_MADT_ENTRY_SAPIC_FLAGS_ENABLED = 1
};
#ifndef VasEBoot_DSDT_TEST
struct VasEBoot_acpi_rsdp_v10 *VasEBoot_acpi_get_rsdpv1 (void);
struct VasEBoot_acpi_rsdp_v20 *VasEBoot_acpi_get_rsdpv2 (void);
struct VasEBoot_acpi_rsdp_v10 *EXPORT_FUNC(VasEBoot_machine_acpi_get_rsdpv1) (void);
struct VasEBoot_acpi_rsdp_v20 *EXPORT_FUNC(VasEBoot_machine_acpi_get_rsdpv2) (void);
VasEBoot_uint8_t EXPORT_FUNC(VasEBoot_byte_checksum) (void *base, VasEBoot_size_t size);
VasEBoot_err_t VasEBoot_acpi_create_ebda (void);
void VasEBoot_acpi_halt (void);
#endif
#define VasEBoot_ACPI_SLP_EN (1 << 13)
#define VasEBoot_ACPI_SLP_TYP_OFFSET 10
enum
{
VasEBoot_ACPI_OPCODE_ZERO = 0, VasEBoot_ACPI_OPCODE_ONE = 1,
VasEBoot_ACPI_OPCODE_NAME = 8, VasEBoot_ACPI_OPCODE_ALIAS = 0x06,
VasEBoot_ACPI_OPCODE_BYTE_CONST = 0x0a,
VasEBoot_ACPI_OPCODE_WORD_CONST = 0x0b,
VasEBoot_ACPI_OPCODE_DWORD_CONST = 0x0c,
VasEBoot_ACPI_OPCODE_STRING_CONST = 0x0d,
VasEBoot_ACPI_OPCODE_SCOPE = 0x10,
VasEBoot_ACPI_OPCODE_BUFFER = 0x11,
VasEBoot_ACPI_OPCODE_PACKAGE = 0x12,
VasEBoot_ACPI_OPCODE_METHOD = 0x14, VasEBoot_ACPI_OPCODE_EXTOP = 0x5b,
VasEBoot_ACPI_OPCODE_ADD = 0x72,
VasEBoot_ACPI_OPCODE_CONCAT = 0x73,
VasEBoot_ACPI_OPCODE_SUBTRACT = 0x74,
VasEBoot_ACPI_OPCODE_MULTIPLY = 0x77,
VasEBoot_ACPI_OPCODE_DIVIDE = 0x78,
VasEBoot_ACPI_OPCODE_LSHIFT = 0x79,
VasEBoot_ACPI_OPCODE_RSHIFT = 0x7a,
VasEBoot_ACPI_OPCODE_AND = 0x7b,
VasEBoot_ACPI_OPCODE_NAND = 0x7c,
VasEBoot_ACPI_OPCODE_OR = 0x7d,
VasEBoot_ACPI_OPCODE_NOR = 0x7e,
VasEBoot_ACPI_OPCODE_XOR = 0x7f,
VasEBoot_ACPI_OPCODE_CONCATRES = 0x84,
VasEBoot_ACPI_OPCODE_MOD = 0x85,
VasEBoot_ACPI_OPCODE_INDEX = 0x88,
VasEBoot_ACPI_OPCODE_CREATE_DWORD_FIELD = 0x8a,
VasEBoot_ACPI_OPCODE_CREATE_WORD_FIELD = 0x8b,
VasEBoot_ACPI_OPCODE_CREATE_BYTE_FIELD = 0x8c,
VasEBoot_ACPI_OPCODE_TOSTRING = 0x9c,
VasEBoot_ACPI_OPCODE_IF = 0xa0, VasEBoot_ACPI_OPCODE_ONES = 0xff
};
enum
{
VasEBoot_ACPI_EXTOPCODE_MUTEX = 0x01,
VasEBoot_ACPI_EXTOPCODE_EVENT_OP = 0x02,
VasEBoot_ACPI_EXTOPCODE_OPERATION_REGION = 0x80,
VasEBoot_ACPI_EXTOPCODE_FIELD_OP = 0x81,
VasEBoot_ACPI_EXTOPCODE_DEVICE_OP = 0x82,
VasEBoot_ACPI_EXTOPCODE_PROCESSOR_OP = 0x83,
VasEBoot_ACPI_EXTOPCODE_POWER_RES_OP = 0x84,
VasEBoot_ACPI_EXTOPCODE_THERMAL_ZONE_OP = 0x85,
VasEBoot_ACPI_EXTOPCODE_INDEX_FIELD_OP = 0x86,
VasEBoot_ACPI_EXTOPCODE_BANK_FIELD_OP = 0x87,
};
struct VasEBoot_acpi_fadt *
EXPORT_FUNC(VasEBoot_acpi_find_fadt) (void);
#endif /* ! VasEBoot_ACPI_HEADER */