mirror of
https://github.com/Tom-on64/kern.git
synced 2026-11-03 18:22:22 +00:00
Got memory map almost working
This commit is contained in:
+27
-11
@@ -9,25 +9,41 @@
|
||||
#define BOOT_MB2 2 // MultiBoot 2
|
||||
#define BOOT_LIMINE 3 // Limine
|
||||
|
||||
struct boot_memmapEntry {
|
||||
uint64_t base;
|
||||
uint64_t size;
|
||||
uint32_t type;
|
||||
uint32_t attr;
|
||||
};
|
||||
// Memmap region types
|
||||
#define BOOT_MMAP_AVAILABLE 1
|
||||
#define BOOT_MMAP_RESERVED 2
|
||||
#define BOOT_MMAP_ACPI_RECLAIM 3
|
||||
#define BOOT_MMAP_NVS 4
|
||||
#define BOOT_MMAP_BADRAM 5
|
||||
|
||||
// A memory map entry
|
||||
struct boot_memmap {
|
||||
uint32_t skip; // Used for skipping (may be padded for alignment)
|
||||
uint64_t base; // Memory region address
|
||||
uint64_t size; // Memory region length
|
||||
uint32_t type; // Memory region type
|
||||
} __packed;
|
||||
|
||||
/*
|
||||
* Some values may not be provided by the bootloader, in this case
|
||||
* pointers will be NULL and integer values will be 0 if applicable.
|
||||
* Some unprovided values may also be implied. Eg.:
|
||||
* If 'memmap = NULL' then 'memmapLen' doesn't matter.
|
||||
|
||||
*/
|
||||
struct boot_info {
|
||||
uint32_t memLower;
|
||||
uint32_t memUpper;
|
||||
struct boot_memmapEntry* memmap;
|
||||
uint8_t bootDrive;
|
||||
uint8_t bootPart1;
|
||||
uint8_t bootPart2;
|
||||
uint8_t bootPart3;
|
||||
char* cmdline;
|
||||
uint32_t memmap;
|
||||
size_t memmapLen;
|
||||
};
|
||||
char* bootname;
|
||||
} __packed;
|
||||
extern struct boot_info bootloader;
|
||||
|
||||
/*
|
||||
* This functions arguments depend on the boot protocol provided.
|
||||
@@ -36,9 +52,9 @@ struct boot_info {
|
||||
*/
|
||||
int boot_init(int type, ...);
|
||||
|
||||
int boot_init_mb1(void* ptr, uint32_t magic);
|
||||
int boot_initMB1(void* ptr, uint32_t magic);
|
||||
// TODO:
|
||||
// int boot_init_mb2(...);
|
||||
// int boot_init_limine(...);
|
||||
// int boot_initMB2(...);
|
||||
// int boot_initLimine(...);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -7,11 +7,12 @@
|
||||
/*
|
||||
* Variable arguments
|
||||
*/
|
||||
typedef void* va_list;
|
||||
#define __va_align(size) ((size + sizeof(int) - 1) & ~(sizeof(int) - 1))
|
||||
#define va_start(ap, param) (void)((ap) = (char*)(&(param) + 1))
|
||||
#define va_end(ap) (void)((ap) = 0)
|
||||
#define va_arg(ap, type) (*(type*)(((ap) += __va_align(sizeof(type))) - sizeof(type)))
|
||||
typedef char* va_list;
|
||||
#define __VA_ALIGN 4
|
||||
#define __va_align(_t) (((sizeof(_t) + __VA_ALIGN - 1) / __VA_ALIGN) * __VA_ALIGN)
|
||||
#define va_start(_ap, _arg) ((_ap) = (char*)(&(_arg) + 1))
|
||||
#define va_arg(_ap, _type) (*(_type*)((_ap += __va_align(_type)) - __va_align(_type)))
|
||||
#define va_end(_ap) (void)((_ap) = 0)
|
||||
|
||||
/*
|
||||
* Utility macros
|
||||
|
||||
Reference in New Issue
Block a user