Cleaned up extended lspci
This commit is contained in:
parent
cdef0f7f52
commit
9b0a46a19d
1 changed files with 51 additions and 37 deletions
|
@ -115,6 +115,14 @@ grub_pci_get_class (int class, int subclass)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const struct grub_arg_option options[] =
|
||||||
|
{
|
||||||
|
{"iospace", 'i', 0, "show I/O spaces", 0, 0},
|
||||||
|
{0, 0, 0, 0, 0, 0}
|
||||||
|
};
|
||||||
|
|
||||||
|
static int iospace;
|
||||||
|
|
||||||
static int NESTED_FUNC_ATTR
|
static int NESTED_FUNC_ATTR
|
||||||
grub_lspci_iter (int bus, int dev, int func, grub_pci_id_t pciid)
|
grub_lspci_iter (int bus, int dev, int func, grub_pci_id_t pciid)
|
||||||
{
|
{
|
||||||
|
@ -144,6 +152,8 @@ grub_lspci_iter (int bus, int dev, int func, grub_pci_id_t pciid)
|
||||||
|
|
||||||
grub_printf ("\n");
|
grub_printf ("\n");
|
||||||
|
|
||||||
|
if (iospace)
|
||||||
|
{
|
||||||
reg = 4;
|
reg = 4;
|
||||||
for (i = 0; i < 6; i++)
|
for (i = 0; i < 6; i++)
|
||||||
{
|
{
|
||||||
|
@ -159,8 +169,8 @@ grub_lspci_iter (int bus, int dev, int func, grub_pci_id_t pciid)
|
||||||
switch (space & GRUB_PCI_ADDR_SPACE_MASK)
|
switch (space & GRUB_PCI_ADDR_SPACE_MASK)
|
||||||
{
|
{
|
||||||
case GRUB_PCI_ADDR_SPACE_IO:
|
case GRUB_PCI_ADDR_SPACE_IO:
|
||||||
grub_printf ("IO space %d at 0x%llx\n", i,
|
grub_printf ("\tIO space %d at 0x%llx\n", i, (unsigned long long)
|
||||||
(unsigned long long) (space & GRUB_PCI_ADDR_IO_MASK));
|
(space & GRUB_PCI_ADDR_IO_MASK));
|
||||||
break;
|
break;
|
||||||
case GRUB_PCI_ADDR_SPACE_MEMORY:
|
case GRUB_PCI_ADDR_SPACE_MEMORY:
|
||||||
if ((space & GRUB_PCI_ADDR_MEM_TYPE_MASK)
|
if ((space & GRUB_PCI_ADDR_MEM_TYPE_MASK)
|
||||||
|
@ -168,43 +178,47 @@ grub_lspci_iter (int bus, int dev, int func, grub_pci_id_t pciid)
|
||||||
{
|
{
|
||||||
space |= grub_pci_make_address (dev, reg);
|
space |= grub_pci_make_address (dev, reg);
|
||||||
reg++;
|
reg++;
|
||||||
grub_printf ("64-bit memory space %d at 0x%16llx [%s]\n", i,
|
grub_printf ("\t64-bit memory space %d at 0x0%16llx [%s]\n",
|
||||||
(unsigned long long) (space & GRUB_PCI_ADDR_MEM_MASK),
|
i, (unsigned long long)
|
||||||
|
(space & GRUB_PCI_ADDR_MEM_MASK),
|
||||||
space & GRUB_PCI_ADDR_MEM_PREFETCH
|
space & GRUB_PCI_ADDR_MEM_PREFETCH
|
||||||
? "prefetchable" : "non-prefetchable");
|
? "prefetchable" : "non-prefetchable");
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
grub_printf ("32-bit memory space %d at 0x%16llx [%s]\n", i,
|
grub_printf ("\t32-bit memory space %d at 0x0%16llx [%s]\n", i,
|
||||||
(unsigned long long) (space & GRUB_PCI_ADDR_MEM_MASK),
|
(unsigned long long)
|
||||||
|
(space & GRUB_PCI_ADDR_MEM_MASK),
|
||||||
space & GRUB_PCI_ADDR_MEM_PREFETCH
|
space & GRUB_PCI_ADDR_MEM_PREFETCH
|
||||||
? "prefetchable" : "non-prefetchable");
|
? "prefetchable" : "non-prefetchable");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static grub_err_t
|
static grub_err_t
|
||||||
grub_cmd_lspci (grub_command_t cmd __attribute__ ((unused)),
|
grub_cmd_lspci (grub_extcmd_t cmd,
|
||||||
int argc __attribute__ ((unused)),
|
int argc __attribute__ ((unused)),
|
||||||
char **args __attribute__ ((unused)))
|
char **args __attribute__ ((unused)))
|
||||||
{
|
{
|
||||||
|
iospace = cmd->state[0].set;
|
||||||
grub_pci_iterate (grub_lspci_iter);
|
grub_pci_iterate (grub_lspci_iter);
|
||||||
return GRUB_ERR_NONE;
|
return GRUB_ERR_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static grub_command_t cmd;
|
static grub_extcmd_t cmd;
|
||||||
|
|
||||||
GRUB_MOD_INIT(pci)
|
GRUB_MOD_INIT(pci)
|
||||||
{
|
{
|
||||||
cmd = grub_register_command ("lspci", grub_cmd_lspci,
|
cmd = grub_register_extcmd ("lspci", grub_cmd_lspci, GRUB_COMMAND_FLAG_BOTH,
|
||||||
0, "List PCI devices");
|
"lspci [-i]", "List PCI devices", options);
|
||||||
}
|
}
|
||||||
|
|
||||||
GRUB_MOD_FINI(pci)
|
GRUB_MOD_FINI(pci)
|
||||||
{
|
{
|
||||||
grub_unregister_command (cmd);
|
grub_unregister_extcmd (cmd);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue