1/*
2 * Copyright (c) 1998-2000 Apple Computer, 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
24#ifndef __IONDRV__
25#define __IONDRV__
26
27#include <IOKit/IORegistryEntry.h>
28#include <IOKit/IOInterruptEventSource.h>
29
30#include <IOKit/ndrvsupport/IOMacOSTypes.h>
31#include <IOKit/ndrvsupport/IONDRVSupport.h>
32
33/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
34
35#ifndef kAAPLRegEntryIDKey
36#define kAAPLRegEntryIDKey      "AAPL,RegEntryID"
37#endif
38
39#ifndef kAAPLDisableMSIKey
40#define kAAPLDisableMSIKey      "AAPL,DisableMSI"
41#endif
42
43#define MAKE_REG_ENTRY(regEntryID, obj)                          	   \
44        (regEntryID)->opaque[0] = (void *) (((uintptr_t)obj)  - ((uintptr_t)gIOFramebufferKey)); \
45        (regEntryID)->opaque[1] = (void *) ~(((uintptr_t)obj) - ((uintptr_t)gIOFramebufferKey)); \
46        (regEntryID)->opaque[2] = (void *) 0x53696d65;                  \
47        (regEntryID)->opaque[3] = (void *) 0x52756c7a;
48
49#define REG_ENTRY_TO_OBJ_RET(regEntryID, obj, ret)                      \
50        uintptr_t __obj;												\
51        if ((__obj = ((uintptr_t *)regEntryID)[0])  			        \
52             != ~((uintptr_t *)regEntryID)[1])        	return (ret);	\
53        obj = (IORegistryEntry *)(__obj + (uintptr_t)gIOFramebufferKey);
54
55#define REG_ENTRY_TO_OBJ(regEntryID, obj) 	REG_ENTRY_TO_OBJ_RET((regEntryID), (obj), -2538)
56
57#define REG_ENTRY_TO_PT(regEntryID,obj)                                 \
58        IORegistryEntry * obj;                                          \
59		REG_ENTRY_TO_OBJ_RET((regEntryID), (obj), -2538)
60
61#define REG_ENTRY_TO_SERVICE(regEntryID, type, obj)                     \
62        IORegistryEntry * regEntry;                                     \
63        type            * obj;                                          \
64		REG_ENTRY_TO_OBJ(regEntryID, regEntry);							\
65        if (0 == (obj = OSDynamicCast(type, regEntry)))                 \
66            return (-2542);
67
68/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
69
70class IONDRV : public OSObject
71{
72    OSDeclareAbstractStructors(IONDRV)
73
74public:
75    virtual IOReturn getSymbol( const char * symbolName,
76                                IOLogicalAddress * address ) = 0;
77
78    virtual const char * driverName( void ) = 0;
79
80    virtual IOReturn doDriverIO( UInt32 commandID, void * contents,
81                                 UInt32 commandCode, UInt32 commandKind ) = 0;
82};
83
84#endif /* __IONDRV__ */
85
86