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.

device.h 1.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. #ifndef _GPXE_DEVICE_H
  2. #define _GPXE_DEVICE_H
  3. /**
  4. * @file
  5. *
  6. * Device model
  7. *
  8. */
  9. #include <gpxe/list.h>
  10. #include <gpxe/tables.h>
  11. /** A hardware device description */
  12. struct device_description {
  13. /** Bus type
  14. *
  15. * This must be a BUS_TYPE_XXX constant.
  16. */
  17. unsigned int bus_type;
  18. /** Location
  19. *
  20. * The interpretation of this field is bus-type-specific.
  21. */
  22. unsigned int location;
  23. /** Vendor ID */
  24. unsigned int vendor;
  25. /** Device ID */
  26. unsigned int device;
  27. /** Device class */
  28. unsigned long class;
  29. /** I/O address */
  30. unsigned long ioaddr;
  31. /** IRQ */
  32. unsigned int irq;
  33. };
  34. /** PCI bus type */
  35. #define BUS_TYPE_PCI 1
  36. /** ISAPnP bus type */
  37. #define BUS_TYPE_ISAPNP 2
  38. /** EISA bus type */
  39. #define BUS_TYPE_EISA 3
  40. /** MCA bus type */
  41. #define BUS_TYPE_MCA 4
  42. /** ISA bus type */
  43. #define BUS_TYPE_ISA 5
  44. /** A hardware device */
  45. struct device {
  46. /** Name */
  47. char name[16];
  48. /** Device description */
  49. struct device_description desc;
  50. /** Devices on the same bus */
  51. struct list_head siblings;
  52. /** Devices attached to this device */
  53. struct list_head children;
  54. /** Bus device */
  55. struct device *parent;
  56. };
  57. /**
  58. * A root device
  59. *
  60. * Root devices are system buses such as PCI, EISA, etc.
  61. *
  62. */
  63. struct root_device {
  64. /** Device chain
  65. *
  66. * A root device has a NULL parent field.
  67. */
  68. struct device dev;
  69. /** Root device driver */
  70. struct root_driver *driver;
  71. };
  72. /** A root device driver */
  73. struct root_driver {
  74. /**
  75. * Add root device
  76. *
  77. * @v rootdev Root device
  78. * @ret rc Return status code
  79. *
  80. * Called from probe_devices() for all root devices in the build.
  81. */
  82. int ( * probe ) ( struct root_device *rootdev );
  83. /**
  84. * Remove root device
  85. *
  86. * @v rootdev Root device
  87. *
  88. * Called from remove_device() for all successfully-probed
  89. * root devices.
  90. */
  91. void ( * remove ) ( struct root_device *rootdev );
  92. };
  93. /** Declare a root device */
  94. #define __root_device __table ( struct root_device, root_devices, 01 )
  95. #endif /* _GPXE_DEVICE_H */