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 _IOKIT_IONVRAM_H
24 #define _IOKIT_IONVRAM_H
26 #include <IOKit/IOService.h>
27 #include <IOKit/IODeviceTreeSupport.h>
28 #include <IOKit/nvram/IONVRAMController.h>
31 kIODTNVRAMImageSize
= 0x2000,
32 kIODTNVRAMXPRAMSize
= 0x0100,
33 kIODTNVRAMNameRegistrySize
= 0x0400
37 kOFVariableTypeBoolean
= 1,
38 kOFVariableTypeNumber
,
39 kOFVariableTypeString
,
44 kOFVariablePermRootOnly
= 0,
45 kOFVariablePermUserRead
,
46 kOFVariablePermUserWrite
49 class IODTNVRAM
: public IOService
51 OSDeclareDefaultStructors(IODTNVRAM
);
54 IONVRAMController
*_nvramController
;
55 const OSSymbol
*_registryPropertiesKey
;
57 bool _nvramImageDirty
;
58 UInt32 _ofPartitionOffset
;
59 UInt32 _ofPartitionSize
;
62 OSDictionary
*_ofDict
;
63 UInt32 _xpramPartitionOffset
;
64 UInt32 _xpramPartitionSize
;
66 UInt32 _nrPartitionOffset
;
67 UInt32 _nrPartitionSize
;
70 virtual IOReturn
initOFVariables(void);
71 virtual IOReturn
syncOFVariables(void);
72 virtual UInt32
getOFVariableType(const OSSymbol
*propSymbol
) const;
73 virtual UInt32
getOFVariablePerm(const OSSymbol
*propSymbol
) const;
74 virtual bool getOWVariableInfo(UInt32 variableNumber
, const OSSymbol
**propSymbol
,
75 UInt32
*propType
, UInt32
*propOffset
);
76 virtual bool convertPropToObject(UInt8
*propName
, UInt32 propNameLength
,
77 UInt8
*propData
, UInt32 propDataLength
,
78 const OSSymbol
**propSymbol
,
79 OSObject
**propObject
);
80 virtual bool convertObjectToProp(UInt8
*buffer
, UInt32
*length
,
81 const OSSymbol
*propSymbol
, OSObject
*propObject
);
82 virtual UInt16
generateOWChecksum(UInt8
*buffer
);
83 virtual bool validateOWChecksum(UInt8
*buffer
);
84 virtual void updateOWBootArgs(const OSSymbol
*key
, OSObject
*value
);
85 virtual bool searchNVRAMProperty(struct IONVRAMDescriptor
*hdr
,
88 virtual IOReturn
readNVRAMPropertyType0(IORegistryEntry
*entry
,
89 const OSSymbol
**name
,
91 virtual IOReturn
writeNVRAMPropertyType0(IORegistryEntry
*entry
,
95 virtual OSData
*unescapeBytesToData(UInt8
*bytes
, UInt32 length
);
96 virtual OSData
*escapeDataToData(OSData
* value
);
98 virtual IOReturn
readNVRAMPropertyType1(IORegistryEntry
*entry
,
99 const OSSymbol
**name
,
101 virtual IOReturn
writeNVRAMPropertyType1(IORegistryEntry
*entry
,
102 const OSSymbol
*name
,
106 virtual bool init(IORegistryEntry
*old
, const IORegistryPlane
*plane
);
108 virtual void registerNVRAMController(IONVRAMController
*nvram
);
110 virtual void sync(void);
112 virtual bool serializeProperties(OSSerialize
* serialize
) const;
113 virtual OSObject
*getProperty(const OSSymbol
*aKey
) const;
114 virtual OSObject
*getProperty(const char *aKey
) const;
115 virtual bool setProperty(const OSSymbol
*aKey
, OSObject
*anObject
);
116 virtual IOReturn
setProperties(OSObject
*properties
);
118 virtual IOReturn
readXPRAM(IOByteCount offset
, UInt8
*buffer
,
120 virtual IOReturn
writeXPRAM(IOByteCount offset
, UInt8
*buffer
,
123 virtual IOReturn
readNVRAMProperty(IORegistryEntry
*entry
,
124 const OSSymbol
**name
,
126 virtual IOReturn
writeNVRAMProperty(IORegistryEntry
*entry
,
127 const OSSymbol
*name
,
131 #endif /* !_IOKIT_IONVRAM_H */