Index: branches/cparm/Chameleon.xcodeproj/project.pbxproj =================================================================== --- branches/cparm/Chameleon.xcodeproj/project.pbxproj (revision 1918) +++ branches/cparm/Chameleon.xcodeproj/project.pbxproj (revision 1919) @@ -8,6 +8,7 @@ /* Begin PBXFileReference section */ AB0E930C14C6223500F798D7 /* cpu_intel_amd.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = cpu_intel_amd.c; sourceTree = ""; }; + AB22095D15334C9E00AA9851 /* md5.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = md5.h; sourceTree = ""; }; AB42D02115187F2C0078E84A /* background.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = background.png; sourceTree = ""; }; AB42D02215187F2C0078E84A /* boot.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = boot.png; sourceTree = ""; }; AB42D02315187F2C0078E84A /* device_cdrom.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = device_cdrom.png; sourceTree = ""; }; @@ -265,7 +266,7 @@ AB43B31C14C37E520018D529 /* libsaio.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = libsaio.h; sourceTree = ""; }; AB43B31D14C37E520018D529 /* load.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = load.c; sourceTree = ""; }; AB43B31E14C37E520018D529 /* Makefile */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.make; path = Makefile; sourceTree = ""; }; - AB43B31F14C37E520018D529 /* md5c.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = md5c.c; sourceTree = ""; }; + AB43B31F14C37E520018D529 /* md5.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = md5.c; sourceTree = ""; }; AB43B32014C37E520018D529 /* misc.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = misc.c; sourceTree = ""; }; AB43B32114C37E520018D529 /* msdos.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = msdos.c; sourceTree = ""; }; AB43B32214C37E520018D529 /* msdos.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = msdos.h; sourceTree = ""; }; @@ -1019,7 +1020,8 @@ 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 */, Index: branches/cparm/CHANGES =================================================================== --- branches/cparm/CHANGES (revision 1918) +++ branches/cparm/CHANGES (revision 1919) @@ -1,3 +1,7 @@ +- 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 Index: branches/cparm/i386/libsaio/md5c.c =================================================================== --- branches/cparm/i386/libsaio/md5c.c (revision 1918) +++ branches/cparm/i386/libsaio/md5c.c (revision 1919) @@ -1,293 +0,0 @@ -/* - * 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 - - -#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)); -} Index: branches/cparm/i386/libsaio/console.c =================================================================== --- branches/cparm/i386/libsaio/console.c (revision 1918) +++ branches/cparm/i386/libsaio/console.c (revision 1919) @@ -79,6 +79,10 @@ 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; Index: branches/cparm/i386/libsaio/bootstruct.c =================================================================== --- branches/cparm/i386/libsaio/bootstruct.c (revision 1918) +++ branches/cparm/i386/libsaio/bootstruct.c (revision 1919) @@ -352,6 +352,9 @@ } DT__FlattenDeviceTree((void **)&addr, &size); + if (!size) { + stop("Couldn't get flatten device tree\n"); + } bootArgs->deviceTreeP = (uint32_t)addr; bootArgs->deviceTreeLength = size; } Index: branches/cparm/i386/libsaio/device_tree.c =================================================================== --- branches/cparm/i386/libsaio/device_tree.c (revision 1918) +++ branches/cparm/i386/libsaio/device_tree.c (revision 1919) @@ -13,15 +13,15 @@ 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]; @@ -73,14 +73,13 @@ 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. @@ -97,11 +96,11 @@ } 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; @@ -110,12 +109,12 @@ } node->last_prop = prop; prop->next = 0; - + DPRINTF("Done [0x%x]\n", prop); DTInfo.numProperties++; DTInfo.totalPropertySize += RoundToLong(length); - + return prop; } @@ -123,13 +122,12 @@ 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 @@ -149,7 +147,7 @@ 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; @@ -202,14 +200,14 @@ { 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); } @@ -218,7 +216,7 @@ rootNode = NULL; // XXX leaks any created strings - + DTInfo.numNodes = 0; DTInfo.numProperties = 0; DTInfo.totalPropertySize = 0; @@ -231,12 +229,12 @@ 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); @@ -246,12 +244,12 @@ 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; } @@ -268,16 +266,16 @@ { 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) { @@ -288,6 +286,10 @@ } else { buf = *buffer_p; } + if (!buf) { + *length = 0; + return; + } bzero(buf, totalSize); FlattenNodes(rootNode, buf); @@ -302,7 +304,7 @@ 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) { @@ -322,26 +324,26 @@ 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) { @@ -353,7 +355,7 @@ char *str = malloc(strlen(nameBuf) + 1); // XXX this will leak strcpy(str, nameBuf); - + child = DT__AddChild(node, str); } node = child; @@ -368,19 +370,19 @@ { 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); Index: branches/cparm/i386/libsaio/md5.c =================================================================== --- branches/cparm/i386/libsaio/md5.c (revision 0) +++ branches/cparm/i386/libsaio/md5.c (revision 1919) @@ -0,0 +1,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" + + +#define memset(x, y, z) bzero(x, z); +#define memcpy(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__) +#define FETCH_32(p) (*(const u_int32_t *)(p)) +#else +#define FETCH_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. */ +#define F(x, y, z) ((((y) ^ (z)) & (x)) ^ (z)) +#define G(x, y, z) ((((x) ^ (y)) & (z)) ^ (y)) +#define H(x, y, z) ((x) ^ (y) ^ (z)) +#define I(x, y, z) (((~(z)) | (x)) ^ (y)) + +/* 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) + (unsigned long long)(ac); \ +(a) = ROTATE_LEFT((a), (s)); \ +(a) += (b); \ +} + +#define GG(a, b, c, d, x, s, ac) { \ +(a) += G((b), (c), (d)) + (x) + (unsigned long long)(ac); \ +(a) = ROTATE_LEFT((a), (s)); \ +(a) += (b); \ +} + +#define HH(a, b, c, d, x, s, ac) { \ +(a) += H((b), (c), (d)) + (x) + (unsigned long long)(ac); \ +(a) = ROTATE_LEFT((a), (s)); \ +(a) += (b); \ +} + +#define II(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 */ +#define S11 7 +#define S12 12 +#define S13 17 +#define S14 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 */ +#define S21 5 +#define S22 9 +#define S23 14 +#define S24 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 */ +#define S31 4 +#define S32 11 +#define S33 16 +#define S34 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 */ +#define S41 6 +#define S42 10 +#define S43 15 +#define S44 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; + +} \ No newline at end of file Index: branches/cparm/i386/libsaio/md5.h =================================================================== --- branches/cparm/i386/libsaio/md5.h (revision 0) +++ branches/cparm/i386/libsaio/md5.h (revision 1919) @@ -0,0 +1,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 +#include + +#define MD5_DIGEST_LENGTH 16 + +/* 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_ */ \ No newline at end of file Index: branches/cparm/i386/libsaio/Makefile =================================================================== --- branches/cparm/i386/libsaio/Makefile (revision 1918) +++ branches/cparm/i386/libsaio/Makefile (revision 1919) @@ -37,7 +37,7 @@ 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 \ Index: branches/cparm/i386/libsaio/device_inject.c =================================================================== --- branches/cparm/i386/libsaio/device_inject.c (revision 1918) +++ branches/cparm/i386/libsaio/device_inject.c (revision 1919) @@ -196,7 +196,12 @@ } } - 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; @@ -264,7 +269,7 @@ if(!device->data) { - device->data = (uint8_t*)malloc(sizeof(uint8_t)); + //device->data = (uint8_t*)malloc(sizeof(uint8_t)); //IMHO this is useless } else { Index: branches/cparm/i386/libsaio/sys.c =================================================================== --- branches/cparm/i386/libsaio/sys.c (revision 1918) +++ branches/cparm/i386/libsaio/sys.c (revision 1919) @@ -66,11 +66,7 @@ #include "disk.h" #include "modules.h" #include "xml.h" -#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 -# include -#else -# include -#endif +# include "md5.h" #include #if 0 /* No OS X release has ever included this. */ #include Index: branches/cparm/i386/libsaio/platform.c =================================================================== --- branches/cparm/i386/libsaio/platform.c (revision 1918) +++ branches/cparm/i386/libsaio/platform.c (revision 1919) @@ -70,23 +70,27 @@ 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) { @@ -141,17 +145,24 @@ 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', @@ -161,7 +172,7 @@ #endif return; } else { - HASH_ADD_STR( platform_env, name, var ); + HASH_ADD_KEYPTR( hh, platform_env, name, strlen(var->name), var ); } } @@ -316,9 +327,11 @@ #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) { @@ -341,6 +354,7 @@ } 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); } } @@ -352,20 +366,28 @@ 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)); @@ -375,7 +397,7 @@ #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)); @@ -506,7 +528,7 @@ century = (century & 0x0F) + ((century / 16) * 10); } } - + // Calculate the full (4-digit) year if(century_register != 0) { @@ -514,7 +536,7 @@ } else { //year += (CURRENT_YEAR / 100) * 100; //if(year < CURRENT_YEAR) year += 100; - + if ((year += 1900) < 1970) year += 100; } @@ -529,8 +551,10 @@ void rtc_time(EFI_TIME *time) { - read_rtc(time); + read_rtc(time); + time->TimeZone = EFI_UNSPECIFIED_TIMEZONE; + return ; } Index: branches/cparm/i386/libsaio/platform.h =================================================================== --- branches/cparm/i386/libsaio/platform.h (revision 1918) +++ branches/cparm/i386/libsaio/platform.h (revision 1919) @@ -79,110 +79,99 @@ } 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 { @@ -208,14 +197,14 @@ char BrandString[48]; // 48 Byte Branding String uint8_t Brand; uint32_t MicrocodeVersion; // 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_t dynamic_acceleration; boolean_t invariant_APIC_timer; boolean_t fine_grain_clock_mod; - + uint32_t cpuid_max_basic; uint32_t cpuid_max_ext; uint32_t sub_Cstates; Index: branches/cparm/i386/libsaio/disk.c =================================================================== --- branches/cparm/i386/libsaio/disk.c (revision 1918) +++ branches/cparm/i386/libsaio/disk.c (revision 1919) @@ -822,230 +822,227 @@ 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); /* @@ -1103,7 +1100,9 @@ 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; @@ -1114,6 +1113,9 @@ if (blksize != BPS) { free(buffer); buffer = malloc(blksize); + if (!buffer) { + return NULL; + } } factor = blksize / BPS; } else { @@ -1121,62 +1123,65 @@ 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; idpme_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; idpme_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); @@ -1274,6 +1279,9 @@ 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); @@ -1369,7 +1377,9 @@ if(bufferSize == 0) goto scanErr; buffer = malloc(bufferSize); - + if (!buffer) { + goto scanErr; + } if(readBytes(biosdev, gptBlock, 0, bufferSize, buffer) != 0) goto scanErr; @@ -1377,6 +1387,9 @@ // 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; @@ -1517,7 +1530,7 @@ } scanErr: - free(buffer); + if (buffer) free(buffer); if(map) { @@ -1615,10 +1628,10 @@ 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; } @@ -1887,6 +1900,9 @@ * Allocate and copy the matched bvr entry into a new one. */ newBVR = (BVRef) malloc(sizeof(*newBVR)); + if (!newBVR) { + continue; + } bcopy(bvr, newBVR, sizeof(*newBVR)); /* @@ -1956,7 +1972,7 @@ int ret = 1; BVRef bvr = chain; BVRef nextBVR = NULL; - + while (bvr < (BVRef)ULONG_MAX) { if (!bvr) { Index: branches/cparm/i386/libsaio/uthash.h =================================================================== --- branches/cparm/i386/libsaio/uthash.h (revision 1918) +++ branches/cparm/i386/libsaio/uthash.h (revision 1919) @@ -646,18 +646,20 @@ _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) ); \ Index: branches/cparm/i386/libsaio/pci.c =================================================================== --- branches/cparm/i386/libsaio/pci.c (revision 1918) +++ branches/cparm/i386/libsaio/pci.c (revision 1919) @@ -89,6 +89,9 @@ 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; @@ -145,6 +148,11 @@ 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); @@ -160,6 +168,10 @@ { char* buffer = malloc(sizeof(char) * 256); + if (!buffer) { + return NULL; + } + pci_dt_t *current; pci_dt_t *end; char tmp[64]; Index: branches/cparm/i386/libsaio/stringTable.c =================================================================== --- branches/cparm/i386/libsaio/stringTable.c (revision 1918) +++ branches/cparm/i386/libsaio/stringTable.c (revision 1919) @@ -740,6 +740,9 @@ "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" Index: branches/cparm/i386/libsaio/convert.c =================================================================== --- branches/cparm/i386/libsaio/convert.c (revision 1918) +++ branches/cparm/i386/libsaio/convert.c (revision 1919) @@ -10,27 +10,27 @@ /** 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; int i; char buf[3]; static EFI_CHAR8 uuid[UUID_LEN+1]=""; - + buf[2] = '\0'; for (i=0; i 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; + } } \ No newline at end of file Index: branches/cparm/i386/libsaio/fake_efi.c =================================================================== --- branches/cparm/i386/libsaio/fake_efi.c (revision 1918) +++ branches/cparm/i386/libsaio/fake_efi.c (revision 1919) @@ -79,6 +79,15 @@ 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; } @@ -150,6 +159,11 @@ 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) @@ -185,8 +199,9 @@ 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); @@ -557,8 +572,16 @@ 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]; Index: branches/cparm/i386/libsaio/misc.c =================================================================== --- branches/cparm/i386/libsaio/misc.c (revision 1918) +++ branches/cparm/i386/libsaio/misc.c (revision 1919) @@ -132,7 +132,9 @@ 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; Index: branches/cparm/i386/boot2/graphics.c =================================================================== --- branches/cparm/i386/boot2/graphics.c (revision 1918) +++ branches/cparm/i386/boot2/graphics.c (revision 1919) @@ -57,33 +57,41 @@ 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; } Index: branches/cparm/i386/boot2/boot.c =================================================================== --- branches/cparm/i386/boot2/boot.c (revision 1918) +++ branches/cparm/i386/boot2/boot.c (revision 1919) @@ -310,14 +310,17 @@ 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); } @@ -1036,6 +1039,9 @@ uuidSet = false; char * valueBuffer; valueBuffer = malloc(VALUE_SIZE); + if (!valueBuffer) { + return; + } char * argP = bootArgs->CommandLine; valueBuffer[0] = '*'; if (cnt > VALUE_SIZE) Index: branches/cparm/i386/boot2/options.c =================================================================== --- branches/cparm/i386/boot2/options.c (revision 1918) +++ branches/cparm/i386/boot2/options.c (revision 1919) @@ -116,11 +116,11 @@ //========================================================================== -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(); @@ -682,12 +682,24 @@ 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); } @@ -1277,6 +1289,10 @@ 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); Index: branches/cparm/i386/modules/YellowIconFixer/YellowIconFixer.c =================================================================== --- branches/cparm/i386/modules/YellowIconFixer/YellowIconFixer.c (revision 1918) +++ branches/cparm/i386/modules/YellowIconFixer/YellowIconFixer.c (revision 1919) @@ -35,7 +35,7 @@ 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, Index: branches/cparm/i386/modules/GUI/gui.c =================================================================== --- branches/cparm/i386/modules/GUI/gui.c (revision 1918) +++ branches/cparm/i386/modules/GUI/gui.c (revision 1919) @@ -2601,13 +2601,15 @@ // 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); } } Index: branches/cparm/i386/modules/GUI/GUI_module.c =================================================================== --- branches/cparm/i386/modules/GUI/GUI_module.c (revision 1918) +++ branches/cparm/i386/modules/GUI/GUI_module.c (revision 1919) @@ -211,7 +211,7 @@ gui.logo.draw = false; drawBackground(); updateVRAM(); - + if(!gVerboseMode) { // Disable outputs, they will still show in the boot log. @@ -220,20 +220,20 @@ } } - + } 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 @@ -242,7 +242,7 @@ 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); @@ -267,7 +267,7 @@ 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"); } @@ -365,7 +365,7 @@ { bool shouldboot = ( res != DO_NOT_BOOT ); safe_set_env(envShouldboot, shouldboot); - + if ( shouldboot ) gui.menu.draw = false; @@ -374,7 +374,7 @@ case BOOT_NORMAL: gVerboseMode = false; safe_set_env(envgBootMode, kBootModeNormal); - + break; case BOOT_VERBOSE: @@ -698,7 +698,7 @@ bool showPrompt, newShowPrompt, isCDROM; int optionKey; int devcnt = (int)get_env(envgDeviceCount); - + // Initialize default menu selection entry. gBootVolume = menuBVR = selectBootVolume(getBvChain()); @@ -710,7 +710,7 @@ { isCDROM = false; } - + // ensure we're in graphics mode if gui is setup if (gui.initialised && (getVideoMode() == VGA_TEXT_MODE)) { @@ -752,7 +752,7 @@ { gBootMode |= kBootModeQuiet; safe_set_env(envgBootMode,gBootMode); - + } // If the user is holding down a modifier key, enter safe mode. @@ -761,7 +761,7 @@ gBootMode |= kBootModeSafe; safe_set_env(envgBootMode,gBootMode); - + } // Checking user pressed keys @@ -778,7 +778,7 @@ { gBootMode &= ~kBootModeQuiet; safe_set_env(envgBootMode,gBootMode); - + timeout = 0; } // If user typed 'v' or 'V', boot in verbose mode. @@ -815,16 +815,26 @@ 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); } @@ -914,7 +924,7 @@ goto done; } } - + if (devcnt) { // Allocate memory for an array of menu items. @@ -960,7 +970,7 @@ // Display banner and show hardware info. gprintf(&gui.screen, bootBanner + 1, (int)(get_env(envConvMem) + get_env(envExtMem)) / 1024); - + } // redraw background Index: branches/cparm/i386/modules/GUI/graphic_utils.c =================================================================== --- branches/cparm/i386/modules/GUI/graphic_utils.c (revision 1918) +++ branches/cparm/i386/modules/GUI/graphic_utils.c (revision 1919) @@ -72,33 +72,40 @@ 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; } Index: branches/cparm/i386/modules/Networking/Networking.c =================================================================== --- branches/cparm/i386/modules/Networking/Networking.c (revision 1918) +++ branches/cparm/i386/modules/Networking/Networking.c (revision 1919) @@ -54,7 +54,7 @@ getBoolForKey(kEnableWifi, &do_wifi_devprop, DEFAULT_BOOT_CONFIG); if (do_wifi_devprop) - set_wifi_airport(current); + set_wifi_airport(current); } @@ -104,6 +104,9 @@ 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); @@ -145,6 +148,9 @@ 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); @@ -158,7 +164,7 @@ 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++) Index: branches/cparm/i386/modules/GraphicsEnabler/gma.c =================================================================== --- branches/cparm/i386/modules/GraphicsEnabler/gma.c (revision 1918) +++ branches/cparm/i386/modules/GraphicsEnabler/gma.c (revision 1919) @@ -1,6 +1,6 @@ /* -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" @@ -98,15 +98,17 @@ 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); @@ -124,7 +126,7 @@ 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)) { @@ -170,7 +172,7 @@ devprop_add_value(device, "AAPL,os-info", HD3000_os_info, 20); } - + stringdata = malloc(sizeof(uint8_t) * string->length); if(!stringdata) { Index: branches/cparm/i386/modules/GraphicsEnabler/GraphicsEnabler.c =================================================================== --- branches/cparm/i386/modules/GraphicsEnabler/GraphicsEnabler.c (revision 1918) +++ branches/cparm/i386/modules/GraphicsEnabler/GraphicsEnabler.c (revision 1919) @@ -37,26 +37,24 @@ 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; } - + } } \ No newline at end of file Index: branches/cparm/i386/modules/GraphicsEnabler/nvidia.c =================================================================== --- branches/cparm/i386/modules/GraphicsEnabler/nvidia.c (revision 1918) +++ branches/cparm/i386/modules/GraphicsEnabler/nvidia.c (revision 1919) @@ -1205,20 +1205,23 @@ 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", @@ -1227,6 +1230,11 @@ 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); @@ -1241,9 +1249,9 @@ } 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*)®s[NV_PRAMIN_OFFSET]; bcopy((uint32_t *)nvRom, rom, NVIDIA_ROM_SIZE); @@ -1253,13 +1261,13 @@ // PROM next // Enable PROM access (REG32(NV_PBUS_PCI_NV_20)) = NV_PBUS_PCI_NV_20_ROM_SHADOW_DISABLED; - + nvRom = (uint8_t*)®s[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 @@ -1280,16 +1288,16 @@ 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) { @@ -1303,17 +1311,17 @@ } } 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); @@ -1322,6 +1330,11 @@ // 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; @@ -1352,11 +1365,11 @@ } 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_t new_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); @@ -1369,7 +1382,7 @@ { 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); } } @@ -1379,7 +1392,7 @@ { 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); } } @@ -1391,14 +1404,14 @@ { 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); @@ -1411,10 +1424,16 @@ 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; } Index: branches/cparm/i386/modules/GraphicsEnabler/ati.c =================================================================== --- branches/cparm/i386/modules/GraphicsEnabler/ati.c (revision 1918) +++ branches/cparm/i386/modules/GraphicsEnabler/ati.c (revision 1919) @@ -458,16 +458,16 @@ { 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 }, @@ -513,9 +513,9 @@ { 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 }, @@ -524,9 +524,9 @@ { 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 }, @@ -536,13 +536,13 @@ { 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 }, @@ -558,11 +558,11 @@ { 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 }, @@ -576,13 +576,13 @@ { 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 }, @@ -592,7 +592,7 @@ { 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 }, @@ -708,10 +708,10 @@ { 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 }, @@ -787,35 +787,35 @@ 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 } }; @@ -883,11 +883,11 @@ 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; } @@ -927,7 +927,7 @@ 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); @@ -1029,9 +1029,9 @@ 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) @@ -1042,9 +1042,9 @@ { 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 @@ -1052,7 +1052,7 @@ } } } - + free(val); } @@ -1206,7 +1206,7 @@ // 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); @@ -1265,7 +1265,7 @@ RegWrite32(R600_CTXSW_VID_LOWER_GPIO_CNTL, ctxsw_vid_lower_gpio_cntl); RegWrite32(R600_LOWER_GPIO_ENABLE, lower_gpio_enable); } - + return ret; } @@ -1347,7 +1347,7 @@ card->io = (uint8_t *)(pci_config_read32(pci_dev->dev.addr, PCI_BASE_ADDRESS_4) & ~0x03); verbose("Framebuffer @0x%08X MMIO @0x%08X I/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"); @@ -1369,15 +1369,15 @@ } } -// 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); @@ -1387,7 +1387,7 @@ // 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); @@ -1415,9 +1415,9 @@ 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; @@ -1435,16 +1435,21 @@ 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; Index: branches/cparm/i386/modules/ACPICodec/acpidecode.c =================================================================== --- branches/cparm/i386/modules/ACPICodec/acpidecode.c (revision 1918) +++ branches/cparm/i386/modules/ACPICodec/acpidecode.c (revision 1919) @@ -505,7 +505,8 @@ 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); Index: branches/cparm/xcode3_sym.zip =================================================================== Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream Property changes on: branches/cparm/xcode3_sym.zip ___________________________________________________________________ Added: svn:mime-type + application/octet-stream