[block] Replace gPXE block-device API with an iPXE asynchronous interface

The block device interface used in gPXE predates the invention of even
the old gPXE data-transfer interface, let alone the current iPXE
generic asynchronous interface mechanism.  Bring this old code up to
date, with the following benefits:

 o  Block device commands can be cancelled by the requestor.  The INT 13
    layer uses this to provide a global timeout on all INT 13 calls,
    with the result that an unexpected passive failure mode (such as
    an iSCSI target ACKing the request but never sending a response)
    will lead to a timeout that gets reported back to the INT 13 user,
    rather than simply freezing the system.

 o  INT 13,00 (reset drive) is now able to reset the underlying block
    device.  INT 13 users, such as DOS, that use INT 13,00 as a method
    for error recovery now have a chance of recovering.

 o  All block device commands are tagged, with a numerical tag that
    will show up in debugging output and in packet captures; this will
    allow easier interpretation of bug reports that include both
    sources of information.

 o  The extremely ugly hacks used to generate the boot firmware tables
    have been eradicated and replaced with a generic acpi_describe()
    method (exploiting the ability of iPXE interfaces to pass through
    methods to an underlying interface).  The ACPI tables are now
    built in a shared data block within .bss16, rather than each
    requiring dedicated space in .data16.

 o  The architecture-independent concept of a SAN device has been
    exposed to the iPXE core through the sanboot API, which provides
    calls to hook, unhook, boot, and describe SAN devices.  This
    allows for much more flexible usage patterns (such as hooking an
    empty SAN device and then running an OS installer via TFTP).

Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
Michael Brown
2010-09-03 16:11:51 +01:00
parent 46c7f99c66
commit 220495f8bf
47 changed files with 4904 additions and 3127 deletions

View File

@@ -1,62 +0,0 @@
/*
* Copyright (C) 2007 Michael Brown <mbrown@fensystems.co.uk>.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
FILE_LICENCE ( GPL2_OR_LATER );
#include <realmode.h>
#include <ipxe/aoe.h>
#include <ipxe/netdevice.h>
#include <ipxe/abft.h>
/** @file
*
* AoE Boot Firmware Table
*
*/
#define abftab __use_data16 ( abftab )
/** The aBFT used by iPXE */
struct abft_table __data16 ( abftab ) __attribute__ (( aligned ( 16 ) )) = {
/* ACPI header */
.acpi = {
.signature = ABFT_SIG,
.length = sizeof ( abftab ),
.revision = 1,
.oem_id = "FENSYS",
.oem_table_id = "iPXE",
},
};
/**
* Fill in all variable portions of aBFT
*
* @v aoe AoE session
*/
void abft_fill_data ( struct aoe_session *aoe ) {
/* Fill in boot parameters */
abftab.shelf = aoe->major;
abftab.slot = aoe->minor;
memcpy ( abftab.mac, aoe->netdev->ll_addr, sizeof ( abftab.mac ) );
/* Update checksum */
acpi_fix_checksum ( &abftab.acpi );
DBG ( "AoE boot firmware table:\n" );
DBG_HD ( &abftab, sizeof ( abftab ) );
}

View File

