Value* WriteBootloaderFn(const char* name, State* state, int argc, Expr* argv[]) { int result = -1; Value* img; Value* xloader_loc; Value* sbl_loc; if (argc != 3) { return ErrorAbort(state, "%s() expects 3 args, got %d", name, argc); } if (ReadValueArgs(state, argv, 3, &img, &xloader_loc, &sbl_loc) < 0) { return NULL; } if(img->type != VAL_BLOB || xloader_loc->type != VAL_STRING || sbl_loc->type != VAL_STRING) { FreeValue(img); FreeValue(xloader_loc); FreeValue(sbl_loc); return ErrorAbort(state, "%s(): argument types are incorrect", name); } result = update_bootloader(img->data, img->size, xloader_loc->data, sbl_loc->data); FreeValue(img); FreeValue(xloader_loc); FreeValue(sbl_loc); return StringValue(strdup(result == 0 ? "t" : "")); }
static void check_bootloader(void) { BootloaderKind kind = get_bootloaderKind(); switch (kind) { case BLK_v1_0_0: case BLK_v1_0_1: case BLK_v1_0_2: case BLK_v1_0_3: case BLK_v1_0_3_elf: case BLK_v1_0_3_sig: case BLK_v1_0_4: #ifndef DEBUG_ON update_bootloader(); #endif return; case BLK_UNKNOWN: #ifndef DEBUG_ON unknown_bootloader(); #endif return; case BLK_v2_0_0: case BLK_v1_1_0: return; } #ifdef DEBUG_ON __builtin_unreachable(); #else unknown_bootloader(); #endif }
void run_scripts(void) { LOG_INFO(NULL, "calling update helpers", class_scripts, ""); if (need_update_boot) update_kernel(); if (need_update_bootloader) update_bootloader(); /* Crudely call post-update hooks after every update, must fix with proper conditions and log output */ update_triggers(); }