iPXE
Data Structures | Functions | Variables
pci_cmd.c File Reference

PCI commands. More...

#include <stdio.h>
#include <getopt.h>
#include <ipxe/pci.h>
#include <ipxe/command.h>
#include <ipxe/parseopt.h>

Go to the source code of this file.

Data Structures

struct  pciscan_options
 "pciscan" options More...

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
static int pciscan_exec (int argc, char **argv)
 "pciscan" command

Variables

static struct option_descriptor pciscan_opts [] = {}
 "pciscan" option list
static struct command_descriptor pciscan_cmd
 "pciscan" command descriptor
struct command pci_commands[] __command
 PCI commands.

Detailed Description

PCI commands.

Definition in file pci_cmd.c.


Function Documentation

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )
static int pciscan_exec ( int  argc,
char **  argv 
) [static]

"pciscan" command

Parameters:
argcArgument count
argvArgument list
Return values:
rcReturn status code

Definition at line 56 of file pci_cmd.c.

References fetchn_setting(), len, setting::name, next, NULL, optind, parse_autovivified_setting(), parse_options(), pci_find_next(), printf(), rc, named_setting::setting, named_setting::settings, storen_setting(), strerror(), and setting::type.

                                                  {
        struct pciscan_options opts;
        struct named_setting setting;
        struct pci_device pci;
        unsigned long prev;
        int next;
        int len;
        int rc;

        /* Parse options */
        if ( ( rc = parse_options ( argc, argv, &pciscan_cmd, &opts ) ) != 0 )
                goto err_parse_options;

        /* Parse setting name */
        if ( ( rc = parse_autovivified_setting ( argv[optind],
                                                 &setting ) ) != 0 )
                goto err_parse_setting;

        /* Determine starting bus:dev.fn address */
        if ( ( len = fetchn_setting ( setting.settings, &setting.setting,
                                      NULL, &setting.setting, &prev ) ) < 0 ) {
                /* Setting not yet defined: start searching from 00:00.0 */
                prev = 0;
        } else {
                /* Setting is defined: start searching from next location */
                prev++;
        }

        /* Find next existent PCI device */
        if ( ( next = pci_find_next ( &pci, prev ) ) < 0 ) {
                rc = next;
                goto err_find_next;
        }

        /* Apply default type if necessary.  Use ":uint16" rather than
         * ":busdevfn" to allow for easy inclusion within a
         * "${pci/${location}.x.y}" constructed setting.
         */
        if ( ! setting.setting.type )
                setting.setting.type = &setting_type_uint16;

        /* Store setting */
        if ( ( rc = storen_setting ( setting.settings, &setting.setting,
                                     next ) ) != 0 ) {
                printf ( "Could not store \"%s\": %s\n",
                         setting.setting.name, strerror ( rc ) );
                goto err_store;
        }

 err_store:
 err_find_next:
 err_parse_setting:
 err_parse_options:
        return rc;
}

Variable Documentation

struct option_descriptor pciscan_opts[] = {} [static]

"pciscan" option list

Definition at line 42 of file pci_cmd.c.

Initial value:
        COMMAND_DESC ( struct pciscan_options, pciscan_opts, 1, 1,
                       "<setting>" )

"pciscan" command descriptor

Definition at line 45 of file pci_cmd.c.

struct command pci_commands [] __command
Initial value:
 {
        {
                .name = "pciscan",
                .exec = pciscan_exec,
        },
}

PCI commands.

Definition at line 113 of file pci_cmd.c.