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

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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. #include "dev.h"
  10. #include "byteswap.h"
  11. #include "dhcp.h"
  12. typedef enum {
  13. DISABLE = 0,
  14. ENABLE,
  15. FORCE
  16. } irq_action_t;
  17. typedef enum duplex {
  18. HALF_DUPLEX = 1,
  19. FULL_DUPLEX
  20. } duplex_t;
  21. /*
  22. * Structure returned from eth_probe and passed to other driver
  23. * functions.
  24. */
  25. struct nic {
  26. struct nic_operations *nic_op;
  27. int flags; /* driver specific flags */
  28. unsigned char *node_addr;
  29. unsigned char *packet;
  30. unsigned int packetlen;
  31. unsigned int ioaddr;
  32. unsigned char irqno;
  33. unsigned int mbps;
  34. duplex_t duplex;
  35. struct dhcp_dev_id dhcp_dev_id;
  36. void *priv_data; /* driver private data */
  37. };
  38. struct nic_operations {
  39. int ( *connect ) ( struct nic * );
  40. int ( *poll ) ( struct nic *, int retrieve );
  41. void ( *transmit ) ( struct nic *, const char *,
  42. unsigned int, unsigned int, const char * );
  43. void ( *irq ) ( struct nic *, irq_action_t );
  44. };
  45. extern struct type_driver nic_driver;
  46. /*
  47. * Function prototypes
  48. *
  49. */
  50. extern int dummy_connect ( struct nic *nic );
  51. extern void dummy_irq ( struct nic *nic, irq_action_t irq_action );
  52. extern void nic_disable ( struct nic *nic );
  53. /*
  54. * Functions that implicitly operate on the current boot device
  55. *
  56. */
  57. extern struct nic nic;
  58. static inline int eth_connect ( void ) {
  59. return nic.nic_op->connect ( &nic );
  60. }
  61. static inline int eth_poll ( int retrieve ) {
  62. return nic.nic_op->poll ( &nic, retrieve );
  63. }
  64. static inline void eth_transmit ( const char *dest, unsigned int type,
  65. unsigned int size, const void *packet ) {
  66. nic.nic_op->transmit ( &nic, dest, type, size, packet );
  67. }
  68. static inline void eth_irq ( irq_action_t action ) {
  69. nic.nic_op->irq ( &nic, action );
  70. }
  71. /* Should be using disable() rather than eth_disable() */
  72. extern void eth_disable ( void ) __attribute__ (( deprecated ));
  73. #endif /* NIC_H */