summaryrefslogtreecommitdiff
path: root/payloads/coreinfo/pci_module.c
diff options
context:
space:
mode:
authorUwe Hermann <uwe@hermann-uwe.de>2008-03-20 01:11:28 +0000
committerUwe Hermann <uwe@hermann-uwe.de>2008-03-20 01:11:28 +0000
commit3a406feb179dbe10bbbc1b07abd935a7d04e6524 (patch)
tree5a210ca3480ce18cc522db72020af22ed5de46af /payloads/coreinfo/pci_module.c
parent7249f7979237d7f14941036dd931545b5c9e73fb (diff)
downloadcoreboot-3a406feb179dbe10bbbc1b07abd935a7d04e6524.tar.xz
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
Diffstat (limited to 'payloads/coreinfo/pci_module.c')
-rw-r--r--payloads/coreinfo/pci_module.c97
1 files changed, 43 insertions, 54 deletions
diff --git a/payloads/coreinfo/pci_module.c b/payloads/coreinfo/pci_module.c
index 723c51377d..af6a23eaaa 100644
--- a/payloads/coreinfo/pci_module.c
+++ b/payloads/coreinfo/pci_module.c
@@ -6,12 +6,12 @@
* 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
@@ -29,7 +29,7 @@ static struct pci_devices devices[64];
static int devices_index;
#define REG_VENDOR_ID 0x00
-#define REG_HEADER_TYPE 0x0E
+#define REG_HEADER_TYPE 0x0e
#define REG_PRIMARY_BUS 0x18
#define HEADER_TYPE_NORMAL 0
@@ -37,7 +37,7 @@ static int devices_index;
#define HEADER_TYPE_CARDBUS 2
#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 */
#define MENU_VISIBLE 16
@@ -67,8 +67,7 @@ static int partition(struct pci_devices *list, int len)
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) {
swap(&list[i], &list[index]);
index++;
@@ -76,6 +75,7 @@ static int partition(struct pci_devices *list, int len)
}
swap(&list[index], &list[len - 1]);
+
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,
unsigned int reg, unsigned int *val)
{
- outl(PCI_ADDR(bus, devfn, reg), 0xCF8);
- *val = inl(0xCFC);
+ outl(PCI_ADDR(bus, devfn, reg), 0xcf8);
+ *val = inl(0xcfc);
}
static void pci_read_byte(unsigned int bus, unsigned int devfn,
unsigned int reg, unsigned char *val)
{
- outl(PCI_ADDR(bus, devfn, reg), 0xCF8);
- *val = inb(0xCFC + (reg & 3));
+ outl(PCI_ADDR(bus, devfn, reg), 0xcf8);
+ *val = inb(0xcfc + (reg & 3));
}
static int show_config_space(WINDOW *win, int row, int col, int index)
@@ -112,79 +112,78 @@ static int show_config_space(WINDOW *win, int row, int col, int index)
int bus, devfn;
int i, x, y;
- bus = (devices[index].device >> 8) & 0xFF;
- devfn = devices[index].device & 0xFF;
+ bus = (devices[index].device >> 8) & 0xff;
+ devfn = devices[index].device & 0xff;
- for(i = 0; i < 64; i+= 4)
- pci_read_dword(bus, devfn, i, ((int *) &cspace[i]));
+ for (i = 0; i < 64; i += 4)
+ pci_read_dword(bus, devfn, i, ((int *)&cspace[i]));
- for(y = 0; y < 4; y++) {
- for(x = 0; x < 16; x++)
- mvwprintw(win, row + y, col + (x * 3), "%2.2X ", cspace[(y * 16) + x]);
+ for (y = 0; y < 4; y++) {
+ for (x = 0; x < 16; x++)
+ mvwprintw(win, row + y, col + (x * 3), "%2.2X ",
+ cspace[(y * 16) + x]);
}
}
int pci_module_redraw(WINDOW *win)
{
unsigned int bus, devfn, func;
- int i;
- int last;
+ int i, last;
print_module_title(win, "PCI Device List");
last = menu_first + MENU_VISIBLE;
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;
- /* Draw a blank space */
-
+ /* Draw a blank space. */
if (item >= devices_index) {
wattrset(win, COLOR_PAIR(2));
mvwprintw(win, 2 + i, 1, " ");
continue;
}
- bus = (devices[item].device >> 8) & 0xFF;
- devfn = (devices[item].device & 0xFF) / 8;
- func = (devices[item].device & 0xFF) % 8;
+ bus = (devices[item].device >> 8) & 0xff;
+ devfn = (devices[item].device & 0xff) / 8;
+ func = (devices[item].device & 0xff) % 8;
if (item == menu_selected)
wattrset(win, COLOR_PAIR(3) | A_BOLD);
else
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,
- devices[item].id & 0xFFFF,
- (devices[item].id >> 16) & 0xFFFF);
+ devices[item].id & 0xffff,
+ (devices[item].id >> 16) & 0xffff);
wattrset(win, COLOR_PAIR(2));
if (i == 0) {
if (item != 0)
- mvwprintw(win, 2+ i, 19, "\30");
+ mvwprintw(win, 2 + i, 19, "\30");
}
if (i == MENU_VISIBLE - 1) {
if ((item + 1) < devices_index)
- mvwprintw(win, 2+ i, 19, "\31");
+ mvwprintw(win, 2 + i, 19, "\31");
}
}
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);
wmove(win, 3, 25);
- for(i = 0; i < 48; i++)
+ for (i = 0; i < 48; i++)
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);
wmove(win, 4 + i, 25);
waddch(win, '\263');
@@ -201,32 +200,27 @@ static void pci_scan_bus(int bus)
unsigned int val;
unsigned char hdr;
- for(devfn = 0; devfn < 0x100; ) {
- for(func = 0; func < 8; func++, devfn++) {
+ for (devfn = 0; devfn < 0x100;) {
+ for (func = 0; func < 8; func++, devfn++) {
pci_read_dword(bus, devfn, REG_VENDOR_ID, &val);
- /* Nobody home */
-
+ /* Nobody home. */
if (val == 0xffffffff || val == 0x00000000 ||
val == 0x0000ffff || val == 0xffff0000)
continue;
- /* FIXME: Remove this arbitrary limitation */
-
+ /* FIXME: Remove this arbitrary limitation. */
if (devices_index >= 64)
return;
- devices[devices_index].device =
- ((bus & 0xFF) << 8) | (devfn & 0xFF);
+ devices[devices_index].device =
+ ((bus & 0xff) << 8) | (devfn & 0xff);
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);
-
- hdr &= 0x7F;
-
+ hdr &= 0x7f;
if (hdr == HEADER_TYPE_BRIDGE ||
hdr == HEADER_TYPE_CARDBUS) {
unsigned int busses;
@@ -234,7 +228,7 @@ static void pci_scan_bus(int bus)
pci_read_dword(bus, devfn, REG_PRIMARY_BUS,
&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;
- switch(key) {
+ switch (key) {
case KEY_DOWN:
if (menu_selected + 1 < devices_index) {
menu_selected++;
ret = 1;
}
-
break;
-
case KEY_UP:
if (menu_selected > 0) {
menu_selected--;
ret = 1;
}
-
break;
}
@@ -276,7 +267,6 @@ int pci_module_handle(int key)
menu_first = 0;
}
-
return ret;
}
@@ -285,7 +275,6 @@ int pci_module_init(void)
unsigned int val;
int bus = 0;
-
pci_scan_bus(0);
return 0;