Example #1
0
int fimg2d4x_bitblt(struct fimg2d_control *ctrl)
{
	int ret = 0;
	enum addr_space addr_type;
	struct fimg2d_context *ctx;
	struct fimg2d_bltcmd *cmd;
	unsigned long *pgd;

	fimg2d_debug("enter blitter\n");

	while (1) {
		cmd = fimg2d_get_command(ctrl);
		if (!cmd)
			break;

		ctx = cmd->ctx;

		atomic_set(&ctrl->busy, 1);

		perf_start(cmd, PERF_SFR);
		ctrl->configure(ctrl, cmd);
		perf_end(cmd, PERF_SFR);

		addr_type = cmd->image[IDST].addr.type;

		if (addr_type == ADDR_USER || addr_type == ADDR_USER_CONTIG) {
			if(!ctx->mm || !ctx->mm->pgd) {
				atomic_set(&ctrl->busy, 0);
				goto fail_n_del;
			}
			pgd = (unsigned long *)ctx->mm->pgd;
			exynos_sysmmu_enable(ctrl->dev,
					(unsigned long)virt_to_phys(pgd));
			fimg2d_debug("sysmmu enable: pgd %p ctx %p seq_no(%u)\n",
					pgd, ctx, cmd->blt.seq_no);

			exynos_sysmmu_set_pbuf(ctrl->dev, nbufs, prefbuf);
			fimg2d_debug("set smmu prefbuf\n");
		}

		fimg2d4x_pre_bitblt(ctrl, cmd);

		perf_start(cmd, PERF_BLIT);
		/* start blit */
		ctrl->run(ctrl);
		ret = fimg2d4x_blit_wait(ctrl, cmd);
		perf_end(cmd, PERF_BLIT);

		if (addr_type == ADDR_USER || addr_type == ADDR_USER_CONTIG) {
			exynos_sysmmu_disable(ctrl->dev);
			fimg2d_debug("sysmmu disable\n");
		}
fail_n_del:
		fimg2d_del_command(ctrl, cmd);
	}

	fimg2d_debug("exit blitter\n");

	return ret;
}
Example #2
0
/**
 * \brief  soft interrupt
 * \details Call trap_s instruction to raise the exception.
 * \param[in] *p_excinf
 */
static void soft_interrupt(void *p_exinf)
{
	//// 2-E: Task1 --> Int
	x.t_t1_int = perf_end();
	//// 3-S: Int --> Nest Int
	perf_start();
	Asm("trap_s 1");
	//// 4-E: Nest Int --> Int
	x.t_nest_int = perf_end();
	//// 5-S: Int --> Task1
	perf_start();
}
Example #3
0
/**
 * \brief  trap exception
 * \details Call xTaskResumeFromISR() to resume task2 that can be called from within ISR.
 * If resuming the task2 should result in a context switch, call vPortYieldFromIsr() to generate task switch request.
 * \param[in] *p_excinf
 */
