Index: branches/ErmaC/Enoch/i386/libsaio/acpi_patcher.c =================================================================== --- branches/ErmaC/Enoch/i386/libsaio/acpi_patcher.c (revision 2470) +++ branches/ErmaC/Enoch/i386/libsaio/acpi_patcher.c (revision 2471) @@ -796,6 +796,7 @@ { rsdt_entries[i-dropoffset+j]=(uint32_t)new_ssdt[j]; } + DBG("RSDT: Added %d SSDT table(s)\n", ssdt_count); } Index: branches/ErmaC/Enoch/i386/libsaio/bootargs.h =================================================================== --- branches/ErmaC/Enoch/i386/libsaio/bootargs.h (revision 2470) +++ branches/ErmaC/Enoch/i386/libsaio/bootargs.h (revision 2471) @@ -137,11 +137,15 @@ #define kBootArgsFlagBlackBg (1 << 6) #define kBootArgsFlagLoginUI (1 << 7) -typedef struct boot_args_pre_lion +typedef struct boot_args { uint16_t Revision; /* Revision of boot_args structure */ uint16_t Version; /* Version of boot_args structure */ + uint8_t efiMode; /* 32 means 32-bit mode, 64 means 64-bit mode */ + uint8_t debugMode; /* Bit field with behavior changes */ + uint16_t flags; + char CommandLine[BOOT_LINE_LENGTH]; /* Passed in command line */ uint32_t MemoryMap; /* Physical address of memory map */ @@ -159,28 +163,35 @@ uint32_t efiRuntimeServicesPageStart; /* physical address of defragmented runtime pages */ uint32_t efiRuntimeServicesPageCount; + uint64_t efiRuntimeServicesVirtualPageStart; /* virtual address of defragmented runtime pages */ uint32_t efiSystemTable; /* physical address of system table in runtime area */ + uint32_t kslide; - uint8_t efiMode; /* 32 means 32-bit mode, 64 means 64-bit mode */ - uint8_t __reserved1[3]; - uint32_t __reserved2[1]; uint32_t performanceDataStart; /* physical address of log */ uint32_t performanceDataSize; - uint64_t efiRuntimeServicesVirtualPageStart; /* virtual address of defragmented runtime pages */ - uint32_t __reserved3[2]; -} boot_args_pre_lion; + uint32_t keyStoreDataStart; /* physical address of key store data */ + uint32_t keyStoreDataSize; + uint64_t bootMemStart; + uint64_t bootMemSize; + uint64_t PhysicalMemorySize; + uint64_t FSBFrequency; -typedef struct boot_args + uint64_t pciConfigSpaceBaseAddress; + uint32_t pciConfigSpaceStartBusNumber; + uint32_t pciConfigSpaceEndBusNumber; + uint32_t csrActiveConfig; + uint32_t csrPendingConfig; + uint32_t __reserved4[728]; + +} boot_args; + +typedef struct boot_args_pre_lion { uint16_t Revision; /* Revision of boot_args structure */ uint16_t Version; /* Version of boot_args structure */ - uint8_t efiMode; /* 32 means 32-bit mode, 64 means 64-bit mode */ - uint8_t debugMode; /* Bit field with behavior changes */ - uint16_t flags; - char CommandLine[BOOT_LINE_LENGTH]; /* Passed in command line */ uint32_t MemoryMap; /* Physical address of memory map */ @@ -198,30 +209,19 @@ uint32_t efiRuntimeServicesPageStart; /* physical address of defragmented runtime pages */ uint32_t efiRuntimeServicesPageCount; - uint64_t efiRuntimeServicesVirtualPageStart; /* virtual address of defragmented runtime pages */ uint32_t efiSystemTable; /* physical address of system table in runtime area */ - uint32_t kslide; + uint8_t efiMode; /* 32 means 32-bit mode, 64 means 64-bit mode */ + uint8_t __reserved1[3]; + uint32_t __reserved2[1]; uint32_t performanceDataStart; /* physical address of log */ uint32_t performanceDataSize; + uint64_t efiRuntimeServicesVirtualPageStart; /* virtual address of defragmented runtime pages */ + uint32_t __reserved3[2]; - uint32_t keyStoreDataStart; /* physical address of key store data */ - uint32_t keyStoreDataSize; - uint64_t bootMemStart; - uint64_t bootMemSize; - uint64_t PhysicalMemorySize; - uint64_t FSBFrequency; +} boot_args_pre_lion; - uint64_t pciConfigSpaceBaseAddress; - uint32_t pciConfigSpaceStartBusNumber; - uint32_t pciConfigSpaceEndBusNumber; - uint32_t csrActiveConfig; - uint32_t csrPendingConfig; - uint32_t __reserved4[728]; - -} boot_args; - extern char gMacOSVersion[8]; #endif /* _PEXPERT_I386_BOOT_H */ Index: branches/ErmaC/Enoch/i386/libsaio/ntfs.c =================================================================== --- branches/ErmaC/Enoch/i386/libsaio/ntfs.c (revision 2470) +++ branches/ErmaC/Enoch/i386/libsaio/ntfs.c (revision 2471) @@ -106,8 +106,7 @@ * Find a resident attribute of a given type. Returns a pointer to the * attribute data, and its size in bytes. */ -static int -ntfs_find_attr( +static int ntfs_find_attr( char *buf, u_int32_t attrType, void **attrData, @@ -148,79 +147,78 @@ /* * Examine a volume to see if we recognize it as a mountable. */ -void -NTFSGetDescription(CICell ih, char *str, long strMaxLen) +void NTFSGetDescription(CICell ih, char *str, long strMaxLen) { - struct bootfile *boot; - unsigned bytesPerSector; - unsigned sectorsPerCluster; - int mftRecordSize; - u_int64_t totalClusters; - u_int64_t cluster, mftCluster; - size_t mftOffset; - void *nameAttr; - size_t nameSize; - char *buf; + struct bootfile *boot; + unsigned bytesPerSector; + unsigned sectorsPerCluster; + int mftRecordSize; + u_int64_t totalClusters; + u_int64_t cluster, mftCluster; + size_t mftOffset; + void *nameAttr; + size_t nameSize; + char *buf; - buf = (char *)malloc(MAX_CLUSTER_SIZE); - if (buf == 0) { - goto error; - } + buf = (char *)malloc(MAX_CLUSTER_SIZE); + if (buf == 0) + { + goto error; + } - /* - * Read the boot sector, check signatures, and do some minimal - * sanity checking. NOTE: the size of the read below is intended - * to be a multiple of all supported block sizes, so we don't - * have to determine or change the device's block size. - */ - Seek(ih, 0); - Read(ih, (long)buf, MAX_BLOCK_SIZE); + /* + * Read the boot sector, check signatures, and do some minimal + * sanity checking. NOTE: the size of the read below is intended + * to be a multiple of all supported block sizes, so we don't + * have to determine or change the device's block size. + */ + Seek(ih, 0); + Read(ih, (long)buf, MAX_BLOCK_SIZE); - boot = (struct bootfile *) buf; - - /* - * The first three bytes are an Intel x86 jump instruction. I assume it - * can be the same forms as DOS FAT: - * 0xE9 0x?? 0x?? - * 0xEC 0x?? 0x90 - * where 0x?? means any byte value is OK. - */ - if (boot->reserved1[0] != 0xE9 - && (boot->reserved1[0] != 0xEB || boot->reserved1[2] != 0x90)) - { - goto error; - } + boot = (struct bootfile *) buf; - /* - * Check the "NTFS " signature. - */ - if (memcmp((const char *)boot->bf_sysid, "NTFS ", 8) != 0) - { - /* - * Check for EXFAT. Finish by jumping to error to free buf, - * although if it is EXFAT then it's no an error. - */ - EXFATGetDescription(ih, str, strMaxLen); - goto error; - } + /* + * The first three bytes are an Intel x86 jump instruction. I assume it + * can be the same forms as DOS FAT: + * 0xE9 0x?? 0x?? + * 0xEC 0x?? 0x90 + * where 0x?? means any byte value is OK. + */ + if (boot->reserved1[0] != 0xE9 && (boot->reserved1[0] != 0xEB || boot->reserved1[2] != 0x90)) + { + goto error; + } - /* - * Make sure the bytes per sector and sectors per cluster are - * powers of two, and within reasonable ranges. - */ - bytesPerSector = OSReadLittleInt16(&boot->bf_bps,0); - if ((bytesPerSector & (bytesPerSector-1)) || bytesPerSector < 512 || bytesPerSector > 32768) - { - //verbose("NTFS: invalid bytes per sector (%d)\n", bytesPerSector); - goto error; - } + /* + * Check the "NTFS " signature. + */ + if (memcmp((const char *)boot->bf_sysid, "NTFS ", 8) != 0) + { + /* + * Check for EXFAT. Finish by jumping to error to free buf, + * although if it is EXFAT then it's no an error. + */ + EXFATGetDescription(ih, str, strMaxLen); + goto error; + } - sectorsPerCluster = boot->bf_spc; /* Just one byte; no swapping needed */ - if ((sectorsPerCluster & (sectorsPerCluster-1)) || sectorsPerCluster > 128) - { - //verbose("NTFS: invalid sectors per cluster (%d)\n", bytesPerSector); - goto error; - } + /* + * Make sure the bytes per sector and sectors per cluster are + * powers of two, and within reasonable ranges. + */ + bytesPerSector = OSReadLittleInt16(&boot->bf_bps,0); + if ((bytesPerSector & (bytesPerSector-1)) || bytesPerSector < 512 || bytesPerSector > 32768) + { + //verbose("NTFS: invalid bytes per sector (%d)\n", bytesPerSector); + goto error; + } + + sectorsPerCluster = boot->bf_spc; /* Just one byte; no swapping needed */ + if ((sectorsPerCluster & (sectorsPerCluster-1)) || sectorsPerCluster > 128) + { + //verbose("NTFS: invalid sectors per cluster (%d)\n", bytesPerSector); + goto error; + } /* * Calculate the number of clusters from the number of sectors. @@ -284,22 +282,25 @@ /* * Loop over the attributes, looking for $VOLUME_NAME (0x60). */ - if(ntfs_find_attr(buf, NTFS_A_VOLUMENAME, &nameAttr, &nameSize) != 0) - { - //verbose("NTFS: $VOLUME_NAME attribute not found\n"); - goto error; - } - - str[0] = '\0'; + if(ntfs_find_attr(buf, NTFS_A_VOLUMENAME, &nameAttr, &nameSize) != 0) + { + //verbose("NTFS: $VOLUME_NAME attribute not found\n"); + goto error; + } - utf_encodestr( nameAttr, nameSize / 2, (u_int8_t *)str, strMaxLen, OSLittleEndian ); + str[0] = '\0'; - free(buf); - return; + utf_encodestr( nameAttr, nameSize / 2, (u_int8_t *)str, strMaxLen, OSLittleEndian ); + free(buf); + return; + error: - if (buf) free(buf); - return; + if (buf) + { + free(buf); + } + return; } long NTFSGetUUID(CICell ih, char *uuidStr) @@ -308,7 +309,8 @@ struct bootfile *boot; void *buf = malloc(MAX_BLOCK_SIZE); - if ( !buf ) { + if ( !buf ) + { return -1; } @@ -324,19 +326,20 @@ boot = (struct bootfile *) buf; // Check for NTFS signature - if ( memcmp((void*)boot->bf_sysid, NTFS_BBID, NTFS_BBIDLEN) != 0 ) { + if ( memcmp((void*)boot->bf_sysid, NTFS_BBID, NTFS_BBIDLEN) != 0 ) + { // If not NTFS, maybe it is EXFAT return EXFATGetUUID(ih, uuidStr); } // Check for non-null volume serial number - if( !boot->bf_volsn ) { + if( !boot->bf_volsn ) + { return -1; } // Use UUID like the one you get on Windows - sprintf(uuidStr, "%04X-%04X", (unsigned short)(boot->bf_volsn >> 16) & 0xFFFF, - (unsigned short)boot->bf_volsn & 0xFFFF); + sprintf(uuidStr, "%04X-%04X", (unsigned short)(boot->bf_volsn >> 16) & 0xFFFF, (unsigned short)boot->bf_volsn & 0xFFFF); return 0; } @@ -349,11 +352,15 @@ // Looking for NTFS signature. if (strncmp((const char *)part_bootfile->bf_sysid, NTFS_BBID, NTFS_BBIDLEN) == 0) + { result = true; + } // If not NTFS, maybe it is EXFAT if (!result) + { result = EXFATProbe(buffer); + } return result; } Index: branches/ErmaC/Enoch/i386/libsaio/sys.c =================================================================== --- branches/ErmaC/Enoch/i386/libsaio/sys.c (revision 2470) +++ branches/ErmaC/Enoch/i386/libsaio/sys.c (revision 2471) @@ -162,7 +162,8 @@ // Resolve the boot volume from the file spec. - if ((bvr = getBootVolumeRef(fileSpec, &filePath)) == NULL) { + if ((bvr = getBootVolumeRef(fileSpec, &filePath)) == NULL) + { return -1; } @@ -176,11 +177,13 @@ const char *filePath; BVRef bvr; - if ((bvr = getBootVolumeRef(fileSpec, &filePath)) == NULL) { + if ((bvr = getBootVolumeRef(fileSpec, &filePath)) == NULL) + { return -1; } - if (bvr->fs_readfile == NULL) { + if (bvr->fs_readfile == NULL) + { return -1; } @@ -198,7 +201,8 @@ // Resolve the boot volume from the file spec. - if ((bvr = getBootVolumeRef(fileSpec, &filePath)) == NULL) { + if ((bvr = getBootVolumeRef(fileSpec, &filePath)) == NULL) + { return -1; } @@ -229,19 +233,24 @@ DBG("Fat Binary found. Reading thin part only...\n"); length = readFile(bvr, (char *)filePath, (void *)kLoadAddr, (unsigned long)(*binary) - kLoadAddr, length); *binary = (void *)kLoadAddr; - } else { + } + else + { // Not a fat binary; read the rest of the file DBG("Thin Binary found. Reading rest of the file...\n"); length2 = readFile(bvr, (char *)filePath, (void *)(kLoadAddr + length), length, 0); - if (length2 == -1) { + if (length2 == -1) + { return -1; } length += length2; } } - } else { + } + else + { length = bvr->fs_loadfile(bvr, (char *)filePath); if (length > 0) @@ -249,7 +258,7 @@ ThinFatFile(binary, &length); } } - + return length; } @@ -302,13 +311,16 @@ i = 0; fmtbase = 0; - for(fmtidx = 0; fmtidx < sizeof(uuidfmt); fmtidx++) { - for (i = 0; i < uuidfmt[fmtidx]; i++) { + for(fmtidx = 0; fmtidx < sizeof(uuidfmt); fmtidx++) + { + for (i = 0; i < uuidfmt[fmtidx]; i++) + { uint8_t byte = mdresult[fmtbase + i]; char nib = byte >> 4; *p = nib + '0'; // 0x4 -> '4' - if (*p > '9') { + if (*p > '9') + { *p = (nib - 9 + ('A'-1)); // 0xB -> 'B' } @@ -317,7 +329,8 @@ nib = byte & 0xf; *p = nib + '0'; // 0x4 -> '4' - if (*p > '9') { + if (*p > '9') + { *p = (nib - 9 + ('A'-1)); // 0xB -> 'B' } @@ -326,7 +339,8 @@ fmtbase += i; - if (fmtidx < sizeof(uuidfmt) - 1) { + if (fmtidx < sizeof(uuidfmt) - 1) + { *(p++) = '-'; } else @@ -351,13 +365,14 @@ // Resolve the boot volume from the dir spec. - if ((bvr = getBootVolumeRef(dirSpec, &dirPath)) == NULL) { + if ((bvr = getBootVolumeRef(dirSpec, &dirPath)) == NULL) + { return -1; } - // Returns 0 on success or -1 when there are no additional entries. + // Return 0 on success, or -1 if there are no additional entries. - return bvr->fs_getdirentry( bvr, + return bvr->fs_getdirentry( bvr, /* dirPath */ (char *)dirPath, /* dirIndex */ dirIndex, /* dirEntry */ (char **)name, flags, time, 0, 0 ); @@ -375,7 +390,8 @@ long long index = 0; const char * entryName; - if (gMakeDirSpec == 0) { + if (gMakeDirSpec == 0) + { gMakeDirSpec = (char *)malloc(1024); } @@ -402,7 +418,8 @@ while (GetDirEntry(dirSpec, &index, &entryName, flags, time) == 0) { - if (strcmp(entryName, name) == 0) { + if (strcmp(entryName, name) == 0) + { return 0; // success } } @@ -435,10 +452,12 @@ int fd; // Locate a free descriptor slot. - for (fd = 0; fd < NFILES; fd++) { - if (iob[fd].i_flgs == 0) { + for (fd = 0; fd < NFILES; fd++) + { + if (iob[fd].i_flgs == 0) + { return fd; - } + } } stop("Out of file descriptors"); // not reached @@ -455,9 +474,12 @@ { register struct iob * io; - if (fdesc < 0 || fdesc >= NFILES || ((io = &iob[fdesc])->i_flgs & F_ALLOC) == 0) { + if (fdesc < 0 || fdesc >= NFILES || ((io = &iob[fdesc])->i_flgs & F_ALLOC) == 0) + { return NULL; - } else { + } + else + { return io; } } @@ -467,21 +489,21 @@ int openmem(char * buf, int len) { - int fdesc; - struct iob * io; + int fdesc; + struct iob * io; - fdesc = GetFreeFd(); - io = &iob[fdesc]; - bzero(io, sizeof(*io)); + fdesc = GetFreeFd(); + io = &iob[fdesc]; + bzero(io, sizeof(*io)); - // Mark the descriptor as taken. Set the F_MEM flag to indicate - // that the file buffer is provided by the caller. + // Mark the descriptor as taken. Set the F_MEM flag to indicate + // that the file buffer is provided by the caller. - io->i_flgs = F_ALLOC | F_MEM; - io->i_buf = buf; - io->i_filesize = len; + io->i_flgs = F_ALLOC | F_MEM; + io->i_buf = buf; + io->i_filesize = len; - return fdesc; + return fdesc; } //========================================================================== @@ -529,7 +551,8 @@ BVRef bvr; // Resolve the boot volume from the file spec. - if ((bvr = getBootVolumeRef(path, &filepath)) != NULL) { + if ((bvr = getBootVolumeRef(path, &filepath)) != NULL) + { return open_bvr(bvr, filepath, flags); } return -1; @@ -537,7 +560,7 @@ int open_bvdev(const char *bvd, const char *path, int flags) { - const struct devsw *dp; + const struct devsw *dp; const char *cp; BVRef bvr; int i; @@ -545,38 +568,46 @@ int unit; int partition; - if ((i = open(path, flags)) >= 0) { + if ((i = open(path, flags)) >= 0) + { return i; } - if (bvd == NULL || (len = strlen(bvd)) < 2) { + if (bvd == NULL || (len = strlen(bvd)) < 2) + { return -1; } - for (dp=devsw; dp->name; dp++) { - if (bvd[0] == dp->name[0] && bvd[1] == dp->name[1]) { + for (dp=devsw; dp->name; dp++) + { + if (bvd[0] == dp->name[0] && bvd[1] == dp->name[1]) + { unit = 0; partition = 0; /* get optional unit and partition */ if (len >= 5 && bvd[2] == '(') { /* min must be present xx(0) */ cp = &bvd[3]; i = 0; - while ((cp - path) < len && isdigit(*cp)) { + while ((cp - path) < len && isdigit(*cp)) + { i = i * 10 + *cp++ - '0'; unit = i; } - if (*cp++ == ',') { + if (*cp++ == ',') + { i = 0; - while ((cp - path) < len && isdigit(*cp)) { + while ((cp - path) < len && isdigit(*cp)) + { i = i * 10 + *cp++ - '0'; partition = i; } } } bvr = newBootVolumeRef(dp->biosdev + unit, partition); + return open_bvr(bvr, path, flags); } - } + } return -1; } @@ -587,7 +618,8 @@ { struct iob * io; - if ((io = iob_from_fdesc(fdesc)) == NULL) { + if ((io = iob_from_fdesc(fdesc)) == NULL) + { return (-1); } @@ -604,7 +636,8 @@ { struct iob * io; - if ((io = iob_from_fdesc(fdesc)) == NULL) { + if ((io = iob_from_fdesc(fdesc)) == NULL) + { return (-1); } @@ -620,7 +653,8 @@ { struct iob * io; - if ((io = iob_from_fdesc(fdesc)) == NULL) { + if ((io = iob_from_fdesc(fdesc)) == NULL) + { return 0; } @@ -821,7 +855,8 @@ const char * systemConfigDir() { - if (gBootFileType == kNetworkDeviceType) { + if (gBootFileType == kNetworkDeviceType) + { return ""; } return "/Library/Preferences/SystemConfiguration"; @@ -836,12 +871,16 @@ BVRef bvr = 0; bvr = diskScanBootVolumes(biosdev, count); - if (bvr == NULL) { + if (bvr == NULL) + { bvr = nbpScanBootVolumes(biosdev, count); - if (bvr != NULL) { + if (bvr != NULL) + { gBootFileType = kNetworkDeviceType; } - } else { + } + else + { gBootFileType = kBlockDeviceType; } } @@ -855,14 +894,16 @@ int hd = 0; // Testing up to MAX_HDD_COUNT hard drives. - while(!testBiosread(0x80 + hd, 0) && hd < MAX_HDD_COUNT) { + while(!testBiosread(0x80 + hd, 0) && hd < MAX_HDD_COUNT) + { bvCount = 0; scanBootVolumes(0x80 + hd, &bvCount); hd++; } // Also scanning CD/DVD drive. - if (biosDevIsCDROM(gBIOSDev)) { + if (biosDevIsCDROM(gBIOSDev)) + { bvCount = 0; scanBootVolumes(gBIOSDev, &bvCount); } @@ -876,13 +917,17 @@ bool foundPrimary = false; BVRef bvr, bvr1 = 0, bvr2 = 0; - if (chain->filtered) { + if (chain->filtered) + { filteredChain = true; } - if (multiboot_partition_set) { - for ( bvr = chain; bvr; bvr = bvr->next ) { - if ( bvr->part_no == multiboot_partition && bvr->biosdev == gBIOSDev ) { + if (multiboot_partition_set) + { + for ( bvr = chain; bvr; bvr = bvr->next ) + { + if ( bvr->part_no == multiboot_partition && bvr->biosdev == gBIOSDev ) + { return bvr; } } @@ -894,9 +939,12 @@ * We accept only kBVFlagSystemVolume or kBVFlagForeignBoot volumes. */ char *val = XMLDecode(getStringForKey(kDefaultPartition, &bootInfo->chameleonConfig)); - if (val) { - for ( bvr = chain; bvr; bvr = bvr->next ) { - if (matchVolumeToString(bvr, val, false)) { + if (val) + { + for ( bvr = chain; bvr; bvr = bvr->next ) + { + if (matchVolumeToString(bvr, val, false)) + { free(val); return bvr; } @@ -910,11 +958,17 @@ * If not found any active partition then we will * select this volume as the boot volume. */ - for ( bvr = chain; bvr; bvr = bvr->next ) { - if (multiboot_skip_partition_set) { - if (bvr->part_no == multiboot_skip_partition) continue; + for ( bvr = chain; bvr; bvr = bvr->next ) + { + if (multiboot_skip_partition_set) + { + if (bvr->part_no == multiboot_skip_partition) + { + continue; + } } - if ( bvr->flags & kBVFlagPrimary && bvr->biosdev == gBIOSDev ) { + if ( bvr->flags & kBVFlagPrimary && bvr->biosdev == gBIOSDev ) + { foundPrimary = true; } @@ -923,7 +977,8 @@ if ( bvr->flags & (kBVFlagBootable|kBVFlagSystemVolume) && gBIOSBootVolume && (!filteredChain || (filteredChain && bvr->visible)) - && bvr->biosdev == gBIOSDev ) { + && bvr->biosdev == gBIOSDev ) + { bvr2 = bvr; } @@ -931,7 +986,8 @@ // from r491, if ( bvr->flags & kBVFlagBootable && ! gBIOSBootVolume - && bvr->biosdev == gBIOSDev ) { + && bvr->biosdev == gBIOSDev ) + { bvr2 = bvr; } } @@ -943,10 +999,12 @@ { for ( bvr = chain; bvr; bvr = bvr->next ) { - if ( bvr->flags & kBVFlagNativeBoot && bvr->biosdev == gBIOSDev ) { + if ( bvr->flags & kBVFlagNativeBoot && bvr->biosdev == gBIOSDev ) + { bvr1 = bvr; } - if ( bvr->flags & kBVFlagPrimary && bvr->biosdev == gBIOSDev ) { + if ( bvr->flags & kBVFlagPrimary && bvr->biosdev == gBIOSDev ) + { bvr2 = bvr; } } @@ -976,7 +1034,8 @@ gRootVolume = volume; // Veto non-native FS. Basically that means don't allow the root volume to // be set to a volume we can't read files from. - if(gRootVolume != NULL && ((gRootVolume->flags & kBVFlagNativeBoot) == 0)) { + if(gRootVolume != NULL && ((gRootVolume->flags & kBVFlagNativeBoot) == 0)) + { gRootVolume = NULL; } } @@ -985,9 +1044,10 @@ { // Record default boot device. gBootVolume = selectBootVolume(chain); - + // turbo - Save the ORIGINAL boot volume too for loading our mkext - if (!gBIOSBootVolume) { + if (!gBIOSBootVolume) + { gBIOSBootVolume = gBootVolume; } @@ -1011,7 +1071,8 @@ // Search for left parenthesis in the path specification. for (cp = path; *cp; cp++) { - if (*cp == LP || *cp == '/') { + if (*cp == LP || *cp == '/') + { break; } } @@ -1020,7 +1081,8 @@ cp = path; // Path is using the implicit current device so if there is // no current device, then we must fail. - if (gRootVolume == NULL) { + if (gRootVolume == NULL) + { return NULL; } } else if ((cp - path) == 2) { // found "xx(" @@ -1035,13 +1097,16 @@ // Check the 2 character device name pointed by 'xp'. - for (dp = devsw; dp->name; dp++) { - if ((xp[0] == dp->name[0]) && (xp[1] == dp->name[1])) { + for (dp = devsw; dp->name; dp++) + { + if ((xp[0] == dp->name[0]) && (xp[1] == dp->name[1])) + { break; // Found matching entry. } } - if (dp->name == NULL) { + if (dp->name == NULL) + { error("Unknown device '%c%c'\n", xp[0], xp[1]); return NULL; } @@ -1051,23 +1116,26 @@ i = 0; - while (*cp >= '0' && *cp <= '9') { + while (*cp >= '0' && *cp <= '9') + { i = i * 10 + *cp++ - '0'; unit = i; } - // Unit is no longer optional and never really was. - // If the user failed to specify it then the unit number from the previous kernDev - // would have been used which makes little sense anyway. - // For example, if the user did fd()/foobar and the current root device was the - // second hard disk (i.e. unit 1) then fd() would select the second floppy drive! - if (unit == -1) { + // Unit is no longer optional and never really was. + // If the user failed to specify it then the unit number from the previous kernDev + // would have been used which makes little sense anyway. + // For example, if the user did fd()/foobar and the current root device was the + // second hard disk (i.e. unit 1) then fd() would select the second floppy drive! + if (unit == -1) + { return NULL; } // Extract the optional partition number from the specification. - if (*cp == ',') { + if (*cp == ',') + { part = atoi(++cp); } @@ -1079,22 +1147,27 @@ for ( ; *cp && *cp != RP; cp++) /* LOOP */; - if (*cp == RP) { + if (*cp == RP) + { cp++; } - + biosdev = dp->biosdev + unit; bvr = newBootVolumeRef(biosdev, part); - if (bvr == NULL) { + if (bvr == NULL) + { return NULL; } - } else { + } + else + { // Bad device specifier, skip past the right paren. for (cp++; *cp && *cp != RP; cp++) /* LOOP */; - if (*cp == RP) { + if (*cp == RP) + { cp++; } @@ -1120,17 +1193,26 @@ bvr = bvr1 = NULL; // Try resolving "rd" and "bt" devices first. - if (biosdev == kPseudoBIOSDevRAMDisk) { - if (gRAMDiskVolume) { + if (biosdev == kPseudoBIOSDevRAMDisk) + { + if (gRAMDiskVolume) + { bvr1 = gRAMDiskVolume; } - } else if (biosdev == kPseudoBIOSDevBooter) { - if (gRAMDiskVolume != NULL && gRAMDiskBTAliased) { + } + else if (biosdev == kPseudoBIOSDevBooter) + { + if (gRAMDiskVolume != NULL && gRAMDiskBTAliased) + { bvr1 = gRAMDiskVolume; - } else { + } + else + { bvr1 = gBIOSBootVolume; } - } else { + } + else + { // Fetch the volume list from the device. scanBootVolumes( biosdev, NULL ); @@ -1138,13 +1220,16 @@ // Look for a perfect match based on device and partition number. - for ( bvr1 = NULL, bvr = bvrChain; bvr; bvr = bvr->next ) { - if ( ( bvr->flags & kBVFlagNativeBoot ) == 0 ) { + for ( bvr1 = NULL, bvr = bvrChain; bvr; bvr = bvr->next ) + { + if ( ( bvr->flags & kBVFlagNativeBoot ) == 0 ) + { continue; } bvr1 = bvr; - if ( bvr->part_no == partno ) { + if ( bvr->part_no == partno ) + { break; } } @@ -1159,19 +1244,23 @@ // Returns length of the out string int getDeviceDescription(BVRef bvr, char *str) { - if(!str) { + if(!str) + { return 0; } *str = '\0'; - if (bvr) { + if (bvr) + { const struct devsw *dp = devsw; - while(dp->name && bvr->biosdev >= dp->biosdev) { + while(dp->name && bvr->biosdev >= dp->biosdev) + { dp++; } dp--; - if (dp->name) { + if (dp->name) + { return sprintf(str, "%s(%d,%d)", dp->name, bvr->biosdev - dp->biosdev, bvr->part_no); } } Index: branches/ErmaC/Enoch/i386/libsaio/cpu.c =================================================================== --- branches/ErmaC/Enoch/i386/libsaio/cpu.c (revision 2470) +++ branches/ErmaC/Enoch/i386/libsaio/cpu.c (revision 2471) @@ -20,6 +20,78 @@ #endif /* + * DFE: Measures the TSC frequency in Hz (64-bit) using the ACPI PM timer + */ +static uint64_t measure_tsc_frequency(void) +{ + uint64_t tscStart; + uint64_t tscEnd; + uint64_t tscDelta = 0xffffffffffffffffULL; + unsigned long pollCount; + uint64_t retval = 0; + int i; + + /* Time how many TSC ticks elapse in 30 msec using the 8254 PIT + * counter 2. We run this loop 3 times to make sure the cache + * is hot and we take the minimum delta from all of the runs. + * That is to say that we're biased towards measuring the minimum + * number of TSC ticks that occur while waiting for the timer to + * expire. That theoretically helps avoid inconsistencies when + * running under a VM if the TSC is not virtualized and the host + * steals time. The TSC is normally virtualized for VMware. + */ + for(i = 0; i < 10; ++i) + { + enable_PIT2(); + set_PIT2_mode0(CALIBRATE_LATCH); + tscStart = rdtsc64(); + pollCount = poll_PIT2_gate(); + tscEnd = rdtsc64(); + /* The poll loop must have run at least a few times for accuracy */ + if (pollCount <= 1) + { + continue; + } + /* The TSC must increment at LEAST once every millisecond. + * We should have waited exactly 30 msec so the TSC delta should + * be >= 30. Anything less and the processor is way too slow. + */ + if ((tscEnd - tscStart) <= CALIBRATE_TIME_MSEC) + { + continue; + } + // tscDelta = MIN(tscDelta, (tscEnd - tscStart)) + if ( (tscEnd - tscStart) < tscDelta ) + { + tscDelta = tscEnd - tscStart; + } + } + /* tscDelta is now the least number of TSC ticks the processor made in + * a timespan of 0.03 s (e.g. 30 milliseconds) + * Linux thus divides by 30 which gives the answer in kiloHertz because + * 1 / ms = kHz. But we're xnu and most of the rest of the code uses + * Hz so we need to convert our milliseconds to seconds. Since we're + * dividing by the milliseconds, we simply multiply by 1000. + */ + + /* Unlike linux, we're not limited to 32-bit, but we do need to take care + * that we're going to multiply by 1000 first so we do need at least some + * arithmetic headroom. For now, 32-bit should be enough. + * Also unlike Linux, our compiler can do 64-bit integer arithmetic. + */ + if (tscDelta > (1ULL<<32)) + { + retval = 0; + } + else + { + retval = tscDelta * 1000 / 30; + } + disable_PIT2(); + return retval; +} + +/* * timeRDTSC() * This routine sets up PIT counter 2 to count down 1/20 of a second. * It pauses until the value is latched in the counter @@ -96,72 +168,6 @@ } /* - * DFE: Measures the TSC frequency in Hz (64-bit) using the ACPI PM timer - */ -static uint64_t measure_tsc_frequency(void) -{ - uint64_t tscStart; - uint64_t tscEnd; - uint64_t tscDelta = 0xffffffffffffffffULL; - unsigned long pollCount; - uint64_t retval = 0; - int i; - - /* Time how many TSC ticks elapse in 30 msec using the 8254 PIT - * counter 2. We run this loop 3 times to make sure the cache - * is hot and we take the minimum delta from all of the runs. - * That is to say that we're biased towards measuring the minimum - * number of TSC ticks that occur while waiting for the timer to - * expire. That theoretically helps avoid inconsistencies when - * running under a VM if the TSC is not virtualized and the host - * steals time. The TSC is normally virtualized for VMware. - */ - for(i = 0; i < 10; ++i) - { - enable_PIT2(); - set_PIT2_mode0(CALIBRATE_LATCH); - tscStart = rdtsc64(); - pollCount = poll_PIT2_gate(); - tscEnd = rdtsc64(); - /* The poll loop must have run at least a few times for accuracy */ - if (pollCount <= 1) { - continue; - } - /* The TSC must increment at LEAST once every millisecond. - * We should have waited exactly 30 msec so the TSC delta should - * be >= 30. Anything less and the processor is way too slow. - */ - if ((tscEnd - tscStart) <= CALIBRATE_TIME_MSEC) { - continue; - } - // tscDelta = MIN(tscDelta, (tscEnd - tscStart)) - if ( (tscEnd - tscStart) < tscDelta ) { - tscDelta = tscEnd - tscStart; - } - } - /* tscDelta is now the least number of TSC ticks the processor made in - * a timespan of 0.03 s (e.g. 30 milliseconds) - * Linux thus divides by 30 which gives the answer in kiloHertz because - * 1 / ms = kHz. But we're xnu and most of the rest of the code uses - * Hz so we need to convert our milliseconds to seconds. Since we're - * dividing by the milliseconds, we simply multiply by 1000. - */ - - /* Unlike linux, we're not limited to 32-bit, but we do need to take care - * that we're going to multiply by 1000 first so we do need at least some - * arithmetic headroom. For now, 32-bit should be enough. - * Also unlike Linux, our compiler can do 64-bit integer arithmetic. - */ - if (tscDelta > (1ULL<<32)) { - retval = 0; - } else { - retval = tscDelta * 1000 / 30; - } - disable_PIT2(); - return retval; -} - -/* * Original comment/code: * "DFE: Measures the Max Performance Frequency in Hz (64-bit)" * @@ -192,18 +198,21 @@ pollCount = poll_PIT2_gate(); aperfEnd = rdmsr64(MSR_AMD_APERF); /* The poll loop must have run at least a few times for accuracy */ - if (pollCount <= 1) { + if (pollCount <= 1) + { continue; } /* The TSC must increment at LEAST once every millisecond. * We should have waited exactly 30 msec so the APERF delta should * be >= 30. Anything less and the processor is way too slow. */ - if ((aperfEnd - aperfStart) <= CALIBRATE_TIME_MSEC) { + if ((aperfEnd - aperfStart) <= CALIBRATE_TIME_MSEC) + { continue; } // tscDelta = MIN(tscDelta, (tscEnd - tscStart)) - if ( (aperfEnd - aperfStart) < aperfDelta ) { + if ( (aperfEnd - aperfStart) < aperfDelta ) + { aperfDelta = aperfEnd - aperfStart; } } @@ -211,9 +220,12 @@ * a timespan of 0.03 s (e.g. 30 milliseconds) */ - if (aperfDelta > (1ULL<<32)) { + if (aperfDelta > (1ULL<<32)) + { retval = 0; - } else { + } + else + { retval = aperfDelta * 1000 / 30; } disable_PIT2(); @@ -256,16 +268,21 @@ do_cpuid2(0x00000004, 0, p->CPU.CPUID[CPUID_4]); do_cpuid(0x80000000, p->CPU.CPUID[CPUID_80]); - if (p->CPU.CPUID[CPUID_0][0] >= 0x5) { + if (p->CPU.CPUID[CPUID_0][0] >= 0x5) + { do_cpuid(5, p->CPU.CPUID[CPUID_5]); } - if (p->CPU.CPUID[CPUID_0][0] >= 6) { + if (p->CPU.CPUID[CPUID_0][0] >= 6) + { do_cpuid(6, p->CPU.CPUID[CPUID_6]); } - if ((p->CPU.CPUID[CPUID_80][0] & 0x0000000f) >= 8) { + if ((p->CPU.CPUID[CPUID_80][0] & 0x0000000f) >= 8) + { do_cpuid(0x80000008, p->CPU.CPUID[CPUID_88]); do_cpuid(0x80000001, p->CPU.CPUID[CPUID_81]); - } else if ((p->CPU.CPUID[CPUID_80][0] & 0x0000000f) >= 1) { + } + else if ((p->CPU.CPUID[CPUID_80][0] & 0x0000000f) >= 1) + { do_cpuid(0x80000001, p->CPU.CPUID[CPUID_81]); } @@ -365,7 +382,8 @@ /* get BrandString (if supported) */ /* Copyright: from Apple's XNU cpuid.c */ - if (p->CPU.CPUID[CPUID_80][0] > 0x80000004) { + if (p->CPU.CPUID[CPUID_80][0] > 0x80000004) + { uint32_t reg[4]; char str[128], *s; /* @@ -378,8 +396,10 @@ bcopy((char *)reg, &str[16], 16); do_cpuid(0x80000004, reg); bcopy((char *)reg, &str[32], 16); - for (s = str; *s != '\0'; s++) { - if (*s != ' ') { + for (s = str; *s != '\0'; s++) + { + if (*s != ' ') + { break; } } @@ -735,11 +755,11 @@ DBG("\n---------------------------------------------\n"); DBG("--------------- CPU INFO ---------------\n"); DBG("---------------------------------------------\n"); - DBG("Brand String: %s\n", p->CPU.BrandString); // Processor name (BIOS) - DBG("Vendor: 0x%x\n", p->CPU.Vendor); // Vendor ex: GenuineIntel - DBG("Family: 0x%x\n", p->CPU.Family); // Family ex: 6 (06h) - DBG("ExtFamily: 0x%x\n", p->CPU.ExtFamily); - DBG("Signature: %x\n", p->CPU.Signature); // CPUID signature + DBG("Brand String: %s\n", p->CPU.BrandString); // Processor name (BIOS) + DBG("Vendor: 0x%x\n", p->CPU.Vendor); // Vendor ex: GenuineIntel + DBG("Family: 0x%x\n", p->CPU.Family); // Family ex: 6 (06h) + DBG("ExtFamily: 0x%x\n", p->CPU.ExtFamily); + DBG("Signature: %x\n", p->CPU.Signature); // CPUID signature /*switch (p->CPU.Type) { case PT_OEM: DBG("Processor type: Intel Original OEM Processor\n"); @@ -756,20 +776,20 @@ default: break; }*/ - DBG("Model: 0x%x\n", p->CPU.Model); // Model ex: 37 (025h) - DBG("ExtModel: 0x%x\n", p->CPU.ExtModel); - DBG("Stepping: 0x%x\n", p->CPU.Stepping); // Stepping ex: 5 (05h) - DBG("MaxCoef: 0x%x\n", p->CPU.MaxCoef); - DBG("CurrCoef: 0x%x\n", p->CPU.CurrCoef); - DBG("MaxDiv: 0x%x\n", p->CPU.MaxDiv); - DBG("CurrDiv: 0x%x\n", p->CPU.CurrDiv); - DBG("TSCFreq: %dMHz\n", p->CPU.TSCFrequency / 1000000); - DBG("FSBFreq: %dMHz\n", (p->CPU.FSBFrequency + 500000) / 1000000); - DBG("CPUFreq: %dMHz\n", p->CPU.CPUFrequency / 1000000); - DBG("Cores: %d\n", p->CPU.NoCores); // Cores - DBG("Logical processor: %d\n", p->CPU.NoThreads); // Logical procesor - DBG("Features: 0x%08x\n", p->CPU.Features); - DBG("Microcode version: %d\n", p->CPU.MCodeVersion); // CPU microcode version + DBG("Model: 0x%x\n", p->CPU.Model); // Model ex: 37 (025h) + DBG("ExtModel: 0x%x\n", p->CPU.ExtModel); + DBG("Stepping: 0x%x\n", p->CPU.Stepping); // Stepping ex: 5 (05h) + DBG("MaxCoef: 0x%x\n", p->CPU.MaxCoef); + DBG("CurrCoef: 0x%x\n", p->CPU.CurrCoef); + DBG("MaxDiv: 0x%x\n", p->CPU.MaxDiv); + DBG("CurrDiv: 0x%x\n", p->CPU.CurrDiv); + DBG("TSCFreq: %dMHz\n", p->CPU.TSCFrequency / 1000000); + DBG("FSBFreq: %dMHz\n", (p->CPU.FSBFrequency + 500000) / 1000000); + DBG("CPUFreq: %dMHz\n", p->CPU.CPUFrequency / 1000000); + DBG("Cores: %d\n", p->CPU.NoCores); // Cores + DBG("Logical processor: %d\n", p->CPU.NoThreads); // Logical procesor + DBG("Features: 0x%08x\n", p->CPU.Features); + DBG("Microcode version: %d\n", p->CPU.MCodeVersion); // CPU microcode version DBG("\n---------------------------------------------\n"); #if DEBUG_CPU pause(); Index: branches/ErmaC/Enoch/i386/libsaio/disk.c =================================================================== --- branches/ErmaC/Enoch/i386/libsaio/disk.c (revision 2470) +++ branches/ErmaC/Enoch/i386/libsaio/disk.c (revision 2471) @@ -717,7 +717,8 @@ int probe, int type, unsigned int bvrFlags ) { BVRef bvr = (BVRef) malloc( sizeof(*bvr) ); - if ( bvr ) { + if ( bvr ) + { bzero(bvr, sizeof(*bvr)); bvr->biosdev = biosdev; @@ -733,14 +734,18 @@ bvr->bv_free = bvFreeFunc; // FIXME: UCS-2 -> UTF-8 the name strlcpy(bvr->name, "----", DPISTRLEN); - if ( (efi_guid_compare(&GPT_BOOT_GUID, (EFI_GUID const*)part->ent_type) == 0) || (efi_guid_compare(&GPT_HFS_GUID, (EFI_GUID const*)part->ent_type) == 0) ) { + if ( (efi_guid_compare(&GPT_BOOT_GUID, (EFI_GUID const*)part->ent_type) == 0) || (efi_guid_compare(&GPT_HFS_GUID, (EFI_GUID const*)part->ent_type) == 0) ) + { strlcpy(bvr->type_name, "GPT HFS+", DPISTRLEN); - } else { + } + else + { strlcpy(bvr->type_name, "GPT Unknown", DPISTRLEN); } /* - if ( part->bootid & FDISK_ACTIVE ) { + if ( part->bootid & FDISK_ACTIVE ) + { bvr->flags |= kBVFlagPrimary; } */ @@ -820,45 +825,45 @@ spc = 1; } - do { - // Create a new mapping. + do { + // Create a new mapping. - map = (struct DiskBVMap *) malloc( sizeof(*map) ); - if ( map ) + map = (struct DiskBVMap *) malloc( sizeof(*map) ); + if ( map ) { - map->biosdev = biosdev; - map->bvr = NULL; - map->bvrcnt = 0; - map->next = gDiskBVMap; - gDiskBVMap = map; + map->biosdev = biosdev; + map->bvr = NULL; + map->bvrcnt = 0; + map->next = gDiskBVMap; + gDiskBVMap = map; - // Create a record for each partition found on the disk. + // Create a record for each partition found on the disk. - while ( getNextFDiskPartition( biosdev, &partno, &part ) ) - { - DEBUG_DISK(("%s: part %d [%x]\n", __FUNCTION__, - partno, part->systid)); - bvr = 0; + while ( getNextFDiskPartition( biosdev, &partno, &part ) ) + { + DEBUG_DISK(("%s: part %d [%x]\n", __FUNCTION__, + partno, part->systid)); + bvr = 0; - switch ( part->systid ) - { + switch ( part->systid ) + { #if UFS_SUPPORT - case FDISK_UFS: - bvr = newFDiskBVRef( - biosdev, partno, - part->relsect + UFS_FRONT_PORCH/BPS, - part, - UFSInitPartition, - UFSLoadFile, - UFSReadFile, - UFSGetDirEntry, - UFSGetFileBlock, - UFSGetUUID, - UFSGetDescription, - UFSFree, - 0, - kBIOSDevTypeHardDrive, 0); - break; + case FDISK_UFS: + bvr = newFDiskBVRef( + biosdev, partno, + part->relsect + UFS_FRONT_PORCH/BPS, + part, + UFSInitPartition, + UFSLoadFile, + UFSReadFile, + UFSGetDirEntry, + UFSGetFileBlock, + UFSGetUUID, + UFSGetDescription, + UFSFree, + 0, + kBIOSDevTypeHardDrive, 0); + break; #endif case FDISK_HFS: @@ -898,8 +903,8 @@ break; #if UFS_SUPPORT - case FDISK_BOOTER: - booterUFS = newFDiskBVRef( + case FDISK_BOOTER: + booterUFS = newFDiskBVRef( biosdev, partno, ((part->relsect + spc - 1) / spc) * spc, part, @@ -913,7 +918,7 @@ UFSFree, 0, kBIOSDevTypeHardDrive, 0); - break; + break; #endif case FDISK_FAT32: @@ -1686,25 +1691,32 @@ u_int32_t time; int fh, fileSize, error; - for (bvr = chain; bvr; bvr = bvr->next) { + for (bvr = chain; bvr; bvr = bvr->next) + { ret = -1; error = 0; // // Check for alternate volume label on boot helper partitions. // - if (bvr->flags & kBVFlagBooter) { + if (bvr->flags & kBVFlagBooter) + { sprintf(dirSpec, "hd(%d,%d)/System/Library/CoreServices/", BIOS_DEV_UNIT(bvr), bvr->part_no); strcpy(fileSpec, ".disk_label.contentDetails"); ret = GetFileInfo(dirSpec, fileSpec, &flags, &time); - if (!ret) { + if (!ret) + { fh = open(strcat(dirSpec, fileSpec), 0); fileSize = file_size(fh); - if (fileSize > 0 && fileSize < BVSTRLEN) { - if (read(fh, label, fileSize) != fileSize) { + if (fileSize > 0 && fileSize < BVSTRLEN) + { + if (read(fh, label, fileSize) != fileSize) + { error = -1; } - } else { + } + else + { error = -1; } @@ -1727,6 +1739,7 @@ bvr->flags |= kBVFlagSystemVolume; } } + } } @@ -1757,11 +1770,16 @@ verbose("Resetting BIOS device %xh\n", biosdev); // Reset the biosbuf cache cache_valid = false; - if(map == gDiskBVMap) { + if(map == gDiskBVMap) + { gDiskBVMap = map->next; - } else if(prevMap != NULL) { + } + else if(prevMap != NULL) + { prevMap->next = map->next; - } else { + } + else + { stop(""); } } @@ -1909,7 +1927,8 @@ if ( (!allowFlags || newBVR->flags & allowFlags) && (!denyFlags || !(newBVR->flags & denyFlags) ) && (newBVR->biosdev >= minBIOSDev && newBVR->biosdev <= maxBIOSDev) - ) { + ) + { newBVR->visible = true; } @@ -1918,7 +1937,8 @@ * to be able to hide foreign partitions from the boot menu. * */ - if ( (newBVR->flags & kBVFlagForeignBoot) ) { + if ( (newBVR->flags & kBVFlagForeignBoot) ) + { char *start, *next = val; long len = 0; do @@ -1935,18 +1955,21 @@ /* * Use the first bvr entry as the starting chain pointer. */ - if (!chain) { + if (!chain) + { chain = newBVR; } /* * Update the previous bvr's link pointer to use the new memory area. */ - if (prevBVR) { + if (prevBVR) + { prevBVR->next = newBVR; } - if (newBVR->visible) { + if (newBVR->visible) + { bvCount++; } } Index: branches/ErmaC/Enoch/i386/libsaio/smbios.c =================================================================== --- branches/ErmaC/Enoch/i386/libsaio/smbios.c (revision 2470) +++ branches/ErmaC/Enoch/i386/libsaio/smbios.c (revision 2471) @@ -652,7 +652,9 @@ defaultBaseBoard.product = kDefaultMacBookProBoardProduct; defaultBaseBoard.boardType = kSMBBaseBoardMotherboard; defaultChassis.chassisType = kSMBchassisUnknown; - } else { + } + else + { defaultSystemInfo.productName = kDefaultMacBook; defaultBIOSInfo.version = kDefaultMacBookBIOSVersion; defaultBIOSInfo.releaseDate = kDefaultMacBookBIOSReleaseDate; @@ -661,7 +663,9 @@ defaultBaseBoard.boardType = kSMBBaseBoardMotherboard; defaultChassis.chassisType = kSMBchassisUnknown; } - } else { + } + else + { switch (Platform.CPU.NoCores) { case 1: Index: branches/ErmaC/Enoch/i386/libsaio/smbios_decode.c =================================================================== --- branches/ErmaC/Enoch/i386/libsaio/smbios_decode.c (revision 2470) +++ branches/ErmaC/Enoch/i386/libsaio/smbios_decode.c (revision 2471) @@ -471,14 +471,18 @@ printHeader(structHeader); DBG("Memory Device\n"); // Aray Handle - if (((SMBMemoryDevice *)structHeader)->errorHandle == 0xFFFF) { + if (((SMBMemoryDevice *)structHeader)->errorHandle == 0xFFFF) + { DBG("\tError Information Handle: No Error\n"); - } else { + } + else + { DBG("\tError Information Handle: 0x%x\n", ((SMBMemoryDevice *)structHeader)->errorHandle); } // Total Width: // Data Width: - switch (((SMBMemoryDevice *)structHeader)->memorySize) { + switch (((SMBMemoryDevice *)structHeader)->memorySize) + { case 0: DBG("\tSize: No Module Installed\n"); break; @@ -492,17 +496,23 @@ DBG("\tSize: %d %s\n", ((SMBMemoryDevice *)structHeader)->memorySize & 0x7FFF, ((((SMBMemoryDevice *)structHeader)->memorySize & 0x8000) == 0x8000) ? "kB" : "MB"); break; } - if ((((SMBMemoryDevice *)structHeader)->formFactor < 0x01) || (((SMBMemoryDevice *)structHeader)->formFactor > 0x0F)) { + if ((((SMBMemoryDevice *)structHeader)->formFactor < 0x01) || (((SMBMemoryDevice *)structHeader)->formFactor > 0x0F)) + { DBG("\tForm Factor: %s\n", OutOfSpecStr); - } else { - DBG("\tForm Factor: %s\n", SMBMemoryDeviceFormFactors[((SMBMemoryDevice *)structHeader)->formFactor - 1]); - } + } + else + { + DBG("\tForm Factor: %s\n", SMBMemoryDeviceFormFactors[((SMBMemoryDevice *)structHeader)->formFactor - 1]); + } // Set: DBG("\tLocator: %s\n", SMBStringForField(structHeader, ((SMBMemoryDevice *)structHeader)->deviceLocator, neverMask)); DBG("\tBank Locator: %s\n", SMBStringForField(structHeader, ((SMBMemoryDevice *)structHeader)->bankLocator, neverMask)); - if (((SMBMemoryDevice *)structHeader)->memoryType > kSMBMemoryDeviceTypeCount) { + if (((SMBMemoryDevice *)structHeader)->memoryType > kSMBMemoryDeviceTypeCount) + { DBG("\tMemory Type: %s\n", OutOfSpecStr); - } else { + } + else + { DBG("\tMemory Type: %s\n", SMBMemoryDeviceTypes[((SMBMemoryDevice *)structHeader)->memoryType]); } // Type Detail: @@ -651,7 +661,8 @@ ptr = (uint8_t *)((uint32_t)structHeader + structHeader->length); for (; ((uint16_t *)ptr)[0] != 0; ptr++); - if (((uint16_t *)ptr)[0] == 0) { + if (((uint16_t *)ptr)[0] == 0) + { ptr += 2; } Index: branches/ErmaC/Enoch/i386/libsaio/convert.c =================================================================== --- branches/ErmaC/Enoch/i386/libsaio/convert.c (revision 2470) +++ branches/ErmaC/Enoch/i386/libsaio/convert.c (revision 2471) @@ -10,21 +10,21 @@ /** Transform a 16 bytes hexadecimal value UUID to a string */ const char * getStringFromUUID(const EFI_CHAR8* eUUID) { - static char msg[UUID_LEN*2 + 8] = ""; - if (!eUUID) return ""; - const unsigned char * uuid = (unsigned char*) eUUID; - sprintf(msg, "%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x", + static char msg[UUID_LEN*2 + 8] = ""; + if (!eUUID) return ""; + const unsigned char * uuid = (unsigned char*) eUUID; + sprintf(msg, "%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x", uuid[0], uuid[1], uuid[2], uuid[3], uuid[4], uuid[5], uuid[6], uuid[7], uuid[8], uuid[9], uuid[10],uuid[11], uuid[12],uuid[13],uuid[14],uuid[15]); - return msg ; + return msg ; } /** Parse an UUID string into an (EFI_CHAR8*) buffer */ EFI_CHAR8* getUUIDFromString(const char *source) { - if (!source) return 0; + if (!source) return 0; char *p = (char *)source; int i; @@ -32,21 +32,25 @@ static EFI_CHAR8 uuid[UUID_LEN+1]=""; buf[2] = '\0'; - for (i=0; i= 48 && buff[i] <= 57) // '0' through '9' - digit = buff[i] - 48; + if (buff[i] >= 48 && buff[i] <= 57) // '0' through '9' + digit = buff[i] - 48; else if (buff[i] >= 65 && buff[i] <= 70) // 'A' through 'F' digit = buff[i] - 55; else if (buff[i] >= 97 && buff[i] <= 102) // 'a' through 'f' digit = buff[i] - 87; else return value; - + value = digit + 16 * value; } return value; @@ -75,58 +79,62 @@ void *convertHexStr2Binary(const char *hexStr, int *outLength) { - int len; - char hexNibble; - char hexByte[2]; - uint8_t binChar; - uint8_t *binStr; - int hexStrIdx, binStrIdx, hexNibbleIdx; + int len; + char hexNibble; + char hexByte[2]; + uint8_t binChar; + uint8_t *binStr; + int hexStrIdx, binStrIdx, hexNibbleIdx; - len = strlen(hexStr); - if (len > 1) - { - // the resulting binary will be the half size of the input hex string - binStr = malloc(len / 2); - binStrIdx = 0; - hexNibbleIdx = 0; - for (hexStrIdx = 0; hexStrIdx < len; hexStrIdx++) - { - hexNibble = hexStr[hexStrIdx]; - - // ignore all chars except valid hex numbers - if ( (hexNibble >= '0' && hexNibble <= '9') || - (hexNibble >= 'A' && hexNibble <= 'F') || - (hexNibble >= 'a' && hexNibble <= 'f') ) { - hexByte[hexNibbleIdx++] = hexNibble; - - // found both two nibbles, convert to binary - if (hexNibbleIdx == 2) - { - binChar = 0; + len = strlen(hexStr); + if (len > 1) + { + // the resulting binary will be the half size of the input hex string + binStr = malloc(len / 2); + + binStrIdx = 0; + hexNibbleIdx = 0; + for (hexStrIdx = 0; hexStrIdx < len; hexStrIdx++) + { + hexNibble = hexStr[hexStrIdx]; + + // ignore all chars except valid hex numbers + if ( (hexNibble >= '0' && hexNibble <= '9') || + (hexNibble >= 'A' && hexNibble <= 'F') || + (hexNibble >= 'a' && hexNibble <= 'f') ) + { + hexByte[hexNibbleIdx++] = hexNibble; + + // found both two nibbles, convert to binary + if (hexNibbleIdx == 2) + { + binChar = 0; + + for (hexNibbleIdx = 0; hexNibbleIdx < sizeof(hexByte); hexNibbleIdx++) + { + if (hexNibbleIdx > 0) + { + binChar = binChar << 4; + } + + if (hexByte[hexNibbleIdx] <= '9') binChar += hexByte[hexNibbleIdx] - '0'; + else if (hexByte[hexNibbleIdx] <= 'F') binChar += hexByte[hexNibbleIdx] - ('A' - 10); + else if (hexByte[hexNibbleIdx] <= 'f') binChar += hexByte[hexNibbleIdx] - ('a' - 10); + } - for (hexNibbleIdx = 0; hexNibbleIdx < sizeof(hexByte); hexNibbleIdx++) { - if (hexNibbleIdx > 0) { - binChar = binChar << 4; + binStr[binStrIdx++] = binChar; + hexNibbleIdx = 0; + } + } } - - if (hexByte[hexNibbleIdx] <= '9') binChar += hexByte[hexNibbleIdx] - '0'; - else if (hexByte[hexNibbleIdx] <= 'F') binChar += hexByte[hexNibbleIdx] - ('A' - 10); - else if (hexByte[hexNibbleIdx] <= 'f') binChar += hexByte[hexNibbleIdx] - ('a' - 10); - } - - binStr[binStrIdx++] = binChar; - hexNibbleIdx = 0; - } - } - } - *outLength = binStrIdx; - return binStr; - } - else - { - *outLength = 0; - return NULL; - } + *outLength = binStrIdx; + return binStr; + } + else + { + *outLength = 0; + return NULL; + } } // FIXME: can't use my original code here, Index: branches/ErmaC/Enoch/i386/libsaio/msdos.c =================================================================== --- branches/ErmaC/Enoch/i386/libsaio/msdos.c (revision 2470) +++ branches/ErmaC/Enoch/i386/libsaio/msdos.c (revision 2471) @@ -71,21 +71,35 @@ static int msdosrootcluster = 0; static int msdosfatbits = 0; +struct msdosdirstate +{ + struct direntry *buf; + uint8_t vfatchecksum; + int root16; + off_t cluster; + int nument; + int vfatnumber; +}; + #if UNUSED /* * Check a volume label. */ -static int -oklabel(const char *src) +static int oklabel(const char *src); + +static int oklabel(const char *src) { int c, i; - for (i = 0, c = 0; i <= 11; i++) { - c = (u_char)*src++; - if (c < ' ' + !i || strchr("\"*+,./:;<=>?[\\]|", c)) - break; - } - return i && !c; + for (i = 0, c = 0; i <= 11; i++) + { + c = (u_char)*src++; + if (c < ' ' + !i || strchr("\"*+,./:;<=>?[\\]|", c)) + { + break; + } + } + return i && !c; } #endif /* UNUSED */ @@ -167,10 +181,10 @@ Seek(ih, 0); Read(ih, (long)buf, 512); - bsp = (union bootsector *)buf; - b33 = (struct bpb33 *)bsp->bs33.bsBPB; - b50 = (struct bpb50 *)bsp->bs50.bsBPB; - b710 = (struct bpb710 *)bsp->bs710.bsBPB; + bsp = (union bootsector *)buf; + b33 = (struct bpb33 *)bsp->bs33.bsBPB; + b50 = (struct bpb50 *)bsp->bs50.bsBPB; + b710 = (struct bpb710 *)bsp->bs710.bsBPB; /* We only work with 512, 1024, and 2048 byte sectors */ @@ -188,7 +202,9 @@ free (buf); return -1; } - if (OSSwapLittleToHostInt16(b50->bpbRootDirEnts) == 0) { /* It's FAT32 */ + if (OSSwapLittleToHostInt16(b50->bpbRootDirEnts) == 0) + { + /* It's FAT32 */ if (memcmp(((struct extboot *)bsp->bs710.bsExt)->exFileSysType, "FAT32 ", 8)) { free (buf); @@ -201,11 +217,16 @@ msdosrootDirSectors = 0; msdosfatbits = 32; } - else if (((struct extboot *)bsp->bs50.bsExt)->exBootSignature == EXBOOTSIG) { + else if (((struct extboot *)bsp->bs50.bsExt)->exBootSignature == EXBOOTSIG) + { if (!memcmp((char *)((struct extboot *)bsp->bs50.bsExt)->exFileSysType, "FAT16 ", 8)) + { msdosfatbits = 16; + } else if (!memcmp((char *)((struct extboot *)bsp->bs50.bsExt)->exFileSysType, "FAT12 ", 8)) + { msdosfatbits = 12; + } else { free (buf); @@ -325,16 +346,6 @@ } } -struct msdosdirstate -{ - struct direntry *buf; - uint8_t vfatchecksum; - int root16; - off_t cluster; - int nument; - int vfatnumber; -}; - static struct direntry * getnextdirent (CICell ih, uint16_t *longname, struct msdosdirstate *st) { @@ -427,134 +438,134 @@ /* First comes lowercase, then uppercase*/ static uint16_t cp850[128][2]= { -{0x00E7,0x00C7}, -{0x00FC,0x00DC}, -{0x00E9,0x00C9}, -{0x00E2,0x00C2}, -{0x00E4,0x00C4}, -{0x00E0,0x00C0}, -{0x00E5,0x00C5}, -{0x00E7,0x00C7}, -{0x00EA,0x00CA}, -{0x00EB,0x00CB}, -{0x00E8,0x00C8}, -{0x00EF,0x00CF}, -{0x00EE,0x00CE}, -{0x00EC,0x00CC}, -{0x00E4,0x00C4}, -{0x00E5,0x00C5}, -{0x00E9,0x00C9}, -{0x00E6,0x00C6}, -{0x00E6,0x00C6}, -{0x00F4,0x00D4}, -{0x00F6,0x00D6}, -{0x00F2,0x00D2}, -{0x00FB,0x00DB}, -{0x00F9,0x00D9}, -{0x00FF,0x0178}, -{0x00F6,0x00D6}, -{0x00FC,0x00DC}, -{0x00F8,0x00D8}, -{0x00A3,0x00A3}, -{0x00F8,0x00D8}, -{0x00D7,0x00D7}, -{0x0192,0x0191}, -{0x00E1,0x00C1}, -{0x00ED,0x00CD}, -{0x00F3,0x00D3}, -{0x00FA,0x00DA}, -{0x00F1,0x00D1}, -{0x00F1,0x00D1}, -{0x00AA,0x00AA}, -{0x00BA,0x00BA}, -{0x00BF,0x00BF}, -{0x00AE,0x00AE}, -{0x00AC,0x00AC}, -{0x00BD,0x00BD}, -{0x00BC,0x00BC}, -{0x00A1,0x00A1}, -{0x00AB,0x00AB}, -{0x00BB,0x00BB}, -{0x2591,0x2591}, -{0x2592,0x2592}, -{0x2593,0x2593}, -{0x2502,0x2502}, -{0x2524,0x2524}, -{0x00E1,0x00C1}, -{0x00E2,0x00C2}, -{0x00E0,0x00C0}, -{0x00A9,0x00A9}, -{0x2563,0x2563}, -{0x2551,0x2551}, -{0x2557,0x2557}, -{0x255D,0x255D}, -{0x00A2,0x00A2}, -{0x00A5,0x00A5}, -{0x2510,0x2510}, -{0x2514,0x2514}, -{0x2534,0x2534}, -{0x252C,0x252C}, -{0x251C,0x251C}, -{0x2500,0x2500}, -{0x253C,0x253C}, -{0x00E3,0x00C3}, -{0x00E3,0x00C3}, -{0x255A,0x255A}, -{0x2554,0x2554}, -{0x2569,0x2569}, -{0x2566,0x2566}, -{0x2560,0x2560}, -{0x2550,0x2550}, -{0x256C,0x256C}, -{0x00A4,0x00A4}, -{0x00F0,0x00D0}, -{0x00F0,0x00D0}, -{0x00EA,0x00CA}, -{0x00EB,0x00CB}, -{0x00E8,0x00C8}, -{0x0131,0x0049}, -{0x00ED,0x00CD}, -{0x00EE,0x00CE}, -{0x00EF,0x00CF}, -{0x2518,0x2518}, -{0x250C,0x250C}, -{0x2588,0x2588}, -{0x2584,0x2584}, -{0x00A6,0x00A6}, -{0x00EC,0x00CC}, -{0x2580,0x2580}, -{0x00F3,0x00D3}, -{0x00DF,0x00DF}, -{0x00F4,0x00D4}, -{0x00F2,0x00D2}, -{0x00F5,0x00D5}, -{0x00F5,0x00D5}, -{0x00B5,0x00B5}, -{0x00FE,0x00DE}, -{0x00FE,0x00DE}, -{0x00FA,0x00DA}, -{0x00FB,0x00DB}, -{0x00F9,0x00D9}, -{0x00FD,0x00DD}, -{0x00FD,0x00DD}, -{0x00AF,0x00AF}, -{0x00B4,0x00B4}, -{0x00AD,0x00AD}, -{0x00B1,0x00B1}, -{0x2017,0x2017}, -{0x00BE,0x00BE}, -{0x00B6,0x00B6}, -{0x00A7,0x00A7}, -{0x00F7,0x00F7}, -{0x00B8,0x00B8}, -{0x00B0,0x00B0}, -{0x00A8,0x00A8}, -{0x00B7,0x00B7}, -{0x00B9,0x00B9}, -{0x00B3,0x00B3}, -{0x00B2,0x00B2}, -{0x25A0,0x25A0}, -{0x00A0,0x00A0} + {0x00E7,0x00C7}, + {0x00FC,0x00DC}, + {0x00E9,0x00C9}, + {0x00E2,0x00C2}, + {0x00E4,0x00C4}, + {0x00E0,0x00C0}, + {0x00E5,0x00C5}, + {0x00E7,0x00C7}, + {0x00EA,0x00CA}, + {0x00EB,0x00CB}, + {0x00E8,0x00C8}, + {0x00EF,0x00CF}, + {0x00EE,0x00CE}, + {0x00EC,0x00CC}, + {0x00E4,0x00C4}, + {0x00E5,0x00C5}, + {0x00E9,0x00C9}, + {0x00E6,0x00C6}, + {0x00E6,0x00C6}, + {0x00F4,0x00D4}, + {0x00F6,0x00D6}, + {0x00F2,0x00D2}, + {0x00FB,0x00DB}, + {0x00F9,0x00D9}, + {0x00FF,0x0178}, + {0x00F6,0x00D6}, + {0x00FC,0x00DC}, + {0x00F8,0x00D8}, + {0x00A3,0x00A3}, + {0x00F8,0x00D8}, + {0x00D7,0x00D7}, + {0x0192,0x0191}, + {0x00E1,0x00C1}, + {0x00ED,0x00CD}, + {0x00F3,0x00D3}, + {0x00FA,0x00DA}, + {0x00F1,0x00D1}, + {0x00F1,0x00D1}, + {0x00AA,0x00AA}, + {0x00BA,0x00BA}, + {0x00BF,0x00BF}, + {0x00AE,0x00AE}, + {0x00AC,0x00AC}, + {0x00BD,0x00BD}, + {0x00BC,0x00BC}, + {0x00A1,0x00A1}, + {0x00AB,0x00AB}, + {0x00BB,0x00BB}, + {0x2591,0x2591}, + {0x2592,0x2592}, + {0x2593,0x2593}, + {0x2502,0x2502}, + {0x2524,0x2524}, + {0x00E1,0x00C1}, + {0x00E2,0x00C2}, + {0x00E0,0x00C0}, + {0x00A9,0x00A9}, + {0x2563,0x2563}, + {0x2551,0x2551}, + {0x2557,0x2557}, + {0x255D,0x255D}, + {0x00A2,0x00A2}, + {0x00A5,0x00A5}, + {0x2510,0x2510}, + {0x2514,0x2514}, + {0x2534,0x2534}, + {0x252C,0x252C}, + {0x251C,0x251C}, + {0x2500,0x2500}, + {0x253C,0x253C}, + {0x00E3,0x00C3}, + {0x00E3,0x00C3}, + {0x255A,0x255A}, + {0x2554,0x2554}, + {0x2569,0x2569}, + {0x2566,0x2566}, + {0x2560,0x2560}, + {0x2550,0x2550}, + {0x256C,0x256C}, + {0x00A4,0x00A4}, + {0x00F0,0x00D0}, + {0x00F0,0x00D0}, + {0x00EA,0x00CA}, + {0x00EB,0x00CB}, + {0x00E8,0x00C8}, + {0x0131,0x0049}, + {0x00ED,0x00CD}, + {0x00EE,0x00CE}, + {0x00EF,0x00CF}, + {0x2518,0x2518}, + {0x250C,0x250C}, + {0x2588,0x2588}, + {0x2584,0x2584}, + {0x00A6,0x00A6}, + {0x00EC,0x00CC}, + {0x2580,0x2580}, + {0x00F3,0x00D3}, + {0x00DF,0x00DF}, + {0x00F4,0x00D4}, + {0x00F2,0x00D2}, + {0x00F5,0x00D5}, + {0x00F5,0x00D5}, + {0x00B5,0x00B5}, + {0x00FE,0x00DE}, + {0x00FE,0x00DE}, + {0x00FA,0x00DA}, + {0x00FB,0x00DB}, + {0x00F9,0x00D9}, + {0x00FD,0x00DD}, + {0x00FD,0x00DD}, + {0x00AF,0x00AF}, + {0x00B4,0x00B4}, + {0x00AD,0x00AD}, + {0x00B1,0x00B1}, + {0x2017,0x2017}, + {0x00BE,0x00BE}, + {0x00B6,0x00B6}, + {0x00A7,0x00A7}, + {0x00F7,0x00F7}, + {0x00B8,0x00B8}, + {0x00B0,0x00B0}, + {0x00A8,0x00A8}, + {0x00B7,0x00B7}, + {0x00B9,0x00B9}, + {0x00B3,0x00B3}, + {0x00B2,0x00B2}, + {0x25A0,0x25A0}, + {0x00A0,0x00A0} }; static int @@ -780,7 +791,8 @@ if (filePath[0] == '/') filePath++; buf = malloc(msdosclustersize); - if (!buf) { + if (!buf) + { return -1; } dirp = getdirpfrompath (ih, filePath, buf); @@ -794,7 +806,8 @@ if (msdosfatbits == 32) cluster |= ((uint32_t)OSReadLittleInt16 ((dirp->deHighClust),0)) <<16; size = (uint32_t)OSReadLittleInt32 ((dirp->deFileSize),0); - if (size<=offset) { + if (size<=offset) + { free (buf); return -1; } @@ -838,7 +851,8 @@ if (filePath[0] == '/') filePath++; buf = malloc(msdosclustersize); - if (!buf) { + if (!buf) + { return -1; } dirp = getdirpfrompath (ih, filePath, buf); @@ -933,7 +947,8 @@ initRoot (&st); st.buf = malloc(msdosclustersize); - if (!st.buf) { + if (!st.buf) + { return; } while ((dirp = getnextdirent (ih, vfatlabel, &st))) @@ -965,7 +980,9 @@ union bootsector *bsp = (union bootsector *)buf; Seek(ih, 0); Read(ih, (long)buf, 512); - if (msdosfatbits == 32) { /* It's FAT32 */ + if (msdosfatbits == 32) + { + /* It's FAT32 */ strncpy((char *)label, (char *)((struct extboot *)bsp->bs710.bsExt)->exVolumeLabel, LABEL_LENGTH); } else if (msdosfatbits == 16) @@ -983,11 +1000,12 @@ MSDOSGetUUID(CICell ih, char *uuidStr) { char *buf = malloc (512); - if (!buf) { + if (!buf) + { return -1; } union bootsector *bsp = (union bootsector *)buf; - + if (MSDOSInitPartition (ih)<0) { free (buf); Index: branches/ErmaC/Enoch/i386/libsaio/smbios_getters.c =================================================================== --- branches/ErmaC/Enoch/i386/libsaio/smbios_getters.c (revision 2470) +++ branches/ErmaC/Enoch/i386/libsaio/smbios_getters.c (revision 2471) @@ -21,8 +21,10 @@ bool getProcessorInformationExternalClock(returnType *value) { - if (Platform.CPU.Vendor == CPUID_VENDOR_INTEL) { // Intel - switch (Platform.CPU.Family) { + if (Platform.CPU.Vendor == CPUID_VENDOR_INTEL) // Intel + { + switch (Platform.CPU.Family) + { case 0x06: { switch (Platform.CPU.Model) @@ -49,7 +51,9 @@ default: value->word = (uint16_t)(Platform.CPU.FSBFrequency/1000000LL); } - } else { + } + else + { value->word = (uint16_t)(Platform.CPU.FSBFrequency/1000000LL); } @@ -102,13 +106,15 @@ // Nehalem supports Scrubbing // First, locate the PCI bus where the MCH is located - for(i = 0; i < (sizeof(possible_nhm_bus)/sizeof(possible_nhm_bus[0])); i++) { + for(i = 0; i < (sizeof(possible_nhm_bus)/sizeof(possible_nhm_bus[0])); i++) + { vid = pci_config_read16(PCIADDR(possible_nhm_bus[i], 3, 4), 0x00); did = pci_config_read16(PCIADDR(possible_nhm_bus[i], 3, 4), 0x02); vid &= 0xFFFF; did &= 0xFF00; - if(vid == 0x8086 && did >= 0x2C00) { + if(vid == 0x8086 && did >= 0x2C00) + { nhm_bus = possible_nhm_bus[i]; } } @@ -119,7 +125,8 @@ DBG("qpimult %d\n", qpimult); qpibusspeed = (qpimult * 2 * (Platform.CPU.FSBFrequency/1000000LL)); // Rek: rounding decimals to match original mac profile info - if (qpibusspeed%100 != 0) { + if (qpibusspeed%100 != 0) + { qpibusspeed = ((qpibusspeed+50)/100)*100; } DBG("qpibusspeed %d\n", qpibusspeed); @@ -139,9 +146,12 @@ uint16_t simpleGetSMBOemProcessorType(void) { - if (Platform.CPU.NoCores >= 4) { + if (Platform.CPU.NoCores >= 4) + { return 0x501; // 1281 - Quad-Core Xeon - } else if (Platform.CPU.NoCores == 1) { + } + else if (Platform.CPU.NoCores == 1) + { return 0x201; // 513 - Core Duo }; @@ -154,13 +164,16 @@ value->word = simpleGetSMBOemProcessorType(); - if (Platform.CPU.Vendor == CPUID_VENDOR_INTEL) { // Intel - if (!done) { + if (Platform.CPU.Vendor == CPUID_VENDOR_INTEL) // Intel + { + if (!done) + { verbose("CPU is %s, family 0x%x, model 0x%x\n", Platform.CPU.BrandString, (uint32_t)Platform.CPU.Family, (uint32_t)Platform.CPU.Model); done = true; } // Bungo: fixes Oem Processor Type - better matching IMHO, needs testing - switch (Platform.CPU.Family) { + switch (Platform.CPU.Family) + { case 0x0F: case 0x06: { @@ -188,11 +201,14 @@ if (strstr(Platform.CPU.BrandString, "Xeon")) { value->word = 0x402; // 1026 - Xeon - return true; + return true; } - if (Platform.CPU.NoCores <= 2) { + if (Platform.CPU.NoCores <= 2) + { value->word = 0x301; // 769 - Core 2 Duo - } else { + } + else + { value->word = 0x402; // 1026 - Core 2 Quad as Xeon } return true; @@ -210,19 +226,23 @@ value->word = 0x501; // 1281 - Lynnfiled Quad-Core Xeon return true; } - if (strstr(Platform.CPU.BrandString, "Core(TM) i3")) { + if (strstr(Platform.CPU.BrandString, "Core(TM) i3")) + { value->word = 0x901; // 2305 - Core i3 return true; } - if (strstr(Platform.CPU.BrandString, "Core(TM) i5")) { + if (strstr(Platform.CPU.BrandString, "Core(TM) i5")) + { value->word = 0x601; // Core i5 return true; } - if (strstr(Platform.CPU.BrandString, "Core(TM) i7")) { + if (strstr(Platform.CPU.BrandString, "Core(TM) i7")) + { value->word = 0x701; // 1793 - Core i7 return true; } - if (Platform.CPU.NoCores <= 2) { + if (Platform.CPU.NoCores <= 2) + { value->word = 0x901; // - Core i3 } return true; @@ -235,19 +255,23 @@ value->word = 0x501; // 1281 - Xeon return true; } - if (strstr(Platform.CPU.BrandString, "Core(TM) i3")) { + if (strstr(Platform.CPU.BrandString, "Core(TM) i3")) + { value->word = 0x901; // 2305 - Core i3 return true; } - if (strstr(Platform.CPU.BrandString, "Core(TM) i5")) { + if (strstr(Platform.CPU.BrandString, "Core(TM) i5")) + { value->word = 0x602; // 1538 - Core i5 return true; } - if (strstr(Platform.CPU.BrandString, "Core(TM) i7")) { + if (strstr(Platform.CPU.BrandString, "Core(TM) i7")) + { value->word = 0x702; // 1794 -Core i7 return true; } - if (Platform.CPU.NoCores <= 2) { + if (Platform.CPU.NoCores <= 2) + { value->word = 0x901; // - Core i3 } return true; @@ -259,19 +283,23 @@ value->word = 0x501; // 1281 - Xeon return true; } - if (strstr(Platform.CPU.BrandString, "Core(TM) i3")) { + if (strstr(Platform.CPU.BrandString, "Core(TM) i3")) + { value->word = 0x902; // 2306 -Core i3 return true; } - if (strstr(Platform.CPU.BrandString, "Core(TM) i5")) { + if (strstr(Platform.CPU.BrandString, "Core(TM) i5")) + { value->word = 0x603; // 1539 - Core i5 return true; } - if (strstr(Platform.CPU.BrandString, "Core(TM) i7")) { + if (strstr(Platform.CPU.BrandString, "Core(TM) i7")) + { value->word = 0x703; // 1795 - Core i7 return true; } - if (Platform.CPU.NoCores <= 2) { + if (Platform.CPU.NoCores <= 2) + { value->word = 0x902; // - Core i5 } return true; @@ -282,19 +310,23 @@ value->word = 0xA01; // 2561 - Xeon return true; } - if (strstr(Platform.CPU.BrandString, "Core(TM) i3")) { + if (strstr(Platform.CPU.BrandString, "Core(TM) i3")) + { value->word = 0x903; // 2307 - Core i3 - Apple doesn't use it return true; } - if (strstr(Platform.CPU.BrandString, "Core(TM) i5")) { + if (strstr(Platform.CPU.BrandString, "Core(TM) i5")) + { value->word = 0x604; // 1540 - Core i5 return true; } - if (strstr(Platform.CPU.BrandString, "Core(TM) i7")) { + if (strstr(Platform.CPU.BrandString, "Core(TM) i7")) + { value->word = 0x704; // 1796 - Core i7 return true; } - if (Platform.CPU.NoCores <= 2) { + if (Platform.CPU.NoCores <= 2) + { value->word = 0x903; // - Core i5 } return true; @@ -312,19 +344,23 @@ value->word = 0xA01; // 2561 - Xeon return true; } - if (strstr(Platform.CPU.BrandString, "Core(TM) i3")) { + if (strstr(Platform.CPU.BrandString, "Core(TM) i3")) + { value->word = 0x904; // 2308 - Core i3 - Apple doesn't use it - but we yes:-) return true; } - if (strstr(Platform.CPU.BrandString, "Core(TM) i5")) { + if (strstr(Platform.CPU.BrandString, "Core(TM) i5")) + { value->word = 0x605; // 1541 - Core i5 return true; } - if (strstr(Platform.CPU.BrandString, "Core(TM) i7")) { + if (strstr(Platform.CPU.BrandString, "Core(TM) i7")) + { value->word = 0x705; // 1797 - Core i7 return true; } - if (Platform.CPU.NoCores <= 2) { + if (Platform.CPU.NoCores <= 2) + { value->word = 0x904; // - Core i3 } return true; @@ -338,7 +374,7 @@ value->word = 0x601; // 1537 - Core i5 return true; default: - break; //Unsupported CPU type + break; // Unsupported CPU type } } default: @@ -354,14 +390,17 @@ static int idx = -1; int map; - if (!bootInfo->memDetect) { + if (!bootInfo->memDetect) + { return false; } idx++; - if (idx < MAX_RAM_SLOTS) { + if (idx < MAX_RAM_SLOTS) + { map = Platform.DMI.DIMM[idx]; - if (Platform.RAM.DIMM[map].InUse && Platform.RAM.DIMM[map].Type != 0) { + if (Platform.RAM.DIMM[map].InUse && Platform.RAM.DIMM[map].Type != 0) + { DBG("RAM Detected Type = %d\n", Platform.RAM.DIMM[map].Type); value->byte = Platform.RAM.DIMM[map].Type; return true; @@ -415,9 +454,11 @@ } idx++; - if (idx < MAX_RAM_SLOTS) { + if (idx < MAX_RAM_SLOTS) + { map = Platform.DMI.DIMM[idx]; - if (Platform.RAM.DIMM[map].InUse && strlen(Platform.RAM.DIMM[map].Vendor) > 0) { + if (Platform.RAM.DIMM[map].InUse && strlen(Platform.RAM.DIMM[map].Vendor) > 0) + { DBG("RAM Detected Vendor[%d]='%s'\n", idx, Platform.RAM.DIMM[map].Vendor); value->string = Platform.RAM.DIMM[map].Vendor; return true; @@ -441,9 +482,11 @@ //DBG("getSMBMemoryDeviceSerialNumber index: %d, MAX_RAM_SLOTS: %d\n",idx,MAX_RAM_SLOTS); - if (idx < MAX_RAM_SLOTS) { + if (idx < MAX_RAM_SLOTS) + { map = Platform.DMI.DIMM[idx]; - if (Platform.RAM.DIMM[map].InUse && strlen(Platform.RAM.DIMM[map].SerialNo) > 0) { + if (Platform.RAM.DIMM[map].InUse && strlen(Platform.RAM.DIMM[map].SerialNo) > 0) + { DBG("map=%d, RAM Detected SerialNo[%d]='%s'\n", map, idx, Platform.RAM.DIMM[map].SerialNo); value->string = Platform.RAM.DIMM[map].SerialNo; return true; @@ -464,9 +507,11 @@ } idx++; - if (idx < MAX_RAM_SLOTS) { + if (idx < MAX_RAM_SLOTS) + { map = Platform.DMI.DIMM[idx]; - if (Platform.RAM.DIMM[map].InUse && strlen(Platform.RAM.DIMM[map].PartNo) > 0) { + if (Platform.RAM.DIMM[map].InUse && strlen(Platform.RAM.DIMM[map].PartNo) > 0) + { DBG("map=%d, RAM Detected PartNo[%d]='%s'\n", map, idx, Platform.RAM.DIMM[map].PartNo); value->string = Platform.RAM.DIMM[map].PartNo; return true; @@ -491,11 +536,13 @@ * for the SMBIOS entry-point structure anchor (literal ASCII "_SM_"). */ smbios = (SMBEntryPoint*)SMBIOS_RANGE_START; - while (smbios <= (SMBEntryPoint *)SMBIOS_RANGE_END) { + while (smbios <= (SMBEntryPoint *)SMBIOS_RANGE_END) + { if (COMPARE_DWORD(smbios->anchor, SMTAG) && COMPARE_DWORD(smbios->dmi.anchor, DMITAG) && smbios->dmi.anchor[4] == DMITAG[4] && - checksum8(smbios, sizeof(SMBEntryPoint)) == 0) { + checksum8(smbios, sizeof(SMBEntryPoint)) == 0) + { return smbios; } smbios = (SMBEntryPoint*)(((char*)smbios) + 16); Index: branches/ErmaC/Enoch/i386/include/mach-o/loader.h =================================================================== --- branches/ErmaC/Enoch/i386/include/mach-o/loader.h (revision 2470) +++ branches/ErmaC/Enoch/i386/include/mach-o/loader.h (revision 2471) @@ -2,14 +2,14 @@ * Copyright (c) 1999-2010 Apple Inc. All Rights Reserved. * * @APPLE_LICENSE_HEADER_START@ - * + * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this * file. - * + * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, @@ -17,7 +17,7 @@ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. - * + * * @APPLE_LICENSE_HEADER_END@ */ #ifndef _MACHO_LOADER_H_ @@ -35,7 +35,7 @@ #include /* - * is needed here for the vm_prot_t type and contains the + * is needed here for the vm_prot_t type and contains the * constants that are or'ed together for the possible values of this type. */ #include @@ -90,10 +90,10 @@ * boundary for efficient demand pageing. The MH_EXECUTE, MH_FVMLIB, MH_DYLIB, * MH_DYLINKER and MH_BUNDLE file types also have the headers included as part * of their first segment. - * + * * The file type MH_OBJECT is a compact format intended as output of the * assembler and input (and possibly output) of the link editor (the .o - * format). All sections are in one unnamed segment with no segment padding. + * format). All sections are in one unnamed segment with no segment padding. * This format is used as an executable format when the file is so small the * segment padding greatly increases its size. * @@ -159,7 +159,7 @@ all two-level namespace modules of its dependent libraries. only used when MH_PREBINDABLE and MH_TWOLEVEL - are both set. */ + are both set. */ #define MH_SUBSECTIONS_VIA_SYMBOLS 0x2000/* safe to divide up the sections into sub-sections via symbols for dead code stripping */ @@ -170,19 +170,19 @@ #define MH_BINDS_TO_WEAK 0x10000 /* the final linked image uses weak symbols */ -#define MH_ALLOW_STACK_EXECUTION 0x20000/* When this bit is set, all stacks +#define MH_ALLOW_STACK_EXECUTION 0x20000/* When this bit is set, all stacks in the task will be given stack execution privilege. Only used in MH_EXECUTE filetypes. */ -#define MH_ROOT_SAFE 0x40000 /* When this bit is set, the binary +#define MH_ROOT_SAFE 0x40000 /* When this bit is set, the binary declares it is safe for use in processes with uid zero */ - -#define MH_SETUID_SAFE 0x80000 /* When this bit is set, the binary + +#define MH_SETUID_SAFE 0x80000 /* When this bit is set, the binary declares it is safe for use in processes when issetugid() is true */ -#define MH_NO_REEXPORTED_DYLIBS 0x100000 /* When this bit is set on a dylib, +#define MH_NO_REEXPORTED_DYLIBS 0x100000 /* When this bit is set on a dylib, the static linker does not need to examine dependent dylibs to see if any are re-exported */ @@ -197,7 +197,7 @@ LC_LOAD_DYLIB load command to the dylib if no symbols are being referenced from the dylib. */ -#define MH_HAS_TLV_DESCRIPTORS 0x800000 /* Contains a section of type +#define MH_HAS_TLV_DESCRIPTORS 0x800000 /* Contains a section of type S_THREAD_LOCAL_VARIABLES */ #define MH_NO_HEAP_EXECUTION 0x1000000 /* When this bit is set, the OS will @@ -303,7 +303,7 @@ uint32_t offset; /* offset to the string */ #ifndef __LP64__ char *ptr; /* pointer to the string */ -#endif +#endif }; /* @@ -474,7 +474,7 @@ interposing */ #define S_16BYTE_LITERALS 0xe /* section with only 16 byte literals */ -#define S_DTRACE_DOF 0xf /* section contains +#define S_DTRACE_DOF 0xf /* section contains DTrace Object Format */ #define S_LAZY_DYLIB_SYMBOL_POINTERS 0x10 /* section with only lazy symbol pointers to lazy @@ -482,12 +482,12 @@ /* * Section types to support thread local variables */ -#define S_THREAD_LOCAL_REGULAR 0x11 /* template of initial +#define S_THREAD_LOCAL_REGULAR 0x11 /* template of initial values for TLVs */ -#define S_THREAD_LOCAL_ZEROFILL 0x12 /* template of initial +#define S_THREAD_LOCAL_ZEROFILL 0x12 /* template of initial values for TLVs */ #define S_THREAD_LOCAL_VARIABLES 0x13 /* TLV descriptors */ -#define S_THREAD_LOCAL_VARIABLE_POINTERS 0x14 /* pointers to TLV +#define S_THREAD_LOCAL_VARIABLE_POINTERS 0x14 /* pointers to TLV descriptors */ #define S_THREAD_LOCAL_INIT_FUNCTION_POINTERS 0x15 /* functions to call to initialize TLV @@ -520,7 +520,7 @@ * a section type S_REGULAR. The static linker will not copy section contents * from sections with this attribute into its output file. These sections * generally contain DWARF debugging info. - */ + */ #define S_ATTR_DEBUG 0x02000000 /* a debug section */ #define SECTION_ATTRIBUTES_SYS 0x00ffff00 /* system setable attributes */ #define S_ATTR_SOME_INSTRUCTIONS 0x00000400 /* section contains some @@ -681,7 +681,7 @@ * A dynamically linked shared library may be a sub_umbrella of an umbrella * framework. If so it will be linked with "-sub_umbrella umbrella_name" where * Where "umbrella_name" is the name of the sub_umbrella framework. When - * staticly linking when -twolevel_namespace is in effect a twolevel namespace + * staticly linking when -twolevel_namespace is in effect a twolevel namespace * umbrella framework will only cause its subframeworks and those frameworks * listed as sub_umbrella frameworks to be implicited linked in. Any other * dependent dynamic libraries will not be linked it when -twolevel_namespace @@ -700,7 +700,7 @@ * A dynamically linked shared library may be a sub_library of another shared * library. If so it will be linked with "-sub_library library_name" where * Where "library_name" is the name of the sub_library shared library. When - * staticly linking when -twolevel_namespace is in effect a twolevel namespace + * staticly linking when -twolevel_namespace is in effect a twolevel namespace * shared library will only cause its subframeworks and those frameworks * listed as sub_umbrella frameworks and libraries listed as sub_libraries to * be implicited linked in. Any other dependent dynamic libraries will not be @@ -780,7 +780,7 @@ }; /* - * The routines command contains the address of the dynamic shared library + * The routines command contains the address of the dynamic shared library * initialization routine and an index into the module table for the module * that defines the routine. Before any modules are used from the library the * dynamic linker fully binds the module that defines the initialization routine @@ -986,12 +986,12 @@ uint32_t locreloff; /* offset to local relocation entries */ uint32_t nlocrel; /* number of local relocation entries */ -}; +}; /* - * An indirect symbol table entry is simply a 32bit index into the symbol table + * An indirect symbol table entry is simply a 32bit index into the symbol table * to the symbol that the pointer or stub is refering to. Unless it is for a - * non-lazy symbol pointer section for a defined symbol which strip(1) as + * non-lazy symbol pointer section for a defined symbol which strip(1) as * removed. In which case it has the value INDIRECT_SYMBOL_LOCAL. If the * symbol was also absolute INDIRECT_SYMBOL_ABS is or'ed with that. */ @@ -1005,7 +1005,7 @@ (index into the symbol table) */ uint32_t module_index; /* index into the module table this symbol is defined in */ -}; +}; /* a module table entry */ struct dylib_module { @@ -1032,7 +1032,7 @@ objc_module_info_addr; /* the (__OBJC,__module_info) section */ uint32_t /* for this module size of */ objc_module_info_size; /* the (__OBJC,__module_info) section */ -}; +}; /* a 64-bit module table entry */ struct dylib_module_64 { @@ -1061,7 +1061,7 @@ objc_module_info_addr; /* the (__OBJC,__module_info) section */ }; -/* +/* * The entries in the reference symbol table are used when loading the module * (both by the static and dynamic link editors) and if the module is unloaded * or replaced. Therefore all external symbols (defined and undefined) are @@ -1102,7 +1102,7 @@ * binary search or a directed linear search. */ struct twolevel_hint { - uint32_t + uint32_t isub_image:8, /* index into the sub images */ itoc:24; /* index into the table of contents */ }; @@ -1145,7 +1145,7 @@ /* * The linkedit_data_command contains the offsets and sizes of a blob - * of data in the __LINKEDIT segment. + * of data in the __LINKEDIT segment. */ struct linkedit_data_command { uint32_t cmd; /* LC_CODE_SIGNATURE, LC_SEGMENT_SPLIT_INFO, @@ -1181,12 +1181,12 @@ }; /* - * The dyld_info_command contains the file offsets and sizes of - * the new compressed form of the information dyld needs to + * The dyld_info_command contains the file offsets and sizes of + * the new compressed form of the information dyld needs to * load the image. This information is used by dyld on Mac OS X * 10.6 and later. All information pointed to by this command * is encoded using byte streams, so no endian swapping is needed - * to interpret it. + * to interpret it. */ struct dyld_info_command { uint32_t cmd; /* LC_DYLD_INFO or LC_DYLD_INFO_ONLY */ @@ -1205,28 +1205,28 @@ */ uint32_t rebase_off; /* file offset to rebase info */ uint32_t rebase_size; /* size of rebase info */ - + /* * Dyld binds an image during the loading process, if the image - * requires any pointers to be initialized to symbols in other images. - * The bind information is a stream of byte sized + * requires any pointers to be initialized to symbols in other images. + * The bind information is a stream of byte sized * opcodes whose symbolic names start with BIND_OPCODE_. * Conceptually the bind information is a table of tuples: * * The opcodes are a compressed way to encode the table by only * encoding when a column changes. In addition simple patterns - * like for runs of pointers initialzed to the same value can be + * like for runs of pointers initialzed to the same value can be * encoded in a few bytes. */ uint32_t bind_off; /* file offset to binding info */ uint32_t bind_size; /* size of binding info */ - + /* * Some C++ programs require dyld to unique symbols so that all * images in the process use the same copy of some code/data. * This step is done after binding. The content of the weak_bind * info is an opcode stream like the bind_info. But it is sorted - * alphabetically by symbol name. This enable dyld to walk + * alphabetically by symbol name. This enable dyld to walk * all images with weak binding information in order and look * for collisions. If there are no collisions, dyld does * no updating. That means that some fixups are also encoded @@ -1238,36 +1238,37 @@ */ uint32_t weak_bind_off; /* file offset to weak binding info */ uint32_t weak_bind_size; /* size of weak binding info */ - + /* * Some uses of external symbols do not need to be bound immediately. * Instead they can be lazily bound on first use. The lazy_bind * are contains a stream of BIND opcodes to bind all lazy symbols. * Normal use is that dyld ignores the lazy_bind section when * loading an image. Instead the static linker arranged for the - * lazy pointer to initially point to a helper function which + * lazy pointer to initially point to a helper function which * pushes the offset into the lazy_bind area for the symbol * needing to be bound, then jumps to dyld which simply adds - * the offset to lazy_bind_off to get the information on what - * to bind. + * the offset to lazy_bind_off to get the information on what + * to bind. */ uint32_t lazy_bind_off; /* file offset to lazy binding info */ uint32_t lazy_bind_size; /* size of lazy binding infs */ - + /* * The symbols exported by a dylib are encoded in a trie. This * is a compact representation that factors out common prefixes. - * It also reduces LINKEDIT pages in RAM because it encodes all + * It also reduces LINKEDIT pages in RAM because it encodes all * information (name, address, flags) in one small, contiguous range. * The export area is a stream of nodes. The first node sequentially - * is the start node for the trie. + * is the start node for the trie. * * Nodes for a symbol start with a uleb128 that is the length of * the exported symbol information for the string so far. - * If there is no exported symbol, the node starts with a zero byte. - * If there is exported info, it follows the length. First is - * a uleb128 containing flags. Normally, it is followed by a - * uleb128 encoded offset which is location of the content named + * If there is no exported symbol, the node starts with a zero byte. + * If there is exported info, it follows the length. + * + * First is a uleb128 containing flags. Normally, it is followed by + * a uleb128 encoded offset which is location of the content named * by the symbol from the mach_header for the image. If the flags * is EXPORT_SYMBOL_FLAGS_REEXPORT, then following the flags is * a uleb128 encoded library ordinal, then a zero terminated @@ -1275,12 +1276,12 @@ * is re-export from the specified dylib with the same name. * * After the optional exported symbol information is a byte of - * how many edges (0-255) that this node has leaving it, + * how many edges (0-255) that this node has leaving it, * followed by each edge. * Each edge is a zero terminated UTF8 of the addition chars * in the symbol, followed by a uleb128 offset for the node that * edge points to. - * + * */ uint32_t export_off; /* file offset to lazy binding info */ uint32_t export_size; /* size of lazy binding infs */ @@ -1389,7 +1390,7 @@ }; /* - * Sections of type S_THREAD_LOCAL_VARIABLES contain an array + * Sections of type S_THREAD_LOCAL_VARIABLES contain an array * of tlv_descriptor structures. */ struct tlv_descriptor Index: branches/ErmaC/Enoch/i386/boot2/boot.h =================================================================== --- branches/ErmaC/Enoch/i386/boot2/boot.h (revision 2470) +++ branches/ErmaC/Enoch/i386/boot2/boot.h (revision 2471) @@ -337,7 +337,8 @@ size_t dst_size, const void * src, size_t src_size); -/*extern size_t lzvn_encode(void * dst, +/* +extern size_t lzvn_encode(void * dst, size_t dst_size, const void * src, size_t src_size, Index: branches/ErmaC/Enoch/i386/boot2/modules.c =================================================================== --- branches/ErmaC/Enoch/i386/boot2/modules.c (revision 2470) +++ branches/ErmaC/Enoch/i386/boot2/modules.c (revision 2471) @@ -78,8 +78,8 @@ return retVal; } -void start_built_in_module(const char* name, - const char* author, +void start_built_in_module(const char* name, + const char* author, const char* description, UInt32 version, UInt32 compat, @@ -95,7 +95,7 @@ * Module depencdies will be loaded first * Modules will only be loaded once. When loaded a module must * setup apropriete function calls and hooks as required. - * NOTE: To ensure a module loads after another you may + * NOTE: To ensure a module loads after another you may * link one module with the other. For dyld to allow this, you must * reference at least one symbol within the module. */ @@ -107,7 +107,7 @@ struct dirstuff* moduleDir = opendir("/Extra/modules/"); if(!moduleDir) { - verbose("Warning: Unable to open modules folder at '/Extra/modules/'. Ingoring modules.\n"); + verbose("Warning: Unable to open modules folder at '/Extra/modules/'. Ignoring modules.\n"); return; } while (readdir(moduleDir, (const char**)&name, &flags, &time) >= 0) { @@ -146,7 +146,7 @@ { return 1; } - + snprintf(modString, sizeof(modString), MODULE_PATH "%s", module); fh = open(modString, 0); if(fh < 0) @@ -197,17 +197,17 @@ /* * add_symbol - * This function adds a symbol from a module to the list of known symbols + * This function adds a symbol from a module to the list of known symbols * possibly change to a pointer and add this to the Symbol module so that it can * 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) { - // This only can handle 32bit symbols + // This only can handle 32bit symbols symbolList_t* entry; //DBG("Adding symbol %s at 0x%X\n", symbol, addr); - + entry = malloc(sizeof(symbolList_t)); entry->next = moduleSymbols; moduleSymbols = entry; @@ -235,7 +235,7 @@ new_entry->next = loadedModules; loadedModules = new_entry; - + if(!name) name = "Unknown"; if(!author) author = "Unknown"; if(!description) description = ""; @@ -269,7 +269,7 @@ } } - + DBG("Module %s not loaded\n", name); DBGPAUSE(); return 0; } @@ -298,7 +298,7 @@ entry = entry->next; } } - + #if CONFIG_MODULE_DEBUG printf("Unable to locate symbol %s\n", name); getchar(); @@ -307,7 +307,7 @@ if(strcmp(name, VOID_SYMBOL) == 0) return 0xFFFFFFFF; // In the event that a symbol does not exist // Return a pointer to a void function. - else return lookup_all_symbols(VOID_SYMBOL); + else return lookup_all_symbols(VOID_SYMBOL); } /********************************************************************************/ @@ -322,15 +322,15 @@ * NOTE: If the module is unable to load ot completeion, the modules * symbols will still be available. */ -void* parse_mach(void* binary, - int(*dylib_loader)(char*), +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) ) -{ +{ char is64 = false; void (*module_start)(void) = NULL; - + // Module info /*char* moduleName = NULL; UInt32 moduleVersion = 0; @@ -340,7 +340,7 @@ struct load_command *loadCommand = NULL; struct dylib_command* dylibCommand = NULL; struct dyld_info_command* dyldInfoCommand = NULL; - + struct symtab_command* symtabCommand = NULL; struct segment_command *segCommand = NULL; struct segment_command_64 *segCommand64 = NULL; @@ -348,7 +348,7 @@ //struct dysymtab_command* dysymtabCommand = NULL; UInt32 binaryIndex = 0; UInt16 cmd = 0; - + textSection = 0; textAddress = 0; // reinitialize text location in case it doesn't exist; @@ -376,21 +376,21 @@ getchar(); return NULL; // Module is in the incorrect format }*/ - + while(cmd < ((struct mach_header*)binary)->ncmds) { cmd++; - + loadCommand = binary + binaryIndex; UInt32 cmdSize = loadCommand->cmdsize; - - + + switch ((loadCommand->cmd & 0x7FFFFFFF)) { case LC_SYMTAB: symtabCommand = binary + binaryIndex; break; - + case LC_SEGMENT: // 32bit macho { segCommand = binary + binaryIndex; @@ -414,7 +414,7 @@ // __TEXT,__text found, save the offset and address for when looking for the calls. textSection = sect->offset; textAddress = sect->addr; - } + } } } break; @@ -440,12 +440,12 @@ // __TEXT,__text found, save the offset and address for when looking for the calls. textSection = sect->offset; textAddress = sect->addr; - } + } } } break; - + case LC_LOAD_DYLIB: case LC_LOAD_WEAK_DYLIB ^ LC_REQ_DYLD: // Required modules @@ -458,7 +458,7 @@ { char* name = malloc(strlen(module) + strlen(".dylib") + 1); sprintf(name, "%s.dylib", module); - + if (!dylib_loader(name)) { // NOTE: any symbols exported by dep will be replace with the void function @@ -481,20 +481,20 @@ // Bind and rebase info is stored here dyldInfoCommand = binary + binaryIndex; break; - + case LC_DYSYMTAB: case LC_UUID: break; case LC_UNIXTHREAD: break; - + default: DBG("Unhandled loadcommand 0x%X\n", loadCommand->cmd & 0x7FFFFFFF); break; - + } - + binaryIndex += cmdSize; } @@ -505,12 +505,12 @@ { // Rebase the module before binding it. if(dyldInfoCommand->rebase_off) rebase_macho(binary, (char*)dyldInfoCommand->rebase_off, dyldInfoCommand->rebase_size); - // Bind all symbols. + // Bind all symbols. if(dyldInfoCommand->bind_off) bind_macho(binary, (UInt8*)dyldInfoCommand->bind_off, dyldInfoCommand->bind_size); if(dyldInfoCommand->weak_bind_off) bind_macho(binary, (UInt8*)dyldInfoCommand->weak_bind_off, dyldInfoCommand->weak_bind_size); if(dyldInfoCommand->lazy_bind_off) bind_macho(binary, (UInt8*)dyldInfoCommand->lazy_bind_off, dyldInfoCommand->lazy_bind_size); } - + return module_start; } @@ -535,7 +535,7 @@ if(symbolEntry->n_value && symbol_handler(symbolString + symbolEntry->n_un.n_strx, textAddress ? (long long)base + symbolEntry->n_value : symbolEntry->n_value, is64) != 0xFFFFFFFF) { - + // Module start located. Start is an alias so don't register it module_start = textAddress ? base + symbolEntry->n_value : symbolEntry->n_value; } @@ -547,7 +547,7 @@ else { struct nlist_64* symbolEntry = (void*)base + symtabCommand->symoff; - // NOTE First entry is *not* correct, but we can ignore it (i'm getting radar:// right now, verify later) + // NOTE First entry is *not* correct, but we can ignore it (i'm getting radar:// right now, verify later) while(symbolIndex < symtabCommand->nsyms) { @@ -572,26 +572,26 @@ void rebase_macho(void* base, char* rebase_stream, UInt32 size) { rebase_stream += (UInt32)base; - + UInt8 immediate = 0; UInt8 opcode = 0; UInt8 type = 0; UInt32 segmentAddress = 0; - - + + UInt32 tmp = 0; UInt32 tmp2 = 0; UInt8 bits = 0; int index = 0; unsigned int i = 0; - + while(i < size) { immediate = rebase_stream[i] & REBASE_IMMEDIATE_MASK; opcode = rebase_stream[i] & REBASE_OPCODE_MASK; - - + + switch(opcode) { case REBASE_OPCODE_DONE: @@ -601,13 +601,13 @@ type = 0; segmentAddress = 0; break; - - + + case REBASE_OPCODE_SET_TYPE_IMM: type = immediate; break; - - + + case REBASE_OPCODE_SET_SEGMENT_AND_OFFSET_ULEB: // Locate address to begin rebasing @@ -624,7 +624,7 @@ } while(index <= immediate); segmentAddress = segCommand->fileoff; - + tmp = 0; bits = 0; do { @@ -632,7 +632,7 @@ bits += 7; } while(rebase_stream[i] & 0x80); - + segmentAddress += tmp; break; @@ -645,10 +645,10 @@ tmp |= rebase_stream[++i] & 0x7f; bits += 7; } while(rebase_stream[i] & 0x80); - - segmentAddress += tmp; + + segmentAddress += tmp; break; - + case REBASE_OPCODE_ADD_ADDR_IMM_SCALED: segmentAddress += immediate * sizeof(void*); break; @@ -661,7 +661,7 @@ segmentAddress += sizeof(void*); } break; - + case REBASE_OPCODE_DO_REBASE_ULEB_TIMES: tmp = 0; bits = 0; @@ -677,7 +677,7 @@ segmentAddress += sizeof(void*); } break; - + case REBASE_OPCODE_DO_REBASE_ADD_ADDR_ULEB: tmp = 0; bits = 0; @@ -685,12 +685,12 @@ tmp |= (rebase_stream[++i] & 0x7f) << bits; bits += 7; } while(rebase_stream[i] & 0x80); - + rebase_location(base + segmentAddress, (char*)base, type); - + segmentAddress += tmp + sizeof(void*); break; - + case REBASE_OPCODE_DO_REBASE_ULEB_TIMES_SKIPPING_ULEB: tmp = 0; bits = 0; @@ -698,8 +698,8 @@ tmp |= (rebase_stream[++i] & 0x7f) << bits; bits += 7; } while(rebase_stream[i] & 0x80); - - + + tmp2 = 0; bits = 0; do { @@ -709,9 +709,9 @@ index = 0; for (index = 0; index < tmp; ++index) { - + rebase_location(base + segmentAddress, (char*)base, type); - + segmentAddress += tmp2 + sizeof(void*); } break; @@ -741,41 +741,41 @@ // Based on code from dylibinfo.cpp and ImageLoaderMachOCompressed.cpp -// NOTE: this uses 32bit values, and not 64bit values. +// NOTE: this uses 32bit values, and not 64bit values. // There is a possibility that this could cause issues, // however the modules are 32 bits, so it shouldn't matter too much void bind_macho(void* base, UInt8* bind_stream, UInt32 size) -{ +{ bind_stream += (UInt32)base; - + UInt8 immediate = 0; UInt8 opcode = 0; UInt8 type = BIND_TYPE_POINTER; - + UInt32 segmentAddress = 0; - + UInt32 address = 0; - + SInt32 addend = 0; SInt32 libraryOrdinal = 0; - + const char* symbolName = NULL; UInt8 symboFlags = 0; UInt32 symbolAddr = 0xFFFFFFFF; - + // Temperary variables UInt32 tmp = 0; UInt32 tmp2 = 0; UInt32 index = 0; unsigned int i = 0; - + while(i < size) { immediate = bind_stream[i] & BIND_IMMEDIATE_MASK; opcode = bind_stream[i] & BIND_OPCODE_MASK; - - + + switch(opcode) { case BIND_OPCODE_DONE: @@ -787,19 +787,19 @@ libraryOrdinal = 0; symbolAddr = 0xFFFFFFFF; break; - + case BIND_OPCODE_SET_DYLIB_ORDINAL_IMM: libraryOrdinal = immediate; break; - + case BIND_OPCODE_SET_DYLIB_ORDINAL_ULEB: libraryOrdinal = read_uleb(bind_stream, &i); break; - + case BIND_OPCODE_SET_DYLIB_SPECIAL_IMM: - libraryOrdinal = immediate ? (SInt8)(BIND_OPCODE_MASK | immediate) : immediate; + libraryOrdinal = immediate ? (SInt8)(BIND_OPCODE_MASK | immediate) : immediate; break; - + case BIND_OPCODE_SET_SYMBOL_TRAILING_FLAGS_IMM: symboFlags = immediate; symbolName = (char*)&bind_stream[++i]; @@ -811,12 +811,12 @@ case BIND_OPCODE_SET_TYPE_IMM: type = immediate; break; - + case BIND_OPCODE_SET_ADDEND_SLEB: addend = read_uleb(bind_stream, &i); if(!(bind_stream[i-1] & 0x40)) addend *= -1; break; - + case BIND_OPCODE_SET_SEGMENT_AND_OFFSET_ULEB: segmentAddress = 0; @@ -837,11 +837,11 @@ segmentAddress += read_uleb(bind_stream, &i); break; - + case BIND_OPCODE_ADD_ADDR_ULEB: segmentAddress += read_uleb(bind_stream, &i); break; - + case BIND_OPCODE_DO_BIND: if(symbolAddr != 0xFFFFFFFF) { @@ -854,10 +854,10 @@ printf("Unable to bind symbol %s\n", symbolName); getchar(); } - + segmentAddress += sizeof(void*); break; - + case BIND_OPCODE_DO_BIND_ADD_ADDR_ULEB: // Read in offset tmp = read_uleb(bind_stream, &i); @@ -865,7 +865,7 @@ if(symbolAddr != 0xFFFFFFFF) { address = segmentAddress + (UInt32)base; - + bind_location((UInt32*)address, (char*)symbolAddr, addend, type); } else @@ -875,15 +875,15 @@ } segmentAddress += tmp + sizeof(void*); - - + + break; - + case BIND_OPCODE_DO_BIND_ADD_ADDR_IMM_SCALED: if(symbolAddr != 0xFFFFFFFF) { address = segmentAddress + (UInt32)base; - + bind_location((UInt32*)address, (char*)symbolAddr, addend, type); } else @@ -892,20 +892,20 @@ getchar(); } segmentAddress += (immediate * sizeof(void*)) + sizeof(void*); - + break; - + case BIND_OPCODE_DO_BIND_ULEB_TIMES_SKIPPING_ULEB: tmp = read_uleb(bind_stream, &i); - - tmp2 = read_uleb(bind_stream, &i); + tmp2 = read_uleb(bind_stream, &i); + if(symbolAddr != 0xFFFFFFFF) { for(index = 0; index < tmp; index++) { - + address = segmentAddress + (UInt32)base; bind_location((UInt32*)address, (char*)symbolAddr, addend, type); segmentAddress += tmp2 + sizeof(void*); @@ -926,14 +926,14 @@ } static inline void rebase_location(UInt32* location, char* base, int type) -{ +{ switch(type) { case REBASE_TYPE_POINTER: case REBASE_TYPE_TEXT_ABSOLUTE32: *location += (UInt32)base; break; - + default: break; } @@ -941,18 +941,18 @@ static inline void bind_location(UInt32* location, char* value, UInt32 addend, int type) -{ +{ // do actual update char* newValue = value + addend; - + switch (type) { case BIND_TYPE_POINTER: case BIND_TYPE_TEXT_ABSOLUTE32: break; - + case BIND_TYPE_TEXT_PCREL32: newValue -= ((UInt32)location + 4); - + break; default: return; @@ -981,7 +981,7 @@ *binary++ = 0xFF; // Jump *binary++ = 0x25; // Long Jump *((UInt32*)binary) = (UInt32)jumpPointer; - + *jumpPointer = (UInt32)newAddress; return 1; } @@ -1035,9 +1035,9 @@ void register_hook_callback(const char* name, void(*callback)(void*, void*, void*, void*)) { DBG("Adding callback for '%s' hook.\n", name); DBGPAUSE(); - + moduleHook_t* hook = hook_exists(name); - + if(hook) { // append @@ -1092,7 +1092,7 @@ void print_hook_list() { printf("---Hook Table---\n"); - + moduleHook_t* hooks = moduleCallbacks; while(hooks) { @@ -1122,7 +1122,7 @@ void load_all_modules() { - + } int execute_hook(const char* name, void* arg1, void* arg2, void* arg3, void* arg4) @@ -1143,8 +1143,8 @@ return 0; } -void start_built_in_module(const char* name, - const char* author, +void start_built_in_module(const char* name, + const char* author, const char* description, UInt32 version, UInt32 compat, Index: branches/ErmaC/Enoch/i386/boot2/options.c =================================================================== --- branches/ErmaC/Enoch/i386/boot2/options.c (revision 2470) +++ branches/ErmaC/Enoch/i386/boot2/options.c (revision 2471) @@ -611,8 +611,7 @@ //========================================================================== -static void -printMemoryInfo(void) +static void printMemoryInfo(void) { int line; int i;