lspci works in grub-emu
This commit is contained in:
parent
3affd0ece8
commit
325c8258e7
5 changed files with 125 additions and 16 deletions
|
@ -143,8 +143,6 @@ grub_lspci_iter (grub_pci_device_t dev, grub_pci_id_t pciid)
|
||||||
|
|
||||||
grub_printf ("\n");
|
grub_printf ("\n");
|
||||||
|
|
||||||
grub_pci_close (dev);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -159,13 +157,13 @@ grub_cmd_lspci (grub_command_t cmd __attribute__ ((unused)),
|
||||||
|
|
||||||
static grub_command_t cmd;
|
static grub_command_t cmd;
|
||||||
|
|
||||||
GRUB_MOD_INIT(pci)
|
GRUB_MOD_INIT(lspci)
|
||||||
{
|
{
|
||||||
cmd = grub_register_command ("lspci", grub_cmd_lspci,
|
cmd = grub_register_command ("lspci", grub_cmd_lspci,
|
||||||
0, "List PCI devices");
|
0, "List PCI devices");
|
||||||
}
|
}
|
||||||
|
|
||||||
GRUB_MOD_FINI(pci)
|
GRUB_MOD_FINI(lspci)
|
||||||
{
|
{
|
||||||
grub_unregister_command (cmd);
|
grub_unregister_command (cmd);
|
||||||
}
|
}
|
||||||
|
|
35
configure.ac
35
configure.ac
|
@ -531,9 +531,14 @@ else
|
||||||
enable_grub_emu=no
|
enable_grub_emu=no
|
||||||
grub_emu_usb_excuse="grub-emu isn't built"
|
grub_emu_usb_excuse="grub-emu isn't built"
|
||||||
fi
|
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
|
if test x"$enable_grub_emu_usb" = xno ; then
|
||||||
grub_emu_usb_excuse="explicitly disabled"
|
grub_emu_usb_excuse="explicitly disabled"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
[if [ x"$grub_emu_usb_excuse" = x ]; then
|
[if [ x"$grub_emu_usb_excuse" = x ]; then
|
||||||
# Check for libusb libraries.]
|
# Check for libusb libraries.]
|
||||||
AC_CHECK_LIB([usb], [usb_claim_interface], [LIBUSB="-lusb"],
|
AC_CHECK_LIB([usb], [usb_claim_interface], [LIBUSB="-lusb"],
|
||||||
|
@ -555,7 +560,29 @@ enable_grub_emu_usb=no
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if test x"$enable_grub_emu_pci" != xyes ; then
|
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
|
fi
|
||||||
|
|
||||||
AC_SUBST([enable_grub_emu])
|
AC_SUBST([enable_grub_emu])
|
||||||
|
@ -634,6 +661,12 @@ echo USB support for grub-emu: Yes
|
||||||
else
|
else
|
||||||
echo USB support for grub-emu: No "($grub_emu_usb_excuse)"
|
echo USB support for grub-emu: No "($grub_emu_usb_excuse)"
|
||||||
fi
|
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
|
if [ x"$enable_mm_debug" = xyes ]; then
|
||||||
echo With memory debugging: Yes
|
echo With memory debugging: Yes
|
||||||
else
|
else
|
||||||
|
|
|
@ -67,9 +67,4 @@ grub_pci_write_byte (grub_pci_address_t addr, grub_uint8_t data)
|
||||||
grub_outb (data, GRUB_PCI_DATA_REG + (addr & 3));
|
grub_outb (data, GRUB_PCI_DATA_REG + (addr & 3));
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void
|
|
||||||
grub_pci_close (grub_pci_device_t dev __attribute__ ((unused)))
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif /* GRUB_CPU_PCI_H */
|
#endif /* GRUB_CPU_PCI_H */
|
||||||
|
|
88
include/grub/pciutils.h
Normal file
88
include/grub/pciutils.h
Normal file
|
@ -0,0 +1,88 @@
|
||||||
|
/*
|
||||||
|
* 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 */
|
|
@ -31,12 +31,6 @@ grub_pci_make_address (grub_pci_device_t dev, int reg)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
grub_pci_close (grub_pci_device_t dev)
|
|
||||||
{
|
|
||||||
pci_free_dev (dev);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
grub_pci_iterate (grub_pci_iteratefunc_t hook)
|
grub_pci_iterate (grub_pci_iteratefunc_t hook)
|
||||||
{
|
{
|
||||||
|
@ -49,6 +43,7 @@ GRUB_MOD_INIT (pci)
|
||||||
{
|
{
|
||||||
acc = pci_alloc ();
|
acc = pci_alloc ();
|
||||||
pci_init (acc);
|
pci_init (acc);
|
||||||
|
pci_scan_bus (acc);
|
||||||
}
|
}
|
||||||
|
|
||||||
GRUB_MOD_FINI (pci)
|
GRUB_MOD_FINI (pci)
|
||||||
|
|
Loading…
Reference in a new issue