static void trap_exception(void *p_excinf)
{
	//// 3-E: Int --> Nest Int
	x.t_int_nest = perf_end();
	//// 4-S: Nest Int --> Int
	perf_start();
}
Example #4
0
static double perf_ccccm_update(unsigned long loops, unsigned long size, const void *arg)
{
    const struct ccccm_perf_test *test=arg;
    const struct ccmode_ccm *ccm=test->ccm;
    size_t keylen=test->keylen;
    unsigned long nblocks=size/ccm->block_size;

    unsigned char keyd[keylen];
    unsigned char nonced[13];
    unsigned char temp[nblocks*ccm->block_size];

    cc_zero(keylen,keyd);
    cc_zero(sizeof(nonced),nonced);
    ccccm_ctx_decl(ccm->size, key);
    ccccm_nonce_decl(ccm->nonce_size, nonce);

    ccccm_init(ccm, key, keylen, keyd);
    ccccm_set_iv(ccm,key, nonce, sizeof(nonced), nonced,16,size,0);
    ccccm_cbcmac(ccm,key, nonce, size, temp);

    perf_start();
    while(loops--)
        ccccm_update(ccm,key, nonce, size, temp, temp);

    return perf_time();
}
Example #5
0
static double perf_ccccm_one_shot(unsigned long loops, unsigned long size, const void *arg)
{
    const struct ccccm_perf_test *test=arg;
    const struct ccmode_ccm *ccm=test->ccm;
    size_t keylen=test->keylen;
    unsigned long nblocks=size/ccm->block_size;

    unsigned char temp[nblocks*ccm->block_size];
    unsigned char keyd[keylen];
    unsigned char tag[16]={0};
    unsigned char nonced[13];
    cc_zero(keylen,keyd);
    cc_zero(sizeof(nonced),nonced);

    perf_start();
    while(loops--) {
        ccccm_one_shot(ccm,
                       keylen,keyd, // Key
                       sizeof(nonced),nonced,      // Nonce
                       size, temp, temp, // Data in/out
                       0, NULL,         // Authenticated data
                       sizeof(tag), tag); // Tag
    }

    return perf_time();
}
Example #6
0
int main(int argc, char *argv[])
{
	int i;
	void *buf;
	uint16_t crc;
	struct perf start, stop;

	printf("crc16_t10dif_perf:\n");

	if (posix_memalign(&buf, 1024, TEST_LEN)) {
		printf("alloc error: Fail");
		return -1;
	}

	printf("Start timed tests\n");
	fflush(0);

	memset(buf, 0, TEST_LEN);
	crc = crc16_t10dif(TEST_SEED, buf, TEST_LEN);
	perf_start(&start);
	for (i = 0; i < TEST_LOOPS; i++) {
		crc = crc16_t10dif(TEST_SEED, buf, TEST_LEN);
	}
	perf_stop(&stop);
	printf("crc16_t10dif" TEST_TYPE_STR ": ");
	perf_print(stop, start, (long long)TEST_LEN * i);

	printf("finish 0x%x\n", crc);
	return 0;
}
Example #7
0
static double perf_ccccm_finalize(unsigned long loops, unsigned long size CC_UNUSED, const void *arg)
{
    const struct ccccm_perf_test *test=arg;
    const struct ccmode_ccm *ccm=test->ccm;
    size_t keylen=test->keylen;

    unsigned char keyd[keylen];
    unsigned char nonced[13];
    unsigned char tag[16]={0};
    unsigned char data[16]={0};

    cc_zero(keylen,keyd);
    cc_zero(sizeof(nonced),nonced);
    ccccm_ctx_decl(ccm->size, key);
    ccccm_nonce_decl(ccm->nonce_size, nonce);

    ccccm_init(ccm, key, keylen, keyd);
    ccccm_set_iv(ccm,key, nonce, sizeof(nonced), nonced,sizeof(tag),size,0);
    ccccm_cbcmac(ccm,key, nonce, 0, NULL);
    ccccm_update(ccm,key, nonce, sizeof(data), data, data);

    perf_start();
    while(loops--)
        ccccm_finalize(ccm, key, nonce, tag);

    return perf_time();
}
Example #8
0
int main() {

  test_setup();
  perf_start();

  for (int i = 0; i < NUM_ITER; ++i) {
    test_clear();

    reset_timer();
    start_timer();

    test_run(i);

    stop_timer();

    samples[i] = get_time();
  }

  perf_stop();
  int check = test_check();

  printf("Correct: %d\n", check);
  for (int i = 0; i < NUM_ITER; ++i)
    printf("TS[%d]: %d\n", i, samples[i]);

  perf_print_all();

  return 0;
}
Example #9
0
static int fimg2d_check_dma_sync(struct fimg2d_bltcmd *cmd)
{
	struct mm_struct *mm = cmd->ctx->mm;

	fimg2d_calc_dma_size(cmd);

	if (fimg2d_check_address(cmd))
		return -EINVAL;

	if (fimg2d_check_pgd(mm, cmd))
		return -EFAULT;

#ifndef CCI_SNOOP
	fimg2d_debug("cache flush\n");
	perf_start(cmd, PERF_CACHE);
	if (is_inner_flushall(cmd->dma_all)) {
		inner_touch_range(cmd);
		flush_all_cpu_caches();
	} else {
		inner_flush_clip_range(cmd);
	}

#ifdef CONFIG_OUTER_CACHE
	if (is_outer_flushall(cmd->dma_all))
		outer_flush_all();
	else
		outer_flush_clip_range(cmd);
#endif
	perf_end(cmd, PERF_CACHE);
#endif
	return 0;
}
Example #10
0
int main(void)
{
	int i;

	unsigned char key1[16], key2[16], tinit[16];
	unsigned char *pt, *ct;

	printf("aes_xts_128_enc_perf:\n");

	pt = malloc(TEST_LEN);
	ct = malloc(TEST_LEN);

	if (NULL == pt || NULL == ct) {
		printf("malloc of testsize failed\n");
		return -1;
	}

	mk_rand_data(key1, key2, tinit, pt, TEST_LEN);
	XTS_AES_128_enc(key2, key1, tinit, TEST_LEN, pt, ct);

	struct perf start, stop;

	perf_start(&start);

	for (i = 0; i < TEST_LOOPS; i++) {
		XTS_AES_128_enc(key2, key1, tinit, TEST_LEN, pt, ct);
	}

	perf_stop(&stop);

	printf("aes_xts_128_enc" TEST_TYPE_STR ": ");
	perf_print(stop, start, (long long)TEST_LEN * i);

	return 0;
}
Example #11
0
static double perf_ccxts_update(unsigned long loops, unsigned long size, const void *arg)
{
    const struct ccxts_perf_test *test=arg;
    const struct ccmode_xts *xts=test->xts;
    size_t keylen=test->keylen;
    unsigned long nblocks=size/xts->block_size;

    unsigned char keyd[keylen];
    unsigned char tweakkeyd[keylen];
    unsigned char tweakd[xts->block_size];
    unsigned char temp[nblocks*xts->block_size];

    cc_zero(keylen,keyd);
    cc_zero(sizeof(tweakd),tweakd);
    ccxts_ctx_decl(xts->size, key);
    ccxts_tweak_decl(xts->tweak_size, tweak);

    ccxts_init(xts, key, keylen, keyd, tweakkeyd);
    ccxts_set_tweak(xts, key, tweak, tweakd);

    perf_start();
    while(loops--)
        ccxts_update(xts, key, tweak, nblocks, temp, temp);

    return perf_time();
}
Example #12
0
int mac_load(char *name, MFDB *out, GEM_WINDOW *wprog)
{
  FILE   *stream ;
  size_t taille ;
  void   *in ;

  perf_start( PERF_DISK, &PerfInfo ) ;
  stream = fopen(name, "rb") ;
  if (stream == NULL) return(-1) ;
  
  fseek(stream, 0x280, SEEK_SET) ;
  out->fd_nplanes = 1 ;
  out->fd_w       = 576 ; 
  out->fd_h       = 720 ;
  out->fd_stand   = 0 ;
  out->fd_wdwidth = out->fd_w/16 ;
  out->fd_addr    = img_alloc(576, 720, 1) ;
  if (out->fd_addr == NULL)
  {
    fclose(stream) ;
    return(-3) ;
  }

  taille = file_size(name)-sizeof(MACPAINT_HEADER) ;
  in     = malloc(taille) ;
  if (in == NULL)
  {
    fclose(stream) ;
    free(out->fd_addr) ;
    return(-3) ;
  }
  fread(in, taille, 1, stream) ;
  fclose(stream) ;
  perf_stop( PERF_DISK, &PerfInfo ) ;

  perf_start( PERF_COMPRESS, &PerfInfo ) ;
  packbits_dcmps(in, out->fd_addr, out->fd_w, out->fd_h, out->fd_nplanes) ;
  perf_stop( PERF_COMPRESS, &PerfInfo ) ;

  free(in) ;

  return(0) ;
}
Example #13
0
static double perf_ccn_cmp(unsigned long loops, cc_size count)
{
    cc_unit s[count];
    cc_unit t[count];
    ccn_random(count, s, rng);
    ccn_set(count, t, s);
    perf_start();
    do {
        r_for_cmp=ccn_cmp(count, s, t);
    } while (--loops != 0);
    return perf_time();
}
Example #14
0
static double perf_cced25519_make_key_pair(unsigned long loops, 
        CC_UNUSED unsigned long size, const struct ccdigest_info *di)
{
    ccec25519secretkey sk;
    ccec25519pubkey pk;

    perf_start();
    do {
        cced25519_make_key_pair(di, rng, pk, sk);
    } while (--loops != 0);
    return perf_time();
}
Example #15
0
static double perf_cccurve25519_make_pub(unsigned long loops,
                                           CC_UNUSED unsigned long size, CC_UNUSED const struct ccdigest_info *di)
{
    ccec25519secretkey sk;
    ccec25519pubkey pk;
    cccurve25519_make_priv(rng, sk);

    perf_start();
    do {
        cccurve25519_make_pub(pk, sk);
    } while (--loops != 0);
    return perf_time();
}
Example #16
0
static void
performance(const char *family, const char *name, unsigned long trimCounter,
            size_t blocksize, void func(void *context), void *context)
{
    /* first trim */
    unsigned long bytes;
    unsigned long count;
    double t;

    /*
     * First figure out a good counter for about 10s worth of runtime
     */

    count = trimCounter;
    {
        perf_start();
        while (count-- > 1)
            func(context);

        t = perf_time();
    }

    count = RUNTIME * trimCounter / t;
    bytes = count * blocksize;

    {
        perf_start();
        while (count-- > 1)
            func(context);

        t = perf_time();
    }

    printf("%-15s%-20s\tblocksize %8zd\ttime: %8.4lfs\tbyte/s: %12.0lf\n",
           family, name, blocksize, t,
           ((double)bytes) / RUNTIME);

}
Example #17
0
static double perf_ccrng_CommonCrypto_generate(unsigned long loops, size_t nbytes)
{
    uint8_t results[nbytes];
    CC_UNUSED int status;
    double time;

    perf_start();
    do {
        status = ccrng_generate((struct ccrng_state *)&nist_ctx, nbytes, results);
        cc_assert(status==0);
    } while (--loops != 0);
    time=perf_time();

    return time;
}
Example #18
0
static double perf_ccecb_init(unsigned long loops, unsigned long size CC_UNUSED, const void *arg)
{
    const struct ccecb_perf_test *test=arg;
    const struct ccmode_ecb *ecb=test->ecb;
    size_t keylen=test->keylen;

    unsigned char keyd[keylen];
    cc_zero(keylen,keyd);
    ccecb_ctx_decl(ecb->size, key);

    perf_start();
    while(loops--)
        ccecb_init(ecb, key, keylen, keyd);
    return perf_time();
}
Example #19
0
static double perf_cccmac(unsigned long loops, unsigned long size, const void *arg)
{
    const struct cccmac_perf_test *test=arg;
    unsigned char mac[test->cbc->block_size];
    unsigned char key[test->keylen];
    unsigned char data[size];

    cc_zero(test->keylen,key);

    perf_start();
    do {
        cccmac(test->cbc, key,
               size, data, mac);
    } while (--loops != 0);
    return perf_time();
}
Example #20
0
static double perf_cccbc_init(unsigned long loops, unsigned long size CC_UNUSED, const void *arg)
{
    const struct cccbc_perf_test *test=arg;
    const struct ccmode_cbc *cbc=test->cbc;
    size_t keylen=test->keylen;

    unsigned char keyd[keylen];

    cc_zero(keylen,keyd);
    cccbc_ctx_decl(cbc->size, key);

    perf_start();
    while(loops--)
        cccbc_init(cbc, key, keylen, keyd);

    return perf_time();
}
Example #21
0
static double perf_cced25519_sign(unsigned long loops, 
        unsigned long size, const struct ccdigest_info *di)
{
    ccec25519secretkey sk;
    ccec25519pubkey pk;
    cced25519_make_key_pair(di, rng, pk, sk);
    ccec25519signature sig;

    uint8_t msg[size];
    memset(msg,0xaa,size);

    perf_start();
    do {
        cced25519_sign(di, sig, sizeof(msg), msg, pk, sk);
    } while (--loops != 0);
    return perf_time();
}
Example #22
0
static double perf_ccrng_system_oneshot(unsigned long loops, size_t nbytes)
{
    struct ccrng_system_state system_ctx;
    CC_UNUSED int status;
    uint8_t results[nbytes];
    double time;

    perf_start();
    do {
        status = ccrng_system_init(&system_ctx);
        cc_assert(status==0);
        status = ccrng_generate((struct ccrng_state *)&system_ctx, nbytes, results);
        cc_assert(status==0);
        ccrng_system_done(&system_ctx);
    } while (--loops != 0);
    time=perf_time();
    return time;
}
Example #23
0
static double perf_ccxts_init(unsigned long loops, unsigned long size  CC_UNUSED, const void *arg)
{
    const struct ccxts_perf_test *test=arg;
    const struct ccmode_xts *xts=test->xts;
    size_t keylen=test->keylen;

    unsigned char keyd[keylen];
    unsigned char tweakkeyd[keylen];

    cc_zero(keylen,keyd);
    ccxts_ctx_decl(xts->size, key);

    perf_start();
    while(loops--)
        ccxts_init(xts, key, keylen, keyd, tweakkeyd);

    return perf_time();
}
Example #24
0
static double perf_cccbc_one_shot(unsigned long loops, unsigned long size, const void *arg)
{
    const struct cccbc_perf_test *test=arg;
    const struct ccmode_cbc *cbc=test->cbc;
    size_t keylen=test->keylen;
    unsigned long nblocks=size/cbc->block_size;

    unsigned char keyd[keylen];
    unsigned char temp[nblocks*cbc->block_size];

    cc_zero(keylen,keyd);
    perf_start();
    while(loops--) {
        cccbc_one_shot(cbc,keylen,keyd,NULL,nblocks,temp, temp);
    }

    return perf_time();
}
void
perf_push (int type)
{
  struct perf *prev;
  struct perf *cur;

  ASSERT (SIZE(metric_names) == PERF_N);
  push_perf_index (type);

  prev = get_perf (-2);
  cur = get_perf (-1);

  ASSERT (cur);

  if (prev)
    perf_interrupt (prev);
  perf_start (cur);
}
Example #26
0
static double perf_ccansikdf(unsigned long loops, unsigned long size, const void *arg)
{
    const struct ccansikdf_perf_test *test=arg;
    unsigned long Zlen=test->Zlen;
    unsigned char Z[Zlen];
    unsigned long sharedInfoLen=0;
    unsigned char *sharedInfo=NULL;
    unsigned long outputLen=size;
    unsigned char output[outputLen];

    ccrng_generate(rng, Zlen, Z);

    perf_start();
    do {
        ccansikdf_x963(test->di, Zlen, Z, sharedInfoLen, sharedInfo, outputLen, output);
    } while (--loops != 0);
    return perf_time();
}
static int fimg2d_check_dma_sync(struct fimg2d_bltcmd *cmd)
{
	struct mm_struct *mm = cmd->ctx->mm;
	struct fimg2d_dma *c;
	enum pt_status pt;
	int i;

	fimg2d_calc_dma_size(cmd);

	if (fimg2d_check_address(cmd))
		return -EINVAL;

	for (i = 0; i < MAX_IMAGES; i++) {
		c = &cmd->dma[i].base;
		if (!c->size)
			continue;

		pt = fimg2d_check_pagetable(mm, c->addr, c->size);
		if (pt == PT_FAULT)
			return -EFAULT;
	}

#ifndef CCI_SNOOP
	fimg2d_debug("cache flush\n");
	perf_start(cmd, PERF_CACHE);

	if (is_inner_flushall(cmd->dma_all)) {
		inner_touch_range(cmd);
		flush_all_cpu_caches();
	} else {
		inner_flush_clip_range(cmd);
	}

#ifdef CONFIG_OUTER_CACHE
	if (is_outer_flushall(cmd->dma_all))
		outer_flush_all();
	else
		outer_flush_clip_range(cmd);
#endif
	perf_end(cmd, PERF_CACHE);
#endif
	return 0;
}
Example #28
0
static double perf_ccecb_one_shot(unsigned long loops, unsigned long size, const void *arg)
{
    const struct ccecb_perf_test *test=arg;
    const struct ccmode_ecb *ecb=test->ecb;
    size_t keylen=test->keylen;
    unsigned long nblocks=size/ecb->block_size;

    unsigned char keyd[keylen];
    unsigned char temp[nblocks*ecb->block_size];

    cc_zero(keylen,keyd);

    perf_start();
    while(loops--) {
        ccecb_one_shot(ecb,keylen, keyd, nblocks, temp, temp);
    }

    return perf_time();
}
Example #29
0
/**
 * \brief  task1 in FreeRTOS
 * \details Call vTaskDelayUntil() to execute task1 with a fixed period 1 second.
 * \param[in] *par
 */
