2 * This file is part of the coreinfo project.
4 * Copyright (C) 2008 Advanced Micro Devices, Inc.
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
22 #ifdef CONFIG_MODULE_LAR
24 static struct LAR *lar;
25 static int lcount, selected;
27 static const char *compression_table[4] = {"none", "LZMA", "NRV2B", "zeroes"};
29 static int lar_module_init(void)
32 struct larent *larent;
39 while ((larent = readlar(lar)))
42 lnames = malloc(lcount * sizeof(char *));
49 while ((larent = readlar(lar)))
50 lnames[index++] = strdup((const char *) larent->name);
55 static int lar_module_redraw(WINDOW *win)
60 print_module_title(win, "LAR Listing");
63 mvwprintw(win, 11, 61 / 2, "Bad or missing LAR");
67 /* Draw a line down the middle. */
68 for (i = 2; i < 21; i++)
69 mvwaddch(win, i, 30, ACS_VLINE);
71 /* Draw the names down the left side. */
72 for (i = 0; i < lcount; i++) {
74 wattrset(win, COLOR_PAIR(3) | A_BOLD);
76 wattrset(win, COLOR_PAIR(2));
78 mvwprintw(win, 2 + i, 1, "%.25s", lnames[i]);
81 /* Get the information for the LAR. */
82 if (larstat(lar, lnames[selected], &stat)) {
83 printf("larstat failed\n");
87 wattrset(win, COLOR_PAIR(2));
89 mvwprintw(win, row++, 32, "Offset: 0x%x", stat.offset);
91 if (stat.compression) {
92 mvwprintw(win, row++, 32, "Compression: %s",
93 compression_table[stat.compression]);
94 mvwprintw(win, row++, 32, "Compressed length: %d", stat.len);
95 mvwprintw(win, row++, 32, "Compressed checksum: 0x%x",
99 mvwprintw(win, row++, 32, "Length: %d", stat.reallen);
100 mvwprintw(win, row++, 32, "Checksum: 0x%x", stat.checksum);
101 mvwprintw(win, row++, 32, "Load address: 0x%llx", stat.loadaddress);
102 mvwprintw(win, row++, 32, "Entry point: 0x%llx", stat.entry);
107 static int lar_module_handle(int key)
116 if (selected + 1 < lcount) {
132 struct coreinfo_module lar_module = {
134 .init = lar_module_init,
135 .redraw = lar_module_redraw,
136 .handle = lar_module_handle
141 struct coreinfo_module lar_module = {