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

device.h 2.0KB

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