void x86_regs_dump(struct x86_regs_t *regs, FILE *f) { int i, j; /* Integer registers */ fprintf(f, " eax=%08x ecx=%08x edx=%08x ebx=%08x\n", regs->eax, regs->ecx, regs->edx, regs->ebx); fprintf(f, " esp=%08x ebp=%08x esi=%08x edi=%08x\n", regs->esp, regs->ebp, regs->esi, regs->edi); fprintf(f, " es=%x, cs=%x, ss=%x, ds=%x, fs=%x, gs=%x\n", regs->es, regs->cs, regs->ss, regs->ds, regs->fs, regs->gs); fprintf(f, " eip=%08x\n", regs->eip); fprintf(f, " flags=%04x (cf=%d pf=%d af=%d zf=%d sf=%d df=%d of=%d)\n", regs->eflags, (regs->eflags & (1 << x86_flag_cf)) > 0, (regs->eflags & (1 << x86_flag_pf)) > 0, (regs->eflags & (1 << x86_flag_af)) > 0, (regs->eflags & (1 << x86_flag_zf)) > 0, (regs->eflags & (1 << x86_flag_sf)) > 0, (regs->eflags & (1 << x86_flag_df)) > 0, (regs->eflags & (1 << x86_flag_of)) > 0); /* Floating-point stack */ fprintf(f, " fpu_stack (last=top): "); x86_regs_fpu_stack_dump(regs, f); /* Floating point code (part from status register) */ fprintf(f, " fpu_code (C3-C2-C1-C0): %d-%d-%d-%d\n", GETBIT32(regs->fpu_code, 3) > 0, GETBIT32(regs->fpu_code, 2) > 0, GETBIT32(regs->fpu_code, 1) > 0, GETBIT32(regs->fpu_code, 0) > 0); fprintf(f, " fpu_ctrl=%04x\n", regs->fpu_ctrl); /* XMM registers */ for (i = 0; i < 8; i++) { fprintf(f, " xmm%d =", i); for (j = 0; j < 16; j++) fprintf(f, " %02x", regs->xmm[i][j]); fprintf(f, "\n"); } }
static inline cmph_uint8 chd_ph_check_bin_hashing(chd_ph_config_data_t *chd_ph, chd_ph_bucket_t *buckets, chd_ph_item_t *items, cmph_uint32 * disp_table, chd_ph_sorted_list_t * sorted_lists,cmph_uint32 max_bucket_size) { register cmph_uint32 bucket_size, i, j; register cmph_uint32 position, probe0_num, probe1_num; register cmph_uint32 m = 0; register chd_ph_item_t * item; if(chd_ph->keys_per_bin > 1) memset(chd_ph->occup_table, 0, chd_ph->n); else memset(chd_ph->occup_table, 0, ((chd_ph->n + 31)/32) * sizeof(cmph_uint32)); for(bucket_size = 1; bucket_size <= max_bucket_size; bucket_size++) for(i = sorted_lists[bucket_size].buckets_list; i < sorted_lists[bucket_size].size + sorted_lists[bucket_size].buckets_list; i++) { j = bucket_size; item = items + buckets[i].items_list; probe0_num = disp_table[buckets[i].bucket_id] % chd_ph->n; probe1_num = disp_table[buckets[i].bucket_id] / chd_ph->n; for(; j > 0; j--) { m++; position = (cmph_uint32)((item->f + ((cmph_uint64 )item->h) * probe0_num + probe1_num) % chd_ph->n); if(chd_ph->keys_per_bin > 1) { if(chd_ph->occup_table[position] >= chd_ph->keys_per_bin) { return 0; } (chd_ph->occup_table[position])++; } else { if(GETBIT32(((cmph_uint32*)chd_ph->occup_table), position)) { return 0; } SETBIT32(((cmph_uint32*)chd_ph->occup_table), position); }; item++; }; }; DEBUGP("We were able to place m = %u keys\n", m); return 1; };
cmph_t *chd_new(cmph_config_t *mph, double c) { cmph_t *mphf = NULL; chd_data_t *chdf = NULL; chd_config_data_t *chd = (chd_config_data_t *)mph->data; chd_ph_config_data_t * chd_ph = (chd_ph_config_data_t *)chd->chd_ph->data; compressed_rank_t cr; register cmph_t * chd_phf = NULL; register cmph_uint32 packed_chd_phf_size = 0; cmph_uint8 * packed_chd_phf = NULL; register cmph_uint32 packed_cr_size = 0; cmph_uint8 * packed_cr = NULL; register cmph_uint32 i, idx, nkeys, nvals, nbins; cmph_uint32 * vals_table = NULL; register cmph_uint32 * occup_table = NULL; #ifdef CMPH_TIMING double construction_time_begin = 0.0; double construction_time = 0.0; ELAPSED_TIME_IN_SECONDS(&construction_time_begin); #endif cmph_config_set_verbosity(chd->chd_ph, mph->verbosity); cmph_config_set_graphsize(chd->chd_ph, c); if (mph->verbosity) { fprintf(stderr, "Generating a CHD_PH perfect hash function with a load factor equal to %.3f\n", c); } chd_phf = cmph_new(chd->chd_ph); if(chd_phf == NULL) { return NULL; } packed_chd_phf_size = cmph_packed_size(chd_phf); DEBUGP("packed_chd_phf_size = %u\n", packed_chd_phf_size); /* Make sure that we have enough space to pack the mphf. */ packed_chd_phf = calloc((size_t)packed_chd_phf_size,(size_t)1); /* Pack the mphf. */ cmph_pack(chd_phf, packed_chd_phf); cmph_destroy(chd_phf); if (mph->verbosity) { fprintf(stderr, "Compressing the range of the resulting CHD_PH perfect hash function\n"); } compressed_rank_init(&cr); nbins = chd_ph->n; nkeys = chd_ph->m; nvals = nbins - nkeys; vals_table = (cmph_uint32 *)calloc(nvals, sizeof(cmph_uint32)); occup_table = (cmph_uint32 *)chd_ph->occup_table; for(i = 0, idx = 0; i < nbins; i++) { if(!GETBIT32(occup_table, i)) { vals_table[idx++] = i; } } compressed_rank_generate(&cr, vals_table, nvals); free(vals_table); packed_cr_size = compressed_rank_packed_size(&cr); packed_cr = (cmph_uint8 *) calloc(packed_cr_size, sizeof(cmph_uint8)); compressed_rank_pack(&cr, packed_cr); compressed_rank_destroy(&cr); mphf = (cmph_t *)malloc(sizeof(cmph_t)); mphf->algo = mph->algo; chdf = (chd_data_t *)malloc(sizeof(chd_data_t)); chdf->packed_cr = packed_cr; packed_cr = NULL; //transfer memory ownership chdf->packed_chd_phf = packed_chd_phf; packed_chd_phf = NULL; //transfer memory ownership chdf->packed_chd_phf_size = packed_chd_phf_size; chdf->packed_cr_size = packed_cr_size; mphf->data = chdf; mphf->size = nkeys; DEBUGP("Successfully generated minimal perfect hash\n"); if (mph->verbosity) { fprintf(stderr, "Successfully generated minimal perfect hash function\n"); } #ifdef CMPH_TIMING ELAPSED_TIME_IN_SECONDS(&construction_time); register cmph_uint32 space_usage = chd_packed_size(mphf)*8; construction_time = construction_time - construction_time_begin; fprintf(stdout, "%u\t%.2f\t%u\t%.4f\t%.4f\n", nkeys, c, chd_ph->keys_per_bucket, construction_time, space_usage/(double)nkeys); #endif return mphf; }
static inline cmph_uint8 place_bucket_probe(chd_ph_config_data_t *chd_ph, chd_ph_bucket_t *buckets, chd_ph_item_t *items, cmph_uint32 probe0_num, cmph_uint32 probe1_num, cmph_uint32 bucket_num, cmph_uint32 size) { register cmph_uint32 i; register chd_ph_item_t * item; register cmph_uint32 position; item = items + buckets[bucket_num].items_list; // try place bucket with probe_num if(chd_ph->keys_per_bin > 1) { for(i = 0; i < size; i++) // placement { position = (cmph_uint32)((item->f + ((cmph_uint64)item->h)*probe0_num + probe1_num) % chd_ph->n); if(chd_ph->occup_table[position] >= chd_ph->keys_per_bin) { break; } (chd_ph->occup_table[position])++; item++; }; } else { for(i = 0; i < size; i++) // placement { position = (cmph_uint32)((item->f + ((cmph_uint64)item->h)*probe0_num + probe1_num) % chd_ph->n); if(GETBIT32(((cmph_uint32 *)chd_ph->occup_table), position)) { break; } SETBIT32(((cmph_uint32*)chd_ph->occup_table), position); item++; }; }; if(i != size) // Undo the placement { item = items + buckets[bucket_num].items_list; if(chd_ph->keys_per_bin > 1) { while(1) { if(i == 0) { break; } position = (cmph_uint32)((item->f + ((cmph_uint64 )item->h) * probe0_num + probe1_num) % chd_ph->n); (chd_ph->occup_table[position])--; item++; i--; }; } else { while(1) { if(i == 0) { break; } position = (cmph_uint32)((item->f + ((cmph_uint64 )item->h) * probe0_num + probe1_num) % chd_ph->n); UNSETBIT32(((cmph_uint32*)chd_ph->occup_table), position); // ([position/32]^=(1<<(position%32)); item++; i--; }; }; return 0; } return 1; };
/** * @fn PwrCon_set_block_power_on(BLKPWR_DOMAIN eDomain) * @param eDomain The IP Block number in NORMAL_CFG Register to turn on * @note This funciton turn on specific IP Block's power * when the system is in NORMAL Mode, not in other Power mode */ BOOL PwrCon_set_block_power_on(BLKPWR_DOMAIN eDomain) { UINT32 TimeOut; assert(g_pSysConReg); RETAILMSG(PWC_ZONE_ENTER, (_T("[PWRCON]++%s(%d)\n"), _T(__FUNCTION__), eDomain)); TimeOut = 10000000L; // This is big value. switch(eDomain) { case BLKPWR_DOMAIN_IROM: // Internal ROM SETBIT32(g_pSysConReg->NORMAL_CFG, BIT_IROM); break; case BLKPWR_DOMAIN_G: // 3D SETBIT32(g_pSysConReg->NORMAL_CFG, BIT_DOMAIN_G); while(!(GETBIT32(g_pSysConReg->BLK_PWR_STAT, BIT_BLK_G)) || (TimeOut-- == 0)); if(TimeOut == 0) goto Block_Pwr_ON_FAIL; break; case BLKPWR_DOMAIN_ETM: // ETM SETBIT32(g_pSysConReg->NORMAL_CFG, BIT_DOMAIN_ETM); while(!(GETBIT32(g_pSysConReg->BLK_PWR_STAT, BIT_BLK_ETM)) || (TimeOut-- == 0)); if(TimeOut == 0) goto Block_Pwr_ON_FAIL; break; case BLKPWR_DOMAIN_S: // SDMA, Security System SETBIT32(g_pSysConReg->NORMAL_CFG, BIT_DOMAIN_S); while(!(GETBIT32(g_pSysConReg->BLK_PWR_STAT, BIT_BLK_S)) || (TimeOut-- == 0)); if(TimeOut == 0) goto Block_Pwr_ON_FAIL; break; case BLKPWR_DOMAIN_F: // Display Controller, Post Processor, Rotator SETBIT32(g_pSysConReg->NORMAL_CFG, BIT_DOMAIN_F); while(!(GETBIT32(g_pSysConReg->BLK_PWR_STAT, BIT_BLK_F)) || (TimeOut-- == 0)); if(TimeOut == 0) goto Block_Pwr_ON_FAIL; break; case BLKPWR_DOMAIN_P: // FIMG-2D, TV Encoder, TV Scaler SETBIT32(g_pSysConReg->NORMAL_CFG, BIT_DOMAIN_P); while(!(GETBIT32(g_pSysConReg->BLK_PWR_STAT, BIT_BLK_P)) || (TimeOut-- == 0)); if(TimeOut == 0) goto Block_Pwr_ON_FAIL; break; case BLKPWR_DOMAIN_I: // Camera interface, Jpeg SETBIT32(g_pSysConReg->NORMAL_CFG, BIT_DOMAIN_I); while(!(GETBIT32(g_pSysConReg->BLK_PWR_STAT, BIT_BLK_I)) || (TimeOut-- == 0)); if(TimeOut == 0) goto Block_Pwr_ON_FAIL; break; case BLKPWR_DOMAIN_V: // MFC SETBIT32(g_pSysConReg->NORMAL_CFG, BIT_DOMAIN_V); while(!(GETBIT32(g_pSysConReg->BLK_PWR_STAT, BIT_BLK_V)) || (TimeOut-- == 0)); if(TimeOut == 0) goto Block_Pwr_ON_FAIL; break; default: RETAILMSG(PWC_ZONE_ERROR, (_T("[PWRCON:ERR] %s() : Unknown Domain = %d\n"), _T(__FUNCTION__), eDomain)); return FALSE; } RETAILMSG(PWC_ZONE_ENTER, (_T("[PWRCON]--%s()\n"), _T(__FUNCTION__))); return TRUE; Block_Pwr_ON_FAIL: RETAILMSG(TRUE, (_T("[PWRCON:ERR] %s() : Time OUT!! Domain = %d\n"), _T(__FUNCTION__), eDomain)); return FALSE; }