Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <sys/mman.h>
- #include <fcntl.h>
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include <unistd.h>
- #define PAGESIZE 4096
- #define SHIFT_AMOUNT 28
- /*
- output = BASE_ADDR
- op1 = BASE_ADDR + sizeof(int)
- op2 = BASE_ADDR + 2*sizeof(int)
- */
- #define BASE_ADDR (0x43C00000)
- int main(int argc, char *argv[])
- {
- int fd;
- int *ptr;
- fd = open("/dev/mem", O_RDWR | O_SYNC);
- int32_t op1, op2;
- int32_t mul = (1 << SHIFT_AMOUNT);
- op1 = (0.25 * mul);
- op2 = (1.0 * mul);
- int32_t re, im;
- int32_t re_o, im_o;
- re = (0.25 * mul);
- im = (1.5 * mul);
- //write(fd, op1, sizeof(op1));
- //write(fd, op2, sizeof(op2));
- ptr = (int *) mmap(NULL, PAGESIZE, PROT_READ | PROT_WRITE, MAP_SHARED, fd, BASE_ADDR);
- close(fd);
- ptr[2] = re;
- ptr[3] = im;
- printf("pointer to mem-mapped file: %p\n", ptr);
- printf("re: %lf\n", ((double)re/mul));
- printf("im: %lf\n", ((double)im/mul));
- printf("re*re: %lf\n", ((double)ptr[4]/mul));
- printf("im*im: %lf\n", ((double)ptr[5]/mul));
- printf("iter_o: %d\n", ptr[6]);
- //printf("%d * %d = %d\n", op1, op2, (op1 + op2))
- //double erg = (double)ptr[0]/mul;
- //printf("erg: %f\n", erg);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement