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

EFI file protocols. More...

#include <stddef.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <strings.h>
#include <errno.h>
#include <wchar.h>
#include <ipxe/image.h>
#include <ipxe/efi/efi.h>
#include <ipxe/efi/Protocol/SimpleFileSystem.h>
#include <ipxe/efi/Protocol/BlockIo.h>
#include <ipxe/efi/Protocol/DiskIo.h>
#include <ipxe/efi/Guid/FileInfo.h>
#include <ipxe/efi/Guid/FileSystemInfo.h>
#include <ipxe/efi/efi_strings.h>
#include <ipxe/efi/efi_file.h>

Go to the source code of this file.

Data Structures

struct  efi_file
 An image exposed as an EFI file. More...
 

Macros

#define EFI_MEDIA_ID_MAGIC   0x69505845
 EFI media ID. More...
 

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
 
static const char * efi_file_name (struct efi_file *file)
 Get EFI file name (for debugging) More...
 
static struct imageefi_file_find (const CHAR16 *wname)
 Find EFI file image. More...
 
static EFI_STATUS EFIAPI efi_file_open (EFI_FILE_PROTOCOL *this, EFI_FILE_PROTOCOL **new, CHAR16 *wname, UINT64 mode __unused, UINT64 attributes __unused)
 Open file. More...
 
static EFI_STATUS EFIAPI efi_file_close (EFI_FILE_PROTOCOL *this)
 Close file. More...
 
static EFI_STATUS EFIAPI efi_file_delete (EFI_FILE_PROTOCOL *this)
 Close and delete file. More...
 
static EFI_STATUS efi_file_varlen (UINT64 *base, size_t base_len, const char *name, UINTN *len, VOID *data)
 Return variable-length data structure. More...
 
static EFI_STATUS efi_file_info (struct image *image, UINTN *len, VOID *data)
 Return file information structure. More...
 
static EFI_STATUS efi_file_read_dir (struct efi_file *file, UINTN *len, VOID *data)
 Read directory entry. More...
 
static EFI_STATUS EFIAPI efi_file_read (EFI_FILE_PROTOCOL *this, UINTN *len, VOID *data)
 Read from file. More...
 
static EFI_STATUS EFIAPI efi_file_write (EFI_FILE_PROTOCOL *this, UINTN *len, VOID *data __unused)
 Write to file. More...
 
static EFI_STATUS EFIAPI efi_file_set_position (EFI_FILE_PROTOCOL *this, UINT64 position)
 Set file position. More...
 
static EFI_STATUS EFIAPI efi_file_get_position (EFI_FILE_PROTOCOL *this, UINT64 *position)
 Get file position. More...
 
static EFI_STATUS EFIAPI efi_file_get_info (EFI_FILE_PROTOCOL *this, EFI_GUID *type, UINTN *len, VOID *data)
 Get file information. More...
 
static EFI_STATUS EFIAPI efi_file_set_info (EFI_FILE_PROTOCOL *this, EFI_GUID *type, UINTN len __unused, VOID *data __unused)
 Set file information. More...
 
static EFI_STATUS EFIAPI efi_file_flush (EFI_FILE_PROTOCOL *this)
 Flush file modified data. More...
 
static EFI_STATUS EFIAPI efi_file_open_volume (EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *filesystem __unused, EFI_FILE_PROTOCOL **file)
 Open root directory. More...
 
static EFI_STATUS EFIAPI efi_block_io_reset (EFI_BLOCK_IO_PROTOCOL *this __unused, BOOLEAN extended)
 Dummy block I/O reset. More...
 
static EFI_STATUS EFIAPI efi_block_io_read_blocks (EFI_BLOCK_IO_PROTOCOL *this __unused, UINT32 MediaId, EFI_LBA lba, UINTN len, VOID *data)
 Dummy block I/O read. More...
 
static EFI_STATUS EFIAPI efi_block_io_write_blocks (EFI_BLOCK_IO_PROTOCOL *this __unused, UINT32 MediaId, EFI_LBA lba, UINTN len, VOID *data)
 Dummy block I/O write. More...
 
static EFI_STATUS EFIAPI efi_block_io_flush_blocks (EFI_BLOCK_IO_PROTOCOL *this __unused)
 Dummy block I/O flush. More...
 
static EFI_STATUS EFIAPI efi_disk_io_read_disk (EFI_DISK_IO_PROTOCOL *this __unused, UINT32 MediaId, UINT64 offset, UINTN len, VOID *data)
 Dummy disk I/O read. More...
 
static EFI_STATUS EFIAPI efi_disk_io_write_disk (EFI_DISK_IO_PROTOCOL *this __unused, UINT32 MediaId, UINT64 offset, UINTN len, VOID *data)
 Dummy disk I/O write. More...
 
int efi_file_install (EFI_HANDLE handle)
 Install EFI simple file system protocol. More...
 
void efi_file_uninstall (EFI_HANDLE handle)
 Uninstall EFI simple file system protocol. More...
 

Variables

static struct efi_file efi_file_root
 Root directory. More...
 
static EFI_SIMPLE_FILE_SYSTEM_PROTOCOL efi_simple_file_system_protocol
 EFI simple file system protocol. More...
 
static EFI_BLOCK_IO_MEDIA efi_block_io_media
 Dummy block I/O media. More...
 
static EFI_BLOCK_IO_PROTOCOL efi_block_io_protocol
 Dummy EFI block I/O protocol. More...
 
static EFI_DISK_IO_PROTOCOL efi_disk_io_protocol
 Dummy EFI disk I/O protocol. More...
 

Detailed Description

EFI file protocols.

Definition in file efi_file.c.

Macro Definition Documentation

◆ EFI_MEDIA_ID_MAGIC

#define EFI_MEDIA_ID_MAGIC   0x69505845

EFI media ID.

Definition at line 51 of file efi_file.c.

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )

◆ efi_file_name()

static const char* efi_file_name ( struct efi_file file)
static

Get EFI file name (for debugging)

Parameters
fileEFI file
Return values
nameName

Definition at line 71 of file efi_file.c.

71  {
72 
73  return ( file->image ? file->image->name : "<root>" );
74 }
struct image * image
Image.
Definition: efi_file.c:58
char * name
Name.
Definition: image.h:34

References efi_file::file.

Referenced by efi_file_close(), efi_file_delete(), efi_file_flush(), efi_file_get_info(), efi_file_open(), efi_file_read(), efi_file_set_info(), efi_file_set_position(), and efi_file_write().

◆ efi_file_find()

static struct image* efi_file_find ( const CHAR16 wname)
static

Find EFI file image.

Parameters
wnameFilename
Return values
imageImage, or NULL

Definition at line 82 of file efi_file.c.

