]> git.saurik.com Git - apple/xnu.git/blame - iokit/IOKit/IONVRAM.h
xnu-344.21.73.tar.gz
[apple/xnu.git] / iokit / IOKit / IONVRAM.h
CommitLineData
1c79356b
A
1/*
2 * Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
d7e50217 6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
1c79356b 7 *
d7e50217
A
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
13 * file.
14 *
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
1c79356b
A
17 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
18 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
d7e50217
A
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.
1c79356b
A
22 *
23 * @APPLE_LICENSE_HEADER_END@
24 */
25
26#ifndef _IOKIT_IONVRAM_H
27#define _IOKIT_IONVRAM_H
28
29#include <IOKit/IOService.h>
30#include <IOKit/IODeviceTreeSupport.h>
31#include <IOKit/nvram/IONVRAMController.h>
32
d52fe63f
A
33
34#define kIODTNVRAMOFPartitionName "common"
35#define kIODTNVRAMXPRAMPartitionName "APL,MacOS75"
9bccf70c 36#define kIODTNVRAMPanicInfoPartitonName "APL,OSXPanic"
d52fe63f
A
37#define kIODTNVRAMFreePartitionName "wwwwwwwwwwww"
38
9bccf70c
A
39#define kIODTNVRAMPanicInfoKey "aapl,panic-info"
40
1c79356b
A
41enum {
42 kIODTNVRAMImageSize = 0x2000,
43 kIODTNVRAMXPRAMSize = 0x0100,
44 kIODTNVRAMNameRegistrySize = 0x0400
45};
46
47enum {
48 kOFVariableTypeBoolean = 1,
49 kOFVariableTypeNumber,
50 kOFVariableTypeString,
51 kOFVariableTypeData
52};
53
54enum {
55 kOFVariablePermRootOnly = 0,
56 kOFVariablePermUserRead,
57 kOFVariablePermUserWrite
58};
59
60class IODTNVRAM : public IOService
61{
62 OSDeclareDefaultStructors(IODTNVRAM);
63
64private:
65 IONVRAMController *_nvramController;
66 const OSSymbol *_registryPropertiesKey;
67 UInt8 *_nvramImage;
68 bool _nvramImageDirty;
69 UInt32 _ofPartitionOffset;
70 UInt32 _ofPartitionSize;
71 UInt8 *_ofImage;
72 bool _ofImageDirty;
73 OSDictionary *_ofDict;
d52fe63f
A
74 OSDictionary *_nvramPartitionOffsets;
75 OSDictionary *_nvramPartitionLengths;
1c79356b
A
76 UInt32 _xpramPartitionOffset;
77 UInt32 _xpramPartitionSize;
78 UInt8 *_xpramImage;
79 UInt32 _nrPartitionOffset;
80 UInt32 _nrPartitionSize;
81 UInt8 *_nrImage;
9bccf70c
A
82 UInt32 _piPartitionOffset;
83 UInt32 _piPartitionSize;
84 UInt8 *_piImage;
85 bool _systemPaniced;
1c79356b 86
9bccf70c 87 virtual UInt8 calculatePartitionChecksum(UInt8 *partitionHeader);
1c79356b
A
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,
104 UInt32 *where);
105
106 virtual IOReturn readNVRAMPropertyType0(IORegistryEntry *entry,
107 const OSSymbol **name,
108 OSData **value);
109 virtual IOReturn writeNVRAMPropertyType0(IORegistryEntry *entry,
110 const OSSymbol *name,
111 OSData * value);
112
113 virtual OSData *unescapeBytesToData(UInt8 *bytes, UInt32 length);
114 virtual OSData *escapeDataToData(OSData * value);
115
116 virtual IOReturn readNVRAMPropertyType1(IORegistryEntry *entry,
117 const OSSymbol **name,
118 OSData **value);
119 virtual IOReturn writeNVRAMPropertyType1(IORegistryEntry *entry,
120 const OSSymbol *name,
121 OSData *value);
122
123public:
124 virtual bool init(IORegistryEntry *old, const IORegistryPlane *plane);
125
126 virtual void registerNVRAMController(IONVRAMController *nvram);
127
128 virtual void sync(void);
129
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);
135
136 virtual IOReturn readXPRAM(IOByteCount offset, UInt8 *buffer,
137 IOByteCount length);
138 virtual IOReturn writeXPRAM(IOByteCount offset, UInt8 *buffer,
139 IOByteCount length);
140
141 virtual IOReturn readNVRAMProperty(IORegistryEntry *entry,
142 const OSSymbol **name,
143 OSData **value);
144 virtual IOReturn writeNVRAMProperty(IORegistryEntry *entry,
145 const OSSymbol *name,
146 OSData *value);
d52fe63f
A
147
148 virtual OSDictionary *getNVRAMPartitions(void);
149
150 virtual IOReturn readNVRAMPartition(const OSSymbol *partitionID,
151 IOByteCount offset, UInt8 *buffer,
152 IOByteCount length);
153
154 virtual IOReturn writeNVRAMPartition(const OSSymbol *partitionID,
155 IOByteCount offset, UInt8 *buffer,
156 IOByteCount length);
9bccf70c
A
157
158 virtual IOByteCount savePanicInfo(UInt8 *buffer, IOByteCount length);
1c79356b
A
159};
160
161#endif /* !_IOKIT_IONVRAM_H */