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 <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...
 

Macros

#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, const char *filename)
 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...
 
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

◆ 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 105 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 115 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 124 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 173 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 93 of file sanboot.h.

93  {
94  /** Device should not be included in description tables */
95  SAN_NO_DESCRIBE = 0x0001,
96 };
Device should not be included in description tables.
Definition: sanboot.h:95

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,
const char *  filename 
)

Attempt to boot from a SAN device.

Parameters
driveDrive number
filenameFilename (or NULL to use default)
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 180 of file sanboot.h.

180  {
181  return ( ! list_empty ( &san_devices ) );
182 }
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 191 of file sanboot.h.

191  {
192  ref_get ( &sandev->refcnt );
193  return sandev;
194 }
#define ref_get(refcnt)
Get additional reference to object.
Definition: refcnt.h:92
struct refcnt refcnt
Reference count.
Definition: sanboot.h:49

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 202 of file sanboot.h.

202  {
203  ref_put ( &sandev->refcnt );
204 }
struct refcnt refcnt
Reference count.
Definition: sanboot.h:49
#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 212 of file sanboot.h.

212  {
213  return ( sandev->capacity.blksize << sandev->blksize_shift );
214 }
unsigned int blksize_shift
Block size shift.
Definition: sanboot.h:73
struct block_device_capacity capacity
Raw block device capacity.
Definition: sanboot.h:66
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 222 of file sanboot.h.

222  {
223  return ( sandev->capacity.blocks >> sandev->blksize_shift );
224 }
unsigned int blksize_shift
Block size shift.
Definition: sanboot.h:73
uint64_t blocks
Total number of blocks.
Definition: blockdev.h:20
struct block_device_capacity capacity
Raw block device capacity.
Definition: sanboot.h:66

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 232 of file sanboot.h.

232  {
233  return ( sandev->active == NULL );
234 }
struct san_path * active
Current active path.
Definition: sanboot.h:83
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362

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 100 of file sanboot.c.

100  {
101  struct san_device *sandev;
102 
103  list_for_each_entry ( sandev, &san_devices, list ) {
104  if ( sandev->drive == drive )
105  return sandev;
106  }
107  return NULL;
108 }
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:420
unsigned int drive
Drive number.
Definition: sanboot.h:54
struct list_head list
List of SAN devices.
Definition: sanboot.h:51
A SAN device.
Definition: sanboot.h:47
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362

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

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

◆ 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 365 of file sanboot.c.

365  {
366  struct san_path *sanpath;
367  int rc;
368 
369  /* Unquiesce system */
370  unquiesce();
371 
372  /* Close any outstanding command and restart interfaces */
374  assert ( sandev->active == NULL );
375  assert ( list_empty ( &sandev->opened ) );
376 
377  /* Open all paths */
378  while ( ( sanpath = list_first_entry ( &sandev->closed,
379  struct san_path, list ) ) ) {
380  if ( ( rc = sanpath_open ( sanpath ) ) != 0 )
381  goto err_open;
382  }
383 
384  /* Wait for any device to become available, or for all devices
385  * to fail.
386  */
387  while ( sandev->active == NULL ) {
388  step();
389  if ( list_empty ( &sandev->opened ) ) {
390  /* Get status of the first device to be
391  * closed. Do this on the basis that earlier
392  * errors (e.g. "invalid IQN") are probably
393  * more interesting than later errors
394  * (e.g. "TCP timeout").
395  */
396  rc = -ENODEV;
397  list_for_each_entry ( sanpath, &sandev->closed, list ) {
398  rc = sanpath->path_rc;
399  break;
400  }
401  DBGC ( sandev, "SAN %#02x never became available: %s\n",
402  sandev->drive, strerror ( rc ) );
403  goto err_none;
404  }
405  }
406 
407  assert ( ! list_empty ( &sandev->opened ) );
408  return 0;
409 
410  err_none:
411  err_open:
412  sandev_restart ( sandev, rc );
413  return rc;
414 }
#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:33
#define DBGC(...)
Definition: compiler.h:505
struct list_head opened
List of opened SAN paths.
Definition: sanboot.h:85
#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:25
#define list_for_each_entry(pos, head, member)
Iterate over entries in a list.
Definition: list.h:420
unsigned int drive
Drive number.
Definition: sanboot.h:54
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:87
int path_rc
Path status.
Definition: sanboot.h:40
#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:341
struct san_path * active
Current active path.
Definition: sanboot.h:83
static int sanpath_open(struct san_path *sanpath)
Open SAN path.
Definition: sanboot.c:191
void unquiesce(void)
Unquiesce system.
Definition: quiesce.c:46
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362
struct san_device * sandev
Containing SAN device.
Definition: sanboot.h:27

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 565 of file sanboot.c.

