Index: branches/ErmaC/Enoch/i386/libsaio/vbe.c =================================================================== --- branches/ErmaC/Enoch/i386/libsaio/vbe.c (revision 2457) +++ branches/ErmaC/Enoch/i386/libsaio/vbe.c (revision 2458) @@ -33,8 +33,6 @@ static biosBuf_t bb; -#if UNUSED - //============================================================================== #if UNUSED static inline void @@ -71,8 +69,6 @@ #endif /* UNUSED */ //============================================================================== -#endif /* UNUSED */ - int getVBEInfo( void * infoBlock ) { bb.intno = 0x10; @@ -163,9 +159,9 @@ int paramType, VBECRTCInfoBlock * timing ) { - double h_period_est, h_freq, h_period, h_total_pixels, h_sync_pixels; + double h_period, h_total_pixels, h_sync_pixels; double h_active_pixels, h_ideal_duty_cycle, h_blank_pixels, pixel_freq = 0; - double v_sync_plus_bp = 0, v_total_lines = 0, v_field_rate_est, v_frame_rate = 0; + double v_sync_plus_bp = 0, v_total_lines = 0, v_frame_rate = 0; const double h_pixels = (double) width; const double v_lines = (double) height; @@ -195,10 +191,13 @@ double v_field_rate_in = (double) paramValue; // Estimate the horizontal period - h_period_est = ((1 / v_field_rate_in) - kMinVSyncPlusBP / 1000000) / - (v_lines + (2 * top_margin_lines) + kMinFrontPorch + interlace) * - 1000000; + double h_period_est = ((1 / v_field_rate_in) - kMinVSyncPlusBP / 1000000) / + (v_lines + (2 * top_margin_lines) + kMinFrontPorch + interlace) * + 1000000; + // Estimate the vertical field frequency + double v_field_rate_est = 1 / h_period_est / v_total_lines * 1000000; + // Number of lines in Vsync + back porch v_sync_plus_bp = Round(kMinVSyncPlusBP / h_period_est); @@ -206,9 +205,6 @@ v_total_lines = v_lines + top_margin_lines + bot_margin_lines + v_sync_plus_bp + interlace + kMinFrontPorch; - // Estimate the vertical field frequency - v_field_rate_est = 1 / h_period_est / v_total_lines * 1000000; - // Find the actual horizontal period h_period = h_period_est / (v_field_rate_in / v_field_rate_est); @@ -230,7 +226,7 @@ if (paramType == kCRTCParamPixelClock) { // Horizontal frequency - h_freq = pixel_freq / h_total_pixels * 1000; + double h_freq = pixel_freq / h_total_pixels * 1000; // Number of lines in V sync + back porch v_sync_plus_bp = Round(kMinVSyncPlusBP * h_freq / 1000); Index: branches/ErmaC/Enoch/i386/libsaio/hfs.c =================================================================== --- branches/ErmaC/Enoch/i386/libsaio/hfs.c (revision 2457) +++ branches/ErmaC/Enoch/i386/libsaio/hfs.c (revision 2458) @@ -2,7 +2,7 @@ * Copyright (c) 2000-2003 Apple Computer, Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ - * + * * 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 @@ -16,10 +16,10 @@ * 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@ - */ -/* + * + * * hfs.c - File System Module for HFS and HFS+. * * Copyright (c) 1999-2002 Apple Computer, Inc. @@ -45,8 +45,8 @@ static long long gAllocationOffset; static long gIsHFSPlus; static long gCaseSensitive; -static long gBlockSize; -static long gCacheBlockSize; +static u_int32_t gBlockSize; +static u_int32_t gCacheBlockSize; static char *gBTreeHeaderBuffer; static BTHeaderRec *gBTHeaders[2]; static char *gHFSMdbVib; @@ -59,45 +59,45 @@ #else /* !__i386__ */ -static CICell gCurrentIH; -static long long gAllocationOffset; -static long gIsHFSPlus; -static long gBlockSize; -static long gCaseSensitive; -static long gCacheBlockSize; -static char gBTreeHeaderBuffer[512]; -static BTHeaderRec *gBTHeaders[2]; -static char gHFSMdbVib[kBlockSize]; -static HFSMasterDirectoryBlock *gHFSMDB =(HFSMasterDirectoryBlock*)gHFSMdbVib; -static char gHFSPlusHeader[kBlockSize]; -static HFSPlusVolumeHeader *gHFSPlus =(HFSPlusVolumeHeader*)gHFSPlusHeader; -static char gLinkTemp[64]; -static long long gVolID; +static CICell gCurrentIH; +static long long gAllocationOffset; +static long gIsHFSPlus; +static long gCaseSensitive; +static u_int32_t gBlockSize; +static u_int32_t gCacheBlockSize; +static char gBTreeHeaderBuffer[512]; +static BTHeaderRec *gBTHeaders[2]; +static char gHFSMdbVib[kBlockSize]; +static HFSMasterDirectoryBlock *gHFSMDB =(HFSMasterDirectoryBlock*)gHFSMdbVib; +static char gHFSPlusHeader[kBlockSize]; +static HFSPlusVolumeHeader *gHFSPlus =(HFSPlusVolumeHeader*)gHFSPlusHeader; +static char gLinkTemp[64]; +static long long gVolID; #endif /* !__i386__ */ -static long ReadFile(void *file, uint64_t *length, void *base, uint64_t offset); -static long GetCatalogEntryInfo(void *entry, long *flags, long *time, +static long ReadFile(void *file, u_int64_t *length, void *base, u_int64_t offset); +static long GetCatalogEntryInfo(void *entry, long *flags, u_int32_t *time, FinderInfo *finderInfo, long *infoValid); static long ResolvePathToCatalogEntry(char *filePath, long *flags, - void *entry, long dirID, long long *dirIndex); + void *entry, u_int32_t dirID, long long *dirIndex); static long GetCatalogEntry(long long *dirIndex, char **name, - long *flags, long *time, + long *flags, u_int32_t *time, FinderInfo *finderInfo, long *infoValid); -static long ReadCatalogEntry(char *fileName, long dirID, void *entry, +static long ReadCatalogEntry(char *fileName, u_int32_t dirID, void *entry, long long *dirIndex); -static long ReadExtentsEntry(long fileID, long startBlock, void *entry); +static long ReadExtentsEntry(u_int32_t fileID, long startBlock, void *entry); static long ReadBTreeEntry(long btree, void *key, char *entry, long long *dirIndex); -static void GetBTreeRecord(long index, char *nodeBuffer, long nodeSize, +static void GetBTreeRecord(u_int16_t index, char *nodeBuffer, u_int16_t nodeSize, char **key, char **data); -static long ReadExtent(char *extent, uint64_t extentSize, long extentFile, - uint64_t offset, uint64_t size, void *buffer, long cache); +static long ReadExtent(char *extent, u_int64_t extentSize, u_int32_t extentFile, + u_int64_t offset, u_int64_t size, void *buffer, long cache); -static long GetExtentStart(void *extents, long index); -static long GetExtentSize(void *extents, long index); +static u_int32_t GetExtentStart(void *extents, u_int32_t index); +static u_int32_t GetExtentSize(void *extents, u_int32_t index); static long CompareHFSCatalogKeys(void *key, void *testKey); static long CompareHFSPlusCatalogKeys(void *key, void *testKey); @@ -108,7 +108,6 @@ extern long BinaryUnicodeCompare(u_int16_t *uniStr1, u_int32_t len1, u_int16_t *uniStr2, u_int32_t len2); - //============================================================================== static void SwapFinderInfo(FndrFileInfo *dst, FndrFileInfo *src) @@ -119,18 +118,17 @@ // Don't bother with location } - //============================================================================== void HFSFree(CICell ih) { - if(gCurrentIH == ih) { + if(gCurrentIH == ih) + { gCurrentIH = 0; } free(ih); } - //============================================================================== bool HFSProbe (const void *buf) @@ -150,13 +148,14 @@ return true; } - //============================================================================== long HFSInitPartition(CICell ih) { - long extentSize, extentFile, nodeSize; + u_int64_t extentSize; void *extent; + u_int32_t extentFile; + u_int16_t nodeSize; if (ih == gCurrentIH) { @@ -284,7 +283,6 @@ return 0; } - //============================================================================== long HFSLoadFile(CICell ih, char * filePath) @@ -292,11 +290,12 @@ return HFSReadFile(ih, filePath, (void *)gFSLoadAddress, 0, 0); } -long HFSReadFile(CICell ih, char * filePath, void *base, uint64_t offset, uint64_t length) +long HFSReadFile(CICell ih, char * filePath, void *base, u_int64_t offset, u_int64_t length) { char entry[512]; char devStr[12]; - long dirID, result, flags = 0; + u_int32_t dirID; + long result, flags; if (HFSInitPartition(ih) == -1) { @@ -358,12 +357,12 @@ return length; } -long HFSGetDirEntry(CICell ih, char * dirPath, long long * dirIndex, char ** name, long * flags, long * time, FinderInfo * finderInfo, long * infoValid) +long HFSGetDirEntry(CICell ih, char * dirPath, long long * dirIndex, char ** name, long * flags, u_int32_t * time, FinderInfo * finderInfo, long * infoValid) { char entry[512]; + u_int32_t dirID; + long dirFlags; - long dirID, dirFlags = 0; - if (HFSInitPartition(ih) == -1) { return -1; @@ -435,19 +434,19 @@ void HFSGetDescription(CICell ih, char *str, long strMaxLen) { - - UInt16 nodeSize; - UInt32 firstLeafNode; - long long dirIndex; + long long dirIndex = 0; char *name; - long flags =0, time; + long flags; + u_int32_t firstLeafNode; + u_int32_t time; + u_int16_t nodeSize; - if (HFSInitPartition(ih) == -1) { + if (HFSInitPartition(ih) == -1) + { return; } /* Fill some crucial data structures by side effect. */ - dirIndex = 0; HFSGetDirEntry(ih, "/", &dirIndex, &name, &flags, &time, 0, 0); /* Now we can loook up the volume name node. */ @@ -462,13 +461,13 @@ str[strMaxLen] = '\0'; } - //============================================================================== -long HFSGetFileBlock(CICell ih, char *filePath, unsigned long long *firstBlock) +long HFSGetFileBlock(CICell ih, char *filePath, u_int64_t *firstBlock) { char entry[512]; - long dirID, result, flags =0; + long result, flags; + u_int32_t dirID; void *extents; HFSCatalogFile *hfsFile = (void *)entry; HFSPlusCatalogFile *hfsPlusFile = (void *)entry; @@ -479,9 +478,7 @@ } dirID = kHFSRootFolderID; - - // Skip a lead '\'. Start in the system folder if there are two. - + // Skip a lead '/'. Start in the system folder if there are two. if (filePath[0] == '/') { if (filePath[1] == '/') @@ -519,13 +516,11 @@ } #if DEBUG - printf("extent start 0x%x\n", (unsigned long)GetExtentStart(extents, 0)); - printf("block size 0x%x\n", (unsigned long)gBlockSize); + printf("extent start 0x%x\n", GetExtentStart(extents, 0)); + printf("block size 0x%x\n", gBlockSize); printf("Allocation offset 0x%x\n", (unsigned long)gAllocationOffset); #endif - - *firstBlock = ((unsigned long long)GetExtentStart(extents, 0) * (unsigned long long) gBlockSize + gAllocationOffset) / 512ULL; - + *firstBlock = ((u_int64_t) GetExtentStart(extents, 0) * (u_int64_t) gBlockSize + gAllocationOffset) / 512ULL; return 0; } @@ -550,16 +545,14 @@ //============================================================================== // Private Functions -static long ReadFile(void * file, uint64_t * length, void * base, uint64_t offset) +static long ReadFile(void * file, u_int64_t * length, void * base, u_int64_t offset) { - void *extents; - long fileID; + u_int64_t fileLength; + void *extents; + HFSCatalogFile *hfsFile = file; + HFSPlusCatalogFile *hfsPlusFile = file; + u_int32_t fileID; - uint64_t fileLength; - - HFSCatalogFile *hfsFile = file; - HFSPlusCatalogFile *hfsPlusFile = file; - if (gIsHFSPlus) { fileID = SWAP_BE32(hfsPlusFile->fileID); @@ -600,14 +593,14 @@ //============================================================================== -static long GetCatalogEntryInfo(void * entry, long * flags, long * time, FinderInfo * finderInfo, long * infoValid) +static long GetCatalogEntryInfo(void * entry, long * flags, u_int32_t * time, FinderInfo * finderInfo, long * infoValid) { - long tmpTime = 0; + u_int32_t tmpTime = 0; long valid = 0; // Get information about the file. - switch (SWAP_BE16(*(short *)entry)) + switch ( SWAP_BE16(*(short *)entry) ) { case kHFSFolderRecord : *flags = kFileTypeDirectory; @@ -654,8 +647,6 @@ *flags = kFileTypeUnknown; tmpTime = 0; break; - default: - break; } if (time != 0) @@ -672,13 +663,13 @@ return 0; } - //============================================================================== -static long ResolvePathToCatalogEntry(char * filePath, long * flags, void * entry, long dirID, long long * dirIndex) +static long ResolvePathToCatalogEntry(char * filePath, long * flags, void * entry, u_int32_t dirID, long long * dirIndex) { char *restPath; - long result, cnt, subFolderID = 0; + long result, cnt; + u_int32_t subFolderID = 0; long long tmpDirIndex; HFSPlusCatalogFile *hfsPlusFile; @@ -742,15 +733,16 @@ return result; } - //============================================================================== -static long GetCatalogEntry(long long * dirIndex, char ** name, long * flags, long * time, FinderInfo * finderInfo, long * infoValid) +static long GetCatalogEntry(long long * dirIndex, char ** name, long * flags, u_int32_t * time, FinderInfo * finderInfo, long * infoValid) { - long extentSize, nodeSize, curNode, index; + u_int64_t extentSize; void *extent; char *nodeBuf, *testKey, *entry; BTNodeDescriptor *node; + u_int32_t curNode; + u_int16_t nodeSize, index; if (gIsHFSPlus) { @@ -767,11 +759,12 @@ nodeBuf = (char *)malloc(nodeSize); node = (BTNodeDescriptor *)nodeBuf; - index = (long) (*dirIndex % nodeSize); - curNode = (long) (*dirIndex / nodeSize); + index = (u_int16_t) (*dirIndex % nodeSize); + curNode = (u_int32_t) (*dirIndex / nodeSize); // Read the BTree node and get the record for index. ReadExtent(extent, extentSize, kHFSCatalogFileID, (long long) curNode * nodeSize, nodeSize, nodeBuf, 1); + GetBTreeRecord(index, nodeBuf, nodeSize, &testKey, &entry); GetCatalogEntryInfo(entry, flags, time, finderInfo, infoValid); @@ -806,39 +799,36 @@ return 0; } - //============================================================================== -static long ReadCatalogEntry(char * fileName, long dirID, void * entry, long long * dirIndex) +static long ReadCatalogEntry(char * fileName, u_int32_t dirID, void * entry, long long * dirIndex) { - long length = 0; + long length = strlen(fileName); char key[sizeof(HFSPlusCatalogKey)]; HFSCatalogKey *hfsKey = (HFSCatalogKey *)key; HFSPlusCatalogKey *hfsPlusKey = (HFSPlusCatalogKey *)key; // Make the catalog key. - if (gIsHFSPlus) + if ( gIsHFSPlus ) { - hfsPlusKey->parentID = SWAP_BE32(dirID); - length = strlen(fileName); - - if (length > 255) + if (length > kHFSPlusMaxFileNameChars) { - length = 255; + length = kHFSPlusMaxFileNameChars; } + hfsPlusKey->parentID = SWAP_BE32(dirID); + utf_decodestr((u_int8_t *)fileName, hfsPlusKey->nodeName.unicode, &(hfsPlusKey->nodeName.length), 512, OSBigEndian); } else { - hfsKey->parentID = SWAP_BE32(dirID); - length = strlen(fileName); - - if (length > 31) + if (length > kHFSMaxFileNameChars) { - length = 31; + length = kHFSMaxFileNameChars; } + hfsKey->parentID = SWAP_BE32(dirID); + hfsKey->nodeName[0] = length; strncpy((char *)(hfsKey->nodeName + 1), fileName, length); } @@ -846,10 +836,9 @@ return ReadBTreeEntry(kBTreeCatalog, &key, entry, dirIndex); } - //============================================================================== -static long ReadExtentsEntry(long fileID, long startBlock, void * entry) +static long ReadExtentsEntry(u_int32_t fileID, long startBlock, void * entry) { char key[sizeof(HFSPlusExtentKey)]; HFSExtentKey *hfsKey = (HFSExtentKey *)key; @@ -872,19 +861,19 @@ return ReadBTreeEntry(kBTreeExtents, &key, entry, 0); } - //============================================================================== static long ReadBTreeEntry(long btree, void * key, char * entry, long long * dirIndex) { - long extentSize; + u_int64_t extentSize; void *extent; - short extentFile; + u_int16_t extentFile; char *nodeBuf; BTNodeDescriptor *node; - long nodeSize, result = 0, entrySize = 0; - long curNode, index = 0, lowerBound, upperBound; - char *testKey, *recordData =0; + long result = 0, entrySize = 0; + u_int32_t curNode; + char *testKey, *recordData; + u_int16_t nodeSize, index = 0, lowerBound, upperBound; // Figure out which tree is being looked at. if (btree == kBTreeCatalog) @@ -981,7 +970,7 @@ } else { - break; // search = trial + break; // search = trial } } @@ -1064,17 +1053,16 @@ //============================================================================== -static void GetBTreeRecord(long index, char * nodeBuffer, long nodeSize, char ** key, char ** data) +static void GetBTreeRecord(u_int16_t index, char * nodeBuffer, u_int16_t nodeSize, char ** key, char ** data) { - long keySize; - long recordOffset; + u_int16_t recordOffset, keySize; - recordOffset = SWAP_BE16(*((short *)(nodeBuffer + (nodeSize - 2 * index - 2)))); + recordOffset = SWAP_BE16(*((u_int16_t *)(nodeBuffer + (nodeSize - 2 * index - 2)))); *key = nodeBuffer + recordOffset; if (gIsHFSPlus) { - keySize = SWAP_BE16(*(short *)*key); + keySize = SWAP_BE16(*(u_int16_t *)*key); *data = *key + 2 + keySize; } else @@ -1086,15 +1074,15 @@ //============================================================================== -static long ReadExtent(char * extent, uint64_t extentSize, long extentFile, uint64_t offset, uint64_t size, void * buffer, long cache) +static long ReadExtent(char * extent, u_int64_t extentSize, u_int32_t extentFile, u_int64_t offset, u_int64_t size, void * buffer, long cache) { - uint64_t lastOffset; - long long blockNumber, countedBlocks = 0; - long long nextExtent = 0, sizeRead = 0, readSize; - long long nextExtentBlock, currentExtentBlock = 0; - long long readOffset; - long long extentDensity, sizeofExtent, currentExtentSize; - char *currentExtent, *extentBuffer = 0, *bufferPos = buffer; + u_int64_t lastOffset; + u_int64_t blockNumber, countedBlocks = 0; + u_int64_t nextExtent = 0, sizeRead = 0, readSize; + u_int64_t nextExtentBlock, currentExtentBlock = 0; + u_int64_t readOffset; + u_int64_t extentDensity, sizeofExtent, currentExtentSize; + char *currentExtent, *extentBuffer = 0, *bufferPos = buffer; if (offset >= extentSize) { @@ -1191,9 +1179,9 @@ //============================================================================== -static long GetExtentStart(void * extents, long index) +static u_int32_t GetExtentStart(void * extents, u_int32_t index) { - long start; + u_int32_t start; HFSExtentDescriptor *hfsExtents = extents; HFSPlusExtentDescriptor *hfsPlusExtents = extents; @@ -1210,12 +1198,11 @@ return start; } - //============================================================================== -static long GetExtentSize(void * extents, long index) +static u_int32_t GetExtentSize(void * extents, u_int32_t index) { - long size = 0; + u_int32_t size = 0; HFSExtentDescriptor *hfsExtents = extents; HFSPlusExtentDescriptor *hfsPlusExtents = extents; @@ -1232,7 +1219,6 @@ return size; } - //============================================================================== static long CompareHFSCatalogKeys(void * key, void * testKey) @@ -1264,7 +1250,6 @@ return result; } - //============================================================================== static long CompareHFSPlusCatalogKeys(void * key, void * testKey) @@ -1313,7 +1298,6 @@ return result; } - //============================================================================== static long CompareHFSExtentsKeys(void * key, void * testKey) @@ -1373,13 +1357,16 @@ static long CompareHFSPlusExtentsKeys(void * key, void * testKey) { - HFSPlusExtentKey *searchKey, *trialKey; + HFSPlusExtentKey *searchKey, *trialKey; - long result = -1; // assume searchKey < trialKey + long result; searchKey = key; trialKey = testKey; + // assume searchKey < trialKey + result = -1; + if (searchKey->fileID == trialKey->fileID) { // FileNum's are equal; compare fork types Index: branches/ErmaC/Enoch/i386/libsaio/acpi_patcher.c =================================================================== --- branches/ErmaC/Enoch/i386/libsaio/acpi_patcher.c (revision 2457) +++ branches/ErmaC/Enoch/i386/libsaio/acpi_patcher.c (revision 2458) @@ -126,14 +126,13 @@ void *loadACPITable (const char * filename) { - void *tableAddr; const char * dirspec=NULL; int fd = search_and_get_acpi_fd(filename, &dirspec); if (fd>=0) { - tableAddr=(void*)AllocateKernelMemory(file_size (fd)); + void *tableAddr = (void*)AllocateKernelMemory(file_size (fd)); if (tableAddr) { if (read (fd, tableAddr, file_size (fd))!=file_size (fd)) @@ -212,7 +211,7 @@ struct acpi_2_ssdt *generate_cst_ssdt(struct acpi_2_fadt* fadt) { - char ssdt_header[] = // cst_ssdt_header + static char ssdt_header[] = // cst_ssdt_header { 0x53, 0x53, 0x44, 0x54, 0xE7, 0x00, 0x00, 0x00, /* SSDT.... */ 0x01, 0x17, 0x50, 0x6D, 0x52, 0x65, 0x66, 0x41, /* ..PmRefA */ @@ -415,7 +414,7 @@ struct acpi_2_ssdt *generate_pss_ssdt(struct acpi_2_dsdt* dsdt) { - char ssdt_header[] = // pss_ssdt_header + static char ssdt_header[] = // pss_ssdt_header { 0x53, 0x53, 0x44, 0x54, 0x7E, 0x00, 0x00, 0x00, /* SSDT.... */ 0x01, 0x6A, 0x50, 0x6D, 0x52, 0x65, 0x66, 0x00, /* ..PmRef. */ @@ -519,7 +518,7 @@ p_states_count = 0; } else { uint8_t vidstep; - uint8_t i = 0, u, invalid = 0; + uint8_t u, invalid = 0; // Finalize P-States // Find how many P-States machine supports p_states_count = (uint8_t)(maximum.CID - minimum.CID + 1); @@ -531,7 +530,7 @@ vidstep = ((maximum.VID << 2) - (minimum.VID << 2)) / (p_states_count - 1); for (u = 0; u < p_states_count; u++) { - i = u - invalid; + uint8_t i = u - invalid; p_states[i].CID = maximum.CID - u; p_states[i].FID = (uint8_t)(p_states[i].CID >> 1); @@ -977,7 +976,7 @@ rsdt=(struct acpi_2_rsdt *)(rsdp->RsdtAddress); - DBG("RSDT @%x, Length %d\n",rsdt, rsdt->Length); + DBG("RSDT @%x, Length %d\n",rsdt, rsdt ? rsdt->Length : 0); if (rsdt && (uint32_t)rsdt !=0xffffffff && rsdt->Length<0x10000) { uint32_t *rsdt_entries; Index: branches/ErmaC/Enoch/i386/libsaio/hfs.h =================================================================== --- branches/ErmaC/Enoch/i386/libsaio/hfs.h (revision 2457) +++ branches/ErmaC/Enoch/i386/libsaio/hfs.h (revision 2458) @@ -20,14 +20,16 @@ * @APPLE_LICENSE_HEADER_END@ */ +#include + extern long HFSInitPartition(CICell ih); extern long HFSLoadFile(CICell ih, char * filePath); -extern long HFSReadFile(CICell ih, char * filePath, void *base, uint64_t offset, uint64_t length); +extern long HFSReadFile(CICell ih, char * filePath, void *base, u_int64_t offset, u_int64_t length); extern long HFSGetDirEntry(CICell ih, char * dirPath, long long * dirIndex, - char ** name, long * flags, long * time, + char ** name, long * flags, u_int32_t * time, FinderInfo * finderInfo, long * infoValid); extern void HFSGetDescription(CICell ih, char *str, long strMaxLen); -extern long HFSGetFileBlock(CICell ih, char *str, unsigned long long *firstBlock); +extern long HFSGetFileBlock(CICell ih, char *str, u_int64_t *firstBlock); extern long HFSGetUUID(CICell ih, char *uuidStr); extern void HFSFree(CICell ih); extern bool HFSProbe (const void *buf); Index: branches/ErmaC/Enoch/i386/libsaio/bootargs.h =================================================================== --- branches/ErmaC/Enoch/i386/libsaio/bootargs.h (revision 2457) +++ branches/ErmaC/Enoch/i386/libsaio/bootargs.h (revision 2458) @@ -131,6 +131,7 @@ #define kBootArgsFlagRebootOnPanic (1 << 0) #define kBootArgsFlagHiDPI (1 << 1) #define kBootArgsFlagBlack (1 << 2) + typedef struct boot_args_pre_lion { uint16_t Revision; /* Revision of boot_args structure */ @@ -166,10 +167,6 @@ } boot_args_pre_lion; -/* Bitfields for boot_args->flags */ -#define kBootArgsFlagRebootOnPanic (1 << 0) -#define kBootArgsFlagHiDPI (1 << 1) - typedef struct boot_args { uint16_t Revision; /* Revision of boot_args structure */ Index: branches/ErmaC/Enoch/i386/libsaio/ufs.h =================================================================== --- branches/ErmaC/Enoch/i386/libsaio/ufs.h (revision 2457) +++ branches/ErmaC/Enoch/i386/libsaio/ufs.h (revision 2458) @@ -24,7 +24,7 @@ extern long UFSLoadFile(CICell ih, char * filePath); extern long UFSReadFile( CICell ih, char * filePath, void * base, uint64_t offset, uint64_t length ); extern long UFSGetDirEntry(CICell ih, char * dirPath, long long * dirIndex, - char ** name, long * flags, long * time, + char ** name, long * flags, u_int32_t * time, FinderInfo * finderInfo, long * infoValid); extern void UFSGetDescription(CICell ih, char *str, long strMaxLen); extern long UFSGetFileBlock(CICell ih, char *str, unsigned long long *firstBlock); Index: branches/ErmaC/Enoch/i386/libsaio/aml_generator.c =================================================================== --- branches/ErmaC/Enoch/i386/libsaio/aml_generator.c (revision 2457) +++ branches/ErmaC/Enoch/i386/libsaio/aml_generator.c (revision 2458) @@ -85,7 +85,7 @@ free(node); } -AML_CHUNK* aml_add_buffer(AML_CHUNK* parent, char* buffer, uint32_t size) +AML_CHUNK* aml_add_buffer(AML_CHUNK* parent, const char* buffer, uint32_t size) { AML_CHUNK* node = aml_create_node(parent); Index: branches/ErmaC/Enoch/i386/libsaio/aml_generator.h =================================================================== --- branches/ErmaC/Enoch/i386/libsaio/aml_generator.h (revision 2457) +++ branches/ErmaC/Enoch/i386/libsaio/aml_generator.h (revision 2458) @@ -186,7 +186,7 @@ bool aml_add_to_parent(AML_CHUNK* parent, AML_CHUNK* node); AML_CHUNK* aml_create_node(AML_CHUNK* parent); void aml_destroy_node(AML_CHUNK* node); -AML_CHUNK* aml_add_buffer(AML_CHUNK* parent, char* buffer, uint32_t size); +AML_CHUNK* aml_add_buffer(AML_CHUNK* parent, const char* buffer, uint32_t size); AML_CHUNK* aml_add_byte(AML_CHUNK* parent, uint8_t value); AML_CHUNK* aml_add_word(AML_CHUNK* parent, uint16_t value); AML_CHUNK* aml_add_dword(AML_CHUNK* parent, uint32_t value); Index: branches/ErmaC/Enoch/i386/libsaio/ati.c =================================================================== --- branches/ErmaC/Enoch/i386/libsaio/ati.c (revision 2457) +++ branches/ErmaC/Enoch/i386/libsaio/ati.c (revision 2458) @@ -941,7 +941,8 @@ idx++; memsize = ((uint64_t)card->vram_size << 32); - if (idx == 0) { + if (idx == 0) + { memsize = memsize | (uint64_t)card->vram_size; } val->type = kCst; @@ -953,7 +954,8 @@ bool get_binimage_val(value_t *val) { - if (!card->rom) { + if (!card->rom) + { return false; } val->type = kPtr; @@ -963,12 +965,12 @@ return true; } - bool get_romrevision_val(value_t *val) { char *cRev="109-B77101-00"; uint8_t *rev; - if (!card->rom) { + if (!card->rom) + { val->type = kPtr; val->size = 13; val->data = malloc(val->size); Index: branches/ErmaC/Enoch/i386/libsaio/sys.c =================================================================== --- branches/ErmaC/Enoch/i386/libsaio/sys.c (revision 2457) +++ branches/ErmaC/Enoch/i386/libsaio/sys.c (revision 2458) @@ -344,7 +344,7 @@ // Fetch the next directory entry for the given directory. long GetDirEntry(const char * dirSpec, long long * dirIndex, const char ** name, - long * flags, long * time) + long * flags, u_int32_t * time) { const char * dirPath; BVRef bvr; @@ -370,7 +370,7 @@ static char* gMakeDirSpec; long GetFileInfo(const char * dirSpec, const char * name, - long * flags, long * time) + long * flags, u_int32_t * time) { long long index = 0; const char * entryName; @@ -796,7 +796,7 @@ //========================================================================== int readdir(struct dirstuff * dirp, const char ** name, long * flags, - long * time) + u_int32_t * time) { return dirp->dir_bvr->fs_getdirentry(dirp->dir_bvr, /* dirPath */ dirp->dir_path, @@ -807,7 +807,7 @@ //========================================================================== int readdir_ext(struct dirstuff * dirp, const char ** name, long * flags, - long * time, FinderInfo *finderInfo, long *infoValid) + u_int32_t * time, FinderInfo *finderInfo, long *infoValid) { return dirp->dir_bvr->fs_getdirentry( dirp->dir_bvr, /* dirPath */ dirp->dir_path, Index: branches/ErmaC/Enoch/i386/libsaio/platform.h =================================================================== --- branches/ErmaC/Enoch/i386/libsaio/platform.h (revision 2457) +++ branches/ErmaC/Enoch/i386/libsaio/platform.h (revision 2458) @@ -13,7 +13,25 @@ extern void scan_platform(void); extern void dumpPhysAddr(const char * title, void * a, int len); +/* CPUID Vendor */ +#define CPUID_VENDOR_INTEL 0x756E6547 +#define CPUID_VENDOR_AMD 0x68747541 +/* CPUID index into cpuid_raw */ +#define CPUID_0 0 +#define CPUID_1 1 +#define CPUID_2 2 +#define CPUID_3 3 +#define CPUID_4 4 +#define CPUID_5 5 +#define CPUID_6 6 +#define CPUID_80 7 +#define CPUID_81 8 +#define CPUID_88 9 +#define CPUID_MAX 10 + +#define CPU_MODEL_ANY 0x00 +#define CPU_MODEL_UNKNOWN 0x01 #define CPU_MODEL_PRESCOTT 0x03 // Celeron D, Pentium 4 (90nm) #define CPU_MODEL_NOCONA 0x04 // Xeon Nocona/Paxville, Irwindale (90nm) #define CPU_MODEL_PRESLER 0x06 // Pentium 4, Pentium D (65nm) @@ -57,10 +75,6 @@ // 5A silvermont / atom // 5D silvermont / atom -/* CPUID Vendor */ -#define CPUID_VENDOR_INTEL 0x756E6547 -#define CPUID_VENDOR_AMD 0x68747541 - /* Unknown CPU */ #define CPU_STRING_UNKNOWN "Unknown CPU Type" #define bit(n) (1ULL << (n)) @@ -239,19 +253,6 @@ // DFE: This constant comes from older xnu: #define CLKNUM 1193182 /* formerly 1193167 */ -/* CPUID index into cpuid_raw */ -#define CPUID_0 0 -#define CPUID_1 1 -#define CPUID_2 2 -#define CPUID_3 3 -#define CPUID_4 4 -#define CPUID_5 5 -#define CPUID_6 6 -#define CPUID_80 7 -#define CPUID_81 8 -#define CPUID_88 9 -#define CPUID_MAX 10 - /* CPU Features */ #define CPU_FEATURE_MMX 0x00000001 // MMX Instruction Set #define CPU_FEATURE_SSE 0x00000002 // SSE Instruction Set Index: branches/ErmaC/Enoch/i386/libsaio/disk.c =================================================================== --- branches/ErmaC/Enoch/i386/libsaio/disk.c (revision 2457) +++ branches/ErmaC/Enoch/i386/libsaio/disk.c (revision 2458) @@ -760,7 +760,7 @@ (*bvr->bv_free)(bvr); bvr = NULL; } - if ( readBootSector( biosdev, blkoff, (void *)0x7e00 ) == 0 ) + else if ( readBootSector( biosdev, blkoff, (void *)0x7e00 ) == 0 ) { bvr->flags |= kBVFlagBootable; } @@ -1040,7 +1040,7 @@ * an Apple partition map elsewhere. */ #if UNUSED - if (map->bvrcnt == 0) + if (map && map->bvrcnt == 0) { static struct fdisk_part cdpart; cdpart.systid = 0xCD; @@ -1066,7 +1066,8 @@ } #endif // Actually this should always be true given the above code - if(map == gDiskBVMap) + // (unless malloc failed above) + if(map && map == gDiskBVMap) { // Don't leave a null map in the chain if(map->bvrcnt == 0 && map->bvr == NULL) @@ -1647,7 +1648,8 @@ char dirSpec[512], fileSpec[512]; char label[BVSTRLEN]; int ret; - long flags, time; + long flags; + u_int32_t time; int fh, fileSize, error; for (bvr = chain; bvr; bvr = bvr->next) { Index: branches/ErmaC/Enoch/i386/libsaio/hpet.c =================================================================== --- branches/ErmaC/Enoch/i386/libsaio/hpet.c (revision 2457) +++ branches/ErmaC/Enoch/i386/libsaio/hpet.c (revision 2458) @@ -242,7 +242,9 @@ lpc_controllers_intel[i].name, lpc_dev->vendor_id, lpc_dev->device_id, rcba); if (rcba == 0) + { printf(" RCBA disabled; cannot force enable HPET\n"); + } else { val = REG32(rcba, 0x3404); Index: branches/ErmaC/Enoch/i386/libsaio/cache.c =================================================================== --- branches/ErmaC/Enoch/i386/libsaio/cache.c (revision 2457) +++ branches/ErmaC/Enoch/i386/libsaio/cache.c (revision 2458) @@ -43,7 +43,7 @@ #define kCacheMaxEntries (kCacheSize / kCacheMinBlockSize) static CICell gCacheIH; -static long gCacheBlockSize; +static u_int32_t gCacheBlockSize; static long gCacheNumEntries; static long gCacheTime; @@ -66,7 +66,7 @@ gCacheIH = NULL; } -void CacheInit( CICell ih, long blockSize ) +void CacheInit( CICell ih, u_int32_t blockSize ) { #ifdef __i386__ if ((ih == gCacheIH) && (blockSize == gCacheBlockSize)) @@ -113,7 +113,7 @@ bzero(gCacheEntries, kCacheMaxEntries * sizeof(CacheEntry)); } -long CacheRead(CICell ih, char * buffer, long long offset, long length, long cache) +u_int32_t CacheRead(CICell ih, char * buffer, long long offset, u_int32_t length, long cache) { long cnt, oldestEntry = 0, oldestTime, loadCache = 0; CacheEntry *entry; Index: branches/ErmaC/Enoch/i386/libsaio/saio_types.h =================================================================== --- branches/ErmaC/Enoch/i386/libsaio/saio_types.h (revision 2457) +++ branches/ErmaC/Enoch/i386/libsaio/saio_types.h (revision 2458) @@ -153,7 +153,7 @@ typedef long (*FSReadFile)(CICell ih, char *filePath, void *base, uint64_t offset, uint64_t length); typedef long (*FSGetFileBlock)(CICell ih, char *filePath, unsigned long long *firstBlock); typedef long (*FSGetDirEntry)(CICell ih, char * dirPath, long long * dirIndex, - char ** name, long * flags, long * time, + char ** name, long * flags, u_int32_t * time, FinderInfo * finderInfo, long * infoValid); typedef long (*FSGetUUID)(CICell ih, char *uuidStr); typedef void (*BVGetDescription)(CICell ih, char * str, long strMaxLen); Index: branches/ErmaC/Enoch/i386/libsaio/msdos.c =================================================================== --- branches/ErmaC/Enoch/i386/libsaio/msdos.c (revision 2457) +++ branches/ErmaC/Enoch/i386/libsaio/msdos.c (revision 2458) @@ -648,7 +648,7 @@ } long MSDOSGetDirEntry(CICell ih, char * dirPath, long long * dirIndex, - char ** name, long * flags, long * time, + char ** name, long * flags, u_int32_t * time, FinderInfo * finderInfo, long * infoValid) { struct msdosdirstate *st; Index: branches/ErmaC/Enoch/i386/libsaio/fake_efi.c =================================================================== --- branches/ErmaC/Enoch/i386/libsaio/fake_efi.c (revision 2457) +++ branches/ErmaC/Enoch/i386/libsaio/fake_efi.c (revision 2458) @@ -771,6 +771,7 @@ } cpuTick = getCPUTick(); // callq 0x121a7 +// printf("value: 0x%llx\n", getCPUTick()); rcx = (cpuTick >> 8); // mov %rax, %rcx // shr $0x8, %rcx rdx = (cpuTick >> 10); // mov %rax, %rdx Index: branches/ErmaC/Enoch/i386/libsaio/msdos.h =================================================================== --- branches/ErmaC/Enoch/i386/libsaio/msdos.h (revision 2457) +++ branches/ErmaC/Enoch/i386/libsaio/msdos.h (revision 2458) @@ -25,7 +25,7 @@ extern long MSDOSLoadFile(CICell ih, char * filePath); extern long MSDOSReadFile(CICell ih, char * filePath, void *base, uint64_t offset, uint64_t length); extern long MSDOSGetDirEntry(CICell ih, char * dirPath, long long * dirIndex, - char ** name, long * flags, long * time, + char ** name, long * flags, u_int32_t * time, FinderInfo * finderInfo, long * infoValid); extern long MSDOSGetFileBlock(CICell ih, char *str, unsigned long long *firstBlock); extern long MSDOSGetUUID(CICell ih, char *uuidStr); Index: branches/ErmaC/Enoch/i386/libsaio/saio_internal.h =================================================================== --- branches/ErmaC/Enoch/i386/libsaio/saio_internal.h (revision 2457) +++ branches/ErmaC/Enoch/i386/libsaio/saio_internal.h (revision 2458) @@ -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@ */ @@ -80,11 +80,10 @@ extern void finalizeBootStruct(void); /* cache.c */ -extern void CacheReset(); -extern void CacheInit(CICell ih, long blockSize); -extern long CacheRead(CICell ih, char *buffer, long long offset, long length, long cache); +extern void CacheReset(); +extern void CacheInit(CICell ih, u_int32_t blockSize); +extern u_int32_t CacheRead(CICell ih, char *buffer, long long offset, u_int32_t length, long cache); - /* console.c */ extern bool gVerboseMode; extern bool gErrors; @@ -96,7 +95,7 @@ extern int printf(const char *format, ...); extern int error(const char *format, ...); extern int verbose(const char *format, ...); -extern void stop(const char *format, ...); +extern void stop(const char *format, ...) __attribute__ ((noreturn)); //Azi: replace getc/getchar with ? console.c extern void pause(); @@ -176,9 +175,9 @@ extern long ReadFileAtOffset(const char * fileSpec, void *buffer, uint64_t offset, uint64_t length); extern long LoadThinFatFile(const char *fileSpec, void **binary); extern long GetDirEntry(const char *dirSpec, long long *dirIndex, const char **name, - long *flags, long *time); + long *flags, u_int32_t *time); extern long GetFileInfo(const char *dirSpec, const char *name, - long *flags, long *time); + long *flags, u_int32_t *time); extern long GetFileBlock(const char *fileSpec, unsigned long long *firstBlock); extern long GetFSUUID(char *spec, char *uuidStr); extern long CreateUUIDString(uint8_t uubytes[], int nbytes, char *uuidStr); @@ -197,9 +196,9 @@ extern struct dirstuff * opendir(const char *path); extern struct dirstuff * vol_opendir(BVRef bvr, const char *path); extern int closedir(struct dirstuff *dirp); -extern int readdir(struct dirstuff *dirp, const char **name, long *flags, long *time); +extern int readdir(struct dirstuff *dirp, const char **name, long *flags, u_int32_t *time); extern int readdir_ext(struct dirstuff * dirp, const char ** name, long * flags, - long * time, FinderInfo *finderInfo, long *infoValid); + u_int32_t * time, FinderInfo *finderInfo, long *infoValid); extern void flushdev(void); extern void scanBootVolumes(int biosdev, int *count); extern void scanDisks(int biosdev, int *count); Index: branches/ErmaC/Enoch/i386/boot2/picopng.c =================================================================== --- branches/ErmaC/Enoch/i386/boot2/picopng.c (revision 2457) +++ branches/ErmaC/Enoch/i386/boot2/picopng.c (revision 2458) @@ -241,35 +241,33 @@ return 1; } -uint32_t vector8_resizev(vector8_t *p, size_t size, uint8_t value) -{ // resize and give all new elements the value - size_t oldsize = p->size, i; - if (!vector8_resize(p, size)) - return 0; - for (i = oldsize; i < size; i++) - p->data[i] = value; - return 1; -} - -void vector8_init(vector8_t *p) -{ - p->data = NULL; - p->size = p->allocsize = 0; -} - vector8_t *vector8_new(size_t size, uint8_t value) { vector8_t *p = png_alloc_malloc(sizeof (vector8_t)); - if(!p) + if (!p) { return NULL; } - vector8_init(p); - if (size && !vector8_resizev(p, size, value)) + + p->data = NULL; + p->size = p->allocsize = 0; + if (size) { - vector8_cleanup(p); - png_alloc_free(p); - return NULL; + size_t i; + size_t newsize = size * sizeof (uint32_t) * 2; + void *data = png_alloc_malloc(newsize); + if (!data) + { + png_alloc_free(p); + return NULL; + } + p->data = (uint8_t *) data; + p->allocsize = newsize; + p->size = size; + for (i = 0; i < size; ++i) + { + p->data[i] = value; + } } return p; } @@ -928,12 +926,21 @@ int PNG_convert(const PNG_info_t *info, vector8_t *out, const uint8_t *in) { // converts from any color type to 32-bit. return value = LodePNG error code size_t i, c; - uint32_t bitDepth, colorType; - bitDepth = info->bitDepth; - colorType = info->colorType; - size_t numpixels = info->width * info->height, bp = 0; - vector8_resize(out, numpixels * 4); - uint8_t *out_data = out->size ? out->data : 0; + size_t numpixels = info->width * info->height; + if (!numpixels) + { + return 0; // nothing to do + } + + if (!vector8_resize(out, numpixels * 4)) + { + return 83; // out of memory + } + + size_t bp = 0; + uint32_t bitDepth = info->bitDepth; + uint32_t colorType = info->colorType; + uint8_t *out_data = out->data; if (bitDepth == 8 && colorType == 0) // greyscale for (i = 0; i < numpixels; i++) { @@ -949,14 +956,16 @@ (in[3 * i + 1] == info->key_g) && (in[3 * i + 2] == info->key_b)) ? 0 : 255; } else if (bitDepth == 8 && colorType == 3) // indexed color (palette) - for (i = 0; i < numpixels; i++) { + for (i = 0; i < numpixels; i++) + { if (4U * in[i] >= info->palette->size) return 46; for (c = 0; c < 4; c++) // get rgb colors from the palette out_data[4 * i + c] = info->palette->data[4 * in[i] + c]; } else if (bitDepth == 8 && colorType == 4) // greyscale with alpha - for (i = 0; i < numpixels; i++) { + for (i = 0; i < numpixels; i++) + { out_data[4 * i + 0] = out_data[4 * i + 1] = out_data[4 * i + 2] = in[2 * i + 0]; out_data[4 * i + 3] = in[2 * i + 1]; } @@ -965,13 +974,15 @@ for (c = 0; c < 4; c++) out_data[4 * i + c] = in[4 * i + c]; // RGB with alpha else if (bitDepth == 16 && colorType == 0) // greyscale - for (i = 0; i < numpixels; i++) { + for (i = 0; i < numpixels; i++) + { out_data[4 * i + 0] = out_data[4 * i + 1] = out_data[4 * i + 2] = in[2 * i]; out_data[4 * i + 3] = (info->key_defined && (256U * in[i] + in[i + 1] == info->key_r)) ? 0 : 255; } else if (bitDepth == 16 && colorType == 2) // RGB color - for (i = 0; i < numpixels; i++) { + for (i = 0; i < numpixels; i++) + { for (c = 0; c < 3; c++) out_data[4 * i + c] = in[6 * i + 2 * c]; out_data[4 * i + 3] = (info->key_defined && @@ -980,7 +991,8 @@ (256U * in[6 * i + 4] + in[6 * i + 5] == info->key_b)) ? 0 : 255; } else if (bitDepth == 16 && colorType == 4) // greyscale with alpha - for (i = 0; i < numpixels; i++) { + for (i = 0; i < numpixels; i++) + { out_data[4 * i + 0] = out_data[4 * i + 1] = out_data[4 * i + 2] = in[4 * i]; // msb out_data[4 * i + 3] = in[4 * i + 2]; } @@ -989,7 +1001,8 @@ for (c = 0; c < 4; c++) out_data[4 * i + c] = in[8 * i + 2 * c]; // RGB with alpha else if (bitDepth < 8 && colorType == 0) // greyscale - for (i = 0; i < numpixels; i++) { + for (i = 0; i < numpixels; i++) + { uint32_t value = (PNG_readBitsFromReversedStream(&bp, in, bitDepth) * 255) / ((1 << bitDepth) - 1); // scale value from 0 to 255 out_data[4 * i + 0] = out_data[4 * i + 1] = out_data[4 * i + 2] = (uint8_t) value; @@ -997,7 +1010,8 @@ (((1U << bitDepth) - 1U) == info->key_r) && ((1U << bitDepth) - 1U)) ? 0 : 255; } else if (bitDepth < 8 && colorType == 3) // palette - for (i = 0; i < numpixels; i++) { + for (i = 0; i < numpixels; i++) + { uint32_t value = PNG_readBitsFromReversedStream(&bp, in, bitDepth); if (4 * value >= info->palette->size) return 47; @@ -1026,7 +1040,8 @@ { PNG_info_t *info; PNG_error = 0; - if (size == 0 || in == 0) { + if (size == 0 || in == 0) + { PNG_error = 48; // the given data is empty return NULL; } @@ -1038,23 +1053,27 @@ } size_t pos = 33; // first byte of the first chunk after the header vector8_t *idat = NULL; // the data from idat chunks - bool IEND = false, known_type = true; + bool IEND = false; info->key_defined = false; // loop through the chunks, ignoring unknown chunks and stopping at IEND chunk. IDAT data is // put at the start of the in buffer - while (!IEND) { - size_t i, j; - if (pos + 8 >= size) { + while (!IEND) + { + size_t i; + if (pos + 8 >= size) + { PNG_error = 30; // error: size of the in buffer too small to contain next chunk return NULL; } size_t chunkLength = PNG_read32bitInt(&in[pos]); pos += 4; - if (chunkLength > 0x7fffffff) { + if (chunkLength > 0x7fffffff) + { PNG_error = 63; return NULL; } - if (pos + chunkLength >= size) { + if (pos + chunkLength >= size) + { PNG_error = 35; // error: size of the in buffer too small to contain next chunk return NULL; } @@ -1086,6 +1105,7 @@ return NULL; } for (i = 0; i < info->palette->size; i += 4) { + size_t j; for (j = 0; j < 3; j++) info->palette->data[i + j] = in[pos++]; // RGB info->palette->data[i + 3] = 255; // alpha @@ -1130,10 +1150,16 @@ return NULL; } pos += (chunkLength + 4); // skip 4 letters and uninterpreted data of unimplemented chunk - known_type = false; } pos += 4; // step over CRC (which is ignored) } + + if (!idat) + { + PNG_error = 1; // no data seen + return NULL; + } + uint32_t bpp = PNG_getBpp(info); vector8_t *scanlines; // now the out buffer will be filled scanlines = vector8_new(((info->width * (info->height * bpp + 7)) / 8) + info->height, 0); Index: branches/ErmaC/Enoch/i386/boot2/graphics.c =================================================================== --- branches/ErmaC/Enoch/i386/boot2/graphics.c (revision 2457) +++ branches/ErmaC/Enoch/i386/boot2/graphics.c (revision 2458) @@ -1265,6 +1265,7 @@ //========================================================================== // Display and clear the activity indicator. +// BASIC Indicator static char indicator[] = {'-', '\\', '|', '/', '-', '\\', '|', '/', '\0'}; // Bouncing ball .oOo. Index: branches/ErmaC/Enoch/i386/boot2/drivers.c =================================================================== --- branches/ErmaC/Enoch/i386/boot2/drivers.c (revision 2457) +++ branches/ErmaC/Enoch/i386/boot2/drivers.c (revision 2458) @@ -279,8 +279,9 @@ static long FileLoadMKext( const char * dirSpec, const char * extDirSpec ) { - long ret, flags, time, time2; - char altDirSpec[512]; + long ret, flags; + u_int32_t time, time2; + char altDirSpec[512]; snprintf(altDirSpec, sizeof(altDirSpec), "%s%s", dirSpec, extDirSpec); ret = GetFileInfo(altDirSpec, "Extensions.mkext", &flags, &time); @@ -310,10 +311,11 @@ long FileLoadDrivers( char * dirSpec, long plugin ) { - long ret, length, flags, time, bundleType; - long long index; - long result = -1; - const char * name; + long long index; + long ret, length, flags, bundleType; + long result = -1; + u_int32_t time; + const char * name; if ( !plugin ) { Index: branches/ErmaC/Enoch/i386/boot2/boot.c =================================================================== --- branches/ErmaC/Enoch/i386/boot2/boot.c (revision 2457) +++ branches/ErmaC/Enoch/i386/boot2/boot.c (revision 2458) @@ -242,8 +242,9 @@ { char kernelCacheFile[512]; char kernelCachePath[512]; - long flags, time, cachetime, kerneltime, exttime, ret=-1; + long flags, ret=-1; unsigned long adler32; + u_int32_t time, cachetime, kerneltime, exttime; if((gBootMode & kBootModeSafe) != 0) { @@ -273,8 +274,8 @@ (archCpuType == CPU_TYPE_I386) ? "i386" : "x86_64"); int lnam = strlen(kernelCacheFile) + 9; //with adler32 - char *name; - long prev_time = 0; + char *name; + u_int32_t prev_time = 0; struct dirstuff* cacheDir = opendir(kDefaultCachePathSnow); @@ -524,10 +525,11 @@ bool useKernelCache = true; // by default try to use the prelinked kernel const char *val; int len, ret = -1; - long flags, sleeptime, time; + long flags; + u_int32_t sleeptime, time; void *binary = (void *)kLoadAddr; - char bootFile[sizeof(bootInfo->bootFile)]; + char bootFile[sizeof(bootInfo->bootFile)]; char bootFilePath[512]; char kernelCacheFile[512]; @@ -710,7 +712,7 @@ // bootFile must start with a / if it not start with a device name if (!bootFileWithDevice && (bootInfo->bootFile)[0] != '/') { - if (!YOSEMITE) + if ( !YOSEMITE ) { //printf(HEADER " (%s).\n", bootInfo->bootFile); snprintf(bootFile, sizeof(bootFile), "/%s", bootInfo->bootFile); // append a leading / @@ -828,7 +830,8 @@ bool checkOSVersion(const char * version) { - if ( (sizeof(version) > 4) && (version[3] == '1') ) { + if ( (sizeof(version) > 4) && ('.' != version[4]) && ('\0' != version[4]) ) + { return ((gMacOSVersion[0] == version[0]) && (gMacOSVersion[1] == version[1]) && (gMacOSVersion[2] == version[2]) && (gMacOSVersion[3] == version[3]) && (gMacOSVersion[4] == version[4])); Index: branches/ErmaC/Enoch/i386/boot2/modules.c =================================================================== --- branches/ErmaC/Enoch/i386/boot2/modules.c (revision 2457) +++ branches/ErmaC/Enoch/i386/boot2/modules.c (revision 2458) @@ -103,7 +103,7 @@ { char* name; long flags; - long time; + u_int32_t time; struct dirstuff* moduleDir = opendir("/Extra/modules/"); if(!moduleDir) { Index: branches/ErmaC/Enoch/i386/boot2/bmdecompress.c =================================================================== --- branches/ErmaC/Enoch/i386/boot2/bmdecompress.c (revision 2457) +++ branches/ErmaC/Enoch/i386/boot2/bmdecompress.c (revision 2458) @@ -42,7 +42,8 @@ uint16_t * sc2 = malloc((width+2) * sizeof(uint16_t)); uint16_t * sc3 = malloc((width+2) * sizeof(uint16_t)); - if (!sc0 || !sc1 || !sc2 || !sc3) { + if (!sc0 || !sc1 || !sc2 || !sc3) + { return; } @@ -54,7 +55,8 @@ bzero(sc3, (width+2) * sizeof(uint16_t)); uint32_t tmp1, tmp2, out; - for (j = 0; j < (height + 2); j++) { + for (j = 0; j < (height + 2); j++) + { input = compressBuffer; if (j < height) Index: branches/ErmaC/Enoch/i386/boot2/gui.c =================================================================== --- branches/ErmaC/Enoch/i386/boot2/gui.c (revision 2457) +++ branches/ErmaC/Enoch/i386/boot2/gui.c (revision 2458) @@ -1009,9 +1009,7 @@ { case kPartitionTypeHFS: { - // ErmaC : TODO test needed for recovery icon - // Use HFSRECOVERY icon. // if (device->flags & kBVFlagBooter) // { Index: branches/ErmaC/Enoch/i386/modules/AcpiCodec/acpi_codec.c =================================================================== --- branches/ErmaC/Enoch/i386/modules/AcpiCodec/acpi_codec.c (revision 2457) +++ branches/ErmaC/Enoch/i386/modules/AcpiCodec/acpi_codec.c (revision 2458) @@ -4743,13 +4743,14 @@ } { - long ret, length, flags, time; - long long index = 0; - const char * name; + long long index = 0; + long ret, length, flags; + u_int32_t time; + const char * name; - U8 i = 0; - char dirspec[512]; - bool acpidir_found = false; + U8 i = 0; + char dirspec[512]; + bool acpidir_found = false; ret = GetFileInfo("rd(0,0)/Extra/", "Acpi", &flags, &time); if ((ret == 0) && ((flags & kFileTypeMask) == kFileTypeDirectory)) @@ -5077,7 +5078,9 @@ MadtPointer = (ACPI_TABLE_MADT *)madt_file; } - } else { + } + else + { MadtPointer = (acpi_tables.MadtPointer64 != (void*)0ul) ? (ACPI_TABLE_MADT *)acpi_tables.MadtPointer64 : (ACPI_TABLE_MADT *)acpi_tables.MadtPointer; } @@ -5158,7 +5161,9 @@ /* XXX aserebln why uint32 cast if pointer is uint64 ? */ rsd_p = (U32)rsdp_mod; addConfigurationTable(&gEfiAcpi20TableGuid, &rsd_p, "ACPI_20"); - } else { + } + else + { /* XXX aserebln why uint32 cast if pointer is uint64 ? */ rsd_p = (U32)rsdp_mod; addConfigurationTable(&gEfiAcpiTableGuid, &rsd_p, "ACPI"); Index: branches/ErmaC/Enoch/i386/libsa/zalloc.c =================================================================== --- branches/ErmaC/Enoch/i386/libsa/zalloc.c (revision 2457) +++ branches/ErmaC/Enoch/i386/libsa/zalloc.c (revision 2458) @@ -157,7 +157,8 @@ #endif done: - if ((ret == 0) || (ret + size >= zalloc_end)) { + if ((ret == 0) || (ret + size >= zalloc_end)) + { if (zerror) { (*zerror)(ret, size, file, line); Index: branches/ErmaC/Enoch/i386/libsa/string.c =================================================================== --- branches/ErmaC/Enoch/i386/libsa/string.c (revision 2457) +++ branches/ErmaC/Enoch/i386/libsa/string.c (revision 2458) @@ -166,9 +166,14 @@ return 0; do { if (*s1 != *s2++) + { return (*(const unsigned char *)s1 - *(const unsigned char *)(s2 - 1)); + } + if (!*s1++) + { break; + } } while (--n); return 0; } Index: branches/ErmaC/Enoch/package/buildpkg.sh =================================================================== --- branches/ErmaC/Enoch/package/buildpkg.sh (revision 2457) +++ branches/ErmaC/Enoch/package/buildpkg.sh (revision 2458) @@ -173,10 +173,14 @@ $chameleonSubsts $ownSubst" + # HACK: Don't try to substitute in TIFF files! for file in "$@";do - cp -pf "$file" "${file}.in" - sed "$allSubst" "${file}.in" > "${file}" - rm -f "${file}.in" + if [ -z `echo "$file" | grep tiff` ] + then + cp -pf "$file" "${file}.in" + sed "$allSubst" "${file}.in" > "${file}" + rm -f "${file}.in" + fi done } Index: branches/ErmaC/Enoch/CHANGES =================================================================== --- branches/ErmaC/Enoch/CHANGES (revision 2457) +++ branches/ErmaC/Enoch/CHANGES (revision 2458) @@ -1,3 +1,11 @@ +- bitshoveler : Make 'buffer' arg to aml_add_buffer 'const char *', was just 'char *' (aml_generator) +- bitshoveler : Fix "sed: RE error: illegal byte sequence", which turns out to be from feeding sed a TIFF file (buildpkg.sh) +- bitshoveler : Remove "-x" option from "ld" command which breaks build under newer Xcode versions (MakeInc.dir) +- bitshoveler : CacheInit(), CacheRead() prototypes: use u_int32_t instead of long where appropriate (saio_internal.h) +- bitshoveler : Improved defensiveness against malloc failure (disk.c) +- bitshoveler : Use u_int32_t instead of long where appropriate (cache.c) +- bitshoveler : Make some constant arrays static; other minor fixes (acpi_patcher.c) +- bitshoveler : Various fixes to problems exposed by Clang static analyzer (picopng.c) - bitshoveler : Remove "-x" option from "ld" command which breaks build under newer Xcode versions (/i386/modules/MakeInc.dir) - bitshoveler : Comment out some unused functions by expanding "#if UNUSED" conditional (stringTable.c) - bitshoveler : Comment out unused static functions, which cause build to fail in "release" mode (vbe.c)