2 * This file is part of the coreinfo project.
4 * Copyright (C) 2008 Jordan Crouse <jordan@cosmicpenguin.net>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 2 of the License.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 #include <multiboot_tables.h>
23 #ifdef CONFIG_MODULE_MULTIBOOT
25 #define MAX_MEMORY_COUNT 10
34 } range[MAX_MEMORY_COUNT];
37 static int tables_good = 0;
39 int multiboot_module_redraw(WINDOW *win)
44 print_module_title(win, "Multiboot Tables");
46 if (tables_good == 0) {
47 mvwprintw(win, row++, 1, "No multiboot tables were found");
52 mvwprintw(win, row++, 1, "-- Memory Map --");
54 for (i = 0; i < cb_info.mem_count; i++) {
56 if (cb_info.range[i].type == 1)
57 mvwprintw(win, row++, 3, " RAM: ");
59 mvwprintw(win, row++, 3, "Reserved: ");
61 wprintw(win, "%16.16llx - %16.16llx",
62 cb_info.range[i].start,
63 cb_info.range[i].start + cb_info.range[i].size - 1);
69 static void parse_memory(struct multiboot_header *table)
71 u8 *start = (u8 *) phys_to_virt(table->mmap_addr);
75 cb_info.mem_count = 0;
77 while(ptr < (start + table->mmap_length)) {
78 struct multiboot_mmap *mmap = (struct multiboot_mmap *) ptr;
80 cb_info.range[i].start = mmap->addr;
81 cb_info.range[i].size = mmap->length;
82 cb_info.range[i].type = mmap->type;
84 if (++cb_info.mem_count == MAX_MEMORY_COUNT)
87 ptr += (mmap->size + sizeof(mmap->size));
92 static void parse_header(unsigned long addr)
94 struct multiboot_header *table = (struct multiboot_header *) addr;
96 if (table->flags & MULTIBOOT_FLAGS_MMAP)
100 static int multiboot_module_init(void)
102 unsigned long mbaddr;
103 tables_good = sysinfo_have_multiboot(&mbaddr);
105 parse_header(mbaddr);
107 return tables_good ? 0 : -1;
110 struct coreinfo_module multiboot_module = {
112 .init = multiboot_module_init,
113 .redraw = multiboot_module_redraw,
118 struct coreinfo_module multiboot_module = {