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