summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Gardner <gardner.ben@gmail.com>2016-04-29 12:45:43 -0500
committerPatrick Georgi <pgeorgi@google.com>2016-10-13 18:21:02 +0200
commitd770bad317417bf37fcad1c0698ed54cfe4830ba (patch)
tree67c3a7c03abb24875a70e2ac548f3c206bdb9094
parent1190e9cf42e4534c9335698cda4f642e0c3eec99 (diff)
downloadcoreboot-d770bad317417bf37fcad1c0698ed54cfe4830ba.tar.xz
coreinfo: make the CBFS list scrollable
This enables viewing more than ~20 files in the file list on the left. Arrows are added to indicate that more items are available off-screen. This mimics what was done in pci_module. Change-Id: Idd1363e1abe98ba51c795879db061cc54808da8e Signed-off-by: Ben Gardner <gardner.ben@gmail.com> Reviewed-on: https://review.coreboot.org/14546 Tested-by: build bot (Jenkins) Reviewed-by: Jonathan Neuschäfer <j.neuschaefer@gmx.net> Reviewed-by: Paul Menzel <paulepanter@users.sourceforge.net> Reviewed-by: Martin Roth <martinroth@google.com>
-rw-r--r--payloads/coreinfo/cbfs_module.c33
1 files changed, 27 insertions, 6 deletions
diff --git a/payloads/coreinfo/cbfs_module.c b/payloads/coreinfo/cbfs_module.c
index 6a3d71ef61..4502505a0f 100644
--- a/payloads/coreinfo/cbfs_module.c
+++ b/payloads/coreinfo/cbfs_module.c
@@ -18,6 +18,8 @@
#if IS_ENABLED(CONFIG_MODULE_CBFS)
+#define FILES_VISIBLE 19
+
#define HEADER_MAGIC 0x4F524243
#define HEADER_ADDR 0xfffffffc
#define LARCHIVE_MAGIC 0x455649484352414cLL /* "LARCHIVE" */
@@ -53,7 +55,7 @@ struct cbfile {
char filename[0];
} __attribute__ ((packed));
-static int filecount = 0, selected = 0;
+static int filecount = 0, selected = 0, start_row = 0;
static char **filenames;
static struct cbheader *header = NULL;
@@ -120,7 +122,7 @@ static int cbfs_module_init(void)
static int cbfs_module_redraw(WINDOW * win)
{
struct cbfile *f;
- int i, row = 2;
+ int i, row, frow;
print_module_title(win, "CBFS Listing");
@@ -134,7 +136,11 @@ static int cbfs_module_redraw(WINDOW * win)
mvwaddch(win, i, 30, ACS_VLINE);
/* Draw the names down the left side. */
- for (i = 0; i < filecount; i++) {
+ for (frow = 0; frow < FILES_VISIBLE; frow++) {
+ row = 2 + frow;
+ i = start_row + frow;
+ if (i >= filecount)
+ break;
if (i == selected)
wattrset(win, COLOR_PAIR(3) | A_BOLD);
else
@@ -142,11 +148,20 @@ static int cbfs_module_redraw(WINDOW * win)
if (strlen(filenames[i]) == 0) {
if (findfile(filenames[i])->type == COMPONENT_NULL)
- mvwprintw(win, 2 + i, 1, "<free space>");
+ mvwprintw(win, row, 1, "<free space>");
else
- mvwprintw(win, 2 + i, 1, "<unnamed>");
+ mvwprintw(win, row, 1, "<unnamed>");
} else {
- mvwprintw(win, 2 + i, 1, "%.25s", filenames[i]);
+ mvwprintw(win, row, 1, "%.25s", filenames[i]);
+ }
+ /* show scroll arrows */
+ if (frow == 0 && start_row > 0) {
+ wattrset(win, COLOR_PAIR(2));
+ mvwaddch(win, row, 28, ACS_UARROW);
+ }
+ if (frow == FILES_VISIBLE - 1 && i != filecount - 1) {
+ wattrset(win, COLOR_PAIR(2));
+ mvwaddch(win, row, 28, ACS_DARROW);
}
}
@@ -158,6 +173,8 @@ static int cbfs_module_redraw(WINDOW * win)
wattrset(win, COLOR_PAIR(2));
+ /* Draw the file information */
+ row = 2;
/* mvwprintw(win, row++, 32, "Offset: 0x%x", f->offset); *//* FIXME */
mvwprintw(win, row, 32, "Type: ");
switch (ntohl(f->type)) {
@@ -212,12 +229,16 @@ static int cbfs_module_handle(int key)
case KEY_DOWN:
if (selected + 1 < filecount) {
selected++;
+ if (selected >= start_row + FILES_VISIBLE - 1)
+ start_row = selected - (FILES_VISIBLE - 1);
ret = 1;
}
break;
case KEY_UP:
if (selected > 0) {
selected--;
+ if (selected < start_row)
+ start_row = selected;
ret = 1;
}
break;