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 1.9KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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. /* to get global "dev" */
  10. struct dev;
  11. #include "main.h"
  12. typedef enum {
  13. DISABLE = 0,
  14. ENABLE,
  15. FORCE
  16. } irq_action_t;
  17. /*
  18. * Structure returned from eth_probe and passed to other driver
  19. * functions.
  20. */
  21. struct nic {
  22. struct nic_operations *nic_op;
  23. int flags; /* driver specific flags */
  24. unsigned char *node_addr;
  25. unsigned char *packet;
  26. unsigned int packetlen;
  27. unsigned int ioaddr;
  28. unsigned char irqno;
  29. void *priv_data; /* driver can hang private data here */
  30. };
  31. struct nic_operations {
  32. int ( *connect ) ( struct nic * );
  33. int ( *poll ) ( struct nic *, int retrieve );
  34. void ( *transmit ) ( struct nic *, const char *,
  35. unsigned int, unsigned int, const char * );
  36. void ( *irq ) ( struct nic *, irq_action_t );
  37. void ( *disable ) ( struct nic * );
  38. };
  39. /*
  40. * Function prototypes
  41. *
  42. */
  43. extern struct nic * nic_device ( struct dev * dev );
  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. #endif /* NIC_H */