sbft.c

Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2009 Fen Systems Ltd <mbrown@fensystems.co.uk>.
00003  * All rights reserved.
00004  *
00005  * Redistribution and use in source and binary forms, with or without
00006  * modification, are permitted provided that the following conditions
00007  * are met:
00008  *
00009  *   Redistributions of source code must retain the above copyright
00010  *   notice, this list of conditions and the following disclaimer.
00011  *
00012  *   Redistributions in binary form must reproduce the above copyright
00013  *   notice, this list of conditions and the following disclaimer in
00014  *   the documentation and/or other materials provided with the
00015  *   distribution.
00016  *
00017  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00018  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00019  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00020  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
00021  * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
00022  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
00023  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
00024  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
00025  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
00026  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
00027  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
00028  * OF THE POSSIBILITY OF SUCH DAMAGE.
00029  */
00030 
00031 FILE_LICENCE ( BSD2 );
00032 
00033 /** @file
00034  *
00035  * SRP boot firmware table
00036  *
00037  */
00038 
00039 #include <assert.h>
00040 #include <realmode.h>
00041 #include <gpxe/srp.h>
00042 #include <gpxe/ib_srp.h>
00043 #include <gpxe/acpi.h>
00044 #include <gpxe/sbft.h>
00045 
00046 #define sbftab __use_data16 ( sbftab )
00047 /** The sBFT used by gPXE */
00048 struct gpxe_sbft __data16 ( sbftab ) = {
00049         /* Table header */
00050         .table = {
00051                 /* ACPI header */
00052                 .acpi = {
00053                         .signature = SBFT_SIG,
00054                         .length = sizeof ( sbftab ),
00055                         .revision = 1,
00056                         .oem_id = "FENSYS",
00057                         .oem_table_id = "gPXE",
00058                 },
00059                 .scsi_offset = offsetof ( typeof ( sbftab ), scsi ),
00060                 .srp_offset = offsetof ( typeof ( sbftab ), srp ),
00061                 .ib_offset = offsetof ( typeof ( sbftab ), ib ),
00062         },
00063 };
00064 
00065 /**
00066  * Fill in all variable portions of sBFT
00067  *
00068  * @v srp               SRP device
00069  * @ret rc              Return status code
00070  */
00071 int sbft_fill_data ( struct srp_device *srp ) {
00072         struct sbft_scsi_subtable *sbft_scsi = &sbftab.scsi;
00073         struct sbft_srp_subtable *sbft_srp = &sbftab.srp;
00074         struct sbft_ib_subtable *sbft_ib = &sbftab.ib;
00075         struct ib_srp_parameters *ib_params;
00076         struct segoff rm_sbftab = {
00077                 .segment = rm_ds,
00078                 .offset = __from_data16 ( &sbftab ),
00079         };
00080 
00081         /* Fill in the SCSI subtable */
00082         memcpy ( &sbft_scsi->lun, &srp->lun, sizeof ( sbft_scsi->lun ) );
00083 
00084         /* Fill in the SRP subtable */
00085         memcpy ( &sbft_srp->port_ids, &srp->port_ids,
00086                  sizeof ( sbft_srp->port_ids ) );
00087 
00088         /* Fill in the IB subtable */
00089         assert ( srp->transport == &ib_srp_transport );
00090         ib_params = ib_srp_params ( srp );
00091         memcpy ( &sbft_ib->sgid, &ib_params->sgid, sizeof ( sbft_ib->sgid ) );
00092         memcpy ( &sbft_ib->dgid, &ib_params->dgid, sizeof ( sbft_ib->dgid ) );
00093         memcpy ( &sbft_ib->service_id, &ib_params->service_id,
00094                  sizeof ( sbft_ib->service_id ) );
00095         sbft_ib->pkey = ib_params->pkey;
00096 
00097         /* Update checksum */
00098         acpi_fix_checksum ( &sbftab.table.acpi );
00099 
00100         DBGC ( &sbftab, "SRP Boot Firmware Table at %04x:%04x:\n",
00101                rm_sbftab.segment, rm_sbftab.offset );
00102         DBGC_HDA ( &sbftab, rm_sbftab, &sbftab, sizeof ( sbftab ) );
00103 
00104         return 0;
00105 }

Generated on Tue Apr 6 20:00:50 2010 for gPXE by  doxygen 1.5.7.1