1/*
2 * Copyright (c) 2000-2008 Apple Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
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.
11 *
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
18 * under the License.
19 *
20 * @APPLE_LICENSE_HEADER_END@
21 */
22
23#if defined( __i386__ ) || defined( __x86_64__ )
24
25#include <IOKit/IOTypes.h>
26#include <architecture/i386/pio.h>  // x86 IN/OUT inline asm
27#include "IOATARegI386.h"
28
29OSDefineMetaClassAndAbstractStructors( IOATAReg8,  OSObject )
30OSDefineMetaClassAndAbstractStructors( IOATAReg16, OSObject )
31OSDefineMetaClassAndAbstractStructors( IOATAReg32, OSObject )
32
33OSDefineMetaClassAndStructors( IOATAIOReg8,  IOATAReg8  )
34OSDefineMetaClassAndStructors( IOATAIOReg16, IOATAReg16 )
35OSDefineMetaClassAndStructors( IOATAIOReg32, IOATAReg32 )
36
37#define ImplementIOATAIOReg(w, s)                             \
38IOATAIOReg##w * IOATAIOReg##w::withAddress( UInt16 address )  \
39{                                                             \
40    IOATAIOReg##w * reg = new IOATAIOReg##w;                  \
41                                                              \
42    if ( reg && !reg->initWithAddress(address) )              \
43    {                                                         \
44        reg->release();                                       \
45        reg = 0;                                              \
46    }                                                         \
47    return reg;                                               \
48}                                                             \
49                                                              \
50bool IOATAIOReg##w::initWithAddress( UInt16 address )         \
51{                                                             \
52    if ( IOATAReg##w::init() == false ) return false;         \
53    _address = address;                                       \
54    return true;                                              \
55}                                                             \
56                                                              \
57UInt16 IOATAIOReg##w::getAddress() const                      \
58{                                                             \
59    return _address;                                          \
60}                                                             \
61                                                              \
62void IOATAIOReg##w::operator = (UInt##w rhs)                  \
63{                                                             \
64    out##s(_address, rhs);                                    \
65}                                                             \
66                                                              \
67IOATAIOReg##w::operator UInt##w() const                       \
68{                                                             \
69    return in##s(_address);                                   \
70}
71
72ImplementIOATAIOReg( 8,  b )
73ImplementIOATAIOReg( 16, w )
74ImplementIOATAIOReg( 32, l )
75
76#endif /* __i386__ || __x86_64__ */
77