iPXE
Data Structures | Macros | Enumerations | Functions | Variables
sanboot.h File Reference

iPXE sanboot API More...

#include <ipxe/api.h>
#include <ipxe/refcnt.h>
#include <ipxe/list.h>
#include <ipxe/uri.h>
#include <ipxe/retry.h>
#include <ipxe/process.h>
#include <ipxe/blockdev.h>
#include <ipxe/acpi.h>
#include <ipxe/uuid.h>
#include <config/sanboot.h>
#include <ipxe/null_sanboot.h>
#include <ipxe/dummy_sanboot.h>
#include <ipxe/efi/efi_block.h>
#include <bits/sanboot.h>

Go to the source code of this file.

Data Structures

struct  san_path
 A SAN path. More...
 
struct  san_device
 A SAN device. More...
 
struct  san_boot_config
 SAN boot configuration parameters. More...
 

Macros

#define SAN_DEFAULT_DRIVE   0x80
 Default SAN drive number. More...
 
#define SANBOOT_INLINE(_subsys, _api_func)   SINGLE_API_INLINE ( SANBOOT_PREFIX_ ## _subsys, _api_func )
 Calculate static inline sanboot API function name. More...
 
#define PROVIDE_SANBOOT(_subsys, _api_func, _func)   PROVIDE_SINGLE_API ( SANBOOT_PREFIX_ ## _subsys, _api_func, _func )
 Provide a sanboot API implementation. More...
 
#define PROVIDE_SANBOOT_INLINE(_subsys, _api_func)   PROVIDE_SINGLE_API_INLINE ( SANBOOT_PREFIX_ ## _subsys, _api_func )
 Provide a static inline sanboot API implementation. More...
 
#define for_each_sandev(sandev)   list_for_each_entry ( (sandev), &san_devices, list )
 Iterate over all SAN devices. More...
 

Enumerations

enum  san_device_flags { SAN_NO_DESCRIBE = 0x0001 }
 SAN device flags. More...
 

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
 
int san_hook (unsigned int drive, struct uri **uris, unsigned int count, unsigned int flags)
 Hook SAN device. More...
 
void san_unhook (unsigned int drive)
 Unhook SAN device. More...
 
int san_boot (unsigned int drive, struct san_boot_config *config)
 Attempt to boot from a SAN device. More...
 
int san_describe (void)
 Describe SAN devices for SAN-booted operating system. More...
 
static int have_sandevs (void)
 There exist some SAN devices. More...
 
static struct san_devicesandev_get (struct san_device *sandev)
 Get reference to SAN device. More...
 
static void sandev_put (struct san_device *sandev)
 Drop reference to SAN device. More...
 
static size_t sandev_blksize (struct san_device *sandev)
 Calculate SAN device block size. More...
 
static uint64_t sandev_capacity (struct san_device *sandev)
 Calculate SAN device capacity. More...
 
static int sandev_needs_reopen (struct san_device *sandev)
 Check if SAN device needs to be reopened. More...
 
struct san_devicesandev_find (unsigned int drive)
 Find SAN device by drive number. More...
 
struct san_devicesandev_next (unsigned int drive)
 Find next SAN device by drive number. More...
 
int sandev_reopen (struct san_device *sandev)
 (Re)open SAN device More...
 
int sandev_reset (struct san_device *sandev)
 Reset SAN device. More...
 
int sandev_read (struct san_device *sandev, uint64_t lba, unsigned int count, userptr_t buffer)
 Read from SAN device. More...
 
int sandev_write (struct san_device *sandev, uint64_t lba, unsigned int count, userptr_t buffer)
 Write to SAN device. More...
 
struct san_devicealloc_sandev (struct uri **uris, unsigned int count, size_t priv_size)
 Allocate SAN device. More...
 
int register_sandev (struct san_device *sandev, unsigned int drive, unsigned int flags)
 Register SAN device. More...
 
void unregister_sandev (struct san_device *sandev)
 Unregister SAN device. More...
 
unsigned int san_default_drive (void)
 Get default SAN drive number. More...
 

Variables

struct list_head san_devices
 

Detailed Description

