int main(int argc, char **argv) { struct pnor pnor; int rc; if (argc != 2) { printf("usage: %s [pnor file]\n", argv[0]); exit(EXIT_FAILURE); } pnor.path = strndup(argv[1], PATH_MAX); rc = pnor_init(&pnor); assert(rc); dump_parts(pnor.ffsh); pnor_close(&pnor); return 0; }
static int run_prd_daemon(struct opal_prd_ctx *ctx) { int rc; /* log to syslog */ pr_log_daemon_init(); ctx->fd = -1; ctx->socket = -1; i2c_init(); #ifdef DEBUG_I2C { uint8_t foo[128]; int i; rc = i2c_read(0, 1, 2, 0x50, 2, 0x10, 128, foo); pr_debug("I2C: read rc: %d", rc); for (i = 0; i < sizeof(foo); i += 8) { pr_debug("I2C: %02x %02x %02x %02x %02x %02x %02x %02x", foo[i + 0], foo[i + 1], foo[i + 2], foo[i + 3], foo[i + 4], foo[i + 5], foo[i + 6], foo[i + 7]); } } #endif rc = init_control_socket(ctx); if (rc) { pr_log(LOG_WARNING, "CTRL: Error initialising PRD control: %m"); goto out_close; } rc = prd_init(ctx); if (rc) { pr_log(LOG_ERR, "FW: Error initialising PRD channel"); goto out_close; } if (ctx->hbrt_file_name) { rc = map_hbrt_file(ctx, ctx->hbrt_file_name); if (rc) { pr_log(LOG_ERR, "IMAGE: Can't access hbrt file %s", ctx->hbrt_file_name); goto out_close; } } else { rc = map_hbrt_physmem(ctx, hbrt_code_region_name); if (rc) { pr_log(LOG_ERR, "IMAGE: Can't access hbrt " "physical memory"); goto out_close; } dump_hbrt_map(ctx); } pr_debug("IMAGE: hbrt map at %p, size 0x%zx", ctx->code_addr, ctx->code_size); fixup_hinterface_table(); pr_debug("HBRT: calling hservices_init"); hservices_init(ctx, ctx->code_addr); pr_debug("HBRT: hservices_init done"); if (ctx->pnor.path) { rc = pnor_init(&ctx->pnor); if (rc) { pr_log(LOG_ERR, "PNOR: Failed to open pnor: %m"); goto out_close; } } ipmi_init(ctx); /* Test a scom */ if (ctx->debug) { uint64_t val; pr_debug("SCOM: trying scom read"); fflush(stdout); hservice_scom_read(0x00, 0xf000f, &val); pr_debug("SCOM: f00f: %lx", be64toh(val)); } run_attn_loop(ctx); rc = 0; out_close: pnor_close(&ctx->pnor); if (ctx->fd != -1) close(ctx->fd); if (ctx->socket != -1) close(ctx->socket); return rc; }