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