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