Index: branches/zenith432/i386/libsaio/fake_efi.h =================================================================== --- branches/zenith432/i386/libsaio/fake_efi.h (revision 2593) +++ branches/zenith432/i386/libsaio/fake_efi.h (revision 2594) @@ -29,7 +29,7 @@ #define __LIBSAIO_FAKE_EFI_H /* Set up space for up to 10 configuration table entries */ -#define MAX_CONFIGURATION_TABLE_ENTRIES 10 +#define MAX_CONFIGURATION_TABLE_ENTRIES (uint32_t)10 extern void setupFakeEfi(void); Index: branches/zenith432/i386/libsaio/xml.c =================================================================== --- branches/zenith432/i386/libsaio/xml.c (revision 2593) +++ branches/zenith432/i386/libsaio/xml.c (revision 2594) @@ -2,15 +2,15 @@ * Copyright (c) 2003 Apple Computer, Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ - * + * * Portions Copyright (c) 2003 Apple Computer, Inc. All Rights - * Reserved. + * Reserved. * The contents of this file constitute Original Code as defined in and * 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. Please obtain a copy of the License at * http://www.apple.com/publicsource and read it before using this file. - * + * * This 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, @@ -18,7 +18,7 @@ * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the * License for the specific language governing rights and limitations * under the License. - * + * * @APPLE_LICENSE_HEADER_END@ */ @@ -30,12 +30,12 @@ string_ref *ref_strings = NULL; /// TODO: remove below -static char* buffer_start = NULL; +static char *buffer_start = NULL; // TODO: redo the next two functions -void SaveRefString(char* string, int id) +void SaveRefString(char *string, int id) { //printf("Adding Ref String %d (%s)\n", id, string); - string_ref* tmp = ref_strings; + string_ref *tmp = ref_strings; while(tmp) { if(tmp->id == id) @@ -55,16 +55,16 @@ ref_strings = new_ref; } -char* GetRefString(int id) +char *GetRefString(int id) { - string_ref* tmp = ref_strings; + string_ref *tmp = ref_strings; while(tmp) { if(tmp->id == id) return tmp->string; tmp = tmp->next; } //verbose("Unable to locate Ref String %d\n", id); - return ""; + return "Unknown"; } struct Module { @@ -127,12 +127,12 @@ //========================================================================== // XMLGetProperty -TagPtr -XMLGetProperty(TagPtr dict, const char * key) +TagPtr XMLGetProperty(TagPtr dict, const char *key) { TagPtr tagList, tag; - if (dict->type != kTagTypeDict) { + if (dict->type != kTagTypeDict) + { return 0; } @@ -142,11 +142,13 @@ tag = tagList; tagList = tag->tagNext; - if ((tag->type != kTagTypeKey) || (tag->string == 0)) { + if ((tag->type != kTagTypeKey) || (tag->string == 0)) + { continue; } - if (!strcmp(tag->string, key)) { + if (!strcmp(tag->string, key)) + { return tag->tag; } } @@ -156,12 +158,12 @@ //========================================================================== // XMLGetProperty -TagPtr -XMLGetKey( TagPtr dict, int id ) +TagPtr XMLGetKey( TagPtr dict, int id ) { TagPtr tagList, tag; - - if (dict->type != kTagTypeDict) { + + if (dict->type != kTagTypeDict) + { return 0; } @@ -173,12 +175,14 @@ tag = tagList; tagList = tag->tagNext; - if ((tag->type != kTagTypeKey) || (tag->string == 0)) { + if ((tag->type != kTagTypeKey) || (tag->string == 0)) + { continue; } element++; - if(id == element) { + if(id == element) + { return tag; } @@ -188,7 +192,8 @@ TagPtr XMLGetValueForKey(TagPtr key) { - if (!key || key->type != kTagTypeKey) { + if (!key || key->type != kTagTypeKey) + { return 0; } @@ -204,7 +209,8 @@ int count = 0; TagPtr tagList, tag; - if (dict->type != kTagTypeDict && dict->type != kTagTypeArray) { + if (dict->type != kTagTypeDict && dict->type != kTagTypeArray) + { return 0; } @@ -214,24 +220,26 @@ { tag = tagList; tagList = tag->tagNext; - + if (((tag->type != kTagTypeKey) && ((tag->string == 0) || (tag->string[0] == 0))) && (dict->type != kTagTypeArray) // If we are an array, any element is valid - ) { + ) + { continue; } - + //if(tag->type == kTagTypeKey) printf("Located key %s\n", tag->string); count++; } - + return count; } TagPtr XMLGetElement( TagPtr dict, int id ) { - if(dict->type != kTagTypeArray) { + if(dict->type != kTagTypeArray) + { return 0; } @@ -243,16 +251,16 @@ element++; tmp = tmp->tagNext; } - + return tmp; } + /* Function for basic XML character entities parsing */ -char* -XMLDecode(const char* src) +char *XMLDecode(const char* src) { typedef const struct XMLEntity { - const char* name; + const char *name; size_t nameLen; char value; } XMLEntity; @@ -269,7 +277,8 @@ const char *s; char *out, *o; - if ( !src || !(len = strlen(src)) || !(out = malloc(len+1)) ) { + if ( !src || !(len = strlen(src)) || !(out = malloc(len+1)) ) + { return 0; } @@ -277,19 +286,22 @@ s = src; while (s <= src+len) /* Make sure the terminator is also copied */ { - if ( *s == '&' ) { + if ( *s == '&' ) + { bool entFound = false; int i; s++; for ( i = 0; i < sizeof(ents)/sizeof(ents[0]); i++) { - if ( strncmp(s, ents[i].name, ents[i].nameLen) == 0 ) { + if ( strncmp(s, ents[i].name, ents[i].nameLen) == 0 ) + { entFound = true; break; } } - if ( entFound ) { + if ( entFound ) + { *o++ = ents[i].value; s += ents[i].nameLen; @@ -303,7 +315,6 @@ return out; } -//#if UNUSED //========================================================================== // XMLParseFile // Expects to see one dictionary in the XML file, the final pos will be returned @@ -311,58 +322,69 @@ // Puts the first dictionary it finds in the // tag pointer and returns the end of the dic, or returns -1 if not found. // -long -XMLParseFile( char * buffer, TagPtr * dict ) +long XMLParseFile( char * buffer, TagPtr *dict ) { - long length, pos; - TagPtr tag; - pos = 0; - char *configBuffer; + long length; + long pos = 0; + TagPtr tag; + char *configBuffer; int strlength = strlen(buffer); configBuffer = malloc(strlength+1); bcopy(buffer, configBuffer, strlength); + configBuffer[strlength] = 0; buffer_start = configBuffer; - while (1) - { - length = XMLParseNextTag(configBuffer + pos, &tag); - if (length == -1) break; + while (1) + { + length = XMLParseNextTag(configBuffer + pos, &tag); + if (length == -1) break; - pos += length; + pos += length; - if (tag == 0) continue; - if (tag->type == kTagTypeDict) break; - - XMLFreeTag(tag); - } + if (tag == 0) + { + continue; + } + + if (tag->type == kTagTypeDict) + { + break; + } + + XMLFreeTag(tag); + } free(configBuffer); - if (length < 0) { - return -1; - } - *dict = tag; - return pos; + if (length < 0) + { + return -1; + } + *dict = tag; + return pos; } -//#endif /* UNUSED */ //========================================================================== // ParseNextTag // TODO: cleanup -long -XMLParseNextTag( char * buffer, TagPtr * tag ) +long XMLParseNextTag( char *buffer, TagPtr *tag ) { - long length, pos; - char * tagName; + long length = 0; + long pos = 0; + + char *tagName; + length = GetNextTag(buffer, &tagName, 0); - if (length == -1) { + if (length == -1) + { return -1; } pos = length; - if (!strncmp(tagName, kXMLTagPList, 6)) { + if (!strncmp(tagName, kXMLTagPList, 6)) + { length = 0; // just a header; nothing to parse // return-via-reference tag should be left alone @@ -371,51 +393,70 @@ else if (!strcmp(tagName, kXMLTagDict)) { length = ParseTagList(buffer + pos, tag, kTagTypeDict, 0); - } else if (!strncmp(tagName, kXMLTagDict, strlen(kXMLTagDict)) && tagName[strlen(tagName)-1] == '/') { + } + else if (!strncmp(tagName, kXMLTagDict, strlen(kXMLTagDict)) && tagName[strlen(tagName)-1] == '/') + { length = ParseTagList(buffer + pos, tag, kTagTypeDict, 1); - } else if (!strncmp(tagName, kXMLTagDict " ", strlen(kXMLTagDict " "))) { + } + else if (!strncmp(tagName, kXMLTagDict " ", strlen(kXMLTagDict " "))) + { length = ParseTagList(buffer + pos, tag, kTagTypeDict, 0); } /***** key ****/ - else if (!strcmp(tagName, kXMLTagKey)) { + else if (!strcmp(tagName, kXMLTagKey)) + { length = ParseTagKey(buffer + pos, tag); } /***** string ****/ - else if (!strcmp(tagName, kXMLTagString)) { + else if (!strcmp(tagName, kXMLTagString)) + { length = ParseTagString(buffer + pos, tag); - } else if (!strncmp(tagName, kXMLTagString " ", strlen(kXMLTagString " "))) { + } + else if (!strncmp(tagName, kXMLTagString " ", strlen(kXMLTagString " "))) + { // TODO: save tag if if found - if(!strncmp(tagName + strlen(kXMLTagString " "), kXMLStringID, strlen(kXMLStringID))) { + if(!strncmp(tagName + strlen(kXMLTagString " "), kXMLStringID, strlen(kXMLStringID))) + { // ID= int id = 0; int cnt = strlen(kXMLTagString " " kXMLStringID "\"") + 1; while ((tagName[cnt] != '\0') && (tagName[cnt] != '"')) cnt++; tagName[cnt] = 0; char* val = tagName + strlen(kXMLTagString " " kXMLStringID "\""); - while(*val) { - if ((*val >= '0' && *val <= '9')) { // 0 - 9 + while(*val) + { + if ((*val >= '0' && *val <= '9')) // 0 - 9 + { id = (id * 10) + (*val++ - '0'); - } else { + } + else + { printf("ParseStringID error (0x%x)\n", *val); getchar(); return -1; } } length = ParseTagString(buffer + pos, tag); - + SaveRefString(buffer + pos, id); - } else if(!strncmp(tagName + strlen(kXMLTagString " "), kXMLStringIDRef, strlen(kXMLStringIDRef))) { + } + else if(!strncmp(tagName + strlen(kXMLTagString " "), kXMLStringIDRef, strlen(kXMLStringIDRef))) + { // IDREF= int id = 0; int cnt = strlen(kXMLTagString " " kXMLStringIDRef "\"") + 1; while ((tagName[cnt] != '\0') && (tagName[cnt] != '"')) cnt++; tagName[cnt] = 0; char* val = tagName + strlen(kXMLTagString " " kXMLStringIDRef "\""); - while(*val) { - if ((*val >= '0' && *val <= '9')) { // 0 - 9 + while(*val) + { + if ((*val >= '0' && *val <= '9')) // 0 - 9 + { id = (id * 10) + (*val++ - '0'); - } else { + } + else + { printf("ParseStringIDREF error (0x%x)\n", *val); getchar(); return -1; @@ -430,53 +471,67 @@ tmpTag->tagNext = 0; tmpTag->offset = buffer_start ? buffer - buffer_start + pos : 0; *tag = tmpTag; - + length = 0; //printf("Located IDREF, id = %d, string = %s\n", id, str); } } /***** integer ****/ - else if (!strcmp(tagName, kXMLTagInteger)) { + else if (!strcmp(tagName, kXMLTagInteger)) + { length = ParseTagInteger(buffer + pos, tag); - } else if (!strncmp(tagName, kXMLTagInteger " ", strlen(kXMLTagInteger " "))) { - if(!strncmp(tagName + strlen(kXMLTagInteger " "), kXMLStringID, strlen(kXMLStringID))) { + } + else if (!strncmp(tagName, kXMLTagInteger " ", strlen(kXMLTagInteger " "))) + { + if(!strncmp(tagName + strlen(kXMLTagInteger " "), kXMLStringID, strlen(kXMLStringID))) + { // ID= int id = 0; int cnt = strlen(kXMLTagInteger " " kXMLStringID "\"") + 1; while ((tagName[cnt] != '\0') && (tagName[cnt] != '"')) cnt++; tagName[cnt] = 0; char* val = tagName + strlen(kXMLTagInteger " " kXMLStringID "\""); - while(*val) { - if ((*val >= '0' && *val <= '9')) { // 0 - 9 + while(*val) + { + if ((*val >= '0' && *val <= '9')) // 0 - 9 + { id = (id * 10) + (*val++ - '0'); - } else { + } + else + { printf("ParseIntegerID error (0x%x)\n", *val); getchar(); return -1; } } length = ParseTagInteger(buffer + pos, tag); - + SaveRefString((*tag)->string, id); - } else if(!strncmp(tagName + strlen(kXMLTagInteger " "), kXMLStringIDRef, strlen(kXMLStringIDRef))) { + } + else if(!strncmp(tagName + strlen(kXMLTagInteger " "), kXMLStringIDRef, strlen(kXMLStringIDRef))) + { // IDREF= int id = 0; int cnt = strlen(kXMLTagInteger " " kXMLStringIDRef "\"") + 1; while ((tagName[cnt] != '\0') && (tagName[cnt] != '"')) cnt++; tagName[cnt] = 0; char* val = tagName + strlen(kXMLTagInteger " " kXMLStringIDRef "\""); - while(*val) { - if ((*val >= '0' && *val <= '9')) { // 0 - 9 + while(*val) + { + if ((*val >= '0' && *val <= '9')) // 0 - 9 + { id = (id * 10) + (*val++ - '0'); - } else { + } + else + { printf("ParseStringIDREF error (0x%x)\n", *val); getchar(); return -1; } } int integer = (int)GetRefString(id); - + TagPtr tmpTag = NewTag(); tmpTag->type = kTagTypeInteger; tmpTag->string = (char*) integer; @@ -485,22 +540,26 @@ tmpTag->offset = buffer_start ? buffer - buffer_start + pos : 0; *tag = tmpTag; - + length = 0; //printf("Located IDREF, id = %d, string = %s\n", id, str); - } else { + } + else + { length = ParseTagInteger(buffer + pos, tag); } } /***** false ****/ - else if (!strcmp(tagName, kXMLTagFalse)) { + else if (!strcmp(tagName, kXMLTagFalse)) + { length = ParseTagBoolean(buffer + pos, tag, kTagTypeFalse); } /***** true ****/ - else if (!strcmp(tagName, kXMLTagTrue)) { + else if (!strcmp(tagName, kXMLTagTrue)) + { length = ParseTagBoolean(buffer + pos, tag, kTagTypeTrue); } @@ -511,35 +570,47 @@ /***** data ****/ - else if (!strcmp(tagName, kXMLTagData)) { + else if (!strcmp(tagName, kXMLTagData)) + { length = ParseTagData(buffer + pos, tag); - } else if (!strncmp(tagName, kXMLTagData " ", strlen(kXMLTagData " "))) { + } + else if (!strncmp(tagName, kXMLTagData " ", strlen(kXMLTagData " "))) + { length = ParseTagData(buffer + pos, tag); - } else if (!strcmp(tagName, kXMLTagDate)) { + } + else if (!strcmp(tagName, kXMLTagDate)) + { length = ParseTagDate(buffer + pos, tag); } /***** date ****/ - else if (!strncmp(tagName, kXMLTagDate " ", strlen(kXMLTagDate " "))) { + else if (!strncmp(tagName, kXMLTagDate " ", strlen(kXMLTagDate " "))) + { length = ParseTagDate(buffer + pos, tag); } /***** array ****/ - else if (!strcmp(tagName, kXMLTagArray)) { + else if (!strcmp(tagName, kXMLTagArray)) + { length = ParseTagList(buffer + pos, tag, kTagTypeArray, 0); } - else if (!strncmp(tagName, kXMLTagArray " ", strlen(kXMLTagArray " "))) { + else if (!strncmp(tagName, kXMLTagArray " ", strlen(kXMLTagArray " "))) + { length = ParseTagList(buffer + pos, tag, kTagTypeArray, 0); - } else if (!strcmp(tagName, kXMLTagArray "/")) { + } + else if (!strcmp(tagName, kXMLTagArray "/")) + { length = ParseTagList(buffer + pos, tag, kTagTypeArray, 1); } /***** unknown ****/ - else { - // it wasn't parsed so we consumed no additional characters + else + { + // it wasn't parsed so we consumed no additional characters *tag = 0; length = 0; } - if (length == -1) { + if (length == -1) + { return -1; } @@ -549,40 +620,45 @@ //========================================================================== // ParseTagList -static long -ParseTagList( char * buffer, TagPtr * tag, long type, long empty ) +static long ParseTagList( char *buffer, TagPtr *tag, long type, long empty ) { - long length, pos; - TagPtr tagList, tmpTag; + long pos = 0; + long length = 0; + TagPtr tagList = 0; + TagPtr tmpTag; + - tagList = 0; - pos = 0; - - if (!empty) { - while (1) { + if (!empty) + { + while (1) + { length = XMLParseNextTag(buffer + pos, &tmpTag); - if (length == -1) { + if (length == -1) + { break; } pos += length; // detect end of list - if (tmpTag == 0) { + if (tmpTag == 0) + { break; } tmpTag->tagNext = tagList; tagList = tmpTag; } - if (length == -1) { + if (length == -1) + { XMLFreeTag(tagList); return -1; } } tmpTag = NewTag(); - if (tmpTag == 0) { + if (tmpTag == 0) + { XMLFreeTag(tagList); return -1; } @@ -601,31 +677,36 @@ //========================================================================== // ParseTagKey -static long -ParseTagKey( char * buffer, TagPtr * tag ) +static long ParseTagKey( char *buffer, TagPtr *tag ) { - long length, length2; - char *string; - TagPtr tmpTag, subTag; + long length = 0; + long length2 = 0; + char *string; + TagPtr tmpTag; + TagPtr subTag; length = FixDataMatchingTag(buffer, kXMLTagKey); - if (length == -1) { + if (length == -1) + { return -1; } length2 = XMLParseNextTag(buffer + length, &subTag); - if (length2 == -1) { + if (length2 == -1) + { return -1; } tmpTag = NewTag(); - if (tmpTag == 0) { + if (tmpTag == 0) + { XMLFreeTag(subTag); return -1; } string = NewSymbol(buffer); - if (string == 0) { + if (string == 0) + { XMLFreeTag(subTag); XMLFreeTag(tmpTag); return -1; @@ -638,31 +719,33 @@ tmpTag->tagNext = 0; *tag = tmpTag; - + return length + length2; } //========================================================================== // ParseTagString -static long -ParseTagString( char * buffer, TagPtr * tag ) +static long ParseTagString( char *buffer, TagPtr *tag ) { - long length; - char * string; + long length = 0; + char *string; length = FixDataMatchingTag(buffer, kXMLTagString); - if (length == -1) { + if (length == -1) + { return -1; } TagPtr tmpTag = NewTag(); - if (tmpTag == 0) { + if (tmpTag == 0) + { return -1; } - + string = NewSymbol(buffer); - if (string == 0) { + if (string == 0) + { XMLFreeTag(tmpTag); return -1; } @@ -670,8 +753,8 @@ tmpTag->type = kTagTypeString; tmpTag->string = string; tmpTag->tag = 0; + tmpTag->tagNext = 0; tmpTag->offset = buffer_start ? buffer - buffer_start: 0; - tmpTag->tagNext = 0; *tag = tmpTag; return length; @@ -680,8 +763,7 @@ //========================================================================== // ParseTagInteger -static long -ParseTagInteger( char * buffer, TagPtr * tag ) +static long ParseTagInteger( char *buffer, TagPtr *tag ) { long length, integer; bool negative = false; @@ -704,46 +786,62 @@ return 0; } - + size = length = FixDataMatchingTag(buffer, kXMLTagInteger); - if (length == -1) { + if (length == -1) + { return -1; } tmpTag = NewTag(); - if (tmpTag == 0) { + if (tmpTag == 0) + { return -1; } integer = 0; - if(size > 1 && (val[1] == 'x' || val[1] == 'X')) { // Hex value + if(size > 1 && (val[1] == 'x' || val[1] == 'X')) // Hex value + { val += 2; - while(*val) { - if ((*val >= '0' && *val <= '9')) { // 0 - 9 - + while(*val) + { + if ((*val >= '0' && *val <= '9')) // 0 - 9 + { integer = (integer * 16) + (*val++ - '0'); - } else if ((*val >= 'a' && *val <= 'f')) { // a - f + } + else if ((*val >= 'a' && *val <= 'f')) // a - f + { integer = (integer * 16) + (*val++ - 'a' + 10); - } else if ((*val >= 'A' && *val <= 'F')) { // A - F + } + else if ((*val >= 'A' && *val <= 'F')) // A - F + { integer = (integer * 16) + (*val++ - 'A' + 10); - } else { + } + else + { printf("ParseTagInteger hex error (0x%x) in buffer %s\n", *val, buffer); getchar(); XMLFreeTag(tmpTag); return -1; } } - } else if ( size ) { // Decimal value - if (*val == '-') { + } + else if ( size ) // Decimal value + { + if (*val == '-') + { negative = true; val++; size--; } - for (integer = 0; size > 0; size--) { - if(*val) { // UGLY HACK, fix me. - if (*val < '0' || *val > '9') { + for (integer = 0; size > 0; size--) + { + if(*val) // UGLY HACK, fix me. + { + if (*val < '0' || *val > '9') + { printf("ParseTagInteger decimal error (0x%x) in buffer %s\n", *val, buffer); getchar(); return -1; @@ -772,28 +870,36 @@ //========================================================================== // ParseTagData -static long -ParseTagData( char * buffer, TagPtr * tag ) +static long ParseTagData( char *buffer, TagPtr *tag ) { - int actuallen = 0; - long length; - TagPtr tmpTag; + int actuallen = 0; + long length = 0; + TagPtr tmpTag; + char *string; length = FixDataMatchingTag(buffer, kXMLTagData); - if (length == -1) return -1; + if (length == -1) + { + return -1; + } tmpTag = NewTag(); - if (tmpTag == 0) return -1; + if (tmpTag == 0) + { + return -1; + } //printf("ParseTagData unimplimented\n"); //printf("Data: %s\n", buffer); // getchar(); - char* string = BASE64Decode(buffer, strlen(buffer), &actuallen); + string = BASE64Decode(buffer, strlen(buffer), &actuallen); tmpTag->type = kTagTypeData; tmpTag->string = string; + tmpTag->tag = 0; tmpTag->offset = actuallen; // buffer_start ? buffer - buffer_start: 0; + tmpTag->tagNext = 0; *tag = tmpTag; @@ -804,17 +910,22 @@ //========================================================================== // ParseTagDate -static long -ParseTagDate( char * buffer, TagPtr * tag ) +static long ParseTagDate( char *buffer, TagPtr *tag ) { - long length; - TagPtr tmpTag; + long length = 0; + TagPtr tmpTag; length = FixDataMatchingTag(buffer, kXMLTagDate); - if (length == -1) return -1; + if (length == -1) + { + return -1; + } tmpTag = NewTag(); - if (tmpTag == 0) return -1; + if (tmpTag == 0) + { + return -1; + } printf("ParseTagDate unimplimented\n"); getchar(); @@ -822,8 +933,8 @@ tmpTag->type = kTagTypeDate; tmpTag->string = 0; tmpTag->tag = 0; + tmpTag->tagNext = 0; tmpTag->offset = buffer_start ? buffer - buffer_start: 0; - tmpTag->tagNext = 0; *tag = tmpTag; @@ -833,19 +944,21 @@ //========================================================================== // ParseTagBoolean -long -ParseTagBoolean( char * buffer, TagPtr * tag, long type ) +long ParseTagBoolean( char *buffer, TagPtr *tag, long type ) { TagPtr tmpTag; tmpTag = NewTag(); - if (tmpTag == 0) return -1; + if (tmpTag == 0) + { + return -1; + } tmpTag->type = type; tmpTag->string = 0; tmpTag->tag = 0; + tmpTag->tagNext = 0; tmpTag->offset = buffer_start ? buffer - buffer_start: 0; - tmpTag->tagNext = 0; *tag = tmpTag; @@ -855,32 +968,44 @@ //========================================================================== // GetNextTag -static long -GetNextTag( char * buffer, char ** tag, long * start ) +static long GetNextTag( char *buffer, char **tag, long *start ) { - long cnt, cnt2; + long cnt; + long cnt2; - if (tag == 0) { + if (tag == 0) + { return -1; } // Find the start of the tag. cnt = 0; - while ((buffer[cnt] != '\0') && (buffer[cnt] != '<')) cnt++; - if (buffer[cnt] == '\0') { + while ((buffer[cnt] != '\0') && (buffer[cnt] != '<')) + { + cnt++; + } + + if (buffer[cnt] == '\0') + { return -1; } // Find the end of the tag. cnt2 = cnt + 1; - while ((buffer[cnt2] != '\0') && (buffer[cnt2] != '>')) cnt2++; - if (buffer[cnt2] == '\0') { + while ((buffer[cnt2] != '\0') && (buffer[cnt2] != '>')) + { + cnt2++; + } + + if (buffer[cnt2] == '\0') + { return -1; } // Fix the tag data. *tag = buffer + cnt + 1; buffer[cnt2] = '\0'; - if (start) { + if (start) + { *start = cnt; } @@ -893,25 +1018,33 @@ // Returns the length of the data found, counting the end tag, // or -1 if the end tag was not found. -static long -FixDataMatchingTag( char * buffer, char * tag ) +static long FixDataMatchingTag( char *buffer, char *tag ) { - long length, start, stop; - char * endTag; - - start = 0; - while (1) - { - length = GetNextTag(buffer + start, &endTag, &stop); - if (length == -1) return -1; - - if ((*endTag == '/') && !strcmp(endTag + 1, tag)) break; - start += length; - } - - buffer[start + stop] = '\0'; - - return start + length; + long length; + long start; + long stop; + char *endTag; + + start = 0; + while (1) + { + length = GetNextTag(buffer + start, &endTag, &stop); + if (length == -1) + { + return -1; + } + + if ((*endTag == '/') && !strcmp(endTag + 1, tag)) + { + break; + } + + start += length; + } + + buffer[start + stop] = '\0'; + + return start + length; } //========================================================================== @@ -921,48 +1054,51 @@ static TagPtr gTagsFree; -static TagPtr -NewTag( void ) +static TagPtr NewTag( void ) { - long cnt; - TagPtr tag; + long cnt; + TagPtr tag; - if (gTagsFree == 0) - { - tag = (TagPtr)malloc(kTagsPerBlock * sizeof(Tag)); - if (tag == 0) return 0; - - // Initalize the new tags. - for (cnt = 0; cnt < kTagsPerBlock; cnt++) - { - tag[cnt].type = kTagTypeNone; - tag[cnt].string = 0; - tag[cnt].tag = 0; - tag[cnt].tagNext = tag + cnt + 1; - } - tag[kTagsPerBlock - 1].tagNext = 0; + if (gTagsFree == 0) + { + tag = (TagPtr)malloc(kTagsPerBlock *sizeof(Tag)); + if (tag == 0) + { + return 0; + } - gTagsFree = tag; - } + // Initalize the new tags. + for (cnt = 0; cnt < kTagsPerBlock; cnt++) + { + tag[cnt].type = kTagTypeNone; + tag[cnt].string = 0; + tag[cnt].tag = 0; + tag[cnt].tagNext = tag + cnt + 1; + } + tag[kTagsPerBlock - 1].tagNext = 0; - tag = gTagsFree; - gTagsFree = tag->tagNext; - - return tag; + gTagsFree = tag; + } + + tag = gTagsFree; + gTagsFree = tag->tagNext; + + return tag; } //========================================================================== // XMLFreeTag -void -XMLFreeTag( TagPtr tag ) +void XMLFreeTag( TagPtr tag ) { #if DOFREE - if (tag == 0) { + if (tag == 0) + { return; } - if (!XMLIsInteger(tag) && tag->string) { + if (!XMLIsInteger(tag) && tag->string) + { FreeSymbol(tag->string); } @@ -992,26 +1128,28 @@ }; typedef struct Symbol Symbol, *SymbolPtr; -static SymbolPtr FindSymbol(char * string, SymbolPtr * prevSymbol); +static SymbolPtr FindSymbol(char *string, SymbolPtr *prevSymbol); static SymbolPtr gSymbolsHead; //========================================================================== // NewSymbol -static char * -NewSymbol( char * string ) +static char *NewSymbol( char *string ) { static SymbolPtr lastGuy = 0; - SymbolPtr symbol; + SymbolPtr symbol; + // Look for string in the list of symbols. symbol = FindSymbol(string, 0); - // Add the new symbol. - if (symbol == 0) { + // Add the new symbol. + if (symbol == 0) + { symbol = (SymbolPtr)malloc(sizeof(Symbol) + 1 + strlen(string)); - if (symbol == 0) { //return 0; + if (symbol == 0) + { //return 0; stop("NULL symbol!"); } @@ -1027,7 +1165,8 @@ // Update the refCount and return the string. symbol->refCount++; - if (lastGuy && lastGuy->next != 0) { + if (lastGuy && lastGuy->next != 0) + { stop("last guy not last!"); } @@ -1038,29 +1177,33 @@ // FreeSymbol #if DOFREE -static void -FreeSymbol( char * string ) +static void FreeSymbol( char *string ) { SymbolPtr symbol, prev; prev = 0; // Look for string in the list of symbols. symbol = FindSymbol(string, &prev); - if (symbol == 0) { + if (symbol == 0) + { return; } // Update the refCount. symbol->refCount--; - if (symbol->refCount != 0) { + if (symbol->refCount != 0) + { return; } // Remove the symbol from the list. - if (prev != 0) { + if (prev != 0) + { prev->next = symbol->next; - } else { + } + else + { gSymbolsHead = symbol->next; } @@ -1072,16 +1215,17 @@ //========================================================================== // FindSymbol -static SymbolPtr -FindSymbol( char * string, SymbolPtr * prevSymbol ) +static SymbolPtr FindSymbol( char *string, SymbolPtr *prevSymbol ) { SymbolPtr symbol, prev; - + symbol = gSymbolsHead; prev = 0; - while (symbol != 0) { - if (!strcmp(symbol->string, string)) { + while (symbol != NULL) + { + if (!strcmp(symbol->string, string)) + { break; } @@ -1089,7 +1233,8 @@ symbol = symbol->next; } - if ((symbol != 0) && (prevSymbol != 0)) { + if ((symbol != 0) && (prevSymbol != 0)) + { *prevSymbol = prev; } @@ -1098,7 +1243,8 @@ bool XMLIsType(TagPtr dict, enum xmltype type) { - if(!dict) { + if(!dict) + { return (type == kTagTypeNone); } return (dict->type == type); @@ -1112,10 +1258,13 @@ TagPtr XMLCastArray(TagPtr dict) { - if(!dict) { + if(!dict) + { return NULL; } - if(dict->type == kTagTypeArray) { + + if(dict->type == kTagTypeArray) + { return dict; } else { return NULL; @@ -1134,12 +1283,17 @@ TagPtr XMLCastDict(TagPtr dict) { - if(!dict) { + if(!dict) + { return NULL; } - if(dict->type == kTagTypeDict) { + + if(dict->type == kTagTypeDict) + { return dict; - } else { + } + else + { return NULL; } } @@ -1149,26 +1303,30 @@ return entry && ((entry->type == kTagTypeString) || (entry->type == kTagTypeKey)); } -char* XMLCastString(TagPtr dict) +char *XMLCastString(TagPtr dict) { - if(!dict) { + if(!dict) + { return NULL; } - if((dict->type == kTagTypeString) || (dict->type == kTagTypeKey)) { + if((dict->type == kTagTypeString) || (dict->type == kTagTypeKey)) + { return dict->string; } return NULL; } -char* XMLCastData(TagPtr dict, int* length) +char *XMLCastData(TagPtr dict, int* length) { - if(!dict) { + if(!dict) + { return NULL; } - if((dict->type == kTagTypeData) || (dict->type == kTagTypeKey)) { + if((dict->type == kTagTypeData) || (dict->type == kTagTypeKey)) + { *length = dict->offset; return dict->string; } @@ -1179,9 +1337,12 @@ long XMLCastStringOffset(TagPtr dict) { - if(dict && ((dict->type == kTagTypeString) || (dict->type == kTagTypeKey))) { + if(dict && ((dict->type == kTagTypeString) || (dict->type == kTagTypeKey))) + { return dict->offset; - } else { + } + else + { return -1; } } @@ -1193,10 +1354,13 @@ bool XMLCastBoolean(TagPtr dict) { - if(!dict) { + if(!dict) + { return false; } - if(dict->type == kTagTypeTrue) { + + if(dict->type == kTagTypeTrue) + { return true; } return false; @@ -1209,19 +1373,23 @@ int XMLCastInteger(TagPtr dict) { - if(!dict) { + if(!dict) + { //printf("XMLCastInteger: null dict\n"); return 0; } - if(dict->type == kTagTypeInteger) { + + if(dict->type == kTagTypeInteger) + { return (int)(dict->string); } return 0; } -bool XMLAddTagToDictionary(TagPtr dict, char* key, TagPtr value) +bool XMLAddTagToDictionary(TagPtr dict, char *key, TagPtr value) { - if (!dict || dict->type != kTagTypeDict) { + if (!dict || dict->type != kTagTypeDict) + { return false; } @@ -1229,12 +1397,14 @@ char* string; tmpTag = NewTag(); - if (tmpTag == 0) { + if (tmpTag == 0) + { return false; } string = NewSymbol(key); - if (string == 0) { + if (string == 0) + { XMLFreeTag(tmpTag); return false; } @@ -1246,13 +1416,15 @@ tmpTag->tagNext = 0; TagPtr tagList = dict->tag; - if(!tagList) { + if(!tagList) + { // First tag dict->tag = tmpTag; return true; } while(tagList && tagList->tagNext) tagList = tagList->tagNext; - if(tagList) { + if(tagList) + { tagList->tagNext = tmpTag; return true; } Index: branches/zenith432/i386/libsaio/xml.h =================================================================== --- branches/zenith432/i386/libsaio/xml.h (revision 2593) +++ branches/zenith432/i386/libsaio/xml.h (revision 2594) @@ -2,7 +2,7 @@ * Copyright (c) 2003 Apple Computer, Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ - * + * * Portions Copyright (c) 2003 Apple Computer, Inc. All Rights * Reserved. This file contains Original Code and/or Modifications of * Original Code as defined in and that are subject to the Apple Public @@ -10,7 +10,7 @@ * except in compliance with the License. Please obtain a copy of the * License at http://www.apple.com/publicsource 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, @@ -18,7 +18,7 @@ * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the * License for the specific language governing rights and limitations * under the License. - * + * * @APPLE_LICENSE_HEADER_END@ */ @@ -40,13 +40,13 @@ struct string_ref { - char* string; + char *string; int id; - struct string_ref* next; + struct string_ref *next; }; typedef struct string_ref string_ref; -extern string_ref* ref_strings; +extern string_ref *ref_strings; #define kXMLTagPList "plist " #define kXMLTagDict "dict" @@ -63,27 +63,17 @@ #define kXMLStringID "ID=" #define kXMLStringIDRef "IDREF=" -#define kPropCFBundleIdentifier ("CFBundleIdentifier") -#define kPropCFBundleExecutable ("CFBundleExecutable") -#define kPropOSBundleRequired ("OSBundleRequired") -#define kPropOSBundleLibraries ("OSBundleLibraries") -#define kPropIOKitPersonalities ("IOKitPersonalities") -#define kPropIONameMatch ("IONameMatch") +#define kPropCFBundleIdentifier ("CFBundleIdentifier") +#define kPropCFBundleExecutable ("CFBundleExecutable") +#define kPropOSBundleRequired ("OSBundleRequired") +#define kPropOSBundleLibraries ("OSBundleLibraries") +#define kPropIOKitPersonalities ("IOKitPersonalities") +#define kPropIONameMatch ("IONameMatch") -/* -struct Tag { - long type; - char *string; - struct Tag *tag; - struct Tag *tagNext; -}; -typedef struct Tag Tag, *TagPtr; - */ - extern long gImageFirstBootXAddr; extern long gImageLastKernelAddr; -TagPtr XMLGetProperty( TagPtr dict, const char * key ); +TagPtr XMLGetProperty( TagPtr dict, const char *key ); TagPtr XMLGetElement( TagPtr dict, int id ); TagPtr XMLGetKey( TagPtr dict, int id ); TagPtr XMLGetValueForKey(TagPtr key); @@ -98,7 +88,7 @@ int XMLCastInteger ( TagPtr dict ); TagPtr XMLCastDict ( TagPtr dict ); TagPtr XMLCastArray( TagPtr dict ); -char* XMLCastData( TagPtr dict, int* length ); +char* XMLCastData( TagPtr dict, int *length ); bool XMLIsBoolean(TagPtr entry); bool XMLIsString (TagPtr entry); @@ -108,7 +98,7 @@ bool XMLIsData (TagPtr entry); -bool XMLAddTagToDictionary(TagPtr dict, char* key, TagPtr value); +bool XMLAddTagToDictionary(TagPtr dict, char *key, TagPtr value); long XMLParseNextTag(char *buffer, TagPtr *tag); void XMLFreeTag(TagPtr tag); @@ -119,11 +109,11 @@ // Puts the first dictionary it finds in the // tag pointer and returns 0, or returns -1 if not found. // -long XMLParseFile( char * buffer, TagPtr * dict ); +long XMLParseFile( char *buffer, TagPtr *dict ); //========================================================================== // ParseTag* -long ParseTagBoolean( char * buffer, TagPtr * tag, long type ); +long ParseTagBoolean( char *buffer, TagPtr *tag, long type ); #endif /* __LIBSAIO_XML_H */ Index: branches/zenith432/i386/libsaio/efi.h =================================================================== --- branches/zenith432/i386/libsaio/efi.h (revision 2593) +++ branches/zenith432/i386/libsaio/efi.h (revision 2594) @@ -254,7 +254,7 @@ IN EFI_UINTN DescriptorSize, IN EFI_UINT32 DescriptorVersion, IN EFI_MEMORY_DESCRIPTOR * VirtualMap - ); + ) __attribute__((regparm(0))); typedef EFI_RUNTIMESERVICE @@ -262,7 +262,7 @@ (EFIAPI *EFI_CONVERT_POINTER) ( IN EFI_UINTN DebugDisposition, IN OUT VOID **Address - ); + ) __attribute__((regparm(0))); // Variable attributes @@ -281,7 +281,7 @@ OUT EFI_UINT32 * Attributes OPTIONAL, IN OUT EFI_UINTN * DataSize, OUT VOID * Data - ); + ) __attribute__((regparm(0))); typedef EFI_RUNTIMESERVICE @@ -290,7 +290,7 @@ IN OUT EFI_UINTN * VariableNameSize, IN OUT EFI_CHAR16 * VariableName, IN OUT EFI_GUID * VendorGuid - ); + ) __attribute__((regparm(0))); typedef EFI_RUNTIMESERVICE @@ -301,7 +301,7 @@ IN EFI_UINT32 Attributes, IN EFI_UINTN DataSize, IN VOID * Data - ); + ) __attribute__((regparm(0))); // EFI Time @@ -318,14 +318,14 @@ (EFIAPI *EFI_GET_TIME) ( OUT EFI_TIME * Time, OUT EFI_TIME_CAPABILITIES * Capabilities OPTIONAL - ); + ) __attribute__((regparm(0))); typedef EFI_RUNTIMESERVICE EFI_STATUS (EFIAPI *EFI_SET_TIME) ( IN EFI_TIME * Time - ); + ) __attribute__((regparm(0))); typedef EFI_RUNTIMESERVICE @@ -334,7 +334,7 @@ OUT EFI_BOOLEAN * Enabled, OUT EFI_BOOLEAN * Pending, OUT EFI_TIME * Time - ); + ) __attribute__((regparm(0))); typedef EFI_RUNTIMESERVICE @@ -342,7 +342,7 @@ (EFIAPI *EFI_SET_WAKEUP_TIME) ( IN EFI_BOOLEAN Enable, IN EFI_TIME * Time OPTIONAL - ); + ) __attribute((regparm(0))); typedef enum { EfiResetCold, @@ -363,7 +363,7 @@ IN EFI_STATUS ResetStatus, IN EFI_UINTN DataSize, IN EFI_CHAR16 * ResetData OPTIONAL - ); + ) __attribute__((regparm(0))); typedef EFI_RUNTIMESERVICE @@ -391,7 +391,7 @@ IN EFI_UINT32 Instance, IN EFI_GUID * CallerId OPTIONAL, IN EFI_STATUS_CODE_DATA * Data OPTIONAL - ); + ) __attribute__((regparm(0))); #endif // Index: branches/zenith432/i386/libsaio/ntfs_private.h =================================================================== --- branches/zenith432/i386/libsaio/ntfs_private.h (revision 2593) +++ branches/zenith432/i386/libsaio/ntfs_private.h (revision 2594) @@ -147,7 +147,7 @@ u_int64_t t_write; u_int64_t t_mftwrite; u_int64_t t_access; -} ntfs_times_t; +} ntfs_times_t; #define NTFS_FFLAG_RDONLY 0x01LL #define NTFS_FFLAG_HIDDEN 0x02LL Index: branches/zenith432/i386/libsaio/vbe.c =================================================================== --- branches/zenith432/i386/libsaio/vbe.c (revision 2593) +++ branches/zenith432/i386/libsaio/vbe.c (revision 2594) @@ -129,7 +129,7 @@ #define kC 30.0 // C = (C'-J) * (K/256) + J #define kM 300.0 // M = K/256 * M' -int Round(double f) +static int Round(double f) { return (int)(f + 0.5); } Index: branches/zenith432/i386/libsaio/device_tree.c =================================================================== --- branches/zenith432/i386/libsaio/device_tree.c (revision 2593) +++ branches/zenith432/i386/libsaio/device_tree.c (revision 2594) @@ -82,8 +82,7 @@ //============================================================================== -Property * -DT__AddProperty(Node *node, const char *name, uint32_t length, void *value) +Property *DT__AddProperty(Node *node, const char *name, uint32_t length, void *value) { Property *prop; @@ -143,8 +142,7 @@ //============================================================================== -Node * -DT__AddChild(Node *parent, const char *name) +Node *DT__AddChild(Node *parent, const char *name) { Node *node; @@ -206,8 +204,7 @@ //============================================================================== -void -DT__FreeProperty(Property *prop) +void DT__FreeProperty(Property *prop) { prop->next = freeProperties; freeProperties = prop; @@ -215,8 +212,7 @@ //============================================================================== -void -DT__FreeNode(Node *node) +void DT__FreeNode(Node *node) { node->next = freeNodes; freeNodes = node; @@ -224,8 +220,7 @@ //============================================================================== -void -DT__Initialize(void) +void DT__Initialize(void) { DPRINTF("DT__Initialize\n"); @@ -246,8 +241,7 @@ /* * Free up memory used by in-memory representation of device tree. */ -void -DT__Finalize(void) +void DT__Finalize(void) { Node *node; Property *prop; @@ -280,8 +274,7 @@ //============================================================================== -static void * -FlattenNodes(Node *node, void *buffer) +static void *FlattenNodes(Node *node, void *buffer) { Property *prop; DeviceTreeNode *flatNode; @@ -325,8 +318,7 @@ * To use your own buffer, call with *result = &buffer. */ -void -DT__FlattenDeviceTree(void **buffer_p, uint32_t *length) +void DT__FlattenDeviceTree(void **buffer_p, uint32_t *length) { uint32_t totalSize; void * buf; @@ -378,8 +370,7 @@ //============================================================================== -char * -DT__GetName(Node *node) +char *DT__GetName(Node *node) { Property *prop; @@ -400,8 +391,7 @@ //============================================================================== // Bungo -Property * -DT__GetProperty(Node *node, const char *name) +Property *DT__GetProperty(Node *node, const char *name) { Property *prop; @@ -418,8 +408,7 @@ //============================================================================== -Node * -DT__FindNode(const char *path, bool createIfMissing) +Node *DT__FindNode(const char *path, bool createIfMissing) { Node *node, *child; DTPropertyNameBuf nameBuf; @@ -486,8 +475,7 @@ //============================================================================== -void -DT__PrintNode(Node *node, int level) +void DT__PrintNode(Node *node, int level) { char spaces[10], *cp = spaces; Property *prop; @@ -524,8 +512,7 @@ //============================================================================== -static void -_PrintTree(Node *node, int level) +static void _PrintTree(Node *node, int level) { DT__PrintNode(node, level); @@ -539,8 +526,7 @@ //============================================================================== -void -DT__PrintTree(Node *node) +void DT__PrintTree(Node *node) { if (node == 0) node = rootNode; _PrintTree(node, 0); @@ -548,8 +534,7 @@ //============================================================================== -void -DT__PrintFlattenedNode(DTEntry entry, int level) +void DT__PrintFlattenedNode(DTEntry entry, int level) { char spaces[10], *cp = spaces; DTPropertyIterator propIter; @@ -580,8 +565,7 @@ //============================================================================== -static void -_PrintFlattenedTree(DTEntry entry, int level) +static void _PrintFlattenedTree(DTEntry entry, int level) { DTEntryIterator entryIter; @@ -602,16 +586,14 @@ //============================================================================== -void -DT__PrintFlattenedTree(DTEntry entry) +void DT__PrintFlattenedTree(DTEntry entry) { _PrintFlattenedTree(entry, 0); } //============================================================================== -int -main(int argc, char **argv) +int main(int argc, char **argv) { DTEntry dtEntry; DTPropertyIterator propIter; Index: branches/zenith432/i386/libsaio/hfs.c =================================================================== --- branches/zenith432/i386/libsaio/hfs.c (revision 2593) +++ branches/zenith432/i386/libsaio/hfs.c (revision 2594) @@ -295,7 +295,7 @@ char entry[512]; char devStr[12]; u_int32_t dirID; - long result, flags; + long result, flags = 0; if (HFSInitPartition(ih) == -1) { @@ -647,6 +647,8 @@ *flags = kFileTypeUnknown; tmpTime = 0; break; + default: + break; } if (time != 0) @@ -920,6 +922,12 @@ curNode = SWAP_BE32(gBTHeaders[btree]->rootNode); nodeSize = SWAP_BE16(gBTHeaders[btree]->nodeSize); nodeBuf = (char *)malloc(nodeSize); + + if (!nodeBuf) + { + return -1; + } + node = (BTNodeDescriptor *)nodeBuf; while (1) @@ -992,7 +1000,7 @@ } // Return error if the file was not found. - if (result != 0) + if (result != 0 || !recordData) { free(nodeBuf); return -1; @@ -1018,6 +1026,8 @@ break; case kHFSPlusFileThreadRecord : entrySize = 264; break; + default: + break; } } else Index: branches/zenith432/i386/libsaio/spd.c =================================================================== --- branches/zenith432/i386/libsaio/spd.c (revision 2593) +++ branches/zenith432/i386/libsaio/spd.c (revision 2594) @@ -126,7 +126,7 @@ #define READ_SPD(spd, base, slot, x) spd[x] = smb_read_byte_intel(base, 0x50 + slot, x) /** Read from spd *used* values only*/ -static void init_spd(char * spd, uint32_t base, int slot) +static void init_spd(char *spd, uint32_t base, int slot) { int i; for (i = 0; i < SPD_INDEXES_SIZE; i++) @@ -232,7 +232,7 @@ #define SLST(a) ((uint8_t)(spd[a] & 0x0f)) /* Get DDR3 or DDR2 serial number, 0 most of the times, always return a valid ptr */ -const char *getDDRSerial(const char* spd) +const char *getDDRSerial(const char *spd) { static char asciiSerial[17]; @@ -296,7 +296,7 @@ int i, speed; uint8_t spd_size, spd_type; uint32_t base, mmio, hostc; - uint16_t cmd; // Command + uint16_t cmd; // bool dump = false; RamSlotInfo_t *slot; Index: branches/zenith432/i386/libsaio/gma.c =================================================================== --- branches/zenith432/i386/libsaio/gma.c (revision 2593) +++ branches/zenith432/i386/libsaio/gma.c (revision 2594) @@ -630,11 +630,11 @@ case GMA_HASWELL_ULT_M_GT2: // 0a16 case GMA_HASWELL_ULT_E_GT2: // 0a1e verbose("Injecting a valid desktop GPU device id (0x0412) instead of patching kexts.\n"); - device_id = 0x0412; // Inject a valid desktop GPU device id (0x0412) instead of patching kexts + device_id = 0x00000412; // Inject a valid desktop GPU device id (0x0412) instead of patching kexts devprop_add_value(device, "vendor-id", (uint8_t *)INTEL_VENDORID, 4); devprop_add_value(device, "device-id", (uint8_t *)&device_id, sizeof(device_id)); devprop_add_value(device, "compatible", (uint8_t *)"pci8086,0412", 13); // GT2 Desktop - devprop_add_value(device, "IOName", (uint8_t *)"pci8086,0412", 13); // GT2 Desktop +// devprop_add_value(device, "IOName", (uint8_t *)"pci8086,0412", 13); // GT2 Desktop devprop_add_value(device, "name", (uint8_t *)"pci8086,0412", 13); // GT2 Desktop verbose("Injeting done: was [%04x:%04x] now is [%04x:%04x]\n", gma_dev->vendor_id, gma_dev->device_id, gma_dev->vendor_id, device_id); Index: branches/zenith432/i386/libsaio/pci_root.c =================================================================== --- branches/zenith432/i386/libsaio/pci_root.c (revision 2593) +++ branches/zenith432/i386/libsaio/pci_root.c (revision 2594) @@ -49,7 +49,7 @@ void *new_dsdt; const char *val; - int len,fsize; + int len, fsize; const char * dsdt_filename = NULL; extern int search_and_get_acpi_fd(const char *, const char **); Index: branches/zenith432/i386/libsaio/device_inject.h =================================================================== --- branches/zenith432/i386/libsaio/device_inject.h (revision 2593) +++ branches/zenith432/i386/libsaio/device_inject.h (revision 2594) @@ -52,7 +52,7 @@ // ------------------------ uint8_t num_pci_devpaths; struct DevPropString *string; - // ------------------------ + // ------------------------ }; typedef struct DevPropDevice DevPropDevice; Index: branches/zenith432/i386/libsaio/nvidia.c =================================================================== --- branches/zenith432/i386/libsaio/nvidia.c (revision 2593) +++ branches/zenith432/i386/libsaio/nvidia.c (revision 2594) @@ -1963,7 +1963,6 @@ unsigned long long mem_detect(volatile uint8_t *regs, uint8_t nvCardType, pci_dt_t *nvda_dev, uint32_t device_id, uint32_t subsys_id) { uint64_t vram_size = 0; - // unsigned long long vram_size = 0; // First check if any value exist in the plist cardList_t * nvcard = FindCardWithIds(device_id, subsys_id); @@ -2323,11 +2322,11 @@ devprop_add_nvidia_template(device); devprop_add_value(device, "NVCAP", default_NVCAP, NVCAP_LEN); devprop_add_value(device, "NVPM", default_NVPM, NVPM_LEN); - devprop_add_value(device, "VRAM,totalsize", (uint8_t*)&videoRam, 4); - devprop_add_value(device, "model", (uint8_t*)model, strlen(model) + 1); - devprop_add_value(device, "rom-revision", (uint8_t*)biosVersion, strlen(biosVersion) + 1); - devprop_add_value(device, "@0,display-cfg", default_dcfg_0, DCFG0_LEN); - devprop_add_value(device, "@1,display-cfg", default_dcfg_1, DCFG1_LEN); + devprop_add_value(device, "VRAM,totalsize", (uint8_t *)&videoRam, 4); + devprop_add_value(device, "model", (uint8_t *)model, strlen(model) + 1); + devprop_add_value(device, "rom-revision", (uint8_t *)biosVersion, strlen(biosVersion) + 1); + devprop_add_value(device, "@0,display-cfg", (uint8_t *)&default_dcfg_0, DCFG0_LEN); + devprop_add_value(device, "@1,display-cfg", (uint8_t *)&default_dcfg_1, DCFG1_LEN); /******************** Added Marchrius.**********************/ // For the AppleBacklightDisplay // Index: branches/zenith432/i386/libsaio/ati.c =================================================================== --- branches/zenith432/i386/libsaio/ati.c (revision 2593) +++ branches/zenith432/i386/libsaio/ati.c (revision 2594) @@ -137,7 +137,12 @@ {"Hamachi", 4}, {"OPM", 6}, {"Ikura", 6}, - {"IkuraS", 1} + {"IkuraS", 1}, + /* AMD8000Controller */ + {"Baladi", 5}, //desktop + {"Exmoor", 4}, //mobile + {"Basset", 4} + }; static radeon_card_info_t radeon_cards[] = { @@ -1500,7 +1505,8 @@ // { 0x99A2, 0x00000000, CHIP_FAMILY_ARUBA, "AMD Radeon HD", kNull }, // Mobile // { 0x99A4, 0x00000000, CHIP_FAMILY_ARUBA, "AMD Radeon HD", kNull }, - { 0x6613, 0x00000000, CHIP_FAMILY_BONAIRE, "AMD Radeon R7 240", kFutomaki }, + { 0x6610, 0x00000000, CHIP_FAMILY_OLAND, "AMD Radeon R7 250", kFutomaki }, + { 0x6613, 0x00000000, CHIP_FAMILY_OLAND, "AMD Radeon R7 240", kFutomaki }, { 0x665C, 0x00000000, CHIP_FAMILY_BONAIRE, "AMD Radeon HD 7790", kFutomaki }, { 0x665D, 0x00000000, CHIP_FAMILY_BONAIRE, "AMD Radeon R9 260", kFutomaki }, @@ -1641,8 +1647,8 @@ // { 0x67A8, 0x00000000, CHIP_FAMILY_HAWAII, "AMD Radeon", kFutomaki }, // { 0x67A9, 0x00000000, CHIP_FAMILY_HAWAII, "AMD Radeon", kFutomaki }, // { 0x67AA, 0x00000000, CHIP_FAMILY_HAWAII, "AMD Radeon", kFutomaki }, - { 0x67B0, 0x00000000, CHIP_FAMILY_HAWAII, "AMD Radeon R9 290X", kFutomaki }, - { 0x67B1, 0x00000000, CHIP_FAMILY_HAWAII, "AMD Radeon R9 290", kFutomaki }, // CHIP_FAMILY_HAWAII + { 0x67B0, 0x00000000, CHIP_FAMILY_HAWAII, "AMD Radeon R9 290X", kBaladi }, + { 0x67B1, 0x00000000, CHIP_FAMILY_HAWAII, "AMD Radeon R9 290", kBaladi }, // CHIP_FAMILY_HAWAII // { 0x67B8, 0x00000000, CHIP_FAMILY_HAWAII, "AMD Radeon", kFutomaki }, // { 0x67B9, 0x00000000, CHIP_FAMILY_HAWAII, "AMD Radeon", kFutomaki }, // { 0x67BA, 0x00000000, CHIP_FAMILY_HAWAII, "AMD Radeon", kFutomaki }, @@ -1770,7 +1776,7 @@ val->type = kCst; val->size = 4; val->data = (uint8_t *)&v; - + return true; } @@ -1850,7 +1856,7 @@ val->type = kPtr; val->size = card->rom_size; val->data = card->rom; - + return true; } @@ -2284,11 +2290,12 @@ } #endif +static char name[24]; +static char name_parent[24]; + static bool init_card(pci_dt_t *pci_dev) { bool add_vbios = true; - char name[24]; - char name_parent[24]; int i; int n_ports = 0; @@ -2347,7 +2354,7 @@ { read_disabled_vbios(); } - verbose("\n"); + verbose("Video BIOS read from file\n"); } } Index: branches/zenith432/i386/libsaio/load.c =================================================================== --- branches/zenith432/i386/libsaio/load.c (revision 2593) +++ branches/zenith432/i386/libsaio/load.c (revision 2594) @@ -57,17 +57,20 @@ struct fat_arch *fap = (struct fat_arch *)((unsigned long)*binary + sizeof(struct fat_header)); cpu_type_t fapcputype; uint32_t fapoffset; - uint32_t fapsize; + uint32_t fapsize; if (fhp->magic == FAT_MAGIC)/* 0xcafebabe */ { nfat = fhp->nfat_arch; swapped = 0; - } else if (fhp->magic == FAT_CIGAM)/* 0xbebafeca */ + } + else if (fhp->magic == FAT_CIGAM)/* 0xbebafeca */ { nfat = OSSwapInt32(fhp->nfat_arch); swapped = 1; - } else { + } + else + { return -1; } @@ -78,7 +81,9 @@ fapcputype = OSSwapInt32(fap->cputype); fapoffset = OSSwapInt32(fap->offset); fapsize = OSSwapInt32(fap->size); - } else { + } + else + { fapcputype = fap->cputype; fapoffset = fap->offset; fapsize = fap->size; @@ -258,12 +263,14 @@ segname = segCmd->segname; #ifdef DEBUG - printf("segname: %s, vmaddr: %x, vmsize: %x, fileoff: %x, filesize: %x, nsects: %d, flags: %x.\n", - segCmd->segname, (unsigned)vmaddr, (unsigned)vmsize, (unsigned)fileaddr, (unsigned)filesize, - (unsigned) segCmd->nsects, (unsigned)segCmd->flags); - getchar(); + printf("segname: %s, vmaddr: %x, vmsize: %x, fileoff: %x, filesize: %x, nsects: %d, flags: %x.\n", + segCmd->segname, (unsigned)vmaddr, (unsigned)vmsize, (unsigned)fileaddr, (unsigned)filesize, + (unsigned) segCmd->nsects, (unsigned)segCmd->flags); + getchar(); #endif - } else { + } + else + { struct segment_command *segCmd; segCmd = (struct segment_command *)cmdBase; @@ -276,7 +283,7 @@ #ifdef DEBUG printf("segname: %s, vmaddr: %x, vmsize: %x, fileoff: %x, filesize: %x, nsects: %d, flags: %x.\n", - segCmd->segname, (unsigned)vmaddr, (unsigned)vmsize, (unsigned)fileaddr, (unsigned)filesize, (unsigned) segCmd->nsects, (unsigned)segCmd->flags); + segCmd->segname, (unsigned)vmaddr, (unsigned)vmsize, (unsigned)fileaddr, (unsigned)filesize, (unsigned) segCmd->nsects, (unsigned)segCmd->flags); getchar(); #endif } @@ -289,21 +296,25 @@ } if (! ((vmaddr >= KERNEL_ADDR && (vmaddr + vmsize) <= (KERNEL_ADDR + KERNEL_LEN)) || - (vmaddr >= HIB_ADDR && (vmaddr + vmsize) <= (HIB_ADDR + HIB_LEN)))) { + (vmaddr >= HIB_ADDR && (vmaddr + vmsize) <= (HIB_ADDR + HIB_LEN)))) + { stop("Kernel overflows available space"); } - if (vmsize && ((strcmp(segname, "__PRELINK_INFO") == 0) || (strcmp(segname, "__PRELINK") == 0))) { + if (vmsize && ((strcmp(segname, "__PRELINK_INFO") == 0) || (strcmp(segname, "__PRELINK") == 0))) + { gHaveKernelCache = true; } // Copy from file load area. - if (vmsize>0 && filesize > 0) { + if (vmsize>0 && filesize > 0) + { bcopy((char *)fileaddr, (char *)vmaddr, vmsize > filesize ? filesize : vmsize); } // Zero space at the end of the segment. - if (vmsize > filesize) { + if (vmsize > filesize) + { bzero((char *)(vmaddr + filesize), vmsize - filesize); } @@ -317,7 +328,8 @@ static long DecodeUnixThread(long cmdBase, unsigned int *entry) { - switch (archCpuType) { + switch (archCpuType) + { case CPU_TYPE_I386: { i386_thread_state_t *i386ThreadState; @@ -355,8 +367,8 @@ symTab = (struct symtab_command *)cmdBase; #if DEBUG - - printf("symoff: %x, nsyms: %x, stroff: %x, strsize: %x\n", symTab->symoff, symTab->nsyms, symTab->stroff, symTab->strsize); + printf("symoff: %x, nsyms: %x, stroff: %x, strsize: %x\n", + symTab->symoff, symTab->nsyms, symTab->stroff, symTab->strsize); getchar(); #endif Index: branches/zenith432/i386/libsaio/ati.h =================================================================== --- branches/zenith432/i386/libsaio/ati.h (revision 2593) +++ branches/zenith432/i386/libsaio/ati.h (revision 2594) @@ -179,6 +179,10 @@ kOPM, kIkura, kIkuraS, + /* AMD8000Controller */ + kBaladi, + kExmoor, + kBasset, kCfgEnd } ati_config_name_t; Index: branches/zenith432/i386/libsaio/cpu.c =================================================================== --- branches/zenith432/i386/libsaio/cpu.c (revision 2593) +++ branches/zenith432/i386/libsaio/cpu.c (revision 2594) @@ -312,11 +312,11 @@ cores_per_package = 1; } - if (p->CPU.CPUID[CPUID_0][0] >= 0x5) // Monitor/Mwait + if (p->CPU.CPUID[CPUID_0][0] >= 0x5) // Monitor/Mwait { do_cpuid(5, p->CPU.CPUID[CPUID_5]); } - if (p->CPU.CPUID[CPUID_0][0] >= 6) // Thermal/Power + if (p->CPU.CPUID[CPUID_0][0] >= 6) // Thermal/Power { do_cpuid(6, p->CPU.CPUID[CPUID_6]); } Index: branches/zenith432/i386/libsaio/platform.h =================================================================== --- branches/zenith432/i386/libsaio/platform.h (revision 2593) +++ branches/zenith432/i386/libsaio/platform.h (revision 2594) @@ -35,7 +35,7 @@ #define CPUID_MODEL_DOTHAN 0x0D // Dothan Pentium M, Celeron M (90nm) #define CPUID_MODEL_YONAH 0x0E // Sossaman, Yonah #define CPUID_MODEL_MEROM 0x0F // Allendale, Conroe, Kentsfield, Woodcrest, Clovertown, Tigerton, Merom -#define CPUID_MODEL_CONROE 0x0F // +#define CPUID_MODEL_CONROE 0x0F // #define CPUID_MODEL_CELERON 0x16 // Merom, Conroe (65nm), Celeron (45nm) #define CPUID_MODEL_PENRYN 0x17 // Wolfdale, Yorkfield, Harpertown, Penryn #define CPUID_MODEL_WOLFDALE 0x17 // Xeon 31xx, 33xx, 52xx, 54xx, Core 2 Quad 8xxx and 9xxx @@ -337,6 +337,7 @@ /* Maximum number of ram slots */ #define MAX_RAM_SLOTS 8 + #define RAM_SLOT_ENUMERATOR {0, 2, 4, 1, 3, 5, 6, 8, 10, 7, 9, 11} /* Maximum number of SPD bytes */ Index: branches/zenith432/i386/libsaio/disk.c =================================================================== --- branches/zenith432/i386/libsaio/disk.c (revision 2593) +++ branches/zenith432/i386/libsaio/disk.c (revision 2594) @@ -844,7 +844,7 @@ // same as Apple ZFS //EFI_GUID const GPT_ZFS_GUID = { 0x6A898CC3, 0x1DD2, 0x11B2, { 0x99, 0xA6, 0x08, 0x00, 0x20, 0x73, 0x66, 0x31 } }; // 0xBF01 "Solaris /usr & Apple ZFS -BVRef newGPTBVRef( int biosdev, +static BVRef newGPTBVRef( int biosdev, int partno, unsigned int blkoff, const gpt_ent *part, @@ -975,7 +975,13 @@ { // Create a new mapping. - map = (struct DiskBVMap *)malloc(sizeof(*map)); + map = (struct DiskBVMap *) malloc(sizeof(*map)); + + if ( !map ) + { + return NULL; + } + if ( map ) { map->biosdev = biosdev; @@ -1430,7 +1436,7 @@ // Determine whether the partition header signature is present. - if (memcmp(headerMap->hdr_sig, GPT_HDR_SIG, strlen(GPT_HDR_SIG))) + if ( memcmp(headerMap->hdr_sig, GPT_HDR_SIG, strlen(GPT_HDR_SIG)) ) { goto scanErr; } @@ -1493,6 +1499,8 @@ goto scanErr; } + bzero(buffer,bufferSize); + if (readBytes(biosdev, gptBlock, 0, bufferSize, buffer) != 0) { goto scanErr; @@ -2218,7 +2226,7 @@ * hd(x,y)|uuid|"label" "alias";hd(m,n)|uuid|"label" "alias"; etc... */ -bool getVolumeLabelAlias(BVRef bvr, char* str, long strMaxLen) +static bool getVolumeLabelAlias(BVRef bvr, char* str, long strMaxLen) { char *aliasList, *entryStart, *entryNext; Index: branches/zenith432/i386/libsaio/pci_setup.c =================================================================== --- branches/zenith432/i386/libsaio/pci_setup.c (revision 2593) +++ branches/zenith432/i386/libsaio/pci_setup.c (revision 2594) @@ -2,11 +2,18 @@ #include "boot.h" #include "bootstruct.h" #include "pci.h" -#include "gma.h" -#include "nvidia.h" -#include "hda.h" #include "modules.h" +#ifndef DEBUG_PCI_SETUP +#define DEBUG_PCI_SETUP 0 +#endif + +#if DEBUG_PCI_SETUP +#define DBG(x...) printf(x) +#else +#define DBG(x...) +#endif + extern bool setup_ati_devprop(pci_dt_t *ati_dev); extern bool setup_nvidia_devprop(pci_dt_t *nvda_dev); extern bool setup_gma_devprop(pci_dt_t *gma_dev); @@ -37,13 +44,15 @@ switch (current->class_id) { case PCI_CLASS_BRIDGE_HOST: + DBG("Setup BRIDGE_HOST \n"); if (current->dev.addr == PCIADDR(0, 0, 0)) { dram_controller_dev = current; } break; // PCI_CLASS_BRIDGE_HOST - + case PCI_CLASS_NETWORK_ETHERNET: + DBG("Setup ETHERNET %s enabled\n", do_eth_devprop? "is":"is not"); if (do_eth_devprop) { set_eth_builtin(current); @@ -51,6 +60,7 @@ break; // PCI_CLASS_NETWORK_ETHERNET case PCI_CLASS_DISPLAY_VGA: + DBG("GraphicsEnabler %s enabled\n", do_gfx_devprop? "is":"is not"); if (do_gfx_devprop) { switch (current->vendor_id) @@ -95,6 +105,7 @@ break; // PCI_CLASS_DISPLAY_VGA case PCI_CLASS_MULTIMEDIA_AUDIO_DEV: + DBG("Setup HDEF %s enabled\n", do_hda_devprop? "is":"is not"); if (do_hda_devprop) { setup_hda_devprop(current); @@ -102,10 +113,12 @@ break; // PCI_CLASS_MULTIMEDIA_AUDIO_DEV case PCI_CLASS_SERIAL_USB: + DBG("USB\n"); notify_usb_dev(current); break; // PCI_CLASS_SERIAL_USB case PCI_CLASS_BRIDGE_ISA: + DBG("Force HPET %s enabled\n", do_enable_hpet? "is":"is not"); if (do_enable_hpet) { force_enable_hpet(current); @@ -115,7 +128,7 @@ } execute_hook("PCIDevice", current, NULL, NULL, NULL); - + DBG("setup_pci_devs current device ID = [%04x:%04x]\n", current->vendor_id, current->device_id); setup_pci_devs(current->children); current = current->next; } Index: branches/zenith432/i386/libsaio/smbios.h =================================================================== --- branches/zenith432/i386/libsaio/smbios.h (revision 2593) +++ branches/zenith432/i386/libsaio/smbios.h (revision 2594) @@ -833,7 +833,7 @@ typedef struct SMBOemProcessorBusSpeed { SMB_STRUCT_HEADER // Type 132 - SMBWord ProcessorBusSpeed; // MT/s unit + SMBWord ProcessorBusSpeed; // MT/s unit } __attribute__((packed)) SMBOemProcessorBusSpeed; //---------------------------------------------------------------------------------------------------------- Index: branches/zenith432/i386/libsaio/nvidia_helper.c =================================================================== --- branches/zenith432/i386/libsaio/nvidia_helper.c (revision 2593) +++ branches/zenith432/i386/libsaio/nvidia_helper.c (revision 2594) @@ -52,28 +52,28 @@ */ -cardList_t* cardList = NULL; +cardList_t *cardList = NULL; -void add_card(char* model, uint32_t id, uint32_t subid, uint64_t videoRam) +void add_card(char *model, uint32_t id, uint32_t subid, uint64_t videoRam) { - cardList_t* new_card = malloc(sizeof(cardList_t)); + cardList_t *new_card = malloc(sizeof(cardList_t)); if (new_card) { new_card->next = cardList; cardList = new_card; - new_card->id = id; - new_card->subid = subid; - new_card->videoRam = videoRam; - new_card->model = model; + new_card->id = id; + new_card->subid = subid; + new_card->videoRam = videoRam; + new_card->model = model; } } -cardList_t* FindCardWithIds(uint32_t id, uint32_t subid) +cardList_t *FindCardWithIds(uint32_t id, uint32_t subid) { - cardList_t* entry = cardList; + cardList_t *entry = cardList; while(entry) { if((entry->id == id) && (entry->subid == subid)) @@ -108,12 +108,16 @@ void fill_card_list(void) { unsigned int i, count; - TagPtr NVDIATag; - char *model_name = NULL, *match_id = NULL, *sub_id = NULL, *vram_size = NULL; - uint32_t dev_id = 0, subdev_id = 0; - uint64_t VramSize = 0; + TagPtr NVDIATag; + char *model_name = NULL; + char *match_id = NULL; + char *sub_id = NULL; + char *vram_size = NULL; + uint32_t dev_id = 0; + uint32_t subdev_id = 0; + uint64_t VramSize = 0; - if ((NVDIATag = XMLCastArray(XMLGetProperty(bootInfo->chameleonConfig.dictionary, (const char*)"NVIDIA")))) + if ((NVDIATag = XMLCastArray(XMLGetProperty(bootInfo->chameleonConfig.dictionary, (const char *)"NVIDIA")))) { count = XMLTagCount(NVDIATag); @@ -127,15 +131,18 @@ model_name = XMLCastString(XMLGetProperty(element, (const char*)"Chipset Name")); vram_size = XMLCastString(XMLGetProperty(element, (const char*)"VRam Size")); - if (match_id) { + if (match_id) + { dev_id = strtoul(match_id, NULL, 16); } - if (sub_id) { + if (sub_id) + { subdev_id = strtoul(sub_id, NULL, 16); } - if (vram_size) { + if (vram_size) + { VramSize = strtoul(vram_size, NULL, 10); } Index: branches/zenith432/i386/libsaio/pci.c =================================================================== --- branches/zenith432/i386/libsaio/pci.c (revision 2593) +++ branches/zenith432/i386/libsaio/pci.c (revision 2594) @@ -14,9 +14,9 @@ #endif #if DEBUG_PCI -#define DBG(x...) printf(x) +#define DBG(x...) printf(x) #else -#define DBG(x...) +#define DBG(x...) msglog(x) #endif pci_dt_t *root_pci_dev; @@ -213,7 +213,7 @@ while (current) { printf("%02x:%02x.%x [%04x%02x] [%04x:%04x] (subsys [%04x:%04x]):: %s\n", current->dev.bits.bus, current->dev.bits.dev, current->dev.bits.func, - current->class_id, 0 /* FIXME: what should this be? */, + current->class_id, current->progif, current->vendor_id, current->device_id, current->subsys_id.subsys.vendor_id, current->subsys_id.subsys.device_id, get_pci_dev_path(current)); Index: branches/zenith432/i386/libsaio/biosfn.c =================================================================== --- branches/zenith432/i386/libsaio/biosfn.c (revision 2593) +++ branches/zenith432/i386/libsaio/biosfn.c (revision 2594) @@ -127,6 +127,8 @@ } #if 0 + +static unsigned long rerangeMemoryMap(unsigned long count); static unsigned long rerangeMemoryMap(unsigned long count) { int i, still_changing, newcount = count; @@ -590,7 +592,7 @@ /* * BIOS drive information. */ -void print_drive_info(boot_drive_info_t *dp) +static void print_drive_info(boot_drive_info_t *dp) { // printf("buf_size = %x\n", dp->params.buf_size); printf("info_flags = %x\n", dp->params.info_flags); @@ -821,7 +823,7 @@ #if DEBUG -int terminateDiskEmulation() +static int terminateDiskEmulation() { static char cd_spec[0x13]; @@ -834,7 +836,7 @@ return bb.eax.r.h; } -int readDriveParameters(int drive, struct driveParameters *dp) +static int readDriveParameters(int drive, struct driveParameters *dp) { bb.intno = 0x13; bb.edx.r.l = drive; @@ -1017,14 +1019,14 @@ void sleep(int n) { // FIXME: doesn't handle midnight wraparound - unsigned int endtime = (time18() + 18*n); + unsigned int endtime = (time18() + 18*n); #ifdef __i386__ while (time18() < endtime) { __asm__ volatile ("rep; nop"); } #else - while (time18() < endtime); + while (time18() < endtime); #endif } Index: branches/zenith432/i386/libsaio/convert.c =================================================================== --- branches/zenith432/i386/libsaio/convert.c (revision 2593) +++ branches/zenith432/i386/libsaio/convert.c (revision 2594) @@ -8,7 +8,7 @@ #include "convert.h" /** Transform a 16 bytes hexadecimal value UUID to a string */ -const char * getStringFromUUID(const EFI_CHAR8* eUUID) +const char *getStringFromUUID(const EFI_CHAR8 *eUUID) { static char msg[UUID_LEN*2 + 8] = ""; if (!eUUID) return ""; @@ -21,8 +21,8 @@ return msg ; } -/** Parse an UUID string into an (EFI_CHAR8*) buffer */ -EFI_CHAR8* getUUIDFromString(const char *source) +/** Parse an UUID string into an (EFI_CHAR8 *) buffer */ +EFI_CHAR8 *getUUIDFromString(const char *source) { if (!source) { @@ -100,6 +100,12 @@ { // the resulting binary will be the half size of the input hex string binStr = malloc(len / 2); + if (!binStr) + { + *outLength = 0; + return NULL; + } + bzero(binStr,len / 2 ); binStrIdx = 0; hexNibbleIdx = 0; @@ -119,7 +125,7 @@ { binChar = 0; - for (hexNibbleIdx = 0; hexNibbleIdx < sizeof(hexByte); hexNibbleIdx++) + for (hexNibbleIdx = 0; (unsigned)hexNibbleIdx < sizeof(hexByte); hexNibbleIdx++) { if (hexNibbleIdx > 0) { @@ -149,7 +155,7 @@ // FIXME: can't use my original code here, // Ironically, trying to reuse convertHexStr2Binary() would RESET the system! /* -static EFI_CHAR8* getUUIDFromString2(const char * szInUUID) +static EFI_CHAR8 *getUUIDFromString2(const char * szInUUID) { char szUUID[UUID_LEN+1], *p=szUUID; int size=0; @@ -165,6 +171,6 @@ verbose("UUID: cannot convert string <%s> to valid UUID.\n", szUUID); return (EFI_CHAR8*) 0; } - return (EFI_CHAR8*) ret; // new allocated buffer containing the converted string to bin + return (EFI_CHAR8 *) ret; // new allocated buffer containing the converted string to bin } */ Index: branches/zenith432/i386/libsaio/convert.h =================================================================== --- branches/zenith432/i386/libsaio/convert.h (revision 2593) +++ branches/zenith432/i386/libsaio/convert.h (revision 2594) @@ -11,10 +11,10 @@ #define UUID_LEN 16 -const char * getStringFromUUID(const EFI_CHAR8* uuid); -EFI_CHAR8* getUUIDFromString(const char *source); -void *convertHexStr2Binary(const char *hexStr, int *outLength); -uint32_t ascii_hex_to_int(char *buff); +const char *getStringFromUUID(const EFI_CHAR8* uuid); +EFI_CHAR8 *getUUIDFromString(const char *source); +void *convertHexStr2Binary(const char *hexStr, int *outLength); +uint32_t ascii_hex_to_int(char *buff); static inline uint16_t dp_swap16(uint16_t toswap) { Index: branches/zenith432/i386/libsaio/md5c.c =================================================================== --- branches/zenith432/i386/libsaio/md5c.c (revision 2593) +++ branches/zenith432/i386/libsaio/md5c.c (revision 2594) @@ -166,11 +166,14 @@ partLen); MD5Transform (context->state, context->buffer); - for (i = partLen; i + 63 < inputLen; i += 64) { + for (i = partLen; i + 63 < inputLen; i += 64) + { MD5Transform (context->state, &((const unsigned char *)input)[i]); } index = 0; - } else { + } + else + { i = 0; } Index: branches/zenith432/i386/libsaio/fake_efi.c =================================================================== --- branches/zenith432/i386/libsaio/fake_efi.c (revision 2593) +++ branches/zenith432/i386/libsaio/fake_efi.c (revision 2594) @@ -145,12 +145,12 @@ DT__AddProperty(tableNode, "guid", sizeof(EFI_GUID), (void *)pGuid); // The "table" property is the 32-bit (in our implementation) physical address of the table - DT__AddProperty(tableNode, "table", sizeof(void*) * 2, table); + DT__AddProperty(tableNode, "table", sizeof(void *) * 2, table); // Assume the alias pointer is a global or static piece of data if (alias != NULL) { - DT__AddProperty(tableNode, "alias", strlen(alias)+1, (char*)alias); + DT__AddProperty(tableNode, "alias", strlen(alias)+1, (char *)alias); } return EFI_SUCCESS; @@ -192,9 +192,9 @@ uint8_t voidret_instructions[sizeof(VOIDRET_INSTRUCTIONS)/sizeof(uint8_t)]; uint8_t unsupportedret_instructions[sizeof(UNSUPPORTEDRET_INSTRUCTIONS_32)/sizeof(uint8_t)]; }; - - struct fake_efi_pages *fakeEfiPages = (struct fake_efi_pages*)AllocateKernelMemory(sizeof(struct fake_efi_pages)); - + + struct fake_efi_pages *fakeEfiPages = (struct fake_efi_pages *)AllocateKernelMemory(sizeof(struct fake_efi_pages)); + // Zero out all the tables in case fields are added later //bzero(fakeEfiPages, sizeof(struct fake_efi_pages)); @@ -262,8 +262,8 @@ // but it is nice if we can at least prevent a complete crash by // at least providing some sort of implementation until one can be provided // nicely in a kext. - void (*voidret_fp)() = (void*)fakeEfiPages->voidret_instructions; - void (*unsupportedret_fp)() = (void*)fakeEfiPages->unsupportedret_instructions; + void (*voidret_fp)() = (void *)fakeEfiPages->voidret_instructions; + void (*unsupportedret_fp)() = (void *)fakeEfiPages->unsupportedret_instructions; efiRuntimeServices->GetTime = (EFI_PTR32)unsupportedret_fp; efiRuntimeServices->SetTime = (EFI_PTR32)unsupportedret_fp; efiRuntimeServices->GetWakeupTime = (EFI_PTR32)unsupportedret_fp; @@ -303,7 +303,7 @@ uint8_t unsupportedret_instructions[sizeof(UNSUPPORTEDRET_INSTRUCTIONS_64)/sizeof(uint8_t)]; }; - struct fake_efi_pages *fakeEfiPages = (struct fake_efi_pages*)AllocateKernelMemory(sizeof(struct fake_efi_pages)); + struct fake_efi_pages *fakeEfiPages = (struct fake_efi_pages *)AllocateKernelMemory(sizeof(struct fake_efi_pages)); // Zero out all the tables in case fields are added later //bzero(fakeEfiPages, sizeof(struct fake_efi_pages)); @@ -371,8 +371,8 @@ // at least providing some sort of implementation until one can be provided // nicely in a kext. - void (*voidret_fp)() = (void*)fakeEfiPages->voidret_instructions; - void (*unsupportedret_fp)() = (void*)fakeEfiPages->unsupportedret_instructions; + void (*voidret_fp)() = (void *)fakeEfiPages->voidret_instructions; + void (*unsupportedret_fp)() = (void *)fakeEfiPages->unsupportedret_instructions; efiRuntimeServices->GetTime = ptov64((EFI_PTR32)unsupportedret_fp); efiRuntimeServices->SetTime = ptov64((EFI_PTR32)unsupportedret_fp); efiRuntimeServices->GetWakeupTime = ptov64((EFI_PTR32)unsupportedret_fp); @@ -451,7 +451,7 @@ static const char FIRMWARE_REVISION_PROP[] = "firmware-revision"; static const char FIRMWARE_ABI_PROP[] = "firmware-abi"; static const char FIRMWARE_VENDOR_PROP[] = "firmware-vendor"; -//static const char FIRMWARE_ABI_32_PROP_VALUE[] = "EFI32"; +static const char FIRMWARE_ABI_32_PROP_VALUE[] = "EFI32"; static const char FIRMWARE_ABI_64_PROP_VALUE[] = "EFI64"; static const char EFI_MODE_PROP[] = "efi-mode"; //Bungo static const char SYSTEM_ID_PROP[] = "system-id"; @@ -465,7 +465,7 @@ /* * Get an smbios option string option to convert to EFI_CHAR16 string */ -static EFI_CHAR16* getSmbiosChar16(const char * key, size_t* len) +static EFI_CHAR16 *getSmbiosChar16(const char *key, size_t *len) { const char *src = getStringForKey(key, &bootInfo->smbiosConfig); EFI_CHAR16* dst = 0; @@ -491,13 +491,15 @@ /* * Get the SystemID from the bios dmi info -static EFI_CHAR8* getSmbiosUUID() +static EFI_CHAR8 *getSmbiosUUID() { - static EFI_CHAR8 uuid[UUID_LEN]; - int i, isZero, isOnes; - SMBByte *p; + static EFI_CHAR8 uuid[UUID_LEN]; + int i; + int isZero; + int isOnes; + SMBByte *p; - p = (SMBByte*)Platform.UUID; + p = (SMBByte *)Platform.UUID; for (i=0, isZero=1, isOnes=1; iefiMode); @@ -636,16 +637,19 @@ // the value in the fsbFrequency global and not an malloc'd pointer // because the DT_AddProperty function does not copy its args. - if (Platform.CPU.FSBFrequency != 0) { + if (Platform.CPU.FSBFrequency != 0) + { DT__AddProperty(efiPlatformNode, FSB_Frequency_prop, sizeof(uint64_t), &Platform.CPU.FSBFrequency); } // Export TSC and CPU frequencies for use by the kernel or KEXTs - if (Platform.CPU.TSCFrequency != 0) { + if (Platform.CPU.TSCFrequency != 0) + { DT__AddProperty(efiPlatformNode, TSC_Frequency_prop, sizeof(uint64_t), &Platform.CPU.TSCFrequency); } - if (Platform.CPU.CPUFrequency != 0) { + if (Platform.CPU.CPUFrequency != 0) + { DT__AddProperty(efiPlatformNode, CPU_Frequency_prop, sizeof(uint64_t), &Platform.CPU.CPUFrequency); } @@ -653,20 +657,23 @@ // Bungo /* Export system-id. Can be disabled with SystemId=No in com.apple.Boot.plist - if ((ret=getSystemID())) { - DT__AddProperty(efiPlatformNode, SYSTEM_ID_PROP, UUID_LEN, (EFI_UINT32*) ret); + if ((ret=getSystemID())) + { + DT__AddProperty(efiPlatformNode, SYSTEM_ID_PROP, UUID_LEN, (EFI_UINT32 *) ret); } */ DT__AddProperty(efiPlatformNode, SYSTEM_ID_PROP, UUID_LEN, (EFI_UINT32 *)Platform.UUID); // Export SystemSerialNumber if present - if ((ret16=getSmbiosChar16("SMserial", &len))) { + if ((ret16=getSmbiosChar16("SMserial", &len))) + { DT__AddProperty(efiPlatformNode, SYSTEM_SERIAL_PROP, len, ret16); } // Export Model if present - if ((ret16=getSmbiosChar16("SMproductname", &len))) { + if ((ret16=getSmbiosChar16("SMproductname", &len))) + { DT__AddProperty(efiPlatformNode, MODEL_PROP, len, ret16); } Index: branches/zenith432/i386/libsaio/saio_internal.h =================================================================== --- branches/zenith432/i386/libsaio/saio_internal.h (revision 2593) +++ branches/zenith432/i386/libsaio/saio_internal.h (revision 2594) @@ -134,7 +134,7 @@ /* memory.c */ long AllocateKernelMemory( long inSize ); -long AllocateMemoryRange(char * rangeName, long start, long length, long type); +long AllocateMemoryRange(char *rangeName, long start, long length, long type); /* misc.c */ extern void enableA20(void); Index: branches/zenith432/i386/boot2/drivers.c =================================================================== --- branches/zenith432/i386/boot2/drivers.c (revision 2593) +++ branches/zenith432/i386/boot2/drivers.c (revision 2594) @@ -740,11 +740,12 @@ //========================================================================== // MatchLibraries -static long -MatchLibraries( void ) +static long MatchLibraries( void ) { - TagPtr prop, prop2; - ModulePtr module, module2; + TagPtr prop; + TagPtr prop2; + ModulePtr module; + ModulePtr module2; long done; do { @@ -798,8 +799,7 @@ // FindModule #if NOTDEF -static ModulePtr -FindModule( char * name ) +static ModulePtr FindModule( char *name ) { ModulePtr module; TagPtr prop; @@ -825,15 +825,14 @@ //========================================================================== // ParseXML -static long -ParseXML( char * buffer, ModulePtr * module, TagPtr * personalities ) +static long ParseXML( char *buffer, ModulePtr *module, TagPtr *personalities ) { - long length, pos; - TagPtr moduleDict, required; - ModulePtr tmpModule; - - pos = 0; - + long length; + long pos = 0; + TagPtr moduleDict; + TagPtr required; + ModulePtr tmpModule; + while (1) { length = XMLParseNextTag(buffer + pos, &moduleDict); Index: branches/zenith432/i386/boot2/mboot.c =================================================================== --- branches/zenith432/i386/boot2/mboot.c (revision 2593) +++ branches/zenith432/i386/boot2/mboot.c (revision 2594) @@ -290,8 +290,8 @@ continue_at_low_address(); // Now fix our return address. - // JrCs: this macro should be rewritten because the code generated by XCode 4.x - // change the value of the argument passed as parameter (multiboot_magic) + // JrCs: this macro should be rewritten because the code generated by XCode 4.x + // change the value of the argument passed as parameter (multiboot_magic) // FIX_RETURN_ADDRESS_USING_FIRST_ARG(multiboot_magic); // We can now do just about anything, including return to our caller correctly. @@ -404,7 +404,7 @@ else doSelectDevice = true; } - + if(getValueForBootKey(mi->mi_cmdline, "timeout", &val, &size)) { char *endptr; @@ -415,8 +415,8 @@ multiboot_timeout = intVal; multiboot_timeout_set = 1; } - } - + } + if(getValueForBootKey(mi->mi_cmdline, "partno", &val, &size)) { char *endptr; Index: branches/zenith432/i386/boot2/lzvn.c =================================================================== --- branches/zenith432/i386/boot2/lzvn.c (revision 2593) +++ branches/zenith432/i386/boot2/lzvn.c (revision 2594) @@ -57,9 +57,9 @@ } while (0) -size_t lzvn_decode(void * dst, +size_t lzvn_decode(void *dst, size_t dst_size, - const void * src, + const void *src, size_t src_size) { size_t rax = 0; Index: branches/zenith432/i386/boot2/resume.c =================================================================== --- branches/zenith432/i386/boot2/resume.c (revision 2593) +++ branches/zenith432/i386/boot2/resume.c (revision 2594) @@ -54,6 +54,7 @@ dst = (unsigned long *) (header->restore1CodePhysPage << 12); count = header->restore1PageCount; proc = (header->restore1CodeOffset + ((uint32_t) dst)); + newSP = header->restore1StackOffset + (header->restore1CodePhysPage << 12); src = (unsigned long *) (((u_int32_t) &header->fileExtentMap[0]) Index: branches/zenith432/i386/boot2/boot.c =================================================================== --- branches/zenith432/i386/boot2/boot.c (revision 2593) +++ branches/zenith432/i386/boot2/boot.c (revision 2594) @@ -77,7 +77,7 @@ bool gScanSingleDrive; bool useGUI; -static int interruptsAvailable = 0; +static int interruptsAvailable = 0; static bool gUnloadPXEOnExit = false; @@ -230,7 +230,10 @@ // Notify modules that the kernel is about to be started execute_hook("Kernel Start", (void *)kernelEntry, (void *)bootArgs, NULL, NULL); - if (interruptsAvailable) DisableInterrupts(); + if (interruptsAvailable) + { + DisableInterrupts(); + } // Masking out so that Lion doesn't doublefault outb(0x21, 0xff); /* Maskout all interrupts Pic1 */ @@ -243,8 +246,12 @@ // Notify modules that the kernel is about to be started execute_hook("Kernel Start", (void*)kernelEntry, (void*)bootArgsPreLion, NULL, NULL); - if (interruptsAvailable) DisableInterrupts(); + if (interruptsAvailable) + { + DisableInterrupts(); + } + startprog( kernelEntry, bootArgsPreLion ); } @@ -252,7 +259,6 @@ __builtin_unreachable(); } - //========================================================================== // LoadKernelCache - Try to load Kernel Cache. // return the length of the loaded cache file or -1 on error @@ -435,9 +441,9 @@ bool firstRun = true; bool instantMenu; bool rescanPrompt; - int status; - unsigned int allowBVFlags = kBVFlagSystemVolume | kBVFlagForeignBoot; - unsigned int denyBVFlags = kBVFlagEFISystem; + int status; + unsigned int allowBVFlags = kBVFlagSystemVolume | kBVFlagForeignBoot; + unsigned int denyBVFlags = kBVFlagEFISystem; // Set reminder to unload the PXE base code. Neglect to unload // the base code will result in a hang or kernel panic. @@ -451,7 +457,10 @@ // Enable interrupts interruptsAvailable = SetupInterrupts(); - if (interruptsAvailable) EnableInterrupts(); + if (interruptsAvailable) + { + EnableInterrupts(); + } // Initialize boot info structure. initKernBootStruct(); @@ -847,7 +856,11 @@ { nbpUnloadBaseCode(); } - if (interruptsAvailable) DisableInterrupts(); + + if (interruptsAvailable) + { + DisableInterrupts(); + } } /*! Index: branches/zenith432/i386/boot2/boot.h =================================================================== --- branches/zenith432/i386/boot2/boot.h (revision 2593) +++ branches/zenith432/i386/boot2/boot.h (revision 2594) @@ -119,13 +119,13 @@ #define kEHCIhard "EHCIhard" /* usb.c */ #define kDefaultPartition "Default Partition" /* sys.c */ -/* Zenith432: added this */ +/* Zenith432: added this key */ #define kXHCILegacyOff "XHCILegacyOff" /* usb.c */ -/* Duvel300: added this */ +/* Duvel300: added this key */ #define kRestartFix "RestartFix" /* acpi_patcher.c */ -/* Slice: added this */ +/* Slice: added these keys */ #define kPS2RestartFix "PS2RestartFix" /* acpi_patcher.c */ #define kUseIntelHDMI "UseIntelHDMI" /* ati.c && nvidia.c && gma.c */ @@ -154,7 +154,7 @@ #define kDcfg0 "display_0" /* nvidia.c */ #define kDcfg1 "display_1" /* nvidia.c */ -/* Marchrius: added these keys */ +/* Marchrius: added this key */ #define kEnableBacklight "EnableBacklight" /* nvidia.c */ /* Kabyl: added these keys */ @@ -180,10 +180,10 @@ #define kHDEFLayoutID "HDEFLayoutID" /* hda.c */ #define kHDAULayoutID "HDAULayoutID" /* hda.c */ -/* Karas: added these keys */ +/* Karas: added this key */ #define kMemFullInfo "ForceFullMemInfo" /* smbios.c */ -/* Bungo: added these keys */ +/* Bungo: added this key */ #define kPrivateData "PrivateData" /* smbios_decode.c */ Index: branches/zenith432/i386/boot2/modules.c =================================================================== --- branches/zenith432/i386/boot2/modules.c (revision 2593) +++ branches/zenith432/i386/boot2/modules.c (revision 2594) @@ -25,8 +25,8 @@ #define DBGPAUSE() #endif -static inline void rebase_location(UInt32* location, char* base, int type); -static inline void bind_location(UInt32* location, char* value, UInt32 addend, int type); +static inline void rebase_location(UInt32 *location, char *base, int type); +static inline void bind_location(UInt32 *location, char *value, UInt32 addend, int type); // NOTE: Global so that modules can link with this static UInt64 textAddress = 0; @@ -118,7 +118,7 @@ last = mod->mm_string; } - char* name = strdup(last); + char *name = strdup(last); name[strlen(last) - sizeof("dylib")] = 0; DBG("Loading multiboot module %s\n", name); @@ -271,7 +271,7 @@ * adjust it's internal symbol list (sort) to optimize locating new symbols * NOTE: returns the address if the symbol is "start", else returns 0xFFFFFFFF */ -long long add_symbol(char* symbol, long long addr, char is64) +long long add_symbol(char *symbol, long long addr, char is64) { // This only can handle 32bit symbols symbolList_t* entry; @@ -300,7 +300,7 @@ */ void module_loaded(const char* name, void* start, const char* author, const char* description, UInt32 version, UInt32 compat) { - moduleList_t* new_entry = malloc(sizeof(moduleList_t)); + moduleList_t *new_entry = malloc(sizeof(moduleList_t)); new_entry->next = loadedModules; loadedModules = new_entry; @@ -1069,7 +1069,6 @@ return 0; } - /* * execute_hook( const char* name ) * name - Name of the module hook @@ -1106,8 +1105,6 @@ } } - - /* * register_hook_callback( const char* name, void(*callback)()) * name - Name of the module hook to attach to. @@ -1229,9 +1226,9 @@ return 0; } -void start_built_in_module(const char* name, - const char* author, - const char* description, +void start_built_in_module(const char *name, + const char *author, + const char *description, UInt32 version, UInt32 compat, void(*start_function)(void)) Index: branches/zenith432/i386/boot2/modules.h =================================================================== --- branches/zenith432/i386/boot2/modules.h (revision 2593) +++ branches/zenith432/i386/boot2/modules.h (revision 2594) @@ -34,14 +34,14 @@ typedef struct callbackList_t { void(*callback)(void*, void*, void*, void*); - struct callbackList_t* next; + struct callbackList_t *next; } callbackList_t; typedef struct moduleHook_t { - const char* name; - callbackList_t* callbacks; - struct moduleHook_t* next; + const char *name; + callbackList_t *callbacks; + struct moduleHook_t *next; } moduleHook_t; typedef struct modulesList_t @@ -68,7 +68,7 @@ int load_module(char* module); int is_module_loaded(const char* name); -void module_loaded(const char* name, void* start, const char* author, const char* description, UInt32 version, UInt32 compat); +void module_loaded(const char *name, void *start, const char *author, const char *description, UInt32 version, UInt32 compat); @@ -76,35 +76,35 @@ /********************************************************************************/ /* Symbol Functions */ /********************************************************************************/ -long long add_symbol(char* symbol, long long addr, char is64); -unsigned int lookup_all_symbols(const char* name); +long long add_symbol(char *symbol, long long addr, char is64); +unsigned int lookup_all_symbols(const char *name); /********************************************************************************/ /* Macho Parser */ /********************************************************************************/ -void* parse_mach(void* binary, +void* parse_mach(void *binary, int(*dylib_loader)(char*), long long(*symbol_handler)(char*, long long, char), - void (*section_handler)(char* section, char* segment, void* cmd, UInt64 offset, UInt64 address) + void (*section_handler)(char *section, char *segment, void *cmd, UInt64 offset, UInt64 address) ); unsigned int handle_symtable(UInt32 base, - struct symtab_command* symtabCommand, + struct symtab_command *symtabCommand, long long(*symbol_handler)(char*, long long, char), char is64); -void rebase_macho(void* base, char* rebase_stream, UInt32 size); +void rebase_macho(void *base, char *rebase_stream, UInt32 size); -void bind_macho(void* base, UInt8* bind_stream, UInt32 size); +void bind_macho(void *base, UInt8 *bind_stream, UInt32 size); /********************************************************************************/ /* Module Interface */ /********************************************************************************/ -int replace_function(const char* symbol, void* newAddress); -int execute_hook(const char* name, void*, void*, void*, void*); -void register_hook_callback(const char* name, void(*callback)(void*, void*, void*, void*)); -moduleHook_t* hook_exists(const char* name); +int replace_function(const char *symbol, void *newAddress); +int execute_hook(const char *name, void*, void*, void*, void*); +void register_hook_callback(const char* name, void(*callback)(void*, void*, void*, void*)); +moduleHook_t *hook_exists(const char* name); #if DEBUG_MODULES void print_hook_list(); Index: branches/zenith432/i386/boot2/gui.c =================================================================== --- branches/zenith432/i386/boot2/gui.c (revision 2593) +++ branches/zenith432/i386/boot2/gui.c (revision 2594) @@ -13,6 +13,16 @@ #include "appleboot.h" #include "vers.h" +#ifndef DEBUG_GUI +#define DEBUG_GUI 0 +#endif + +#if DEBUG_GUI +#define DBG(x...) printf(x) +#else +#define DBG(x...) +#endif + #define IMG_REQUIRED -1 #define THEME_NAME_DEFAULT "Default" static const char *theme_name = THEME_NAME_DEFAULT; @@ -456,6 +466,8 @@ initFont( &font_console, &images[iFontConsole]); initFont( &font_small, &images[iFontSmall]); +// DBG("Graphic objects successfully loaded !!\n",theme_name); + return 0; } @@ -524,13 +536,18 @@ int createBackBuffer( window_t *window ) { gui.backbuffer = malloc(sizeof(pixmap_t)); - if(!gui.backbuffer) { + if(!gui.backbuffer) + { + DBG("Unable to allocate memory for gui.backbuffer"); return 1; } + gui.backbuffer->pixels = malloc( window->width * window->height * 4 ); - if(!gui.backbuffer->pixels) { + if(!gui.backbuffer->pixels) + { free(gui.backbuffer); gui.backbuffer = 0; + DBG("Unable to allocate memory for gui.backbuffer->pixels"); return 1; } @@ -545,14 +562,18 @@ int createWindowBuffer( window_t *window ) { window->pixmap = malloc(sizeof(pixmap_t)); - if(!window->pixmap) { + if(!window->pixmap) + { + DBG("Unable to allocate memory for window->pixmap"); return 1; } window->pixmap->pixels = malloc( window->width * window->height * 4 ); - if(!window->pixmap->pixels) { + if(!window->pixmap->pixels) + { free(window->pixmap); window->pixmap = 0; + DBG("Unable to allocate memory for window->pixmap->pixels"); return 1; } @@ -566,11 +587,13 @@ int freeWindowBuffer( window_t *window ) { - if (window->pixmap && window->pixmap->pixels) { + if (window->pixmap && window->pixmap->pixels) + { free(window->pixmap->pixels); free(window->pixmap); return 0; } + return 1; } @@ -620,18 +643,22 @@ int val, len; const char *string; - if(getIntForKey("devices_max_visible", &val, theme )) { + if(getIntForKey("devices_max_visible", &val, theme )) + { gui.maxdevices = MIN( val, gDeviceCount ); } - if(getIntForKey("devices_iconspacing", &val, theme )) { + if(getIntForKey("devices_iconspacing", &val, theme )) + { gui.devicelist.iconspacing = val; } // check layout for horizontal or vertical gui.layout = HorizontalLayout; - if(getValueForKey( "devices_layout", &string, &len, theme)) { - if (!strcmp (string, "vertical")) { + if(getValueForKey( "devices_layout", &string, &len, theme)) + { + if (!strcmp (string, "vertical")) + { gui.layout = VerticalLayout; } } @@ -756,7 +783,7 @@ gui.countdown.pos.y = pixel; } - /* + /* * Parse devicelist parameters */ setupDeviceList(theme); @@ -907,7 +934,11 @@ return 1; } #else + + DBG("Unable to load %s theme plist.\n",theme_name); + return 1; + #endif } // parse display size parameters @@ -931,23 +962,32 @@ gui.screen.height = screen_params[1]; // load graphics otherwise fail and return - if (loadGraphics() == 0) { + if (loadGraphics() == 0) + { loadThemeValues(&bootInfo->themeConfig); colorFont(&font_small, gui.screen.font_small_color); colorFont(&font_console, gui.screen.font_console_color); // create the screen & window buffers - if (createBackBuffer(&gui.screen) == 0) { - if (createWindowBuffer(&gui.screen) == 0) { - if (createWindowBuffer(&gui.devicelist) == 0) { - if (createWindowBuffer(&gui.bootprompt) == 0) { - if (createWindowBuffer(&gui.infobox) == 0) { - if (createWindowBuffer(&gui.menu) == 0) { + if (createBackBuffer(&gui.screen) == 0) + { + if (createWindowBuffer(&gui.screen) == 0) + { + if (createWindowBuffer(&gui.devicelist) == 0) + { + if (createWindowBuffer(&gui.bootprompt) == 0) + { + if (createWindowBuffer(&gui.infobox) == 0) + { + if (createWindowBuffer(&gui.menu) == 0) + { gui.logo.draw = true; drawBackground(); // lets copy the screen into the back buffer memcpy( gui.backbuffer->pixels, gui.screen.pixmap->pixels, gui.backbuffer->width * gui.backbuffer->height * 4 ); + setVideoMode( GRAPHICS_MODE, 0 ); + gui.initialised = true; return 0; } @@ -958,15 +998,17 @@ } } - // not available memory, freeing resources - freeWindowBuffer(&gui.menu); - freeWindowBuffer(&gui.infobox); - freeWindowBuffer(&gui.bootprompt); - freeWindowBuffer(&gui.devicelist); - freeWindowBuffer(&gui.screen); - freeBackBuffer(&gui.screen); - unloadGraphics(); + DBG("Loading error occurred, reseting...\n",theme_name); + // Loading error occurred, freeing resources + freeWindowBuffer(&gui.menu); + freeWindowBuffer(&gui.infobox); + freeWindowBuffer(&gui.bootprompt); + freeWindowBuffer(&gui.devicelist); + freeWindowBuffer(&gui.screen); + freeBackBuffer(&gui.screen); + unloadGraphics(); + return 1; } @@ -1130,7 +1172,8 @@ } // draw visible device icons - for (i = 0; i < gui.maxdevices; i++) { + for (i = 0; i < gui.maxdevices; i++) + { BVRef param = menuItems[start + i].param; bool isSelected = ((start + i) == selection) ? true : false; @@ -1172,10 +1215,12 @@ drawDeviceIcon( param, gui.devicelist.pixmap, p, isSelected); - if (gui.layout == HorizontalLayout) { + if (gui.layout == HorizontalLayout) + { p.x += images[iSelection].image->width + gui.devicelist.iconspacing; } - if (gui.layout == VerticalLayout) { + if (gui.layout == VerticalLayout) + { p.y += ( images[iSelection].image->height + font_console.chars[0]->height + gui.devicelist.iconspacing ); } } @@ -1203,7 +1248,8 @@ //prompt_pos=0; - if( gui.bootprompt.draw == true ) { + if(gui.bootprompt.draw == true ) + { gui.bootprompt.draw = false; gui.redraw = true; // this causes extra frames to be drawn @@ -1245,17 +1291,25 @@ static inline void vramwrite (void *data, int width, int height) { - if (VIDEO (depth) == 32 && VIDEO (rowBytes) == gui.backbuffer->width * 4) { + if (VIDEO (depth) == 32 && VIDEO (rowBytes) == gui.backbuffer->width * 4) + { memcpy((uint8_t *)vram, gui.backbuffer->pixels, VIDEO (rowBytes)*VIDEO (height)); - } else { - uint32_t r, g, b; + } + else + { + uint32_t r; + uint32_t g; + uint32_t b; int i, j; - for (i = 0; i < VIDEO (height); i++) { - for (j = 0; j < VIDEO (width); j++) { + for (i = 0; i < VIDEO (height); i++) + { + for (j = 0; j < VIDEO (width); j++) + { b = ((uint8_t *) data)[4*i*width + 4*j]; g = ((uint8_t *) data)[4*i*width + 4*j + 1]; r = ((uint8_t *) data)[4*i*width + 4*j + 2]; - switch (VIDEO (depth)) { + switch (VIDEO (depth)) + { case 32: *(uint32_t *)(((uint8_t *)vram)+i*VIDEO (rowBytes) + j*4) = (b&0xff) | ((g&0xff)<<8) | ((r&0xff)<<16); break; @@ -1270,6 +1324,8 @@ case 15: *(uint16_t *)(((uint8_t *)vram)+i*VIDEO (rowBytes) + j*2) = ((b&0xf8)>>3) | ((g&0xf8)<<2) | ((r&0xf8)<<7); break; + default: + break; } } } @@ -1280,24 +1336,30 @@ void updateVRAM() { - if (gui.redraw) { - if (gui.devicelist.draw) { + if (gui.redraw) + { + if (gui.devicelist.draw) + { blend( gui.devicelist.pixmap, gui.backbuffer, gui.devicelist.pos ); } - if (gui.bootprompt.draw) { + if (gui.bootprompt.draw) + { blend( gui.bootprompt.pixmap, gui.backbuffer, gui.bootprompt.pos ); } - if (gui.menu.draw) { - blend( gui.menu.pixmap, gui.backbuffer, gui.menu.pos ); + if (gui.menu.draw) + { + blend( gui.menu.pixmap, gui.backbuffer, gui.menu.pos ); } - if (gui.infobox.draw) { + if (gui.infobox.draw) + { blend( gui.infobox.pixmap, gui.backbuffer, gui.infobox.pos ); } } vramwrite ( gui.backbuffer->pixels, gui.backbuffer->width, gui.backbuffer->height ); - if (gui.redraw) { + if (gui.redraw) + { memcpy( gui.backbuffer->pixels, gui.screen.pixmap->pixels, gui.backbuffer->width * gui.backbuffer->height * 4 ); gui.redraw = false; } @@ -1316,8 +1378,10 @@ static int sputc(int c, struct putc_info * pi) //Azi: same as above { - if (pi->last_str) { - if (pi->str == pi->last_str) { + if (pi->last_str) + { + if (pi->str == pi->last_str) + { *(pi->str) = '\0'; return 0; } @@ -1333,10 +1397,11 @@ char *formattedtext; va_list ap; - + struct putc_info pi; - if ((formattedtext = malloc(1024)) != NULL) { + if ((formattedtext = malloc(1024)) != NULL) + { // format the text va_start(ap, fmt); pi.str = formattedtext; @@ -1360,42 +1425,49 @@ font_t *font = &font_console; - for( i=0; i< strlen(formattedtext); i++ ) { + for( i=0; i< strlen(formattedtext); i++ ) + { character = formattedtext[i]; character -= 32; // newline ? - if( formattedtext[i] == '\n' ) { + if( formattedtext[i] == '\n' ) + { cursor.x = window->hborder; cursor.y += font->height; - if ( cursor.y > bounds.y ) { + if ( cursor.y > bounds.y ) + { cursor.y = origin.y; } continue; } // tab ? - if( formattedtext[i] == '\t' ) { + if( formattedtext[i] == '\t' ) + { cursor.x += ( font->chars[0]->width * 5 ); } // draw the character - if( font->chars[character]) { + if( font->chars[character]) + { blend(font->chars[character], window->pixmap, cursor); } cursor.x += font->chars[character]->width; // check x pos and do newline - if ( cursor.x > bounds.x ) { + if ( cursor.x > bounds.x ) + { cursor.x = origin.x; cursor.y += font->height; } // check y pos and reset to origin.y - if ( cursor.y > bounds.y ) { + if ( cursor.y > bounds.y ) + { cursor.y = origin.y; } } @@ -1417,12 +1489,13 @@ char *formattedtext; va_list ap; - + //window = &gui.debug; struct putc_info pi; - - if ((formattedtext = malloc(1024)) != NULL) { + + if ((formattedtext = malloc(1024)) != NULL) + { // format the text va_start(ap, fmt); pi.str = formattedtext; @@ -1432,10 +1505,10 @@ va_end(ap); position_t origin, cursor, bounds; - + int i; int character; - + origin.x = MAX( gui.debug.cursor.x, window->hborder ); origin.y = MAX( gui.debug.cursor.y, window->vborder ); @@ -1446,40 +1519,47 @@ font_t *font = &font_console; - for( i=0; i< strlen(formattedtext); i++ ) { + for( i=0; i< strlen(formattedtext); i++ ) + { character = formattedtext[i]; character -= 32; // newline ? - if( formattedtext[i] == '\n' ) { + if( formattedtext[i] == '\n' ) + { cursor.x = window->hborder; cursor.y += font->height; - if ( cursor.y > bounds.y ) { + if ( cursor.y > bounds.y ) + { cursor.y = origin.y; } continue; } // tab ? - if( formattedtext[i] == '\t' ) { + if( formattedtext[i] == '\t' ) + { cursor.x += ( font->chars[0]->width * 5 ); } // draw the character - if( font->chars[character]) { + if( font->chars[character]) + { blend(font->chars[character], gui.backbuffer, cursor); } cursor.x += font->chars[character]->width; // check x pos and do newline - if ( cursor.x > bounds.x ) { + if ( cursor.x > bounds.x ) + { cursor.x = origin.x; cursor.y += font->height; } // check y pos and reset to origin.y - if ( cursor.y > bounds.y ) { + if ( cursor.y > bounds.y ) + { cursor.y = origin.y; } } @@ -1509,7 +1589,8 @@ position_t origin, cursor, bounds; font_t *font = &font_console; - if ((formattedtext = malloc(1024)) != NULL) { + if ((formattedtext = malloc(1024)) != NULL) + { // format the text pi.str = formattedtext; pi.last_str = 0; @@ -1522,15 +1603,18 @@ bounds.y = ( window->height - ( window->vborder * 2 ) ); cursor = origin; - for( i=0; i< strlen(formattedtext); i++ ) { + for( i=0; i< strlen(formattedtext) ; i++ ) + { character = formattedtext[i]; character -= 32; // newline ? - if( formattedtext[i] == '\n' ) { + if( formattedtext[i] == '\n' ) + { cursor.x = window->hborder; cursor.y += font->height; - if ( cursor.y > bounds.y ) { + if ( cursor.y > bounds.y ) + { gui.redraw = true; updateVRAM(); cursor.y = window->vborder; @@ -1540,26 +1624,30 @@ } // tab ? - if( formattedtext[i] == '\t' ) { + if( formattedtext[i] == '\t' ) + { cursor.x = ( cursor.x / ( font->chars[0]->width * 8 ) + 1 ) * ( font->chars[0]->width * 8 ); continue; } cursor.x += font->chars[character]->width; // check x pos and do newline - if ( cursor.x > bounds.x ) { + if ( cursor.x > bounds.x ) + { cursor.x = origin.x; cursor.y += font->height; } // check y pos and reset to origin.y - if ( cursor.y > ( bounds.y + font->chars[0]->height) ) { + if ( cursor.y > ( bounds.y + font->chars[0]->height) ) + { gui.redraw = true; updateVRAM(); cursor.y = window->vborder; } // draw the character - if( font->chars[character]) { + if( font->chars[character]) + { blend(font->chars[character], gui.backbuffer, cursor); } } @@ -1574,9 +1662,11 @@ // ==================================================================== -pixmap_t* charToPixmap(unsigned char ch, font_t *font) { +pixmap_t *charToPixmap(unsigned char ch, font_t *font) +{ unsigned int cha = (unsigned int)ch - 32; - if (cha >= font->count) { + if (cha >= font->count) + { // return ? if the font for the char doesn't exists cha = '?' - 32; } @@ -1585,12 +1675,16 @@ // ==================================================================== -position_t drawChar(unsigned char ch, font_t *font, pixmap_t *blendInto, position_t p) { +position_t drawChar(unsigned char ch, font_t *font, pixmap_t *blendInto, position_t p) +{ pixmap_t* pm = charToPixmap(ch, font); - if (pm && ((p.x + pm->width) < blendInto->width)) { + if (pm && ((p.x + pm->width) < blendInto->width)) + { blend(pm, blendInto, p); return pos(p.x + pm->width, p.y); - } else { + } + else + { return p; } } @@ -1602,16 +1696,19 @@ int i=0; position_t current_pos = pos(p.x, p.y); - for (i=0; i < strlen(ch); i++) { + for (i=0; i < strlen(ch); i++) + { // newline ? - if ( ch[i] == '\n' ) { + if ( ch[i] == '\n' ) + { current_pos.x = p.x; current_pos.y += font->height; continue; } // tab ? - if ( ch[i] == '\t' ) { + if ( ch[i] == '\t' ) + { current_pos.x += TAB_PIXELS_WIDTH; continue; } @@ -1630,19 +1727,27 @@ int height = font->height; // calculate the width in pixels - for (i=0; i < strlen(text); i++) { - if (text[i] == '\n') { + for (i=0; i < strlen(text); i++) + { + if (text[i] == '\n') + { width = 0; height += font->height; - } else if (text[i] == '\t') { + } + else if (text[i] == '\t') + { width += TAB_PIXELS_WIDTH; - } else { + } + else + { pixmap_t* pm = charToPixmap(text[i], font); - if (pm) { + if (pm) + { width += pm->width; } } - if (width > max_width) { + if (width > max_width) + { max_width = width; } } @@ -1658,9 +1763,12 @@ int destroyFont(font_t *font) { int i; - for (i = 0; i < CHARACTERS_COUNT; i++) { - if (font->chars[i]) { - if (font->chars[i]->pixels) { + for (i = 0; i < CHARACTERS_COUNT; i++) + { + if (font->chars[i]) + { + if (font->chars[i]->pixels) + { free (font->chars[i]->pixels); } free (font->chars[i]); @@ -1682,44 +1790,53 @@ font->height = data->image->height; - for( x = 0; x < data->image->width && count < CHARACTERS_COUNT; x++) { + for( x = 0; x < data->image->width && count < CHARACTERS_COUNT; x++) + { start = end; // if the pixel is red we've reached the end of the char - if( pixel( data->image, x, 0 ).value == 0xFFFF0000) { + if( pixel( data->image, x, 0 ).value == 0xFFFF0000) + { end = x + 1; - if( (font->chars[count] = malloc(sizeof(pixmap_t)) ) ) { + if( (font->chars[count] = malloc(sizeof(pixmap_t)) ) ) + { font->chars[count]->width = ( end - start) - 1; font->chars[count]->height = font->height; - - if ( ( font->chars[count]->pixels = malloc( font->chars[count]->width * data->image->height * 4) ) ) { + + if ( ( font->chars[count]->pixels = malloc( font->chars[count]->width * data->image->height * 4) ) ) + { space += ( font->chars[count]->width * data->image->height * 4 ); // we skip the first line because there are just the red pixels for the char width - for( y = 1; y< (font->height); y++) { - for( x2 = start, x3 = 0; x2 < end; x2++, x3++) { + for( y = 1; y< (font->height); y++) + { + for( x2 = start, x3 = 0; x2 < end; x2++, x3++) + { pixel( font->chars[count], x3, y ) = pixel( data->image, x2, y ); } } - + // check if font is monospaced - if( ( count > 0 ) && ( font->width != font->chars[count]->width ) ) { + if( ( count > 0 ) && ( font->width != font->chars[count]->width ) ) + { monospaced = true; } font->width = font->chars[count]->width; - + count++; } } } } - for (x = count; x < CHARACTERS_COUNT; x++) { + for (x = count; x < CHARACTERS_COUNT; x++) + { font->chars[x] = NULL; } - if(monospaced) { + if(monospaced) + { font->width = 0; } @@ -1732,7 +1849,8 @@ void colorFont(font_t *font, uint32_t color) { - if( !color ) { + if( !color ) + { return; } @@ -1740,13 +1858,17 @@ int count = 0; pixel_t *buff; - while( font->chars[count++] ) { + while( font->chars[count++] ) + { width = font->chars[count-1]->width; height = font->chars[count-1]->height; - for( y = 0; y < height; y++ ) { - for( x = 0; x < width; x++ ) { + for( y = 0; y < height; y++ ) + { + for( x = 0; x < width; x++ ) + { buff = &(pixel( font->chars[count-1], x, y )); - if( buff->ch.a ) { + if( buff->ch.a ) + { buff->ch.r = (color & 0xFFFF0000) >> 16; buff->ch.g = (color & 0xFF00FF00) >> 8; buff->ch.b = (color & 0xFF0000FF); @@ -1781,10 +1903,13 @@ uint8_t alpha=0; - for( y=0; y<10; y++) { - for( x=0; x<10; x++) { + for( y=0; y<10; y++) + { + for( x=0; x<10; x++) + { // skip if the pixel should be visible - if(roundedCorner[y][x] != 0xFF) { + if(roundedCorner[y][x] != 0xFF) + { alpha = ( roundedCorner[y][x] ? (uint8_t) (roundedCorner[y][x] * pixel(p, x, y).ch.a) / 255 : 0 ); // Upper left corner pixel(p, x, y).ch.a = alpha; @@ -1845,23 +1970,32 @@ visiblelines = ( ( gui.infobox.height - ( gui.infobox.vborder * 2 ) ) / font_console.height ) - 1; // lets display the text and allow scroll thru using up down / arrows - while(1) { + while(1) + { // move to current line in text - for( offset = 0, i = 0; offset < strlen(text); offset++ ) { - if( currentline == i) { + for( offset = 0, i = 0; offset < strlen(text); offset++ ) + { + if( currentline == i) + { break; } - if( text[offset] =='\n') { + + if( text[offset] =='\n') + { i++; } } // find last visible line in text and place \0 - for( i = offset, cnt = 0; i < strlen(text); i++) { - if(text[i]=='\n') { + for( i = offset, cnt = 0; i < strlen(text); i++) + { + if(text[i]=='\n') + { cnt++; } - if ( cnt == visiblelines ) { + + if ( cnt == visiblelines ) + { text[i]='\0'; break; } @@ -1885,12 +2019,14 @@ position_t pos_indicator = pos( gui.infobox.width - ( images[iTextScrollPrev].image->width - ( gui.infobox.vborder / 2) ), pos_text.y ); // draw prev indicator - if(offset) { + if(offset) + { blend( images[iTextScrollPrev].image, gui.infobox.pixmap, centeredAt( images[iTextScrollPrev].image, pos_indicator )); } // draw next indicator - if( lines > ( currentline + visiblelines ) ) { + if( lines > ( currentline + visiblelines ) ) + { pos_indicator.y = ( gui.infobox.height - ( ( images[iTextScrollNext].image->width + gui.infobox.vborder ) / 2 ) ); blend( images[iTextScrollNext].image, gui.infobox.pixmap, centeredAt( images[iTextScrollNext].image, pos_indicator ) ); } @@ -1902,7 +2038,7 @@ updateVRAM(); key = getchar(); - + if( key == KEY_UP ) { if( currentline > 0 ) { currentline--; @@ -1941,7 +2077,8 @@ { int y; - if( time18() > lasttime) { + if( time18() > lasttime) + { lasttime = time18(); pixmap_t *buffBar = images[iProgressBar].image; @@ -2134,6 +2271,8 @@ return buff; } break; + default: + break; } return DO_NOT_BOOT; } @@ -2155,7 +2294,8 @@ char dirspec[256]; - if ((strlen(theme_name) + 24) > sizeof(dirspec)) { + if ((strlen(theme_name) + 24) > sizeof(dirspec)) + { usePngImage = false; return; } Index: branches/zenith432/i386/boot2/options.c =================================================================== --- branches/zenith432/i386/boot2/options.c (revision 2593) +++ branches/zenith432/i386/boot2/options.c (revision 2594) @@ -197,7 +197,10 @@ if( currenttime > lasttime) { multi -= (currenttime - lasttime); - if (multi < 0) multi = 0; + if (multi < 0) + { + multi = 0; + } lasttime=currenttime; } } @@ -423,7 +426,7 @@ gMenuStart = 0; gMenuEnd = MIN( count, gui.maxdevices ) - 1; - + // If the selected item is not visible, shift the list down. if ( gMenuSelection > gMenuBottom ) @@ -461,38 +464,38 @@ static int updateMenu( int key, void ** paramPtr ) { - int moved = 0; + int moved = 0; - union { - struct { - unsigned int - selectionUp : 1, - selectionDown : 1, - scrollUp : 1, - scrollDown : 1; - } f; - unsigned int w; - } draw = {{0}}; + union { + struct { + unsigned int + selectionUp : 1, + selectionDown : 1, + scrollUp : 1, + scrollDown : 1; + } f; + unsigned int w; + } draw = {{0}}; - if ( gMenuItems == NULL ) + if ( gMenuItems == NULL ) return 0; if( bootArgs->Video.v_display != VGA_TEXT_MODE ) { int res; - + // set navigation keys for horizontal layout as defaults int previous = 0x4B00; // left arrow int subsequent = 0x4D00; // right arrow - int menu = 0x5000; // down arrow - + int menu = 0x5000; // down arrow + if ( gui.layout == VerticalLayout ) { // set navigation keys for vertical layout previous = 0x4800; // up arrow subsequent = 0x5000; // down arrow menu = 0x4B00; // right arrow - } + } if ( key == previous ) { @@ -500,7 +503,7 @@ draw.f.selectionUp = 1; else if ( gMenuTop > 0 ) draw.f.scrollDown = 1; - + } else if ( key == subsequent ) @@ -528,7 +531,7 @@ else { shouldboot = ( res != DO_NOT_BOOT ); - + if ( shouldboot ) gui.menu.draw = false; @@ -538,31 +541,33 @@ gVerboseMode = false; gBootMode = kBootModeNormal; break; - + case BOOT_VERBOSE: gVerboseMode = true; gBootMode = kBootModeNormal; addBootArg(kVerboseModeFlag); break; - + case BOOT_IGNORECACHE: gVerboseMode = false; gBootMode = kBootModeNormal; addBootArg(kIgnoreCachesFlag); break; - + case BOOT_SINGLEUSER: gVerboseMode = true; gBootMode = kBootModeNormal; addBootArg(kSingleUserModeFlag); break; } - + } - - } - - } else { + + } + + } + else + { switch ( key ) { case 0x4800: // Up Arrow @@ -581,31 +586,30 @@ } } - if ( draw.w ) - { - if ( draw.f.scrollUp ) - { - scollPage(0, gMenuRow, 40, gMenuRow + gMenuHeight - 1, 0x07, 1, 1); - gMenuTop++; gMenuBottom++; + if ( draw.w ) + { + if ( draw.f.scrollUp ) + { + scollPage(0, gMenuRow, 40, gMenuRow + gMenuHeight - 1, 0x07, 1, 1); + gMenuTop++; gMenuBottom++; gMenuStart++; gMenuEnd++; - draw.f.selectionDown = 1; - } + draw.f.selectionDown = 1; + } - if ( draw.f.scrollDown ) - { - scollPage(0, gMenuRow, 40, gMenuRow + gMenuHeight - 1, 0x07, 1, -1); - gMenuTop--; gMenuBottom--; - gMenuStart--; gMenuEnd--; - draw.f.selectionUp = 1; - } + if ( draw.f.scrollDown ) + { + scollPage(0, gMenuRow, 40, gMenuRow + gMenuHeight - 1, 0x07, 1, -1); + gMenuTop--; gMenuBottom--; + gMenuStart--; gMenuEnd--; + draw.f.selectionUp = 1; + } - if ( draw.f.selectionUp || draw.f.selectionDown ) - { - + if ( draw.f.selectionUp || draw.f.selectionDown ) + { CursorState cursorState; // Set cursor at current position, and clear inverse video. - + if( bootArgs->Video.v_display == VGA_TEXT_MODE ) { changeCursor( 0, gMenuRow + gMenuSelection - gMenuTop, kCursorTypeHidden, &cursorState ); @@ -620,32 +624,35 @@ gMenuStart--; gMenuEnd--; } - - } else { - gMenuSelection++; - if(( gMenuSelection - ( gui.maxdevices - 1) - gMenuStart) > 0 ) + + } + else { - gMenuStart++; - gMenuEnd++; + gMenuSelection++; + if(( gMenuSelection - ( gui.maxdevices - 1) - gMenuStart) > 0 ) + { + gMenuStart++; + gMenuEnd++; + } } - } - if( bootArgs->Video.v_display == VGA_TEXT_MODE ) - { - moveCursor( 0, gMenuRow + gMenuSelection - gMenuTop ); - printMenuItem( &gMenuItems[gMenuSelection], 1 ); - restoreCursor( &cursorState ); + if( bootArgs->Video.v_display == VGA_TEXT_MODE ) + { + moveCursor( 0, gMenuRow + gMenuSelection - gMenuTop ); + printMenuItem( &gMenuItems[gMenuSelection], 1 ); + restoreCursor( &cursorState ); - } else + } + else + { + drawDeviceList (gMenuStart, gMenuEnd, gMenuSelection); + } + } - drawDeviceList (gMenuStart, gMenuEnd, gMenuSelection); - + *paramPtr = gMenuItems[gMenuSelection].param; + moved = 1; } - *paramPtr = gMenuItems[gMenuSelection].param; - moved = 1; - } - return moved; } @@ -760,7 +767,8 @@ void lspci(void) { - if (bootArgs->Video.v_display == VGA_TEXT_MODE) { + if (bootArgs->Video.v_display == VGA_TEXT_MODE) + { setActiveDisplayPage(1); clearScreenRows(0, 24); setCursorPosition(0, 0, 1); @@ -770,7 +778,8 @@ pause(); - if (bootArgs->Video.v_display == VGA_TEXT_MODE) { + if (bootArgs->Video.v_display == VGA_TEXT_MODE) + { setActiveDisplayPage(0); } } @@ -1166,6 +1175,7 @@ clearScreenRows(kMenuTopRow, kScreenLastRow); changeCursor(0, kMenuTopRow, kCursorTypeUnderline, 0); } + shouldboot = false; gui.menu.draw = false; if (menuItems) { @@ -1210,6 +1220,7 @@ *argP += cnt; *argP[0] = ' '; (*argP)++; + *cntRemainingP -= len; return true; @@ -1253,15 +1264,15 @@ int processBootOptions() { - const char *cp = gBootArgs; - const char *val = 0; - const char *kernel; - int cnt; - int userCnt; - int cntRemaining; - char *argP; - char *configKernelFlags; - char *valueBuffer; + const char *cp = gBootArgs; + const char *val = 0; + const char *kernel; + int cnt; + int userCnt; + int cntRemaining; + char *argP; + char *configKernelFlags; + char *valueBuffer; valueBuffer = malloc(VALUE_SIZE); Index: branches/zenith432/i386/boot2/graphic_utils.c =================================================================== --- branches/zenith432/i386/boot2/graphic_utils.c (revision 2593) +++ branches/zenith432/i386/boot2/graphic_utils.c (revision 2594) @@ -78,7 +78,8 @@ uint32_t x; register uint8_t tempB; - for (x = 0; x < (p->height) * (p->width) ; x++) { + for (x = 0; x < (p->height) * (p->width) ; x++) + { tempB = (p->pixels[x]).ch.b; (p->pixels[x]).ch.b = (p->pixels[x]).ch.r; (p->pixels[x]).ch.r = tempB; Index: branches/zenith432/i386/modules/Resolution/Resolution.c =================================================================== --- branches/zenith432/i386/modules/Resolution/Resolution.c (revision 2593) +++ branches/zenith432/i386/modules/Resolution/Resolution.c (revision 2594) @@ -9,11 +9,11 @@ void Resolution_start(); void Resolution_start() { - UInt32 bp = 0; - UInt32 x, y; + UInt32 bp = 0; + UInt32 x, y; patchVideoBios(); - getResolution(&x, &y, &bp); - gui.screen.width = x; - gui.screen.height = y; + getResolution(&x, &y, &bp); + gui.screen.width = x; + gui.screen.height = y; } Index: branches/zenith432/i386/modules/Keylayout/layouts/cham-mklayout.c =================================================================== --- branches/zenith432/i386/modules/Keylayout/layouts/cham-mklayout.c (revision 2593) +++ branches/zenith432/i386/modules/Keylayout/layouts/cham-mklayout.c (revision 2594) @@ -365,9 +365,9 @@ struct keyboard_layout* new_layout = create_keylayout(in); if (new_layout) { write_layout(new_layout, out); - free(new_layout); - new_layout = NULL; - } + free(new_layout); + new_layout = NULL; + } fclose(out); fclose(in); Index: branches/zenith432/i386/modules/Keylayout/Keylayout.c =================================================================== --- branches/zenith432/i386/modules/Keylayout/Keylayout.c (revision 2593) +++ branches/zenith432/i386/modules/Keylayout/Keylayout.c (revision 2594) @@ -13,9 +13,20 @@ #include "Keylayout.h" #include "bootstruct.h" +#ifndef DEBUG_KLAYOUT +#define DEBUG_KLAYOUT 0 +#endif + +#if DEBUG_KLAYOUT +#define DBG(x...) printf(x) +#else +#define DBG(x...) +#endif + #define kKeyboardLayout "KeyboardLayout" struct keyboard_layout *current_layout = NULL; +int getchar_replacement(); int getchar_replacement() { int code = bgetc(); @@ -50,46 +61,57 @@ return (code); } -static uint32_t load_keyboard_layout_file(const char *filename) { +static uint32_t load_keyboard_layout_file(const char *filename) +{ int fd; char magic[KEYBOARD_LAYOUTS_MAGIC_SIZE]; uint32_t version; - if ((fd = open_bvdev("bt(0,0)", filename, 0)) < 0) { + if ((fd = open_bvdev("bt(0,0)", filename, 0)) < 0) + { goto fail; // fail } - if (read(fd, magic, sizeof(magic)) != sizeof(magic)) { + if (read(fd, magic, sizeof(magic)) != sizeof(magic)) + { printf("Can't find magic in keyboard layout file: %s\n", filename); goto fail; } - if (memcmp (magic, KEYBOARD_LAYOUTS_MAGIC, KEYBOARD_LAYOUTS_MAGIC_SIZE) != 0) { + if (memcmp (magic, KEYBOARD_LAYOUTS_MAGIC, KEYBOARD_LAYOUTS_MAGIC_SIZE) != 0) + { printf("Invalid magic code in keyboard layout file: %s\n", filename); goto fail; - } + } - if (read(fd, (char*) &version, sizeof(version)) != sizeof(version)) { + if (read(fd, (char*) &version, sizeof(version)) != sizeof(version)) + { printf("Can't get version of keyboard layout file: %s\n", filename); goto fail; } - if (version != KEYBOARD_LAYOUTS_VERSION) { + if (version != KEYBOARD_LAYOUTS_VERSION) + { verbose("Bad version for keyboard layout file %s expected v%d found v%d\n", - filename, KEYBOARD_LAYOUTS_VERSION, version); + filename, KEYBOARD_LAYOUTS_VERSION, version); goto fail; } if (current_layout) + { free(current_layout); - + } + current_layout = malloc(sizeof(*current_layout)); if (!current_layout) + { goto fail; + } b_lseek(fd, KEYBOARD_LAYOUTS_MAP_OFFSET, 0); - if (read(fd, (char*) current_layout, sizeof(*current_layout)) != sizeof(*current_layout)) { + if (read(fd, (char*) current_layout, sizeof(*current_layout)) != sizeof(*current_layout)) + { printf("Wrong keyboard layout file %s size\n", filename); goto fail; } @@ -97,10 +119,11 @@ close(fd); return 1; - - fail: + +fail: - if (current_layout) { + if (current_layout) + { free(current_layout); current_layout = NULL; } @@ -113,17 +136,20 @@ const char *val; int len; - if (getValueForKey("KeyLayout", &val, &len, &bootInfo->chameleonConfig)) { + if (getValueForKey("KeyLayout", &val, &len, &bootInfo->chameleonConfig)) + { sprintf(layoutPath, "/Extra/Keymaps/%s", val); // Add the extension if needed if (len <= 4 || strcmp(val+len-4,".lyt") != 0) strncat(layoutPath, ".lyt", sizeof(layoutPath) - strlen(layoutPath) - 1); - if (!load_keyboard_layout_file(layoutPath)) { - printf("Can't load %s keyboard layout file. Keylayout will not be used !\n", - layoutPath); + if (!load_keyboard_layout_file(layoutPath)) + { + DBG("Can't load %s keyboard layout file. Keylayout will not be used !\n", layoutPath); sleep(2); - } else if (!replace_function("_getchar", &getchar_replacement)) { + } + else if (!replace_function("_getchar", &getchar_replacement)) + { printf("Can't replace function getchar: Keylayout module can't be used !\n"); sleep(2); } Index: branches/zenith432/i386/modules/AcpiCodec/acpi_codec.c =================================================================== --- branches/zenith432/i386/modules/AcpiCodec/acpi_codec.c (revision 2593) +++ branches/zenith432/i386/modules/AcpiCodec/acpi_codec.c (revision 2594) @@ -1005,21 +1005,22 @@ boolean_t fine_grain_clock_mod = 0; #if BUILD_ACPI_TSS || pstate_power_support - if (Platform.CPU.CPUID[CPUID_0][0] >= 0x5) { + if (Platform.CPU.CPUID[CPUID_0][0] >= 0x5) { /* * Extract the Monitor/Mwait Leaf info: */ sub_Cstates = Platform.CPU.CPUID[CPUID_5][3]; extensions = Platform.CPU.CPUID[CPUID_5][2]; } - - if (Platform.CPU.CPUID[CPUID_0][0] >= 6) { + + if (Platform.CPU.CPUID[CPUID_0][0] >= 6) + { dynamic_acceleration = bitfield(Platform.CPU.CPUID[CPUID_6][0], 1, 1); // "Dynamic Acceleration Technology (Turbo Mode)" invariant_APIC_timer = bitfield(Platform.CPU.CPUID[CPUID_6][0], 2, 2); // "Invariant APIC Timer" fine_grain_clock_mod = bitfield(Platform.CPU.CPUID[CPUID_6][0], 4, 4); } - cpu->turbo_available = (U32)dynamic_acceleration; - + cpu->turbo_available = (U32)dynamic_acceleration; + { U32 temp32 = 0; U64 temp64= 0; @@ -1027,18 +1028,18 @@ if (getIntForKey("TDP", &tdp, &bootInfo->chameleonConfig)) { temp32 = (U32) (tdp*8) ; - + int tdc; if (getIntForKey("TDC", &tdc, &bootInfo->chameleonConfig)) { - temp32 = (U32) (temp32) | tdc<<16 ; - + temp32 = (U32) (temp32) | tdc<<16 ; + } else if (tdp) { temp32 = (U32) (temp32) | ((tdp)*8)<<16 ; } - + } else if (!is_sandybridge() && !is_jaketown()) { @@ -1055,16 +1056,17 @@ // in your boot.plist temp32 = (U32)0x02a802f8; } - + } - if (temp32) { + if (temp32) + { cpu->tdp_limit = ( temp32 & 0x7fff ); cpu->tdc_limit = ( (temp32 >> 16) & 0x7fff ); } } - + #endif - + switch (Platform.CPU.Family) { case 0x06: @@ -1077,26 +1079,26 @@ case CPUID_MODEL_PENRYN: // Penryn case CPUID_MODEL_ATOM: // Intel Atom (45nm) { - + cpu->core_c1_supported = ((sub_Cstates >> 4) & 0xf) ? 1 : 0; cpu->core_c4_supported = ((sub_Cstates >> 16) & 0xf) ? 1 : 0; - + if (Platform.CPU.Model == CPUID_MODEL_ATOM) { cpu->core_c2_supported = cpu->core_c3_supported = ((sub_Cstates >> 8) & 0xf) ? 1 : 0; cpu->core_c6_supported = ((sub_Cstates >> 12) & 0xf) ? 1 : 0; - + } else { cpu->core_c3_supported = ((sub_Cstates >> 12) & 0xf) ? 1 : 0; cpu->core_c2_supported = ((sub_Cstates >> 8) & 0xf) ? 1 : 0; cpu->core_c6_supported = 0; - + } - + cpu->core_c7_supported = 0; - + #if BETA GetMaxRatio(&cpu->max_ratio_as_mfg); U64 msr = rdmsr64(MSR_IA32_PERF_STATUS); @@ -1104,7 +1106,7 @@ U16 idhi = (msr >> 32) & 0xffff; cpu->min_ratio = (U32) (idlo >> 8) & 0xff; cpu->max_ratio_as_cfg = (U32) (idhi >> 8) & 0xff; - + #else if (Platform.CPU.MaxCoef) { @@ -1118,7 +1120,7 @@ } } #endif - + break; } case CPUID_MODEL_FIELDS: @@ -1131,25 +1133,25 @@ case CPUID_MODEL_SANDYBRIDGE: case CPUID_MODEL_JAKETOWN: { - + cpu->core_c1_supported = ((sub_Cstates >> 4) & 0xf) ? 1 : 0; cpu->core_c3_supported = ((sub_Cstates >> 8) & 0xf) ? 1 : 0; cpu->core_c6_supported = ((sub_Cstates >> 12) & 0xf) ? 1 : 0; cpu->core_c7_supported = ((sub_Cstates >> 16) & 0xf) ? 1 : 0; cpu->core_c2_supported = 0; cpu->core_c4_supported = 0; - + GetMaxRatio(&cpu->max_ratio_as_mfg); U64 platform_info = rdmsr64(MSR_PLATFORM_INFO); cpu->max_ratio_as_cfg = (U32) ((U32)platform_info >> 8) & 0xff; cpu->min_ratio = (U32) ((platform_info >> 40) & 0xff); - + cpu->tdc_tdp_limits_for_turbo_flag = (platform_info & (1ULL << 29)) ? 1 : 0; cpu->ratio_limits_for_turbo_flag = (platform_info & (1ULL << 28)) ? 1 : 0; cpu->xe_available = cpu->tdc_tdp_limits_for_turbo_flag | cpu->ratio_limits_for_turbo_flag; - - + + if (is_sandybridge() || is_jaketown()) { cpu->package_power_limit = rdmsr64(MSR_PKG_RAPL_POWER_LIMIT); @@ -1166,11 +1168,11 @@ default: break; } - + cpu->mwait_supported = (extensions & (1UL << 0)) ? 1 : 0; + + cpu->invariant_apic_timer_flag = (U32)invariant_APIC_timer; - cpu->invariant_apic_timer_flag = (U32)invariant_APIC_timer; - #if DEBUG_ACPI printf("CPU INFO : \n"); #if BETA @@ -1178,29 +1180,28 @@ #endif printf("max_ratio_as_cfg : %d\n", cpu->max_ratio_as_cfg); printf("max_ratio_as_mfg : %d\n", cpu->max_ratio_as_mfg); - + printf("turbo_available : %d\n",cpu->turbo_available); - + printf("core_c1_supported : %d\n",cpu->core_c1_supported); printf("core_c2_supported : %d\n",cpu->core_c1_supported); printf("core_c3_supported : %d\n",cpu->core_c3_supported); printf("core_c6_supported : %d\n",cpu->core_c6_supported); printf("core_c7_supported : %d\n",cpu->core_c7_supported); printf("mwait_supported : %d\n",cpu->mwait_supported); - + #if BUILD_ACPI_TSS || pstate_power_support if (is_sandybridge() || is_jaketown()) { - + printf("package_power_limit : %d\n",cpu->package_power_limit); printf("package_power_sku_unit : %d\n",cpu->package_power_sku_unit); - + } #endif - + DBG("invariant_apic_timer_flag : %d\n",cpu->invariant_apic_timer_flag); - - + #endif } @@ -1311,19 +1312,18 @@ //----------------------------------------------------------------------------- static U32 BuildPstateInfo(CPU_DETAILS * cpu) { - struct p_state p_states[32]; U8 p_states_count = 0; - - if (!cpu) - { - return (0); - } - + + if (!cpu) { + return (0); + } + + { #if UNUSED struct p_state initial; -#endif +#endif struct p_state maximum, minimum; // Retrieving P-States, ported from code by superhai (c) switch (Platform.CPU.Family) @@ -4330,7 +4330,7 @@ { DropTables_p = XMLCastDict(XMLGetProperty(bootInfo->chameleonConfig.dictionary, (const char*)"ACPIDropTables")); if (DropTables_p) DropTables_tag_count = XMLTagCount(DropTables_p) ; - } + } U32 new_table = 0ul; U8 new_table_index = 0, table_added = 0; Index: branches/zenith432/i386/modules/Makefile =================================================================== --- branches/zenith432/i386/modules/Makefile (revision 2593) +++ branches/zenith432/i386/modules/Makefile (revision 2594) @@ -57,6 +57,10 @@ #SUBDIRS += HDAEnabler #endif +#ifdef CONFIG_GRAPHICSENABLER_MODULE +#SUBDIRS += GraphicsEnabler +#endif + CFLAGS= -O3 $(MORECPP) -arch i386 -g -static DEFINES= CONFIG = hd Index: branches/zenith432/i386/libsa/libsa.h =================================================================== --- branches/zenith432/i386/libsa/libsa.h (revision 2593) +++ branches/zenith432/i386/libsa/libsa.h (revision 2594) @@ -2,7 +2,7 @@ * Copyright (c) 1999-2003 Apple Computer, Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ - * + * * Portions Copyright (c) 1999-2003 Apple Computer, Inc. All Rights * Reserved. This file contains Original Code and/or Modifications of * Original Code as defined in and that are subject to the Apple Public @@ -10,7 +10,7 @@ * except in compliance with the License. Please obtain a copy of the * License at http://www.apple.com/publicsource 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, @@ -18,7 +18,7 @@ * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the * License for the specific language governing rights and limitations * under the License. - * + * * @APPLE_LICENSE_HEADER_END@ */ @@ -88,71 +88,71 @@ #error bzero is defined. #endif -extern void * memset(void * dst, int c, size_t n); -extern void * memcpy(void * dst, const void * src, size_t len); -extern int memcmp(const void * p1, const void * p2, size_t len); -extern int strcmp(const char * s1, const char * s2); -extern int strncmp(const char * s1, const char * s2, size_t n); -extern char * strcpy(char * s1, const char * s2); -extern char * stpcpy(char * s1, const char * s2); -extern char * strncpy(char * s1, const char * s2, size_t n); -extern char * strpcpy(char * s1, const char * s2, size_t n); -extern size_t strlcpy(char * s1, const char * s2, size_t n); -extern char * strstr(const char *in, const char *str); -extern int atoi(const char * str); -extern int ptol(const char * str); -extern size_t strlen(const char * str); -extern char * strcat(char * s1, const char * s2); -extern char * strncat(char * s1, const char * s2, size_t n); -extern char * strdup(const char *s1); +extern void *memset(void * dst, int c, size_t n); +extern void *memcpy(void * dst, const void * src, size_t len); +extern int memcmp(const void * p1, const void * p2, size_t len); +extern int strcmp(const char * s1, const char * s2); +extern int strncmp(const char * s1, const char * s2, size_t n); +extern char *strcpy(char * s1, const char * s2); +extern char *stpcpy(char * s1, const char * s2); +extern char *strncpy(char * s1, const char * s2, size_t n); +extern char *strpcpy(char * s1, const char * s2, size_t n); +extern size_t strlcpy(char * s1, const char * s2, size_t n); +extern char *strstr(const char *in, const char *str); +extern int atoi(const char * str); +extern int ptol(const char * str); +extern size_t strlen(const char * str); +extern char *strcat(char * s1, const char * s2); +extern char *strncat(char * s1, const char * s2, size_t n); +extern char *strdup(const char *s1); #if STRNCASECMP extern int strncasecmp(const char *s1, const char *s2, size_t n); #endif -extern char * strchr(const char *str, int c); -extern char * strbreak(const char *str, char **next, long *len); +extern char *strchr(const char *str, int c); +extern char *strbreak(const char *str, char **next, long *len); extern uint8_t checksum8( void * start, unsigned int length ); /* * error.c */ -extern int errno; -extern char * strerror(int errnum); +extern int errno; +extern char *strerror(int errnum); /* * strtol.c */ -extern long strtol(const char * nptr, char ** endptr, int base); -extern unsigned long strtoul(const char * nptr, char ** endptr, int base); -extern unsigned long long strtouq(const char *nptr, char ** endptr, int base); +extern long strtol(const char *nptr, char **endptr, int base); +extern unsigned long strtoul(const char *nptr, char **endptr, int base); +extern unsigned long long strtouq(const char *nptr, char **endptr, int base); /* * prf.c */ -extern void prf(const char * fmt, va_list ap, int (*putfn_p)(), void * putfn_arg); +extern void prf(const char *fmt, va_list ap, int (*putfn_p)(), void *putfn_arg); /* * printf.c */ -extern int sprintf(char *s, const char * format, ...); -extern int snprintf(char *s, size_t size, const char * format, ...); -extern int slvprintf(char * buffer, int len, const char * fmt, va_list arg); +extern int sprintf(char *s, const char *format, ...); +extern int snprintf(char *s, size_t size, const char *format, ...); +extern int slvprintf(char *buffer, int len, const char *fmt, va_list arg); /* * zalloc.c */ #define malloc(size) safe_malloc(size, __FILE__, __LINE__) -extern void malloc_init(char * start, int size, int nodes, void (*malloc_error)(char *, size_t, const char *, int)); -extern void * safe_malloc(size_t size,const char *file, int line); -extern void free(void * start); -extern void * realloc(void * ptr, size_t size); +extern void malloc_init(char *start, int size, int nodes, void (*malloc_error)(char *, size_t, const char *, int)); +extern void *safe_malloc(size_t size,const char *file, int line); +extern void free(void *start); +extern void *realloc(void *ptr, size_t size); /* * getsegbyname.c */ -extern struct segment_command * getsegbynamefromheader(struct mach_header * mhp, char * segname); +extern struct segment_command *getsegbynamefromheader(struct mach_header *mhp, char *segname); /* * interrupts.c Index: branches/zenith432/i386/libsa/string.c =================================================================== --- branches/zenith432/i386/libsa/string.c (revision 2593) +++ branches/zenith432/i386/libsa/string.c (revision 2594) @@ -25,25 +25,25 @@ #include "libsa.h" -void * memset(void * dst, int val, size_t len) +void *memset(void * dst, int val, size_t len) { - asm volatile ( "rep; stosb" - : "=c" (len), "=D" (dst) - : "0" (len), "1" (dst), "a" (val) - : "memory" ); + asm volatile ( "rep; stosb" + : "=c" (len), "=D" (dst) + : "0" (len), "1" (dst), "a" (val) + : "memory" ); - return dst; + return dst; } #if 0 void * memcpy(void * dst, const void * src, size_t len) { - asm volatile ( "rep; movsb" - : "=c" (len), "=D" (dst), "=S" (src) - : "0" (len), "1" (dst), "2" (src) - : "memory" ); + asm volatile ( "rep; movsb" + : "=c" (len), "=D" (dst), "=S" (src) + : "0" (len), "1" (dst), "2" (src) + : "memory" ); - return dst; + return dst; } void bcopy(const void * src, void * dst, size_t len) @@ -53,53 +53,53 @@ void bzero(void * dst, size_t len) { - memset(dst, 0, len); + memset(dst, 0, len); } #else void * memcpy(void * dst, const void * src, size_t len) { - asm volatile ( "cld \n\t" - "movl %%ecx, %%edx \n\t" - "shrl $2, %%ecx \n\t" - "rep; movsl \n\t" - "movl %%edx, %%ecx \n\t" - "andl $3, %%ecx \n\t" - "rep; movsb \n\t" - : "=D" (dst) - : "c" (len), "D" (dst), "S" (src) - : "memory", "%edx" ); + asm volatile ( "cld \n\t" + "movl %%ecx, %%edx \n\t" + "shrl $2, %%ecx \n\t" + "rep; movsl \n\t" + "movl %%edx, %%ecx \n\t" + "andl $3, %%ecx \n\t" + "rep; movsb \n\t" + : "=D" (dst) + : "c" (len), "D" (dst), "S" (src) + : "memory", "%edx" ); - return dst; + return dst; } void bcopy(const void * src, void * dst, size_t len) { - asm volatile ( "cld \n\t" - "movl %%ecx, %%edx \n\t" - "shrl $2, %%ecx \n\t" - "rep; movsl \n\t" - "movl %%edx, %%ecx \n\t" - "andl $3, %%ecx \n\t" - "rep; movsb \n\t" - : - : "c" (len), "D" (dst), "S" (src) - : "memory", "%edx" ); + asm volatile ( "cld \n\t" + "movl %%ecx, %%edx \n\t" + "shrl $2, %%ecx \n\t" + "rep; movsl \n\t" + "movl %%edx, %%ecx \n\t" + "andl $3, %%ecx \n\t" + "rep; movsb \n\t" + : + : "c" (len), "D" (dst), "S" (src) + : "memory", "%edx" ); } void bzero(void * dst, size_t len) { - asm volatile ( "xorl %%eax, %%eax \n\t" - "cld \n\t" - "movl %%ecx, %%edx \n\t" - "shrl $2, %%ecx \n\t" - "rep; stosl \n\t" - "movl %%edx, %%ecx \n\t" - "andl $3, %%ecx \n\t" - "rep; stosb \n\t" - : - : "c" (len), "D" (dst) - : "memory", "%eax" ); + asm volatile ( "xorl %%eax, %%eax \n\t" + "cld \n\t" + "movl %%ecx, %%edx \n\t" + "shrl $2, %%ecx \n\t" + "rep; stosl \n\t" + "movl %%edx, %%ecx \n\t" + "andl $3, %%ecx \n\t" + "rep; stosb \n\t" + : + : "c" (len), "D" (dst) + : "memory", "%eax" ); } #endif @@ -157,8 +157,7 @@ return 0; } -char * -strcpy(char * s1, const char * s2) +char *strcpy(char *s1, const char *s2) { register char *ret = s1; while ((*s1++ = *s2++)) @@ -166,8 +165,7 @@ return ret; } -char * -stpcpy(char * s1, const char * s2) +char *stpcpy(char *s1, const char *s2) { while ((*s1++ = *s2++)) { @@ -176,8 +174,7 @@ return --s1; } -char * -strncpy(char * s1, const char * s2, size_t n) +char *strncpy(char *s1, const char *s2, size_t n) { register char *ret = s1; while (n && (*s1++ = *s2++)) @@ -189,8 +186,7 @@ return ret; } -char * -stpncpy(char * s1, const char * s2, size_t n) +char *stpncpy(char *s1, const char *s2, size_t n) { while (n && (*s1++ = *s2++)) --n; @@ -201,8 +197,7 @@ return s1; } -char * -strstr(const char *in, const char *str) +char *strstr(const char *in, const char *str) { char c; size_t len; @@ -225,8 +220,7 @@ return (char *) (in - 1); } -int -ptol(const char *str) +int ptol(const char *str) { register int c = *str; @@ -238,8 +232,7 @@ return c; } -int -atoi(const char *str) +int atoi(const char *str) { register int sum = 0; while (*str == ' ' || *str == '\t') @@ -287,7 +280,7 @@ } #endif -char* strchr(const char *str, int c) +char *strchr(const char *str, int c) { do { @@ -297,9 +290,9 @@ while(*(str++)); return 0; -} - -char* strbreak(const char *str, char **next, long *len) +} + +char *strbreak(const char *str, char **next, long *len) { char *start = (char*)str, *end; bool quoted = false; @@ -337,13 +330,14 @@ } /* COPYRIGHT NOTICE: checksum8 from AppleSMBIOS */ -uint8_t checksum8( void * start, unsigned int length ) +uint8_t checksum8( void *start, unsigned int length ) { uint8_t csum = 0; uint8_t * cp = (uint8_t *) start; unsigned int i; - for ( i = 0; i < length; i++) { + for ( i = 0; i < length; i++) + { csum += *cp++; } return csum; Index: branches/zenith432/i386/util/dyldsymboltool.c =================================================================== --- branches/zenith432/i386/util/dyldsymboltool.c (revision 2593) +++ branches/zenith432/i386/util/dyldsymboltool.c (revision 2594) @@ -135,9 +135,9 @@ dylib.dylib_info.cmd = LC_ID_DYLIB; dylib.dylib_info.cmdsize = sizeof(struct dylib_command) + sizeof(dylib.module_name); // todo: verify dylib.dylib_info.dylib.name.offset = sizeof(struct dylib_command); - dylib.dylib_info.dylib.timestamp = 0; // TODO: populate with time - dylib.dylib_info.dylib.current_version = 0; // TODO - dylib.dylib_info.dylib.compatibility_version = 0; // TODO + dylib.dylib_info.dylib.timestamp = 0; // TODO: populate with time + dylib.dylib_info.dylib.current_version = 0; // TODO + dylib.dylib_info.dylib.compatibility_version = 0; // TODO //int offset = dylib.dylib_info.cmdsize%4 ? 4 - (dylib.dylib_info.cmdsize % 4) : 0; Index: branches/zenith432/i386/util/segsize.c =================================================================== --- branches/zenith432/i386/util/segsize.c (revision 2593) +++ branches/zenith432/i386/util/segsize.c (revision 2594) @@ -103,7 +103,7 @@ // bool isDATA; // unsigned vmsize; -#define lcp ((struct load_command *)cp) +#define lcp ((struct load_command *)cp) switch(swap(lcp->cmd)) { case LC_SEGMENT: Index: branches/zenith432/package/Scripts.templates/AddOption/postinstall =================================================================== --- branches/zenith432/package/Scripts.templates/AddOption/postinstall (revision 2593) +++ branches/zenith432/package/Scripts.templates/AddOption/postinstall (revision 2594) @@ -3,9 +3,9 @@ set -u configFile='/private/tmp/InstallConfig.plist' -v_mntptDev=$( /usr/libexec/plistbuddy -c "Print :ramdisk" ${configFile} | sed -e 's/[[:blank:]]*//g' ) -v_mntpt=$( LC_ALL=C diskutil info ${v_mntptDev} | grep -i 'mount point' | awk '{$1=$2=""; print $0}' \ - | sed -e 's/^[ \t]*//' ) +v_mntptDev=$( /usr/libexec/PlistBuddy -c "Print :ramdisk" ${configFile} ) +v_mntpt=$( LC_ALL=C diskutil info ${v_mntptDev} | grep -i 'mount point' | awk '{$1=$2=""; print $0}' | \ + sed -e 's/^ *//' | sed -e 's/ *$//' ) key="@optionKey@" value="@optionValue@" @@ -33,10 +33,10 @@ case "$type" in bool|text) - /usr/libexec/plistbuddy -c "Add :${key} string ${value}" "$bootPListFile" + /usr/libexec/PlistBuddy -c "Add :${key} string ${value}" "$bootPListFile" ;; list) - current_values=$( /usr/libexec/plistbuddy -c "Print :${key}" \ + current_values=$( /usr/libexec/PlistBuddy -c "Print :${key}" \ "$bootPListFile" 2>/dev/null ) result=$? current_values="${current_values// /\\ }" # Escape spaces @@ -49,12 +49,12 @@ else new_values="${current_values}\ ${value}" fi - /usr/libexec/plistbuddy -c "Set :${key} ${new_values}" \ + /usr/libexec/PlistBuddy -c "Set :${key} ${new_values}" \ "$bootPListFile" else # Create a new option new_values="${value}" - /usr/libexec/plistbuddy -c "Add :${key} string ${new_values}" \ + /usr/libexec/PlistBuddy -c "Add :${key} string ${new_values}" \ "$bootPListFile" fi ;; Index: branches/zenith432/package/Scripts.templates/Post/postinstall =================================================================== --- branches/zenith432/package/Scripts.templates/Post/postinstall (revision 2593) +++ branches/zenith432/package/Scripts.templates/Post/postinstall (revision 2594) @@ -5,6 +5,7 @@ # $3 = Installation volume (mountpoint) to receive the payload # $4 = Root directory for the system +logName="@LOG_FILENAME@" mainLine="==============================================================================" subLine="------------------------------------------------------------------------------" @@ -19,33 +20,33 @@ configFile='/private/tmp/InstallConfig.plist' v_mntptDev=$( /usr/libexec/PlistBuddy -c "Print :ramdisk" ${configFile} ) -v_mntpt=$( LC_ALL=C diskutil info ${v_mntptDev} | grep -i 'mount point' | awk '{$1=$2=""; print $0}' \ - | sed -e 's/^[ \t]*//' ) +v_mntpt=$( LC_ALL=C diskutil info ${v_mntptDev} | grep -i 'mount point' | awk '{$1=$2=""; print $0}' | \ + sed -e 's/^ *//' | sed -e 's/ *$//') targetDevice=$( /usr/libexec/PlistBuddy -c "Print :targetdev" ${configFile} ) -choicedVolume=$( LC_ALL=C diskutil info ${targetDevice} | grep -i 'mount point' | awk '{$1=$2=""; print $0}' \ - | sed -e 's/^[ \t]*//' ) +choicedVolume=$( LC_ALL=C diskutil info ${targetDevice} | grep -i 'mount point' | awk '{$1=$2=""; print $0}' | \ + sed -e 's/^ *//' | sed -e 's/ *$//' ) backupRootDir="${targetVolume}/Chameleon.Backups" backupDir=$( /usr/libexec/PlistBuddy -c "Print :backupDir" ${configFile} ) # Check target exists -if [ ! -d "${targetVolume}" ]; then - echo "Target volume does not exist !" >&2 +if [ ! -d "${v_mntpt}" ]; then + echo "Ram disk volume does not exist !" exit 1 fi -if [ ! -d "${v_mntpt}" ]; then - echo "Ram disk volume does not exist !" >&2 + +exec > >(tee -a "${v_mntpt}/${logName}") 2>&1 + +if [ ! -d "${targetVolume}" ]; then + echo "Target volume does not exist !" exit 1 fi + if [ ! -d "${choicedVolume}" ]; then - echo "${choicedVolume} volume does not exist !" >&2 + echo "${choicedVolume} volume does not exist !" exit 1 fi -logName="@LOG_FILENAME@" - -exec > >(tee -a "${v_mntpt}/${logName}") 2>&1 - echo "$mainLine" echo "Running Post postinstall script" echo "Target volume = ${choicedVolume}" @@ -55,10 +56,6 @@ echo "Moving Extra folder to ${choicedVolume}" cp -R "${v_mntpt}/Extra" "${choicedVolume}"/ -echo "NOTE: any Themes or modules you have must be there since this now is the boot partition," -echo " ACPI tables, SMBios.plist and the org.chameleon.Boot.plist (with custom settings" -echo " for the target OSX must be in each partition that contanin it.)" - echo "$subLine" echo "Post postinstall script complete" echo "$mainLine" @@ -79,6 +76,11 @@ # copying the installer log inside the Extra folder if [[ $( /usr/libexec/PlistBuddy -c "Print bootloader" ${configFile} ) == "true" ]];then # if we have installed the bootloader, this is a new log + echo "NOTE: any Themes or modules you have must be there since this now" + echo " is the boot partition. ACPI tables, SMBios.plist and the" + echo " org.chameleon.Boot.plist (with custom settings for the target" + echo " OSX must be in each partition that contain it.)" + echo "$mainLine" cat "${v_mntpt}/${logName}" > "${choicedVolume}/Extra/${logName}" else # ..otherwise adding the new log to the existing one (if exist) Index: branches/zenith432/package/Scripts.templates/Pre/preinstall =================================================================== --- branches/zenith432/package/Scripts.templates/Pre/preinstall (revision 2593) +++ branches/zenith432/package/Scripts.templates/Pre/preinstall (revision 2594) @@ -29,8 +29,8 @@ } RAM_DISK() { - if [ $( df | awk '{$1=$2=$3=$4=$5=$6=$7=$8=""; print $0}' | sed -e 's/^[ \t]*//' | \ - grep -x "${v_mntpt}" ) ]; then + if [ $( df | awk '{$1=$2=$3=$4=$5=$6=$7=$8=""; print $0}' | \ + sed -e 's/^ *//' | sed -e 's/ *$//' | grep -x "${v_mntpt}" ) ]; then devToUmount=$( LC_ALL=C diskutil info "${v_mntpt}" | grep -i 'Device Node:' | awk '{print $3}' ) UMOUNT_VDISK $devToUmount fi @@ -45,6 +45,7 @@ exit 1 fi + dev=$( echo "${dev}" | tr -d " \t\n" ) rm -f $configFile # adding the Ram disk device to InstallConfig.plist to be shared with other packages /usr/libexec/PlistBuddy -c "Add :ramdisk string ${dev}" $configFile @@ -53,8 +54,8 @@ RAM_DISK # ensure that ram disk has "/Volumes/BOOTRAMDISK" mount point -v_mntpt=$( LC_ALL=C diskutil info ${dev} | grep -i 'mount point' | awk '{$1=$2=""; print $0}' \ - | sed -e 's/^[ \t]*//' ) +v_mntpt=$( LC_ALL=C diskutil info ${dev} | grep -i 'mount point' | awk '{$1=$2=""; print $0}' | \ + sed -e 's/^ *//' | sed -e 's/ *$//' ) if [ ! -d "${v_mntpt}" ]; then echo "Ram Disk not found!" exit @@ -64,6 +65,9 @@ exec > >(tee -a "${v_mntpt}/${logName}") 2>&1 echo "$mainLine" +echo "SYSTEM INFO:" +sw_vers +echo "$mainLine" echo "Pre-Install Script" echo "$subLine" Index: branches/zenith432/package/Scripts.templates/InstallTheme/postinstall =================================================================== --- branches/zenith432/package/Scripts.templates/InstallTheme/postinstall (revision 2593) +++ branches/zenith432/package/Scripts.templates/InstallTheme/postinstall (revision 2594) @@ -3,10 +3,9 @@ set -u configFile='/private/tmp/InstallConfig.plist' -v_mntptDev=$( /usr/libexec/PlistBuddy -c "Print :ramdisk" ${configFile} | sed -e 's/[[:blank:]]*//g' ) -v_mntpt=$( LC_ALL=C diskutil info ${v_mntptDev} | grep -i 'mount point' | awk '{$1=$2=""; print $0}' \ - | sed -e 's/^[ \t]*//' ) - +v_mntptDev=$( /usr/libexec/PlistBuddy -c "Print :ramdisk" ${configFile} ) +v_mntpt=$( LC_ALL=C diskutil info ${v_mntptDev} | grep -i 'mount point' | awk '{$1=$2=""; print $0}' | \ + sed -e 's/^ *//' | sed -e 's/ *$//' ) themeName="@themeName@" themeDir="@themeDir@" logName="@LOG_FILENAME@" Index: branches/zenith432/package/Scripts.templates/InstallModule/postinstall =================================================================== --- branches/zenith432/package/Scripts.templates/InstallModule/postinstall (revision 2593) +++ branches/zenith432/package/Scripts.templates/InstallModule/postinstall (revision 2594) @@ -3,9 +3,9 @@ set -u configFile='/private/tmp/InstallConfig.plist' -v_mntptDev=$( /usr/libexec/PlistBuddy -c "Print :ramdisk" ${configFile} | sed -e 's/[[:blank:]]*//g' ) -v_mntpt=$( LC_ALL=C diskutil info ${v_mntptDev} | grep -i 'mount point' | awk '{$1=$2=""; print $0}' \ - | sed -e 's/^[ \t]*//' ) +v_mntptDev=$( /usr/libexec/PlistBuddy -c "Print :ramdisk" ${configFile} ) +v_mntpt=$( LC_ALL=C diskutil info ${v_mntptDev} | grep -i 'mount point' | awk '{$1=$2=""; print $0}' | \ + sed -e 's/^ *//' | sed -e 's/ *$//' ) moduleName="@moduleName@" moduleFile="@moduleFile@" Index: branches/zenith432/package/Scripts/Main/ESPpostinstall =================================================================== --- branches/zenith432/package/Scripts/Main/ESPpostinstall (revision 2593) +++ branches/zenith432/package/Scripts/Main/ESPpostinstall (revision 2594) @@ -1,14 +1,18 @@ #!/bin/bash # -------------------------------------------------------------------------------------------------------- -# Install.sh v1.3, script to install Chameleon +# Install.sh v1.5, script to install Chameleon # Created by Miky1979 on December 8th, 2014 # -------------------------------------------------------------------------------------------------------- targetVolume="${3}" InstallToESP="1" InstallBootloader="0" +espmtp="/Volumes/ESP" +WINDOWS_EXIST="0" +opt="u" configFile="/private/tmp/InstallConfig.plist" +if [ "${InstallToESP}" == "1" ]; then TYPE="ESP"; else TYPE="Standard"; fi if [[ $( /usr/libexec/PlistBuddy -c "Print bootloader" ${configFile} ) == "true" ]];then # installing stage 0, 1 and 2 only if user want this: # ie only if have no selected noboot choice @@ -23,28 +27,26 @@ choicedVolume="${targetVolume}" ESP_MOUNTED="0" # -------------------------------------------------------------------------------------------------------- -v_mntptDev=$( /usr/libexec/PlistBuddy -c "Print :ramdisk" ${configFile} | sed -e 's/[[:blank:]]*//g' ) -v_mntpt=$( LC_ALL=C diskutil info ${v_mntptDev} | grep -i 'mount point' | awk '{$1=$2=""; print $0}' \ - | sed -e 's/^[ \t]*//') +v_mntptDev=$( /usr/libexec/PlistBuddy -c "Print :ramdisk" ${configFile} ) +v_mntpt=$( LC_ALL=C diskutil info ${v_mntptDev} | grep -i 'mount point' | awk '{$1=$2=""; print $0}' | \ + sed -e 's/^ *//' | sed -e 's/ *$//' ) backupRootDir="${targetVolume}/Chameleon.Backups" backupDir=$( /usr/libexec/PlistBuddy -c "Print :backupDir" ${configFile} ) logName="Chameleon_Installer_Log.txt" logFile="${v_mntpt}/${logName}" # -------------------------------------------------------------------------------------------------------- -stage0Loader="boot0" -stage0LoaderDualBoot="boot0md" stage1LoaderHFS="boot1h" stage1LoaderFAT="boot1f32" stage1LoaderExFAT="boot1x" stage2Loader="boot" versionToInstall=$(cat "${i386Dir}/Boot" | grep -a 'Darwin/x86 boot v' ) # -------------------------------------------------------------------------------------------------------- -localdd="/bin/dd" SS="${usrLocalBin}/sectorsize" # -------------------------------------------------------------------------------------------------------- # Scanning all Variables. We are switching to the target Volume or its ESP. # This function is usefull to rescan the new target "at need" SCAN() { + bootDevice=$( LC_ALL=C diskutil info / | grep -i 'Device Node:' | awk '{print $NF}' ) targetDevice=$( LC_ALL=C diskutil info "${choicedVolume}" | grep -i 'Device Node:' | awk '{print $NF}' ) targetDeviceRaw=${targetDevice/disk/rdisk} targetDisk=${targetDevice%s*} @@ -52,9 +54,9 @@ targetSlice=${targetDevice#*disk*s} IOContent=$( LC_ALL=C diskutil info "${targetDisk}" | grep -i 'Content (IOContent)' | awk '{print $NF}' ) FS=$( LC_ALL=C diskutil info ${targetDevice} | grep -i 'Type (Bundle)' | \ - awk '{print $NF}' | awk '{print tolower($0)}' ) + awk '{print $NF}' | awk '{print tolower($0)}' ) disksignature=$( dd 2>/dev/null if="${targetDisk}" count=1 | dd 2>/dev/null count=4 bs=1 skip=440 | \ - perl -ne '@a=split"";for(@a){printf"%02x",ord}' ) + perl -ne '@a=split"";for(@a){printf"%02x",ord}' ) if [ $InstallBootloader = "1" ];then blocksize=$( "${SS}" "${targetDeviceRaw}" | awk '{ print $2 }' ) @@ -69,10 +71,9 @@ # Create a folder inside the Desktop called "DebugChameleon", and the log will be full DEBUG() { echo "$mainLine" - echo "DEBUG: display script variables (ESPpostinstall)" + echo "DEBUG: display script variables (${TYPE}postinstall)" echo "$mainLine" - echo "DEBUG: stage0Loader: Disk loader is ${stage0Loader} (or boot0hfs)" - echo "DEBUG: stage0LoaderDualBoot: Disk loader is ${stage0LoaderDualBoot} (or boot0hfs)" + echo "DEBUG: stage0Loader: Disk loader is ${stage0Loader}" echo "DEBUG: stage1LoaderHFS: Partition loader is ${stage1LoaderHFS}" echo "DEBUG: stage1LoaderFat: Partition loader is ${stage1LoaderFAT}" echo "DEBUG: stage1LoaderExFAT: Partition loader is ${stage1LoaderExFAT}" @@ -83,6 +84,7 @@ echo "DEBUG: targetDisk: Disk device is ${targetDisk}" echo "DEBUG: targetDiskRaw: Disk raw device is ${targetDiskRaw}" echo "DEBUG: targetSlice: Volume slice is ${targetSlice}" + echo "DEBUG: bootDevice: Current Volume device is ${bootDevice}" echo "DEBUG: versionToInstall: version to install is ${versionToInstall}" echo "DEBUG: IOContent: partition scheme is ${IOContent}" echo "DEBUG: FS: file System is ${FS}" @@ -93,8 +95,8 @@ # -------------------------------------------------------------------------------------------------------- # Checking for unsupported FAT16 filesystem CHECK_FAT16() { - pers=$( LC_ALL=C diskutil info "${targetDeviceRaw}" | grep -i 'File System Personality' \ - | awk '{print $NF}' | awk '{print tolower($0)}' ) + pers=$( LC_ALL=C diskutil info "${targetDeviceRaw}" | grep -i 'File System Personality' | \ + awk '{print $NF}' | awk '{print tolower($0)}' ) case $pers in fat16) @@ -102,7 +104,7 @@ exit 1 ;; *) - echo "First Check Passed!" + echo "First Check Passed (not Fat16)!" ;; esac } @@ -116,9 +118,9 @@ CHECK_ESP_MOUNTPOINT() { # umount the ESP by its Mount Point # and checking it if is busy by another ESP - if [ $( df | awk '{$1=$2=$3=$4=$5=$6=$7=$8=""; print $0}' | sed -e 's/^[ \t]*//' | \ - grep -x '/Volumes/ESP' ) ]; then - umount -f /Volumes/ESP + if [ $( df | awk '{$1=$2=$3=$4=$5=$6=$7=$8=""; print $0}' | sed -e 's/^ *//' | sed -e 's/ *$//' | \ + grep -x "${espmtp}" ) ]; then + umount -f ${espmtp} ESP_MOUNTED="0" fi } @@ -128,7 +130,7 @@ if [ $( df | grep "${espDisk}" | awk '{print $1}' | grep -x "${espDisk}" ) ];then # ESP is already mounted, so now we aquire the Mount Point espmtp=$( LC_ALL=C diskutil info ${espDisk} | grep -i 'mount point' | awk '{$1=$2=""; print $0}' | \ - sed -e 's/^[ \t]*//' ) + sed -e 's/^ *//' | sed -e 's/ *$//' ) if [ -d "${espmtp}" ];then echo "ESP Mount Point is:${espmtp}, using that as target Volume!" choicedVolume="${espmtp}" @@ -144,13 +146,15 @@ fi if [ $ESP_MOUNTED = "0" ];then - mkdir -p /Volumes/ESP + mkdir -p "${espmtp}" case $( fstyp $espDisk ) in hfs) - mount -t hfs $espDisk /Volumes/ESP + echo "Mounting $espDisk on $espmtp as hfs Volume.." + mount -t hfs $espDisk "${espmtp}" ;; msdos) - mount -t msdos $espDisk /Volumes/ESP + echo "Mounting $espDisk on $espmtp as msdos Volume.." + mount -t msdos $espDisk "${espmtp}" ;; *) echo "ESP fileSystem unsupported, Installing to ${targetVolume}!" @@ -159,10 +163,11 @@ esac sleep 0.3 - if [ $( df | awk '{$1=$2=$3=$4=$5=$6=$7=$8=""; print $0}' | sed -e 's/^[ \t]*//' | \ - grep -x '/Volumes/ESP' ) ]; then + if [ $( df | awk '{$1=$2=$3=$4=$5=$6=$7=$8=""; print $0}' | sed -e 's/^ *//' | sed -e 's/ *$//' | \ + grep -x "${espmtp}" ) ]; then + echo "EFI System Partition mounted!" ESP_MOUNTED="1" - choicedVolume="/Volumes/ESP" + choicedVolume="${espmtp}" SCAN else echo "ESP can't be mounted, Installing to ${targetVolume}!" @@ -172,17 +177,18 @@ } # -------------------------------------------------------------------------------------------------------- PARTITION_ACTIVE_IF() { - echo -e "${mainLine}\nSET PARTITION ACTIVE:" - # if Windows was detected, don't activate the partition.. - # if the stage 0 loader is boo0hfs, don't activate the partition - if [ WINDOWS_EXIST = "0" ] || [ "${stage0Loader}" != "boot0hfs" ];then - partitionactive=$( fdisk -d ${targetDiskRaw} | grep -n "*" | awk -F: '{print $1}') - if [ "${partitionactive}" ] && [ "${partitionactive}" = "${targetSlice}" ]; then - echo "${targetDiskRaw#/dev/r}, slice "${targetSlice}" is already set active. No need to change it." - else - echo "Setting ${choicedVolume} partition active." - # BadAxe requires EFI partition to be flagged active. - # but it doesn't' hurt to do it for any non-windows partition. + if [ $InstallBootloader = "1" ];then + echo -e "${mainLine}\nSET PARTITION ACTIVE:" + # if Windows was detected, don't activate the partition.. + # if the stage 0 loader is boo0hfs, don't activate the partition + if [ WINDOWS_EXIST = "0" ] || [ "${stage0Loader}" != "boot0hfs" ];then + partitionactive=$( fdisk -d ${targetDiskRaw} | grep -n "*" | awk -F: '{print $1}') + if [ "${partitionactive}" ] && [ "${partitionactive}" = "${targetSlice}" ]; then + echo "${targetDiskRaw#/dev/r}, slice "${targetSlice}" is already set active. No need to change it." + else + echo "Setting ${choicedVolume} partition active." + # BadAxe requires EFI partition to be flagged active. + # but it doesn't' hurt to do it for any non-windows partition. # leave left aligned the follow code: fdisk -e ${targetDiskRaw} <<-MAKEACTIVE @@ -192,17 +198,17 @@ y quit MAKEACTIVE + fi + else + echo "Partition will not activate when Windows is detected or stage 0 is boot0hfs" fi - else - echo "Partition will not activate when Windows is detected or stage 0 is boot0hfs" + echo "" + echo "$mainLine" fi - echo "" - echo "$mainLine" } # -------------------------------------------------------------------------------------------------------- # Writing stage 0 CHECK_WINDOWS() { - WINDOWS_EXIST="0" if [ "${disksignature}" = "00000000" ]; then echo "Windows installation not found on ${targetDisk}." else @@ -214,55 +220,21 @@ WRITE_STAGE0() { if [ $InstallBootloader = "1" ];then echo -e "${mainLine}\nWRITING STAGE 0:" - CHECK_WINDOWS - case "$1" in - hfs) - if [ WINDOWS_EXIST = "1" ];then stage0Loader="boo0hfs"; else stage0Loader="boot0"; fi - ;; - msdos) - if [ WINDOWS_EXIST = "1" ];then stage0Loader="boo0md"; else stage0Loader="boot0";fi - ;; - exfat) - stage0Loader="boot0" - ;; - esac - "${usrLocalBin}/fdisk440" -u -f "${i386Dir}/${stage0Loader}" -y ${targetDisk} echo "${stage0Loader} writed to ${targetDisk}" fi } - # -------------------------------------------------------------------------------------------------------- -# Writing stage 1 on different filesystems -WRITE_STAGE1_HFS() { +# Writing stage 1 +WRITE_STAGE1() { if [ $InstallBootloader = "1" ];then - echo -e "${mainLine}\nWRITING STAGE 1 HFS:" - $localdd if="${i386Dir}/${stage1LoaderHFS}" of=${targetDeviceRaw} - echo "${stage1LoaderHFS} (hfs) writed to ${targetDeviceRaw}." - fi -} - -WRITE_STAGE1_EXFAT() { - if [ $InstallBootloader = "1" ];then - echo -e "${mainLine}\nWRITING STAGE 1 ExFAT:" + echo -e "${mainLine}\nWRITING STAGE 1 ${2}:" cp -R "${usrLocalBin}/boot1-install" "${v_mntpt}"/ - cp -R "${i386Dir}/${stage1LoaderExFAT}" "${v_mntpt}"/ - "${v_mntpt}/boot1-install" -y -u -f "${v_mntpt}/${stage1LoaderExFAT}" ${targetDeviceRaw} - echo "${stage1LoaderExFAT} (ExFAT) writed to ${targetDeviceRaw}." + cp -R "${i386Dir}/${1}" "${v_mntpt}"/ + "${v_mntpt}/boot1-install" -y "-${3}" -f "${v_mntpt}/${1}" ${targetDeviceRaw} + echo "${stage1Loader} (${2}) writed to ${targetDeviceRaw}." fi } - -WRITE_STAGE1_FAT32() { - if [ $InstallBootloader = "1" ];then - echo -e "${mainLine}\nWRITING STAGE 1 FAT32:" - $localdd if=${targetDeviceRaw} count=1 bs=512 of="${v_mntpt}/origbs" - cp "${i386Dir}/${stage1LoaderFAT}" "${v_mntpt}/newbs" - $localdd if="${v_mntpt}/origbs" of="${v_mntpt}/newbs" skip=3 seek=3 bs=1 count=87 conv=notrunc - $localdd if="${v_mntpt}/newbs" of="${targetDeviceRaw}" count=1 bs=512 - - echo "${stage1LoaderFAT} (Fat32) writed to ${targetDeviceRaw}." - fi -} # -------------------------------------------------------------------------------------------------------- # Writing stage 2 WRITE_STAGE2() { @@ -275,15 +247,22 @@ } # -------------------------------------------------------------------------------------------------------- # Waiting for targhet Volume was re-mounted before proceeding.. -# Note: the target Volume is umonted by boot1-install that also take the step to remount it (only waiting..) -WAIT_REMOUNT() { +# Note: the target Volume is umonted by boot1-install that also take the step to remount it (only waiting..). +# exception is the EFI partition: in Mavericks autoremount...in Yosemite not.. +REMOUNT() { if [ $InstallBootloader = "1" ];then - if [ ! -d "${choicedVolume}" ]; then - echo -e "${mainLine}\nWAITING TO RE-MOUNT ${choicedVolume}:" - until [ -d "${choicedVolume}" ]; do - sleep 0.3 - done - echo "${choicedVolume} is mounted!" + if [ "${InstallToESP}" == "1" ]; then + if [ ! -d "${choicedVolume}" ]; then + MOUNT_ESP + fi + else + if [ ! -d "${choicedVolume}" ]; then + echo -e "${mainLine}\nWAITING TO RE-MOUNT ${choicedVolume}:" + until [ -d "${choicedVolume}" ]; do + sleep 0.3 + done + echo "${choicedVolume} is mounted!" + fi fi fi } @@ -298,7 +277,7 @@ else echo "Extra folder already exist on ${choicedVolume}, copying to the Ram Disk.." cp -R "${choicedVolume}/Extra" "${v_mntpt}"/ - ./clean_bootplist.pl "${v_mntpt}" >/dev/null + ./clean_bootplist.pl "${v_mntpt}" fi } # -------------------------------------------------------------------------------------------------------- @@ -332,7 +311,7 @@ exec > >(tee -a "${logFile}") 2>&1 echo "$mainLine" -echo "Main ESP Post-Install Script" +echo "Main ${TYPE} Post-Install Script" echo "Chameleon installer log - $( date )" if [ $InstallBootloader = "1" ];then echo "$versionToInstall"; else echo "no boot session"; fi echo "" @@ -355,7 +334,7 @@ echo "GPT partition Scheme detected.." espDisk="${targetDisk}s1" if [ $( LC_ALL=C diskutil info ${espDisk} | grep -i 'Partition Type:' | \ - awk '{print $NF}' ) = "EFI" ]; then + awk '{print $NF}' | sed -e 's/^ *//' | sed -e 's/ *$//' ) = "EFI" ]; then echo "EFI partition found is ${espDisk}, try to mount it.." MOUNT_ESP else @@ -364,6 +343,7 @@ fi ;; *) + InstallToESP = "0" echo "Can't install on the ESP, because does not exist.." echo "..continue installing to ${targetVolume}" ;; @@ -372,11 +352,6 @@ SCAN fi - -if [ -d "${HOME}/Desktop/DebugChameleon" ]; then - DEBUG -fi - # adding the chosen Volume dev id to the InstallConfig.plist /usr/libexec/PlistBuddy -c "Add :targetdev string ${targetDevice}" $configFile @@ -385,22 +360,22 @@ echo "${mainLine}" CHECK_FAT16 +CHECK_WINDOWS case "$FS" in hfs) echo "${targetDevice} is HFS formatted" - WRITE_STAGE0 hfs - WRITE_STAGE1_HFS + if [ $WINDOWS_EXIST = "1" ];then stage0Loader="boot0hfs"; else stage0Loader="boot0"; fi + stage1Loader="${stage1LoaderHFS}" ;; msdos) echo "${targetDevice} is FAT32 formatted" - WRITE_STAGE0 msdos - WRITE_STAGE1_FAT32 + if [ $WINDOWS_EXIST = "1" ];then stage0Loader="boot0md"; else stage0Loader="boot0"; fi + stage1Loader="${stage1LoaderFAT}" ;; exfat) echo "${targetDevice} is ExFAT formatted" - WRITE_STAGE0 exfat - WRITE_STAGE1_EXFAT - WAIT_REMOUNT + stage0Loader="boot0" + stage1Loader="${stage1LoaderExFAT}" ;; *) echo "FileSystem unsupported, aborting!" @@ -408,11 +383,19 @@ ;; esac +# Debug mode: create a "DebugChameleon" folder on your Desktop to debug this script +if [ -d "${HOME}/Desktop/DebugChameleon" ]; then DEBUG; fi +# if the target device is equal to the boot device keep the Volume mounted using boot1-install +if [ "${bootDevice}" = "${targetDevice}" ]; then opt="M"; fi + +WRITE_STAGE0 "${stage0Loader}" +WRITE_STAGE1 "${stage1Loader}" "${FS}" "${opt}" +if [ "${bootDevice}" != "${targetDevice}" ]; then REMOUNT; fi WRITE_STAGE2 PARTITION_ACTIVE_IF echo "$mainLine" -echo "END - ESP Post-Install Script" +echo "END - ${TYPE} Post-Install Script" # -------------------------------------------------------------------------------------------------------- exit 0 Index: branches/zenith432/package/Scripts/Main/Standardpostinstall =================================================================== --- branches/zenith432/package/Scripts/Main/Standardpostinstall (revision 2593) +++ branches/zenith432/package/Scripts/Main/Standardpostinstall (revision 2594) @@ -1,14 +1,18 @@ #!/bin/bash # -------------------------------------------------------------------------------------------------------- -# Install.sh v1.3, script to install Chameleon +# Install.sh v1.5, script to install Chameleon # Created by Miky1979 on December 8th, 2014 # -------------------------------------------------------------------------------------------------------- targetVolume="${3}" InstallToESP="0" InstallBootloader="0" +espmtp="/Volumes/ESP" +WINDOWS_EXIST="0" +opt="u" configFile="/private/tmp/InstallConfig.plist" +if [ "${InstallToESP}" == "1" ]; then TYPE="ESP"; else TYPE="Standard"; fi if [[ $( /usr/libexec/PlistBuddy -c "Print bootloader" ${configFile} ) == "true" ]];then # installing stage 0, 1 and 2 only if user want this: # ie only if have no selected noboot choice @@ -23,28 +27,26 @@ choicedVolume="${targetVolume}" ESP_MOUNTED="0" # -------------------------------------------------------------------------------------------------------- -v_mntptDev=$( /usr/libexec/PlistBuddy -c "Print :ramdisk" ${configFile} | sed -e 's/[[:blank:]]*//g' ) -v_mntpt=$( LC_ALL=C diskutil info ${v_mntptDev} | grep -i 'mount point' | awk '{$1=$2=""; print $0}' \ - | sed -e 's/^[ \t]*//') +v_mntptDev=$( /usr/libexec/PlistBuddy -c "Print :ramdisk" ${configFile} ) +v_mntpt=$( LC_ALL=C diskutil info ${v_mntptDev} | grep -i 'mount point' | awk '{$1=$2=""; print $0}' | \ + sed -e 's/^ *//' | sed -e 's/ *$//' ) backupRootDir="${targetVolume}/Chameleon.Backups" backupDir=$( /usr/libexec/PlistBuddy -c "Print :backupDir" ${configFile} ) logName="Chameleon_Installer_Log.txt" logFile="${v_mntpt}/${logName}" # -------------------------------------------------------------------------------------------------------- -stage0Loader="boot0" -stage0LoaderDualBoot="boot0md" stage1LoaderHFS="boot1h" stage1LoaderFAT="boot1f32" stage1LoaderExFAT="boot1x" stage2Loader="boot" versionToInstall=$(cat "${i386Dir}/Boot" | grep -a 'Darwin/x86 boot v' ) # -------------------------------------------------------------------------------------------------------- -localdd="/bin/dd" SS="${usrLocalBin}/sectorsize" # -------------------------------------------------------------------------------------------------------- # Scanning all Variables. We are switching to the target Volume or its ESP. # This function is usefull to rescan the new target "at need" SCAN() { + bootDevice=$( LC_ALL=C diskutil info / | grep -i 'Device Node:' | awk '{print $NF}' ) targetDevice=$( LC_ALL=C diskutil info "${choicedVolume}" | grep -i 'Device Node:' | awk '{print $NF}' ) targetDeviceRaw=${targetDevice/disk/rdisk} targetDisk=${targetDevice%s*} @@ -52,9 +54,9 @@ targetSlice=${targetDevice#*disk*s} IOContent=$( LC_ALL=C diskutil info "${targetDisk}" | grep -i 'Content (IOContent)' | awk '{print $NF}' ) FS=$( LC_ALL=C diskutil info ${targetDevice} | grep -i 'Type (Bundle)' | \ - awk '{print $NF}' | awk '{print tolower($0)}' ) + awk '{print $NF}' | awk '{print tolower($0)}' ) disksignature=$( dd 2>/dev/null if="${targetDisk}" count=1 | dd 2>/dev/null count=4 bs=1 skip=440 | \ - perl -ne '@a=split"";for(@a){printf"%02x",ord}' ) + perl -ne '@a=split"";for(@a){printf"%02x",ord}' ) if [ $InstallBootloader = "1" ];then blocksize=$( "${SS}" "${targetDeviceRaw}" | awk '{ print $2 }' ) @@ -69,10 +71,9 @@ # Create a folder inside the Desktop called "DebugChameleon", and the log will be full DEBUG() { echo "$mainLine" - echo "DEBUG: display script variables (Standardpostinstall)" + echo "DEBUG: display script variables (${TYPE}postinstall)" echo "$mainLine" - echo "DEBUG: stage0Loader: Disk loader is ${stage0Loader} (or boot0hfs)" - echo "DEBUG: stage0LoaderDualBoot: Disk loader is ${stage0LoaderDualBoot} (or boot0hfs)" + echo "DEBUG: stage0Loader: Disk loader is ${stage0Loader}" echo "DEBUG: stage1LoaderHFS: Partition loader is ${stage1LoaderHFS}" echo "DEBUG: stage1LoaderFat: Partition loader is ${stage1LoaderFAT}" echo "DEBUG: stage1LoaderExFAT: Partition loader is ${stage1LoaderExFAT}" @@ -83,6 +84,7 @@ echo "DEBUG: targetDisk: Disk device is ${targetDisk}" echo "DEBUG: targetDiskRaw: Disk raw device is ${targetDiskRaw}" echo "DEBUG: targetSlice: Volume slice is ${targetSlice}" + echo "DEBUG: bootDevice: Current Volume device is ${bootDevice}" echo "DEBUG: versionToInstall: version to install is ${versionToInstall}" echo "DEBUG: IOContent: partition scheme is ${IOContent}" echo "DEBUG: FS: file System is ${FS}" @@ -93,8 +95,8 @@ # -------------------------------------------------------------------------------------------------------- # Checking for unsupported FAT16 filesystem CHECK_FAT16() { - pers=$( LC_ALL=C diskutil info "${targetDeviceRaw}" | grep -i 'File System Personality' \ - | awk '{print $NF}' | awk '{print tolower($0)}' ) + pers=$( LC_ALL=C diskutil info "${targetDeviceRaw}" | grep -i 'File System Personality' | \ + awk '{print $NF}' | awk '{print tolower($0)}' ) case $pers in fat16) @@ -102,7 +104,7 @@ exit 1 ;; *) - echo "First Check Passed!" + echo "First Check Passed (not Fat16)!" ;; esac } @@ -116,9 +118,9 @@ CHECK_ESP_MOUNTPOINT() { # umount the ESP by its Mount Point # and checking it if is busy by another ESP - if [ $( df | awk '{$1=$2=$3=$4=$5=$6=$7=$8=""; print $0}' | sed -e 's/^[ \t]*//' | \ - grep -x '/Volumes/ESP' ) ]; then - umount -f /Volumes/ESP + if [ $( df | awk '{$1=$2=$3=$4=$5=$6=$7=$8=""; print $0}' | sed -e 's/^ *//' | sed -e 's/ *$//' | \ + grep -x "${espmtp}" ) ]; then + umount -f ${espmtp} ESP_MOUNTED="0" fi } @@ -128,7 +130,7 @@ if [ $( df | grep "${espDisk}" | awk '{print $1}' | grep -x "${espDisk}" ) ];then # ESP is already mounted, so now we aquire the Mount Point espmtp=$( LC_ALL=C diskutil info ${espDisk} | grep -i 'mount point' | awk '{$1=$2=""; print $0}' | \ - sed -e 's/^[ \t]*//' ) + sed -e 's/^ *//' | sed -e 's/ *$//' ) if [ -d "${espmtp}" ];then echo "ESP Mount Point is:${espmtp}, using that as target Volume!" choicedVolume="${espmtp}" @@ -144,13 +146,15 @@ fi if [ $ESP_MOUNTED = "0" ];then - mkdir -p /Volumes/ESP + mkdir -p "${espmtp}" case $( fstyp $espDisk ) in hfs) - mount -t hfs $espDisk /Volumes/ESP + echo "Mounting $espDisk on $espmtp as hfs Volume.." + mount -t hfs $espDisk "${espmtp}" ;; msdos) - mount -t msdos $espDisk /Volumes/ESP + echo "Mounting $espDisk on $espmtp as msdos Volume.." + mount -t msdos $espDisk "${espmtp}" ;; *) echo "ESP fileSystem unsupported, Installing to ${targetVolume}!" @@ -159,10 +163,11 @@ esac sleep 0.3 - if [ $( df | awk '{$1=$2=$3=$4=$5=$6=$7=$8=""; print $0}' | sed -e 's/^[ \t]*//' | \ - grep -x '/Volumes/ESP' ) ]; then + if [ $( df | awk '{$1=$2=$3=$4=$5=$6=$7=$8=""; print $0}' | sed -e 's/^ *//' | sed -e 's/ *$//' | \ + grep -x "${espmtp}" ) ]; then + echo "EFI System Partition mounted!" ESP_MOUNTED="1" - choicedVolume="/Volumes/ESP" + choicedVolume="${espmtp}" SCAN else echo "ESP can't be mounted, Installing to ${targetVolume}!" @@ -172,17 +177,18 @@ } # -------------------------------------------------------------------------------------------------------- PARTITION_ACTIVE_IF() { - echo -e "${mainLine}\nSET PARTITION ACTIVE:" - # if Windows was detected, don't activate the partition.. - # if the stage 0 loader is boo0hfs, don't activate the partition - if [ WINDOWS_EXIST = "0" ] || [ "${stage0Loader}" != "boot0hfs" ];then - partitionactive=$( fdisk -d ${targetDiskRaw} | grep -n "*" | awk -F: '{print $1}') - if [ "${partitionactive}" ] && [ "${partitionactive}" = "${targetSlice}" ]; then - echo "${targetDiskRaw#/dev/r}, slice "${targetSlice}" is already set active. No need to change it." - else - echo "Setting ${choicedVolume} partition active." - # BadAxe requires EFI partition to be flagged active. - # but it doesn't' hurt to do it for any non-windows partition. + if [ $InstallBootloader = "1" ];then + echo -e "${mainLine}\nSET PARTITION ACTIVE:" + # if Windows was detected, don't activate the partition.. + # if the stage 0 loader is boo0hfs, don't activate the partition + if [ WINDOWS_EXIST = "0" ] || [ "${stage0Loader}" != "boot0hfs" ];then + partitionactive=$( fdisk -d ${targetDiskRaw} | grep -n "*" | awk -F: '{print $1}') + if [ "${partitionactive}" ] && [ "${partitionactive}" = "${targetSlice}" ]; then + echo "${targetDiskRaw#/dev/r}, slice "${targetSlice}" is already set active. No need to change it." + else + echo "Setting ${choicedVolume} partition active." + # BadAxe requires EFI partition to be flagged active. + # but it doesn't' hurt to do it for any non-windows partition. # leave left aligned the follow code: fdisk -e ${targetDiskRaw} <<-MAKEACTIVE @@ -192,17 +198,17 @@ y quit MAKEACTIVE + fi + else + echo "Partition will not activate when Windows is detected or stage 0 is boot0hfs" fi - else - echo "Partition will not activate when Windows is detected or stage 0 is boot0hfs" + echo "" + echo "$mainLine" fi - echo "" - echo "$mainLine" } # -------------------------------------------------------------------------------------------------------- # Writing stage 0 CHECK_WINDOWS() { - WINDOWS_EXIST="0" if [ "${disksignature}" = "00000000" ]; then echo "Windows installation not found on ${targetDisk}." else @@ -214,54 +220,21 @@ WRITE_STAGE0() { if [ $InstallBootloader = "1" ];then echo -e "${mainLine}\nWRITING STAGE 0:" - CHECK_WINDOWS - case "$1" in - hfs) - if [ WINDOWS_EXIST = "1" ];then stage0Loader="boo0hfs"; else stage0Loader="boot0"; fi - ;; - msdos) - if [ WINDOWS_EXIST = "1" ];then stage0Loader="boo0md"; else stage0Loader="boot0";fi - ;; - exfat) - stage0Loader="boot0" - ;; - esac - "${usrLocalBin}/fdisk440" -u -f "${i386Dir}/${stage0Loader}" -y ${targetDisk} echo "${stage0Loader} writed to ${targetDisk}" fi } # -------------------------------------------------------------------------------------------------------- -# Writing stage 1 on different filesystems -WRITE_STAGE1_HFS() { +# Writing stage 1 +WRITE_STAGE1() { if [ $InstallBootloader = "1" ];then - echo -e "${mainLine}\nWRITING STAGE 1 HFS:" - $localdd if="${i386Dir}/${stage1LoaderHFS}" of=${targetDeviceRaw} - echo "${stage1LoaderHFS} (hfs) writed to ${targetDeviceRaw}." - fi -} - -WRITE_STAGE1_EXFAT() { - if [ $InstallBootloader = "1" ];then - echo -e "${mainLine}\nWRITING STAGE 1 ExFAT:" + echo -e "${mainLine}\nWRITING STAGE 1 ${2}:" cp -R "${usrLocalBin}/boot1-install" "${v_mntpt}"/ - cp -R "${i386Dir}/${stage1LoaderExFAT}" "${v_mntpt}"/ - "${v_mntpt}/boot1-install" -y -u -f "${v_mntpt}/${stage1LoaderExFAT}" ${targetDeviceRaw} - echo "${stage1LoaderExFAT} (ExFAT) writed to ${targetDeviceRaw}." + cp -R "${i386Dir}/${1}" "${v_mntpt}"/ + "${v_mntpt}/boot1-install" -y "-${3}" -f "${v_mntpt}/${1}" ${targetDeviceRaw} + echo "${stage1Loader} (${2}) writed to ${targetDeviceRaw}." fi } - -WRITE_STAGE1_FAT32() { - if [ $InstallBootloader = "1" ];then - echo -e "${mainLine}\nWRITING STAGE 1 FAT32:" - $localdd if=${targetDeviceRaw} count=1 bs=512 of="${v_mntpt}/origbs" - cp "${i386Dir}/${stage1LoaderFAT}" "${v_mntpt}/newbs" - $localdd if="${v_mntpt}/origbs" of="${v_mntpt}/newbs" skip=3 seek=3 bs=1 count=87 conv=notrunc - $localdd if="${v_mntpt}/newbs" of="${targetDeviceRaw}" count=1 bs=512 - - echo "${stage1LoaderFAT} (Fat32) writed to ${targetDeviceRaw}." - fi -} # -------------------------------------------------------------------------------------------------------- # Writing stage 2 WRITE_STAGE2() { @@ -274,15 +247,22 @@ } # -------------------------------------------------------------------------------------------------------- # Waiting for targhet Volume was re-mounted before proceeding.. -# Note: the target Volume is umonted by boot1-install that also take the step to remount it (only waiting..) -WAIT_REMOUNT() { +# Note: the target Volume is umonted by boot1-install that also take the step to remount it (only waiting..). +# exception is the EFI partition: in Mavericks autoremount...in Yosemite not.. +REMOUNT() { if [ $InstallBootloader = "1" ];then - if [ ! -d "${choicedVolume}" ]; then - echo -e "${mainLine}\nWAITING TO RE-MOUNT ${choicedVolume}:" - until [ -d "${choicedVolume}" ]; do - sleep 0.3 - done - echo "${choicedVolume} is mounted!" + if [ "${InstallToESP}" == "1" ]; then + if [ ! -d "${choicedVolume}" ]; then + MOUNT_ESP + fi + else + if [ ! -d "${choicedVolume}" ]; then + echo -e "${mainLine}\nWAITING TO RE-MOUNT ${choicedVolume}:" + until [ -d "${choicedVolume}" ]; do + sleep 0.3 + done + echo "${choicedVolume} is mounted!" + fi fi fi } @@ -297,7 +277,7 @@ else echo "Extra folder already exist on ${choicedVolume}, copying to the Ram Disk.." cp -R "${choicedVolume}/Extra" "${v_mntpt}"/ - ./clean_bootplist.pl "${v_mntpt}" >/dev/null + ./clean_bootplist.pl "${v_mntpt}" fi } # -------------------------------------------------------------------------------------------------------- @@ -331,7 +311,7 @@ exec > >(tee -a "${logFile}") 2>&1 echo "$mainLine" -echo "Main Standard Post-Install Script" +echo "Main ${TYPE} Post-Install Script" echo "Chameleon installer log - $( date )" if [ $InstallBootloader = "1" ];then echo "$versionToInstall"; else echo "no boot session"; fi echo "" @@ -354,7 +334,7 @@ echo "GPT partition Scheme detected.." espDisk="${targetDisk}s1" if [ $( LC_ALL=C diskutil info ${espDisk} | grep -i 'Partition Type:' | \ - awk '{print $NF}' ) = "EFI" ]; then + awk '{print $NF}' | sed -e 's/^ *//' | sed -e 's/ *$//' ) = "EFI" ]; then echo "EFI partition found is ${espDisk}, try to mount it.." MOUNT_ESP else @@ -363,6 +343,7 @@ fi ;; *) + InstallToESP = "0" echo "Can't install on the ESP, because does not exist.." echo "..continue installing to ${targetVolume}" ;; @@ -371,11 +352,6 @@ SCAN fi - -if [ -d "${HOME}/Desktop/DebugChameleon" ]; then - DEBUG -fi - # adding the chosen Volume dev id to the InstallConfig.plist /usr/libexec/PlistBuddy -c "Add :targetdev string ${targetDevice}" $configFile @@ -384,22 +360,22 @@ echo "${mainLine}" CHECK_FAT16 +CHECK_WINDOWS case "$FS" in hfs) echo "${targetDevice} is HFS formatted" - WRITE_STAGE0 hfs - WRITE_STAGE1_HFS + if [ $WINDOWS_EXIST = "1" ];then stage0Loader="boot0hfs"; else stage0Loader="boot0"; fi + stage1Loader="${stage1LoaderHFS}" ;; msdos) echo "${targetDevice} is FAT32 formatted" - WRITE_STAGE0 msdos - WRITE_STAGE1_FAT32 + if [ $WINDOWS_EXIST = "1" ];then stage0Loader="boot0md"; else stage0Loader="boot0"; fi + stage1Loader="${stage1LoaderFAT}" ;; exfat) echo "${targetDevice} is ExFAT formatted" - WRITE_STAGE0 exfat - WRITE_STAGE1_EXFAT - WAIT_REMOUNT + stage0Loader="boot0" + stage1Loader="${stage1LoaderExFAT}" ;; *) echo "FileSystem unsupported, aborting!" @@ -407,11 +383,19 @@ ;; esac +# Debug mode: create a "DebugChameleon" folder on your Desktop to debug this script +if [ -d "${HOME}/Desktop/DebugChameleon" ]; then DEBUG; fi +# if the target device is equal to the boot device keep the Volume mounted using boot1-install +if [ "${bootDevice}" = "${targetDevice}" ]; then opt="M"; fi + +WRITE_STAGE0 "${stage0Loader}" +WRITE_STAGE1 "${stage1Loader}" "${FS}" "${opt}" +if [ "${bootDevice}" != "${targetDevice}" ]; then REMOUNT; fi WRITE_STAGE2 PARTITION_ACTIVE_IF echo "$mainLine" -echo "END - Standard Post-Install Script" +echo "END - ${TYPE} Post-Install Script" # -------------------------------------------------------------------------------------------------------- exit 0 Index: branches/zenith432/package/buildpkg.sh =================================================================== --- branches/zenith432/package/buildpkg.sh (revision 2593) +++ branches/zenith432/package/buildpkg.sh (revision 2594) @@ -475,6 +475,7 @@ ditto --noextattr --noqtn ${SYMROOT}/i386/boot ${PKG_BUILD_DIR}/${choiceId}/Root/usr/standalone/i386 ditto --noextattr --noqtn ${SYMROOT}/i386/boot0 ${PKG_BUILD_DIR}/${choiceId}/Root/usr/standalone/i386 ditto --noextattr --noqtn ${SYMROOT}/i386/boot0md ${PKG_BUILD_DIR}/${choiceId}/Root/usr/standalone/i386 + ditto --noextattr --noqtn ${SYMROOT}/i386/boot0hfs ${PKG_BUILD_DIR}/${choiceId}/Root/usr/standalone/i386 ditto --noextattr --noqtn ${SYMROOT}/i386/boot1f32 ${PKG_BUILD_DIR}/${choiceId}/Root/usr/standalone/i386 ditto --noextattr --noqtn ${SYMROOT}/i386/boot1h ${PKG_BUILD_DIR}/${choiceId}/Root/usr/standalone/i386 ditto --noextattr --noqtn ${SYMROOT}/i386/boot1x ${PKG_BUILD_DIR}/${choiceId}/Root/usr/standalone/i386 Index: branches/zenith432/CHANGES =================================================================== --- branches/zenith432/CHANGES (revision 2593) +++ branches/zenith432/CHANGES (revision 2594) @@ -1,3 +1,4 @@ +- Zenith432 : Interrupt Management - Bungo : Added ability to auto-select last booted partition as the boot volume. - Bungo : Added MacOSVerCurrent and MacOSVer2Int function to use instead of macros. - Bungo : Fixed bug in gDarwinBuildVerStr extracting. Property changes on: branches/zenith432 ___________________________________________________________________ Modified: svn:mergeinfo Merged /trunk:r2580-2593