82  {
83  char name[ wcslen ( wname ) + 1 /* NUL */ ];
84  struct image *image;
85 
86  /* Find image */
87  snprintf ( name, sizeof ( name ), "%ls", wname );
89  if ( strcasecmp ( image->name, name ) == 0 )
90  return image;
91  }
92 
93  return NULL;
94 
95 }
const char * name
Definition: ath9k_hw.c:1984
int strcasecmp(const char *first, const char *second)
Compare case-insensitive strings.
Definition: string.c:192
An executable image.
Definition: image.h:24
size_t wcslen(const wchar_t *string)
Calculate length of wide-character string.
Definition: wchar.c:41
#define list_for_each_entry(pos, head, member)
Iterate over entries in a list.
Definition: list.h:420
struct list_head images
List of registered images.
Definition: image.c:56
int snprintf(char *buf, size_t size, const char *fmt,...)
Write a formatted string to a buffer.
Definition: vsprintf.c:382
struct list_head list
List of registered images.
Definition: image.h:29
char * name
Name.
Definition: image.h:34
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362

References images, image::list, list_for_each_entry, image::name, name, NULL, snprintf(), strcasecmp(), and wcslen().

Referenced by efi_file_open().

◆ efi_file_open()

static EFI_STATUS EFIAPI efi_file_open ( EFI_FILE_PROTOCOL this,
EFI_FILE_PROTOCOL **  new,
CHAR16 wname,
UINT64 mode  __unused,
UINT64 attributes  __unused 
)
static

Open file.

Parameters
thisEFI file
Return values
newNew EFI file
Parameters
wnameFilename
modeFile mode
attributesFile attributes (for newly-created files)
Return values
efircEFI status code

Definition at line 108 of file efi_file.c.

110  {
111  struct efi_file *file = container_of ( this, struct efi_file, file );
112  struct efi_file *new_file;
113  struct image *image;
114 
115  /* Initial '\' indicates opening from the root directory */
116  while ( *wname == L'\\' ) {
117  file = &efi_file_root;
118  wname++;
119  }
120 
121  /* Allow root directory itself to be opened */
122  if ( ( wname[0] == L'\0' ) || ( wname[0] == L'.' ) ) {
123  *new = &efi_file_root.file;
124  return 0;
125  }
126 
127  /* Fail unless opening from the root */
128  if ( file->image ) {
129  DBGC ( file, "EFIFILE %s is not a directory\n",
130  efi_file_name ( file ) );
131  return EFI_NOT_FOUND;
132  }
133 
134  /* Identify image */
135  image = efi_file_find ( wname );
136  if ( ! image ) {
137  DBGC ( file, "EFIFILE \"%ls\" does not exist\n", wname );
138  return EFI_NOT_FOUND;
139  }
140 
141  /* Fail unless opening read-only */
142  if ( mode != EFI_FILE_MODE_READ ) {
143  DBGC ( file, "EFIFILE %s cannot be opened in mode %#08llx\n",
144  image->name, mode );
145  return EFI_WRITE_PROTECTED;
146  }
147 
148  /* Allocate and initialise file */
149  new_file = zalloc ( sizeof ( *new_file ) );
150  memcpy ( &new_file->file, &efi_file_root.file,
151  sizeof ( new_file->file ) );
152  new_file->image = image_get ( image );
153  *new = &new_file->file;
154  DBGC ( new_file, "EFIFILE %s opened\n", efi_file_name ( new_file ) );
155 
156  return 0;
157 }
static struct image * image_get(struct image *image)
Increment reference count on an image.
Definition: image.h:196
#define DBGC(...)
Definition: compiler.h:505
static struct image * efi_file_find(const CHAR16 *wname)
Find EFI file image.
Definition: efi_file.c:82
An executable image.
Definition: image.h:24
EFI_FILE_PROTOCOL file
EFI file protocol.
Definition: efi_file.c:56
void * memcpy(void *dest, const void *src, size_t len) __nonnull
#define container_of(ptr, type, field)
Get containing structure.
Definition: stddef.h:35
static struct efi_file efi_file_root
Root directory.
Definition: efi_file.c:63
#define EFI_WRITE_PROTECTED
Enumeration of EFI_STATUS.
Definition: UefiBaseType.h:128
void * zalloc(size_t size)
Allocate cleared memory.
Definition: malloc.c:624
#define EFI_NOT_FOUND
Enumeration of EFI_STATUS.
Definition: UefiBaseType.h:134
#define EFI_FILE_MODE_READ
struct image * image
Image.
Definition: efi_file.c:58
char * name
Name.
Definition: image.h:34
An image exposed as an EFI file.
Definition: efi_file.c:54
static const char * efi_file_name(struct efi_file *file)
Get EFI file name (for debugging)
Definition: efi_file.c:71

References container_of, DBGC, efi_file_find(), EFI_FILE_MODE_READ, efi_file_name(), efi_file_root, EFI_NOT_FOUND, EFI_WRITE_PROTECTED, efi_file::file, efi_file::image, image_get(), memcpy(), image::name, and zalloc().

◆ efi_file_close()

static EFI_STATUS EFIAPI efi_file_close ( EFI_FILE_PROTOCOL this)
static

Close file.

Parameters
thisEFI file
Return values
efircEFI status code

Definition at line 165 of file efi_file.c.

165  {
166  struct efi_file *file = container_of ( this, struct efi_file, file );
167 
168  /* Do nothing if this is the root */
169  if ( ! file->image )
170  return 0;
171 
172  /* Close file */
173  DBGC ( file, "EFIFILE %s closed\n", efi_file_name ( file ) );
174  image_put ( file->image );
175  free ( file );
176 
177  return 0;
178 }
#define DBGC(...)
Definition: compiler.h:505
EFI_FILE_PROTOCOL file
EFI file protocol.
Definition: efi_file.c:56
#define container_of(ptr, type, field)
Get containing structure.
Definition: stddef.h:35
static void(* free)(struct refcnt *refcnt))
Definition: refcnt.h:54
static void image_put(struct image *image)
Decrement reference count on an image.
Definition: image.h:206
An image exposed as an EFI file.
Definition: efi_file.c:54
static const char * efi_file_name(struct efi_file *file)
Get EFI file name (for debugging)
Definition: efi_file.c:71

References container_of, DBGC, efi_file_name(), efi_file::file, free, and image_put().

Referenced by efi_file_delete().

◆ efi_file_delete()

static EFI_STATUS EFIAPI efi_file_delete ( EFI_FILE_PROTOCOL this)
static

Close and delete file.

Parameters
thisEFI file
Return values
efircEFI status code

Definition at line 186 of file efi_file.c.

186  {
187  struct efi_file *file = container_of ( this, struct efi_file, file );
188 
189  DBGC ( file, "EFIFILE %s cannot be deleted\n", efi_file_name ( file ) );
190 
191  /* Close file */
192  efi_file_close ( this );
193 
194  /* Warn of failure to delete */
196 }
#define DBGC(...)
Definition: compiler.h:505
EFI_FILE_PROTOCOL file
EFI file protocol.
Definition: efi_file.c:56
#define container_of(ptr, type, field)
Get containing structure.
Definition: stddef.h:35
static EFI_STATUS EFIAPI efi_file_close(EFI_FILE_PROTOCOL *this)
Close file.
Definition: efi_file.c:165
#define EFI_WARN_DELETE_FAILURE
Enumeration of EFI_STATUS.
Definition: UefiBaseType.h:155
An image exposed as an EFI file.
Definition: efi_file.c:54
static const char * efi_file_name(struct efi_file *file)
Get EFI file name (for debugging)
Definition: efi_file.c:71

