iPXE
Data Structures | Macros | Functions | Variables
shim_cmd.c File Reference

EFI shim command. More...

#include <getopt.h>
#include <ipxe/command.h>
#include <ipxe/parseopt.h>
#include <ipxe/efi/efi_image.h>
#include <usr/imgmgmt.h>
#include <usr/shimmgmt.h>

Go to the source code of this file.

Data Structures

struct  shim_options
 "shim" options More...
 

Macros

#define shim_dummy   1
 

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
 
static int shim_exec (int argc, char **argv)
 The "shim" command. More...
 

Variables

static struct option_descriptor shim_opts []
 "shim" option list More...
 
static struct command_descriptor shim_cmd
 "shim" command descriptor More...
 
struct command shim_commands [] __command
 Shim commands. More...
 

Detailed Description

EFI shim command.

Definition in file shim_cmd.c.

Macro Definition Documentation

◆ shim_dummy

#define shim_dummy   1

Definition at line 43 of file shim_cmd.c.

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )

◆ shim_exec()

static int shim_exec ( int  argc,
char **  argv 
)
static

The "shim" command.

Parameters
argcArgument count
argvArgument list
Return values
rcReturn status code

Definition at line 81 of file shim_cmd.c.

81  {
82  struct shim_options opts;
83  struct image *image = NULL;
84  struct image *kernel;
85  char *name_uri;
86  int download;
87  int rc;
88 
89  /* Do absolutely nothing if this is a non-EFI platform */
90  if ( shim_dummy ) {
91  rc = 0;
92  goto err_dummy;
93  }
94 
95  /* Parse options */
96  if ( ( rc = parse_options ( argc, argv, &shim_cmd, &opts ) ) != 0 )
97  goto err_parse;
98 
99  /* Decide whether or not to download images */
101  download = ( ! ( kernel && efi_can_load ( kernel ) ) );
102 
103  /* Parse name/URI string */
104  name_uri = argv[optind];
105 
106  /* Acquire image, if applicable */
107  if ( download && name_uri &&
108  ( ( rc = imgacquire ( name_uri, opts.timeout,
109  &image ) ) != 0 ) ) {
110  goto err_image;
111  }
112 
113  /* (Un)register as shim */
114  if ( ( rc = shim ( image, opts.require_loader, opts.allow_pxe,
115  opts.allow_sbat ) ) != 0 )
116  goto err_shim;
117 
118  err_shim:
119  err_image:
120  err_parse:
121  err_dummy:
122  return rc;
123 }
struct image_tag selected_image
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
int optind
Current option index.
Definition: getopt.c:51
static struct command_descriptor shim_cmd
"shim" command descriptor
Definition: shim_cmd.c:71
"shim" options
Definition: shim_cmd.c:47
int parse_options(int argc, char **argv, struct command_descriptor *cmd, void *opts)
Parse command-line options.
Definition: parseopt.c:484
An executable image.
Definition: image.h:24
struct image * find_image_tag(struct image_tag *tag)
Find image by tag.
Definition: image.c:338
uint32_t kernel
Kernel version (numeric)
Definition: ena.h:20
static int efi_can_load(struct image *image)
Check if EFI image can be loaded directly.
Definition: efi_image.h:22
static union @437 opts
"cert<xxx>" option list
#define shim_dummy
Definition: shim_cmd.c:43
int shim(struct image *image, int require_loader, int allow_pxe, int allow_sbat)
Set shim image.
Definition: shimmgmt.c:45
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321
int imgacquire(const char *name_uri, unsigned long timeout, struct image **image)
Acquire an image.
Definition: imgmgmt.c:141

References efi_can_load(), find_image_tag(), imgacquire(), kernel, NULL, optind, opts, parse_options(), rc, selected_image, shim(), shim_cmd, and shim_dummy.

Variable Documentation

◆ shim_opts

struct option_descriptor shim_opts[]
static
Initial value:
= {
OPTION_DESC ( "timeout", 't', required_argument,
OPTION_DESC ( "require-loader", 'l', no_argument,
struct shim_options, require_loader, parse_flag ),
OPTION_DESC ( "allow-pxe", 'p', no_argument,
struct shim_options, allow_pxe, parse_flag ),
OPTION_DESC ( "allow-sbat", 's', no_argument,
struct shim_options, allow_sbat, parse_flag ),
}
int parse_timeout(char *text, unsigned long *value)
Parse timeout value (in ms)
Definition: parseopt.c:114
"shim" options
Definition: shim_cmd.c:47
int parse_flag(char *text __unused, int *flag)
Parse flag.
Definition: parseopt.c:226
Option does not take an argument.
Definition: getopt.h:16
#define OPTION_DESC(_longopt, _shortopt, _has_arg, _struct, _field, _parse)
Construct option descriptor.
Definition: parseopt.h:67
Option requires an argument.
Definition: getopt.h:18
void timeout(int)

"shim" option list

Definition at line 59 of file shim_cmd.c.

◆ shim_cmd

struct command_descriptor shim_cmd
static
Initial value:
=
"shim" options
Definition: shim_cmd.c:47
static struct option_descriptor shim_opts[]
"shim" option list
Definition: shim_cmd.c:59
#define COMMAND_DESC(_struct, _options, _min_args, _max_args, _usage)
Construct command descriptor.
Definition: parseopt.h:108
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321

"shim" command descriptor

Definition at line 71 of file shim_cmd.c.

Referenced by shim_exec().

◆ __command

struct command shim_commands [] __command
Initial value:
= {
{
.name = "shim",
.exec = shim_exec,
},
}
static int shim_exec(int argc, char **argv)
The "shim" command.
Definition: shim_cmd.c:81

Shim commands.

Definition at line 126 of file shim_cmd.c.