1#ifndef __CONFIG_H
2#define __CONFIG_H
3
4#include <multiboot2.h>
5#include <stdint.h>
6
7/* The default inital stack size for the CPU driver, if it's not specified in
8 * the configuration file. */
9#define DEFAULT_STACK_SIZE 16384
10
11struct component_config {
12    /* The offset and length of the image path, and argument strings for this
13     * component. */
14    size_t path_start, path_len;
15    size_t args_start, args_len;
16
17    /* The size and target address of the ELF image. */
18    size_t image_size, alloc_size;
19    uint64_t image_address;
20
21    /* A pointer to the module tag in the multiboot info image. */
22    struct multiboot_tag_module_64 *tag;
23
24    /* A pointer to the loaded image. */
25    void *image;
26
27    struct component_config *next;
28};
29
30struct config {
31    /* The raw configuration file. */
32    char *buf;
33
34    /* The multiboot information structure. */
35    void *multiboot;
36    size_t multiboot_size, multiboot_alloc;
37
38    /* Pointers (within the multiboot structure), to the memory map that needs
39     * to be filled in after all allocation is finished. */
40    struct multiboot_tag_efi_mmap *mmap_tag;
41    void *mmap_start;
42
43    /* The CPU driver load information. */
44    struct component_config *kernel;
45    uint64_t kernel_entry;
46    uint64_t kernel_stack;
47    uint64_t stack_size;
48
49    /* The additional modules. */
50    struct component_config *first_module, *last_module;
51};
52
53struct config *parse_config(char *buf, size_t size);
54
55#endif /* __CONFIG_H */
56