Git Product home page Git Product logo

Comments (2)

ReinForce-II avatar ReinForce-II commented on June 13, 2024
        aes_param_t aes_param;
        aes_param.cipher_mode = AES_CBC;
        aes_param.input_data = new uint8_t[AES_TEST_LENGTH];
        memset(aes_param.input_data, 0x00, AES_TEST_LENGTH);
        aes_param.input_data_len = AES_TEST_LENGTH;
        aes_param.input_key = new uint8_t[16];
        memset(aes_param.input_key, 0x00, 16);
        aes_param.input_key_len = 16;
        aes_param.iv = new uint8_t[16];
        memset(aes_param.iv, 0x00, 16);
        aes_param.iv_len = 16;
        aes_param.output_data = new uint8_t[AES_TEST_LENGTH];
        memset(aes_param.output_data, 0x00, AES_TEST_LENGTH);

        uint64_t mcycle_start, mcycle_end;
        __asm volatile("csrr %0, mcycle" : "=r"(mcycle_start)::);
        aes_hard_encrypt(&aes_param);
        __asm volatile("csrr %0, mcycle" : "=r"(mcycle_end)::);
        auto time_spent = (mcycle_end - mcycle_start) * 1.0 / ck_cpu;
    volatile aes_t *aes = (volatile aes_t *)0x50450000;
    aes->aes_endian |= 1;
    aes->aes_key[0] = 0;
    aes->aes_key[1] = 0;
    aes->aes_key[2] = 0;
    aes->aes_key[3] = 0;
    aes->encrypt_sel = 0;
    aes->mode_ctl.cipher_mode = 0;
    aes->mode_ctl.kmode = 0;
    aes->aes_iv[0] = 0;
    aes->aes_iv[1] = 0;
    aes->aes_iv[2] = 0;
    aes->aes_iv[3] = 0;
    aes->gb_aad_end_adr = -1;
    aes->gb_pc_end_adr = -1;
    aes->gb_aes_en |= 1;
    aes->dma_sel |= 1;
    uint64_t mcycle_start, mcycle_end;
    uint32_t *in = new uint32_t[AES_TEST_LENGTH / sizeof(aes->aes_text_data)];
    uint32_t *out = new uint32_t[AES_TEST_LENGTH / sizeof(aes->aes_text_data)];
    if (!out || !in) {
        printf("AES RAWDMA ALLOC FAILED\n");
        return;
    }
    SemaphoreHandle_t signal_s, signal_r;
    signal_s = xSemaphoreCreateBinary();
    signal_r = xSemaphoreCreateBinary();
    auto h_dma_s = dma_open_free();
    auto h_dma_r = dma_open_free();
    dma_set_request_source(h_dma_r, SYSCTL_DMA_SELECT_AES_REQ);
    __asm volatile("csrr %0, mcycle" : "=r"(mcycle_start)::);
    /*
    * batch size larger than 80B cannot work here
    */
    for (uint64_t i = 0; i < AES_TEST_LENGTH / 160; i++) {
        dma_transmit_async(h_dma_s, &in[i * 40], &aes->aes_text_data, 1, 0, 4,
                           40, 4, signal_s);
        dma_transmit_async(h_dma_r, &aes->aes_out_data, &out[i * 40], 0, 1, 4,
                           40, 4, signal_r);
        xSemaphoreTake(signal_s, 1000);
        xSemaphoreTake(signal_r, 1000);
    }
    __asm volatile("csrr %0, mcycle" : "=r"(mcycle_end)::);
    vSemaphoreDelete(signal_s);
    vSemaphoreDelete(signal_r);
    delete[] in;
    delete[] out;
    auto ck_cpu = sysctl_clock_get_freq(SYSCTL_CLOCK_CPU);
    auto __time = (mcycle_end - mcycle_start) * 1.0 / ck_cpu;

from kendryte-freertos-sdk.

sunnycase avatar sunnycase commented on June 13, 2024

Performance of AES has been improved to ~30MB/s in v0.5.0.

from kendryte-freertos-sdk.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.