iPXE
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.
#define SANBOOT_INLINE(_subsys, _api_func)
 Calculate static inline sanboot API function name.
#define PROVIDE_SANBOOT(_subsys, _api_func, _func)
 Provide a sanboot API implementation.
#define PROVIDE_SANBOOT_INLINE(_subsys, _api_func)
 Provide a static inline sanboot API implementation.
#define for_each_sandev(sandev)
 Iterate over all SAN devices.

Enumerations

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

Functions

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

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

Referenced by efi_block_boot(), and san_default_drive().

◆ SANBOOT_INLINE

#define SANBOOT_INLINE ( _subsys,
_api_func )
Value:
SINGLE_API_INLINE ( SANBOOT_PREFIX_ ## _subsys, _api_func )
#define SINGLE_API_INLINE(_prefix, _api_func)
Calculate static inline function name.
Definition api.h:45

Calculate static inline sanboot API function name.

Parameters
_prefixSubsystem prefix
_api_funcAPI function
Return values
_subsys_funcSubsystem API function

Definition at line 129 of file sanboot.h.

129#define SANBOOT_INLINE( _subsys, _api_func ) \
130 SINGLE_API_INLINE ( SANBOOT_PREFIX_ ## _subsys, _api_func )

◆ PROVIDE_SANBOOT

#define PROVIDE_SANBOOT ( _subsys,
_api_func,
_func )
Value:
PROVIDE_SINGLE_API ( SANBOOT_PREFIX_ ## _subsys, _api_func, _func )
#define PROVIDE_SINGLE_API(_prefix, _api_func, _func)
Provide an API implementation.
Definition api.h:55

Provide a sanboot API implementation.

Parameters
_prefixSubsystem prefix
_api_funcAPI function
_funcImplementing function

Definition at line 139 of file sanboot.h.

139#define PROVIDE_SANBOOT( _subsys, _api_func, _func ) \
140 PROVIDE_SINGLE_API ( SANBOOT_PREFIX_ ## _subsys, _api_func, _func )

◆ PROVIDE_SANBOOT_INLINE

#define PROVIDE_SANBOOT_INLINE ( _subsys,
_api_func )
Value:
PROVIDE_SINGLE_API_INLINE ( SANBOOT_PREFIX_ ## _subsys, _api_func )
#define PROVIDE_SINGLE_API_INLINE(_prefix, _api_func)
Provide a static inline API implementation.
Definition api.h:74

Provide a static inline sanboot API implementation.

Parameters
_prefixSubsystem prefix
_api_funcAPI function

Definition at line 148 of file sanboot.h.

148#define PROVIDE_SANBOOT_INLINE( _subsys, _api_func ) \
149 PROVIDE_SINGLE_API_INLINE ( SANBOOT_PREFIX_ ## _subsys, _api_func )

◆ for_each_sandev

#define for_each_sandev ( sandev)
Value:
list_for_each_entry ( (sandev), &san_devices, list )
struct list_head san_devices
#define list_for_each_entry(pos, head, member)
Iterate over entries in a list.
Definition list.h:432

Iterate over all SAN devices.

Definition at line 197 of file sanboot.h.

197#define for_each_sandev( sandev ) \
198 list_for_each_entry ( (sandev), &san_devices, list )

Referenced by efi_block_local(), int13(), int13_sync_num_drives(), and register_sandev().

Enumeration Type Documentation

◆ san_device_flags

SAN device flags.

Enumerator
SAN_NO_DESCRIBE 

Device should not be included in description tables.

Definition at line 105 of file sanboot.h.

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

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )

◆ FILE_SECBOOT()

FILE_SECBOOT ( PERMITTED )

◆ 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

References count, drive, and flags.

Referenced by PROVIDE_SANBOOT(), PROVIDE_SANBOOT(), PROVIDE_SANBOOT(), PROVIDE_SANBOOT(), and uriboot().

◆ san_unhook()

void san_unhook ( unsigned int drive)

Unhook SAN device.

Parameters
driveDrive number

References drive.

Referenced by PROVIDE_SANBOOT(), PROVIDE_SANBOOT(), PROVIDE_SANBOOT(), PROVIDE_SANBOOT(), and 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

References drive.

Referenced by PROVIDE_SANBOOT(), PROVIDE_SANBOOT(), PROVIDE_SANBOOT(), PROVIDE_SANBOOT(), and uriboot().

◆ san_describe()

int san_describe ( void )

Describe SAN devices for SAN-booted operating system.

Return values
rcReturn status code

References san_devices.

Referenced by PROVIDE_SANBOOT(), PROVIDE_SANBOOT(), PROVIDE_SANBOOT(), PROVIDE_SANBOOT(), and uriboot().

◆ have_sandevs()

int have_sandevs ( void )
inlinestatic

There exist some SAN devices.

Return values
existenceExistence of SAN devices

Definition at line 204 of file sanboot.h.

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

References list_empty, and san_devices.

Referenced by int13_hook(), and int13_unhook().

◆ sandev_get()

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

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

References ref_get, and san_device::refcnt.

◆ sandev_put()

void sandev_put ( struct san_device * sandev)
inlinestatic

Drop reference to SAN device.

Parameters
sandevSAN device

Definition at line 226 of file sanboot.h.

226 {
227 ref_put ( &sandev->refcnt );
228}
#define ref_put(refcnt)
Drop reference to object.
Definition refcnt.h:107

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

size_t sandev_blksize ( struct san_device * sandev)
inlinestatic

Calculate SAN device block size.

Parameters
sandevSAN device
Return values
blksizeSector size

Definition at line 236 of file sanboot.h.

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

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

uint64_t sandev_capacity ( struct san_device * sandev)
inlinestatic

Calculate SAN device capacity.

Parameters
sandevSAN device
Return values
blocksNumber of blocks

Definition at line 246 of file sanboot.h.

246 {
247 return ( sandev->capacity.blocks >> sandev->blksize_shift );
248}
uint64_t blocks
Total number of blocks.
Definition blockdev.h:20

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

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

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

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

Find SAN device by drive number.

Parameters
driveDrive number
Return values
sandevSAN device, or NULL

Definition at line 92 of file sanboot.c.

92 {
93 struct san_device *sandev;
94
96 if ( sandev->drive == drive )
97 return sandev;
98 }
99 return NULL;
100}
uint8_t drive
Drive number.
Definition int13.h:5
A SAN device.
Definition sanboot.h:59
unsigned int drive
Drive number.
Definition sanboot.h:66
struct list_head list
List of SAN devices.
Definition sanboot.h:63

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

Find next SAN device by drive number.

Parameters
driveMinimum drive number
Return values
sandevSAN device, or NULL

Definition at line 108 of file sanboot.c.

108 {
109 struct san_device *sandev;
110
111 list_for_each_entry ( sandev, &san_devices, list ) {
112 if ( sandev->drive >= drive )
113 return sandev;
114 }
115 return NULL;
116}

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

(Re)open SAN device

Parameters
sandevSAN device
Return values
rcReturn status code

This function will block until the device is available.

Definition at line 373 of file sanboot.c.

373 {
374 struct san_path *sanpath;
375 int rc;
376
377 /* Unquiesce system */
378 unquiesce();
379
380 /* Close any outstanding command and restart interfaces */
382 assert ( sandev->active == NULL );
383 assert ( list_empty ( &sandev->opened ) );
384
385 /* Open all paths */
386 while ( ( sanpath = list_first_entry ( &sandev->closed,
387 struct san_path, list ) ) ) {
388 if ( ( rc = sanpath_open ( sanpath ) ) != 0 )
389 goto err_open;
390 }
391
392 /* Wait for any device to become available, or for all devices
393 * to fail.
394 */
395 while ( sandev->active == NULL ) {
396 step();
397 if ( list_empty ( &sandev->opened ) ) {
398 /* Get status of the first device to be
399 * closed. Do this on the basis that earlier
400 * errors (e.g. "invalid IQN") are probably
401 * more interesting than later errors
402 * (e.g. "TCP timeout").
403 */
404 rc = -ENODEV;
405 list_for_each_entry ( sanpath, &sandev->closed, list ) {
406 rc = sanpath->path_rc;
407 break;
408 }
409 DBGC ( sandev->drive, "SAN %#02x never became "
410 "available: %s\n", sandev->drive,
411 strerror ( rc ) );
412 goto err_none;
413 }
414 }
415
416 assert ( ! list_empty ( &sandev->opened ) );
417 return 0;
418
419 err_none:
420 err_open:
422 return rc;
423}
struct arbelprm_rc_send_wqe rc
Definition arbel.h:3
#define assert(condition)
Assert a condition at run-time.
Definition assert.h:50
#define DBGC(...)
Definition compiler.h:505
#define ENODEV
No such device.
Definition errno.h:510
#define ECONNRESET
Connection reset.
Definition errno.h:364
#define list_first_entry(list, type, member)
Get the container of the first entry in a list.
Definition list.h:334
void step(void)
Single-step a single process.
Definition process.c:99
void unquiesce(void)
Unquiesce system.
Definition quiesce.c:47
static void sandev_restart(struct san_device *sandev, int rc)
Restart SAN device interface.
Definition sanboot.c:349
static int sanpath_open(struct san_path *sanpath)
Open SAN path.
Definition sanboot.c:199
char * strerror(int errno)
Retrieve string representation of error number.
Definition strerror.c:79
struct list_head opened
List of opened SAN paths.
Definition sanboot.h:97
struct list_head closed
List of closed SAN paths.
Definition sanboot.h:99
A SAN path.
Definition sanboot.h:37
struct list_head list
List of open/closed paths.
Definition sanboot.h:45
int path_rc
Path status.
Definition sanboot.h:52
struct san_device * sandev
Containing SAN device.
Definition sanboot.h:39

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

Reset SAN device.

Parameters
sandevSAN device
Return values
rcReturn status code

Definition at line 576 of file sanboot.c.

576 {
577 int rc;
578
579 DBGC ( sandev->drive, "SAN %#02x reset\n", sandev->drive );
580
581 /* Close and reopen underlying block device */
582 if ( ( rc = sandev_reopen ( sandev ) ) != 0 )
583 return rc;
584
585 return 0;
586}
int sandev_reopen(struct san_device *sandev)
(Re)open SAN device
Definition sanboot.c:373

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,
void * buffer )
extern

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

648 {
649 int rc;
650
651 /* Read from device */
652 if ( ( rc = sandev_rw ( sandev, lba, count, buffer,
653 block_read ) ) != 0 )
654 return rc;
655
656 return 0;
657}
int block_read(struct interface *control, struct interface *data, uint64_t lba, unsigned int count, void *buffer, size_t len)
Read from block device.
Definition blockdev.c:48
static unsigned int count
Number of entries.
Definition dwmac.h:220
uint32_t buffer
Buffer index (or NETVSC_RNDIS_NO_BUFFER)
Definition netvsc.h:5
uint64_t lba
Starting block number.
Definition int13.h:11
static int sandev_rw(struct san_device *sandev, uint64_t lba, unsigned int count, void *buffer, int(*block_rw)(struct interface *control, struct interface *data, uint64_t lba, unsigned int count, void *buffer, size_t len))
Read from or write to SAN device.
Definition sanboot.c:598

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,
void * buffer )
extern

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

