comparison tests/004_090809/004.c @ 0:42f240cc4bc6

From: 太田 篤志 <atoc@namikilab.tuat.ac.jp>
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Tue, 08 Sep 2009 13:44:18 +0900
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:42f240cc4bc6
1 #include <stdio.h>
2 #include <stdint.h>
3 #include <sys/types.h>
4 #include <sys/stat.h>
5 #include <fcntl.h>
6 #include <unistd.h>
7 #include <sys/ioctl.h>
8 #include <sys/mman.h>
9 #include <memory.h>
10
11 #include "../../include/ioctl.h"
12 #include "../../include/spe_process.h"
13
14
15 uint64_t hoge[4] __attribute__((aligned(128))) = { 0x5c812625b0c98a84UL, 0xb0589ae8e319ca7bUL, 0xc797c3af5d2807eaUL, 0x7df3ed18fa5dc081UL };
16
17 volatile unsigned char a[1024] __attribute__((aligned(128)));
18
19
20 int main(int argc, char *argv[])
21 {
22 int fd;
23 fd = open("/dev/spe_manager", O_RDWR);
24 printf("fd: %d\n", fd);
25
26 int fd_mmap;
27 fd_mmap = open("./004", O_RDONLY);
28 printf("fd_mmap: %d\n", fd_mmap);
29 volatile void *mapped = mmap(NULL, 1024, PROT_READ, MAP_SHARED, fd_mmap, 0);
30 printf("ADDR(mapped): 0x%016lx\n", (uint64_t)mapped);
31 printf("ADDR(mapped): 0x%016lx\n", (uint64_t)a);
32
33 memcpy(a, mapped, 1024);
34
35 spe_process_context_write_data_t spe_write = { 0 };
36 // spe_write.pid = (int32_t)getpid();
37 spe_write.pgm_start = (uint64_t)a;
38 spe_write.pgm_size = 1024;
39 spe_write.arg = 0x5c812625b0c98a84UL;
40
41 spe_process_context_read_data_t spe_read;
42
43
44 lseek(fd, 0, SEEK_SET);
45 write(fd, &spe_write, sizeof(spe_write));
46
47 ioctl(fd, SPE_MANAGER_IOCTL_START_PROCESS);
48
49 do
50 {
51 lseek(fd, 0, SEEK_SET);
52 read(fd, &spe_read, sizeof(spe_read));
53 }
54 while (spe_read.status != SPE_PROCESS_CONTEXT_STATUS_NOT_RELEASED);
55
56 printf("spe_read.ret: 0x%016lx\n", spe_read.ret);
57
58
59 close(fd_mmap);
60 close(fd);
61 return 0;
62 }