]>
git.saurik.com Git - apple/xnu.git/blob - iokit/Drivers/network/drvIntel82557/i82557Inline.h
2 * Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * The contents of this file constitute Original Code as defined in and
7 * are subject to the Apple Public Source License Version 1.1 (the
8 * "License"). You may not use this file except in compliance with the
9 * License. Please obtain a copy of the License at
10 * http://www.apple.com/publicsource and read it before using this file.
12 * This Original Code and all software distributed under the License are
13 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
17 * License for the specific language governing rights and limitations
20 * @APPLE_LICENSE_HEADER_END@
23 #ifndef _I82557INLINE_H
24 #define _I82557INLINE_H
26 #include <libkern/OSByteOrder.h>
27 #include <libkern/OSAtomic.h>
29 //---------------------------------------------------------------------------
32 #define CSR_VALUE(name, x) (((x) & name ## _MASK) >> name ## _SHIFT)
33 #define CSR_FIELD(name, x) (((x) << name ## _SHIFT) & name ## _MASK)
34 #define CSR_MASK(name, x) ((x) << name ## _SHIFT)
35 #define BIT(x) (1 << (x))
37 #define IOSync() OSSynchronizeIO()
39 //---------------------------------------------------------------------------
44 OSReadLE8(volatile void * base
)
46 return *(volatile UInt8
*)base
;
51 OSReadLE16(volatile void * base
)
53 return OSReadLittleInt16(base
, 0);
58 OSReadLE32(volatile void * base
)
60 return OSReadLittleInt32(base
, 0);
65 OSWriteLE8(volatile void * base
, UInt8 data
)
67 *(volatile UInt8
*)base
= data
;
73 OSWriteLE16(volatile void * base
, UInt16 data
)
75 OSWriteLittleInt16(base
, 0, data
);
81 OSWriteLE32(volatile void * base
, UInt32 data
)
83 OSWriteLittleInt32(base
, 0, data
);
87 //---------------------------------------------------------------------------
88 // Set/clear bit(s) macros.
92 OSSetLE##n(volatile void * base, UInt##n bit) \
94 OSWriteLE##n(base, (OSReadLE##n(base) | (bit))); \
99 OSClearLE##n(volatile void * base, UInt##n bit) \
101 OSWriteLE##n(base, (OSReadLE##n(base) & ~(bit))); \
112 #endif /* !_I82557INLINE_H */