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.0KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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. /*
  15. * Structure returned from eth_probe and passed to other driver
  16. * functions.
  17. */
  18. struct nic {
  19. struct nic_operations *nic_op;
  20. int flags; /* driver specific flags */
  21. unsigned char *node_addr;
  22. unsigned char *packet;
  23. unsigned int packetlen;
  24. unsigned int ioaddr;
  25. unsigned char irqno;
  26. void *priv_data; /* driver can hang private data here */
  27. };
  28. struct nic_operations {
  29. int ( *connect ) ( struct nic * );
  30. int ( *poll ) ( struct nic *, int retrieve );
  31. void ( *transmit ) ( struct nic *, const char *,
  32. unsigned int, unsigned int, const char * );
  33. void ( *irq ) ( struct nic *, irq_action_t );
  34. void ( *disable ) ( struct nic * );
  35. };
  36. /*
  37. * Function prototypes
  38. *
  39. */
  40. struct dev;
  41. extern struct nic * nic_device ( struct dev * dev );
  42. extern int dummy_connect ( struct nic *nic );
  43. extern int dummy_irq ( struct nic *nic );
  44. /*
  45. * Functions that implicitly operate on the current boot device
  46. *
  47. * "nic" always points to &dev.nic
  48. */
  49. extern struct nic *nic;
  50. static inline int eth_connect ( void ) {
  51. return nic->nic_op->connect ( nic );
  52. }
  53. static inline int eth_poll ( int retrieve ) {
  54. return nic->nic_op->poll ( nic, retrieve );
  55. }
  56. static inline void eth_transmit ( const char *dest, unsigned int type,
  57. unsigned int size, const void *packet ) {
  58. nic->nic_op->transmit ( nic, dest, type, size, packet );
  59. }
  60. static inline void eth_irq ( irq_action_t action ) {
  61. nic->nic_op->irq ( nic, action );
  62. }
  63. /* Should be using disable() rather than eth_disable() */
  64. static inline void eth_disable ( void ) __attribute__ (( deprecated ));
  65. static inline void eth_disable ( void ) {
  66. nic->nic_op->disable ( nic );
  67. }
  68. /* dev.h needs declarations from nic.h */
  69. #include "dev.h"
  70. /* to get global "dev" */
  71. #include "main.h"
  72. #endif /* NIC_H */