您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

dummy_sanboot.c 2.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  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. * @ret drive Drive number, or negative error
  38. */
  39. static int dummy_san_hook ( unsigned int drive, struct uri **uris,
  40. unsigned int count ) {
  41. struct san_device *sandev;
  42. int rc;
  43. /* Allocate SAN device */
  44. sandev = alloc_sandev ( uris, count, 0 );
  45. if ( ! sandev ) {
  46. rc = -ENOMEM;
  47. goto err_alloc;
  48. }
  49. sandev->drive = drive;
  50. /* Register SAN device */
  51. if ( ( rc = register_sandev ( sandev ) ) != 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. */
  86. static int dummy_san_boot ( unsigned int drive __unused ) {
  87. return -EOPNOTSUPP;
  88. }
  89. /**
  90. * Describe dummy SAN device
  91. *
  92. * @v drive Drive number
  93. */
  94. static int dummy_san_describe ( unsigned int drive __unused ) {
  95. return 0;
  96. }
  97. PROVIDE_SANBOOT ( dummy, san_hook, dummy_san_hook );
  98. PROVIDE_SANBOOT ( dummy, san_unhook, dummy_san_unhook );
  99. PROVIDE_SANBOOT ( dummy, san_boot, dummy_san_boot );
  100. PROVIDE_SANBOOT ( dummy, san_describe, dummy_san_describe );