References container_of, DBGC, efi_file_close(), efi_file_name(), EFI_WARN_DELETE_FAILURE, and efi_file::file.

◆ efi_file_varlen()

static EFI_STATUS efi_file_varlen ( UINT64 base,
size_t  base_len,
const char *  name,
UINTN len,
VOID data 
)
static

Return variable-length data structure.

Parameters
baseBase data structure (starting with UINT64)
base_lenLength of base data structure
nameName to append to base data structure
lenLength of data buffer
dataData buffer
Return values
efircEFI status code

Definition at line 208 of file efi_file.c.

209  {
210  size_t name_len;
211 
212  /* Calculate structure length */
213  name_len = strlen ( name );
214  *base = ( base_len + ( name_len + 1 /* NUL */ ) * sizeof ( wchar_t ) );
215  if ( *len < *base ) {
216  *len = *base;
217  return EFI_BUFFER_TOO_SMALL;
218  }
219 
220  /* Copy data to buffer */
221  *len = *base;
222  memcpy ( data, base, base_len );
223  efi_snprintf ( ( data + base_len ), ( name_len + 1 /* NUL */ ),
224  "%s", name );
225 
226  return 0;
227 }
const char * name
Definition: ath9k_hw.c:1984
#define EFI_BUFFER_TOO_SMALL
Enumeration of EFI_STATUS.
Definition: UefiBaseType.h:125
void * memcpy(void *dest, const void *src, size_t len) __nonnull
int efi_snprintf(wchar_t *wbuf, size_t wsize, const char *fmt,...)
Write a formatted string to a buffer.
Definition: efi_strings.c:104
size_t strlen(const char *src)
Get length of string.
Definition: string.c:213
uint16_t base
Base address.
Definition: edd.h:14
uint32_t len
Length.
Definition: ena.h:14
struct arbelprm_port_state_change_st data
Message.
Definition: arbel.h:12

References base, data, EFI_BUFFER_TOO_SMALL, efi_snprintf(), len, memcpy(), name, and strlen().

Referenced by efi_file_get_info(), and efi_file_info().

◆ efi_file_info()

static EFI_STATUS efi_file_info ( struct image image,
UINTN len,
VOID data 
)
static

Return file information structure.

Parameters
imageImage, or NULL for the root directory
lenLength of data buffer
dataData buffer
Return values
efircEFI status code

Definition at line 237 of file efi_file.c.

238  {
240  const char *name;
241 
242  /* Populate file information */
243  memset ( &info, 0, sizeof ( info ) );
244  if ( image ) {
245  info.FileSize = image->len;
246  info.PhysicalSize = image->len;
247  info.Attribute = EFI_FILE_READ_ONLY;
248  name = image->name;
249  } else {
250  info.Attribute = ( EFI_FILE_READ_ONLY | EFI_FILE_DIRECTORY );
251  name = "";
252  }
253 
255  len, data );
256 }
const char * name
Definition: ath9k_hw.c:1984
u32 info
Definition: ar9003_mac.h:67
An executable image.
Definition: image.h:24
#define EFI_FILE_READ_ONLY
#define EFI_FILE_DIRECTORY
#define SIZE_OF_EFI_FILE_INFO
The FileName field of the EFI_FILE_INFO data structure is variable length.
Definition: FileInfo.h:69
static EFI_STATUS efi_file_varlen(UINT64 *base, size_t base_len, const char *name, UINTN *len, VOID *data)
Return variable-length data structure.
Definition: efi_file.c:208
size_t len
Length of raw file image.
Definition: image.h:43
uint32_t len
Length.
Definition: ena.h:14
struct arbelprm_port_state_change_st data
Message.
Definition: arbel.h:12
char * name
Name.
Definition: image.h:34
void * memset(void *dest, int character, size_t len) __nonnull

References data, EFI_FILE_DIRECTORY, EFI_FILE_READ_ONLY, efi_file_varlen(), info, len, image::len, memset(), image::name, name, and SIZE_OF_EFI_FILE_INFO.

Referenced by efi_file_get_info(), and efi_file_read_dir().

◆ efi_file_read_dir()

static EFI_STATUS efi_file_read_dir ( struct efi_file file,
UINTN len,
VOID data 
)
static

Read directory entry.

Parameters
fileEFI file
lenLength to read
dataData buffer
Return values
efircEFI status code

Definition at line 266 of file efi_file.c.

267  {
268  EFI_STATUS efirc;
269  struct image *image;
270  unsigned int index;
271 
272  /* Construct directory entry at current position */
273  index = file->pos;
274  for_each_image ( image ) {
275  if ( index-- == 0 ) {
276  efirc = efi_file_info ( image, len, data );
277  if ( efirc == 0 )
278  file->pos++;
279  return efirc;
280  }
281  }
282 
283  /* No more entries */
284  *len = 0;
285  return 0;
286 }
static EFI_STATUS efi_file_info(struct image *image, UINTN *len, VOID *data)
Return file information structure.
Definition: efi_file.c:237
An executable image.
Definition: image.h:24
size_t pos
Current file position.
Definition: efi_file.c:60
#define for_each_image(image)
Iterate over all registered images.
Definition: image.h:149
uint32_t len
Length.
Definition: ena.h:14
RETURN_STATUS EFI_STATUS
Function return status for EFI API.
Definition: UefiBaseType.h:35
struct arbelprm_port_state_change_st data
Message.
Definition: arbel.h:12
uint64_t index
Index of the first segment within the content.
Definition: pccrc.h:21

References data, efi_file_info(), for_each_image, index, len, and efi_file::pos.

Referenced by efi_file_read().

◆ efi_file_read()

static EFI_STATUS EFIAPI efi_file_read ( EFI_FILE_PROTOCOL this,
UINTN len,
VOID data 
)
static

Read from file.

Parameters
thisEFI file
lenLength to read
dataData buffer
Return values
efircEFI status code

Definition at line 296 of file efi_file.c.

