Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  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 uri URI
  35. * @v drive Drive number
  36. * @ret drive Drive number, or negative error
  37. */
  38. static int dummy_san_hook ( struct uri *uri, unsigned int drive ) {
  39. struct san_device *sandev;
  40. int rc;
  41. /* Allocate SAN device */
  42. sandev = alloc_sandev ( uri, 0 );
  43. if ( ! sandev ) {
  44. rc = -ENOMEM;
  45. goto err_alloc;
  46. }
  47. sandev->drive = drive;
  48. /* Register SAN device */
  49. if ( ( rc = register_sandev ( sandev ) ) != 0 ) {
  50. DBGC ( sandev, "SAN %#02x could not register: %s\n",
  51. sandev->drive, strerror ( rc ) );
  52. goto err_register;
  53. }
  54. return drive;
  55. unregister_sandev ( sandev );
  56. err_register:
  57. sandev_put ( sandev );
  58. err_alloc:
  59. return rc;
  60. }
  61. /**
  62. * Unhook dummy SAN device
  63. *
  64. * @v drive Drive number
  65. */
  66. static void dummy_san_unhook ( unsigned int drive ) {
  67. struct san_device *sandev;
  68. /* Find drive */
  69. sandev = sandev_find ( drive );
  70. if ( ! sandev ) {
  71. DBG ( "SAN %#02x does not exist\n", drive );
  72. return;
  73. }
  74. /* Unregister SAN device */
  75. unregister_sandev ( sandev );
  76. /* Drop reference to drive */
  77. sandev_put ( sandev );
  78. }
  79. /**
  80. * Boot from dummy SAN device
  81. *
  82. * @v drive Drive number
  83. */
  84. static int dummy_san_boot ( unsigned int drive __unused ) {
  85. return -EOPNOTSUPP;
  86. }
  87. /**
  88. * Describe dummy SAN device
  89. *
  90. * @v drive Drive number
  91. */
  92. static int dummy_san_describe ( unsigned int drive __unused ) {
  93. return 0;
  94. }
  95. PROVIDE_SANBOOT ( dummy, san_hook, dummy_san_hook );
  96. PROVIDE_SANBOOT ( dummy, san_unhook, dummy_san_unhook );
  97. PROVIDE_SANBOOT ( dummy, san_boot, dummy_san_boot );
  98. PROVIDE_SANBOOT ( dummy, san_describe, dummy_san_describe );