summaryrefslogtreecommitdiffhomepage
path: root/src/loader/inc
diff options
context:
space:
mode:
Diffstat (limited to 'src/loader/inc')
-rw-r--r--src/loader/inc/acpi.h168
-rw-r--r--src/loader/inc/cfg.h22
-rw-r--r--src/loader/inc/def.h1
-rw-r--r--src/loader/inc/dev.h1
-rw-r--r--src/loader/inc/impl/mb1.h13
-rw-r--r--src/loader/inc/lib.h4
6 files changed, 208 insertions, 1 deletions
diff --git a/src/loader/inc/acpi.h b/src/loader/inc/acpi.h
new file mode 100644
index 0000000..f7626e9
--- /dev/null
+++ b/src/loader/inc/acpi.h
@@ -0,0 +1,168 @@
+// MIT License, Copyright (c) 2021 Marvin Borner
+// Many huge structures from ACPI spec
+
+#ifndef ACPI_H
+#define ACPI_H
+
+#include <def.h>
+
+#define RSDP_MAGIC "RSD PTR "
+#define RSDT_MAGIC "RSDT"
+#define MADT_MAGIC "APIC"
+#define FADT_MAGIC "FACP"
+#define HPET_MAGIC "HPET"
+
+/**
+ * General headers
+ */
+
+struct sdt_header {
+ u8 signature[4];
+ u32 length;
+ u8 revision;
+ u8 checksum;
+ u8 oem_id[6];
+ u8 oem_table_id[8];
+ u32 oem_revision;
+ u32 creator_id;
+ u32 creator_revision;
+};
+
+struct sdp_header {
+ u8 signature[8];
+ u8 checksum;
+ u8 oem_id[6];
+ u8 revision;
+};
+
+struct generic_address {
+ u8 address_space;
+ u8 bit_width;
+ u8 bit_offset;
+ u8 access_size;
+ u32 phys_high;
+ u32 phys_low;
+};
+
+/**
+ * RSDT
+ */
+
+struct rsdt {
+ struct sdt_header header;
+ u32 sdt_pointer[];
+};
+
+/**
+ * RSDP - points to RSDT
+ */
+
+struct rsdp {
+ struct sdp_header header;
+ struct rsdt *rsdt;
+};
+
+/**
+ * MADT
+ */
+
+struct madt_entry_header {
+ u8 type;
+ u8 length;
+};
+
+struct madt {
+ struct sdt_header header;
+ u32 local_address;
+ u32 flags;
+ struct madt_entry_header entry;
+} PACKED;
+
+/**
+ * FADT
+ */
+
+struct fadt {
+ struct sdt_header header;
+ u32 firmware_ctrl;
+ u32 dsdt;
+ u8 reserved;
+ u8 preferred_power_mgmt;
+ u16 sci_interrupt;
+ u32 smi_command_port;
+ u8 acpi_enable;
+ u8 acpi_disable;
+ u8 s4_bios_req;
+ u8 pstate_control;
+ u32 pm1a_event_block;
+ u32 pm1b_event_block;
+ u32 pm1a_control_block;
+ u32 pm1b_control_block;
+ u32 pm2_control_block;
+ u32 pm_timer_block;
+ u32 gpe0_block;
+ u32 gpe1_block;
+ u8 pm1_event_length;
+ u8 pm1_control_length;
+ u8 pm2_control_length;
+ u8 pm_timer_length;
+ u8 gpe0_length;
+ u8 gpe1_length;
+ u8 gpe1_base;
+ u8 c_state_control;
+ u16 worst_c2_latency;
+ u16 worst_c3_latency;
+ u16 flush_size;
+ u16 flush_stride;
+ u8 duty_offset;
+ u8 duty_width;
+ u8 day_alarm;
+ u8 month_alarm;
+ u8 century;
+
+ // Used since ACPI 2.0+
+ u16 boot_architecture_flags;
+
+ u8 reserved2;
+ u32 flags;
+ struct generic_address reset_reg;
+ u8 reset_value;
+ u8 reserved3[3];
+
+ // Available on ACPI 2.0+
+ u32 x_firmware_control_high;
+ u32 x_firmware_control_low;
+ u32 x_dsdt_high;
+ u32 x_dsdt_low;
+
+ struct generic_address x_pm1a_event_block;
+ struct generic_address x_pm1b_event_block;
+ struct generic_address x_pm1a_control_block;
+ struct generic_address x_pm1b_control_block;
+ struct generic_address x_pm2_control_block;
+ struct generic_address x_pm_timer_block;
+ struct generic_address x_gpe0_block;
+ struct generic_address x_gpe1_block;
+} PACKED;
+
+/**
+ * HPET
+ */
+
+struct hpet {
+ struct sdt_header header;
+ u8 hardware_rev_id;
+ u8 comparator_count : 5;
+ u8 counter_size : 1;
+ u8 reserved : 1;
+ u8 legacy_replacement : 1;
+ u16 pci_vendor_id;
+ struct generic_address address;
+ u8 hpet_number;
+ u16 minimum_tick;
+ u8 page_protection;
+} PACKED;
+
+void acpi_probe(void);
+
+#endif
diff --git a/src/loader/inc/cfg.h b/src/loader/inc/cfg.h
new file mode 100644
index 0000000..a214db2
--- /dev/null
+++ b/src/loader/inc/cfg.h
@@ -0,0 +1,22 @@
+// MIT License, Copyright (c) 2021 Marvin Borner
+
+#ifndef CFG_H
+#define CFG_H
+
+#include <def.h>
+
+// Global config element index (can actually be anything but wth)
+#define CFG_GLOBAL 0
+
+enum cfg_key {
+ CFG_NONE,
+ CFG_NAME,
+ CFG_TIMEOUT,
+ CFG_PATH,
+};
+
+const void *cfg_get(u8 index, enum cfg_key key);
+void cfg_exec(void);
+void cfg_print(void);
+
+#endif
diff --git a/src/loader/inc/def.h b/src/loader/inc/def.h
index cb41c78..3532bc1 100644
--- a/src/loader/inc/def.h
+++ b/src/loader/inc/def.h
@@ -23,6 +23,7 @@ typedef __builtin_va_list va_list;
#define MAX(a, b) (((a) > (b)) ? (a) : (b))
#define ABS(a) (((a) < 0) ? -(a) : (a))
#define COUNT(a) (sizeof(a) / sizeof 0 [a])
+#define UNUSED(a) ((void)a);
#define PACKED __attribute__((packed))
diff --git a/src/loader/inc/dev.h b/src/loader/inc/dev.h
index 6fcbf25..9d9913e 100644
--- a/src/loader/inc/dev.h
+++ b/src/loader/inc/dev.h
@@ -25,6 +25,7 @@ struct dev {
};
struct dev *dev_get(u8 id);
+void dev_foreach(enum dev_type type, u8 (*cb)(struct dev *)); // cb=1 => break
u8 dev_register(enum dev_type type, char *name, u32 data,
s32 (*read)(void *, u32, u32, struct dev *),
s32 (*write)(const void *, u32, u32, struct dev *));
diff --git a/src/loader/inc/impl/mb1.h b/src/loader/inc/impl/mb1.h
new file mode 100644
index 0000000..fa0efc1
--- /dev/null
+++ b/src/loader/inc/impl/mb1.h
@@ -0,0 +1,13 @@
+// MIT License, Copyright (c) 2021 Marvin Borner
+
+#ifndef MB1_H
+#define MB1_H
+
+#include <def.h>
+#include <dev.h>
+
+#define MB1_MAGIC 0x1badb002
+
+u8 mb1_probe(struct dev *dev);
+
+#endif
diff --git a/src/loader/inc/lib.h b/src/loader/inc/lib.h
index e811670..2f49007 100644
--- a/src/loader/inc/lib.h
+++ b/src/loader/inc/lib.h
@@ -12,7 +12,9 @@ s32 strncmp(const char *s1, const char *s2, u32 n);
void *memcpy(void *dest, const void *src, u32 n);
void *memset(void *dest, u32 val, u32 n);
+s32 memcmp(const void *s1, const void *s2, u32 n);
-int itoa(s32 value, char *buffer, u32 base);
+s32 itoa(s32 value, char *buffer, u32 base);
+s32 atoi(const char *inp);
#endif