#pragma once

#include "../types.h"

struct AcpiRSDP;
struct AcpiXSDT;

/**
 * Common ACPI table header
 */
struct AcpiSDTHeader {
	c8  Signature[4];
	u32 Length;
	u8  Revision;
	u8  Checksum;
	c8  OEMID[6];
	c8  OEMTableID[6];
	u32 OEMRevision;
	u32 CreatorID;
	u32 CreatorRevision;
};

/**
 * ACPI Root System Description Pointer
 */
struct [[gnu::packed]] AcpiRSDP {
	c8               Signature[8];
	u8               Checksum;
	c8               OEM[6];
	u8               Revision;
	[[gnu::deprecated]] // we dont care :>
	u32              RSDTAddress;
	u32              Length;
	struct AcpiXSDT* XSDTAddress;
	u8               ExtendedChecksum;
	u8               Reserved[3];
};

/**
 * The table of tables
 */
struct AcpiXSDT {
	struct AcpiSDTHeader Header;
	
	/// Pointers to other tables
	[[gnu::aligned(4)]] 
	u64 Tables[];
};

/**
 * Initialize ACPI code
 */
void AcpiInitialize();

/**
 * Check if ACPI is present
 */
bool AcpiPresent();