iPXE sanboot API

The sanboot API provides methods for hooking, unhooking, describing, and booting from SAN devices.

Definition in file sanboot.h.

Macro Definition Documentation

◆ SAN_DEFAULT_DRIVE

#define SAN_DEFAULT_DRIVE   0x80

Default SAN drive number.

The drive number is an externally defined concept only in a BIOS environment, where it represents the INT13 drive number (0x80 for the first hard disk). We retain it in other environments to allow for a simple way for iPXE commands to refer to SAN drives.

Definition at line 33 of file sanboot.h.

◆ SANBOOT_INLINE

#define SANBOOT_INLINE (   _subsys,
  _api_func 
)    SINGLE_API_INLINE ( SANBOOT_PREFIX_ ## _subsys, _api_func )

Calculate static inline sanboot API function name.

Parameters
_prefixSubsystem prefix
_api_funcAPI function
Return values
_subsys_funcSubsystem API function

Definition at line 128 of file sanboot.h.

◆ PROVIDE_SANBOOT

#define PROVIDE_SANBOOT (   _subsys,
  _api_func,
  _func 
)    PROVIDE_SINGLE_API ( SANBOOT_PREFIX_ ## _subsys, _api_func, _func )

Provide a sanboot API implementation.

Parameters
_prefixSubsystem prefix
_api_funcAPI function
_funcImplementing function

Definition at line 138 of file sanboot.h.

◆ PROVIDE_SANBOOT_INLINE

#define PROVIDE_SANBOOT_INLINE (   _subsys,
  _api_func 
)    PROVIDE_SINGLE_API_INLINE ( SANBOOT_PREFIX_ ## _subsys, _api_func )

Provide a static inline sanboot API implementation.

Parameters
_prefixSubsystem prefix
_api_funcAPI function

Definition at line 147 of file sanboot.h.

◆ for_each_sandev

#define for_each_sandev (   sandev)    list_for_each_entry ( (sandev), &san_devices, list )

Iterate over all SAN devices.

Definition at line 196 of file sanboot.h.

Enumeration Type Documentation

◆ san_device_flags

SAN device flags.

Enumerator
SAN_NO_DESCRIBE 

Device should not be included in description tables.

Definition at line 104 of file sanboot.h.

104  {
105  /** Device should not be included in description tables */
106  SAN_NO_DESCRIBE = 0x0001,
107 };
Device should not be included in description tables.
Definition: sanboot.h:106

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )

◆ san_hook()

int san_hook ( unsigned int  drive,
struct uri **  uris,
unsigned int  count,
unsigned int  flags 
)

Hook SAN device.

Parameters
driveDrive number
urisList of URIs
countNumber of URIs
flagsFlags
Return values
driveDrive number, or negative error

Referenced by uriboot().

◆ san_unhook()

void san_unhook ( unsigned int  drive)

Unhook SAN device.

Parameters
driveDrive number

Referenced by uriboot().

◆ san_boot()

int san_boot ( unsigned int  drive,
struct san_boot_config config 
)

Attempt to boot from a SAN device.

Parameters
driveDrive number
configBoot configuration parameters
Return values
rcReturn status code

Referenced by uriboot().

◆ san_describe()

int san_describe ( void  )

Describe SAN devices for SAN-booted operating system.

Return values
rcReturn status code

Referenced by uriboot().

◆ have_sandevs()

static int have_sandevs ( void  )
inlinestatic

There exist some SAN devices.

Return values
existenceExistence of SAN devices

Definition at line 203 of file sanboot.h.

203  {
204  return ( ! list_empty ( &san_devices ) );
205 }
struct list_head san_devices
#define list_empty(list)
Test whether a list is empty.
Definition: list.h:136

References list_empty, and san_devices.

Referenced by int13_hook(), and int13_unhook().

◆ sandev_get()

static struct san_device* sandev_get ( struct san_device sandev)
inlinestatic

Get reference to SAN device.

Parameters
sandevSAN device
Return values
sandevSAN device

Definition at line 214 of file sanboot.h.

