#ifndef _I82557INLINE_H
#define _I82557INLINE_H
#include <libkern/OSByteOrder.h>
#include <libkern/OSAtomic.h>
#define CSR_VALUE(name, x) (((x) & name ## _MASK) >> name ## _SHIFT)
#define CSR_FIELD(name, x) (((x) << name ## _SHIFT) & name ## _MASK)
#define CSR_MASK(name, x) ((x) << name ## _SHIFT)
#define BIT(x) (1 << (x))
#define IOSync() OSSynchronizeIO()
static inline
UInt8
OSReadLE8(volatile void * base)
{
return *(volatile UInt8 *)base;
}
static inline
UInt16
OSReadLE16(volatile void * base)
{
return OSReadLittleInt16(base, 0);
}
static inline
UInt32
OSReadLE32(volatile void * base)
{
return OSReadLittleInt32(base, 0);
}
static inline
void
OSWriteLE8(volatile void * base, UInt8 data)
{
*(volatile UInt8 *)base = data;
IOSync();
}
static inline
void
OSWriteLE16(volatile void * base, UInt16 data)
{
OSWriteLittleInt16(base, 0, data);
IOSync();
}
static inline
void
OSWriteLE32(volatile void * base, UInt32 data)
{
OSWriteLittleInt32(base, 0, data);
IOSync();
}
#define __SET(n) \
static inline void \
OSSetLE##n(volatile void * base, UInt##n bit) \
{ \
OSWriteLE##n(base, (OSReadLE##n(base) | (bit))); \
}
#define __CLR(n) \
static inline void \
OSClearLE##n(volatile void * base, UInt##n bit) \
{ \
OSWriteLE##n(base, (OSReadLE##n(base) & ~(bit))); \
}
__SET(8)
__SET(16)
__SET(32)
__CLR(8)
__CLR(16)
__CLR(32)
#endif