Skip to content

Commit b2451ba

Browse files
committed
multiboot: set bootloader name
1 parent 151d7f5 commit b2451ba

File tree

4 files changed

+33
-0
lines changed

4 files changed

+33
-0
lines changed

loader.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,11 @@ loader_main(struct loader_callbacks *cb, void *arg, int version, int ndisks)
137137
ERROR(EINVAL, "Could not set kernel command line");
138138
goto error;
139139
}
140+
141+
if (multiboot_info_set_loader_name(&mb->info, BOOTLOADER_NAME)) {
142+
ERROR(EINVAL, "Could not set bootloader name");
143+
goto error;
144+
}
140145
}
141146

142147
/* Cleanup. */

loader.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@
3434
#define USERBOOT_VERSION 4
3535
#define MALLOCSZ (64*1024*1024)
3636

37+
#define BOOTLOADER_NAME "bhyve-multiboot.so"
38+
3739
enum LOAD_TYPE {
3840
LOAD_ELF = 1,
3941
LOAD_AOUT = 2,

multiboot.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,22 @@ multiboot_info_set_meminfo(struct multiboot_info* info,
5252
return 0;
5353
}
5454

55+
uint32_t
56+
multiboot_info_set_loader_name(struct multiboot_info* info, const char* name)
57+
{
58+
uint32_t error = 0;
59+
size_t length = strlen(name);
60+
void* p_addr = allocate(length+1);
61+
62+
if (!p_addr)
63+
return ENOMEM;
64+
65+
error = CALLBACK(copyin, name, p_addr, length+1);
66+
info->boot_loader_name = p_addr;
67+
info->flags |= MULTIBOOT_BOOTLOADER_NAME;
68+
return error;
69+
}
70+
5571
uint32_t
5672
multiboot_info_set_cmdline(struct multiboot_info* info, const char* cmdline)
5773
{

multiboot.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,16 @@ uint32_t
233233
multiboot_info_set_meminfo(struct multiboot_info* info,
234234
uint32_t mem_lower, uint32_t mem_upper);
235235

236+
/**
237+
* @brief Set multiboot info bootloader name
238+
*
239+
* @param info pointer to the multiboot_info struct
240+
* @param name bootloader name to set
241+
* @return uint32_t 0 on success, error code on failure
242+
*/
243+
uint32_t
244+
multiboot_info_set_loader_name(struct multiboot_info* info, const char* name);
245+
236246
/**
237247
* @brief Set multiboot info command line
238248
*

0 commit comments

Comments
 (0)