aboutsummaryrefslogtreecommitdiffstats
path: root/gpxe/src/arch/i386/interface/pcbios
diff options
context:
space:
mode:
Diffstat (limited to 'gpxe/src/arch/i386/interface/pcbios')
-rw-r--r--gpxe/src/arch/i386/interface/pcbios/abft.c2
-rw-r--r--gpxe/src/arch/i386/interface/pcbios/aoeboot.c62
-rw-r--r--gpxe/src/arch/i386/interface/pcbios/bios_nap.c2
-rw-r--r--gpxe/src/arch/i386/interface/pcbios/bios_smbios.c2
-rw-r--r--gpxe/src/arch/i386/interface/pcbios/bios_timer.c2
-rw-r--r--gpxe/src/arch/i386/interface/pcbios/biosint.c2
-rw-r--r--gpxe/src/arch/i386/interface/pcbios/ib_srpboot.c73
-rw-r--r--gpxe/src/arch/i386/interface/pcbios/ibft.c17
-rw-r--r--gpxe/src/arch/i386/interface/pcbios/int13.c79
-rw-r--r--gpxe/src/arch/i386/interface/pcbios/iscsiboot.c20
-rw-r--r--gpxe/src/arch/i386/interface/pcbios/keepsan.c26
-rw-r--r--gpxe/src/arch/i386/interface/pcbios/memtop_umalloc.c2
-rw-r--r--gpxe/src/arch/i386/interface/pcbios/pcibios.c2
-rw-r--r--gpxe/src/arch/i386/interface/pcbios/sbft.c105
14 files changed, 338 insertions, 58 deletions
diff --git a/gpxe/src/arch/i386/interface/pcbios/abft.c b/gpxe/src/arch/i386/interface/pcbios/abft.c
index af28bbcf..86941728 100644
--- a/gpxe/src/arch/i386/interface/pcbios/abft.c
+++ b/gpxe/src/arch/i386/interface/pcbios/abft.c
@@ -16,6 +16,8 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
+FILE_LICENCE ( GPL2_OR_LATER );
+
#include <realmode.h>
#include <gpxe/aoe.h>
#include <gpxe/netdevice.h>
diff --git a/gpxe/src/arch/i386/interface/pcbios/aoeboot.c b/gpxe/src/arch/i386/interface/pcbios/aoeboot.c
index 6e1e51cb..2670b15d 100644
--- a/gpxe/src/arch/i386/interface/pcbios/aoeboot.c
+++ b/gpxe/src/arch/i386/interface/pcbios/aoeboot.c
@@ -1,58 +1,74 @@
#include <stdint.h>
#include <string.h>
+#include <stdlib.h>
#include <stdio.h>
-#include <byteswap.h>
+#include <errno.h>
#include <gpxe/aoe.h>
#include <gpxe/ata.h>
#include <gpxe/netdevice.h>
-#include <gpxe/settings.h>
#include <gpxe/sanboot.h>
#include <gpxe/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;
+ struct ata_device *ata;
+ struct int13_drive *drive;
int rc;
- memset ( &ata, 0, sizeof ( ata ) );
- memset ( &drive, 0, sizeof ( drive ) );
-
- printf ( "AoE booting from %s\n", root_path );
+ 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 ) {
+ if ( ( rc = aoe_attach ( ata, netdev, root_path ) ) != 0 ) {
printf ( "Could not attach AoE device: %s\n",
strerror ( rc ) );
- goto error_attach;
+ goto err_attach;
}
- if ( ( rc = init_atadev ( &ata ) ) != 0 ) {
+ if ( ( rc = init_atadev ( ata ) ) != 0 ) {
printf ( "Could not initialise AoE device: %s\n",
strerror ( rc ) );
- goto error_init;
+ goto err_init;
}
/* FIXME: ugly, ugly hack */
struct aoe_session *aoe =
- container_of ( ata.backend, struct aoe_session, refcnt );
+ container_of ( ata->backend, struct aoe_session, refcnt );
abft_fill_data ( aoe );
- drive.blockdev = &ata.blockdev;
+ 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 );
+ 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" );
- printf ( "Unregistering BIOS drive %#02x\n", drive.drive );
- unregister_int13_drive ( &drive );
+ /* 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 );
- error_init:
- aoe_detach ( &ata );
- error_attach:
+ err_init:
+ aoe_detach ( ata );
+ err_attach:
+ free ( drive );
+ err_alloc_drive:
+ free ( ata );
+ err_alloc_ata:
return rc;
}
diff --git a/gpxe/src/arch/i386/interface/pcbios/bios_nap.c b/gpxe/src/arch/i386/interface/pcbios/bios_nap.c
index 2f4a0513..e38cac7a 100644
--- a/gpxe/src/arch/i386/interface/pcbios/bios_nap.c
+++ b/gpxe/src/arch/i386/interface/pcbios/bios_nap.c
@@ -1,6 +1,8 @@
#include <gpxe/nap.h>
#include <realmode.h>
+FILE_LICENCE ( GPL2_OR_LATER );
+
/**
* Save power by halting the CPU until the next interrupt
*
diff --git a/gpxe/src/arch/i386/interface/pcbios/bios_smbios.c b/gpxe/src/arch/i386/interface/pcbios/bios_smbios.c
index efaaef0d..094214bd 100644
--- a/gpxe/src/arch/i386/interface/pcbios/bios_smbios.c
+++ b/gpxe/src/arch/i386/interface/pcbios/bios_smbios.c
@@ -16,6 +16,8 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
+FILE_LICENCE ( GPL2_OR_LATER );
+
#include <stdint.h>
#include <string.h>
#include <errno.h>
diff --git a/gpxe/src/arch/i386/interface/pcbios/bios_timer.c b/gpxe/src/arch/i386/interface/pcbios/bios_timer.c
index 0b475ea3..8ecf7c12 100644
--- a/gpxe/src/arch/i386/interface/pcbios/bios_timer.c
+++ b/gpxe/src/arch/i386/interface/pcbios/bios_timer.c
@@ -16,6 +16,8 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
+FILE_LICENCE ( GPL2_OR_LATER );
+
/** @file
*
* BIOS timer
diff --git a/gpxe/src/arch/i386/interface/pcbios/biosint.c b/gpxe/src/arch/i386/interface/pcbios/biosint.c
index 1306f918..a193defa 100644
--- a/gpxe/src/arch/i386/interface/pcbios/biosint.c
+++ b/gpxe/src/arch/i386/interface/pcbios/biosint.c
@@ -7,6 +7,8 @@
*
*/
+FILE_LICENCE ( GPL2_OR_LATER );
+
/**
* Hook INT vector
*
diff --git a/gpxe/src/arch/i386/interface/pcbios/ib_srpboot.c b/gpxe/src/arch/i386/interface/pcbios/ib_srpboot.c
new file mode 100644
index 00000000..b1cbc337
--- /dev/null
+++ b/gpxe/src/arch/i386/interface/pcbios/ib_srpboot.c
@@ -0,0 +1,73 @@
+#include <stdint.h>
+#include <string.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <errno.h>
+#include <gpxe/sanboot.h>
+#include <int13.h>
+#include <gpxe/srp.h>
+#include <gpxe/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,
+};
diff --git a/gpxe/src/arch/i386/interface/pcbios/ibft.c b/gpxe/src/arch/i386/interface/pcbios/ibft.c
index 43d1f85f..adf8e6b9 100644
--- a/gpxe/src/arch/i386/interface/pcbios/ibft.c
+++ b/gpxe/src/arch/i386/interface/pcbios/ibft.c
@@ -25,6 +25,8 @@
*
*/
+FILE_LICENCE ( BSD2 );
+
#include <stdint.h>
#include <stdio.h>
#include <string.h>
@@ -35,6 +37,7 @@
#include <gpxe/acpi.h>
#include <gpxe/in.h>
#include <gpxe/netdevice.h>
+#include <gpxe/ethernet.h>
#include <gpxe/dhcp.h>
#include <gpxe/iscsi.h>
#include <gpxe/ibft.h>
@@ -234,7 +237,8 @@ static int ibft_set_string_option ( struct ibft_string_block *strings,
*/
static const char * ibft_string ( struct ibft_string_block *strings,
struct ibft_string *string ) {
- return ( ( ( char * ) strings->table ) + string->offset );
+ return ( string->offset ?
+ ( ( ( char * ) strings->table ) + string->offset ) : NULL );
}
/**
@@ -248,6 +252,7 @@ static const char * ibft_string ( struct ibft_string_block *strings,
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;
@@ -276,10 +281,12 @@ static int ibft_fill_nic ( struct ibft_nic *nic,
DBG ( "iBFT NIC subnet = /%d\n", nic->subnet_mask_prefix );
/* Extract values from net-device configuration */
- memcpy ( nic->mac_address, netdev->ll_addr,
- sizeof ( nic->mac_address ) );
- DBG ( "iBFT NIC MAC = %s\n",
- netdev->ll_protocol->ntoa ( nic->mac_address ) );
+ 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 );
diff --git a/gpxe/src/arch/i386/interface/pcbios/int13.c b/gpxe/src/arch/i386/interface/pcbios/int13.c
index 2e9de5cb..87b613a8 100644
--- a/gpxe/src/arch/i386/interface/pcbios/int13.c
+++ b/gpxe/src/arch/i386/interface/pcbios/int13.c
@@ -16,6 +16,8 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
+FILE_LICENCE ( GPL2_OR_LATER );
+
#include <stdint.h>
#include <limits.h>
#include <byteswap.h>
@@ -50,6 +52,48 @@ extern void int13_wrapper ( void );
static LIST_HEAD ( drives );
/**
+ * Number of BIOS drives
+ *
+ * Note that this is the number of drives in the system as a whole
+ * (i.e. a mirror of the counter at 40:75), rather than a count of the
+ * number of emulated drives.
+ */
+static uint8_t num_drives;
+
+/**
+ * Update BIOS drive count
+ */
+static void int13_set_num_drives ( void ) {
+ struct int13_drive *drive;
+
+ /* Get current drive count */
+ get_real ( num_drives, BDA_SEG, BDA_NUM_DRIVES );
+
+ /* Ensure count is large enough to cover all of our emulated drives */
+ list_for_each_entry ( drive, &drives, list ) {
+ if ( num_drives <= ( drive->drive & 0x7f ) )
+ num_drives = ( ( drive->drive & 0x7f ) + 1 );
+ }
+
+ /* Update current drive count */
+ put_real ( num_drives, BDA_SEG, BDA_NUM_DRIVES );
+}
+
+/**
+ * Check number of drives
+ */
+static void int13_check_num_drives ( void ) {
+ uint8_t check_num_drives;
+
+ get_real ( check_num_drives, BDA_SEG, BDA_NUM_DRIVES );
+ if ( check_num_drives != num_drives ) {
+ int13_set_num_drives();
+ DBG ( "INT13 fixing up number of drives from %d to %d\n",
+ check_num_drives, num_drives );
+ }
+}
+
+/**
* INT 13, 00 - Reset disk system
*
* @v drive Emulated drive
@@ -98,6 +142,7 @@ static int int13_rw_sectors ( struct int13_drive *drive,
unsigned long lba;
unsigned int count;
userptr_t buffer;
+ int rc;
/* Validate blocksize */
if ( blockdev->blksize != INT13_BLKSIZE ) {
@@ -122,8 +167,10 @@ static int int13_rw_sectors ( struct int13_drive *drive,
head, sector, lba, ix86->segs.es, ix86->regs.bx, count );
/* Read from / write to block device */
- if ( io ( blockdev, lba, count, buffer ) != 0 )
+ if ( ( rc = io ( blockdev, lba, count, buffer ) ) != 0 ) {
+ DBG ( "INT 13 failed: %s\n", strerror ( rc ) );
return -INT13_STATUS_READ_ERROR;
+ }
return 0;
}
@@ -202,9 +249,13 @@ static int int13_get_parameters ( struct int13_drive *drive,
*/
static int int13_get_disk_type ( struct int13_drive *drive,
struct i386_all_regs *ix86 ) {
+ uint32_t blocks;
+
DBG ( "Get disk type\n" );
- ix86->regs.cx = ( drive->cylinders >> 16 );
- ix86->regs.dx = ( drive->cylinders & 0xffff );
+ blocks = ( ( drive->blockdev->blocks <= 0xffffffffUL ) ?
+ drive->blockdev->blocks : 0xffffffffUL );
+ ix86->regs.cx = ( blocks >> 16 );
+ ix86->regs.dx = ( blocks & 0xffff );
return INT13_DISK_TYPE_HDD;
}
@@ -248,6 +299,7 @@ static int int13_extended_rw ( struct int13_drive *drive,
uint64_t lba;
unsigned long count;
userptr_t buffer;
+ int rc;
/* Read parameters from disk address structure */
copy_from_real ( &addr, ix86->segs.ds, ix86->regs.si, sizeof ( addr ));
@@ -259,8 +311,10 @@ static int int13_extended_rw ( struct int13_drive *drive,
addr.buffer.segment, addr.buffer.offset, count );
/* Read from / write to block device */
- if ( io ( blockdev, lba, count, buffer ) != 0 )
+ if ( ( rc = io ( blockdev, lba, count, buffer ) ) != 0 ) {
+ DBG ( "INT 13 failed: %s\n", strerror ( rc ) );
return -INT13_STATUS_READ_ERROR;
+ }
return 0;
}
@@ -328,6 +382,9 @@ static __asmcall void int13 ( struct i386_all_regs *ix86 ) {
struct int13_drive *drive;
int status;
+ /* Check BIOS hasn't killed off our drive */
+ int13_check_num_drives();
+
list_for_each_entry ( drive, &drives, list ) {
if ( bios_drive != drive->drive ) {
@@ -387,7 +444,7 @@ static __asmcall void int13 ( struct i386_all_regs *ix86 ) {
/* Negative status indicates an error */
if ( status < 0 ) {
status = -status;
- DBG ( "INT13 failed with status %x\n", status );
+ DBG ( "INT 13 returning failure status %x\n", status );
} else {
ix86->flags &= ~CF;
}
@@ -543,7 +600,6 @@ void register_int13_drive ( struct int13_drive *drive ) {
/* Assign natural drive number */
get_real ( num_drives, BDA_SEG, BDA_NUM_DRIVES );
drive->natural_drive = ( num_drives | 0x80 );
- num_drives++;
/* Assign drive number */
if ( ( drive->drive & 0xff ) == 0xff ) {
@@ -552,13 +608,8 @@ void register_int13_drive ( struct int13_drive *drive ) {
} else {
/* Use specified drive number (+0x80 if necessary) */
drive->drive |= 0x80;
- if ( num_drives <= ( drive->drive & 0x7f ) )
- num_drives = ( ( drive->drive & 0x7f ) + 1 );
}
- /* Update BIOS drive count */
- put_real ( num_drives, BDA_SEG, BDA_NUM_DRIVES );
-
DBG ( "Registered INT13 drive %02x (naturally %02x) with C/H/S "
"geometry %d/%d/%d\n", drive->drive, drive->natural_drive,
drive->cylinders, drive->heads, drive->sectors_per_track );
@@ -569,6 +620,9 @@ void register_int13_drive ( struct int13_drive *drive ) {
/* Add to list of emulated drives */
list_add ( &drive->list, &drives );
+
+ /* Update BIOS drive count */
+ int13_set_num_drives();
}
/**
@@ -652,7 +706,8 @@ int int13_boot ( unsigned int drive ) {
/* Jump to boot sector */
if ( ( rc = call_bootsector ( 0x0, 0x7c00, drive ) ) != 0 ) {
- DBG ( "INT 13 drive %02x boot returned\n", drive );
+ DBG ( "INT 13 drive %02x boot returned: %s\n",
+ drive, strerror ( rc ) );
return rc;
}
diff --git a/gpxe/src/arch/i386/interface/pcbios/iscsiboot.c b/gpxe/src/arch/i386/interface/pcbios/iscsiboot.c
index 02aec4ba..00efd8ff 100644
--- a/gpxe/src/arch/i386/interface/pcbios/iscsiboot.c
+++ b/gpxe/src/arch/i386/interface/pcbios/iscsiboot.c
@@ -4,26 +4,16 @@
#include <stdio.h>
#include <errno.h>
#include <gpxe/iscsi.h>
-#include <gpxe/settings.h>
-#include <gpxe/dhcp.h>
#include <gpxe/netdevice.h>
#include <gpxe/ibft.h>
-#include <gpxe/init.h>
#include <gpxe/sanboot.h>
#include <int13.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,
-};
+FILE_LICENCE ( GPL2_OR_LATER );
static int iscsiboot ( const char *root_path ) {
struct scsi_device *scsi;
struct int13_drive *drive;
- int keep_san;
int rc;
scsi = zalloc ( sizeof ( *scsi ) );
@@ -37,8 +27,6 @@ static int iscsiboot ( const char *root_path ) {
goto err_alloc_drive;
}
- printf ( "iSCSI booting from %s\n", root_path );
-
if ( ( rc = iscsi_attach ( scsi, root_path ) ) != 0 ) {
printf ( "Could not attach iSCSI device: %s\n",
strerror ( rc ) );
@@ -65,12 +53,8 @@ static int iscsiboot ( const char *root_path ) {
printf ( "Boot failed\n" );
/* Leave drive registered, if instructed to do so */
- keep_san = fetch_intz_setting ( NULL, &keep_san_setting );
- if ( keep_san ) {
- printf ( "Preserving connection to SAN disk\n" );
- shutdown_exit_flags |= SHUTDOWN_KEEP_DEVICES;
+ if ( keep_san() )
return rc;
- }
printf ( "Unregistering BIOS drive %#02x\n", drive->drive );
unregister_int13_drive ( drive );
diff --git a/gpxe/src/arch/i386/interface/pcbios/keepsan.c b/gpxe/src/arch/i386/interface/pcbios/keepsan.c
new file mode 100644
index 00000000..904e017d
--- /dev/null
+++ b/gpxe/src/arch/i386/interface/pcbios/keepsan.c
@@ -0,0 +1,26 @@
+#include <stdint.h>
+#include <stdio.h>
+#include <gpxe/settings.h>
+#include <gpxe/dhcp.h>
+#include <gpxe/init.h>
+#include <gpxe/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;
+}
diff --git a/gpxe/src/arch/i386/interface/pcbios/memtop_umalloc.c b/gpxe/src/arch/i386/interface/pcbios/memtop_umalloc.c
index 744d8e30..0645fe63 100644
--- a/gpxe/src/arch/i386/interface/pcbios/memtop_umalloc.c
+++ b/gpxe/src/arch/i386/interface/pcbios/memtop_umalloc.c
@@ -16,6 +16,8 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
+FILE_LICENCE ( GPL2_OR_LATER );
+
/**
* @file
*
diff --git a/gpxe/src/arch/i386/interface/pcbios/pcibios.c b/gpxe/src/arch/i386/interface/pcbios/pcibios.c
index 81b4fd3c..f2c3880c 100644
--- a/gpxe/src/arch/i386/interface/pcbios/pcibios.c
+++ b/gpxe/src/arch/i386/interface/pcbios/pcibios.c
@@ -16,6 +16,8 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
+FILE_LICENCE ( GPL2_OR_LATER );
+
#include <stdint.h>
#include <gpxe/pci.h>
#include <realmode.h>
diff --git a/gpxe/src/arch/i386/interface/pcbios/sbft.c b/gpxe/src/arch/i386/interface/pcbios/sbft.c
new file mode 100644
index 00000000..12927c77
--- /dev/null
+++ b/gpxe/src/arch/i386/interface/pcbios/sbft.c
@@ -0,0 +1,105 @@
+/*
+ * 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 <gpxe/srp.h>
+#include <gpxe/ib_srp.h>
+#include <gpxe/acpi.h>
+#include <gpxe/sbft.h>
+
+#define sbftab __use_data16 ( sbftab )
+/** The sBFT used by gPXE */
+struct gpxe_sbft __data16 ( sbftab ) = {
+ /* Table header */
+ .table = {
+ /* ACPI header */
+ .acpi = {
+ .signature = SBFT_SIG,
+ .length = sizeof ( sbftab ),
+ .revision = 1,
+ .oem_id = "FENSYS",
+ .oem_table_id = "gPXE",
+ },
+ .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;
+}