]> git.saurik.com Git - apple/xnu.git/blob - iokit/IOKit/IONVRAM.h
866a9b9e14c9deedef8f607e080bfe4e499744eb
[apple/xnu.git] / iokit / IOKit / IONVRAM.h
1 /*
2 * Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
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.
11 *
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
18 * under the License.
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
30
31 #define kIODTNVRAMOFPartitionName "common"
32 #define kIODTNVRAMXPRAMPartitionName "APL,MacOS75"
33 #define kIODTNVRAMFreePartitionName "wwwwwwwwwwww"
34
35 enum {
36 kIODTNVRAMImageSize = 0x2000,
37 kIODTNVRAMXPRAMSize = 0x0100,
38 kIODTNVRAMNameRegistrySize = 0x0400
39 };
40
41 enum {
42 kOFVariableTypeBoolean = 1,
43 kOFVariableTypeNumber,
44 kOFVariableTypeString,
45 kOFVariableTypeData
46 };
47
48 enum {
49 kOFVariablePermRootOnly = 0,
50 kOFVariablePermUserRead,
51 kOFVariablePermUserWrite
52 };
53
54 class IODTNVRAM : public IOService
55 {
56 OSDeclareDefaultStructors(IODTNVRAM);
57
58 private:
59 IONVRAMController *_nvramController;
60 const OSSymbol *_registryPropertiesKey;
61 UInt8 *_nvramImage;
62 bool _nvramImageDirty;
63 UInt32 _ofPartitionOffset;
64 UInt32 _ofPartitionSize;
65 UInt8 *_ofImage;
66 bool _ofImageDirty;
67 OSDictionary *_ofDict;
68 OSDictionary *_nvramPartitionOffsets;
69 OSDictionary *_nvramPartitionLengths;
70 UInt32 _xpramPartitionOffset;
71 UInt32 _xpramPartitionSize;
72 UInt8 *_xpramImage;
73 UInt32 _nrPartitionOffset;
74 UInt32 _nrPartitionSize;
75 UInt8 *_nrImage;
76
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,
93 UInt32 *where);
94
95 virtual IOReturn readNVRAMPropertyType0(IORegistryEntry *entry,
96 const OSSymbol **name,
97 OSData **value);
98 virtual IOReturn writeNVRAMPropertyType0(IORegistryEntry *entry,
99 const OSSymbol *name,
100 OSData * value);
101
102 virtual OSData *unescapeBytesToData(UInt8 *bytes, UInt32 length);
103 virtual OSData *escapeDataToData(OSData * value);
104
105 virtual IOReturn readNVRAMPropertyType1(IORegistryEntry *entry,
106 const OSSymbol **name,
107 OSData **value);
108 virtual IOReturn writeNVRAMPropertyType1(IORegistryEntry *entry,
109 const OSSymbol *name,
110 OSData *value);
111
112 public:
113 virtual bool init(IORegistryEntry *old, const IORegistryPlane *plane);
114
115 virtual void registerNVRAMController(IONVRAMController *nvram);
116
117 virtual void sync(void);
118
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);
124
125 virtual IOReturn readXPRAM(IOByteCount offset, UInt8 *buffer,
126 IOByteCount length);
127 virtual IOReturn writeXPRAM(IOByteCount offset, UInt8 *buffer,
128 IOByteCount length);
129
130 virtual IOReturn readNVRAMProperty(IORegistryEntry *entry,
131 const OSSymbol **name,
132 OSData **value);
133 virtual IOReturn writeNVRAMProperty(IORegistryEntry *entry,
134 const OSSymbol *name,
135 OSData *value);
136
137 virtual OSDictionary *getNVRAMPartitions(void);
138
139 virtual IOReturn readNVRAMPartition(const OSSymbol *partitionID,
140 IOByteCount offset, UInt8 *buffer,
141 IOByteCount length);
142
143 virtual IOReturn writeNVRAMPartition(const OSSymbol *partitionID,
144 IOByteCount offset, UInt8 *buffer,
145 IOByteCount length);
146 };
147
148 #endif /* !_IOKIT_IONVRAM_H */