// negative_test.c
// 2018/10/28 by marsee
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <unistd.h>
#include "xnegative.h"
int main(){
XNegative xnegative_ap;
volatile unsigned int *udmabuf4_buf;
int udmabuf4_fd, fd_phys_addr;
char attr[1024];
unsigned long phys_addr;
int Xneg_status;
int i;
// udmabuf4
udmabuf4_fd = open("/dev/udmabuf4", O_RDWR); // frame_buffer, The chache is enabled.
if (udmabuf4_fd == -1){
fprintf(stderr, "/dev/udmabuf4 open error\n");
exit(-1);
}
udmabuf4_buf = (volatile unsigned int *)mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_SHARED, udmabuf4_fd, 0);
if (!udmabuf4_buf){
fprintf(stderr, "udmabuf4_buf mmap error\n");
exit(-1);
}
// phys_addr of udmabuf4
fd_phys_addr = open("/sys/class/udmabuf/udmabuf4/phys_addr", O_RDONLY);
if (fd_phys_addr == -1){
fprintf(stderr, "/sys/class/udmabuf/udmabuf4/phys_addr open error\n");
exit(-1);
}
read(fd_phys_addr, attr, 1024);
sscanf(attr, "%lx", &phys_addr);
close(fd_phys_addr);
printf("phys_addr = %x\n", (int)phys_addr);
printf("1"); fflush(stdout);
// data set
for(i=0; i<10; i++){
udmabuf4_buf[i] = i;
}
printf("1"); fflush(stdout);
Xneg_status = XNegative_Initialize(&xnegative_ap, "negative-uio");
if (Xneg_status != XST_SUCCESS){
fprintf(stderr, "Could not Initialize XNegative\n");
return(-1);
}
printf("1"); fflush(stdout);
XNegative_Set_in_r(&xnegative_ap, phys_addr);
printf("1"); fflush(stdout);
XNegative_Set_out_r(&xnegative_ap, (phys_addr+10*sizeof(int)));
printf("1"); fflush(stdout);
XNegative_Set_size(&xnegative_ap, (u32)10);
printf("1"); fflush(stdout);
XNegative_Start(&xnegative_ap);
printf("1"); fflush(stdout);
while(!XNegative_IsDone(&xnegative_ap));
for(i=0; i<10; i++){
printf("data[%d] = %d, result[%d] = %d\n", i, udmabuf4_buf[i], i, udmabuf4_buf[10+i]);
}
return(0);
}
// negative_test2.c
// 2018/10/28 by marsee
//
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <assert.h>
#include <sys/mman.h>
#include <fcntl.h>
#include <unistd.h>
int main(){
volatile unsigned int *udmabuf4_buf;
int udmabuf4_fd, fd_phys_addr;
char attr[1024];
unsigned long phys_addr;
int fd1;
volatile unsigned int *negative;
int i;
// udmabuf4
udmabuf4_fd = open("/dev/udmabuf4", O_RDWR|O_SYNC); // frame_buffer, The chache is enabled.
if (udmabuf4_fd == -1){
fprintf(stderr, "/dev/udmabuf4 open error\n");
exit(-1);
}
udmabuf4_buf = (volatile unsigned int *)mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_SHARED, udmabuf4_fd, 0);
if (!udmabuf4_buf){
fprintf(stderr, "udmabuf4_buf mmap error\n");
exit(-1);
}
// phys_addr of udmabuf4
fd_phys_addr = open("/sys/class/udmabuf/udmabuf4/phys_addr", O_RDONLY);
if (fd_phys_addr == -1){
fprintf(stderr, "/sys/class/udmabuf/udmabuf4/phys_addr open error\n");
exit(-1);
}
read(fd_phys_addr, attr, 1024);
sscanf(attr, "%lx", &phys_addr);
close(fd_phys_addr);
printf("phys_addr = %x\n", (int)phys_addr);
// data set
for(i=0; i<10; i++){
udmabuf4_buf[i] = i;
}
// uio initialize (uio1)
fd1 = open("/dev/uio1", O_RDWR|O_SYNC); // negative IP
if (fd1 < 1){
fprintf(stderr, "/dev/uio1 (negative) open error\n");
exit(1);
}
negative = (volatile unsigned *)mmap(NULL, 0x10000, PROT_READ|PROT_WRITE, MAP_SHARED, fd1, 0);
if (!negative){
fprintf(stderr, "negative mmap error\n");
exit(1);
}
negative[6] = phys_addr; // Data signal of in_r
negative[8] = phys_addr+10*sizeof(int); // Data signal of out_r
negative[10] = 10; // Data signal of size
negative[0] = 1; // ap_start
while (!(negative[0] & 0x2)) ; // ap_done ?
for(i=0; i<10; i++){
printf("data[%d] = %d, result[%d] = %d\n", i, udmabuf4_buf[i], i, udmabuf4_buf[10+i]);
}
munmap((void *)negative, 0x10000);
close(fd1);
munmap((void *)udmabuf4_buf, 0x1000);
close(udmabuf4_fd);
return(0);
}
// DMA_pow2_test2.c
// 2018/10/28 by marsee
//
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <assert.h>
#include <sys/mman.h>
#include <fcntl.h>
#include <unistd.h>
int main(){
volatile unsigned int *udmabuf4_buf;
int udmabuf4_fd, fd_phys_addr;
char attr[1024];
unsigned long phys_addr;
int fd1;
volatile unsigned int *dma_pow2;
int i;
// udmabuf4
udmabuf4_fd = open("/dev/udmabuf4", O_RDWR); // frame_buffer, The chache is enabled.
if (udmabuf4_fd == -1){
fprintf(stderr, "/dev/udmabuf4 open error\n");
exit(-1);
}
udmabuf4_buf = (volatile unsigned int *)mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_SHARED, udmabuf4_fd, 0);
if (!udmabuf4_buf){
fprintf(stderr, "udmabuf4_buf mmap error\n");
exit(-1);
}
// phys_addr of udmabuf4
fd_phys_addr = open("/sys/class/udmabuf/udmabuf4/phys_addr", O_RDONLY);
if (fd_phys_addr == -1){
fprintf(stderr, "/sys/class/udmabuf/udmabuf4/phys_addr open error\n");
exit(-1);
}
read(fd_phys_addr, attr, 1024);
sscanf(attr, "%lx", &phys_addr);
close(fd_phys_addr);
printf("phys_addr = %x\n", (int)phys_addr);
// data set
for(i=0; i<20; i++){
udmabuf4_buf[i] = i;
}
// uio initialize (uio1)
fd1 = open("/dev/uio1", O_RDWR|O_SYNC); // dma_pow2 IP
if (fd1 < 1){
fprintf(stderr, "/dev/uio1 (dma_pow2) open error\n");
exit(1);
}
dma_pow2 = (volatile unsigned *)mmap(NULL, 0x10000, PROT_READ|PROT_WRITE, MAP_SHARED, fd1, 0);
if (!dma_pow2){
fprintf(stderr, "dma_pow2 mmap error\n");
exit(1);
}
printf("Address of int size is %d\n", sizeof(int *));
dma_pow2[6] = phys_addr; // Data signal of in_r
dma_pow2[8] = phys_addr+10*sizeof(int); // Data signal of out_r
dma_pow2[0] = 1; // ap_start
while (!(dma_pow2[0] & 0x2)) ; // ap_done ?
for(i=0; i<10; i++){
printf("data[%d] = %d, result[%d] = %d\n", i, udmabuf4_buf[i], i, udmabuf4_buf[10+i]);
}
munmap((void *)dma_pow2, 0x10000);
close(fd1);
munmap((void *)udmabuf4_buf, 0x1000);
close(udmabuf4_fd);
return(0);
}
日 | 月 | 火 | 水 | 木 | 金 | 土 |
---|---|---|---|---|---|---|
- | - | - | - | - | 1 | 2 |
3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | 21 | 22 | 23 |
24 | 25 | 26 | 27 | 28 | 29 | 30 |
31 | - | - | - | - | - | - |