565  {
566  int rc;
567 
568  DBGC ( sandev, "SAN %#02x reset\n", sandev->drive );
569 
570  /* Close and reopen underlying block device */
571  if ( ( rc = sandev_reopen ( sandev ) ) != 0 )
572  return rc;
573 
574  return 0;
575 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
#define DBGC(...)
Definition: compiler.h:505
unsigned int drive
Drive number.
Definition: sanboot.h:54
int sandev_reopen(struct san_device *sandev)
(Re)open SAN device
Definition: sanboot.c:365
struct san_device * sandev
Containing SAN device.
Definition: sanboot.h:27

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 636 of file sanboot.c.

637  {
638  int rc;
639 
640  /* Read from device */
641  if ( ( rc = sandev_rw ( sandev, lba, count, buffer, block_read ) ) != 0 )
642  return rc;
643 
644  return 0;
645 }
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:587
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:27

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 656 of file sanboot.c.

657  {
658  int rc;
659 
660  /* Write to device */
661  if ( ( rc = sandev_rw ( sandev, lba, count, buffer, block_write ) ) != 0 )
662  return rc;
663 
664  /* Quiesce system. This is a heuristic designed to ensure
665  * that the system is quiesced before Windows starts up, since
666  * a Windows SAN boot will typically write a status flag to
667  * the disk as its last action before transferring control to
668  * the native drivers.
669  */
670  quiesce();
671 
672  return 0;
673 }
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:587
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:27

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 825 of file sanboot.c.

826  {
827  struct san_device *sandev;
828  struct san_path *sanpath;
829  size_t size;
830  unsigned int i;
831 
832  /* Allocate and initialise structure */
833  size = ( sizeof ( *sandev ) + ( count * sizeof ( sandev->path[0] ) ) );
834  sandev = zalloc ( size + priv_size );
835  if ( ! sandev )
836  return NULL;
839  timer_init ( &sandev->timer, sandev_command_expired, &sandev->refcnt );
840  sandev->priv = ( ( ( void * ) sandev ) + size );
841  sandev->paths = count;
844  for ( i = 0 ; i < count ; i++ ) {
845  sanpath = &sandev->path[i];
846  sanpath->sandev = sandev;
847  sanpath->index = i;
848  sanpath->uri = uri_get ( uris[i] );
849  list_add_tail ( &sanpath->list, &sandev->closed );
850  intf_init ( &sanpath->block, &sanpath_block_desc,
851  &sandev->refcnt );
852  process_init_stopped ( &sanpath->process, &sanpath_process_desc,
853  &sandev->refcnt );
854  sanpath->path_rc = -EINPROGRESS;
855  }
856 
857  return sandev;
858 }
static struct interface_descriptor sandev_command_desc
SAN device command interface descriptor.
Definition: sanboot.c:169
static struct uri * uri_get(struct uri *uri)
Increment URI reference count.
Definition: uri.h:177
struct san_path path[0]
SAN paths.
Definition: sanboot.h:89
static void sandev_free(struct refcnt *refcnt)
Free SAN device.
Definition: sanboot.c:115
#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:85
struct interface command
Command interface.
Definition: sanboot.h:59
A SAN path.
Definition: sanboot.h:25
#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:328
#define EINPROGRESS
Operation in progress.
Definition: errno.h:418
struct list_head closed
List of closed SAN paths.
Definition: sanboot.h:87
void * zalloc(size_t size)
Allocate cleared memory.
Definition: malloc.c:624
A SAN device.
Definition: sanboot.h:47
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:81
static void sandev_command_expired(struct retry_timer *timer, int over __unused)
Handle SAN device command timeout.
Definition: sanboot.c:177
#define INIT_LIST_HEAD(list)
Initialise a list head.
Definition: list.h:45
struct refcnt refcnt
Reference count.
Definition: sanboot.h:49
void * priv
Driver private data.
Definition: sanboot.h:78
static struct process_descriptor sanpath_process_desc
SAN path process descriptor.
Definition: sanboot.c:332
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:61
static void intf_init(struct interface *intf, struct interface_descriptor *desc, struct refcnt *refcnt)
Initialise an object interface.
Definition: interface.h:173
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362
struct san_device * sandev
Containing SAN device.
Definition: sanboot.h:27

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 868 of file sanboot.c.

869  {
870  int rc;
871 
872  /* Check that drive number is not in use */
873  if ( sandev_find ( drive ) != NULL ) {
874  DBGC ( sandev, "SAN %#02x is already in use\n", drive );
875  rc = -EADDRINUSE;
876  goto err_in_use;
877  }
878 
879  /* Record drive number and flags */
880  sandev->drive = drive;
881  sandev->flags = flags;
882 
883  /* Check that device is capable of being opened (i.e. that all
884  * URIs are well-formed and that at least one path is
885  * working).
886  */
887  if ( ( rc = sandev_reopen ( sandev ) ) != 0 )
888  goto err_reopen;
889 
890  /* Describe device */
891  if ( ( rc = sandev_describe ( sandev ) ) != 0 )
892  goto err_describe;
893 
894  /* Read device capacity */
896  NULL ) ) != 0 )
897  goto err_capacity;
898 
899  /* Configure as a CD-ROM, if applicable */
900  if ( ( rc = sandev_parse_iso9660 ( sandev ) ) != 0 )
901  goto err_iso9660;
902 
903  /* Add to list of SAN devices */
905  DBGC ( sandev, "SAN %#02x registered\n", sandev->drive );
906 
907  return 0;
908 
909  list_del ( &sandev->list );
910  err_iso9660:
911  err_capacity:
912  err_describe:
913  err_reopen:
914  sandev_restart ( sandev, rc );
916  err_in_use:
917  return rc;
918 }
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:472
#define EADDRINUSE
Address already in use.
Definition: errno.h:303
#define DBGC(...)
Definition: compiler.h:505
struct list_head san_devices
uint8_t drive
Drive number.
Definition: int13.h:16
static void sandev_undescribe(struct san_device *sandev)
Remove SAN device descriptors.
Definition: sanboot.c:727
#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:54
static int sandev_describe(struct san_device *sandev)
Describe SAN device.
Definition: sanboot.c:684
struct list_head list
List of SAN devices.
Definition: sanboot.h:51
static int sandev_parse_iso9660(struct san_device *sandev)
Configure SAN device as a CD-ROM, if applicable.
Definition: sanboot.c:755
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:500
struct san_device * sandev_find(unsigned int drive)
Find SAN device by drive number.
Definition: sanboot.c:100
static void sandev_restart(struct san_device *sandev, int rc)
Restart SAN device interface.
Definition: sanboot.c:341
unsigned int flags
Flags.
Definition: sanboot.h:56
int sandev_reopen(struct san_device *sandev)
(Re)open SAN device
Definition: sanboot.c:365
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362
struct san_device * sandev
Containing SAN device.
Definition: sanboot.h:27
uint8_t flags
Flags.
Definition: ena.h:18