297  {
298  struct efi_file *file = container_of ( this, struct efi_file, file );
299  size_t remaining;
300 
301  /* If this is the root directory, then construct a directory entry */
302  if ( ! file->image )
303  return efi_file_read_dir ( file, len, data );
304 
305  /* Read from the file */
306  remaining = ( file->image->len - file->pos );
307  if ( *len > remaining )
308  *len = remaining;
309  DBGC ( file, "EFIFILE %s read [%#08zx,%#08zx)\n",
310  efi_file_name ( file ), file->pos,
311  ( ( size_t ) ( file->pos + *len ) ) );
312  copy_from_user ( data, file->image->data, file->pos, *len );
313  file->pos += *len;
314  return 0;
315 }
static __always_inline void copy_from_user(void *dest, userptr_t src, off_t src_off, size_t len)
Copy data from user buffer.
Definition: uaccess.h:337
#define DBGC(...)
Definition: compiler.h:505
EFI_FILE_PROTOCOL file
EFI file protocol.
Definition: efi_file.c:56
#define container_of(ptr, type, field)
Get containing structure.
Definition: stddef.h:35
static EFI_STATUS efi_file_read_dir(struct efi_file *file, UINTN *len, VOID *data)
Read directory entry.
Definition: efi_file.c:266
uint32_t len
Length.
Definition: ena.h:14
struct arbelprm_port_state_change_st data
Message.
Definition: arbel.h:12
An image exposed as an EFI file.
Definition: efi_file.c:54
static const char * efi_file_name(struct efi_file *file)
Get EFI file name (for debugging)
Definition: efi_file.c:71

References container_of, copy_from_user(), data, DBGC, efi_file_name(), efi_file_read_dir(), efi_file::file, and len.

◆ efi_file_write()

static EFI_STATUS EFIAPI efi_file_write ( EFI_FILE_PROTOCOL this,
UINTN len,
VOID *data  __unused 
)
static

Write to file.

Parameters
thisEFI file
lenLength to write
dataData buffer
Return values
efircEFI status code

Definition at line 325 of file efi_file.c.

326  {
327  struct efi_file *file = container_of ( this, struct efi_file, file );
328 
329  DBGC ( file, "EFIFILE %s cannot write [%#08zx, %#08zx)\n",
330  efi_file_name ( file ), file->pos,
331  ( ( size_t ) ( file->pos + *len ) ) );
332  return EFI_WRITE_PROTECTED;
333 }
#define DBGC(...)
Definition: compiler.h:505
EFI_FILE_PROTOCOL file
EFI file protocol.
Definition: efi_file.c:56
#define container_of(ptr, type, field)
Get containing structure.
Definition: stddef.h:35
#define EFI_WRITE_PROTECTED
Enumeration of EFI_STATUS.
Definition: UefiBaseType.h:128
uint32_t len
Length.
Definition: ena.h:14
An image exposed as an EFI file.
Definition: efi_file.c:54
static const char * efi_file_name(struct efi_file *file)
Get EFI file name (for debugging)
Definition: efi_file.c:71

References container_of, DBGC, efi_file_name(), EFI_WRITE_PROTECTED, efi_file::file, and len.

◆ efi_file_set_position()

static EFI_STATUS EFIAPI efi_file_set_position ( EFI_FILE_PROTOCOL this,
UINT64  position 
)
static

Set file position.

Parameters
thisEFI file
positionNew file position
Return values
efircEFI status code

Definition at line 342 of file efi_file.c.

343  {
344  struct efi_file *file = container_of ( this, struct efi_file, file );
345 
346  /* If this is the root directory, reset to the start */
347  if ( ! file->image ) {
348  DBGC ( file, "EFIFILE root directory rewound\n" );
349  file->pos = 0;
350  return 0;
351  }
352 
353  /* Check for the magic end-of-file value */
354  if ( position == 0xffffffffffffffffULL )
355  position = file->image->len;
356 
357  /* Fail if we attempt to seek past the end of the file (since
358  * we do not support writes).
359  */
360  if ( position > file->image->len ) {
361  DBGC ( file, "EFIFILE %s cannot seek to %#08llx of %#08zx\n",
362  efi_file_name ( file ), position, file->image->len );
363  return EFI_UNSUPPORTED;
364  }
365 
366  /* Set position */
367  file->pos = position;
368  DBGC ( file, "EFIFILE %s position set to %#08zx\n",
369  efi_file_name ( file ), file->pos );
370 
371  return 0;
372 }
#define EFI_UNSUPPORTED
Enumeration of EFI_STATUS.
Definition: UefiBaseType.h:123
#define DBGC(...)
Definition: compiler.h:505
EFI_FILE_PROTOCOL file
EFI file protocol.
Definition: efi_file.c:56
#define container_of(ptr, type, field)
Get containing structure.
Definition: stddef.h:35
An image exposed as an EFI file.
Definition: efi_file.c:54
static const char * efi_file_name(struct efi_file *file)
Get EFI file name (for debugging)
Definition: efi_file.c:71

References container_of, DBGC, efi_file_name(), EFI_UNSUPPORTED, and efi_file::file.

◆ efi_file_get_position()

static EFI_STATUS EFIAPI efi_file_get_position ( EFI_FILE_PROTOCOL this,
UINT64 position 
)
static

Get file position.

Parameters
thisEFI file
Return values
positionNew file position
efircEFI status code

Definition at line 381 of file efi_file.c.

382  {
383  struct efi_file *file = container_of ( this, struct efi_file, file );
384 
385  *position = file->pos;
386  return 0;
387 }
EFI_FILE_PROTOCOL file
EFI file protocol.
Definition: efi_file.c:56
#define container_of(ptr, type, field)
Get containing structure.
Definition: stddef.h:35
An image exposed as an EFI file.
Definition: efi_file.c:54

References container_of, and efi_file::file.

◆ efi_file_get_info()

static EFI_STATUS EFIAPI efi_file_get_info ( EFI_FILE_PROTOCOL this,
EFI_GUID type,
UINTN len,
VOID data 
)
static

Get file information.

Parameters
thisEFI file
typeType of information
lenBuffer size
dataBuffer
Return values
efircEFI status code

Definition at line 398 of file efi_file.c.

