etherif.h 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  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 mbps; /* Mbps */
  11. int minmtu;
  12. int maxmtu;
  13. uchar ea[Eaddrlen];
  14. void (*attach)(Ether*); /* filled in by reset routine */
  15. void (*detach)(Ether*); /* NEW, from ../pc */
  16. void (*transmit)(Ether*);
  17. void (*interrupt)(Ureg*, void*);
  18. long (*ifstat)(Ether*, void*, long, ulong);
  19. long (*ctl)(Ether*, void*, long); /* custom ctl messages */
  20. /* START NEW, from ../pc */
  21. void (*power)(Ether*, int); /* power on/off */
  22. void (*shutdown)(Ether*); /* shutdown hardware before reboot */
  23. /* END NEW */
  24. void *ctlr;
  25. Queue* oq;
  26. Netif;
  27. };
  28. extern Block* etheriq(Ether*, Block*, int);
  29. extern void addethercard(char*, int(*)(Ether*));
  30. extern ulong ethercrc(uchar*, int);
  31. extern int parseether(uchar*, char*);
  32. #define NEXT(x, l) (((x)+1)%(l))
  33. #define PREV(x, l) (((x) == 0) ? (l)-1: (x)-1)
  34. #define HOWMANY(x, y) (((x)+((y)-1))/(y))
  35. #define ROUNDUP(x, y) (HOWMANY((x), (y))*(y))