summaryrefslogtreecommitdiff
path: root/kernel/mboot/rsdp.c
blob: f20d986cbe83079bd507310fee386a51b8ab641d (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
#include <lib.h>
#include <comus/mboot.h>

#include "mboot.h"

#define MULTIBOOT_TAG_TYPE_ACPI_OLD 14
#define MULTIBOOT_TAG_TYPE_ACPI_NEW 15

struct multiboot_tag_old_acpi {
	uint32_t type;
	uint32_t size;
	uint8_t rsdp[];
};

struct multiboot_tag_new_acpi {
	uint32_t type;
	uint32_t size;
	uint8_t rsdp[];
};

void *mboot_get_rsdp(void)
{
	void *tag;

	// acpi 2.0
	tag = locate_mboot_table(MULTIBOOT_TAG_TYPE_ACPI_NEW);
	if (tag != NULL) {
		struct multiboot_tag_new_acpi *rsdp = (struct multiboot_tag_new_acpi *)tag;
		return rsdp->rsdp;
	}

	// acpi 1.0
	tag = locate_mboot_table(MULTIBOOT_TAG_TYPE_ACPI_OLD);
	if (tag != NULL) {
		struct multiboot_tag_old_acpi *rsdp = (struct multiboot_tag_old_acpi *)tag;
		return rsdp->rsdp;
	}

	return NULL;
}