Index: trunk/i386/libsaio/asm.s =================================================================== --- trunk/i386/libsaio/asm.s (revision 2537) +++ trunk/i386/libsaio/asm.s (revision 2538) @@ -521,4 +521,4 @@ popl %edx ret - +// computeRand() end function - - - - - - - - - - - - - - - - - - - - - - - - Index: trunk/i386/libsaio/console.c =================================================================== --- trunk/i386/libsaio/console.c (revision 2537) +++ trunk/i386/libsaio/console.c (revision 2538) @@ -99,11 +99,13 @@ va_list ap; struct putc_info pi; - if (!msgbuf) { + if (!msgbuf) + { return; } - if (((cursor - msgbuf) > (BOOTER_LOG_SIZE - SAFE_LOG_SIZE))) { + if (((cursor - msgbuf) > (BOOTER_LOG_SIZE - SAFE_LOG_SIZE))) + { return; } @@ -117,7 +119,8 @@ void setupBooterLog(void) { - if (!msgbuf) { + if (!msgbuf) + { return; } @@ -300,8 +303,8 @@ } /** Print a "Press a key to continue..." message and wait for a key press. */ -void pause() +void pause() { - printf("Press a key to continue...\n"); + printf("Press a key to continue...\n"); getchar(); // replace getchar() by pause() were useful. } Index: trunk/i386/libsaio/bootstruct.c =================================================================== --- trunk/i386/libsaio/bootstruct.c (revision 2537) +++ trunk/i386/libsaio/bootstruct.c (revision 2538) @@ -97,6 +97,7 @@ if (node == 0) { stop("Couldn't create root node"); } + getPlatformName(platformName); nameLen = strlen(platformName) + 1; DT__AddProperty(node, "compatible", nameLen, platformName); Index: trunk/i386/libsaio/ntfs_private.h =================================================================== --- trunk/i386/libsaio/ntfs_private.h (revision 2537) +++ trunk/i386/libsaio/ntfs_private.h (revision 2538) @@ -94,6 +94,7 @@ }; #define NTFS_AF_INRUN 0x00000001 + struct attrhdr { u_int32_t a_type; u_int32_t reclen; @@ -105,16 +106,18 @@ u_int8_t reserved2; u_int16_t a_index; }; -#define NTFS_A_STD 0x10 -#define NTFS_A_ATTRLIST 0x20 -#define NTFS_A_NAME 0x30 + +#define NTFS_A_STD 0x10 +#define NTFS_A_ATTRLIST 0x20 +#define NTFS_A_NAME 0x30 #define NTFS_A_VOLUMENAME 0x60 -#define NTFS_A_DATA 0x80 -#define NTFS_A_INDXROOT 0x90 -#define NTFS_A_INDX 0xA0 -#define NTFS_A_INDXBITMAP 0xB0 +#define NTFS_A_DATA 0x80 +#define NTFS_A_INDXROOT 0x90 +#define NTFS_A_INDX 0xA0 +#define NTFS_A_INDXBITMAP 0xB0 #define NTFS_MAXATTRNAME 255 + struct attr { struct attrhdr a_hdr; union { @@ -266,7 +269,7 @@ u_int8_t bf_spc; /* sectors per cluster */ u_int8_t reserved2[7]; /* unused (zeroed) */ u_int8_t bf_media; /* media desc. (0xF8) */ - u_int8_t reserved3[2]; + u_int8_t reserved3[2]; /* always 0 */ u_int16_t bf_spt; /* sectors per track */ u_int16_t bf_heads; /* number of heads */ u_int8_t reserver4[12]; @@ -275,9 +278,9 @@ cn_t bf_mftmirrcn; /* $MFTMirr cn */ u_int8_t bf_mftrecsz; /* MFT record size (clust) */ /* 0xF6 inducates 1/4 */ - u_int8_t reserved5[3]; + u_int8_t reserved5[3]; u_int8_t bf_ibsz; /* index buffer size */ - u_int8_t reserved6[3]; + u_int8_t reserved6[3]; u_int64_t bf_volsn; /* volume ser. num. */ }; Index: trunk/i386/libsaio/vbe.c =================================================================== --- trunk/i386/libsaio/vbe.c (revision 2537) +++ trunk/i386/libsaio/vbe.c (revision 2538) @@ -69,7 +69,7 @@ #endif /* UNUSED */ //============================================================================== -int getVBEInfo( void * infoBlock ) +int getVBEInfo( void *infoBlock ) { bb.intno = 0x10; bb.eax.rr = funcGetControllerInfo; @@ -81,7 +81,7 @@ //============================================================================== -int getVBEModeInfo( int mode, void * minfo_p ) +int getVBEModeInfo( int mode, void *minfo_p ) { bb.intno = 0x10; bb.eax.rr = funcGetModeInfo; @@ -268,68 +268,69 @@ int setVBEMode(unsigned short mode, const VBECRTCInfoBlock * timing) { - bb.intno = 0x10; - bb.eax.rr = funcSetMode; - bb.ebx.rr = mode; - if (timing) { - bb.es = SEG(timing); - bb.edi.rr = OFF(timing); - } - bios(&bb); - return(bb.eax.r.h); + bb.intno = 0x10; + bb.eax.rr = funcSetMode; + bb.ebx.rr = mode; + if (timing) + { + bb.es = SEG(timing); + bb.edi.rr = OFF(timing); + } + bios(&bb); + return(bb.eax.r.h); } //============================================================================== int setVBEPalette(void *palette) { - bb.intno = 0x10; - bb.eax.rr = funcGetSetPaletteData; - bb.ebx.r.l = subfuncSet; - bb.ecx.rr = 256; - bb.edx.rr = 0; - bb.es = SEG(palette); - bb.edi.rr = OFF(palette); - bios(&bb); - return(bb.eax.r.h); + bb.intno = 0x10; + bb.eax.rr = funcGetSetPaletteData; + bb.ebx.r.l = subfuncSet; + bb.ecx.rr = 256; + bb.edx.rr = 0; + bb.es = SEG(palette); + bb.edi.rr = OFF(palette); + bios(&bb); + return(bb.eax.r.h); } //============================================================================== int getVBEPalette(void *palette) { - bb.intno = 0x10; - bb.eax.rr = funcGetSetPaletteData; - bb.ebx.r.l = subfuncGet; - bb.ecx.rr = 256; - bb.edx.rr = 0; - bb.es = SEG(palette); - bb.edi.rr = OFF(palette); - bios(&bb); - return(bb.eax.r.h); + bb.intno = 0x10; + bb.eax.rr = funcGetSetPaletteData; + bb.ebx.r.l = subfuncGet; + bb.ecx.rr = 256; + bb.edx.rr = 0; + bb.es = SEG(palette); + bb.edi.rr = OFF(palette); + bios(&bb); + return(bb.eax.r.h); } //============================================================================== int getVBECurrentMode(unsigned short *mode) { - bb.intno = 0x10; - bb.eax.rr = funcGetCurrentMode; - bios(&bb); - *mode = bb.ebx.rr; - return(bb.eax.r.h); + bb.intno = 0x10; + bb.eax.rr = funcGetCurrentMode; + bios(&bb); + *mode = bb.ebx.rr; + return(bb.eax.r.h); } //============================================================================== int getVBEPixelClock(unsigned short mode, unsigned long * pixelClock) { - bb.intno = 0x10; - bb.eax.rr = funcGetSetPixelClock; - bb.ebx.r.l = 0; - bb.ecx.rx = *pixelClock; - bb.edx.rr = mode; - bios(&bb); - *pixelClock = bb.ecx.rx; - return(bb.eax.r.h); + bb.intno = 0x10; + bb.eax.rr = funcGetSetPixelClock; + bb.ebx.r.l = 0; + bb.ecx.rx = *pixelClock; + bb.edx.rr = mode; + bios(&bb); + *pixelClock = bb.ecx.rx; + return(bb.eax.r.h); } Index: trunk/i386/libsaio/device_tree.c =================================================================== --- trunk/i386/libsaio/device_tree.c (revision 2537) +++ trunk/i386/libsaio/device_tree.c (revision 2538) @@ -87,13 +87,13 @@ { Property *prop; - DPRINTF("DT__AddProperty([Node '%s'], '%s', %d, 0x%x)\n", DT__GetName(node), name, length, value); + DPRINTF("DT__AddProperty([Node '%s'], '%s', %d, 0x%X)\n", DT__GetName(node), name, length, value); if (freeProperties == NULL) { void *buf = malloc(kAllocSize); int i; - DPRINTF("Allocating more free properties\n"); + DPRINTF("DT__AddProperty: Allocating more free properties\n"); if (buf == 0) { return 0; @@ -159,7 +159,7 @@ int i; - DPRINTF("Allocating more free nodes\n"); + DPRINTF("DT__AddChild: Allocating more free nodes\n"); bzero(buf, kAllocSize); node = (Node *)buf; @@ -183,8 +183,8 @@ node = freeNodes; freeNodes = node->next; - DPRINTF("Got free node 0x%x\n", node); - DPRINTF("prop = 0x%x, children = 0x%x, next = 0x%x\n", node->properties, node->children, node->next); + DPRINTF("DT__AddChild: Got free node 0x%x\n", node); + DPRINTF("DT__AddChild: prop = 0x%x, children = 0x%x, next = 0x%x\n", node->properties, node->children, node->next); if (parent == NULL) { @@ -239,7 +239,7 @@ DTInfo.totalPropertySize = 0; rootNode = DT__AddChild(NULL, "/"); - DPRINTF("DT__Initialize done\n"); + DPRINTF("DT__Initialize: done\n"); } //============================================================================== @@ -430,11 +430,11 @@ // Start at root node = rootNode; - DPRINTF("root = 0x%x\n", rootNode); + DPRINTF("DT__FindNode: root = 0x%x\n", rootNode); while (node) { - // Skip leading slash + // Skip leading slash(es) while (*path == '/') { path++; @@ -447,35 +447,34 @@ *bp = '\0'; - if (nameBuf[0] == '\0') - { - // last path entry - break; - } - - DPRINTF("Node '%s'\n", nameBuf); - - for (child = node->children; child != 0; child = child->next) - { - DPRINTF("Child 0x%x\n", child); - - if (strcmp(DT__GetName(child), nameBuf) == 0) + if (nameBuf[0] == '\0') { + // last path entry break; } - } - if (child == 0 && createIfMissing) - { - DPRINTF("Creating node\n"); + DPRINTF("DT__FindNode: Node '%s'\n", nameBuf); - char *str = malloc(strlen(nameBuf) + 1); - // XXX this will leak - strcpy(str, nameBuf); + for (child = node->children; child != 0; child = child->next) + { + DPRINTF("DT__FindNode: Child 0x%x\n", child); - child = DT__AddChild(node, str); - } + if (strcmp(DT__GetName(child), nameBuf) == 0) + { + break; + } + } + if (child == 0 && createIfMissing) + { + char *str = malloc(strlen(nameBuf) + 1); + // XXX this will leak + strcpy(str, nameBuf); + + child = DT__AddChild(node, str); + DPRINTF("DT__FindNode: Creating node: %s\n", str); + } + node = child; } Index: trunk/i386/libsaio/hfs.c =================================================================== --- trunk/i386/libsaio/hfs.c (revision 2537) +++ trunk/i386/libsaio/hfs.c (revision 2538) @@ -290,7 +290,7 @@ return HFSReadFile(ih, filePath, (void *)gFSLoadAddress, 0, 0); } -long HFSReadFile(CICell ih, char * filePath, void *base, u_int64_t offset, u_int64_t length) +long HFSReadFile(CICell ih, char *filePath, void *base, u_int64_t offset, u_int64_t length) { char entry[512]; char devStr[12]; @@ -453,7 +453,7 @@ nodeSize = SWAP_BE16(gBTHeaders[kBTreeCatalog]->nodeSize); firstLeafNode = SWAP_BE32(gBTHeaders[kBTreeCatalog]->firstLeafNode); - dirIndex = (long long) firstLeafNode * nodeSize; + dirIndex = (long long)firstLeafNode * nodeSize; GetCatalogEntry(&dirIndex, &name, &flags, &time, 0, 0); @@ -505,7 +505,7 @@ if ((result == -1) || ((flags & kFileTypeMask) != kFileTypeFlat)) { - printf("HFS: Resolve path %s failed\n", filePath); + printf("HFS: Resolve path '%s' failed\n", filePath); return -1; } @@ -568,7 +568,7 @@ if (offset > fileLength) { - printf("Offset is too large.\n"); + printf("ReadFile(HFS%c): Offset is too large.\n", gIsHFSPlus ? "+" : ""); return -1; } Index: trunk/i386/libsaio/acpi_patcher.c =================================================================== --- trunk/i386/libsaio/acpi_patcher.c (revision 2537) +++ trunk/i386/libsaio/acpi_patcher.c (revision 2538) @@ -42,7 +42,7 @@ } /* Gets the ACPI 1.0 RSDP address */ -static struct acpi_2_rsdp* getAddressOfAcpiTable() +static struct acpi_2_rsdp *getAddressOfAcpiTable() { /* TODO: Before searching the BIOS space we are supposed to search the first 1K of the EBDA */ @@ -65,13 +65,13 @@ } /* Gets the ACPI 2.0 RSDP address */ -static struct acpi_2_rsdp* getAddressOfAcpi20Table() +static struct acpi_2_rsdp *getAddressOfAcpi20Table() { /* TODO: Before searching the BIOS space we are supposed to search the first 1K of the EBDA */ - void *acpi_addr = (void*)ACPI_RANGE_START; + void *acpi_addr = (void *)ACPI_RANGE_START; - for(; acpi_addr <= (void*)ACPI_RANGE_END; acpi_addr += 16) + for(; acpi_addr <= (void *)ACPI_RANGE_END; acpi_addr += 16) { if(*(uint64_t *)acpi_addr == ACPI_SIGNATURE_UINT64_LE) { @@ -97,7 +97,7 @@ /* The folowing ACPI Table search algo. should be reused anywhere needed:*/ /* WARNING: outDirspec string will be overwritten by subsequent calls! */ -int search_and_get_acpi_fd(const char * filename, const char ** outDirspec) +int search_and_get_acpi_fd(const char *filename, const char **outDirspec) { int fd = 0; static char dirSpec[512]; @@ -127,51 +127,51 @@ return fd; } -void *loadACPITable (const char * filename) +void *loadACPITable (const char *filename) { - const char * dirspec=NULL; + const char *dirspec = NULL; int fd = search_and_get_acpi_fd(filename, &dirspec); if (fd >= 0) { - void *tableAddr = (void*)AllocateKernelMemory(file_size (fd)); + void *tableAddr = (void*)AllocateKernelMemory(file_size(fd)); if (tableAddr) { - if (read (fd, tableAddr, file_size (fd))!=file_size (fd)) + if (read(fd, tableAddr, file_size(fd)) != file_size(fd)) { DBG("Couldn't read table %s\n",dirspec); - free (tableAddr); - close (fd); + free(tableAddr); + close(fd); return NULL; } DBG("Table %s read and stored at: %x\n", dirspec, tableAddr); - close (fd); + close(fd); return tableAddr; } - close (fd); + close(fd); DBG("Couldn't allocate memory for table \n", dirspec); } //printf("Couldn't find table %s\n", filename); return NULL; } -uint8_t acpi_cpu_count = 0; -char* acpi_cpu_name[32]; +uint8_t acpi_cpu_count = 0; uint32_t acpi_cpu_p_blk = 0; +char *acpi_cpu_name[32]; -void get_acpi_cpu_names(unsigned char* dsdt, uint32_t length) +void get_acpi_cpu_names(unsigned char *dsdt, uint32_t length) { uint32_t i; - DBG("Start finding cpu names. length %d\n", length); + DBG("ACPIpatcher: start finding cpu names. Length %d\n", length); for (i=0; i> 6); @@ -186,7 +186,7 @@ if (!aml_isvalidchar(c)) { add_name = false; - DBG("Invalid character found in ProcessorOP 0x%x!\n", c); + DBG("ACPIpatcher: invalid character found in ProcessorOP '0x%X'!\n", c); break; } } @@ -202,7 +202,7 @@ acpi_cpu_p_blk = dsdt[i] | (dsdt[i+1] << 8); } - DBG("Found ACPI CPU: %c%c%c%c\n", acpi_cpu_name[acpi_cpu_count][0], acpi_cpu_name[acpi_cpu_count][1], acpi_cpu_name[acpi_cpu_count][2], acpi_cpu_name[acpi_cpu_count][3]); + DBG("ACPIpatcher: found ACPI CPU [%c%c%c%c]\n", acpi_cpu_name[acpi_cpu_count][0], acpi_cpu_name[acpi_cpu_count][1], acpi_cpu_name[acpi_cpu_count][2], acpi_cpu_name[acpi_cpu_count][3]); if (++acpi_cpu_count == 32) { @@ -212,12 +212,12 @@ } } - DBG("End finding cpu names: cpu names found: %d\n", acpi_cpu_count); + DBG("ACPIpatcher: finished finding cpu names. Found: %d.\n", acpi_cpu_count); } struct acpi_2_fadt *patch_fadt(struct acpi_2_fadt *fadt, struct acpi_2_dsdt *new_dsdt) { - extern void setupSystemType(); + extern void setupSystemType(); struct acpi_2_fadt *fadt_mod = NULL; bool fadt_rev2_needed = false; @@ -253,14 +253,14 @@ // Allocate new fadt table if (fadt->Length < 0x84 && fadt_rev2_needed) { - fadt_mod=(struct acpi_2_fadt *)AllocateKernelMemory(0x84); + fadt_mod = (struct acpi_2_fadt *)AllocateKernelMemory(0x84); memcpy(fadt_mod, fadt, fadt->Length); fadt_mod->Length = 0x84; fadt_mod->Revision = 0x02; // FADT rev 2 (ACPI 1.0B MS extensions) } else { - fadt_mod=(struct acpi_2_fadt *)AllocateKernelMemory(fadt->Length); + fadt_mod = (struct acpi_2_fadt *)AllocateKernelMemory(fadt->Length); memcpy(fadt_mod, fadt, fadt->Length); } // Determine system type / PM_Model @@ -412,7 +412,7 @@ int ssdt_count=0; // SSDT Options - bool drop_ssdt=false, generate_pstates=false, generate_cstates=false; + bool drop_ssdt = false, generate_pstates = false, generate_cstates = false; getBoolForKey(kDropSSDT, &drop_ssdt, &bootInfo->chameleonConfig); getBoolForKey(kGeneratePStates, &generate_pstates, &bootInfo->chameleonConfig); @@ -449,7 +449,7 @@ int rsdplength; // Find original rsdp - rsdp=(struct acpi_2_rsdp *)(version ? getAddressOfAcpi20Table() : getAddressOfAcpiTable()); + rsdp = (struct acpi_2_rsdp *)(version ? getAddressOfAcpi20Table() : getAddressOfAcpiTable()); if (!rsdp) { DBG("No ACPI version %d found. Ignoring\n", version+1); @@ -463,7 +463,7 @@ } continue; } - rsdplength=version ? rsdp->Length : 20; + rsdplength = version ? rsdp->Length : 20; DBG("RSDP version %d found @%x. Length=%d\n",version+1,rsdp,rsdplength); @@ -472,26 +472,26 @@ * For more info see ACPI Specification pages 110 and following */ - rsdp_mod=(struct acpi_2_rsdp *) AllocateKernelMemory(rsdplength); + rsdp_mod = (struct acpi_2_rsdp *) AllocateKernelMemory(rsdplength); memcpy(rsdp_mod, rsdp, rsdplength); - rsdt=(struct acpi_2_rsdt *)(rsdp->RsdtAddress); + rsdt = (struct acpi_2_rsdt *)rsdp->RsdtAddress; DBG("RSDT @%x, Length %d\n",rsdt, rsdt ? rsdt->Length : 0); - - if (rsdt && (uint32_t)rsdt !=0xffffffff && rsdt->Length<0x10000) + + if (rsdt && (uint32_t)rsdt !=0xffffffff && rsdt->Length < 0x10000) { uint32_t *rsdt_entries; int rsdt_entries_num; int dropoffset=0, i; // mozo: using malloc cos I didn't found how to free already allocated kernel memory - rsdt_mod=(struct acpi_2_rsdt *)malloc(rsdt->Length); - memcpy (rsdt_mod, rsdt, rsdt->Length); - rsdp_mod->RsdtAddress=(uint32_t)rsdt_mod; - rsdt_entries_num=(rsdt_mod->Length-sizeof(struct acpi_2_rsdt))/4; - rsdt_entries=(uint32_t *)(rsdt_mod+1); - for (i=0;iLength); + memcpy(rsdt_mod, rsdt, rsdt->Length); + rsdp_mod->RsdtAddress = (uint32_t)rsdt_mod; + rsdt_entries_num = (rsdt_mod->Length - sizeof(struct acpi_2_rsdt)) / 4; + rsdt_entries = (uint32_t *)(rsdt_mod + 1); + for (i = 0;i < rsdt_entries_num;i++) { char *table=(char *)(rsdt_entries[i]); if (!table) @@ -536,7 +536,7 @@ } fadt_mod = patch_fadt(fadt, new_dsdt); - rsdt_entries[i-dropoffset]=(uint32_t)fadt_mod; + rsdt_entries[i-dropoffset] = (uint32_t)fadt_mod; // Generate _CST SSDT if (generate_cstates && (new_ssdt[ssdt_count] = generate_cst_ssdt(fadt_mod))) @@ -561,11 +561,12 @@ // Allocate rsdt in Kernel memory area rsdt_mod->Length += 4*ssdt_count - 4*dropoffset; struct acpi_2_rsdt *rsdt_copy = (struct acpi_2_rsdt *)AllocateKernelMemory(rsdt_mod->Length); - memcpy (rsdt_copy, rsdt_mod, rsdt_mod->Length); - free(rsdt_mod); rsdt_mod = rsdt_copy; - rsdp_mod->RsdtAddress=(uint32_t)rsdt_mod; - rsdt_entries_num=(rsdt_mod->Length-sizeof(struct acpi_2_rsdt))/4; - rsdt_entries=(uint32_t *)(rsdt_mod+1); + memcpy(rsdt_copy, rsdt_mod, rsdt_mod->Length); + free(rsdt_mod); + rsdt_mod = rsdt_copy; + rsdp_mod->RsdtAddress = (uint32_t)rsdt_mod; + rsdt_entries_num = (rsdt_mod->Length-sizeof(struct acpi_2_rsdt)) / 4; + rsdt_entries = (uint32_t *)(rsdt_mod + 1); // Mozodojo: Insert additional SSDTs into RSDT if(ssdt_count > 0) @@ -612,20 +613,20 @@ int dropoffset=0; // mozo: using malloc cos I didn't found how to free already allocated kernel memory - xsdt_mod=(struct acpi_2_xsdt*)malloc(xsdt->Length); + xsdt_mod=(struct acpi_2_xsdt*)malloc(xsdt->Length); memcpy(xsdt_mod, xsdt, xsdt->Length); - rsdp_mod->XsdtAddress=(uint32_t)xsdt_mod; - xsdt_entries_num=(xsdt_mod->Length-sizeof(struct acpi_2_xsdt))/8; - xsdt_entries=(uint64_t *)(xsdt_mod+1); - for (i=0;iXsdtAddress = (uint32_t)xsdt_mod; + xsdt_entries_num = (xsdt_mod->Length - sizeof(struct acpi_2_xsdt)) / 8; + xsdt_entries = (uint64_t *)(xsdt_mod + 1); + for (i = 0;i < xsdt_entries_num;i++) { - char *table=(char *)((uint32_t)(xsdt_entries[i])); + char *table = (char *)((uint32_t)(xsdt_entries[i])); if (!table) { continue; } - xsdt_entries[i-dropoffset]=xsdt_entries[i]; + xsdt_entries[i - dropoffset] = xsdt_entries[i]; if (drop_ssdt && tableSign(table, "SSDT")) { @@ -639,7 +640,7 @@ if (new_dsdt) { - xsdt_entries[i-dropoffset]=(uint32_t)new_dsdt; + xsdt_entries[i-dropoffset] = (uint32_t)new_dsdt; DBG("custom table added\n"); } @@ -692,10 +693,11 @@ xsdt_mod->Length += 8*ssdt_count - 8*dropoffset; struct acpi_2_xsdt *xsdt_copy = (struct acpi_2_xsdt *)AllocateKernelMemory(xsdt_mod->Length); memcpy(xsdt_copy, xsdt_mod, xsdt_mod->Length); - free(xsdt_mod); xsdt_mod = xsdt_copy; - rsdp_mod->XsdtAddress=(uint32_t)xsdt_mod; - xsdt_entries_num=(xsdt_mod->Length-sizeof(struct acpi_2_xsdt))/8; - xsdt_entries=(uint64_t *)(xsdt_mod+1); + free(xsdt_mod); + xsdt_mod = xsdt_copy; + rsdp_mod->XsdtAddress = (uint32_t)xsdt_mod; + xsdt_entries_num = (xsdt_mod->Length - sizeof(struct acpi_2_xsdt)) / 8; + xsdt_entries = (uint64_t *)(xsdt_mod + 1); // Mozodojo: Insert additional SSDTs into XSDT if(ssdt_count > 0) Index: trunk/i386/libsaio/spd.c =================================================================== --- trunk/i386/libsaio/spd.c (revision 2537) +++ trunk/i386/libsaio/spd.c (revision 2538) @@ -128,7 +128,8 @@ static void init_spd(char * spd, uint32_t base, int slot) { int i; - for (i=0; i< SPD_INDEXES_SIZE; i++) { + for (i = 0; i < SPD_INDEXES_SIZE; i++) + { READ_SPD(spd, base, slot, spd_indexes[i]); } } @@ -239,7 +240,9 @@ if (spd[SPD_MEMORY_TYPE]==SPD_MEMORY_TYPE_SDRAM_DDR3) { start = 128; - } else if (spd[SPD_MEMORY_TYPE]==SPD_MEMORY_TYPE_SDRAM_DDR2 || spd[SPD_MEMORY_TYPE]==SPD_MEMORY_TYPE_SDRAM_DDR) { + } + else if (spd[SPD_MEMORY_TYPE]==SPD_MEMORY_TYPE_SDRAM_DDR2 || spd[SPD_MEMORY_TYPE]==SPD_MEMORY_TYPE_SDRAM_DDR) + { start = 73; } Index: trunk/i386/libsaio/gma.c =================================================================== --- trunk/i386/libsaio/gma.c (revision 2537) +++ trunk/i386/libsaio/gma.c (revision 2538) @@ -396,7 +396,7 @@ struct DevPropDevice *device = devprop_add_device(string, devicepath); if (!device) { - printf("Failed initializing dev-prop string dev-entry.\n"); + printf("[setup_gma_devprop] Failed initializing dev-prop string dev-entry!\n"); pause(); return false; } @@ -716,7 +716,7 @@ stringdata = malloc(sizeof(uint8_t) * string->length); if (!stringdata) { - printf("No stringdata.\n"); + printf("[setup_gma_devprop] No stringdata!\n"); pause(); return false; } Index: trunk/i386/libsaio/pci_root.c =================================================================== --- trunk/i386/libsaio/pci_root.c (revision 2537) +++ trunk/i386/libsaio/pci_root.c (revision 2538) @@ -97,12 +97,14 @@ fsize = file_size(fd); - if (!(new_dsdt = malloc(fsize))) { + if (!(new_dsdt = malloc(fsize))) + { verbose("[ERROR] alloc DSDT memory failed\n"); close (fd); goto out; } - if (read (fd, new_dsdt, fsize) != fsize) { + if (read (fd, new_dsdt, fsize) != fsize) + { verbose("[ERROR] read %s failed\n", dsdt_filename); free(new_dsdt); close (fd); Index: trunk/i386/libsaio/device_inject.c =================================================================== --- trunk/i386/libsaio/device_inject.c (revision 2537) +++ trunk/i386/libsaio/device_inject.c (revision 2538) @@ -64,13 +64,14 @@ binStr = convertHexStr2Binary(val, &cnt2); if (cnt2 > 0) { DT__AddProperty(node, DEVICE_PROPERTIES_PROP, cnt2, binStr); + DBG("Adding device-properties string to DT"); } } } DevPropString *devprop_create_string(void) { - string = (struct DevPropString*)malloc(sizeof(struct DevPropString)); + string = (struct DevPropString *)malloc(sizeof(struct DevPropString)); if(string == NULL) { return NULL; Index: trunk/i386/libsaio/fdisk.h =================================================================== --- trunk/i386/libsaio/fdisk.h (revision 2537) +++ trunk/i386/libsaio/fdisk.h (revision 2538) @@ -41,22 +41,30 @@ #define DISK_SIGNATURE 0xAA55 /* signature of the boot record */ #define FDISK_NPART 4 /* number of entries in fdisk table */ #define FDISK_ACTIVE 0x80 /* indicator of active partition */ -#define FDISK_NEXTNAME 0xA7 /* indicator of NeXT partition */ + + #define FDISK_DOS12 0x01 /* 12-bit fat < 10MB dos partition */ #define FDISK_DOS16S 0x04 /* 16-bit fat < 32MB dos partition */ #define FDISK_DOSEXT 0x05 /* extended DOS partition */ #define FDISK_DOS16B 0x06 /* 16-bit fat >= 32MB dos partition */ #define FDISK_NTFS 0x07 /* NTFS partition */ -#define FDISK_SMALLFAT32 0x0b /* FAT32 partition */ -#define FDISK_FAT32 0x0c /* FAT32 partition */ -#define FDISK_DOS16SLBA 0x0e /* 16-bit FAT, LBA-mapped */ +#define FDISK_SMALLFAT32 0x0B /* DOS FAT32 partition */ +#define FDISK_FAT32 0x0C /* Win FAT32 partition */ +#define FDISK_DOS16SLBA 0x0E /* Win 16-bit FAT, LBA-mapped */ +#define FDISK_WIN_LDM 0x42 /* NTFS partition */ +#define FDISK_LINUX_SWAP 0x82 /* Linux swap */ #define FDISK_LINUX 0x83 /* Linux native */ -#define FDISK_OPENBSD 0xa6 /* OpenBSD FFS partition */ -#define FDISK_FREEBSD 0xa5 /* FreeBSD UFS2 partition */ -#define FDISK_BEFS 0xeb /* Haiku BeFS partition */ -#define FDISK_UFS 0xa8 /* Apple UFS partition */ -#define FDISK_HFS 0xaf /* Apple HFS partition */ -#define FDISK_BOOTER 0xab /* Apple booter partition */ +#define FDISK_LINUX_LVM 0x8E /* Linux LVM */ +#define FDISK_FREEBSD 0xA5 /* FreeBSD UFS2 partition */ +#define FDISK_OPENBSD 0xA6 /* OpenBSD FFS partition */ +#define FDISK_NEXTNAME 0xA7 /* Indicator of NeXT partition */ +#define FDISK_UFS 0xA8 /* Apple UFS partition */ +#define FDISK_NETBSD 0xA9 /* NetBSD disk label */ +#define FDISK_BOOTER 0xAB /* Apple booter partition */ +#define FDISK_ENCRYPTED 0xAE /* Apple encrypted */ +#define FDISK_HFS 0xAF /* Apple HFS partition */ +#define FDISK_BEFS 0xEB /* Haiku BeFS partition */ +#define FDISK_LINUX_RAID 0xFD /* Linux RAID */ #define FDISK_PSEUDO_EXFAT 0x107 /* Shared with FDISK_NTFS */ /* Index: trunk/i386/libsaio/sys.c =================================================================== --- trunk/i386/libsaio/sys.c (revision 2537) +++ trunk/i386/libsaio/sys.c (revision 2538) @@ -85,7 +85,7 @@ struct devsw { - const char * name; + const char *name; // size increased from char to short to handle non-BIOS internal devices unsigned short biosdev; int type; @@ -385,12 +385,12 @@ // GetFileInfo - LOW-LEVEL FILESYSTEM FUNCTION. // Get attributes for the specified file. -static char* gMakeDirSpec; +static char *gMakeDirSpec; -long GetFileInfo(const char * dirSpec, const char * name, long * flags, u_int32_t * time) +long GetFileInfo(const char *dirSpec, const char *name, long *flags, u_int32_t *time) { long long index = 0; - const char * entryName; + const char *entryName; if (gMakeDirSpec == 0) { @@ -498,10 +498,10 @@ //========================================================================== // openmem() -int openmem(char * buf, int len) +int openmem(char *buf, int len) { int fdesc; - struct iob * io; + struct iob *io; fdesc = GetFreeFd(); io = &iob[fdesc]; @@ -822,16 +822,16 @@ //========================================================================== -struct dirstuff * opendir(const char * path) +struct dirstuff *opendir(const char *path) { - struct dirstuff * dirp = 0; - const char * dirPath; - BVRef bvr; + struct dirstuff *dirp = 0; + const char *dirPath; + BVRef bvr; if ((bvr = getBootVolumeRef(path, &dirPath)) == NULL) goto error; - dirp = (struct dirstuff *) malloc(sizeof(struct dirstuff)); + dirp = (struct dirstuff *)malloc(sizeof(struct dirstuff)); if (dirp == NULL) goto error; @@ -948,7 +948,7 @@ //========================================================================== -BVRef selectBootVolume( BVRef chain ) +BVRef selectBootVolume(BVRef chain) { bool filteredChain = false; bool foundPrimary = false; @@ -963,7 +963,7 @@ { for ( bvr = chain; bvr; bvr = bvr->next ) { - if ( bvr->part_no == multiboot_partition && bvr->biosdev == gBIOSDev ) + if ( (bvr->part_no == multiboot_partition) && (bvr->biosdev == gBIOSDev) ) { return bvr; } @@ -990,7 +990,7 @@ } /* - * Scannig the volume chain backwards and trying to find + * Scannig the volume chain backwards and trying to find * a HFS+ volume with valid boot record signature. * If not found any active partition then we will * select this volume as the boot volume. @@ -1005,26 +1005,26 @@ } } - if ( bvr->flags & kBVFlagPrimary && bvr->biosdev == gBIOSDev ) + if ( (bvr->flags & kBVFlagPrimary) && (bvr->biosdev == gBIOSDev) ) { foundPrimary = true; } // zhell -- Undo a regression that was introduced from r491 to 492. // if gBIOSBootVolume is set already, no change is required - if ( bvr->flags & (kBVFlagBootable|kBVFlagSystemVolume) + if ( (bvr->flags & (kBVFlagBootable | kBVFlagSystemVolume)) && gBIOSBootVolume && (!filteredChain || (filteredChain && bvr->visible)) - && bvr->biosdev == gBIOSDev ) + && (bvr->biosdev == gBIOSDev) ) { bvr2 = bvr; } // zhell -- if gBIOSBootVolume is NOT set, we use the "if" statement // from r491, - if ( bvr->flags & kBVFlagBootable - && ! gBIOSBootVolume - && bvr->biosdev == gBIOSDev ) + if ( (bvr->flags & kBVFlagBootable) + && !gBIOSBootVolume + && (bvr->biosdev == gBIOSDev) ) { bvr2 = bvr; } @@ -1037,11 +1037,11 @@ { 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; } @@ -1102,7 +1102,7 @@ is changed to the selected volume unless the volume selector is that of a ramdisk. */ -BVRef getBootVolumeRef( const char * path, const char ** outPath ) +BVRef getBootVolumeRef(const char *path, const char **outPath) { const char *cp; BVRef bvr = gRootVolume; @@ -1130,8 +1130,8 @@ } else if ((cp - path) == 2) // found "xx(" { - const struct devsw * dp; - const char * xp = path; + const struct devsw *dp; + const char *xp = path; int i; int unit = -1; Index: trunk/i386/libsaio/acpi.h =================================================================== --- trunk/i386/libsaio/acpi.h (revision 2537) +++ trunk/i386/libsaio/acpi.h (revision 2538) @@ -22,11 +22,13 @@ // TODO Migrate struct acpi_2_rsdp { + // 1.0 char Signature[8]; uint8_t Checksum; char OEMID[6]; uint8_t Revision; uint32_t RsdtAddress; + // 2.0 uint32_t Length; uint64_t XsdtAddress; uint8_t ExtendedChecksum; @@ -141,6 +143,7 @@ /* Begin Asere */ //Reset Fix uint32_t Flags; + // Reset Register uint8_t Reset_SpaceID; uint8_t Reset_BitWidth; uint8_t Reset_BitOffset; Index: trunk/i386/libsaio/cpu.c =================================================================== --- trunk/i386/libsaio/cpu.c (revision 2537) +++ trunk/i386/libsaio/cpu.c (revision 2538) @@ -80,8 +80,8 @@ lastValue = timerValue; } while (timerValue > 5); printf("timerValue %d\n",timerValue); - printf("intermediate 0x%016llx\n",intermediate); - printf("saveTime 0x%016llx\n",saveTime); + printf("intermediate 0x%016llX\n",intermediate); + printf("saveTime 0x%016llX\n",saveTime); intermediate -= saveTime; // raw count for about 1/20 second intermediate *= scale[timerValue]; // rescale measured time spent Index: trunk/i386/libsaio/disk.c =================================================================== --- trunk/i386/libsaio/disk.c (revision 2537) +++ trunk/i386/libsaio/disk.c (revision 2538) @@ -89,6 +89,7 @@ #define UFS_FRONT_PORCH 0 #define kAPMSector 2 /* Sector number of Apple partition map */ #define kAPMCDSector 8 /* Translated sector of Apple partition map on a CD */ +#define ECC_CORRECTED_ERR 0x11 /* * IORound and IOTrunc convenience functions, in the spirit @@ -100,7 +101,25 @@ #define IOTrunc(value,multiple) \ (((value) / (multiple)) * (multiple)); +//========================================================================== +// Maps (E)BIOS return codes to message strings. + +struct NamedValue { + unsigned char value; + const char *name; +}; + /* + * Map a disk drive to bootable volumes contained within. + */ +struct DiskBVMap { + int biosdev; // BIOS device number (unique) + BVRef bvr; // chain of boot volumes on the disk + int bvrcnt; // number of boot volumes + struct DiskBVMap *next; // linkage to next mapping +}; + +/* * trackbuf points to the start of the track cache. Biosread() * will store the sectors read from disk to this memory area. * @@ -110,19 +129,9 @@ static char * const trackbuf = (char *) ptov(BIOS_ADDR); static char * biosbuf; -/* - * Map a disk drive to bootable volumes contained within. - */ -struct DiskBVMap { - int biosdev; // BIOS device number (unique) - BVRef bvr; // chain of boot volumes on the disk - int bvrcnt; // number of boot volumes - struct DiskBVMap * next; // linkage to next mapping -}; +static struct DiskBVMap *gDiskBVMap = NULL; +static struct disk_blk0 *gBootSector = NULL; -static struct DiskBVMap * gDiskBVMap = NULL; -static struct disk_blk0 * gBootSector = NULL; - // Function pointers to be filled in if ramdisks are available: int (*p_ramdiskReadBytes)( int biosdev, unsigned int blkno, unsigned int byteoff, @@ -130,7 +139,49 @@ int (*p_get_ramdisk_info)(int biosdev, struct driveInfo *dip) = NULL; static bool getOSVersion(BVRef bvr, char *str); +static bool cache_valid = false; +static const struct NamedValue bios_errors[] = +{ + { 0x10, "Media error" }, + { 0x11, "Corrected ECC error" }, + { 0x20, "Controller or device error" }, + { 0x40, "Seek failed" }, + { 0x80, "Device timeout" }, + { 0xAA, "Drive not ready" }, + { 0x00, NULL } +}; + +static const struct NamedValue fdiskTypes[] = +{ + { FDISK_DOS12, "DOS_FAT_12" }, + { FDISK_DOS16S, "DOS_FAT_16_S" }, + { FDISK_DOS16B, "DOS_FAT_16" }, + { FDISK_NTFS, "Windows NTFS" }, + { FDISK_DOS16SLBA, "Windows FAT16" }, + + { FDISK_FAT32, "Windows FAT32" }, + { FDISK_SMALLFAT32, "Windows FAT32" }, + + { FDISK_LINUX, "Linux" }, + + + { FDISK_FREEBSD, "FreeBSD" }, + { FDISK_OPENBSD, "OpenBSD" }, + { FDISK_NEXTNAME, "Apple_Rhapsody_UFS" }, // 0xA7 + { FDISK_UFS, "Apple UFS" }, + { FDISK_NETBSD, "NetBSD" }, // 0xA9 + { FDISK_BOOTER, "Apple_Boot" }, // 0xAB + { FDISK_ENCRYPTED, "Apple_Encrypted" }, // 0xAE + { FDISK_HFS, "Apple HFS" }, // 0xAF + { 0xCD, "CD-ROM" }, + { FDISK_BEFS, "Haiku" }, // 0xEB + { FDISK_LINUX_RAID, "Linux_RAID" }, // 0xFD + { 0x00, NULL } /* must be last */ +}; + +//============================================================================== + extern void spinActivityIndicator(int sectors); //========================================================================== @@ -182,19 +233,11 @@ } //========================================================================== -// Maps (E)BIOS return codes to message strings. -struct NamedValue { - unsigned char value; - const char * name; -}; - -//========================================================================== - static const char * getNameForValue( const struct NamedValue * nameTable, unsigned char value ) { - const struct NamedValue * np; + const struct NamedValue *np; for ( np = nameTable; np->value; np++) { @@ -207,20 +250,6 @@ return NULL; } -#define ECC_CORRECTED_ERR 0x11 - -static const struct NamedValue bios_errors[] = -{ - { 0x10, "Media error" }, - { 0x11, "Corrected ECC error" }, - { 0x20, "Controller or device error" }, - { 0x40, "Seek failed" }, - { 0x80, "Device timeout" }, - { 0xAA, "Drive not ready" }, - { 0x00, 0 } -}; - - //============================================================================== static const char * bios_error(int errnum) @@ -247,8 +276,6 @@ // Return: // 0 on success, or an error code from INT13/F2 or INT13/F42 BIOS call. -static bool cache_valid = false; - static int Biosread( int biosdev, unsigned long long secno ) { static int xbiosdev, xcyl, xhead; @@ -366,7 +393,6 @@ return rc; } - //============================================================================== int testBiosread(int biosdev, unsigned long long secno) @@ -388,7 +414,7 @@ int error; int copy_len; - DEBUG_DISK(("%s: dev %x block %x [%d] -> 0x%x...", __FUNCTION__, biosdev, blkno, byteCount, (unsigned)cbuf)); + DEBUG_DISK(("%s: dev %X block %X [%d] -> 0x%X...", __FUNCTION__, biosdev, blkno, byteCount, (unsigned)cbuf)); for (; byteCount; cbuf += copy_len, blkno++) { @@ -414,7 +440,7 @@ //============================================================================== -static int isExtendedFDiskPartition( const struct fdisk_part * part ) +static int isExtendedFDiskPartition( const struct fdisk_part *part ) { static unsigned char extParts[] = { @@ -437,16 +463,15 @@ //============================================================================== -static int getNextFDiskPartition( int biosdev, int * partno, - const struct fdisk_part ** outPart ) +static int getNextFDiskPartition( int biosdev, int *partno, const struct fdisk_part **outPart ) { static int sBiosdev = -1; static int sNextPartNo; static unsigned int sFirstBase; static unsigned int sExtBase; static unsigned int sExtDepth; - static struct fdisk_part * sExtPart; - struct fdisk_part * part; + static struct fdisk_part *sExtPart; + struct fdisk_part *part; if ( sBiosdev != biosdev || *partno < 0 ) { @@ -529,9 +554,107 @@ //============================================================================== -static BVRef newFDiskBVRef( int biosdev, int partno, unsigned int blkoff, - const struct fdisk_part * part, - FSInit initFunc, FSLoadFile loadFunc, +/* + * Trying to figure out the filsystem type of a given partition. + * X = fdisk partition type + * 0 = Unknown/Unused + * -1 = error + */ +static int probeFileSystem(int biosdev, unsigned int blkoff) +{ + // detected filesystem type; + int result = -1; + int fatbits = 0; + + // Allocating buffer for 4 sectors. + const void *probeBuffer = malloc(PROBEFS_SIZE); + if (probeBuffer == NULL) + { + goto exit; + } + + // Reading first 4 sectors of current partition + int error = readBytes(biosdev, blkoff, 0, PROBEFS_SIZE, (void *)probeBuffer); + + if (error) + { + goto exit; + } + + if (HFSProbe(probeBuffer)) + { + result = FDISK_HFS; + } + else if (EX2Probe(probeBuffer)) + { + result = FDISK_LINUX; + } + else if (FreeBSDProbe(probeBuffer)) + { + result = FDISK_FREEBSD; + } + + else if (OpenBSDProbe(probeBuffer)) + { + result = FDISK_OPENBSD; + } + + else if (BeFSProbe(probeBuffer)) + { + result = FDISK_BEFS; + } + + else if (NTFSProbe(probeBuffer)) + { + result = FDISK_NTFS; + } + + else if (EXFATProbe(probeBuffer)) + { + result = FDISK_PSEUDO_EXFAT; + } + + else if ((fatbits = MSDOSProbe(probeBuffer))) + { + switch (fatbits) + { + case 12: + result = FDISK_DOS12; + break; + + case 16: + result = FDISK_DOS16B; + break; + + case 32: + default: + result = FDISK_FAT32; + break; + } + } + else + { + // Couldn't detect filesystem type + result = 0; + } + +exit: + if (probeBuffer) + { + free((void *)probeBuffer); + } + + return result; +} + +//============================================================================== + +static BVRef newFDiskBVRef( int biosdev, + int partno, + unsigned int blkoff, + const struct fdisk_part *part, + FSInit initFunc, + FSLoadFile loadFunc, FSReadFile readFunc, FSGetDirEntry getdirFunc, FSGetFileBlock getBlockFunc, @@ -540,7 +663,7 @@ BVFree bvFreeFunc, int probe, int type, unsigned int bvrFlags ) { - BVRef bvr = (BVRef) malloc( sizeof(*bvr) ); + BVRef bvr = (BVRef)malloc(sizeof(*bvr)); if ( bvr ) { bzero(bvr, sizeof(*bvr)); @@ -573,7 +696,7 @@ { // filesystem probe failed. - DEBUG_DISK(("%s: failed probe on dev %x part %d\n", __FUNCTION__, biosdev, partno)); + DEBUG_DISK(("%s: failed probe on dev %X part %d\n", __FUNCTION__, biosdev, partno)); (*bvr->bv_free)(bvr); bvr = NULL; @@ -613,10 +736,12 @@ } } - if (bvr) bvr->flags |= bvrFlags; + if ( bvr ) { - return bvr; + bvr->flags |= bvrFlags; } + + return bvr; } //============================================================================== @@ -632,7 +757,7 @@ BVFree bvFreeFunc, int probe, int type, unsigned int bvrFlags ) { - BVRef bvr = (BVRef) malloc( sizeof(*bvr) ); + BVRef bvr = (BVRef)malloc(sizeof(*bvr)); if ( bvr ) { bzero(bvr, sizeof(*bvr)); @@ -668,7 +793,7 @@ { // filesystem probe failed. - DEBUG_DISK(("%s: failed probe on dev %x part %d\n", __FUNCTION__, biosdev, partno)); + DEBUG_DISK(("%s: failed probe on dev %X part %d\n", __FUNCTION__, biosdev, partno)); (*bvr->bv_free)(bvr); bvr = NULL; @@ -686,10 +811,12 @@ bvr = NULL; } } - if (bvr) + + if ( bvr ) { bvr->flags |= bvrFlags; } + return bvr; } @@ -721,33 +848,38 @@ // same as Apple ZFS //EFI_GUID const GPT_ZFS_GUID = { 0x6A898CC3, 0x1DD2, 0x11B2, { 0x99, 0xA6, 0x08, 0x00, 0x20, 0x73, 0x66, 0x31 } }; // 0xBF01 "Solaris /usr & Apple ZFS -BVRef newGPTBVRef( int biosdev, int partno, unsigned int blkoff, - const gpt_ent * part, - FSInit initFunc, FSLoadFile loadFunc, +BVRef newGPTBVRef( int biosdev, + int partno, + unsigned int blkoff, + const gpt_ent *part, + FSInit initFunc, + FSLoadFile loadFunc, FSReadFile readFunc, FSGetDirEntry getdirFunc, FSGetFileBlock getBlockFunc, FSGetUUID getUUIDFunc, BVGetDescription getDescriptionFunc, BVFree bvFreeFunc, - int probe, int type, unsigned int bvrFlags ) + int probe, + int type, + unsigned int bvrFlags ) { - BVRef bvr = (BVRef) malloc( sizeof(*bvr) ); + BVRef bvr = (BVRef)malloc(sizeof(*bvr)); if ( bvr ) { bzero(bvr, sizeof(*bvr)); - bvr->biosdev = biosdev; - bvr->part_no = partno; - bvr->part_boff = blkoff; - bvr->fs_loadfile = loadFunc; - bvr->fs_readfile = readFunc; - bvr->fs_getdirentry = getdirFunc; - bvr->fs_getfileblock= getBlockFunc; - bvr->fs_getuuid = getUUIDFunc; - bvr->description = getDescriptionFunc; - bvr->type = type; - bvr->bv_free = bvFreeFunc; + bvr->biosdev = biosdev; + bvr->part_no = partno; + bvr->part_boff = blkoff; + bvr->fs_loadfile = loadFunc; + bvr->fs_readfile = readFunc; + bvr->fs_getdirentry = getdirFunc; + bvr->fs_getfileblock = getBlockFunc; + bvr->fs_getuuid = getUUIDFunc; + bvr->description = getDescriptionFunc; + bvr->type = type; + 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) ) @@ -796,10 +928,12 @@ bvr = NULL; } } - if (bvr) + + if ( bvr ) { bvr->flags |= bvrFlags; } + return bvr; } @@ -812,18 +946,18 @@ * one extended partition they will be numbered 1, 2, 5. */ -static BVRef diskScanFDiskBootVolumes( int biosdev, int * countPtr ) +static BVRef diskScanFDiskBootVolumes( int biosdev, int *countPtr ) { - const struct fdisk_part * part; - struct DiskBVMap * map; - int partno = -1; - BVRef bvr; + const struct fdisk_part *part; + struct DiskBVMap *map; + int partno = -1; + BVRef bvr; #if UFS_SUPPORT - BVRef booterUFS = NULL; + BVRef booterUFS = NULL; #endif - int spc; - struct driveInfo di; - boot_drive_info_t *dp; + int spc; + struct driveInfo di; + boot_drive_info_t *dp; /* Initialize disk info */ @@ -841,10 +975,11 @@ spc = 1; } - do { + do + { // Create a new mapping. - map = (struct DiskBVMap *) malloc( sizeof(*map) ); + map = (struct DiskBVMap *)malloc(sizeof(*map)); if ( map ) { map->biosdev = biosdev; @@ -857,8 +992,7 @@ while ( getNextFDiskPartition( biosdev, &partno, &part ) ) { - DEBUG_DISK(("%s: part %d [%x]\n", __FUNCTION__, - partno, part->systid)); + DEBUG_DISK(("%s: part %d [%X]\n", __FUNCTION__, partno, part->systid)); bvr = 0; switch ( part->systid ) @@ -879,166 +1013,173 @@ UFSFree, 0, kBIOSDevTypeHardDrive, 0); - break; + break; #endif - case FDISK_HFS: - bvr = newFDiskBVRef( - biosdev, partno, - part->relsect, - part, - HFSInitPartition, - HFSLoadFile, - HFSReadFile, - HFSGetDirEntry, - HFSGetFileBlock, - HFSGetUUID, - HFSGetDescription, - HFSFree, - 0, - kBIOSDevTypeHardDrive, 0); - break; + case FDISK_HFS: + bvr = newFDiskBVRef( + biosdev, partno, + part->relsect, + part, + HFSInitPartition, + HFSLoadFile, + HFSReadFile, + HFSGetDirEntry, + HFSGetFileBlock, + HFSGetUUID, + HFSGetDescription, + HFSFree, + 0, + kBIOSDevTypeHardDrive, 0); + break; - // turbo - we want the booter type scanned also - case FDISK_BOOTER: - if (part->bootid & FDISK_ACTIVE) - gBIOSBootVolume = newFDiskBVRef( - biosdev, partno, - part->relsect, - part, - HFSInitPartition, - HFSLoadFile, - HFSReadFile, - HFSGetDirEntry, - HFSGetFileBlock, - HFSGetUUID, - HFSGetDescription, - HFSFree, - 0, - kBIOSDevTypeHardDrive, 0); - break; + // turbo - we want the booter type scanned also + case FDISK_BOOTER: + if (part->bootid & FDISK_ACTIVE) + { + gBIOSBootVolume = newFDiskBVRef( + biosdev, partno, + part->relsect, + part, + HFSInitPartition, + HFSLoadFile, + HFSReadFile, + HFSGetDirEntry, + HFSGetFileBlock, + HFSGetUUID, + HFSGetDescription, + HFSFree, + 0, + kBIOSDevTypeHardDrive, 0); + } + break; #if UFS_SUPPORT - case FDISK_BOOTER: - booterUFS = newFDiskBVRef( - biosdev, partno, - ((part->relsect + spc - 1) / spc) * spc, - part, - UFSInitPartition, - UFSLoadFile, - UFSReadFile, - UFSGetDirEntry, - UFSGetFileBlock, - UFSGetUUID, - UFSGetDescription, - UFSFree, - 0, - kBIOSDevTypeHardDrive, 0); - break; + case FDISK_BOOTER: + booterUFS = newFDiskBVRef( + biosdev, partno, + ((part->relsect + spc - 1) / spc) * spc, + part, + UFSInitPartition, + UFSLoadFile, + UFSReadFile, + UFSGetDirEntry, + UFSGetFileBlock, + UFSGetUUID, + UFSGetDescription, + UFSFree, + 0, + kBIOSDevTypeHardDrive, 0); + break; #endif - case FDISK_FAT32: - case FDISK_DOS12: - case FDISK_DOS16S: - case FDISK_DOS16B: - case FDISK_SMALLFAT32: - case FDISK_DOS16SLBA: - bvr = newFDiskBVRef( - biosdev, partno, - part->relsect, - part, - MSDOSInitPartition, - MSDOSLoadFile, - MSDOSReadFile, - MSDOSGetDirEntry, - MSDOSGetFileBlock, - MSDOSGetUUID, - MSDOSGetDescription, - MSDOSFree, - 0, - kBIOSDevTypeHardDrive, 0); - break; + case FDISK_FAT32: + case FDISK_DOS12: + case FDISK_DOS16S: + case FDISK_DOS16B: + case FDISK_SMALLFAT32: + case FDISK_DOS16SLBA: + bvr = newFDiskBVRef( + biosdev, partno, + part->relsect, + part, + MSDOSInitPartition, + MSDOSLoadFile, + MSDOSReadFile, + MSDOSGetDirEntry, + MSDOSGetFileBlock, + MSDOSGetUUID, + MSDOSGetDescription, + MSDOSFree, + 0, + kBIOSDevTypeHardDrive, 0); + break; - case FDISK_NTFS: - bvr = newFDiskBVRef( - biosdev, partno, - part->relsect, - part, - 0, 0, 0, 0, 0, - NTFSGetUUID, - NTFSGetDescription, - (BVFree)free, - 0, kBIOSDevTypeHardDrive, 0); - break; + case FDISK_NTFS: + bvr = newFDiskBVRef( + biosdev, partno, + part->relsect, + part, + 0, 0, 0, 0, 0, + NTFSGetUUID, + NTFSGetDescription, + (BVFree)free, + 0, + kBIOSDevTypeHardDrive, 0); + break; - case FDISK_LINUX: - bvr = newFDiskBVRef( - biosdev, partno, - part->relsect, - part, - 0, 0, 0, 0, 0, - EX2GetUUID, - EX2GetDescription, - (BVFree)free, - 0, kBIOSDevTypeHardDrive, 0); - break; + case FDISK_LINUX: + bvr = newFDiskBVRef( + biosdev, partno, + part->relsect, + part, + 0, 0, 0, 0, 0, + EX2GetUUID, + EX2GetDescription, + (BVFree)free, + 0, + kBIOSDevTypeHardDrive, 0); + break; - case FDISK_BEFS: - bvr = newFDiskBVRef( - biosdev, partno, - part->relsect, - part, - 0, 0, 0, 0, 0, 0, - BeFSGetDescription, - (BVFree)free, - 0, kBIOSDevTypeHardDrive, 0); - break; + case FDISK_BEFS: + bvr = newFDiskBVRef( + biosdev, partno, + part->relsect, + part, + 0, 0, 0, 0, 0, 0, + BeFSGetDescription, + (BVFree)free, + 0, + kBIOSDevTypeHardDrive, 0); + break; - case FDISK_FREEBSD: - bvr = newFDiskBVRef( - biosdev, partno, - part->relsect, - part, - 0, 0, 0, 0, 0, 0, - FreeBSDGetDescription, - (BVFree)free, - 0, kBIOSDevTypeHardDrive, 0); - break; + case FDISK_FREEBSD: + bvr = newFDiskBVRef( + biosdev, partno, + part->relsect, + part, + 0, 0, 0, 0, 0, 0, + FreeBSDGetDescription, + (BVFree)free, + 0, + kBIOSDevTypeHardDrive, 0); + break; - case FDISK_OPENBSD: - bvr = newFDiskBVRef( - biosdev, partno, - part->relsect, - part, - 0, 0, 0, 0, 0, 0, - OpenBSDGetDescription, - (BVFree)free, - 0, kBIOSDevTypeHardDrive, 0); - break; + case FDISK_OPENBSD: + bvr = newFDiskBVRef( + biosdev, partno, + part->relsect, + part, + 0, 0, 0, 0, 0, 0, + OpenBSDGetDescription, + (BVFree)free, + 0, + kBIOSDevTypeHardDrive, 0); + break; - default: - bvr = newFDiskBVRef( - biosdev, partno, - part->relsect, - part, - 0, 0, 0, 0, 0, 0, 0, - (BVFree)free, - 0, - kBIOSDevTypeHardDrive, 0); - break; - } + default: + bvr = newFDiskBVRef( + biosdev, partno, + part->relsect, + part, + 0, 0, 0, 0, 0, 0, 0, + (BVFree)free, + 0, + kBIOSDevTypeHardDrive, 0); + break; + } - if ( bvr ) - { - bvr->next = map->bvr; - map->bvr = bvr; - map->bvrcnt++; - } - } + if ( bvr ) + { + bvr->next = map->bvr; + map->bvr = bvr; + map->bvrcnt++; + } + } #if UFS_SUPPORT - // Booting from a CD with an UFS filesystem embedded - // in a booter partition. + // Booting from a CD with an UFS filesystem embedded + // in a booter partition. if ( booterUFS ) { @@ -1056,11 +1197,11 @@ } } while (0); +#if UNUSED /* * If no FDisk partition, then we will check for * an Apple partition map elsewhere. */ -#if UNUSED if (map && map->bvrcnt == 0) { static struct fdisk_part cdpart; @@ -1088,10 +1229,10 @@ #endif // Actually this should always be true given the above code // (unless malloc failed above) - if(map && map == gDiskBVMap) + if(map && (map == gDiskBVMap)) { // Don't leave a null map in the chain - if(map->bvrcnt == 0 && map->bvr == NULL) + if((map->bvrcnt == 0) && (map->bvr == NULL)) { gDiskBVMap = map->next; free(map); @@ -1101,23 +1242,24 @@ if (countPtr) *countPtr = map ? map->bvrcnt : 0; - return map ? map->bvr : NULL; + return map ? map->bvr : NULL; } //============================================================================== static BVRef diskScanAPMBootVolumes( int biosdev, int * countPtr ) { - struct DiskBVMap * map; - struct Block0 *block0_p; - unsigned int blksize; - unsigned int factor; - void *buffer = malloc(BPS); + struct DiskBVMap *map; + struct Block0 *block0_p; + unsigned int blksize; + unsigned int factor; + void *buffer = malloc(BPS); if (!buffer) { return NULL; } + bzero(buffer,BPS); /* Check for alternate block size */ @@ -1125,6 +1267,7 @@ { return NULL; } + block0_p = buffer; if (OSSwapBigToHostInt16(block0_p->sbSig) == BLOCK0_SIGNATURE) { @@ -1165,7 +1308,7 @@ map->next = gDiskBVMap; gDiskBVMap = map; - for (i=0; idpme_map_entries); } @@ -1210,101 +1353,17 @@ } } while (0); - free(buffer); - - if (countPtr) *countPtr = map ? map->bvrcnt : 0; - - return map ? map->bvr : NULL; -} - -//============================================================================== - -/* - * Trying to figure out the filsystem type of a given partition. - */ -static int probeFileSystem(int biosdev, unsigned int blkoff) -{ - // detected filesystem type; - int result = -1; - int fatbits; - - // Allocating buffer for 4 sectors. - const void * probeBuffer = malloc(PROBEFS_SIZE); - if (probeBuffer == NULL) + if (buffer) { - goto exit; + free(buffer); } - // Reading first 4 sectors of current partition - int error = readBytes(biosdev, blkoff, 0, PROBEFS_SIZE, (void *)probeBuffer); - - if (error) + if (countPtr) { - goto exit; + *countPtr = map ? map->bvrcnt : 0; } - if (HFSProbe(probeBuffer)) - { - result = FDISK_HFS; - } - else if (EX2Probe(probeBuffer)) - { - result = FDISK_LINUX; - } - else if (FreeBSDProbe(probeBuffer)) - { - result = FDISK_FREEBSD; - } - - else if (OpenBSDProbe(probeBuffer)) - { - result = FDISK_OPENBSD; - } - - else if (BeFSProbe(probeBuffer)) - { - result = FDISK_BEFS; - } - - else if (EXFATProbe(probeBuffer)) - { - result = FDISK_PSEUDO_EXFAT; - } - - else if (NTFSProbe(probeBuffer)) - { - result = FDISK_NTFS; - } - - else if ( (fatbits = MSDOSProbe(probeBuffer)) ) - { - switch (fatbits) - { - case 32: - default: - result = FDISK_FAT32; - break; - case 16: - result = FDISK_DOS16B; - break; - case 12: - result = FDISK_DOS12; - break; - } - } - else - { - // Couldn't detect filesystem type - result = 0; - } - -exit: - if (probeBuffer) - { - free((void *)probeBuffer); - } - - return result; + return map ? map->bvr : NULL; } //============================================================================== @@ -1326,7 +1385,8 @@ void *buffer = malloc(BPS); int error; - if ( (error = readBytes( biosdev, /*secno*/0, 0, BPS, buffer )) != 0) + + if ((error = readBytes( biosdev, /*secno*/0, 0, BPS, buffer )) != 0) { verbose("Failed to read boot sector from BIOS device %02xh. Error=%d\n", biosdev, error); goto scanErr; @@ -1374,7 +1434,7 @@ // Determine whether the partition header signature is present. - if ( memcmp(headerMap->hdr_sig, GPT_HDR_SIG, strlen(GPT_HDR_SIG)) ) + if (memcmp(headerMap->hdr_sig, GPT_HDR_SIG, strlen(GPT_HDR_SIG))) { goto scanErr; } @@ -1384,7 +1444,7 @@ UInt32 headerCheck = OSSwapLittleToHostInt32(headerMap->hdr_crc_self); UInt32 headerSize = OSSwapLittleToHostInt32(headerMap->hdr_size); - if ( headerSize < offsetof(gpt_hdr, padding) ) + if (headerSize < offsetof(gpt_hdr, padding)) { goto scanErr; } @@ -1405,12 +1465,12 @@ // Determine whether the partition entry size is valid. - UInt64 gptBlock = 0; - UInt32 gptCheck = 0; - UInt32 gptCount = 0; - UInt32 gptID = 0; - gpt_ent * gptMap = 0; - UInt32 gptSize = 0; + UInt64 gptBlock = 0; + UInt32 gptCheck = 0; + UInt32 gptCount = 0; + UInt32 gptID = 0; + gpt_ent *gptMap = 0; + UInt32 gptSize = 0; gptBlock = OSSwapLittleToHostInt64(headerMap->hdr_lba_table); gptCheck = OSSwapLittleToHostInt32(headerMap->hdr_crc_table); @@ -1458,12 +1518,13 @@ // fdisk like partition type id. int fsType = 0; - for(gptID = 1; gptID <= gptCount; ++gptID) { + for(gptID = 1; gptID <= gptCount; ++gptID) + { BVRef bvr = NULL; unsigned int bvrFlags = 0; // size on disk can be larger than sizeof(gpt_ent) - gptMap = (gpt_ent *) ( buffer + ( (gptID - 1) * gptSize) ); + gptMap = (gpt_ent *)(buffer + ((gptID - 1) * gptSize)); // NOTE: EFI_GUID's are in LE and we know we're on an x86. // The IOGUIDPartitionScheme.cpp code uses byte-based UUIDs, we don't. @@ -1476,27 +1537,28 @@ // Getting fdisk like partition type. fsType = probeFileSystem(biosdev, gptMap->ent_lba_start); - if ( (efi_guid_compare(&GPT_BOOT_GUID, (EFI_GUID const*)gptMap->ent_type) == 0) || (efi_guid_compare(&GPT_HFS_GUID, (EFI_GUID const*)gptMap->ent_type) == 0) ) { - bvrFlags = (efi_guid_compare(&GPT_BOOT_GUID, (EFI_GUID const*)gptMap->ent_type) == 0) ? kBVFlagBooter : 0; - bvr = newGPTBVRef(biosdev, - gptID, - gptMap->ent_lba_start, - gptMap, - HFSInitPartition, - HFSLoadFile, - HFSReadFile, - HFSGetDirEntry, - HFSGetFileBlock, - HFSGetUUID, - HFSGetDescription, - HFSFree, - 0, - kBIOSDevTypeHardDrive, bvrFlags); - } + if ( (efi_guid_compare(&GPT_BOOT_GUID, (EFI_GUID const*)gptMap->ent_type) == 0) || (efi_guid_compare(&GPT_HFS_GUID, (EFI_GUID const*)gptMap->ent_type) == 0) ) { + bvrFlags = (efi_guid_compare(&GPT_BOOT_GUID, (EFI_GUID const*)gptMap->ent_type) == 0) ? kBVFlagBooter : 0; + bvr = newGPTBVRef(biosdev, + gptID, + gptMap->ent_lba_start, + gptMap, + HFSInitPartition, + HFSLoadFile, + HFSReadFile, + HFSGetDirEntry, + HFSGetFileBlock, + HFSGetUUID, + HFSGetDescription, + HFSFree, + 0, + kBIOSDevTypeHardDrive, bvrFlags); + } // zef - foreign OS support - if ( (efi_guid_compare(&GPT_BASICDATA_GUID, (EFI_GUID const*)gptMap->ent_type) == 0) || - (efi_guid_compare(&GPT_BASICDATA2_GUID, (EFI_GUID const*)gptMap->ent_type) == 0) ) { + if ((efi_guid_compare(&GPT_BASICDATA_GUID, (EFI_GUID const*)gptMap->ent_type) == 0) || + (efi_guid_compare(&GPT_BASICDATA2_GUID, (EFI_GUID const*)gptMap->ent_type) == 0) ) + { switch (fsType) { case FDISK_NTFS: @@ -1606,17 +1668,21 @@ } scanErr: - if (buffer) { + if (buffer) + { free(buffer); } - if(map) { + if(map) + { if(countPtr) *countPtr = map->bvrcnt; { return map->bvr; } - } else { + } + else + { if(countPtr) *countPtr = 0; { return NULL; @@ -1686,7 +1752,6 @@ { const char *val; int len; - if (getValueForKey(kProductVersion, &val, &len, &systemVersion)) { // getValueForKey uses const char for val @@ -1757,7 +1822,7 @@ { ret = -1; error = 0; - + // // Check for alternate volume label on boot helper partitions. // @@ -1796,7 +1861,7 @@ if (bvr->flags & kBVFlagNativeBoot) { - if (getOSVersion(bvr,bvr->OSVersion) == true) + if (getOSVersion(bvr, bvr->OSVersion) == true) { bvr->flags |= kBVFlagSystemVolume; } @@ -1897,6 +1962,7 @@ { bvr = diskScanAPMBootVolumes(biosdev, &count); } + if (bvr) { scanFSLevelBVRSettings(bvr); @@ -1906,10 +1972,12 @@ { bvr = map->bvr; } + if (countPtr) { *countPtr += count; } + return bvr; } @@ -2082,28 +2150,6 @@ //============================================================================== -static const struct NamedValue fdiskTypes[] = -{ - { FDISK_NTFS, "Windows NTFS" }, - { FDISK_DOS12, "Windows FAT12" }, - { FDISK_DOS16B, "Windows FAT16" }, - { FDISK_DOS16S, "Windows FAT16" }, - { FDISK_DOS16SLBA, "Windows FAT16" }, - { FDISK_SMALLFAT32, "Windows FAT32" }, - { FDISK_FAT32, "Windows FAT32" }, - { FDISK_FREEBSD, "FreeBSD" }, - { FDISK_OPENBSD, "OpenBSD" }, - { FDISK_LINUX, "Linux" }, - { FDISK_UFS, "Apple UFS" }, - { FDISK_HFS, "Apple HFS" }, - { FDISK_BOOTER, "Apple Boot/UFS" }, - { FDISK_BEFS, "Haiku" }, - { 0xCD, "CD-ROM" }, - { 0x00, 0 } /* must be last */ -}; - -//============================================================================== - bool matchVolumeToString( BVRef bvr, const char* match, long matchLen) { char testStr[128]; @@ -2264,7 +2310,7 @@ if (name == NULL) { - sprintf(p, "TYPE %02x", type); + sprintf(p, "TYPE %02X", type); } else { @@ -2279,16 +2325,16 @@ //============================================================================== -int readBootSector(int biosdev, unsigned int secno, void * buffer) +int readBootSector(int biosdev, unsigned int secno, void *buffer) { int error; - struct disk_blk0 * bootSector = (struct disk_blk0 *) buffer; + struct disk_blk0 * bootSector = (struct disk_blk0 *)buffer; if (bootSector == NULL) { if (gBootSector == NULL) { - gBootSector = (struct disk_blk0 *) malloc(sizeof(*gBootSector)); + gBootSector = (struct disk_blk0 *)malloc(sizeof(*gBootSector)); if (gBootSector == NULL) { @@ -2328,26 +2374,26 @@ //============================================================================== -int testFAT32EFIBootSector( int biosdev, unsigned int secno, void * buffer ) +int testFAT32EFIBootSector(int biosdev, unsigned int secno, void *buffer) { - struct disk_boot1f32_blk * bootSector = (struct disk_boot1f32_blk *) buffer; - int error; + struct disk_boot1f32_blk *bootSector = (struct disk_boot1f32_blk *)buffer; + int error; - if ( bootSector == NULL ) + if (bootSector == NULL) { - if ( gBootSector == NULL ) + if (gBootSector == NULL) { - gBootSector = (struct disk_blk0 *) malloc(sizeof(*gBootSector)); + gBootSector = (struct disk_blk0 *)malloc(sizeof(*gBootSector)); if ( gBootSector == NULL ) { return -1; } } - bootSector = (struct disk_boot1f32_blk *) gBootSector; + bootSector = (struct disk_boot1f32_blk *)gBootSector; } - error = readBytes( biosdev, secno, 0, BPS, bootSector ); - if ( error || bootSector->signature != DISK_SIGNATURE || strncmp((const char *)bootSector->magic, BOOT1F32_MAGIC, BOOT1F32_MAGICLEN) ) + error = readBytes(biosdev, secno, 0, BPS, bootSector); + if (error || bootSector->signature != DISK_SIGNATURE || strncmp((const char *)bootSector->magic, BOOT1F32_MAGIC, BOOT1F32_MAGICLEN) ) { return -1; } @@ -2470,7 +2516,7 @@ int diskIsCDROM(BVRef bvr) { - struct driveInfo di; + struct driveInfo di; if (getDriveInfo(bvr->biosdev, &di) == 0 && di.no_emulation) { @@ -2483,7 +2529,7 @@ int biosDevIsCDROM(int biosdev) { - struct driveInfo di; + struct driveInfo di; if (getDriveInfo(biosdev, &di) == 0 && di.no_emulation) { Index: trunk/i386/libsaio/cpu.h =================================================================== --- trunk/i386/libsaio/cpu.h (revision 2537) +++ trunk/i386/libsaio/cpu.h (revision 2538) @@ -11,7 +11,7 @@ extern void scan_cpu(PlatformInfo_t *); #define bit(n) (1ULL << (n)) -#define bitmask(h,l) ((bit(h)|(bit(h)-1)) & ~(bit(l)-1)) +#define bitmask(h,l) ((bit(h) | (bit(h)-1)) & ~(bit(l)-1)) #define bitfield(x,h,l) (((x) & bitmask(h,l)) >> l) #define CPU_STRING_UNKNOWN "Unknown CPU Type" Index: trunk/i386/libsaio/smbios.c =================================================================== --- trunk/i386/libsaio/smbios.c (revision 2537) +++ trunk/i386/libsaio/smbios.c (revision 2538) @@ -828,7 +828,7 @@ strSize = strlen(string); - // remove any spaces found at the end but only in MemoryDevice + // remove any spaces found at the end but only in MemoryDevice avoiding errors if (structHeader->type == kSMBTypeMemoryDevice) { while ((strSize != 0) && (string[strSize - 1] == ' ')) { strSize--; @@ -1103,7 +1103,7 @@ if (handle < structPtr->orig->handle) { handle = structPtr->orig->handle; } - // Bungo: fix unsuported tables lengths from original smbios: extend smaller or truncate bigger - we use SMBIOS rev. 2.4 like Apple uses + // Bungo: fix unsuported tables lengths from original smbios: extend shorter or truncate longer - we use SMBIOS rev. 2.4 like Apple uses switch (structPtr->orig->type) { case kSMBTypeBIOSInformation: structSize = sizeof(SMBBIOSInformation); @@ -1245,12 +1245,12 @@ ptr = ((SMBSystemInformation *)structHeader)->uuid; - if (!sysId || !ret) { // no or bad custom UUID,... + if (!sysId || !ret) { // no or bad custom uuid,... sysId = 0; - ret = Platform.UUID; // ...try bios dmi system uuid extraction + ret = Platform.UUID; // ...use original (factory) system uuid } - for (i=0, isZero=1, isOnes=1; i" // value out of smbios spec. range -#define PrivateStr "** PRIVATE **" // masking private data -#define neverMask false +#define NotSpecifiedStr "Not Specified" // no string +#define OutOfSpecStr "" // value out of smbios spec. range +#define PrivateStr "** PRIVATE **" // masking private data +#define neverMask false -static bool privateData = true; +static bool privateData = true; static SMBByte minorVersion; // SMBIOS rev. minor static SMBByte majorVersion; // SMBIOS rev. major static SMBByte bcdRevisionLo; // DMI rev. minor @@ -223,18 +223,19 @@ "FBD2" /* 19h FBD2 */ }; -static const int kSMBMemoryDeviceTypeCount = sizeof(SMBMemoryDeviceTypes) / - sizeof(SMBMemoryDeviceTypes[0]); +static const int kSMBMemoryDeviceTypeCount = sizeof(SMBMemoryDeviceTypes) / sizeof(SMBMemoryDeviceTypes[0]); // Bungo: fixes random string readout if null in smbios to "Not Specified" as dmidecode displays char *SMBStringForField(SMBStructHeader *structHeader, uint8_t field, const bool mask) { char *str = NULL; str = getSMBStringForField(structHeader, field); - if (!field) { + if (!field) + { str = NotSpecifiedStr; } - else if (mask) { + else if (mask) + { str = PrivateStr; } @@ -243,7 +244,7 @@ void printHeader(SMBStructHeader *structHeader) { - DBG("Handle: 0x%04x, DMI type %d, %d bytes\n", structHeader->handle, structHeader->type, structHeader->length); + DBG("Handle: 0x%04X, DMI type %d, %d bytes\n", structHeader->handle, structHeader->type, structHeader->length); } //------------------------------------------------------------------------------------------------------------------------- @@ -372,14 +373,17 @@ // DBG("\tSignature: Type %u, Family %u, Model %u, Stepping %u\n", (eax >> 12) & 0x3, ((eax >> 20) & 0xFF) + ((eax >> 8) & 0x0F), ((eax >> 12) & 0xF0) + ((eax >> 4) & 0x0F), eax & 0xF); // Flags: DBG("\tVersion: %s\n", SMBStringForField(structHeader, ((SMBProcessorInformation *)structHeader)->processorVersion, neverMask)); -// DBG("\tVoltage: 0.%xV\n", ((SMBProcessorInformation *)structHeader)->voltage); +// DBG("\tVoltage: 0.%dV\n", ((SMBProcessorInformation *)structHeader)->voltage); DBG("\tExternal Clock: %d MHz\n", ((SMBProcessorInformation *)structHeader)->externalClock); DBG("\tMax Speed: %d MHz\n", ((SMBProcessorInformation *)structHeader)->maximumClock); DBG("\tCurrent Speed: %d MHz\n", ((SMBProcessorInformation *)structHeader)->currentClock); // Status: Populated/Unpopulated - if ((((SMBProcessorInformation *)structHeader)->processorUpgrade < 1) || (((SMBProcessorInformation *)structHeader)->processorUpgrade > 0x2C)) { + if ((((SMBProcessorInformation *)structHeader)->processorUpgrade < 1) || (((SMBProcessorInformation *)structHeader)->processorUpgrade > 0x2C)) + { DBG("\tUpgrade: %s\n", OutOfSpecStr); - } else { + } + else + { DBG("\tUpgrade: %s\n", SMBProcessorUpgrades[((SMBProcessorInformation *)structHeader)->processorUpgrade - 1]); } // L1 Cache Handle: @@ -388,11 +392,18 @@ DBG("\tSerial Number: %s\n", SMBStringForField(structHeader, ((SMBProcessorInformation *)structHeader)->serialNumber, privateData)); DBG("\tAsset Tag: %s\n", SMBStringForField(structHeader, ((SMBProcessorInformation *)structHeader)->assetTag, neverMask)); DBG("\tPart Number: %s\n", SMBStringForField(structHeader, ((SMBProcessorInformation *)structHeader)->partNumber, neverMask)); - if(((SMBProcessorInformation *)structHeader)->coreCount != 0) { - DBG("\tCore Count: %d\n", ((SMBProcessorInformation *)structHeader)->coreCount);} - if(((SMBProcessorInformation *)structHeader)->coreEnabled != 0) { - DBG("\tCore Enabled: %d\n", ((SMBProcessorInformation *)structHeader)->coreEnabled);} - if(((SMBProcessorInformation *)structHeader)->threadCount != 0) { + if(((SMBProcessorInformation *)structHeader)->coreCount != 0) + { + DBG("\tCore Count: %d\n", ((SMBProcessorInformation *)structHeader)->coreCount); + } + + if(((SMBProcessorInformation *)structHeader)->coreEnabled != 0) + { + DBG("\tCore Enabled: %d\n", ((SMBProcessorInformation *)structHeader)->coreEnabled); + } + + if(((SMBProcessorInformation *)structHeader)->threadCount != 0) + { DBG("\tThread Count: %d\n", ((SMBProcessorInformation *)structHeader)->threadCount); } // Characteristics: @@ -533,7 +544,7 @@ { printHeader(structHeader); DBG("Apple specific Processor Type\n"); - DBG("\tCpu-type: 0x%x\n", ((SMBOemProcessorType *)structHeader)->ProcessorType); + DBG("\tCpu-type = 0x%04X\n", ((SMBOemProcessorType *)structHeader)->ProcessorType); DBG("\n"); } Index: trunk/i386/libsaio/smbios.h =================================================================== --- trunk/i386/libsaio/smbios.h (revision 2537) +++ trunk/i386/libsaio/smbios.h (revision 2538) @@ -23,7 +23,6 @@ #ifndef __LIBSAIO_SMBIOS_H #define __LIBSAIO_SMBIOS_H - /* Based on System Management BIOS Reference Specification v2.4 */ // http://dmtf.org/standards/smbios @@ -33,7 +32,6 @@ typedef uint32_t SMBDWord; typedef uint64_t SMBQWord; - typedef struct DMIEntryPoint { SMBByte anchor[5]; @@ -140,7 +138,7 @@ }; //---------------------------------------------------------------------------------------------------------- -// Struct - BIOS Information (Type 0) +// Struct - BIOS Information (Type 0), Apple uses 24 bytes length typedef struct SMBBIOSInformation { SMB_STRUCT_HEADER @@ -160,7 +158,7 @@ } __attribute__((packed)) SMBBIOSInformation; //---------------------------------------------------------------------------------------------------------- -// Struct - System Information (Type 1) +// Struct - System Information (Type 1), Apple uses 27 bytes length typedef struct SMBSystemInformation { // 2.0+ spec (8 bytes) @@ -199,7 +197,7 @@ kSMBBaseBoardInterconnect = 0x0D // Interconnect board } BASE_BOARD_TYPE; -// Struct - Base Board (or Module) Information (Type 2) +// Struct - Base Board (or Module) Information (Type 2), Apple uses 16 bytes length typedef struct SMBBaseBoard { SMB_STRUCT_HEADER // Type 2 @@ -268,7 +266,7 @@ kSMBChassisSecurityStatusExternalInterfaceLockedEnabled = 0x05 } MISC_CHASSIS_SECURITY_STATE; -// Struct - System Enclosure (Type 3) +// Struct - System Enclosure (Type 3), Apple uses 21 bytes length typedef struct SMBSystemEnclosure { SMB_STRUCT_HEADER // Type 3 @@ -287,7 +285,8 @@ SMBByte containedElementCount; // Number of Contained Element record that follow, in the range 0 to 255 // SMBByte containedElementRecord; // Byte leght of each Contained Element record that follow, in the range 0 to 255 // SMBByte containedElements; // Elements, possibly defined by other SMBIOS structures present in chassis - // SMBString skuNumber; // Number of null-terminated string describing the chassis or enclosure SKU number (2.7+) + // 2.7+ + // SMBString skuNumber; // Number of null-terminated string describing the chassis or enclosure SKU number } __attribute__((packed)) SMBSystemEnclosure; //---------------------------------------------------------------------------------------------------------- @@ -542,7 +541,7 @@ kSMBprocessorUpgradeSocketFM2 = 0x2A } PROCESSOR_UPGRADE; -// Struct - Processor Information (Type 4). +// Struct - Processor Information (Type 4), Apple uses 35 bytes length typedef struct SMBProcessorInformation { // 2.0+ spec (26 bytes) @@ -610,7 +609,7 @@ #define kSMBMemoryModuleSizeNotInstalled 0x7F //---------------------------------------------------------------------------------------------------------- -// Struct - Cache Information (Type 7) +// Struct - Cache Information (Type 7), Apple uses 19 bytes length typedef struct SMBCacheInformation { SMB_STRUCT_HEADER // Type 7 @@ -627,7 +626,7 @@ } __attribute__((packed)) SMBCacheInformation; //---------------------------------------------------------------------------------------------------------- -// Struct - System Slots (Type 9) +// Struct - System Slots (Type 9), Apple uses 13 bytes length typedef struct SMBSystemSlot { // 2.0+ spec (12 bytes) @@ -648,7 +647,7 @@ } __attribute__((packed)) SMBSystemSlot; //---------------------------------------------------------------------------------------------------------- -// Struct - OEM Strings (Type 11) +// Struct - OEM Strings (Type 11), Apple uses 5 bytes length typedef struct SMBOEMStrings { SMB_STRUCT_HEADER // Type 11 @@ -684,7 +683,7 @@ kSMBMemoryArrayErrorCorrectionTypeCRC = 0x07 } MEMORY_ERROR_CORRECTION; -// Struct - Physical Memory Array (Type 16) +// Struct - Physical Memory Array (Type 16), Apple uses 15 bytes length typedef struct SMBPhysicalMemoryArray { // 2.1+ spec (15 bytes) @@ -700,7 +699,7 @@ } __attribute__((packed)) SMBPhysicalMemoryArray; //---------------------------------------------------------------------------------------------------------- -// Struct - Memory Device (Type 17) +// Struct - Memory Device (Type 17), Apple uses 27 bytes length typedef struct SMBMemoryDevice { // 2.1+ spec (21 bytes) @@ -735,7 +734,7 @@ //---------------------------------------------------------------------------------------------------------- -// Struct - Memory Array Mapped Address (Type 19) +// Struct - Memory Array Mapped Address (Type 19), Apple uses 15 bytes length //typedef struct SMBMemoryArrayMappedAddress //{ // 2.1+ spec @@ -787,7 +786,7 @@ SMBDWord EndAddress; } __attribute__((packed)) FW_REGION_INFO; -// Struct - Firmware Volume Description (Apple Specific - Type 128) +// Struct - Firmware Volume Description (Apple Specific - Type 128), Apple uses 88 bytes length typedef struct SMBFirmwareVolume { SMB_STRUCT_HEADER // Type 128 @@ -861,5 +860,4 @@ extern void decodeSMBIOSTable(SMBEntryPoint *eps); - #endif /* !__LIBSAIO_SMBIOS_H */ Index: trunk/i386/libsaio/pci.c =================================================================== --- trunk/i386/libsaio/pci.c (revision 2537) +++ trunk/i386/libsaio/pci.c (revision 2538) @@ -159,6 +159,7 @@ } static char dev_path[256]; + char *get_pci_dev_path(pci_dt_t *pci_dt) { pci_dt_t *current; Index: trunk/i386/libsaio/stringTable.c =================================================================== --- trunk/i386/libsaio/stringTable.c (revision 2537) +++ trunk/i386/libsaio/stringTable.c (revision 2538) @@ -332,11 +332,12 @@ } /* Return NULL if no option has been successfully retrieved, or the string otherwise */ -const char * getStringForKey(const char * key, config_file_t *config) +const char *getStringForKey(const char *key, config_file_t *config) { - static const char* value =0; - int len=0; - if(!getValueForKey(key, &value, &len, config)) { + static const char *value = 0; + int len = 0; + if (!getValueForKey(key, &value, &len, config)) + { value = 0; } return value; @@ -347,15 +348,19 @@ * The boolean value of the key is stored in 'val'. */ -bool getBoolForKey( const char *key, bool *result_val, config_file_t *config ) +bool getBoolForKey(const char *key, bool *result_val, config_file_t *config) { const char *key_val; int size; - if (getValueForKey(key, &key_val, &size, config)) { - if ( (size >= 1) && (key_val[0] == 'Y' || key_val[0] == 'y') ) { + if (getValueForKey(key, &key_val, &size, config)) + { + if ((size >= 1) && (key_val[0] == 'Y' || key_val[0] == 'y')) + { *result_val = true; - } else { + } + else + { *result_val = false; } return true; @@ -363,14 +368,14 @@ return false; } -bool getIntForKey( const char *key, int *value, config_file_t *config ) +bool getIntForKey(const char *key, int *value, config_file_t *config) { const char *val; int size, sum; bool negative = false; if (getValueForKey(key, &val, &size, config)) { - if ( size ) { + if (size) { if (*val == '-') { negative = true; val++; @@ -508,7 +513,7 @@ if (override) { *val = overrideVal; *size = overrideSize; - return true; + ret = true; } } } @@ -547,7 +552,7 @@ // (and does not modify dict pointer). // Prints an error message if there is a parsing error. // -int ParseXMLFile( char * buffer, TagPtr * dict ) +int ParseXMLFile( char *buffer, TagPtr *dict ) { long length, pos; TagPtr tag; @@ -617,7 +622,7 @@ "/Mac OS X Install Data/com.apple.Boot.plist", // OS X Installer (Lion 10.7) "/OS X Install Data/com.apple.Boot.plist", // OS X Installer (10.8+) "/.IABootFiles/com.apple.Boot.plist", // OS X Installer - "/Library/Preferences/SystemConfiguration/com.apple.Boot.plist", // com.boot.Apple.plist + "/Library/Preferences/SystemConfiguration/com.apple.Boot.plist", // com.apple.Boot.plist "/com.apple.recovery.boot/com.apple.Boot.plist" // OS X Recovery }; Index: trunk/i386/libsaio/convert.c =================================================================== --- trunk/i386/libsaio/convert.c (revision 2537) +++ trunk/i386/libsaio/convert.c (revision 2538) @@ -29,20 +29,20 @@ char *p = (char *)source; int i; char buf[3]; - static EFI_CHAR8 uuid[UUID_LEN+1]=""; + static EFI_CHAR8 uuid[UUID_LEN+1] = ""; buf[2] = '\0'; - for (i=0; iDSDT; + struct acpi_2_dsdt *dsdt = (void *)fadt->DSDT; if (dsdt == NULL) { Index: trunk/i386/libsaio/fake_efi.c =================================================================== --- trunk/i386/libsaio/fake_efi.c (revision 2537) +++ trunk/i386/libsaio/fake_efi.c (revision 2538) @@ -123,7 +123,7 @@ // We only do adds, not modifications and deletes like InstallConfigurationTable if (i >= MAX_CONFIGURATION_TABLE_ENTRIES) { - stop("Ran out of space for configuration tables. Increase the reserved size in the code.\n"); + stop("Fake EFI [ERROR]: Ran out of space for configuration tables [%d]. Increase the reserved size in the code.\n", i); } if (pGuid == NULL) @@ -142,7 +142,7 @@ Node *tableNode = DT__AddChild(gEfiConfigurationTableNode, mallocStringForGuid(pGuid)); // Use the pointer to the GUID we just stuffed into the system table - DT__AddProperty(tableNode, "guid", sizeof(EFI_GUID), (void*)pGuid); + DT__AddProperty(tableNode, "guid", sizeof(EFI_GUID), (void *)pGuid); // The "table" property is the 32-bit (in our implementation) physical address of the table DT__AddProperty(tableNode, "table", sizeof(void*) * 2, table); @@ -551,15 +551,15 @@ */ /* - * Must be called AFTER setup Acpi because we need to take care of correct - * facp content to reflect in ioregs + * Must be called AFTER setupAcpi because we need to take care of correct + * FACP content to reflect in ioregs */ void setupSystemType() { Node *node = DT__FindNode("/", false); if (node == 0) { - stop("Couldn't get root node"); + stop("Couldn't get root '/' node"); } // we need to write this property after facp parsing // Export system-type only if it has been overrriden by the SystemType option @@ -676,7 +676,7 @@ node = DT__FindNode("/", false); if (node == 0) { - stop("Couldn't get root node"); + stop("Couldn't get root '/' node"); } const char *boardid = getStringForKey("SMboardproduct", &bootInfo->smbiosConfig); if (boardid) @@ -695,7 +695,7 @@ chosenNode = DT__FindNode("/chosen", false); if (chosenNode == 0) { - stop("Couldn't get chosen node"); + stop("setupChosenNode: Couldn't get '/chosen' node"); } int length = strlen(gBootUUIDString); Index: trunk/i386/libsaio/smbios_getters.c =================================================================== --- trunk/i386/libsaio/smbios_getters.c (revision 2537) +++ trunk/i386/libsaio/smbios_getters.c (revision 2538) @@ -31,7 +31,6 @@ switch (Platform.CPU.Family) { case 0x06: - { switch (Platform.CPU.Model) { // set external clock to 0 for SANDY @@ -49,12 +48,13 @@ break; default: value->word = (uint16_t)(Platform.CPU.FSBFrequency/1000000LL); + break; } - } break; default: value->word = (uint16_t)(Platform.CPU.FSBFrequency/1000000LL); + break; } } else @@ -78,7 +78,6 @@ switch (Platform.CPU.Family) { case 0x06: - { switch (Platform.CPU.Model) { case CPUID_MODEL_PENTIUM_M: @@ -138,15 +137,19 @@ value->word = qpibusspeed; return true; } + break; + default: - break; //Unsupported CPU type + break; } - } + break; + default: break; } } - return false; + + return false; //Unsupported CPU type } uint16_t simpleGetSMBOemProcessorType(void) @@ -181,7 +184,7 @@ { case 0x0F: case 0x06: - { + switch (Platform.CPU.Model) { case CPUID_MODEL_PENTIUM_M: @@ -381,7 +384,8 @@ default: break; // Unsupported CPU type } - } + break; + default: break; } Index: trunk/i386/libsaio/state_generator.h =================================================================== --- trunk/i386/libsaio/state_generator.h (revision 2537) +++ trunk/i386/libsaio/state_generator.h (revision 2538) @@ -15,8 +15,8 @@ #include "aml_generator.h" #include "libsaio.h" -void get_acpi_cpu_names(uint8_t* dsdt, uint32_t length); -struct acpi_2_ssdt *generate_cst_ssdt(struct acpi_2_fadt* fadt); -struct acpi_2_ssdt *generate_pss_ssdt(struct acpi_2_dsdt* dsdt); +void get_acpi_cpu_names(uint8_t *dsdt, uint32_t length); +struct acpi_2_ssdt *generate_cst_ssdt(struct acpi_2_fadt *fadt); +struct acpi_2_ssdt *generate_pss_ssdt(struct acpi_2_dsdt *dsdt); #endif /* !__LIBSAIO_STATE_GENERATOR_H */ Index: trunk/i386/include/IOKit/storage/IOFDiskPartitionScheme.h =================================================================== --- trunk/i386/include/IOKit/storage/IOFDiskPartitionScheme.h (revision 2537) +++ trunk/i386/include/IOKit/storage/IOFDiskPartitionScheme.h (revision 2538) @@ -56,7 +56,7 @@ UInt8 beghead; /* (beginning head) */ UInt8 begsect; /* (beginning sector; beginning cylinder, high 2 bits) */ UInt8 begcyl; /* (beginning cylinder, low 8 bits) */ - UInt8 systid; /* (type) */ + UInt8 systid; /* (OS type) */ UInt8 endhead; /* (ending head) */ UInt8 endsect; /* (ending sector; ending cylinder, high 2 bits) */ UInt8 endcyl; /* (ending cylinder, low 8 bits) */ Index: trunk/i386/boot2/graphics.c =================================================================== --- trunk/i386/boot2/graphics.c (revision 2537) +++ trunk/i386/boot2/graphics.c (revision 2538) @@ -279,6 +279,7 @@ // Get mode information. bzero( &modeInfo, sizeof(modeInfo) ); + err = getVBEModeInfo( *modePtr, &modeInfo ); if ( err != errSuccess ) { @@ -427,23 +428,23 @@ unsigned char bitsPerPixel, unsigned short refreshRate ) { - VBEModeInfoBlock minfo; - unsigned short mode; - unsigned short vesaVersion; - int err = errFuncNotSupported; + VBEModeInfoBlock minfo; + unsigned short mode; + unsigned short vesaVersion; + int err = errFuncNotSupported; - do { - mode = getVESAModeWithProperties( width, height, bitsPerPixel, + do { + mode = getVESAModeWithProperties( width, height, bitsPerPixel, maColorModeBit | maModeIsSupportedBit | maGraphicsModeBit | maLinearFrameBufferAvailBit, 0, &minfo, &vesaVersion ); - if ( mode == modeEndOfList ) - { - break; - } + if ( mode == modeEndOfList ) + { + break; + } // // FIXME : generateCRTCTiming() causes crash. @@ -484,9 +485,9 @@ // Set the mode with default refresh rate. - err = setVBEMode( mode | kLinearFrameBufferBit, NULL ); + err = setVBEMode(mode | kLinearFrameBufferBit, NULL); - if ( err != errSuccess ) + if (err != errSuccess) { break; } @@ -520,8 +521,7 @@ bootArgs->Video.v_rowBytes = minfo.BytesPerScanline; bootArgs->Video.v_baseAddr = VBEMakeUInt32(minfo.PhysBasePtr); - } - while ( 0 ); + } while ( 0 ); return err; } @@ -1120,28 +1120,29 @@ unsigned long numbers[], unsigned long maxArrayCount ) { - char * propStr; - unsigned long count = 0; + char *propStr; + unsigned long count = 0; - propStr = newStringForKey( (char *) propKey , &bootInfo->chameleonConfig ); - if ( propStr ) + propStr = newStringForKey((char *)propKey , &bootInfo->chameleonConfig); + + if (propStr) { - char * delimiter = propStr; - char * p = propStr; + char *delimiter = propStr; + char *p = propStr; - while ( count < maxArrayCount && *p != '\0' ) + while ((count < maxArrayCount) && (*p != '\0')) { - unsigned long val = strtoul( p, &delimiter, 10 ); - if ( p != delimiter ) + unsigned long val = strtoul(p, &delimiter, 10); + if (p != delimiter) { numbers[count++] = val; p = delimiter; } - while ( ( *p != '\0' ) && !isdigit(*p) ) + while ((*p != '\0') && !isdigit(*p)) p++; } - free( propStr ); + free(propStr); } return count; @@ -1163,7 +1164,7 @@ // Use the default resolution if we don't have an initialized GUI. if (gui.screen.width == 0 || gui.screen.height == 0) { - gui.screen.width = DEFAULT_SCREEN_WIDTH; + gui.screen.width = DEFAULT_SCREEN_WIDTH; gui.screen.height = DEFAULT_SCREEN_HEIGHT; } @@ -1183,7 +1184,7 @@ if ( params[2] == 888 ) params[2] = 32; - return setVESAGraphicsMode( params[0], params[1], params[2], params[3] ); + return setVESAGraphicsMode( params[0], params[1], params[2], params[3] ); } //========================================================================== @@ -1199,7 +1200,7 @@ if ( mode == GRAPHICS_MODE ) { - if ( (err=initGraphicsMode ()) == errSuccess ) + if ( (err = initGraphicsMode()) == errSuccess ) { if (gVerboseMode) { @@ -1215,14 +1216,14 @@ if ( (mode == VGA_TEXT_MODE) || (err != errSuccess) ) { - count = getNumberArrayFromProperty( kTextModeKey, params, 2 ); + count = getNumberArrayFromProperty(kTextModeKey, params, 2); if ( count < 2 ) { params[0] = 80; // Default text mode is 80x25. params[1] = 25; } - setVESATextMode( params[0], params[1], 4 ); + setVESATextMode(params[0], params[1], 4); bootArgs->Video.v_display = VGA_TEXT_MODE; } @@ -1239,15 +1240,15 @@ unsigned short vesaVersion; unsigned short mode = modeEndOfList; - getNumberArrayFromProperty( kGraphicsModeKey, params, 4); + getNumberArrayFromProperty(kGraphicsModeKey, params, 4); - mode = getVESAModeWithProperties( params[0], params[1], params[2], + mode = getVESAModeWithProperties(params[0], params[1], params[2], maColorModeBit | maModeIsSupportedBit | maGraphicsModeBit | maLinearFrameBufferAvailBit, 0, - &minfo, &vesaVersion ); + &minfo, &vesaVersion); params[0] = minfo.XResolution; params[1] = minfo.YResolution; Index: trunk/i386/boot2/drivers.c =================================================================== --- trunk/i386/boot2/drivers.c (revision 2537) +++ trunk/i386/boot2/drivers.c (revision 2538) @@ -110,15 +110,17 @@ static long InitDriverSupport(void); ModulePtr gModuleHead, gModuleTail; -static TagPtr gPersonalityHead, gPersonalityTail; -static char * gExtensionsSpec; -static char * gDriverSpec; -static char * gFileSpec; -static char * gTempSpec; -static char * gFileName; +static TagPtr gPersonalityHead, gPersonalityTail; +static char *gExtensionsSpec; +static char *gDriverSpec; +static char *gFileSpec; +static char *gTempSpec; +static char *gFileName; +// Bungo +char *gDarwinBuildVerStr = "Darwin Kernel Version"; /*static*/ unsigned long -Adler32( unsigned char * buffer, long length ) +Adler32( unsigned char *buffer, long length ) { long cnt; unsigned long result, lowHalf, highHalf; @@ -186,7 +188,7 @@ { if (NetLoadDrivers(dirSpec) != 0) { - error("Could not load drivers from the network\n"); + error("LoadDrivers: Could not load drivers from the network\n"); return -1; } } @@ -238,7 +240,7 @@ if (gMKextName[0] != '\0') { - verbose("LoadDrivers: Loading from [%s]\n", gMKextName); + verbose("LoadDrivers: Loading from '%s'\n", gMKextName); if ( LoadDriverMKext(gMKextName) != 0 ) { error("Could not load %s\n", gMKextName); @@ -295,7 +297,7 @@ || (((gBootMode & kBootModeSafe) == 0) && (time == (time2 + 1)))) { snprintf(gDriverSpec, sizeof(altDirSpec) + 18, "%sExtensions.mkext", altDirSpec); - verbose("LoadDrivers: Loading from [%s]\n", gDriverSpec); + verbose("LoadDrivers: Loading from '%s'\n", gDriverSpec); if (LoadDriverMKext(gDriverSpec) == 0) { @@ -877,12 +879,10 @@ static char gPlatformName[64]; #endif -char *gDarwinBuildVerStr = "Darwin Kernel Version"; // Bungo - long DecodeKernel(void *binary, entry_t *rentry, char **raddr, int *rsize) { long ret = 0; - compressed_kernel_header * kernel_header = (compressed_kernel_header *) binary; + compressed_kernel_header *kernel_header = (compressed_kernel_header *)binary; u_int32_t uncompressed_size = 0, size = 0, adler32 = 0; void *buffer = NULL; unsigned long len = 0; @@ -899,7 +899,7 @@ if (kernel_header->signature == OSSwapBigToHostConstInt32('comp')) { - DBG("Decompressing Kernel: "); + DBG("Decompressing Kernel Cache"); if ((kernel_header->compress_type != OSSwapBigToHostConstInt32('lzss')) && (kernel_header->compress_type != OSSwapBigToHostConstInt32('lzvn'))) @@ -912,12 +912,10 @@ { verbose ("Decompressing Kernel Using lzss\n"); } - else + + if (kernel_header->compress_type == OSSwapBigToHostConstInt32('lzvn')) { - if (kernel_header->compress_type == OSSwapBigToHostConstInt32('lzvn')) - { - verbose ("Decompressing Kernel Using lzvn\n"); - } + verbose ("Decompressing Kernel Using lzvn\n"); } #if NOTDEF @@ -939,11 +937,11 @@ switch (kernel_header->compress_type) { case OSSwapBigToHostConstInt32('lzvn'): - size = lzvn_decode( binary, uncompressed_size, &kernel_header->data[0], OSSwapBigToHostInt32(kernel_header->compressed_size)); + size = lzvn_decode(binary, uncompressed_size, &kernel_header->data[0], OSSwapBigToHostInt32(kernel_header->compressed_size)); break; case OSSwapBigToHostConstInt32('lzss'): - size = decompress_lzss( (u_int8_t *)binary, uncompressed_size, &kernel_header->data[0], OSSwapBigToHostInt32(kernel_header->compressed_size)); + size = decompress_lzss((u_int8_t *)binary, uncompressed_size, &kernel_header->data[0], OSSwapBigToHostInt32(kernel_header->compressed_size)); break; default: @@ -955,12 +953,12 @@ { if ( kernel_header->compress_type == OSSwapBigToHostConstInt32('lzvn')) { - error("ERROR: size mismatch from lzvn (found: %x, expected: %x).\n", size, uncompressed_size); + error("ERROR! Size mismatch from lzvn (found: %x, expected: %x).\n", size, uncompressed_size); } if ( kernel_header->compress_type == OSSwapBigToHostConstInt32('lzss')) { - error("ERROR: size mismatch from lzss (found: %x, expected: %x).\n", size, uncompressed_size); + error("ERROR! size mismatch from lzss (found: %x, expected: %x).\n", size, uncompressed_size); } return -1; @@ -969,7 +967,7 @@ adler32 = Adler32(binary, uncompressed_size); if (OSSwapBigToHostInt32(kernel_header->adler32) != adler32) { - error("ERROR: adler mismatch (found: %x, expected: %x).\n", adler32, OSSwapBigToHostInt32(kernel_header->adler32)); + error("ERROR! Adler mismatch (found: %X, expected: %X).\n", adler32, OSSwapBigToHostInt32(kernel_header->adler32)); return -1; } @@ -991,7 +989,7 @@ gDarwinBuildVerStr = (char *)binary + size; // Notify modules that the kernel has been decompressed, thinned and is about to be decoded - execute_hook("DecodeKernel", (void*)binary, NULL, NULL, NULL); + execute_hook("DecodeKernel", (void *)binary, NULL, NULL, NULL); ret = DecodeMachO(binary, rentry, raddr, rsize); if (ret < 0 && archCpuType == CPU_TYPE_X86_64) Index: trunk/i386/boot2/boot.c =================================================================== --- trunk/i386/boot2/boot.c (revision 2537) +++ trunk/i386/boot2/boot.c (revision 2538) @@ -93,7 +93,6 @@ extern char* msgbuf; void showTextBuffer(char *buf, int size); - //========================================================================== // Zero the BSS. @@ -127,7 +126,7 @@ } //========================================================================== -// execKernel - Load the kernel image (mach-o) and jump to its entry point. +// ExecKernel - Load the kernel image (mach-o) and jump to its entry point. static int ExecKernel(void *binary) { @@ -135,12 +134,12 @@ entry_t kernelEntry; bootArgs->kaddr = bootArgs->ksize = 0; - execute_hook("ExecKernel", (void*)binary, NULL, NULL, NULL); + execute_hook("ExecKernel", (void *)binary, NULL, NULL, NULL); ret = DecodeKernel(binary, &kernelEntry, (char **) &bootArgs->kaddr, - (int *)&bootArgs->ksize ); + (int *)&bootArgs->ksize); if ( ret != 0 ) { @@ -151,7 +150,7 @@ reserveKernBootStruct(); // Notify modules that the kernel has been decoded - execute_hook("DecodedKernel", (void*)binary, (void*)bootArgs->kaddr, (void*)bootArgs->ksize, NULL); + execute_hook("DecodedKernel", (void *)binary, (void *)bootArgs->kaddr, (void *)bootArgs->ksize, NULL); setupFakeEfi(); @@ -161,7 +160,7 @@ LoadDrivers("/"); } - execute_hook("DriversLoaded", (void*)binary, NULL, NULL, NULL); + execute_hook("DriversLoaded", (void *)binary, NULL, NULL, NULL); clearActivityIndicator(); @@ -180,7 +179,7 @@ { if ( (ret = nbpUnloadBaseCode()) != nbpStatusSuccess ) { - printf("nbpUnloadBaseCode error %d\n", (int) ret); + printf("nbpUnloadBaseCode error %d\n", (int)ret); sleep(2); } } @@ -198,7 +197,7 @@ // verbose mode. if (gVerboseMode) { - setVideoMode( GRAPHICS_MODE, 0 ); + setVideoMode(GRAPHICS_MODE, 0); } else { @@ -224,7 +223,7 @@ else { // Notify modules that the kernel is about to be started - execute_hook("Kernel Start", (void*)kernelEntry, (void*)bootArgs, NULL, NULL); + execute_hook("Kernel Start", (void *)kernelEntry, (void *)bootArgs, NULL, NULL); // Masking out so that Lion doesn't doublefault outb(0x21, 0xff); /* Maskout all interrupts Pic1 */ @@ -259,7 +258,7 @@ if (cacheFile[0] != 0) { strlcpy(kernelCacheFile, cacheFile, sizeof(kernelCacheFile)); - verbose("Specified kernel cache file path = %s\n", cacheFile); + verbose("Specified kernel cache file path: %s\n", cacheFile); } else { @@ -271,7 +270,7 @@ snprintf(gCacheNameAdler + 64, sizeof(gCacheNameAdler) - 64, "%s,%s", gRootDevice, bootInfo->bootFile); adler32 = Adler32((unsigned char *)gCacheNameAdler, sizeof(gCacheNameAdler)); snprintf(kernelCacheFile, sizeof(kernelCacheFile), "%s.%08lX", kDefaultCachePathLeo, adler32); - verbose("Reseted kernel cache file path = %s\n", kernelCacheFile); + verbose("Reseted kernel cache file path: %s\n", kernelCacheFile);; } // Snow Leopard prelink kernel cache file else if ( SNOW_LEOPARD ) @@ -279,32 +278,34 @@ snprintf(kernelCacheFile, sizeof(kernelCacheFile), "kernelcache_%s", (archCpuType == CPU_TYPE_I386) ? "i386" : "x86_64"); - int lnam = strlen(kernelCacheFile) + 9; //with adler32 - char *name; - u_int32_t prev_time = 0; + int lnam = strlen(kernelCacheFile) + 9; //with adler32 + char *name; + u_int32_t prev_time = 0; - struct dirstuff* cacheDir = opendir(kDefaultCachePathSnow); + struct dirstuff* cacheDir = opendir(kDefaultCachePathSnow); - /* TODO: handle error? */ - if (cacheDir) - { - while(readdir(cacheDir, (const char**)&name, &flags, &time) >= 0) + /* TODO: handle error? */ + if (cacheDir) { - if (((flags & kFileTypeMask) != kFileTypeDirectory) && time > prev_time - && strstr(name, kernelCacheFile) && (name[lnam] != '.')) + while(readdir(cacheDir, (const char**)&name, &flags, &time) >= 0) { - snprintf(kernelCacheFile, sizeof(kernelCacheFile), "%s%s", kDefaultCachePathSnow, name); - prev_time = time; + if (((flags & kFileTypeMask) != kFileTypeDirectory) && time > prev_time + && strstr(name, kernelCacheFile) && (name[lnam] != '.')) + { + snprintf(kernelCacheFile, sizeof(kernelCacheFile), "%s%s", kDefaultCachePathSnow, name); + prev_time = time; + } } + verbose("Kernel Cache file path (Mac OS X 10.6.X): %s\n", kernelCacheFile); } - verbose("Snow Leopard kernel cache file path = %s\n", kernelCacheFile); + closedir(cacheDir); } - closedir(cacheDir); - } else { + else + { // Lion, Mountain Lion, Mavericks, and Yosemite prelink kernel cache file // for 10.7 10.8 10.9 10.10 snprintf(kernelCacheFile, sizeof(kernelCacheFile), "%skernelcache", kDefaultCachePathSnow); - verbose("10.7, 10.8, 10.9 & 10.10 kernel cache file path = %s\n", kernelCacheFile); + verbose("Kernel Cache file path (Mac OS X 10.7 and newer): %s\n", kernelCacheFile);; } } @@ -367,7 +368,7 @@ // Check if the kernel file is more recent than the cache file if ((ret == 0) && ((flags & kFileTypeMask) == kFileTypeFlat) && (kerneltime > cachetime)) { - DBG("Kernel file (%s) is more recent than Kernel Cache (%s)! Ignoring Kernel Cache.\n", bootInfo->bootFile, kernelCacheFile); + DBG("Kernel file '%s' is more recent than Kernel Cache '%s'! Ignoring Kernel Cache.\n", bootInfo->bootFile, kernelCacheFile); return -1; } @@ -376,12 +377,12 @@ // Check if the S/L/E directory time is more recent than the cache file if ((ret == 0) && ((flags & kFileTypeMask) == kFileTypeDirectory) && (exttime > cachetime)) { - DBG("Folder: '/System/Library/Extensions' is more recent than Kernel Cache file (%s)! Ignoring Kernel Cache.\n", kernelCacheFile); + DBG("Folder '/System/Library/Extensions' is more recent than Kernel Cache file '%s'! Ignoring Kernel Cache.\n", kernelCacheFile); return -1; } // Since the kernel cache file exists and is the most recent try to load it - DBG("Loading kernel cache: '%s'\n", kernelCachePath); + DBG("Loading Kernel Cache from: '%s'\n", kernelCachePath); ret = LoadThinFatFile(kernelCachePath, binary); return ret; // ret contain the length of the binary @@ -478,8 +479,10 @@ gEnableCDROMRescan = true; } + // Disable rescanPrompt option by default + rescanPrompt = false; + // Ask the user for Rescan option by setting "Rescan Prompt"=y in system config. - rescanPrompt = false; if (getBoolForKey(kRescanPromptKey, &rescanPrompt , &bootInfo->chameleonConfig) && rescanPrompt && biosDevIsCDROM(gBIOSDev)) { gEnableCDROMRescan = promptForRescanOption(); @@ -510,10 +513,10 @@ init_module_system(); #if DEBUG - printf(" Default: %d, ->biosdev: %d, ->part_no: %d ->flags: %d\n", - gBootVolume, gBootVolume->biosdev, gBootVolume->part_no, gBootVolume->flags); - printf(" bt(0,0): %d, ->biosdev: %d, ->part_no: %d ->flags: %d\n", - gBIOSBootVolume, gBIOSBootVolume->biosdev, gBIOSBootVolume->part_no, gBIOSBootVolume->flags); + printf("Default: %d, ->biosdev: %d, ->part_no: %d ->flags: 0x%08X\n", + gBootVolume, gBootVolume->biosdev, gBootVolume->part_no, gBootVolume->flags); + printf("bt(0,0): %d, ->biosdev: %d, ->part_no: %d ->flags: 0x%08X\n", + gBIOSBootVolume, gBIOSBootVolume->biosdev, gBIOSBootVolume->part_no, gBIOSBootVolume->flags); getchar(); #endif @@ -667,42 +670,54 @@ } getBoolForKey(kUseKernelCache, &useKernelCache, &bootInfo->chameleonConfig); - if (useKernelCache) do { + if (useKernelCache) + { + do + { + // Determine the name of the Kernel Cache + if (getValueForKey(kKernelCacheKey, &val, &len, &bootInfo->bootConfig)) + { + if (val[0] == '\\') + { + len--; + val++; + } + /* FIXME: check len vs sizeof(kernelCacheFile) */ + strlcpy(kernelCacheFile, val, len + 1); + } + else + { + kernelCacheFile[0] = 0; // Use default kernel cache file + } - // Determine the name of the Kernel Cache - if (getValueForKey(kKernelCacheKey, &val, &len, &bootInfo->bootConfig)) { - if (val[0] == '\\') + if (gOverrideKernel && kernelCacheFile[0] == 0) { - len--; - val++; + DBG("Using a non default kernel (%s) without specifying 'Kernel Cache' path, KernelCache will not be used\n", bootInfo->bootFile); + useKernelCache = false; + break; } - /* FIXME: check len vs sizeof(kernelCacheFile) */ - strlcpy(kernelCacheFile, val, len + 1); - } - else - { - kernelCacheFile[0] = 0; // Use default kernel cache file - } - if (gOverrideKernel && kernelCacheFile[0] == 0) - { - DBG("Using a non default kernel (%s) without specifying 'Kernel Cache' path, KernelCache will not be used\n", bootInfo->bootFile); - useKernelCache = false; - break; - } - if (gMKextName[0] != 0) - { - DBG("Using a specific MKext Cache (%s), KernelCache will not be used\n", - gMKextName); - useKernelCache = false; - break; - } - if (gBootFileType != kBlockDeviceType) - useKernelCache = false; + if (gMKextName[0] != 0) + { + DBG("Using a specific MKext Cache (%s), KernelCache will not be used\n", gMKextName); + useKernelCache = false; + break; + } - } while(0); + if (gBootFileType != kBlockDeviceType) + { + useKernelCache = false; + } - do { + } while(0); + } + else + { + verbose("Kernel Cache using disabled by user."); + } + + do + { if (useKernelCache) { ret = LoadKernelCache(kernelCacheFile, &binary); @@ -724,16 +739,11 @@ { if ( !YOSEMITE ) { - //printf(HEADER " (%s).\n", bootInfo->bootFile); snprintf(bootFile, sizeof(bootFile), "/%s", bootInfo->bootFile); // append a leading / - //sleep(1); } else { - - //printf(HEADER " (%s).\n", bootInfo->bootFile); snprintf(bootFile, sizeof(bootFile), kDefaultKernelPathForYos"%s", bootInfo->bootFile); // Yosemite - //sleep(1); } } else @@ -764,7 +774,7 @@ strlcpy(bootFilePath, bootFile, sizeof(bootFilePath)); } - DBG("Loading kernel: '%s'\n", bootFilePath); + DBG("Loading kernel from: '%s'\n", bootFilePath); ret = LoadThinFatFile(bootFilePath, &binary); if (ret <= 0 && archCpuType == CPU_TYPE_X86_64) { @@ -782,7 +792,7 @@ if (ret <= 0) { - printf("Can't find %s\n", bootFile); + printf("Can't find boot file: '%s'\n", bootFile); sleep(1); if (gBootFileType == kNetworkDeviceType) Index: trunk/i386/boot2/boot.h =================================================================== --- trunk/i386/boot2/boot.h (revision 2537) +++ trunk/i386/boot2/boot.h (revision 2538) @@ -43,20 +43,20 @@ */ // kernel cache -#define kDefaultCachePathLeo "/System/Library/Caches/com.apple.kernelcaches/" -#define kDefaultCachePathSnow "/System/Library/Caches/com.apple.kext.caches/Startup/" +#define kDefaultCachePathLeo "/System/Library/Caches/com.apple.kernelcaches/" +#define kDefaultCachePathSnow "/System/Library/Caches/com.apple.kext.caches/Startup/" // Lion installer -#define kLionInstallerDataFolder "/Mac OS X Install Data/" -#define kLionInstallerPlist kLionInstallerDataFolder "com.apple.Boot.plist" +#define kLionInstallerDataFolder "/Mac OS X Install Data/" +#define kLionInstallerPlist kLionInstallerDataFolder "com.apple.Boot.plist" // Mountain Lion installer -#define kMLionInstallerDataFolder "/OS X Install Data/" -#define kMLionInstallerPlist kMLionInstallerDataFolder "com.apple.Boot.plist" +#define kMLionInstallerDataFolder "/OS X Install Data/" +#define kMLionInstallerPlist kMLionInstallerDataFolder "com.apple.Boot.plist" //kernel path #define kDefaultKernelPathPreYos "/" -#define kDefaultKernelPathForYos "/System/Library/Kernels/" //for Yosemite +#define kDefaultKernelPathForYos "/System/Library/Kernels/" //for Yosemite and newer /* * Keys used in system Boot.plist @@ -87,7 +87,7 @@ #define kOSXKernel "kernel" // Yosemite #define kGUIKey "GUI" #define kBootBannerKey "Boot Banner" -#define kShowInfoKey "ShowInfo" /* gui.c */ +#define kShowInfoKey "ShowInfo" // gui.c #define kWaitForKeypressKey "Wait" /* AsereBLN: added these keys */ @@ -184,9 +184,9 @@ #define kMemFullInfo "ForceFullMemInfo" /* smbios.c */ /* Bungo: added these keys */ -// mask private data or no #define kPrivateData "PrivateData" /* smbios_decode.c */ + /* * Flags to the booter or kernel */ @@ -199,8 +199,8 @@ /* * Booter behavior control */ -#define kBootTimeout -1 -#define kCDBootTimeout 8 +#define kBootTimeout -1 +#define kCDBootTimeout 8 /* * A global set by boot() to record the device that the booter was loaded from. @@ -231,7 +231,7 @@ extern void initialize_runtime(); extern void common_boot(int biosdev); - +bool checkOSVersion(const char * version); /* * usb.c */ @@ -257,7 +257,7 @@ unsigned short y, unsigned short width, unsigned short height, - unsigned char * data + unsigned char *data ); extern int convertImage( unsigned short width, @@ -266,19 +266,19 @@ unsigned char **newImageData ); extern char * decodeRLE( const void * rleData, int rleBlocks, int outBytes ); extern void drawBootGraphics(void); -extern void drawPreview(void *src, uint8_t * saveunder); +extern void drawPreview(void *src, uint8_t *saveunder); extern int getVideoMode(void); extern void loadImageScale (void *input, int iw, int ih, int ip, void *output, int ow, int oh, int op, int or); /* * drivers.c */ -extern char *gDarwinBuildVerStr; // Bungo extern long LoadExtraDrivers(char * dirSpec); extern long LoadDrivers(char * dirSpec); extern long DecodeKernel(void *binary, entry_t *rentry, char **raddr, int *rsize); - typedef long (*FileLoadDrivers_t)(char *dirSpec, long plugin); + // Bungo +extern char *gDarwinBuildVerStr; /*! Hookable function pointer called during the driver loading phase that allows other code to cause additional drivers to be loaded. @@ -289,7 +289,6 @@ * options.c */ extern char gBootUUIDString[]; - extern int getBootOptions(bool firstRun); extern int processBootOptions(); extern int selectAlternateBootDevice(int bootdevice); @@ -313,16 +312,16 @@ /* * lzvn.c */ -extern size_t lzvn_decode(void * dst, - size_t dst_size, - const void * src, - size_t src_size); +extern size_t lzvn_decode(void *dst, + size_t dst_size, + const void *src, + size_t src_size); /* -extern size_t lzvn_encode(void * dst, - size_t dst_size, - const void * src, - size_t src_size, - void * work); +extern size_t lzvn_encode(void *dst, + size_t dst_size, + const void *src, + size_t src_size, + void *work); */ struct compressed_kernel_header { @@ -342,8 +341,6 @@ void HibernateBoot(char *boot_device); /* bmdecompress.c */ -void * DecompressData(void *srcbase, int *dw, int *dh, int *bytesPerPixel); +void *DecompressData(void *srcbase, int *dw, int *dh, int *bytesPerPixel); -bool checkOSVersion(const char * version); - #endif /* !__BOOT2_BOOT_H */ Index: trunk/i386/boot2/modules.c =================================================================== --- trunk/i386/boot2/modules.c (revision 2537) +++ trunk/i386/boot2/modules.c (revision 2538) @@ -76,7 +76,7 @@ // Module system was compiled in (Symbols.dylib addr known) module_start = parse_mach(module_data, &load_module, &add_symbol, NULL); - if(module_start && module_start != (void*)0xFFFFFFFF) + if(module_start && (module_start != (void*)0xFFFFFFFF)) { // Notify the system that it was laoded module_loaded(SYMBOLS_MODULE, module_start, SYMBOLS_AUTHOR, SYMBOLS_DESCRIPTION, SYMBOLS_VERSION, SYMBOLS_COMPAT); @@ -88,7 +88,8 @@ else { // The module does not have a valid start function - printf("Unable to start %s at 0x%x\n", SYMBOLS_MODULE, module_data); pause(); + printf("Unable to start %s at 0x%x\n", SYMBOLS_MODULE, module_data); + pause(); } } @@ -123,7 +124,7 @@ module_start = parse_mach(module_data, &load_module, &add_symbol, NULL); - if(module_start && module_start != (void*)0xFFFFFFFF) + if(module_start && (module_start != (void*)0xFFFFFFFF)) { // Notify the system that it was laoded module_loaded(name, module_start, NULL, NULL, 0, 0 /*moduleName, NULL, moduleVersion, moduleCompat*/); @@ -164,18 +165,18 @@ */ void load_all_modules() { - char* name; + char *name; long flags; u_int32_t time; - struct dirstuff* moduleDir = opendir("/Extra/modules/"); + struct dirstuff *moduleDir = opendir("/Extra/modules/"); if(!moduleDir) { - verbose("Warning: Unable to open modules folder at '/Extra/modules/'. Ignoring 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) { if(strcmp(&name[strlen(name) - sizeof("dylib")], ".dylib") == 0) { - char* tmp = malloc(strlen(name) + 1); + char *tmp = malloc(strlen(name) + 1); strcpy(tmp, name); if(!load_module(tmp)) @@ -208,6 +209,7 @@ // Check to see if the module has already been loaded if(is_module_loaded(module)) { + DBG("Module '%s' already loaded.\n", module); return 1; } @@ -215,16 +217,17 @@ fh = open(modString, 0); if(fh < 0) { - DBG("WARNING: Unable to locate module %s\n", modString); DBGPAUSE(); + DBG("[WARNING!] Unable to locate module '%s'. Not loaded.\n", modString); + DBGPAUSE(); return 0; } unsigned int moduleSize = file_size(fh); - if(moduleSize == 0) - { - DBG("WARNING: The module %s has a file size of %d, the module will not be loaded.\n", modString, moduleSize); - return 0; - } + if(moduleSize == 0) + { + DBG("[WARNING!] The module '%s' has a file size=%d. Not loading.\n", modString, moduleSize); + return 0; + } char* module_base = (char*) malloc(moduleSize); if (moduleSize && read(fh, module_base, moduleSize) == moduleSize) @@ -237,21 +240,23 @@ // Notify the system that it was laoded module_loaded(module, module_start, NULL, NULL, 0, 0 /*moduleName, NULL, moduleVersion, moduleCompat*/); (*module_start)(); // Start the module - DBG("Module %s Loaded.\n", module); DBGPAUSE(); + DBG("Module %s Loaded.\n", module); + DBGPAUSE(); } #if CONFIG_MODULE_DEBUG else // The module does not have a valid start function. This may be a library. { - printf("WARNING: Unable to start %s\n", module); + printf("[WARNING!] Unable to start module '%s'.\n", module); getchar(); } #else - else msglog("WARNING: Unable to start %s\n", module); + else msglog("[WARNING!] Unable to start module '%s'.\n", module); #endif } else { - DBG("Unable to read in module %s\n.", module); DBGPAUSE(); + DBG("[WARNING!] Unable to read in module '%s'.\n", module); + DBGPAUSE(); retVal = 0; } @@ -311,7 +316,7 @@ new_entry->compat = compat; DBG("Module '%s' by '%s' Loaded.\n", name, author); - DBG("\tInitialization: 0x%X\n", start); + DBG("\tInitialization: 0x%08X\n", start); DBG("\tDescription: %s\n", description); DBG("\tVersion: %d\n", version); // todo: sperate to major.minor.bugfix DBG("\tCompat: %d\n", compat); // todo: ^^^ major.minor.bugfix @@ -320,12 +325,13 @@ int is_module_loaded(const char* name) { // todo sorted search - moduleList_t* entry = loadedModules; + moduleList_t *entry = loadedModules; while(entry) { if(strcmp(entry->name, name) == 0) { - DBG("Located module %s\n", name); DBGPAUSE(); + DBG("Located module %s\n", name); + DBGPAUSE(); return 1; } else @@ -335,7 +341,8 @@ } - DBG("Module %s not loaded\n", name); DBGPAUSE(); + DBG("Module %s not loaded\n", name); + DBGPAUSE(); return 0; } @@ -365,7 +372,7 @@ } #if CONFIG_MODULE_DEBUG - printf("Unable to locate symbol %s\n", name); + printf("[WARNING!] Unable to locate symbol %s.\n", name); getchar(); #endif @@ -431,7 +438,7 @@ } else { - verbose("Invalid mach magic 0x%X\n", ((struct mach_header*)binary)->magic); + verbose("[ERROR!] Invalid mach magic: 0x%08X.\n", ((struct mach_header*)binary)->magic); return NULL; } @@ -564,7 +571,7 @@ break; default: - DBG("Unhandled loadcommand 0x%X\n", loadCommand->cmd & 0x7FFFFFFF); + DBG("[WARNING!] Unhandled loadcommand: 0x%08X.\n", loadCommand->cmd & 0x7FFFFFFF); break; } @@ -925,7 +932,7 @@ } else { - printf("Unable to bind symbol %s\n", symbolName); + printf("[ERROR!] Unable to bind symbol %s.\n", symbolName); getchar(); } @@ -944,7 +951,7 @@ } else { - printf("Unable to bind symbol %s\n", symbolName); + printf("[ERROR!] Unable to bind symbol %s.\n", symbolName); getchar(); } @@ -962,7 +969,7 @@ } else { - printf("Unable to bind symbol %s\n", symbolName); + printf("[ERROR!] Unable to bind symbol %s.\n", symbolName); getchar(); } segmentAddress += (immediate * sizeof(void*)) + sizeof(void*); @@ -987,7 +994,7 @@ } else { - printf("Unable to bind symbol %s\n", symbolName); + printf("[ERROR!] Unable to bind symbol %s.\n", symbolName); getchar(); } break; @@ -1072,7 +1079,8 @@ */ int execute_hook(const char* name, void* arg1, void* arg2, void* arg3, void* arg4) { - DBG("Attempting to execute hook '%s'\n", name); DBGPAUSE(); + DBG("Attempting to execute hook '%s'...\n", name); + DBGPAUSE(); moduleHook_t* hook = hook_exists(name); if(hook) @@ -1086,13 +1094,14 @@ callbacks->callback(arg1, arg2, arg3, arg4); callbacks = callbacks->next; } - DBG("Hook '%s' executed.\n", name); DBGPAUSE(); + DBG("Hook '%s' executed.\n", name); + DBGPAUSE(); return 1; } else { // Callback for this hook doesn't exist; - DBG("No callbacks for '%s' hook.\n", name); + DBG("No callbacks for hook '%s'.\n", name); return 0; } } @@ -1108,22 +1117,25 @@ */ void register_hook_callback(const char* name, void(*callback)(void*, void*, void*, void*)) { - DBG("Adding callback for '%s' hook.\n", name); DBGPAUSE(); + DBG("Adding callback for '%s' hook... ", name); + DBGPAUSE(); - moduleHook_t* hook = hook_exists(name); + moduleHook_t *hook = hook_exists(name); if(hook) { // append - callbackList_t* newCallback = malloc(sizeof(callbackList_t)); + callbackList_t *newCallback = malloc(sizeof(callbackList_t)); newCallback->next = hook->callbacks; hook->callbacks = newCallback; newCallback->callback = callback; + DBG("Added.\n"); } else { // create new hook - moduleHook_t* newHook = malloc(sizeof(moduleHook_t)); + DBG("Hook not exists, creating a new hook.\n"); + moduleHook_t *newHook = malloc(sizeof(moduleHook_t)); newHook->name = name; newHook->callbacks = malloc(sizeof(callbackList_t)); newHook->callbacks->callback = callback; @@ -1183,7 +1195,7 @@ void dyld_stub_binder() { - printf("ERROR: dyld_stub_binder was called, should have been take care of by the linker.\n"); + printf("[ERROR!] 'dyld_stub_binder' was called, should have been take care of by the linker.\n"); getchar(); } @@ -1206,13 +1218,13 @@ void register_hook_callback(const char* name, void(*callback)(void*, void*, void*, void*)) { - printf("WARNING: register_hook_callback is not supported when compiled in.\n"); + printf("[WARNING!] 'register_hook_callback' is not supported when compiled in.\n"); pause(); } int replace_function(const char* symbol, void* newAddress) { - printf("WARNING: replace_functions is not supported when compiled in.\n"); + printf("[WARNING!] 'replace_functions' is not supported when compiled in.\n"); pause(); return 0; } Index: trunk/i386/boot2/gui.c =================================================================== --- trunk/i386/boot2/gui.c (revision 2537) +++ trunk/i386/boot2/gui.c (revision 2538) @@ -889,7 +889,7 @@ int initGUI(void) { - int val; + int val; int len; char dirspec[256]; @@ -911,10 +911,12 @@ #endif } // parse display size parameters - if (getIntForKey("screen_width", &val, &bootInfo->themeConfig) && val > 0) { + if (getIntForKey("screen_width", &val, &bootInfo->themeConfig) && (val > 0)) + { screen_params[0] = val; } - if (getIntForKey("screen_height", &val, &bootInfo->themeConfig) && val > 0) { + if (getIntForKey("screen_height", &val, &bootInfo->themeConfig) && (val > 0)) + { screen_params[1] = val; } Index: trunk/i386/boot2/options.c =================================================================== --- trunk/i386/boot2/options.c (revision 2537) +++ trunk/i386/boot2/options.c (revision 2538) @@ -50,15 +50,16 @@ extern int gDeviceCount; int selectIndex = 0; -MenuItem * menuItems = NULL; +MenuItem *menuItems = NULL; + enum { kMenuTopRow = 5, kMenuMaxItems = 10, kScreenLastRow = 24 }; -extern char* msgbuf; +extern char *msgbuf; void showTextBuffer(char *buf_orig, int size); @@ -185,11 +186,11 @@ //========================================================================== -char gBootArgs[BOOT_STRING_LEN]; -static char * gBootArgsPtr = gBootArgs; -static char * gBootArgsEnd = gBootArgs + BOOT_STRING_LEN - 1; -static char booterCommand[BOOT_STRING_LEN]; -static char booterParam[BOOT_STRING_LEN]; +char gBootArgs[BOOT_STRING_LEN]; +static char *gBootArgsPtr = gBootArgs; +static char *gBootArgsEnd = gBootArgs + BOOT_STRING_LEN - 1; +static char booterCommand[BOOT_STRING_LEN]; +static char booterParam[BOOT_STRING_LEN]; static void clearBootArgs(void) { @@ -260,49 +261,55 @@ static void updateBootArgs( int key ) { - key = ASCII_KEY(key); + key = ASCII_KEY(key); - switch ( key ) - { - case KEY_BKSP: - if ( gBootArgsPtr > gBootArgs ) - { - *--gBootArgsPtr = '\0'; + switch ( key ) + { + case KEY_BKSP: + if ( gBootArgsPtr > gBootArgs ) + { + *--gBootArgsPtr = '\0'; - int x, y, t; - getCursorPositionAndType( &x, &y, &t ); - if ( x == 0 && y ) - { - x = 80; y--; - } - if (x) { - x--; - } + int x, y, t; + getCursorPositionAndType( &x, &y, &t ); + if ( x == 0 && y ) + { + x = 80; y--; + } - if( bootArgs->Video.v_display == VGA_TEXT_MODE ) - { - setCursorPosition( x, y, 0 ); - putca(' ', 0x07, 1); - } - else - { - updateGraphicBootPrompt(); - } - } + if (x) + { + x--; + } + + if( bootArgs->Video.v_display == VGA_TEXT_MODE ) + { + setCursorPosition( x, y, 0 ); + putca(' ', 0x07, 1); + } + else + { + updateGraphicBootPrompt(); + } + } break; - default: - if ( key >= ' ' && gBootArgsPtr < gBootArgsEnd) - { - *gBootArgsPtr++ = key; + default: + if ( key >= ' ' && gBootArgsPtr < gBootArgsEnd) + { + *gBootArgsPtr++ = key; - if( bootArgs->Video.v_display != VGA_TEXT_MODE ) - updateGraphicBootPrompt(); - else if ( key >= ' ' && key < 0x7f) - putchar(key); - } + if( bootArgs->Video.v_display != VGA_TEXT_MODE ) + { + updateGraphicBootPrompt(); + } + else if ( key >= ' ' && key < 0x7f) + { + putchar(key); + } + } - break; + break; } } @@ -375,11 +382,11 @@ // Draw the visible items. if( bootArgs->Video.v_display != VGA_TEXT_MODE ) - + { drawDeviceList(gMenuStart, gMenuEnd, gMenuSelection); - - else { - + } + else + { changeCursor( 0, row, kCursorTypeHidden, &cursorState ); for ( i = gMenuTop; i <= gMenuBottom; i++ ) @@ -905,7 +912,7 @@ // gDeviceCount is actually > 0, so menuItems[selectIndex] exists menuBVR = (BVRef)(menuItems[selectIndex].param); - // what happen is bvChain is empty ? + // what happen if bvChain is empty ? } } @@ -1114,14 +1121,15 @@ 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 len = argLen + cnt + 1; // +1 to account for space if (argName) { len++; // +1 to account for '=' } - if (len > *cntRemainingP) { + if (len > *cntRemainingP) + { error("Warning: boot arguments too long, truncating\n"); return false; } @@ -1179,8 +1187,7 @@ // Maximum config table value size #define VALUE_SIZE 2048 -int -processBootOptions() +int processBootOptions() { const char *cp = gBootArgs; const char *val = 0; @@ -1197,10 +1204,11 @@ skipblanks( &cp ); // Update the unit and partition number. - - if ( gBootVolume ) { - if (!( gBootVolume->flags & kBVFlagNativeBoot )) { - readBootSector( gBootVolume->biosdev, gBootVolume->part_boff, (void *) 0x7c00 ); + if (gBootVolume) + { + if (!(gBootVolume->flags & kBVFlagNativeBoot)) + { + readBootSector(gBootVolume->biosdev, gBootVolume->part_boff, (void *)0x7c00); // // Setup edx, and signal intention to chain load the // foreign booter. @@ -1217,7 +1225,8 @@ } // If no boot volume fail immediately because we're just going to fail // trying to load the config file anyway. - else { + else + { return -1; } @@ -1226,7 +1235,8 @@ // Load config table specified by the user, or use the default. - if (!getValueForBootKey(cp, "config", &val, &cnt)) { + if (!getValueForBootKey(cp, "config", &val, &cnt)) + { val = 0; cnt = 0; } @@ -1259,15 +1269,12 @@ { if( YOSEMITE ) // is 10.10 { - strlcpy( bootInfo->bootFile, kOSXKernel, sizeof(bootInfo->bootFile) ); - //printf(HEADER "/System/Library/Kernels/%s\n", bootInfo->bootFile); } else { // OSX is not 10.10 strlcpy( bootInfo->bootFile, kDefaultKernel, sizeof(bootInfo->bootFile) ); - //printf(HEADER "/%s\n", bootInfo->bootFile); } } } @@ -1299,8 +1306,7 @@ argP = bootArgs->CommandLine; // Get config kernel flags, if not ignored. - if (getValueForBootKey(cp, kIgnoreBootFileFlag, &val, &cnt) || - !getValueForKey( kKernelFlagsKey, &val, &cnt, &bootInfo->bootConfig )) + if (getValueForBootKey(cp, kIgnoreBootFileFlag, &val, &cnt) || !getValueForKey(kKernelFlagsKey, &val, &cnt, &bootInfo->bootConfig)) { val = ""; cnt = 0; @@ -1378,7 +1384,7 @@ { copyArgument( kRootDeviceKey, val, cnt, &argP, &cntRemaining); } - strlcpy( gRootDevice, val, (cnt + 1)); + strlcpy(gRootDevice, val, (cnt + 1)); } /*