]>
Commit | Line | Data |
---|---|---|
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/IOKitKeys.h> | |
27 | #include <IOKit/IOService.h> | |
28 | #include <IOKit/IODeviceTreeSupport.h> | |
29 | #include <IOKit/nvram/IONVRAMController.h> | |
30 | ||
31 | ||
32 | #define kIODTNVRAMOFPartitionName "common" | |
33 | #define kIODTNVRAMXPRAMPartitionName "APL,MacOS75" | |
34 | #define kIODTNVRAMPanicInfoPartitonName "APL,OSXPanic" | |
35 | #define kIODTNVRAMFreePartitionName "wwwwwwwwwwww" | |
36 | ||
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; | |
70 | OSDictionary *_nvramPartitionOffsets; | |
71 | OSDictionary *_nvramPartitionLengths; | |
72 | UInt32 _xpramPartitionOffset; | |
73 | UInt32 _xpramPartitionSize; | |
74 | UInt8 *_xpramImage; | |
75 | UInt32 _nrPartitionOffset; | |
76 | UInt32 _nrPartitionSize; | |
77 | UInt8 *_nrImage; | |
78 | UInt32 _piPartitionOffset; | |
79 | UInt32 _piPartitionSize; | |
80 | UInt8 *_piImage; | |
81 | bool _systemPaniced; | |
82 | ||
83 | virtual UInt8 calculatePartitionChecksum(UInt8 *partitionHeader); | |
84 | virtual IOReturn initOFVariables(void); | |
85 | public: | |
86 | virtual IOReturn syncOFVariables(void); | |
87 | private: | |
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 | ||
111 | virtual OSData *unescapeBytesToData(const UInt8 *bytes, UInt32 length); | |
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 | ||
128 | virtual bool serializeProperties(OSSerialize *s) const; | |
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); | |
132 | virtual void removeProperty(const OSSymbol *aKey); | |
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); | |
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); | |
156 | ||
157 | virtual IOByteCount savePanicInfo(UInt8 *buffer, IOByteCount length); | |
158 | }; | |
159 | ||
160 | #endif /* !_IOKIT_IONVRAM_H */ |