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 kIODTNVRAMFreePartitionName "wwwwwwwwwwww"
36 kIODTNVRAMImageSize
= 0x2000,
37 kIODTNVRAMXPRAMSize
= 0x0100,
38 kIODTNVRAMNameRegistrySize
= 0x0400
42 kOFVariableTypeBoolean
= 1,
43 kOFVariableTypeNumber
,
44 kOFVariableTypeString
,
49 kOFVariablePermRootOnly
= 0,
50 kOFVariablePermUserRead
,
51 kOFVariablePermUserWrite
54 class IODTNVRAM
: public IOService
56 OSDeclareDefaultStructors(IODTNVRAM
);
59 IONVRAMController
*_nvramController
;
60 const OSSymbol
*_registryPropertiesKey
;
62 bool _nvramImageDirty
;
63 UInt32 _ofPartitionOffset
;
64 UInt32 _ofPartitionSize
;
67 OSDictionary
*_ofDict
;
68 OSDictionary
*_nvramPartitionOffsets
;
69 OSDictionary
*_nvramPartitionLengths
;
70 UInt32 _xpramPartitionOffset
;
71 UInt32 _xpramPartitionSize
;
73 UInt32 _nrPartitionOffset
;
74 UInt32 _nrPartitionSize
;
77 virtual IOReturn
initOFVariables(void);
78 virtual IOReturn
syncOFVariables(void);
79 virtual UInt32
getOFVariableType(const OSSymbol
*propSymbol
) const;
80 virtual UInt32
getOFVariablePerm(const OSSymbol
*propSymbol
) const;
81 virtual bool getOWVariableInfo(UInt32 variableNumber
, const OSSymbol
**propSymbol
,
82 UInt32
*propType
, UInt32
*propOffset
);
83 virtual bool convertPropToObject(UInt8
*propName
, UInt32 propNameLength
,
84 UInt8
*propData
, UInt32 propDataLength
,
85 const OSSymbol
**propSymbol
,
86 OSObject
**propObject
);
87 virtual bool convertObjectToProp(UInt8
*buffer
, UInt32
*length
,
88 const OSSymbol
*propSymbol
, OSObject
*propObject
);
89 virtual UInt16
generateOWChecksum(UInt8
*buffer
);
90 virtual bool validateOWChecksum(UInt8
*buffer
);
91 virtual void updateOWBootArgs(const OSSymbol
*key
, OSObject
*value
);
92 virtual bool searchNVRAMProperty(struct IONVRAMDescriptor
*hdr
,
95 virtual IOReturn
readNVRAMPropertyType0(IORegistryEntry
*entry
,
96 const OSSymbol
**name
,
98 virtual IOReturn
writeNVRAMPropertyType0(IORegistryEntry
*entry
,
102 virtual OSData
*unescapeBytesToData(UInt8
*bytes
, UInt32 length
);
103 virtual OSData
*escapeDataToData(OSData
* value
);
105 virtual IOReturn
readNVRAMPropertyType1(IORegistryEntry
*entry
,
106 const OSSymbol
**name
,
108 virtual IOReturn
writeNVRAMPropertyType1(IORegistryEntry
*entry
,
109 const OSSymbol
*name
,
113 virtual bool init(IORegistryEntry
*old
, const IORegistryPlane
*plane
);
115 virtual void registerNVRAMController(IONVRAMController
*nvram
);
117 virtual void sync(void);
119 virtual bool serializeProperties(OSSerialize
* serialize
) const;
120 virtual OSObject
*getProperty(const OSSymbol
*aKey
) const;
121 virtual OSObject
*getProperty(const char *aKey
) const;
122 virtual bool setProperty(const OSSymbol
*aKey
, OSObject
*anObject
);
123 virtual IOReturn
setProperties(OSObject
*properties
);
125 virtual IOReturn
readXPRAM(IOByteCount offset
, UInt8
*buffer
,
127 virtual IOReturn
writeXPRAM(IOByteCount offset
, UInt8
*buffer
,
130 virtual IOReturn
readNVRAMProperty(IORegistryEntry
*entry
,
131 const OSSymbol
**name
,
133 virtual IOReturn
writeNVRAMProperty(IORegistryEntry
*entry
,
134 const OSSymbol
*name
,
137 virtual OSDictionary
*getNVRAMPartitions(void);
139 virtual IOReturn
readNVRAMPartition(const OSSymbol
*partitionID
,
140 IOByteCount offset
, UInt8
*buffer
,
143 virtual IOReturn
writeNVRAMPartition(const OSSymbol
*partitionID
,
144 IOByteCount offset
, UInt8
*buffer
,
148 #endif /* !_IOKIT_IONVRAM_H */