Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

undionly.c 3.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. /*
  2. * Copyright (C) 2007 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., 675 Mass Ave, Cambridge, MA 02139, USA.
  17. */
  18. FILE_LICENCE ( GPL2_OR_LATER );
  19. #include <stdint.h>
  20. #include <stdlib.h>
  21. #include <stdio.h>
  22. #include <string.h>
  23. #include <ipxe/device.h>
  24. #include <ipxe/init.h>
  25. #include <ipxe/pci.h>
  26. #include <undi.h>
  27. #include <undinet.h>
  28. #include <undipreload.h>
  29. /** @file
  30. *
  31. * "Pure" UNDI driver
  32. *
  33. * This is the UNDI driver without explicit support for PCI or any
  34. * other bus type. It is capable only of using the preloaded UNDI
  35. * device. It must not be combined in an image with any other
  36. * drivers.
  37. *
  38. * If you want a PXE-loadable image that contains only the UNDI
  39. * driver, build "bin/undionly.kpxe".
  40. *
  41. * If you want any other image format, or any other drivers in
  42. * addition to the UNDI driver, build e.g. "bin/undi.dsk".
  43. */
  44. /**
  45. * Probe UNDI root bus
  46. *
  47. * @v rootdev UNDI bus root device
  48. *
  49. * Scans the UNDI bus for devices and registers all devices it can
  50. * find.
  51. */
  52. static int undibus_probe ( struct root_device *rootdev ) {
  53. struct undi_device *undi = &preloaded_undi;
  54. int rc;
  55. /* Check for a valie preloaded UNDI device */
  56. if ( ! undi->entry.segment ) {
  57. DBG ( "No preloaded UNDI device found!\n" );
  58. return -ENODEV;
  59. }
  60. /* Add to device hierarchy */
  61. undi->dev.driver_name = "undionly";
  62. if ( undi->pci_busdevfn != UNDI_NO_PCI_BUSDEVFN ) {
  63. undi->dev.desc.bus_type = BUS_TYPE_PCI;
  64. undi->dev.desc.location = undi->pci_busdevfn;
  65. undi->dev.desc.vendor = undi->pci_vendor;
  66. undi->dev.desc.device = undi->pci_device;
  67. snprintf ( undi->dev.name, sizeof ( undi->dev.name ),
  68. "UNDI-PCI%02x:%02x.%x",
  69. PCI_BUS ( undi->pci_busdevfn ),
  70. PCI_SLOT ( undi->pci_busdevfn ),
  71. PCI_FUNC ( undi->pci_busdevfn ) );
  72. } else if ( undi->isapnp_csn != UNDI_NO_ISAPNP_CSN ) {
  73. undi->dev.desc.bus_type = BUS_TYPE_ISAPNP;
  74. snprintf ( undi->dev.name, sizeof ( undi->dev.name ),
  75. "UNDI-ISAPNP" );
  76. }
  77. undi->dev.parent = &rootdev->dev;
  78. list_add ( &undi->dev.siblings, &rootdev->dev.children);
  79. INIT_LIST_HEAD ( &undi->dev.children );
  80. /* Create network device */
  81. if ( ( rc = undinet_probe ( undi ) ) != 0 )
  82. goto err;
  83. return 0;
  84. err:
  85. list_del ( &undi->dev.siblings );
  86. return rc;
  87. }
  88. /**
  89. * Remove UNDI root bus
  90. *
  91. * @v rootdev UNDI bus root device
  92. */
  93. static void undibus_remove ( struct root_device *rootdev __unused ) {
  94. struct undi_device *undi = &preloaded_undi;
  95. undinet_remove ( undi );
  96. list_del ( &undi->dev.siblings );
  97. }
  98. /** UNDI bus root device driver */
  99. static struct root_driver undi_root_driver = {
  100. .probe = undibus_probe,
  101. .remove = undibus_remove,
  102. };
  103. /** UNDI bus root device */
  104. struct root_device undi_root_device __root_device = {
  105. .dev = { .name = "UNDI" },
  106. .driver = &undi_root_driver,
  107. };
  108. /**
  109. * Prepare for exit
  110. *
  111. * @v booting System is shutting down for OS boot
  112. */
  113. static void undionly_shutdown ( int booting ) {
  114. /* If we are shutting down to boot an OS, clear the "keep PXE
  115. * stack" flag.
  116. */
  117. if ( booting )
  118. preloaded_undi.flags &= ~UNDI_FL_KEEP_ALL;
  119. }
  120. struct startup_fn startup_undionly __startup_fn ( STARTUP_LATE ) = {
  121. .shutdown = undionly_shutdown,
  122. };