summaryrefslogtreecommitdiffhomepage
path: root/src/modules/ACPI/ACPI.h
blob: 4ebc6e2c49919a00449662bae20a2a08e048c82b (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
// Copyright 2024-2025, Amlal El Mahrouss (amlal@nekernel.org)
// Licensed under the Apache License, Version 2.0 (see LICENSE file)
// Official repository: https://github.com/nekernel-org/nekernel

#ifndef __ACPI__
#define __ACPI__

/**
  https://uefi.org/specs/ACPI/6.5/05_ACPI_Software_Programming_Model.html
*/

#include <NeKit/Config.h>

#define SDT_OBJECT : public Kernel::SDT

namespace Kernel {
class PACKED SDT {
 public:
  Char   Signature[4];
  UInt32 Length;
  UInt8  Revision;
  Char   Checksum;
  Char   OemId[6];
  Char   OemTableId[8];
  UInt32 OemRev;
  UInt32 CreatorID;
  UInt32 CreatorRevision;
};

class PACKED RSDP : public SDT {
 public:
  UInt32  RsdtAddress;
  UIntPtr XsdtAddress;
  UInt8   ExtendedChecksum;
  UInt8   Reserved0[3];
};

class PACKED ConfigHeader {
 public:
  UInt64 BaseAddress;
  UInt16 PciSegGroup;
  UInt8  StartBus;
  UInt8  EndBus;
  UInt32 Reserved;
};

enum ACPI_ADDRESS_SPACE_KIND : UInt8 {
  eSystemMemory = 0,
  eSystemIO     = 1,
  ePci          = 2,
  eController   = 3,
  eSmBus        = 4,
  eCount        = 5,
  eInvalid      = 0xFF,
};

class PACKED ACPI_ADDRESS final {
 public:
  UInt8   AddressSpaceId;
  UInt8   RegisterBitWidth;
  UInt8   RegisterBitOffset;
  UInt8   Reserved;
  UIntPtr Address;
};

class PACKED RSDT final {
 public:
  Char   Signature[4];
  UInt32 Length;
  UInt8  Revision;
  Char   Checksum;
  Char   OemId[6];
  Char   OemTableId[8];
  UInt32 OemRev;
  UInt32 CreatorID;
  UInt32 CreatorRevision;
  UInt32 AddressArr[1];
};
}  // namespace Kernel

#endif  // !__ACPI__