diff options
author | H. Peter Anvin <hpa@zytor.com> | 2007-03-07 11:07:52 -0800 |
---|---|---|
committer | H. Peter Anvin <hpa@zytor.com> | 2007-03-07 11:07:52 -0800 |
commit | 0bcec261c03301966dc02104428f4212d70a26c9 (patch) | |
tree | 9a7291b11cd48d1b75bed18d1becc2e3f8d47aa9 | |
parent | faece000985cc54fc4c75172e16b379bbdad63c2 (diff) | |
download | syslinux-0bcec261c03301966dc02104428f4212d70a26c9.tar.gz |
Formatting cleanupssyslinux-3.40-pre12
-rw-r--r-- | cache.inc | 1 | ||||
-rw-r--r-- | com32/modules/pci.c | 224 | ||||
-rw-r--r-- | comboot.doc | 2 | ||||
-rw-r--r-- | configinit.inc | 3 |
4 files changed, 128 insertions, 102 deletions
@@ -112,4 +112,3 @@ getcachesector: ; The first entry is the head node of the list alignb 4 CachePtrs resb (NCacheEntries+1)*cptr_size - diff --git a/com32/modules/pci.c b/com32/modules/pci.c index 4eb8f986..dc6ca132 100644 --- a/com32/modules/pci.c +++ b/com32/modules/pci.c @@ -1,6 +1,6 @@ /* ----------------------------------------------------------------------- * * - * Copyright 2006 Erwan Velu - All Rights Reserved + * Copyright 2006-2007 Erwan Velu - All Rights Reserved * * 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 @@ -32,10 +32,9 @@ #endif #define MAX_LINE 512 -static char * -skipspace(char *p) +static char *skipspace(char *p) { - while ( *p && *p <= ' ' ) + while (*p && *p <= ' ') p++; return p; @@ -43,97 +42,119 @@ skipspace(char *p) void remove_eol(char *string) { - int j = strlen(string); - int i = 0; - for(i = 0; i < j; i++) if(string[i] == '\n') string[i] = 0; + int j = strlen(string); + int i = 0; + for (i = 0; i < j; i++) + if (string[i] == '\n') + string[i] = 0; } int hex_to_int(char *hexa) { - int i; - sscanf(hexa,"%x",&i); - return i; + int i; + sscanf(hexa, "%x", &i); + return i; } -void get_name_from_pci_ids(s_pci_device *pci_device) +void get_name_from_pci_ids(s_pci_device * pci_device) { char line[MAX_LINE]; - char *vendor=NULL; + char *vendor = NULL; char vendor_id[5]; - char *product=NULL; + char *product = NULL; char product_id[5]; char sub_product_id[5]; char sub_vendor_id[5]; FILE *f; - f=fopen("pci.ids","r"); + f = fopen("pci.ids", "r"); if (!f) - return; - - strcpy(pci_device->vendor_name,"Unknown"); - strcpy(pci_device->product_name,"Unknown"); - strcpy(vendor_id,"0000"); - strcpy(product_id,"0000"); - strcpy(sub_product_id,"0000"); - strcpy(sub_vendor_id,"0000"); - - - while ( fgets(line, sizeof line, f) ) { - if ((line[0] == '#') || (line[0] == ' ') || (line[0] == 'C') || (line[0] == 10)) - continue; + return; + + strcpy(pci_device->vendor_name, "Unknown"); + strcpy(pci_device->product_name, "Unknown"); + strcpy(vendor_id, "0000"); + strcpy(product_id, "0000"); + strcpy(sub_product_id, "0000"); + strcpy(sub_vendor_id, "0000"); + + while (fgets(line, sizeof line, f)) { + if ((line[0] == '#') || (line[0] == ' ') || (line[0] == 'C') + || (line[0] == 10)) + continue; if (line[0] != '\t') { - strncpy(vendor_id,line,4); - vendor_id[4]=0; - vendor=strdup(skipspace(strstr(line," "))); - remove_eol(vendor); - strcpy(product_id,"0000"); - strcpy(sub_product_id,"0000"); - strcpy(sub_vendor_id,"0000"); - if (strstr(vendor_id,"ffff")) break; - if (hex_to_int(vendor_id)==pci_device->vendor) strcpy(pci_device->vendor_name,vendor); + strncpy(vendor_id, line, 4); + vendor_id[4] = 0; + vendor = strdup(skipspace(strstr(line, " "))); + remove_eol(vendor); + strcpy(product_id, "0000"); + strcpy(sub_product_id, "0000"); + strcpy(sub_vendor_id, "0000"); + if (strstr(vendor_id, "ffff")) + break; + if (hex_to_int(vendor_id) == pci_device->vendor) + strcpy(pci_device->vendor_name, vendor); } else if ((line[0] == '\t') && (line[1] != '\t')) { - product=strdup(skipspace(strstr(line," "))); - remove_eol(product); - strncpy(product_id,&line[1],4); - product_id[4]=0; - strcpy(sub_product_id,"0000"); - strcpy(sub_vendor_id,"0000"); - if ((hex_to_int(vendor_id)==pci_device->vendor) && (hex_to_int(product_id)==pci_device->product)) strcpy(pci_device->product_name,product); + product = strdup(skipspace(strstr(line, " "))); + remove_eol(product); + strncpy(product_id, &line[1], 4); + product_id[4] = 0; + strcpy(sub_product_id, "0000"); + strcpy(sub_vendor_id, "0000"); + if ((hex_to_int(vendor_id) == pci_device->vendor) + && (hex_to_int(product_id) == pci_device->product)) + strcpy(pci_device->product_name, product); } else if ((line[0] == '\t') && (line[1] == '\t')) { - product=skipspace(strstr(line," ")); - product=strdup(skipspace(strstr(product," "))); - remove_eol(product); - strncpy(sub_vendor_id,&line[2],4); - sub_vendor_id[4]=0; - strncpy(sub_product_id,&line[7],4); - sub_product_id[4]=0; - if ((hex_to_int(vendor_id)==pci_device->vendor) && (hex_to_int(product_id)==pci_device->product) && (hex_to_int(sub_product_id)==pci_device->sub_product) && (hex_to_int(sub_vendor_id)==pci_device->sub_vendor)) strcpy(pci_device->product_name,product); + product = skipspace(strstr(line, " ")); + product = strdup(skipspace(strstr(product, " "))); + remove_eol(product); + strncpy(sub_vendor_id, &line[2], 4); + sub_vendor_id[4] = 0; + strncpy(sub_product_id, &line[7], 4); + sub_product_id[4] = 0; + if ((hex_to_int(vendor_id) == pci_device->vendor) + && (hex_to_int(product_id) == pci_device->product) + && (hex_to_int(sub_product_id) == + pci_device->sub_product) + && (hex_to_int(sub_vendor_id) == + pci_device->sub_vendor)) + strcpy(pci_device->product_name, product); } } - fclose(f); + fclose(f); } -struct match * find_pci_device(s_pci_device_list *pci_device_list, struct match *list) { - int pci_dev; - uint32_t did,sid; - struct match *m; - for (pci_dev=0; pci_dev<pci_device_list->count;pci_dev++) { - s_pci_device *pci_device = &pci_device_list->pci_device[pci_dev]; - sid=((pci_device->sub_product)<<16 | (pci_device->sub_vendor)); - did=((pci_device->product<<16) | (pci_device->vendor)); - for ( m = list ; m ; m = m->next ) { - if ( ((did ^ m->did) & m->did_mask) == 0 && - ((sid ^ m->sid) & m->sid_mask) == 0 && - pci_device->revision >= m->rid_min && pci_device->revision <= m->rid_max ) { - dprintf("PCI Match: Vendor=%04x Product=%04x Sub_vendor=%04x Sub_Product=%04x Release=%02x\n",pci_device->vendor,pci_device->product,pci_device->sub_vendor,pci_device->sub_product,pci_device->revision); - return m; - } - } - } - return NULL; +struct match *find_pci_device(s_pci_device_list * pci_device_list, + struct match *list) +{ + int pci_dev; + uint32_t did, sid; + struct match *m; + for (pci_dev = 0; pci_dev < pci_device_list->count; pci_dev++) { + s_pci_device *pci_device = + &pci_device_list->pci_device[pci_dev]; + sid = + ((pci_device->sub_product) << 16 | (pci_device-> + sub_vendor)); + did = ((pci_device->product << 16) | (pci_device->vendor)); + for (m = list; m; m = m->next) { + if (((did ^ m->did) & m->did_mask) == 0 && + ((sid ^ m->sid) & m->sid_mask) == 0 && + pci_device->revision >= m->rid_min + && pci_device->revision <= m->rid_max) { + dprintf("PCI Match: Vendor=%04x Product=%04x Sub_vendor=%04x Sub_Product=%04x Release=%02x\n", + pci_device->vendor, pci_device->product, + pci_device->sub_vendor, + pci_device->sub_product, + pci_device->revision); + return m; + } + } + } + return NULL; } -int pci_scan(s_pci_bus_list *pci_bus_list, s_pci_device_list *pci_device_list) +int pci_scan(s_pci_bus_list * pci_bus_list, s_pci_device_list * pci_device_list) { unsigned int bus, dev, func, maxfunc; uint32_t did, sid; @@ -141,7 +162,7 @@ int pci_scan(s_pci_bus_list *pci_bus_list, s_pci_device_list *pci_device_list) pciaddr_t a; int cfgtype; - pci_device_list->count=0; + pci_device_list->count = 0; #ifdef DEBUG outl(~0, 0xcf8); @@ -155,57 +176,64 @@ int pci_scan(s_pci_bus_list *pci_bus_list, s_pci_device_list *pci_device_list) dprintf("PCI configuration type %d\n", cfgtype); printf("Scanning PCI Buses\n"); - for ( bus = 0 ; bus <= 0xff ; bus++ ) { + for (bus = 0; bus <= 0xff; bus++) { dprintf("Probing bus 0x%02x... \n", bus); - pci_bus_list->pci_bus[bus].id=bus; - pci_bus_list->pci_bus[bus].pci_device_count=0; - pci_bus_list->count=0;; + pci_bus_list->pci_bus[bus].id = bus; + pci_bus_list->pci_bus[bus].pci_device_count = 0; + pci_bus_list->count = 0;; - for ( dev = 0 ; dev <= 0x1f ; dev++ ) { + for (dev = 0; dev <= 0x1f; dev++) { maxfunc = 0; - for ( func = 0 ; func <= maxfunc ; func++ ) { + for (func = 0; func <= maxfunc; func++) { a = pci_mkaddr(bus, dev, func, 0); did = pci_readl(a); - if ( did == 0xffffffff || did == 0xffff0000 || - did == 0x0000ffff || did == 0x00000000 ) + if (did == 0xffffffff || did == 0xffff0000 || + did == 0x0000ffff || did == 0x00000000) continue; hdrtype = pci_readb(a + 0x0e); - if ( hdrtype & 0x80 ) - maxfunc = 7; /* Multifunction device */ + if (hdrtype & 0x80) + maxfunc = 7; /* Multifunction device */ -// if ( hdrtype & 0x7f ) -// continue; /* Ignore bridge devices */ + // if ( hdrtype & 0x7f ) + // continue; /* Ignore bridge devices */ rid = pci_readb(a + 0x08); sid = pci_readl(a + 0x2c); - s_pci_device *pci_device = &pci_device_list->pci_device[pci_device_list->count]; - pci_device->product=did>>16; - pci_device->sub_product=sid>>16; - pci_device->vendor=(did<<16)>>16; - pci_device->sub_vendor=(sid<<16)>>16; - pci_device->revision=rid; + s_pci_device *pci_device = + &pci_device_list-> + pci_device[pci_device_list->count]; + pci_device->product = did >> 16; + pci_device->sub_product = sid >> 16; + pci_device->vendor = (did << 16) >> 16; + pci_device->sub_vendor = (sid << 16) >> 16; + pci_device->revision = rid; pci_device_list->count++; get_name_from_pci_ids(pci_device); - dprintf("Scanning: BUS %02x DID %08x (%04x:%04x) SID %08x RID %02x\n", bus, did, did>>16, (did<<16)>>16 , sid, rid); - /* Adding the detected pci device to the bus*/ - pci_bus_list->pci_bus[bus].pci_device[pci_bus_list->pci_bus[bus].pci_device_count]=pci_device; + dprintf + ("Scanning: BUS %02x DID %08x (%04x:%04x) SID %08x RID %02x\n", + bus, did, did >> 16, (did << 16) >> 16, + sid, rid); + /* Adding the detected pci device to the bus */ + pci_bus_list->pci_bus[bus]. + pci_device[pci_bus_list->pci_bus[bus]. + pci_device_count] = pci_device; pci_bus_list->pci_bus[bus].pci_device_count++; } } } - /* Detecting pci buses that have pci devices connected*/ - for (bus=0;bus<=0xff;bus++) { + /* Detecting pci buses that have pci devices connected */ + for (bus = 0; bus <= 0xff; bus++) { - if (pci_bus_list->pci_bus[bus].pci_device_count>0) { - pci_bus_list->count++; - } + if (pci_bus_list->pci_bus[bus].pci_device_count > 0) { + pci_bus_list->count++; + } } return 0; } diff --git a/comboot.doc b/comboot.doc index 92852012..ced893c7 100644 --- a/comboot.doc +++ b/comboot.doc @@ -665,7 +665,7 @@ AX=0016h [3.10] Run kernel image The file types are defined as follows: Equivalent - EDX Config Extensions Type of file + EDX Config Extensions Type of file 0 KERNEL Determined by filename extension 1 LINUX none Linux kernel image 2 BOOT .bs .bin Bootstrap program diff --git a/configinit.inc b/configinit.inc index b26216e6..1f080c7b 100644 --- a/configinit.inc +++ b/configinit.inc @@ -1,5 +1,5 @@ ;; ----------------------------------------------------------------------- -;; +;; ;; Copyright 1994-2006 H. Peter Anvin - All Rights Reserved ;; ;; This program is free software; you can redistribute it and/or modify @@ -55,4 +55,3 @@ mkkeymap: stosb section .data linuxauto_cmd db 'linux auto',0 linuxauto_len equ $-linuxauto_cmd - |