diff options
author | Marvin Borner | 2021-07-07 19:13:11 +0200 |
---|---|---|
committer | Marvin Borner | 2021-07-07 19:13:11 +0200 |
commit | 9a2d5cbdc7972d1d5bfb1ea93f82f66d113faa17 (patch) | |
tree | 08ceb8427b64a08c89a5526dfbf8b66c78f9d12c /src/loader/inc | |
parent | 6355c3e08c9f4d3db122252abce5837c364d5b81 (diff) |
Strange implementations
Diffstat (limited to 'src/loader/inc')
-rw-r--r-- | src/loader/inc/acpi.h | 2 | ||||
-rw-r--r-- | src/loader/inc/cfg.h | 5 | ||||
-rw-r--r-- | src/loader/inc/def.h | 3 | ||||
-rw-r--r-- | src/loader/inc/dev.h | 2 | ||||
-rw-r--r-- | src/loader/inc/impl.h | 20 | ||||
-rw-r--r-- | src/loader/inc/impl/all.h | 20 | ||||
-rw-r--r-- | src/loader/inc/impl/mb1.h | 126 | ||||
-rw-r--r-- | src/loader/inc/impl/mb2.h | 61 | ||||
-rw-r--r-- | src/loader/inc/pnc.h | 3 |
9 files changed, 219 insertions, 23 deletions
diff --git a/src/loader/inc/acpi.h b/src/loader/inc/acpi.h index f7626e9..f1794b9 100644 --- a/src/loader/inc/acpi.h +++ b/src/loader/inc/acpi.h @@ -40,8 +40,8 @@ struct generic_address { u8 bit_width; u8 bit_offset; u8 access_size; - u32 phys_high; u32 phys_low; + u32 phys_high; }; /** diff --git a/src/loader/inc/cfg.h b/src/loader/inc/cfg.h index 156d561..f3a15ab 100644 --- a/src/loader/inc/cfg.h +++ b/src/loader/inc/cfg.h @@ -4,6 +4,7 @@ #define CFG_H #include <def.h> +#include <impl.h> // Global config element index (can actually be anything but wth) #define CFG_GLOBAL 0 @@ -18,8 +19,10 @@ enum cfg_key { struct cfg_entry { u8 exists : 1; char name[64]; - char path[64]; + char full_path[64]; // With disk name + const char *path; // Without disk name struct dev *dev; + struct impl impl; }; struct cfg { diff --git a/src/loader/inc/def.h b/src/loader/inc/def.h index 3532bc1..a8ee30b 100644 --- a/src/loader/inc/def.h +++ b/src/loader/inc/def.h @@ -25,6 +25,9 @@ typedef __builtin_va_list va_list; #define COUNT(a) (sizeof(a) / sizeof 0 [a]) #define UNUSED(a) ((void)a); +#define STRINGIFY_PARAM(a) #a +#define STRINGIFY(a) STRINGIFY_PARAM(a) + #define PACKED __attribute__((packed)) #endif diff --git a/src/loader/inc/dev.h b/src/loader/inc/dev.h index 9e64bdb..7120a83 100644 --- a/src/loader/inc/dev.h +++ b/src/loader/inc/dev.h @@ -5,7 +5,6 @@ #include <def.h> #include <dsk.h> -#include <impl/all.h> enum dev_type { DEV_DISK, @@ -23,7 +22,6 @@ struct dev { union { struct { struct fs fs; - struct impl impl; } disk; // TODO: Other (framebuffer?) } p; // Prototype union diff --git a/src/loader/inc/impl.h b/src/loader/inc/impl.h new file mode 100644 index 0000000..c7b1261 --- /dev/null +++ b/src/loader/inc/impl.h @@ -0,0 +1,20 @@ +// MIT License, Copyright (c) 2021 Marvin Borner + +#ifndef IMPL_H +#define IMPL_H + +#include <dev.h> + +enum impl_type { + IMPL_NONE, + IMPL_MB1, + IMPL_MB2, +}; + +struct impl { + enum impl_type type; + void *start; // Of header/entry + void (*load)(struct dev *, const char *); +}; + +#endif diff --git a/src/loader/inc/impl/all.h b/src/loader/inc/impl/all.h index f38fe42..01565a6 100644 --- a/src/loader/inc/impl/all.h +++ b/src/loader/inc/impl/all.h @@ -3,24 +3,10 @@ #ifndef IMPL_ALL_H #define IMPL_ALL_H +#include <cfg.h> #include <def.h> -enum impl_type { - IMPL_NONE, - IMPL_MB1, - IMPL_MB2, -}; - -struct dev; -struct impl { - enum impl_type type; - void *start; // Of header/entry - void (*load)(struct dev *, const char *); -}; - -#include <dev.h> - -u8 impl_detect(struct dev *dev, const char *path); -void impl_exec(struct dev *dev, const char *path); +u8 impl_detect(struct cfg_entry *cfg); +void impl_exec(struct cfg_entry *cfg); #endif diff --git a/src/loader/inc/impl/mb1.h b/src/loader/inc/impl/mb1.h index d737cb2..5e68ece 100644 --- a/src/loader/inc/impl/mb1.h +++ b/src/loader/inc/impl/mb1.h @@ -3,10 +3,132 @@ #ifndef IMPL_MB1_H #define IMPL_MB1_H +#include <cfg.h> #include <def.h> #include <dev.h> -u8 mb1_detect(struct dev *dev, const char *path); -void mb1_exec(struct dev *dev, const char *path); +#define MB1_MAGIC 0x1badb002 // Identifies kernel +#define MB1_LOAD_MAGIC 0x2badb002 // Passed to kernel + +#define MB1_INFO_MEMORY 0x00000001 +#define MB1_INFO_BOOTDEV 0x00000002 +#define MB1_INFO_CMDLINE 0x00000004 +#define MB1_INFO_MODS 0x00000008 +#define MB1_INFO_AOUT_SYMS 0x00000010 +#define MB1_INFO_ELF_SHDR 0x00000020 +#define MB1_INFO_MEM_MAP 0x00000040 +#define MB1_INFO_DRIVE_INFO 0x00000080 +#define MB1_INFO_CONFIG_TABLE 0x00000100 +#define MB1_INFO_BOOT_LOADER_NAME 0x00000200 +#define MB1_INFO_APM_TABLE 0x00000400 +#define MB1_INFO_VBE_INFO 0x00000800 +#define MB1_INFO_FRAMEBUFFER_INFO 0x00001000 + +#define MB1_FRAMEBUFFER_TYPE_INDEXED 0 +#define MB1_FRAMEBUFFER_TYPE_RGB 1 +#define MB1_FRAMEBUFFER_TYPE_EGA_TEXT 2 + +#define MB1_MEMORY_AVAILABLE 1 +#define MB1_MEMORY_RESERVED 2 +#define MB1_MEMORY_ACPI_RECLAIMABLE 3 +#define MB1_MEMORY_NVS 4 +#define MB1_MEMORY_BADRAM 5 + +#include <def.h> + +struct mb1_aout_symbol_table { + u32 tabsize; + u32 strsize; + u32 addr; + u32 reserved; +}; + +struct mb1_elf_section_header_table { + u32 num; + u32 size; + u32 addr; + u32 shndx; +}; + +struct mb1_info { + u32 flags; + + u32 mem_lower; + u32 mem_upper; + + u32 boot_device; + + u32 cmdline; + + u32 mods_count; + u32 mods_addr; + + union { + struct mb1_aout_symbol_table aout_sym; + struct mb1_elf_section_header_table elf_sec; + } u; + + u32 mmap_length; + u32 mmap_addr; + + u32 drives_length; + u32 drives_addr; + + u32 config_table; + + u32 boot_loader_name; + + u32 apm_table; + + u32 vbe_control_info; + u32 vbe_mode_info; + u16 vbe_mode; + u16 vbe_interface_seg; + u16 vbe_interface_off; + u16 vbe_interface_len; + + u32 framebuffer_addr_high; + u32 framebuffer_addr_low; + u32 framebuffer_pitch; + u32 framebuffer_width; + u32 framebuffer_height; + u8 framebuffer_bpp; + u8 framebuffer_type; + union { + struct { + u32 framebuffer_palette_addr; + u16 framebuffer_palette_num_colors; + } palette; + struct { + u8 framebuffer_red_field_position; + u8 framebuffer_red_mask_size; + u8 framebuffer_green_field_position; + u8 framebuffer_green_mask_size; + u8 framebuffer_blue_field_position; + u8 framebuffer_blue_mask_size; + } colors; + } framebuffer_colors; +} PACKED; + +struct mb1_mmap_entry { + u32 struct_size; + u32 addr_low; + u32 addr_high; + u32 len_low; + u32 len_high; + u32 type; +} PACKED; + +struct mb1_mod_list { + u32 mod_start; + u32 mod_end; + + u32 cmdline; + + u32 pad; +}; + +u8 mb1_detect(struct cfg_entry *cfg); +void mb1_exec(struct cfg_entry *cfg); #endif diff --git a/src/loader/inc/impl/mb2.h b/src/loader/inc/impl/mb2.h new file mode 100644 index 0000000..3f64dbd --- /dev/null +++ b/src/loader/inc/impl/mb2.h @@ -0,0 +1,61 @@ +// MIT License, Copyright (c) 2021 Marvin Borner + +#ifndef IMPL_MB2_H +#define IMPL_MB2_H + +#include <cfg.h> +#include <def.h> +#include <dev.h> + +#define MB2_MAGIC 0xe85250d6 // Identifies kernel +#define MB2_LOAD_MAGIC 0x36d76289 // Passed to kernel + +struct mb2_header { + u32 total_size; + u32 unknown; +} PACKED; + +struct mb2_tag { + u32 type; + u32 size; +} PACKED; + +struct mb2_memory { + u32 addr_low; + u32 addr_high; + u32 size_low; + u32 size_high; + u32 type; + u32 reserved; +} PACKED; + +struct mb2_module { + u32 start; + u32 end; + char string[1]; +} PACKED; + +struct mb2_fb { + u32 addr_low; + u32 addr_high; + u32 pitch; + u32 width; + u32 height; + u8 bpp; + u8 type; +} PACKED; + +enum mb2_tags { + MB2_TAG_END = 0, + MB2_TAG_CMDLINE = 1, + MB2_TAG_MODULE = 3, + MB2_TAG_MEMORY = 6, + MB2_TAG_FB = 8, + MB2_TAG_ACPI_1 = 14, + MB2_TAG_ACPI_2 = 15, +}; + +u8 mb2_detect(struct cfg_entry *cfg); +void mb2_exec(struct cfg_entry *cfg); + +#endif diff --git a/src/loader/inc/pnc.h b/src/loader/inc/pnc.h index 1630bd9..73819c9 100644 --- a/src/loader/inc/pnc.h +++ b/src/loader/inc/pnc.h @@ -18,4 +18,7 @@ panic("Assertion '" #exp "' failed\n"); \ } +// This shouldn't return, therefore this declaration belongs here (kinda) +void jmp_kernel(void *kernel, int args, ...); + #endif |