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/IOKitKeys.h>
27 #include <IOKit/IOService.h>
28 #include <IOKit/IODeviceTreeSupport.h>
29 #include <IOKit/nvram/IONVRAMController.h>
32 #define kIODTNVRAMOFPartitionName "common"
33 #define kIODTNVRAMXPRAMPartitionName "APL,MacOS75"
34 #define kIODTNVRAMPanicInfoPartitonName "APL,OSXPanic"
35 #define kIODTNVRAMFreePartitionName "wwwwwwwwwwww"
38 kIODTNVRAMImageSize
= 0x2000,
39 kIODTNVRAMXPRAMSize
= 0x0100,
40 kIODTNVRAMNameRegistrySize
= 0x0400
44 kOFVariableTypeBoolean
= 1,
45 kOFVariableTypeNumber
,
46 kOFVariableTypeString
,
51 kOFVariablePermRootOnly
= 0,
52 kOFVariablePermUserRead
,
53 kOFVariablePermUserWrite
56 class IODTNVRAM
: public IOService
58 OSDeclareDefaultStructors(IODTNVRAM
);
61 IONVRAMController
*_nvramController
;
62 const OSSymbol
*_registryPropertiesKey
;
64 bool _nvramImageDirty
;
65 UInt32 _ofPartitionOffset
;
66 UInt32 _ofPartitionSize
;
69 OSDictionary
*_ofDict
;
70 OSDictionary
*_nvramPartitionOffsets
;
71 OSDictionary
*_nvramPartitionLengths
;
72 UInt32 _xpramPartitionOffset
;
73 UInt32 _xpramPartitionSize
;
75 UInt32 _nrPartitionOffset
;
76 UInt32 _nrPartitionSize
;
78 UInt32 _piPartitionOffset
;
79 UInt32 _piPartitionSize
;
83 virtual UInt8
calculatePartitionChecksum(UInt8
*partitionHeader
);
84 virtual IOReturn
initOFVariables(void);
86 virtual IOReturn
syncOFVariables(void);
88 virtual UInt32
getOFVariableType(const OSSymbol
*propSymbol
) const;
89 virtual UInt32
getOFVariablePerm(const OSSymbol
*propSymbol
) const;
90 virtual bool getOWVariableInfo(UInt32 variableNumber
, const OSSymbol
**propSymbol
,
91 UInt32
*propType
, UInt32
*propOffset
);
92 virtual bool convertPropToObject(UInt8
*propName
, UInt32 propNameLength
,
93 UInt8
*propData
, UInt32 propDataLength
,
94 const OSSymbol
**propSymbol
,
95 OSObject
**propObject
);
96 virtual bool convertObjectToProp(UInt8
*buffer
, UInt32
*length
,
97 const OSSymbol
*propSymbol
, OSObject
*propObject
);
98 virtual UInt16
generateOWChecksum(UInt8
*buffer
);
99 virtual bool validateOWChecksum(UInt8
*buffer
);
100 virtual void updateOWBootArgs(const OSSymbol
*key
, OSObject
*value
);
101 virtual bool searchNVRAMProperty(struct IONVRAMDescriptor
*hdr
,
104 virtual IOReturn
readNVRAMPropertyType0(IORegistryEntry
*entry
,
105 const OSSymbol
**name
,
107 virtual IOReturn
writeNVRAMPropertyType0(IORegistryEntry
*entry
,
108 const OSSymbol
*name
,
111 virtual OSData
*unescapeBytesToData(const UInt8
*bytes
, UInt32 length
);
112 virtual OSData
*escapeDataToData(OSData
* value
);
114 virtual IOReturn
readNVRAMPropertyType1(IORegistryEntry
*entry
,
115 const OSSymbol
**name
,
117 virtual IOReturn
writeNVRAMPropertyType1(IORegistryEntry
*entry
,
118 const OSSymbol
*name
,
122 virtual bool init(IORegistryEntry
*old
, const IORegistryPlane
*plane
);
124 virtual void registerNVRAMController(IONVRAMController
*nvram
);
126 virtual void sync(void);
128 virtual bool serializeProperties(OSSerialize
*s
) const;
129 virtual OSObject
*getProperty(const OSSymbol
*aKey
) const;
130 virtual OSObject
*getProperty(const char *aKey
) const;
131 virtual bool setProperty(const OSSymbol
*aKey
, OSObject
*anObject
);
132 virtual void removeProperty(const OSSymbol
*aKey
);
133 virtual IOReturn
setProperties(OSObject
*properties
);
135 virtual IOReturn
readXPRAM(IOByteCount offset
, UInt8
*buffer
,
137 virtual IOReturn
writeXPRAM(IOByteCount offset
, UInt8
*buffer
,
140 virtual IOReturn
readNVRAMProperty(IORegistryEntry
*entry
,
141 const OSSymbol
**name
,
143 virtual IOReturn
writeNVRAMProperty(IORegistryEntry
*entry
,
144 const OSSymbol
*name
,
147 virtual OSDictionary
*getNVRAMPartitions(void);
149 virtual IOReturn
readNVRAMPartition(const OSSymbol
*partitionID
,
150 IOByteCount offset
, UInt8
*buffer
,
153 virtual IOReturn
writeNVRAMPartition(const OSSymbol
*partitionID
,
154 IOByteCount offset
, UInt8
*buffer
,
157 virtual IOByteCount
savePanicInfo(UInt8
*buffer
, IOByteCount length
);
160 #endif /* !_IOKIT_IONVRAM_H */