2 * Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
8 * This file contains Original Code and/or Modifications of Original Code
9 * as defined in and that are subject to the Apple Public Source License
10 * Version 2.0 (the 'License'). You may not use this file except in
11 * compliance with the License. Please obtain a copy of the License at
12 * http://www.opensource.apple.com/apsl/ and read it before using this
15 * The Original Code and all software distributed under the License are
16 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
17 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
18 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
20 * Please see the License for the specific language governing rights and
21 * limitations under the License.
23 * @APPLE_LICENSE_HEADER_END@
26 #ifndef _IOKIT_IONVRAM_H
27 #define _IOKIT_IONVRAM_H
29 #include <IOKit/IOService.h>
30 #include <IOKit/IODeviceTreeSupport.h>
31 #include <IOKit/nvram/IONVRAMController.h>
34 #define kIODTNVRAMOFPartitionName "common"
35 #define kIODTNVRAMXPRAMPartitionName "APL,MacOS75"
36 #define kIODTNVRAMPanicInfoPartitonName "APL,OSXPanic"
37 #define kIODTNVRAMFreePartitionName "wwwwwwwwwwww"
39 #define kIODTNVRAMPanicInfoKey "aapl,panic-info"
42 kIODTNVRAMImageSize
= 0x2000,
43 kIODTNVRAMXPRAMSize
= 0x0100,
44 kIODTNVRAMNameRegistrySize
= 0x0400
48 kOFVariableTypeBoolean
= 1,
49 kOFVariableTypeNumber
,
50 kOFVariableTypeString
,
55 kOFVariablePermRootOnly
= 0,
56 kOFVariablePermUserRead
,
57 kOFVariablePermUserWrite
60 class IODTNVRAM
: public IOService
62 OSDeclareDefaultStructors(IODTNVRAM
);
65 IONVRAMController
*_nvramController
;
66 const OSSymbol
*_registryPropertiesKey
;
68 bool _nvramImageDirty
;
69 UInt32 _ofPartitionOffset
;
70 UInt32 _ofPartitionSize
;
73 OSDictionary
*_ofDict
;
74 OSDictionary
*_nvramPartitionOffsets
;
75 OSDictionary
*_nvramPartitionLengths
;
76 UInt32 _xpramPartitionOffset
;
77 UInt32 _xpramPartitionSize
;
79 UInt32 _nrPartitionOffset
;
80 UInt32 _nrPartitionSize
;
82 UInt32 _piPartitionOffset
;
83 UInt32 _piPartitionSize
;
87 virtual UInt8
calculatePartitionChecksum(UInt8
*partitionHeader
);
88 virtual IOReturn
initOFVariables(void);
89 virtual IOReturn
syncOFVariables(void);
90 virtual UInt32
getOFVariableType(const OSSymbol
*propSymbol
) const;
91 virtual UInt32
getOFVariablePerm(const OSSymbol
*propSymbol
) const;
92 virtual bool getOWVariableInfo(UInt32 variableNumber
, const OSSymbol
**propSymbol
,
93 UInt32
*propType
, UInt32
*propOffset
);
94 virtual bool convertPropToObject(UInt8
*propName
, UInt32 propNameLength
,
95 UInt8
*propData
, UInt32 propDataLength
,
96 const OSSymbol
**propSymbol
,
97 OSObject
**propObject
);
98 virtual bool convertObjectToProp(UInt8
*buffer
, UInt32
*length
,
99 const OSSymbol
*propSymbol
, OSObject
*propObject
);
100 virtual UInt16
generateOWChecksum(UInt8
*buffer
);
101 virtual bool validateOWChecksum(UInt8
*buffer
);
102 virtual void updateOWBootArgs(const OSSymbol
*key
, OSObject
*value
);
103 virtual bool searchNVRAMProperty(struct IONVRAMDescriptor
*hdr
,
106 virtual IOReturn
readNVRAMPropertyType0(IORegistryEntry
*entry
,
107 const OSSymbol
**name
,
109 virtual IOReturn
writeNVRAMPropertyType0(IORegistryEntry
*entry
,
110 const OSSymbol
*name
,
113 virtual OSData
*unescapeBytesToData(UInt8
*bytes
, UInt32 length
);
114 virtual OSData
*escapeDataToData(OSData
* value
);
116 virtual IOReturn
readNVRAMPropertyType1(IORegistryEntry
*entry
,
117 const OSSymbol
**name
,
119 virtual IOReturn
writeNVRAMPropertyType1(IORegistryEntry
*entry
,
120 const OSSymbol
*name
,
124 virtual bool init(IORegistryEntry
*old
, const IORegistryPlane
*plane
);
126 virtual void registerNVRAMController(IONVRAMController
*nvram
);
128 virtual void sync(void);
130 virtual bool serializeProperties(OSSerialize
* serialize
) const;
131 virtual OSObject
*getProperty(const OSSymbol
*aKey
) const;
132 virtual OSObject
*getProperty(const char *aKey
) const;
133 virtual bool setProperty(const OSSymbol
*aKey
, OSObject
*anObject
);
134 virtual IOReturn
setProperties(OSObject
*properties
);
136 virtual IOReturn
readXPRAM(IOByteCount offset
, UInt8
*buffer
,
138 virtual IOReturn
writeXPRAM(IOByteCount offset
, UInt8
*buffer
,
141 virtual IOReturn
readNVRAMProperty(IORegistryEntry
*entry
,
142 const OSSymbol
**name
,
144 virtual IOReturn
writeNVRAMProperty(IORegistryEntry
*entry
,
145 const OSSymbol
*name
,
148 virtual OSDictionary
*getNVRAMPartitions(void);
150 virtual IOReturn
readNVRAMPartition(const OSSymbol
*partitionID
,
151 IOByteCount offset
, UInt8
*buffer
,
154 virtual IOReturn
writeNVRAMPartition(const OSSymbol
*partitionID
,
155 IOByteCount offset
, UInt8
*buffer
,
158 virtual IOByteCount
savePanicInfo(UInt8
*buffer
, IOByteCount length
);
161 #endif /* !_IOKIT_IONVRAM_H */