瀏覽代碼

Now obsolete. :)

tags/v0.9.3
Michael Brown 19 年之前
父節點
當前提交
daad093c40
共有 1 個文件被更改,包括 0 次插入195 次删除
  1. 0
    195
      src/core/pci_legacy.c

+ 0
- 195
src/core/pci_legacy.c 查看文件

@@ -1,195 +0,0 @@
1
-#ifdef CONFIG_PCI
2
-
3
-/*
4
- * This program is free software; you can redistribute it and/or
5
- * modify it under the terms of the GNU General Public License as
6
- * published by the Free Software Foundation; either version 2, or (at
7
- * your option) any later version.
8
- */
9
-
10
-#include "etherboot.h"
11
-#include "pci.h"
12
-
13
-/*#define	DEBUG	1*/
14
-
15
-static void scan_drivers(
16
-	int type, 
17
-	uint32_t class, uint16_t vendor, uint16_t device,
18
-	const struct pci_driver *last_driver, struct pci_device *dev)
19
-{
20
-	const struct pci_driver *skip_driver = last_driver;
21
-	/* Assume there is only one match of the correct type */
22
-	const struct pci_driver *driver;
23
-	
24
-	for(driver = pci_drivers; driver < pci_drivers_end; driver++) {
25
-		int i;
26
-		if (driver->type != type)
27
-			continue;
28
-		if (skip_driver) {
29
-			if (skip_driver == driver)
30
-				skip_driver = 0;
31
-			continue;
32
-		}
33
-		for(i = 0; i < driver->id_count; i++) {
34
-			if ((vendor == driver->ids[i].vendor) &&
35
-				(device == driver->ids[i].dev_id)) {
36
-
37
-				dev->driver = driver;
38
-				dev->name   = driver->ids[i].name;
39
-
40
-				goto out;
41
-			}
42
-		}
43
-	}
44
-	if (!class) {
45
-		goto out;
46
-	}
47
-	for(driver = pci_drivers; driver < pci_drivers_end; driver++) {
48
-		if (driver->type != type)
49
-			continue;
50
-		if (skip_driver) {
51
-			if (skip_driver == driver)
52
-				skip_driver = 0;
53
-			continue;
54
-		}
55
-		if (last_driver == driver)
56
-			continue;
57
-		if ((class >> 8) == driver->class) {
58
-			dev->driver = driver;
59
-			dev->name   = driver->name;
60
-			goto out;
61
-		}
62
-	}
63
- out:
64
-	return;
65
-}
66
-
67
-void scan_pci_bus(int type, struct pci_device *dev)
68
-{
69
-	unsigned int first_bus, first_devfn;
70
-	const struct pci_driver *first_driver;
71
-	unsigned int devfn, bus, buses;
72
-	unsigned char hdr_type = 0;
73
-	uint32_t class;
74
-	uint16_t vendor, device;
75
-	uint32_t l, membase, ioaddr, romaddr;
76
-	uint8_t irq;
77
-	int reg;
78
-
79
-	first_bus    = 0;
80
-	first_devfn  = 0;
81
-	first_driver = 0;
82
-	if (dev->driver || dev->use_specified) {
83
-		first_driver = dev->driver;
84
-		first_bus    = dev->bus;
85
-		first_devfn  = dev->devfn;
86
-		/* Re read the header type on a restart */
87
-		pcibios_read_config_byte(first_bus, first_devfn & ~0x7, 
88
-			PCI_HEADER_TYPE, &hdr_type);
89
-		dev->driver  = 0;
90
-		dev->bus     = 0;
91
-		dev->devfn   = 0;
92
-	}
93
-		
94
-	/* Scan all PCI buses, until we find our card.
95
-	 * We could be smart only scan the required buses but that
96
-	 * is error prone, and tricky.
97
-	 * By scanning all possible pci buses in order we should find
98
-	 * our card eventually. 
99
-	 */
100
-	buses=256;
101
-	for (bus = first_bus; bus < buses; ++bus) {
102
-		for (devfn = first_devfn; devfn < 0xff; ++devfn, first_driver = 0) {
103
-			if (PCI_FUNC (devfn) == 0)
104
-				pcibios_read_config_byte(bus, devfn, PCI_HEADER_TYPE, &hdr_type);
105
-			else if (!(hdr_type & 0x80))	/* not a multi-function device */
106
-				continue;
107
-			pcibios_read_config_dword(bus, devfn, PCI_VENDOR_ID, &l);
108
-			/* some broken boards return 0 if a slot is empty: */
109
-			if (l == 0xffffffff || l == 0x00000000) {
110
-				continue;
111
-			}
112
-			vendor = l & 0xffff;
113
-			device = (l >> 16) & 0xffff;
114
-
115
-			pcibios_read_config_dword(bus, devfn, PCI_REVISION, &l);
116
-			class = (l >> 8) & 0xffffff;
117
-#if	DEBUG
118
-		{
119
-			int i;
120
-			printf("%hhx:%hhx.%hhx [%hX/%hX] Class %hX\n",
121
-				bus, PCI_SLOT(devfn), PCI_FUNC(devfn),
122
-				vendor, device, class >> 8);
123
-#if	DEBUG > 1
124
-			for(i = 0; i < 256; i++) {
125
-				unsigned char byte;
126
-				if ((i & 0xf) == 0) {
127
-					printf("%hhx: ", i);
128
-				}
129
-				pcibios_read_config_byte(bus, devfn, i, &byte);
130
-				printf("%hhx ", byte);
131
-				if ((i & 0xf) == 0xf) {
132
-					printf("\n");
133
-				}
134
-			}
135
-#endif
136
-
137
-		}
138
-#endif
139
-			scan_drivers(type, class, vendor, device, first_driver, dev);
140
-			if (!dev->driver)
141
-				continue;
142
-
143
-			dev->devfn = devfn;
144
-			dev->bus = bus;
145
-			dev->class = class;
146
-			dev->vendor = vendor;
147
-			dev->dev_id = device;
148
-			
149
-			
150
-			/* Get the ROM base address */
151
-			pcibios_read_config_dword(bus, devfn, 
152
-				PCI_ROM_ADDRESS, &romaddr);
153
-			romaddr >>= 10;
154
-			dev->romaddr = romaddr;
155
-			
156
-			/* Get the ``membase'' */
157
-			pcibios_read_config_dword(bus, devfn,
158
-				PCI_BASE_ADDRESS_1, &membase);
159
-			dev->membase = membase;
160
-				
161
-			/* Get the ``ioaddr'' */
162
-			for (reg = PCI_BASE_ADDRESS_0; reg <= PCI_BASE_ADDRESS_5; reg += 4) {
163
-				pcibios_read_config_dword(bus, devfn, reg, &ioaddr);
164
-				if ((ioaddr & PCI_BASE_ADDRESS_IO_MASK) == 0 || (ioaddr & PCI_BASE_ADDRESS_SPACE_IO) == 0)
165
-					continue;
166
-				
167
-				
168
-				/* Strip the I/O address out of the returned value */
169
-				ioaddr &= PCI_BASE_ADDRESS_IO_MASK;
170
-				
171
-				/* Take the first one or the one that matches in boot ROM address */
172
-				dev->ioaddr = ioaddr;
173
-			}
174
-
175
-			/* Get the irq */
176
-			pci_read_config_byte(dev, PCI_INTERRUPT_PIN, &irq);
177
-			if (irq) {
178
-				pci_read_config_byte(dev, PCI_INTERRUPT_LINE,
179
-						     &irq);
180
-			}
181
-			dev->irq = irq;
182
-
183
-#if DEBUG > 2
184
-			printf("Found %s ROM address %#hx\n",
185
-				dev->name, romaddr);
186
-#endif
187
-			return;
188
-		}
189
-		first_devfn = 0;
190
-	}
191
-	first_bus = 0;
192
-}
193
-
194
-
195
-#endif /* CONFIG_PCI */

Loading…
取消
儲存