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

Read memory command. More...

#include <getopt.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. More...
 

Variables

static struct option_descriptor imgmem_opts []
 "imgmem" option list More...
 
static struct command_descriptor imgmem_cmd
 "imgmem" command descriptor More...
 
struct command imgmem_commands [] __command
 Read memory command. More...
 

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()

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

The "imgmem" command.

Parameters
argcArgument count
argvArgument list
Return values
rcReturn status code

Definition at line 61 of file image_mem_cmd.c.

61  {
62  struct imgmem_options opts;
63  unsigned int data;
64  unsigned int len;
65  int rc;
66 
67  /* Parse options */
68  if ( ( rc = parse_options ( argc, argv, &imgmem_cmd, &opts ) ) != 0 )
69  return rc;
70 
71  /* Use start address as name if none specified */
72  if ( ! opts.name )
73  opts.name = argv[optind];
74 
75  /* Parse address */
76  if ( ( rc = parse_integer ( argv[optind++], &data ) ) != 0 )
77  return rc;
78 
79  /* Parse length */
80  if ( ( rc = parse_integer ( argv[optind++], &len ) ) != 0 )
81  return rc;
82 
83  /* Create image */
84  if ( ( rc = imgmem ( opts.name, phys_to_user ( data ), len ) ) != 0 )
85  return rc;
86 
87  return 0;
88 }
int parse_integer(char *text, unsigned int *value)
Parse integer value.
Definition: parseopt.c:91
int imgmem(const char *name, userptr_t data, size_t len)
Create image from block of memory.
Definition: imgmgmt.c:187
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
int optind
Current option index.
Definition: getopt.c:51
static struct command_descriptor imgmem_cmd
"imgmem" command descriptor
Definition: image_mem_cmd.c:50
userptr_t phys_to_user(unsigned long phys_addr)
Convert physical address to user pointer.
int parse_options(int argc, char **argv, struct command_descriptor *cmd, void *opts)
Parse command-line options.
Definition: parseopt.c:484
"imgmem" options
Definition: image_mem_cmd.c:38
static union @437 opts
"cert<xxx>" option list
uint32_t len
Length.
Definition: ena.h:14
uint8_t data[48]
Additional event data.
Definition: ena.h:22

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

Variable Documentation

◆ imgmem_opts

struct option_descriptor imgmem_opts[]
static
Initial value:
= {
}
const char * name
Definition: ath9k_hw.c:1984
"imgmem" options
Definition: image_mem_cmd.c:38
int parse_string(char *text, char **value)
Parse string value.
Definition: parseopt.c:73
#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

"imgmem" option list

Definition at line 44 of file image_mem_cmd.c.

◆ imgmem_cmd

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

"imgmem" command descriptor

Definition at line 50 of file image_mem_cmd.c.

Referenced by imgmem_exec().

◆ __command

struct command imgmem_commands [] __command
Initial value:
= {
{
.name = "imgmem",
.exec = imgmem_exec,
},
}
static int imgmem_exec(int argc, char **argv)
The "imgmem" command.
Definition: image_mem_cmd.c:61

Read memory command.

Definition at line 91 of file image_mem_cmd.c.