dword scene_readimage(dword selidx) { u64 timer_start, timer_end; u64 slide_start, slide_end; width_rotated = 0, height_rotated = 0, thumb_width = 0, thumb_height = 0, paintleft = 0, painttop = 0; imgdata = NULL, imgshow = NULL; oldangle = 0; curtop = 0, curleft = 0, xpos = 0, ypos = 0; img_needrf = true, img_needrc = true, img_needrp = true, showinfo = false, thumb = false; slideshow = false; now = 0, lasttime = 0; imgreading = true; if (config.imginfobar) imgh = PSP_SCREEN_HEIGHT - DISP_FONTSIZE; else imgh = PSP_SCREEN_HEIGHT; if (config.use_image_queue) { cache_setup(config.max_cache_img, &selidx); cache_set_forward(true); cache_on(true); } xrRtcGetCurrentTick(&timer_start); while (1) { u64 dbgnow, dbglasttick; dword key = 0; int ret; if (img_needrf) { int fid; dword ret; fid = freq_enter_hotzone(); xrRtcGetCurrentTick(&dbglasttick); ret = scene_reloadimage(selidx); if (ret == -1) { freq_leave(fid); break; } img_needrf = false; xrRtcGetCurrentTick(&dbgnow); dbg_printf(d, _("装载图像时间: %.2f秒"), pspDiffTime(&dbgnow, &dbglasttick)); freq_leave(fid); } if (img_needrc) { int fid; fid = freq_enter_hotzone(); xrRtcGetCurrentTick(&dbglasttick); scene_rotateimage(); img_needrc = false; xrRtcGetCurrentTick(&dbgnow); dbg_printf(d, _("旋转图像时间: %.2f秒"), pspDiffTime(&dbgnow, &dbglasttick)); freq_leave(fid); } if (img_needrp) { scene_printimage(selidx); img_needrp = false; } now = time(NULL); if (config.thumb == conf_thumb_scroll && thumb) { thumb = false; img_needrp = true; } key = ctrl_read_cont(); ret = image_handle_input(&selidx, key); if (ret == -1 && slideshow && !slideshow_move) { if (key == PSP_CTRL_CIRCLE) { } else if (key != 0 && (key == config.imgkey[1] || key == config.imgkey2[1] || key == CTRL_FORWARD)) { bool should_exit = false; next_image(&selidx, &should_exit); if (should_exit) { break; } } else if (key != 0 && (key == config.imgkey[0] || key == config.imgkey2[0] || key == CTRL_BACK)) { prev_image(&selidx); } else { xrPowerTick(0); if (config.imgpaging == conf_imgpaging_direct || config.imgpaging == conf_imgpaging_updown || config.imgpaging == conf_imgpaging_leftright) { if (now - lasttime >= config.slideinterval) { lasttime = now; ret = scene_slideshow_forward(&selidx); } } else { xrRtcGetCurrentTick(&slide_end); if (pspDiffTime(&slide_end, &slide_start) >= 0.1) { xrRtcGetCurrentTick(&slide_start); } else { lasttime = now; ret = scene_slideshow_forward(&selidx); } } } } if (showinfo && (key & PSP_CTRL_CIRCLE) == 0) { img_needrp = true; showinfo = false; } xrRtcGetCurrentTick(&timer_end); if (pspDiffTime(&timer_end, &timer_start) >= 1.0) { xrRtcGetCurrentTick(&timer_start); secticks++; } if (config.autosleep != 0 && secticks > 60 * config.autosleep) { power_down(); xrPowerRequestSuspend(); secticks = 0; } if (ret != -1) { selidx = ret; break; } scene_image_delay_action(); } reset_image_show_ptr(); if (config.use_image_queue) { cache_on(false); } imgreading = false; if (config.use_image_queue) { } else { if (imgdata != NULL) { free(imgdata); imgdata = NULL; } } if (config.use_image_queue) { // let cacher delete exif data exif_array = NULL; } else { if (exif_array) { buffer_array_free(exif_array); exif_array = NULL; } } return selidx; }
void initarm(struct arm64_bootparams *abp) { struct efi_map_header *efihdr; struct pcpu *pcpup; vm_offset_t lastaddr; caddr_t kmdp; vm_paddr_t mem_len; int i; /* Set the module data location */ preload_metadata = (caddr_t)(uintptr_t)(abp->modulep); /* Find the kernel address */ kmdp = preload_search_by_type("elf kernel"); if (kmdp == NULL) kmdp = preload_search_by_type("elf64 kernel"); boothowto = MD_FETCH(kmdp, MODINFOMD_HOWTO, int); kern_envp = MD_FETCH(kmdp, MODINFOMD_ENVP, char *); #ifdef FDT try_load_dtb(kmdp); #endif /* Find the address to start allocating from */ lastaddr = MD_FETCH(kmdp, MODINFOMD_KERNEND, vm_offset_t); /* Load the physical memory ranges */ physmap_idx = 0; efihdr = (struct efi_map_header *)preload_search_info(kmdp, MODINFO_METADATA | MODINFOMD_EFI_MAP); add_efi_map_entries(efihdr, physmap, &physmap_idx); /* Print the memory map */ mem_len = 0; for (i = 0; i < physmap_idx; i += 2) { dump_avail[i] = physmap[i]; dump_avail[i + 1] = physmap[i + 1]; mem_len += physmap[i + 1] - physmap[i]; } dump_avail[i] = 0; dump_avail[i + 1] = 0; /* Set the pcpu data, this is needed by pmap_bootstrap */ pcpup = &__pcpu[0]; pcpu_init(pcpup, 0, sizeof(struct pcpu)); /* * Set the pcpu pointer with a backup in tpidr_el1 to be * loaded when entering the kernel from userland. */ __asm __volatile( "mov x18, %0 \n" "msr tpidr_el1, %0" :: "r"(pcpup)); PCPU_SET(curthread, &thread0); /* Do basic tuning, hz etc */ init_param1(); cache_setup(); /* Bootstrap enough of pmap to enter the kernel proper */ pmap_bootstrap(abp->kern_l1pt, KERNBASE - abp->kern_delta, lastaddr - KERNBASE); arm_devmap_bootstrap(0, NULL); cninit(); init_proc0(abp->kern_stack); msgbufinit(msgbufp, msgbufsize); mutex_init(); init_param2(physmem); dbg_monitor_init(); kdb_init(); early_boot = 0; }
int main (int argc, char *argv[]) { int rv; /* return value for functionss */ FILE *file_in; /* file for mem RW/addr input */ settings_t settings; /* settings structure */ char line_buffer[64];/* buffer for reading in lines */ mem_rw_t parse_data; save_data_t save_data; init_save(&save_data); /* inits the stats */ init_settings(&settings); /* inits the settings struct */ /* parses the input arguements for the cache set up and run info */ if ((rv = get_settings(&settings, argc, argv)) != RTN_SUCCESS) { if (rv == RTN_PARSE_ERR) { fprintf(stderr, "Error parsing input arguements" "exiting\n"); return rv; } else if (rv == RTN_NO_SET) { fprintf(stderr, "Not all of the settings were" "present or set correctly, exiting\n"); return rv; } else { fprintf(stderr, "Unknown error, exiting\n"); return rv; } } /* sets up the cache array in memory */ if (cache_setup(&settings) == RTN_FAIL) { fprintf(stderr, "Failed to malloc memory, exiting\n"); } /* opens the input file */ if ((file_in = fopen(settings.file_path, "r")) == NULL) { fprintf(stderr, "Can not open input file, exiting\n"); return RTN_FILE_ERR; } /* reads one line from the input */ if(fgets(line_buffer, 64, file_in) == NULL) { fprintf(stderr, "The input file is empty, exiting\n"); return 1; } parse_data.time = 0ull; do { if (sscanf(line_buffer, "%d %d %u", &parse_data.flags, &parse_data.data_len, &parse_data.addr) != 3) { fprintf(stderr, "%llu: could not be parsed" ", skipping\n", parse_data.time + 1ull); continue; /* skip if the data isn't * read correctly */ } if (parse_data.flags == 0) { /* read */ read_cache(&settings, &parse_data, &save_data); parse_data.time++; } else if (parse_data.flags == 1) { /* write */ ; } else { /* error */ fprintf(stderr, "%llu: neither read nor write" ", skipping\n", parse_data.time + 1ull); } fgets(line_buffer, 64, file_in); } while (!feof(file_in)); print_save(&save_data); return 0; }