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 #define kIODTNVRAMOFPartitionName "common"
32 #define kIODTNVRAMXPRAMPartitionName "APL,MacOS75"
33 #define kIODTNVRAMPanicInfoPartitonName "APL,OSXPanic"
34 #define kIODTNVRAMFreePartitionName "wwwwwwwwwwww"
36 #define kIODTNVRAMPanicInfoKey "aapl,panic-info"
39 kIODTNVRAMImageSize
= 0x2000,
40 kIODTNVRAMXPRAMSize
= 0x0100,
41 kIODTNVRAMNameRegistrySize
= 0x0400
45 kOFVariableTypeBoolean
= 1,
46 kOFVariableTypeNumber
,
47 kOFVariableTypeString
,
52 kOFVariablePermRootOnly
= 0,
53 kOFVariablePermUserRead
,
54 kOFVariablePermUserWrite
57 class IODTNVRAM
: public IOService
59 OSDeclareDefaultStructors(IODTNVRAM
);
62 IONVRAMController
*_nvramController
;
63 const OSSymbol
*_registryPropertiesKey
;
65 bool _nvramImageDirty
;
66 UInt32 _ofPartitionOffset
;
67 UInt32 _ofPartitionSize
;
70 OSDictionary
*_ofDict
;
71 OSDictionary
*_nvramPartitionOffsets
;
72 OSDictionary
*_nvramPartitionLengths
;
73 UInt32 _xpramPartitionOffset
;
74 UInt32 _xpramPartitionSize
;
76 UInt32 _nrPartitionOffset
;
77 UInt32 _nrPartitionSize
;
79 UInt32 _piPartitionOffset
;
80 UInt32 _piPartitionSize
;
84 virtual UInt8
calculatePartitionChecksum(UInt8
*partitionHeader
);
85 virtual IOReturn
initOFVariables(void);
86 virtual IOReturn
syncOFVariables(void);
87 virtual UInt32
getOFVariableType(const OSSymbol
*propSymbol
) const;
88 virtual UInt32
getOFVariablePerm(const OSSymbol
*propSymbol
) const;
89 virtual bool getOWVariableInfo(UInt32 variableNumber
, const OSSymbol
**propSymbol
,
90 UInt32
*propType
, UInt32
*propOffset
);
91 virtual bool convertPropToObject(UInt8
*propName
, UInt32 propNameLength
,
92 UInt8
*propData
, UInt32 propDataLength
,
93 const OSSymbol
**propSymbol
,
94 OSObject
**propObject
);
95 virtual bool convertObjectToProp(UInt8
*buffer
, UInt32
*length
,
96 const OSSymbol
*propSymbol
, OSObject
*propObject
);
97 virtual UInt16
generateOWChecksum(UInt8
*buffer
);
98 virtual bool validateOWChecksum(UInt8
*buffer
);
99 virtual void updateOWBootArgs(const OSSymbol
*key
, OSObject
*value
);
100 virtual bool searchNVRAMProperty(struct IONVRAMDescriptor
*hdr
,
103 virtual IOReturn
readNVRAMPropertyType0(IORegistryEntry
*entry
,
104 const OSSymbol
**name
,
106 virtual IOReturn
writeNVRAMPropertyType0(IORegistryEntry
*entry
,
107 const OSSymbol
*name
,
110 virtual OSData
*unescapeBytesToData(UInt8
*bytes
, UInt32 length
);
111 virtual OSData
*escapeDataToData(OSData
* value
);
113 virtual IOReturn
readNVRAMPropertyType1(IORegistryEntry
*entry
,
114 const OSSymbol
**name
,
116 virtual IOReturn
writeNVRAMPropertyType1(IORegistryEntry
*entry
,
117 const OSSymbol
*name
,
121 virtual bool init(IORegistryEntry
*old
, const IORegistryPlane
*plane
);
123 virtual void registerNVRAMController(IONVRAMController
*nvram
);
125 virtual void sync(void);
127 virtual bool serializeProperties(OSSerialize
* serialize
) const;
128 virtual OSObject
*getProperty(const OSSymbol
*aKey
) const;
129 virtual OSObject
*getProperty(const char *aKey
) const;
130 virtual bool setProperty(const OSSymbol
*aKey
, OSObject
*anObject
);
131 virtual IOReturn
setProperties(OSObject
*properties
);
133 virtual IOReturn
readXPRAM(IOByteCount offset
, UInt8
*buffer
,
135 virtual IOReturn
writeXPRAM(IOByteCount offset
, UInt8
*buffer
,
138 virtual IOReturn
readNVRAMProperty(IORegistryEntry
*entry
,
139 const OSSymbol
**name
,
141 virtual IOReturn
writeNVRAMProperty(IORegistryEntry
*entry
,
142 const OSSymbol
*name
,
145 virtual OSDictionary
*getNVRAMPartitions(void);
147 virtual IOReturn
readNVRAMPartition(const OSSymbol
*partitionID
,
148 IOByteCount offset
, UInt8
*buffer
,
151 virtual IOReturn
writeNVRAMPartition(const OSSymbol
*partitionID
,
152 IOByteCount offset
, UInt8
*buffer
,
155 virtual IOByteCount
savePanicInfo(UInt8
*buffer
, IOByteCount length
);
158 #endif /* !_IOKIT_IONVRAM_H */