[MODERN FEATURES] ACPI tables

This commit is contained in:
2016-11-20 00:22:13 +01:00
parent d801e0fd6c
commit 56d5fea388
6 changed files with 193 additions and 5 deletions

63
kernel/include/acpi.h Normal file
View File

@@ -0,0 +1,63 @@
#pragma once
#include <stdint.h>
typedef struct RSDP_st
{
unsigned char signature[8];
uint8_t checksum;
unsigned char OEMID[6];
uint8_t revision;
uint32_t RSDT_p;
// The following are only available if revision != 0
uint32_t length;
uint64_t XSDT_p;
uint8_t checksum2;
uint8_t reserved[3];
}__attribute__ ((packed)) RSDP_st;
typedef struct SDT_header
{
unsigned char signature[4];
uint32_t length;
uint8_t revision;
uint8_t checksum;
unsigned char OEMID[6];
unsigned char OEMtable[8];
uint32_t OEMrevision;
uint32_t CreatorID;
uint32_t CreatorRevision;
uint8_t data[];
}__attribute__ ((packed)) SDT_header;
typedef struct MADT_header
{
uint32_t LCA;
uint32_t flags;
uint8_t fields[];
}__attribute__((packed)) MADT_header;
typedef struct MADT_field
{
uint8_t type;
uint8_t length;
union{
struct{
uint8_t proc_ID;
uint8_t APIC_ID;
uint32_t flags;
}__attribute__((packed)) proc;
struct {
uint8_t APIC_ID;
uint8_t reserved;
uint32_t address;
uint32_t base;
}__attribute__((packed)) IOAPIC;
struct {
uint8_t bus;
uint8_t irq;
uint32_t interrupt;
uint16_t flags;
}__attribute__((packed)) ISO;
};
}__attribute__((packed)) MADT_field;
void acpi_init();

View File

@@ -80,6 +80,8 @@ typedef struct {
#define MBOOT2_CMDLINE 1
#define MBOOT2_BOOTLOADER 2
#define MBOOT2_MMAP 6
#define MBOOT2_ACPI_V1 14
#define MBOOT2_ACPI_V2 15
// Multiboot tags are padded to a multiple of 8 bytes
#define next_tag(tag) ((void *)((((uintptr_t)tag) + tag->size + 7) & ~0x7))
@@ -92,6 +94,7 @@ typedef struct {
char *bootloader;
void *mmap;
uint32_t mmap_size;
void *rsdp;
};
extern struct mboot_data_st mboot_data;