]> git.saurik.com Git - apple/xnu.git/blame - iokit/IOKit/IONVRAM.h
xnu-517.9.5.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 *
e5568f75
A
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.
1c79356b 11 *
e5568f75
A
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
1c79356b
A
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
e5568f75
A
16 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
17 * License for the specific language governing rights and limitations
18 * under the License.
1c79356b
A
19 *
20 * @APPLE_LICENSE_HEADER_END@
21 */
22
23#ifndef _IOKIT_IONVRAM_H
24#define _IOKIT_IONVRAM_H
25
26#include <IOKit/IOService.h>
27#include <IOKit/IODeviceTreeSupport.h>
28#include <IOKit/nvram/IONVRAMController.h>
29
d52fe63f
A
30
31#define kIODTNVRAMOFPartitionName "common"
32#define kIODTNVRAMXPRAMPartitionName "APL,MacOS75"
9bccf70c 33#define kIODTNVRAMPanicInfoPartitonName "APL,OSXPanic"
d52fe63f
A
34#define kIODTNVRAMFreePartitionName "wwwwwwwwwwww"
35
9bccf70c
A
36#define kIODTNVRAMPanicInfoKey "aapl,panic-info"
37
1c79356b
A
38enum {
39 kIODTNVRAMImageSize = 0x2000,
40 kIODTNVRAMXPRAMSize = 0x0100,
41 kIODTNVRAMNameRegistrySize = 0x0400
42};
43
44enum {
45 kOFVariableTypeBoolean = 1,
46 kOFVariableTypeNumber,
47 kOFVariableTypeString,
48 kOFVariableTypeData
49};
50
51enum {
52 kOFVariablePermRootOnly = 0,
53 kOFVariablePermUserRead,
54 kOFVariablePermUserWrite
55};
56
57class IODTNVRAM : public IOService
58{
59 OSDeclareDefaultStructors(IODTNVRAM);
60
61private:
62 IONVRAMController *_nvramController;
63 const OSSymbol *_registryPropertiesKey;
64 UInt8 *_nvramImage;
65 bool _nvramImageDirty;
66 UInt32 _ofPartitionOffset;
67 UInt32 _ofPartitionSize;
68 UInt8 *_ofImage;
69 bool _ofImageDirty;
70 OSDictionary *_ofDict;
d52fe63f
A
71 OSDictionary *_nvramPartitionOffsets;
72 OSDictionary *_nvramPartitionLengths;
1c79356b
A
73 UInt32 _xpramPartitionOffset;
74 UInt32 _xpramPartitionSize;
75 UInt8 *_xpramImage;
76 UInt32 _nrPartitionOffset;
77 UInt32 _nrPartitionSize;
78 UInt8 *_nrImage;
9bccf70c
A
79 UInt32 _piPartitionOffset;
80 UInt32 _piPartitionSize;
81 UInt8 *_piImage;
82 bool _systemPaniced;
1c79356b 83
9bccf70c 84 virtual UInt8 calculatePartitionChecksum(UInt8 *partitionHeader);
1c79356b
A
85 virtual IOReturn initOFVariables(void);
86 virtual IOReturn syncOFVariables(void);
87 virtual UInt32 getOFVariableType(const OSSymbol *propSymbol) const;
88 virtual UInt32 getOFVariablePerm(const OSSymbol *propSymbol) const;
89 virtual bool getOWVariableInfo(UInt32 variableNumber, const OSSymbol **propSymbol,
90 UInt32 *propType, UInt32 *propOffset);
91 virtual bool convertPropToObject(UInt8 *propName, UInt32 propNameLength,
92 UInt8 *propData, UInt32 propDataLength,
93 const OSSymbol **propSymbol,
94 OSObject **propObject);
95 virtual bool convertObjectToProp(UInt8 *buffer, UInt32 *length,
96 const OSSymbol *propSymbol, OSObject *propObject);
97 virtual UInt16 generateOWChecksum(UInt8 *buffer);
98 virtual bool validateOWChecksum(UInt8 *buffer);
99 virtual void updateOWBootArgs(const OSSymbol *key, OSObject *value);
100 virtual bool searchNVRAMProperty(struct IONVRAMDescriptor *hdr,
101 UInt32 *where);
102
103 virtual IOReturn readNVRAMPropertyType0(IORegistryEntry *entry,
104 const OSSymbol **name,
105 OSData **value);
106 virtual IOReturn writeNVRAMPropertyType0(IORegistryEntry *entry,
107 const OSSymbol *name,
108 OSData * value);
109
110 virtual OSData *unescapeBytesToData(UInt8 *bytes, UInt32 length);
111 virtual OSData *escapeDataToData(OSData * value);
112
113 virtual IOReturn readNVRAMPropertyType1(IORegistryEntry *entry,
114 const OSSymbol **name,
115 OSData **value);
116 virtual IOReturn writeNVRAMPropertyType1(IORegistryEntry *entry,
117 const OSSymbol *name,
118 OSData *value);
119
120public:
121 virtual bool init(IORegistryEntry *old, const IORegistryPlane *plane);
122
123 virtual void registerNVRAMController(IONVRAMController *nvram);
124
125 virtual void sync(void);
126
127 virtual bool serializeProperties(OSSerialize * serialize) const;
128 virtual OSObject *getProperty(const OSSymbol *aKey) const;
129 virtual OSObject *getProperty(const char *aKey) const;
130 virtual bool setProperty(const OSSymbol *aKey, OSObject *anObject);
131 virtual IOReturn setProperties(OSObject *properties);
132
133 virtual IOReturn readXPRAM(IOByteCount offset, UInt8 *buffer,
134 IOByteCount length);
135 virtual IOReturn writeXPRAM(IOByteCount offset, UInt8 *buffer,
136 IOByteCount length);
137
138 virtual IOReturn readNVRAMProperty(IORegistryEntry *entry,
139 const OSSymbol **name,
140 OSData **value);
141 virtual IOReturn writeNVRAMProperty(IORegistryEntry *entry,
142 const OSSymbol *name,
143 OSData *value);
d52fe63f
A
144
145 virtual OSDictionary *getNVRAMPartitions(void);
146
147 virtual IOReturn readNVRAMPartition(const OSSymbol *partitionID,
148 IOByteCount offset, UInt8 *buffer,
149 IOByteCount length);
150
151 virtual IOReturn writeNVRAMPartition(const OSSymbol *partitionID,
152 IOByteCount offset, UInt8 *buffer,
153 IOByteCount length);
9bccf70c
A
154
155 virtual IOByteCount savePanicInfo(UInt8 *buffer, IOByteCount length);
1c79356b
A
156};
157
158#endif /* !_IOKIT_IONVRAM_H */