enable_grub_emu=no
grub_emu_usb_excuse="grub-emu isn't built"
fi
+if test x"$enable_grub_emu_pci" = xyes ; then
+ grub_emu_usb_excuse="conflicts with PCI support"
+fi
+
if test x"$enable_grub_emu_usb" = xno ; then
grub_emu_usb_excuse="explicitly disabled"
fi
+
[if [ x"$grub_emu_usb_excuse" = x ]; then
# Check for libusb libraries.]
AC_CHECK_LIB([usb], [usb_claim_interface], [LIBUSB="-lusb"],
fi
if test x"$enable_grub_emu_pci" != xyes ; then
- enable_grub_emu_pci = no
+ grub_emu_pci_excuse="not enabled"
+fi
+
+if test x"$enable_grub_emu_usb" = xyes ; then
+ grub_emu_pci_excuse="conflicts with USB support"
+fi
+
+[if [ x"$grub_emu_pci_excuse" = x ]; then
+ # Check for libpci libraries.]
+ AC_CHECK_LIB([pci], [pci_alloc], [LIBPCI="-lpci"],
+ [grub_emu_pci_excuse=["need libpci library"]])
+ AC_SUBST([LIBPCI])
+[fi]
+[if [ x"$grub_emu_pci_excuse" = x ]; then
+ # Check for headers.]
+ AC_CHECK_HEADERS([pci/pci.h], [],
+ [grub_emu_pci_excuse=["need libpci headers"]])
+[fi]
+
+if test x"$grub_emu_pci_excuse" = x ; then
+enable_grub_emu_pci=yes
+else
+enable_grub_emu_pci=no
fi
AC_SUBST([enable_grub_emu])
else
echo USB support for grub-emu: No "($grub_emu_usb_excuse)"
fi
+if [ x"$grub_emu_pci_excuse" = x ]; then
+echo PCI support for grub-emu: Yes
+else
+echo PCI support for grub-emu: No "($grub_emu_pci_excuse)"
+fi
+
if [ x"$enable_mm_debug" = xyes ]; then
echo With memory debugging: Yes
else
--- /dev/null
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2008,2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef GRUB_PCIUTILS_H
+#define GRUB_PCIUTILS_H 1
+
+#include <pci/pci.h>
+
+typedef struct pci_dev *grub_pci_device_t;
+
+static inline int
+grub_pci_get_bus (grub_pci_device_t dev)
+{
+ return dev->bus;
+}
+
+static inline int
+grub_pci_get_device (grub_pci_device_t dev)
+{
+ return dev->dev;
+}
+
+static inline int
+grub_pci_get_function (grub_pci_device_t dev)
+{
+ return dev->func;
+}
+
+struct grub_pci_address
+{
+ grub_pci_device_t dev;
+ int pos;
+};
+
+typedef struct grub_pci_address grub_pci_address_t;
+
+static inline grub_uint32_t
+grub_pci_read (grub_pci_address_t addr)
+{
+ return pci_read_long (addr.dev, addr.pos);
+}
+
+static inline grub_uint16_t
+grub_pci_read_word (grub_pci_address_t addr)
+{
+ return pci_read_word (addr.dev, addr.pos);
+}
+
+static inline grub_uint8_t
+grub_pci_read_byte (grub_pci_address_t addr)
+{
+ return pci_read_byte (addr.dev, addr.pos);
+}
+
+static inline void
+grub_pci_write (grub_pci_address_t addr, grub_uint32_t data)
+{
+ pci_write_long (addr.dev, addr.pos, data);
+}
+
+static inline void
+grub_pci_write_word (grub_pci_address_t addr, grub_uint16_t data)
+{
+ pci_write_word (addr.dev, addr.pos, data);
+}
+
+static inline void
+grub_pci_write_byte (grub_pci_address_t addr, grub_uint8_t data)
+{
+ pci_write_byte (addr.dev, addr.pos, data);
+}
+
+#endif /* GRUB_PCIUTILS_H */