Initial work.
authorethereal <ethereal@ethv.net>
Sun, 7 Jun 2015 00:20:43 +0000 (00:20 +0000)
committerethereal <ethereal@ethv.net>
Sun, 7 Jun 2015 00:20:43 +0000 (00:20 +0000)
.gitignore [new file with mode: 0644]
CMakeLists.txt [new file with mode: 0644]
Makefile [new file with mode: 0644]
build.config [new file with mode: 0644]
src/CMakeLists.txt [new file with mode: 0644]
src/ecore/ecore.c [new file with mode: 0644]
src/ewrap/main.c [new file with mode: 0644]

diff --git a/.gitignore b/.gitignore
new file mode 100644 (file)
index 0000000..a680c7e
--- /dev/null
@@ -0,0 +1,5 @@
+/ecore.srec
+/build
+/ewrap
+
+*.swp
diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100644 (file)
index 0000000..0bfaaae
--- /dev/null
@@ -0,0 +1,9 @@
+cmake_minimum_required(VERSION 2.8)
+
+project(sphoot C)
+
+set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_LIST_DIR})
+
+include(build.config)
+
+add_subdirectory(src)
diff --git a/Makefile b/Makefile
new file mode 100644 (file)
index 0000000..c92961c
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,17 @@
+.PHONY: all
+all:
+       $(MAKE) -C build
+
+.PHONY: redep
+redep:
+       mkdir -p build/
+       cd build/
+       cmake ..
+
+.PHONY: clean
+clean:
+       $(MAKE) -C build clean
+
+.PHONY: distclean
+distclean:
+       rm -rf build/
diff --git a/build.config b/build.config
new file mode 100644 (file)
index 0000000..1ce7c36
--- /dev/null
@@ -0,0 +1,3 @@
+set(build_ecore 1)
+set(build_ewrap 1)
+set(build_inter 0)
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
new file mode 100644 (file)
index 0000000..25f4e04
--- /dev/null
@@ -0,0 +1,22 @@
+add_definitions(-Wall -Wextra -std=c99 -Wno-unused-parameter)
+
+include_directories($ENV{EPIPHANY_HOME}/tools/host/include)
+link_directories($ENV{EPIPHANY_HOME}/tools/host/lib)
+
+if(${build_ecore})
+    #add_custom_command(OUTPUT ecore.o DEPENDS ecore/ecore.s COMMAND e-as ${CMAKE_CURRENT_LIST_DIR}/ecore/ecore.s -o ecore.o)
+    #add_custom_command(OUTPUT ecore.elf DEPENDS ecore.o COMMAND e-ld ecore.o -o ecore.elf)
+    #add_custom_command(OUTPUT ecore.srec DEPENDS ecore.elf COMMAND e-objcopy --srec-forceS3 --output-target srec ecore.elf ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/ecore.srec)
+    #add_custom_target(ecore ALL DEPENDS ecore.srec)
+
+    add_custom_command(OUTPUT ecore.elf DEPENDS ecore/ecore.c COMMAND e-gcc -Wall -Wextra ${CMAKE_CURRENT_LIST_DIR}/ecore/ecore.c -o ecore.elf -le-lib -T$ENV{EPIPHANY_HOME}/bsps/current/internal.ldf)
+    add_custom_command(OUTPUT ecore.srec DEPENDS ecore.elf COMMAND e-objcopy --srec-forceS3 --output-target srec ecore.elf ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/ecore.srec)
+    add_custom_target(ecore ALL DEPENDS ecore.srec)
+endif(${build_ecore})
+
+if(${build_ewrap})
+    aux_source_directory(ewrap ewrap_sources)
+    set(sources ${ewrap_sources})
+    add_executable(ewrap ${sources})
+    target_link_libraries(ewrap e-hal e-loader pthread)
+endif(${build_ewrap})
diff --git a/src/ecore/ecore.c b/src/ecore/ecore.c
new file mode 100644 (file)
index 0000000..b77926b
--- /dev/null
@@ -0,0 +1,27 @@
+#include <stdint.h>
+
+#include "e_lib.h"
+
+int main() {
+    e_coreid_t id = e_get_coreid();
+
+    unsigned x, y;
+    e_coords_from_coreid(id, &x, &y);
+    
+    int iid = y*e_group_config.group_rows + x;
+
+    e_memseg_t mem;
+
+    e_shm_attach(&mem, "message_shm");
+
+    unsigned char buf = 1;
+    *((uint8_t *)mem.ephy_base + iid) = 1;
+    //e_write(&mem, &buf, e_group_config.core_row, e_group_config.core_col, (void *)14, 1);
+    //e_write(&e_emem_config, &buf, e_group_config.core_row, e_group_config.core_col, (void *)0, 1);
+    //uint8_t *ext = (uint8_t*)e_emem_config.base + 0x01000000;
+
+    //ext[0] = 1;
+
+    while(1) {}
+    return 0;
+}
diff --git a/src/ewrap/main.c b/src/ewrap/main.c
new file mode 100644 (file)
index 0000000..e9595b7
--- /dev/null
@@ -0,0 +1,62 @@
+#include <stdint.h>
+#include <stdio.h>
+
+#include "e-hal.h"
+#include "e-loader.h"
+
+int main() {
+    e_platform_t platform;
+    e_epiphany_t dev;
+    e_mem_t mem;
+
+    e_init(NULL);
+    e_reset_system();
+    e_get_platform_info(&platform);
+
+    e_set_host_verbosity(H_D0);
+
+    int r = e_shm_alloc(&mem, "message_shm", platform.rows * platform.cols);
+    if(r != E_OK) r = e_shm_attach(&mem, "message_shm");
+    if(r != E_OK) {
+        printf("Failed to attach to shared memory!\n");
+        return 1;
+    }
+
+    e_open(&dev, 0, 0, platform.rows, platform.cols);
+    printf("rows, cols: %i, %i\n", platform.rows, platform.cols);
+
+
+    uint8_t finished[platform.rows * platform.cols];
+    for(int i = 0; i < platform.rows * platform.cols; i ++) finished[i] = 0;
+    r = e_write(&mem, 0,0, 0, finished, platform.rows * platform.cols);
+    if(r == E_ERR) { printf("Failed to write\n"); }
+
+    e_load_group("ecore.srec", &dev, 0, 0, 4, 4, E_TRUE);
+
+    sleep(1);
+
+    int cnt = 0;
+    while(1) {
+        uint8_t finished[platform.rows * platform.cols];
+        e_read(&mem, 0,0, 0, finished, 16);
+        if(r == E_ERR) { printf("Failed to read\n"); }
+
+        cnt = 0;
+        for(int i = 0; i < 16; i ++) {
+            if(finished[i] != 0) {
+                cnt ++;
+                printf("%i finished! (%i)\n", i, finished[i]);
+            }
+        }
+        if(cnt != 0) break;
+    }
+
+    if(cnt) printf("Received message from a core!\n");
+
+    e_close(&dev);
+
+    e_shm_release("message_shm");
+    e_finalize();
+
+    return 0;
+}