summaryrefslogtreecommitdiff
path: root/i386/i386at/acpi_rsdp.h
blob: 661d101c7f2e3fd66d1e5c355c32c29729050c97 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
/*Copyright 2018 Juan Bosco Garcia
 *This file is part of Min_SMP.
 *Min_SMP 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.
 *Min_SMP 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 Min_SMP.  If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef __ACPI_H__
#define __ACPI_H__

#include <include/stdint.h> //uint16_t, uint32_t_t...


#define ACPI_RSDP_ALIGN 16
#define ACPI_RSDP_SIG "RSD PTR "


struct acpi_rsdp
{
    uint8_t signature[8];
    uint8_t checksum;
    uint8_t oem_id[6];
    uint8_t revision[1];
    uint32_t rsdt_addr;
} __attribute__((__packed__));


/* RSDT Entry Header 
 * 
 * Header which stores the descriptors of tables pointed from RDSP's Entry Field
 * Includes the signature of the table, to identify each table
 * 
 * In MADT, the signature is 'APIC'
 */ 
struct acpi_dhdr
{
    uint8_t signature[4];
    uint32_t length;
    uint8_t revision;
    uint8_t checksum;
    uint8_t oem_id[6];
    uint8_t oem_table_id[8];
    uint32_t oem_revision;
    uint8_t creator_id[4];
    uint32_t creator_revision;
} __attribute__((__packed__));


#define ACPI_RSDT_SIG "RSDT"

struct acpi_rsdt
{
    struct acpi_dhdr header;
    uint32_t entry[0];
} __attribute__((__packed__));

//APIC table signature
#define ACPI_APIC_SIG "APIC"

//Types value for Local APIC and I/O APIC ACPI's structures
#define ACPI_APIC_ENTRY_LAPIC  0
#define ACPI_APIC_ENTRY_IOAPIC 1

/* APIC descriptor header 
 * Define the type of the structure (Local APIC, I/O APIC or others)
 * Type: Local APIC (0), I/O APIC (1)
 */
struct acpi_apic_dhdr
{
    uint8_t type;
    uint8_t length;
} __attribute__((__packed__));


/* Multiple APIC Description Table (MADT)
 *
 * Describes the APIC structures which exist in the machine
 * Includes the common address where Local APIC is mapped in main memory
 * 
 * Entry field stores the descriptors of APIC structures
 */
struct acpi_apic
{
    struct acpi_dhdr header; //Header, which stores the descriptor for RDST's Entry field
    uint32_t lapic_addr; //Local Interrupt Controller Address
    uint32_t flags;
    struct acpi_apic_dhdr entry[0]; //Interrupt Controller Structure 
} __attribute__((__packed__));

/* Processor Local APIC Structure
 *
 * Stores information about APIC ID, flags and ACPI Processor UID
 */

struct acpi_apic_lapic
{
    struct acpi_apic_dhdr header;
    uint8_t processor_id; //ACPI Processor UID
    uint8_t apic_id;
    uint32_t flags;
} __attribute__((__packed__));


/* I/O APIC Structure 
 *
 * Stores information about APIC ID, and I/O APIC tables
 */

struct acpi_apic_ioapic
{
    struct acpi_apic_dhdr header;
    uint8_t apic_id;
    uint8_t reserved;
    uint32_t addr;
    uint32_t base;
} __attribute__((__packed__));




int acpi_setup();
void acpi_print_info();

/* extra_setup() function:  
 *
 * Must be executed after configure paging
 * Reserve Local APIC common pointer in a physical page
 */
int extra_setup();


#endif /* __ACPI_H__ */