1 /* SPDX-License-Identifier: GPL-2.0-only */
3 #include <multiboot_tables.h>
6 #if CONFIG(MODULE_MULTIBOOT)
8 #define MAX_MEMORY_COUNT 10
17 } range
[MAX_MEMORY_COUNT
];
20 static int tables_good
= 0;
22 static int multiboot_module_redraw(WINDOW
*win
)
27 print_module_title(win
, "Multiboot Tables");
29 if (tables_good
== 0) {
30 mvwprintw(win
, row
++, 1, "No multiboot tables were found");
35 mvwprintw(win
, row
++, 1, "-- Memory Map --");
37 for (i
= 0; i
< cb_info
.mem_count
; i
++) {
39 if (cb_info
.range
[i
].type
== 1)
40 mvwprintw(win
, row
++, 3, " RAM: ");
42 mvwprintw(win
, row
++, 3, "Reserved: ");
44 wprintw(win
, "%16.16llx - %16.16llx",
45 cb_info
.range
[i
].start
,
46 cb_info
.range
[i
].start
+ cb_info
.range
[i
].size
- 1);
52 static void parse_memory(struct multiboot_header
*table
)
54 u8
*start
= (u8
*) phys_to_virt(table
->mmap_addr
);
58 cb_info
.mem_count
= 0;
60 while(ptr
< (start
+ table
->mmap_length
)) {
61 struct multiboot_mmap
*mmap
= (struct multiboot_mmap
*) ptr
;
63 cb_info
.range
[i
].start
= mmap
->addr
;
64 cb_info
.range
[i
].size
= mmap
->length
;
65 cb_info
.range
[i
].type
= mmap
->type
;
67 if (++cb_info
.mem_count
== MAX_MEMORY_COUNT
)
70 ptr
+= (mmap
->size
+ sizeof(mmap
->size
));
75 static void parse_header(unsigned long addr
)
77 struct multiboot_header
*table
= (struct multiboot_header
*) addr
;
79 if (table
->flags
& MULTIBOOT_FLAGS_MMAP
)
83 static int multiboot_module_init(void)
86 tables_good
= sysinfo_have_multiboot(&mbaddr
);
90 return tables_good
? 0 : -1;
93 struct coreinfo_module multiboot_module
= {
95 .init
= multiboot_module_init
,
96 .redraw
= multiboot_module_redraw
,
101 struct coreinfo_module multiboot_module
= {
104 #endif /* CONFIG_MODULE_MULTIBOOT */