Chameleon

Chameleon Commit Details

Date:2012-04-10 14:00:20 (7 years 4 months ago)
Author:armel cadet-petit
Commit:1919
Parents: 1918
Message:Security and stability fix
Changes:
R/branches/cparm/i386/libsaio/md5c.c → /branches/cparm/i386/libsaio/md5.c
A/branches/cparm/xcode3_sym.zip
A/branches/cparm/i386/libsaio/md5.h
M/branches/cparm/i386/libsaio/stringTable.c
M/branches/cparm/i386/libsaio/convert.c
M/branches/cparm/i386/libsaio/platform.c
M/branches/cparm/Chameleon.xcodeproj/project.pbxproj
M/branches/cparm/i386/modules/GraphicsEnabler/nvidia.c
M/branches/cparm/i386/libsaio/platform.h
M/branches/cparm/i386/modules/YellowIconFixer/YellowIconFixer.c
M/branches/cparm/i386/libsaio/disk.c
M/branches/cparm/i386/libsaio/device_inject.c
M/branches/cparm/i386/modules/GraphicsEnabler/ati.c
M/branches/cparm/i386/libsaio/Makefile
M/branches/cparm/i386/boot2/options.c
M/branches/cparm/i386/libsaio/uthash.h
M/branches/cparm/i386/libsaio/console.c
M/branches/cparm/i386/modules/GUI/GUI_module.c
M/branches/cparm/i386/boot2/graphics.c
M/branches/cparm/i386/modules/GraphicsEnabler/GraphicsEnabler.c
M/branches/cparm/CHANGES
M/branches/cparm/i386/libsaio/device_tree.c
M/branches/cparm/i386/libsaio/sys.c
M/branches/cparm/i386/modules/ACPICodec/acpidecode.c
M/branches/cparm/i386/modules/GraphicsEnabler/gma.c
M/branches/cparm/i386/libsaio/fake_efi.c
M/branches/cparm/i386/libsaio/misc.c
M/branches/cparm/i386/modules/GUI/gui.c
M/branches/cparm/i386/modules/Networking/Networking.c
M/branches/cparm/i386/boot2/boot.c
M/branches/cparm/i386/modules/GUI/graphic_utils.c
M/branches/cparm/i386/libsaio/bootstruct.c
M/branches/cparm/i386/libsaio/pci.c

File differences

