diff 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
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/004_090809/004.c	Tue Sep 08 13:44:18 2009 +0900
@@ -0,0 +1,62 @@
+#include <stdio.h>
+#include <stdint.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <sys/ioctl.h>
+#include <sys/mman.h>
+#include <memory.h>
+
+#include "../../include/ioctl.h"
+#include "../../include/spe_process.h"
+
+
+uint64_t hoge[4] __attribute__((aligned(128))) = { 0x5c812625b0c98a84UL, 0xb0589ae8e319ca7bUL, 0xc797c3af5d2807eaUL, 0x7df3ed18fa5dc081UL };
+
+volatile unsigned char a[1024] __attribute__((aligned(128)));
+
+
+int main(int argc, char *argv[])
+{
+	int fd;
+	fd = open("/dev/spe_manager", O_RDWR);
+	printf("fd: %d\n", fd);
+
+	int fd_mmap;
+	fd_mmap = open("./004", O_RDONLY);
+	printf("fd_mmap: %d\n", fd_mmap);
+	volatile void *mapped = mmap(NULL, 1024, PROT_READ, MAP_SHARED, fd_mmap, 0);
+	printf("ADDR(mapped): 0x%016lx\n", (uint64_t)mapped);
+	printf("ADDR(mapped): 0x%016lx\n", (uint64_t)a);
+
+	memcpy(a, mapped, 1024);
+
+	spe_process_context_write_data_t spe_write = { 0 };
+//	spe_write.pid       =  (int32_t)getpid();
+	spe_write.pgm_start = (uint64_t)a;
+	spe_write.pgm_size  = 1024;
+	spe_write.arg       = 0x5c812625b0c98a84UL;
+
+	spe_process_context_read_data_t  spe_read;
+
+
+	lseek(fd, 0, SEEK_SET);
+	write(fd, &spe_write, sizeof(spe_write));
+
+	ioctl(fd, SPE_MANAGER_IOCTL_START_PROCESS);
+
+	do
+	{
+		lseek(fd, 0, SEEK_SET);
+		read(fd, &spe_read, sizeof(spe_read));
+	}
+	while (spe_read.status != SPE_PROCESS_CONTEXT_STATUS_NOT_RELEASED);
+
+	printf("spe_read.ret: 0x%016lx\n", spe_read.ret);
+
+
+	close(fd_mmap);
+	close(fd);
+	return 0;
+}