Skip to content

Commit

Permalink
multiboot: set up multiboot information structure
Browse files Browse the repository at this point in the history
  • Loading branch information
fabianfreyer committed Feb 20, 2018
1 parent e97fbfa commit d4fb303
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 0 deletions.
4 changes: 4 additions & 0 deletions loader.c
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,10 @@ loader_main(struct loader_callbacks *cb, void *arg, int version, int ndisks)
if (mb->header.mb.header->flags & MULTIBOOT_FLAG_GRAPHICS) {
ERROR(ENOTSUP, "VBE info requested by kernel, but not supported.");
}

if (multiboot_info_finalize(mb)) {
ERROR(ECANCELED, "Could not set up multiboot information structure");
}
}

/* Cleanup. */
Expand Down
23 changes: 23 additions & 0 deletions multiboot.c
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,29 @@ multiboot_info_set_cmdline(struct multiboot_info* info, const char* cmdline)
return error;
}

uint32_t
multiboot_info_finalize(struct multiboot *mb)
{
uint32_t error = 0;

void* p_addr = allocate(sizeof(struct multiboot_info));
if (!p_addr)
return ENOMEM;

error = CALLBACK(copyin, &mb->info, p_addr, sizeof(struct multiboot_info));
if (error)
return error;

/*
* Multiboot specification, section 3.2:
* EBX Must contain the 32-bit physical address of the Multiboot information
* structure provided by the boot loader (see spec, section 3.3).
*/
error = CALLBACK(vm_set_register, 0, VM_REG_GUEST_RBX, p_addr);

return error;
}

struct multiboot*
mb_scan(void *kernel, size_t kernsz)
{
Expand Down
9 changes: 9 additions & 0 deletions multiboot.h
Original file line number Diff line number Diff line change
Expand Up @@ -278,4 +278,13 @@ multiboot_info_set_loader_name(struct multiboot_info* info, const char* name);
*/
uint32_t
multiboot_info_set_cmdline(struct multiboot_info* info, const char* cmdline);

/**
* @brief Copy the multiboot structure into the hypervisor and set up registers
*
* @param mb pointer to the multiboot context
* @return uint32_t 0 on success, error code on failure
*/
uint32_t multiboot_info_finalize(struct multiboot *mb);

/* vim: set noexpandtab ts=4 : */

0 comments on commit d4fb303

Please sign in to comment.