iPXE
efi_local.c
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2016 Michael Brown <mbrown@fensystems.co.uk>.
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License as
6  * published by the Free Software Foundation; either version 2 of the
7  * License, or (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful, but
10  * WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17  * 02110-1301, USA.
18  *
19  * You can also choose to distribute this program under the terms of
20  * the Unmodified Binary Distribution Licence (as given in the file
21  * COPYING.UBDL), provided that you have satisfied its requirements.
22  */
23 
24 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
25 
26 #include <string.h>
27 #include <strings.h>
28 #include <stdio.h>
29 #include <errno.h>
30 #include <assert.h>
31 #include <ipxe/refcnt.h>
32 #include <ipxe/malloc.h>
33 #include <ipxe/xfer.h>
34 #include <ipxe/open.h>
35 #include <ipxe/uri.h>
36 #include <ipxe/iobuf.h>
37 #include <ipxe/process.h>
38 #include <ipxe/errortab.h>
39 #include <ipxe/efi/efi.h>
40 #include <ipxe/efi/efi_strings.h>
41 #include <ipxe/efi/efi_path.h>
43 #include <ipxe/efi/Guid/FileInfo.h>
45 
46 /** @file
47  *
48  * EFI local file access
49  *
50  */
51 
52 /* Disambiguate the various error causes */
53 #define EINFO_EEFI_OPEN \
54  __einfo_uniqify ( EINFO_EPLATFORM, 0x01, "Could not open" )
55 #define EINFO_EEFI_OPEN_NOT_FOUND \
56  __einfo_platformify ( EINFO_EEFI_OPEN, EFI_NOT_FOUND, \
57  "Not found" )
58 #define EEFI_OPEN_NOT_FOUND \
59  __einfo_error ( EINFO_EEFI_OPEN_NOT_FOUND )
60 #define EEFI_OPEN( efirc ) EPLATFORM ( EINFO_EEFI_OPEN, efirc, \
61  EEFI_OPEN_NOT_FOUND )
62 
63 /** Download blocksize */
64 #define EFI_LOCAL_BLKSIZE 4096
65 
66 /** An EFI local file */
67 struct efi_local {
68  /** Reference count */
69  struct refcnt refcnt;
70  /** Data transfer interface */
71  struct interface xfer;
72  /** Download process */
73  struct process process;
74 
75  /** Download URI */
76  struct uri *uri;
77  /** Volume name, or NULL to use loaded image's device */
78  const char *volume;
79  /** File path */
80  const char *path;
81 
82  /** EFI root directory */
84  /** EFI file */
86  /** Length of file */
87  size_t len;
88 };
89 
90 /** Human-readable error messages */
91 struct errortab efi_local_errors[] __errortab = {
93 };
94 
95 /**
96  * Free local file
97  *
98  * @v refcnt Reference count
99  */
100 static void efi_local_free ( struct refcnt *refcnt ) {
101  struct efi_local *local =
102  container_of ( refcnt, struct efi_local, refcnt );
103 
104  uri_put ( local->uri );
105  free ( local );
106 }
107 
108 /**
109  * Close local file
110  *
111  * @v local Local file
112  * @v rc Reason for close
113  */
114 static void efi_local_close ( struct efi_local *local, int rc ) {
115 
116  /* Stop process */
117  process_del ( &local->process );
118 
119  /* Shut down data transfer interface */
120  intf_shutdown ( &local->xfer, rc );
121 
122  /* Close EFI file */
123  if ( local->file ) {
124  local->file->Close ( local->file );
125  local->file = NULL;
126  }
127 
128  /* Close EFI root directory */
129  if ( local->root ) {
130  local->root->Close ( local->root );
131  local->root = NULL;
132  }
133 }
134 
135 /**
136  * Check for matching volume name
137  *
138  * @v local Local file
139  * @v device Device handle
140  * @v root Root filesystem handle
141  * @v volume Volume name
142  * @ret rc Return status code
143  */
144 static int efi_local_check_volume_name ( struct efi_local *local,
147  const char *volume ) {
149  UINTN size;
150  char *label;
151  EFI_STATUS efirc;
152  int rc;
153 
154  /* Get length of file system information */
155  size = 0;
156  root->GetInfo ( root, &efi_file_system_info_id, &size, NULL );
157 
158  /* Allocate file system information */
159  info = malloc ( size );
160  if ( ! info ) {
161  rc = -ENOMEM;
162  goto err_alloc_info;
163  }
164 
165  /* Get file system information */
166  if ( ( efirc = root->GetInfo ( root, &efi_file_system_info_id, &size,
167  info ) ) != 0 ) {
168  rc = -EEFI ( efirc );
169  DBGC ( local, "LOCAL %p could not get file system info on %s: "
170  "%s\n", local, efi_handle_name ( device ),
171  strerror ( rc ) );
172  goto err_get_info;
173  }
174  DBGC2 ( local, "LOCAL %p found %s with label \"%ls\"\n",
175  local, efi_handle_name ( device ), info->VolumeLabel );
176 
177  /* Construct volume label for comparison */
178  if ( asprintf ( &label, "%ls", info->VolumeLabel ) < 0 ) {
179  rc = -ENOMEM;
180  goto err_alloc_label;
181  }
182 
183  /* Compare volume label */
184  if ( strcasecmp ( volume, label ) != 0 ) {
185  rc = -ENOENT;
186  goto err_compare;
187  }
188 
189  /* Success */
190  rc = 0;
191 
192  err_compare:
193  free ( label );
194  err_alloc_label:
195  err_get_info:
196  free ( info );
197  err_alloc_info:
198  return rc;
199 }
200 
201 /**
202  * Open root filesystem
203  *
204  * @v local Local file
205  * @v device Device handle
206  * @v root Root filesystem handle to fill in
207  * @ret rc Return status code
208  */
209 static int efi_local_open_root ( struct efi_local *local, EFI_HANDLE device,
210  EFI_FILE_PROTOCOL **root ) {
212  EFI_STATUS efirc;
213  int rc;
214 
215  /* Open file system protocol */
217  &fs ) ) != 0 ) {
218  DBGC ( local, "LOCAL %p could not open filesystem on %s: %s\n",
219  local, efi_handle_name ( device ), strerror ( rc ) );
220  return rc;
221  }
222 
223  /* Open root directory */
224  if ( ( efirc = fs->OpenVolume ( fs, root ) ) != 0 ) {
225  rc = -EEFI ( efirc );
226  DBGC ( local, "LOCAL %p could not open volume on %s: %s\n",
227  local, efi_handle_name ( device ), strerror ( rc ) );
228  return rc;
229  }
230 
231  return 0;
232 }
233 
234 /**
235  * Open root filesystem of specified volume
236  *
237  * @v local Local file
238  * @ret rc Return status code
239  */
240 static int efi_local_open_volume ( struct efi_local *local ) {
243  int ( * check ) ( struct efi_local *local, EFI_HANDLE device,
244  EFI_FILE_PROTOCOL *root, const char *volume );
245  const char *volume = local->volume;
248  EFI_HANDLE *handles;
250  UINTN num_handles;
251  UINTN i;
252  EFI_STATUS efirc;
253  int rc;
254 
255  /* Identify candidate handles */
256  if ( volume ) {
257  /* Locate all filesystem handles */
258  if ( ( efirc = bs->LocateHandleBuffer ( ByProtocol, protocol,
259  NULL, &num_handles,
260  &handles ) ) != 0 ) {
261  rc = -EEFI ( efirc );
262  DBGC ( local, "LOCAL %p could not enumerate handles: "
263  "%s\n", local, strerror ( rc ) );
264  return rc;
265  }
267  } else {
268  /* Locate filesystem from which we were loaded */
270  if ( ( efirc = bs->LocateDevicePath ( protocol, &path,
271  &device ) ) != 0 ) {
272  rc = -EEFI ( efirc );
273  DBGC ( local, "LOCAL %p could not locate file system "
274  "on %s: %s\n", local,
276  strerror ( rc ) );
277  return rc;
278  }
279  handles = &device;
280  num_handles = 1;
281  check = NULL;
282  }
283 
284  /* Find matching handle */
285  for ( i = 0 ; i < num_handles ; i++ ) {
286 
287  /* Get this device handle */
288  device = handles[i];
289 
290  /* Open root directory */
291  if ( ( rc = efi_local_open_root ( local, device, &root ) ) != 0)
292  continue;
293 
294  /* Check volume name, if applicable */
295  if ( ( check == NULL ) ||
296  ( ( rc = check ( local, device, root, volume ) ) == 0 ) ) {
297  DBGC ( local, "LOCAL %p using %s",
298  local, efi_handle_name ( device ) );
299  if ( volume )
300  DBGC ( local, " with label \"%s\"", volume );
301  DBGC ( local, "\n" );
302  local->root = root;
303  break;
304  }
305 
306  /* Close root directory */
307  root->Close ( root );
308  }
309 
310  /* Free handles, if applicable */
311  if ( volume )
312  bs->FreePool ( handles );
313 
314  /* Fail if we found no matching handle */
315  if ( ! local->root ) {
316  DBGC ( local, "LOCAL %p found no matching handle\n", local );
317  return -ENOENT;
318  }
319 
320  return 0;
321 }
322 
323 /**
324  * Open fully-resolved path
325  *
326  * @v local Local file
327  * @v resolved Resolved path
328  * @ret rc Return status code
329  */
330 static int efi_local_open_resolved ( struct efi_local *local,
331  const char *resolved ) {
332  size_t name_len = strlen ( resolved );
333  CHAR16 name[ name_len + 1 /* wNUL */ ];
335  EFI_STATUS efirc;
336  int rc;
337 
338  /* Construct filename */
339  efi_snprintf ( name, ( name_len + 1 /* wNUL */ ), "%s", resolved );
340 
341  /* Open file */
342  if ( ( efirc = local->root->Open ( local->root, &file, name,
343  EFI_FILE_MODE_READ, 0 ) ) != 0 ) {
344  rc = -EEFI_OPEN ( efirc );
345  DBGC ( local, "LOCAL %p could not open \"%s\": %s\n",
346  local, resolved, strerror ( rc ) );
347  return rc;
348  }
349  local->file = file;
350 
351  return 0;
352 }
353 
354 /**
355  * Open specified path
356  *
357  * @v local Local file
358  * @ret rc Return status code
359  */
360 static int efi_local_open_path ( struct efi_local *local ) {
364  char base[ efi_path_len ( path ) / 2 /* Cannot exceed this length */ ];
365  size_t remaining = sizeof ( base );
366  size_t len;
367  char *resolved;
368  char *tmp;
369  int rc;
370 
371  /* Construct base path to our own image, if possible */
372  memset ( base, 0, sizeof ( base ) );
373  tmp = base;
374  for ( ; ( next = efi_path_next ( path ) ) ; path = next ) {
376  len = snprintf ( tmp, remaining, "%ls", fp->PathName );
377  assert ( len < remaining );
378  tmp += len;
379  remaining -= len;
380  }
381  DBGC2 ( local, "LOCAL %p base path \"%s\"\n",
382  local, base );
383 
384  /* Convert to sane path separators */
385  for ( tmp = base ; *tmp ; tmp++ ) {
386  if ( *tmp == '\\' )
387  *tmp = '/';
388  }
389 
390  /* Resolve path */
391  resolved = resolve_path ( base, local->path );
392  if ( ! resolved ) {
393  rc = -ENOMEM;
394  goto err_resolve;
395  }
396 
397  /* Convert to insane path separators */
398  for ( tmp = resolved ; *tmp ; tmp++ ) {
399  if ( *tmp == '/' )
400  *tmp = '\\';
401  }
402  DBGC ( local, "LOCAL %p using \"%s\"\n",
403  local, resolved );
404 
405  /* Open resolved path */
406  if ( ( rc = efi_local_open_resolved ( local, resolved ) ) != 0 )
407  goto err_open;
408 
409  err_open:
410  free ( resolved );
411  err_resolve:
412  return rc;
413 }
414 
415 /**
416  * Get file length
417  *
418  * @v local Local file
419  * @ret rc Return status code
420  */
421 static int efi_local_len ( struct efi_local *local ) {
422  EFI_FILE_PROTOCOL *file = local->file;
424  EFI_STATUS efirc;
425  UINTN size;
426  int rc;
427 
428  /* Get size of file information */
429  size = 0;
431 
432  /* Allocate file information */
433  info = malloc ( size );
434  if ( ! info ) {
435  rc = -ENOMEM;
436  goto err_alloc;
437  }
438 
439  /* Get file information */
440  if ( ( efirc = file->GetInfo ( file, &efi_file_info_id, &size,
441  info ) ) != 0 ) {
442  rc = -EEFI ( efirc );
443  DBGC ( local, "LOCAL %p could not get file info: %s\n",
444  local, strerror ( rc ) );
445  goto err_info;
446  }
447 
448  /* Record file length */
449  local->len = info->FileSize;
450 
451  /* Success */
452  rc = 0;
453 
454  err_info:
455  free ( info );
456  err_alloc:
457  return rc;
458 }
459 
460 /**
461  * Local file process
462  *
463  * @v local Local file
464  */
465 static void efi_local_step ( struct efi_local *local ) {
466  struct io_buffer *iobuf = NULL;
467  size_t remaining;
468  size_t frag_len;
469  UINTN size;
470  EFI_STATUS efirc;
471  int rc;
472 
473  /* Wait until data transfer interface is ready */
474  if ( ! xfer_window ( &local->xfer ) )
475  return;
476 
477  /* Open specified volume root directory, if not yet open */
478  if ( ( ! local->root ) &&
479  ( ( rc = efi_local_open_volume ( local ) ) != 0 ) )
480  goto err;
481 
482  /* Open specified file, if not yet open */
483  if ( ( ! local->file ) &&
484  ( ( rc = efi_local_open_path ( local ) ) != 0 ) )
485  goto err;
486 
487  /* Get file length, if not yet known */
488  if ( ( ! local->len ) &&
489  ( ( rc = efi_local_len ( local ) ) != 0 ) )
490  goto err;
491 
492  /* Presize receive buffer */
493  remaining = local->len;
494  xfer_seek ( &local->xfer, remaining );
495  xfer_seek ( &local->xfer, 0 );
496 
497  /* Get file contents */
498  while ( remaining ) {
499 
500  /* Calculate length for this fragment */
501  frag_len = remaining;
502  if ( frag_len > EFI_LOCAL_BLKSIZE )
503  frag_len = EFI_LOCAL_BLKSIZE;
504 
505  /* Allocate I/O buffer */
506  iobuf = xfer_alloc_iob ( &local->xfer, frag_len );
507  if ( ! iobuf ) {
508  rc = -ENOMEM;
509  goto err;
510  }
511 
512  /* Read block */
513  size = frag_len;
514  if ( ( efirc = local->file->Read ( local->file, &size,
515  iobuf->data ) ) != 0 ) {
516  rc = -EEFI ( efirc );
517  DBGC ( local, "LOCAL %p could not read from file: %s\n",
518  local, strerror ( rc ) );
519  goto err;
520  }
521  assert ( size <= frag_len );
522  iob_put ( iobuf, size );
523 
524  /* Deliver data */
525  if ( ( rc = xfer_deliver_iob ( &local->xfer,
526  iob_disown ( iobuf ) ) ) != 0 ) {
527  DBGC ( local, "LOCAL %p could not deliver data: %s\n",
528  local, strerror ( rc ) );
529  goto err;
530  }
531 
532  /* Move to next block */
533  remaining -= frag_len;
534  }
535 
536  /* Close download */
537  efi_local_close ( local, 0 );
538 
539  return;
540 
541  err:
542  free_iob ( iobuf );
543  efi_local_close ( local, rc );
544 }
545 
546 /** Data transfer interface operations */
550 };
551 
552 /** Data transfer interface descriptor */
554  INTF_DESC ( struct efi_local, xfer, efi_local_operations );
555 
556 /** Process descriptor */
559 
560 /**
561  * Open local file
562  *
563  * @v xfer Data transfer interface
564  * @v uri Request URI
565  * @ret rc Return status code
566  */
567 static int efi_local_open ( struct interface *xfer, struct uri *uri ) {
568  struct efi_local *local;
569 
570  /* Allocate and initialise structure */
571  local = zalloc ( sizeof ( *local ) );
572  if ( ! local )
573  return -ENOMEM;
574  ref_init ( &local->refcnt, efi_local_free );
575  intf_init ( &local->xfer, &efi_local_xfer_desc, &local->refcnt );
577  &local->refcnt );
578  local->uri = uri_get ( uri );
579  local->volume = ( ( uri->host && uri->host[0] ) ? uri->host : NULL );
580  local->path = ( uri->opaque ? uri->opaque : uri->path );
581 
582  /* Start download process */
583  process_add ( &local->process );
584 
585  /* Attach to parent interface, mortalise self, and return */
586  intf_plug_plug ( &local->xfer, xfer );
587  ref_put ( &local->refcnt );
588  return 0;
589 }
590 
591 /** EFI local file URI opener */
592 struct uri_opener efi_local_uri_opener __uri_opener = {
593  .scheme = "file",
594  .open = efi_local_open,
595 };
struct errortab efi_local_errors [] __errortab
Human-readable error messages.
Definition: efi_local.c:91
A process.
Definition: process.h:17
struct uri_opener efi_local_uri_opener __uri_opener
EFI local file URI opener.
Definition: efi_local.c:592
EFI_FILE_CLOSE Close
EFI_BOOT_SERVICES * BootServices
A pointer to the EFI Boot Services Table.
Definition: UefiSpec.h:2098
uint32_t base
Base.
Definition: librm.h:138
An object interface operation.
Definition: interface.h:17
EFI_LOADED_IMAGE_PROTOCOL * efi_loaded_image
Loaded image protocol for this image.
Definition: efi_init.c:38
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
const char * name
Definition: ath9k_hw.c:1984
void xfer_window_changed(struct interface *intf)
Report change of flow control window.
Definition: xfer.c:146
void intf_close(struct interface *intf, int rc)
Close an object interface.
Definition: interface.c:249
A text label widget.
Definition: label.h:16
#define iob_put(iobuf, len)
Definition: iobuf.h:124
Error message tables.
void intf_shutdown(struct interface *intf, int rc)
Shut down an object interface.
Definition: interface.c:278
#define EEFI(efirc)
Convert an EFI status code to an iPXE status code.
Definition: efi.h:174
u32 info
Definition: ar9003_mac.h:67
static void uri_put(struct uri *uri)
Decrement URI reference count.
Definition: uri.h:205
int xfer_deliver_iob(struct interface *intf, struct io_buffer *iobuf)
Deliver datagram as I/O buffer without metadata.
Definition: xfer.c:255
static struct uri * uri_get(struct uri *uri)
Increment URI reference count.
Definition: uri.h:194
struct stp_switch root
Root switch.
Definition: stp.h:26
struct process process
Download process.
Definition: efi_local.c:73
EFI_GUID efi_file_system_info_id
File system information GUID.
Definition: efi_guid.c:465
128 bit buffer containing a unique identifier value.
Definition: Base.h:215
#define ref_init(refcnt, free)
Initialise a reference counter.
Definition: refcnt.h:64
Error codes.
I/O buffers.
void free_iob(struct io_buffer *iobuf)
Free I/O buffer.
Definition: iobuf.c:152
EFI strings.
#define __einfo_errortab(einfo)
Definition: errortab.h:23
uint16_t size
Buffer size.
Definition: dwmac.h:14
#define DBGC(...)
Definition: compiler.h:505
EFI_DEVICE_PATH_PROTOCOL * FilePath
A pointer to the file path portion specific to DeviceHandle that the EFI Image was loaded from.
Definition: LoadedImage.h:56
A process descriptor.
Definition: process.h:31
EFI_FILE_GET_INFO GetInfo
#define ENOENT
No such file or directory.
Definition: errno.h:514
void intf_plug_plug(struct interface *a, struct interface *b)
Plug two object interfaces together.
Definition: interface.c:107
int strcasecmp(const char *first, const char *second)
Compare case-insensitive strings.
Definition: string.c:208
size_t efi_path_len(EFI_DEVICE_PATH_PROTOCOL *path)
Find length of device path (excluding terminator)
Definition: efi_path.c:173
struct io_buffer * xfer_alloc_iob(struct interface *intf, size_t len)
Allocate I/O buffer.
Definition: xfer.c:158
unsigned short CHAR16
#define PROC_DESC_ONCE(object_type, process, _step)
Define a process descriptor for a process that runs only once.
Definition: process.h:97
This protocol can be used on any device handle to obtain generic path/location information concerning...
Definition: DevicePath.h:45
CHAR16 PathName[1]
A NULL-terminated Path string including directory and file names.
Definition: DevicePath.h:1106
uint16_t device
Device ID.
Definition: ena.h:24
Uniform Resource Identifiers.
void process_del(struct process *process)
Remove process from process list.
Definition: process.c:79
static void efi_local_step(struct efi_local *local)
Local file process.
Definition: efi_local.c:465
static void efi_local_free(struct refcnt *refcnt)
Free local file.
Definition: efi_local.c:100
size_t xfer_window(struct interface *intf)
Check flow control window.
Definition: xfer.c:116
struct refcnt refcnt
Reference count.
Definition: efi_local.c:69
struct uri * uri
Download URI.
Definition: efi_local.c:76
Dynamic memory allocation.
Data transfer interfaces.
A reference counter.
Definition: refcnt.h:26
unsigned long tmp
Definition: linux_pci.h:64
#define ENOMEM
Not enough space.
Definition: errno.h:534
A hardware device.
Definition: device.h:76
#define iob_disown(iobuf)
Disown an I/O buffer.
Definition: iobuf.h:216
EFI_DEVICE_PATH_PROTOCOL * efi_loaded_image_path
Device path for the loaded image's device handle.
Definition: efi_init.c:41
Assertions.
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
#define container_of(ptr, type, field)
Get containing structure.
Definition: stddef.h:35
An object interface.
Definition: interface.h:124
SimpleFileSystem protocol as defined in the UEFI 2.0 specification.
EFI_GUID efi_simple_file_system_protocol_guid
Simple file system protocol GUID.
Definition: efi_guid.c:336
ring len
Length.
Definition: dwmac.h:231
const char * path
Path (after URI decoding)
Definition: uri.h:80
const char * scheme
URI protocol name.
Definition: open.h:53
int efi_snprintf(wchar_t *wbuf, size_t wsize, const char *fmt,...)
Write a formatted string to a buffer.
Definition: efi_strings.c:106
EFI_FILE_PROTOCOL * file
EFI file.
Definition: efi_local.c:85
const char * efi_devpath_text(EFI_DEVICE_PATH_PROTOCOL *path)
Get textual representation of device path.
Definition: efi_debug.c:247
size_t len
Length of file.
Definition: efi_local.c:87
static int efi_local_check_volume_name(struct efi_local *local, EFI_HANDLE device, EFI_FILE_PROTOCOL *root, const char *volume)
Check for matching volume name.
Definition: efi_local.c:144
char * resolve_path(const char *base_path, const char *relative_path)
Resolve base+relative path.
Definition: uri.c:632
const char * volume
Volume name, or NULL to use loaded image's device.
Definition: efi_local.c:78
static int efi_local_len(struct efi_local *local)
Get file length.
Definition: efi_local.c:421
int xfer_seek(struct interface *intf, off_t offset)
Seek to position.
Definition: xfer.c:351
void process_add(struct process *process)
Add process to process list.
Definition: process.c:59
const char * efi_handle_name(EFI_HANDLE handle)
Get name of an EFI handle.
Definition: efi_debug.c:652
An object interface descriptor.
Definition: interface.h:55
uint32_t fs
Definition: librm.h:138
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
static void(* free)(struct refcnt *refcnt))
Definition: refcnt.h:54
#define EEFI_OPEN(efirc)
Definition: efi_local.c:60
static int efi_local_open_volume(struct efi_local *local)
Open root filesystem of specified volume.
Definition: efi_local.c:240
void * zalloc(size_t size)
Allocate cleared memory.
Definition: malloc.c:661
EFI Boot Services Table.
Definition: UefiSpec.h:1930
const char * path
File path.
Definition: efi_local.c:80
static int efi_local_open_root(struct efi_local *local, EFI_HANDLE device, EFI_FILE_PROTOCOL **root)
Open root filesystem.
Definition: efi_local.c:209
int asprintf(char **strp, const char *fmt,...)
Write a formatted string to newly allocated memory.
Definition: asprintf.c:41
#define INTF_OP(op_type, object_type, op_func)
Define an object interface operation.
Definition: interface.h:32
static struct interface_descriptor efi_local_xfer_desc
Data transfer interface descriptor.
Definition: efi_local.c:553
#define efi_open(handle, protocol, interface)
Open protocol for ephemeral use.
Definition: efi.h:443
size_t strlen(const char *src)
Get length of string.
Definition: string.c:243
Processes.
static struct interface_operation efi_local_operations[]
Data transfer interface operations.
Definition: efi_local.c:547
Data transfer interface opening.
EFI device paths.
UINT64 UINTN
Unsigned value of native width.
static struct process_descriptor efi_local_process_desc
Process descriptor.
Definition: efi_local.c:557
static void process_init_stopped(struct process *process, struct process_descriptor *desc, struct refcnt *refcnt)
Initialise process without adding to process list.
Definition: process.h:145
uint32_t next
Next descriptor address.
Definition: dwmac.h:22
void * malloc(size_t size)
Allocate memory.
Definition: malloc.c:620
EFI_DEVICE_PATH_PROTOCOL * efi_path_next(EFI_DEVICE_PATH_PROTOCOL *path)
Find next element in device path.
Definition: efi_path.c:118
const char * host
Host name.
Definition: uri.h:76
EFI_FREE_POOL FreePool
Definition: UefiSpec.h:1949
Provides a GUID and a data structure that can be used with EFI_FILE_PROTOCOL.SetInfo() and EFI_FILE_P...
static int efi_local_open(struct interface *xfer, struct uri *uri)
Open local file.
Definition: efi_local.c:567
static void efi_local_close(struct efi_local *local, int rc)
Close local file.
Definition: efi_local.c:114
EFI API.
#define INTF_DESC(object_type, intf, operations)
Define an object interface descriptor.
Definition: interface.h:80
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)
static int efi_local_open_path(struct efi_local *local)
Open specified path.
Definition: efi_local.c:360
EFI_FILE_PROTOCOL * root
EFI root directory.
Definition: efi_local.c:83
const char * opaque
Opaque part.
Definition: uri.h:70
#define DBGC2(...)
Definition: compiler.h:522
An EFI local file.
Definition: efi_local.c:67
static int efi_local_open_resolved(struct efi_local *local, const char *resolved)
Open fully-resolved path.
Definition: efi_local.c:330
EFI_GUID efi_file_info_id
File information GUID.
Definition: efi_guid.c:462
#define EFI_FILE_MODE_READ
void * data
Start of data.
Definition: iobuf.h:52
RETURN_STATUS EFI_STATUS
Function return status for EFI API.
Definition: UefiBaseType.h:31
Reference counting.
int snprintf(char *buf, size_t size, const char *fmt,...)
Write a formatted string to a buffer.
Definition: vsprintf.c:382
Retrieve the set of handles from the handle database that support a specified protocol.
Definition: UefiSpec.h:1530
A Uniform Resource Identifier.
Definition: uri.h:64
EFI_SYSTEM_TABLE * efi_systab
uint16_t protocol
Protocol ID.
Definition: stp.h:18
struct interface xfer
Data transfer interface.
Definition: efi_local.c:71
static void intf_init(struct interface *intf, struct interface_descriptor *desc, struct refcnt *refcnt)
Initialise an object interface.
Definition: interface.h:203
A URI opener.
Definition: open.h:47
#define EINFO_EEFI_OPEN_NOT_FOUND
Definition: efi_local.c:55
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321
String functions.
Provides a GUID and a data structure that can be used with EFI_FILE_PROTOCOL.GetInfo() or EFI_FILE_PR...
#define EFI_LOCAL_BLKSIZE
Download blocksize.
Definition: efi_local.c:64
The EFI_FILE_PROTOCOL provides file IO access to supported file systems.
Definition: efi.h:61
EFI_LOCATE_HANDLE_BUFFER LocateHandleBuffer
Definition: UefiSpec.h:2007
EFI_LOCATE_DEVICE_PATH LocateDevicePath
Definition: UefiSpec.h:1971
#define ref_put(refcnt)
Drop reference to object.
Definition: refcnt.h:106
String functions.
void * memset(void *dest, int character, size_t len) __nonnull
A persistent I/O buffer.
Definition: iobuf.h:37
PACKED union @541::@555 Header
Definition: Acpi10.h:155