etherif.h 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. enum {
  2. MaxEther = 24,
  3. Ntypes = 8,
  4. };
  5. typedef struct Ether Ether;
  6. struct Ether {
  7. ISAConf; /* hardware info */
  8. int ctlrno;
  9. int tbdf; /* type+busno+devno+funcno */
  10. int minmtu;
  11. int maxmtu;
  12. uchar ea[Eaddrlen];
  13. void (*attach)(Ether*); /* filled in by reset routine */
  14. void (*detach)(Ether*); /* NEW, from ../pc */
  15. void (*transmit)(Ether*);
  16. void (*interrupt)(Ureg*, void*);
  17. long (*ifstat)(Ether*, void*, long, ulong);
  18. long (*ctl)(Ether*, void*, long); /* custom ctl messages */
  19. /* START NEW, from ../pc */
  20. void (*power)(Ether*, int); /* power on/off */
  21. void (*shutdown)(Ether*); /* shutdown hardware before reboot */
  22. /* END NEW */
  23. void *ctlr;
  24. Queue* oq;
  25. Netif;
  26. };
  27. extern Block* etheriq(Ether*, Block*, int);
  28. extern void addethercard(char*, int(*)(Ether*));
  29. extern ulong ethercrc(uchar*, int);
  30. extern int parseether(uchar*, char*);
  31. #define NEXT(x, l) (((x)+1)%(l))
  32. #define PREV(x, l) (((x) == 0) ? (l)-1: (x)-1)
  33. #define HOWMANY(x, y) (((x)+((y)-1))/(y))
  34. #define ROUNDUP(x, y) (HOWMANY((x), (y))*(y))