669 {
670 int rc;
671
672 /* Write to device */
673 if ( ( rc = sandev_rw ( sandev, lba, count, buffer,
674 block_write ) ) != 0 )
675 return rc;
676
677 /* Quiesce system. This is a heuristic designed to ensure
678 * that the system is quiesced before Windows starts up, since
679 * a Windows SAN boot will typically write a status flag to
680 * the disk as its last action before transferring control to
681 * the native drivers.
682 */
683 quiesce();
684
685 return 0;
686}
int block_write(struct interface *control, struct interface *data, uint64_t lba, unsigned int count, void *buffer, size_t len)
Write to block device.
Definition blockdev.c:79
void quiesce(void)
Quiesce system.
Definition quiesce.c:37

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

Allocate SAN device.

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

Definition at line 837 of file sanboot.c.

838 {
839 struct san_device *sandev;
840 struct san_path *sanpath;
841 size_t size;
842 unsigned int i;
843
844 /* Allocate and initialise structure */
845 size = ( sizeof ( *sandev ) + ( count * sizeof ( sandev->path[0] ) ) );
846 sandev = zalloc ( size + priv_size );
847 if ( ! sandev )
848 return NULL;
851 timer_init ( &sandev->timer, sandev_command_expired, &sandev->refcnt );
852 sandev->priv = ( ( ( void * ) sandev ) + size );
853 sandev->paths = count;
856 for ( i = 0 ; i < count ; i++ ) {
857 sanpath = &sandev->path[i];
858 sanpath->sandev = sandev;
859 sanpath->index = i;
860 sanpath->uri = uri_get ( uris[i] );
861 list_add_tail ( &sanpath->list, &sandev->closed );
862 intf_init ( &sanpath->block, &sanpath_block_desc,
863 &sandev->refcnt );
865 &sandev->refcnt );
866 sanpath->path_rc = -EINPROGRESS;
867 }
868
869 return sandev;
870}
uint16_t size
Buffer size.
Definition dwmac.h:3
#define EINPROGRESS
Operation in progress.
Definition errno.h:419
static void intf_init(struct interface *intf, struct interface_descriptor *desc, struct refcnt *refcnt)
Initialise an object interface.
Definition interface.h:204
#define list_add_tail(new, head)
Add a new entry to the tail of a list.
Definition list.h:94
#define INIT_LIST_HEAD(list)
Initialise a list head.
Definition list.h:46
void * zalloc(size_t size)
Allocate cleared memory.
Definition malloc.c:662
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:146
#define ref_init(refcnt, free)
Initialise a reference counter.
Definition refcnt.h:65
static struct process_descriptor sanpath_process_desc
SAN path process descriptor.
Definition sanboot.c:340
static void sandev_command_expired(struct retry_timer *timer, int over __unused)
Handle SAN device command timeout.
Definition sanboot.c:185
static struct interface_descriptor sanpath_block_desc
SAN path block interface descriptor.
Definition sanboot.c:336
static void sandev_free(struct refcnt *refcnt)
Free SAN device.
Definition sanboot.c:123
static struct interface_descriptor sandev_command_desc
SAN device command interface descriptor.
Definition sanboot.c:177
void * priv
Driver private data.
Definition sanboot.h:90
struct retry_timer timer
Command timeout timer.
Definition sanboot.h:73
struct interface command
Command interface.
Definition sanboot.h:71
unsigned int paths
Number of paths.
Definition sanboot.h:93
struct san_path path[0]
SAN paths.
Definition sanboot.h:101
struct process process
Process.
Definition sanboot.h:50
unsigned int index
Path index.
Definition sanboot.h:41
struct interface block
Underlying block device interface.
Definition sanboot.h:48
struct uri * uri
SAN device URI.
Definition sanboot.h:43
static struct uri * uri_get(struct uri *uri)
Increment URI reference count.
Definition uri.h:195

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