400  {
401  struct efi_file *file = container_of ( this, struct efi_file, file );
402  EFI_FILE_SYSTEM_INFO fsinfo;
403  struct image *image;
404 
405  /* Determine information to return */
406  if ( memcmp ( type, &efi_file_info_id, sizeof ( *type ) ) == 0 ) {
407 
408  /* Get file information */
409  DBGC ( file, "EFIFILE %s get file information\n",
410  efi_file_name ( file ) );
411  return efi_file_info ( file->image, len, data );
412 
413  } else if ( memcmp ( type, &efi_file_system_info_id,
414  sizeof ( *type ) ) == 0 ) {
415 
416  /* Get file system information */
417  DBGC ( file, "EFIFILE %s get file system information\n",
418  efi_file_name ( file ) );
419  memset ( &fsinfo, 0, sizeof ( fsinfo ) );
420  fsinfo.ReadOnly = 1;
422  fsinfo.VolumeSize += image->len;
423  return efi_file_varlen ( &fsinfo.Size,
425  len, data );
426  } else {
427 
428  DBGC ( file, "EFIFILE %s cannot get information of type %s\n",
429  efi_file_name ( file ), efi_guid_ntoa ( type ) );
430  return EFI_UNSUPPORTED;
431  }
432 }
#define EFI_UNSUPPORTED
Enumeration of EFI_STATUS.
Definition: UefiBaseType.h:123
BOOLEAN ReadOnly
TRUE if the volume only supports read access.
EFI_GUID efi_file_system_info_id
File system information GUID.
Definition: efi_guid.c:306
uint8_t type
Type.
Definition: ena.h:16
static EFI_STATUS efi_file_info(struct image *image, UINTN *len, VOID *data)
Return file information structure.
Definition: efi_file.c:237
#define DBGC(...)
Definition: compiler.h:505
An executable image.
Definition: image.h:24
EFI_FILE_PROTOCOL file
EFI file protocol.
Definition: efi_file.c:56
#define container_of(ptr, type, field)
Get containing structure.
Definition: stddef.h:35
#define for_each_image(image)
Iterate over all registered images.
Definition: image.h:149
static EFI_STATUS efi_file_varlen(UINT64 *base, size_t base_len, const char *name, UINTN *len, VOID *data)
Return variable-length data structure.
Definition: efi_file.c:208
size_t len
Length of raw file image.
Definition: image.h:43
UINT64 VolumeSize
The number of bytes managed by the file system.
const char * efi_guid_ntoa(EFI_GUID *guid)
Convert GUID to a printable string.
Definition: efi_debug.c:192
uint32_t len
Length.
Definition: ena.h:14
EFI_GUID efi_file_info_id
File information GUID.
Definition: efi_guid.c:303
struct image * image
Image.
Definition: efi_file.c:58
struct arbelprm_port_state_change_st data
Message.
Definition: arbel.h:12
int memcmp(const void *first, const void *second, size_t len)
Compare memory regions.
Definition: string.c:98
UINT64 Size
The size of the EFI_FILE_SYSTEM_INFO structure, including the Null-terminated VolumeLabel string.
An image exposed as an EFI file.
Definition: efi_file.c:54
#define SIZE_OF_EFI_FILE_SYSTEM_INFO
The VolumeLabel field of the EFI_FILE_SYSTEM_INFO data structure is variable length.
static const char * efi_file_name(struct efi_file *file)
Get EFI file name (for debugging)
Definition: efi_file.c:71
void * memset(void *dest, int character, size_t len) __nonnull

References container_of, data, DBGC, efi_file_info(), efi_file_info_id, efi_file_name(), efi_file_system_info_id, efi_file_varlen(), efi_guid_ntoa(), EFI_UNSUPPORTED, efi_file::file, for_each_image, efi_file::image, len, image::len, memcmp(), memset(), EFI_FILE_SYSTEM_INFO::ReadOnly, EFI_FILE_SYSTEM_INFO::Size, SIZE_OF_EFI_FILE_SYSTEM_INFO, type, and EFI_FILE_SYSTEM_INFO::VolumeSize.

◆ efi_file_set_info()

static EFI_STATUS EFIAPI efi_file_set_info ( EFI_FILE_PROTOCOL this,
EFI_GUID type,
UINTN len  __unused,
VOID *data  __unused 
)
static

Set file information.

Parameters
thisEFI file
typeType of information
lenBuffer size
dataBuffer
Return values
efircEFI status code

Definition at line 444 of file efi_file.c.