214  {
215  ref_get ( &sandev->refcnt );
216  return sandev;
217 }
#define ref_get(refcnt)
Get additional reference to object.
Definition: refcnt.h:92
struct refcnt refcnt
Reference count.
Definition: sanboot.h:60

References ref_get, and san_device::refcnt.

◆ sandev_put()

static void sandev_put ( struct san_device sandev)
inlinestatic

Drop reference to SAN device.

Parameters
sandevSAN device

Definition at line 225 of file sanboot.h.

225  {
226  ref_put ( &sandev->refcnt );
227 }
struct refcnt refcnt
Reference count.
Definition: sanboot.h:60
#define ref_put(refcnt)
Drop reference to object.
Definition: refcnt.h:106

References ref_put, and san_device::refcnt.

Referenced by dummy_san_hook(), dummy_san_unhook(), efi_block_hook(), efi_block_unhook(), int13_hook(), and int13_unhook().

◆ sandev_blksize()

static size_t sandev_blksize ( struct san_device sandev)
inlinestatic

Calculate SAN device block size.

Parameters
sandevSAN device
Return values
blksizeSector size

Definition at line 235 of file sanboot.h.

235  {
236  return ( sandev->capacity.blksize << sandev->blksize_shift );
237 }
unsigned int blksize_shift
Block size shift.
Definition: sanboot.h:84
struct block_device_capacity capacity
Raw block device capacity.
Definition: sanboot.h:77
size_t blksize
Block size.
Definition: blockdev.h:22

References block_device_capacity::blksize, san_device::blksize_shift, and san_device::capacity.

Referenced by int13_get_extended_parameters(), int13_get_parameters(), int13_hook(), and int13_rw_sectors().

◆ sandev_capacity()

static uint64_t sandev_capacity ( struct san_device sandev)
inlinestatic

Calculate SAN device capacity.

Parameters
sandevSAN device
Return values
blocksNumber of blocks

Definition at line 245 of file sanboot.h.

245  {
246  return ( sandev->capacity.blocks >> sandev->blksize_shift );
247 }
unsigned int blksize_shift
Block size shift.
Definition: sanboot.h:84
uint64_t blocks
Total number of blocks.
Definition: blockdev.h:20
struct block_device_capacity capacity
Raw block device capacity.
Definition: sanboot.h:77

References san_device::blksize_shift, block_device_capacity::blocks, and san_device::capacity.

Referenced by int13_capacity32(), int13_get_extended_parameters(), and int13_guess_geometry_fdd().

◆ sandev_needs_reopen()

static int sandev_needs_reopen ( struct san_device sandev)
inlinestatic

Check if SAN device needs to be reopened.

Parameters
sandevSAN device
Return values
needs_reopenSAN device needs to be reopened

Definition at line 255 of file sanboot.h.

255  {
256  return ( sandev->active == NULL );
257 }
struct san_path * active
Current active path.
Definition: sanboot.h:94
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321

References san_device::active, and NULL.

Referenced by int13_device_path_info(), and sandev_command().

◆ sandev_find()

struct san_device* sandev_find ( unsigned int  drive)

Find SAN device by drive number.

Parameters
driveDrive number
Return values
sandevSAN device, or NULL

Definition at line 90 of file sanboot.c.

90  {
91  struct san_device *sandev;
92 
93  list_for_each_entry ( sandev, &san_devices, list ) {
94  if ( sandev->drive == drive )
95  return sandev;
96  }
97  return NULL;
98 }
struct list_head san_devices
uint8_t drive
Drive number.
Definition: int13.h:16
#define list_for_each_entry(pos, head, member)
Iterate over entries in a list.
Definition: list.h:431
unsigned int drive
Drive number.
Definition: sanboot.h:65
struct list_head list
List of SAN devices.
Definition: sanboot.h:62
A SAN device.
Definition: sanboot.h:58
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321

References drive, san_device::drive, san_device::list, list_for_each_entry, NULL, and san_devices.

Referenced by dummy_san_unhook(), efi_block_unhook(), int13_unhook(), and register_sandev().

◆ sandev_next()

struct san_device* sandev_next ( unsigned int  drive)

Find next SAN device by drive number.

