1 /* pci.c - Generic PCI interfaces. */
3 * GRUB -- GRand Unified Bootloader
4 * Copyright (C) 2007,2009 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/>.
22 #include <grub/util/misc.h>
25 grub_pci_make_address (grub_pci_device_t dev
, int reg
)
27 grub_pci_address_t ret
;
34 grub_pci_iterate (grub_pci_iteratefunc_t hook
)
36 struct pci_device_iterator
*iter
;
37 struct pci_slot_match slot
;
38 struct pci_device
*dev
;
39 slot
.domain
= PCI_MATCH_ANY
;
40 slot
.bus
= PCI_MATCH_ANY
;
41 slot
.dev
= PCI_MATCH_ANY
;
42 slot
.func
= PCI_MATCH_ANY
;
43 iter
= pci_slot_match_iterator_create (&slot
);
44 while ((dev
= pci_device_next (iter
)))
45 hook (dev
, dev
->vendor_id
| (dev
->device_id
<< 16));
46 pci_iterator_destroy (iter
);
50 grub_pci_device_map_range (grub_pci_device_t dev
, grub_addr_t base
,
55 err
= pci_device_map_range (dev
, base
, size
, PCI_DEV_MAP_FLAG_WRITABLE
, &addr
);
57 grub_util_error ("mapping 0x%x failed (error %d)\n", base
, err
);
62 grub_pci_device_unmap_range (grub_pci_device_t dev
, void *mem
,
65 pci_device_unmap_range (dev
, mem
, size
);
75 pci_system_cleanup ();