References DBGC, drive, san_device::drive, EADDRINUSE, flags, san_device::flags, san_device::list, list_add_tail, list_del, NULL, rc, san_devices, san_path::sandev, 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 925 of file sanboot.c.

925  {
926 
927  /* Sanity check */
928  assert ( ! timer_running ( &sandev->timer ) );
929 
930  /* Remove from list of SAN devices */
931  list_del ( &sandev->list );
932 
933  /* Shut down interfaces */
934  sandev_restart ( sandev, 0 );
935 
936  /* Remove ACPI descriptors */
938 
939  DBGC ( sandev, "SAN %#02x unregistered\n", sandev->drive );
940 }
#define DBGC(...)
Definition: compiler.h:505
static void sandev_undescribe(struct san_device *sandev)
Remove SAN device descriptors.
Definition: sanboot.c:727
#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:54
struct list_head list
List of SAN devices.
Definition: sanboot.h:51
static void sandev_restart(struct san_device *sandev, int rc)
Restart SAN device interface.
Definition: sanboot.c:341
struct retry_timer timer
Command timeout timer.
Definition: sanboot.h:61
struct san_device * sandev
Containing SAN device.
Definition: sanboot.h:27

References assert(), DBGC, san_device::drive, san_device::list, list_del, san_path::sandev, 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 956 of file sanboot.c.

956  {
957  unsigned long drive;
958 
959  /* Use "san-drive" setting, if specified */
960  if ( fetch_uint_setting ( NULL, &san_drive_setting, &drive ) >= 0 )
961  return drive;
962 
963  /* Otherwise, default to booting from first hard disk */
964  return SAN_DEFAULT_DRIVE;
965 }
uint8_t drive
Drive number.
Definition: int13.h:16
#define SAN_DEFAULT_DRIVE
Default SAN drive number.
Definition: sanboot.c:55
int fetch_uint_setting(struct settings *settings, const struct setting *setting, unsigned long *value)
Fetch value of unsigned integer setting.
Definition: settings.c:1043
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362

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