Parameters
driveMinimum drive number
Return values
sandevSAN device, or NULL

Definition at line 106 of file sanboot.c.

106  {
107  struct san_device *sandev;
108 
109  list_for_each_entry ( sandev, &san_devices, list ) {
110  if ( sandev->drive >= drive )
111  return sandev;
112  }
113  return NULL;
114 }
struct list_head san_devices
uint8_t drive
Drive number.
Definition: int13.h:16
#define list_for_each_entry(pos, head, member)
Iterate over entries in a list.
Definition: list.h:431
unsigned int drive
Drive number.
Definition: sanboot.h:65
struct list_head list
List of SAN devices.
Definition: sanboot.h:62
A SAN device.
Definition: sanboot.h:58
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321

References drive, san_device::drive, san_device::list, list_for_each_entry, NULL, and san_devices.

Referenced by efi_block_boot().

◆ sandev_reopen()

int sandev_reopen ( struct san_device sandev)

(Re)open SAN device

Parameters
sandevSAN device
Return values
rcReturn status code

This function will block until the device is available.

Definition at line 371 of file sanboot.c.

371  {
372  struct san_path *sanpath;
373  int rc;
374 
375  /* Unquiesce system */
376  unquiesce();
377 
378  /* Close any outstanding command and restart interfaces */
380  assert ( sandev->active == NULL );
381  assert ( list_empty ( &sandev->opened ) );
382 
383  /* Open all paths */
384  while ( ( sanpath = list_first_entry ( &sandev->closed,
385  struct san_path, list ) ) ) {
386  if ( ( rc = sanpath_open ( sanpath ) ) != 0 )
387  goto err_open;
388  }
389 
390  /* Wait for any device to become available, or for all devices
391  * to fail.
392  */
393  while ( sandev->active == NULL ) {
394  step();
395  if ( list_empty ( &sandev->opened ) ) {
396  /* Get status of the first device to be
397  * closed. Do this on the basis that earlier
398  * errors (e.g. "invalid IQN") are probably
399  * more interesting than later errors
400  * (e.g. "TCP timeout").
401  */
402  rc = -ENODEV;
403  list_for_each_entry ( sanpath, &sandev->closed, list ) {
404  rc = sanpath->path_rc;
405  break;
406  }
407  DBGC ( sandev->drive, "SAN %#02x never became "
408  "available: %s\n", sandev->drive,
409  strerror ( rc ) );
410  goto err_none;
411  }
412  }
413 
414  assert ( ! list_empty ( &sandev->opened ) );
415  return 0;
416 
417  err_none:
418  err_open:
419  sandev_restart ( sandev, rc );
420  return rc;
421 }
#define ECONNRESET
Connection reset.
Definition: errno.h:363
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
struct list_head list
List of open/closed paths.
Definition: sanboot.h:44
#define DBGC(...)
Definition: compiler.h:505
struct list_head opened
List of opened SAN paths.
Definition: sanboot.h:96
#define list_empty(list)
Test whether a list is empty.
Definition: list.h:136
#define list_first_entry(list, type, member)
Get the container of the first entry in a list.
Definition: list.h:333
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
A SAN path.
Definition: sanboot.h:36
#define list_for_each_entry(pos, head, member)
Iterate over entries in a list.
Definition: list.h:431
unsigned int drive
Drive number.
Definition: sanboot.h:65
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
struct list_head closed
List of closed SAN paths.
Definition: sanboot.h:98
int path_rc
Path status.
Definition: sanboot.h:51
#define ENODEV
No such device.
Definition: errno.h:509
void step(void)
Single-step a single process.
Definition: process.c:98
static void sandev_restart(struct san_device *sandev, int rc)
Restart SAN device interface.
Definition: sanboot.c:347
struct san_path * active
Current active path.
Definition: sanboot.h:94
static int sanpath_open(struct san_path *sanpath)
Open SAN path.
Definition: sanboot.c:197
void unquiesce(void)
Unquiesce system.
Definition: quiesce.c:46
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321
struct san_device * sandev
Containing SAN device.
Definition: sanboot.h:38

