aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorErwan Velu <erwan@seanodes.com>2007-02-08 21:39:47 +0100
committerH. Peter Anvin <hpa@zytor.com>2007-03-07 11:04:11 -0800
commitfaece000985cc54fc4c75172e16b379bbdad63c2 (patch)
treeece08dd7176cf22e72f3dec08cf784ac392c2619
parent703a777878cb84a59e1eb98926e81e0e223b1d0b (diff)
downloadsyslinux-faece000985cc54fc4c75172e16b379bbdad63c2.tar.gz
syslinux-faece000985cc54fc4c75172e16b379bbdad63c2.tar.xz
syslinux-faece000985cc54fc4c75172e16b379bbdad63c2.zip
Ethersel must use the pci com32 module instead of builtin pci detection code
From : Erwan Velu <erwan.velu@free.fr> This patch - remove the pci detection code from ethersel - add a find_pci_device() function in the PCI com32 module - make ethersel using the pci com32 module instead of builtin pci detection code Testing and feedback are welcome. Signed-off-by:Erwan Velu <erwan.velu@free.fr>
-rw-r--r--com32/include/sys/pci.h11
-rw-r--r--com32/modules/Makefile3
-rw-r--r--com32/modules/ethersel.c77
-rw-r--r--com32/modules/pci.c20
4 files changed, 38 insertions, 73 deletions
diff --git a/com32/include/sys/pci.h b/com32/include/sys/pci.h
index b3099584..4862cda9 100644
--- a/com32/include/sys/pci.h
+++ b/com32/include/sys/pci.h
@@ -37,6 +37,16 @@ typedef struct {
uint8_t count;
} s_pci_bus_list;
+struct match {
+ struct match *next;
+ uint32_t did;
+ uint32_t did_mask;
+ uint32_t sid;
+ uint32_t sid_mask;
+ uint8_t rid_min, rid_max;
+ char *filename;
+};
+
static inline pciaddr_t pci_mkaddr(uint32_t bus, uint32_t dev,
uint32_t func, uint32_t reg)
{
@@ -62,4 +72,5 @@ void pci_writew(uint16_t, pciaddr_t);
void pci_writel(uint32_t, pciaddr_t);
extern int pci_scan(s_pci_bus_list *pci_bus_list, s_pci_device_list *pci_device_list);
+extern struct match * find_pci_device(s_pci_device_list *pci_device_list, struct match *list);
#endif /* _SYS_PCI_H */
diff --git a/com32/modules/Makefile b/com32/modules/Makefile
index 877ce399..297e1b1d 100644
--- a/com32/modules/Makefile
+++ b/com32/modules/Makefile
@@ -91,6 +91,9 @@ menu.elf : menu.o menumain.o readconfig.o $(LIBS)
vesamenu.elf : vesamenu.o menumain.o readconfig.o $(LIBS)
$(LD) $(LDFLAGS) -o $@ $^
+ethersel.elf : ethersel.o pci.o $(LIBS)
+ $(LD) $(LDFLAGS) -o $@ $^
+
menu.lnx : menu.lo readconfig.lo $(LNXLIBS)
$(CC) $(LNXLDFLAGS) -o $@ $^
diff --git a/com32/modules/ethersel.c b/com32/modules/ethersel.c
index 4d17ca5c..c3f99fe7 100644
--- a/com32/modules/ethersel.c
+++ b/com32/modules/ethersel.c
@@ -42,16 +42,6 @@
# define dprintf(...) ((void)0)
#endif
-struct match {
- struct match *next;
- uint32_t did;
- uint32_t did_mask;
- uint32_t sid;
- uint32_t sid_mask;
- uint8_t rid_min, rid_max;
- char *filename;
-};
-
static const char *
get_config(void)
{
@@ -201,68 +191,6 @@ parse_config(const char *filename)
return list;
}
-static struct match *
-pciscan(struct match *list)
-{
- unsigned int bus, dev, func, maxfunc;
- uint32_t did, sid;
- uint8_t hdrtype, rid;
- pciaddr_t a;
- struct match *m;
- int cfgtype;
-
-#ifdef DEBUG
- outl(~0, 0xcf8);
- printf("Poking at port CF8 = %#08x\n", inl(0xcf8));
- outl(0, 0xcf8);
-#endif
-
- cfgtype = pci_set_config_type(PCI_CFG_AUTO);
- (void)cfgtype;
-
- dprintf("PCI configuration type %d\n", cfgtype);
-
- for ( bus = 0 ; bus <= 0xff ; bus++ ) {
-
- dprintf("Probing bus 0x%02x... \n", bus);
-
- for ( dev = 0 ; dev <= 0x1f ; dev++ ) {
- maxfunc = 0;
- 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 )
- continue;
-
- hdrtype = pci_readb(a + 0x0e);
-
- if ( hdrtype & 0x80 )
- maxfunc = 7; /* Multifunction device */
-
- if ( hdrtype & 0x7f )
- continue; /* Ignore bridge devices */
-
- rid = pci_readb(a + 0x08);
- sid = pci_readl(a + 0x2c);
-
- dprintf("Scanning: DID %08x SID %08x RID %02x\n", did, sid, rid);
-
- for ( m = list ; m ; m = m->next ) {
- if ( ((did ^ m->did) & m->did_mask) == 0 &&
- ((sid ^ m->sid) & m->sid_mask) == 0 &&
- rid >= m->rid_min && rid <= m->rid_max )
- return m;
- }
- }
- }
- }
-
- return NULL;
-}
-
static void __attribute__((noreturn))
execute(const char *cmdline)
{
@@ -279,12 +207,15 @@ execute(const char *cmdline)
int main(int argc, char *argv[])
{
struct match *list, *match;
+ s_pci_device_list pci_device_list;
+ s_pci_bus_list pci_bus_list;
openconsole(&dev_null_r, &dev_stdcon_w);
+ pci_scan(&pci_bus_list,&pci_device_list);
list = parse_config(argc < 2 ? NULL : argv[1]);
- match = pciscan(list);
+ match = find_pci_device(&pci_device_list,list);
if ( match )
execute(match->filename);
diff --git a/com32/modules/pci.c b/com32/modules/pci.c
index 3d83db1b..4eb8f986 100644
--- a/com32/modules/pci.c
+++ b/com32/modules/pci.c
@@ -113,6 +113,26 @@ void get_name_from_pci_ids(s_pci_device *pci_device)
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;
+}
+
int pci_scan(s_pci_bus_list *pci_bus_list, s_pci_device_list *pci_device_list)
{
unsigned int bus, dev, func, maxfunc;