coreinfo: Add a module for browsing the boot LAR
Signed-off-by: Jordan Crouse <jordan.crouse@amd.com> Acked-by: Peter Stuge <peter@stuge.se> git-svn-id: svn://svn.coreboot.org/coreboot/trunk@3289 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1
This commit is contained in:
parent
681ec27e2c
commit
aa6e378c4e
@ -68,5 +68,9 @@ config MODULE_BOOTLOG
|
|||||||
bool "Enable the coreboot bootlog module"
|
bool "Enable the coreboot bootlog module"
|
||||||
default y
|
default y
|
||||||
|
|
||||||
|
config MODULE_LAR
|
||||||
|
bool "Enable the coreboot LAR module"
|
||||||
|
default y
|
||||||
|
|
||||||
endmenu
|
endmenu
|
||||||
|
|
||||||
|
@ -51,7 +51,7 @@ AS = $(LIBPAYLOAD_DIR)/bin/lpas
|
|||||||
INCLUDES = -Ibuild
|
INCLUDES = -Ibuild
|
||||||
CFLAGS := -Wall -Werror -Os $(INCLUDES)
|
CFLAGS := -Wall -Werror -Os $(INCLUDES)
|
||||||
OBJECTS = cpuinfo_module.o cpuid.S.o pci_module.o coreboot_module.o \
|
OBJECTS = cpuinfo_module.o cpuid.S.o pci_module.o coreboot_module.o \
|
||||||
nvram_module.o bootlog_module.o coreinfo.o
|
nvram_module.o bootlog_module.o lar_module.o coreinfo.o
|
||||||
OBJS = $(patsubst %,$(obj)/%,$(OBJECTS))
|
OBJS = $(patsubst %,$(obj)/%,$(OBJECTS))
|
||||||
TARGET = $(obj)/coreinfo.elf
|
TARGET = $(obj)/coreinfo.elf
|
||||||
|
|
||||||
|
@ -27,6 +27,7 @@ extern struct coreinfo_module pci_module;
|
|||||||
extern struct coreinfo_module coreboot_module;
|
extern struct coreinfo_module coreboot_module;
|
||||||
extern struct coreinfo_module nvram_module;
|
extern struct coreinfo_module nvram_module;
|
||||||
extern struct coreinfo_module bootlog_module;
|
extern struct coreinfo_module bootlog_module;
|
||||||
|
extern struct coreinfo_module lar_module;
|
||||||
|
|
||||||
struct coreinfo_module *system_modules[] = {
|
struct coreinfo_module *system_modules[] = {
|
||||||
#ifdef CONFIG_MODULE_CPUINFO
|
#ifdef CONFIG_MODULE_CPUINFO
|
||||||
@ -47,6 +48,9 @@ struct coreinfo_module *coreboot_modules[] = {
|
|||||||
#ifdef CONFIG_MODULE_BOOTLOG
|
#ifdef CONFIG_MODULE_BOOTLOG
|
||||||
&bootlog_module,
|
&bootlog_module,
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef CONFIG_MODULE_LAR
|
||||||
|
&lar_module
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
struct coreinfo_cat {
|
struct coreinfo_cat {
|
||||||
@ -90,7 +94,7 @@ static void print_submenu(struct coreinfo_cat *cat)
|
|||||||
char menu[80];
|
char menu[80];
|
||||||
char *ptr = menu;
|
char *ptr = menu;
|
||||||
|
|
||||||
wmove(stdscr, 22, 0);
|
wmove(stdscr, SCREEN_Y - 2, 0);
|
||||||
|
|
||||||
for (j = 0; j < SCREEN_X; j++)
|
for (j = 0; j < SCREEN_X; j++)
|
||||||
waddch(stdscr, ' ');
|
waddch(stdscr, ' ');
|
||||||
@ -101,7 +105,7 @@ static void print_submenu(struct coreinfo_cat *cat)
|
|||||||
for (i = 0; i < cat->count; i++)
|
for (i = 0; i < cat->count; i++)
|
||||||
ptr += sprintf(ptr, "[%c: %s] ", 'A' + i, cat->modules[i]->name);
|
ptr += sprintf(ptr, "[%c: %s] ", 'A' + i, cat->modules[i]->name);
|
||||||
|
|
||||||
mvprintw(22, 0, menu);
|
mvprintw(SCREEN_Y - 2, 0, menu);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_SHOW_DATE_TIME
|
#ifdef CONFIG_SHOW_DATE_TIME
|
||||||
@ -126,7 +130,7 @@ static void print_menu(void)
|
|||||||
char menu[80];
|
char menu[80];
|
||||||
char *ptr = menu;
|
char *ptr = menu;
|
||||||
|
|
||||||
wmove(stdscr, 23, 0);
|
wmove(stdscr, SCREEN_Y - 1, 0);
|
||||||
|
|
||||||
for (j = 0; j < SCREEN_X; j++)
|
for (j = 0; j < SCREEN_X; j++)
|
||||||
waddch(stdscr, ' ');
|
waddch(stdscr, ' ');
|
||||||
@ -267,12 +271,12 @@ int main(void)
|
|||||||
init_pair(2, COLOR_BLACK, COLOR_WHITE);
|
init_pair(2, COLOR_BLACK, COLOR_WHITE);
|
||||||
init_pair(3, COLOR_WHITE, COLOR_WHITE);
|
init_pair(3, COLOR_WHITE, COLOR_WHITE);
|
||||||
|
|
||||||
modwin = newwin(22, 80, 1, 0);
|
modwin = newwin(SCREEN_Y-2, SCREEN_X, 1, 0);
|
||||||
|
|
||||||
wattrset(stdscr, COLOR_PAIR(1) | A_BOLD);
|
wattrset(stdscr, COLOR_PAIR(1) | A_BOLD);
|
||||||
wattrset(modwin, COLOR_PAIR(2));
|
wattrset(modwin, COLOR_PAIR(2));
|
||||||
|
|
||||||
for (i = 0; i < 23; i++) {
|
for (i = 0; i < SCREEN_Y - 1; i++) {
|
||||||
wmove(modwin, i - 1, 0);
|
wmove(modwin, i - 1, 0);
|
||||||
|
|
||||||
for (j = 0; j < SCREEN_X; j++)
|
for (j = 0; j < SCREEN_X; j++)
|
||||||
|
163
payloads/coreinfo/lar_module.c
Normal file
163
payloads/coreinfo/lar_module.c
Normal file
@ -0,0 +1,163 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of the coreinfo project.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2008 Advanced Micro Devices, Inc.
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; version 2 of the License.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "coreinfo.h"
|
||||||
|
|
||||||
|
#ifdef CONFIG_MODULE_LAR
|
||||||
|
|
||||||
|
static struct LAR *lar;
|
||||||
|
static int lcount;
|
||||||
|
static char **lnames;
|
||||||
|
|
||||||
|
static int lar_module_init(void)
|
||||||
|
{
|
||||||
|
int index = 0;
|
||||||
|
struct larent *larent;
|
||||||
|
|
||||||
|
lar = openlar(NULL);
|
||||||
|
|
||||||
|
if (lar == NULL)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
while((larent = readlar(lar)))
|
||||||
|
lcount++;
|
||||||
|
|
||||||
|
lnames = malloc(lcount * sizeof(char *));
|
||||||
|
|
||||||
|
if (lnames == NULL)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
rewindlar(lar);
|
||||||
|
|
||||||
|
while((larent = readlar(lar)))
|
||||||
|
lnames[index++] = strdup((const char *) larent->name);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int selected;
|
||||||
|
|
||||||
|
static int lar_module_redraw(WINDOW *win)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
int row = 2;
|
||||||
|
struct larstat stat;
|
||||||
|
|
||||||
|
print_module_title(win, "LAR Listing");
|
||||||
|
|
||||||
|
if (lar == 0) {
|
||||||
|
mvwprintw(win, 11, 61/2, "Bad or missing LAR");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Draw a line down the middle */
|
||||||
|
|
||||||
|
for(i = 2; i < 20; i++) {
|
||||||
|
wmove(win, i, 30);
|
||||||
|
waddch(win, '\263');
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Draw the names down the left side */
|
||||||
|
|
||||||
|
for(i = 0; i < lcount; i++) {
|
||||||
|
if (i == selected)
|
||||||
|
wattrset(win, COLOR_PAIR(3) | A_BOLD);
|
||||||
|
else
|
||||||
|
wattrset(win, COLOR_PAIR(2));
|
||||||
|
|
||||||
|
mvwprintw(win, 2 + i, 1, "%.25s", lnames[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Get the information for the LAR */
|
||||||
|
|
||||||
|
if (larstat(lar, lnames[selected], &stat)) {
|
||||||
|
printf("larstat failed\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
wattrset(win, COLOR_PAIR(2));
|
||||||
|
|
||||||
|
mvwprintw(win, row++, 32, "Offset: 0x%x", stat.offset);
|
||||||
|
|
||||||
|
if (stat.compression) {
|
||||||
|
switch(stat.compression) {
|
||||||
|
case ALGO_LZMA:
|
||||||
|
mvwprintw(win, row++, 32, "Compression: LZMA");
|
||||||
|
break;
|
||||||
|
case ALGO_NRV2B:
|
||||||
|
mvwprintw(win, row++, 32, "Compression: NRV2B");
|
||||||
|
break;
|
||||||
|
case ALGO_ZEROES:
|
||||||
|
mvwprintw(win, row++, 32, "Compression: zeroes");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
mvwprintw(win, row++, 32, "Compressed length: %d", stat.len);
|
||||||
|
mvwprintw(win, row++, 32, "Compressed checksum: 0x%x", stat.compchecksum);
|
||||||
|
}
|
||||||
|
|
||||||
|
mvwprintw(win, row++, 32, "Length: %d", stat.reallen);
|
||||||
|
mvwprintw(win, row++, 32, "Checksum: 0x%x", stat.checksum);
|
||||||
|
mvwprintw(win, row++, 32, "Load Address: 0x%llx", stat.loadaddress);
|
||||||
|
mvwprintw(win, row++, 32, "Entry Point: 0x%llx", stat.entry);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int lar_module_handle(int key)
|
||||||
|
{
|
||||||
|
int ret = 0;
|
||||||
|
|
||||||
|
if (lar == NULL)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
switch (key) {
|
||||||
|
case KEY_DOWN:
|
||||||
|
if (selected + 1 < lcount) {
|
||||||
|
selected++;
|
||||||
|
ret = 1;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case KEY_UP:
|
||||||
|
if (selected > 0) {
|
||||||
|
selected--;
|
||||||
|
ret = 1;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct coreinfo_module lar_module = {
|
||||||
|
.name = "LAR",
|
||||||
|
.init = lar_module_init,
|
||||||
|
.redraw = lar_module_redraw,
|
||||||
|
.handle = lar_module_handle
|
||||||
|
};
|
||||||
|
#else
|
||||||
|
|
||||||
|
struct coreinfo_module lar_module = {
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user