@@ -1,78 +0,0 @@
#include <stdint.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <errno.h>
#include <ipxe/aoe.h>
#include <ipxe/ata.h>
#include <ipxe/netdevice.h>
#include <ipxe/sanboot.h>
#include <ipxe/abft.h>
#include <int13.h>
FILE_LICENCE ( GPL2_OR_LATER );
static int aoeboot ( const char *root_path ) {
struct ata_device *ata;
struct int13_drive *drive;
int rc;
ata = zalloc ( sizeof ( *ata ) );
if ( ! ata ) {
rc = -ENOMEM;
goto err_alloc_ata;
}
drive = zalloc ( sizeof ( *drive ) );
if ( ! drive ) {
rc = -ENOMEM;
goto err_alloc_drive;
}
/* FIXME: ugly, ugly hack */
struct net_device *netdev = last_opened_netdev();
if ( ( rc = aoe_attach ( ata, netdev, root_path ) ) != 0 ) {
printf ( "Could not attach AoE device: %s\n",
strerror ( rc ) );
goto err_attach;
}
if ( ( rc = init_atadev ( ata ) ) != 0 ) {
printf ( "Could not initialise AoE device: %s\n",
strerror ( rc ) );
goto err_init;
}
/* FIXME: ugly, ugly hack */
struct aoe_session *aoe =
container_of ( ata->backend, struct aoe_session, refcnt );
abft_fill_data ( aoe );
drive->blockdev = &ata->blockdev;
register_int13_drive ( drive );
printf ( "Registered as BIOS drive %#02x\n", drive->drive );
printf ( "Booting from BIOS drive %#02x\n", drive->drive );
rc = int13_boot ( drive->drive );
printf ( "Boot failed\n" );
/* Leave drive registered, if instructed to do so */
if ( keep_san() )
return rc;
printf ( "Unregistering BIOS drive %#02x\n", drive->drive );
unregister_int13_drive ( drive );
err_init:
aoe_detach ( ata );
err_attach:
free ( drive );
err_alloc_drive:
free ( ata );
err_alloc_ata:
return rc;
}
struct sanboot_protocol aoe_sanboot_protocol __sanboot_protocol = {
.prefix = "aoe:",
.boot = aoeboot,
};

View File

@@ -1,73 +0,0 @@
#include <stdint.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <errno.h>
#include <ipxe/sanboot.h>
#include <int13.h>
#include <ipxe/srp.h>
#include <ipxe/sbft.h>
FILE_LICENCE ( GPL2_OR_LATER );
static int ib_srpboot ( const char *root_path ) {
struct scsi_device *scsi;
struct int13_drive *drive;
int rc;
scsi = zalloc ( sizeof ( *scsi ) );
if ( ! scsi ) {
rc = -ENOMEM;
goto err_alloc_scsi;
}
drive = zalloc ( sizeof ( *drive ) );
if ( ! drive ) {
rc = -ENOMEM;
goto err_alloc_drive;
}
if ( ( rc = srp_attach ( scsi, root_path ) ) != 0 ) {
printf ( "Could not attach IB_SRP device: %s\n",
strerror ( rc ) );
goto err_attach;
}
if ( ( rc = init_scsidev ( scsi ) ) != 0 ) {
printf ( "Could not initialise IB_SRP device: %s\n",
strerror ( rc ) );
goto err_init;
}
drive->blockdev = &scsi->blockdev;
/* FIXME: ugly, ugly hack */
struct srp_device *srp =
container_of ( scsi->backend, struct srp_device, refcnt );
sbft_fill_data ( srp );
register_int13_drive ( drive );
printf ( "Registered as BIOS drive %#02x\n", drive->drive );
printf ( "Booting from BIOS drive %#02x\n", drive->drive );
rc = int13_boot ( drive->drive );
printf ( "Boot failed\n" );
/* Leave drive registered, if instructed to do so */
if ( keep_san() )
return rc;
printf ( "Unregistering BIOS drive %#02x\n", drive->drive );
unregister_int13_drive ( drive );
err_init:
srp_detach ( scsi );
err_attach:
free ( drive );
err_alloc_drive:
free ( scsi );
err_alloc_scsi:
return rc;
}
struct sanboot_protocol ib_srp_sanboot_protocol __sanboot_protocol = {
.prefix = "ib_srp:",
.boot = ib_srpboot,
};

View File

