2N/A/* pci.c - Generic PCI interfaces. */
2N/A/*
2N/A * GRUB -- GRand Unified Bootloader
2N/A * Copyright (C) 2007,2009 Free Software Foundation, Inc.
2N/A *
2N/A * GRUB is free software: you can redistribute it and/or modify
2N/A * it under the terms of the GNU General Public License as published by
2N/A * the Free Software Foundation, either version 3 of the License, or
2N/A * (at your option) any later version.
2N/A *
2N/A * GRUB is distributed in the hope that it will be useful,
2N/A * but WITHOUT ANY WARRANTY; without even the implied warranty of
2N/A * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2N/A * GNU General Public License for more details.
2N/A *
2N/A * You should have received a copy of the GNU General Public License
2N/A * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
2N/A */
2N/A
2N/A#include <grub/pci.h>
2N/A#include <grub/dl.h>
2N/A#include <grub/emu/misc.h>
2N/A#include <grub/util/misc.h>
2N/A
2N/Agrub_pci_address_t
2N/Agrub_pci_make_address (grub_pci_device_t dev, int reg)
2N/A{
2N/A grub_pci_address_t ret;
2N/A ret.dev = dev;
2N/A ret.pos = reg;
2N/A return ret;
2N/A}
2N/A
2N/Avoid
2N/Agrub_pci_iterate (grub_pci_iteratefunc_t hook)
2N/A{
2N/A struct pci_device_iterator *iter;
2N/A struct pci_slot_match slot;
2N/A struct pci_device *dev;
2N/A slot.domain = PCI_MATCH_ANY;
2N/A slot.bus = PCI_MATCH_ANY;
2N/A slot.dev = PCI_MATCH_ANY;
2N/A slot.func = PCI_MATCH_ANY;
2N/A iter = pci_slot_match_iterator_create (&slot);
2N/A while ((dev = pci_device_next (iter)))
2N/A hook (dev, dev->vendor_id | (dev->device_id << 16));
2N/A pci_iterator_destroy (iter);
2N/A}
2N/A
2N/Avoid *
2N/Agrub_pci_device_map_range (grub_pci_device_t dev, grub_addr_t base,
2N/A grub_size_t size)
2N/A{
2N/A void *addr;
2N/A int err;
2N/A err = pci_device_map_range (dev, base, size, PCI_DEV_MAP_FLAG_WRITABLE, &addr);
2N/A if (err)
2N/A grub_util_error ("mapping 0x%x failed (error %d)\n", base, err);
2N/A return addr;
2N/A}
2N/A
2N/Avoid
2N/Agrub_pci_device_unmap_range (grub_pci_device_t dev, void *mem,
2N/A grub_size_t size)
2N/A{
2N/A pci_device_unmap_range (dev, mem, size);
2N/A}
2N/A
2N/AGRUB_MOD_INIT (pci)
2N/A{
2N/A pci_system_init ();
2N/A}
2N/A
2N/AGRUB_MOD_FINI (pci)
2N/A{
2N/A pci_system_cleanup ();
2N/A}