References san_device::active, assert(), san_device::closed, DBGC, san_device::drive, ECONNRESET, ENODEV, san_path::list, list_empty, list_first_entry, list_for_each_entry, NULL, san_device::opened, san_path::path_rc, rc, san_path::sandev, sandev_restart(), sanpath_open(), step(), strerror(), and unquiesce().

Referenced by int13_device_path_info(), register_sandev(), sandev_command(), and sandev_reset().

◆ sandev_reset()

int sandev_reset ( struct san_device sandev)

Reset SAN device.

Parameters
sandevSAN device
Return values
rcReturn status code

Definition at line 574 of file sanboot.c.

574  {
575  int rc;
576 
577  DBGC ( sandev->drive, "SAN %#02x reset\n", sandev->drive );
578 
579  /* Close and reopen underlying block device */
580  if ( ( rc = sandev_reopen ( sandev ) ) != 0 )
581  return rc;
582 
583  return 0;
584 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
#define DBGC(...)
Definition: compiler.h:505
unsigned int drive
Drive number.
Definition: sanboot.h:65
int sandev_reopen(struct san_device *sandev)
(Re)open SAN device
Definition: sanboot.c:371
struct san_device * sandev
Containing SAN device.
Definition: sanboot.h:38

References DBGC, san_device::drive, rc, san_path::sandev, and sandev_reopen().

Referenced by efi_block_io_reset(), and int13_reset().

◆ sandev_read()

int sandev_read ( struct san_device sandev,
uint64_t  lba,
unsigned int  count,
userptr_t  buffer 
)

Read from SAN device.

Parameters
sandevSAN device
lbaStarting logical block address
countNumber of logical blocks
bufferData buffer
Return values
rcReturn status code

Definition at line 645 of file sanboot.c.

646  {
647  int rc;
648 
649  /* Read from device */
650  if ( ( rc = sandev_rw ( sandev, lba, count, buffer, block_read ) ) != 0 )
651  return rc;
652 
653  return 0;
654 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
uint32_t lba
Start address.
Definition: scsi.h:23
static int sandev_rw(struct san_device *sandev, uint64_t lba, unsigned int count, userptr_t buffer, int(*block_rw)(struct interface *control, struct interface *data, uint64_t lba, unsigned int count, userptr_t buffer, size_t len))
Read from or write to SAN device.
Definition: sanboot.c:596
int block_read(struct interface *control, struct interface *data, uint64_t lba, unsigned int count, userptr_t buffer, size_t len)
Read from block device.
Definition: blockdev.c:47
uint32_t buffer
Buffer index (or NETVSC_RNDIS_NO_BUFFER)
Definition: netvsc.h:16
uint16_t count
Number of entries.
Definition: ena.h:22
struct san_device * sandev
Containing SAN device.
Definition: sanboot.h:38

References block_read(), buffer, count, lba, rc, and sandev_rw().

Referenced by efi_block_io_read(), int13_cdrom_read_boot_catalog(), int13_extended_read(), int13_guess_geometry_hdd(), int13_parse_eltorito(), int13_read_sectors(), and sandev_parse_iso9660().

◆ sandev_write()

int sandev_write ( struct san_device sandev,
uint64_t  lba,
unsigned int  count,
userptr_t  buffer 
)

Write to SAN device.

Parameters
sandevSAN device
lbaStarting logical block address
countNumber of logical blocks
bufferData buffer
Return values
rcReturn status code

Definition at line 665 of file sanboot.c.

666  {
667  int rc;
668 
669  /* Write to device */
670  if ( ( rc = sandev_rw ( sandev, lba, count, buffer, block_write ) ) != 0 )
671  return rc;
672 
673  /* Quiesce system. This is a heuristic designed to ensure
674  * that the system is quiesced before Windows starts up, since
675  * a Windows SAN boot will typically write a status flag to
676  * the disk as its last action before transferring control to
677  * the native drivers.
678  */
679  quiesce();
680 
681  return 0;
682 }
int block_write(struct interface *control, struct interface *data, uint64_t lba, unsigned int count, userptr_t buffer, size_t len)
Write to block device.
Definition: blockdev.c:78
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
uint32_t lba
Start address.
Definition: scsi.h:23
static int sandev_rw(struct san_device *sandev, uint64_t lba, unsigned int count, userptr_t buffer, int(*block_rw)(struct interface *control, struct interface *data, uint64_t lba, unsigned int count, userptr_t buffer, size_t len))
Read from or write to SAN device.
Definition: sanboot.c:596
uint32_t buffer
Buffer index (or NETVSC_RNDIS_NO_BUFFER)
Definition: netvsc.h:16
void quiesce(void)
Quiesce system.
Definition: quiesce.c:36
uint16_t count
Number of entries.
Definition: ena.h:22
struct san_device * sandev
Containing SAN device.
Definition: sanboot.h:38

References block_write(), buffer, count, lba, quiesce(), rc, and sandev_rw().

Referenced by efi_block_io_write(), int13_extended_write(), and int13_write_sectors().

◆ alloc_sandev()

struct san_device* alloc_sandev ( struct uri **  uris,
unsigned int  count,
size_t  priv_size 
)

Allocate SAN device.

Parameters
urisList of URIs
countNumber of URIs
priv_sizeSize of private data
Return values
sandevSAN device, or NULL

Definition at line 834 of file sanboot.c.

835  {
836  struct san_device *sandev;
837  struct san_path *sanpath;
838  size_t size;
839  unsigned int i;
840 
841  /* Allocate and initialise structure */
842  size = ( sizeof ( *sandev ) + ( count * sizeof ( sandev->path[0] ) ) );
843  sandev = zalloc ( size + priv_size );
844  if ( ! sandev )
845  return NULL;
848  timer_init ( &sandev->timer, sandev_command_expired, &sandev->refcnt );
849  sandev->priv = ( ( ( void * ) sandev ) + size );
850  sandev->paths = count;
853  for ( i = 0 ; i < count ; i++ ) {
854  sanpath = &sandev->path[i];
855  sanpath->sandev = sandev;
856  sanpath->index = i;
857  sanpath->uri = uri_get ( uris[i] );
858  list_add_tail ( &sanpath->list, &sandev->closed );
859  intf_init ( &sanpath->block, &sanpath_block_desc,
860  &sandev->refcnt );
861  process_init_stopped ( &sanpath->process, &sanpath_process_desc,
862  &sandev->refcnt );
863  sanpath->path_rc = -EINPROGRESS;
864  }
865 
866  return sandev;
867 }
static struct interface_descriptor sandev_command_desc
SAN device command interface descriptor.
Definition: sanboot.c:175
static struct uri * uri_get(struct uri *uri)
Increment URI reference count.
Definition: uri.h:194
struct san_path path[0]
SAN paths.
Definition: sanboot.h:100
static void sandev_free(struct refcnt *refcnt)
Free SAN device.
Definition: sanboot.c:121
#define ref_init(refcnt, free)
Initialise a reference counter.
Definition: refcnt.h:64
struct list_head opened
List of opened SAN paths.
Definition: sanboot.h:96
struct interface command
Command interface.
Definition: sanboot.h:70
A SAN path.
Definition: sanboot.h:36
#define list_add_tail(new, head)
Add a new entry to the tail of a list.
Definition: list.h:93
static struct interface_descriptor sanpath_block_desc
SAN path block interface descriptor.
Definition: sanboot.c:334
#define EINPROGRESS
Operation in progress.
Definition: errno.h:418
struct list_head closed
List of closed SAN paths.
Definition: sanboot.h:98
void * zalloc(size_t size)
Allocate cleared memory.
Definition: malloc.c:624
A SAN device.
Definition: sanboot.h:58
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
unsigned int paths
Number of paths.
Definition: sanboot.h:92
static void sandev_command_expired(struct retry_timer *timer, int over __unused)
Handle SAN device command timeout.
Definition: sanboot.c:183
#define INIT_LIST_HEAD(list)
Initialise a list head.
Definition: list.h:45
struct refcnt refcnt
Reference count.
Definition: sanboot.h:60
void * priv
Driver private data.
Definition: sanboot.h:89
static struct process_descriptor sanpath_process_desc
SAN path process descriptor.
Definition: sanboot.c:338
uint16_t count
Number of entries.
Definition: ena.h:22
uint8_t size
Entry size (in 32-bit words)
Definition: ena.h:16
struct retry_timer timer
Command timeout timer.
Definition: sanboot.h:72
static void intf_init(struct interface *intf, struct interface_descriptor *desc, struct refcnt *refcnt)
Initialise an object interface.
Definition: interface.h:203
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321
struct san_device * sandev
Containing SAN device.
Definition: sanboot.h:38

References san_path::block, san_device::closed, san_device::command, count, EINPROGRESS, san_path::index, INIT_LIST_HEAD, intf_init(), san_path::list, list_add_tail, NULL, san_device::opened, san_device::path, san_path::path_rc, san_device::paths, san_device::priv, san_path::process, process_init_stopped(), ref_init, san_device::refcnt, san_path::sandev, sandev_command_desc, sandev_command_expired(), sandev_free(), sanpath_block_desc, sanpath_process_desc, size, san_device::timer, san_path::uri, uri_get(), and zalloc().

Referenced by dummy_san_hook(), efi_block_hook(), and int13_hook().

◆ register_sandev()

int register_sandev ( struct san_device sandev,
unsigned int  drive,
unsigned int  flags 
)

Register SAN device.

Parameters
sandevSAN device
driveDrive number
flagsFlags
Return values
rcReturn status code

Definition at line 877 of file sanboot.c.

878  {
879  struct san_device *before;
880  int rc;
881 
882  /* Check that drive number is not in use */
883  if ( sandev_find ( drive ) != NULL ) {
884  DBGC ( sandev->drive, "SAN %#02x is already in use\n", drive );
885  rc = -EADDRINUSE;
886  goto err_in_use;
887  }
888 
889  /* Record drive number and flags */
890  sandev->drive = drive;
891  sandev->flags = flags;
892 
893  /* Check that device is capable of being opened (i.e. that all
894  * URIs are well-formed and that at least one path is
895  * working).
896  */
897  if ( ( rc = sandev_reopen ( sandev ) ) != 0 )
898  goto err_reopen;
899 
900  /* Describe device */
901  if ( ( rc = sandev_describe ( sandev ) ) != 0 )
902  goto err_describe;
903 
904  /* Read device capacity */
906  NULL ) ) != 0 )
907  goto err_capacity;
908 
909  /* Configure as a CD-ROM, if applicable */
910  if ( ( rc = sandev_parse_iso9660 ( sandev ) ) != 0 )
911  goto err_iso9660;
912 
913  /* Add to list of SAN devices, in drive order */
914  for_each_sandev ( before ) {
915  if ( before->drive > sandev->drive )
916  break;
917  }
918  list_add_tail ( &sandev->list, &before->list );
919  DBGC ( sandev->drive, "SAN %#02x registered\n", sandev->drive );
920 
921  return 0;
922 
923  list_del ( &sandev->list );
924  err_iso9660:
925  err_capacity:
926  err_describe:
927  err_reopen:
928  sandev_restart ( sandev, rc );
929  sandev_undescribe ( sandev );
930  err_in_use:
931  return rc;
932 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
static int sandev_command_read_capacity(struct san_device *sandev, const union san_command_params *params __unused)
Initiate SAN device read capacity command.
Definition: sanboot.c:480
#define EADDRINUSE
Address already in use.
Definition: errno.h:303
#define DBGC(...)
Definition: compiler.h:505
int32_t before
Initial microcode version.
Definition: ucode.h:16
uint8_t drive
Drive number.
Definition: int13.h:16
static void sandev_undescribe(struct san_device *sandev)
Remove SAN device descriptors.
Definition: sanboot.c:736
#define list_del(list)
Delete an entry from a list.
Definition: list.h:119
#define list_add_tail(new, head)
Add a new entry to the tail of a list.
Definition: list.h:93
unsigned int drive
Drive number.
Definition: sanboot.h:65
static int sandev_describe(struct san_device *sandev)
Describe SAN device.
Definition: sanboot.c:693
struct list_head list
List of SAN devices.
Definition: sanboot.h:62
A SAN device.
Definition: sanboot.h:58
#define for_each_sandev(sandev)
Iterate over all SAN devices.
Definition: sanboot.h:196
static int sandev_parse_iso9660(struct san_device *sandev)
Configure SAN device as a CD-ROM, if applicable.
Definition: sanboot.c:764
static int sandev_command(struct san_device *sandev, int(*command)(struct san_device *sandev, const union san_command_params *params), const union san_command_params *params)
Execute a single SAN device command and wait for completion.
Definition: sanboot.c:509
struct san_device * sandev_find(unsigned int drive)
Find SAN device by drive number.
Definition: sanboot.c:90
static void sandev_restart(struct san_device *sandev, int rc)
Restart SAN device interface.
Definition: sanboot.c:347
unsigned int flags
Flags.
Definition: sanboot.h:67
int sandev_reopen(struct san_device *sandev)
(Re)open SAN device
Definition: sanboot.c:371
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321
uint8_t flags
Flags.
Definition: ena.h:18

