You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

sbft.c 3.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. /*
  2. * Copyright (C) 2009 Fen Systems Ltd <mbrown@fensystems.co.uk>.
  3. * All rights reserved.
  4. *
  5. * Redistribution and use in source and binary forms, with or without
  6. * modification, are permitted provided that the following conditions
  7. * are met:
  8. *
  9. * Redistributions of source code must retain the above copyright
  10. * notice, this list of conditions and the following disclaimer.
  11. *
  12. * Redistributions in binary form must reproduce the above copyright
  13. * notice, this list of conditions and the following disclaimer in
  14. * the documentation and/or other materials provided with the
  15. * distribution.
  16. *
  17. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  18. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  19. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
  20. * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
  21. * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
  22. * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  23. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  24. * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  25. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
  26. * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  27. * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
  28. * OF THE POSSIBILITY OF SUCH DAMAGE.
  29. */
  30. FILE_LICENCE ( BSD2 );
  31. /** @file
  32. *
  33. * SRP boot firmware table
  34. *
  35. */
  36. #include <assert.h>
  37. #include <realmode.h>
  38. #include <ipxe/srp.h>
  39. #include <ipxe/ib_srp.h>
  40. #include <ipxe/acpi.h>
  41. #include <ipxe/sbft.h>
  42. #define sbftab __use_data16 ( sbftab )
  43. /** The sBFT used by iPXE */
  44. struct ipxe_sbft __data16 ( sbftab ) = {
  45. /* Table header */
  46. .table = {
  47. /* ACPI header */
  48. .acpi = {
  49. .signature = SBFT_SIG,
  50. .length = sizeof ( sbftab ),
  51. .revision = 1,
  52. .oem_id = "FENSYS",
  53. .oem_table_id = "iPXE",
  54. },
  55. .scsi_offset = offsetof ( typeof ( sbftab ), scsi ),
  56. .srp_offset = offsetof ( typeof ( sbftab ), srp ),
  57. .ib_offset = offsetof ( typeof ( sbftab ), ib ),
  58. },
  59. };
  60. /**
  61. * Fill in all variable portions of sBFT
  62. *
  63. * @v srp SRP device
  64. * @ret rc Return status code
  65. */
  66. int sbft_fill_data ( struct srp_device *srp ) {
  67. struct sbft_scsi_subtable *sbft_scsi = &sbftab.scsi;
  68. struct sbft_srp_subtable *sbft_srp = &sbftab.srp;
  69. struct sbft_ib_subtable *sbft_ib = &sbftab.ib;
  70. struct ib_srp_parameters *ib_params;
  71. struct segoff rm_sbftab = {
  72. .segment = rm_ds,
  73. .offset = __from_data16 ( &sbftab ),
  74. };
  75. /* Fill in the SCSI subtable */
  76. memcpy ( &sbft_scsi->lun, &srp->lun, sizeof ( sbft_scsi->lun ) );
  77. /* Fill in the SRP subtable */
  78. memcpy ( &sbft_srp->port_ids, &srp->port_ids,
  79. sizeof ( sbft_srp->port_ids ) );
  80. /* Fill in the IB subtable */
  81. assert ( srp->transport == &ib_srp_transport );
  82. ib_params = ib_srp_params ( srp );
  83. memcpy ( &sbft_ib->sgid, &ib_params->sgid, sizeof ( sbft_ib->sgid ) );
  84. memcpy ( &sbft_ib->dgid, &ib_params->dgid, sizeof ( sbft_ib->dgid ) );
  85. memcpy ( &sbft_ib->service_id, &ib_params->service_id,
  86. sizeof ( sbft_ib->service_id ) );
  87. sbft_ib->pkey = ib_params->pkey;
  88. /* Update checksum */
  89. acpi_fix_checksum ( &sbftab.table.acpi );
  90. DBGC ( &sbftab, "SRP Boot Firmware Table at %04x:%04x:\n",
  91. rm_sbftab.segment, rm_sbftab.offset );
  92. DBGC_HDA ( &sbftab, rm_sbftab, &sbftab, sizeof ( sbftab ) );
  93. return 0;
  94. }