/* lspci.c - List PCI devices. */
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2008, 2009 Free Software Foundation, Inc.
*
* 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/>.
*/
GRUB_MOD_LICENSE ("GPLv3+");
struct pci_register
{
const char *name;
unsigned size;
};
{
};
{
{0, 0, 0, 0, 0, 0}
};
static int regsize;
static const char *varname;
static int NESTED_FUNC_ATTR
{
return 0;
return 0;
return 0;
return 0;
switch (regsize)
{
case 1:
break;
case 2:
break;
case 4:
break;
}
if (varname)
{
return 1;
}
if (!write_mask)
{
regval);
return 0;
}
switch (regsize)
{
case 1:
break;
case 2:
break;
case 4:
break;
}
return 0;
}
static grub_err_t
{
const char *ptr;
unsigned i;
pciid_check_value = 0;
pciid_check_mask = 0;
{
if (grub_errno == GRUB_ERR_BAD_NUMBER)
{
}
else
pciid_check_mask |= 0xffff;
if (grub_errno)
return grub_errno;
if (*ptr != ':')
ptr++;
<< 16;
if (grub_errno == GRUB_ERR_BAD_NUMBER)
else
pciid_check_mask |= 0xffff0000;
}
{
const char *optr;
if (grub_errno == GRUB_ERR_BAD_NUMBER)
{
}
else
check_bus = 1;
if (grub_errno)
return grub_errno;
if (*ptr != ':')
ptr++;
if (grub_errno == GRUB_ERR_BAD_NUMBER)
{
}
else
check_device = 1;
if (*ptr == '.')
{
ptr++;
if (grub_errno)
return grub_errno;
check_function = 1;
}
}
else
write_mask = 0;
if (argc == 0)
if (argc > 1)
for (i = 0; i < ARRAY_SIZE (pci_registers); i++)
{
break;
}
if (i == ARRAY_SIZE (pci_registers))
{
regsize = 0;
if (grub_errno)
}
else
{
}
if (grub_errno)
return grub_errno;
if (*ptr == '+')
{
ptr++;
if (grub_errno)
return grub_errno;
}
{
regsize = 4;
}
{
regsize = 2;
}
{
regsize = 1;
}
if (!regsize)
return grub_error (GRUB_ERR_BAD_ARGUMENT,
"Unknown register size.");
write_mask = 0;
if (*ptr == '=')
{
ptr++;
if (grub_errno)
return grub_errno;
write_mask = 0xffffffff;
if (*ptr == ':')
{
ptr++;
if (grub_errno)
return grub_errno;
write_mask = 0xffffffff;
}
regwrite &= write_mask;
}
if (write_mask && varname)
return grub_error (GRUB_ERR_BAD_ARGUMENT,
"Option -v isn't valid for writes.");
return GRUB_ERR_NONE;
}
{
N_("[-s POSITION] [-d DEVICE] [-v VAR] "
"[REGISTER][=VALUE[:MASK]]"),
}
{
}