Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

undionly.c 3.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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. #include <stdint.h>
  19. #include <stdlib.h>
  20. #include <string.h>
  21. #include <gpxe/device.h>
  22. #include <undi.h>
  23. #include <undinet.h>
  24. #include <undipreload.h>
  25. /** @file
  26. *
  27. * "Pure" UNDI driver
  28. *
  29. * This is the UNDI driver without explicit support for PCI or any
  30. * other bus type. It is capable only of using the preloaded UNDI
  31. * device. It must not be combined in an image with any other
  32. * drivers.
  33. *
  34. * If you want a PXE-loadable image that contains only the UNDI
  35. * driver, build "bin/undionly.kpxe".
  36. *
  37. * If you want any other image format, or any other drivers in
  38. * addition to the UNDI driver, build e.g. "bin/undi.dsk".
  39. */
  40. /**
  41. * Probe UNDI root bus
  42. *
  43. * @v rootdev UNDI bus root device
  44. *
  45. * Scans the UNDI bus for devices and registers all devices it can
  46. * find.
  47. */
  48. static int undibus_probe ( struct root_device *rootdev ) {
  49. struct undi_device *undi = &preloaded_undi;
  50. int rc;
  51. /* Check for a valie preloaded UNDI device */
  52. if ( ! undi->entry.segment ) {
  53. DBG ( "No preloaded UNDI device found!\n" );
  54. return -ENODEV;
  55. }
  56. /* Add to device hierarchy */
  57. strncpy ( undi->dev.name, "UNDI",
  58. ( sizeof ( undi->dev.name ) - 1 ) );
  59. if ( undi->pci_busdevfn != UNDI_NO_PCI_BUSDEVFN ) {
  60. undi->dev.desc.bus_type = BUS_TYPE_PCI;
  61. undi->dev.desc.location = undi->pci_busdevfn;
  62. undi->dev.desc.vendor = undi->pci_vendor;
  63. undi->dev.desc.device = undi->pci_device;
  64. } else if ( undi->isapnp_csn != UNDI_NO_ISAPNP_CSN ) {
  65. undi->dev.desc.bus_type = BUS_TYPE_ISAPNP;
  66. }
  67. undi->dev.parent = &rootdev->dev;
  68. list_add ( &undi->dev.siblings, &rootdev->dev.children);
  69. INIT_LIST_HEAD ( &undi->dev.children );
  70. /* Create network device */
  71. if ( ( rc = undinet_probe ( undi ) ) != 0 )
  72. goto err;
  73. return 0;
  74. err:
  75. list_del ( &undi->dev.siblings );
  76. return rc;
  77. }
  78. /**
  79. * Remove UNDI root bus
  80. *
  81. * @v rootdev UNDI bus root device
  82. */
  83. static void undibus_remove ( struct root_device *rootdev __unused ) {
  84. struct undi_device *undi = &preloaded_undi;
  85. undinet_remove ( undi );
  86. list_del ( &undi->dev.siblings );
  87. }
  88. /** UNDI bus root device driver */
  89. static struct root_driver undi_root_driver = {
  90. .probe = undibus_probe,
  91. .remove = undibus_remove,
  92. };
  93. /** UNDI bus root device */
  94. struct root_device undi_root_device __root_device = {
  95. .dev = { .name = "UNDI" },
  96. .driver = &undi_root_driver,
  97. };