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:
Uwe Hermann 2008-03-20 01:11:28 +00:00
parent 7249f79792
commit 3a406feb17
6 changed files with 142 additions and 172 deletions

View File

@ -37,7 +37,7 @@ 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 $@

View File

@ -98,16 +98,13 @@ int coreboot_module_redraw(WINDOW *win)
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: ");
} }
@ -180,23 +177,23 @@ static int parse_header(void *addr, int len)
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++) {
@ -206,11 +203,9 @@ static int parse_header(void *addr, int len)
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;
} }
@ -249,14 +241,11 @@ int coreboot_module_init(void)
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,

View File

@ -50,11 +50,11 @@ void print_module_title(WINDOW *win, const char *title)
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);
@ -92,7 +92,6 @@ void header(int row, const char *str)
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, "=");

View File

@ -21,7 +21,6 @@
#define COREINFO_H_ #define COREINFO_H_
#include <libpayload.h> #include <libpayload.h>
#include <curses.h> #include <curses.h>
struct coreinfo_module { struct coreinfo_module {
@ -31,8 +30,9 @@ struct coreinfo_module {
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

View File

@ -47,6 +47,7 @@ const char *intel_cap_generic_ecx_flags[] = {
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,
@ -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;
@ -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,10 +152,9 @@ 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;
@ -181,10 +180,8 @@ static void do_name(WINDOW *win, int row)
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");
@ -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,8 +244,7 @@ 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();

View File

@ -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
@ -68,7 +68,6 @@ 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");
@ -140,17 +140,16 @@ int pci_module_redraw(WINDOW *win)
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);
@ -159,8 +158,8 @@ int pci_module_redraw(WINDOW *win)
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));
@ -205,28 +204,23 @@ static void pci_scan_bus(int bus)
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);
} }
} }
@ -253,15 +247,12 @@ int pci_module_handle(int key)
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;