utility.c 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. #include "fs.h"
  2. #include "buf.h"
  3. #include "inode.h"
  4. #include "super.h"
  5. /*===========================================================================*
  6. * conv2 *
  7. *===========================================================================*/
  8. unsigned conv2(norm, w)
  9. int norm; /* TRUE if no swap, FALSE for byte swap */
  10. int w; /* promotion of 16-bit word to be swapped */
  11. {
  12. /* Possibly swap a 16-bit word between 8086 and 68000 byte order. */
  13. if (norm) return( (unsigned) w & 0xFFFF);
  14. return( ((w&BYTE) << 8) | ( (w>>8) & BYTE));
  15. }
  16. /*===========================================================================*
  17. * conv4 *
  18. *===========================================================================*/
  19. long conv4(norm, x)
  20. int norm; /* TRUE if no swap, FALSE for byte swap */
  21. long x; /* 32-bit long to be byte swapped */
  22. {
  23. /* Possibly swap a 32-bit long between 8086 and 68000 byte order. */
  24. unsigned lo, hi;
  25. long l;
  26. if (norm) return(x); /* byte order was already ok */
  27. lo = conv2(FALSE, (int) x & 0xFFFF); /* low-order half, byte swapped */
  28. hi = conv2(FALSE, (int) (x>>16) & 0xFFFF); /* high-order half, swapped */
  29. l = ( (long) lo <<16) | hi;
  30. return(l);
  31. }