選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

dev.h 1.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. #ifndef DEV_H
  2. #define DEV_H
  3. #include "stdint.h"
  4. #include "nic.h"
  5. /* Need to check the packing of this struct if Etherboot is ported */
  6. struct dev_id {
  7. uint16_t vendor_id;
  8. uint16_t device_id;
  9. uint8_t bus_type;
  10. #define PCI_BUS_TYPE 1
  11. #define ISA_BUS_TYPE 2
  12. } __attribute__ ((packed));
  13. /* Dont use sizeof, that will include the padding */
  14. #define DEV_ID_SIZE 8
  15. struct dev {
  16. const char *name;
  17. struct dev_id devid; /* device ID string (sent to DHCP server) */
  18. struct dev_operations *dev_op;
  19. /* All possible device types */
  20. union {
  21. struct nic nic;
  22. };
  23. };
  24. struct dev_operations {
  25. void ( *disable ) ( struct dev * );
  26. int ( *load_configuration ) ( struct dev * );
  27. int ( *load ) ( struct dev * );
  28. };
  29. struct boot_driver {
  30. char *name;
  31. int (*probe) ( struct dev * );
  32. };
  33. #define BOOT_DRIVER( driver_name, probe_func ) \
  34. static struct boot_driver boot_driver \
  35. __attribute__ ((used,__section__(".boot_drivers"))) = { \
  36. .name = driver_name, \
  37. .probe = probe_func, \
  38. };
  39. /* Functions in dev.c */
  40. extern void print_drivers ( void );
  41. extern int probe ( struct dev *dev );
  42. extern void disable ( struct dev *dev );
  43. static inline int load_configuration ( struct dev *dev ) {
  44. return dev->dev_op->load_configuration ( dev );
  45. }
  46. static inline int load ( struct dev *dev ) {
  47. return dev->dev_op->load ( dev );
  48. }
  49. #endif /* DEV_H */