branches/cparm/Chameleon.xcodeproj/project.pbxproj
88
99
1010
11
1112
1213
1314
......
265266
266267
267268
268
269
269270
270271
271272
......
10191020
10201021
10211022
1022
1023
1024
10231025
10241026
10251027
/* Begin PBXFileReference section */
AB0E930C14C6223500F798D7 /* cpu_intel_amd.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = cpu_intel_amd.c; sourceTree = "<group>"; };
AB22095D15334C9E00AA9851 /* md5.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = md5.h; sourceTree = "<group>"; };
AB42D02115187F2C0078E84A /* background.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = background.png; sourceTree = "<group>"; };
AB42D02215187F2C0078E84A /* boot.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = boot.png; sourceTree = "<group>"; };
AB42D02315187F2C0078E84A /* device_cdrom.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = device_cdrom.png; sourceTree = "<group>"; };
AB43B31C14C37E520018D529 /* libsaio.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = libsaio.h; sourceTree = "<group>"; };
AB43B31D14C37E520018D529 /* load.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = load.c; sourceTree = "<group>"; };
AB43B31E14C37E520018D529 /* Makefile */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.make; path = Makefile; sourceTree = "<group>"; };
AB43B31F14C37E520018D529 /* md5c.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = md5c.c; sourceTree = "<group>"; };
AB43B31F14C37E520018D529 /* md5.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = md5.c; sourceTree = "<group>"; };
AB43B32014C37E520018D529 /* misc.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = misc.c; sourceTree = "<group>"; };
AB43B32114C37E520018D529 /* msdos.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = msdos.c; sourceTree = "<group>"; };
AB43B32214C37E520018D529 /* msdos.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = msdos.h; sourceTree = "<group>"; };
AB43B31C14C37E520018D529 /* libsaio.h */,
AB43B31D14C37E520018D529 /* load.c */,
AB43B31E14C37E520018D529 /* Makefile */,
AB43B31F14C37E520018D529 /* md5c.c */,
AB43B31F14C37E520018D529 /* md5.c */,
AB22095D15334C9E00AA9851 /* md5.h */,
AB43B32014C37E520018D529 /* misc.c */,
ABE5FF4E14F9495500447F78 /* modules.c */,
ABE5FF4F14F9495500447F78 /* modules.h */,
branches/cparm/CHANGES
1
2
3
4
15
26
37
- Stability fixes
- Added mountain lion auto_installer compatibility
- Changed md5c.c to the Xnu's md5.c
- Added a dirty workaround to selectBootVolume (still need more investigations to find out what happening exactly during the bvchain construction, and how the h... the loop can stop with gcc)
- Improved Xcode4.3+ support
branches/cparm/i386/libsaio/md5c.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
/*
* MD5C.C - RSA Data Security, Inc., MD5 message-digest algorithm
*
* Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All
* rights reserved.
*
* License to copy and use this software is granted provided that it
* is identified as the "RSA Data Security, Inc. MD5 Message-Digest
* Algorithm" in all material mentioning or referencing this software
* or this function.
*
* License is also granted to make and use derivative works provided
* that such works are identified as "derived from the RSA Data
* Security, Inc. MD5 Message-Digest Algorithm" in all material
* mentioning or referencing the derived work.
*
* RSA Data Security, Inc. makes no representations concerning either
* the merchantability of this software or the suitability of this
* software for any particular purpose. It is provided "as is"
* without express or implied warranty of any kind.
*
* These notices must be retained in any copies of any part of this
* documentation and/or software.
*
* $Id: md5c.c,v 1.1 2005/06/24 22:47:12 curtisg Exp $
*
* This code is the same as the code published by RSA Inc. It has been
* edited for clarity and style only.
*/
#include "libsaio.h"
# include <Kernel/libkern/crypto/md5.h>
#define Encode memcpy
#define Decode memcpy
static unsigned char PADDING[64] = {
0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
};
/* F, G, H and I are basic MD5 functions. */
#define F(x, y, z) (((x) & (y)) | ((~x) & (z)))
#define G(x, y, z) (((x) & (z)) | ((y) & (~z)))
#define H(x, y, z) ((x) ^ (y) ^ (z))
#define I(x, y, z) ((y) ^ ((x) | (~z)))
/* ROTATE_LEFT rotates x left n bits. */
#define ROTATE_LEFT(x, n) (((x) << (n)) | ((x) >> (32-(n))))
/*
* FF, GG, HH, and II transformations for rounds 1, 2, 3, and 4.
* Rotation is separate from addition to prevent recomputation.
*/
#define FF(a, b, c, d, x, s, ac) { \
(a) += F ((b), (c), (d)) + (x) + (u_int32_t)(ac); \
(a) = ROTATE_LEFT ((a), (s)); \
(a) += (b); \
}
#define GG(a, b, c, d, x, s, ac) { \
(a) += G ((b), (c), (d)) + (x) + (u_int32_t)(ac); \
(a) = ROTATE_LEFT ((a), (s)); \
(a) += (b); \
}
#define HH(a, b, c, d, x, s, ac) { \
(a) += H ((b), (c), (d)) + (x) + (u_int32_t)(ac); \
(a) = ROTATE_LEFT ((a), (s)); \
(a) += (b); \
}
#define II(a, b, c, d, x, s, ac) { \
(a) += I ((b), (c), (d)) + (x) + (u_int32_t)(ac); \
(a) = ROTATE_LEFT ((a), (s)); \
(a) += (b); \
}
static void MD5Transform (u_int32_t state[4], const unsigned char block[64]);
/* MD5 initialization. Begins an MD5 operation, writing a new context. */
void
MD5Init (context)
MD5_CTX *context;
{
context->count[0] = context->count[1] = 0;
/* Load magic initialization constants. */
context->state[0] = 0x67452301;
context->state[1] = 0xefcdab89;
context->state[2] = 0x98badcfe;
context->state[3] = 0x10325476;
}
/*
* MD5 block update operation. Continues an MD5 message-digest
* operation, processing another message block, and updating the
* context.
*/
void
MD5Update (context, input, inputLen)
MD5_CTX *context;
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5
const void *input;
#else
const unsigned char *input;
#endif
unsigned int inputLen;
{
unsigned int i, index, partLen;
/* Compute number of bytes mod 64 */
index = (unsigned int)((context->count[0] >> 3) & 0x3F);
/* Update number of bits */
if ((context->count[0] += ((u_int32_t)inputLen << 3))
< ((u_int32_t)inputLen << 3))
context->count[1]++;
context->count[1] += ((u_int32_t)inputLen >> 29);
partLen = 64 - index;
/* Transform as many times as possible. */
if (inputLen >= partLen) {
memcpy((void *)&context->buffer[index], (const void *)input,
partLen);
MD5Transform (context->state, context->buffer);
for (i = partLen; i + 63 < inputLen; i += 64)
MD5Transform (context->state, &((const unsigned char *)input)[i]);
index = 0;
}
else
i = 0;
/* Buffer remaining input */
memcpy ((void *)&context->buffer[index], (const void *)&((const unsigned char*)input)[i],
inputLen-i);
}
/*
* MD5 padding. Adds padding followed by original length.
*/
static void
MD5Pad (context)
MD5_CTX *context;
{
unsigned char bits[8];
unsigned int index, padLen;
/* Save number of bits */
Encode (bits, context->count, 8);
/* Pad out to 56 mod 64. */
index = (unsigned int)((context->count[0] >> 3) & 0x3f);
padLen = (index < 56) ? (56 - index) : (120 - index);
MD5Update (context, PADDING, padLen);
/* Append length (before padding) */
MD5Update (context, bits, 8);
}
/*
* MD5 finalization. Ends an MD5 message-digest operation, writing the
* the message digest and zeroizing the context.
*/
void
MD5Final (digest, context)
unsigned char digest[16];
MD5_CTX *context;
{
/* Do padding. */
MD5Pad (context);
/* Store state in digest */
Encode (digest, context->state, 16);
/* Zeroize sensitive information. */
memset ((void *)context, 0, sizeof (*context));
}
/* MD5 basic transformation. Transforms state based on block. */
static void
MD5Transform (state, block)
u_int32_t state[4];
const unsigned char block[64];
{
u_int32_t a = state[0], b = state[1], c = state[2], d = state[3], x[16];
Decode (x, block, 64);
/* Round 1 */
#define S11 7
#define S12 12
#define S13 17
#define S14 22
FF (a, b, c, d, x[ 0], S11, 0xd76aa478); /* 1 */
FF (d, a, b, c, x[ 1], S12, 0xe8c7b756); /* 2 */
FF (c, d, a, b, x[ 2], S13, 0x242070db); /* 3 */
FF (b, c, d, a, x[ 3], S14, 0xc1bdceee); /* 4 */
FF (a, b, c, d, x[ 4], S11, 0xf57c0faf); /* 5 */
FF (d, a, b, c, x[ 5], S12, 0x4787c62a); /* 6 */
FF (c, d, a, b, x[ 6], S13, 0xa8304613); /* 7 */
FF (b, c, d, a, x[ 7], S14, 0xfd469501); /* 8 */
FF (a, b, c, d, x[ 8], S11, 0x698098d8); /* 9 */
FF (d, a, b, c, x[ 9], S12, 0x8b44f7af); /* 10 */
FF (c, d, a, b, x[10], S13, 0xffff5bb1); /* 11 */
FF (b, c, d, a, x[11], S14, 0x895cd7be); /* 12 */
FF (a, b, c, d, x[12], S11, 0x6b901122); /* 13 */
FF (d, a, b, c, x[13], S12, 0xfd987193); /* 14 */
FF (c, d, a, b, x[14], S13, 0xa679438e); /* 15 */
FF (b, c, d, a, x[15], S14, 0x49b40821); /* 16 */
/* Round 2 */
#define S21 5
#define S22 9
#define S23 14
#define S24 20
GG (a, b, c, d, x[ 1], S21, 0xf61e2562); /* 17 */
GG (d, a, b, c, x[ 6], S22, 0xc040b340); /* 18 */
GG (c, d, a, b, x[11], S23, 0x265e5a51); /* 19 */
GG (b, c, d, a, x[ 0], S24, 0xe9b6c7aa); /* 20 */
GG (a, b, c, d, x[ 5], S21, 0xd62f105d); /* 21 */
GG (d, a, b, c, x[10], S22, 0x2441453); /* 22 */
GG (c, d, a, b, x[15], S23, 0xd8a1e681); /* 23 */
GG (b, c, d, a, x[ 4], S24, 0xe7d3fbc8); /* 24 */
GG (a, b, c, d, x[ 9], S21, 0x21e1cde6); /* 25 */
GG (d, a, b, c, x[14], S22, 0xc33707d6); /* 26 */
GG (c, d, a, b, x[ 3], S23, 0xf4d50d87); /* 27 */
GG (b, c, d, a, x[ 8], S24, 0x455a14ed); /* 28 */
GG (a, b, c, d, x[13], S21, 0xa9e3e905); /* 29 */
GG (d, a, b, c, x[ 2], S22, 0xfcefa3f8); /* 30 */
GG (c, d, a, b, x[ 7], S23, 0x676f02d9); /* 31 */
GG (b, c, d, a, x[12], S24, 0x8d2a4c8a); /* 32 */
/* Round 3 */
#define S31 4
#define S32 11
#define S33 16
#define S34 23
HH (a, b, c, d, x[ 5], S31, 0xfffa3942); /* 33 */
HH (d, a, b, c, x[ 8], S32, 0x8771f681); /* 34 */
HH (c, d, a, b, x[11], S33, 0x6d9d6122); /* 35 */
HH (b, c, d, a, x[14], S34, 0xfde5380c); /* 36 */
HH (a, b, c, d, x[ 1], S31, 0xa4beea44); /* 37 */
HH (d, a, b, c, x[ 4], S32, 0x4bdecfa9); /* 38 */
HH (c, d, a, b, x[ 7], S33, 0xf6bb4b60); /* 39 */
HH (b, c, d, a, x[10], S34, 0xbebfbc70); /* 40 */
HH (a, b, c, d, x[13], S31, 0x289b7ec6); /* 41 */
HH (d, a, b, c, x[ 0], S32, 0xeaa127fa); /* 42 */
HH (c, d, a, b, x[ 3], S33, 0xd4ef3085); /* 43 */
HH (b, c, d, a, x[ 6], S34, 0x4881d05); /* 44 */
HH (a, b, c, d, x[ 9], S31, 0xd9d4d039); /* 45 */
HH (d, a, b, c, x[12], S32, 0xe6db99e5); /* 46 */
HH (c, d, a, b, x[15], S33, 0x1fa27cf8); /* 47 */
HH (b, c, d, a, x[ 2], S34, 0xc4ac5665); /* 48 */
/* Round 4 */
#define S41 6
#define S42 10
#define S43 15
#define S44 21
II (a, b, c, d, x[ 0], S41, 0xf4292244); /* 49 */
II (d, a, b, c, x[ 7], S42, 0x432aff97); /* 50 */
II (c, d, a, b, x[14], S43, 0xab9423a7); /* 51 */
II (b, c, d, a, x[ 5], S44, 0xfc93a039); /* 52 */
II (a, b, c, d, x[12], S41, 0x655b59c3); /* 53 */
II (d, a, b, c, x[ 3], S42, 0x8f0ccc92); /* 54 */
II (c, d, a, b, x[10], S43, 0xffeff47d); /* 55 */
II (b, c, d, a, x[ 1], S44, 0x85845dd1); /* 56 */
II (a, b, c, d, x[ 8], S41, 0x6fa87e4f); /* 57 */
II (d, a, b, c, x[15], S42, 0xfe2ce6e0); /* 58 */
II (c, d, a, b, x[ 6], S43, 0xa3014314); /* 59 */
II (b, c, d, a, x[13], S44, 0x4e0811a1); /* 60 */
II (a, b, c, d, x[ 4], S41, 0xf7537e82); /* 61 */
II (d, a, b, c, x[11], S42, 0xbd3af235); /* 62 */
II (c, d, a, b, x[ 2], S43, 0x2ad7d2bb); /* 63 */
II (b, c, d, a, x[ 9], S44, 0xeb86d391); /* 64 */
state[0] += a;
state[1] += b;
state[2] += c;
state[3] += d;
/* Zeroize sensitive information. */
memset ((void *)x, 0, sizeof (x));
}
branches/cparm/i386/libsaio/console.c
7979
8080
8181
82
83
84
85
8286
8387
8488
void initBooterLog(void)
{
msgbuf = malloc(BOOTER_LOG_SIZE);
if (!msgbuf) {
printf("Couldn't allocate buffer for booter log\n");
return;
}
bzero(msgbuf, BOOTER_LOG_SIZE);
cursor = msgbuf;
branches/cparm/i386/libsaio/bootstruct.c
352352
353353
354354
355
356
357
355358
356359
357360
}
DT__FlattenDeviceTree((void **)&addr, &size);
if (!size) {
stop("Couldn't get flatten device tree\n");
}
bootArgs->deviceTreeP = (uint32_t)addr;
bootArgs->deviceTreeLength = size;
}
branches/cparm/i386/libsaio/device_tree.c
1313
1414
1515
16
17
16
17
1818
1919
2020
2121
2222
23
24
23
24
2525
2626
2727
......
7373
7474
7575
76
76
7777
7878
7979
80
81
80
81
8282
83
8483
8584
8685
......
9796
9897
9998
100
99
101100
102101
103102
104
103
105104
106105
107106
......
110109
111110
112111
113
112
114113
115114
116115
117116
118
117
119118
120119
121120
......
123122
124123
125124
126
125
127126
128127
129
130
128
129
131130
132
133131
134132
135133
......
149147
150148
151149
152
150
153151
154152
155153
......
202200
203201
204202
205
203
206204
207205
208206
209207
210208
211209
212
210
213211
214212
215213
......
218216
219217
220218
221
219
222220
223221
224222
......
231229
232230
233231
234
232
235233
236
234
237235
238236
239
237
240238
241239
242240
......
246244
247245
248246
249
247
250248
251249
252250
253251
254
252
255253
256254
257255
......
268266
269267
270268
271
269
272270
273271
274272
275273
276274
277275
278
279
280
276
277
278
281279
282280
283281
......
288286
289287
290288
289
290
291
292
291293
292294
293295
......
302304
303305
304306
305
307
306308
307309
308310
......
322324
323325
324326
325
327
326328
327329
328330
329331
330332
331
333
332334
333335
334336
335
337
336338
337339
338
340
339341
340342
341343
342344
343345
344
346
345347
346348
347349
......
353355
354356
355357
356
358
357359
358360
359361
......
368370
369371
370372
371
373
372374
373375
374376
375
377
376378
377379
378380
379381
380
381
382
383
382
383
384
385
384386
385387
386388
typedef struct DeviceTreeNodeProperty {
char name[kPropNameLength]; // NUL terminated property name
unsigned long length; // Length (bytes) of folloing prop value
// unsigned long value[1]; // Variable length value of property
// Padded to a multiple of a longword?
// unsigned long value[1]; // Variable length value of property
// Padded to a multiple of a longword?
} DeviceTreeNodeProperty;
typedef struct OpaqueDTEntry {
unsigned long nProperties; // Number of props[] elements (0 => end)
unsigned long nChildren; // Number of children[] elements
// DeviceTreeNodeProperty props[];// array size == nProperties
// DeviceTreeNode children[]; // array size == nChildren
// DeviceTreeNodeProperty props[];// array size == nProperties
// DeviceTreeNode children[]; // array size == nChildren
} DeviceTreeNode;
typedef char DTPropertyNameBuf[32];
DT__AddProperty(Node *node, const char *name, uint32_t length, void *value)
{
Property *prop;
DPRINTF("DT__AddProperty([Node '%s'], '%s', %d, 0x%x)\n", DT__GetName(node), name, length, value);
if (freeProperties == NULL) {
void *buf = malloc(kAllocSize);
int i;
if (buf == 0) return 0;
int i;
DPRINTF("Allocating more free properties\n");
if (buf == 0) return 0;
bzero(buf, kAllocSize);
// Use the first property to record the allocated buffer
// for later freeing.
}
prop = freeProperties;
freeProperties = prop->next;
prop->name = name;
prop->length = length;
prop->value = value;
// Always add to end of list
if (node->properties == 0) {
node->properties = prop;
}
node->last_prop = prop;
prop->next = 0;
DPRINTF("Done [0x%x]\n", prop);
DTInfo.numProperties++;
DTInfo.totalPropertySize += RoundToLong(length);
return prop;
}
DT__AddChild(Node *parent, const char *name)
{
Node *node;
if (freeNodes == NULL) {
void *buf = malloc(kAllocSize);
int i;
if (buf == 0) return 0;
int i;
DPRINTF("Allocating more free nodes\n");
if (buf == 0) return 0;
bzero(buf, kAllocSize);
node = (Node *)buf;
// Use the first node to record the allocated buffer
freeNodes = node->next;
DPRINTF("Got free node 0x%x\n", node);
DPRINTF("prop = 0x%x, children = 0x%x, next = 0x%x\n", node->properties, node->children, node->next);
if (parent == NULL) {
rootNode = node;
node->next = 0;
{
Node *node;
Property *prop;
DPRINTF("DT__Finalize\n");
for (prop = allocedProperties; prop != NULL; prop = prop->next) {
free(prop->value);
}
allocedProperties = NULL;
freeProperties = NULL;
for (node = allocedNodes; node != NULL; node = node->next) {
free((void *)node->children);
}
rootNode = NULL;
// XXX leaks any created strings
DTInfo.numNodes = 0;
DTInfo.numProperties = 0;
DTInfo.totalPropertySize = 0;
DeviceTreeNode *flatNode;
DeviceTreeNodeProperty *flatProp;
int count;
if (node == 0) return buffer;
flatNode = (DeviceTreeNode *)buffer;
buffer += sizeof(DeviceTreeNode);
for (count = 0, prop = node->properties; prop != 0; count++, prop = prop->next) {
flatProp = (DeviceTreeNodeProperty *)buffer;
strcpy(flatProp->name, prop->name);
buffer += RoundToLong(prop->length);
}
flatNode->nProperties = count;
for (count = 0, node = node->children; node != 0; count++, node = node->next) {
buffer = FlattenNodes(node, buffer);
}
flatNode->nChildren = count;
return buffer;
}
{
uint32_t totalSize;
void *buf;
DPRINTF("DT__FlattenDeviceTree(0x%x, 0x%x)\n", buffer_p, length);
#if DEBUG
if (buffer_p) DT__PrintTree(rootNode);
#endif
totalSize = DTInfo.numNodes * sizeof(DeviceTreeNode) +
DTInfo.numProperties * sizeof(DeviceTreeNodeProperty) +
DTInfo.totalPropertySize;
DTInfo.numProperties * sizeof(DeviceTreeNodeProperty) +
DTInfo.totalPropertySize;
DPRINTF("Total size 0x%x\n", totalSize);
if (buffer_p != 0) {
if (totalSize == 0) {
} else {
buf = *buffer_p;
}
if (!buf) {
*length = 0;
return;
}
bzero(buf, totalSize);
FlattenNodes(rootNode, buf);
DT__GetName(Node *node)
{
Property *prop;
//DPRINTF("DT__GetName(0x%x)\n", node);
//DPRINTF("Node properties = 0x%x\n", node->properties);
for (prop = node->properties; prop; prop = prop->next) {
DTPropertyNameBuf nameBuf;
char *bp;
int i;
DPRINTF("DT__FindNode('%s', %d)\n", path, createIfMissing);
// Start at root
node = rootNode;
DPRINTF("root = 0x%x\n", rootNode);
while (node) {
// Skip leading slash
while (*path == '/') path++;
for (i=0, bp = nameBuf; ++i < kDTMaxEntryNameLength && *path && *path != '/'; bp++, path++) *bp = *path;
*bp = '\0';
if (nameBuf[0] == '\0') {
// last path entry
break;
}
DPRINTF("Node '%s'\n", nameBuf);
for (child = node->children; child != 0; child = child->next) {
DPRINTF("Child 0x%x\n", child);
if (strcmp(DT__GetName(child), nameBuf) == 0) {
char *str = malloc(strlen(nameBuf) + 1);
// XXX this will leak
strcpy(str, nameBuf);
child = DT__AddChild(node, str);
}
node = child;
{
char spaces[10], *cp = spaces;
Property *prop;
if (level > 9) level = 9;
while (level--) *cp++ = ' ';
*cp = '\0';
printf("%s===Node===\n", spaces);
for (prop = node->properties; prop; prop = prop->next) {
char c = *((char *)prop->value);
if (prop->length < 64 && (
strcmp(prop->name, "name") == 0 ||
(c >= '0' && c <= '9') ||
(c >= 'a' && c <= 'z') ||
(c >= 'A' && c <= 'Z') || c == '_')) {
strcmp(prop->name, "name") == 0 ||
(c >= '0' && c <= '9') ||
(c >= 'a' && c <= 'z') ||
(c >= 'A' && c <= 'Z') || c == '_')) {
printf("%s Property '%s' [%d] = '%s'\n", spaces, prop->name, prop->length, prop->value);
} else {
printf("%s Property '%s' [%d] = (data)\n", spaces, prop->name, prop->length);
branches/cparm/i386/libsaio/md5.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
/*
* Copyright (c) 2000-2006 Apple Computer, Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
/*
* MD5.C - RSA Data Security, Inc., MD5 message-digest algorithm
*
* Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All
* rights reserved.
*
* License to copy and use this software is granted provided that it
* is identified as the "RSA Data Security, Inc. MD5 Message-Digest
* Algorithm" in all material mentioning or referencing this software
* or this function.
*
* License is also granted to make and use derivative works provided
* that such works are identified as "derived from the RSA Data
* Security, Inc. MD5 Message-Digest Algorithm" in all material
* mentioning or referencing the derived work.
*
* RSA Data Security, Inc. makes no representations concerning either
* the merchantability of this software or the suitability of this
* software for any particular purpose. It is provided "as is"
* without express or implied warranty of any kind.
*
* These notices must be retained in any copies of any part of this
* documentation and/or software.
*
* This code is the same as the code published by RSA Inc. It has been
* edited for clarity and style only.
*/
#include "libsa.h"
#include "md5.h"
#definememset(x, y, z)bzero(x, z);
#definememcpy(x, y, z)bcopy(y, x, z)
/*
* The digest algorithm interprets the input message as a sequence of 32-bit
* little-endian words. We must reverse bytes in each word on PPC and other
* big-endian platforms, but not on little-endian ones. When we can, we try
* to load each word at once. We don't quite care about alignment, since
* x86/x64 allows us to do 4-byte loads on non 4-byte aligned addresses,
* and on PPC we do 1-byte loads anyway.
*
* We could check against __LITLE_ENDIAN__ to generalize the 4-byte load
* optimization, but that might not tell us whether or not we need 4-byte
* aligned loads. Since we know that __i386__ and __x86_64__ are the two
* little-endian architectures that are not alignment-restrictive, we check
* explicitly against them below. Note that the byte-reversing code for
* big-endian will still work on little-endian, albeit much slower.
*/
#if defined(__i386__) || defined(__x86_64__)
#defineFETCH_32(p)(*(const u_int32_t *)(p))
#else
#defineFETCH_32(p)\
(((u_int32_t)*((const u_int8_t *)(p))) |\
(((u_int32_t)*((const u_int8_t *)(p) + 1)) << 8) |\
(((u_int32_t)*((const u_int8_t *)(p) + 2)) << 16) |\
(((u_int32_t)*((const u_int8_t *)(p) + 3)) << 24))
#endif /* __i386__ || __x86_64__ */
/*
* Encodes input (u_int32_t) into output (unsigned char). Assumes len is
* a multiple of 4. This is not compatible with memcpy().
*/
static void
Encode(unsigned char *output, u_int32_t *input, unsigned int len)
{
unsigned int i, j;
for (i = 0, j = 0; j < len; i++, j += 4) {
#if defined(__i386__) || defined(__x86_64__)
*(u_int32_t *)(output + j) = input[i];
#else
output[j] = input[i] & 0xff;
output[j + 1] = (input[i] >> 8) & 0xff;
output[j + 2] = (input[i] >> 16) & 0xff;
output[j + 3] = (input[i] >> 24) & 0xff;
#endif /* __i386__ || __x86_64__ */
}
}
static unsigned char PADDING[64] = { 0x80, /* zeros */ };
/* F, G, H and I are basic MD5 functions. */
#defineF(x, y, z)((((y) ^ (z)) & (x)) ^ (z))
#defineG(x, y, z)((((x) ^ (y)) & (z)) ^ (y))
#defineH(x, y, z)((x) ^ (y) ^ (z))
#defineI(x, y, z)(((~(z)) | (x)) ^ (y))
/* ROTATE_LEFT rotates x left n bits. */
#defineROTATE_LEFT(x, n) (((x) << (n)) | ((x) >> (32 - (n))))
/*
* FF, GG, HH, and II transformations for rounds 1, 2, 3, and 4.
* Rotation is separate from addition to prevent recomputation.
*/
#defineFF(a, b, c, d, x, s, ac) {\
(a) += F((b), (c), (d)) + (x) + (unsigned long long)(ac);\
(a) = ROTATE_LEFT((a), (s));\
(a) += (b);\
}
#defineGG(a, b, c, d, x, s, ac) {\
(a) += G((b), (c), (d)) + (x) + (unsigned long long)(ac);\
(a) = ROTATE_LEFT((a), (s));\
(a) += (b);\
}
#defineHH(a, b, c, d, x, s, ac) {\
(a) += H((b), (c), (d)) + (x) + (unsigned long long)(ac);\
(a) = ROTATE_LEFT((a), (s));\
(a) += (b);\
}
#defineII(a, b, c, d, x, s, ac) {\
(a) += I((b), (c), (d)) + (x) + (unsigned long long)(ac);\
(a) = ROTATE_LEFT((a), (s));\
(a) += (b);\
}
static void MD5Transform(u_int32_t, u_int32_t, u_int32_t, u_int32_t,
const u_int8_t [64], MD5_CTX *);
/*
* MD5 initialization. Begins an MD5 operation, writing a new context.
*/
void
MD5Init(MD5_CTX *context)
{
context->count[0] = context->count[1] = 0;
/* Load magic initialization constants. */
context->state[0] = 0x67452301UL;
context->state[1] = 0xefcdab89UL;
context->state[2] = 0x98badcfeUL;
context->state[3] = 0x10325476UL;
}
/*
* MD5 block update operation. Continues an MD5 message-digest
* operation, processing another message block, and updating the
* context.
*/
void
MD5Update(MD5_CTX *context, const void *inpp, unsigned int inputLen)
{
u_int32_t i, index, partLen;
const unsigned char *input = (const unsigned char *)inpp;
/* Compute number of bytes mod 64 */
index = (context->count[0] >> 3) & 0x3F;
/* Update number of bits */
if ((context->count[0] += (inputLen << 3)) < (inputLen << 3))
context->count[1]++;
context->count[1] += (inputLen >> 29);
partLen = 64 - index;
/* Transform as many times as possible. */
i = 0;
if (inputLen >= partLen) {
if (index != 0) {
memcpy(&context->buffer[index], input, partLen);
MD5Transform(context->state[0], context->state[1],
context->state[2], context->state[3],
context->buffer, context);
i = partLen;
}
for (; i + 63 < inputLen; i += 64)
MD5Transform(context->state[0], context->state[1],
context->state[2], context->state[3],
&input[i], context);
if (inputLen == i)
return;
index = 0;
}
/* Buffer remaining input */
memcpy(&context->buffer[index], &input[i], inputLen - i);
}
/*
* MD5 finalization. Ends an MD5 message-digest operation, writing the
* the message digest and zeroizing the context.
*/
void
MD5Final(unsigned char digest[MD5_DIGEST_LENGTH], MD5_CTX *context)
{
unsigned char bits[8];
u_int32_t index = (context->count[0] >> 3) & 0x3f;
/* Save number of bits */
Encode(bits, context->count, 8);
/* Pad out to 56 mod 64. */
MD5Update(context, PADDING, ((index < 56) ? 56 : 120) - index);
/* Append length (before padding) */
MD5Update(context, bits, 8);
/* Store state in digest */
Encode(digest, context->state, 16);
/* Zeroize sensitive information. */
memset(context, 0, sizeof (*context));
}
/*
* MD5 basic transformation. Transforms state based on block.
*/
static void
MD5Transform(u_int32_t a, u_int32_t b, u_int32_t c, u_int32_t d,
const u_int8_t block[64], MD5_CTX *context)
{
/* Register (instead of array) is a win in most cases */
register u_int32_t x0, x1, x2, x3, x4, x5, x6, x7;
register u_int32_t x8, x9, x10, x11, x12, x13, x14, x15;
x15 = FETCH_32(block + 60);
x14 = FETCH_32(block + 56);
x13 = FETCH_32(block + 52);
x12 = FETCH_32(block + 48);
x11 = FETCH_32(block + 44);
x10 = FETCH_32(block + 40);
x9 = FETCH_32(block + 36);
x8 = FETCH_32(block + 32);
x7 = FETCH_32(block + 28);
x6 = FETCH_32(block + 24);
x5 = FETCH_32(block + 20);
x4 = FETCH_32(block + 16);
x3 = FETCH_32(block + 12);
x2 = FETCH_32(block + 8);
x1 = FETCH_32(block + 4);
x0 = FETCH_32(block + 0);
/* Round 1 */
#defineS11 7
#defineS12 12
#defineS13 17
#defineS14 22
FF(a, b, c, d, x0, S11, 0xd76aa478UL); /* 1 */
FF(d, a, b, c, x1, S12, 0xe8c7b756UL); /* 2 */
FF(c, d, a, b, x2, S13, 0x242070dbUL); /* 3 */
FF(b, c, d, a, x3, S14, 0xc1bdceeeUL); /* 4 */
FF(a, b, c, d, x4, S11, 0xf57c0fafUL); /* 5 */
FF(d, a, b, c, x5, S12, 0x4787c62aUL); /* 6 */
FF(c, d, a, b, x6, S13, 0xa8304613UL); /* 7 */
FF(b, c, d, a, x7, S14, 0xfd469501UL); /* 8 */
FF(a, b, c, d, x8, S11, 0x698098d8UL); /* 9 */
FF(d, a, b, c, x9, S12, 0x8b44f7afUL); /* 10 */
FF(c, d, a, b, x10, S13, 0xffff5bb1UL); /* 11 */
FF(b, c, d, a, x11, S14, 0x895cd7beUL); /* 12 */
FF(a, b, c, d, x12, S11, 0x6b901122UL); /* 13 */
FF(d, a, b, c, x13, S12, 0xfd987193UL); /* 14 */
FF(c, d, a, b, x14, S13, 0xa679438eUL); /* 15 */
FF(b, c, d, a, x15, S14, 0x49b40821UL); /* 16 */
/* Round 2 */
#defineS21 5
#defineS22 9
#defineS23 14
#defineS24 20
GG(a, b, c, d, x1, S21, 0xf61e2562UL); /* 17 */
GG(d, a, b, c, x6, S22, 0xc040b340UL); /* 18 */
GG(c, d, a, b, x11, S23, 0x265e5a51UL); /* 19 */
GG(b, c, d, a, x0, S24, 0xe9b6c7aaUL); /* 20 */
GG(a, b, c, d, x5, S21, 0xd62f105dUL); /* 21 */
GG(d, a, b, c, x10, S22, 0x02441453UL); /* 22 */
GG(c, d, a, b, x15, S23, 0xd8a1e681UL); /* 23 */
GG(b, c, d, a, x4, S24, 0xe7d3fbc8UL); /* 24 */
GG(a, b, c, d, x9, S21, 0x21e1cde6UL); /* 25 */
GG(d, a, b, c, x14, S22, 0xc33707d6UL); /* 26 */
GG(c, d, a, b, x3, S23, 0xf4d50d87UL); /* 27 */
GG(b, c, d, a, x8, S24, 0x455a14edUL); /* 28 */
GG(a, b, c, d, x13, S21, 0xa9e3e905UL); /* 29 */
GG(d, a, b, c, x2, S22, 0xfcefa3f8UL); /* 30 */
GG(c, d, a, b, x7, S23, 0x676f02d9UL); /* 31 */
GG(b, c, d, a, x12, S24, 0x8d2a4c8aUL); /* 32 */
/* Round 3 */
#defineS31 4
#defineS32 11
#defineS33 16
#defineS34 23
HH(a, b, c, d, x5, S31, 0xfffa3942UL); /* 33 */
HH(d, a, b, c, x8, S32, 0x8771f681UL); /* 34 */
HH(c, d, a, b, x11, S33, 0x6d9d6122UL); /* 35 */
HH(b, c, d, a, x14, S34, 0xfde5380cUL); /* 36 */
HH(a, b, c, d, x1, S31, 0xa4beea44UL); /* 37 */
HH(d, a, b, c, x4, S32, 0x4bdecfa9UL); /* 38 */
HH(c, d, a, b, x7, S33, 0xf6bb4b60UL); /* 39 */
HH(b, c, d, a, x10, S34, 0xbebfbc70UL); /* 40 */
HH(a, b, c, d, x13, S31, 0x289b7ec6UL); /* 41 */
HH(d, a, b, c, x0, S32, 0xeaa127faUL); /* 42 */
HH(c, d, a, b, x3, S33, 0xd4ef3085UL); /* 43 */
HH(b, c, d, a, x6, S34, 0x04881d05UL); /* 44 */
HH(a, b, c, d, x9, S31, 0xd9d4d039UL); /* 45 */
HH(d, a, b, c, x12, S32, 0xe6db99e5UL); /* 46 */
HH(c, d, a, b, x15, S33, 0x1fa27cf8UL); /* 47 */
HH(b, c, d, a, x2, S34, 0xc4ac5665UL); /* 48 */
/* Round 4 */
#defineS41 6
#defineS42 10
#defineS43 15
#defineS44 21
II(a, b, c, d, x0, S41, 0xf4292244UL); /* 49 */
II(d, a, b, c, x7, S42, 0x432aff97UL); /* 50 */
II(c, d, a, b, x14, S43, 0xab9423a7UL); /* 51 */
II(b, c, d, a, x5, S44, 0xfc93a039UL); /* 52 */
II(a, b, c, d, x12, S41, 0x655b59c3UL); /* 53 */
II(d, a, b, c, x3, S42, 0x8f0ccc92UL); /* 54 */
II(c, d, a, b, x10, S43, 0xffeff47dUL); /* 55 */
II(b, c, d, a, x1, S44, 0x85845dd1UL); /* 56 */
II(a, b, c, d, x8, S41, 0x6fa87e4fUL); /* 57 */
II(d, a, b, c, x15, S42, 0xfe2ce6e0UL); /* 58 */
II(c, d, a, b, x6, S43, 0xa3014314UL); /* 59 */
II(b, c, d, a, x13, S44, 0x4e0811a1UL); /* 60 */
II(a, b, c, d, x4, S41, 0xf7537e82UL); /* 61 */
II(d, a, b, c, x11, S42, 0xbd3af235UL); /* 62 */
II(c, d, a, b, x2, S43, 0x2ad7d2bbUL); /* 63 */
II(b, c, d, a, x9, S44, 0xeb86d391UL); /* 64 */
context->state[0] += a;
context->state[1] += b;
context->state[2] += c;
context->state[3] += d;
/* Zeroize sensitive information. */
x15 = x14 = x13 = x12 = x11 = x10 = x9 = x8 = 0;
x7 = x6 = x5 = x4 = x3 = x2 = x1 = x0 = 0;
/* Silent a warning reported by the clang static analizer . */
(void)x0;(void)x1;(void)x2;(void)x3;(void)x4;(void)x5;(void)x6;(void)x7;
(void)x8;(void)x9;(void)x10;(void)x11;(void)x12;(void)x13;(void)x14;(void)x15;
}
branches/cparm/i386/libsaio/md5.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
/*
* Copyright (c) 2000-2006 Apple Computer, Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
/*
* MD5.H - header file for MD5.C
*/
/*
* Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All
* rights reserved.
*
* License to copy and use this software is granted provided that it
* is identified as the "RSA Data Security, Inc. MD5 Message-Digest
* Algorithm" in all material mentioning or referencing this software
* or this function.
*
* License is also granted to make and use derivative works provided
* that such works are identified as "derived from the RSA Data
* Security, Inc. MD5 Message-Digest Algorithm" in all material
* mentioning or referencing the derived work.
*
* RSA Data Security, Inc. makes no representations concerning either
* the merchantability of this software or the suitability of this
* software for any particular purpose. It is provided "as is"
* without express or implied warranty of any kind.
*
* These notices must be retained in any copies of any part of this
* documentation and/or software.
*/
#ifndef _CRYPTO_MD5_H_
#define_CRYPTO_MD5_H_
#include <sys/types.h>
#include <sys/cdefs.h>
#defineMD5_DIGEST_LENGTH16
/* MD5 context. */
typedef struct {
u_int32_t state[4];/* state (ABCD) */
u_int32_t count[2];/* number of bits, modulo 2^64 (lsb first) */
unsigned char buffer[64];/* input buffer */
} MD5_CTX;
extern void MD5Init(MD5_CTX *);
extern void MD5Update(MD5_CTX *, const void *, unsigned int);
extern void MD5Final(unsigned char [MD5_DIGEST_LENGTH], MD5_CTX *);
#endif /* _CRYPTO_MD5_H_ */
branches/cparm/i386/libsaio/Makefile
3737
3838
3939
40
40
4141
4242
4343
disk.o sys.o cache.o bootstruct.o \
stringTable.o load.o pci.o allocate.o misc.o \
vbe.o hfs.o hfs_compare.o \
xml.o md5c.o device_tree.o modules.o \
xml.o md5.o device_tree.o modules.o \
cpu.o platform.o \
fake_efi.o \
device_inject.o pci_root.o \
branches/cparm/i386/libsaio/device_inject.c
196196
197197
198198
199
199
200
201
202
203
204
200205
201206
202207
......
264269
265270
266271
267
272
268273
269274
270275
}
}
string->entries[string->numentries++] = (struct DevPropDevice*)malloc(sizeof(device));
if((string->entries[string->numentries++] = (struct DevPropDevice*)malloc(sizeof(device)))== NULL)
{
free(device);
free(string->entries);
return NULL;
}
string->entries[string->numentries-1] = device;
return device;
if(!device->data)
{
device->data = (uint8_t*)malloc(sizeof(uint8_t));
//device->data = (uint8_t*)malloc(sizeof(uint8_t)); //IMHO this is useless
}
else
{
branches/cparm/i386/libsaio/sys.c
6666
6767
6868
69
70
71
72
73
69
7470
7571
7672
#include "disk.h"
#include "modules.h"
#include "xml.h"
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5
# include <Kernel/libkern/crypto/md5.h>
#else
# include <sys/md5.h>
#endif
# include "md5.h"
#include <uuid/uuid.h>
#if 0 /* No OS X release has ever included this. */
#include <Kernel/uuid/namespace.h>
branches/cparm/i386/libsaio/platform.c
7070
7171
7272
73
73
7474
7575
7676
7777
7878
7979
80
80
8181
8282
8383
8484
8585
86
86
8787
8888
89
90
91
8992
93
9094
9195
9296
......
141145
142146
143147
148
149
150
144151
145
152
146153
147154
148155
149156
150157
151158
152
159
153160
154
161
162
163
164
165
155166
156167
157168
......
161172
162173
163174
164
175
165176
166177
167178
......
316327
317328
318329
319
330
331
332
333
320334
321
322335
323336
324337
......
341354
342355
343356
357
344358
345359
346360
......
352366
353367
354368
369
355370
356371
357372
358373
359
374
375
376
377
378
379
380
381
360382
361383
362384
363385
364386
365387
366
367
368
388
389
390
369391
370392
371393
......
375397
376398
377399
378
400
379401
380402
381403
......
506528
507529
508530
509
531
510532
511533
512534
......
514536
515537
516538
517
539
518540
519541
520542
......
529551
530552
531553
532
554
533555
556
557
534558
535559
536560
struct env_struct {
unsigned long long value;
char name[10];
char *name;
void * ptr;
//int lock;
enum envtype Type;
UT_hash_handle hh; /* makes this structure hashable */
};
static void CopyVarPtr (struct env_struct *var, void* ptr, size_t size);
static int CopyVarPtr (struct env_struct *var, void* ptr, size_t size);
static struct env_struct *find_env(const char *name);
static void _re_set_env_copy(struct env_struct *var , void* ptr,size_t size);
struct env_struct *platform_env = NULL;
static void CopyVarPtr (struct env_struct *var, void* ptr, size_t size)
static int CopyVarPtr (struct env_struct *var, void* ptr, size_t size)
{
var->ptr = malloc(size);
if (!var->ptr) {
return 0;
}
memcpy(var->ptr, ptr, size);
return 1;
}
static struct env_struct *find_env(const char *name) {
struct env_struct *var;
var = (struct env_struct*)malloc(sizeof(struct env_struct));
if (!var) {
return;
}
if (Type == kEnvPtr) {
CopyVarPtr( var, ptr, size);
if (!CopyVarPtr( var, ptr, size)) return;
}
else if (Type == kEnvValue)
var->value = value;
else
return;
var->Type = Type;
var->Type = Type;
strlcpy(var->name, name, sizeof(var->name));
var->name = newString(name);
if (!var->name) {
free(var);
return;
}
if (setjmp(h_buf_error) == -1) {
printf("_set_env: Unable to set environement variable"); // don't try to acces to the string 'name',
#endif
return;
} else {
HASH_ADD_STR( platform_env, name, var );
HASH_ADD_KEYPTR( hh, platform_env, name, strlen(var->name), var );
}
}
#endif
return;
} else {
HASH_DEL( platform_env, var);
HASH_DEL( platform_env, var);
if (var->name) free(var->name);
free(var);
}
free(var);
}
void unset_env(const char *name) {
} else {
HASH_ITER(hh, platform_env, current_var, tmp) {
HASH_DEL(platform_env,current_var);
if (current_var->name) free(current_var->name);
free(current_var);
}
}
struct env_struct *current_var = platform_env;
for(current_var=platform_env;current_var;current_var=(struct env_struct*)(current_var->hh.next))
{
#if DEBUG_PLATFORM >= 2
if (current_var->Type == kEnvValue)
printf(" Name = %s | Type = VALUE | Value = 0x%04x\n",current_var->name,(uint32_t)current_var->value);
else if (current_var->Type == kEnvPtr )
printf(" Name = %s | Type = PTR(Copy) | Value = 0x%x\n",current_var->name,(uint32_t)current_var->ptr);
#else
if (current_var->Type == kEnvValue)
printf("%s: 0x%04x\n",current_var->name,(uint32_t)current_var->value);
else if (current_var->Type == kEnvPtr )
printf("%s(ptr): 0x%x\n",current_var->name,(uint32_t)current_var->ptr);
#endif
}
getc();
}
#endif
/**
Scan platform hardware information, called by the main entry point (common_boot() )
_before_ bootConfig xml parsing settings are loaded
*/
Scan platform hardware information, called by the main entry point (common_boot() )
_before_ bootConfig xml parsing settings are loaded
*/
void scan_platform(void)
{
//memset(&Platform, 0, sizeof(PlatformInfo_t));
#if DEBUG_PLATFORM
DBG("CPU: %s\n", (char*)get_env_ptr(envBrandString));
if (get_env(envVendor) == CPUID_VENDOR_AMD)
DBG("CPU: Vendor/Model/ExtModel: 0x%x/0x%x/0x%x\n", (uint32_t)get_env(envVendor), (uint32_t)get_env(envModel), (uint32_t)get_env(envExtModel));
DBG("CPU: Vendor/Model/ExtModel: 0x%x/0x%x/0x%x\n", (uint32_t)get_env(envVendor), (uint32_t)get_env(envModel), (uint32_t)get_env(envExtModel));
DBG("CPU: Family/ExtFamily: 0x%x/0x%x\n", (uint32_t)get_env(envFamily), (uint32_t)get_env(envExtFamily));
if (get_env(envVendor) == CPUID_VENDOR_AMD) {
DBG("CPU (AMD): TSCFreq: %dMHz\n", (uint32_t)(get_env(envTSCFreq) / 1000000));
century = (century & 0x0F) + ((century / 16) * 10);
}
}
// Calculate the full (4-digit) year
if(century_register != 0) {
} else {
//year += (CURRENT_YEAR / 100) * 100;
//if(year < CURRENT_YEAR) year += 100;
if ((year += 1900) < 1970)
year += 100;
}
void rtc_time(EFI_TIME *time) {
read_rtc(time);
read_rtc(time);
time->TimeZone = EFI_UNSPECIFIED_TIMEZONE;
return ;
}
branches/cparm/i386/libsaio/platform.h
7979
8080
8181
82
83
84
85
86
87
88
82
83
8984
90
91
92
93
94
95
96
97
98
85
86
87
88
89
90
91
92
93
94
95
96
97
98
9999
100
101
102
103
104
105
106
107
108
109
110
111
112
113
100
101
114102
115
103
104
105
116106
117
118
119
120
121
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122122
123
124
125
126
123
124
125
126
127
127128
128
129
130
131
132
133
134
135
129
130
131
132
133
134
136135
136
137
138
139
140
137141
138
139
140
141
142
142
143
144
143145
144
145
146
147
148
149
150
151
152
153
146154
147
148
149
155
156
157
158
150159
151
152
153
154
155
156
157
158
159
160160
161
161
162
163
164
165
166
167
168
162169
163
164
165
166
170
171
172
173
167174
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186175
187176
188177
......
208197
209198
210199
211
200
212201
213202
214203
215204
216205
217206
218
207
219208
220209
221210
} RamSlotInfo_t;
#define envVendor "Vendor"
#define envCPUIDMaxBasic "max_basic"
#define envCPUIDMaxExt "max_ext"
#define envMicrocodeVersion "Microcode"
#define envSignature "Signature"
#define envStepping "Stepping"
#define envModel "Model"
#define envVendor "boot.cpu.vendor"
#define envFamily "boot.cpu.family"
#define envFamily "Family"
#define envExtModel "ExtModel"
#define envExtFamily "ExtFamily"
#define envBrand "Brand"
#define envFeatures "Feat"
#define envExtFeatures "ExtFeat"
#define envSubCstates "sub_Csta"
#define envExtensions "CPUIDext"
#define envBrandString "BrandStr"
#define envCPUIDMaxBasic "boot.cpu.max_basic"
#define envCPUIDMaxExt "boot.cpu.max_ext"
#define envMicrocodeVersion "boot.cpu.microcode_version"
#define envSignature "boot.cpu.signature"
#define envStepping "boot.cpu.stepping"
#define envModel "boot.cpu.model"
#define envBrandString "boot.cpu.brand_string"
#define envNoThreads "boot.cpu.logical_per_package"
#define envNoCores "boot.cpu.cores_per_package"
#define envExtModel "boot.cpu.extmodel"
#define envExtFamily "boot.cpu.extfamily"
#define envBrand "boot.cpu.brand"
#define envFeatures "boot.cpu.feature_bits"
#define envExtFeatures "boot.cpu.extfeature_bits"
#define envDynamicAcceleration "dynAcc"
#define envInvariantAPICTimer "invAPIC"
#define envFineGrainClockMod "fineGrain"
#define envNoThreads "NoThreads"
#define envNoCores "NoCores"
#define envIsMobile "isMobile"
#define envMaxCoef "MaxCoef"
#define envMaxDiv "MaxDiv"
#define envCurrCoef "CurrCoef"
#define envCurrDiv "CurrDiv"
#define envTSCFreq "TSCFreq"
#define envFSBFreq "FSBFreq"
#define envCPUFreq "CPUFreq"
#define envIsServer "isServer"
#define envSubCstates "boot.cpu.mwait.sub_Cstates"
#define envExtensions "boot.cpu.mwait.extensions"
#define envAdler32"adler32"
#define envDynamicAcceleration "boot.cpu.thermal.dynamic_acceleration"
#define envInvariantAPICTimer "boot.cpu.thermal.invariant_APIC_timer"
#define envFineGrainClockMod "boot.cpu.thermal.fine_grain_clock_mod"
#define envCurrCoef "CurrCoef"
#define envCurrDiv "CurrDiv"
#define envTSCFreq "TSCFreq"
#define envFSBFreq "FSBFreq"
#define envCPUFreq "CPUFreq"
#define envIsMobile "boot.hw.is_mobile"
#define envMaxCoef "boot.hw.maxcoef"
#define envMaxDiv "boot.hw.maxdiv"
#define envCurrCoef "boot.hw.currcoef"
#define envCurrDiv "boot.hw.currdiv"
#define envTSCFreq "boot.hw.tscfrequency"
#define envFSBFreq "boot.hw.busfrequency"
#define envCPUFreq "boot.hw.cpufrequency"
#define envIsServer "boot.hw.is_server"
#define envHardwareSignature "boot.hw.signature"
#define envType "boot.hw.type"
#define envUUID "boot.hw.uuid_ptr"
#define envSysId "boot.hw.sysid"
#define envgBIOSDev "boot.hw.bios_device"
#define envgDeviceCount "boot.hw.device_count"
#define envHardwareSignature "HdwSign"
#define envType "Type"
#define envUUID "UUID"
#define envSysId "SysId"
#define envAdler32"boot.kern.adler32"
#define envkCache "boot.kern.kernelcache"
#define envMKextName "boot.kern.mkextcache"
#define envArgCntRemaining "boot.kern.argCount_remaining"
#define envgBootArgs"boot.kern.boot_args"
#define envgBootMode "gBootMode"
#define envgBIOSDev "gBIOSDev"
#define envSysConfigValid "IsSysConf"
#define envgOverrideKernel "IsKover"
#define envgEnableCDROMRescan "CDRescan"
#define envgScanSingleDrive "1Drive"
#define envgDeviceCount "DevCnt"
#define envShouldboot "shldboot"
#define envgBootMode "boot.options.boot_mode"
#define envSysConfigValid "boot.options.sysconfing_valid"
#define envgOverrideKernel "boot.options.kernel_overide"
#define envgEnableCDROMRescan "boot.options.rescan_cdrom"
#define envgScanSingleDrive "boot.options.single_drive"
#define envShouldboot "boot.options.should_boot"
#define envDriverExtSpec "boot.drivers.extspec"
#define envDriverSpec "boot.drivers.spec"
#define envDriverFileSpec "boot.drivers.filespec"
#define envDriverTempSpec "boot.drivers.tempspec"
#define envDriverFileName "boot.drivers.filename"
#define envDriverExtSpec "DrvXSpec"
#define envDriverSpec "DrvSpec"
#define envDriverFileSpec "DrvFSpes"
#define envDriverTempSpec "DrvTSpes"
#define envDriverFileName "DrvFName"
#define envBootBanner "boot.ui.banner"
#define envBootPrompt "boot.ui.prompt"
#define envBootRescanPrompt "boot.ui.promptrescan"
#define envkCache "kCache"
#define envMKextName "MCache"
#define envgMenuRow "boot.ui.menu_row"
#define envgMenuHeight "boot.ui.menu_height"
#define envgMenuItemCount "boot.ui.menu_itemcount"
#define envgMenuTop "boot.ui.menu_top"
#define envgMenuBottom "boot.ui.menu_bottom"
#define envgMenuSelection "boot.ui.menu_selection"
#define envgMenuStart "boot.ui.menu_start"
#define envgMenuEnd "boot.ui.menu_end"
#define envBootBanner "Banner"
#define envBootPrompt "Prompt"
#define envBootRescanPrompt "PromptBis"
#define envConvMem "boot.memmap.Conventional"
#define envExtMem "boot.memmap.Extended"
#define envMemoryMap "boot.memmap.Address"
#define envMemoryMapCnt "boot.memmap.Count"
#define envgMenuRow "MenuRow"
#define envgMenuHeight "MenuH"
#define envgMenuItemCount "MenuCnt"
#define envgMenuTop "MenuTop"
#define envgMenuBottom "MenuB"
#define envgMenuSelection "MenuSel"
#define envgMenuStart "MenuStart"
#define envgMenuEnd "MenuEnd"
#define envArgCntRemaining "ArgCntRem"
#define envgBootArgs"gBootArgs"
#define envRamFrequency "boot.ram.frequency"
#define envRamCas "boot.ram.tCAS"
#define envRamTrc "boot.ram.tRCD"
#define envRamRas "boot.ram.tRAS"
#define envRamTrp "boot.ram.tRP"
#define envRamChannels "boot.ram.channels"
#define envRamType "boot.ram.type"
#define envRamDimm "boot.ram.dimm"
#define envConvMem "ConvMem"
#define envExtMem "ExtMem"
#define envMemoryMap "MemoryMap"
#define envMemoryMapCnt "MemMapCnt"
#define envDMIMemModules "boot.dmi.memory_modules"
#define envDMIMaxMemorySlots "boot.dmi.max_slots"
#define envDMICntMemorySlots "boot.dmi.slots_count"
#define envDmiDimm "boot.dmi.dimm"
#define envRamFrequency "RamFreq"
#define envRamCas "tCAS"
#define envRamTrc "tRCD"
#define envRamRas "tRAS"
#define envRamTrp "tRP"
#define envRamChannels "RamChans"
#define envRamType "RamType"
#define envRamCas "tCAS"
#define envRamCas "tCAS"
#define envRamCas "tCAS"
#define envRamCas "tCAS"
#define envDMIMemModules "DmiMemMod"
#define envDMIMaxMemorySlots "DmiMaxSlt"
#define envDMICntMemorySlots "DmiCntSlt"
#define envRamDimm "RamDimm"
#define envDmiDimm "DmiDimm"
#if UNUSED
typedef struct _PlatformInfo_t {
charBrandString[48];// 48 Byte Branding String
uint8_t Brand;
uint32_tMicrocodeVersion; // The microcode version number a.k.a. signature a.k.a. BIOS ID
bool isMobile;
bool isServer;// Unlike isMobile, if this value is set it will disable all kind of detection and enforce "Server" as platform (must be set by user)
boolean_tdynamic_acceleration;
boolean_tinvariant_APIC_timer;
boolean_tfine_grain_clock_mod;
uint32_t cpuid_max_basic;
uint32_t cpuid_max_ext;
uint32_tsub_Cstates;
branches/cparm/i386/libsaio/disk.c
822822
823823
824824
825
826
825827
826828
827829
828830
829831
830832
831
832
833
834
835
833
836834
837
838
839
840
841
842
843
844
845
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
846850
847
848
849
850
851
852
853851
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
870868
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
887904
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
905
908906
909
907
910908
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
928926
929927
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
962960
963
961
964962
965
966
967
968
969
970
971
972
973
974
975
963
964
965
966
967
968
969
970
971
972
973
976974
977975
978
979
980
981
982
983
984
985
986
987
976
977
978
979
980
981
982
983
984
985
988986
989987
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
10111009
1012
1010
10131011
1014
1015
1016
1017
1018
1019
1020
1021
1012
1013
1014
1015
1016
1017
1018
1019
10221020
1023
1024
1025
1026
1027
1028
1029
1030
1031
1021
10321022
1033
1023
1024
1025
1026
1027
1028
1029
1030
1031
10341032
1035
1036
1037
1038
1033
1034
1035
1036
1037
1038
10391039
1040
1041
1042
1043
1044
1045
1040
1041
10461042
1043
1044
10471045
1048
10491046
10501047
10511048
......
11031100
11041101
11051102
1106
1103
1104
1105
11071106
11081107
11091108
......
11141113
11151114
11161115
1116
1117
1118
11171119
11181120
11191121
......
11211123
11221124
11231125
1126
1127
1128
1129
1130
1131
1132
1133
11241134
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
11781152
1179
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
11801185
11811186
11821187
......
12741279
12751280
12761281
1282
1283
1284
12771285
12781286
12791287
......
13691377
13701378
13711379
1372
1380
1381
1382
13731383
13741384
13751385
......
13771387
13781388
13791389
1390
1391
1392
13801393
13811394
13821395
......
15171530
15181531
15191532
1520
1533
15211534
15221535
15231536
......
16151628
16161629
16171630
1618
1619
1620
1621
1631
1632
1633
1634
16221635
16231636
16241637
......
18871900
18881901
18891902
1903
1904
1905
18901906
18911907
18921908
......
19561972
19571973
19581974
1959
1975
19601976
19611977
19621978
spc = 1;
}
#endif
// Create a new mapping.
map = (struct DiskBVMap *) malloc( sizeof(*map) );
if ( !map )
{
return NULL;
}
do {
// Create a new mapping.
//map = (struct DiskBVMap *) malloc( sizeof(*map) );
//if ( map )
//{
do {
map->biosdev = biosdev;
map->bvr = NULL;
map->bvrcnt = 0;
map->next = gDiskBVMap;
gDiskBVMap = map;
// Create a record for each partition found on the disk.
while ( getNextFDiskPartition( biosdev, &partno, &part ) )
map->biosdev = biosdev;
map->bvr = NULL;
map->bvrcnt = 0;
map->next = gDiskBVMap;
gDiskBVMap = map;
// Create a record for each partition found on the disk.
while ( getNextFDiskPartition( biosdev, &partno, &part ) )
{
DEBUG_DISK(("%s: part %d [%x]\n", __FUNCTION__,
partno, part->systid));
bvr = 0;
switch ( part->systid )
{
DEBUG_DISK(("%s: part %d [%x]\n", __FUNCTION__,
partno, part->systid));
bvr = 0;
switch ( part->systid )
{
#ifdef UFS_SUPPORT
case FDISK_UFS:
bvr = newFDiskBVRef(
biosdev, partno,
part->relsect + UFS_FRONT_PORCH/BPS,
part,
UFSInitPartition,
UFSLoadFile,
UFSReadFile,
UFSGetDirEntry,
UFSGetFileBlock,
UFSGetUUID,
UFSGetDescription,
UFSFree,
0,
kBIOSDevTypeHardDrive, 0);
break;
case FDISK_UFS:
bvr = newFDiskBVRef(
biosdev, partno,
part->relsect + UFS_FRONT_PORCH/BPS,
part,
UFSInitPartition,
UFSLoadFile,
UFSReadFile,
UFSGetDirEntry,
UFSGetFileBlock,
UFSGetUUID,
UFSGetDescription,
UFSFree,
0,
kBIOSDevTypeHardDrive, 0);
break;
#endif
case FDISK_HFS:
bvr = newFDiskBVRef(
biosdev, partno,
part->relsect,
part,
HFSInitPartition,
HFSLoadFile,
HFSReadFile,
HFSGetDirEntry,
HFSGetFileBlock,
HFSGetUUID,
HFSGetDescription,
HFSFree,
0,
kBIOSDevTypeHardDrive, 0);
case FDISK_HFS:
bvr = newFDiskBVRef(
biosdev, partno,
part->relsect,
part,
HFSInitPartition,
HFSLoadFile,
HFSReadFile,
HFSGetDirEntry,
HFSGetFileBlock,
HFSGetUUID,
HFSGetDescription,
HFSFree,
0,
kBIOSDevTypeHardDrive, 0);
break;
// turbo - we want the booter type scanned also
case FDISK_BOOTER:
if (part->bootid & FDISK_ACTIVE) {
gBIOSBootVolume = newFDiskBVRef(
biosdev, partno,
part->relsect,
part,
HFSInitPartition,
HFSLoadFile,
HFSReadFile,
HFSGetDirEntry,
HFSGetFileBlock,
HFSGetUUID,
HFSGetDescription,
HFSFree,
0,
kBIOSDevTypeHardDrive, 0);
break;
// turbo - we want the booter type scanned also
case FDISK_BOOTER:
if (part->bootid & FDISK_ACTIVE) {
gBIOSBootVolume = newFDiskBVRef(
biosdev, partno,
part->relsect,
part,
HFSInitPartition,
HFSLoadFile,
HFSReadFile,
HFSGetDirEntry,
HFSGetFileBlock,
HFSGetUUID,
HFSGetDescription,
HFSFree,
0,
kBIOSDevTypeHardDrive, 0);
break;
}
}
#ifndef UFS_SUPPORT
break;
break;
#else
//case FDISK_BOOTER:
booterUFS = newFDiskBVRef(
biosdev, partno,
((part->relsect + spc - 1) / spc) * spc,
part,
UFSInitPartition,
UFSLoadFile,
UFSReadFile,
UFSGetDirEntry,
UFSGetFileBlock,
UFSGetUUID,
UFSGetDescription,
UFSFree,
0,
kBIOSDevTypeHardDrive, 0);
break;
//case FDISK_BOOTER:
booterUFS = newFDiskBVRef(
biosdev, partno,
((part->relsect + spc - 1) / spc) * spc,
part,
UFSInitPartition,
UFSLoadFile,
UFSReadFile,
UFSGetDirEntry,
UFSGetFileBlock,
UFSGetUUID,
UFSGetDescription,
UFSFree,
0,
kBIOSDevTypeHardDrive, 0);
break;
#endif
#ifndef NO_WIN_SUPPORT
case FDISK_FAT32:
case FDISK_DOS12:
case FDISK_DOS16S:
case FDISK_DOS16B:
case FDISK_SMALLFAT32:
case FDISK_DOS16SLBA:
bvr = newFDiskBVRef(
biosdev, partno,
part->relsect,
part,
MSDOSInitPartition,
MSDOSLoadFile,
MSDOSReadFile,
MSDOSGetDirEntry,
MSDOSGetFileBlock,
MSDOSGetUUID,
MSDOSGetDescription,
MSDOSFree,
0,
kBIOSDevTypeHardDrive, 0);
break;
case FDISK_NTFS:
bvr = newFDiskBVRef(
biosdev, partno,
part->relsect,
part,
0, 0, 0, 0, 0,
NTFSGetUUID,
NTFSGetDescription,
(BVFree)free,
0, kBIOSDevTypeHardDrive, 0);
break;
case FDISK_FAT32:
case FDISK_DOS12:
case FDISK_DOS16S:
case FDISK_DOS16B:
case FDISK_SMALLFAT32:
case FDISK_DOS16SLBA:
bvr = newFDiskBVRef(
biosdev, partno,
part->relsect,
part,
MSDOSInitPartition,
MSDOSLoadFile,
MSDOSReadFile,
MSDOSGetDirEntry,
MSDOSGetFileBlock,
MSDOSGetUUID,
MSDOSGetDescription,
MSDOSFree,
0,
kBIOSDevTypeHardDrive, 0);
break;
case FDISK_NTFS:
bvr = newFDiskBVRef(
biosdev, partno,
part->relsect,
part,
0, 0, 0, 0, 0,
NTFSGetUUID,
NTFSGetDescription,
(BVFree)free,
0, kBIOSDevTypeHardDrive, 0);
break;
#endif
#ifndef NO_LINUX_SUPPORT
case FDISK_LINUX:
bvr = newFDiskBVRef(
biosdev, partno,
part->relsect,
part,
0, 0, 0, 0, 0, 0,
EX2GetDescription,
(BVFree)free,
0, kBIOSDevTypeHardDrive, 0);
break;
case FDISK_LINUX:
bvr = newFDiskBVRef(
biosdev, partno,
part->relsect,
part,
0, 0, 0, 0, 0, 0,
EX2GetDescription,
(BVFree)free,
0, kBIOSDevTypeHardDrive, 0);
break;
#endif
#ifndef NO_HAIKU_SUPPORT
case FDISK_BEFS:
bvr = newFDiskBVRef(
biosdev, partno,
part->relsect,
part,
0, 0, 0, 0, 0, 0,
BeFSGetDescription,
(BVFree)free,
0, kBIOSDevTypeHardDrive, 0);
break;
case FDISK_BEFS:
bvr = newFDiskBVRef(
biosdev, partno,
part->relsect,
part,
0, 0, 0, 0, 0, 0,
BeFSGetDescription,
(BVFree)free,
0, kBIOSDevTypeHardDrive, 0);
break;
#endif
#ifndef NO_OTHERS_BSD_SUPPORT
case FDISK_FREEBSD:
bvr = newFDiskBVRef(
biosdev, partno,
part->relsect,
part,
0, 0, 0, 0, 0, 0,
FreeBSDGetDescription,
(BVFree)free,
0, kBIOSDevTypeHardDrive, 0);
break;
case FDISK_OPENBSD:
bvr = newFDiskBVRef(
biosdev, partno,
part->relsect,
part,
0, 0, 0, 0, 0, 0,
OpenBSDGetDescription,
(BVFree)free,
0, kBIOSDevTypeHardDrive, 0);
break;
case FDISK_FREEBSD:
bvr = newFDiskBVRef(
biosdev, partno,
part->relsect,
part,
0, 0, 0, 0, 0, 0,
FreeBSDGetDescription,
(BVFree)free,
0, kBIOSDevTypeHardDrive, 0);
break;
case FDISK_OPENBSD:
bvr = newFDiskBVRef(
biosdev, partno,
part->relsect,
part,
0, 0, 0, 0, 0, 0,
OpenBSDGetDescription,
(BVFree)free,
0, kBIOSDevTypeHardDrive, 0);
break;
#endif
default:
default:
#if UNUSED
bvr = newFDiskBVRef(
biosdev, partno,
part->relsect,
part,
0, 0, 0, 0, 0, 0, 0,
(BVFree)free,
0,
kBIOSDevTypeHardDrive, 0);
bvr = newFDiskBVRef(
biosdev, partno,
part->relsect,
part,
0, 0, 0, 0, 0, 0, 0,
(BVFree)free,
0,
kBIOSDevTypeHardDrive, 0);
#endif
break;
}
if ( bvr )
{
bvr->next = map->bvr;
map->bvr = bvr;
map->bvrcnt++;
}
break;
}
if ( bvr )
{
bvr->next = map->bvr;
map->bvr = bvr;
map->bvrcnt++;
}
}
#ifdef UFS_SUPPORT
// Booting from a CD with an UFS filesystem embedded
// in a booter partition.
if ( booterUFS )
// Booting from a CD with an UFS filesystem embedded
// in a booter partition.
if ( booterUFS )
{
if ( map->bvrcnt == 0 )
{
if ( map->bvrcnt == 0 )
{
map->bvr = booterUFS;
map->bvrcnt++;
}
else free( booterUFS );
map->bvr = booterUFS;
map->bvrcnt++;
}
else free( booterUFS );
}
#endif
//}
} while (0);
/*
unsigned int blksize;
unsigned int factor;
void *buffer = malloc(BPS);
if (!buffer) {
return NULL;
}
/* Check for alternate block size */
if (readBytes( biosdev, 0, 0, BPS, buffer ) != 0) {
return NULL;
if (blksize != BPS) {
free(buffer);
buffer = malloc(blksize);
if (!buffer) {
return NULL;
}
}
factor = blksize / BPS;
} else {
factor = 1;
}
// Create a new mapping.
map = (struct DiskBVMap *) malloc( sizeof(*map) );
if ( !map )
{
return NULL;
}
do {
// Create a new mapping.
map = (struct DiskBVMap *) malloc( sizeof(*map) );
if ( map )
{
int error;
DPME *dpme_p = (DPME *)buffer;
UInt32 i, npart = UINT_MAX;
BVRef bvr;
map->biosdev = biosdev;
map->bvr = NULL;
map->bvrcnt = 0;
map->next = gDiskBVMap;
gDiskBVMap = map;
for (i=0; i<npart; i++) {
error = readBytes( biosdev, (kAPMSector + i) * factor, 0, blksize, buffer );
if (error || OSSwapBigToHostInt16(dpme_p->dpme_signature) != DPME_SIGNATURE) {
break;
}
if (i==0) {
npart = OSSwapBigToHostInt32(dpme_p->dpme_map_entries);
}
/*
printf("name = %s, %s%s %d -> %d [%d -> %d] {%d}\n",
dpme.dpme_name, dpme.dpme_type, (dpme.dpme_flags & DPME_FLAGS_BOOTABLE) ? "(bootable)" : "",
dpme.dpme_pblock_start, dpme.dpme_pblocks,
dpme.dpme_lblock_start, dpme.dpme_lblocks,
dpme.dpme_boot_block);
*/
if (strcmp(dpme_p->dpme_type, "Apple_HFS") == 0) {
bvr = newAPMBVRef(biosdev,
i,
OSSwapBigToHostInt32(dpme_p->dpme_pblock_start) * factor,
dpme_p,
HFSInitPartition,
HFSLoadFile,
HFSReadFile,
HFSGetDirEntry,
HFSGetFileBlock,
HFSGetUUID,
HFSGetDescription,
HFSFree,
0,
kBIOSDevTypeHardDrive, 0);
bvr->next = map->bvr;
map->bvr = bvr;
map->bvrcnt++;
}
int error;
DPME *dpme_p = (DPME *)buffer;
UInt32 i, npart = UINT_MAX;
BVRef bvr;
map->biosdev = biosdev;
map->bvr = NULL;
map->bvrcnt = 0;
map->next = gDiskBVMap;
gDiskBVMap = map;
for (i=0; i<npart; i++) {
error = readBytes( biosdev, (kAPMSector + i) * factor, 0, blksize, buffer );
if (error || OSSwapBigToHostInt16(dpme_p->dpme_signature) != DPME_SIGNATURE) {
break;
}
}
if (i==0) {
npart = OSSwapBigToHostInt32(dpme_p->dpme_map_entries);
}
/*
printf("name = %s, %s%s %d -> %d [%d -> %d] {%d}\n",
dpme.dpme_name, dpme.dpme_type, (dpme.dpme_flags & DPME_FLAGS_BOOTABLE) ? "(bootable)" : "",
dpme.dpme_pblock_start, dpme.dpme_pblocks,
dpme.dpme_lblock_start, dpme.dpme_lblocks,
dpme.dpme_boot_block);
*/
if (strcmp(dpme_p->dpme_type, "Apple_HFS") == 0) {
bvr = newAPMBVRef(biosdev,
i,
OSSwapBigToHostInt32(dpme_p->dpme_pblock_start) * factor,
dpme_p,
HFSInitPartition,
HFSLoadFile,
HFSReadFile,
HFSGetDirEntry,
HFSGetFileBlock,
HFSGetUUID,
HFSGetDescription,
HFSFree,
0,
kBIOSDevTypeHardDrive, 0);
bvr->next = map->bvr;
map->bvr = bvr;
map->bvrcnt++;
}
}
} while (0);
free(buffer);
struct DiskBVMap * map = NULL;
void *buffer = malloc(BPS);
if (!buffer) {
goto scanErr;
}
int error;
if ( (error = readBytes( biosdev, /*secno*/0, 0, BPS, buffer )) != 0) {
DBG("Failed to read boot sector from BIOS device %02xh. Error=%d\n", biosdev, error);
if(bufferSize == 0)
goto scanErr;
buffer = malloc(bufferSize);
if (!buffer) {
goto scanErr;
}
if(readBytes(biosdev, gptBlock, 0, bufferSize, buffer) != 0)
goto scanErr;
// Allocate a new map for this BIOS device and insert it into the chain
map = malloc(sizeof(*map));
if (!map) {
goto scanErr;
}
map->biosdev = biosdev;
map->bvr = NULL;
map->bvrcnt = 0;
}
scanErr:
free(buffer);
if (buffer) free(buffer);
if(map)
{
sprintf(dirSpec, "hd(%d,%d)/Mac OS X Install Data/index.sproduct", BIOS_DEV_UNIT(bvr), bvr->part_no); // 10.7
if (!getOSInstallVersion(dirSpec, str, &systemVersion))
return false;
else
return true;
return false;
else
return true;
}
else return true;
}
* Allocate and copy the matched bvr entry into a new one.
*/
newBVR = (BVRef) malloc(sizeof(*newBVR));
if (!newBVR) {
continue;
}
bcopy(bvr, newBVR, sizeof(*newBVR));
/*
int ret = 1;
BVRef bvr = chain;
BVRef nextBVR = NULL;
while (bvr < (BVRef)ULONG_MAX)
{
if (!bvr) {
branches/cparm/i386/libsaio/uthash.h
646646
647647
648648
649
650
651
652
653
654
655
656
657
658
659
660
649
650
651
652
653
654
655
656
657
658
659
660
661
662
661663
662664
663665
_he_hh_nxt = _he_thh->hh_next; \
HASH_TO_BKT( _he_thh->hashv, tbl->num_buckets*2, _he_bkt); \
_he_newbkt = &(_he_new_buckets[ _he_bkt ]); \
if (!_he_newbkt) { uthash_fatal( "out of memory"); } \
if (++(_he_newbkt->count) > tbl->ideal_chain_maxlen) { \
tbl->nonideal_items++; \
_he_newbkt->expand_mult = _he_newbkt->count / \
tbl->ideal_chain_maxlen; \
} \
_he_thh->hh_prev = NULL; \
_he_thh->hh_next = _he_newbkt->hh_head; \
if (_he_newbkt->hh_head) _he_newbkt->hh_head->hh_prev = \
_he_thh; \
_he_newbkt->hh_head = _he_thh; \
_he_thh = _he_hh_nxt; \
if (_he_newbkt) { \
if (++(_he_newbkt->count) > tbl->ideal_chain_maxlen) { \
tbl->nonideal_items++; \
_he_newbkt->expand_mult = _he_newbkt->count / \
tbl->ideal_chain_maxlen; \
} \
_he_thh->hh_prev = NULL; \
_he_thh->hh_next = _he_newbkt->hh_head; \
if (_he_newbkt->hh_head) _he_newbkt->hh_head->hh_prev = \
_he_thh; \
_he_newbkt->hh_head = _he_thh; \
_he_thh = _he_hh_nxt; \
} \
else { uthash_fatal( "out of memory"); } \
} \
} \
uthash_free( tbl->buckets, tbl->num_buckets*sizeof(struct UT_hash_bucket) ); \
branches/cparm/i386/libsaio/pci.c
8989
9090
9191
92
93
94
9295
9396
9497
......
145148
146149
147150
151
152
153
154
155
148156
149157
150158
......
160168
161169
162170
171
172
173
174
163175
164176
165177
continue;
}
new = (pci_dt_t*)malloc(sizeof(pci_dt_t));
if (!new) {
continue;
}
bzero(new, sizeof(pci_dt_t));
new->dev.addr= pci_addr;
new->vendor_id= id & 0xffff;
dev_path = malloc(sizeof(char) * 256);// TODO: remove
root_pci_dev = malloc(sizeof(pci_dt_t));
if (!dev_path || !root_pci_dev) {
stop("Couldn't allocate memory for the pci root device\n");
return ;
}
bzero(root_pci_dev, sizeof(pci_dt_t));
enable_pci_devs();
scan_pci_bus(root_pci_dev, 0);
{
char* buffer = malloc(sizeof(char) * 256);
if (!buffer) {
return NULL;
}
pci_dt_t*current;
pci_dt_t*end;
chartmp[64];
branches/cparm/i386/libsaio/stringTable.c
740740
741741
742742
743
744
745
743746
744747
745748
"rd(0,0)/Library/Preferences/SystemConfiguration/com.apple.Boot.plist",
"/Library/Preferences/SystemConfiguration/com.apple.Boot.plist",
"bt(0,0)/Library/Preferences/SystemConfiguration/com.apple.Boot.plist",
"rd(0,0)/OS X Install Data/com.apple.Boot.plist",
"/OS X Install Data/com.apple.Boot.plist",
"bt(0,0)/OS X Install Data/com.apple.Boot.plist",
"rd(0,0)/Mac OS X Install Data/com.apple.Boot.plist",
"/Mac OS X Install Data/com.apple.Boot.plist",
"bt(0,0)/Mac OS X Install Data/com.apple.Boot.plist"
branches/cparm/i386/libsaio/convert.c
1010
1111
1212
13
14
15
16
13
14
15
16
1717
1818
1919
2020
21
21
2222
2323
2424
2525
2626
27
28
27
28
2929
3030
3131
3232
33
33
3434
3535
3636
......
4545
4646
4747
48
48
4949
5050
5151
......
7575
7676
7777
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
78
79
80
81
82
83
84
85
86
9387
94
95
96
97
98
99
100
101
102
103
104
88
89
90
91
92
93
94
95
96
10597
106
107
108
109
110
98
11199
112
113
114
115
116
117
118
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
119125
120
126
127
121128
122
123
124
125
126
127
128
129
129
130
131
132
133
130134
/** Transform a 16 bytes hexadecimal value UUID to a string */
const char * getStringFromUUID(const EFI_CHAR8* eUUID)
{
static char msg[UUID_STR_LEN] = "";
if (!eUUID) return "";
const unsigned char * uuid = (unsigned char*) eUUID;
sprintf(msg, "%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x",
static char msg[UUID_STR_LEN] = "";
if (!eUUID) return "";
const unsigned char * uuid = (unsigned char*) eUUID;
sprintf(msg, "%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x",
uuid[0], uuid[1], uuid[2], uuid[3],
uuid[4], uuid[5], uuid[6], uuid[7],
uuid[8], uuid[9], uuid[10],uuid[11],
uuid[12],uuid[13],uuid[14],uuid[15]);
return msg ;
return msg ;
}
/** Parse an UUID string into an (EFI_CHAR8*) buffer */
EFI_CHAR8* getUUIDFromString(const char *source)
{
if (!source) return 0;
if (!source) return 0;
char*p = (char *)source;
inti;
charbuf[3];
static EFI_CHAR8 uuid[UUID_LEN+1]="";
buf[2] = '\0';
for (i=0; i<UUID_LEN; i++) {
if (p[0] == '\0' || p[1] == '\0' || !isxdigit(p[0]) || !isxdigit(p[1])) {
}
}
uuid[UUID_LEN]='\0';
if (*p != '\0') {
verbose("[ERROR] UUID='%s' syntax error\n", source);
return 0;
void *convertHexStr2Binary(const char *hexStr, int *outLength)
{
int len;
char hexNibble;
char hexByte[2];
uint8_t binChar;
uint8_t *binStr;
int hexStrIdx, binStrIdx, hexNibbleIdx;
len = strlen(hexStr);
if (len > 1)
{
// the resulting binary will be the half size of the input hex string
binStr = malloc(len / 2);
binStrIdx = 0;
hexNibbleIdx = 0;
for (hexStrIdx = 0; hexStrIdx < len; hexStrIdx++)
int len;
char hexNibble;
char hexByte[2];
uint8_t binChar;
uint8_t *binStr;
int hexStrIdx, binStrIdx, hexNibbleIdx;
len = strlen(hexStr);
if (len > 1)
{
hexNibble = hexStr[hexStrIdx];
// ignore all chars except valid hex numbers
if ((hexNibble >= '0' && hexNibble <= '9')
|| (hexNibble >= 'A' && hexNibble <= 'F')
|| (hexNibble >= 'a' && hexNibble <= 'f'))
{
hexByte[hexNibbleIdx++] = hexNibble;
// found both two nibbles, convert to binary
if (hexNibbleIdx == 2)
// the resulting binary will be the half size of the input hex string
binStr = malloc(len / 2);
if (!binStr) {
*outLength = 0;
return NULL;
}
binStrIdx = 0;
hexNibbleIdx = 0;
for (hexStrIdx = 0; hexStrIdx < len; hexStrIdx++)
{
binChar = 0;
for (hexNibbleIdx = 0; (unsigned)hexNibbleIdx < sizeof(hexByte); hexNibbleIdx++)
{
if (hexNibbleIdx > 0) binChar = binChar << 4;
hexNibble = hexStr[hexStrIdx];
if (hexByte[hexNibbleIdx] <= '9') binChar += hexByte[hexNibbleIdx] - '0';
else if (hexByte[hexNibbleIdx] <= 'F') binChar += hexByte[hexNibbleIdx] - ('A' - 10);
else if (hexByte[hexNibbleIdx] <= 'f') binChar += hexByte[hexNibbleIdx] - ('a' - 10);
}
binStr[binStrIdx++] = binChar;
hexNibbleIdx = 0;
// ignore all chars except valid hex numbers
if ((hexNibble >= '0' && hexNibble <= '9')
|| (hexNibble >= 'A' && hexNibble <= 'F')
|| (hexNibble >= 'a' && hexNibble <= 'f'))
{
hexByte[hexNibbleIdx++] = hexNibble;
// found both two nibbles, convert to binary
if (hexNibbleIdx == 2)
{
binChar = 0;
for (hexNibbleIdx = 0; (unsigned)hexNibbleIdx < sizeof(hexByte); hexNibbleIdx++)
{
if (hexNibbleIdx > 0) binChar = binChar << 4;
if (hexByte[hexNibbleIdx] <= '9') binChar += hexByte[hexNibbleIdx] - '0';
else if (hexByte[hexNibbleIdx] <= 'F') binChar += hexByte[hexNibbleIdx] - ('A' - 10);
else if (hexByte[hexNibbleIdx] <= 'f') binChar += hexByte[hexNibbleIdx] - ('a' - 10);
}
binStr[binStrIdx++] = binChar;
hexNibbleIdx = 0;
}
}
}
}
*outLength = binStrIdx;
return binStr;
}
*outLength = binStrIdx;
return binStr;
}
else
{
*outLength = 0;
return NULL;
}
else
{
*outLength = 0;
return NULL;
}
}
branches/cparm/i386/libsaio/fake_efi.c
7979
8080
8181
82
83
84
85
86
87
88
89
90
8291
8392
8493
......
150159
151160
152161
162
163
164
165
166
153167
154168
155169
......
185199
186200
187201
188
189202
203
204
190205
191206
192207
......
557572
558573
559574
560
561
575
576
577
578
579
580
581
582
583
584
562585
563586
564587
static inline char * mallocStringForGuid(EFI_GUID const *pGuid)
{
char *string = malloc(37);
if (!string) {
#if DEBUG_EFI
char string_d[37];
efi_guid_unparse_upper(pGuid, string_d);
printf("Couldn't allocate Guid String for %s\n", string_d);
#endif
return NULL;
}
efi_guid_unparse_upper(pGuid, string);
return string;
}
if (pGuid == NULL || table == NULL)
return EFI_INVALID_PARAMETER;
char * GuidStr = mallocStringForGuid(pGuid);
if (!GuidStr) {
return EFI_OUT_OF_RESOURCES;
}
//Azi: as is, cpu's with em64t will use EFI64 on pre 10.6 systems,
// wich seems to cause no problem. In case it does, force i386 arch.
if (archCpuType == CPU_TYPE_I386)
gNumTables64++ ;
}
Node *tableNode = DT__AddChild(gEfiConfigurationTableNode, mallocStringForGuid(pGuid));
Node *tableNode = DT__AddChild(gEfiConfigurationTableNode, GuidStr);
// Use the pointer to the GUID we just stuffed into the system table
DT__AddProperty(tableNode, "guid", sizeof(EFI_GUID), (void*)pGuid);
if (!key || !(*key) || !src) return 0;
*len = strlen(src);
dst = (EFI_CHAR16*) malloc( ((*len)+1) * 2 );
int tmp_len = strlen(src);
dst = (EFI_CHAR16*) malloc( ((tmp_len)+1) * 2 );
if (!dst)
{
*len = 0;
return NULL;
}
*len = tmp_len;
{
size_t i = 0;
for (; i < (*len); i++) dst[i] = src[i];
branches/cparm/i386/libsaio/misc.c
132132
133133
134134
135
135
136
137
136138
137139
138140
int tab[rand_tab_len];
struct ran_obj * self = (struct ran_obj * )malloc(sizeof(struct ran_obj));
if (!self) {
return NULL;
}
bzero(self,sizeof(struct ran_obj));
self->rmin= rmin;
branches/cparm/i386/boot2/graphics.c
5757
5858
5959
60
60
6161
6262
6363
6464
6565
66
6667
67
68
6869
6970
7071
72
7173
72
74
7375
76
7477
75
78
7679
7780
7881
82
7983
80
84
8185
86
8287
88
8389
90
8491
92
8593
86
94
8795
8896
8997
unsigned char **newImageData )
{
int cnt;
unsigned char *img = 0;
unsigned char *img;
unsigned short *img16;
unsigned long *img32;
switch ( VIDEO(depth) ) {
case 16 :
{
img16 = malloc(width * height * 2);
if ( !img16 ) break;
if ( !img16 ) return 1;
for (cnt = 0; cnt < (width * height); cnt++)
img16[cnt] = lookUpCLUTIndex(imageData[cnt], 16);
img = (unsigned char *)img16;
*newImageData = img;
break;
}
case 32 :
{
img32 = malloc(width * height * 4);
if ( !img32 ) break;
if ( !img32 ) return 1;
for (cnt = 0; cnt < (width * height); cnt++)
img32[cnt] = lookUpCLUTIndex(imageData[cnt], 32);
img = (unsigned char *)img32;
*newImageData = img;
break;
}
default :
{
img = malloc(width * height);
if ( !img ) return 1;
bcopy(imageData, img, width * height);
*newImageData = img;
break;
}
}
*newImageData = img;
return 0;
}
branches/cparm/i386/boot2/boot.c
310310
311311
312312
313
314
315
316
317
318
319
320
313
314
315
316
317
318
319
320
321
322
323
321324
322325
323326
......
10361039
10371040
10381041
1042
1043
1044
10391045
10401046
10411047
appleBootPict = (uint8_t *) __decodeRLE(gAppleBootPictRLE, kAppleBootRLEBlocks, bootImageWidth * bootImageHeight);
if (appleBootPict)
{
__convertImage(bootImageWidth, bootImageHeight, appleBootPict, &bootImageData);
if (bootImageData)
{
x = (screen_params[0] - MIN(kAppleBootWidth, screen_params[0])) / 2;
y = (screen_params[1] - MIN(kAppleBootHeight, screen_params[1])) / 2;
__drawDataRectangle(x, y, kAppleBootWidth, kAppleBootHeight, bootImageData);
free(bootImageData);
}
if(__convertImage(bootImageWidth, bootImageHeight, appleBootPict, &bootImageData) == 0)
{
if (bootImageData)
{
x = (screen_params[0] - MIN(kAppleBootWidth, screen_params[0])) / 2;
y = (screen_params[1] - MIN(kAppleBootHeight, screen_params[1])) / 2;
__drawDataRectangle(x, y, kAppleBootWidth, kAppleBootHeight, bootImageData);
free(bootImageData);
}
}
free(appleBootPict);
}
uuidSet = false;
char * valueBuffer;
valueBuffer = malloc(VALUE_SIZE);
if (!valueBuffer) {
return;
}
char * argP = bootArgs->CommandLine;
valueBuffer[0] = '*';
if (cnt > VALUE_SIZE)
branches/cparm/i386/boot2/options.c
116116
117117
118118
119
119
120120
121
121
122122
123
123
124124
125125
126126
......
682682
683683
684684
685
686
687
688
685689
686690
687691
692
693
694
695
688696
689697
690
698
699
700
701
702
691703
692704
693705
......
12771289
12781290
12791291
1292
1293
1294
1295
12801296
12811297
12821298
//==========================================================================
static int countdown( const char * msg, int row, int timeout, int *optionKey )
static int countdown( const char * msg, register int row, register int timeout, int *optionKey )
{
unsigned long time;
register unsigned long time;
int ch = 0;
int col = strlen(msg) + 1;
register int col = strlen(msg) + 1;
flushKeyboardBuffer();
if (getValueForKey(kCDROMPromptKey, &val, &cnt, DEFAULT_BOOT_CONFIG)) {
prompt = malloc(cnt + 1);
if (!prompt) {
stop("Couldn't allocate memory for the prompt\n"); //TODO: Find a better stategie
return -1;
}
strncat(prompt, val, cnt);
} else {
name = malloc(80);
if (!name) {
stop("Couldn't allocate memory for the device name\n"); //TODO: Find a better stategie
return -1;
}
getBootVolumeDescription(gBootVolume, name, 79, false);
prompt = malloc(256);
if (!prompt) {
free(name);
stop("Couldn't allocate memory for the prompt\n"); //TODO: Find a better stategie
return -1;
}
sprintf(prompt, "Press ENTER to start up from %s, or press any key to enter startup options.", name);
free(name);
}
size = MAX_TEXT_FILE_SIZE;
}
buf = malloc(size);
if (!buf) {
printf("Couldn't allocate memory for the buf in showTextFile\n");
return ;
}
read(fd, buf, size);
close(fd);
showTextBuffer(buf, size);
branches/cparm/i386/modules/YellowIconFixer/YellowIconFixer.c
3535
3636
3737
38
38
3939
4040
4141
if (current && current->class_id == PCI_CLASS_STORAGE_SATA)
{
devicepath = get_pci_dev_path(current);
if (devicepath[0] != 0)
if (devicepath)
{
verbose("SATA device : [%04x:%04x :: %04x] :: %s\n",
current->vendor_id, current->device_id,current->class_id,
branches/cparm/i386/modules/GUI/gui.c
26012601
26022602
26032603
2604
2605
2606
2607
2608
2609
2610
2604
2605
2606
2607
2608
2609
2610
2611
2612
26112613
26122614
26132615
// Prepare the data for the default Apple boot image.
appleBootPict = (uint8_t *) decodeRLE(gAppleBootPictRLE, kAppleBootRLEBlocks, bootImageWidth * bootImageHeight);
if (appleBootPict) {
convertImage(bootImageWidth, bootImageHeight, appleBootPict, &bootImageData);
if (bootImageData) {
x = (screen_params[0] - MIN(kAppleBootWidth, screen_params[0])) / 2;
y = (screen_params[1] - MIN(kAppleBootHeight, screen_params[1])) / 2;
drawDataRectangle(x, y, kAppleBootWidth, kAppleBootHeight, bootImageData);
free(bootImageData);
}
if (convertImage(bootImageWidth, bootImageHeight, appleBootPict, &bootImageData) == 0)
{
if (bootImageData) {
x = (screen_params[0] - MIN(kAppleBootWidth, screen_params[0])) / 2;
y = (screen_params[1] - MIN(kAppleBootHeight, screen_params[1])) / 2;
drawDataRectangle(x, y, kAppleBootWidth, kAppleBootHeight, bootImageData);
free(bootImageData);
}
}
free(appleBootPict);
}
}
branches/cparm/i386/modules/GUI/GUI_module.c
211211
212212
213213
214
214
215215
216216
217217
......
220220
221221
222222
223
223
224224
225225
226226
227227
228228
229229
230
230
231231
232232
233233
234234
235235
236
236
237237
238238
239239
......
242242
243243
244244
245
245
246246
247247
248248
......
267267
268268
269269
270
270
271271
272272
273273
......
365365
366366
367367
368
368
369369
370370
371371
......
374374
375375
376376
377
377
378378
379379
380380
......
698698
699699
700700
701
701
702702
703703
704704
......
710710
711711
712712
713
713
714714
715715
716716
......
752752
753753
754754
755
755
756756
757757
758758
......
761761
762762
763763
764
764
765765
766766
767767
......
778778
779779
780780
781
781
782782
783783
784784
......
815815
816816
817817
818
819
818
820819
820
821
822
823
821824
822
823
824
825
825826
827
828
829
830
826831
827
832
833
834
835
836
837
828838
829839
830840
......
914924
915925
916926
917
927
918928
919929
920930
......
960970
961971
962972
963
973
964974
965975
966976
gui.logo.draw = false;
drawBackground();
updateVRAM();
if(!gVerboseMode)
{
// Disable outputs, they will still show in the boot log.
}
}
}
void GUI_diplay_hook(void* arg1, void* arg2, void* arg3, void* arg4, void* arg5, void* arg6)
{
// Start and display the gui
msglog("* Attempting to Display GUI\n");
if (initGUI())
{
useGUI = false; // initGUI() returned with an error, disabling GUI.
msglog("* GUI failed to Display, or disabled by user (a.k.a you)\n");
}
else
replace_system_function("_getBootOptions", &GUI_getBootOptions);
replace_system_function("_clearBootArgs", &GUI_clearBootArgs);
replace_system_function("_addBootArg", &GUI_addBootArg);
replace_system_function("_showHelp", &GUI_showHelp);
replace_system_function("_printf", &GUI_printf);
showMessage = (void*)lookup_all_symbols(SYMBOLS_MODULE,"_showMessage");
showTextBuffer = (void*)lookup_all_symbols(SYMBOLS_MODULE,"_showTextBuffer");
safe_set_env(envgBootArgs,(uint32_t)gBootArgs);
msglog("* GUI successfully Displayed\n");
}
{
bool shouldboot = ( res != DO_NOT_BOOT );
safe_set_env(envShouldboot, shouldboot);
if ( shouldboot )
gui.menu.draw = false;
case BOOT_NORMAL:
gVerboseMode = false;
safe_set_env(envgBootMode, kBootModeNormal);
break;
case BOOT_VERBOSE:
bool showPrompt, newShowPrompt, isCDROM;
int optionKey;
int devcnt = (int)get_env(envgDeviceCount);
// Initialize default menu selection entry.
gBootVolume = menuBVR = selectBootVolume(getBvChain());
{
isCDROM = false;
}
// ensure we're in graphics mode if gui is setup
if (gui.initialised && (getVideoMode() == VGA_TEXT_MODE))
{
{
gBootMode |= kBootModeQuiet;
safe_set_env(envgBootMode,gBootMode);
}
// If the user is holding down a modifier key, enter safe mode.
gBootMode |= kBootModeSafe;
safe_set_env(envgBootMode,gBootMode);
}
// Checking user pressed keys
{
gBootMode &= ~kBootModeQuiet;
safe_set_env(envgBootMode,gBootMode);
timeout = 0;
}
// If user typed 'v' or 'V', boot in verbose mode.
char *name = NULL;
int cnt;
if (getValueForKey(kCDROMPromptKey, &val, &cnt, DEFAULT_BOOT_CONFIG))
{
if (getValueForKey(kCDROMPromptKey, &val, &cnt, DEFAULT_BOOT_CONFIG)) {
prompt = malloc(cnt + 1);
if (!prompt) {
stop("Couldn't allocate memory for the prompt\n"); //TODO: Find a better stategie
return -1;
}
strncat(prompt, val, cnt);
}
else
{
} else {
name = malloc(80);
if (!name) {
stop("Couldn't allocate memory for the device name\n"); //TODO: Find a better stategie
return -1;
}
getBootVolumeDescription(gBootVolume, name, 79, false);
prompt = malloc(256);
prompt = malloc(256);
if (!prompt) {
free(name);
stop("Couldn't allocate memory for the prompt\n"); //TODO: Find a better stategie
return -1;
}
sprintf(prompt, "Press ENTER to start up from %s, or press any key to enter startup options.", name);
free(name);
}
goto done;
}
}
if (devcnt)
{
// Allocate memory for an array of menu items.
// Display banner and show hardware info.
gprintf(&gui.screen, bootBanner + 1, (int)(get_env(envConvMem) + get_env(envExtMem)) / 1024);
}
// redraw background
branches/cparm/i386/modules/GUI/graphic_utils.c
7272
7373
7474
75
75
7676
7777
7878
7979
8080
81
8182
82
83
8384
8485
8586
87
8688
87
89
8890
91
8992
90
93
9194
9295
9396
97
9498
95
99
96100
101
97102
103
98104
105
99106
107
100108
101
102109
103110
104111
unsigned char **newImageData )
{
int cnt;
unsigned char *img = 0;
unsigned char *img;
unsigned short *img16;
unsigned long *img32;
switch ( VIDEO(depth) ) {
case 16 :
{
img16 = malloc(width * height * 2);
if ( !img16 ) break;
if ( !img16 ) return 1;
for (cnt = 0; cnt < (width * height); cnt++)
img16[cnt] = lookUpCLUTIndex(imageData[cnt], 16);
img = (unsigned char *)img16;
*newImageData = img;
break;
}
case 32 :
{
img32 = malloc(width * height * 4);
if ( !img32 ) break;
if ( !img32 ) return 1;
for (cnt = 0; cnt < (width * height); cnt++)
img32[cnt] = lookUpCLUTIndex(imageData[cnt], 32);
img = (unsigned char *)img32;
*newImageData = img;
break;
}
default :
{
img = malloc(width * height);
if ( !img ) return 1;
bcopy(imageData, img, width * height);
*newImageData = img;
break;
}
}
*newImageData = img;
return 0;
}
branches/cparm/i386/modules/Networking/Networking.c
5454
5555
5656
57
57
5858
5959
6060
......
104104
105105
106106
107
108
109
107110
108111
109112
......
145148
146149
147150
151
152
153
148154
149155
150156
......
158164
159165
160166
161
167
162168
163169
164170
getBoolForKey(kEnableWifi, &do_wifi_devprop, DEFAULT_BOOT_CONFIG);
if (do_wifi_devprop)
set_wifi_airport(current);
set_wifi_airport(current);
}
static void set_eth_builtin(pci_dt_t *eth_dev)
{
char *devicepath = get_pci_dev_path(eth_dev);
if (!devicepath) {
return ;
}
struct DevPropDevice *device /*= (struct DevPropDevice*)malloc(sizeof(struct DevPropDevice))*/;
verbose("LAN Controller [%04x:%04x] :: %s\n", eth_dev->vendor_id, eth_dev->device_id, devicepath);
char tmp[16];
char *devicepath = get_pci_dev_path(wlan_dev);
if (!devicepath) {
return ;
}
struct DevPropDevice *device /*= (struct DevPropDevice*)malloc(sizeof(struct DevPropDevice))*/;
verbose("Wifi Controller [%04x:%04x] :: %s\n", wlan_dev->vendor_id, wlan_dev->device_id, devicepath);
sprintf(tmp, "Airport");
devprop_add_value(device, "AAPL,slot-name", (uint8_t *) tmp, strlen(tmp) + 1);
devprop_add_value(device, "device_type", (uint8_t *) tmp, strlen(tmp) + 1);
unsigned int i = 0;
for( ; i < sizeof(known_wifi_cards) / sizeof(known_wifi_cards[0]); i++)
branches/cparm/i386/modules/GraphicsEnabler/gma.c
11
2
3
2
3
44
55
66
......
9898
9999
100100
101
101
102102
103
103
104
105
104106
105107
106108
107109
108110
109
111
110112
111113
112114
......
124126
125127
126128
127
129
128130
129131
130132
......
170172
171173
172174
173
175
174176
175177
176178
/*
Original patch by nawcom -> http://forum.voodooprojects.org/index.php/topic,1029.msg4427.html#msg4427
*/
Original patch by nawcom -> http://forum.voodooprojects.org/index.php/topic,1029.msg4427.html#msg4427
*/
#include "libsaio.h"
#include "bootstruct.h"
#include "pci.h"
char *model;
uint8_t BuiltIn = 0x00;
uint8_t ClassFix[4] = { 0x00, 0x00, 0x03, 0x00 };
devicepath = get_pci_dev_path(gma_dev);
if (!devicepath) {
return false;
}
bar[0] = pci_config_read32(gma_dev->dev.addr, 0x10);
#if UNUSED
regs = (uint8_t *) (bar[0] & ~0x0f);
#endif
model = get_gma_model((gma_dev->vendor_id << 16) | gma_dev->device_id);
verbose("Intel %s [%04x:%04x] :: %s\n",
model, gma_dev->vendor_id, gma_dev->device_id, devicepath);
devprop_add_value(device, "model", (uint8_t*)model, (strlen(model) + 1));
devprop_add_value(device, "device_type", (uint8_t*)"display", 8);
if ((strcmp(model, "Mobile GMA950") == 0) ||
(strcmp(model, "Mobile GMA3150") == 0))
{
devprop_add_value(device, "AAPL,os-info", HD3000_os_info, 20);
}
stringdata = malloc(sizeof(uint8_t) * string->length);
if(!stringdata)
{
branches/cparm/i386/modules/GraphicsEnabler/GraphicsEnabler.c
3737
3838
3939
40
41
40
4241
4342
4443
45
46
44
4745
4846
4947
5048
5149
5250
53
51
5452
5553
5654
5755
5856
5957
60
58
6159
6260
if(current && current->class_id == PCI_CLASS_DISPLAY_VGA)
{
char *devicepath = get_pci_dev_path(current);
switch (current->vendor_id)
{
case PCI_VENDOR_ID_ATI:
verbose("ATI VGA Controller [%04x:%04x] :: %s \n",
current->vendor_id, current->device_id, devicepath);
setup_ati_devprop(current);
break;
case PCI_VENDOR_ID_INTEL:
setup_gma_devprop(current);
break;
case PCI_VENDOR_ID_NVIDIA:
setup_nvidia_devprop(current);
break;
default:
break;
}
}
}
branches/cparm/i386/modules/GraphicsEnabler/nvidia.c
12051205
12061206
12071207
1208
1208
12091209
1210
1211
1212
12101213
12111214
12121215
12131216
1214
1217
12151218
12161219
1217
1220
12181221
1219
1222
12201223
1221
1224
12221225
12231226
12241227
......
12271230
12281231
12291232
1233
1234
1235
1236
1237
12301238
12311239
12321240
......
12411249
12421250
12431251
1244
1252
12451253
1246
1254
12471255
12481256
12491257
......
12531261
12541262
12551263
1256
1264
12571265
12581266
12591267
12601268
12611269
1262
1270
12631271
12641272
12651273
......
12801288
12811289
12821290
1283
1291
12841292
12851293
12861294
12871295
12881296
12891297
1290
1298
12911299
1292
1300
12931301
12941302
12951303
......
13031311
13041312
13051313
1306
1307
1314
1315
13081316
13091317
13101318
13111319
1312
1320
13131321
13141322
13151323
1316
1324
13171325
13181326
13191327
......
13221330
13231331
13241332
1333
1334
1335
1336
1337
13251338
13261339
13271340
......
13521365
13531366
13541367
1355
1368
13561369
13571370
13581371
1359
1372
13601373
13611374
13621375
......
13691382
13701383
13711384
1372
1385
13731386
13741387
13751388
......
13791392
13801393
13811394
1382
1395
13831396
13841397
13851398
......
13911404
13921405
13931406
1394
1395
1396
1397
1398
1399
1400
1401
1407
1408
1409
1410
1411
1412
1413
1414
14021415
14031416
14041417
......
14111424
14121425
14131426
1414
1427
14151428
1429
1430
1431
1432
1433
1434
14161435
14171436
1418
1437
14191438
14201439
dcfg_t default_dcfg_1;
bool dcfg0_set = false;
bool dcfg1_set = false;
devicepath = get_pci_dev_path(nvda_dev);
if (!devicepath) {
return false;
}
bar[0] = pci_config_read32(nvda_dev->dev.addr, 0x10 );
regs = (uint8_t *) (bar[0] & ~0x0f);
delay(50);
// get card type
nvCardType = (REG32(0) >> 20) & 0x1ff;
// Amount of VRAM in kilobytes
videoRam = mem_detect(regs, nvCardType, nvda_dev);
model = get_nvidia_model((nvda_dev->vendor_id << 16) | nvda_dev->device_id);
verbose("nVidia %s %dMB NV%02x [%04x:%04x] :: %s\n",
devicepath);
rom = malloc(NVIDIA_ROM_SIZE);
if (!rom) {
printf("Couldn't allocate momory for device rom\n");
return false;
}
sprintf(nvFilename, "/Extra/%04x_%04x.rom", (uint16_t)nvda_dev->vendor_id, (uint16_t)nvda_dev->device_id);
if (getBoolForKey(kUseNvidiaROM, &doit, DEFAULT_BOOT_CONFIG) && doit) {
verbose("Looking for nvidia video bios file %s\n", nvFilename);
} else {
// Otherwise read bios from card
nvBiosOveride = 0;
// TODO: we should really check for the signature before copying the rom, i think.
// PRAMIN first
nvRom = (uint8_t*)&regs[NV_PRAMIN_OFFSET];
bcopy((uint32_t *)nvRom, rom, NVIDIA_ROM_SIZE);
// PROM next
// Enable PROM access
(REG32(NV_PBUS_PCI_NV_20)) = NV_PBUS_PCI_NV_20_ROM_SHADOW_DISABLED;
nvRom = (uint8_t*)&regs[NV_PROM_OFFSET];
bcopy((uint8_t *)nvRom, rom, NVIDIA_ROM_SIZE);
// disable PROM access
(REG32(NV_PBUS_PCI_NV_20)) = NV_PBUS_PCI_NV_20_ROM_SHADOW_ENABLED;
// Valid Signature ?
if (rom[0] != 0x55 && rom[1] != 0xaa) {
// 0xC0000 last
DBG("PRAM Address 0x%x Signature 0x%02x%02x\n", nvRom, rom[0], rom[1]);
}
}
if ((nvPatch = patch_nvidia_rom(rom)) == PATCH_ROM_FAILED) {
printf("ERROR: nVidia ROM Patching Failed!\n");
free(rom);
return false;
}
DBG("nvidia rom successfully patched\n");
rom_pci_header = (struct pci_rom_pci_header_t*)(rom + *(uint16_t *)&rom[24]);
// check for 'PCIR' sig
if (rom_pci_header->signature == 0x50434952) {
if (rom_pci_header->device != nvda_dev->device_id) {
}
}
DBG("nvidia model : %s\n",model);
if (!string) {
string = devprop_create_string();
}
device = devprop_add_device(string, devicepath);
/* FIXME: for primary graphics card only */
boot_display = 1;
devprop_add_value(device, "@0,AAPL,boot-display", (uint8_t*)&boot_display, 4);
if(nvPatch == PATCH_ROM_SUCCESS_HAS_LVDS) {
uint8_t built_in = 0x01;
devprop_add_value(device, "@0,built-in", &built_in, 1);
// get bios version
const int MAX_BIOS_VERSION_LENGTH = 32;
char* version_str = (char*)malloc(MAX_BIOS_VERSION_LENGTH);
if (!version_str) {
printf("Couldn't allocate momory for device version_str\n");
free(rom);
return false;
}
memset(version_str, 0, MAX_BIOS_VERSION_LENGTH);
int i, version_start;
int crlf_count = 0;
}
sprintf(biosVersion, "%s", (nvBiosOveride > 0) ? nvFilename : version_str);
sprintf(kNVCAP, "NVCAP_%04x", nvda_dev->device_id);
if (getValueForKey(kNVCAP, &value, &len, DEFAULT_BOOT_CONFIG) && len == NVCAP_LEN * 2) {
uint8_tnew_NVCAP[NVCAP_LEN];
if (hex2bin(value, new_NVCAP, NVCAP_LEN) == 0) {
verbose("Using user supplied NVCAP for %s :: %s\n", model, devicepath);
memcpy(default_NVCAP, new_NVCAP, NVCAP_LEN);
{
dcfg0_set = true;
verbose("@0,display-cfg: %02x%02x%02x%02x\n",
default_dcfg_0.val0, default_dcfg_0.val1, default_dcfg_0.val2, default_dcfg_0.val3);
default_dcfg_0.val0, default_dcfg_0.val1, default_dcfg_0.val2, default_dcfg_0.val3);
}
}
{
dcfg1_set = true;
verbose("@1,display-cfg: %02x%02x%02x%02x\n",
default_dcfg_1.val0, default_dcfg_1.val1, default_dcfg_1.val2, default_dcfg_1.val3);
default_dcfg_1.val0, default_dcfg_1.val1, default_dcfg_1.val2, default_dcfg_1.val3);
}
}
{
memcpy(&default_dcfg_1, default_dcfg,DCFG_LEN );
}
#if DEBUG_NVCAP
printf("NVCAP: %02x%02x%02x%02x-%02x%02x%02x%02x-%02x%02x%02x%02x-%02x%02x%02x%02x-%02x%02x%02x%02x\n",
default_NVCAP[0], default_NVCAP[1], default_NVCAP[2], default_NVCAP[3],
default_NVCAP[4], default_NVCAP[5], default_NVCAP[6], default_NVCAP[7],
default_NVCAP[8], default_NVCAP[9], default_NVCAP[10], default_NVCAP[11],
default_NVCAP[12], default_NVCAP[13], default_NVCAP[14], default_NVCAP[15],
default_NVCAP[16], default_NVCAP[17], default_NVCAP[18], default_NVCAP[19]);
#if DEBUG_NVCAP
printf("NVCAP: %02x%02x%02x%02x-%02x%02x%02x%02x-%02x%02x%02x%02x-%02x%02x%02x%02x-%02x%02x%02x%02x\n",
default_NVCAP[0], default_NVCAP[1], default_NVCAP[2], default_NVCAP[3],
default_NVCAP[4], default_NVCAP[5], default_NVCAP[6], default_NVCAP[7],
default_NVCAP[8], default_NVCAP[9], default_NVCAP[10], default_NVCAP[11],
default_NVCAP[12], default_NVCAP[13], default_NVCAP[14], default_NVCAP[15],
default_NVCAP[16], default_NVCAP[17], default_NVCAP[18], default_NVCAP[19]);
#endif
devprop_add_nvidia_template(device);
if (getBoolForKey(kVBIOS, &doit, DEFAULT_BOOT_CONFIG) && doit) {
devprop_add_value(device, "vbios", rom, (nvBiosOveride > 0) ? nvBiosOveride : (uint32_t)(rom[2] * 512));
}
stringdata = malloc(sizeof(uint8_t) * string->length);
if (!stringdata) {
free(rom);
free(version_str);
printf("Couldn't allocate momory for device stringdata\n");
return false;
}
memcpy(stringdata, (uint8_t*)devprop_generate_string(string), string->length);
stringlength = string->length;
return true;
}
branches/cparm/i386/modules/GraphicsEnabler/ati.c
458458
459459
460460
461
461
462462
463463
464
464
465465
466
466
467467
468
468
469469
470
470
471471
472472
473473
......
513513
514514
515515
516
516
517517
518
518
519519
520520
521521
......
524524
525525
526526
527
527
528528
529
529
530530
531531
532532
......
536536
537537
538538
539
539
540540
541541
542542
543543
544544
545
545
546546
547547
548548
......
558558
559559
560560
561
561
562562
563563
564564
565
565
566566
567567
568568
......
576576
577577
578578
579
579
580580
581581
582582
583583
584584
585
585
586586
587587
588588
......
592592
593593
594594
595
595
596596
597597
598598
......
708708
709709
710710
711
711
712712
713713
714
714
715715
716716
717717
......
787787
788788
789789
790
790
791791
792
793
794
795
796
797
792
793
794
795
796
797
798798
799
799
800800
801
802
801
802
803803
804804
805805
806806
807807
808808
809
810
811
809
810
811
812812
813
813
814814
815815
816816
817817
818
818
819819
820820
821821
......
883883
884884
885885
886
887
888
889
890
886
887
888
889
890
891891
892892
893893
......
927927
928928
929929
930
930
931931
932932
933933
......
10291029
10301030
10311031
1032
1033
1034
1032
1033
1034
10351035
10361036
10371037
......
10421042
10431043
10441044
1045
1046
1047
1045
1046
1047
10481048
10491049
10501050
......
10521052
10531053
10541054
1055
1055
10561056
10571057
10581058
......
12061206
12071207
12081208
1209
1209
12101210
12111211
12121212
......
12651265
12661266
12671267
1268
1268
12691269
12701270
12711271
......
13471347
13481348
13491349
1350
1350
13511351
13521352
13531353
......
13691369
13701370
13711371
1372
1372
13731373
13741374
13751375
13761376
1377
1377
13781378
13791379
1380
1380
13811381
13821382
13831383
......
13871387
13881388
13891389
1390
1390
13911391
13921392
13931393
......
14151415
14161416
14171417
1418
1419
1420
1418
1419
1420
14211421
14221422
14231423
......
14351435
14361436
14371437
1438
1439
1440
1441
1438
14421439
14431440
14441441
14451442
14461443
14471444
1445
1446
1447
1448
1449
1450
1451
1452
14481453
14491454
14501455
{ 0x95C5,0x01051A93, CHIP_FAMILY_RV620,"Qimonda Radeon HD 3450",kNull},
{ 0x95CC,0x00000000/*0x1b0317aa*/, CHIP_FAMILY_RV620,"ATI FirePro V3700 (FireGL)", kNull},
/* Evergreen */
{ 0x6898,0x0B001002, CHIP_FAMILY_CYPRESS,"ATI Radeon HD 5870",kZonalis},
{ 0x6898,0x032E1043, CHIP_FAMILY_CYPRESS,"ATI Radeon HD 5870",kUakari},
{ 0x6898,0x00D0106B, CHIP_FAMILY_CYPRESS,"ATI Radeon HD 5870",kLangur},
{ 0x6898,0xE140174B, CHIP_FAMILY_CYPRESS,"ATI Radeon HD 5870",kUakari},
{ 0x6898,0x29611682, CHIP_FAMILY_CYPRESS,"ATI Radeon HD 5870",kUakari},
{ 0x6899,0x21E41458, CHIP_FAMILY_CYPRESS,"ATI Radeon HD 5850",kUakari},
{ 0x68C8,0x2306103C, CHIP_FAMILY_REDWOOD,"ATI FirePro V4800 (FireGL)",kNull},
{ 0x68D8,0x03561043, CHIP_FAMILY_REDWOOD,"ATI Radeon HD 5670",kBaboon},
{ 0x68D8,0x21D91458, CHIP_FAMILY_REDWOOD,"ATI Radeon HD 5670",kBaboon},
{ 0x68D8,0x5690174B, CHIP_FAMILY_REDWOOD,"ATI Radeon HD 5690",kNull},
{ 0x68D8,0x5730174B, CHIP_FAMILY_REDWOOD,"ATI Radeon HD 5730",kNull},
{ 0x68D8,0xE151174B, CHIP_FAMILY_REDWOOD,"ATI Radeon HD 5670",kBaboon},
{ 0x68D8,0x301017AF, CHIP_FAMILY_REDWOOD,"ATI Radeon HD 5730",kNull},
{ 0x68D8,0x301117AF, CHIP_FAMILY_REDWOOD,"ATI Radeon HD 5690",kNull},
{ 0x68D9,0x301017AF, CHIP_FAMILY_REDWOOD,"ATI Radeon HD 5630",kNull},
{ 0x68DA,0x5630174B, CHIP_FAMILY_REDWOOD,"ATI Radeon HD 5630",kNull},
{ 0x68DA,0x30001787, CHIP_FAMILY_REDWOOD,"ATI Radeon HD 5630",kNull},
{ 0x68E0,0x04561028, CHIP_FAMILY_CEDAR,"ATI Radeon HD 5470M",kEulemur},
{ 0x68E0,0x1433103C, CHIP_FAMILY_CEDAR,"ATI Radeon HD 5470M",kEulemur},
{ 0x68E1,0x1426103C, CHIP_FAMILY_CEDAR,"ATI Radeon HD 5430M",kEulemur},
{ 0x68F9,0x5470174B, CHIP_FAMILY_CEDAR,"ATI Radeon HD 5470",kNull},
{ 0x68F9,0x5490174B, CHIP_FAMILY_CEDAR,"ATI Radeon HD 5490",kNull},
{ 0x68F9,0x5530174B, CHIP_FAMILY_CEDAR,"ATI Radeon HD 5530",kNull},
{ 0x68F9,0x20091787, CHIP_FAMILY_CEDAR,"ATI Radeon HD 5450",kEulemur},
{ 0x68F9,0x22911787, CHIP_FAMILY_CEDAR,"ATI Radeon HD 5450",kEulemur},
{ 0x68F9,0x30001787, CHIP_FAMILY_CEDAR,"ATI Radeon HD 5470",kNull},
{ 0x6718,0x67181002, CHIP_FAMILY_CAYMAN,"AMD Radeon HD 6970",kNull},
{ 0x6718,0x31301682, CHIP_FAMILY_CAYMAN,"AMD Radeon HD 6970",kNull},
{ 0x6738,0x00D01002,CHIP_FAMILY_BARTS,"AMD Radeon HD 6870",kDuckweed},
{ 0x6738,0x21FA1002,CHIP_FAMILY_BARTS,"AMD Radeon HD 6870",kDuckweed},
{ 0x6738,0x67381002, CHIP_FAMILY_BARTS,"AMD Radeon HD 6870",kDuckweed},
{ 0x6738,0x21FA1458,CHIP_FAMILY_BARTS,"AMD Radeon HD 6870",kDuckweed},
{ 0x6738,0x31031682,CHIP_FAMILY_BARTS,"AMD Radeon HD 6870",kDuckweed},
{ 0x6739,0x67391002, CHIP_FAMILY_BARTS,"AMD Radeon HD 6850",kDuckweed},
{ 0x6739,0x21F81458, CHIP_FAMILY_BARTS,"AMD Radeon HD 6850",kDuckweed},
{ 0x6739,0x24411462, CHIP_FAMILY_BARTS,"AMD Radeon HD 6850",kDuckweed},
{ 0x6739,0x31101682, CHIP_FAMILY_BARTS,"AMD Radeon HD 6850",kDuckweed},
{ 0x6739,0xE177174B,CHIP_FAMILY_BARTS,"AMD Radeon HD 6850",kDuckweed},
{ 0x6740,0x1657103C, CHIP_FAMILY_TURKS,"AMD Radeon HD 6770M",kNull},
{ 0x6740,0x165A103C, CHIP_FAMILY_TURKS,"AMD Radeon HD 6770M",kNull},
{ 0x6741,0x1646103C, CHIP_FAMILY_TURKS,"AMD Radeon HD 6750M",kNull},
{ 0x6741,0x9080104D,CHIP_FAMILY_TURKS,"AMD Radeon HD 6630M",kNull},
{ 0x6758,0x67581002,CHIP_FAMILY_TURKS,"AMD Radeon HD 6670",kBulrushes},
{ 0x6758,0x22051458,CHIP_FAMILY_TURKS,"AMD Radeon HD 6670",kBulrushes},
{ 0x6758,0x00000000, CHIP_FAMILY_TURKS,"AMD Radeon HD 6670 Series",kBulrushes},
{ 0x6759,0x00000000, CHIP_FAMILY_TURKS,"AMD Radeon HD 6500 Series",kNull},
{ 0x6760,0x00000000, CHIP_FAMILY_CAICOS,"AMD Radeon HD 6400M Series",kNull},
{ 0x6761,0x00000000, CHIP_FAMILY_CAICOS,"AMD Radeon HD 6430M Series",kNull},
{ 0x6770,0x00000000, CHIP_FAMILY_CAICOS,"AMD Radeon HD 6400 Series",kNull},
{ 0x6779,0x00000000, CHIP_FAMILY_CAICOS,"AMD Radeon HD 6450 Series",kBulrushes},
dev_prop_t ati_devprop_list[] = {
{FLAGTRUE,false,"@0,AAPL,boot-display",get_bootdisplay_val,NULVAL},
//{FLAGTRUE,false,"@0,ATY,EFIDisplay",NULL,STRVAL("TMDSA")},
//{FLAGTRUE,false,"@0,ATY,EFIDisplay",NULL,STRVAL("TMDSA")},
//{FLAGTRUE,true,"@0,AAPL,vram-memory",get_vrammemory_val,NULVAL},
//{FLAGTRUE,true,"@0,compatible",get_name_val,NULVAL},
//{FLAGTRUE,true,"@0,connector-type",get_conntype_val,NULVAL},
//{FLAGTRUE,true,"@0,device_type",NULL,STRVAL("display")},
//{FLAGTRUE,false,"@0,display-connect-flags", NULL,DWRVAL((uint32_t)0)},
//{FLAGTRUE,true,"@0,display-type",NULL,STRVAL("NONE")},
//{FLAGTRUE,true,"@0,AAPL,vram-memory",get_vrammemory_val,NULVAL},
//{FLAGTRUE,true,"@0,compatible",get_name_val,NULVAL},
//{FLAGTRUE,true,"@0,connector-type",get_conntype_val,NULVAL},
//{FLAGTRUE,true,"@0,device_type",NULL,STRVAL("display")},
//{FLAGTRUE,false,"@0,display-connect-flags", NULL,DWRVAL((uint32_t)0)},
//{FLAGTRUE,true,"@0,display-type",NULL,STRVAL("NONE")},
{FLAGTRUE,true,"@0,name",get_name_val,NULVAL},
//{FLAGTRUE,true,"@0,VRAM,memsize",get_vrammemsize_val,NULVAL},
//{FLAGTRUE,true,"@0,VRAM,memsize",get_vrammemsize_val,NULVAL},
//{FLAGTRUE,false,"AAPL,aux-power-connected", NULL,DWRVAL((uint32_t)1)},
//{FLAGTRUE,false,"AAPL,backlight-control",NULL,DWRVAL((uint32_t)0)},
//{FLAGTRUE,false,"AAPL,aux-power-connected", NULL,DWRVAL((uint32_t)1)},
//{FLAGTRUE,false,"AAPL,backlight-control",NULL,DWRVAL((uint32_t)0)},
{FLAGTRUE,false,"ATY,bin_image",get_binimage_val,NULVAL},
{FLAGTRUE,false,"ATY,Copyright",NULL,STRVAL("Copyright AMD Inc. All Rights Reserved. 2005-2010") },
{FLAGTRUE,false,"ATY,Card#",get_romrevision_val,NULVAL},
{FLAGTRUE,false,"ATY,VendorID",NULL,WRDVAL((uint16_t)0x1002)},
{FLAGTRUE,false,"ATY,DeviceID",get_deviceid_val,NULVAL},
//{FLAGTRUE,false,"ATY,MCLK",get_mclk_val,NULVAL},
//{FLAGTRUE,false,"ATY,SCLK",get_sclk_val,NULVAL},
//{FLAGTRUE,false,"ATY,RefCLK",get_refclk_val,DWRVAL((uint32_t)0x0a8c)},
//{FLAGTRUE,false,"ATY,MCLK",get_mclk_val,NULVAL},
//{FLAGTRUE,false,"ATY,SCLK",get_sclk_val,NULVAL},
//{FLAGTRUE,false,"ATY,RefCLK",get_refclk_val,DWRVAL((uint32_t)0x0a8c)},
//{FLAGTRUE,false,"ATY,PlatformInfo",get_platforminfo_val,NULVAL},
//{FLAGTRUE,false,"ATY,PlatformInfo",get_platforminfo_val,NULVAL},
{FLAGTRUE,false,"name",get_nameparent_val,NULVAL},
{FLAGTRUE,false,"device_type",get_nameparent_val,NULVAL},
{FLAGTRUE,false,"model",get_model_val,STRVAL("ATI Radeon")},
//{FLAGTRUE,false,"VRAM,totalsize",get_vramtotalsize_val,NULVAL},
//{FLAGTRUE,false,"VRAM,totalsize",get_vramtotalsize_val,NULVAL},
{FLAGTRUE,false,NULL,NULL,NULVAL}
};
bool get_conntype_val(value_t *val)
{
//Connector types:
//0x4 : DisplayPort
//0x400: DL DVI-I
//0x800: HDMI
//Connector types:
//0x4 : DisplayPort
//0x400: DL DVI-I
//0x800: HDMI
return false;
}
return false;
rev = card->rom + *(uint8_t *)(card->rom + OFFSET_TO_GET_ATOMBIOS_STRINGS_START);
val->type = kPtr;
val->size = strlen((char *)rev);
val->data = malloc(val->size);
if (devprop_list[i].default_val.type != kNul)
{
devprop_add_value(card->device, devprop_list[i].name,
devprop_list[i].default_val.type == kCst ?
(uint8_t *)&(devprop_list[i].default_val.data) : devprop_list[i].default_val.data,
devprop_list[i].default_val.size);
devprop_list[i].default_val.type == kCst ?
(uint8_t *)&(devprop_list[i].default_val.data) : devprop_list[i].default_val.data,
devprop_list[i].default_val.size);
}
if (devprop_list[i].all_ports)
{
devprop_list[i].name[1] = 0x30 + pnum; // convert to ascii
devprop_add_value(card->device, devprop_list[i].name,
devprop_list[i].default_val.type == kCst ?
(uint8_t *)&(devprop_list[i].default_val.data) : devprop_list[i].default_val.data,
devprop_list[i].default_val.size);
devprop_list[i].default_val.type == kCst ?
(uint8_t *)&(devprop_list[i].default_val.data) : devprop_list[i].default_val.data,
devprop_list[i].default_val.size);
}
}
devprop_list[i].name[1] = 0x30; // write back our "@0," for a next possible card
}
}
}
free(val);
}
// wait for SPLL_CHG_STATUS to change to 1
cg_spll_status = 0;
while (!(cg_spll_status & R600_SPLL_CHG_STATUS))
cg_spll_status = RegRead32(R600_CG_SPLL_STATUS);
cg_spll_status = RegRead32(R600_CG_SPLL_STATUS);
}
RegWrite32(RADEON_VIPH_CONTROL, viph_control);
RegWrite32(RADEON_BUS_CNTL, bus_cntl);
RegWrite32(R600_CTXSW_VID_LOWER_GPIO_CNTL, ctxsw_vid_lower_gpio_cntl);
RegWrite32(R600_LOWER_GPIO_ENABLE, lower_gpio_enable);
}
return ret;
}
card->io= (uint8_t *)(pci_config_read32(pci_dev->dev.addr, PCI_BASE_ADDRESS_4) & ~0x03);
verbose("Framebuffer @0x%08X MMIO @0x%08XI/O Port @0x%08X ROM Addr @0x%08X\n",
card->fb, card->mmio, card->io, pci_config_read32(pci_dev->dev.addr, PCI_ROM_ADDRESS));
card->fb, card->mmio, card->io, pci_config_read32(pci_dev->dev.addr, PCI_ROM_ADDRESS));
card->posted = radeon_card_posted();
verbose("ATI card %s, ", card->posted ? "POSTed" : "non-POSTed");
}
}
//card->ports = 2; // default - Azi: default is card_configs
//card->ports = 2; // default - Azi: default is card_configs
if (card->info->chip_family >= CHIP_FAMILY_CEDAR)
{
card->flags |= EVERGREEN;
//card->ports = 3; //Azi: use the AtiPorts key if needed
//card->ports = 3; //Azi: use the AtiPorts key if needed
}
//atN = 0;
//atN = 0;
// Check AtiConfig key for a framebuffer name,
card->cfg_name = getStringForKey(kAtiConfig, DEFAULT_BOOT_CONFIG);
// use cfg_name on radeon_cards, to retrive the default name from card_configs,
card->cfg_name = card_configs[card->info->cfg_name].name;
// and leave ports alone!
//card->ports = card_configs[card->info->cfg_name].ports;
//card->ports = card_configs[card->info->cfg_name].ports;
// which means one of the fb's or kNull
verbose("Framebuffer set to device's default: %s\n", card->cfg_name);
verbose("Nr of ports set to framebuffer's default: %d\n", card->ports);
}
//else
//card->ports = 2/1 ?; // set a min if 0 ports ?
//verbose("Nr of ports set to min: %d\n", card->ports);
//else
//card->ports = 2/1 ?; // set a min if 0 ports ?
//verbose("Nr of ports set to min: %d\n", card->ports);
sprintf(name, "ATY,%s", card->cfg_name);
aty_name.type = kStr;
bool setup_ati_devprop(pci_dt_t *ati_dev)
{
char *devicepath;
if (!init_card(ati_dev))
return false;
// -------------------------------------------------
// Find a better way to do this (in device_inject.c)
if (!string)
string = devprop_create_string();
devicepath = get_pci_dev_path(ati_dev);
if (!devicepath) {
return false;
}
verbose("ATI VGA Controller [%04x:%04x] :: %s \n",
ati_dev->vendor_id, ati_dev->device_id, devicepath);
if (!init_card(ati_dev))
return false;
card->device = devprop_add_device(string, devicepath);
if (!card->device)
return false;
branches/cparm/i386/modules/ACPICodec/acpidecode.c
505505
506506
507507
508
508
509
509510
510511
511512
id = *current++;
pmbase = *(U32 *) current;
current += 4;
(void)current; // Silent a warning reported by the clang static analizer .
#if DEBUG_ACPI_DECODE
DBG( "Found CPU object: ");
dprint_namespace(&new_ns);

Archive Download the corresponding diff file

Revision: 1919