@@ -1,451 +0,0 @@
/*
* Copyright Fen Systems Ltd. 2007. Portions of this code are derived
* from IBM Corporation Sample Programs. Copyright IBM Corporation
* 2004, 2007. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use, copy,
* modify, merge, publish, distribute, sublicense, and/or sell copies
* of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
FILE_LICENCE ( BSD2 );
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <byteswap.h>
#include <realmode.h>
#include <ipxe/pci.h>
#include <ipxe/acpi.h>
#include <ipxe/in.h>
#include <ipxe/netdevice.h>
#include <ipxe/ethernet.h>
#include <ipxe/dhcp.h>
#include <ipxe/iscsi.h>
#include <ipxe/ibft.h>
/** @file
*
* iSCSI boot firmware table
*
* The information in this file is derived from the document "iSCSI
* Boot Firmware Table (iBFT)" as published by IBM at
*
* ftp://ftp.software.ibm.com/systems/support/system_x_pdf/ibm_iscsi_boot_firmware_table_v1.02.pdf
*
*/
#define ibftab __use_data16 ( ibftab )
/** The iBFT used by iPXE */
struct ipxe_ibft __data16 ( ibftab ) = {
/* Table header */
.table = {
/* ACPI header */
.acpi = {
.signature = IBFT_SIG,
.length = sizeof ( ibftab ),
.revision = 1,
.oem_id = "FENSYS",
.oem_table_id = "iPXE",
},
/* Control block */
.control = {
.header = {
.structure_id = IBFT_STRUCTURE_ID_CONTROL,
.version = 1,
.length = sizeof ( ibftab.table.control ),
.flags = 0,
},
.initiator = offsetof ( typeof ( ibftab ), initiator ),
.nic_0 = offsetof ( typeof ( ibftab ), nic ),
.target_0 = offsetof ( typeof ( ibftab ), target ),
},
},
/* iSCSI initiator information */
.initiator = {
.header = {
.structure_id = IBFT_STRUCTURE_ID_INITIATOR,
.version = 1,
.length = sizeof ( ibftab.initiator ),
.flags = ( IBFT_FL_INITIATOR_BLOCK_VALID |
IBFT_FL_INITIATOR_FIRMWARE_BOOT_SELECTED ),
},
},
/* NIC information */
.nic = {
.header = {
.structure_id = IBFT_STRUCTURE_ID_NIC,
.version = 1,
.length = sizeof ( ibftab.nic ),
.flags = ( IBFT_FL_NIC_BLOCK_VALID |
IBFT_FL_NIC_FIRMWARE_BOOT_SELECTED ),
},
},
/* iSCSI target information */
.target = {
.header = {
.structure_id = IBFT_STRUCTURE_ID_TARGET,
.version = 1,
.length = sizeof ( ibftab.target ),
.flags = ( IBFT_FL_TARGET_BLOCK_VALID |
IBFT_FL_TARGET_FIRMWARE_BOOT_SELECTED ),
},
},
};
/**
* Fill in an IP address field within iBFT
*
* @v ipaddr IP address field
* @v in IPv4 address
*/
static void ibft_set_ipaddr ( struct ibft_ipaddr *ipaddr, struct in_addr in ) {
memset ( ipaddr, 0, sizeof ( ipaddr ) );
if ( in.s_addr ) {
ipaddr->in = in;
ipaddr->ones = 0xffff;
}
}
/**
* Fill in an IP address within iBFT from configuration setting
*
* @v ipaddr IP address field
* @v setting Configuration setting
* @v tag DHCP option tag
*/
static void ibft_set_ipaddr_option ( struct ibft_ipaddr *ipaddr,
struct setting *setting ) {
struct in_addr in = { 0 };
fetch_ipv4_setting ( NULL, setting, &in );
ibft_set_ipaddr ( ipaddr, in );
}
/**
* Read IP address from iBFT (for debugging)
*
* @v strings iBFT string block descriptor
* @v string String field
* @ret ipaddr IP address string
*/
static const char * ibft_ipaddr ( struct ibft_ipaddr *ipaddr ) {
return inet_ntoa ( ipaddr->in );
}
/**
* Allocate a string within iBFT
*
* @v strings iBFT string block descriptor
* @v string String field to fill in
* @v len Length of string to allocate (excluding NUL)
* @ret rc Return status code
*/
static int ibft_alloc_string ( struct ibft_string_block *strings,
struct ibft_string *string, size_t len ) {
char *dest;
unsigned int remaining;
dest = ( ( ( char * ) strings->table ) + strings->offset );
remaining = ( strings->table->acpi.length - strings->offset );
if ( len >= remaining )
return -ENOMEM;
string->offset = strings->offset;
string->length = len;
strings->offset += ( len + 1 );
return 0;
}
/**
* Fill in a string field within iBFT
*
* @v strings iBFT string block descriptor
* @v string String field
* @v data String to fill in, or NULL
* @ret rc Return status code
*/
static int ibft_set_string ( struct ibft_string_block *strings,
struct ibft_string *string, const char *data ) {
char *dest;
int rc;
if ( ! data )
return 0;
if ( ( rc = ibft_alloc_string ( strings, string,
strlen ( data ) ) ) != 0 )
return rc;
dest = ( ( ( char * ) strings->table ) + string->offset );
strcpy ( dest, data );
return 0;
}
/**
* Fill in a string field within iBFT from configuration setting
*
* @v strings iBFT string block descriptor
* @v string String field
* @v setting Configuration setting
* @ret rc Return status code
*/
static int ibft_set_string_option ( struct ibft_string_block *strings,
struct ibft_string *string,
struct setting *setting ) {
int len;
char *dest;
int rc;
len = fetch_setting_len ( NULL, setting );
if ( len < 0 ) {
string->offset = 0;
string->length = 0;
return 0;
}
if ( ( rc = ibft_alloc_string ( strings, string, len ) ) != 0 )
return rc;
dest = ( ( ( char * ) strings->table ) + string->offset );
fetch_string_setting ( NULL, setting, dest, ( len + 1 ) );
return 0;
}
/**
* Read string from iBFT (for debugging)
*
* @v strings iBFT string block descriptor
* @v string String field
* @ret data String content (or "<empty>")
*/
static const char * ibft_string ( struct ibft_string_block *strings,
struct ibft_string *string ) {
return ( string->offset ?
( ( ( char * ) strings->table ) + string->offset ) : NULL );
}
/**
* Fill in NIC portion of iBFT
*
* @v nic NIC portion of iBFT
* @v strings iBFT string block descriptor
* @v netdev Network device
* @ret rc Return status code
*/
static int ibft_fill_nic ( struct ibft_nic *nic,
struct ibft_string_block *strings,
struct net_device *netdev ) {
struct ll_protocol *ll_protocol = netdev->ll_protocol;
struct in_addr netmask_addr = { 0 };
unsigned int netmask_count = 0;
int rc;
/* Extract values from DHCP configuration */
ibft_set_ipaddr_option ( &nic->ip_address, &ip_setting );
DBG ( "iBFT NIC IP = %s\n", ibft_ipaddr ( &nic->ip_address ) );
ibft_set_ipaddr_option ( &nic->gateway, &gateway_setting );
DBG ( "iBFT NIC gateway = %s\n", ibft_ipaddr ( &nic->gateway ) );
ibft_set_ipaddr_option ( &nic->dns[0], &dns_setting );
DBG ( "iBFT NIC DNS = %s\n", ibft_ipaddr ( &nic->dns[0] ) );
if ( ( rc = ibft_set_string_option ( strings, &nic->hostname,
&hostname_setting ) ) != 0 )
return rc;
DBG ( "iBFT NIC hostname = %s\n",
ibft_string ( strings, &nic->hostname ) );
/* Derive subnet mask prefix from subnet mask */
fetch_ipv4_setting ( NULL, &netmask_setting, &netmask_addr );
while ( netmask_addr.s_addr ) {
if ( netmask_addr.s_addr & 0x1 )
netmask_count++;
netmask_addr.s_addr >>= 1;
}
nic->subnet_mask_prefix = netmask_count;
DBG ( "iBFT NIC subnet = /%d\n", nic->subnet_mask_prefix );
/* Extract values from net-device configuration */
if ( ( rc = ll_protocol->eth_addr ( netdev->ll_addr,
nic->mac_address ) ) != 0 ) {
DBG ( "Could not determine iBFT MAC: %s\n", strerror ( rc ) );
return rc;
}
DBG ( "iBFT NIC MAC = %s\n", eth_ntoa ( nic->mac_address ) );
nic->pci_bus_dev_func = netdev->dev->desc.location;
DBG ( "iBFT NIC PCI = %04x\n", nic->pci_bus_dev_func );
return 0;
}
/**
* Fill in Initiator portion of iBFT
*
* @v initiator Initiator portion of iBFT
* @v strings iBFT string block descriptor
* @ret rc Return status code
*/
static int ibft_fill_initiator ( struct ibft_initiator *initiator,
struct ibft_string_block *strings ) {
const char *initiator_iqn = iscsi_initiator_iqn();
int rc;
if ( ( rc = ibft_set_string ( strings, &initiator->initiator_name,
initiator_iqn ) ) != 0 )
return rc;
DBG ( "iBFT initiator hostname = %s\n",
ibft_string ( strings, &initiator->initiator_name ) );
return 0;
}
/**
* Fill in Target CHAP portion of iBFT
*
* @v target Target portion of iBFT
* @v strings iBFT string block descriptor
* @v iscsi iSCSI session
* @ret rc Return status code
*/
static int ibft_fill_target_chap ( struct ibft_target *target,
struct ibft_string_block *strings,
struct iscsi_session *iscsi ) {
int rc;
if ( ! ( iscsi->status & ISCSI_STATUS_AUTH_FORWARD_REQUIRED ) )
return 0;
assert ( iscsi->initiator_username );
assert ( iscsi->initiator_password );
target->chap_type = IBFT_CHAP_ONE_WAY;
if ( ( rc = ibft_set_string ( strings, &target->chap_name,
iscsi->initiator_username ) ) != 0 )
return rc;
DBG ( "iBFT target username = %s\n",
ibft_string ( strings, &target->chap_name ) );
if ( ( rc = ibft_set_string ( strings, &target->chap_secret,
iscsi->initiator_password ) ) != 0 )
return rc;
DBG ( "iBFT target password = <redacted>\n" );
return 0;
}
/**
* Fill in Target Reverse CHAP portion of iBFT
*
* @v target Target portion of iBFT
* @v strings iBFT string block descriptor
* @v iscsi iSCSI session
* @ret rc Return status code
*/
static int ibft_fill_target_reverse_chap ( struct ibft_target *target,
struct ibft_string_block *strings,
struct iscsi_session *iscsi ) {
int rc;
if ( ! ( iscsi->status & ISCSI_STATUS_AUTH_REVERSE_REQUIRED ) )
return 0;
assert ( iscsi->initiator_username );
assert ( iscsi->initiator_password );
assert ( iscsi->target_username );
assert ( iscsi->target_password );
target->chap_type = IBFT_CHAP_MUTUAL;
if ( ( rc = ibft_set_string ( strings, &target->reverse_chap_name,
iscsi->target_username ) ) != 0 )
return rc;
DBG ( "iBFT target reverse username = %s\n",
ibft_string ( strings, &target->chap_name ) );
if ( ( rc = ibft_set_string ( strings, &target->reverse_chap_secret,
iscsi->target_password ) ) != 0 )
return rc;
DBG ( "iBFT target reverse password = <redacted>\n" );
return 0;
}
/**
* Fill in Target portion of iBFT
*
* @v target Target portion of iBFT
* @v strings iBFT string block descriptor
* @v iscsi iSCSI session
* @ret rc Return status code
*/
static int ibft_fill_target ( struct ibft_target *target,
struct ibft_string_block *strings,
struct iscsi_session *iscsi ) {
struct sockaddr_in *sin_target =
( struct sockaddr_in * ) &iscsi->target_sockaddr;
int rc;
/* Fill in Target values */
ibft_set_ipaddr ( &target->ip_address, sin_target->sin_addr );
DBG ( "iBFT target IP = %s\n", ibft_ipaddr ( &target->ip_address ) );
target->socket = ntohs ( sin_target->sin_port );
DBG ( "iBFT target port = %d\n", target->socket );
if ( ( rc = ibft_set_string ( strings, &target->target_name,
iscsi->target_iqn ) ) != 0 )
return rc;
DBG ( "iBFT target name = %s\n",
ibft_string ( strings, &target->target_name ) );
if ( ( rc = ibft_fill_target_chap ( target, strings, iscsi ) ) != 0 )
return rc;
if ( ( rc = ibft_fill_target_reverse_chap ( target, strings,
iscsi ) ) != 0 )
return rc;
return 0;
}
/**
* Fill in all variable portions of iBFT
*
* @v netdev Network device
* @v initiator_iqn Initiator IQN
* @v st_target Target socket address
* @v target_iqn Target IQN
* @ret rc Return status code
*
*/
int ibft_fill_data ( struct net_device *netdev,
struct iscsi_session *iscsi ) {
struct ibft_string_block strings = {
.table = &ibftab.table,
.offset = offsetof ( typeof ( ibftab ), strings ),
};
int rc;
/* Fill in NIC, Initiator and Target portions */
if ( ( rc = ibft_fill_nic ( &ibftab.nic, &strings, netdev ) ) != 0 )
return rc;
if ( ( rc = ibft_fill_initiator ( &ibftab.initiator,
&strings ) ) != 0 )
return rc;
if ( ( rc = ibft_fill_target ( &ibftab.target, &strings,
iscsi ) ) != 0 )
return rc;
/* Update checksum */
acpi_fix_checksum ( &ibftab.table.acpi );
return 0;
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,75 +0,0 @@
#include <stdint.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <errno.h>
#include <ipxe/iscsi.h>
#include <ipxe/netdevice.h>
#include <ipxe/ibft.h>
#include <ipxe/sanboot.h>
#include <int13.h>
FILE_LICENCE ( GPL2_OR_LATER );
static int iscsiboot ( const char *root_path ) {
struct scsi_device *scsi;
struct int13_drive *drive;
int rc;
scsi = zalloc ( sizeof ( *scsi ) );
if ( ! scsi ) {
rc = -ENOMEM;
goto err_alloc_scsi;
}
drive = zalloc ( sizeof ( *drive ) );
if ( ! drive ) {
rc = -ENOMEM;
goto err_alloc_drive;
}
if ( ( rc = iscsi_attach ( scsi, root_path ) ) != 0 ) {
printf ( "Could not attach iSCSI device: %s\n",
strerror ( rc ) );
goto err_attach;
}
if ( ( rc = init_scsidev ( scsi ) ) != 0 ) {
printf ( "Could not initialise iSCSI device: %s\n",
strerror ( rc ) );
goto err_init;
}
drive->blockdev = &scsi->blockdev;
/* FIXME: ugly, ugly hack */
struct net_device *netdev = last_opened_netdev();
struct iscsi_session *iscsi =
container_of ( scsi->backend, struct iscsi_session, refcnt );
ibft_fill_data ( netdev, iscsi );
register_int13_drive ( drive );
printf ( "Registered as BIOS drive %#02x\n", drive->drive );
printf ( "Booting from BIOS drive %#02x\n", drive->drive );
rc = int13_boot ( drive->drive );
printf ( "Boot failed\n" );
/* Leave drive registered, if instructed to do so */
if ( keep_san() )
return rc;
printf ( "Unregistering BIOS drive %#02x\n", drive->drive );
unregister_int13_drive ( drive );
err_init:
iscsi_detach ( scsi );
err_attach:
free ( drive );
err_alloc_drive:
free ( scsi );
err_alloc_scsi:
return rc;
}
struct sanboot_protocol iscsi_sanboot_protocol __sanboot_protocol = {
.prefix = "iscsi:",
.boot = iscsiboot,
};

View File

@@ -1,26 +0,0 @@
#include <stdint.h>
#include <stdio.h>
#include <ipxe/settings.h>
#include <ipxe/dhcp.h>
#include <ipxe/init.h>
#include <ipxe/sanboot.h>
#include <usr/autoboot.h>
struct setting keep_san_setting __setting = {
.name = "keep-san",
.description = "Preserve SAN connection",
.tag = DHCP_EB_KEEP_SAN,
.type = &setting_type_int8,
};
int keep_san ( void ) {
int keep_san;
keep_san = fetch_intz_setting ( NULL, &keep_san_setting );
if ( ! keep_san )
return 0;
printf ( "Preserving connection to SAN disk\n" );
shutdown_exit_flags |= SHUTDOWN_KEEP_DEVICES;
return 1;
}

View File

@@ -1,105 +0,0 @@
/*
* Copyright (C) 2009 Fen Systems Ltd <mbrown@fensystems.co.uk>.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
*/
FILE_LICENCE ( BSD2 );
/** @file
*
* SRP boot firmware table
*
*/
#include <assert.h>
#include <realmode.h>
#include <ipxe/srp.h>
#include <ipxe/ib_srp.h>
#include <ipxe/acpi.h>
#include <ipxe/sbft.h>
#define sbftab __use_data16 ( sbftab )
/** The sBFT used by iPXE */
struct ipxe_sbft __data16 ( sbftab ) = {
/* Table header */
.table = {
/* ACPI header */
.acpi = {
.signature = SBFT_SIG,
.length = sizeof ( sbftab ),
.revision = 1,
.oem_id = "FENSYS",
.oem_table_id = "iPXE",
},
.scsi_offset = offsetof ( typeof ( sbftab ), scsi ),
.srp_offset = offsetof ( typeof ( sbftab ), srp ),
.ib_offset = offsetof ( typeof ( sbftab ), ib ),
},
};
/**
* Fill in all variable portions of sBFT
*
* @v srp SRP device
* @ret rc Return status code
*/
int sbft_fill_data ( struct srp_device *srp ) {
struct sbft_scsi_subtable *sbft_scsi = &sbftab.scsi;
struct sbft_srp_subtable *sbft_srp = &sbftab.srp;
struct sbft_ib_subtable *sbft_ib = &sbftab.ib;
struct ib_srp_parameters *ib_params;
struct segoff rm_sbftab = {
.segment = rm_ds,
.offset = __from_data16 ( &sbftab ),
};
/* Fill in the SCSI subtable */
memcpy ( &sbft_scsi->lun, &srp->lun, sizeof ( sbft_scsi->lun ) );
/* Fill in the SRP subtable */
memcpy ( &sbft_srp->port_ids, &srp->port_ids,
sizeof ( sbft_srp->port_ids ) );
/* Fill in the IB subtable */
assert ( srp->transport == &ib_srp_transport );
ib_params = ib_srp_params ( srp );
memcpy ( &sbft_ib->sgid, &ib_params->sgid, sizeof ( sbft_ib->sgid ) );
memcpy ( &sbft_ib->dgid, &ib_params->dgid, sizeof ( sbft_ib->dgid ) );
memcpy ( &sbft_ib->service_id, &ib_params->service_id,
sizeof ( sbft_ib->service_id ) );
sbft_ib->pkey = ib_params->pkey;
/* Update checksum */
acpi_fix_checksum ( &sbftab.table.acpi );
DBGC ( &sbftab, "SRP Boot Firmware Table at %04x:%04x:\n",
rm_sbftab.segment, rm_sbftab.offset );
DBGC_HDA ( &sbftab, rm_sbftab, &sbftab, sizeof ( sbftab ) );
return 0;
}