445  {
446  struct efi_file *file = container_of ( this, struct efi_file, file );
447 
448  DBGC ( file, "EFIFILE %s cannot set information of type %s\n",
450  return EFI_WRITE_PROTECTED;
451 }
uint8_t type
Type.
Definition: ena.h:16
#define DBGC(...)
Definition: compiler.h:505
EFI_FILE_PROTOCOL file
EFI file protocol.
Definition: efi_file.c:56
#define container_of(ptr, type, field)
Get containing structure.
Definition: stddef.h:35
#define EFI_WRITE_PROTECTED
Enumeration of EFI_STATUS.
Definition: UefiBaseType.h:128
const char * efi_guid_ntoa(EFI_GUID *guid)
Convert GUID to a printable string.
Definition: efi_debug.c:192
An image exposed as an EFI file.
Definition: efi_file.c:54
static const char * efi_file_name(struct efi_file *file)
Get EFI file name (for debugging)
Definition: efi_file.c:71

References container_of, DBGC, efi_file_name(), efi_guid_ntoa(), EFI_WRITE_PROTECTED, efi_file::file, and type.

◆ efi_file_flush()

static EFI_STATUS EFIAPI efi_file_flush ( EFI_FILE_PROTOCOL this)
static

Flush file modified data.

Parameters
thisEFI file
typeType of information
lenBuffer size
dataBuffer
Return values
efircEFI status code

Definition at line 462 of file efi_file.c.

462  {
463  struct efi_file *file = container_of ( this, struct efi_file, file );
464 
465  DBGC ( file, "EFIFILE %s flushed\n", efi_file_name ( file ) );
466  return 0;
467 }
#define DBGC(...)
Definition: compiler.h:505
EFI_FILE_PROTOCOL file
EFI file protocol.
Definition: efi_file.c:56
#define container_of(ptr, type, field)
Get containing structure.
Definition: stddef.h:35
An image exposed as an EFI file.
Definition: efi_file.c:54
static const char * efi_file_name(struct efi_file *file)
Get EFI file name (for debugging)
Definition: efi_file.c:71

References container_of, DBGC, efi_file_name(), and efi_file::file.

◆ efi_file_open_volume()

static EFI_STATUS EFIAPI efi_file_open_volume ( EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *filesystem  __unused,
EFI_FILE_PROTOCOL **  file 
)
static

Open root directory.

Parameters
filesystemEFI simple file system
Return values
fileEFI file handle
efircEFI status code

Definition at line 495 of file efi_file.c.

496  {
497 
498  DBGC ( &efi_file_root, "EFIFILE open volume\n" );
499  *file = &efi_file_root.file;
500  return 0;
501 }
#define DBGC(...)
Definition: compiler.h:505
EFI_FILE_PROTOCOL file
EFI file protocol.
Definition: efi_file.c:56
static struct efi_file efi_file_root
Root directory.
Definition: efi_file.c:63

References DBGC, efi_file_root, and efi_file::file.

◆ efi_block_io_reset()

static EFI_STATUS EFIAPI efi_block_io_reset ( EFI_BLOCK_IO_PROTOCOL *this  __unused,
BOOLEAN  extended 
)
static

Dummy block I/O reset.

Definition at line 511 of file efi_file.c.

511  {
512 
513  DBGC ( &efi_file_root, "EFIFILE block %sreset\n",
514  ( extended ? "extended " : "" ) );
515  return 0;
516 }
#define DBGC(...)
Definition: compiler.h:505
static struct efi_file efi_file_root
Root directory.
Definition: efi_file.c:63

References DBGC, and efi_file_root.

◆ efi_block_io_read_blocks()

static EFI_STATUS EFIAPI efi_block_io_read_blocks ( EFI_BLOCK_IO_PROTOCOL *this  __unused,
UINT32  MediaId,
EFI_LBA  lba,
UINTN  len,
VOID data 
)
static

Dummy block I/O read.

Definition at line 520 of file efi_file.c.

521  {
522 
523  DBGC ( &efi_file_root, "EFIFILE block read ID %#08x LBA %#08llx -> "
524  "%p+%zx\n", MediaId, ( ( unsigned long long ) lba ),
525  data, ( ( size_t ) len ) );
526  return EFI_NO_MEDIA;
527 }
uint32_t lba
Start address.
Definition: scsi.h:23
#define DBGC(...)
Definition: compiler.h:505
#define EFI_NO_MEDIA
Enumeration of EFI_STATUS.
Definition: UefiBaseType.h:132
static struct efi_file efi_file_root
Root directory.
Definition: efi_file.c:63
uint32_t len
Length.
Definition: ena.h:14
struct arbelprm_port_state_change_st data
Message.
Definition: arbel.h:12

References data, DBGC, efi_file_root, EFI_NO_MEDIA, lba, and len.

◆ efi_block_io_write_blocks()

static EFI_STATUS EFIAPI efi_block_io_write_blocks ( EFI_BLOCK_IO_PROTOCOL *this  __unused,
UINT32  MediaId,
EFI_LBA  lba,
UINTN  len,
VOID data 
)
static

Dummy block I/O write.

Definition at line 531 of file efi_file.c.

533  {
534 
535  DBGC ( &efi_file_root, "EFIFILE block write ID %#08x LBA %#08llx <- "
536  "%p+%zx\n", MediaId, ( ( unsigned long long ) lba ),
537  data, ( ( size_t ) len ) );
538  return EFI_NO_MEDIA;
539 }
uint32_t lba
Start address.
Definition: scsi.h:23
#define DBGC(...)
Definition: compiler.h:505
#define EFI_NO_MEDIA
Enumeration of EFI_STATUS.
Definition: UefiBaseType.h:132
static struct efi_file efi_file_root
Root directory.
Definition: efi_file.c:63
uint32_t len
Length.
Definition: ena.h:14
struct arbelprm_port_state_change_st data
Message.
Definition: arbel.h:12

References data, DBGC, efi_file_root, EFI_NO_MEDIA, lba, and len.

◆ efi_block_io_flush_blocks()

static EFI_STATUS EFIAPI efi_block_io_flush_blocks ( EFI_BLOCK_IO_PROTOCOL *this  __unused)
static

Dummy block I/O flush.

Definition at line 543 of file efi_file.c.

543  {
544 
545  DBGC ( &efi_file_root, "EFIFILE block flush\n" );
546  return 0;
547 }
#define DBGC(...)
Definition: compiler.h:505
static struct efi_file efi_file_root
Root directory.
Definition: efi_file.c:63

References DBGC, and efi_file_root.

◆ efi_disk_io_read_disk()

static EFI_STATUS EFIAPI efi_disk_io_read_disk ( EFI_DISK_IO_PROTOCOL *this  __unused,
UINT32  MediaId,
UINT64  offset,
UINTN  len,
VOID data 
)
static

Dummy disk I/O read.

Definition at line 569 of file efi_file.c.

570  {
571 
572  DBGC ( &efi_file_root, "EFIFILE disk read ID %#08x offset %#08llx -> "
573  "%p+%zx\n", MediaId, ( ( unsigned long long ) offset ),
574  data, ( ( size_t ) len ) );
575  return EFI_NO_MEDIA;
576 }
#define DBGC(...)
Definition: compiler.h:505
#define EFI_NO_MEDIA
Enumeration of EFI_STATUS.
Definition: UefiBaseType.h:132
static userptr_t size_t offset
Offset of the first segment within the content.
Definition: deflate.h:259
static struct efi_file efi_file_root
Root directory.
Definition: efi_file.c:63
uint32_t len
Length.
Definition: ena.h:14
struct arbelprm_port_state_change_st data
Message.
Definition: arbel.h:12

References data, DBGC, efi_file_root, EFI_NO_MEDIA, len, and offset.

◆ efi_disk_io_write_disk()

static EFI_STATUS EFIAPI efi_disk_io_write_disk ( EFI_DISK_IO_PROTOCOL *this  __unused,
UINT32  MediaId,
UINT64  offset,
UINTN  len,
VOID data 
)
static

Dummy disk I/O write.

Definition at line 580 of file efi_file.c.

581  {
582 
583  DBGC ( &efi_file_root, "EFIFILE disk write ID %#08x offset %#08llx <- "
584  "%p+%zx\n", MediaId, ( ( unsigned long long ) offset ),
585  data, ( ( size_t ) len ) );
586  return EFI_NO_MEDIA;
587 }
#define DBGC(...)
Definition: compiler.h:505
#define EFI_NO_MEDIA
Enumeration of EFI_STATUS.
Definition: UefiBaseType.h:132
static userptr_t size_t offset
Offset of the first segment within the content.
Definition: deflate.h:259
static struct efi_file efi_file_root
Root directory.
Definition: efi_file.c:63
uint32_t len
Length.
Definition: ena.h:14
struct arbelprm_port_state_change_st data
Message.
Definition: arbel.h:12

References data, DBGC, efi_file_root, EFI_NO_MEDIA, len, and offset.

◆ efi_file_install()

int efi_file_install ( EFI_HANDLE  handle)

Install EFI simple file system protocol.

Parameters
handleEFI handle
Return values
rcReturn status code

Definition at line 602 of file efi_file.c.

602  {
604  union {
605  EFI_DISK_IO_PROTOCOL *diskio;
606  void *interface;
607  } diskio;
608  EFI_STATUS efirc;
609  int rc;
610 
611  /* Reset root directory state */
612  efi_file_root.pos = 0;
613 
614  /* Install the simple file system protocol, block I/O
615  * protocol, and disk I/O protocol. We don't have a block
616  * device, but large parts of the EDK2 codebase make the
617  * assumption that file systems are normally attached to block
618  * devices, and so we create a dummy block device on the same
619  * handle just to keep things looking normal.
620  */
621  if ( ( efirc = bs->InstallMultipleProtocolInterfaces (
622  &handle,
629  rc = -EEFI ( efirc );
630  DBGC ( handle, "Could not install simple file system "
631  "protocols: %s\n", strerror ( rc ) );
632  goto err_install;
633  }
634 
635  /* The FAT filesystem driver has a bug: if a block device
636  * contains no FAT filesystem but does have an
637  * EFI_SIMPLE_FILE_SYSTEM_PROTOCOL instance, the FAT driver
638  * will assume that it must have previously installed the
639  * EFI_SIMPLE_FILE_SYSTEM_PROTOCOL. This causes the FAT
640  * driver to claim control of our device, and to refuse to
641  * stop driving it, which prevents us from later uninstalling
642  * correctly.
643  *
644  * Work around this bug by opening the disk I/O protocol
645  * ourselves, thereby preventing the FAT driver from opening
646  * it.
647  *
648  * Note that the alternative approach of opening the block I/O
649  * protocol (and thereby in theory preventing DiskIo from
650  * attaching to the block I/O protocol) causes an endless loop
651  * of calls to our DRIVER_STOP method when starting the EFI
652  * shell. I have no idea why this is.
653  */
654  if ( ( efirc = bs->OpenProtocol ( handle, &efi_disk_io_protocol_guid,
655  &diskio.interface, efi_image_handle,
656  handle,
657  EFI_OPEN_PROTOCOL_BY_DRIVER ) ) != 0){
658  rc = -EEFI ( efirc );
659  DBGC ( handle, "Could not open disk I/O protocol: %s\n",
660  strerror ( rc ) );
662  goto err_open;
663  }
664  assert ( diskio.diskio == &efi_disk_io_protocol );
665 
666  return 0;
667 
670  err_open:
672  handle,
679  err_install:
680  return rc;
681 }
EFI_BOOT_SERVICES * BootServices
A pointer to the EFI Boot Services Table.
Definition: UefiSpec.h:2000
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
#define EEFI(efirc)
Convert an EFI status code to an iPXE status code.
Definition: efi.h:157
static EFI_BLOCK_IO_PROTOCOL efi_block_io_protocol
Dummy EFI block I/O protocol.
Definition: efi_file.c:558
#define DBGC(...)
Definition: compiler.h:505
#define EFI_OPEN_PROTOCOL_BY_DRIVER
Definition: UefiSpec.h:1274
EFI_INSTALL_MULTIPLE_PROTOCOL_INTERFACES InstallMultipleProtocolInterfaces
Definition: UefiSpec.h:1915
#define DBGC_EFI_OPENERS(...)
Definition: efi.h:260
EFI_CLOSE_PROTOCOL CloseProtocol
Definition: UefiSpec.h:1906
static EFI_DISK_IO_PROTOCOL efi_disk_io_protocol
Dummy EFI disk I/O protocol.
Definition: efi_file.c:590
EFI_GUID efi_disk_io_protocol_guid
Disk I/O protocol GUID.
Definition: efi_guid.c:144
size_t pos
Current file position.
Definition: efi_file.c:60
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
An object interface.
Definition: interface.h:109
EFI_GUID efi_simple_file_system_protocol_guid
Simple file system protocol GUID.
Definition: efi_guid.c:232
static struct efi_file efi_file_root
Root directory.
Definition: efi_file.c:63
This protocol is used to abstract Block I/O interfaces.
Definition: DiskIo.h:106
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
EFI Boot Services Table.
Definition: UefiSpec.h:1836
EFI_HANDLE efi_image_handle
Image handle passed to entry point.
Definition: efi_init.c:30
EFI_UNINSTALL_MULTIPLE_PROTOCOL_INTERFACES UninstallMultipleProtocolInterfaces
Definition: UefiSpec.h:1916
EFI_GUID efi_block_io_protocol_guid
Block I/O protocol GUID.
Definition: efi_guid.c:108
RETURN_STATUS EFI_STATUS
Function return status for EFI API.
Definition: UefiBaseType.h:35
EFI_SYSTEM_TABLE * efi_systab
EFI_OPEN_PROTOCOL OpenProtocol
Definition: UefiSpec.h:1905
static EFI_SIMPLE_FILE_SYSTEM_PROTOCOL efi_simple_file_system_protocol
EFI simple file system protocol.
Definition: efi_file.c:504
uint16_t handle
Handle.
Definition: smbios.h:16
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362

References assert(), EFI_SYSTEM_TABLE::BootServices, EFI_BOOT_SERVICES::CloseProtocol, DBGC, DBGC_EFI_OPENERS, EEFI, efi_block_io_protocol, efi_block_io_protocol_guid, efi_disk_io_protocol, efi_disk_io_protocol_guid, efi_file_root, efi_image_handle, EFI_OPEN_PROTOCOL_BY_DRIVER, efi_simple_file_system_protocol, efi_simple_file_system_protocol_guid, efi_systab, handle, EFI_BOOT_SERVICES::InstallMultipleProtocolInterfaces, NULL, EFI_BOOT_SERVICES::OpenProtocol, efi_file::pos, rc, strerror(), and EFI_BOOT_SERVICES::UninstallMultipleProtocolInterfaces.

Referenced by efi_image_exec().

◆ efi_file_uninstall()

void efi_file_uninstall ( EFI_HANDLE  handle)

Uninstall EFI simple file system protocol.

Parameters
handleEFI handle

Definition at line 688 of file efi_file.c.

688  {
690  EFI_STATUS efirc;
691  int rc;
692 
693  /* Close our own disk I/O protocol */
696 
697  /* We must install the file system protocol first, since
698  * otherwise the EDK2 code will attempt to helpfully uninstall
699  * it when the block I/O protocol is uninstalled, leading to a
700  * system lock-up.
701  */
702  if ( ( efirc = bs->UninstallMultipleProtocolInterfaces (
703  handle,
709  &efi_block_io_protocol, NULL ) ) != 0 ) {
710  rc = -EEFI ( efirc );
711  DBGC ( handle, "Could not uninstall simple file system "
712  "protocols: %s\n", strerror ( rc ) );
713  /* Oh dear */
714  }
715 }
EFI_BOOT_SERVICES * BootServices
A pointer to the EFI Boot Services Table.
Definition: UefiSpec.h:2000
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
#define EEFI(efirc)
Convert an EFI status code to an iPXE status code.
Definition: efi.h:157
static EFI_BLOCK_IO_PROTOCOL efi_block_io_protocol
Dummy EFI block I/O protocol.
Definition: efi_file.c:558
#define DBGC(...)
Definition: compiler.h:505
EFI_CLOSE_PROTOCOL CloseProtocol
Definition: UefiSpec.h:1906
static EFI_DISK_IO_PROTOCOL efi_disk_io_protocol
Dummy EFI disk I/O protocol.
Definition: efi_file.c:590
EFI_GUID efi_disk_io_protocol_guid
Disk I/O protocol GUID.
Definition: efi_guid.c:144
EFI_GUID efi_simple_file_system_protocol_guid
Simple file system protocol GUID.
Definition: efi_guid.c:232
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
EFI Boot Services Table.
Definition: UefiSpec.h:1836
EFI_HANDLE efi_image_handle
Image handle passed to entry point.
Definition: efi_init.c:30
EFI_UNINSTALL_MULTIPLE_PROTOCOL_INTERFACES UninstallMultipleProtocolInterfaces
Definition: UefiSpec.h:1916
EFI_GUID efi_block_io_protocol_guid
Block I/O protocol GUID.
Definition: efi_guid.c:108
RETURN_STATUS EFI_STATUS
Function return status for EFI API.
Definition: UefiBaseType.h:35
EFI_SYSTEM_TABLE * efi_systab
static EFI_SIMPLE_FILE_SYSTEM_PROTOCOL efi_simple_file_system_protocol
EFI simple file system protocol.
Definition: efi_file.c:504
uint16_t handle
Handle.
Definition: smbios.h:16
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362

References EFI_SYSTEM_TABLE::BootServices, EFI_BOOT_SERVICES::CloseProtocol, DBGC, EEFI, efi_block_io_protocol, efi_block_io_protocol_guid, efi_disk_io_protocol, efi_disk_io_protocol_guid, efi_image_handle, efi_simple_file_system_protocol, efi_simple_file_system_protocol_guid, efi_systab, handle, NULL, rc, strerror(), and EFI_BOOT_SERVICES::UninstallMultipleProtocolInterfaces.

Referenced by efi_image_exec().

Variable Documentation

◆ efi_file_root

static struct efi_file efi_file_root
static
Initial value:
= {
.file = {
.Open = efi_file_open,
.Close = efi_file_close,
.Delete = efi_file_delete,
.Read = efi_file_read,
.Write = efi_file_write,
.GetPosition = efi_file_get_position,
.SetPosition = efi_file_set_position,
.GetInfo = efi_file_get_info,
.SetInfo = efi_file_set_info,
.Flush = efi_file_flush,
},
.image = NULL,
}
static EFI_STATUS EFIAPI efi_file_set_info(EFI_FILE_PROTOCOL *this, EFI_GUID *type, UINTN len __unused, VOID *data __unused)
Set file information.
Definition: efi_file.c:444
static EFI_STATUS EFIAPI efi_file_get_info(EFI_FILE_PROTOCOL *this, EFI_GUID *type, UINTN *len, VOID *data)
Get file information.
Definition: efi_file.c:398
static EFI_STATUS EFIAPI efi_file_get_position(EFI_FILE_PROTOCOL *this, UINT64 *position)
Get file position.
Definition: efi_file.c:381
static EFI_STATUS EFIAPI efi_file_open(EFI_FILE_PROTOCOL *this, EFI_FILE_PROTOCOL **new, CHAR16 *wname, UINT64 mode __unused, UINT64 attributes __unused)
Open file.
Definition: efi_file.c:108
static EFI_STATUS EFIAPI efi_file_read(EFI_FILE_PROTOCOL *this, UINTN *len, VOID *data)
Read from file.
Definition: efi_file.c:296
static EFI_STATUS EFIAPI efi_file_set_position(EFI_FILE_PROTOCOL *this, UINT64 position)
Set file position.
Definition: efi_file.c:342
static EFI_STATUS EFIAPI efi_file_close(EFI_FILE_PROTOCOL *this)
Close file.
Definition: efi_file.c:165
static EFI_STATUS EFIAPI efi_file_flush(EFI_FILE_PROTOCOL *this)
Flush file modified data.
Definition: efi_file.c:462
static EFI_STATUS EFIAPI efi_file_write(EFI_FILE_PROTOCOL *this, UINTN *len, VOID *data __unused)
Write to file.
Definition: efi_file.c:325
#define EFI_FILE_PROTOCOL_REVISION
static EFI_STATUS EFIAPI efi_file_delete(EFI_FILE_PROTOCOL *this)
Close and delete file.
Definition: efi_file.c:186
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362

Root directory.

Definition at line 63 of file efi_file.c.

Referenced by efi_block_io_flush_blocks(), efi_block_io_read_blocks(), efi_block_io_reset(), efi_block_io_write_blocks(), efi_disk_io_read_disk(), efi_disk_io_write_disk(), efi_file_install(), efi_file_open(), and efi_file_open_volume().

◆ efi_simple_file_system_protocol

EFI_SIMPLE_FILE_SYSTEM_PROTOCOL efi_simple_file_system_protocol
static
Initial value:
= {
.OpenVolume = efi_file_open_volume,
}
static EFI_STATUS EFIAPI efi_file_open_volume(EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *filesystem __unused, EFI_FILE_PROTOCOL **file)
Open root directory.
Definition: efi_file.c:495
#define EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_REVISION

EFI simple file system protocol.

Definition at line 504 of file efi_file.c.

Referenced by efi_file_install(), and efi_file_uninstall().

◆ efi_block_io_media

EFI_BLOCK_IO_MEDIA efi_block_io_media
static
Initial value:
= {
.MediaId = EFI_MEDIA_ID_MAGIC,
.MediaPresent = TRUE,
.ReadOnly = TRUE,
.BlockSize = 1,
}
#define TRUE
Definition: tlan.h:46
#define EFI_MEDIA_ID_MAGIC
EFI media ID.
Definition: efi_file.c:51

Dummy block I/O media.

Definition at line 550 of file efi_file.c.

◆ efi_block_io_protocol

EFI_BLOCK_IO_PROTOCOL efi_block_io_protocol
static
Initial value:
= {
.Media = &efi_block_io_media,
.ReadBlocks = efi_block_io_read_blocks,
.WriteBlocks = efi_block_io_write_blocks,
.FlushBlocks = efi_block_io_flush_blocks,
}
static EFI_STATUS EFIAPI efi_block_io_read_blocks(EFI_BLOCK_IO_PROTOCOL *this __unused, UINT32 MediaId, EFI_LBA lba, UINTN len, VOID *data)
Dummy block I/O read.
Definition: efi_file.c:520
static EFI_STATUS EFIAPI efi_block_io_write_blocks(EFI_BLOCK_IO_PROTOCOL *this __unused, UINT32 MediaId, EFI_LBA lba, UINTN len, VOID *data)
Dummy block I/O write.
Definition: efi_file.c:531
static EFI_STATUS EFIAPI efi_block_io_reset(EFI_BLOCK_IO_PROTOCOL *this __unused, BOOLEAN extended)
Dummy block I/O reset.
Definition: efi_file.c:511
static EFI_STATUS EFIAPI efi_block_io_flush_blocks(EFI_BLOCK_IO_PROTOCOL *this __unused)
Dummy block I/O flush.
Definition: efi_file.c:543
#define EFI_BLOCK_IO_PROTOCOL_REVISION
Definition: BlockIo.h:210
static EFI_BLOCK_IO_MEDIA efi_block_io_media
Dummy block I/O media.
Definition: efi_file.c:550

Dummy EFI block I/O protocol.

Definition at line 558 of file efi_file.c.

Referenced by efi_file_install(), and efi_file_uninstall().

◆ efi_disk_io_protocol

EFI_DISK_IO_PROTOCOL efi_disk_io_protocol
static
Initial value:
= {
.ReadDisk = efi_disk_io_read_disk,
.WriteDisk = efi_disk_io_write_disk,
}
static EFI_STATUS EFIAPI efi_disk_io_read_disk(EFI_DISK_IO_PROTOCOL *this __unused, UINT32 MediaId, UINT64 offset, UINTN len, VOID *data)
Dummy disk I/O read.
Definition: efi_file.c:569
static EFI_STATUS EFIAPI efi_disk_io_write_disk(EFI_DISK_IO_PROTOCOL *this __unused, UINT32 MediaId, UINT64 offset, UINTN len, VOID *data)
Dummy disk I/O write.
Definition: efi_file.c:580
#define EFI_DISK_IO_PROTOCOL_REVISION
Definition: DiskIo.h:96

Dummy EFI disk I/O protocol.

Definition at line 590 of file efi_file.c.

Referenced by efi_file_install(), and efi_file_uninstall().