2 * Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_OSREFERENCE_HEADER_START@
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. The rights granted to you under the
10 * License may not be used to create, or enable the creation or
11 * redistribution of, unlawful or unlicensed copies of an Apple operating
12 * system, or to circumvent, violate, or enable the circumvention or
13 * violation of, any terms of an Apple operating system software license
16 * Please obtain a copy of the License at
17 * http://www.opensource.apple.com/apsl/ and read it before using this
20 * The Original Code and all software distributed under the License are
21 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
22 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
23 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
24 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
25 * Please see the License for the specific language governing rights and
26 * limitations under the License.
28 * @APPLE_LICENSE_OSREFERENCE_HEADER_END@
31 #ifndef _IOKIT_IONVRAM_H
32 #define _IOKIT_IONVRAM_H
34 #include <IOKit/IOKitKeys.h>
35 #include <IOKit/IOService.h>
36 #include <IOKit/IODeviceTreeSupport.h>
37 #include <IOKit/nvram/IONVRAMController.h>
40 #define kIODTNVRAMOFPartitionName "common"
41 #define kIODTNVRAMXPRAMPartitionName "APL,MacOS75"
42 #define kIODTNVRAMPanicInfoPartitonName "APL,OSXPanic"
43 #define kIODTNVRAMFreePartitionName "wwwwwwwwwwww"
46 kIODTNVRAMImageSize
= 0x2000,
47 kIODTNVRAMXPRAMSize
= 0x0100,
48 kIODTNVRAMNameRegistrySize
= 0x0400
52 kOFVariableTypeBoolean
= 1,
53 kOFVariableTypeNumber
,
54 kOFVariableTypeString
,
59 kOFVariablePermRootOnly
= 0,
60 kOFVariablePermUserRead
,
61 kOFVariablePermUserWrite
64 class IODTNVRAM
: public IOService
66 OSDeclareDefaultStructors(IODTNVRAM
);
69 IONVRAMController
*_nvramController
;
70 const OSSymbol
*_registryPropertiesKey
;
72 bool _nvramImageDirty
;
73 UInt32 _ofPartitionOffset
;
74 UInt32 _ofPartitionSize
;
77 OSDictionary
*_ofDict
;
78 OSDictionary
*_nvramPartitionOffsets
;
79 OSDictionary
*_nvramPartitionLengths
;
80 UInt32 _xpramPartitionOffset
;
81 UInt32 _xpramPartitionSize
;
83 UInt32 _nrPartitionOffset
;
84 UInt32 _nrPartitionSize
;
86 UInt32 _piPartitionOffset
;
87 UInt32 _piPartitionSize
;
91 virtual UInt8
calculatePartitionChecksum(UInt8
*partitionHeader
);
92 virtual IOReturn
initOFVariables(void);
94 virtual IOReturn
syncOFVariables(void);
96 virtual UInt32
getOFVariableType(const OSSymbol
*propSymbol
) const;
97 virtual UInt32
getOFVariablePerm(const OSSymbol
*propSymbol
) const;
98 virtual bool getOWVariableInfo(UInt32 variableNumber
, const OSSymbol
**propSymbol
,
99 UInt32
*propType
, UInt32
*propOffset
);
100 virtual bool convertPropToObject(UInt8
*propName
, UInt32 propNameLength
,
101 UInt8
*propData
, UInt32 propDataLength
,
102 const OSSymbol
**propSymbol
,
103 OSObject
**propObject
);
104 virtual bool convertObjectToProp(UInt8
*buffer
, UInt32
*length
,
105 const OSSymbol
*propSymbol
, OSObject
*propObject
);
106 virtual UInt16
generateOWChecksum(UInt8
*buffer
);
107 virtual bool validateOWChecksum(UInt8
*buffer
);
108 virtual void updateOWBootArgs(const OSSymbol
*key
, OSObject
*value
);
109 virtual bool searchNVRAMProperty(struct IONVRAMDescriptor
*hdr
,
112 virtual IOReturn
readNVRAMPropertyType0(IORegistryEntry
*entry
,
113 const OSSymbol
**name
,
115 virtual IOReturn
writeNVRAMPropertyType0(IORegistryEntry
*entry
,
116 const OSSymbol
*name
,
119 virtual OSData
*unescapeBytesToData(const UInt8
*bytes
, UInt32 length
);
120 virtual OSData
*escapeDataToData(OSData
* value
);
122 virtual IOReturn
readNVRAMPropertyType1(IORegistryEntry
*entry
,
123 const OSSymbol
**name
,
125 virtual IOReturn
writeNVRAMPropertyType1(IORegistryEntry
*entry
,
126 const OSSymbol
*name
,
130 virtual bool init(IORegistryEntry
*old
, const IORegistryPlane
*plane
);
132 virtual void registerNVRAMController(IONVRAMController
*nvram
);
134 virtual void sync(void);
136 virtual bool serializeProperties(OSSerialize
*s
) const;
137 virtual OSObject
*getProperty(const OSSymbol
*aKey
) const;
138 virtual OSObject
*getProperty(const char *aKey
) const;
139 virtual bool setProperty(const OSSymbol
*aKey
, OSObject
*anObject
);
140 virtual void removeProperty(const OSSymbol
*aKey
);
141 virtual IOReturn
setProperties(OSObject
*properties
);
143 virtual IOReturn
readXPRAM(IOByteCount offset
, UInt8
*buffer
,
145 virtual IOReturn
writeXPRAM(IOByteCount offset
, UInt8
*buffer
,
148 virtual IOReturn
readNVRAMProperty(IORegistryEntry
*entry
,
149 const OSSymbol
**name
,
151 virtual IOReturn
writeNVRAMProperty(IORegistryEntry
*entry
,
152 const OSSymbol
*name
,
155 virtual OSDictionary
*getNVRAMPartitions(void);
157 virtual IOReturn
readNVRAMPartition(const OSSymbol
*partitionID
,
158 IOByteCount offset
, UInt8
*buffer
,
161 virtual IOReturn
writeNVRAMPartition(const OSSymbol
*partitionID
,
162 IOByteCount offset
, UInt8
*buffer
,
165 virtual IOByteCount
savePanicInfo(UInt8
*buffer
, IOByteCount length
);
168 #endif /* !_IOKIT_IONVRAM_H */