References before, DBGC, drive, san_device::drive, EADDRINUSE, flags, san_device::flags, for_each_sandev, san_device::list, list_add_tail, list_del, NULL, rc, sandev_command(), sandev_command_read_capacity(), sandev_describe(), sandev_find(), sandev_parse_iso9660(), sandev_reopen(), sandev_restart(), and sandev_undescribe().

Referenced by dummy_san_hook(), efi_block_hook(), and int13_hook().

◆ unregister_sandev()

void unregister_sandev ( struct san_device sandev)

Unregister SAN device.

Parameters
sandevSAN device

Definition at line 939 of file sanboot.c.

939  {
940 
941  /* Sanity check */
942  assert ( ! timer_running ( &sandev->timer ) );
943 
944  /* Remove from list of SAN devices */
945  list_del ( &sandev->list );
946 
947  /* Shut down interfaces */
948  sandev_restart ( sandev, 0 );
949 
950  /* Remove ACPI descriptors */
951  sandev_undescribe ( sandev );
952 
953  DBGC ( sandev->drive, "SAN %#02x unregistered\n", sandev->drive );
954 }
#define DBGC(...)
Definition: compiler.h:505
static void sandev_undescribe(struct san_device *sandev)
Remove SAN device descriptors.
Definition: sanboot.c:736
#define list_del(list)
Delete an entry from a list.
Definition: list.h:119
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
unsigned int drive
Drive number.
Definition: sanboot.h:65
struct list_head list
List of SAN devices.
Definition: sanboot.h:62
static void sandev_restart(struct san_device *sandev, int rc)
Restart SAN device interface.
Definition: sanboot.c:347
struct retry_timer timer
Command timeout timer.
Definition: sanboot.h:72

