compat.h 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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 ROUND(s, sz) (((s)+((sz)-1))&~((sz)-1))
  19. #define Block Msgbuf
  20. #define rp data /* Block member → Msgbuf member */
  21. #define Etherpkt Enpkt
  22. #define Eaddrlen Easize
  23. #define ETHERHDRSIZE Ensize
  24. #ifndef CACHELINESZ
  25. #define CACHELINESZ 32 /* pentium & later */
  26. #endif
  27. #define KNAMELEN NAMELEN
  28. #define READSTR 128
  29. #define KADDR(a) ((void*)((ulong)(a)|KZERO))
  30. #define PCIWINDOW 0
  31. #define PCIWADDR(va) (PADDR(va)+PCIWINDOW)
  32. #define iprint print
  33. /* buffers */
  34. #define allocb(sz) mballoc((sz), 0, Maeth1)
  35. #define iallocb(sz) mballoc((sz), 0, Mbeth1)
  36. /* other memory */
  37. #define malloc(sz) ialloc((sz), 0)
  38. #define xspanalloc(sz, align, span) ialloc((sz)+(align)+(span), (align))
  39. /* offset==0 in all uses in fs */
  40. #define mallocalign(sz, align, offset, span) \
  41. ialloc((sz)+(align)+(span), (align))
  42. /* sleazy hacks; really need better allocators */
  43. #define xalloc(sz) malloc(sz)
  44. #define xfree(p)
  45. #define smalloc(sz) malloc(sz)
  46. #define waserror() 0
  47. #define poperror()
  48. #define nexterror() return
  49. #define error(x) goto err
  50. #define qsetlimit(q, lim)
  51. #define ioalloc(a, b, c, d) 0
  52. #define iofree(p)
  53. #define strtol strtoul
  54. #define PROCARG(arg)
  55. #define GETARG(arg) getarg()
  56. #define vmap(bar, size) upamalloc(bar, size, 0)
  57. /* see portdat.h for Msgbuf flags */
  58. void freeb(Block *b);
  59. void freeblist(Block *b);
  60. void free(void *p);
  61. void *mallocz(ulong sz, int clr);
  62. char *strdup(char *); /* port/config.c */
  63. void kstrdup(char **p, char *s);
  64. /* header files mysteriously fail to declare this */
  65. ulong upamalloc(ulong addr, int size, int align);
  66. int readstr(vlong, void *, int, char *);
  67. void addethercard(char *, int (*)(struct Ether *));
  68. void kproc(char *text, void (*f)(void), void *arg);
  69. /* pc-specific? */
  70. int intrdisable(int irq, void (*f)(Ureg *, void *), void *a, int, char *);
  71. void intrenable(int irq, void (*f)(Ureg*, void*), void* a, int, char *name);