int main(void) { const char ShmName[] = "hello_shm"; const char Msg[] = "Hello World from core 0x%03x!"; char buf[256] = { 0 }; e_coreid_t coreid; e_memseg_t emem; unsigned my_row; unsigned my_col; ///////////////////////////// trace_start_wait_all(); ///////////////////////////// // Who am I? Query the CoreID from hardware. coreid = e_get_coreid(); e_coords_from_coreid(coreid, &my_row, &my_col); if ( E_OK != e_shm_attach(&emem, ShmName) ) { return EXIT_FAILURE; } // Attach to the shm segment snprintf(buf, sizeof(buf), Msg, coreid); if ( emem.size >= strlen(buf) + 1 ) { // Write the message (including the null terminating // character) to shared memory e_write((void*)&emem, buf, my_row, my_col, NULL, strlen(buf) + 1); } else { // Shared memory region is too small for the message return EXIT_FAILURE; } return EXIT_SUCCESS; }
int main(void) { int i = 0, x = 0, j = 0; char name[10] = {0}; row = e_group_config.group_row-32; col = e_group_config.group_col-8; //memory alloc snprintf(name, 10, "_%dmStr%d", row, col); if (E_OK != e_shm_attach(&mem, name)) { return 0; } snprintf(name, 10, "_%dmInp%d", row, col); if (E_OK != e_shm_attach(&inpmem, name)) { return 0; } volatile void* mem_addr = (volatile void*)mem.ephy_base; pmsg = (volatile char*)((char*)mem_addr + MSG_OFF); pmem.parameters = (volatile Spara*)((char*)mem_addr + PARA_OFF); pmem.data = (float*)((char*)mem_addr + DATA_OFF); pmem.syn = (volatile char*)((char*)mem_addr + SYN_OFF); pmem.paraUpdate = (volatile char*)((char*)mem_addr + PARAUP_OFF); pmem.force = (volatile char*)((char*)mem_addr + FORCE_OFF); pmem.reset = (volatile char*)((char*)mem_addr + RESET_OFF); pmem.num = (volatile unsigned *)((char*)mem_addr + NUM_OFF); pmem.msg = (volatile char*)((char*)mem_addr + MSG_OFF); pinp = (volatile float*)inpmem.ephy_base; do{ memcpy((void*)&sp,(void*)(pmem.parameters), sizeof(Spara)); }while(sp.version != pmem.parameters->version); memspace * test = NULL; //e_string_modes(&s1, &sp); e_string_modes_renew(&s1, &sp); snprintf(pmsg,128,"modes num: %d",s1.m); e_inp_gen(&s1, &sp); e_string_output(s1, &sp); return EXIT_SUCCESS; }
int main(void) { unsigned k,i,j; e_dma_desc_t dma_desc; e_dma_desc_t dma_desc1; unsigned *dst, *src; unsigned tran; unsigned *p; unsigned dma_busy; unsigned *test_c1; unsigned *test_c2; e_memseg_t emem; // Attach to the shm segment if ( E_OK != e_shm_attach(&emem, "shm_1") ) { return -1; } tran = 128; p = (unsigned *)emem.ephy_base; // Initialize the buffer address dst = (int *)0x2000; test_c1 = (unsigned *)0x6000; test_c2 = (unsigned *)0x6004; src = p; // Under the message mode // Initialize the source, destination buffer for (k=0; k<tran; k++) { src[k] = 0x12345678; dst[k] = 0x00000000; } src[tran-1] = 0x87654321; // Prepare for the descriptor for 2d dma e_dma_set_desc(E_DMA_0,(E_DMA_ENABLE|E_DMA_MASTER|E_DMA_WORD|E_DMA_MSGMODE), 0x0000, 0x0004, 0x0004, 0x0080, 0x0001, 0x0000, 0x0000, (void *)src,(void *)dst, &dma_desc); // Start transaction e_dma_start(&dma_desc, E_DMA_0); do { dma_busy = e_reg_read(E_REG_DMA0STATUS) & 0xf; } while (dma_busy); test_c1[0] = dst[tran-1]; // Not under message mode // Initialize the source, destination buffer for (k=0; k<tran; k++) { src[k] = 0x12345678; dst[k] = 0x00000000; } src[tran-1] = 0x87654321; // Prepare for the descriptor for 2d dma e_dma_set_desc(E_DMA_0,(E_DMA_ENABLE|E_DMA_MASTER|E_DMA_WORD), 0x0000, 0x0004, 0x0004, 0x0080, 0x0001, 0x0000, 0x0000, (void *)src,(void *)dst, &dma_desc); // Start transaction e_dma_start(&dma_desc, E_DMA_0); do { dma_busy = e_reg_read(E_REG_DMA0STATUS) & 0xf; } while (dma_busy); test_c2[0] = dst[tran-1]; return 0; }