static int search_cb(search_t *search, search_event_t *evt, void *udata) { batch_decoder_t *bd = (batch_decoder_t *) udata; dict_t *d = search_factory_d2p(bd->sf)->dict; double delta = get_time_delta(bd); double frate = cmd_ln_int32_r(search_config(search), "-frate"); FILE *hypfh = NULL; void *val; if (hash_table_lookup(bd->hypfiles, search_name(search), &val) == 0) hypfh = val; else hypfh = stdout; fprintf(hypfh, "time delta %f ", delta); switch (evt->event) { case SEARCH_PARTIAL_RESULT: { int32 score; seg_iter_t *seg = search_seg_iter(search, &score); fprintf(hypfh, "partial: "); for (; seg; seg = seg_iter_next(seg)) { int sf, ef; seg_iter_times(seg, &sf, &ef); fprintf(hypfh, "%s:%.3f ", dict_basestr(d, seg_iter_wid(seg)), (double) ef / frate); } fprintf(hypfh, "(%s)\n", search_uttid(search)); break; } case SEARCH_START_UTT: fprintf(hypfh, "start %s\n", search_uttid(search)); break; case SEARCH_END_UTT: fprintf(hypfh, "end %s\n", search_uttid(search)); break; case SEARCH_FINAL_RESULT: { int32 score; seg_iter_t *seg = search_seg_iter(search, &score); fprintf(hypfh, "full: "); for (; seg; seg = seg_iter_next(seg)) { int sf, ef; seg_iter_times(seg, &sf, &ef); fprintf(hypfh, "%s:%.3f ", dict_basestr(d, seg_iter_wid(seg)), (double) ef / frate); } fprintf(hypfh, "(%s)\n", search_uttid(search)); break; } } return 0; }
int load_kernel_and_config(struct loader_info *li) { EFI_HANDLE handles[128]; EFI_BLOCK_IO *blkio; UINTN i, nparts = sizeof(handles); EFI_STATUS status; EFI_DEVICE_PATH *devpath; unsigned char buf[512]; EFI_LBA head; UINTN size; status = systab->BootServices->LocateHandle(ByProtocol, &BlockIoGUID, NULL, &nparts, handles); nparts /= sizeof(handles[0]); for (i = 0; i < nparts; i++) { status = systab->BootServices->HandleProtocol(handles[i], &DevicePathGUID, (void **)&devpath); if (EFI_ERROR(status)) continue; while (!IsDevicePathEnd(NextDevicePathNode(devpath))) devpath = NextDevicePathNode(devpath); status = systab->BootServices->HandleProtocol(handles[i], &BlockIoGUID, (void **)&blkio); if (EFI_ERROR(status)) continue; if (!blkio->Media->LogicalPartition) continue; status = blkio->ReadBlocks(blkio, blkio->Media->MediaId, 0, 512, buf); if (EFI_ERROR(status)) continue; if (buf[0] != 0xeb && buf[0] != 0xe9) continue; if (buf[510] != 0x55 || buf[511] != 0xaa) continue; /* ここまできたら blkio は FAT ファイルシステム */ if (search_kernel(blkio, &head, &size)) continue; if (load_kernel(blkio, &head, &size, li)) return -1; printstr("KERNEL BASE: "); printhex64(li->kernel_base); putchar('\n'); printstr("KERNEL SIZE: "); printhex64(li->kernel_size); putchar('\n'); if (search_config(blkio, &head, &size) || (size == 0) || load_config(blkio, &head, &size, li)) { li->config_base = 0; li->config_size = 0; } printstr("CONFIG BASE: "); printhex64(li->config_base); putchar('\n'); printstr("CONFIG SIZE: "); printhex64(li->config_size); putchar('\n'); /* 正常完了 */ return 0; } /* 失敗 */ return -1; }