2 * Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_OSREFERENCE_LICENSE_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 License
10 * may not be used to create, or enable the creation or redistribution of,
11 * unlawful or unlicensed copies of an Apple operating system, or to
12 * circumvent, violate, or enable the circumvention or violation of, any
13 * terms of an Apple operating system software license agreement.
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
18 * The Original Code and all software distributed under the License are
19 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 * Please see the License for the specific language governing rights and
24 * limitations under the License.
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
29 #ifndef _IOKIT_IONVRAM_H
30 #define _IOKIT_IONVRAM_H
33 #include <IOKit/IOKitKeys.h>
34 #include <IOKit/IOService.h>
35 #include <IOKit/IODeviceTreeSupport.h>
36 #include <IOKit/nvram/IONVRAMController.h>
37 #endif /* __cplusplus */
39 #define kIODTNVRAMOFPartitionName "common"
40 #define kIODTNVRAMXPRAMPartitionName "APL,MacOS75"
41 #define kIODTNVRAMPanicInfoPartitonName "APL,OSXPanic"
42 #define kIODTNVRAMFreePartitionName "wwwwwwwwwwww"
44 #define MIN_SYNC_NOW_INTERVAL 15*60 /* Minimum 15 Minutes interval mandated */
47 kIODTNVRAMImageSize
= 0x2000,
48 kIODTNVRAMXPRAMSize
= 0x0100,
49 kIODTNVRAMNameRegistrySize
= 0x0400
53 kOFVariableTypeBoolean
= 1,
54 kOFVariableTypeNumber
,
55 kOFVariableTypeString
,
60 kOFVariablePermRootOnly
= 0,
61 kOFVariablePermUserRead
,
62 kOFVariablePermUserWrite
,
63 kOFVariablePermKernelOnly
68 class IODTNVRAM
: public IOService
70 OSDeclareDefaultStructors(IODTNVRAM
);
73 IONVRAMController
*_nvramController
;
74 const OSSymbol
*_registryPropertiesKey
;
76 bool _nvramImageDirty
;
77 UInt32 _ofPartitionOffset
;
78 UInt32 _ofPartitionSize
;
81 OSDictionary
*_ofDict
;
82 OSDictionary
*_nvramPartitionOffsets
;
83 OSDictionary
*_nvramPartitionLengths
;
84 UInt32 _xpramPartitionOffset
;
85 UInt32 _xpramPartitionSize
;
87 UInt32 _nrPartitionOffset
;
88 UInt32 _nrPartitionSize
;
90 UInt32 _piPartitionOffset
;
91 UInt32 _piPartitionSize
;
94 SInt32 _lastDeviceSync
;
97 virtual UInt8
calculatePartitionChecksum(UInt8
*partitionHeader
);
98 virtual IOReturn
initOFVariables(void);
100 virtual IOReturn
syncOFVariables(void);
102 virtual UInt32
getOFVariableType(const OSSymbol
*propSymbol
) const;
103 virtual UInt32
getOFVariablePerm(const OSSymbol
*propSymbol
) const;
104 virtual bool getOWVariableInfo(UInt32 variableNumber
, const OSSymbol
**propSymbol
,
105 UInt32
*propType
, UInt32
*propOffset
);
106 virtual bool convertPropToObject(UInt8
*propName
, UInt32 propNameLength
,
107 UInt8
*propData
, UInt32 propDataLength
,
108 const OSSymbol
**propSymbol
,
109 OSObject
**propObject
);
110 virtual bool convertObjectToProp(UInt8
*buffer
, UInt32
*length
,
111 const OSSymbol
*propSymbol
, OSObject
*propObject
);
112 virtual UInt16
generateOWChecksum(UInt8
*buffer
);
113 virtual bool validateOWChecksum(UInt8
*buffer
);
114 virtual void updateOWBootArgs(const OSSymbol
*key
, OSObject
*value
);
115 virtual bool searchNVRAMProperty(struct IONVRAMDescriptor
*hdr
,
118 virtual IOReturn
readNVRAMPropertyType0(IORegistryEntry
*entry
,
119 const OSSymbol
**name
,
121 virtual IOReturn
writeNVRAMPropertyType0(IORegistryEntry
*entry
,
122 const OSSymbol
*name
,
125 virtual OSData
*unescapeBytesToData(const UInt8
*bytes
, UInt32 length
);
126 virtual OSData
*escapeDataToData(OSData
* value
);
128 virtual IOReturn
readNVRAMPropertyType1(IORegistryEntry
*entry
,
129 const OSSymbol
**name
,
131 virtual IOReturn
writeNVRAMPropertyType1(IORegistryEntry
*entry
,
132 const OSSymbol
*name
,
136 virtual bool init(IORegistryEntry
*old
, const IORegistryPlane
*plane
);
138 virtual void registerNVRAMController(IONVRAMController
*nvram
);
140 virtual void sync(void);
142 virtual bool serializeProperties(OSSerialize
*s
) const;
143 virtual OSObject
*getProperty(const OSSymbol
*aKey
) const;
144 virtual OSObject
*getProperty(const char *aKey
) const;
145 virtual bool setProperty(const OSSymbol
*aKey
, OSObject
*anObject
);
146 virtual void removeProperty(const OSSymbol
*aKey
);
147 virtual IOReturn
setProperties(OSObject
*properties
);
149 virtual IOReturn
readXPRAM(IOByteCount offset
, UInt8
*buffer
,
151 virtual IOReturn
writeXPRAM(IOByteCount offset
, UInt8
*buffer
,
154 virtual IOReturn
readNVRAMProperty(IORegistryEntry
*entry
,
155 const OSSymbol
**name
,
157 virtual IOReturn
writeNVRAMProperty(IORegistryEntry
*entry
,
158 const OSSymbol
*name
,
161 virtual OSDictionary
*getNVRAMPartitions(void);
163 virtual IOReturn
readNVRAMPartition(const OSSymbol
*partitionID
,
164 IOByteCount offset
, UInt8
*buffer
,
167 virtual IOReturn
writeNVRAMPartition(const OSSymbol
*partitionID
,
168 IOByteCount offset
, UInt8
*buffer
,
171 virtual IOByteCount
savePanicInfo(UInt8
*buffer
, IOByteCount length
);
172 virtual bool safeToSync(void);
175 #endif /* __cplusplus */
177 #endif /* !_IOKIT_IONVRAM_H */