Register SAN device.

Parameters
sandevSAN device
driveDrive number
flagsFlags
Return values
rcReturn status code

Definition at line 880 of file sanboot.c.

881 {
882 struct san_device *before;
883 int rc;
884
885 /* Check that drive number is not in use */
886 if ( sandev_find ( drive ) != NULL ) {
887 DBGC ( sandev->drive, "SAN %#02x is already in use\n", drive );
888 rc = -EADDRINUSE;
889 goto err_in_use;
890 }
891
892 /* Record drive number and flags */
893 sandev->drive = drive;
894 sandev->flags = flags;
895
896 /* Check that device is capable of being opened (i.e. that all
897 * URIs are well-formed and that at least one path is
898 * working).
899 */
900 if ( ( rc = sandev_reopen ( sandev ) ) != 0 )
901 goto err_reopen;
902
903 /* Describe device */
904 if ( ( rc = sandev_describe ( sandev ) ) != 0 )
905 goto err_describe;
906
907 /* Read device capacity */
909 NULL ) ) != 0 )
910 goto err_capacity;
911
912 /* Configure as a CD-ROM, if applicable */
913 if ( ( rc = sandev_parse_iso9660 ( sandev ) ) != 0 )
914 goto err_iso9660;
915
916 /* Add to list of SAN devices, in drive order */
918 if ( before->drive > sandev->drive )
919 break;
920 }
921 list_add_tail ( &sandev->list, &before->list );
922 DBGC ( sandev->drive, "SAN %#02x registered\n", sandev->drive );
923
924 return 0;
925
926 list_del ( &sandev->list );
927 err_iso9660:
928 err_capacity:
929 err_describe:
930 err_reopen:
931 sandev_restart ( sandev, rc );
932 sandev_undescribe ( sandev );
933 err_in_use:
934 return rc;
935}
uint8_t flags
Flags.
Definition ena.h:7
#define EADDRINUSE
Address already in use.
Definition errno.h:304
#define for_each_sandev(sandev)
Iterate over all SAN devices.
Definition sanboot.h:197
#define list_del(list)
Delete an entry from a list.
Definition list.h:120
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:511
static void sandev_undescribe(struct san_device *sandev)
Remove SAN device descriptors.
Definition sanboot.c:740
static int sandev_parse_iso9660(struct san_device *sandev)
Configure SAN device as a CD-ROM, if applicable.
Definition sanboot.c:768
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:482
struct san_device * sandev_find(unsigned int drive)
Find SAN device by drive number.
Definition sanboot.c:92
static int sandev_describe(struct san_device *sandev)
Describe SAN device.
Definition sanboot.c:697
unsigned int flags
Flags.
Definition sanboot.h:68
int32_t before
Initial microcode version.
Definition ucode.h:5

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

