iPXE
|
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_device * | sandev_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_device * | sandev_find (unsigned int drive) |
Find SAN device by drive number. More... | |
struct san_device * | sandev_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_device * | alloc_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 |
iPXE sanboot API
The sanboot API provides methods for hooking, unhooking, describing, and booting from SAN devices.
Definition in file sanboot.h.
#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.
#define SANBOOT_INLINE | ( | _subsys, | |
_api_func | |||
) | SINGLE_API_INLINE ( SANBOOT_PREFIX_ ## _subsys, _api_func ) |
#define PROVIDE_SANBOOT | ( | _subsys, | |
_api_func, | |||
_func | |||
) | PROVIDE_SINGLE_API ( SANBOOT_PREFIX_ ## _subsys, _api_func, _func ) |
#define PROVIDE_SANBOOT_INLINE | ( | _subsys, | |
_api_func | |||
) | PROVIDE_SINGLE_API_INLINE ( SANBOOT_PREFIX_ ## _subsys, _api_func ) |
#define for_each_sandev | ( | sandev | ) | list_for_each_entry ( (sandev), &san_devices, list ) |
enum san_device_flags |
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.
drive | Drive number |
uris | List of URIs |
count | Number of URIs |
flags | Flags |
drive | Drive number, or negative error |
Referenced by uriboot().
void san_unhook | ( | unsigned int | drive | ) |
int san_boot | ( | unsigned int | drive, |
struct san_boot_config * | config | ||
) |
Attempt to boot from a SAN device.
drive | Drive number |
config | Boot configuration parameters |
rc | Return status code |
Referenced by uriboot().
int san_describe | ( | void | ) |
Describe SAN devices for SAN-booted operating system.
rc | Return status code |
Referenced by uriboot().
|
inlinestatic |
There exist some SAN devices.
existence | Existence of SAN devices |
Definition at line 203 of file sanboot.h.
References list_empty, and san_devices.
Referenced by int13_hook(), and int13_unhook().
|
inlinestatic |
Get reference to SAN device.
sandev | SAN device |
sandev | SAN device |
Definition at line 214 of file sanboot.h.
References ref_get, and san_device::refcnt.
|
inlinestatic |
Drop reference to SAN device.
sandev | SAN device |
Definition at line 225 of file sanboot.h.
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().
|
inlinestatic |
Calculate SAN device block size.
sandev | SAN device |
blksize | Sector size |
Definition at line 235 of file sanboot.h.
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().
|
inlinestatic |
Calculate SAN device capacity.
sandev | SAN device |
blocks | Number of blocks |
Definition at line 245 of file sanboot.h.
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().
|
inlinestatic |
Check if SAN device needs to be reopened.
sandev | SAN device |
needs_reopen | SAN device needs to be reopened |
Definition at line 255 of file sanboot.h.
References san_device::active, and NULL.
Referenced by int13_device_path_info(), and sandev_command().
struct san_device* sandev_find | ( | unsigned int | drive | ) |
Find SAN device by drive number.
drive | Drive number |
sandev | SAN device, or NULL |
Definition at line 90 of file sanboot.c.
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().
struct san_device* sandev_next | ( | unsigned int | drive | ) |
Find next SAN device by drive number.
drive | Minimum drive number |
sandev | SAN device, or NULL |
Definition at line 106 of file sanboot.c.
References drive, san_device::drive, san_device::list, list_for_each_entry, NULL, and san_devices.
Referenced by efi_block_boot().
int sandev_reopen | ( | struct san_device * | sandev | ) |
(Re)open SAN device
sandev | SAN device |
rc | Return status code |
This function will block until the device is available.
Definition at line 371 of file sanboot.c.
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().
int sandev_reset | ( | struct san_device * | sandev | ) |
Reset SAN device.
sandev | SAN device |
rc | Return status code |
Definition at line 574 of file sanboot.c.
References DBGC, san_device::drive, rc, san_path::sandev, and sandev_reopen().
Referenced by efi_block_io_reset(), and int13_reset().
int sandev_read | ( | struct san_device * | sandev, |
uint64_t | lba, | ||
unsigned int | count, | ||
userptr_t | buffer | ||
) |
Read from SAN device.
sandev | SAN device |
lba | Starting logical block address |
count | Number of logical blocks |
buffer | Data buffer |
rc | Return status code |
Definition at line 645 of file sanboot.c.
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().
int sandev_write | ( | struct san_device * | sandev, |
uint64_t | lba, | ||
unsigned int | count, | ||
userptr_t | buffer | ||
) |
Write to SAN device.
sandev | SAN device |
lba | Starting logical block address |
count | Number of logical blocks |
buffer | Data buffer |
rc | Return status code |
Definition at line 665 of file sanboot.c.
References block_write(), buffer, count, lba, quiesce(), rc, and sandev_rw().
Referenced by efi_block_io_write(), int13_extended_write(), and int13_write_sectors().
struct san_device* alloc_sandev | ( | struct uri ** | uris, |
unsigned int | count, | ||
size_t | priv_size | ||
) |
Allocate SAN device.
uris | List of URIs |
count | Number of URIs |
priv_size | Size of private data |
sandev | SAN device, or NULL |
Definition at line 834 of file sanboot.c.
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().
int register_sandev | ( | struct san_device * | sandev, |
unsigned int | drive, | ||
unsigned int | flags | ||
) |
Register SAN device.
sandev | SAN device |
drive | Drive number |
flags | Flags |
rc | Return status code |
Definition at line 877 of file sanboot.c.
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().
void unregister_sandev | ( | struct san_device * | sandev | ) |
Unregister SAN device.
sandev | SAN device |
Definition at line 939 of file sanboot.c.
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().
unsigned int san_default_drive | ( | void | ) |
Get default SAN drive number.
drive | Default drive number |
Definition at line 970 of file sanboot.c.
References drive, fetch_uint_setting(), NULL, and SAN_DEFAULT_DRIVE.
Referenced by netboot(), and sanboot_core_exec().
struct list_head san_devices |
Referenced by have_sandevs(), sandev_find(), and sandev_next().