]> git.saurik.com Git - apple/xnu.git/blob - iokit/IOKit/IONVRAM.h
xnu-201.14.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_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 enum {
31 kIODTNVRAMImageSize = 0x2000,
32 kIODTNVRAMXPRAMSize = 0x0100,
33 kIODTNVRAMNameRegistrySize = 0x0400
34 };
35
36 enum {
37 kOFVariableTypeBoolean = 1,
38 kOFVariableTypeNumber,
39 kOFVariableTypeString,
40 kOFVariableTypeData
41 };
42
43 enum {
44 kOFVariablePermRootOnly = 0,
45 kOFVariablePermUserRead,
46 kOFVariablePermUserWrite
47 };
48
49 class IODTNVRAM : public IOService
50 {
51 OSDeclareDefaultStructors(IODTNVRAM);
52
53 private:
54 IONVRAMController *_nvramController;
55 const OSSymbol *_registryPropertiesKey;
56 UInt8 *_nvramImage;
57 bool _nvramImageDirty;
58 UInt32 _ofPartitionOffset;
59 UInt32 _ofPartitionSize;
60 UInt8 *_ofImage;
61 bool _ofImageDirty;
62 OSDictionary *_ofDict;
63 UInt32 _xpramPartitionOffset;
64 UInt32 _xpramPartitionSize;
65 UInt8 *_xpramImage;
66 UInt32 _nrPartitionOffset;
67 UInt32 _nrPartitionSize;
68 UInt8 *_nrImage;
69
70 virtual IOReturn initOFVariables(void);
71 virtual IOReturn syncOFVariables(void);
72 virtual UInt32 getOFVariableType(const OSSymbol *propSymbol) const;
73 virtual UInt32 getOFVariablePerm(const OSSymbol *propSymbol) const;
74 virtual bool getOWVariableInfo(UInt32 variableNumber, const OSSymbol **propSymbol,
75 UInt32 *propType, UInt32 *propOffset);
76 virtual bool convertPropToObject(UInt8 *propName, UInt32 propNameLength,
77 UInt8 *propData, UInt32 propDataLength,
78 const OSSymbol **propSymbol,
79 OSObject **propObject);
80 virtual bool convertObjectToProp(UInt8 *buffer, UInt32 *length,
81 const OSSymbol *propSymbol, OSObject *propObject);
82 virtual UInt16 generateOWChecksum(UInt8 *buffer);
83 virtual bool validateOWChecksum(UInt8 *buffer);
84 virtual void updateOWBootArgs(const OSSymbol *key, OSObject *value);
85 virtual bool searchNVRAMProperty(struct IONVRAMDescriptor *hdr,
86 UInt32 *where);
87
88 virtual IOReturn readNVRAMPropertyType0(IORegistryEntry *entry,
89 const OSSymbol **name,
90 OSData **value);
91 virtual IOReturn writeNVRAMPropertyType0(IORegistryEntry *entry,
92 const OSSymbol *name,
93 OSData * value);
94
95 virtual OSData *unescapeBytesToData(UInt8 *bytes, UInt32 length);
96 virtual OSData *escapeDataToData(OSData * value);
97
98 virtual IOReturn readNVRAMPropertyType1(IORegistryEntry *entry,
99 const OSSymbol **name,
100 OSData **value);
101 virtual IOReturn writeNVRAMPropertyType1(IORegistryEntry *entry,
102 const OSSymbol *name,
103 OSData *value);
104
105 public:
106 virtual bool init(IORegistryEntry *old, const IORegistryPlane *plane);
107
108 virtual void registerNVRAMController(IONVRAMController *nvram);
109
110 virtual void sync(void);
111
112 virtual bool serializeProperties(OSSerialize * serialize) const;
113 virtual OSObject *getProperty(const OSSymbol *aKey) const;
114 virtual OSObject *getProperty(const char *aKey) const;
115 virtual bool setProperty(const OSSymbol *aKey, OSObject *anObject);
116 virtual IOReturn setProperties(OSObject *properties);
117
118 virtual IOReturn readXPRAM(IOByteCount offset, UInt8 *buffer,
119 IOByteCount length);
120 virtual IOReturn writeXPRAM(IOByteCount offset, UInt8 *buffer,
121 IOByteCount length);
122
123 virtual IOReturn readNVRAMProperty(IORegistryEntry *entry,
124 const OSSymbol **name,
125 OSData **value);
126 virtual IOReturn writeNVRAMProperty(IORegistryEntry *entry,
127 const OSSymbol *name,
128 OSData *value);
129 };
130
131 #endif /* !_IOKIT_IONVRAM_H */