1 #include <linux/sched.h>
12 #include <linux/pci.h>
13 #include <linux/export.h>
18 #include <asm/mmzone.h>
19 #include <asm/setup.h>
20 #include <asm/sections.h>
24 static struct resource system_rom_resource = {
31 static struct resource extension_rom_resource = {
32 .name =
"Extension ROM",
38 static struct resource adapter_rom_resources[] = { {
39 .name =
"Adapter ROM",
44 .name =
"Adapter ROM",
49 .name =
"Adapter ROM",
54 .name =
"Adapter ROM",
59 .name =
"Adapter ROM",
64 .name =
"Adapter ROM",
70 static struct resource video_rom_resource = {
92 return id &&
id->vendor;
95 static bool probe_list(
struct pci_dev *pdev,
unsigned short vendor,
96 const unsigned char *rom_list)
104 if (device && match_id(pdev, vendor, device))
118 for (i = 0; i <
ARRAY_SIZE(adapter_rom_resources); i++) {
121 const unsigned char *
rom;
136 if (match_id(pdev, vendor, device)) {
144 probe_list(pdev, vendor, rom + offset + list)) {
155 struct resource *oprom = find_oprom(pdev);
172 struct resource *oprom = find_oprom(pdev);
174 return oprom ? resource_size(oprom) : 0;
178 #define ROMSIGNATURE 0xaa55
180 static int __init romsignature(
const unsigned char *rom)
182 const unsigned short *
const ptr = (
const unsigned short *)rom;
188 static int __init romchecksum(
const unsigned char *rom,
unsigned long length)
190 unsigned char sum,
c;
194 return !length && !
sum;
199 const unsigned char *
rom;
205 upper = adapter_rom_resources[0].
start;
206 for (start = video_rom_resource.
start; start < upper; start += 2048) {
208 if (!romsignature(rom))
220 if (length && romchecksum(rom, length))
221 video_rom_resource.
end = start + length - 1;
227 start = (video_rom_resource.
end + 1 + 2047) & ~2047
UL;
233 upper = system_rom_resource.
start;
237 if (romsignature(rom)) {
238 length = resource_size(&extension_rom_resource);
239 if (romchecksum(rom, length)) {
241 upper = extension_rom_resource.
start;
246 for (i = 0; i <
ARRAY_SIZE(adapter_rom_resources) && start < upper; start += 2048) {
248 if (!romsignature(rom))
258 if (!length || start + length > upper || !romchecksum(rom, length))
262 adapter_rom_resources[
i].
end = start + length - 1;
265 start = adapter_rom_resources[i++].
end & ~2047
UL;