References assert(), DBGC, san_device::drive, san_device::list, list_del, sandev_restart(), sandev_undescribe(), and san_device::timer.

Referenced by dummy_san_hook(), dummy_san_unhook(), efi_block_hook(), efi_block_unhook(), int13_hook(), and int13_unhook().

◆ san_default_drive()

unsigned int san_default_drive ( void  )

Get default SAN drive number.

Return values
driveDefault drive number

Definition at line 970 of file sanboot.c.

970  {
971  unsigned long drive;
972 
973  /* Use "san-drive" setting, if specified */
974  if ( fetch_uint_setting ( NULL, &san_drive_setting, &drive ) >= 0 )
975  return drive;
976 
977  /* Otherwise, default to booting from first hard disk */
978  return SAN_DEFAULT_DRIVE;
979 }
uint8_t drive
Drive number.
Definition: int13.h:16
int fetch_uint_setting(struct settings *settings, const struct setting *setting, unsigned long *value)
Fetch value of unsigned integer setting.
Definition: settings.c:1039
#define SAN_DEFAULT_DRIVE
Default SAN drive number.
Definition: sanboot.h:33
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321

References drive, fetch_uint_setting(), NULL, and SAN_DEFAULT_DRIVE.

Referenced by netboot(), and sanboot_core_exec().

Variable Documentation

◆ san_devices

struct list_head san_devices