static void task1(void *par)
{
	uint32_t queue_data = 1;
	TickType_t xLastExecutionTime;
	xLastExecutionTime = xTaskGetTickCount(); /*!< initialize current tick */

	while (1) {
		//// 1-E: Task2 --> Task1
		x.t_t2_t1 = perf_end();
		//// 2-S: Task1 --> Int
		perf_start();
		_arc_aux_write(AUX_IRQ_HINT, SWI_INTNO); /*!< activate soft_interrupt */
		//// 5-E: Int --> Task1
		x.t_int_t1 = perf_end();

		// task delay, to control benchmark run speed
		vTaskDelayUntil( &xLastExecutionTime, TASK_DELAY_MS);
		// Task 1 acquire mutex first
		xSemaphoreTake(mux1_id, portMAX_DELAY);
		// Task 1 acquire semaphore first
		xSemaphoreTake(sem1_id, portMAX_DELAY);

		//// 6-S: Task1 --> Task2
		perf_start();
		vTaskResume(task2_handle);

		//// 8-S: Mutex Release -> Mutex Acquire
		perf_start();
		// Task 1 release mutex, task 2 acquire it
		xSemaphoreGive(mux1_id);

		//// 9-S: Sem Post -> Sem Acquire
		perf_start();
		// Task 1 post sem, task 2 acquire it
		xSemaphoreGive(sem1_id);

		//// 10-S: Event Write -> Event Read
		perf_start();
		// Task 1 write event, task 2 read it
		xEventGroupSetBits(evt1_cb, EVENT_WAIT_BITS);

		//// 11-S: Queue Write -> Queue Read
		perf_start();
		// Task 1 write queue, task 2 read it
		xQueueSend(dtq1_id, (void *)(&queue_data),  portMAX_DELAY);
		queue_data ++;
	}

}
Example #30
0
static double perf_ccccm_set_iv(unsigned long loops, unsigned long size CC_UNUSED, const void *arg)
{
    const struct ccccm_perf_test *test=arg;
    const struct ccmode_ccm *ccm=test->ccm;
    size_t keylen=test->keylen;

    unsigned char keyd[keylen];
    unsigned char nonced[7];

    cc_zero(keylen,keyd);
    cc_zero(sizeof(nonced),nonced);
    ccccm_ctx_decl(ccm->size, key);
    ccccm_nonce_decl(ccm->nonce_size, nonce);
    ccccm_init(ccm, key, keylen, keyd);

    perf_start();
    while(loops--)
        ccccm_set_iv(ccm,key, nonce, sizeof(nonced), nonced,16,16,16);

    return perf_time();
}