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.

nic.h 2.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /*
  2. * This program is free software; you can redistribute it and/or
  3. * modify it under the terms of the GNU General Public License as
  4. * published by the Free Software Foundation; either version 2, or (at
  5. * your option) any later version.
  6. */
  7. #ifndef NIC_H
  8. #define NIC_H
  9. typedef enum {
  10. DISABLE = 0,
  11. ENABLE,
  12. FORCE
  13. } irq_action_t;
  14. typedef enum duplex {
  15. HALF_DUPLEX = 1,
  16. FULL_DUPLEX
  17. } duplex_t;
  18. /*
  19. * Structure returned from eth_probe and passed to other driver
  20. * functions.
  21. */
  22. struct nic {
  23. struct nic_operations *nic_op;
  24. int flags; /* driver specific flags */
  25. unsigned char *node_addr;
  26. unsigned char *packet;
  27. unsigned int packetlen;
  28. unsigned int ioaddr;
  29. unsigned char irqno;
  30. unsigned int mbps;
  31. duplex_t duplex;
  32. void *priv_data; /* driver can hang private data here */
  33. };
  34. struct nic_operations {
  35. int ( *connect ) ( struct nic * );
  36. int ( *poll ) ( struct nic *, int retrieve );
  37. void ( *transmit ) ( struct nic *, const char *,
  38. unsigned int, unsigned int, const char * );
  39. void ( *irq ) ( struct nic *, irq_action_t );
  40. void ( *disable ) ( struct nic * );
  41. };
  42. /*
  43. * Function prototypes
  44. *
  45. */
  46. struct dev;
  47. extern struct nic * nic_device ( struct dev * dev );
  48. extern int dummy_connect ( struct nic *nic );
  49. extern void dummy_irq ( struct nic *nic, irq_action_t irq_action );
  50. /*
  51. * Functions that implicitly operate on the current boot device
  52. *
  53. * "nic" always points to &dev.nic
  54. */
  55. extern struct nic *nic;
  56. static inline int eth_connect ( void ) {
  57. return nic->nic_op->connect ( nic );
  58. }
  59. static inline int eth_poll ( int retrieve ) {
  60. return nic->nic_op->poll ( nic, retrieve );
  61. }
  62. static inline void eth_transmit ( const char *dest, unsigned int type,
  63. unsigned int size, const void *packet ) {
  64. nic->nic_op->transmit ( nic, dest, type, size, packet );
  65. }
  66. static inline void eth_irq ( irq_action_t action ) {
  67. nic->nic_op->irq ( nic, action );
  68. }
  69. /* Should be using disable() rather than eth_disable() */
  70. static inline void eth_disable ( void ) __attribute__ (( deprecated ));
  71. static inline void eth_disable ( void ) {
  72. nic->nic_op->disable ( nic );
  73. }
  74. /* dev.h needs declarations from nic.h */
  75. #include "dev.h"
  76. /* to get global "dev" */
  77. #include "main.h"
  78. #endif /* NIC_H */