Chameleon

Chameleon Svn Source Tree

Root/trunk/i386/include/IOKit/IONVRAM.h

1/*
2 * Copyright (c) 1998-2006 Apple Computer, Inc. All rights reserved.
3 * Copyright (c) 2007-2012 Apple Inc. All rights reserved.
4 *
5 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
6 *
7 * This file contains Original Code and/or Modifications of Original Code
8 * as defined in and that are subject to the Apple Public Source License
9 * Version 2.0 (the 'License'). You may not use this file except in
10 * compliance with the License. The rights granted to you under the License
11 * may not be used to create, or enable the creation or redistribution of,
12 * unlawful or unlicensed copies of an Apple operating system, or to
13 * circumvent, violate, or enable the circumvention or violation of, any
14 * terms of an Apple operating system software license agreement.
15 *
16 * Please obtain a copy of the License at
17 * http://www.opensource.apple.com/apsl/ and read it before using this file.
18 *
19 * The Original Code and all software distributed under the License are
20 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
21 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
22 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
23 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
24 * Please see the License for the specific language governing rights and
25 * limitations under the License.
26 *
27 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
28 */
29
30#ifndef _IOKIT_IONVRAM_H
31#define _IOKIT_IONVRAM_H
32
33#include <IOKit/IOKitKeys.h>
34#include <IOKit/IOService.h>
35#include <IOKit/IODeviceTreeSupport.h>
36#include <IOKit/nvram/IONVRAMController.h>
37
38
39#define kIODTNVRAMOFPartitionName "common"
40#define kIODTNVRAMXPRAMPartitionName "APL,MacOS75"
41#define kIODTNVRAMPanicInfoPartitonName "APL,OSXPanic"
42#define kIODTNVRAMFreePartitionName "wwwwwwwwwwww"
43
44enum {
45 kIODTNVRAMImageSize = 0x2000,
46 kIODTNVRAMXPRAMSize = 0x0100,
47 kIODTNVRAMNameRegistrySize = 0x0400
48};
49
50enum {
51 kOFVariableTypeBoolean = 1,
52 kOFVariableTypeNumber,
53 kOFVariableTypeString,
54 kOFVariableTypeData
55};
56
57enum {
58 kOFVariablePermRootOnly = 0,
59 kOFVariablePermUserRead,
60 kOFVariablePermUserWrite,
61 kOFVariablePermKernelOnly
62};
63
64class IODTNVRAM : public IOService
65{
66 OSDeclareDefaultStructors(IODTNVRAM);
67
68private:
69 IONVRAMController *_nvramController;
70 const OSSymbol *_registryPropertiesKey;
71 UInt8 *_nvramImage;
72 bool _nvramImageDirty;
73 UInt32 _ofPartitionOffset;
74 UInt32 _ofPartitionSize;
75 UInt8 *_ofImage;
76 bool _ofImageDirty;
77 OSDictionary *_ofDict;
78 OSDictionary *_nvramPartitionOffsets;
79 OSDictionary *_nvramPartitionLengths;
80 UInt32 _resv0 __unused;
81 UInt32 _resv1 __unused;
82 IOLock *_ofLock;
83 UInt32 _resv2 __unused;
84 UInt32 _resv3 __unused;
85 UInt8 *_resv4 __unused;
86 UInt32 _piPartitionOffset;
87 UInt32 _piPartitionSize;
88 UInt8 *_piImage;
89 bool _systemPaniced;
90 SInt32 _lastDeviceSync;
91 bool _freshInterval;
92 bool _isProxied;
93
94 virtual UInt8 calculatePartitionChecksum(UInt8 *partitionHeader);
95 virtual IOReturn initOFVariables(void);
96public:
97 virtual IOReturn syncOFVariables(void);
98private:
99 virtual UInt32 getOFVariableType(const OSSymbol *propSymbol) const;
100 virtual UInt32 getOFVariablePerm(const OSSymbol *propSymbol) const;
101 virtual bool getOWVariableInfo(UInt32 variableNumber, const OSSymbol **propSymbol,
102 UInt32 *propType, UInt32 *propOffset);
103 virtual bool convertPropToObject(UInt8 *propName, UInt32 propNameLength,
104 UInt8 *propData, UInt32 propDataLength,
105 const OSSymbol **propSymbol,
106 OSObject **propObject);
107 virtual bool convertObjectToProp(UInt8 *buffer, UInt32 *length,
108 const OSSymbol *propSymbol, OSObject *propObject);
109 virtual UInt16 generateOWChecksum(UInt8 *buffer);
110 virtual bool validateOWChecksum(UInt8 *buffer);
111 virtual void updateOWBootArgs(const OSSymbol *key, OSObject *value);
112 virtual bool searchNVRAMProperty(struct IONVRAMDescriptor *hdr,
113 UInt32 *where);
114
115 virtual IOReturn readNVRAMPropertyType0(IORegistryEntry *entry,
116 const OSSymbol **name,
117 OSData **value);
118 virtual IOReturn writeNVRAMPropertyType0(IORegistryEntry *entry,
119 const OSSymbol *name,
120 OSData * value);
121
122 virtual OSData *unescapeBytesToData(const UInt8 *bytes, UInt32 length);
123 virtual OSData *escapeDataToData(OSData * value);
124
125 virtual IOReturn readNVRAMPropertyType1(IORegistryEntry *entry,
126 const OSSymbol **name,
127 OSData **value);
128 virtual IOReturn writeNVRAMPropertyType1(IORegistryEntry *entry,
129 const OSSymbol *name,
130 OSData *value);
131
132 void initNVRAMImage(void);
133 void initProxyData(void);
134
135public:
136 virtual bool init(IORegistryEntry *old, const IORegistryPlane *plane);
137
138 virtual void registerNVRAMController(IONVRAMController *nvram);
139
140 virtual void sync(void);
141
142 virtual bool serializeProperties(OSSerialize *s) const;
143 virtual OSObject *copyProperty(const OSSymbol *aKey) const;
144 virtual OSObject *copyProperty(const char *aKey) const;
145 virtual OSObject *getProperty(const OSSymbol *aKey) const;
146 virtual OSObject *getProperty(const char *aKey) const;
147 virtual bool setProperty(const OSSymbol *aKey, OSObject *anObject);
148 virtual void removeProperty(const OSSymbol *aKey);
149 virtual IOReturn setProperties(OSObject *properties);
150
151 virtual IOReturn readXPRAM(IOByteCount offset, UInt8 *buffer,
152 IOByteCount length);
153 virtual IOReturn writeXPRAM(IOByteCount offset, UInt8 *buffer,
154 IOByteCount length);
155
156 virtual IOReturn readNVRAMProperty(IORegistryEntry *entry,
157 const OSSymbol **name,
158 OSData **value);
159 virtual IOReturn writeNVRAMProperty(IORegistryEntry *entry,
160 const OSSymbol *name,
161 OSData *value);
162
163 virtual OSDictionary *getNVRAMPartitions(void);
164
165 virtual IOReturn readNVRAMPartition(const OSSymbol *partitionID,
166 IOByteCount offset, UInt8 *buffer,
167 IOByteCount length);
168
169 virtual IOReturn writeNVRAMPartition(const OSSymbol *partitionID,
170 IOByteCount offset, UInt8 *buffer,
171 IOByteCount length);
172
173 virtual IOByteCount savePanicInfo(UInt8 *buffer, IOByteCount length);
174 virtual bool safeToSync(void);
175};
176
177#endif /* !_IOKIT_IONVRAM_H */
178

Archive Download this file

Revision: 2783