Cosmetic changes and coding style fixes by running 'indent', with some
manual fixups afterwards (trivial). No functionality changes, compile-tested. Signed-off-by: Uwe Hermann <uwe@hermann-uwe.de> Acked-by: Uwe Hermann <uwe@hermann-uwe.de> git-svn-id: svn://svn.coreboot.org/coreboot/trunk@3174 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1
This commit is contained in:
parent
7249f79792
commit
3a406feb17
|
@ -17,14 +17,14 @@
|
||||||
## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
##
|
##
|
||||||
|
|
||||||
CC=gcc
|
CC = gcc
|
||||||
CROSS_CFLAGS = -m32
|
CROSS_CFLAGS = -m32
|
||||||
|
|
||||||
INCLUDES = -I../libpayload/include
|
INCLUDES = -I../libpayload/include
|
||||||
INCLUDES += -I$(shell $(CC) $(CROSS_CFLAGS) -print-search-dirs | head -n 1 | cut -d' ' -f2)include
|
INCLUDES += -I$(shell $(CC) $(CROSS_CFLAGS) -print-search-dirs | head -n 1 | cut -d' ' -f2)include
|
||||||
|
|
||||||
LIBPAYLOAD=../libpayload/libpayload.a
|
LIBPAYLOAD = ../libpayload/libpayload.a
|
||||||
LIBGCC:=$(shell $(CC) $(CROSS_CFLAGS) -print-libgcc-file-name)
|
LIBGCC := $(shell $(CC) $(CROSS_CFLAGS) -print-libgcc-file-name)
|
||||||
CFLAGS := -Werror -fno-stack-protector -nostdinc $(INCLUDES)
|
CFLAGS := -Werror -fno-stack-protector -nostdinc $(INCLUDES)
|
||||||
|
|
||||||
MODULES = cpuinfo_module.o cpuid.o pci_module.o coreboot_module.o
|
MODULES = cpuinfo_module.o cpuid.o pci_module.o coreboot_module.o
|
||||||
|
@ -34,12 +34,12 @@ TARGET = coreinfo.elf
|
||||||
all: $(TARGET)
|
all: $(TARGET)
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
@ rm -f $(TARGET) $(MODULES) $(OBJECTS)
|
@rm -f $(TARGET) $(MODULES) $(OBJECTS)
|
||||||
|
|
||||||
$(TARGET): $(OBJECTS) $(MODULES)
|
$(TARGET): $(OBJECTS) $(MODULES)
|
||||||
#ld --verbose -T ../libpayload/libpayload.ldscript -o $@ $(OBJECTS) --whole-archive $(LIBPAYLOAD) --no-whole-archive $(LIBGCC)
|
@#ld --verbose -T ../libpayload/libpayload.ldscript -o $@ $(OBJECTS) --whole-archive $(LIBPAYLOAD) --no-whole-archive $(LIBGCC)
|
||||||
ld -T ../libpayload/libpayload.ldscript -o $@ $(OBJECTS) $(MODULES) ../libpayload/i386/head.o $(LIBPAYLOAD) $(LIBGCC)
|
ld -T ../libpayload/libpayload.ldscript -o $@ $(OBJECTS) $(MODULES) ../libpayload/i386/head.o $(LIBPAYLOAD) $(LIBGCC)
|
||||||
@ strip $@
|
@strip $@
|
||||||
|
|
||||||
.S.o:
|
.S.o:
|
||||||
$(AS) --32 -o $@ $<
|
$(AS) --32 -o $@ $<
|
||||||
|
|
|
@ -72,7 +72,7 @@ int coreboot_module_redraw(WINDOW *win)
|
||||||
if (cb_info.console.tag != 0x0) {
|
if (cb_info.console.tag != 0x0) {
|
||||||
mvwprintw(win, row++, 2, "Default Output Console: ");
|
mvwprintw(win, row++, 2, "Default Output Console: ");
|
||||||
|
|
||||||
switch(cb_info.console.type) {
|
switch (cb_info.console.type) {
|
||||||
case CB_TAG_CONSOLE_SERIAL8250:
|
case CB_TAG_CONSOLE_SERIAL8250:
|
||||||
wprintw(win, "Serial Port");
|
wprintw(win, "Serial Port");
|
||||||
break;
|
break;
|
||||||
|
@ -97,17 +97,14 @@ int coreboot_module_redraw(WINDOW *win)
|
||||||
row++;
|
row++;
|
||||||
mvwprintw(win, row++, 2, "-- Memory Map --");
|
mvwprintw(win, row++, 2, "-- Memory Map --");
|
||||||
|
|
||||||
for(i = 0; i < cb_info.mem_count; i++) {
|
for (i = 0; i < cb_info.mem_count; i++) {
|
||||||
|
switch (cb_info.range[i].type) {
|
||||||
switch(cb_info.range[i].type) {
|
|
||||||
case CB_MEM_RAM:
|
case CB_MEM_RAM:
|
||||||
mvwprintw(win, row++, 4, " RAM: ");
|
mvwprintw(win, row++, 4, " RAM: ");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CB_MEM_RESERVED:
|
case CB_MEM_RESERVED:
|
||||||
mvwprintw(win, row++, 4, "Reserved: ");
|
mvwprintw(win, row++, 4, "Reserved: ");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CB_MEM_TABLE:
|
case CB_MEM_TABLE:
|
||||||
mvwprintw(win, row++, 4, " Table: ");
|
mvwprintw(win, row++, 4, " Table: ");
|
||||||
}
|
}
|
||||||
|
@ -121,15 +118,15 @@ int coreboot_module_redraw(WINDOW *win)
|
||||||
|
|
||||||
static void parse_memory(unsigned char *ptr)
|
static void parse_memory(unsigned char *ptr)
|
||||||
{
|
{
|
||||||
struct cb_memory *mem = (struct cb_memory *) ptr;
|
struct cb_memory *mem = (struct cb_memory *)ptr;
|
||||||
|
|
||||||
int max = (MEM_RANGE_COUNT(mem) > MAX_MEMORY_COUNT)
|
int max = (MEM_RANGE_COUNT(mem) > MAX_MEMORY_COUNT)
|
||||||
? MAX_MEMORY_COUNT : MEM_RANGE_COUNT(mem);
|
? MAX_MEMORY_COUNT : MEM_RANGE_COUNT(mem);
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for(i = 0; i < max; i++) {
|
for (i = 0; i < max; i++) {
|
||||||
struct cb_memory_range *range =
|
struct cb_memory_range *range =
|
||||||
(struct cb_memory_range *) MEM_RANGE_PTR(mem, i);
|
(struct cb_memory_range *)MEM_RANGE_PTR(mem, i);
|
||||||
|
|
||||||
memcpy(&cb_info.range[i], range, sizeof(*range));
|
memcpy(&cb_info.range[i], range, sizeof(*range));
|
||||||
}
|
}
|
||||||
|
@ -140,7 +137,7 @@ static void parse_memory(unsigned char *ptr)
|
||||||
|
|
||||||
static void parse_mainboard(unsigned char *ptr)
|
static void parse_mainboard(unsigned char *ptr)
|
||||||
{
|
{
|
||||||
struct cb_mainboard *mb = (struct cb_mainboard *) ptr;
|
struct cb_mainboard *mb = (struct cb_mainboard *)ptr;
|
||||||
|
|
||||||
strncpy(cb_info.vendor, MB_VENDOR_STRING(mb), 31);
|
strncpy(cb_info.vendor, MB_VENDOR_STRING(mb), 31);
|
||||||
strncpy(cb_info.part, MB_PART_STRING(mb), 31);
|
strncpy(cb_info.part, MB_PART_STRING(mb), 31);
|
||||||
|
@ -148,7 +145,7 @@ static void parse_mainboard(unsigned char *ptr)
|
||||||
|
|
||||||
static void parse_strings(unsigned char *ptr)
|
static void parse_strings(unsigned char *ptr)
|
||||||
{
|
{
|
||||||
struct cb_string *string = (struct cb_string *) ptr;
|
struct cb_string *string = (struct cb_string *)ptr;
|
||||||
int index = string->tag - CB_TAG_VERSION;
|
int index = string->tag - CB_TAG_VERSION;
|
||||||
|
|
||||||
strncpy(cb_info.strings[index], string->string, 63);
|
strncpy(cb_info.strings[index], string->string, 63);
|
||||||
|
@ -157,60 +154,58 @@ static void parse_strings(unsigned char *ptr)
|
||||||
|
|
||||||
static void parse_serial(unsigned char *ptr)
|
static void parse_serial(unsigned char *ptr)
|
||||||
{
|
{
|
||||||
memcpy(&cb_info.serial, (struct cb_serial *) ptr,
|
memcpy(&cb_info.serial, (struct cb_serial *)ptr,
|
||||||
sizeof(struct cb_serial));
|
sizeof(struct cb_serial));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void parse_console(unsigned char *ptr)
|
static void parse_console(unsigned char *ptr)
|
||||||
{
|
{
|
||||||
memcpy(&cb_info.console, (struct cb_console *) ptr,
|
memcpy(&cb_info.console, (struct cb_console *)ptr,
|
||||||
sizeof(struct cb_console));
|
sizeof(struct cb_console));
|
||||||
}
|
}
|
||||||
|
|
||||||
static int parse_header(void *addr, int len)
|
static int parse_header(void *addr, int len)
|
||||||
{
|
{
|
||||||
struct cb_header *header;
|
struct cb_header *header;
|
||||||
unsigned char *ptr = (unsigned char *) addr;
|
unsigned char *ptr = (unsigned char *)addr;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < len; i += 16, ptr += 16) {
|
for (i = 0; i < len; i += 16, ptr += 16) {
|
||||||
header = (struct cb_header *) ptr;
|
header = (struct cb_header *)ptr;
|
||||||
|
|
||||||
if (!strncmp(header->signature, "LBIO", 4))
|
if (!strncmp(header->signature, "LBIO", 4))
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* We walked the entire space and didn't find anything */
|
/* We walked the entire space and didn't find anything. */
|
||||||
if (i >= len)
|
if (i >= len)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (!header->table_bytes)
|
if (!header->table_bytes)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
/* FIXME: Check the checksum */
|
/* FIXME: Check the checksum. */
|
||||||
|
|
||||||
if (ipchksum((uint16_t *) header, sizeof(*header)))
|
if (ipchksum((uint16_t *) header, sizeof(*header)))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (ipchksum((uint16_t *) (ptr + sizeof(*header)), header->table_bytes) !=
|
if (ipchksum((uint16_t *) (ptr + sizeof(*header)), header->table_bytes)
|
||||||
header->table_checksum)
|
!= header->table_checksum)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
/* Now, walk the tables */
|
/* Now, walk the tables. */
|
||||||
ptr += header->header_bytes;
|
ptr += header->header_bytes;
|
||||||
|
|
||||||
for(i = 0; i < header->table_entries; i++) {
|
for (i = 0; i < header->table_entries; i++) {
|
||||||
struct cb_record *rec = (struct cb_record *) ptr;
|
struct cb_record *rec = (struct cb_record *)ptr;
|
||||||
|
|
||||||
switch(rec->tag) {
|
switch (rec->tag) {
|
||||||
case CB_TAG_MEMORY:
|
case CB_TAG_MEMORY:
|
||||||
parse_memory(ptr);
|
parse_memory(ptr);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CB_TAG_MAINBOARD:
|
case CB_TAG_MAINBOARD:
|
||||||
parse_mainboard(ptr);
|
parse_mainboard(ptr);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CB_TAG_VERSION:
|
case CB_TAG_VERSION:
|
||||||
case CB_TAG_EXTRA_VERSION:
|
case CB_TAG_EXTRA_VERSION:
|
||||||
case CB_TAG_BUILD:
|
case CB_TAG_BUILD:
|
||||||
|
@ -223,15 +218,12 @@ static int parse_header(void *addr, int len)
|
||||||
case CB_TAG_ASSEMBLER:
|
case CB_TAG_ASSEMBLER:
|
||||||
parse_strings(ptr);
|
parse_strings(ptr);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CB_TAG_SERIAL:
|
case CB_TAG_SERIAL:
|
||||||
parse_serial(ptr);
|
parse_serial(ptr);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CB_TAG_CONSOLE:
|
case CB_TAG_CONSOLE:
|
||||||
parse_console(ptr);
|
parse_console(ptr);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -244,19 +236,16 @@ static int parse_header(void *addr, int len)
|
||||||
|
|
||||||
int coreboot_module_init(void)
|
int coreboot_module_init(void)
|
||||||
{
|
{
|
||||||
int ret = parse_header((void *) 0x00000, 0x1000);
|
int ret = parse_header((void *)0x00000, 0x1000);
|
||||||
|
|
||||||
if (ret != 1)
|
if (ret != 1)
|
||||||
ret = parse_header((void *) 0xf0000, 0x1000);
|
ret = parse_header((void *)0xf0000, 0x1000);
|
||||||
|
|
||||||
/* return error if we couldn't find it at either address */
|
|
||||||
|
|
||||||
|
/* Return error if we couldn't find it at either address. */
|
||||||
tables_good = (ret == 1) ? 0 : -1;
|
tables_good = (ret == 1) ? 0 : -1;
|
||||||
return tables_good;
|
return tables_good;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
struct coreinfo_module coreboot_module = {
|
struct coreinfo_module coreboot_module = {
|
||||||
.name = "Coreboot",
|
.name = "Coreboot",
|
||||||
.init = coreboot_module_init,
|
.init = coreboot_module_init,
|
||||||
|
|
|
@ -46,22 +46,22 @@ void print_module_title(WINDOW *win, const char *title)
|
||||||
|
|
||||||
wmove(win, 1, 1);
|
wmove(win, 1, 1);
|
||||||
|
|
||||||
for(i = 0; i < 78; i++)
|
for (i = 0; i < 78; i++)
|
||||||
waddch(win, '\304');
|
waddch(win, '\304');
|
||||||
}
|
}
|
||||||
|
|
||||||
void print_menu(void) {
|
void print_menu(void)
|
||||||
int i, len;
|
{
|
||||||
|
int i, j, len;
|
||||||
char menu[80];
|
char menu[80];
|
||||||
char *ptr = menu;
|
char *ptr = menu;
|
||||||
int j;
|
|
||||||
|
|
||||||
wmove(stdscr, 23, 0);
|
wmove(stdscr, 23, 0);
|
||||||
|
|
||||||
for(j = 0; j < SCREEN_X; j++)
|
for (j = 0; j < SCREEN_X; j++)
|
||||||
waddch(stdscr, ' ');
|
waddch(stdscr, ' ');
|
||||||
|
|
||||||
for(i = 0; i < MODULE_COUNT; i++)
|
for (i = 0; i < MODULE_COUNT; i++)
|
||||||
ptr += sprintf(ptr, "F%d: %s ", i + 1, modules[i]->name);
|
ptr += sprintf(ptr, "F%d: %s ", i + 1, modules[i]->name);
|
||||||
|
|
||||||
mvprintw(23, 0, menu);
|
mvprintw(23, 0, menu);
|
||||||
|
@ -74,7 +74,7 @@ void center(int row, const char *str)
|
||||||
|
|
||||||
wmove(stdscr, row, 0);
|
wmove(stdscr, row, 0);
|
||||||
|
|
||||||
for(j = 0; j < SCREEN_X; j++)
|
for (j = 0; j < SCREEN_X; j++)
|
||||||
waddch(stdscr, ' ');
|
waddch(stdscr, ' ');
|
||||||
|
|
||||||
mvprintw(row, (SCREEN_X - len) / 2, str);
|
mvprintw(row, (SCREEN_X - len) / 2, str);
|
||||||
|
@ -87,13 +87,12 @@ void header(int row, const char *str)
|
||||||
int i;
|
int i;
|
||||||
int len = strlen(str) + 4;
|
int len = strlen(str) + 4;
|
||||||
|
|
||||||
for(i = 0; i < (SCREEN_X - len) / 2; i++)
|
for (i = 0; i < (SCREEN_X - len) / 2; i++)
|
||||||
ptr += sprintf(ptr, "=");
|
ptr += sprintf(ptr, "=");
|
||||||
|
|
||||||
ptr += sprintf(ptr, "[ %s ]", str);
|
ptr += sprintf(ptr, "[ %s ]", str);
|
||||||
|
|
||||||
|
for (i = ((SCREEN_X - len) / 2) + len; i < SCREEN_X; i++)
|
||||||
for(i = ((SCREEN_X - len) / 2) + len; i < SCREEN_X ; i++)
|
|
||||||
ptr += sprintf(ptr, "=");
|
ptr += sprintf(ptr, "=");
|
||||||
|
|
||||||
mvprintw(row, 0, buf);
|
mvprintw(row, 0, buf);
|
||||||
|
@ -116,7 +115,7 @@ int loop(void)
|
||||||
modules[curwin]->redraw(modwin);
|
modules[curwin]->redraw(modwin);
|
||||||
refresh();
|
refresh();
|
||||||
|
|
||||||
while(1) {
|
while (1) {
|
||||||
key = getch();
|
key = getch();
|
||||||
|
|
||||||
if (key == ERR)
|
if (key == ERR)
|
||||||
|
@ -156,16 +155,16 @@ int main(void)
|
||||||
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 < 23; 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++)
|
||||||
waddch(modwin, ' ');
|
waddch(modwin, ' ');
|
||||||
}
|
}
|
||||||
|
|
||||||
refresh();
|
refresh();
|
||||||
|
|
||||||
for(i = 0; i < MODULE_COUNT; i++)
|
for (i = 0; i < MODULE_COUNT; i++)
|
||||||
modules[i]->init();
|
modules[i]->init();
|
||||||
|
|
||||||
loop();
|
loop();
|
||||||
|
|
|
@ -21,18 +21,18 @@
|
||||||
#define COREINFO_H_
|
#define COREINFO_H_
|
||||||
|
|
||||||
#include <libpayload.h>
|
#include <libpayload.h>
|
||||||
|
|
||||||
#include <curses.h>
|
#include <curses.h>
|
||||||
|
|
||||||
struct coreinfo_module {
|
struct coreinfo_module {
|
||||||
char name[15];
|
char name[15];
|
||||||
int (*init)(void);
|
int (*init) (void);
|
||||||
int (*redraw)(WINDOW *);
|
int (*redraw) (WINDOW *);
|
||||||
int (*handle)(int);
|
int (*handle) (int);
|
||||||
};
|
};
|
||||||
|
|
||||||
extern void docpuid(int, unsigned long *, unsigned long *, unsigned long *, unsigned long *);
|
extern void docpuid(int, unsigned long *, unsigned long *, unsigned long *,
|
||||||
|
unsigned long *);
|
||||||
|
|
||||||
void print_module_title(WINDOW *, const char *title);
|
void print_module_title(WINDOW *win, const char *title);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -40,13 +40,14 @@ const char *generic_cap_flags[] = {
|
||||||
"fxsr", "sse", "sse2", "ss", "ht", "tm", NULL, "pbe"
|
"fxsr", "sse", "sse2", "ss", "ht", "tm", NULL, "pbe"
|
||||||
};
|
};
|
||||||
|
|
||||||
/* CPUID 0x00000001 ECX flags */
|
/* CPUID 0x00000001 ECX flags */
|
||||||
const char *intel_cap_generic_ecx_flags[] = {
|
const char *intel_cap_generic_ecx_flags[] = {
|
||||||
"sse3", NULL, NULL, "monitor", "ds-cpl", "vmx", NULL, "est",
|
"sse3", NULL, NULL, "monitor", "ds-cpl", "vmx", NULL, "est",
|
||||||
"tm2", "ssse3", "cntx-id", NULL, NULL, "cx16", "xTPR", NULL,
|
"tm2", "ssse3", "cntx-id", NULL, NULL, "cx16", "xTPR", NULL,
|
||||||
NULL, NULL, "dca", NULL, NULL, NULL, NULL, NULL,
|
NULL, NULL, "dca", NULL, NULL, NULL, NULL, NULL,
|
||||||
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
|
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
/* CPUID 0x80000001 EDX flags */
|
/* CPUID 0x80000001 EDX flags */
|
||||||
const char *intel_cap_extended_edx_flags[] = {
|
const char *intel_cap_extended_edx_flags[] = {
|
||||||
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
||||||
|
@ -54,6 +55,7 @@ const char *intel_cap_extended_edx_flags[] = {
|
||||||
NULL, NULL, NULL, NULL, "xd", NULL, NULL, NULL,
|
NULL, NULL, NULL, NULL, "xd", NULL, NULL, NULL,
|
||||||
NULL, NULL, NULL, NULL, NULL, "em64t", NULL, NULL,
|
NULL, NULL, NULL, NULL, NULL, "em64t", NULL, NULL,
|
||||||
};
|
};
|
||||||
|
|
||||||
/* CPUID 0x80000001 ECX flags */
|
/* CPUID 0x80000001 ECX flags */
|
||||||
const char *intel_cap_extended_ecx_flags[] = {
|
const char *intel_cap_extended_ecx_flags[] = {
|
||||||
"lahf_lm", NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
"lahf_lm", NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
||||||
|
@ -96,7 +98,7 @@ void decode_flags(WINDOW *win, unsigned long reg, const char **flags, int *row)
|
||||||
|
|
||||||
wmove(win, lrow, 2);
|
wmove(win, lrow, 2);
|
||||||
|
|
||||||
for(i = 0; i < 32; i++) {
|
for (i = 0; i < 32; i++) {
|
||||||
if (flags[i] == NULL)
|
if (flags[i] == NULL)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
@ -112,7 +114,6 @@ void decode_flags(WINDOW *win, unsigned long reg, const char **flags, int *row)
|
||||||
*row = lrow;
|
*row = lrow;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void get_features(WINDOW *win, int *row)
|
static void get_features(WINDOW *win, int *row)
|
||||||
{
|
{
|
||||||
unsigned long eax, ebx, ecx, edx;
|
unsigned long eax, ebx, ecx, edx;
|
||||||
|
@ -127,7 +128,7 @@ static void get_features(WINDOW *win, int *row)
|
||||||
|
|
||||||
lrow++;
|
lrow++;
|
||||||
|
|
||||||
switch(vendor) {
|
switch (vendor) {
|
||||||
case VENDOR_AMD:
|
case VENDOR_AMD:
|
||||||
wmove(win, lrow++, 1);
|
wmove(win, lrow++, 1);
|
||||||
wprintw(win, "AMD Extended Flags: ");
|
wprintw(win, "AMD Extended Flags: ");
|
||||||
|
@ -136,7 +137,6 @@ static void get_features(WINDOW *win, int *row)
|
||||||
decode_flags(win, edx, amd_cap_extended_edx_flags, &lrow);
|
decode_flags(win, edx, amd_cap_extended_edx_flags, &lrow);
|
||||||
decode_flags(win, ecx, amd_cap_extended_ecx_flags, &lrow);
|
decode_flags(win, ecx, amd_cap_extended_ecx_flags, &lrow);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VENDOR_INTEL:
|
case VENDOR_INTEL:
|
||||||
wmove(win, lrow++, 1);
|
wmove(win, lrow++, 1);
|
||||||
wprintw(win, "Intel Extended Flags: ");
|
wprintw(win, "Intel Extended Flags: ");
|
||||||
|
@ -152,46 +152,43 @@ static void get_features(WINDOW *win, int *row)
|
||||||
|
|
||||||
static void do_name(WINDOW *win, int row)
|
static void do_name(WINDOW *win, int row)
|
||||||
{
|
{
|
||||||
char str[80];
|
char str[80], name[49], *p;
|
||||||
unsigned long eax, ebx, ecx, edx;
|
unsigned long eax, ebx, ecx, edx;
|
||||||
int i, t;
|
int i, t;
|
||||||
char name[49], *p;
|
|
||||||
|
|
||||||
p = name;
|
p = name;
|
||||||
|
|
||||||
for(i = 0x80000002; i <= 0x80000004; i++) {
|
for (i = 0x80000002; i <= 0x80000004; i++) {
|
||||||
docpuid(i, &eax, &ebx, &ecx, &edx);
|
docpuid(i, &eax, &ebx, &ecx, &edx);
|
||||||
|
|
||||||
if (eax == 0)
|
if (eax == 0)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
for(t = 0; t < 4; t++)
|
for (t = 0; t < 4; t++)
|
||||||
*p++ = eax >> (8 * t);
|
*p++ = eax >> (8 * t);
|
||||||
for(t = 0; t < 4; t++)
|
for (t = 0; t < 4; t++)
|
||||||
*p++ = ebx >> (8 * t);
|
*p++ = ebx >> (8 * t);
|
||||||
for(t = 0; t < 4; t++)
|
for (t = 0; t < 4; t++)
|
||||||
*p++ = ecx >> (8 * t);
|
*p++ = ecx >> (8 * t);
|
||||||
for(t = 0; t < 4; t++)
|
for (t = 0; t < 4; t++)
|
||||||
*p++ = edx >> (8 * t);
|
*p++ = edx >> (8 * t);
|
||||||
}
|
}
|
||||||
|
|
||||||
mvwprintw(win, row,1, "Processor: %s", name);
|
mvwprintw(win, row, 1, "Processor: %s", name);
|
||||||
}
|
}
|
||||||
|
|
||||||
int cpuinfo_module_redraw(WINDOW *win)
|
int cpuinfo_module_redraw(WINDOW * win)
|
||||||
{
|
{
|
||||||
unsigned long eax, ebx, ecx, edx;
|
unsigned long eax, ebx, ecx, edx;
|
||||||
|
|
||||||
unsigned int brand;
|
unsigned int brand;
|
||||||
char str[80];
|
char str[80], *vstr;
|
||||||
char *vstr;
|
|
||||||
int row = 2;
|
int row = 2;
|
||||||
|
|
||||||
print_module_title(win, "CPU Information");
|
print_module_title(win, "CPU Information");
|
||||||
|
|
||||||
docpuid(0, NULL, &vendor, NULL, NULL);
|
docpuid(0, NULL, &vendor, NULL, NULL);
|
||||||
|
|
||||||
switch(vendor) {
|
switch (vendor) {
|
||||||
case VENDOR_INTEL:
|
case VENDOR_INTEL:
|
||||||
vstr = "Intel";
|
vstr = "Intel";
|
||||||
break;
|
break;
|
||||||
|
@ -221,7 +218,7 @@ int cpuinfo_module_redraw(WINDOW *win)
|
||||||
|
|
||||||
docpuid(0x00000001, &eax, &ebx, &ecx, &edx);
|
docpuid(0x00000001, &eax, &ebx, &ecx, &edx);
|
||||||
|
|
||||||
mvwprintw(win, row++, 1, "Family: %X",(eax >> 8) & 0x0f);
|
mvwprintw(win, row++, 1, "Family: %X", (eax >> 8) & 0x0f);
|
||||||
mvwprintw(win, row++, 1, "Model: %X",
|
mvwprintw(win, row++, 1, "Model: %X",
|
||||||
((eax >> 4) & 0xf) | ((eax >> 16) & 0xf) << 4);
|
((eax >> 4) & 0xf) | ((eax >> 16) & 0xf) << 4);
|
||||||
|
|
||||||
|
@ -229,18 +226,15 @@ int cpuinfo_module_redraw(WINDOW *win)
|
||||||
|
|
||||||
if (vendor == VENDOR_AMD) {
|
if (vendor == VENDOR_AMD) {
|
||||||
docpuid(0x80000001, &eax, &ebx, &ecx, &edx);
|
docpuid(0x80000001, &eax, &ebx, &ecx, &edx);
|
||||||
brand = ((ebx >> 9) & 0x1F);
|
brand = ((ebx >> 9) & 0x1f);
|
||||||
|
|
||||||
mvwprintw(win, row++, 1,"Brand: %X", brand);
|
mvwprintw(win, row++, 1, "Brand: %X", brand);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cpu_khz != 0) {
|
if (cpu_khz != 0)
|
||||||
mvwprintw(win, row++, 1, "CPU Speed: %d Mhz",
|
mvwprintw(win, row++, 1, "CPU Speed: %d Mhz", cpu_khz / 1000);
|
||||||
cpu_khz / 1000);
|
else
|
||||||
}
|
|
||||||
else {
|
|
||||||
mvwprintw(win, row++, 1, "CPU Speed: Error");
|
mvwprintw(win, row++, 1, "CPU Speed: Error");
|
||||||
}
|
|
||||||
|
|
||||||
row++;
|
row++;
|
||||||
get_features(win, &row);
|
get_features(win, &row);
|
||||||
|
@ -250,13 +244,12 @@ unsigned int getticks(void)
|
||||||
{
|
{
|
||||||
unsigned long long start, end;
|
unsigned long long start, end;
|
||||||
|
|
||||||
/* Read the number of ticks during the period */
|
/* Read the number of ticks during the period. */
|
||||||
|
|
||||||
start = rdtsc();
|
start = rdtsc();
|
||||||
mdelay(100);
|
mdelay(100);
|
||||||
end = rdtsc();
|
end = rdtsc();
|
||||||
|
|
||||||
return (unsigned int) ((end - start) / 100);
|
return (unsigned int)((end - start) / 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
int cpuinfo_module_init(void)
|
int cpuinfo_module_init(void)
|
||||||
|
|
|
@ -29,7 +29,7 @@ static struct pci_devices devices[64];
|
||||||
static int devices_index;
|
static int devices_index;
|
||||||
|
|
||||||
#define REG_VENDOR_ID 0x00
|
#define REG_VENDOR_ID 0x00
|
||||||
#define REG_HEADER_TYPE 0x0E
|
#define REG_HEADER_TYPE 0x0e
|
||||||
#define REG_PRIMARY_BUS 0x18
|
#define REG_PRIMARY_BUS 0x18
|
||||||
|
|
||||||
#define HEADER_TYPE_NORMAL 0
|
#define HEADER_TYPE_NORMAL 0
|
||||||
|
@ -37,7 +37,7 @@ static int devices_index;
|
||||||
#define HEADER_TYPE_CARDBUS 2
|
#define HEADER_TYPE_CARDBUS 2
|
||||||
|
|
||||||
#define PCI_ADDR(_bus, _dev, _reg) \
|
#define PCI_ADDR(_bus, _dev, _reg) \
|
||||||
(0x80000000 | (_bus << 16) | (_dev << 8) | (_reg & ~3))
|
(0x80000000 | (_bus << 16) | (_dev << 8) | (_reg & ~3))
|
||||||
|
|
||||||
/* Number of entries to show in the list */
|
/* Number of entries to show in the list */
|
||||||
#define MENU_VISIBLE 16
|
#define MENU_VISIBLE 16
|
||||||
|
@ -67,8 +67,7 @@ static int partition(struct pci_devices *list, int len)
|
||||||
|
|
||||||
swap(&list[len / 2], &list[len - 1]);
|
swap(&list[len / 2], &list[len - 1]);
|
||||||
|
|
||||||
for(i = 0; i < len - 1; i++) {
|
for (i = 0; i < len - 1; i++) {
|
||||||
|
|
||||||
if (list[i].device < val) {
|
if (list[i].device < val) {
|
||||||
swap(&list[i], &list[index]);
|
swap(&list[i], &list[index]);
|
||||||
index++;
|
index++;
|
||||||
|
@ -76,6 +75,7 @@ static int partition(struct pci_devices *list, int len)
|
||||||
}
|
}
|
||||||
|
|
||||||
swap(&list[index], &list[len - 1]);
|
swap(&list[index], &list[len - 1]);
|
||||||
|
|
||||||
return index;
|
return index;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -95,15 +95,15 @@ static void quicksort(struct pci_devices *list, int len)
|
||||||
static void pci_read_dword(unsigned int bus, unsigned int devfn,
|
static void pci_read_dword(unsigned int bus, unsigned int devfn,
|
||||||
unsigned int reg, unsigned int *val)
|
unsigned int reg, unsigned int *val)
|
||||||
{
|
{
|
||||||
outl(PCI_ADDR(bus, devfn, reg), 0xCF8);
|
outl(PCI_ADDR(bus, devfn, reg), 0xcf8);
|
||||||
*val = inl(0xCFC);
|
*val = inl(0xcfc);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void pci_read_byte(unsigned int bus, unsigned int devfn,
|
static void pci_read_byte(unsigned int bus, unsigned int devfn,
|
||||||
unsigned int reg, unsigned char *val)
|
unsigned int reg, unsigned char *val)
|
||||||
{
|
{
|
||||||
outl(PCI_ADDR(bus, devfn, reg), 0xCF8);
|
outl(PCI_ADDR(bus, devfn, reg), 0xcf8);
|
||||||
*val = inb(0xCFC + (reg & 3));
|
*val = inb(0xcfc + (reg & 3));
|
||||||
}
|
}
|
||||||
|
|
||||||
static int show_config_space(WINDOW *win, int row, int col, int index)
|
static int show_config_space(WINDOW *win, int row, int col, int index)
|
||||||
|
@ -112,23 +112,23 @@ static int show_config_space(WINDOW *win, int row, int col, int index)
|
||||||
int bus, devfn;
|
int bus, devfn;
|
||||||
int i, x, y;
|
int i, x, y;
|
||||||
|
|
||||||
bus = (devices[index].device >> 8) & 0xFF;
|
bus = (devices[index].device >> 8) & 0xff;
|
||||||
devfn = devices[index].device & 0xFF;
|
devfn = devices[index].device & 0xff;
|
||||||
|
|
||||||
for(i = 0; i < 64; i+= 4)
|
for (i = 0; i < 64; i += 4)
|
||||||
pci_read_dword(bus, devfn, i, ((int *) &cspace[i]));
|
pci_read_dword(bus, devfn, i, ((int *)&cspace[i]));
|
||||||
|
|
||||||
for(y = 0; y < 4; y++) {
|
for (y = 0; y < 4; y++) {
|
||||||
for(x = 0; x < 16; x++)
|
for (x = 0; x < 16; x++)
|
||||||
mvwprintw(win, row + y, col + (x * 3), "%2.2X ", cspace[(y * 16) + x]);
|
mvwprintw(win, row + y, col + (x * 3), "%2.2X ",
|
||||||
|
cspace[(y * 16) + x]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int pci_module_redraw(WINDOW *win)
|
int pci_module_redraw(WINDOW *win)
|
||||||
{
|
{
|
||||||
unsigned int bus, devfn, func;
|
unsigned int bus, devfn, func;
|
||||||
int i;
|
int i, last;
|
||||||
int last;
|
|
||||||
|
|
||||||
print_module_title(win, "PCI Device List");
|
print_module_title(win, "PCI Device List");
|
||||||
|
|
||||||
|
@ -137,54 +137,53 @@ int pci_module_redraw(WINDOW *win)
|
||||||
if (last > devices_index)
|
if (last > devices_index)
|
||||||
last = devices_index;
|
last = devices_index;
|
||||||
|
|
||||||
for(i = 0; i < MENU_VISIBLE; i++) {
|
for (i = 0; i < MENU_VISIBLE; i++) {
|
||||||
int item = menu_first + i;
|
int item = menu_first + i;
|
||||||
|
|
||||||
/* Draw a blank space */
|
/* Draw a blank space. */
|
||||||
|
|
||||||
if (item >= devices_index) {
|
if (item >= devices_index) {
|
||||||
wattrset(win, COLOR_PAIR(2));
|
wattrset(win, COLOR_PAIR(2));
|
||||||
mvwprintw(win, 2 + i, 1, " ");
|
mvwprintw(win, 2 + i, 1, " ");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
bus = (devices[item].device >> 8) & 0xFF;
|
bus = (devices[item].device >> 8) & 0xff;
|
||||||
devfn = (devices[item].device & 0xFF) / 8;
|
devfn = (devices[item].device & 0xff) / 8;
|
||||||
func = (devices[item].device & 0xFF) % 8;
|
func = (devices[item].device & 0xff) % 8;
|
||||||
|
|
||||||
if (item == menu_selected)
|
if (item == menu_selected)
|
||||||
wattrset(win, COLOR_PAIR(3) | A_BOLD);
|
wattrset(win, COLOR_PAIR(3) | A_BOLD);
|
||||||
else
|
else
|
||||||
wattrset(win, COLOR_PAIR(2));
|
wattrset(win, COLOR_PAIR(2));
|
||||||
|
|
||||||
mvwprintw(win, 2+i, 1, "%X:%2.2X.%2.2X %X:%X ",
|
mvwprintw(win, 2 + i, 1, "%X:%2.2X.%2.2X %X:%X ",
|
||||||
bus, devfn, func,
|
bus, devfn, func,
|
||||||
devices[item].id & 0xFFFF,
|
devices[item].id & 0xffff,
|
||||||
(devices[item].id >> 16) & 0xFFFF);
|
(devices[item].id >> 16) & 0xffff);
|
||||||
|
|
||||||
wattrset(win, COLOR_PAIR(2));
|
wattrset(win, COLOR_PAIR(2));
|
||||||
|
|
||||||
if (i == 0) {
|
if (i == 0) {
|
||||||
if (item != 0)
|
if (item != 0)
|
||||||
mvwprintw(win, 2+ i, 19, "\30");
|
mvwprintw(win, 2 + i, 19, "\30");
|
||||||
}
|
}
|
||||||
if (i == MENU_VISIBLE - 1) {
|
if (i == MENU_VISIBLE - 1) {
|
||||||
if ((item + 1) < devices_index)
|
if ((item + 1) < devices_index)
|
||||||
mvwprintw(win, 2+ i, 19, "\31");
|
mvwprintw(win, 2 + i, 19, "\31");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
wattrset(win, COLOR_PAIR(2));
|
wattrset(win, COLOR_PAIR(2));
|
||||||
|
|
||||||
for(i = 0; i < 16; i++)
|
for (i = 0; i < 16; i++)
|
||||||
mvwprintw(win, 2, 26 + (i * 3), "%2.2X ", i);
|
mvwprintw(win, 2, 26 + (i * 3), "%2.2X ", i);
|
||||||
|
|
||||||
wmove(win, 3, 25);
|
wmove(win, 3, 25);
|
||||||
|
|
||||||
for(i = 0; i < 48; i++)
|
for (i = 0; i < 48; i++)
|
||||||
waddch(win, (i == 0) ? '\332' : '\304');
|
waddch(win, (i == 0) ? '\332' : '\304');
|
||||||
|
|
||||||
for(i = 0; i < 4; i++) {
|
for (i = 0; i < 4; i++) {
|
||||||
mvwprintw(win, 4 + i, 23, "%2.2X", i * 16);
|
mvwprintw(win, 4 + i, 23, "%2.2X", i * 16);
|
||||||
wmove(win, 4 + i, 25);
|
wmove(win, 4 + i, 25);
|
||||||
waddch(win, '\263');
|
waddch(win, '\263');
|
||||||
|
@ -201,32 +200,27 @@ static void pci_scan_bus(int bus)
|
||||||
unsigned int val;
|
unsigned int val;
|
||||||
unsigned char hdr;
|
unsigned char hdr;
|
||||||
|
|
||||||
for(devfn = 0; devfn < 0x100; ) {
|
for (devfn = 0; devfn < 0x100;) {
|
||||||
for(func = 0; func < 8; func++, devfn++) {
|
for (func = 0; func < 8; func++, devfn++) {
|
||||||
pci_read_dword(bus, devfn, REG_VENDOR_ID, &val);
|
pci_read_dword(bus, devfn, REG_VENDOR_ID, &val);
|
||||||
|
|
||||||
/* Nobody home */
|
/* Nobody home. */
|
||||||
|
|
||||||
if (val == 0xffffffff || val == 0x00000000 ||
|
if (val == 0xffffffff || val == 0x00000000 ||
|
||||||
val == 0x0000ffff || val == 0xffff0000)
|
val == 0x0000ffff || val == 0xffff0000)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
/* FIXME: Remove this arbitrary limitation */
|
/* FIXME: Remove this arbitrary limitation. */
|
||||||
|
|
||||||
if (devices_index >= 64)
|
if (devices_index >= 64)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
devices[devices_index].device =
|
devices[devices_index].device =
|
||||||
((bus & 0xFF) << 8) | (devfn & 0xFF);
|
((bus & 0xff) << 8) | (devfn & 0xff);
|
||||||
|
|
||||||
devices[devices_index++].id = val;
|
devices[devices_index++].id = val;
|
||||||
|
|
||||||
/* If this is a bridge, then follow it */
|
/* If this is a bridge, then follow it. */
|
||||||
|
|
||||||
pci_read_byte(bus, devfn, REG_HEADER_TYPE, &hdr);
|
pci_read_byte(bus, devfn, REG_HEADER_TYPE, &hdr);
|
||||||
|
hdr &= 0x7f;
|
||||||
hdr &= 0x7F;
|
|
||||||
|
|
||||||
if (hdr == HEADER_TYPE_BRIDGE ||
|
if (hdr == HEADER_TYPE_BRIDGE ||
|
||||||
hdr == HEADER_TYPE_CARDBUS) {
|
hdr == HEADER_TYPE_CARDBUS) {
|
||||||
unsigned int busses;
|
unsigned int busses;
|
||||||
|
@ -234,7 +228,7 @@ static void pci_scan_bus(int bus)
|
||||||
pci_read_dword(bus, devfn, REG_PRIMARY_BUS,
|
pci_read_dword(bus, devfn, REG_PRIMARY_BUS,
|
||||||
&busses);
|
&busses);
|
||||||
|
|
||||||
pci_scan_bus((busses >> 8) & 0xFF);
|
pci_scan_bus((busses >> 8) & 0xff);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -247,21 +241,18 @@ int pci_module_handle(int key)
|
||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
switch(key) {
|
switch (key) {
|
||||||
case KEY_DOWN:
|
case KEY_DOWN:
|
||||||
if (menu_selected + 1 < devices_index) {
|
if (menu_selected + 1 < devices_index) {
|
||||||
menu_selected++;
|
menu_selected++;
|
||||||
ret = 1;
|
ret = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case KEY_UP:
|
case KEY_UP:
|
||||||
if (menu_selected > 0) {
|
if (menu_selected > 0) {
|
||||||
menu_selected--;
|
menu_selected--;
|
||||||
ret = 1;
|
ret = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -276,7 +267,6 @@ int pci_module_handle(int key)
|
||||||
menu_first = 0;
|
menu_first = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -285,7 +275,6 @@ int pci_module_init(void)
|
||||||
unsigned int val;
|
unsigned int val;
|
||||||
int bus = 0;
|
int bus = 0;
|
||||||
|
|
||||||
|
|
||||||
pci_scan_bus(0);
|
pci_scan_bus(0);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Reference in New Issue