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.

dummy_sanboot.c 3.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. /*
  2. * Copyright (C) 2017 Michael Brown <mbrown@fensystems.co.uk>.
  3. *
  4. * This program is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU General Public License as
  6. * published by the Free Software Foundation; either version 2 of the
  7. * License, or any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful, but
  10. * WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. * General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, write to the Free Software
  16. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  17. * 02110-1301, USA.
  18. *
  19. * You can also choose to distribute this program under the terms of
  20. * the Unmodified Binary Distribution Licence (as given in the file
  21. * COPYING.UBDL), provided that you have satisfied its requirements.
  22. */
  23. FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
  24. /** @file
  25. *
  26. * Dummy SAN device
  27. *
  28. */
  29. #include <errno.h>
  30. #include <ipxe/sanboot.h>
  31. /**
  32. * Hook dummy SAN device
  33. *
  34. * @v drive Drive number
  35. * @v uris List of URIs
  36. * @v count Number of URIs
  37. * @v flags Flags
  38. * @ret drive Drive number, or negative error
  39. */
  40. static int dummy_san_hook ( unsigned int drive, struct uri **uris,
  41. unsigned int count, unsigned int flags ) {
  42. struct san_device *sandev;
  43. int rc;
  44. /* Allocate SAN device */
  45. sandev = alloc_sandev ( uris, count, 0 );
  46. if ( ! sandev ) {
  47. rc = -ENOMEM;
  48. goto err_alloc;
  49. }
  50. /* Register SAN device */
  51. if ( ( rc = register_sandev ( sandev, drive, flags ) ) != 0 ) {
  52. DBGC ( sandev, "SAN %#02x could not register: %s\n",
  53. sandev->drive, strerror ( rc ) );
  54. goto err_register;
  55. }
  56. return drive;
  57. unregister_sandev ( sandev );
  58. err_register:
  59. sandev_put ( sandev );
  60. err_alloc:
  61. return rc;
  62. }
  63. /**
  64. * Unhook dummy SAN device
  65. *
  66. * @v drive Drive number
  67. */
  68. static void dummy_san_unhook ( unsigned int drive ) {
  69. struct san_device *sandev;
  70. /* Find drive */
  71. sandev = sandev_find ( drive );
  72. if ( ! sandev ) {
  73. DBG ( "SAN %#02x does not exist\n", drive );
  74. return;
  75. }
  76. /* Unregister SAN device */
  77. unregister_sandev ( sandev );
  78. /* Drop reference to drive */
  79. sandev_put ( sandev );
  80. }
  81. /**
  82. * Boot from dummy SAN device
  83. *
  84. * @v drive Drive number
  85. * @v filename Filename (or NULL to use default)
  86. * @ret rc Return status code
  87. */
  88. static int dummy_san_boot ( unsigned int drive __unused,
  89. const char *filename __unused ) {
  90. return -EOPNOTSUPP;
  91. }
  92. /**
  93. * Install ACPI table
  94. *
  95. * @v acpi ACPI description header
  96. * @ret rc Return status code
  97. */
  98. static int dummy_install ( struct acpi_header *acpi ) {
  99. DBGC ( acpi, "ACPI table %s:\n", acpi_name ( acpi->signature ) );
  100. DBGC_HDA ( acpi, 0, acpi, le32_to_cpu ( acpi->length ) );
  101. return 0;
  102. }
  103. /**
  104. * Describe dummy SAN device
  105. *
  106. * @ret rc Return status code
  107. */
  108. static int dummy_san_describe ( void ) {
  109. return acpi_install ( dummy_install );
  110. }
  111. PROVIDE_SANBOOT ( dummy, san_hook, dummy_san_hook );
  112. PROVIDE_SANBOOT ( dummy, san_unhook, dummy_san_unhook );
  113. PROVIDE_SANBOOT ( dummy, san_boot, dummy_san_boot );
  114. PROVIDE_SANBOOT ( dummy, san_describe, dummy_san_describe );