Index: trunk/i386/libsaio/console.c =================================================================== --- trunk/i386/libsaio/console.c (revision 2411) +++ trunk/i386/libsaio/console.c (revision 2412) @@ -247,24 +247,24 @@ vprf(fmt, ap); } + // Kabyl: BooterLog + struct putc_info pi; + + if (!msgbuf) { - // Kabyl: BooterLog - struct putc_info pi; + return 0; + } - if (!msgbuf) { - return 0; - } + if (((cursor - msgbuf) > (BOOTER_LOG_SIZE - SAFE_LOG_SIZE))) + { + return 0; + } - if (((cursor - msgbuf) > (BOOTER_LOG_SIZE - SAFE_LOG_SIZE))) { - return 0; - } + pi.str = cursor; + pi.last_str = 0; + prf(fmt, ap, sputc, &pi); + cursor += strlen((char *)cursor); - pi.str = cursor; - pi.last_str = 0; - prf(fmt, ap, sputc, &pi); - cursor += strlen((char *)cursor); - } - va_end(ap); return(0); } Index: trunk/i386/libsaio/bootstruct.c =================================================================== --- trunk/i386/libsaio/bootstruct.c (revision 2411) +++ trunk/i386/libsaio/bootstruct.c (revision 2412) @@ -44,10 +44,10 @@ * the kernel by the booter. */ -boot_args *bootArgs; +boot_args *bootArgs; boot_args_pre_lion *bootArgsPreLion; PrivateBootInfo_t *bootInfo; -Node *gMemoryMapNode; +Node *gMemoryMapNode; static char platformName[64]; @@ -56,7 +56,7 @@ Node *node; int nameLen; static int init_done = 0; - + if ( !init_done ) { bootArgs = (boot_args *)malloc(sizeof(boot_args)); @@ -64,11 +64,11 @@ bootInfo = (PrivateBootInfo_t *)malloc(sizeof(PrivateBootInfo_t)); if (bootArgs == 0 || bootArgsPreLion == 0 || bootInfo == 0) stop("Couldn't allocate boot info\n"); - + bzero(bootArgs, sizeof(boot_args)); bzero(bootArgsPreLion, sizeof(boot_args_pre_lion)); bzero(bootInfo, sizeof(PrivateBootInfo_t)); - + // Get system memory map. Also update the size of the // conventional/extended memory for backwards compatibility. @@ -76,22 +76,22 @@ getMemoryMap( bootInfo->memoryMap, kMemoryMapCountMax, (unsigned long *) &bootInfo->convmem, (unsigned long *) &bootInfo->extmem ); - + if ( bootInfo->memoryMapCount == 0 ) { // BIOS did not provide a memory map, systems with // discontiguous memory or unusual memory hole locations // may have problems. - - bootInfo->convmem = getConventionalMemorySize(); - bootInfo->extmem = getExtendedMemorySize(); + + bootInfo->convmem = getConventionalMemorySize(); + bootInfo->extmem = getExtendedMemorySize(); } - - bootInfo->configEnd = bootInfo->config; - bootArgs->Video.v_display = VGA_TEXT_MODE; - + + bootInfo->configEnd = bootInfo->config; + bootArgs->Video.v_display = VGA_TEXT_MODE; + DT__Initialize(); - + node = DT__FindNode("/", true); if (node == 0) { stop("Couldn't create root node"); @@ -100,20 +100,19 @@ nameLen = strlen(platformName) + 1; DT__AddProperty(node, "compatible", nameLen, platformName); DT__AddProperty(node, "model", nameLen, platformName); - + gMemoryMapNode = DT__FindNode("/chosen/memory-map", true); - + bootArgs->Version = kBootArgsVersion; bootArgs->Revision = kBootArgsRevision; - + bootArgsPreLion->Version = kBootArgsPreLionVersion; bootArgsPreLion->Revision = kBootArgsPreLionRevision; - + init_done = 1; } } - /* Copy boot args after kernel and record address. */ void @@ -132,8 +131,9 @@ } } -void -finalizeBootStruct(void) +//============================================================================== + +void finalizeBootStruct(void) { uint32_t size; void *addr; @@ -141,65 +141,76 @@ EfiMemoryRange *memoryMap; MemoryRange *range; int memoryMapCount = bootInfo->memoryMapCount; - - if (memoryMapCount == 0) { + + if (memoryMapCount == 0) + { // XXX could make a two-part map here stop("Unable to convert memory map into proper format\n"); } - + // convert memory map to boot_args memory map memoryMap = (EfiMemoryRange *)AllocateKernelMemory(sizeof(EfiMemoryRange) * memoryMapCount); - bootArgs->MemoryMap = (uint32_t)memoryMap; - bootArgs->MemoryMapSize = sizeof(EfiMemoryRange) * memoryMapCount; - bootArgs->MemoryMapDescriptorSize = sizeof(EfiMemoryRange); - bootArgs->MemoryMapDescriptorVersion = 0; - + + bootArgs->MemoryMap = (uint32_t)memoryMap; + bootArgs->MemoryMapSize = sizeof(EfiMemoryRange) * memoryMapCount; + bootArgs->MemoryMapDescriptorSize = sizeof(EfiMemoryRange); + bootArgs->MemoryMapDescriptorVersion = 0; + for (i = 0; i < memoryMapCount; i++, memoryMap++) { range = &bootInfo->memoryMap[i]; - switch(range->type) { + + switch(range->type) + { case kMemoryRangeACPI: memoryMap->Type = kEfiACPIReclaimMemory; break; + case kMemoryRangeNVS: memoryMap->Type = kEfiACPIMemoryNVS; break; + case kMemoryRangeUsable: memoryMap->Type = kEfiConventionalMemory; break; + case kMemoryRangeReserved: + default: memoryMap->Type = kEfiReservedMemoryType; break; } - memoryMap->PhysicalStart = range->base; - memoryMap->VirtualStart = range->base; - memoryMap->NumberOfPages = range->length >> I386_PGSHIFT; - memoryMap->Attribute = 0; + + memoryMap->PhysicalStart = range->base; + memoryMap->VirtualStart = range->base; + memoryMap->NumberOfPages = range->length >> I386_PGSHIFT; + memoryMap->Attribute = 0; } - + // copy bootFile into device tree // XXX - + // add PCI info somehow into device tree // XXX - + // Flatten device tree DT__FlattenDeviceTree(0, &size); addr = (void *)AllocateKernelMemory(size); - if (addr == 0) { + + if (addr == 0) + { stop("Couldn't allocate device tree\n"); } - + DT__FlattenDeviceTree((void **)&addr, &size); bootArgs->deviceTreeP = (uint32_t)addr; bootArgs->deviceTreeLength = size; // Copy BootArgs values to older structure - + memcpy(&bootArgsPreLion->CommandLine, &bootArgs->CommandLine, BOOT_LINE_LENGTH); memcpy(&bootArgsPreLion->Video, &bootArgs->Video, sizeof(Boot_Video)); - + bootArgsPreLion->MemoryMap = bootArgs->MemoryMap; bootArgsPreLion->MemoryMapSize = bootArgs->MemoryMapSize; bootArgsPreLion->MemoryMapDescriptorSize = bootArgs->MemoryMapDescriptorSize; @@ -207,16 +218,16 @@ bootArgsPreLion->deviceTreeP = bootArgs->deviceTreeP; bootArgsPreLion->deviceTreeLength = bootArgs->deviceTreeLength; - + bootArgsPreLion->kaddr = bootArgs->kaddr; bootArgsPreLion->ksize = bootArgs->ksize; - + bootArgsPreLion->efiRuntimeServicesPageStart = bootArgs->efiRuntimeServicesPageStart; bootArgsPreLion->efiRuntimeServicesPageCount = bootArgs->efiRuntimeServicesPageCount; bootArgsPreLion->efiSystemTable = bootArgs->efiSystemTable; - + bootArgsPreLion->efiMode = bootArgs->efiMode; - + bootArgsPreLion->performanceDataStart = bootArgs->performanceDataStart; bootArgsPreLion->performanceDataSize = bootArgs->performanceDataSize; bootArgsPreLion->efiRuntimeServicesVirtualPageStart = bootArgs->efiRuntimeServicesVirtualPageStart; Index: trunk/i386/libsaio/bootstruct.h =================================================================== --- trunk/i386/libsaio/bootstruct.h (revision 2411) +++ trunk/i386/libsaio/bootstruct.h (revision 2412) @@ -47,7 +47,7 @@ /* * Maximum number of boot drivers that can be loaded. */ -#define NDRIVERS 500 +#define NDRIVERS 500 #define CONFIG_SIZE (40 * 4096) @@ -74,10 +74,12 @@ unsigned char BIOSPresent; } PCI_bus_info_t; -typedef struct { - unsigned long address; // address where driver was loaded - unsigned long size; // number of bytes - unsigned long type; // driver type + +typedef struct +{ + unsigned long address; // address where driver was loaded + unsigned long size; // number of bytes + unsigned long type; // driver type } driver_config_t; /* @@ -90,11 +92,12 @@ /* * ACPI defined memory range types. */ -enum { - kMemoryRangeUsable = 1, // RAM usable by the OS. - kMemoryRangeReserved = 2, // Reserved. (Do not use) - kMemoryRangeACPI = 3, // ACPI tables. Can be reclaimed. - kMemoryRangeNVS = 4, // ACPI NVS memory. (Do not use) +enum +{ + kMemoryRangeUsable = 1, // RAM usable by the OS. + kMemoryRangeReserved = 2, // Reserved. (Do not use) + kMemoryRangeACPI = 3, // ACPI tables. Can be reclaimed. + kMemoryRangeNVS = 4, // ACPI NVS memory. (Do not use) /* Undefined types should be treated as kMemoryRangeReserved */ }; Index: trunk/i386/libsaio/device_tree.c =================================================================== --- trunk/i386/libsaio/device_tree.c (revision 2411) +++ trunk/i386/libsaio/device_tree.c (revision 2412) @@ -403,7 +403,7 @@ DT__GetProperty(Node *node, const char *name) { Property *prop; - + for (prop = node->properties; prop; prop = prop->next) { if (strcmp(prop->name, name) == 0) @@ -411,7 +411,7 @@ return prop; } } - + return NULL; } Index: trunk/i386/libsaio/acpi_patcher.c =================================================================== --- trunk/i386/libsaio/acpi_patcher.c (revision 2411) +++ trunk/i386/libsaio/acpi_patcher.c (revision 2412) @@ -1035,6 +1035,7 @@ } DBG("TABLE %c%c%c%c@%x \n", table[0],table[1],table[2],table[3],xsdt_entries[i]); + continue; } if (tableSign(table, "FACP")) { @@ -1113,6 +1114,7 @@ DBG("\n"); // Correct the checksum of RSDP + DBG("RSDP: Original checksum %d, ", rsdp_mod->Checksum); rsdp_mod->Checksum=0; rsdp_mod->Checksum=256-checksum8(rsdp_mod,20); Index: trunk/i386/libsaio/bootargs.h =================================================================== --- trunk/i386/libsaio/bootargs.h (revision 2411) +++ trunk/i386/libsaio/bootargs.h (revision 2412) @@ -109,8 +109,8 @@ /* Snapshot constants of previous revisions that are supported */ -#define kBootArgsEfiMode32 32 -#define kBootArgsEfiMode64 64 +#define kBootArgsEfiMode32 32 +#define kBootArgsEfiMode64 64 typedef struct boot_args { uint16_t Revision; /* Revision of boot_args structure */ Index: trunk/i386/libsaio/device_inject.c =================================================================== --- trunk/i386/libsaio/device_inject.c (revision 2411) +++ trunk/i386/libsaio/device_inject.c (revision 2412) @@ -23,11 +23,11 @@ #define DBG(x...) msglog(x) #endif -uint32_t devices_number = 1; -uint32_t builtin_set = 0; -DevPropString *string = 0; -uint8_t *stringdata = 0; -uint32_t stringlength = 0; +uint32_t devices_number = 1; +uint32_t builtin_set = 0; +DevPropString *string = 0; +uint8_t *stringdata = 0; +uint32_t stringlength = 0; char *efi_inject_get_devprop_string(uint32_t *len) { Index: trunk/i386/libsaio/load.c =================================================================== --- trunk/i386/libsaio/load.c (revision 2411) +++ trunk/i386/libsaio/load.c (revision 2412) @@ -18,12 +18,11 @@ * under the License. * * @APPLE_LICENSE_HEADER_END@ - */ -/* - * load.c - Functions for decoding a Mach-o Kernel. * - * Copyright (c) 1998-2003 Apple Computer, Inc. + * load.c - Functions for decoding a Mach-o Kernel. * + * Copyright (c) 1998-2003 Apple Computer, Inc. + * */ #include @@ -59,19 +58,23 @@ cpu_type_t fapcputype; uint32_t fapoffset; uint32_t fapsize; - - if (fhp->magic == FAT_MAGIC)/* 0xcafebabe */{ + + if (fhp->magic == FAT_MAGIC)/* 0xcafebabe */ + { nfat = fhp->nfat_arch; swapped = 0; - } else if (fhp->magic == FAT_CIGAM)/* 0xbebafeca */{ + } else if (fhp->magic == FAT_CIGAM)/* 0xbebafeca */ + { nfat = OSSwapInt32(fhp->nfat_arch); swapped = 1; } else { return -1; } - for (; nfat > 0; nfat--, fap++) { - if (swapped) { + for (; nfat > 0; nfat--, fap++) + { + if (swapped) + { fapcputype = OSSwapInt32(fap->cputype); fapoffset = OSSwapInt32(fap->offset); fapsize = OSSwapInt32(fap->size); @@ -81,14 +84,16 @@ fapsize = fap->size; } - if (fapcputype == archCpuType) { + if (fapcputype == archCpuType) + { *binary = (void *) ((unsigned long)*binary + fapoffset); size = fapsize; break; } } - if (length != 0) { + if (length != 0) + { *length = size; } @@ -113,7 +118,7 @@ mH = (struct mach_header *)(gBinaryAddress); - /*#if DEBUG +/*#if DEBUG DBG("magic: 0x%x\n", (unsigned)mH->magic); DBG("cputype: 0x%x\n", (unsigned)mH->cputype); DBG("cpusubtype: 0x%x\n", (unsigned)mH->cpusubtype); @@ -121,15 +126,16 @@ DBG("ncmds: 0x%x\n", (unsigned)mH->ncmds); DBG("sizeofcmds: 0x%x\n", (unsigned)mH->sizeofcmds); DBG("flags: 0x%x\n", (unsigned)mH->flags); - DBG("archCpuType: 0x%x\n", archCpuType); + DBG("archCpuType: 0x%x\n", archCpuType); //getchar(); - #endif*/ - +#endif*/ + switch (archCpuType) { case CPU_TYPE_I386: - if (mH->magic != MH_MAGIC) { + if (mH->magic != MH_MAGIC) + { error("Mach-O file has bad magic number\n"); return -1; } @@ -139,11 +145,13 @@ case CPU_TYPE_X86_64: /* - if (mH->magic != MH_MAGIC_64 && mH->magic == MH_MAGIC) { + if (mH->magic != MH_MAGIC_64 && mH->magic == MH_MAGIC) + { return -1; } */ - if (mH->magic != MH_MAGIC_64) { + if (mH->magic != MH_MAGIC_64) + { error("Mach-O file has bad magic number\n"); return -1; } @@ -167,7 +175,8 @@ unsigned int load_addr; unsigned int load_size; - switch (cmd) { + switch (cmd) + { case LC_SEGMENT_64: case LC_SEGMENT: ret = DecodeSegment(cmdBase, &load_addr, &load_size); @@ -194,7 +203,8 @@ } - if (ret != 0) { + if (ret != 0) + { return -1; } @@ -207,19 +217,22 @@ cmdBase = cmdstart; - for (cnt = 0; cnt < ncmds; cnt++) { + for (cnt = 0; cnt < ncmds; cnt++) + { cmd = ((long *)cmdBase)[0]; cmdsize = ((long *)cmdBase)[1]; - - if (cmd == LC_SYMTAB) { - if (DecodeSymbolTable(cmdBase) != 0) { + + if (cmd == LC_SYMTAB) + { + if (DecodeSymbolTable(cmdBase) != 0) + { return -1; } } cmdBase += cmdsize; } - + return ret; } @@ -234,7 +247,8 @@ long vmsize, filesize; unsigned long vmaddr, fileaddr; - if (((long *)cmdBase)[0] == LC_SEGMENT_64) { + if (((long *)cmdBase)[0] == LC_SEGMENT_64) + { struct segment_command_64 *segCmd; segCmd = (struct segment_command_64 *)cmdBase; vmaddr = (segCmd->vmaddr & 0x3fffffff); @@ -267,20 +281,21 @@ #endif } - if (vmsize == 0 || filesize == 0) { + if (vmsize == 0 || filesize == 0) + { *load_addr = ~0; *load_size = 0; return 0; } - if (! ((vmaddr >= KERNEL_ADDR && (vmaddr + vmsize) <= (KERNEL_ADDR + KERNEL_LEN)) || - (vmaddr >= HIB_ADDR && (vmaddr + vmsize) <= (HIB_ADDR + HIB_LEN)))) { - stop("Kernel overflows available space"); - } + if (! ((vmaddr >= KERNEL_ADDR && (vmaddr + vmsize) <= (KERNEL_ADDR + KERNEL_LEN)) || + (vmaddr >= HIB_ADDR && (vmaddr + vmsize) <= (HIB_ADDR + HIB_LEN)))) { + stop("Kernel overflows available space"); + } - if (vmsize && ((strcmp(segname, "__PRELINK_INFO") == 0) || (strcmp(segname, "__PRELINK") == 0))) { - gHaveKernelCache = true; - } + if (vmsize && ((strcmp(segname, "__PRELINK_INFO") == 0) || (strcmp(segname, "__PRELINK") == 0))) { + gHaveKernelCache = true; + } // Copy from file load area. if (vmsize>0 && filesize > 0) { Index: trunk/i386/libsaio/cpu.c =================================================================== --- trunk/i386/libsaio/cpu.c (revision 2411) +++ trunk/i386/libsaio/cpu.c (revision 2412) @@ -106,7 +106,7 @@ 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. @@ -176,7 +176,7 @@ unsigned long pollCount; uint64_t retval = 0; int i; - + /* Time how many APERF 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. @@ -210,7 +210,7 @@ /* mperfDelta is now the least number of MPERF ticks the processor made in * a timespan of 0.03 s (e.g. 30 milliseconds) */ - + if (aperfDelta > (1ULL<<32)) { retval = 0; } else { @@ -244,9 +244,11 @@ /* get cpuid values */ do_cpuid(0x00000000, p->CPU.CPUID[CPUID_0]); do_cpuid(0x00000001, p->CPU.CPUID[CPUID_1]); + do_cpuid(0x00000002, p->CPU.CPUID[CPUID_2]); do_cpuid(0x00000003, p->CPU.CPUID[CPUID_3]); 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) { do_cpuid(5, p->CPU.CPUID[CPUID_5]); @@ -321,13 +323,13 @@ p->CPU.NoCores = bitfield(p->CPU.CPUID[CPUID_4][0], 31, 26) + 1; } - /* get brand string (if supported) */ + /* get BrandString (if supported) */ /* Copyright: from Apple's XNU cpuid.c */ if (p->CPU.CPUID[CPUID_80][0] > 0x80000004) { uint32_t reg[4]; char str[128], *s; /* - * The brand string 48 bytes (max), guaranteed to + * The BrandString 48 bytes (max), guaranteed to * be NULL terminated. */ do_cpuid(0x80000002, reg); @@ -352,7 +354,7 @@ p->CPU.BrandString[0] = '\0'; } } - + /* setup features */ if ((bit(23) & p->CPU.CPUID[CPUID_1][3]) != 0) { p->CPU.Features |= CPU_FEATURE_MMX; Index: trunk/i386/libsaio/disk.c =================================================================== --- trunk/i386/libsaio/disk.c (revision 2411) +++ trunk/i386/libsaio/disk.c (revision 2412) @@ -681,19 +681,19 @@ // GUID's in LE form: // HFS+ partition - 48465300-0000-11AA-AA11-00306543ECAC -EFI_GUID const GPT_HFS_GUID = { 0x48465300, 0x0000, 0x11AA, { 0xAA, 0x11, 0x00, 0x30, 0x65, 0x43, 0xEC, 0xAC } }; +EFI_GUID const GPT_HFS_GUID = { 0x48465300, 0x0000, 0x11AA, { 0xAA, 0x11, 0x00, 0x30, 0x65, 0x43, 0xEC, 0xAC } }; // 0xAF00 "Apple HFS/HFS+" // turbo - Apple Boot Partition - 426F6F74-0000-11AA-AA11-00306543ECAC -EFI_GUID const GPT_BOOT_GUID = { 0x426F6F74, 0x0000, 0x11AA, { 0xAA, 0x11, 0x00, 0x30, 0x65, 0x43, 0xEC, 0xAC } }; +EFI_GUID const GPT_BOOT_GUID = { 0x426F6F74, 0x0000, 0x11AA, { 0xAA, 0x11, 0x00, 0x30, 0x65, 0x43, 0xEC, 0xAC } }; // 0xAB00 "Apple boot" // turbo - or an EFI System Partition - C12A7328-F81F-11D2-BA4B-00A0C93EC93B -EFI_GUID const GPT_EFISYS_GUID = { 0xC12A7328, 0xF81F, 0x11D2, { 0xBA, 0x4B, 0x00, 0xA0, 0xC9, 0x3E, 0xC9, 0x3B } }; +EFI_GUID const GPT_EFISYS_GUID = { 0xC12A7328, 0xF81F, 0x11D2, { 0xBA, 0x4B, 0x00, 0xA0, 0xC9, 0x3E, 0xC9, 0x3B } }; // 0xEF00 "EFI System" // zef - Basic Data Partition - EBD0A0A2-B9E5-4433-87C0-68B6B72699C7 for foreign OS support -EFI_GUID const GPT_BASICDATA_GUID = { 0xEBD0A0A2, 0xB9E5, 0x4433, { 0x87, 0xC0, 0x68, 0xB6, 0xB7, 0x26, 0x99, 0xC7 } }; +EFI_GUID const GPT_BASICDATA_GUID = { 0xEBD0A0A2, 0xB9E5, 0x4433, { 0x87, 0xC0, 0x68, 0xB6, 0xB7, 0x26, 0x99, 0xC7 } }; // 0x0100 "Microsoft basic data" // Microsoft Reserved Partition - E3C9E316-0B5C-4DB8-817DF92DF00215AE -EFI_GUID const GPT_BASICDATA2_GUID = { 0xE3C9E316, 0x0B5C, 0x4DB8, { 0x81, 0x7D, 0xF9, 0x2D, 0xF0, 0x02, 0x15, 0xAE } }; +EFI_GUID const GPT_BASICDATA2_GUID = { 0xE3C9E316, 0x0B5C, 0x4DB8, { 0x81, 0x7D, 0xF9, 0x2D, 0xF0, 0x02, 0x15, 0xAE } }; // 0x0C01 "Microsoft reserved" BVRef newGPTBVRef( int biosdev, int partno, unsigned int blkoff, Index: trunk/i386/libsaio/smbios.c =================================================================== --- trunk/i386/libsaio/smbios.c (revision 2411) +++ trunk/i386/libsaio/smbios.c (revision 2412) @@ -267,7 +267,7 @@ kSMBBaseBoardSerialNumberKey, NULL, &defaultBaseBoard.serialNumber }, // SMboardserial - C02140302D5DMT31M {kSMBTypeBaseBoard, kSMBString, getFieldOffset(SMBBaseBoard, assetTag), - kSMBBaseBoardAssetTagKey, NULL, &defaultBaseBoard.assetTag }, // SMboardassetag - Base Board Asset Tag# + kSMBBaseBoardAssetTagKey, NULL, &defaultBaseBoard.assetTag }, // SMboardassettag - Base Board Asset Tag# {kSMBTypeBaseBoard, kSMBString, getFieldOffset(SMBBaseBoard, locationInChassis), kSMBBaseBoardLocationInChassisKey, NULL, &defaultBaseBoard.locationInChassis }, // SMboardlocation - Part Component Index: trunk/i386/libsaio/smbios_decode.c =================================================================== --- trunk/i386/libsaio/smbios_decode.c (revision 2411) +++ trunk/i386/libsaio/smbios_decode.c (revision 2412) @@ -401,6 +401,10 @@ } //------------------------------------------------------------------------------------------------------------------------- +// Memory Controller Information (Type 5) +//------------------------------------------------------------------------------------------------------------------------- + +//------------------------------------------------------------------------------------------------------------------------- // Memory Module Information (Type 6) //------------------------------------------------------------------------------------------------------------------------- //void decodeMemoryModule(SMBStructHeader *structHeader) @@ -417,6 +421,22 @@ //} //------------------------------------------------------------------------------------------------------------------------- +// Cache Information (Type 7) +//------------------------------------------------------------------------------------------------------------------------- + +//------------------------------------------------------------------------------------------------------------------------- +// Port Connector Information (Type 8) +//------------------------------------------------------------------------------------------------------------------------- + +//------------------------------------------------------------------------------------------------------------------------- +// System Slot Information (Type 9) +//------------------------------------------------------------------------------------------------------------------------- + +//------------------------------------------------------------------------------------------------------------------------- +// On Board Device Information (Type 10) +//------------------------------------------------------------------------------------------------------------------------- + +//------------------------------------------------------------------------------------------------------------------------- // OEM Strings (Type 11) //------------------------------------------------------------------------------------------------------------------------- void decodeSMBOEMStrings(SMBStructHeader *structHeader) @@ -431,8 +451,19 @@ } DBG("\n"); } +//------------------------------------------------------------------------------------------------------------------------- +// System Configuration Options (Type 12) +//------------------------------------------------------------------------------------------------------------------------- //------------------------------------------------------------------------------------------------------------------------- +// BIOS Language Information (Type 13) +//------------------------------------------------------------------------------------------------------------------------- + +//------------------------------------------------------------------------------------------------------------------------- +// Physical Memory Array (Type 16) +//------------------------------------------------------------------------------------------------------------------------- + +//------------------------------------------------------------------------------------------------------------------------- // MemoryDevice (Type 17) //------------------------------------------------------------------------------------------------------------------------- void decodeMemoryDevice(SMBStructHeader *structHeader) Index: trunk/i386/libsaio/saio_types.h =================================================================== --- trunk/i386/libsaio/saio_types.h (revision 2411) +++ trunk/i386/libsaio/saio_types.h (revision 2412) @@ -41,13 +41,16 @@ typedef unsigned long entry_t; -typedef struct { +typedef struct +{ unsigned int sectors:8; unsigned int heads:8; unsigned int cylinders:16; } compact_diskinfo_t; -struct driveParameters { + +struct driveParameters +{ int cylinders; int sectors; int heads; @@ -77,8 +80,10 @@ /* * BIOS drive information. */ -struct boot_drive_info { - struct drive_params { +struct boot_drive_info +{ + struct drive_params + { unsigned short buf_size; unsigned short info_flags; unsigned long phys_cyls; @@ -100,7 +105,8 @@ unsigned char checksum; } params; - struct drive_dpte { + struct drive_dpte + { unsigned short io_port_base; unsigned short control_port_base; unsigned char head_flags; @@ -120,7 +126,9 @@ } __attribute__((packed)); typedef struct boot_drive_info boot_drive_info_t; -struct driveInfo { + +struct driveInfo +{ boot_drive_info_t di; int uses_ebios; @@ -129,7 +137,9 @@ int valid; }; -typedef struct FinderInfo { + +typedef struct FinderInfo +{ unsigned char data[16]; } FinderInfo; @@ -205,7 +215,8 @@ }; -enum { +enum +{ kBVFlagPrimary = 0x01, kBVFlagNativeBoot = 0x02, kBVFlagForeignBoot = 0x04, @@ -216,7 +227,8 @@ kBVFlagInstallVolume = 0x80 }; -enum { +enum +{ kBIOSDevTypeFloppy = 0x00, kBIOSDevTypeHardDrive = 0x80, kBIOSDevTypeNetwork = 0xE0, @@ -225,7 +237,8 @@ kBIOSDevMask = 0xFF }; -enum { +enum +{ //KPartitionTypeFAT12 = 0x01, // FAT12 kPartitionTypeHPFS = 0x07, // Mac OS X kPartitionTypeFAT16 = 0x06, // FAT16 @@ -248,7 +261,8 @@ // KernBootStruct device types. -enum { +enum +{ DEV_SD = 0, DEV_HD = 1, DEV_FD = 2, @@ -277,7 +291,8 @@ kBlockDeviceType = kBIOSDevTypeHardDrive }; //gBootFileType_t; -enum { +enum +{ kCursorTypeHidden = 0x0100, kCursorTypeUnderline = 0x0607 }; Index: trunk/i386/libsaio/md5c.c =================================================================== --- trunk/i386/libsaio/md5c.c (revision 2411) +++ trunk/i386/libsaio/md5c.c (revision 2412) @@ -50,8 +50,6 @@ * These notices must be retained in any copies of any part of this * documentation and/or software. * - * $Id: md5c.c,v 1.1 2005/06/24 22:47:12 curtisg Exp $ - * * This code is the same as the code published by RSA Inc. It has been * edited for clarity and style only. */ @@ -151,7 +149,8 @@ index = (unsigned int)((context->count[0] >> 3) & 0x3F); /* Update number of bits */ - if ((context->count[0] += ((u_int32_t)inputLen << 3)) < ((u_int32_t)inputLen << 3)) { + if ((context->count[0] += ((u_int32_t)inputLen << 3)) < ((u_int32_t)inputLen << 3)) + { context->count[1]++; } @@ -161,7 +160,8 @@ /* Transform as many times as possible. */ - if (inputLen >= partLen) { + if (inputLen >= partLen) + { memcpy((void *)&context->buffer[index], (const void *)input, partLen); MD5Transform (context->state, context->buffer); Index: trunk/i386/libsaio/fake_efi.c =================================================================== --- trunk/i386/libsaio/fake_efi.c (revision 2411) +++ trunk/i386/libsaio/fake_efi.c (revision 2412) @@ -93,6 +93,8 @@ EFI_SYSTEM_TABLE_64 *gST64 = NULL; Node *gEfiConfigurationTableNode = NULL; +// ========================================================================== + extern EFI_STATUS addConfigurationTable(EFI_GUID const *pGuid, void *table, char const *alias) { EFI_UINTN i = 0; @@ -146,6 +148,8 @@ return EFI_UNSUPPORTED; } +// ========================================================================== + //Azi: crc32 done in place, on the cases were it wasn't. /*static inline void fixupEfiSystemTableCRC32(EFI_SYSTEM_TABLE_64 *efiSystemTable) { Index: trunk/i386/libsaio/saio_internal.h =================================================================== --- trunk/i386/libsaio/saio_internal.h (revision 2411) +++ trunk/i386/libsaio/saio_internal.h (revision 2412) @@ -28,11 +28,11 @@ #include "saio_types.h" /* asm.s */ -extern void real_to_prot(void); -extern void prot_to_real(void); -extern void halt(void); -extern void startprog(unsigned int address, void *arg); -extern void loader(UInt32 code, UInt32 cmdptr); +extern void real_to_prot(void); +extern void prot_to_real(void); +extern void halt(void); +extern void startprog(unsigned int address, void *arg); +extern void loader(UInt32 code, UInt32 cmdptr); /* bios.s */ extern void bios(biosBuf_t *bb); @@ -79,11 +79,11 @@ extern void finalizeBootStruct(void); /* cache.c */ -extern void CacheReset(); -extern void CacheInit(CICell ih, long blockSize); -extern long CacheRead(CICell ih, char *buffer, long long offset, - long length, long cache); +extern void CacheReset(); +extern void CacheInit(CICell ih, long blockSize); +extern long CacheRead(CICell ih, char *buffer, long long offset, long length, long cache); + /* console.c */ extern bool gVerboseMode; extern bool gErrors; Index: trunk/i386/boot0/boot0.s =================================================================== --- trunk/i386/boot0/boot0.s (revision 2411) +++ trunk/i386/boot0/boot0.s (revision 2412) @@ -322,7 +322,7 @@ ; signature check. jmp .tryToBoot -.Pass2: +.Pass2: cmp BYTE [si + part.type], kPartTypeHFS ; In pass 2 we're going to find a HFS+ partition ; equipped with boot1h in its boot record ; regardless if it's active or not. @@ -740,7 +740,7 @@ popad ret - + print_nibble: and al, 0x0f add al, '0' Index: trunk/i386/boot1/boot1h.s =================================================================== --- trunk/i386/boot1/boot1h.s (revision 2411) +++ trunk/i386/boot1/boot1h.s (revision 2412) @@ -1,7 +1,7 @@ ; Copyright (c) 1999-2003 Apple Computer, Inc. All rights reserved. ; ; @APPLE_LICENSE_HEADER_START@ -; +; ; Portions Copyright (c) 1999-2003 Apple Computer, Inc. All Rights ; Reserved. This file contains Original Code and/or Modifications of ; Original Code as defined in and that are subject to the Apple Public @@ -9,7 +9,7 @@ ; except in compliance with the License. Please obtain a copy of the ; License at http://www.apple.com/publicsource and read it before using ; this file. -; +; ; The Original Code and all software distributed under the License are ; distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER ; EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, @@ -17,7 +17,7 @@ ; FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the ; License for the specific language governing rights and limitations ; under the License. -; +; ; @APPLE_LICENSE_HEADER_END@ ; ; Partition Boot Loader: boot1h @@ -335,7 +335,7 @@ mov si, %1 call print_string %endmacro - + %macro LogString 1 mov di, %1 call log_string @@ -352,7 +352,7 @@ %define PutChar(x) %define PrintHex(x) %endif - + ;-------------------------------------------------------------------------- ; Start of text segment. @@ -388,7 +388,7 @@ mov cx, kSectorBytes ; copy 256 words rep movsb ; repeat string move (word) operation pop si - + ; ; Code relocated, jump to startReloc in relocated location. ; @@ -406,7 +406,7 @@ ; Initializing global variables. ; mov eax, [si + part.lba] - mov [gPartLBA], eax ; save the current partition LBA offset + mov [gPartLBA], eax ; save the current partition LBA offset mov [gBIOSDriveNumber], dl ; save BIOS drive number mov WORD [gMallocPtr], mallocStart ; set free space pointer @@ -500,7 +500,7 @@ %if VERBOSE LogString(error_str) %endif - + hang: hlt jmp hang @@ -1058,11 +1058,11 @@ mov bx, [bp + BTree.nodeBuffer + BTNodeDescriptor.numRecords] xchg bh, bl dec bx - + .bsearch: cmp ax, bx ja .checkResult ; jump if lowerBound > upperBound - + mov cx, ax add cx, bx shr cx, 1 ; test index = (lowerBound + upperBound / 2) @@ -1088,7 +1088,7 @@ je .checkResult jl .searchLessThanTrial jg .searchGreaterThanTrial - jmp .bsearch + jmp .bsearch .searchLessThanTrial: mov bx, cx @@ -1099,7 +1099,7 @@ mov ax, cx inc ax ; lowerBound = index + 1 jmp .bsearch - + .checkResult: cmp BYTE [bp + BTree.searchResult], 0 jge .foundKey @@ -1115,7 +1115,7 @@ mov bx, [bx] mov edx, [bx] jmp .readNode - + .exit: cmp BYTE [bp + BTree.searchResult], 0 ret @@ -1183,7 +1183,7 @@ .exit: pop di ; restore address of trialKey -%if UNUSED +%if UNUSED ; ; Print catalog trial key ; @@ -1199,15 +1199,15 @@ .printLoop: lodsw call print_char - loop .printLoop + loop .printLoop .printExit: popad ; ; ; %endif ; UNUSED - -%if UNUSED + +%if UNUSED ; ; Print extent trial key ; @@ -1230,7 +1230,7 @@ pop si ; restore SI call bx ; call key compare proc popad - ret + ret ;-------------------------------------------------------------------------- ; readExtent - read extents from a HFS+ file (multiple extent support) @@ -1300,7 +1300,7 @@ pop ebx jmp .beginExtentBlock - + .continue: mov edx, [di + HFSPlusExtentDescriptor.blockCount] call blockToSector ; ECX = converted current extent's blockCount to sectors @@ -1328,20 +1328,20 @@ mov edx, [di + HFSPlusExtentDescriptor.startBlock] call blockToSector ; ECX = converted to sectors add ecx, eax ; file offset converted to sectors - + push si mov ax, si mov edx, [bp + BTree.readBufferPtr] call readSectors pop si - + add ebx, esi mov ax, si cwde shl ax, 9 ; convert SI (read sector count) to byte unit add [bp + BTree.readBufferPtr], eax sub [bp + BTree.readSize], esi - + jz .exit .nextExtent: Index: trunk/i386/boot1/boot1hp.s =================================================================== --- trunk/i386/boot1/boot1hp.s (revision 2411) +++ trunk/i386/boot1/boot1hp.s (revision 2412) @@ -269,7 +269,7 @@ mov al, 1 ; read HFS+ Volume Header mov edx, kHFSPlusBuffer call readLBA - jc NEAR bios_read_error + jc NEAR bios_read_error ; ; Looking for HFSPlus ('H+') or HFSPlus case-sensitive ('HX') signature. Index: trunk/i386/boot2/picopng.c =================================================================== --- trunk/i386/boot2/picopng.c (revision 2411) +++ trunk/i386/boot2/picopng.c (revision 2412) @@ -23,7 +23,8 @@ /*************************************************************************************************/ -typedef struct png_alloc_node { +typedef struct png_alloc_node +{ struct png_alloc_node *prev, *next; void *addr; size_t size; @@ -32,32 +33,55 @@ png_alloc_node_t *png_alloc_head = NULL; png_alloc_node_t *png_alloc_tail = NULL; +//============================================================================== + png_alloc_node_t *png_alloc_find_node(void *addr) { png_alloc_node_t *node; + for (node = png_alloc_head; node; node = node->next) + { if (node->addr == addr) + { break; + } + } + return node; } + +//============================================================================== + void png_alloc_add_node(void *addr, size_t size) { png_alloc_node_t *node; + if (png_alloc_find_node(addr)) + { return; - node = malloc(sizeof (png_alloc_node_t)); + } + + node = malloc(sizeof(png_alloc_node_t)); node->addr = addr; node->size = size; node->prev = png_alloc_tail; node->next = NULL; png_alloc_tail = node; + if (node->prev) + { node->prev->next = node; + } + if (!png_alloc_head) + { png_alloc_head = node; + } } +//============================================================================== + void png_alloc_remove_node(png_alloc_node_t *node) { if (!node) { Index: trunk/i386/boot2/graphics.c =================================================================== --- trunk/i386/boot2/graphics.c (revision 2411) +++ trunk/i386/boot2/graphics.c (revision 2412) @@ -20,11 +20,10 @@ * under the License. * * @APPLE_LICENSE_HEADER_END@ + * + * Copyright 1993 NeXT, Inc. All rights reserved. + * */ -/* - * Copyright 1993 NeXT, Inc. - * All rights reserved. - */ #include "boot.h" #include "vbe.h" @@ -50,18 +49,18 @@ { VBEInfoBlock vbeInfo; int err, small; - + bzero( &vbeInfo, sizeof(vbeInfo) ); strcpy( (char*)&vbeInfo, "VBE2" ); err = getVBEInfo( &vbeInfo ); if (err != errSuccess) return 0; - + if ( strncmp( (char *)vbeInfo.VESASignature, "VESA", 4 ) ) return 0; - + small = (vbeInfo.TotalMemory < 16); - + return vbeInfo.TotalMemory * 64 * 1024; } @@ -79,23 +78,24 @@ err = getVBEInfo( &vbeInfo ); if (err != errSuccess) return 0; - + if ( strncmp( (char *)vbeInfo.VESASignature, "VESA", 4 ) ) return 0; - + buff = malloc(sizeof(char) * 256); if (!buff) { return 0; } + small = (vbeInfo.TotalMemory < 16); - + snprintf(buff, 256, - "VESA v%d.%d %d%s (%s)\n", - vbeInfo.VESAVersion >> 8, - vbeInfo.VESAVersion & 0xf, - small ? (vbeInfo.TotalMemory * 64) : (vbeInfo.TotalMemory / 16), - small ? "KB" : "MB", - VBEDecodeFP(const char *, vbeInfo.OEMStringPtr) ); + "VESA v%d.%d %d%s (%s)\n", + vbeInfo.VESAVersion >> 8, + vbeInfo.VESAVersion & 0xf, + small ? (vbeInfo.TotalMemory * 64) : (vbeInfo.TotalMemory / 16), + small ? "KB" : "MB", + VBEDecodeFP(const char *, vbeInfo.OEMStringPtr) ); return buff; } @@ -163,13 +163,15 @@ clearScreenRows(0, 24); setCursorPosition( 0, 0, 1 ); } - } + } if (line != 0) { pause(); } setActiveDisplayPage(0); } +//============================================================================== + char *getVBEModeInfoString() { VBEInfoBlock vbeInfo; @@ -184,7 +186,8 @@ return 0; } char *buff=malloc(sizeof(char)*3072); - if(!buff) { + if(!buff) + { return 0; } @@ -208,7 +211,7 @@ *modePtr, modeInfo.XResolution, modeInfo.YResolution, modeInfo.BitsPerPixel, modeInfo.MemoryModel, modeInfo.ModeAttributes); - } + } return buff; } @@ -219,141 +222,146 @@ // If a mode is not found, then return the "best" available mode. static unsigned short -getVESAModeWithProperties( unsigned short width, - unsigned short height, - unsigned char bitsPerPixel, - unsigned short attributesSet, - unsigned short attributesClear, - VBEModeInfoBlock * outModeInfo, - unsigned short * vesaVersion ) +getVESAModeWithProperties( unsigned short width, + unsigned short height, + unsigned char bitsPerPixel, + unsigned short attributesSet, + unsigned short attributesClear, + VBEModeInfoBlock *outModeInfo, + unsigned short *vesaVersion + ) { - VBEInfoBlock vbeInfo; - unsigned short * modePtr; - VBEModeInfoBlock modeInfo; - unsigned char modeBitsPerPixel; - unsigned short matchedMode = modeEndOfList; - int err; + VBEInfoBlock vbeInfo; + unsigned short * modePtr; + VBEModeInfoBlock modeInfo; + unsigned char modeBitsPerPixel; + unsigned short matchedMode = modeEndOfList; + int err; - // Clear output mode info. + // Clear output mode info. - bzero( outModeInfo, sizeof(*outModeInfo) ); + bzero( outModeInfo, sizeof(*outModeInfo) ); - // Get VBE controller info containing the list of supported modes. + // Get VBE controller info containing the list of supported modes. - bzero( &vbeInfo, sizeof(vbeInfo) ); - strcpy( (char*)&vbeInfo, "VBE2" ); - err = getVBEInfo( &vbeInfo ); - if ( err != errSuccess ) - { - return modeEndOfList; - } + bzero( &vbeInfo, sizeof(vbeInfo) ); + strcpy( (char*)&vbeInfo, "VBE2" ); + err = getVBEInfo( &vbeInfo ); + if ( err != errSuccess ) + { + return modeEndOfList; + } - // Report the VESA major/minor version number. + // Report the VESA major/minor version number. - if (vesaVersion) *vesaVersion = vbeInfo.VESAVersion; + if (vesaVersion) + { + *vesaVersion = vbeInfo.VESAVersion; + } - // Loop through the mode list, and find the matching mode. + // Loop through the mode list, and find the matching mode. - for ( modePtr = VBEDecodeFP( unsigned short *, vbeInfo.VideoModePtr ); - *modePtr != modeEndOfList; modePtr++ ) - { - // Get mode information. + for ( modePtr = VBEDecodeFP( unsigned short *, vbeInfo.VideoModePtr ); + *modePtr != modeEndOfList; modePtr++ ) + { + // Get mode information. - bzero( &modeInfo, sizeof(modeInfo) ); - err = getVBEModeInfo( *modePtr, &modeInfo ); - if ( err != errSuccess ) - { - continue; - } + bzero( &modeInfo, sizeof(modeInfo) ); + err = getVBEModeInfo( *modePtr, &modeInfo ); + if ( err != errSuccess ) + { + continue; + } #if DEBUG - printf("Mode %x: %dx%dx%d mm:%d attr:%x\n", + printf("Mode %x: %dx%dx%d mm:%d attr:%x\n", *modePtr, modeInfo.XResolution, modeInfo.YResolution, modeInfo.BitsPerPixel, modeInfo.MemoryModel, modeInfo.ModeAttributes); #endif - // Filter out unwanted modes based on mode attributes. + // Filter out unwanted modes based on mode attributes. - if ( ( ( modeInfo.ModeAttributes & attributesSet ) != attributesSet ) + if ( ( ( modeInfo.ModeAttributes & attributesSet ) != attributesSet ) || ( ( modeInfo.ModeAttributes & attributesClear ) != 0 ) ) - { - continue; - } + { + continue; + } - // Pixel depth in bits. + // Pixel depth in bits. - modeBitsPerPixel = modeInfo.BitsPerPixel; + modeBitsPerPixel = modeInfo.BitsPerPixel; - if ( ( modeBitsPerPixel == 4 ) && ( modeInfo.MemoryModel == 0 ) ) - { - // Text mode, 16 colors. - } - else if ( ( modeBitsPerPixel == 8 ) && ( modeInfo.MemoryModel == 4 ) ) - { - // Packed pixel, 256 colors. - } - else if ( ( ( modeBitsPerPixel == 16 ) || ( modeBitsPerPixel == 15 ) ) - && ( modeInfo.MemoryModel == 6 ) - && ( modeInfo.RedMaskSize == 5 ) - && ( modeInfo.GreenMaskSize == 5 ) - && ( modeInfo.BlueMaskSize == 5 ) ) - { - // Direct color, 16 bpp (1:5:5:5). - modeInfo.BitsPerPixel = modeBitsPerPixel = 16; - } - else if ( ( modeBitsPerPixel == 32 ) - && ( modeInfo.MemoryModel == 6 ) - && ( modeInfo.RedMaskSize == 8 ) - && ( modeInfo.GreenMaskSize == 8 ) - && ( modeInfo.BlueMaskSize == 8 ) ) - { - // Direct color, 32 bpp (8:8:8:8). - } - else - { - continue; // Not a supported mode. - } + if ( ( modeBitsPerPixel == 4 ) && ( modeInfo.MemoryModel == 0 ) ) + { + // Text mode, 16 colors. + } + else if ( ( modeBitsPerPixel == 8 ) && ( modeInfo.MemoryModel == 4 ) ) + { + // Packed pixel, 256 colors. + } + else if ( ( ( modeBitsPerPixel == 16 ) || ( modeBitsPerPixel == 15 ) ) + && ( modeInfo.MemoryModel == 6 ) + && ( modeInfo.RedMaskSize == 5 ) + && ( modeInfo.GreenMaskSize == 5 ) + && ( modeInfo.BlueMaskSize == 5 ) ) + { + // Direct color, 16 bpp (1:5:5:5). + modeInfo.BitsPerPixel = modeBitsPerPixel = 16; + } + else if ( ( modeBitsPerPixel == 32 ) + && ( modeInfo.MemoryModel == 6 ) + && ( modeInfo.RedMaskSize == 8 ) + && ( modeInfo.GreenMaskSize == 8 ) + && ( modeInfo.BlueMaskSize == 8 ) ) + { + // Direct color, 32 bpp (8:8:8:8). + } + else + { + continue; // Not a supported mode. + } - // Modes larger than the specified dimensions are skipped. + // Modes larger than the specified dimensions are skipped. - if ( ( modeInfo.XResolution > width ) || - ( modeInfo.YResolution > height ) ) - { - continue; - } + if ( ( modeInfo.XResolution > width ) || + ( modeInfo.YResolution > height ) ) + { + continue; + } - // Perfect match, we're done looking. + // Perfect match, we're done looking. - if ( ( modeInfo.XResolution == width ) && - ( modeInfo.YResolution == height ) && - ( modeBitsPerPixel == bitsPerPixel ) ) - { - matchedMode = *modePtr; - bcopy( &modeInfo, outModeInfo, sizeof(modeInfo) ); - break; - } + if ( ( modeInfo.XResolution == width ) && + ( modeInfo.YResolution == height ) && + ( modeBitsPerPixel == bitsPerPixel ) ) + { + matchedMode = *modePtr; + bcopy( &modeInfo, outModeInfo, sizeof(modeInfo) ); + break; + } - // Save the next "best" mode in case a perfect match is not found. + // Save the next "best" mode in case a perfect match is not found. - if ( modeInfo.XResolution == outModeInfo->XResolution && - modeInfo.YResolution == outModeInfo->YResolution && - modeBitsPerPixel <= outModeInfo->BitsPerPixel ) - { - continue; // Saved mode has more depth. - } - if ( modeInfo.XResolution < outModeInfo->XResolution || - modeInfo.YResolution < outModeInfo->YResolution || - modeBitsPerPixel < outModeInfo->BitsPerPixel ) - { - continue; // Saved mode has more resolution. - } + if ( modeInfo.XResolution == outModeInfo->XResolution && + modeInfo.YResolution == outModeInfo->YResolution && + modeBitsPerPixel <= outModeInfo->BitsPerPixel ) + { + continue; // Saved mode has more depth. + } - matchedMode = *modePtr; - bcopy( &modeInfo, outModeInfo, sizeof(modeInfo) ); - } + if ( modeInfo.XResolution < outModeInfo->XResolution || + modeInfo.YResolution < outModeInfo->YResolution || + modeBitsPerPixel < outModeInfo->BitsPerPixel ) + { + continue; // Saved mode has more resolution. + } - return matchedMode; + matchedMode = *modePtr; + bcopy( &modeInfo, outModeInfo, sizeof(modeInfo) ); + } + + return matchedMode; } //========================================================================== @@ -506,11 +514,9 @@ return err; } -int -convertImage( unsigned short width, - unsigned short height, - const unsigned char *imageData, - unsigned char **newImageData ) +//============================================================================== + +int convertImage( unsigned short width, unsigned short height, const unsigned char *imageData, unsigned char **newImageData ) { int cnt; unsigned char *img = 0; @@ -525,7 +531,7 @@ img16[cnt] = lookUpCLUTIndex(imageData[cnt], 16); img = (unsigned char *)img16; break; - + case 32 : img32 = malloc(width * height * 4); if ( !img32 ) break; @@ -533,7 +539,7 @@ img32[cnt] = lookUpCLUTIndex(imageData[cnt], 32); img = (unsigned char *)img32; break; - + default : img = malloc(width * height); bcopy(imageData, img, width * height); @@ -543,6 +549,8 @@ return 0; } +//============================================================================== + int loadPngImage(const char *filename, uint16_t *width, uint16_t *height, uint8_t **imageData) { @@ -595,6 +603,8 @@ return error; } +//============================================================================== + int loadEmbeddedPngImage(uint8_t *pngData, int pngSize, uint16_t *width, uint16_t *height, uint8_t **imageData) { PNG_info_t *info; int error = 0; @@ -623,6 +633,8 @@ return error; } +//============================================================================== + void blendImage(uint16_t x, uint16_t y, uint16_t width, uint16_t height, uint8_t *data) { @@ -640,7 +652,7 @@ uint32_t a; // Alpha uint32_t dstrb, dstg, srcrb, srcg, drb, dg, rb, g, tempB; // Intermediate variables uint16_t pos; - + for (pos = 0; pos < drawWidth * 4; pos += 4) { // Fast pseudo-vector alpha blending, adapted from: http://www.stereopsis.com/doubleblend.html s = *((uint32_t*) (data + pos)); @@ -669,7 +681,7 @@ } } break; - + default: /*Universal version*/ { uint32_t s; @@ -677,7 +689,7 @@ uint32_t dr, dg, db, sr, sg, sb; // Intermediate variables uint16_t pos; int bpp = (VIDEO (depth) + 7)/8; - + for (pos = 0; pos < drawWidth; pos ++) { // Fast pseudo-vector alpha blending, adapted from: http://www.stereopsis.com/doubleblend.html s = *((uint32_t*) (data + 4*pos)); @@ -687,7 +699,7 @@ sr = (s & 0xFF); a = (s >> 24) + 1; - + switch (VIDEO (depth)) { case 24: @@ -704,7 +716,7 @@ db = ((*(uint16_t *)(vram + bpp*pos))&0x1f)<<3; dg = ((*(uint16_t *)(vram + bpp*pos))&0x03e0)>>2; dr = ((*(uint16_t *)(vram + bpp*pos))&0x7c00)>>7; - break; + break; default: return; } @@ -725,8 +737,8 @@ *(uint16_t *)(vram + bpp*pos) = ((db&0xf8)>>3) | ((dg&0xf8)<<2) | ((dr&0xf8)<<7); break; } - - } + + } } break; } @@ -735,6 +747,8 @@ } } +//============================================================================== + void drawCheckerBoard() { uint32_t *vram = (uint32_t *) VIDEO(baseAddr); @@ -752,8 +766,7 @@ //========================================================================== // LookUpCLUTIndex -unsigned long lookUpCLUTIndex( unsigned char index, - unsigned char depth ) +unsigned long lookUpCLUTIndex( unsigned char index, unsigned char depth ) { long result, red, green, blue; @@ -787,14 +800,16 @@ void * stosl(void * dst, long val, long len) { - asm volatile ( "rep; stosl" - : "=c" (len), "=D" (dst) - : "0" (len), "1" (dst), "a" (val) - : "memory" ); + asm volatile ( "rep; stosl" + : "=c" (len), "=D" (dst) + : "0" (len), "1" (dst), "a" (val) + : "memory" ); - return dst; + return dst; } +//============================================================================== + void drawColorRectangle( unsigned short x, unsigned short y, unsigned short width, @@ -844,8 +859,9 @@ } } -void -loadImageScale (void *input, int iw, int ih, int ip, void *output, int ow, int oh, int op, int or) +//============================================================================== + +void loadImageScale (void *input, int iw, int ih, int ip, void *output, int ow, int oh, int op, int or) { int x,y, off; int red=0x7f, green=0x7f, blue=0x7f; @@ -862,7 +878,7 @@ red=(val>>7)&0xf8; green=(val>>2)&0xf8; blue=(val<<3)&0xf8; - break; + break; } case 32: { @@ -872,7 +888,7 @@ green=(val>>8)&0xff; blue=(val)&0xff; break; - } + } } char *ptr=(char *)output+x*(op/8)+y*or; switch (op) @@ -889,6 +905,8 @@ } } +//============================================================================== + DECLARE_IOHIBERNATEPROGRESSALPHA void drawPreview(void *src, uint8_t * saveunder) @@ -902,7 +920,7 @@ void *uncomp; int origwidth, origheight, origbpx; uint32_t saveindex[kIOHibernateProgressCount] = { 0 }; - + if (src && (uncomp=DecompressData(src, &origwidth, &origheight, &origbpx))) { if (!setVESAGraphicsMode(origwidth, origheight, origbpx, 0)) @@ -921,15 +939,15 @@ // Set the screen to 75% grey. drawColorRectangle(0, 0, VIDEO(width), VIDEO(height), 0x01 /* color index */); } - - + + pixelShift = VIDEO (depth) >> 4; if (pixelShift < 1) return; - + screen += ((VIDEO (width) - kIOHibernateProgressCount * (kIOHibernateProgressWidth + kIOHibernateProgressSpacing)) << (pixelShift - 1)) + (VIDEO (height) - kIOHibernateProgressOriginY - kIOHibernateProgressHeight) * rowBytes; - + for (y = 0; y < kIOHibernateProgressHeight; y++) { out = screen + y * rowBytes; @@ -969,6 +987,8 @@ } } +//============================================================================== + void updateProgressBar(uint8_t * saveunder, int32_t firstBlob, int32_t select) { uint8_t * screen; @@ -978,20 +998,20 @@ uint32_t alpha, in, color, result; uint8_t * out; uint32_t saveindex[kIOHibernateProgressCount] = { 0 }; - + pixelShift = VIDEO(depth) >> 4; if (pixelShift < 1) return; screen = (uint8_t *) VIDEO (baseAddr); rowBytes = VIDEO (rowBytes); - + screen += ((VIDEO (width) - kIOHibernateProgressCount * (kIOHibernateProgressWidth + kIOHibernateProgressSpacing)) << (pixelShift - 1)) + (VIDEO (height) - kIOHibernateProgressOriginY - kIOHibernateProgressHeight) * rowBytes; - + lastBlob = (select < kIOHibernateProgressCount) ? select : (kIOHibernateProgressCount - 1); - + screen += (firstBlob * (kIOHibernateProgressWidth + kIOHibernateProgressSpacing)) << pixelShift; - + for (y = 0; y < kIOHibernateProgressHeight; y++) { out = screen + y * rowBytes; @@ -1028,10 +1048,7 @@ //========================================================================== // setVESATextMode -static int -setVESATextMode( unsigned short cols, - unsigned short rows, - unsigned char bitsPerPixel ) +static int setVESATextMode( unsigned short cols, unsigned short rows, unsigned char bitsPerPixel ) { VBEModeInfoBlock minfo; unsigned short mode = modeEndOfList; @@ -1068,8 +1085,7 @@ //========================================================================== // getNumberArrayFromProperty -static int -getNumberArrayFromProperty( const char * propKey, +static int getNumberArrayFromProperty( const char * propKey, unsigned long numbers[], unsigned long maxArrayCount ) { @@ -1100,11 +1116,13 @@ return count; } +//============================================================================== + int initGraphicsMode () { unsigned long params[4]; int count; - + params[3] = 0; count = getNumberArrayFromProperty( kGraphicsModeKey, params, 4 ); @@ -1122,13 +1140,13 @@ params[1] = gui.screen.height; params[2] = 32; } - + // Map from pixel format to bits per pixel. - + if ( params[2] == 256 ) params[2] = 8; if ( params[2] == 555 ) params[2] = 16; if ( params[2] == 888 ) params[2] = 32; - + return setVESAGraphicsMode( params[0], params[1], params[2], params[3] ); } @@ -1137,8 +1155,7 @@ // // Set the video mode to VGA_TEXT_MODE or GRAPHICS_MODE. -void -setVideoMode( int mode, int drawgraphics) +void setVideoMode( int mode, int drawgraphics) { unsigned long params[4]; int count; @@ -1165,13 +1182,14 @@ params[1] = 25; } - setVESATextMode( params[0], params[1], 4 ); + setVESATextMode( params[0], params[1], 4 ); bootArgs->Video.v_display = VGA_TEXT_MODE; } currentIndicator = 0; } +//============================================================================== void getGraphicModeParams(unsigned long params[]) { params[3] = 0; @@ -1180,7 +1198,7 @@ unsigned short vesaVersion; unsigned short mode = modeEndOfList; - + getNumberArrayFromProperty( kGraphicsModeKey, params, 4); mode = getVESAModeWithProperties( params[0], params[1], params[2], @@ -1190,7 +1208,7 @@ maLinearFrameBufferAvailBit, 0, &minfo, &vesaVersion ); - + params[0] = minfo.XResolution; params[1] = minfo.YResolution; params[2] = 32; @@ -1213,11 +1231,12 @@ // ensure a minimum of 1/9 sec between animation frames. #define MIN_TICKS 2 -void -spinActivityIndicator(int sectors) +//============================================================================== + +void spinActivityIndicator(int sectors) { static unsigned long lastTickTime = 0, currentTickTime; - + if (previewTotalSectors && previewSaveunder) { int blob, lastBlob; @@ -1227,10 +1246,12 @@ blob = (previewLoadedSectors * kIOHibernateProgressCount) / previewTotalSectors; if (blob!=lastBlob) + { updateProgressBar (previewSaveunder, lastBlob, blob); + } return; } - + currentTickTime = time18(); // late binding if (currentTickTime < lastTickTime + MIN_TICKS) { @@ -1240,7 +1261,7 @@ { lastTickTime = currentTickTime; } - + if (getVideoMode() == VGA_TEXT_MODE) { if (currentIndicator >= sizeof(indicator)) @@ -1252,13 +1273,15 @@ } } -void -clearActivityIndicator( void ) +//============================================================================== + +void clearActivityIndicator( void ) { - if ( getVideoMode() == VGA_TEXT_MODE ) - { + if ( getVideoMode() == VGA_TEXT_MODE ) + { putchar(' '); putchar('\b'); - } + } } +//============================================================================== Index: trunk/i386/boot2/graphics.h =================================================================== --- trunk/i386/boot2/graphics.h (revision 2411) +++ trunk/i386/boot2/graphics.h (revision 2412) @@ -1,7 +1,7 @@ /* * graphics.h - * * + * * Created by fassl on 22.12.08. * Copyright 2008 __MyCompanyName__. All rights reserved. * @@ -26,15 +26,12 @@ void drawDataRectangle( unsigned short x, unsigned short y, unsigned short width, unsigned short height, unsigned char * data ); int convertImage( unsigned short width, unsigned short height, const unsigned char *imageData, unsigned char **newImageData ); -int initGraphicsMode (); +int initGraphicsMode(); void drawCheckerBoard(); void blendImage(uint16_t x, uint16_t y, uint16_t width, uint16_t height, uint8_t *data); -void drawCheckerBoard(); -void blendImage(uint16_t x, uint16_t y, uint16_t width, uint16_t height, uint8_t *data); - int loadEmbeddedPngImage(uint8_t *pngData, int pngSize, uint16_t *width, uint16_t *height, uint8_t **imageData); uint32_t getVBEVideoRam(); Index: trunk/i386/boot2/drivers.c =================================================================== --- trunk/i386/boot2/drivers.c (revision 2411) +++ trunk/i386/boot2/drivers.c (revision 2412) @@ -846,8 +846,7 @@ char *gDarwinBuildVerStr = "Darwin Kernel Version"; // Bungo -long -DecodeKernel(void *binary, entry_t *rentry, char **raddr, int *rsize) +long DecodeKernel(void *binary, entry_t *rentry, char **raddr, int *rsize) { long ret = 0; compressed_kernel_header * kernel_header = (compressed_kernel_header *) binary; Index: trunk/i386/boot2/modules.c =================================================================== --- trunk/i386/boot2/modules.c (revision 2411) +++ trunk/i386/boot2/modules.c (revision 2412) @@ -105,13 +105,11 @@ long flags; long time; struct dirstuff* moduleDir = opendir("/Extra/modules/"); - if(!moduleDir) { verbose("Warning: Unable to open modules folder at '/Extra/modules/'. Ingoring modules.\n"); return; } - while (readdir(moduleDir, (const char**)&name, &flags, &time) >= 0) { if(strcmp(&name[strlen(name) - sizeof("dylib")], ".dylib") == 0) { char* tmp = malloc(strlen(name) + 1); Index: trunk/i386/boot2/modules_support.s =================================================================== --- trunk/i386/boot2/modules_support.s (revision 2411) +++ trunk/i386/boot2/modules_support.s (revision 2412) @@ -3,8 +3,8 @@ LABEL(dyld_stub_binder) jmp _dyld_stub_binder - + LABEL(dyld_void_start) ret -#endif \ No newline at end of file +#endif Index: trunk/i386/boot2/appleClut8.h =================================================================== --- trunk/i386/boot2/appleClut8.h (revision 2411) +++ trunk/i386/boot2/appleClut8.h (revision 2412) @@ -2,7 +2,7 @@ * Copyright (c) 1999-2003 Apple Computer, Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ - * + * * Portions Copyright (c) 1999-2003 Apple Computer, Inc. All Rights * Reserved. This file contains Original Code and/or Modifications of * Original Code as defined in and that are subject to the Apple Public @@ -10,7 +10,7 @@ * except in compliance with the License. Please obtain a copy of the * License at http://www.apple.com/publicsource and read it before using * this file. - * + * * The Original Code and all software distributed under the License are * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, @@ -18,7 +18,7 @@ * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the * License for the specific language governing rights and limitations * under the License. - * + * * @APPLE_LICENSE_HEADER_END@ */ @@ -31,62 +31,77 @@ 0xbc,0xbc,0xbc, 0xff,0xff,0x00, 0xba,0xba,0xba, 0xb9,0xb9,0xb9, 0xb8,0xb8,0xb8, 0xb7,0xb7,0xb7, 0xb6,0xb6,0xb6, 0xb5,0xb5,0xb5, 0xb4,0xb4,0xb4, 0xb3,0xb3,0xb3, 0xb2,0xb2,0xb2, 0x00,0x00,0x00, + 0xb1,0xb1,0xb1, 0xb0,0xb0,0xb0, 0xaf,0xaf,0xaf, 0xae,0xae,0xae, 0xad,0xad,0xad, 0xac,0xac,0xac, 0xab,0xab,0xab, 0xaa,0xaa,0xaa, 0xff,0x00,0xff, 0xa9,0xa9,0xa9, 0xa8,0xa8,0xa8, 0xa7,0xa7,0xa7, 0xa6,0xa6,0xa6, 0xa5,0xa5,0xa5, 0xa4,0xa4,0xa4, 0xa3,0xa3,0xa3, + 0xa2,0xa2,0xa2, 0xa1,0xa1,0xa1, 0xa0,0xa0,0xa0, 0xff,0x00,0x00, 0x9f,0x9f,0x9f, 0x9e,0x9e,0x9e, 0x9d,0x9d,0x9d, 0x9c,0x9c,0x9c, 0x9b,0x9b,0x9b, 0x9a,0x9a,0x9a, 0xcc,0xcc,0xff, 0xcc,0xcc,0xcc, 0x99,0x99,0x99, 0x98,0x98,0x98, 0x97,0x97,0x97, 0x96,0x96,0x96, + 0x95,0x95,0x95, 0x94,0x94,0x94, 0x93,0x93,0x93, 0x92,0x92,0x92, 0x91,0x91,0x91, 0x90,0x90,0x90, 0x8f,0x8f,0x8f, 0x8e,0x8e,0x8e, 0x8d,0x8d,0x8d, 0x8c,0x8c,0x8c, 0x8b,0x8b,0x8b, 0x8a,0x8a,0x8a, - 0x89,0x89,0x89, 0x87,0x87,0x87, 0x86,0x86,0x86, 0x85,0x85,0x85, + 0x89,0x89,0x89, 0x88,0x88,0x88, 0x86,0x86,0x86, 0x85,0x85,0x85, + 0x84,0x84,0x84, 0x83,0x83,0x83, 0x82,0x82,0x82, 0x81,0x81,0x81, 0x80,0x80,0x80, 0x7f,0x7f,0x7f, 0x7e,0x7e,0x7e, 0x7d,0x7d,0x7d, 0x7c,0x7c,0x7c, 0x7b,0x7b,0x7b, 0x7a,0x7a,0x7a, 0x79,0x79,0x79, 0x78,0x78,0x78, 0x76,0x76,0x76, 0x75,0x75,0x75, 0x74,0x74,0x74, + 0x73,0x73,0x73, 0x72,0x72,0x72, 0x71,0x71,0x71, 0x70,0x70,0x70, 0x6f,0x6f,0x6f, 0x6e,0x6e,0x6e, 0x6d,0x6d,0x6d, 0x6c,0x6c,0x6c, 0x6b,0x6b,0x6b, 0x6a,0x6a,0x6a, 0x69,0x69,0x69, 0x68,0x68,0x68, 0x67,0x67,0x67, 0x66,0x66,0x66, 0x64,0x64,0x64, 0x63,0x63,0x63, + 0x62,0x62,0x62, 0x61,0x61,0x61, 0x60,0x60,0x60, 0x5f,0x5f,0x5f, 0x5e,0x5e,0x5e, 0x5d,0x5d,0x5d, 0x5c,0x5c,0x5c, 0x5b,0x5b,0x5b, 0x5a,0x5a,0x5a, 0x59,0x59,0x59, 0x58,0x58,0x58, 0x57,0x57,0x57, 0x56,0x56,0x56, 0x54,0x54,0x54, 0x53,0x53,0x53, 0x52,0x52,0x52, + 0x51,0x51,0x51, 0x50,0x50,0x50, 0x4f,0x4f,0x4f, 0x4e,0x4e,0x4e, 0x4d,0x4d,0x4d, 0x4c,0x4c,0x4c, 0x4b,0x4b,0x4b, 0x4a,0x4a,0x4a, 0x49,0x49,0x49, 0x48,0x48,0x48, 0x47,0x47,0x47, 0x46,0x46,0x46, 0x45,0x45,0x45, 0x43,0x43,0x43, 0x42,0x42,0x42, 0x41,0x41,0x41, + 0x40,0x40,0x40, 0x3f,0x3f,0x3f, 0x3e,0x3e,0x3e, 0x3d,0x3d,0x3d, 0x3c,0x3c,0x3c, 0x3b,0x3b,0x3b, 0x3a,0x3a,0x3a, 0x39,0x39,0x39, 0x38,0x38,0x38, 0x37,0x37,0x37, 0x36,0x36,0x36, 0x35,0x35,0x35, 0x65,0x65,0x65, 0x65,0x65,0x65, 0x65,0x65,0x65, 0x65,0x65,0x65, + 0x65,0x65,0x65, 0x65,0x65,0x65, 0x65,0x65,0x65, 0x65,0x65,0x65, 0x65,0x65,0x65, 0x65,0x65,0x65, 0x65,0x65,0x65, 0x65,0x65,0x65, 0x65,0x65,0x65, 0x65,0x65,0x65, 0x65,0x65,0x65, 0x65,0x65,0x65, 0x65,0x65,0x65, 0x65,0x65,0x65, 0x65,0x65,0x65, 0x65,0x65,0x65, + 0x65,0x65,0x65, 0x65,0x65,0x65, 0x65,0x65,0x65, 0x65,0x65,0x65, 0x65,0x65,0x65, 0x65,0x65,0x65, 0x65,0x65,0x65, 0x65,0x65,0x65, 0x65,0x65,0x65, 0x65,0x65,0x65, 0x65,0x65,0x65, 0x65,0x65,0x65, 0x65,0x65,0x65, 0x65,0x65,0x65, 0x65,0x65,0x65, 0x65,0x65,0x65, + 0x65,0x65,0x65, 0x65,0x65,0x65, 0x65,0x65,0x65, 0x65,0x65,0x65, 0x00,0xff,0xff, 0x65,0x65,0x65, 0x65,0x65,0x65, 0x65,0x65,0x65, 0x65,0x65,0x65, 0x00,0xff,0x00, 0x65,0x65,0x65, 0x65,0x65,0x65, 0x65,0x65,0x65, 0x65,0x65,0x65, 0x65,0x65,0x65, 0x65,0x65,0x65, + 0x65,0x65,0x65, 0x65,0x65,0x65, 0x65,0x65,0x65, 0x65,0x65,0x65, 0x65,0x65,0x65, 0x65,0x65,0x65, 0x65,0x65,0x65, 0x65,0x65,0x65, 0x65,0x65,0x65, 0x65,0x65,0x65, 0x65,0x65,0x65, 0x65,0x65,0x65, 0x65,0x65,0x65, 0x65,0x65,0x65, 0x65,0x65,0x65, 0x65,0x65,0x65, + 0x65,0x65,0x65, 0x65,0x65,0x65, 0x00,0x00,0xff, 0x65,0x65,0x65, 0x65,0x65,0x65, 0x65,0x65,0x65, 0x65,0x65,0x65, 0x65,0x65,0x65, - 0xdd,0x00,0x00, 0x65,0x65,0x65, 0x65,0x65,0x65, 0x65,0x65,0x65, + 0xd0,0x00,0x00, 0x65,0x65,0x65, 0x65,0x65,0x65, 0x65,0x65,0x65, 0x65,0x65,0x65, 0x65,0x65,0x65, 0x65,0x65,0x65, 0x65,0x65,0x65, + 0x65,0x65,0x65, 0x65,0x65,0x65, 0x65,0x65,0x65, 0x00,0xbb,0x00, 0x65,0x65,0x65, 0x65,0x65,0x65, 0x65,0x65,0x65, 0x65,0x65,0x65, 0x65,0x65,0x65, 0x65,0x65,0x65, 0x65,0x65,0x65, 0x65,0x65,0x65, 0x65,0x65,0x65, 0x65,0x65,0x65, 0x65,0x65,0x65, 0x65,0x65,0x65, + 0x65,0x65,0x65, 0x65,0x65,0x65, 0x65,0x65,0x65, 0x65,0x65,0x65, 0x65,0x65,0x65, 0x65,0x65,0x65, 0x65,0x65,0x65, 0xbb,0xbb,0xbb, 0x65,0x65,0x65, 0x88,0x88,0x88, 0x77,0x77,0x77, 0x55,0x55,0x55, Index: trunk/i386/boot2/options.c =================================================================== --- trunk/i386/boot2/options.c (revision 2411) +++ trunk/i386/boot2/options.c (revision 2412) @@ -1094,8 +1094,8 @@ bool copyArgument(const char *argName, const char *val, int cnt, char **argP, int *cntRemainingP) { - int argLen = argName ? strlen(argName) : 0; - int len = argLen + cnt + 1; // +1 to account for space + int argLen = argName ? strlen(argName) : 0; + int len = argLen + cnt + 1; // + 1 to account for space. if (argName) { @@ -1107,8 +1107,9 @@ return false; } - if (argName) { - strncpy( *argP, argName, argLen ); + if (argName) + { + strncpy(*argP, argName, argLen); *argP += argLen; *argP[0] = '='; (*argP)++; @@ -1118,8 +1119,8 @@ *argP += cnt; *argP[0] = ' '; (*argP)++; + *cntRemainingP -= len; - *cntRemainingP -= len; return true; } @@ -1225,11 +1226,15 @@ if (( kernel = extractKernelName((char **)&cp) )) { strlcpy( bootInfo->bootFile, kernel, sizeof(bootInfo->bootFile) ); - } else { + } + else + { if ( getValueForKey( kKernelNameKey, &val, &cnt, &bootInfo->bootConfig ) ) { strlcpy( bootInfo->bootFile, val, cnt+1 ); - } else { + } + else + { strlcpy( bootInfo->bootFile, kDefaultKernel, sizeof(bootInfo->bootFile) ); } } @@ -1300,12 +1305,16 @@ cnt++; strlcpy(valueBuffer + 1, val, cnt); val = valueBuffer; - } else { /* + } + else + { /* if (strlen(gBootUUIDString)) { val = "*uuid"; cnt = 5; - } else { */ + } + else + { */ // Don't set "rd=.." if there is no boot device key // and no UUID. val = ""; @@ -1380,7 +1389,9 @@ if ( getValueForKey( kMKextCacheKey, &val, &cnt, &bootInfo->bootConfig ) ) { strlcpy(gMKextName, val, cnt + 1); - } else { + } + else + { gMKextName[0]=0; } @@ -1470,9 +1481,12 @@ void showHelp(void) { - if (bootArgs->Video.v_display != VGA_TEXT_MODE) { + if (bootArgs->Video.v_display != VGA_TEXT_MODE) + { showInfoBox("Help. Press q to quit.\n", (char *)BootHelp_txt); - } else { + } + else + { showTextBuffer((char *)BootHelp_txt, BootHelp_txt_len); } } @@ -1484,14 +1498,16 @@ int fd; int size; - if ((fd = open_bvdev("bt(0,0)", filename, 0)) < 0) { + if ((fd = open_bvdev("bt(0,0)", filename, 0)) < 0) + { printf("\nFile not found: %s\n", filename); sleep(2); return; } size = file_size(fd); - if (size > MAX_TEXT_FILE_SIZE) { + if (size > MAX_TEXT_FILE_SIZE) + { size = MAX_TEXT_FILE_SIZE; } buf = malloc(size); @@ -1518,9 +1534,11 @@ printf("Enter two-digit hexadecimal boot device [%02x]: ", bootdevice); do { key = getchar(); - switch (ASCII_KEY(key)) { + switch (ASCII_KEY(key)) + { case KEY_BKSP: - if (digitsI > 0) { + if (digitsI > 0) + { int x, y, t; getCursorPositionAndType(&x, &y, &t); // Assume x is not 0; @@ -1529,7 +1547,9 @@ // Overwrite with space without moving cursor position putca(' ', 0x07, 1); digitsI--; - } else { + } + else + { // TODO: Beep or something } break; @@ -1537,7 +1557,8 @@ case KEY_ENTER: digits[digitsI] = '\0'; newbootdevice = strtol(digits, &end, 16); - if (end == digits && *end == '\0') { + if (end == digits && *end == '\0') + { // User entered empty string printf("\nUsing default boot device %x\n", bootdevice); key = 0; @@ -1552,10 +1573,13 @@ break; default: - if (isxdigit(ASCII_KEY(key)) && digitsI < 2) { + if (isxdigit(ASCII_KEY(key)) && digitsI < 2) + { putchar(ASCII_KEY(key)); digits[digitsI++] = ASCII_KEY(key); - } else { + } + else + { // TODO: Beep or something } break; @@ -1568,9 +1592,12 @@ bool promptForRescanOption(void) { printf("\nWould you like to enable media rescan option?\nPress ENTER to enable or any key to skip.\n"); - if (getchar() == KEY_ENTER) { + if (getchar() == KEY_ENTER) + { return true; - } else { + } + else + { return false; } } Index: trunk/i386/libsa/zalloc.c =================================================================== --- trunk/i386/libsa/zalloc.c (revision 2411) +++ trunk/i386/libsa/zalloc.c (revision 2412) @@ -57,7 +57,7 @@ static void zcoalesce(void); #if ZDEBUG -size_t zalloced_size; + size_t zalloced_size; #endif #define ZALLOC_NODES 32767 /* was 16384 */ @@ -78,7 +78,8 @@ zavailable = (zmem *) zalloc_base + sizeof(zmem) * totalNodes; zavailable[0].start = (char *)zavailable + sizeof(zmem) * totalNodes; - if (size == 0) { + if (size == 0) + { size = ZALLOC_LEN; } @@ -108,8 +109,10 @@ size = ((size + 0xf) & ~0xf); - if (size == 0) { - if (zerror) { + if (size == 0) + { + if (zerror) + { (*zerror)((char *)0xdeadbeef, 0, file, line); } } @@ -155,12 +158,14 @@ done: if ((ret == 0) || (ret + size >= zalloc_end)) { - if (zerror) { + if (zerror) + { (*zerror)(ret, size, file, line); } } - if (ret != 0) { + if (ret != 0) + { bzero(ret, size); } #if ZDEBUG @@ -186,7 +191,8 @@ rp = 0; #endif - if (!start) { + if (!start) + { return; } @@ -207,8 +213,10 @@ break; } } - if (!found) { - if (zerror) { + if (!found) + { + if (zerror) + { (*zerror)(pointer, rp, "free", 0); } else { return; @@ -218,7 +226,8 @@ zalloced_size -= tsize; #endif - for (i = 0; i < availableNodes; i++) { + for (i = 0; i < availableNodes; i++) + { if ((start + tsize) == zavailable[i].start) // merge it in { zavailable[i].start = start; @@ -227,15 +236,19 @@ return; } - if ((i > 0) && (zavailable[i-1].start + zavailable[i-1].size == start)) { + if ((i > 0) && (zavailable[i-1].start + zavailable[i-1].size == start)) + { zavailable[i-1].size += tsize; zcoalesce(); return; } - if ((start + tsize) < zavailable[i].start) { - if (++availableNodes > totalNodes) { - if (zerror) { + if ((start + tsize) < zavailable[i].start) + { + if (++availableNodes > totalNodes) + { + if (zerror) + { (*zerror)((char *)0xf000f000, 0, "free", 0); } } @@ -246,8 +259,10 @@ } } - if (++availableNodes > totalNodes) { - if (zerror) { + if (++availableNodes > totalNodes) + { + if (zerror) + { (*zerror)((char *)0xf000f000, 1, "free", 0); } } @@ -270,8 +285,10 @@ zalloced[allocedNodes].start = start; zalloced[allocedNodes].size = size; - if (++allocedNodes > totalNodes) { - if (zerror) { + if (++allocedNodes > totalNodes) + { + if (zerror) + { (*zerror)((char *)0xf000f000, 2, "zallocate", 0); } }; @@ -287,7 +304,8 @@ z1 = zp + i; z2 = z1 + 1; - for (; i >= ndx; i--, z1--, z2--) { + for (; i >= ndx; i--, z1--, z2--) + { *z2 = *z1; } } @@ -301,7 +319,8 @@ z1 = zp + ndx; z2 = z1 + 1; - for (i = ndx; i < totalNodes - 1; i++, z1++, z2++) { + for (i = ndx; i < totalNodes - 1; i++, z1++, z2++) + { *z1 = *z2; } } @@ -311,8 +330,10 @@ { int i; - for (i = 0; i < availableNodes-1; i++) { - if ( zavailable[i].start + zavailable[i].size == zavailable[i + 1].start ) { + for (i = 0; i < availableNodes-1; i++) + { + if ( zavailable[i].start + zavailable[i].size == zavailable[i + 1].start ) + { zavailable[i].size += zavailable[i + 1].size; zdelete(zavailable, i + 1); availableNodes--; return; Index: trunk/CHANGES =================================================================== --- trunk/CHANGES (revision 2411) +++ trunk/CHANGES (revision 2412) @@ -1,3 +1,4 @@ +- Typo - Make compile on gcc w/ errors enabled. - Remove the '-x' option from the offending 'ld' command - Makefile dependency missing for boot0 and boot1h