sbft.c
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 FILE_LICENCE ( BSD2 );
00032
00033
00034
00035
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
00048 struct gpxe_sbft __data16 ( sbftab ) = {
00049
00050 .table = {
00051
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
00067
00068
00069
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
00082 memcpy ( &sbft_scsi->lun, &srp->lun, sizeof ( sbft_scsi->lun ) );
00083
00084
00085 memcpy ( &sbft_srp->port_ids, &srp->port_ids,
00086 sizeof ( sbft_srp->port_ids ) );
00087
00088
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
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 }