iPXE
image_mem_cmd.c File Reference

Read memory command. More...

#include <getopt.h>
#include <ipxe/uaccess.h>
#include <ipxe/command.h>
#include <ipxe/parseopt.h>
#include <usr/imgmgmt.h>

Go to the source code of this file.

Data Structures

struct  imgmem_options
 "imgmem" options More...

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
static int imgmem_exec (int argc, char **argv)
 The "imgmem" command.
 COMMAND (imgmem, imgmem_exec)
 Read memory command.

Variables

static struct option_descriptor imgmem_opts []
 "imgmem" option list
static struct command_descriptor imgmem_cmd
 "imgmem" command descriptor

Detailed Description

Read memory command.

Definition in file image_mem_cmd.c.

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )

◆ imgmem_exec()

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

The "imgmem" command.

Parameters
argcArgument count
argvArgument list
Return values
rcReturn status code

Definition at line 62 of file image_mem_cmd.c.

62 {
63 struct imgmem_options opts;
64 unsigned int data;
65 unsigned int len;
66 int rc;
67
68 /* Parse options */
69 if ( ( rc = parse_options ( argc, argv, &imgmem_cmd, &opts ) ) != 0 )
70 return rc;
71
72 /* Use start address as name if none specified */
73 if ( ! opts.name )
74 opts.name = argv[optind];
75
76 /* Parse address */
77 if ( ( rc = parse_integer ( argv[optind++], &data ) ) != 0 )
78 return rc;
79
80 /* Parse length */
81 if ( ( rc = parse_integer ( argv[optind++], &len ) ) != 0 )
82 return rc;
83
84 /* Create image */
85 if ( ( rc = imgmem ( opts.name, phys_to_virt ( data ), len ) ) != 0 )
86 return rc;
87
88 return 0;
89}
struct arbelprm_rc_send_wqe rc
Definition arbel.h:3
static union @024010030001061367220137227263210031030210157031 opts
"cert<xxx>" option list
ring len
Length.
Definition dwmac.h:226
uint8_t data[48]
Additional event data.
Definition ena.h:11
int optind
Current option index.
Definition getopt.c:52
static struct command_descriptor imgmem_cmd
"imgmem" command descriptor
int imgmem(const char *name, const void *data, size_t len)
Create image from block of memory.
Definition imgmgmt.c:189
int parse_integer(char *text, unsigned int *value)
Parse integer value.
Definition parseopt.c:92
int parse_options(int argc, char **argv, struct command_descriptor *cmd, void *opts)
Parse command-line options.
Definition parseopt.c:485
"imgmem" options

References data, imgmem(), imgmem_cmd, len, optind, opts, parse_integer(), parse_options(), and rc.

Referenced by COMMAND().

◆ COMMAND()

COMMAND ( imgmem ,
imgmem_exec  )

Read memory command.

References imgmem(), and imgmem_exec().

Variable Documentation

◆ imgmem_opts

struct option_descriptor imgmem_opts[]
static
Initial value:
= {
}
const char * name
Definition ath9k_hw.c:1986
@ required_argument
Option requires an argument.
Definition getopt.h:19
int parse_string(char *text, char **value)
Parse string value.
Definition parseopt.c:74
#define OPTION_DESC(_longopt, _shortopt, _has_arg, _struct, _field, _parse)
Construct option descriptor.
Definition parseopt.h:68

"imgmem" option list

Definition at line 45 of file image_mem_cmd.c.

45 {
46 OPTION_DESC ( "name", 'n', required_argument,
48};

◆ imgmem_cmd

struct command_descriptor imgmem_cmd
static
Initial value:
=
"<address> <length>" )
static struct option_descriptor imgmem_opts[]
"imgmem" option list
#define COMMAND_DESC(_struct, _options, _min_args, _max_args, _usage)
Construct command descriptor.
Definition parseopt.h:109

"imgmem" command descriptor

Definition at line 51 of file image_mem_cmd.c.

Referenced by imgmem_exec().