Skip to content

Commit 151d7f5

Browse files
committed
multiboot: set up memory information
1 parent f00b6ab commit 151d7f5

File tree

3 files changed

+27
-0
lines changed

3 files changed

+27
-0
lines changed

loader.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,11 @@ loader_main(struct loader_callbacks *cb, void *arg, int version, int ndisks)
128128
goto error;
129129
}
130130

131+
if (multiboot_info_set_meminfo(&mb->info, lowmem, highmem)) {
132+
ERROR(EINVAL, "Could not set up memory information");
133+
goto error;
134+
}
135+
131136
if (multiboot_info_set_cmdline(&mb->info, loader_args.cmdline)) {
132137
ERROR(EINVAL, "Could not set kernel command line");
133138
goto error;

multiboot.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,16 @@
4242

4343
void *entry = NULL;
4444

45+
uint32_t
46+
multiboot_info_set_meminfo(struct multiboot_info* info,
47+
uint32_t mem_lower, uint32_t mem_upper)
48+
{
49+
info->mem_lower = mem_lower;
50+
info->mem_upper = mem_upper;
51+
info->flags |= MULTIBOOT_MEMINFO;
52+
return 0;
53+
}
54+
4555
uint32_t
4656
multiboot_info_set_cmdline(struct multiboot_info* info, const char* cmdline)
4757
{

multiboot.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,18 @@ multiboot_load_elf(void *kernel, size_t kernsz, Elf *kernel_elf);
221221
uint32_t
222222
multiboot_load(void* kernel, size_t kernsz, struct multiboot *mb);
223223

224+
/**
225+
* @brief Set the multiboot info memory information
226+
*
227+
* @param info pointer to the multiboot_info struct
228+
* @param mem_lower the amount of lower memory starting at 0
229+
* @param mem_upper the amount of upper memory starting at 1 MiB
230+
* @return uint32_t 0 on success, error code on failure
231+
*/
232+
uint32_t
233+
multiboot_info_set_meminfo(struct multiboot_info* info,
234+
uint32_t mem_lower, uint32_t mem_upper);
235+
224236
/**
225237
* @brief Set multiboot info command line
226238
*

0 commit comments

Comments
 (0)