Unregister SAN device.

Parameters
sandevSAN device

Definition at line 942 of file sanboot.c.

942 {
943
944 /* Sanity check */
945 assert ( ! timer_running ( &sandev->timer ) );
946
947 /* Remove from list of SAN devices */
948 list_del ( &sandev->list );
949
950 /* Shut down interfaces */
951 sandev_restart ( sandev, 0 );
952
953 /* Remove ACPI descriptors */
954 sandev_undescribe ( sandev );
955
956 DBGC ( sandev->drive, "SAN %#02x unregistered\n", sandev->drive );
957}

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

Get default SAN drive number.

Return values
driveDefault drive number

Definition at line 973 of file sanboot.c.

973 {
974 unsigned long drive;
975
976 /* Use "san-drive" setting, if specified */
977 if ( fetch_uint_setting ( NULL, &san_drive_setting, &drive ) >= 0 )
978 return drive;
979
980 /* Otherwise, default to booting from first hard disk */
981 return SAN_DEFAULT_DRIVE;
982}
#define SAN_DEFAULT_DRIVE
Default SAN drive number.
Definition sanboot.h:34
int fetch_uint_setting(struct settings *settings, const struct setting *setting, unsigned long *value)
Fetch value of unsigned integer setting.
Definition settings.c:1040

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
extern