void cmd_install(int argc, char** argv) { bufferPrintf("Installing Images...\r\n"); images_install(&_start, (uint32_t)&OpenIBootEnd - (uint32_t)&_start); bufferPrintf("Setting version and defaulting menu-timeout to 10s\r\n"); nvram_setvar("opib-version", "0.1.1-zinnx"); nvram_setvar("opib-menu-timeout", "10000"); nvram_save(); bufferPrintf("Images installed\r\n"); }
static void reset_tempos(const char* sDefaultOS) { framebuffer_setdisplaytext(FALSE); nvram_setvar("opib-temp-os",sDefaultOS); nvram_save(); framebuffer_setdisplaytext(TRUE); }
void cmd_install(int argc, char** argv) { bufferPrintf("Installing Images...\r\n"); images_install(&_start, (uint32_t)&OpenIBootEnd - (uint32_t)&_start); bufferPrintf("Setting NVRAM version...\r\n"); nvram_setvar("opib-version", "0.1.1"); nvram_save(1); bufferPrintf("Images installed\r\n"); }
void cmd_setenv(int argc, char** argv) { if(argc < 3) { bufferPrintf("Usage: %s <name> <value>\r\n", argv[0]); return; } nvram_setvar(argv[1], argv[2]); bufferPrintf("Set %s = %s\r\n", argv[1], argv[2]); }
void cmd_uninstall(int argc, char** argv) { nvram_setvar("opib-version", ""); images_uninstall(); }
void images_install(void* newData, size_t newDataLen, uint32_t newFourcc, uint32_t replaceFourcc) { ImageDataList* list = NULL; ImageDataList* cur = NULL; ImageDataList* toReplace = NULL; ImageDataList* verify = NULL; int isReplace = (replaceFourcc != newFourcc) ? TRUE : FALSE; int isUpgrade = FALSE; Image* curImage = imageList; while(curImage != NULL) { if(cur == NULL) { list = cur = verify = malloc(sizeof(ImageDataList)); } else { cur->next = malloc(sizeof(ImageDataList)); cur = cur->next; } bufferPrintf("Reading: "); print_fourcc(curImage->type); bufferPrintf(" (%d bytes)\r\n", curImage->padded); cur->type = curImage->type; cur->next = NULL; cur->data = malloc(curImage->padded); nor_read(cur->data, curImage->offset, curImage->padded); if(isReplace && cur->type == replaceFourcc) { isUpgrade = TRUE; } else if(cur->type == newFourcc) { toReplace = cur; } curImage = curImage->next; } if(!isUpgrade) { bufferPrintf("Performing installation... (%d bytes)\r\n", newDataLen); ImageDataList* ibox = malloc(sizeof(ImageDataList)); ibox->type = replaceFourcc; ibox->data = toReplace->data; ibox->next = toReplace->next; toReplace->next = ibox; toReplace->data = images_inject_img3(toReplace->data, newData, newDataLen); images_change_type(ibox->data, ibox->type); } else { bufferPrintf("Performing upgrade... (%d bytes)\r\n", newDataLen); void* newIBoot = images_inject_img3(toReplace->data, newData, newDataLen); free(toReplace->data); toReplace->data = newIBoot; } //check for size and availability size_t newPaddedDataLen=0; size_t totalBytes=0; //if somebody can find how to get padded length for new ibot maybe this loop not needed while(verify != NULL) { cur = verify; verify = verify->next; AppleImg3RootHeader* header = (AppleImg3RootHeader*) cur->data; totalBytes += header->base.size; if(cur->type == newFourcc) { newPaddedDataLen = header->base.size; } } bufferPrintf("Total size to be written %d\r\n",totalBytes); if((ImagesStart + totalBytes) >= 0xfc000) { bufferPrintf("**ABORTED** Writing total image size: 0x%x, new ibot size: 0x%x at 0x%x would overflow NOR!\r\n", totalBytes, newPaddedDataLen,ImagesStart); images_rewind(); images_release(); images_setup(); return; } bufferPrintf("Flashing...\r\n"); images_rewind(); while(list != NULL) { cur = list; list = list->next; AppleImg3RootHeader* header = (AppleImg3RootHeader*) cur->data; bufferPrintf("Flashing: "); print_fourcc(cur->type); bufferPrintf(" (%x, %d bytes)\r\n", cur->data, header->base.size); images_append(cur->data, header->base.size); free(cur->data); free(cur); } bufferPrintf("Flashing Complete, Free space after flashing %d\r\n",0xfc000-MaxOffset); images_release(); images_setup(); bufferPrintf("Configuring openiBoot settings...\r\n"); Volume* volume; io_func* io; io = bdev_open(0); volume = openVolume(io); char buffer [sizeof(XSTRINGIFY(OPENIBOOT_VERSION))]; strcpy(buffer, XSTRINGIFY(OPENIBOOT_VERSION)); add_hfs(volume, (uint8_t*)buffer, sizeof(buffer), "/openiboot"); closeVolume(volume); CLOSE(io); ftl_sync(); if(!nvram_getvar("opib-temp-os")) { nvram_setvar("opib-temp-os", "0"); } if(!nvram_getvar("opib-default-os")) { nvram_setvar("opib-default-os", "1"); } if(!nvram_getvar("opib-menu-timeout")) { nvram_setvar("opib-menu-timeout", "10000"); } nvram_save(); bufferPrintf("openiBoot installation complete.\r\n"); }