1 /* pci.c - Generic PCI interfaces. */
3 * GRUB -- GRand Unified Bootloader
4 * Copyright (C) 2007 Free Software Foundation, Inc.
6 * GRUB is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
11 * GRUB is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
24 grub_pci_make_address (int bus
, int device
, int function
, int reg
)
26 return (1 << 31) | (bus
<< 16) | (device
<< 11) | (function
<< 8) | (reg
<< 2);
30 grub_pci_iterate (grub_pci_iteratefunc_t hook
)
35 grub_pci_address_t addr
;
39 for (bus
= 0; bus
< 256; bus
++)
41 for (dev
= 0; dev
< 32; dev
++)
43 for (func
= 0; func
< 8; func
++)
45 addr
= grub_pci_make_address (bus
, dev
, func
, 0);
46 id
= grub_pci_read (addr
);
48 /* Check if there is a device present. */
49 if (id
>> 16 == 0xFFFF)
52 if (hook (bus
, dev
, func
, id
))
55 /* Probe only func = 0 if the device if not multifunction */
58 addr
= grub_pci_make_address (bus
, dev
, func
, 3);
59 hdr
= grub_pci_read (addr
);
60 if (!(hdr
& 0x800000))