compat.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /*
  2. * fs kernel compatibility hacks for drivers from the cpu/terminal kernel
  3. */
  4. #define ETHERIQ(a, b, c) etheriq((a), (b))
  5. /*
  6. * cpu kernel uses bp->rp to point to start of packet and bp->wp to point
  7. * just past valid data in the packet.
  8. * fs kernel uses bp->data to point to start of packet and bp->data+bp->count
  9. * points just past valid data.
  10. * except beware that mballoc(count, ...) sets bp->count = count(!)
  11. */
  12. #define BLEN(bp) (bp)->count
  13. #define SETWPCNT(bp, cnt) (bp)->count = (cnt)
  14. /* mballoc does: mb->data = mb->xdata+256; */
  15. #define BLKRESET(bp) ((bp)->data = (bp)->xdata +256, (bp)->count = 0)
  16. #define INCRPTR(bp, incr) (bp)->count += (incr)
  17. #define ENDDATA(bp) ((bp)->data + (bp)->count)
  18. #define Block Msgbuf
  19. #define rp data /* Block member → Msgbuf member */
  20. #define Etherpkt Enpkt
  21. #define Eaddrlen Easize
  22. #define KADDR(a) ((void*)((ulong)(a)|KZERO))
  23. #define PCIWINDOW 0
  24. #define PCIWADDR(va) (PADDR(va)+PCIWINDOW)
  25. #define iprint print
  26. #define allocb(sz) mballoc((sz), 0, Maeth1)
  27. #define iallocb(sz) mballoc((sz), 0, Mbeth1)
  28. #define malloc(sz) ialloc((sz), 0)
  29. #define xspanalloc(sz, align, span) ialloc((sz)+(align)+(span), (align))
  30. #define waserror() 0
  31. #define poperror()
  32. #define nexterror() return
  33. #define error(x) goto err
  34. #define qsetlimit(q, lim)
  35. #define ioalloc(a, b, c, d) 0
  36. #define strtol strtoul
  37. #define kproc(name, f, arg) userinit(f, arg, name)
  38. /* see portdat.h for Msgbuf flags */
  39. void freeb(Block *b);
  40. void freeblist(Block *b);
  41. void free(void *p);
  42. void *mallocz(ulong sz, int clr);
  43. /* header files mysteriously fail to declare this */
  44. ulong upamalloc(ulong addr, int size, int align);