stivale2: Implement boot volume struct tag

This commit is contained in:
mintsuki 2021-11-24 12:24:17 +01:00
parent 5555af6641
commit ad3e17569c
4 changed files with 26 additions and 1 deletions

View File

@ -14,6 +14,7 @@ bool fs_get_guid(struct guid *guid, struct volume *part);
struct file_handle {
bool is_memfile;
bool readall;
struct volume *vol;
void *fd;
void (*read)(void *fd, void *buf, uint64_t loc, uint64_t count);
void (*close)(void *fd);

View File

@ -30,6 +30,8 @@ struct file_handle *fopen(struct volume *part, const char *filename) {
ret->is_memfile = false;
ret->readall = false;
ret->vol = part;
#if bios == 1
if (part->pxe) {
if (!tftp_open(ret, 0, 69, filename)) {

View File

@ -9,7 +9,7 @@ struct guid {
uint16_t b;
uint16_t c;
uint8_t d[8];
} __attribute__((packed));
};
bool is_valid_guid(const char *s);
bool string_to_guid_be(struct guid *guid, const char *s);

View File

@ -107,6 +107,8 @@ void stivale2_load(char *config, char *cmdline) {
size_t kernel_file_size = kernel_file->size;
struct volume *kernel_volume = kernel_file->vol;
fclose(kernel_file);
if (bits == -1) {
@ -238,6 +240,26 @@ failed_to_load_header_section:
strcpy(stivale2_struct.bootloader_brand, "Limine");
strcpy(stivale2_struct.bootloader_version, LIMINE_VERSION);
//////////////////////////////////////////////
// Create boot volume tag
//////////////////////////////////////////////
{
struct stivale2_struct_tag_boot_volume *tag = ext_mem_alloc(sizeof(struct stivale2_struct_tag_boot_volume));
tag->tag.identifier = STIVALE2_STRUCT_TAG_BOOT_VOLUME_ID;
if (kernel_volume->guid_valid) {
tag->flags |= (1 << 0);
memcpy(&tag->guid, &kernel_volume->guid, sizeof(struct stivale2_guid));
}
if (kernel_volume->part_guid_valid) {
tag->flags |= (1 << 1);
memcpy(&tag->part_guid, &kernel_volume->part_guid, sizeof(struct stivale2_guid));
}
append_tag(&stivale2_struct, (struct stivale2_tag *)tag);
}
//////////////////////////////////////////////
// Create kernel file struct tag
//////////////////////////////////////////////