summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 3707476)
raw | patch | inline | side by side (parent: 3707476)
author | eanjum <etsam_anjum@mentor.com> | |
Fri, 10 Oct 2014 10:24:20 +0000 (15:24 +0500) | ||
committer | eanjum <etsam_anjum@mentor.com> | |
Fri, 10 Oct 2014 10:24:20 +0000 (15:24 +0500) |
218 files changed:
diff --git a/Makefile b/Makefile
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,45 @@
+# Make file to create ipc stack library.\r
+\r
+# Include commons make file to get platform and tool chain specific variables.\r
+include Makefile.commons\r
+\r
+LIB := libs/open_amp/libopen_amp.a\r
+\r
+HEADERS += \\r
+$(wildcard */*.h) \\r
+$(wildcard *.h)\r
+\r
+C_SRCFILES += \\r
+$(wildcard *.c) \\r
+$(wildcard */*.c) \\r
+$(wildcard */*/*/*.c) \\r
+$(wildcard */*/*.c)\r
+\r
+AS_SRCFILES += \\r
+$(wildcard *.S) \\r
+$(wildcard */*.S) \\r
+$(wildcard */*/*/*.S) \\r
+$(wildcard */*/*.S)\r
+\r
+OBJFILES := $(patsubst %.c, %.o, $(C_SRCFILES)) $(patsubst %.S, %.o, $(AS_SRCFILES))\r
+\r
+DEPFILES := $(patsubst %.c, %.d, $(C_SRCFILES)) $(patsubst %.S, %.d, $(AS_SRCFILES))\r
+\r
+all: $(LIB)\r
+\r
+$(LIB): $(OBJFILES)\r
+ @echo AR $@\r
+ @$(AR) -r $@ $(OBJFILES)\r
+\r
+%.o:%.c $(HEADERS)\r
+ @echo CC $(<:.c=.o)\r
+ @$(CC) $(CFLAGS) $(ARCH_CFLAGS) $(INCLUDE) -c $< -o $@\r
+\r
+%.o:%.S\r
+ @echo AS $(<:.S=.o)\r
+ @$(AS) $(ARCH_ASFLAGS) $(INCLUDE) $< -o $@\r
+\r
+clean:\r
+ -$(RM) $(LIB) $(OBJFILES) $(DEPFILES)\r
+\r
+PHONY: all clean\r
diff --git a/Makefile.commons b/Makefile.commons
--- /dev/null
+++ b/Makefile.commons
@@ -0,0 +1,85 @@
+\r
+TOOLSET := csgnu\r
+CROSS := arm-xilinx-eabi-\r
+CFLAGS := -Wall -ffunction-sections -fdata-sections -O0 -g3 -MMD \r
+CXXFLAGS := -Wall -fno-enforce-eh-specs -MMD\r
+ASFLAGS := -gdwarf2 -meabi=4 -mcpu=cortex-a9 -mfpu=neon\r
+ARFLAGS := \r
+ARCH_CFLAGS := -gdwarf-2 -mthumb-interwork -mcpu=cortex-a9\r
+ARCH_CXXFLAGS := -gdwarf-2 -mthumb-interwork -mcpu=cortex-a9\r
+ARCH_ASFLAGS := -gdwarf-2 -mthumb-interwork -mcpu=cortex-a9\r
+ARCH_ARFLAGS := \r
+CC = $(CROSS)gcc\r
+CXX = $(CROSS)g++\r
+AS = $(CROSS)as\r
+AR = $(CROSS)ar\r
+LD = $(CROSS)gcc\r
+OBJCPY = $(CROSS)objcopy\r
+INCLUDE := \r
+RM := rm -f\r
+CP := cp\r
+OHOME := $(OPENAMP)\r
+\r
+ifeq ($(PLAT),)\r
+export PLAT := zc702evk\r
+endif\r
+\r
+ifeq ($(OS),)\r
+export OS := nucleus\r
+endif\r
+\r
+BAREMETAL_INCLUDES := -I"$(OHOME)/libs/system/$(PLAT)/baremetal"\r
+NUCLEUS_INCLUDES := -I"$(OHOME)/libs/system/$(PLAT)/nucleus/arch/arm/tool-csgnu_arm" -I"$(OHOME)/libs/system/$(PLAT)/nucleus/bsp/arch/plat-zynq7000" -I"$(OHOME)/libs/system/$(PLAT)/nucleus" -I"$(OHOME)/libs/system/$(PLAT)/nucleus/arch/arm" \r
+GENERAL_INCLUDES := -I"$(OHOME)/include"\r
+\r
+ifeq ($(OS),nucleus)\r
+CFLAGS += $(NUCLEUS_INCLUDES)\r
+CFLAGS +=-D"ENV=0"\r
+ifeq ($(ROLE),master)\r
+CFLAGS +=-I"$(OHOME)/libs/system/$(PLAT)/nucleus/lib/$(CROSS)/master"\r
+CFLAGS+=-D"MASTER=1"\r
+else\r
+CFLAGS +=-I"$(OHOME)/libs/system/$(PLAT)/nucleus/lib/$(CROSS)/remote"\r
+CFLAGS+=-D"MASTER=0"\r
+endif\r
+endif\r
+\r
+ifeq ($(OS),baremetal)\r
+CFLAGS += $(BAREMETAL_INCLUDES)\r
+CFLAGS +=-D"ENV=1"\r
+\r
+ifeq ($(ROLE),master)\r
+CFLAGS+=-D"MASTER=1"\r
+else\r
+CFLAGS+=-D"MASTER=0"\r
+endif\r
+endif\r
+\r
+ifeq ($(BENCHMARK),1)\r
+CFLAGS+=-D"OPENAMP_BENCHMARK_ENABLE"\r
+endif\r
+\r
+ifeq ($(LINUXREMOTE),1)\r
+CFLAGS+=-D"OPENAMP_REMOTE_LINUX_ENABLE"\r
+endif\r
+\r
+CFLAGS += $(GENERAL_INCLUDES)\r
+\r
+#The example make file for csgnu and zynq platform would look like below\r
+\r
+#TOOLSET := csgnu\r
+#CROSS := arm-none-eabi-\r
+#CFLAGS := -Wall -ffunction-sections -fdata-sections -O0 -g3\r
+#CXXFLAGS := -Wall -fno-enforce-eh-specs\r
+#ASFLAGS := -gdwarf2 -meabi=4 -mcpu=cortex-a9 -mfpu=neon\r
+#ARFLAGS := \r
+#ARCH_CFLAGS := -gdwarf-2 -mthumb-interwork -mcpu=cortex-a9\r
+#ARCH_CXXFLAGS := -gdwarf-2 -mthumb-interwork -mcpu=cortex-a9\r
+#ARCH_ASFLAGS := -gdwarf-2 -mthumb-interwork -mcpu=cortex-a9\r
+#ARCH_ARFLAGS := \r
+#CC = $(CROSS)gcc\r
+#CXX = $(CROSS)g++\r
+#AS = $(CROSS)as\r
+#AR = $(CROSS)ar\r
+#INCLUDE := \r
+#RM := rm -f\r
diff --git a/apps/Makefile b/apps/Makefile
--- /dev/null
+++ b/apps/Makefile
@@ -0,0 +1,95 @@
+
+# Include commons make file to get platform and tool chain specific variables.
+
+
+include ../Makefile.commons
+
+all:
+ifeq ($(OS),nucleus)
+ifeq ($(ROLE),master)
+ make -f samples/master/nucleus/matrix_multiply/nucleus_nucleusbm/make
+ make -f tests/master/nucleus/echo_test/nucleus_nucleusbm/make
+ make -f tests/master/nucleus/func_test_suite/nucleus_nucleusbm/make
+else
+ make -f samples/remote/nucleus/matrix_multiply/make
+ make -f tests/remote/nucleus/echo_test/make
+ make -f tests/remote/nucleus/func_test_suite/make
+ make -f samples/remote/nucleus/rpc_demo/make
+endif
+endif
+ifeq ($(OS),baremetal)
+ifeq ($(ROLE),remote)
+ make -f samples/remote/baremetal/matrix_multiply/make
+ make -f tests/remote/baremetal/echo_test/make
+ make -f tests/remote/baremetal/func_test_suite/make
+ make -f samples/remote/baremetal/rpc_demo/make
+endif
+endif
+
+benchmark:
+ make -f tests/master/nucleus/latency_test/nucleus_nucleusbm/make
+
+linux_remote:
+ifeq ($(OS),nucleus)
+ make -f samples/master/nucleus/matrix_multiply/nucleus_linux/make
+ make -f tests/master/nucleus/echo_test/nucleus_linux/make
+ make -f tests/master/nucleus/func_test_suite/nucleus_linux/make
+else
+ make -f samples/master/baremetal/matrix_multiply/make
+ make -f tests/master/baremetal/echo_test/make
+ make -f tests/master/baremetal/func_test_suite/make
+endif
+
+linux_remote_benchmark:
+ifeq ($(OS),nucleus)
+ make -f tests/master/nucleus/latency_test/nucleus_linux/make
+endif
+
+clean:
+ifeq ($(OS),nucleus)
+ifeq ($(ROLE),master)
+ make -f samples/master/nucleus/matrix_multiply/nucleus_nucleusbm/make clean
+ make -f tests/master/nucleus/echo_test/nucleus_nucleusbm/make clean
+ make -f tests/master/nucleus/func_test_suite/nucleus_nucleusbm/make clean
+else
+ make -f samples/remote/nucleus/matrix_multiply/make clean
+ make -f tests/remote/nucleus/echo_test/make clean
+ make -f tests/remote/nucleus/func_test_suite/make clean
+ make -f samples/remote/nucleus/rpc_demo/make clean
+endif
+endif
+ifeq ($(OS),baremetal)
+ifeq ($(ROLE),remote)
+ make -f samples/remote/baremetal/matrix_multiply/make clean
+ make -f tests/remote/baremetal/echo_test/make clean
+ make -f tests/remote/baremetal/func_test_suite/make clean
+ make -f samples/remote/baremetal/rpc_demo/make clean
+endif
+endif
+
+cleanbenchmark:
+ make -f tests/master/nucleus/latency_test/nucleus_nucleusbm/make clean
+
+clean_linux_remote:
+ifeq ($(OS),nucleus)
+ make -f samples/master/nucleus/matrix_multiply/nucleus_linux/make clean
+ make -f tests/master/nucleus/echo_test/nucleus_linux/make clean
+ make -f tests/master/nucleus/func_test_suite/nucleus_linux/make clean
+else
+ make -f samples/master/baremetal/matrix_multiply/make clean
+ make -f tests/master/baremetal/echo_test/make clean
+ make -f tests/master/baremetal/func_test_suite/make clean
+endif
+
+clean_linux_remote_benchmark:
+ifeq ($(OS),nucleus)
+ make -f tests/master/nucleus/latency_test/nucleus_linux/make clean
+endif
+
+post-build:
+ -@echo ' '
+
+secondary-outputs:
+
+PHONY: all clean dependents
+.SECONDARY: post-build
diff --git a/apps/samples/master/baremetal/matrix_multiply/make b/apps/samples/master/baremetal/matrix_multiply/make
--- /dev/null
@@ -0,0 +1,52 @@
+
+include ../Makefile.commons
+
+SAMPLE_OUT := samples/master/baremetal/matrix_multiply/matrix_multiply.out
+SAMPLE_C_SRC := samples/master/baremetal/matrix_multiply/matrix_multiply.c
+
+
+REMOTE_OUT := matrix_multiply.out
+DST_DIR := samples/master/baremetal/matrix_multiply
+LINUX_SRC_DIR := firmware/$(PLAT)/linux
+
+SAMPLEOBJFILES := $(patsubst %.c, %.o, $(SAMPLE_C_SRC))
+SAMPLE_DEPS := $(patsubst %.c, %.d, $(SAMPLE_C_SRC))
+SAMPLE_MAP := $(patsubst %.out, %.map, $(SAMPLE_OUT))
+SAMPLE_BIN := $(patsubst %.out, %.bin, $(SAMPLE_OUT))
+
+
+$(SAMPLE_OUT): $(REMOTE_OUT) $(SAMPLEOBJFILES)
+
+ @echo 'Building master core matrix multiply sample for baremetal : $@'
+
+ $(LD) -Wl,-Map=samples/master/baremetal/matrix_multiply/matrix_multiply.map -Wl,--gc-sections -T"$(OHOME)/libs/system/$(PLAT)/baremetal/linker_master.ld" -L"$(OHOME)/libs/system/$(PLAT)/baremetal" -L"$(OHOME)/libs/open_amp" -o "$(SAMPLE_OUT)" -Wl,--start-group $(SAMPLEOBJFILES) $(DST_DIR)/firmware1.o $(DST_DIR)/firmware2.o -lbaremetal_master -lopen_amp -lc -lm -lstdc++ -lcs3 -lcs3arm -lcs3unhosted -Wl,--end-group
+
+ $(OBJCPY) -O binary $(SAMPLE_OUT) $(SAMPLE_BIN)
+
+ @echo 'Finished building target: $@'
+
+%.o:%.c
+ @echo CC $(<:.c=.o)
+ @$(CC) $(CFLAGS) $(ARCH_CFLAGS) $(INCLUDE) -c $< -o $@
+
+%.o:%.S
+ @$(AS) -c -mcpu=cortex-a9 $(ARCH_ASFLAGS) $(INCLUDE) $< -o $@
+
+$(REMOTE_OUT):
+ cd $(LINUX_SRC_DIR)/; cp firmware firmware1; \
+ $(OBJCPY) -I binary -O elf32-littlearm -B arm firmware1 firmware1.o
+ mv $(LINUX_SRC_DIR)/firmware1.o $(DST_DIR)/firmware1.o
+ cd $(LINUX_SRC_DIR)/; cp firmware firmware2; \
+ $(OBJCPY) -I binary -O elf32-littlearm -B arm firmware2 firmware2.o
+ mv $(LINUX_SRC_DIR)/firmware2.o $(DST_DIR)/
+ cd $(LINUX_SRC_DIR)/; rm firmware1; rm firmware2;
+clean:
+ -$(RM) $(SAMPLEOBJFILES) $(SAMPLE_DEPS) $(SAMPLE_OUT) $(SAMPLE_MAP) $(SAMPLE_BIN) $(DST_DIR)/firmware1.o $(DST_DIR)/firmware2.o
+
+post-build:
+ -@echo ' '
+
+secondary-outputs:
+
+PHONY: all clean dependents
+.SECONDARY: post-build
diff --git a/apps/samples/master/baremetal/matrix_multiply/matrix_multiply.c b/apps/samples/master/baremetal/matrix_multiply/matrix_multiply.c
--- /dev/null
@@ -0,0 +1,194 @@
+/* This is a sample demonstration application that showcases usage of remoteproc
+and rpmsg APIs. This application is meant to run on the master CPU running baremetal
+and showcases booting of linux remote firmware using remoteproc and
+IPC with remote firmware using rpmsg; Baremetal on master core acts as a remoteproc master
+but as an rpmsg remote;It brings up a remote Linux based
+firmware which acts as an rpmsg master and offloads matrix multiplication to the baremetal context.
+Linux app generates two random matrices and transmits them to baremetal env which computes
+the product and transmits results back to Linux. Once Linux application is complete, it
+requests a shutdown from baremetal env. Baremetal env acknowledges with a shutdown message which results
+in Linux starting a system halt. Baremetal env shutsdown the remot core after a reasonable delay which allows
+Linux to gracefully shutdown. */
+
+
+/* Including required headers */
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "open_amp.h"
+
+#define BAREMETAL_MASTER 1
+
+#include "baremetal.h"
+
+#define MAX_SIZE 6
+#define NUM_MATRIX 2
+
+#define SHUTDOWN_MSG 0xEF56A55A
+
+
+typedef struct _matrix
+{
+ unsigned long size;
+ unsigned long elements[MAX_SIZE][MAX_SIZE];
+} matrix;
+
+
+static matrix matrix_array[NUM_MATRIX];
+
+static matrix matrix_result;
+
+/* Prototypes */
+static void init_system();
+
+void sleep();
+
+/* Application provided callbacks */
+void rpmsg_channel_created( struct rpmsg_channel *rp_chnl );
+void rpmsg_channel_deleted( struct rpmsg_channel *rp_chnl );
+void rpmsg_read_cb( struct rpmsg_channel *rp_chnl , void *data , int len , void * pric , unsigned long src );
+
+/* Globals */
+struct rpmsg_endpoint *rp_ept;
+struct rpmsg_channel *app_rp_chnl;
+char fw_name []= "firmware1";
+
+int int_flag;
+
+static int shutdown_called = 0;
+
+static void Matrix_Multiply(const matrix *m, const matrix *n, matrix *r)
+{
+ int i, j, k;
+
+ r->size = m->size;
+
+ for (i = 0; i < m->size; ++i) {
+ for (j = 0; j < n->size; ++j) {
+ r->elements[i][j] = 0;
+ }
+ }
+
+ for (i = 0; i < m->size; ++i) {
+ for (j = 0; j < n->size; ++j) {
+ for (k = 0; k < r->size; ++k) {
+ r->elements[i][j] += m->elements[i][k] * n->elements[k][j];
+ }
+ }
+ }
+}
+
+
+/* Application entry point */
+int main() {
+
+ int status;
+ struct remote_proc *proc;
+ int i;
+ int shutdown_msg = SHUTDOWN_MSG;
+
+ /* Switch to System Mode */
+ SWITCH_TO_SYS_MODE();
+
+ /* Initialize HW system components */
+ init_system();
+
+ status = remoteproc_init((void *) fw_name, rpmsg_channel_created, rpmsg_channel_deleted, rpmsg_read_cb, &proc);
+
+ if(!status)
+ {
+ status = remoteproc_boot(proc);
+ }
+
+ if(status)
+ {
+ return -1;
+ }
+ while (1) {
+
+ if (int_flag) {
+
+ if(shutdown_called == 1)
+ {
+ break;
+ }
+
+ /* Process received data and multiple matrices. */
+ Matrix_Multiply(&matrix_array[0], &matrix_array[1], &matrix_result);
+
+ /* Send the result of matrix multiplication back to master. */
+ rpmsg_send(app_rp_chnl, &matrix_result, sizeof(matrix));
+
+ int_flag = 0;
+
+ sleep();
+ }
+
+ sleep();
+ }
+
+ /* Send shutdown message to remote */
+ rpmsg_send(app_rp_chnl, &shutdown_msg, sizeof(int));
+
+ for (i = 0; i < 100000; i++)
+ {
+ sleep();
+ }
+
+ remoteproc_shutdown(proc);
+
+ remoteproc_deinit(proc);
+
+ return 0;
+}
+
+/* This callback gets invoked when the remote chanl is created */
+void rpmsg_channel_created(struct rpmsg_channel *rp_chnl) {
+
+ app_rp_chnl = rp_chnl;
+ rp_ept = rpmsg_create_ept(rp_chnl , rpmsg_read_cb ,RPMSG_NULL , RPMSG_ADDR_ANY);
+
+}
+
+/* This callback gets invoked when the remote channel is deleted */
+void rpmsg_channel_deleted(struct rpmsg_channel *rp_chnl) {
+ rpmsg_destroy_ept(rp_ept);
+}
+
+/* This is the read callback, note we are in a task context when this callback
+is invoked, so kernel primitives can be used freely */
+void rpmsg_read_cb(struct rpmsg_channel *rp_chnl, void *data, int len,
+ void * priv, unsigned long src) {
+
+ if ((*(int *) data) == SHUTDOWN_MSG)
+ {
+ shutdown_called = 1;
+ }
+ else
+ {
+ memcpy(matrix_array, data, len);
+ }
+
+ int_flag = 1;
+}
+
+void sleep() {
+ volatile int i;
+ for (i = 0; i < 10000000; i++);
+}
+
+static void init_system() {
+
+ /* Place the vector table at the image entry point */
+ arm_arch_install_isr_vector_table(RAM_VECTOR_TABLE_ADDR);
+
+ /* Enable MMU */
+ arm_ar_mem_enable_mmu();
+
+ /* Initialize ARM stacks */
+ init_arm_stacks();
+
+ /* Initialize GIC */
+ zc702evk_gic_initialize();
+}
+
diff --git a/apps/samples/master/linux/kernelspace/rpmsg_mat_mul_kern_app/rpmsg_mat_mul_kern_app.c b/apps/samples/master/linux/kernelspace/rpmsg_mat_mul_kern_app/rpmsg_mat_mul_kern_app.c
--- /dev/null
@@ -0,0 +1,202 @@
+/*
+ * RPMSG Matrix Multiplication Kernel Driver
+ *
+ * Copyright (C) 2014 Mentor Graphics Corporation
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ */
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/rpmsg.h>
+#include <linux/slab.h>
+#include <linux/random.h>
+
+/* Application */
+#define MAX_SIZE 6
+#define NUM_MATRIX 2
+/* Shutdown message ID */
+#define SHUTDOWN_MSG 0xEF56A55A
+
+struct rpmsg_endpoint *ept;
+static const char init_msg[] = "init_msg";
+
+static const char *const shutdown_argv[]
+ = { "/sbin/shutdown", "-h", "-P", "now", NULL };
+
+struct _matrix {
+ unsigned long size;
+ unsigned long elements[MAX_SIZE][MAX_SIZE];
+};
+
+static struct _matrix *p_matrix;
+
+static void matrix_print(struct _matrix *m)
+{
+ int i, j;
+
+ /* Generate two random matrices */
+ pr_err(" \r\n Master : Linux : Printing results \r\n");
+
+ for (i = 0; i < m->size; ++i) {
+ for (j = 0; j < m->size; ++j)
+ pr_cont(" %d ", (unsigned int)m->elements[i][j]);
+ pr_info("\r\n");
+ }
+}
+
+static void generate_matrices(int num_matrices, unsigned int matrix_size,
+ void *p_data)
+{
+ int i, j, k, val;
+ struct _matrix *p_matrix = p_data;
+
+ /* Generate two random matrices */
+ pr_err(" \r\n Master : Linux : Generating random matrices \r\n");
+
+ for (i = 0; i < num_matrices; i++) {
+
+ /* Initialize workload */
+ p_matrix[i].size = matrix_size;
+
+ pr_err(" \r\n Master : Linux : Input matrix %d \r\n", i);
+ for (j = 0; j < matrix_size; j++) {
+
+ pr_info("\r\n");
+ for (k = 0; k < matrix_size; k++) {
+ get_random_bytes(&val, sizeof(val));
+ p_matrix[i].elements[j][k] =
+ ((val & 0x7F) % 10);
+ pr_cont(" %d ",
+ (unsigned int)p_matrix[i].elements[j][k]);
+ }
+ }
+ pr_err("\r\n");
+ }
+
+}
+
+static void rpmsg_mat_mul_kern_app_rx_cb(struct rpmsg_channel *rpdev,
+ void *data, int len, void *priv, u32 src)
+{
+ int err;
+ int shutdown_msg = SHUTDOWN_MSG;
+
+ pr_err(" \r\n Master : Linux : Received %d bytes of data", len);
+ pr_err(" over rpmsg channel from remote \r\n");
+
+ /* Shutdown Linux if such a message is received. Only applicable
+ when Linux is a remoteproc remote. */
+ if ((*(int *) data) == SHUTDOWN_MSG) {
+ call_usermodehelper(shutdown_argv[0], shutdown_argv,
+ NULL, UMH_NO_WAIT);
+ } else {
+ /* print results */
+ matrix_print((struct _matrix *)data);
+
+ /* Send payload to remote. */
+ err = rpmsg_send_offchannel(rpdev, ept->addr, rpdev->dst,
+ &shutdown_msg, sizeof(int));
+
+ if (err)
+ pr_err(" Shutdown send failed!\r\n");
+
+ kzfree(p_matrix);
+ }
+}
+
+static int rpmsg_mat_mul_kern_app_probe(struct rpmsg_channel *rpdev)
+{
+ int err;
+
+ pr_err("\r\n Demo Start - Demo rpmsg driver got probed \r\n");
+ pr_err("since the rpmsg device associated with driver was found !\r\n");
+
+ pr_err("\r\n Create endpoint and register rx callback \r\n");
+ /* Create endpoint for remote channel and register rx callabck */
+ ept = rpmsg_create_ept(rpdev, rpmsg_mat_mul_kern_app_rx_cb, 0,
+ RPMSG_ADDR_ANY);
+
+ if (!ept) {
+ pr_err(" Endpoint creation for failed!\r\n");
+ return -ENOMEM;
+ }
+
+ /* Send init message to complete the connection loop */
+ err = rpmsg_send_offchannel(rpdev, ept->addr, rpdev->dst,
+ init_msg, sizeof(init_msg));
+
+ if (err) {
+ pr_err(" Init messages send failed!\r\n");
+ return err;
+ }
+
+ /* Allocate memory for random matrices */
+ p_matrix = kzalloc(sizeof(struct _matrix)*2, GFP_KERNEL);
+
+ /* Generate random matrices */
+ generate_matrices(NUM_MATRIX, MAX_SIZE, p_matrix);
+
+ /* Send matrices to remote for computation */
+ err = rpmsg_send_offchannel(rpdev, ept->addr, rpdev->dst,
+ p_matrix, sizeof(struct _matrix) * 2);
+
+ pr_err("\r\n Master : Linux : Sent %d bytes of data over rpmsg channel to remote \r\n",
+ sizeof(struct _matrix) * 2);
+
+ if (err) {
+ pr_err(" send failed!\r\n");
+ return err;
+ }
+
+ return 0;
+}
+
+static void rpmsg_mat_mul_kern_app_remove(struct rpmsg_channel *rpdev)
+{
+ rpmsg_destroy_ept(ept);
+}
+
+static void rpmsg_cb(struct rpmsg_channel *rpdev, void *data,
+ int len, void *priv, u32 src)
+{
+
+}
+
+static struct rpmsg_device_id rpmsg_mat_mul_kern_app_id_table[] = {
+ { .name = "rpmsg-openamp-demo-channel" },
+ { },
+};
+MODULE_DEVICE_TABLE(rpmsg, rpmsg_mat_mul_kern_app_id_table);
+
+static struct rpmsg_driver rpmsg_mat_mul_kern_app = {
+ .drv.name = KBUILD_MODNAME,
+ .drv.owner = THIS_MODULE,
+ .id_table = rpmsg_mat_mul_kern_app_id_table,
+ .probe = rpmsg_mat_mul_kern_app_probe,
+ .callback = rpmsg_cb,
+ .remove = rpmsg_mat_mul_kern_app_remove,
+};
+
+static int __init init(void)
+{
+ return register_rpmsg_driver(&rpmsg_mat_mul_kern_app);
+}
+
+static void __exit fini(void)
+{
+ unregister_rpmsg_driver(&rpmsg_mat_mul_kern_app);
+}
+
+module_init(init);
+module_exit(fini);
+
+MODULE_DESCRIPTION("Sample rpmsg matrix multiplication kernel application");
+MODULE_LICENSE("GPL v2");
diff --git a/apps/samples/master/linux/kernelspace/rpmsg_user_dev_driver/rpmsg_user_dev_driver.c b/apps/samples/master/linux/kernelspace/rpmsg_user_dev_driver/rpmsg_user_dev_driver.c
--- /dev/null
@@ -0,0 +1,389 @@
+/*
+ * RPMSG User Device Kernel Driver
+ *
+ * Copyright (C) 2014 Mentor Graphics Corporation
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ */
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/rpmsg.h>
+#include <linux/slab.h>
+#include <linux/device.h>
+#include <linux/cdev.h>
+#include <linux/mutex.h>
+#include <linux/wait.h>
+#include <linux/fs.h>
+#include <linux/kfifo.h>
+#include <linux/uaccess.h>
+#include <linux/kthread.h>
+#include <linux/ioctl.h>
+#include <linux/errno.h>
+
+static struct class *rpmsg_class;
+static dev_t rpmsg_dev;
+
+struct _rpmsg_dev_params {
+ int rpmsg_major;
+ int rpmsg_minor;
+ struct device *rpmsg_dev;
+ struct cdev cdev;
+ struct rpmsg_channel *rpmsg_chnl;
+};
+
+struct _rpmsg_dev_instance {
+ struct rpmsg_endpoint *ept;
+ struct _rpmsg_dev_params *dev_params;
+ wait_queue_head_t usr_wait_q;
+ struct mutex sync_lock;
+};
+
+#define MAX_RPMSG_BUFF_SIZE 512
+#define RPMSG_KFIFO_SIZE (MAX_RPMSG_BUFF_SIZE * 4)
+
+#define IOCTL_CMD_GET_KFIFO_SIZE 1
+#define IOCTL_CMD_GET_AVAIL_DATA_SIZE 2
+#define IOCTL_CMD_GET_FREE_BUFF_SIZE 3
+
+/* Shutdown message ID */
+#define SHUTDOWN_MSG 0xEF56A55A
+
+static struct kfifo rpmsg_kfifo;
+static int block_flag ;
+static const char init_msg[] = "init_msg";
+
+static const char *const shutdown_argv[]
+ = { "/sbin/shutdown", "-h", "-P", "now", NULL };
+
+/* This callback gets invoked when we received data from the remote node */
+static void rpmsg_user_dev_drv_rx_cb(struct rpmsg_channel *rpdev,
+ void *data, int len, void *priv, u32 src)
+{
+ struct _rpmsg_dev_instance *rpmsg_dev_instance = priv;
+
+ /* Shutdown Linux if such a message is received. Only applicable
+ when Linux is a remoteproc remote. */
+ if ((*(int *) data) == SHUTDOWN_MSG) {
+ call_usermodehelper(shutdown_argv[0], shutdown_argv,
+ NULL, UMH_NO_WAIT);
+ } else {
+ /* Push data received into rpmsg kfifo */
+ mutex_lock_interruptible(&rpmsg_dev_instance->sync_lock);
+ kfifo_in(&rpmsg_kfifo, data, (unsigned int)len);
+ mutex_unlock(&rpmsg_dev_instance->sync_lock);
+
+ /* Wake up any blocking contexts waiting for data */
+ block_flag = 1;
+ wake_up_interruptible(&rpmsg_dev_instance->usr_wait_q);
+ }
+}
+
+
+static int rpmsg_dev_open(struct inode *inode, struct file *p_file)
+{
+ struct _rpmsg_dev_instance *rpmsg_dev_instance;
+ struct _rpmsg_dev_params *rpmsg_dev_params;
+ int retval;
+
+ /* Create and initialize rpmsg device instance */
+ rpmsg_dev_instance = kzalloc(sizeof(struct _rpmsg_dev_instance),
+ GFP_KERNEL);
+
+ if (!rpmsg_dev_instance) {
+ pr_err("\r\n cannot allocate memory for rpmsg device instance \r\n");
+ return -ENOMEM;
+ }
+
+ /* Initialize rpmsg instance with device params from inode */
+ rpmsg_dev_instance->dev_params = container_of(inode->i_cdev,
+ struct _rpmsg_dev_params, cdev);
+
+ rpmsg_dev_params = rpmsg_dev_instance->dev_params;
+
+ /* Allocate kfifo for rpmsg */
+ retval = kfifo_alloc(&rpmsg_kfifo, RPMSG_KFIFO_SIZE, GFP_KERNEL);
+ kfifo_reset(&rpmsg_kfifo);
+
+ if (retval) {
+ pr_err("\r\n error in kfifo_alloc for rpmsg \r\n");
+
+ return retval;
+ }
+
+ /* Initialize mutex */
+ mutex_init(&rpmsg_dev_instance->sync_lock);
+
+ /* Initialize wait queue head that provides blocking rx for userspace */
+ init_waitqueue_head(&rpmsg_dev_instance->usr_wait_q);
+
+ p_file->private_data = rpmsg_dev_instance;
+
+ /* Create endpoint for remote channel and register rx callabck */
+ rpmsg_dev_instance->ept = rpmsg_create_ept(rpmsg_dev_params->rpmsg_chnl,
+ rpmsg_user_dev_drv_rx_cb,
+ rpmsg_dev_instance,
+ RPMSG_ADDR_ANY);
+
+
+ if (!rpmsg_dev_instance->ept) {
+ pr_err(" Endpoint creation for failed!\r\n");
+ return -ENOMEM;
+ }
+
+ /* Send init message to remote to complete the connection stage.
+ The message carries the address of new endpoint so that the
+ further messages from remote are received in its call back */
+ retval = rpmsg_send_offchannel(rpmsg_dev_params->rpmsg_chnl,
+ rpmsg_dev_instance->ept->addr,
+ rpmsg_dev_params->rpmsg_chnl->dst,
+ init_msg, sizeof(init_msg));
+
+ if (retval) {
+ pr_err(" Init message send failed!\r\n");
+ return retval;
+ }
+
+ return 0;
+}
+
+static ssize_t rpmsg_dev_write(struct file *p_file,
+ const char __user *ubuff, size_t len,
+ loff_t *p_off)
+{
+ struct _rpmsg_dev_instance *rpmsg_dev_instance = p_file->private_data;
+ struct _rpmsg_dev_params *rpmsg_dev_params
+ = rpmsg_dev_instance->dev_params;
+ int err;
+ unsigned int size;
+ char *tmp_buff;
+
+ if (len < MAX_RPMSG_BUFF_SIZE)
+ size = len;
+ else
+ size = MAX_RPMSG_BUFF_SIZE;
+
+ tmp_buff = kzalloc(size, GFP_KERNEL);
+
+ if (copy_from_user(tmp_buff, ubuff, size)) {
+ pr_err("\r\n user to kernel buff copy error \r\n");
+ return -1;
+ }
+
+ err = rpmsg_send_offchannel(rpmsg_dev_params->rpmsg_chnl,
+ rpmsg_dev_instance->ept->addr,
+ rpmsg_dev_params->rpmsg_chnl->dst,
+ tmp_buff, size);
+
+ if (err) {
+ size = 0;
+ pr_err("\r\n rpmsg_send_off_channel error \r\n");
+ }
+
+ return size;
+}
+
+static ssize_t rpmsg_dev_read(struct file *p_file, char __user *ubuff,
+ size_t len, loff_t *p_off)
+{
+ struct _rpmsg_dev_instance *rpmsg_dev_instance = p_file->private_data;
+ int retval;
+ unsigned int data_available, data_used, bytes_copied;
+
+ /* Acquire lock to access rpmsg kfifo */
+ if (mutex_lock_interruptible(&rpmsg_dev_instance->sync_lock))
+ return -ERESTARTSYS;
+
+ data_available = kfifo_len(&rpmsg_kfifo);
+
+ if (data_available == 0) {
+ /* Release lock */
+ mutex_unlock(&rpmsg_dev_instance->sync_lock);
+
+ /* if non-blocking read is requested return error */
+ if (p_file->f_flags & O_NONBLOCK)
+ return -EAGAIN;
+
+ /* Block the calling context till data becomes available */
+ wait_event_interruptible(rpmsg_dev_instance->usr_wait_q,
+ block_flag != 0);
+ }
+
+ /* reset block flag */
+ block_flag = 0;
+
+ /* Provide requested data size to user space */
+ data_available = kfifo_len(&rpmsg_kfifo);
+ data_used = (data_available > len) ? len : data_available;
+ retval = kfifo_to_user(&rpmsg_kfifo, ubuff, data_used, &bytes_copied);
+
+ /* Release lock on rpmsg kfifo */
+ mutex_unlock(&rpmsg_dev_instance->sync_lock);
+
+ return retval ? retval : bytes_copied;
+}
+
+static long rpmsg_dev_ioctl(struct file *p_file, unsigned int cmd,
+ unsigned long arg)
+{
+ unsigned int tmp;
+
+ switch (cmd) {
+ case IOCTL_CMD_GET_KFIFO_SIZE:
+ tmp = kfifo_size(&rpmsg_kfifo);
+ if (copy_to_user((unsigned int *)arg, &tmp, sizeof(int)))
+ return -EACCES;
+ break;
+
+ case IOCTL_CMD_GET_AVAIL_DATA_SIZE:
+ tmp = kfifo_len(&rpmsg_kfifo);
+ pr_err("kfifo len ioctl = %d ", kfifo_len(&rpmsg_kfifo));
+ if (copy_to_user((unsigned int *)arg, &tmp, sizeof(int)))
+ return -EACCES;
+ break;
+ case IOCTL_CMD_GET_FREE_BUFF_SIZE:
+ tmp = kfifo_avail(&rpmsg_kfifo);
+ if (copy_to_user((unsigned int *)arg, &tmp, sizeof(int)))
+ return -EACCES;
+ break;
+
+ default:
+ return -EINVAL;
+ }
+
+ return 0;
+}
+
+static int rpmsg_dev_release(struct inode *inode, struct file *p_file)
+{
+ struct _rpmsg_dev_instance *rpmsg_dev_instance = p_file->private_data;
+
+ rpmsg_destroy_ept(rpmsg_dev_instance->ept);
+ kfree(rpmsg_dev_instance);
+
+ return 0;
+}
+
+static const struct file_operations rpmsg_dev_fops = {
+ .owner = THIS_MODULE,
+ .read = rpmsg_dev_read,
+ .write = rpmsg_dev_write,
+ .open = rpmsg_dev_open,
+ .unlocked_ioctl = rpmsg_dev_ioctl,
+ .release = rpmsg_dev_release,
+};
+
+static int rpmsg_user_dev_drv_probe(struct rpmsg_channel *rpdev)
+{
+ struct _rpmsg_dev_params *rpmsg_dev_params;
+
+ /* Allocate memory for the rpmsg device parameters data structure */
+ rpmsg_dev_params = kzalloc(sizeof(struct _rpmsg_dev_params),
+ GFP_KERNEL);
+
+ if (!rpmsg_dev_params) {
+ pr_err("\r\n cannot allocate memory for rpmsg device params \r\n");
+ return -ENOMEM;
+ }
+
+ /* Initialize rpmsg device parameters data structure */
+ rpmsg_dev_params->rpmsg_major = MAJOR(rpmsg_dev);
+ rpmsg_dev_params->rpmsg_minor = 0;
+ /* Create device */
+ rpmsg_dev_params->rpmsg_dev = device_create(rpmsg_class, &rpdev->dev,
+ rpmsg_dev, NULL, "rpmsg");
+ if (rpmsg_dev_params->rpmsg_dev == NULL) {
+ class_destroy(rpmsg_class);
+ unregister_chrdev_region(rpmsg_dev, 1);
+ return -1;
+ }
+ /* Initialize character device */
+ cdev_init(&rpmsg_dev_params->cdev, &rpmsg_dev_fops);
+ rpmsg_dev_params->cdev.owner = THIS_MODULE;
+ if (cdev_add(&rpmsg_dev_params->cdev, rpmsg_dev, 1) == -1) {
+ device_destroy(rpmsg_class, rpmsg_dev);
+ class_destroy(rpmsg_class);
+ unregister_chrdev_region(rpmsg_dev, 1);
+ return -1;
+ }
+ rpmsg_dev_params->rpmsg_chnl = rpdev;
+
+ dev_set_drvdata(&rpdev->dev, rpmsg_dev_params);
+
+ dev_info(&rpdev->dev, "new channel: 0x%x -> 0x%x!\n",
+ rpdev->src, rpdev->dst);
+
+ return 0;
+}
+
+static void rpmsg_user_dev_drv_remove(struct rpmsg_channel *rpdev)
+{
+ struct _rpmsg_dev_params *rpmsg_dev_params
+ = dev_get_drvdata(&rpdev->dev);
+
+ device_destroy(rpmsg_class, rpmsg_dev);
+ cdev_del(&rpmsg_dev_params->cdev);
+ kfree(rpmsg_dev_params);
+}
+
+static void rpmsg_cb(struct rpmsg_channel *rpdev, void *data,
+ int len, void *priv, u32 src)
+{
+
+}
+
+static struct rpmsg_device_id rpmsg_user_dev_drv_id_table[] = {
+ { .name = "rpmsg-openamp-demo-channel" },
+ { },
+};
+MODULE_DEVICE_TABLE(rpmsg, rpmsg_user_dev_drv_id_table);
+
+static struct rpmsg_driver rpmsg_user_dev_drv = {
+ .drv.name = KBUILD_MODNAME,
+ .drv.owner = THIS_MODULE,
+ .id_table = rpmsg_user_dev_drv_id_table,
+ .probe = rpmsg_user_dev_drv_probe,
+ .callback = rpmsg_cb,
+ .remove = rpmsg_user_dev_drv_remove,
+};
+
+static int __init init(void)
+{
+ /* Allocate char device for this rpmsg driver */
+ if (alloc_chrdev_region(&rpmsg_dev, 0, 1, KBUILD_MODNAME) < 0) {
+ pr_err("\r\n Error allocating char device \r\n");
+ return -1;
+ }
+
+ /* Create device class for this device */
+ rpmsg_class = class_create(THIS_MODULE, KBUILD_MODNAME);
+
+ if (rpmsg_class == NULL) {
+ unregister_chrdev_region(rpmsg_dev, 1);
+ pr_err("\r\n Error allocating char device \r\n");
+ return -1;
+ }
+
+ /* Register this rpmsg driver with the rpmsg bus layer */
+ return register_rpmsg_driver(&rpmsg_user_dev_drv);
+}
+
+static void __exit fini(void)
+{
+ unregister_rpmsg_driver(&rpmsg_user_dev_drv);
+ class_destroy(rpmsg_class);
+ unregister_chrdev_region(rpmsg_dev, 1);
+}
+
+module_init(init);
+module_exit(fini);
+
+MODULE_DESCRIPTION("Sample driver to exposes rpmsg svcs to userspace via a char device");
+MODULE_LICENSE("GPL v2");
diff --git a/apps/samples/master/linux/kernelspace/zynq_remoteproc_driver/remoteproc_internal.h b/apps/samples/master/linux/kernelspace/zynq_remoteproc_driver/remoteproc_internal.h
--- /dev/null
@@ -0,0 +1,109 @@
+/*
+ * Remote processor framework
+ *
+ * Copyright (C) 2011 Texas Instruments, Inc.
+ * Copyright (C) 2011 Google, Inc.
+ *
+ * Ohad Ben-Cohen <ohad@wizery.com>
+ * Brian Swetland <swetland@google.com>
+ *
+ * This software is licensed under the terms of the GNU General Public
+ * License version 2, as published by the Free Software Foundation, and
+ * may be copied, distributed, and modified under those terms.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ */
+
+#ifndef REMOTEPROC_INTERNAL_H
+#define REMOTEPROC_INTERNAL_H
+
+#include <linux/irqreturn.h>
+#include <linux/firmware.h>
+
+struct rproc;
+
+/**
+ * struct rproc_fw_ops - firmware format specific operations.
+ * @find_rsc_table: finds the resource table inside the firmware image
+ * @load: load firmeware to memory, where the remote processor
+ * expects to find it
+ * @sanity_check: sanity check the fw image
+ * @get_boot_addr: get boot address to entry point specified in firmware
+ */
+struct rproc_fw_ops {
+ struct resource_table *(*find_rsc_table) (struct rproc *rproc,
+ const struct firmware *fw,
+ int *tablesz);
+ int (*load)(struct rproc *rproc, const struct firmware *fw);
+ int (*sanity_check)(struct rproc *rproc, const struct firmware *fw);
+ u32 (*get_boot_addr)(struct rproc *rproc, const struct firmware *fw);
+};
+
+/* from remoteproc_core.c */
+void rproc_release(struct kref *kref);
+irqreturn_t rproc_vq_interrupt(struct rproc *rproc, int vq_id);
+
+/* from remoteproc_virtio.c */
+int rproc_add_virtio_dev(struct rproc_vdev *rvdev, int id);
+void rproc_remove_virtio_dev(struct rproc_vdev *rvdev);
+
+/* from remoteproc_debugfs.c */
+void rproc_remove_trace_file(struct dentry *tfile);
+struct dentry *rproc_create_trace_file(const char *name, struct rproc *rproc,
+ struct rproc_mem_entry *trace);
+void rproc_delete_debug_dir(struct rproc *rproc);
+void rproc_create_debug_dir(struct rproc *rproc);
+void rproc_init_debugfs(void);
+void rproc_exit_debugfs(void);
+
+void rproc_free_vring(struct rproc_vring *rvring);
+int rproc_alloc_vring(struct rproc_vdev *rvdev, int i);
+
+void *rproc_da_to_va(struct rproc *rproc, u64 da, int len);
+int rproc_trigger_recovery(struct rproc *rproc);
+
+static inline
+int rproc_fw_sanity_check(struct rproc *rproc, const struct firmware *fw)
+{
+ if (rproc->fw_ops->sanity_check)
+ return rproc->fw_ops->sanity_check(rproc, fw);
+
+ return 0;
+}
+
+static inline
+u32 rproc_get_boot_addr(struct rproc *rproc, const struct firmware *fw)
+{
+ if (rproc->fw_ops->get_boot_addr)
+ return rproc->fw_ops->get_boot_addr(rproc, fw);
+
+ return 0;
+}
+
+static inline
+int rproc_load_segments(struct rproc *rproc, const struct firmware *fw)
+{
+ if (rproc->fw_ops->load)
+ return rproc->fw_ops->load(rproc, fw);
+
+ return -EINVAL;
+}
+
+static inline
+struct resource_table *rproc_find_rsc_table(struct rproc *rproc,
+ const struct firmware *fw, int *tablesz)
+{
+ if (rproc->fw_ops->find_rsc_table)
+ return rproc->fw_ops->find_rsc_table(rproc, fw, tablesz);
+
+ return NULL;
+}
+
+extern const struct rproc_fw_ops rproc_elf_fw_ops;
+
+extern int __cpuinit zynq_cpun_start(u32 address, int cpu);
+
+#endif /* REMOTEPROC_INTERNAL_H */
diff --git a/apps/samples/master/linux/kernelspace/zynq_remoteproc_driver/zynq_remoteproc_driver.c b/apps/samples/master/linux/kernelspace/zynq_remoteproc_driver/zynq_remoteproc_driver.c
--- /dev/null
@@ -0,0 +1,371 @@
+/*
+ * Zynq Remote Processor driver
+ *
+ * Copyright (C) 2012 Michal Simek <monstr@monstr.eu>
+ * Copyright (C) 2012 PetaLogix
+ *
+ * Based on origin OMAP Remote Processor driver
+ *
+ * Copyright (C) 2011 Texas Instruments, Inc.
+ * Copyright (C) 2011 Google, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ */
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/err.h>
+#include <linux/platform_device.h>
+#include <linux/dma-mapping.h>
+#include <linux/remoteproc.h>
+#include <linux/interrupt.h>
+#include <linux/of_irq.h>
+#include <linux/smp.h>
+#include <asm/hardware/gic.h>
+#include <asm/outercache.h>
+#include <asm/cacheflush.h>
+#include <linux/slab.h>
+#include <linux/cpu.h>
+
+#include "remoteproc_internal.h"
+
+/* Module parameter */
+static char *firmware;
+
+/* Structure for storing IRQs */
+struct irq_list {
+ int irq;
+ struct list_head list;
+};
+
+/* Private data */
+struct zynq_rproc_pdata {
+ struct irq_list mylist;
+ struct rproc *rproc;
+ u32 ipino;
+ u32 vring0;
+ u32 vring1;
+ u32 mem_start;
+ u32 mem_end;
+};
+
+/* Store rproc for IPI handler */
+static struct platform_device *remoteprocdev;
+static struct work_struct workqueue;
+
+static void handle_event(struct work_struct *work)
+{
+ struct zynq_rproc_pdata *local = platform_get_drvdata(remoteprocdev);
+
+ flush_cache_all();
+ outer_flush_range(local->mem_start, local->mem_end);
+
+ if (rproc_vq_interrupt(local->rproc, 0) == IRQ_NONE)
+ dev_dbg(&remoteprocdev->dev, "no message found in vqid 0\n");
+}
+
+static void ipi_kick(void)
+{
+ dev_dbg(&remoteprocdev->dev, "KICK Linux because of pending message\n");
+ schedule_work(&workqueue);
+}
+
+static int zynq_rproc_start(struct rproc *rproc)
+{
+ struct device *dev = rproc->dev.parent;
+ struct platform_device *pdev = to_platform_device(dev);
+ struct zynq_rproc_pdata *local = platform_get_drvdata(pdev);
+ int ret;
+
+ dev_dbg(dev, "%s\n", __func__);
+ INIT_WORK(&workqueue, handle_event);
+
+ flush_cache_all();
+ outer_flush_range(local->mem_start, local->mem_end);
+
+ remoteprocdev = pdev;
+ ret = zynq_cpun_start(0, 1);
+
+ return ret;
+}
+
+/* kick a firmware */
+static void zynq_rproc_kick(struct rproc *rproc, int vqid)
+{
+ struct device *dev = rproc->dev.parent;
+ struct platform_device *pdev = to_platform_device(dev);
+ struct zynq_rproc_pdata *local = platform_get_drvdata(pdev);
+
+ dev_dbg(dev, "KICK Firmware to start send messages vqid %d\n",
+ vqid);
+ /* Send swirq to firmware */
+ if (!vqid)
+ gic_raise_softirq(cpumask_of(1), local->vring0);
+ else
+ gic_raise_softirq(cpumask_of(1), local->vring1);
+}
+
+/* power off the remote processor */
+static int zynq_rproc_stop(struct rproc *rproc)
+{
+ dev_dbg(rproc->dev.parent, "%s\n", __func__);
+
+ /* FIXME missing reset option */
+ return 0;
+}
+
+static struct rproc_ops zynq_rproc_ops = {
+ .start = zynq_rproc_start,
+ .stop = zynq_rproc_stop,
+ .kick = zynq_rproc_kick,
+};
+
+/* Just to detect bug if interrupt forwarding is broken */
+static irqreturn_t zynq_remoteproc_interrupt(int irq, void *dev_id)
+{
+ struct device *dev = dev_id;
+
+ dev_err(dev, "GIC IRQ %d is not forwarded correctly\n", irq);
+
+ /*
+ * MS: Calling this function doesn't need to be BUG
+ * especially for cases where firmware doesn't disable
+ * interrupts. In next probing can be som interrupts pending.
+ * The next scenario is for cases when you want to monitor
+ * non frequent interrupt through Linux kernel. Interrupt happen
+ * and it is forwarded to Linux which update own statistic
+ * in (/proc/interrupt) and forward it to firmware.
+ *
+ * gic_set_cpu(1, irq); - setup cpu1 as destination cpu
+ * gic_raise_softirq(cpumask_of(1), irq); - forward irq to firmware
+ */
+
+ gic_set_cpu(1, irq);
+ return IRQ_HANDLED;
+}
+
+static void clear_irq(struct platform_device *pdev)
+{
+ struct list_head *pos, *q;
+ struct irq_list *tmp;
+ struct zynq_rproc_pdata *local = platform_get_drvdata(pdev);
+
+ dev_info(&pdev->dev, "Deleting the irq_list\n");
+ list_for_each_safe(pos, q, &local->mylist.list) {
+ tmp = list_entry(pos, struct irq_list, list);
+ free_irq(tmp->irq, &pdev->dev);
+ gic_set_cpu(0, tmp->irq);
+ list_del(pos);
+ kfree(tmp);
+ }
+}
+
+static int zynq_remoteproc_probe(struct platform_device *pdev)
+{
+ const unsigned char *prop;
+ const void *of_prop;
+ struct resource *res; /* IO mem resources */
+ int ret = 0;
+ struct irq_list *tmp;
+ int count;
+ struct zynq_rproc_pdata *local;
+
+ ret = cpu_down(1);
+ /* EBUSY means CPU is already released */
+ if (ret && (ret != -EBUSY)) {
+ dev_err(&pdev->dev, "Can't release cpu1\n");
+ return -ENOMEM;
+ }
+
+ local = kzalloc(sizeof(struct zynq_rproc_pdata), GFP_KERNEL);
+ if (!local) {
+ dev_err(&pdev->dev, "Unable to alloc private data\n");
+ return -ENOMEM;
+ }
+
+ platform_set_drvdata(pdev, local);
+
+ /* Declare memory for firmware */
+ res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+ if (!res) {
+ dev_err(&pdev->dev, "invalid address\n");
+ return -ENODEV;
+ }
+
+ local->mem_start = res->start;
+ local->mem_end = res->end;
+
+ /* Alloc phys addr from 0 to max_addr for firmware */
+ ret = dma_declare_coherent_memory(&pdev->dev, local->mem_start,
+ local->mem_start, local->mem_end - local->mem_start + 1,
+ DMA_MEMORY_IO);
+ if (!ret) {
+ dev_err(&pdev->dev, "dma_declare_coherent_memory failed\n");
+ goto dma_fault;
+ }
+
+ ret = dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(32));
+ if (ret) {
+ dev_err(&pdev->dev, "dma_set_coherent_mask: %d\n", ret);
+ goto dma_fault;
+ }
+
+ /* Init list for IRQs - it can be long list */
+ INIT_LIST_HEAD(&local->mylist.list);
+
+ count = of_irq_count(pdev->dev.of_node);
+ /* Alloc IRQ based on DTS to be sure that no other driver will use it */
+ while (count--) {
+ tmp = kzalloc(sizeof(struct irq_list), GFP_KERNEL);
+ if (!tmp) {
+ dev_err(&pdev->dev, "Unable to alloc irq list\n");
+ ret = -ENOMEM;
+ goto irq_fault;
+ }
+
+ tmp->irq = irq_of_parse_and_map(pdev->dev.of_node, count);
+
+ dev_dbg(&pdev->dev, "%d: Alloc irq: %d\n", count, tmp->irq);
+
+ /* Allocating shared IRQs will ensure that any module will
+ * use these IRQs */
+ ret = request_irq(tmp->irq, zynq_remoteproc_interrupt, 0,
+ dev_name(&pdev->dev), &pdev->dev);
+ if (ret) {
+ dev_err(&pdev->dev, "IRQ %d already allocated\n",
+ tmp->irq);
+ goto irq_fault;
+ }
+
+ /*
+ * MS: Here is place for detecting problem with firmware
+ * which doesn't work correctly with interrupts
+ *
+ * MS: Comment if you want to count IRQs on Linux
+ */
+ gic_set_cpu(1, tmp->irq);
+ list_add(&(tmp->list), &(local->mylist.list));
+ }
+
+ /* Allocate free IPI number */
+ of_prop = of_get_property(pdev->dev.of_node, "ipino", NULL);
+ if (!of_prop) {
+ dev_err(&pdev->dev, "Please specify ipino node property\n");
+ goto ipi_fault;
+ }
+
+ local->ipino = be32_to_cpup(of_prop);
+ ret = set_ipi_handler(local->ipino, ipi_kick, "Firmware kick");
+ if (ret) {
+ dev_err(&pdev->dev, "IPI handler already registered\n");
+ goto ipi_fault;
+ }
+
+ /* Let the vring0 use the same ipi number. This will avoid the
+ need of having separate interrupt from remote side */
+ local->vring0 = local->ipino;
+
+ /* Read vring1 ipi number */
+ of_prop = of_get_property(pdev->dev.of_node, "vring1", NULL);
+ if (!of_prop) {
+ dev_err(&pdev->dev, "Please specify vring1 node property\n");
+ goto ipi_fault;
+ }
+ local->vring1 = be32_to_cpup(of_prop);
+
+ /* Module param firmware first */
+ if (firmware)
+ prop = firmware;
+ else
+ prop = of_get_property(pdev->dev.of_node, "firmware", NULL);
+
+ if (prop) {
+ dev_dbg(&pdev->dev, "Using firmware: %s\n", prop);
+ local->rproc = rproc_alloc(&pdev->dev, dev_name(&pdev->dev),
+ &zynq_rproc_ops, prop, sizeof(struct rproc));
+ if (!local->rproc) {
+ dev_err(&pdev->dev, "rproc allocation failed\n");
+ goto rproc_fault;
+ }
+
+ ret = rproc_add(local->rproc);
+ if (ret) {
+ dev_err(&pdev->dev, "rproc registration failed\n");
+ goto rproc_fault;
+ }
+
+ return ret;
+ } else
+ ret = -ENODEV;
+
+rproc_fault:
+ rproc_put(local->rproc);
+ipi_fault:
+ clear_ipi_handler(local->ipino);
+
+irq_fault:
+ clear_irq(pdev);
+
+dma_fault:
+ /* Cpu can't be power on - for example in nosmp mode */
+ ret |= cpu_up(1);
+ if (ret)
+ dev_err(&pdev->dev, "Can't power on cpu1 %d\n", ret);
+
+ return ret;
+}
+
+static int zynq_remoteproc_remove(struct platform_device *pdev)
+{
+ struct zynq_rproc_pdata *local = platform_get_drvdata(pdev);
+ u32 ret;
+
+ dev_info(&pdev->dev, "%s\n", __func__);
+
+ dma_release_declared_memory(&pdev->dev);
+
+ clear_ipi_handler(local->ipino);
+ clear_irq(pdev);
+
+ rproc_del(local->rproc);
+ rproc_put(local->rproc);
+
+ /* Cpu can't be power on - for example in nosmp mode */
+ ret = cpu_up(1);
+ if (ret)
+ dev_err(&pdev->dev, "Can't power on cpu1 %d\n", ret);
+
+ return 0;
+}
+
+/* Match table for OF platform binding */
+static struct of_device_id zynq_remoteproc_match[] = {
+ { .compatible = "xlnx,zynq_remoteproc", },
+ { /* end of list */ },
+};
+MODULE_DEVICE_TABLE(of, zynq_remoteproc_match);
+
+static struct platform_driver zynq_remoteproc_driver = {
+ .probe = zynq_remoteproc_probe,
+ .remove = zynq_remoteproc_remove,
+ .driver = {
+ .name = "zynq_remoteproc",
+ .owner = THIS_MODULE,
+ .of_match_table = zynq_remoteproc_match,
+ },
+};
+module_platform_driver(zynq_remoteproc_driver);
+
+module_param(firmware, charp, 0);
+MODULE_PARM_DESC(firmware, "Override the firmware image name. Default value in DTS.");
+
+MODULE_AUTHOR("Michal Simek <monstr@monstr.eu");
+MODULE_LICENSE("GPL v2");
+MODULE_DESCRIPTION("Zynq remote processor control driver");
diff --git a/apps/samples/master/linux/kernelspace/zynq_rpmsg_driver/zynq_rpmsg_driver.c b/apps/samples/master/linux/kernelspace/zynq_rpmsg_driver/zynq_rpmsg_driver.c
--- /dev/null
@@ -0,0 +1,476 @@
+/*
+ * Zynq Remote Processor Messaging Framework driver
+ *
+ * Copyright (C) 2014 Mentor Graphics Corporation
+ *
+ * Based on Zynq Remote Processor driver
+ *
+ * Copyright (C) 2012 Michal Simek <monstr@monstr.eu>
+ * Copyright (C) 2012 PetaLogix
+ *
+ * Based on origin OMAP Remote Processor driver
+ *
+ * Copyright (C) 2011 Texas Instruments, Inc.
+ * Copyright (C) 2011 Google, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ */
+
+#include <linux/kernel.h>
+#include <linux/init.h>
+#include <linux/module.h>
+#include <linux/device.h>
+#include <linux/slab.h>
+#include <linux/mutex.h>
+#include <linux/string.h>
+#include <linux/interrupt.h>
+#include <linux/platform_device.h>
+#include <linux/dma-mapping.h>
+#include <linux/of_irq.h>
+#include <linux/virtio.h>
+#include <linux/virtio_ids.h>
+#include <linux/virtio_ring.h>
+#include <linux/virtio_config.h>
+#include <asm/outercache.h>
+#include <asm/cacheflush.h>
+#include <asm/hardware/gic.h>
+#include <linux/of_device.h>
+#include <linux/of_platform.h>
+#include <linux/idr.h>
+
+#include "zynq_rpmsg_internals.h"
+
+static DEFINE_IDA(rpmsg_zynq_dev_index);
+
+/* Globals. */
+struct work_struct zynq_rpmsg_work;
+
+struct platform_device *zynq_rpmsg_platform;
+struct zynq_rpmsg_instance *zynq_rpmsg_p;
+
+static void zynq_rpmsg_virtio_notify(struct virtqueue *vq)
+{
+ /* Notify the other core. */
+ if (vq == zynq_rpmsg_p->vrings[0].vq)
+ /* Raise soft IRQ on GIC. */
+ gic_raise_softirq_unicore(0, zynq_rpmsg_p->vring0);
+ else
+ gic_raise_softirq_unicore(0, zynq_rpmsg_p->vring1);
+}
+
+static void zynq_rpmsg_virtio_del_vqs(struct virtio_device *vdev)
+{
+ struct zynq_rpmsg_vring *local_vring;
+ int i;
+
+ for (i = 0; i < ZYNQ_RPMSG_NUM_VRINGS; i++) {
+
+ local_vring = &(zynq_rpmsg_p->vrings[i]);
+
+ vring_del_virtqueue(local_vring->vq);
+
+ local_vring->vq = NULL;
+
+ dma_free_coherent(&(zynq_rpmsg_platform->dev),
+ local_vring->len, local_vring->va,
+ local_vring->dma);
+ }
+}
+
+static int zynq_rpmsg_virtio_find_vqs(struct virtio_device *vdev,
+ unsigned nvqs, struct virtqueue *vqs[],
+ vq_callback_t *callbacks[],
+ const char *names[])
+{
+ int i;
+ struct zynq_rpmsg_vring *local_vring;
+ void *vring_va;
+ int size;
+
+ /* Skip through the vrings. */
+ for (i = 0; i < nvqs; i++) {
+
+ local_vring = &(zynq_rpmsg_p->vrings[i]);
+
+ local_vring->len = zynq_rpmsg_p->num_descs;
+
+ size = vring_size(zynq_rpmsg_p->num_descs,
+ zynq_rpmsg_p->align);
+
+ /* Allocate non-cacheable memory for the vring. */
+ local_vring->va = dma_alloc_coherent
+ (&(zynq_rpmsg_platform->dev),
+ size, &(local_vring->dma), GFP_KERNEL);
+
+ vring_va = local_vring->va;
+
+ memset(vring_va, 0, size);
+
+ local_vring->vq = vring_new_virtqueue(i,
+ zynq_rpmsg_p->num_descs,
+ zynq_rpmsg_p->align, vdev,
+ false, vring_va,
+ zynq_rpmsg_virtio_notify,
+ callbacks[i], names[i]);
+
+ vqs[i] = local_vring->vq;
+ }
+
+ return 0;
+}
+
+static u8 zynq_rpmsg_virtio_get_status(struct virtio_device *vdev)
+{
+ return 0;
+}
+
+static void zynq_rpmsg_virtio_set_status(struct virtio_device *vdev, u8 status)
+{
+ /* */
+}
+
+static void zynq_rpmsg_virtio_reset(struct virtio_device *vdev)
+{
+ /* */
+}
+
+static u32 zynq_rpmsg_virtio_get_features(struct virtio_device *vdev)
+{
+ /* Return features. */
+ return zynq_rpmsg_p->dev_feature;
+}
+
+static void zynq_rpmsg_virtio_finalize_features(struct virtio_device *vdev)
+{
+ /* Set vring transport features. */
+ vring_transport_features(vdev);
+
+ zynq_rpmsg_p->gen_feature = vdev->features[0];
+}
+
+static void zynq_rpmsg_vdev_release(struct device *dev)
+{
+
+}
+
+static void mid_level_type_release(struct device *dev)
+{
+
+}
+
+static struct virtio_config_ops zynq_rpmsg_virtio_config_ops = {
+ .get_features = zynq_rpmsg_virtio_get_features,
+ .finalize_features = zynq_rpmsg_virtio_finalize_features,
+ .find_vqs = zynq_rpmsg_virtio_find_vqs,
+ .del_vqs = zynq_rpmsg_virtio_del_vqs,
+ .reset = zynq_rpmsg_virtio_reset,
+ .set_status = zynq_rpmsg_virtio_set_status,
+ .get_status = zynq_rpmsg_virtio_get_status,
+};
+
+static struct device_type mid_level_type = {
+ .name = "rpmsg_mid",
+ .release = mid_level_type_release,
+};
+
+static void handle_event(struct work_struct *work)
+{
+ struct virtqueue *vq;
+
+ flush_cache_all();
+
+ outer_flush_range(zynq_rpmsg_p->mem_start, zynq_rpmsg_p->mem_end);
+
+ vq = zynq_rpmsg_p->vrings[0].vq;
+
+ if (vring_interrupt(0, vq) == IRQ_NONE)
+ dev_dbg(&zynq_rpmsg_platform->dev, "no message found in vqid 0\n");
+}
+
+static void ipi_handler(void)
+{
+ schedule_work(&zynq_rpmsg_work);
+}
+
+static int zynq_rpmsg_deinitialize(struct platform_device *pdev)
+{
+ unregister_virtio_device(&(zynq_rpmsg_p->virtio_dev));
+
+ put_device(&(zynq_rpmsg_p->mid_dev));
+
+ dma_release_declared_memory(&pdev->dev);
+
+ clear_ipi_handler(zynq_rpmsg_p->vring0);
+
+ return 0;
+}
+
+static int zynq_rpmsg_initialize(struct platform_device *pdev)
+{
+ int ret = 0;
+ int index;
+ struct virtio_device *virtio_dev;
+
+ /* Register ipi handler. */
+ ret = set_ipi_handler(zynq_rpmsg_p->vring0, ipi_handler,
+ "Firmware kick");
+
+ if (ret) {
+ dev_err(&pdev->dev, "IPI handler already registered\n");
+ return -ENODEV;
+ }
+
+ /* Initialize work. */
+ INIT_WORK(&zynq_rpmsg_work, handle_event);
+
+ /* Memory allocations for vrings. */
+ ret = dma_declare_coherent_memory(&pdev->dev,
+ zynq_rpmsg_p->mem_start,
+ zynq_rpmsg_p->mem_start,
+ zynq_rpmsg_p->mem_end -
+ zynq_rpmsg_p->mem_start + 1,
+ DMA_MEMORY_IO);
+
+ if (!ret) {
+ dev_err(&pdev->dev, "dma_declare_coherent_memory failed\n");
+ return -ENODEV;
+ }
+
+ ret = dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(32));
+
+ if (ret) {
+ dev_err(&pdev->dev, "dma_set_coherent_mask: %d\n", ret);
+ return -ENODEV;
+ }
+
+ /* Initialize a mid-level device. Needed because of bad data structure
+ * handling and assumptions within the virtio rpmsg bus. We are doing it
+ * to just make sure that the virtio device has a parent device which
+ * then itself has a parent in the form of the platform device. */
+ device_initialize(&(zynq_rpmsg_p->mid_dev));
+
+ zynq_rpmsg_p->mid_dev.parent = &(pdev->dev);
+ zynq_rpmsg_p->mid_dev.type = &mid_level_type;
+
+ index = ida_simple_get(&rpmsg_zynq_dev_index, 0, 0, GFP_KERNEL);
+
+ if (index < 0) {
+ put_device(&(zynq_rpmsg_p->mid_dev));
+ return -ENODEV;
+ }
+
+ dev_set_name(&(zynq_rpmsg_p->mid_dev), "rpmsg_mid%d", index);
+
+ device_add(&(zynq_rpmsg_p->mid_dev));
+
+ /* Setup the virtio device structure. */
+ virtio_dev = &(zynq_rpmsg_p->virtio_dev);
+
+ virtio_dev->id.device = zynq_rpmsg_p->virtioid;
+ virtio_dev->config = &zynq_rpmsg_virtio_config_ops;
+ virtio_dev->dev.parent = &(zynq_rpmsg_p->mid_dev);
+ virtio_dev->dev.release = zynq_rpmsg_vdev_release;
+
+ /* Register the virtio device. */
+ ret = register_virtio_device(virtio_dev);
+
+ dev_info(&(zynq_rpmsg_platform->dev), "virtio device registered \r\n");
+
+ return ret;
+}
+
+static int zynq_rpmsg_retrieve_dts_info(struct platform_device *pdev)
+{
+ const void *of_prop;
+ struct resource *res;
+
+ /* Retrieve memory information. */
+ res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+ if (!res) {
+ dev_err(&pdev->dev, "invalid address\n");
+ return -ENODEV;
+ }
+
+ zynq_rpmsg_p->mem_start = res->start;
+ zynq_rpmsg_p->mem_end = res->end;
+
+ /* Allocate free IPI number */
+ of_prop = of_get_property(pdev->dev.of_node, "vring0", NULL);
+ if (!of_prop) {
+ dev_err(&pdev->dev, "Please specify vring0 node property\n");
+ return -ENODEV;
+ }
+
+ zynq_rpmsg_p->vring0 = be32_to_cpup(of_prop);
+
+
+ /* Read vring1 ipi number */
+ of_prop = of_get_property(pdev->dev.of_node, "vring1", NULL);
+ if (!of_prop) {
+ dev_err(&pdev->dev, "Please specify vring1 node property\n");
+ return -ENODEV;
+ }
+
+ zynq_rpmsg_p->vring1 = be32_to_cpup(of_prop);
+
+ of_prop = of_get_property(pdev->dev.of_node, "num-descs", NULL);
+ if (!of_prop) {
+ dev_err(&pdev->dev, "Please specify num descs node property\n");
+ return -ENODEV;
+ }
+
+ zynq_rpmsg_p->num_descs = be32_to_cpup(of_prop);
+
+ /* Read dev-feature */
+ of_prop = of_get_property(pdev->dev.of_node, "dev-feature", NULL);
+ if (!of_prop) {
+ dev_err(&pdev->dev, "Please specify dev features node property\n");
+ return -ENODEV;
+ }
+
+ zynq_rpmsg_p->dev_feature = be32_to_cpup(of_prop);
+
+ /* Read gen-feature */
+ of_prop = of_get_property(pdev->dev.of_node, "gen-feature", NULL);
+ if (!of_prop) {
+ dev_err(&pdev->dev, "Please specify gen features node property\n");
+ return -ENODEV;
+ }
+
+ zynq_rpmsg_p->gen_feature = be32_to_cpup(of_prop);
+
+ /* Read number of vrings */
+ of_prop = of_get_property(pdev->dev.of_node, "num-vrings", NULL);
+ if (!of_prop) {
+ dev_err(&pdev->dev, "Please specify num-vrings node property\n");
+ return -ENODEV;
+ }
+
+ zynq_rpmsg_p->num_vrings = be32_to_cpup(of_prop);
+
+ if (zynq_rpmsg_p->num_vrings > 2) {
+ dev_err(&pdev->dev, "We do not currently support more than 2 vrings.\n");
+ return -ENODEV;
+ }
+
+ /* Read vring alignment */
+ of_prop = of_get_property(pdev->dev.of_node, "alignment", NULL);
+ if (!of_prop) {
+ dev_err(&pdev->dev, "Please specify alignment node property\n");
+ return -ENODEV;
+ }
+
+ zynq_rpmsg_p->align = be32_to_cpup(of_prop);
+
+ /* Read virtio ID*/
+ of_prop = of_get_property(pdev->dev.of_node, "virtioid", NULL);
+ if (!of_prop) {
+ dev_err(&pdev->dev, "Please specify virtio id property\n");
+ return -ENODEV;
+ }
+
+ zynq_rpmsg_p->virtioid = be32_to_cpup(of_prop);
+
+ /* Read Ring Tx address. */
+ of_prop = of_get_property(pdev->dev.of_node, "ringtx", NULL);
+ if (!of_prop) {
+ dev_err(&pdev->dev, "Please specify ring tx property\n");
+ return -ENODEV;
+ }
+
+ zynq_rpmsg_p->ringtx = be32_to_cpup(of_prop);
+
+ /* Read Ring Rx address. */
+ of_prop = of_get_property(pdev->dev.of_node, "ringrx", NULL);
+ if (!of_prop) {
+ dev_err(&pdev->dev, "Please specify ringrx property\n");
+ return -ENODEV;
+ }
+
+ zynq_rpmsg_p->ringrx = be32_to_cpup(of_prop);
+
+ return 0;
+}
+
+static int zynq_rpmsg_probe(struct platform_device *pdev)
+{
+ int ret = 0;
+
+ zynq_rpmsg_platform = pdev;
+
+ /* Allocate memory for the Zynq RPMSG instance. */
+ zynq_rpmsg_p = kzalloc(sizeof(struct zynq_rpmsg_instance), GFP_KERNEL);
+
+ if (!zynq_rpmsg_p) {
+ dev_err(&pdev->dev, "Unable to alloc memory for zynq_rpmsg instance.\n");
+ return -ENOMEM;
+ }
+
+ /* Save the instance handle. */
+ platform_set_drvdata(pdev, zynq_rpmsg_p);
+
+ /* Retrieve the rquired information from DTS. */
+ ret = zynq_rpmsg_retrieve_dts_info(pdev);
+
+ if (ret) {
+ dev_err(&pdev->dev, "Failure in retrieving info from DTS.\n");
+ kzfree(zynq_rpmsg_p);
+ return -ENOMEM;
+ }
+
+ /* Perform all the initializations. */
+ ret = zynq_rpmsg_initialize(pdev);
+
+ return ret;
+}
+
+static int zynq_rpmsg_remove(struct platform_device *pdev)
+{
+ zynq_rpmsg_deinitialize(pdev);
+
+ kfree(zynq_rpmsg_p);
+
+ return 0;
+}
+
+
+/* Match table for OF platform binding */
+static struct of_device_id zynq_rpmsg_match[] = {
+ { .compatible = "xlnx,zynq_rpmsg_driver", },
+ { /* end of list */ },
+};
+MODULE_DEVICE_TABLE(of, zynq_rpmsg_match);
+
+static struct platform_driver zynq_rpmsg_driver = {
+ .probe = zynq_rpmsg_probe,
+ .remove = zynq_rpmsg_remove,
+ .driver = {
+ .name = "zynq_rpmsg_driver",
+ .owner = THIS_MODULE,
+ .of_match_table = zynq_rpmsg_match,
+ },
+};
+
+static int __init init(void)
+{
+ return platform_driver_register(&zynq_rpmsg_driver);
+}
+
+static void __exit fini(void)
+{
+ platform_driver_unregister(&zynq_rpmsg_driver);
+}
+
+
+module_init(init);
+module_exit(fini);
+
+MODULE_LICENSE("GPL v2");
+MODULE_DESCRIPTION("Zynq RPMSG driver to use RPMSG framework without remoteproc");
diff --git a/apps/samples/master/linux/kernelspace/zynq_rpmsg_driver/zynq_rpmsg_internals.h b/apps/samples/master/linux/kernelspace/zynq_rpmsg_driver/zynq_rpmsg_internals.h
--- /dev/null
@@ -0,0 +1,67 @@
+/*
+ * Zynq Remote Processor Messaging Framework driver
+ *
+ * Copyright (C) 2014 Mentor Graphics Corporation
+ *
+ * Based on Zynq Remote Processor driver
+ *
+ * Copyright (C) 2012 Michal Simek <monstr@monstr.eu>
+ * Copyright (C) 2012 PetaLogix
+ *
+ * Based on origin OMAP Remote Processor driver
+ *
+ * Copyright (C) 2011 Texas Instruments, Inc.
+ * Copyright (C) 2011 Google, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ */
+
+
+#define ZYNQ_RPMSG_NUM_VRINGS 2
+struct zynq_rpmsg_vring {
+
+ void *va;
+ dma_addr_t dma;
+ int len;
+ u32 da;
+ u32 align;
+ struct virtqueue *vq;
+};
+
+struct zynq_rpmsg_instance {
+
+ u32 vring0;
+ u32 vring1;
+ u32 mem_start;
+ u32 mem_end;
+ u32 num_descs;
+ u32 dev_feature;
+ u32 gen_feature;
+ u32 num_vrings;
+ u32 align;
+ u32 virtioid;
+ u32 ringtx;
+ u32 ringrx;
+
+ struct virtio_device virtio_dev;
+
+ struct zynq_rpmsg_vring vrings[ZYNQ_RPMSG_NUM_VRINGS];
+
+ struct device mid_dev;
+};
+
+#ifndef CONFIG_SMP
+extern int set_ipi_handler(int ipinr, void *handler, char *desc);
+
+extern void clear_ipi_handler(int ipinr);
+
+extern void gic_raise_softirq_unicore(unsigned long cpu, unsigned int irq);
+#endif
+
diff --git a/apps/samples/master/linux/userspace/matrix_multiply/mat_mul_demo.c b/apps/samples/master/linux/userspace/matrix_multiply/mat_mul_demo.c
--- /dev/null
@@ -0,0 +1,219 @@
+/*
+ * Sample demo application that showcases inter processor
+ * communication from linux userspace to a remote software
+ * context. The application generates random matrices and
+ * transmits them to the remote context over rpmsg. The
+ * remote application performs multiplication of matrices
+ * and transmits the results back to this application.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <sys/ioctl.h>
+#include <time.h>
+#include <fcntl.h>
+#include <pthread.h>
+#include <string.h>
+
+#define MATRIX_SIZE 6
+
+/* Shutdown message ID */
+#define SHUTDOWN_MSG 0xEF56A55A
+
+struct _matrix {
+ unsigned long size;
+ unsigned long elements[MATRIX_SIZE][MATRIX_SIZE];
+};
+
+static void matrix_print(struct _matrix *m)
+{
+ int i, j;
+
+ /* Generate two random matrices */
+ printf(" \r\n Master : Linux : Printing results \r\n");
+
+ for (i = 0; i < m->size; ++i) {
+ for (j = 0; j < m->size; ++j)
+ printf(" %d ", (unsigned int)m->elements[i][j]);
+ printf("\r\n");
+ }
+}
+
+static void generate_matrices(int num_matrices,
+ unsigned int matrix_size, void *p_data)
+{
+ int i, j, k;
+ struct _matrix *p_matrix = p_data;
+ time_t t;
+ unsigned long value;
+
+ srand((unsigned) time(&t));
+
+ for (i = 0; i < num_matrices; i++) {
+ /* Initialize workload */
+ p_matrix[i].size = matrix_size;
+
+ printf(" \r\n Master : Linux : Input matrix %d \r\n", i);
+ for (j = 0; j < matrix_size; j++) {
+ printf("\r\n");
+ for (k = 0; k < matrix_size; k++) {
+
+ value = (rand() & 0x7F);
+ value = value % 10;
+ p_matrix[i].elements[j][k] = value;
+ printf(" %d ",
+ (unsigned int)p_matrix[i].elements[j][k]);
+ }
+ }
+ printf("\r\n");
+ }
+
+}
+
+static pthread_t ui_thread, compute_thread;
+static pthread_mutex_t sync_lock;
+
+static int fd, compute_flag;
+static struct _matrix *i_matrix;
+static struct _matrix *r_matrix;
+
+#define RPMSG_GET_KFIFO_SIZE 1
+#define RPMSG_GET_FREE_SPACE 3
+
+void *ui_thread_entry(void *ptr)
+{
+ int cmd, ret;
+ int flag = 1;
+
+ while (flag) {
+ printf("\r\n **************************************** \r\n");
+ printf(" Please enter command and press enter key\r\n");
+ printf(" **************************************** \r\n");
+ printf(" 1 - Generates random 6x6 matrices and transmits");
+ printf(" them to remote core over rpmsg .. \r\n");
+ printf(" 2 - Quit this application .. \r\n");
+ printf(" CMD>");
+ ret = scanf("%d", &cmd);
+ if (!ret) {
+ while (1) {
+ if (getchar() == '\n')
+ break;
+ }
+
+ printf("\r\n invalid command\r\n");
+ continue;
+ }
+ if (cmd == 1) {
+ compute_flag = 1;
+ pthread_mutex_unlock(&sync_lock);
+
+ printf("\r\n Compute thread unblocked .. \r\n");
+ printf(" The compute thread is now blocking on");
+ printf("a read() from rpmsg device \r\n");
+ printf("\r\n Generating random matrices now ... \r\n");
+
+ i_matrix = malloc(sizeof(*i_matrix)*2);
+
+ generate_matrices(2, 6, i_matrix);
+
+ printf("\r\n Writing generated matrices to rpmsg ");
+ printf("rpmsg device, %d bytes written .. \r\n",
+ sizeof(*i_matrix)*2);
+
+ write(fd, i_matrix, sizeof(*i_matrix)*2);
+
+ free(i_matrix);
+
+ /* adding this so the threads
+ dont overlay the strings they print */
+ sleep(1);
+ } else if (cmd == 2) {
+ flag = 0;
+ compute_flag = 0;
+ pthread_mutex_unlock(&sync_lock);
+ printf("\r\n Quitting application .. \r\n");
+ printf(" Matrix multiplication demo end \r\n");
+ } else {
+ printf("\r\n invalid command! \r\n");
+ }
+ }
+
+ return 0;
+}
+
+void *compute_thread_entry(void *ptr)
+{
+ int bytes_rcvd;
+
+ pthread_mutex_lock(&sync_lock);
+
+ while (compute_flag == 1) {
+ r_matrix = malloc(sizeof(*r_matrix));
+
+ bytes_rcvd = read(fd, r_matrix, sizeof(*r_matrix));
+
+ printf("\r\n Received results! - %d bytes from ", bytes_rcvd);
+ printf("rpmsg device (transmitted from remote context) \r\n");
+
+ matrix_print(r_matrix);
+
+ free(r_matrix);
+
+ pthread_mutex_lock(&sync_lock);
+ }
+
+ return 0;
+}
+
+int main(int argc, char *argv[])
+{
+ unsigned int size;
+ int shutdown_msg = SHUTDOWN_MSG;
+
+ printf("\r\n Matrix multiplication demo start \r\n");
+
+ printf("\r\n Open rpmsg dev! \r\n");
+
+ fd = open("/dev/rpmsg", O_RDWR);
+
+ printf("\r\n Query internal info .. \r\n");
+
+ ioctl(fd, RPMSG_GET_KFIFO_SIZE, &size);
+
+ printf(" rpmsg kernel fifo size = %u \r\n", size);
+
+ ioctl(fd, RPMSG_GET_FREE_SPACE, &size);
+
+ printf(" rpmsg kernel fifo free space = %u \r\n", size);
+
+ if (pthread_mutex_init(&sync_lock, NULL) != 0)
+ printf("\r\n mutex initialization failure \r\n");
+
+ pthread_mutex_lock(&sync_lock);
+
+ printf("\r\n Creating ui_thread and compute_thread ... \r\n");
+
+ pthread_create(&ui_thread, NULL, &ui_thread_entry, "ui_thread");
+
+ pthread_create(&compute_thread, NULL, &compute_thread_entry,
+ "compute_thread");
+ pthread_join(ui_thread, NULL);
+
+ pthread_join(compute_thread, NULL);
+
+ /* Send shutdown message to remote */
+ write(fd, &shutdown_msg , sizeof(int));
+ sleep(1);
+
+ printf("\r\n Quitting application .. \r\n");
+ printf(" Matrix multiply application end \r\n");
+
+ close(fd);
+
+ pthread_mutex_destroy(&sync_lock);
+
+ return 0;
+}
+
+
diff --git a/apps/samples/master/nucleus/matrix_multiply/nucleus_linux/make b/apps/samples/master/nucleus/matrix_multiply/nucleus_linux/make
--- /dev/null
@@ -0,0 +1,52 @@
+
+include ../Makefile.commons
+
+SAMPLE_OUT := samples/master/nucleus/matrix_multiply/nucleus_linux/matrix_multiply.out
+SAMPLE_C_SRC := samples/master/nucleus/matrix_multiply/nucleus_linux/matrix_multiply.c
+
+REMOTE_OUT := matrix_multiply.out
+DST_DIR := samples/master/nucleus/matrix_multiply/nucleus_linux
+LINUX_SRC_DIR := firmware/$(PLAT)/linux
+
+SAMPLEOBJFILES := $(patsubst %.c, %.o, $(SAMPLE_C_SRC))
+SAMPLE_DEPS := $(patsubst %.c, %.d, $(SAMPLE_C_SRC))
+
+SAMPLE_MAP := $(patsubst %.out, %.map, $(SAMPLE_OUT))
+SAMPLE_BIN := $(patsubst %.out, %.bin, $(SAMPLE_OUT))
+
+
+$(SAMPLE_OUT): $(REMOTE_OUT) $(SAMPLEOBJFILES)
+
+ @echo 'Building master core matrix multiply sample for nucleus : $@'
+
+ $(LD) -Wl,-Map=samples/master/nucleus/matrix_multiply/nucleus_linux/matrix_multiply.map -nostartfiles -Wl,--gc-sections -Wl,--wrap=malloc -Wl,--wrap=calloc -Wl,--wrap=realloc -Wl,--wrap=free -T"$(OHOME)/libs/system/$(PLAT)/nucleus/linker_master.ld" -L"$(OHOME)/libs/system/$(PLAT)/nucleus/lib/$(CROSS)/master" -L"$(OHOME)/libs/open_amp" -o "$(SAMPLE_OUT)" -Wl,--start-group $(SAMPLEOBJFILES) $(DST_DIR)/firmware1.o $(DST_DIR)/firmware2.o -lnucleus_master -lopen_amp -lc -lm -lstdc++ -Wl,--end-group
+
+ $(OBJCPY) -O binary $(SAMPLE_OUT) $(SAMPLE_BIN)
+
+ @echo 'Finished building target: $@'
+
+%.o:%.c
+ @echo CC $(<:.c=.o)
+ @$(CC) $(CFLAGS) $(ARCH_CFLAGS) $(INCLUDE) -c $< -o $@
+
+%.o:%.S
+ @$(AS) -c -mcpu=cortex-a9 $(ARCH_ASFLAGS) $(INCLUDE) $< -o $@
+
+$(REMOTE_OUT):
+ cd $(LINUX_SRC_DIR)/; cp firmware firmware1; \
+ $(OBJCPY) -I binary -O elf32-littlearm -B arm firmware1 firmware1.o
+ mv $(LINUX_SRC_DIR)/firmware1.o $(DST_DIR)/firmware1.o
+ cd $(LINUX_SRC_DIR)/; cp firmware firmware2; \
+ $(OBJCPY) -I binary -O elf32-littlearm -B arm firmware2 firmware2.o
+ mv $(LINUX_SRC_DIR)/firmware2.o $(DST_DIR)/
+ cd $(LINUX_SRC_DIR)/; rm firmware1; rm firmware2;
+clean:
+ -$(RM) $(SAMPLEOBJFILES) $(SAMPLE_DEPS) $(SAMPLE_OUT) $(SAMPLE_MAP) $(SAMPLE_BIN) $(DST_DIR)/firmware1.o $(DST_DIR)/firmware2.o
+
+post-build:
+ -@echo ' '
+
+secondary-outputs:
+
+PHONY: all clean dependents
+.SECONDARY: post-build
diff --git a/apps/samples/master/nucleus/matrix_multiply/nucleus_linux/matrix_multiply.c b/apps/samples/master/nucleus/matrix_multiply/nucleus_linux/matrix_multiply.c
--- /dev/null
@@ -0,0 +1,243 @@
+/* This is a sample demonstration application that showcases usage of remoteproc
+and rpmsg APIs. This application is meant to run on the master CPU running Nucleus
+and showcases booting of linux remote firmware using remoteproc and
+IPC with remote firmware using rpmsg; Nucleus on master core acts as a remoteproc master
+but as an rpmsg remote;It brings up a remote Linux based
+firmware which acts as an rpmsg master and offloads matrix multiplication to Nucleus.
+Linux app generates two random matrices and transmits them to Nucleus which computes
+the product and transmits results back to Linux. Once Linux application is complete, it
+requests a shutdown from Nucleus. Nucleus acknowledges with a shutdown message which results
+in Linux starting a system halt. Nucleus shutsdown the remote core after a reasonable delay which allows
+Linux to gracefully shutdown. */
+
+/* Including required headers */
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include "open_amp.h"
+#include "nucleus.h"
+#include "kernel/nu_kernel.h"
+
+/* Define the main task's stack size */
+#define STACK_SIZE (NU_MIN_STACK_SIZE * 64)
+
+/* Define the main task's priority */
+#define TASK_PRIORITY 26
+
+/* Define the main task's time slice */
+#define TASK_SLICE 20
+
+#define MAX_SIZE 6
+#define NUM_MATRIX 2
+/* Shutdown message ID */
+#define SHUTDOWN_MSG 0xEF56A55A
+
+typedef struct _matrix
+{
+ unsigned long size;
+ unsigned long elements[MAX_SIZE][MAX_SIZE];
+} matrix;
+
+
+static matrix matrix_array[NUM_MATRIX];
+
+static matrix matrix_result;
+
+/* Prototypes */
+static void Main_Task_Entry( UNSIGNED argc , VOID *argv );
+
+/* Application provided callbacks */
+void rpmsg_channel_created( struct rpmsg_channel *rp_chnl );
+void rpmsg_channel_deleted( struct rpmsg_channel *rp_chnl );
+void rpmsg_read_cb( struct rpmsg_channel *rp_chnl , void *data , int len , void * pric , unsigned long src );
+
+/* Globals */
+NU_TASK Task_Control_Block;
+NU_SEMAPHORE App_Sem;
+struct rpmsg_endpoint *rp_ept;
+struct rpmsg_channel *app_rp_chnl;
+char fw1_name []= "firmware1";
+
+static int shutdown_received = 0;
+
+static void Matrix_Multiply(const matrix *m, const matrix *n, matrix *r)
+{
+ int i, j, k;
+
+ r->size = m->size;
+
+ for (i = 0; i < m->size; ++i) {
+ for (j = 0; j < n->size; ++j) {
+ r->elements[i][j] = 0;
+ }
+ }
+
+ for (i = 0; i < m->size; ++i) {
+ for (j = 0; j < n->size; ++j) {
+ for (k = 0; k < r->size; ++k) {
+ r->elements[i][j] += m->elements[i][k] * n->elements[k][j];
+ }
+ }
+ }
+}
+
+
+/***********************************************************************
+ * *
+ * * FUNCTION
+ * *
+ * * Application_Initialize
+ * *
+ * * DESCRIPTION
+ * *
+ * * Demo application entry point
+ *
+ * ***********************************************************************/
+VOID Application_Initialize(NU_MEMORY_POOL* mem_pool , NU_MEMORY_POOL* uncached_mem_pool )
+{
+ VOID *pointer;
+ STATUS status = NU_SUCCESS;
+
+ /* Reference unused parameters to avoid toolset warnings */
+ NU_UNUSED_PARAM( uncached_mem_pool );
+
+ if (status == NU_SUCCESS)
+ {
+ status = NU_Allocate_Memory(mem_pool, &pointer, STACK_SIZE, NU_NO_SUSPEND);
+
+ /* Create the main task for matrix processing */
+ if ( status == NU_SUCCESS )
+ {
+ status = NU_Create_Task( &Task_Control_Block , "MAIN" , Main_Task_Entry , 0 ,
+ uncached_mem_pool , pointer , STACK_SIZE , TASK_PRIORITY , TASK_SLICE ,
+ NU_PREEMPT , NU_START );
+ }
+ if(status == NU_SUCCESS)
+ {
+ status = NU_Create_Semaphore(&App_Sem ,"APP_SEM", 0, NU_FIFO);
+ }
+ }
+
+ /* Check to see if previous operations were successful */
+ if ( status != NU_SUCCESS )
+ {
+ /* Loop forever */
+ while ( 1 );
+ }
+}
+
+/***********************************************************************
+ * *
+ * * FUNCTION
+ * *
+ * * Main_Task_Entry
+ * *
+ * * DESCRIPTION
+ * *
+ * * Entry function for the main task. This task prints a hello world
+ * * message.
+ * *
+ * ***********************************************************************/
+static VOID Main_Task_Entry( UNSIGNED argc , VOID *argv ) {
+
+ struct remote_proc *proc;
+ NU_MEMORY_POOL *sys_pool_ptr;
+ STATUS status;
+ int shutdown_msg = SHUTDOWN_MSG;
+
+ status = NU_System_Memory_Get(&sys_pool_ptr, NU_NULL);
+
+ /* Start first firmware*/
+ if(status == NU_SUCCESS)
+ {
+ printf("\n\n\r************************************");
+ printf("*******************************************\r\n");
+ printf("\r\n Matrix Multiplication Application \r\n");
+ printf("\r\n");
+ printf("\r\nThis sample application will boot a remote Linux firmware \r\n");
+ printf("\r\nThis sample application will boot a remote Linux firmware \r\n");
+ printf("\r\nand handle offloaded matrix multiplication operations from\r\n");
+ printf("\r\nLinux RPMSG master to Nuclues RPMS Remote \r\n");
+
+ printf("\r\n******************************************");
+ printf("*************************************\n\r\n");
+
+
+ printf("\r\n\nLoading remote context : %s \r\n" , fw1_name);
+
+ printf("\r\n******************************************");
+ printf("*************************************\n\r\n");
+
+ status = remoteproc_init((void *) fw1_name, rpmsg_channel_created, rpmsg_channel_deleted, rpmsg_read_cb, &proc);
+ }
+
+ if((!status) && (proc))
+ {
+ printf("\r\n\n********************************************\r\n");
+ printf("BOOTING LINUX REMOTE FIRMWARE");
+ printf("\r\n********************************************\r\n\n");
+ status = remoteproc_boot(proc);
+ }
+
+ if(!status)
+ {
+ while(1)
+ {
+ NU_Obtain_Semaphore(&App_Sem, NU_SUSPEND);
+
+ if(shutdown_received == 1)
+ {
+ break;
+ }
+
+ /* Process received data and multiple matrices. */
+ Matrix_Multiply(&matrix_array[0], &matrix_array[1], &matrix_result);
+
+ /* Send the result of matrix multiplication back to master. */
+ rpmsg_send(app_rp_chnl, &matrix_result, sizeof(matrix));
+ }
+
+ /* Send shutdown message to remote */
+ rpmsg_send(app_rp_chnl, &shutdown_msg, sizeof(int));
+
+ /* The remote Linux kernel requires around ~15 seconds to shutdown itself. Wait. */
+ NU_Sleep(100 * 18);
+
+ remoteproc_shutdown(proc);
+
+ remoteproc_deinit(proc);
+ }
+ else
+ {
+ printf("\r\n\nLoading remote context: %s failed \r\n" , fw1_name);
+ }
+}
+
+/* This callback gets invoked when the remote chanl is created */
+void rpmsg_channel_created(struct rpmsg_channel *rp_chnl) {
+
+ app_rp_chnl = rp_chnl;
+ rp_ept = rpmsg_create_ept(rp_chnl , rpmsg_read_cb ,RPMSG_NULL , RPMSG_ADDR_ANY);
+}
+
+/* This callback gets invoked when the remote channel is deleted */
+void rpmsg_channel_deleted(struct rpmsg_channel *rp_chnl) {
+
+ rpmsg_destroy_ept(rp_ept);
+}
+
+/* This is the read callback, note we are in a task context when this callback
+is invoked, so kernel primitives can be used freely */
+void rpmsg_read_cb(struct rpmsg_channel *rp_chnl, void *data, int len,
+ void * priv, unsigned long src) {
+
+ if ((*(int *) data) == SHUTDOWN_MSG)
+ {
+ shutdown_received = 1;
+ }
+
+ memcpy(matrix_array, data, len);
+
+ NU_Release_Semaphore(&App_Sem);
+}
+
diff --git a/apps/samples/master/nucleus/matrix_multiply/nucleus_nucleusbm/make b/apps/samples/master/nucleus/matrix_multiply/nucleus_nucleusbm/make
--- /dev/null
@@ -0,0 +1,57 @@
+
+include ../Makefile.commons
+
+SAMPLE_OUT := samples/master/nucleus/matrix_multiply/nucleus_nucleusbm/matrix_multiply.out
+SAMPLE_C_SRC := samples/master/nucleus/matrix_multiply/nucleus_nucleusbm/matrix_multiply.c
+
+REMOTE_OUT := matrix_multiply.out
+DST_DIR := samples/master/nucleus/matrix_multiply/nucleus_nucleusbm
+NU_SRC_DIR := firmware/$(PLAT)/nucleus/matrix_multiply
+BM_SRC_DIR := firmware/$(PLAT)/baremetal/matrix_multiply
+
+
+SAMPLEOBJFILES := $(patsubst %.c, %.o, $(SAMPLE_C_SRC))
+
+
+SAMPLE_DEPS := $(patsubst %.c, %.d, $(SAMPLE_C_SRC))
+
+SAMPLE_MAP := $(patsubst %.out, %.map, $(SAMPLE_OUT))
+SAMPLE_BIN := $(patsubst %.out, %.bin, $(SAMPLE_OUT))
+
+
+$(SAMPLE_OUT): $(REMOTE_OUT) $(SAMPLEOBJFILES)
+
+ @echo 'Building master core matrix multiply sample for nucleus : $@'
+
+ $(LD) -Wl,-Map=samples/master/nucleus/matrix_multiply/nucleus_nucleusbm/matrix_multiply.map -nostartfiles -Wl,--gc-sections -Wl,--wrap=malloc -Wl,--wrap=calloc -Wl,--wrap=realloc -Wl,--wrap=free -T"$(OHOME)/libs/system/$(PLAT)/nucleus/linker_master.ld" -L"$(OHOME)/libs/system/$(PLAT)/nucleus/lib/$(CROSS)/master" -L"$(OHOME)/libs/open_amp" -o "$(SAMPLE_OUT)" -Wl,--start-group $(SAMPLEOBJFILES) $(DST_DIR)/firmware1.o $(DST_DIR)/firmware2.o -lnucleus_master -lopen_amp -lc -lm -lstdc++ -Wl,--end-group
+
+ $(OBJCPY) -O binary $(SAMPLE_OUT) $(SAMPLE_BIN)
+
+ @echo 'Finished building target: $@'
+
+%.o:%.c
+ @echo CC $(<:.c=.o)
+ @$(CC) $(CFLAGS) $(ARCH_CFLAGS) $(INCLUDE) -c $< -o $@
+
+%.o:%.S
+ @$(AS) -c -mcpu=cortex-a9 $(ARCH_ASFLAGS) $(INCLUDE) $< -o $@
+
+$(REMOTE_OUT):
+ cd $(NU_SRC_DIR)/; cp firmware firmware1; \
+ $(OBJCPY) -I binary -O elf32-littlearm -B arm firmware1 firmware1.o
+ mv $(NU_SRC_DIR)/firmware1.o $(DST_DIR)/
+ cd $(BM_SRC_DIR)/; cp firmware firmware2; \
+ $(OBJCPY) -I binary -O elf32-littlearm -B arm firmware2 firmware2.o
+ mv $(BM_SRC_DIR)/firmware2.o $(DST_DIR)/
+ cd $(NU_SRC_DIR)/; rm firmware1
+ cd $(BM_SRC_DIR)/; rm firmware2
+clean:
+ -$(RM) $(SAMPLEOBJFILES) $(SAMPLE_DEPS) $(SAMPLE_OUT) $(SAMPLE_MAP) $(SAMPLE_BIN) $(DST_DIR)/firmware1.o $(DST_DIR)/firmware2.o
+
+post-build:
+ -@echo ' '
+
+secondary-outputs:
+
+PHONY: all clean dependents
+.SECONDARY: post-build
diff --git a/apps/samples/master/nucleus/matrix_multiply/nucleus_nucleusbm/matrix_multiply.c b/apps/samples/master/nucleus/matrix_multiply/nucleus_nucleusbm/matrix_multiply.c
--- /dev/null
@@ -0,0 +1,395 @@
+/* This is a sample demonstration application that showcases usage of remoteproc
+and rpmsg APIs. This application is meant to run on the master CPU running Nucleus
+and showcases booting of two sub-sequent remote firmware cycles using remoteproc and
+IPC with remote firmware using rpmsg; 1. It brings up a remote Nucleus based remote
+firmware which performs matrix multiplication, 2. It brings up a baremetal based
+remote firmware which performs matrix multiplication. Master app generates two random
+matrices and transmits them to remotr firmware which computes the product and transmit
+results back to master CPU */
+
+/* Including required headers */
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include "nucleus.h"
+#include "kernel/nu_kernel.h"
+#include "open_amp.h"
+
+/* Define the main task's stack size */
+#define STACK_SIZE (NU_MIN_STACK_SIZE * 64)
+
+/* Define the main task's priority */
+#define TASK_PRIORITY 26
+
+/* Define the main task's time slice */
+#define TASK_SLICE 20
+
+#define MATRIX_SIZE 6
+
+#define SHUTDOWN_MSG 0xEF56A55A
+
+typedef struct _matrix
+{
+ unsigned long size;
+ unsigned long elements[MATRIX_SIZE][MATRIX_SIZE];
+} matrix;
+
+/* Prototypes */
+static void Main_Task_Entry( UNSIGNED argc , VOID *argv );
+
+/* Application provided callbacks */
+void rpmsg_channel_created( struct rpmsg_channel *rp_chnl );
+void rpmsg_channel_deleted( struct rpmsg_channel *rp_chnl );
+void rpmsg_read_cb( struct rpmsg_channel *rp_chnl , void *data , int len , void * pric , unsigned long src );
+
+/* Globals */
+NU_TASK Task_Control_Block;
+NU_SEMAPHORE App_Sem;
+
+struct rpmsg_endpoint *rp_ept;
+struct rpmsg_channel *app_rp_chnl;
+
+char fw1_name []= "firmware1"; /* Nucleus based matrix multiply remote firmware */
+char fw2_name []= "firmware2"; /* Baremetal based matrix multiply remote firmware */
+
+static struct _matrix* i_matrix;
+static struct _matrix* r_matrix;
+static int bytes_received;
+
+/***********************************************************************
+ * *
+ * * FUNCTION
+ * *
+ * * Application_Initialize
+ * *
+ * * DESCRIPTION
+ * *
+ * * Demo application entry point
+ *
+ * ***********************************************************************/
+VOID Application_Initialize(NU_MEMORY_POOL* mem_pool , NU_MEMORY_POOL* uncached_mem_pool )
+{
+ VOID *pointer;
+ STATUS status = NU_SUCCESS;
+
+ /* Reference unused parameters to avoid toolset warnings */
+ NU_UNUSED_PARAM( uncached_mem_pool );
+
+ if (status == NU_SUCCESS)
+ {
+ status = NU_Allocate_Memory(mem_pool, &pointer, STACK_SIZE, NU_NO_SUSPEND);
+
+ /* Create the main task for matrix processing */
+ if ( status == NU_SUCCESS )
+ {
+ status = NU_Create_Task( &Task_Control_Block , "MAIN" , Main_Task_Entry , 0 ,
+ uncached_mem_pool , pointer , STACK_SIZE , TASK_PRIORITY , TASK_SLICE ,
+ NU_PREEMPT , NU_START );
+ }
+ if(status == NU_SUCCESS)
+ {
+ status = NU_Create_Semaphore(&App_Sem ,"APP_SEM", 0, NU_FIFO);
+ }
+ }
+
+ /* Check to see if previous operations were successful */
+ if ( status != NU_SUCCESS )
+ {
+ /* Loop forever */
+ while ( 1 );
+ }
+}
+
+/***********************************************************************
+ * *
+ * * FUNCTION
+ * *
+ * * matrix_print
+ * *
+ * * DESCRIPTION
+ * *
+ * * Function to print a matrix.
+ * *
+ * ***********************************************************************/
+static void matrix_print(struct _matrix* m)
+{
+ int i, j;
+
+ /* Generate two random matrices */
+ printf( " \r\n Master : Nucleus : Printing results \r\n");
+
+ for (i = 0; i < m->size; ++i) {
+ for (j = 0; j < m->size; ++j) {
+ printf(" %d ", (unsigned int)m->elements[i][j]);
+ }
+ printf("\r\n");
+ }
+}
+
+/***********************************************************************
+ * *
+ * * FUNCTION
+ * *
+ * * generate_matrices
+ * *
+ * * DESCRIPTION
+ * *
+ * * Function to generate random matrices.
+ * *
+ * ***********************************************************************/
+static void generate_matrices(int num_matrices,
+ unsigned int matrix_size, void* p_data)
+{
+ int i, j, k;
+ struct _matrix* p_matrix = p_data;
+ unsigned long value;
+
+ /* Seed for random number generator */
+ srand(ESAL_GE_TMR_OS_COUNT_READ());
+
+ for(i=0; i< num_matrices; i++)
+ {
+ /* Initialize workload */
+ p_matrix[i].size = matrix_size;
+
+ printf( " \r\n Master : Nucleus : Input matrix %d \r\n", i);
+ for(j = 0; j < matrix_size; j++)
+ {
+ printf( "\r\n");
+ for(k = 0; k < matrix_size; k++)
+ {
+ value = (rand()&0x7F);
+ value = value%10;
+ p_matrix[i].elements[j][k] = value;
+ printf( " %d ", (unsigned int)p_matrix[i].elements[j][k]);
+ }
+ }
+ printf( "\r\n");
+ }
+
+}
+
+/***********************************************************************
+ * *
+ * * FUNCTION
+ * *
+ * * matrix_multiply_shell
+ * *
+ * * DESCRIPTION
+ * *
+ * * Simple demo shell
+ * *
+ * ***********************************************************************/
+static void matrix_multiply_shell(void)
+{
+ unsigned char cmd;
+
+ for ( ; ; )
+ {
+ printf("\r\n **************************************** \r\n");
+ printf(" Please enter command and press enter key\r\n");
+ printf(" **************************************** \r\n");
+ printf(" 1 - Generates random 6x6 matrices and transmits them to remote core over rpmsg .. \r\n");
+ printf(" 2 - Quit this application .. \r\n");
+ printf(" CMD>");
+
+ cmd = getchar();
+
+ if(cmd == '1')
+ {
+ printf("\r\n Generating random matrices now ... \r\n");
+
+ generate_matrices(2, 6, i_matrix);
+
+ printf("\r\n Writing generated matrices to rpmsg device, %d bytes written .. \r\n", \
+ sizeof(*i_matrix)*2);
+
+ rpmsg_send(app_rp_chnl, i_matrix, sizeof(*i_matrix)*2);
+
+ NU_Obtain_Semaphore(&App_Sem , NU_SUSPEND);
+
+ printf("\r\n Received results! - %d bytes from rpmsg device (transmitted from remote context) \r\n", bytes_received);
+
+ matrix_print(r_matrix);
+
+ }
+ else if(cmd == '2')
+ {
+ printf("\r\n Quitting application .. \r\n");
+ printf("\r\n Matrix multiplication demo end \r\n");
+
+ break;
+ }
+ else
+ {
+ printf("\r\n invalid command! \r\n");
+ }
+ }
+}
+
+/***********************************************************************
+ * *
+ * * FUNCTION
+ * *
+ * * Main_Task_Entry
+ * *
+ * * DESCRIPTION
+ * *
+ * * Entry function for the main task. This task prints a hello world
+ * * message.
+ * *
+ * ***********************************************************************/
+static VOID Main_Task_Entry( UNSIGNED argc , VOID *argv ) {
+
+ struct remote_proc *proc;
+ NU_MEMORY_POOL *sys_pool_ptr;
+ STATUS status;
+ int shutdown_msg = SHUTDOWN_MSG;
+
+ status = NU_System_Memory_Get(&sys_pool_ptr, NU_NULL);
+
+ /* Allocate memory for input matrices */
+ if(status == NU_SUCCESS)
+ {
+ status = NU_Allocate_Memory (sys_pool_ptr, (VOID *)&i_matrix,sizeof(*i_matrix)*2, NU_NO_SUSPEND);
+ }
+
+ /* Allocate memory for result matrix */
+ if(status == NU_SUCCESS)
+ {
+ status = NU_Allocate_Memory (sys_pool_ptr, (VOID *)&r_matrix,sizeof(*r_matrix), NU_NO_SUSPEND);
+ }
+
+ /* Start first firmware*/
+ if(status == NU_SUCCESS)
+ {
+ printf("\n\n\r************************************");
+ printf("*******************************************\r\n");
+ printf("\r\n Matrix Multiplication Application \r\n");
+ printf("\r\n");
+ printf("\r\nThis sample application will offload matrix multiplication \r\n");
+ printf("\r\noperations from Nucleus master to remote cores\r\n");
+
+ printf("\r\n******************************************");
+ printf("*************************************\n\r\n");
+
+
+ printf("\r\n\nLoading remote context : %s \r\n" , fw1_name);
+
+ printf("\r\n******************************************");
+ printf("*************************************\n\r\n");
+
+ status = remoteproc_init((void *) fw1_name, rpmsg_channel_created, rpmsg_channel_deleted, rpmsg_read_cb, &proc);
+ }
+
+ /* Boot first firmware */
+ if((!status) && (proc))
+ {
+ printf("\r\n\n********************************************\r\n");
+ printf("BOOTING NUCLEUS REMOTE FIRMWARE");
+ printf("\r\n********************************************\r\n\n");
+ status = remoteproc_boot(proc);
+ }
+
+ if(!status)
+ {
+ /* Wait till communication channel is established */
+ NU_Obtain_Semaphore(&App_Sem, NU_SUSPEND);
+
+ printf("\r\n******************************************");
+ printf("*************************************\n\r\n");
+ printf("\r\nStarting application for first firmware .. \r\n");
+ printf("\r\n******************************************");
+ printf("*************************************\n\r\n");
+
+ /* Call matrix multiply application */
+ matrix_multiply_shell();
+
+ printf("\r\n******************************************");
+ printf("*************************************\n\r\n");
+ printf("\r\nShutting down and deinitializing remote context : %s \r\n" , fw1_name);
+ printf("\r\n******************************************");
+ printf("*************************************\n\r\n");
+
+ /* Send shutdown message to remote */
+ rpmsg_send(app_rp_chnl, &shutdown_msg, sizeof(int));
+
+ /* Wait for channel deletion callback. */
+ NU_Obtain_Semaphore(&App_Sem , NU_SUSPEND);
+
+ /* Shutdown remote processor and deinitialize remoteproc */
+ remoteproc_shutdown(proc);
+ remoteproc_deinit(proc);
+ }
+ else
+ {
+ printf("\r\n\nLoading remote context: %s failed \r\n" , fw1_name);
+ }
+
+ /* Start second firmware */
+ status = remoteproc_init((void *) fw2_name, rpmsg_channel_created, rpmsg_channel_deleted, rpmsg_read_cb, &proc);
+
+ /* Boot first firmware */
+ if((!status) && (proc))
+ {
+ printf("\r\n\n********************************************\r\n");
+ printf("BOOTING BAREMETAL REMOTE FIRMWARE");
+ printf("\r\n********************************************\r\n\n");
+ status = remoteproc_boot(proc);
+ }
+
+ if(!status)
+ {
+ /* Wait till communication channel is established */
+ NU_Obtain_Semaphore(&App_Sem, NU_SUSPEND);
+
+ printf("\r\n******************************************");
+ printf("*************************************\n\r\n");
+ printf("\r\nStarting application for second firmware .. \r\n");
+ printf("\r\n******************************************");
+ printf("*************************************\n\r\n");
+
+ /* Call matrix multiply application */
+ matrix_multiply_shell();
+
+ printf("\r\n******************************************");
+ printf("*************************************\n\r\n");
+ printf("\r\nShutting down and deinitializing remote context : %s \r\n" , fw2_name);
+ printf("\r\n******************************************");
+ printf("*************************************\n\r\n");
+
+ /* Shut down remote processor and deinitialize remoteproc */
+ remoteproc_shutdown(proc);
+ remoteproc_deinit(proc);
+ }
+ else
+ {
+ printf("\r\n\nLoading remote context: %s failed \r\n" , fw2_name);
+ }
+
+}
+
+/* This callback gets invoked when the remote channel is created */
+void rpmsg_channel_created(struct rpmsg_channel *rp_chnl) {
+ app_rp_chnl = rp_chnl;
+ rp_ept = rpmsg_create_ept(rp_chnl , rpmsg_read_cb ,RPMSG_NULL , RPMSG_ADDR_ANY);
+ NU_Release_Semaphore(&App_Sem);
+}
+
+/* This callback gets invoked when the remote channel is deleted */
+void rpmsg_channel_deleted(struct rpmsg_channel *rp_chnl) {
+ NU_Release_Semaphore(&App_Sem);
+}
+
+/* This is the read callback, note we are in a task context when this callback
+is invoked, so kernel primitives can be used freely */
+void rpmsg_read_cb(struct rpmsg_channel *rp_chnl, void *data, int len,
+ void * priv, unsigned long src) {
+
+ memcpy(r_matrix,data,len);
+
+ bytes_received = len;
+
+ NU_Release_Semaphore(&App_Sem);
+}
+
diff --git a/apps/samples/remote/baremetal/matrix_multiply/make b/apps/samples/remote/baremetal/matrix_multiply/make
--- /dev/null
@@ -0,0 +1,32 @@
+
+include ../Makefile.commons
+
+SAMPLE_OUT := samples/remote/baremetal/matrix_multiply/matrix_multiply.out
+SAMPLE_SRC := samples/remote/baremetal/matrix_multiply/matrix_multiply.c samples/remote/baremetal/matrix_multiply/rsc_table.c
+
+SAMPLEOBJFILES := $(patsubst %.c, %.o, $(SAMPLE_SRC))
+SAMPLE_DEPS := $(patsubst %.c, %.d, $(SAMPLE_SRC))
+SAMPLE_MAP := $(patsubst %.out, %.map, $(SAMPLE_OUT))
+
+$(SAMPLE_OUT): $(SAMPLEOBJFILES)
+ @echo 'Building matrix multiplication sample for baremetal environment : $@'
+ $(LD) -Wl,-Map=samples/remote/baremetal/matrix_multiply/matrix_multiply.map -Wl,--gc-sections -T"$(OHOME)/libs/system/$(PLAT)/baremetal/linker_remote.ld" -L"$(OHOME)/libs/open_amp" -L"$(OHOME)/libs/system/$(PLAT)/baremetal" -o "$(SAMPLE_OUT)" -Wl,--start-group $(SAMPLEOBJFILES) -lopen_amp -lbaremetal_remote -lc -lm -lstdc++ -lcs3 -lcs3arm -lcs3unhosted -Wl,--end-group
+ @echo 'Finished building target: $@'
+
+ @echo 'Copying ELF image to firmware folder'
+ $(CP) $(SAMPLE_OUT) firmware/$(PLAT)/$(OS)/matrix_multiply/firmware
+
+%.o:%.c
+ @echo CC $(<:.c=.o)
+ @$(CC) $(CFLAGS) $(ARCH_CFLAGS) $(INCLUDE) -c $< -o $@
+
+clean:
+ -$(RM) $(SAMPLEOBJFILES) $(SAMPLE_DEPS) $(SAMPLE_OUT) $(SAMPLE_MAP)
+
+post-build:
+ -@echo ' '
+
+secondary-outputs:
+
+PHONY: all clean dependents
+.SECONDARY: post-build
diff --git a/apps/samples/remote/baremetal/matrix_multiply/matrix_multiply.c b/apps/samples/remote/baremetal/matrix_multiply/matrix_multiply.c
--- /dev/null
@@ -0,0 +1,131 @@
+/* This is a sample demonstration application that showcases usage of remoteproc\r
+and rpmsg APIs on the remote core. This application is meant to run on the remote CPU \r
+running baremetal code. This applicationr receives two matrices from the master, \r
+multiplies them and returns the result to the master core. */\r
+\r
+#include <stdio.h>\r
+#include <stdlib.h>\r
+#include <string.h>\r
+#include "open_amp.h"\r
+#include "rsc_table.h"\r
+#include "baremetal.h"\r
+\r
+#define MAX_SIZE 6\r
+#define NUM_MATRIX 2\r
+#define SHUTDOWN_MSG 0xEF56A55A\r
+\r
+typedef struct _matrix {\r
+ unsigned long size;\r
+ unsigned long elements[MAX_SIZE][MAX_SIZE];\r
+} matrix;\r
+\r
+/* Internal functions */\r
+static void rpmsg_channel_created(struct rpmsg_channel *rp_chnl);\r
+static void rpmsg_channel_deleted(struct rpmsg_channel *rp_chnl);\r
+static void rpmsg_read_cb(struct rpmsg_channel *, void *, int, void *, unsigned long);\r
+static void Matrix_Multiply(const matrix *m, const matrix *n, matrix *r);\r
+static void sleep();\r
+static void init_system();\r
+\r
+/* Globals */\r
+static struct rpmsg_channel *app_rp_chnl;\r
+volatile int int_flag = 0;\r
+static struct rpmsg_endpoint *rp_ept;\r
+static matrix matrix_array[NUM_MATRIX];\r
+static matrix matrix_result;\r
+static struct remote_proc *proc = NULL;\r
+static struct rsc_table_info rsc_info;\r
+extern const struct remote_resource_table resources;\r
+\r
+/* Application entry point */\r
+int main() {\r
+\r
+ /* Switch to System Mode */\r
+ SWITCH_TO_SYS_MODE();\r
+\r
+ /* Initialize HW system components */\r
+ init_system();\r
+\r
+ rsc_info.rsc_tab = (struct resource_table *)&resources;\r
+ rsc_info.size = sizeof(resources);\r
+\r
+ /* Initialize RPMSG framework */\r
+ remoteproc_resource_init(&rsc_info, rpmsg_channel_created, rpmsg_channel_deleted,\r
+ rpmsg_read_cb ,&proc);\r
+\r
+ while (1) {\r
+ if (int_flag) {\r
+\r
+ /* Process received data and multiple matrices. */\r
+ Matrix_Multiply(&matrix_array[0], &matrix_array[1], &matrix_result);\r
+\r
+ /* Send the result of matrix multiplication back to master. */\r
+ rpmsg_send(app_rp_chnl, &matrix_result, sizeof(matrix));\r
+\r
+ int_flag = 0;\r
+ }\r
+ sleep();\r
+ }\r
+\r
+ return 0;\r
+}\r
+\r
+static void rpmsg_channel_created(struct rpmsg_channel *rp_chnl) {\r
+ app_rp_chnl = rp_chnl;\r
+ rp_ept = rpmsg_create_ept(rp_chnl, rpmsg_read_cb, RPMSG_NULL,\r
+ RPMSG_ADDR_ANY);\r
+}\r
+\r
+static void rpmsg_channel_deleted(struct rpmsg_channel *rp_chnl) {\r
+ rpmsg_destroy_ept(rp_ept);\r
+}\r
+\r
+static void rpmsg_read_cb(struct rpmsg_channel *rp_chnl, void *data, int len,\r
+ void * priv, unsigned long src) {\r
+ if ((*(int *) data) == SHUTDOWN_MSG) {\r
+ remoteproc_resource_deinit(proc);\r
+ }else{\r
+ env_memcpy(matrix_array, data, len);\r
+ int_flag = 1;\r
+ }\r
+}\r
+\r
+void sleep() {\r
+ int i;\r
+ for (i = 0; i < 1000; i++);\r
+}\r
+\r
+static void Matrix_Multiply(const matrix *m, const matrix *n, matrix *r) {\r
+ int i, j, k;\r
+\r
+ r->size = m->size;\r
+\r
+ for (i = 0; i < m->size; ++i) {\r
+ for (j = 0; j < n->size; ++j) {\r
+ r->elements[i][j] = 0;\r
+ }\r
+ }\r
+\r
+ for (i = 0; i < m->size; ++i) {\r
+ for (j = 0; j < n->size; ++j) {\r
+ for (k = 0; k < r->size; ++k) {\r
+ r->elements[i][j] += m->elements[i][k] * n->elements[k][j];\r
+ }\r
+ }\r
+ }\r
+}\r
+\r
+static void init_system() {\r
+\r
+ /* Place the vector table at the image entry point */\r
+ arm_arch_install_isr_vector_table(RAM_VECTOR_TABLE_ADDR);\r
+\r
+ /* Enable MMU */\r
+ arm_ar_mem_enable_mmu();\r
+\r
+ /* Initialize ARM stacks */\r
+ init_arm_stacks();\r
+\r
+ /* Initialize GIC */\r
+ zc702evk_gic_initialize();\r
+}\r
diff --git a/apps/samples/remote/baremetal/matrix_multiply/rsc_table.c b/apps/samples/remote/baremetal/matrix_multiply/rsc_table.c
--- /dev/null
@@ -0,0 +1,89 @@
+/*\r
+ * Copyright (c) 2014, Mentor Graphics Corporation\r
+ * All rights reserved.\r
+ *\r
+ * Redistribution and use in source and binary forms, with or without\r
+ * modification, are permitted provided that the following conditions are met:\r
+ *\r
+ * 1. Redistributions of source code must retain the above copyright notice,\r
+ * this list of conditions and the following disclaimer.\r
+ * 2. Redistributions in binary form must reproduce the above copyright notice,\r
+ * this list of conditions and the following disclaimer in the documentation\r
+ * and/or other materials provided with the distribution.\r
+ * 3. Neither the name of Mentor Graphics Corporation nor the names of its\r
+ * contributors may be used to endorse or promote products derived from this\r
+ * software without specific prior written permission.\r
+ *\r
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"\r
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\r
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\r
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE\r
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\r
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\r
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\r
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\r
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\r
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\r
+ * POSSIBILITY OF SUCH DAMAGE.\r
+ */\r
+\r
+/* This file populates resource table for Nucleus and BM remotes\r
+ * for use by the Linux Master */\r
+\r
+#include "open_amp.h"\r
+#include "rsc_table.h"\r
+\r
+/* Place resource table in special ELF section */\r
+#define __section(S) __attribute__((__section__(#S)))\r
+#define __resource __section(.resource_table)\r
+\r
+#define RPMSG_IPU_C0_FEATURES 1\r
+\r
+/* VirtIO rpmsg device id */\r
+#define VIRTIO_ID_RPMSG_ 7\r
+\r
+/* Remote supports Name Service announcement */\r
+#define VIRTIO_RPMSG_F_NS 0\r
+\r
+/* Resource table entries */\r
+#define ELF_START 0x00000000\r
+#define ELF_END 0x08000000\r
+#define NUM_VRINGS 0x02\r
+#define VRING_ALIGN 0x1000\r
+#define RING_TX 0x08000000\r
+#define RING_RX 0x08004000\r
+#define VRING_SIZE 256\r
+\r
+const struct remote_resource_table __resource resources =\r
+{\r
+ /* Version */\r
+ 1,\r
+\r
+ /* NUmber of table entries */\r
+ 2,\r
+ /* reserved fields */\r
+ { 0, 0,},\r
+\r
+ /* Offsets of rsc entries */\r
+ {\r
+ offsetof(struct remote_resource_table, elf_cout),\r
+ offsetof(struct remote_resource_table, rpmsg_vdev),\r
+ },\r
+\r
+ /* End of ELF file */\r
+ {\r
+ RSC_CARVEOUT, ELF_START, ELF_START, ELF_END, 0, 0, "ELF_COUT",\r
+ },\r
+\r
+ /* Virtio device entry */\r
+ { RSC_VDEV, VIRTIO_ID_RPMSG_, 0, RPMSG_IPU_C0_FEATURES, 0, 0, 0, NUM_VRINGS, {0, 0},\r
+ },\r
+\r
+ /* Vring rsc entry - part of vdev rsc entry */\r
+ {\r
+ RING_TX, VRING_ALIGN, VRING_SIZE, 1, 0\r
+ },\r
+ {\r
+ RING_RX, VRING_ALIGN, VRING_SIZE, 2, 0\r
+ },\r
+};\r
diff --git a/apps/samples/remote/baremetal/matrix_multiply/rsc_table.h b/apps/samples/remote/baremetal/matrix_multiply/rsc_table.h
--- /dev/null
@@ -0,0 +1,51 @@
+/*\r
+ * Copyright (c) 2014, Mentor Graphics Corporation\r
+ * All rights reserved.\r
+ *\r
+ * Redistribution and use in source and binary forms, with or without\r
+ * modification, are permitted provided that the following conditions are met:\r
+ *\r
+ * 1. Redistributions of source code must retain the above copyright notice,\r
+ * this list of conditions and the following disclaimer.\r
+ * 2. Redistributions in binary form must reproduce the above copyright notice,\r
+ * this list of conditions and the following disclaimer in the documentation\r
+ * and/or other materials provided with the distribution.\r
+ * 3. Neither the name of Mentor Graphics Corporation nor the names of its\r
+ * contributors may be used to endorse or promote products derived from this\r
+ * software without specific prior written permission.\r
+ *\r
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"\r
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\r
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\r
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE\r
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\r
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\r
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\r
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\r
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\r
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\r
+ * POSSIBILITY OF SUCH DAMAGE.\r
+ */\r
+\r
+/* This file populates resource table for Nucleus and BM remotes\r
+ * for use by the Linux Master */\r
+\r
+#include <stddef.h>\r
+#include "open_amp.h"\r
+\r
+#define NO_RESOURCE_ENTRIES 8\r
+\r
+/* Resource table for the given remote */\r
+struct remote_resource_table {\r
+ unsigned int version;\r
+ unsigned int num;\r
+ unsigned int reserved[2];\r
+ unsigned int offset[NO_RESOURCE_ENTRIES];\r
+ /* text carveout entry */\r
+ struct fw_rsc_carveout elf_cout;\r
+ /* rpmsg vdev entry */\r
+ struct fw_rsc_vdev rpmsg_vdev;\r
+ struct fw_rsc_vdev_vring rpmsg_vring0;\r
+ struct fw_rsc_vdev_vring rpmsg_vring1;\r
+};\r
+\r
diff --git a/apps/samples/remote/baremetal/rpc_demo/make b/apps/samples/remote/baremetal/rpc_demo/make
--- /dev/null
@@ -0,0 +1,32 @@
+
+include ../Makefile.commons
+
+SAMPLE_OUT := samples/remote/baremetal/rpc_demo/rpc_demo.out
+SAMPLE_SRC := samples/remote/baremetal/rpc_demo/rpc_demo.c samples/remote/baremetal/rpc_demo/rsc_table.c ../proxy/remote/rpmsg_retarget/rpmsg_retarget.c
+APP_INCLUDE := -I"../proxy/remote/rpmsg_retarget"
+SAMPLEOBJFILES := $(patsubst %.c, %.o, $(SAMPLE_SRC))
+SAMPLE_DEPS := $(patsubst %.c, %.d, $(SAMPLE_SRC))
+SAMPLE_MAP := $(patsubst %.out, %.map, $(SAMPLE_OUT))
+
+$(SAMPLE_OUT): $(SAMPLEOBJFILES)
+ @echo 'Building rpc sample for baremetal environment : $@'
+ $(LD) -Wl,-Map=samples/remote/baremetal/rpc_demo/rpc_demo.map -Wl,--gc-sections -T"$(OHOME)/libs/system/$(PLAT)/baremetal/linker_remote.ld" -L"$(OHOME)/libs/open_amp" -L"$(OHOME)/libs/system/$(PLAT)/baremetal" -o "$(SAMPLE_OUT)" -Wl,--start-group $(SAMPLEOBJFILES) -lopen_amp -lbaremetal_remote_rpc -lc -lm -lstdc++ -lcs3 -lcs3arm -lcs3unhosted -Wl,--end-group
+ @echo 'Finished building target: $@'
+
+ @echo 'Copying ELF image to firmware folder'
+ $(CP) $(SAMPLE_OUT) firmware/$(PLAT)/$(OS)/rpc_demo/firmware
+
+%.o:%.c
+ @echo CC $(<:.c=.o)
+ @$(CC) $(CFLAGS) $(ARCH_CFLAGS) $(INCLUDE) $(APP_INCLUDE) -c $< -o $@
+
+clean:
+ -$(RM) $(SAMPLEOBJFILES) $(SAMPLE_DEPS) $(SAMPLE_OUT) $(SAMPLE_MAP)
+
+post-build:
+ -@echo ' '
+
+secondary-outputs:
+
+PHONY: all clean dependents
+.SECONDARY: post-build
diff --git a/apps/samples/remote/baremetal/rpc_demo/rpc_demo.c b/apps/samples/remote/baremetal/rpc_demo/rpc_demo.c
--- /dev/null
@@ -0,0 +1,181 @@
+/* This is a sample demonstration application that showcases usage of proxy from the remote core. \r
+ This application is meant to run on the remote CPU running baremetal.\r
+ This applicationr can print to to master console and perform file I/O using proxy mechanism. */\r
+\r
+#include <stdio.h>\r
+#include <string.h>\r
+#include <stdlib.h>\r
+#include <fcntl.h>\r
+#include <unistd.h>\r
+#include "open_amp.h"\r
+#include "rsc_table.h"\r
+#include "baremetal.h"\r
+#include "rpmsg_retarget.h"\r
+\r
+/* Internal functions */\r
+static void rpmsg_channel_created(struct rpmsg_channel *rp_chnl);\r
+static void rpmsg_channel_deleted(struct rpmsg_channel *rp_chnl);\r
+static void rpmsg_read_cb(struct rpmsg_channel *, void *, int, void *,\r
+ unsigned long);\r
+static void init_system();\r
+static void shutdown_cb(struct rpmsg_channel *rp_chnl);\r
+\r
+/* Globals */\r
+static struct rpmsg_channel *app_rp_chnl;\r
+volatile int chnl_cb_flag = 0;\r
+static struct remote_proc *proc = NULL;\r
+static struct rsc_table_info rsc_info;\r
+extern const struct remote_resource_table resources;\r
+\r
+#define REDEF_O_CREAT 100\r
+#define REDEF_O_EXCL 200\r
+#define REDEF_O_RDONLY 0\r
+#define REDEF_O_WRONLY 1\r
+#define REDEF_O_RDWR 2\r
+#define REDEF_O_APPEND 2000\r
+#define REDEF_O_ACCMODE 3\r
+\r
+/* Application entry point */\r
+int main() {\r
+ int fd, bytes_written, bytes_read;\r
+ char fname[] = "remote.file";\r
+ char wbuff[50];\r
+ char rbuff[1024];\r
+ char ubuff[50];\r
+ float fdata;\r
+ int idata;\r
+ int ret;\r
+\r
+ /* Switch to System Mode */\r
+ SWITCH_TO_SYS_MODE();\r
+\r
+ /* Initialize HW system components */\r
+ init_system();\r
+\r
+ rsc_info.rsc_tab = (struct resource_table *) &resources;\r
+ rsc_info.size = sizeof(resources);\r
+\r
+ /* Initialize RPMSG framework */\r
+ remoteproc_resource_init(&rsc_info, rpmsg_channel_created,\r
+ rpmsg_channel_deleted, rpmsg_read_cb, &proc);\r
+\r
+ while (!chnl_cb_flag);\r
+\r
+ chnl_cb_flag = 0;\r
+\r
+ rpmsg_retarget_init(app_rp_chnl, shutdown_cb);\r
+\r
+ printf("\r\nRemote>***************************************************\r\n");\r
+ printf("\r\nRemote>Baremetal Remote Procedure Call (RPC) Demonstration\r\n");\r
+ printf("\r\nRemote>***************************************************\r\n");\r
+ printf("\r\nRemote>Rpmsg based retargetting to proxy initialized..\r\n");\r
+\r
+ /* Remote performing file IO on Master */\r
+ printf("\r\nRemote>FileIO demo ..\r\n");\r
+\r
+ printf("\r\nRemote>Creating a file on master and writing to it..\r\n");\r
+ fd = open(fname, REDEF_O_CREAT | REDEF_O_WRONLY | REDEF_O_APPEND,\r
+ S_IRUSR | S_IWUSR);\r
+ printf("\r\nRemote>Opened file '%s' with fd = %d\r\n", fname, fd);\r
+\r
+ sprintf(wbuff, "This is a test string being written to file..");\r
+ bytes_written = write(fd, wbuff, strlen(wbuff));\r
+ printf("\r\nRemote>Wrote to fd = %d, size = %d, content = %s\r\n", fd,\r
+ bytes_written, wbuff);\r
+\r
+ close(fd);\r
+ printf("\r\nRemote>Closed fd = %d\r\n", fd);\r
+\r
+ /* Remote performing file IO on Master */\r
+ printf("\r\nRemote>Reading a file on master and displaying its contents..\r\n");\r
+ fd = open(fname, REDEF_O_RDONLY, S_IRUSR | S_IWUSR);\r
+ printf("\r\nRemote>Opened file '%s' with fd = %d\r\n", fname, fd);\r
+ bytes_read = read(fd, rbuff, 1024);\r
+ *(char*) (&rbuff[0] + bytes_read + 1) = 0;\r
+ printf( "\r\nRemote>Read from fd = %d, size = %d, printing contents below .. %s\r\n",\r
+ fd, bytes_read, rbuff);\r
+ close(fd);\r
+ printf("\r\nRemote>Closed fd = %d\r\n", fd);\r
+\r
+ for(;;)\r
+ {\r
+ /* Remote performing STDIO on Master */\r
+ printf("\r\nRemote>Remote firmware using scanf and printf ..\r\n");\r
+ printf("\r\nRemote>Scanning user input from master..\r\n");\r
+ printf("\r\nRemote>Enter name\r\n");\r
+ ret = scanf("%s", ubuff);\r
+ if(ret) {\r
+ printf("\r\nRemote>Enter age\r\n");\r
+ ret = scanf("%d", &idata);\r
+ if(ret) {\r
+ printf("\r\nRemote>Enter value for pi\r\n");\r
+ ret = scanf("%f", &fdata);\r
+ if(ret) {\r
+ printf("\r\nRemote>User name = '%s'\r\n", ubuff);\r
+ printf("\r\nRemote>User age = '%d'\r\n", idata);\r
+ printf("\r\nRemote>User entered value of pi = '%f'\r\n", fdata);\r
+ }\r
+ }\r
+ }\r
+\r
+ if(!ret)\r
+ {\r
+ /* Consume the read buffer */\r
+ while(getchar() != '\n');\r
+ printf("Remote> Invalid value. Starting again....");\r
+ }\r
+ else\r
+ {\r
+ printf("\r\nRemote>Repeat demo ? (enter yes or no) \r\n");\r
+ scanf("%s", ubuff);\r
+\r
+ if((strcmp(ubuff,"no")) && (strcmp(ubuff,"yes")))\r
+ {\r
+ printf("\r\nRemote>Invalid option. Starting again....\r\n");\r
+ }\r
+ else if((!strcmp(ubuff,"no")))\r
+ {\r
+ printf("\r\nRemote>RPC retargetting quitting ...\r\n");\r
+ break;\r
+ }\r
+ }\r
+ }\r
+\r
+ printf("\r\nRemote> Firmware's rpmsg-openamp-demo-channel going down! \r\n");\r
+\r
+ while (1);\r
+\r
+ return 0;\r
+}\r
+\r
+static void rpmsg_channel_created(struct rpmsg_channel *rp_chnl) {\r
+ app_rp_chnl = rp_chnl;\r
+ chnl_cb_flag = 1;\r
+}\r
+\r
+static void rpmsg_channel_deleted(struct rpmsg_channel *rp_chnl) {\r
+}\r
+\r
+static void rpmsg_read_cb(struct rpmsg_channel *rp_chnl, void *data, int len,\r
+ void * priv, unsigned long src) {\r
+}\r
+\r
+static void shutdown_cb(struct rpmsg_channel *rp_chnl) {\r
+ rpmsg_retarget_deinit(rp_chnl);\r
+ remoteproc_resource_deinit(proc);\r
+}\r
+\r
+static void init_system() {\r
+\r
+ /* Place the vector table at the image entry point */\r
+ arm_arch_install_isr_vector_table(RAM_VECTOR_TABLE_ADDR);\r
+\r
+ /* Enable MMU */\r
+ arm_ar_mem_enable_mmu();\r
+\r
+ /* Initialize ARM stacks */\r
+ init_arm_stacks();\r
+\r
+ /* Initialize GIC */\r
+ zc702evk_gic_initialize();\r
+}\r
diff --git a/apps/samples/remote/baremetal/rpc_demo/rsc_table.c b/apps/samples/remote/baremetal/rpc_demo/rsc_table.c
--- /dev/null
@@ -0,0 +1,89 @@
+/*\r
+ * Copyright (c) 2014, Mentor Graphics Corporation\r
+ * All rights reserved.\r
+ *\r
+ * Redistribution and use in source and binary forms, with or without\r
+ * modification, are permitted provided that the following conditions are met:\r
+ *\r
+ * 1. Redistributions of source code must retain the above copyright notice,\r
+ * this list of conditions and the following disclaimer.\r
+ * 2. Redistributions in binary form must reproduce the above copyright notice,\r
+ * this list of conditions and the following disclaimer in the documentation\r
+ * and/or other materials provided with the distribution.\r
+ * 3. Neither the name of Mentor Graphics Corporation nor the names of its\r
+ * contributors may be used to endorse or promote products derived from this\r
+ * software without specific prior written permission.\r
+ *\r
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"\r
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\r
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\r
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE\r
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\r
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\r
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\r
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\r
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\r
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\r
+ * POSSIBILITY OF SUCH DAMAGE.\r
+ */\r
+\r
+/* This file populates resource table for Nucleus and BM remotes\r
+ * for use by the Linux Master */\r
+\r
+#include "open_amp.h"\r
+#include "rsc_table.h"\r
+\r
+/* Place resource table in special ELF section */\r
+#define __section(S) __attribute__((__section__(#S)))\r
+#define __resource __section(.resource_table)\r
+\r
+#define RPMSG_IPU_C0_FEATURES 1\r
+\r
+/* VirtIO rpmsg device id */\r
+#define VIRTIO_ID_RPMSG_ 7\r
+\r
+/* Remote supports Name Service announcement */\r
+#define VIRTIO_RPMSG_F_NS 0\r
+\r
+/* Resource table entries */\r
+#define ELF_START 0x00000000\r
+#define ELF_END 0x08000000\r
+#define NUM_VRINGS 0x02\r
+#define VRING_ALIGN 0x1000\r
+#define RING_TX 0x08000000\r
+#define RING_RX 0x08004000\r
+#define VRING_SIZE 256\r
+\r
+const struct remote_resource_table __resource resources =\r
+{\r
+ /* Version */\r
+ 1,\r
+\r
+ /* NUmber of table entries */\r
+ 2,\r
+ /* reserved fields */\r
+ { 0, 0,},\r
+\r
+ /* Offsets of rsc entries */\r
+ {\r
+ offsetof(struct remote_resource_table, elf_cout),\r
+ offsetof(struct remote_resource_table, rpmsg_vdev),\r
+ },\r
+\r
+ /* End of ELF file */\r
+ {\r
+ RSC_CARVEOUT, ELF_START, ELF_START, ELF_END, 0, 0, "ELF_COUT",\r
+ },\r
+\r
+ /* Virtio device entry */\r
+ { RSC_VDEV, VIRTIO_ID_RPMSG_, 0, RPMSG_IPU_C0_FEATURES, 0, 0, 0, NUM_VRINGS, {0, 0},\r
+ },\r
+\r
+ /* Vring rsc entry - part of vdev rsc entry */\r
+ {\r
+ RING_TX, VRING_ALIGN, VRING_SIZE, 1, 0\r
+ },\r
+ {\r
+ RING_RX, VRING_ALIGN, VRING_SIZE, 2, 0\r
+ },\r
+};\r
diff --git a/apps/samples/remote/baremetal/rpc_demo/rsc_table.h b/apps/samples/remote/baremetal/rpc_demo/rsc_table.h
--- /dev/null
@@ -0,0 +1,51 @@
+/*\r
+ * Copyright (c) 2014, Mentor Graphics Corporation\r
+ * All rights reserved.\r
+ *\r
+ * Redistribution and use in source and binary forms, with or without\r
+ * modification, are permitted provided that the following conditions are met:\r
+ *\r
+ * 1. Redistributions of source code must retain the above copyright notice,\r
+ * this list of conditions and the following disclaimer.\r
+ * 2. Redistributions in binary form must reproduce the above copyright notice,\r
+ * this list of conditions and the following disclaimer in the documentation\r
+ * and/or other materials provided with the distribution.\r
+ * 3. Neither the name of Mentor Graphics Corporation nor the names of its\r
+ * contributors may be used to endorse or promote products derived from this\r
+ * software without specific prior written permission.\r
+ *\r
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"\r
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\r
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\r
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE\r
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\r
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\r
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\r
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\r
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\r
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\r
+ * POSSIBILITY OF SUCH DAMAGE.\r
+ */\r
+\r
+/* This file populates resource table for Nucleus and BM remotes\r
+ * for use by the Linux Master */\r
+\r
+#include <stddef.h>\r
+#include "open_amp.h"\r
+\r
+#define NO_RESOURCE_ENTRIES 8\r
+\r
+/* Resource table for the given remote */\r
+struct remote_resource_table {\r
+ unsigned int version;\r
+ unsigned int num;\r
+ unsigned int reserved[2];\r
+ unsigned int offset[NO_RESOURCE_ENTRIES];\r
+ /* text carveout entry */\r
+ struct fw_rsc_carveout elf_cout;\r
+ /* rpmsg vdev entry */\r
+ struct fw_rsc_vdev rpmsg_vdev;\r
+ struct fw_rsc_vdev_vring rpmsg_vring0;\r
+ struct fw_rsc_vdev_vring rpmsg_vring1;\r
+};\r
+\r
diff --git a/apps/samples/remote/nucleus/matrix_multiply/make b/apps/samples/remote/nucleus/matrix_multiply/make
--- /dev/null
@@ -0,0 +1,38 @@
+
+include ../Makefile.commons
+
+SAMPLE_OUT := samples/remote/nucleus/matrix_multiply/matrix_multiply.out
+
+SAMPLE_SRC := samples/remote/nucleus/matrix_multiply/matrix_multiply.c samples/remote/nucleus/matrix_multiply/rsc_table.c
+
+SAMPLEOBJFILES := $(patsubst %.c, %.o, $(SAMPLE_SRC))
+
+SAMPLE_DEPS := $(patsubst %.c, %.d, $(SAMPLE_SRC))
+
+SAMPLE_MAP := $(patsubst %.out, %.map, $(SAMPLE_OUT))
+
+$(SAMPLE_OUT): $(SAMPLEOBJFILES)
+
+ @echo 'Building matrix multiplication application : $@'
+
+ $(LD) -Wl,-Map=samples/remote/nucleus/matrix_multiply/matrix_multiply.map -nostartfiles -Wl,--gc-sections -Wl,--wrap=malloc -Wl,--wrap=calloc -Wl,--wrap=realloc -Wl,--wrap=free -T"$(OHOME)/libs/system/$(PLAT)/nucleus/linker_remote.ld" -L"$(OHOME)/libs/system/$(PLAT)/nucleus/lib/$(CROSS)/remote" -L"$(OHOME)/libs/open_amp" -o "$(SAMPLE_OUT)" -Wl,--start-group $(SAMPLEOBJFILES) -lnucleus_remote -lopen_amp -lc -lm -lstdc++ -Wl,--end-group
+
+ @echo 'Copying ELF image to firmware folder'
+ $(CP) $(SAMPLE_OUT) firmware/$(PLAT)/$(OS)/matrix_multiply/firmware
+
+ @echo 'Finished building target: $@'
+
+%.o:%.c
+ @echo CC $(<:.c=.o)
+ @$(CC) $(CFLAGS) $(ARCH_CFLAGS) $(INCLUDE) -c $< -o $@
+
+clean:
+ -$(RM) $(SAMPLEOBJFILES) $(SAMPLE_DEPS) $(SAMPLE_OUT) $(SAMPLE_MAP)
+
+post-build:
+ -@echo ' '
+
+secondary-outputs:
+
+PHONY: all clean dependents
+.SECONDARY: post-build
diff --git a/apps/samples/remote/nucleus/matrix_multiply/matrix_multiply.c b/apps/samples/remote/nucleus/matrix_multiply/matrix_multiply.c
--- /dev/null
@@ -0,0 +1,174 @@
+/* This is a sample demonstration application that showcases usage of remoteproc\r
+ and rpmsg APIs on the remote core. This application is meant to run on the remote CPU\r
+ running Nucleus. This applicationr receives two matrices from the master, multiplies\r
+ them and returns the result to the master core. */\r
+\r
+/* Including required headers */\r
+#include <stdio.h>\r
+#include <string.h>\r
+#include <stdlib.h>\r
+#include "open_amp.h"\r
+#include "rsc_table.h"\r
+#include "nucleus.h"\r
+#include "kernel/nu_kernel.h"\r
+\r
+/* Define the main task's stack size */\r
+#define STACK_SIZE (NU_MIN_STACK_SIZE * 64)\r
+\r
+/* Define the main task's priority */\r
+#define TASK_PRIORITY 26\r
+\r
+/* Define the main task's time slice */\r
+#define TASK_SLICE 20\r
+\r
+/* Application */\r
+#define MAX_SIZE 6\r
+#define NUM_MATRIX 2\r
+\r
+#define SHUTDOWN_MSG 0xEF56A55A\r
+\r
+typedef struct _matrix {\r
+ unsigned long size;\r
+ unsigned long elements[MAX_SIZE][MAX_SIZE];\r
+} matrix;\r
+\r
+/* Prototype for the main task's entry function */\r
+static void Main_Task_Entry(UNSIGNED argc, VOID *argv);\r
+\r
+static NU_TASK Task_Control_Block;\r
+static NU_SEMAPHORE Remote_Sem;\r
+static struct rpmsg_endpoint *rp_ept;\r
+static struct rpmsg_channel *app_rp_chnl;\r
+static matrix matrix_array[NUM_MATRIX];\r
+static matrix matrix_result;\r
+static struct remote_proc *proc;\r
+static struct rsc_table_info rsc_info;\r
+extern const struct remote_resource_table resources;\r
+static int shutdown_flag = 0;\r
+\r
+void rpmsg_channel_created(struct rpmsg_channel *rp_chnl);\r
+void rpmsg_channel_deleted(struct rpmsg_channel *rp_chnl);\r
+void rpmsg_read_default_cb(struct rpmsg_channel *rp_chnl, void *data, int len,\r
+ void * pric, unsigned long src);\r
+\r
+/***********************************************************************\r
+ * *\r
+ * * FUNCTION\r
+ * *\r
+ * * Application_Initialize\r
+ * *\r
+ * * DESCRIPTION\r
+ * *\r
+ * * Demo application entry point\r
+ *\r
+ * ***********************************************************************/\r
+VOID Application_Initialize(NU_MEMORY_POOL* mem_pool,\r
+ NU_MEMORY_POOL* uncached_mem_pool) {\r
+ VOID *pointer;\r
+ STATUS status;\r
+\r
+ /* Reference unused parameters to avoid toolset warnings */\r
+ NU_UNUSED_PARAM(uncached_mem_pool);\r
+\r
+ status = NU_Create_Semaphore(&Remote_Sem, "r_sem", 0, NU_FIFO);\r
+\r
+ if (status == NU_SUCCESS) {\r
+ status = NU_Allocate_Memory(mem_pool, &pointer,\r
+ STACK_SIZE, NU_NO_SUSPEND);\r
+ if (status == NU_SUCCESS) {\r
+ /* Create task 0. */\r
+ status = NU_Create_Task(&Task_Control_Block, "MAIN",\r
+ Main_Task_Entry, 0, uncached_mem_pool, pointer,\r
+ STACK_SIZE, TASK_PRIORITY, TASK_SLICE,\r
+ NU_PREEMPT, NU_START);\r
+ }\r
+ }\r
+\r
+ /* Check to see if previous operations were successful */\r
+ if (status != NU_SUCCESS) {\r
+ /* Loop forever */\r
+ while (1);\r
+ }\r
+}\r
+\r
+static void Matrix_Multiply(const matrix *m, const matrix *n, matrix *r) {\r
+ int i, j, k;\r
+\r
+ r->size = m->size;\r
+\r
+ for (i = 0; i < m->size; ++i) {\r
+ for (j = 0; j < n->size; ++j) {\r
+ r->elements[i][j] = 0;\r
+ }\r
+ }\r
+\r
+ for (i = 0; i < m->size; ++i) {\r
+ for (j = 0; j < n->size; ++j) {\r
+ for (k = 0; k < r->size; ++k) {\r
+ r->elements[i][j] += m->elements[i][k] * n->elements[k][j];\r
+ }\r
+ }\r
+ }\r
+}\r
+\r
+void rpmsg_channel_created(struct rpmsg_channel *rp_chnl) {\r
+\r
+ app_rp_chnl = rp_chnl;\r
+ rp_ept = rpmsg_create_ept(rp_chnl, rpmsg_read_default_cb, RPMSG_NULL,\r
+ RPMSG_ADDR_ANY);\r
+}\r
+\r
+void rpmsg_channel_deleted(struct rpmsg_channel *rp_chnl) {\r
+ rpmsg_destroy_ept(rp_ept);\r
+}\r
+\r
+void rpmsg_read_default_cb(struct rpmsg_channel *rp_chnl, void *data, int len,\r
+ void * priv, unsigned long src) {\r
+\r
+ if ((*(int *) data) == SHUTDOWN_MSG) {\r
+ shutdown_flag = 1;\r
+ NU_Release_Semaphore(&Remote_Sem);\r
+ } else {\r
+ env_memcpy(matrix_array, data, len);\r
+ NU_Release_Semaphore(&Remote_Sem);\r
+ }\r
+}\r
+\r
+/***********************************************************************\r
+ * *\r
+ * * FUNCTION\r
+ * *\r
+ * * Main_Task_Entry\r
+ * *\r
+ * * DESCRIPTION\r
+ * *\r
+ * * Entry function for the main task. This task prints a hello world\r
+ * * message.\r
+ * *\r
+ * ***********************************************************************/\r
+static VOID Main_Task_Entry(UNSIGNED argc, VOID *argv) {\r
+ rsc_info.rsc_tab = (struct resource_table *) &resources;\r
+ rsc_info.size = sizeof(resources);\r
+\r
+ remoteproc_resource_init(&rsc_info, rpmsg_channel_created,\r
+ rpmsg_channel_deleted, rpmsg_read_default_cb, &proc);\r
+\r
+ for (;;) {\r
+\r
+ /* Wait for incoming matrix data. */\r
+ NU_Obtain_Semaphore(&Remote_Sem, NU_SUSPEND);\r
+\r
+ if (shutdown_flag) {\r
+ remoteproc_resource_deinit(proc);\r
+ break;\r
+ }\r
+\r
+ /* Process received data and multiple matrices. */\r
+ Matrix_Multiply(&matrix_array[0], &matrix_array[1], &matrix_result);\r
+\r
+ /* Send the result of matrix multiplication back to master. */\r
+ rpmsg_send(app_rp_chnl, &matrix_result, sizeof(matrix));\r
+\r
+ NU_Sleep(5);\r
+ }\r
+}\r
diff --git a/apps/samples/remote/nucleus/matrix_multiply/rsc_table.c b/apps/samples/remote/nucleus/matrix_multiply/rsc_table.c
--- /dev/null
@@ -0,0 +1,90 @@
+/*\r
+ * Copyright (c) 2014, Mentor Graphics Corporation\r
+ * All rights reserved.\r
+ *\r
+ * Redistribution and use in source and binary forms, with or without\r
+ * modification, are permitted provided that the following conditions are met:\r
+ *\r
+ * 1. Redistributions of source code must retain the above copyright notice,\r
+ * this list of conditions and the following disclaimer.\r
+ * 2. Redistributions in binary form must reproduce the above copyright notice,\r
+ * this list of conditions and the following disclaimer in the documentation\r
+ * and/or other materials provided with the distribution.\r
+ * 3. Neither the name of Mentor Graphics Corporation nor the names of its\r
+ * contributors may be used to endorse or promote products derived from this\r
+ * software without specific prior written permission.\r
+ *\r
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"\r
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\r
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\r
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE\r
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\r
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\r
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\r
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\r
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\r
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\r
+ * POSSIBILITY OF SUCH DAMAGE.\r
+ */\r
+\r
+/* This file populates resource table for Nucleus and BM remotes\r
+ * for use by the Linux Master */\r
+\r
+#include "open_amp.h"\r
+#include "rsc_table.h"\r
+\r
+/* Place resource table in special ELF section */\r
+#define __section(S) __attribute__((__section__(#S)))\r
+#define __resource __section(.resource_table)\r
+\r
+\r
+#define RPMSG_IPU_C0_FEATURES 1\r
+\r
+/* VirtIO rpmsg device id */\r
+#define VIRTIO_ID_RPMSG_ 7\r
+\r
+/* Remote supports Name Service announcement */\r
+#define VIRTIO_RPMSG_F_NS 0\r
+\r
+/* Resource table entries */\r
+#define ELF_START 0x00000000\r
+#define ELF_END 0x08000000\r
+#define NUM_VRINGS 0x02\r
+#define VRING_ALIGN 0x1000\r
+#define RING_TX 0x08000000\r
+#define RING_RX 0x08004000\r
+#define VRING_SIZE 256\r
+\r
+const struct remote_resource_table __resource resources =\r
+{\r
+ /* Version */\r
+ 1,\r
+\r
+ /* NUmber of table entries */\r
+ 2,\r
+ /* reserved fields */\r
+ { 0, 0,},\r
+\r
+ /* Offsets of rsc entries */\r
+ {\r
+ offsetof(struct remote_resource_table, elf_cout),\r
+ offsetof(struct remote_resource_table, rpmsg_vdev),\r
+ },\r
+\r
+ /* End of ELF file */\r
+ {\r
+ RSC_CARVEOUT, ELF_START, ELF_START, ELF_END, 0, 0, "ELF_COUT",\r
+ },\r
+\r
+ /* Virtio device entry */\r
+ { RSC_VDEV, VIRTIO_ID_RPMSG_, 0, RPMSG_IPU_C0_FEATURES, 0, 0, 0, NUM_VRINGS, {0, 0},\r
+ },\r
+\r
+ /* Vring rsc entry - part of vdev rsc entry */\r
+ {\r
+ RING_TX, VRING_ALIGN, VRING_SIZE, 1, 0\r
+ },\r
+ {\r
+ RING_RX, VRING_ALIGN, VRING_SIZE, 2, 0\r
+ },\r
+};\r
diff --git a/apps/samples/remote/nucleus/matrix_multiply/rsc_table.h b/apps/samples/remote/nucleus/matrix_multiply/rsc_table.h
--- /dev/null
@@ -0,0 +1,51 @@
+/*\r
+ * Copyright (c) 2014, Mentor Graphics Corporation\r
+ * All rights reserved.\r
+ *\r
+ * Redistribution and use in source and binary forms, with or without\r
+ * modification, are permitted provided that the following conditions are met:\r
+ *\r
+ * 1. Redistributions of source code must retain the above copyright notice,\r
+ * this list of conditions and the following disclaimer.\r
+ * 2. Redistributions in binary form must reproduce the above copyright notice,\r
+ * this list of conditions and the following disclaimer in the documentation\r
+ * and/or other materials provided with the distribution.\r
+ * 3. Neither the name of Mentor Graphics Corporation nor the names of its\r
+ * contributors may be used to endorse or promote products derived from this\r
+ * software without specific prior written permission.\r
+ *\r
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"\r
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\r
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\r
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE\r
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\r
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\r
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\r
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\r
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\r
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\r
+ * POSSIBILITY OF SUCH DAMAGE.\r
+ */\r
+\r
+/* This file populates resource table for Nucleus and BM remotes\r
+ * for use by the Linux Master */\r
+\r
+#include <stddef.h>\r
+#include "open_amp.h"\r
+\r
+#define NO_RESOURCE_ENTRIES 8\r
+\r
+/* Resource table for the given remote */\r
+struct remote_resource_table {\r
+ unsigned int version;\r
+ unsigned int num;\r
+ unsigned int reserved[2];\r
+ unsigned int offset[NO_RESOURCE_ENTRIES];\r
+ /* text carveout entry */\r
+ struct fw_rsc_carveout elf_cout;\r
+ /* rpmsg vdev entry */\r
+ struct fw_rsc_vdev rpmsg_vdev;\r
+ struct fw_rsc_vdev_vring rpmsg_vring0;\r
+ struct fw_rsc_vdev_vring rpmsg_vring1;\r
+};\r
+\r
diff --git a/apps/samples/remote/nucleus/rpc_demo/make b/apps/samples/remote/nucleus/rpc_demo/make
--- /dev/null
@@ -0,0 +1,40 @@
+
+include ../Makefile.commons
+
+SAMPLE_OUT := samples/remote/nucleus/rpc_demo/rpc_demo.out
+
+SAMPLE_SRC := samples/remote/nucleus/rpc_demo/rpc_demo.c samples/remote/nucleus/rpc_demo/rsc_table.c ../proxy/remote/rpmsg_retarget/rpmsg_retarget.c
+APP_INCLUDE := -I"../proxy/remote/rpmsg_retarget"
+
+
+SAMPLEOBJFILES := $(patsubst %.c, %.o, $(SAMPLE_SRC))
+
+SAMPLE_DEPS := $(patsubst %.c, %.d, $(SAMPLE_SRC))
+
+SAMPLE_MAP := $(patsubst %.out, %.map, $(SAMPLE_OUT))
+
+$(SAMPLE_OUT): $(SAMPLEOBJFILES)
+
+ @echo 'Building rpc demo application : $@'
+
+ $(LD) -Wl,-Map=samples/remote/nucleus/rpc_demo/rpc_demo.map -nostartfiles -Wl,--gc-sections -Wl,--wrap=malloc -Wl,--wrap=calloc -Wl,--wrap=realloc -Wl,--wrap=free -T"$(OHOME)/libs/system/$(PLAT)/nucleus/linker_remote.ld" -L"$(OHOME)/libs/system/$(PLAT)/nucleus/lib/$(CROSS)/remote_proxy" -L"$(OHOME)/libs/open_amp" -o "$(SAMPLE_OUT)" -Wl,--start-group $(SAMPLEOBJFILES) -lnucleus_remote -lopen_amp -lc -lm -lstdc++ -Wl,--end-group
+
+ @echo 'Copying ELF image to firmware folder'
+ $(CP) $(SAMPLE_OUT) firmware/$(PLAT)/$(OS)/rpc_demo/firmware
+
+ @echo 'Finished building target: $@'
+
+%.o:%.c
+ @echo CC $(<:.c=.o)
+ @$(CC) $(CFLAGS) $(ARCH_CFLAGS) $(INCLUDE) $(APP_INCLUDE) -c $< -o $@
+
+clean:
+ -$(RM) $(SAMPLEOBJFILES) $(SAMPLE_DEPS) $(SAMPLE_OUT) $(SAMPLE_MAP)
+
+post-build:
+ -@echo ' '
+
+secondary-outputs:
+
+PHONY: all clean dependents
+.SECONDARY: post-build
diff --git a/apps/samples/remote/nucleus/rpc_demo/rpc_demo.c b/apps/samples/remote/nucleus/rpc_demo/rpc_demo.c
--- /dev/null
@@ -0,0 +1,227 @@
+
+/* This is a sample demonstration application that showcases usage of proxy from the remote core.
+This application is meant to run on the remote CPU running Nucleus.
+This applicationr can print to to master console and perform file I/O using proxy mechanism*/
+
+
+/* Including required headers */
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include "open_amp.h"
+#include "rsc_table.h"
+#include "nucleus.h"
+#include "kernel/nu_kernel.h"
+#include "rpmsg_retarget.h"
+
+/* Define the main task's stack size */
+#define STACK_SIZE (NU_MIN_STACK_SIZE * 64)
+
+/* Define the main task's priority */
+#define TASK_PRIORITY 26
+
+/* Define the main task's time slice */
+#define TASK_SLICE 20
+
+/* Prototype for the main task's entry function */
+static void Main_Task_Entry( UNSIGNED argc , VOID *argv );
+
+static NU_TASK Task_Control_Block;
+static NU_SEMAPHORE Remote_Sem;
+volatile int int_flag = 0;
+static struct rpmsg_channel *app_rp_chnl;
+static struct remote_proc *proc;
+static struct rsc_table_info rsc_info;
+extern const struct remote_resource_table resources;
+
+void rpmsg_channel_created( struct rpmsg_channel *rp_chnl );
+void rpmsg_channel_deleted( struct rpmsg_channel *rp_chnl );
+void rpmsg_read_default_cb( struct rpmsg_channel *rp_chnl , void *data , int len , void * pric ,
+ unsigned long src );
+void shutdown_cb(struct rpmsg_channel *rp_chnl);
+
+/***********************************************************************
+ * *
+ * * FUNCTION
+ * *
+ * * Application_Initialize
+ * *
+ * * DESCRIPTION
+ * *
+ * * Demo application entry point
+ *
+ * ***********************************************************************/
+VOID Application_Initialize(
+ NU_MEMORY_POOL* mem_pool , NU_MEMORY_POOL* uncached_mem_pool )
+{
+ VOID *pointer;
+ STATUS status;
+ /* Reference unused parameters to avoid toolset warnings */
+ NU_UNUSED_PARAM( uncached_mem_pool );
+
+ status = NU_Create_Semaphore( &Remote_Sem , "r_sem" , 0 , NU_FIFO );
+
+ if (status == NU_SUCCESS)
+ {
+ status = NU_Allocate_Memory(mem_pool, &pointer,
+ STACK_SIZE, NU_NO_SUSPEND);
+ if ( status == NU_SUCCESS )
+ {
+ /* Create task 0. */
+ status = NU_Create_Task( &Task_Control_Block , "MAIN" , Main_Task_Entry , 0 ,
+ uncached_mem_pool , pointer , STACK_SIZE , TASK_PRIORITY , TASK_SLICE ,
+ NU_PREEMPT , NU_START );
+ }
+ }
+
+ /* Check to see if previous operations were successful */
+ if ( status != NU_SUCCESS )
+ {
+ /* Loop forever */
+ while ( 1 );
+ }
+}
+
+void rpmsg_channel_created(struct rpmsg_channel *rp_chnl)
+{
+ app_rp_chnl = rp_chnl;
+ NU_Release_Semaphore( &Remote_Sem );
+}
+
+void rpmsg_channel_deleted(struct rpmsg_channel *rp_chnl)
+{
+
+}
+
+void rpmsg_read_default_cb(struct rpmsg_channel *rp_chnl, void *data, int len,
+ void * priv, unsigned long src)
+{
+
+}
+
+#define REDEF_O_CREAT 100
+#define REDEF_O_EXCL 200
+#define REDEF_O_RDONLY 0
+#define REDEF_O_WRONLY 1
+#define REDEF_O_RDWR 2
+#define REDEF_O_APPEND 2000
+#define REDEF_O_ACCMODE 3
+
+
+/***********************************************************************
+ * *
+ * * FUNCTION
+ * *
+ * * Main_Task_Entry
+ * *
+ * * DESCRIPTION
+ * *
+ * * Entry function for the main task. This task prints a hello world
+ * * message.
+ * *
+ * ***********************************************************************/
+
+static VOID Main_Task_Entry( UNSIGNED argc , VOID *argv )
+{
+ int fd, bytes_written, bytes_read;
+ char fname[]="remote.file";
+ char wbuff[50];
+ char rbuff[1024];
+ char ubuff[50];
+ float fdata;
+ int idata;
+ int ret;
+
+ rsc_info.rsc_tab = (struct resource_table *)&resources;
+ rsc_info.size = sizeof(resources);
+
+ remoteproc_resource_init(&rsc_info, rpmsg_channel_created , rpmsg_channel_deleted ,rpmsg_read_default_cb, &proc);
+
+ NU_Obtain_Semaphore( &Remote_Sem , NU_SUSPEND );
+
+ rpmsg_retarget_init(app_rp_chnl , shutdown_cb);
+
+ printf("\r\nRemote>******************************************************\r\n");
+ printf("\r\nRemote>Nucleus RTOS Remote Procedure Call (RPC) Demonstration\r\n");
+ printf("\r\nRemote>******************************************************\r\n");
+
+ printf("\r\nRemote>Rpmsg based retargetting to proxy initialized..\r\n");
+
+ /* Remote performing file IO on Master */
+ printf("\r\nRemote>FileIO demo using open, write, read, close CRTL calls ..\r\n");
+
+ printf("\r\nRemote>Creating a file on master and writing to it..\r\n");
+ fd = open(fname, REDEF_O_CREAT | REDEF_O_WRONLY | REDEF_O_APPEND, S_IRUSR | S_IWUSR);
+ printf("\r\nRemote>Opened file '%s' with fd = %d\r\n", fname, fd);
+
+ sprintf(wbuff,"This is a test string being written to file..");
+ bytes_written = write(fd, wbuff, strlen(wbuff));
+ printf("\r\nRemote>Wrote to fd = %d, size = %d bytes \r\ncontent = %s\r\n", fd, bytes_written, wbuff);
+
+ close(fd);
+ printf("\r\nRemote>Closed fd = %d\r\n", fd);
+
+ /* Remote performing file IO on Master */
+ printf("\r\nRemote>Reading a file on master and displaying its contents..\r\n");
+ fd = open(fname, REDEF_O_RDONLY, S_IRUSR | S_IWUSR);
+ printf("\r\nRemote>Opened file '%s' with fd = %d\r\n", fname, fd);
+ bytes_read = read(fd, rbuff, 1024);
+ *(char*)(&rbuff[0]+bytes_read+1)=0;
+ printf("\r\nRemote>Read from fd = %d, size = %d bytes \r\ncontent = %s\r\n", fd, bytes_read, rbuff);
+ close(fd);
+ printf("\r\nRemote>Closed fd = %d\r\n", fd);
+
+ for(;;)
+ {
+ /* Remote performing STDIO on Master */
+ printf("\r\nRemote>Remote firmware using scanf and printf ..\r\n");
+ printf("\r\nRemote>Scanning user input from master..\r\n");
+ printf("\r\nRemote>Enter name\r\n");
+ ret = scanf("%s", ubuff);
+ if(ret) {
+ printf("\r\nRemote>Enter age\r\n");
+ ret = scanf("%d", &idata);
+ if(ret) {
+ printf("\r\nRemote>Enter value for pi\r\n");
+ ret = scanf("%f", &fdata);
+ if(ret) {
+ printf("\r\nRemote>User name = '%s'\r\n", ubuff);
+ printf("\r\nRemote>User age = '%d'\r\n", idata);
+ printf("\r\nRemote>User entered value of pi = '%f'\r\n", fdata);
+ }
+ }
+ }
+
+ if(!ret)
+ {
+ /* Consume the read buffer */
+ while(getchar() != '\n');
+ printf("Remote> Invalid value. Starting again....");
+ }
+ else
+ {
+ printf("\r\nRemote>Repeat demo ? (enter yes or no) \r\n");
+ scanf("%s", ubuff);
+
+ if((strcmp(ubuff,"no")) && (strcmp(ubuff,"yes")))
+ {
+ printf("\r\nRemote>Invalid option. Starting again....\r\n");
+ }
+ else if((!strcmp(ubuff,"no")))
+ {
+ printf("\r\nRemote>RPC retargetting quitting ...\r\n");
+ break;
+ }
+ }
+ }
+
+
+ printf("\r\nRemote> Firmware's rpmsg-openamp-demo-channel going down! \r\n");
+}
+
+void shutdown_cb(struct rpmsg_channel *rp_chnl){
+ rpmsg_retarget_deinit(rp_chnl);
+ remoteproc_resource_deinit(proc);
+}
diff --git a/apps/samples/remote/nucleus/rpc_demo/rpc_demo.h b/apps/samples/remote/nucleus/rpc_demo/rpc_demo.h
--- /dev/null
@@ -0,0 +1,72 @@
+/*
+ * proxy_rtl.h
+ *
+ * Created on: Mar 28, 2014
+ * Author: etsam
+ */
+
+#ifndef PROXY_RTL_H_
+#define PROXY_RTL_H_
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#define PRINTF 0x00000000
+#define SCANF 0x00000001
+#define FOPEN 0x00000002
+#define FCLOSE 0x00000003
+#define FREAD 0x00000004
+#define FWRITE 0x00000005
+#define COMMAND_ID 0xEF56A55A
+#define FILE_NAME_LEN 32
+#define FILE_MOD_LEN 4
+
+struct rtl_cmd {
+
+ /* Unique identifer for command message */
+ unsigned int cmd_id;
+
+ /* Command code */
+ unsigned int cmd_cc;
+
+ /* Length of data to to transfer ins response to command */
+ unsigned int data_len;
+
+ /* Command payload */
+ char buff[0];
+
+}__attribute__((__packed__));
+
+struct rtl_cmd_ack {
+
+ /* Command code for which ACK is sent */
+ unsigned int cmd_id;
+
+ /* Any data - apart from status */
+ unsigned int data;
+
+ /* Command status */
+ unsigned int status;
+};
+
+struct fopen_data {
+ char name[FILE_NAME_LEN];
+ char mode[FILE_MOD_LEN];
+};
+
+struct proxy_rtl {
+ /* Lock to exclusively accesses RTL functions */
+ void *rtl_lock;
+ /* Command completion lock */
+ void *data_lock;
+ /* Buffer for data transfer */
+ void *buff;
+ /* Current command reference */
+ /* Command completion status */
+ struct rtl_cmd *cmd;
+ struct rtl_cmd_ack cmd_ack;
+ /* Data length yet to transfer */
+ int rem_len;
+};
+
+#endif /* PROXY_RTL_H_ */
diff --git a/apps/samples/remote/nucleus/rpc_demo/rsc_table.c b/apps/samples/remote/nucleus/rpc_demo/rsc_table.c
--- /dev/null
@@ -0,0 +1,89 @@
+/*\r
+ * Copyright (c) 2014, Mentor Graphics Corporation\r
+ * All rights reserved.\r
+ *\r
+ * Redistribution and use in source and binary forms, with or without\r
+ * modification, are permitted provided that the following conditions are met:\r
+ *\r
+ * 1. Redistributions of source code must retain the above copyright notice,\r
+ * this list of conditions and the following disclaimer.\r
+ * 2. Redistributions in binary form must reproduce the above copyright notice,\r
+ * this list of conditions and the following disclaimer in the documentation\r
+ * and/or other materials provided with the distribution.\r
+ * 3. Neither the name of Mentor Graphics Corporation nor the names of its\r
+ * contributors may be used to endorse or promote products derived from this\r
+ * software without specific prior written permission.\r
+ *\r
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"\r
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\r
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\r
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE\r
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\r
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\r
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\r
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\r
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\r
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\r
+ * POSSIBILITY OF SUCH DAMAGE.\r
+ */\r
+\r
+/* This file populates resource table for Nucleus and BM remotes\r
+ * for use by the Linux Master */\r
+\r
+#include "open_amp.h"\r
+#include "rsc_table.h"\r
+\r
+/* Place resource table in special ELF section */\r
+#define __section(S) __attribute__((__section__(#S)))\r
+#define __resource __section(.resource_table)\r
+\r
+#define RPMSG_IPU_C0_FEATURES 1\r
+\r
+/* VirtIO rpmsg device id */\r
+#define VIRTIO_ID_RPMSG_ 7\r
+\r
+/* Remote supports Name Service announcement */\r
+#define VIRTIO_RPMSG_F_NS 0\r
+\r
+/* Resource table entries */\r
+#define ELF_START 0x00000000\r
+#define ELF_END 0x08000000\r
+#define NUM_VRINGS 0x02\r
+#define VRING_ALIGN 0x1000\r
+#define RING_TX 0x08000000\r
+#define RING_RX 0x08004000\r
+#define VRING_SIZE 256\r
+\r
+const struct remote_resource_table __resource resources =\r
+{\r
+ /* Version */\r
+ 1,\r
+\r
+ /* NUmber of table entries */\r
+ 2,\r
+ /* reserved fields */\r
+ { 0, 0,},\r
+\r
+ /* Offsets of rsc entries */\r
+ {\r
+ offsetof(struct remote_resource_table, elf_cout),\r
+ offsetof(struct remote_resource_table, rpmsg_vdev),\r
+ },\r
+\r
+ /* End of ELF file */\r
+ {\r
+ RSC_CARVEOUT, ELF_START, ELF_START, ELF_END, 0, 0, "ELF_COUT",\r
+ },\r
+\r
+ /* Virtio device entry */\r
+ { RSC_VDEV, VIRTIO_ID_RPMSG_, 0, RPMSG_IPU_C0_FEATURES, 0, 0, 0, NUM_VRINGS, {0, 0},\r
+ },\r
+\r
+ /* Vring rsc entry - part of vdev rsc entry */\r
+ {\r
+ RING_TX, VRING_ALIGN, VRING_SIZE, 1, 0\r
+ },\r
+ {\r
+ RING_RX, VRING_ALIGN, VRING_SIZE, 2, 0\r
+ },\r
+};\r
diff --git a/apps/samples/remote/nucleus/rpc_demo/rsc_table.h b/apps/samples/remote/nucleus/rpc_demo/rsc_table.h
--- /dev/null
@@ -0,0 +1,51 @@
+/*\r
+ * Copyright (c) 2014, Mentor Graphics Corporation\r
+ * All rights reserved.\r
+ *\r
+ * Redistribution and use in source and binary forms, with or without\r
+ * modification, are permitted provided that the following conditions are met:\r
+ *\r
+ * 1. Redistributions of source code must retain the above copyright notice,\r
+ * this list of conditions and the following disclaimer.\r
+ * 2. Redistributions in binary form must reproduce the above copyright notice,\r
+ * this list of conditions and the following disclaimer in the documentation\r
+ * and/or other materials provided with the distribution.\r
+ * 3. Neither the name of Mentor Graphics Corporation nor the names of its\r
+ * contributors may be used to endorse or promote products derived from this\r
+ * software without specific prior written permission.\r
+ *\r
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"\r
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\r
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\r
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE\r
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\r
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\r
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\r
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\r
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\r
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\r
+ * POSSIBILITY OF SUCH DAMAGE.\r
+ */\r
+\r
+/* This file populates resource table for Nucleus and BM remotes\r
+ * for use by the Linux Master */\r
+\r
+#include <stddef.h>\r
+#include "open_amp.h"\r
+\r
+#define NO_RESOURCE_ENTRIES 8\r
+\r
+/* Resource table for the given remote */\r
+struct remote_resource_table {\r
+ unsigned int version;\r
+ unsigned int num;\r
+ unsigned int reserved[2];\r
+ unsigned int offset[NO_RESOURCE_ENTRIES];\r
+ /* text carveout entry */\r
+ struct fw_rsc_carveout elf_cout;\r
+ /* rpmsg vdev entry */\r
+ struct fw_rsc_vdev rpmsg_vdev;\r
+ struct fw_rsc_vdev_vring rpmsg_vring0;\r
+ struct fw_rsc_vdev_vring rpmsg_vring1;\r
+};\r
+\r
diff --git a/apps/tests/master/baremetal/echo_test/echo_test.c b/apps/tests/master/baremetal/echo_test/echo_test.c
--- /dev/null
@@ -0,0 +1,133 @@
+/* This is a sample demonstration application that showcases usage of remoteproc
+and rpmsg APIs. This application is meant to run on the master CPU running baremetal env
+and showcases booting of linux remote firmware using remoteproc and
+IPC with remote firmware using rpmsg; Baremetal env on master core acts as a remoteproc master
+but as an rpmsg remote;It brings up a remote Linux based
+firmware which acts as an rpmsg master and transmits data payloads to bametal code.
+Linux app sends paylaods of incremental sizes to baremetal code which echoes them back to Linux.
+Once Linux application is complete, it requests a shutdown from baremetal env.
+Baremetal env acknowledges with a shutdown message which results in Linux starting a system halt.
+Baremetal env shutsdown the remote core after a reasonable delay which allows
+Linux to gracefully shutdown. */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "open_amp.h"
+
+#define BAREMETAL_MASTER 1
+
+#include "baremetal.h"
+
+#define SHUTDOWN_MSG 0xEF56A55A
+
+
+/* Internal functions */
+static void rpmsg_channel_created(struct rpmsg_channel *rp_chnl);
+static void rpmsg_channel_deleted(struct rpmsg_channel *rp_chnl);
+static void rpmsg_read_cb(struct rpmsg_channel *, void *, int, void *, unsigned long);
+static void sleep();
+static void init_system();
+
+/* Globals */
+static struct rpmsg_channel *app_rp_chnl;
+static struct rpmsg_endpoint *rp_ept;
+
+char fw_name []= "firmware1";
+
+static int shutdown_called = 0;
+
+/* Application entry point */
+int main() {
+
+ int status;
+ struct remote_proc *proc;
+ int shutdown_msg = SHUTDOWN_MSG;
+ int i;
+
+ /* Switch to System Mode */
+ SWITCH_TO_SYS_MODE();
+
+ /* Initialize HW system components */
+ init_system();
+
+ status = remoteproc_init((void *) fw_name, rpmsg_channel_created, rpmsg_channel_deleted, rpmsg_read_cb, &proc);
+
+ if(!status)
+ {
+ status = remoteproc_boot(proc);
+ }
+
+ if(status)
+ {
+ return -1;
+ }
+
+ while (1) {
+
+ if(shutdown_called == 1)
+ {
+ break;
+ }
+ sleep();
+ }
+
+ /* Send shutdown message to remote */
+ rpmsg_send(app_rp_chnl, &shutdown_msg, sizeof(int));
+
+ for (i = 0; i < 100000; i++)
+ {
+ sleep();
+ }
+
+ remoteproc_shutdown(proc);
+
+ remoteproc_deinit(proc);
+
+ return 0;
+}
+
+static void rpmsg_channel_created(struct rpmsg_channel *rp_chnl) {
+ app_rp_chnl = rp_chnl;
+ rp_ept = rpmsg_create_ept(rp_chnl, rpmsg_read_cb, RPMSG_NULL,
+ RPMSG_ADDR_ANY);
+}
+
+static void rpmsg_channel_deleted(struct rpmsg_channel *rp_chnl) {
+ rpmsg_destroy_ept(rp_ept);
+}
+
+static void rpmsg_read_cb(struct rpmsg_channel *rp_chnl, void *data, int len,
+ void * priv, unsigned long src) {
+
+ if ((*(int *) data) == SHUTDOWN_MSG)
+ {
+ shutdown_called = 1;
+ }
+ else
+ {
+ /* Send data back to master*/
+ rpmsg_send(rp_chnl, data, len);
+ }
+}
+
+void sleep() {
+ volatile int i;
+ for (i = 0; i < 100000; i++);
+}
+
+
+static void init_system() {
+
+ /* Place the vector table at the image entry point */
+ arm_arch_install_isr_vector_table(RAM_VECTOR_TABLE_ADDR);
+
+ /* Enable MMU */
+ arm_ar_mem_enable_mmu();
+
+ /* Initialize ARM stacks */
+ init_arm_stacks();
+
+ /* Initialize GIC */
+ zc702evk_gic_initialize();
+}
diff --git a/apps/tests/master/baremetal/echo_test/make b/apps/tests/master/baremetal/echo_test/make
--- /dev/null
@@ -0,0 +1,51 @@
+
+include ../Makefile.commons
+
+SAMPLE_OUT := tests/master/baremetal/echo_test/echo_test.out
+SAMPLE_SRC := tests/master/baremetal/echo_test/echo_test.c
+
+
+REMOTE_OUT := echo_test.out
+LINUX_SRC_DIR := firmware/$(PLAT)/linux
+DST_DIR := tests/master/baremetal/echo_test
+
+SAMPLEOBJFILES := $(patsubst %.c, %.o, $(SAMPLE_SRC))
+
+SAMPLE_DEPS := $(patsubst %.c, %.d, $(SAMPLE_SRC))
+
+SAMPLE_MAP := $(patsubst %.out, %.map, $(SAMPLE_OUT))
+SAMPLE_BIN := $(patsubst %.out, %.bin, $(SAMPLE_OUT))
+
+$(SAMPLE_OUT): $(REMOTE_OUT) $(SAMPLEOBJFILES)
+
+ @echo 'Building echo test for baremetal : $@'
+
+ $(LD) -Wl,-Map=tests/master/baremetal/echo_test/echo_test.map -Wl,--gc-sections -T"$(OHOME)/libs/system/$(PLAT)/baremetal/linker_master.ld" -L"$(OHOME)/libs/open_amp" -L"$(OHOME)/libs/system/$(PLAT)/baremetal" -o "$(SAMPLE_OUT)" -Wl,--start-group $(SAMPLEOBJFILES) $(DST_DIR)/firmware1.o $(DST_DIR)/firmware2.o -lopen_amp -lbaremetal_master -lc -lm -lstdc++ -lcs3 -lcs3arm -lcs3unhosted -Wl,--end-group
+
+ $(OBJCPY) -O binary $(SAMPLE_OUT) $(SAMPLE_BIN)
+
+ @echo 'Finished building target: $@'
+
+%.o:%.c
+ @echo CC $(<:.c=.o)
+ @$(CC) $(CFLAGS) $(ARCH_CFLAGS) $(INCLUDE) -c $< -o $@
+
+$(REMOTE_OUT):
+ cd $(LINUX_SRC_DIR)/; cp firmware firmware1; \
+ $(OBJCPY) -I binary -O elf32-littlearm -B arm firmware1 firmware1.o
+ mv $(LINUX_SRC_DIR)/firmware1.o $(DST_DIR)/firmware1.o
+ cd $(LINUX_SRC_DIR)/; cp firmware firmware2; \
+ $(OBJCPY) -I binary -O elf32-littlearm -B arm firmware2 firmware2.o
+ mv $(LINUX_SRC_DIR)/firmware2.o $(DST_DIR)/
+ cd $(LINUX_SRC_DIR)/; rm firmware1; rm firmware2;
+
+clean:
+ -$(RM) $(SAMPLEOBJFILES) $(SAMPLE_DEPS) $(SAMPLE_OUT) $(SAMPLE_MAP) $(SAMPLE_BIN) $(DST_DIR)/firmware1.o $(DST_DIR)/firmware2.o
+
+post-build:
+ -@echo ' '
+
+secondary-outputs:
+
+PHONY: all clean dependents
+.SECONDARY: post-build
diff --git a/apps/tests/master/baremetal/func_test_suite/func_test_suite.c b/apps/tests/master/baremetal/func_test_suite/func_test_suite.c
--- /dev/null
@@ -0,0 +1,591 @@
+/* This is a test demonstration application that tests usage of remoteproc
+and rpmsg APIs. This application is meant to run on the master CPU running baremetal env
+and showcases booting of two sub-sequent remote firmware cycles using remoteproc and
+IPC with remote firmware using rpmsg. It brings up a remote Linux based remote
+firmware which can respond to test calls. Master app executes tests to validate
+the rpmsg APIs and shutsdown the core once the test has been completed.*/
+
+/* Including required headers */
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include "open_amp.h"
+#include "test_suite.h"
+
+#define BAREMETAL_MASTER 1
+
+#include "baremetal.h"
+
+/* Application provided callbacks */
+void rpmsg_channel_created( struct rpmsg_channel *rp_chnl );
+void rpmsg_channel_deleted( struct rpmsg_channel *rp_chnl );
+void rpmsg_read_default_cb( struct rpmsg_channel *rp_chnl , void *data , int len , void * pric ,
+ unsigned long src );
+void rpmsg_read_ept1_cb( struct rpmsg_channel *rp_chnl , void *data , int len , void * pric ,
+ unsigned long src );
+void rpmsg_read_ept2_cb( struct rpmsg_channel *rp_chnl , void *data , int len , void * pric ,
+ unsigned long src );
+
+int test_rpmsg_send(struct rpmsg_channel *rpmsg_chnl);
+int test_rpmsg_send_offchannel(struct rpmsg_channel *rpmsg_chnl, unsigned long src, unsigned long dst);
+int test_rpmsg_create_ept(struct rpmsg_channel *rpmsg_chnl);
+int test_remoteproc_multiple_lifecycles(char * firmware_name);
+int test_rpmsg_send_offchannel_impl(struct rpmsg_channel *rpmsg_chnl, unsigned long src, unsigned long dst);
+int test_rpmsg_send_impl(struct rpmsg_channel *rpmsg_chnl);
+int test_rpmsg_remote_channel_deletion(struct rpmsg_channel *rpmsg_chnl, char *channel_name);
+int test_execute_suite(char * firmware_name);
+static void sleep();
+static void init_system();
+
+int int_flag;
+
+struct rpmsg_endpoint *rp_ept1 , *rp_ept2;
+struct rpmsg_channel *app_rp_chnl;
+char fw_name1[] = "firmware1";
+
+struct _payload* p_payload = NULL;
+struct _payload* r_payload = NULL;
+
+
+void sleep() {
+ int i;
+ for (i = 0; i < 10000; i++);
+}
+
+static void init_system() {
+
+ /* Place the vector table at the image entry point */
+ arm_arch_install_isr_vector_table(RAM_VECTOR_TABLE_ADDR);
+
+ /* Enable MMU */
+ arm_ar_mem_enable_mmu();
+
+ /* Initialize ARM stacks */
+ init_arm_stacks();
+
+ /* Initialize GIC */
+ zc702evk_gic_initialize();
+}
+
+int main()
+{
+ /* Switch to System Mode */
+ SWITCH_TO_SYS_MODE();
+
+ /* Initialize HW system components */
+ init_system();
+
+ test_execute_suite(fw_name1);
+
+ return 0;
+}
+
+/* This callback gets invoked when the remote chanl is created */
+void rpmsg_channel_created( struct rpmsg_channel *rp_chnl )
+{
+ app_rp_chnl = rp_chnl;
+
+ rp_ept1 = rpmsg_create_ept(rp_chnl , rpmsg_read_ept1_cb , RPMSG_NULL , RPMSG_ADDR_ANY);
+}
+
+/* This callback gets invoked when the remote channel is deleted */
+void rpmsg_channel_deleted( struct rpmsg_channel *rp_chnl )
+{
+ rpmsg_destroy_ept( rp_ept1 );
+
+ int_flag = 1;
+
+}
+
+/* This is the read callback, note we are in a task context when this callback
+ is invoked, so kernel primitives can be used freely */
+void rpmsg_read_default_cb( struct rpmsg_channel *rp_chnl , void *data , int len , void * priv ,
+ unsigned long src )
+{
+ memcpy( r_payload , data , len );
+ int_flag = 1;
+}
+
+void rpmsg_read_ept1_cb( struct rpmsg_channel *rp_chnl , void *data , int len , void * priv ,
+ unsigned long src )
+{
+ memcpy( r_payload , data , len );
+ int_flag = 1;
+}
+
+void rpmsg_read_ept2_cb( struct rpmsg_channel *rp_chnl , void *data , int len , void * priv ,
+ unsigned long src )
+{
+ memcpy( r_payload , data , len );
+ int_flag = 1;
+}
+
+
+void wait_for_event(void)
+{
+ while (1)
+ {
+ if (int_flag) {
+
+ int_flag = 0;
+
+ break;
+ }
+
+ sleep();
+ }
+}
+
+void send_test_case_report(char *result_string)
+{
+ struct command* cmd;
+
+ cmd = malloc(sizeof(struct command) + strlen(result_string) + 1);
+
+ cmd->comm_start=CMD_START;
+ cmd->comm_code = PRINT_RESULT;
+
+ strcpy(cmd->data, result_string);
+
+ (void)rpmsg_send(app_rp_chnl, cmd, sizeof(struct command) + strlen(result_string) + 1);
+
+ free(cmd);
+
+ wait_for_event();
+}
+
+int test_execute_suite(char * firmware_name)
+{
+ struct remote_proc *proc;
+ int status;
+ char default_channel[] = "rpmsg-openamp-demo-channel";
+ struct command* cmd;
+ int i;
+
+ status = remoteproc_init( (void *) firmware_name ,rpmsg_channel_created, rpmsg_channel_deleted, rpmsg_read_default_cb, &proc);
+
+ if (status)
+ {
+ printf( "\r\n CRITICAL ERROR: remoteproc_init call for remote context %s failed \r\n", firmware_name);
+
+ return -1;
+ }
+
+ status = remoteproc_boot( proc );
+
+ if (status)
+ {
+ printf( "\r\n CRITICAL ERROR: remoteproc_boot call for remote context %s failed \r\n", firmware_name);
+
+ return -1;
+ }
+
+ /* Wait for channel creation event */
+ wait_for_event();
+
+ /* Obtain remote firmware name */
+
+ cmd = malloc(sizeof(struct command));
+
+ cmd->comm_start=CMD_START;
+ cmd->comm_code = QUERY_FW_NAME;
+ status = rpmsg_send(app_rp_chnl, cmd, sizeof(struct command));
+
+ free(cmd);
+
+ /* Wait to receive firmware name */
+ wait_for_event();
+
+ /* Test rpmsg_send API */
+ status = test_rpmsg_send(app_rp_chnl);
+
+ if(!status)
+ {
+ send_test_case_report("\r\nRPMSG Send Test: Passed\r\n");
+ }
+ else
+ {
+ send_test_case_report("\r\nRPMSG Send Test: Failed\r\n");
+ }
+
+ /* Test rpmsg_send_offchannel API. */
+ status = test_rpmsg_send_offchannel(app_rp_chnl, rp_ept1->addr, app_rp_chnl->dst);
+
+ if(!status)
+ {
+ send_test_case_report("\r\nRPMSG Send Offchannel Test: Passed\r\n");
+ }
+ else
+ {
+ send_test_case_report("\r\nRPMSG Send Offchannel: Failed\r\n");
+ }
+
+ status = test_rpmsg_create_ept(app_rp_chnl);
+
+ if(!status)
+ {
+ send_test_case_report("\r\nRPMSG Create EPT Test: Passed\r\n");
+ }
+ else
+ {
+ send_test_case_report("\r\nRPMSG Create EPT Test: Failed\r\n");
+ }
+
+ send_test_case_report("\r\nChannel Deletion. Shutdown would be next\r\n");
+
+ status = test_rpmsg_remote_channel_deletion(app_rp_chnl, default_channel);
+
+ for (i = 0; i < 200000; i++)
+ {
+ sleep();
+ }
+
+ status = remoteproc_shutdown(proc);
+ if(!status)
+ {
+ status = remoteproc_deinit(proc);
+ }
+
+ /* The multiple life-cycles test has been disabled for remote Linux configuration
+ as it would require manual user input at linux console to complete
+ the rpmsg connection and would be cumbersome for the user. The multiple
+ lifecycles have been tested seperately. */
+
+
+ /*if(!status)
+ {
+ status = test_remoteproc_multiple_lifecycles(firmware_name);
+ }*/
+
+ return status;
+}
+
+int test_remoteproc_multiple_lifecycles(char * firmware_name)
+{
+ int i,j, status;
+ struct remote_proc *proc;
+
+ for(i = 0; i < 2; i++)
+ {
+ status = remoteproc_init( (void *) firmware_name ,rpmsg_channel_created, rpmsg_channel_deleted, rpmsg_read_default_cb, &proc);
+
+ if (status)
+ {
+ break;
+ }
+
+ status = remoteproc_boot( proc );
+
+ if (status)
+ {
+ break;
+ }
+
+ /* Wait for channel creation event */
+ wait_for_event();
+
+ if (!status)
+ {
+ status = test_rpmsg_send_impl(app_rp_chnl);
+ }
+
+ if(!status){
+ test_rpmsg_remote_channel_deletion(app_rp_chnl , app_rp_chnl->name);
+ }
+
+ if (!status)
+ {
+ for (j = 0; j < 200000; j++)
+ {
+ sleep();
+ }
+
+ status = remoteproc_shutdown(proc);
+ }
+ if (status)
+ {
+ break;
+ }
+ status = remoteproc_deinit(proc);
+
+ if (status)
+ {
+ break;
+ }
+ }
+
+ return status;
+}
+
+int test_rpmsg_remote_channel_deletion(struct rpmsg_channel *rpmsg_chnl, char *channel_name)
+{
+ struct command *cmd;
+ int status;
+ struct chnl_cmd_data *chnl_data;
+
+ cmd = malloc(sizeof(struct command)+ sizeof(struct chnl_cmd_data));
+
+ cmd->comm_code = DELETE_CHNL;
+ cmd->comm_start = CMD_START;
+
+ chnl_data = (struct chnl_cmd_data *)cmd->data;
+
+ strncpy(chnl_data->name , channel_name, sizeof(struct chnl_cmd_data));
+
+ /* Let the other side that uninit its resources */
+ status = rpmsg_send( rpmsg_chnl , cmd , sizeof(struct command) + sizeof(struct chnl_cmd_data) );
+ if(status)
+ {
+ return status;
+ }
+
+ /* Wait for echo back */
+ wait_for_event();
+
+ free(cmd);
+
+ return status;
+}
+
+int test_rpmsg_create_ept(struct rpmsg_channel *rpmsg_chnl)
+{
+ struct command *cmd;
+ int status =-1, i;
+ struct ept_cmd_data *ept_data;
+ struct rpmsg_endpoint *test_ept[NUM_TEST_EPS];
+
+ cmd = malloc(sizeof(struct command) + sizeof(struct ept_cmd_data));
+
+ if(!cmd)
+ {
+ return status;
+ }
+
+ for(i = 0; i < NUM_TEST_EPS; i++)
+ {
+ /* Tell the remote to create a new endpoint. */
+ cmd->comm_code = CREATE_EPT;
+ cmd->comm_start = CMD_START;
+
+ /* Send create endpoint command to remote */
+ ept_data = (struct ept_cmd_data *)cmd->data;
+ ept_data->dst= EPT_TEST_ADDR + i;
+ ept_data->src= EPT_TEST_ADDR + i;
+
+ /* Let the other side know that it needs to create endpoint with the given address */
+ status = rpmsg_send(rpmsg_chnl, cmd, sizeof(struct command) + sizeof(struct ept_cmd_data));
+
+ if(!status)
+ {
+ /* Wait for ack */
+ wait_for_event();
+ }
+
+ if(!status)
+ {
+ test_ept[i] = rpmsg_create_ept(rpmsg_chnl , rpmsg_read_ept2_cb , RPMSG_NULL , EPT_TEST_ADDR + i);
+
+ if ( !test_ept[i] )
+ {
+ status = -1;
+ }
+
+ }
+ if(!status)
+ {
+ status = test_rpmsg_send_offchannel_impl(rpmsg_chnl, test_ept[i]->addr, test_ept[i]->addr);
+ }
+
+ if(!status)
+ {
+ /* Tell the remote to delete the endpoint. */
+ cmd->comm_code = DELETE_EPT;
+ cmd->comm_start = CMD_START;
+ /* Send delete endpoint command to remote */
+ ept_data = (struct ept_cmd_data *)cmd->data;
+ ept_data->dst= EPT_TEST_ADDR + i;
+ ept_data->src= EPT_TEST_ADDR + i;
+
+ /* Let the other side know that it needs to delete endpoint with the given address */
+ status = rpmsg_send(rpmsg_chnl, cmd, sizeof(struct command) + sizeof(struct ept_cmd_data));
+ }
+
+ if(!status)
+ {
+ /* Wait for ack */
+ wait_for_event();
+ }
+
+ if(!status)
+ {
+ rpmsg_destroy_ept(test_ept[i]);
+ }
+ }
+
+ free(cmd);
+
+ if(status)
+ {
+ return -1;
+ }
+
+ return status;
+}
+
+int test_rpmsg_send_impl(struct rpmsg_channel *rpmsg_chnl)
+{
+ struct command cmd;
+ int status;
+ int i, size, idx;
+
+ /* Tell the remote to be prepared for echo payloads. */
+ cmd.comm_start = CMD_START;
+ cmd.comm_code = START_ECHO;
+
+ status = rpmsg_send(rpmsg_chnl, &cmd, sizeof(struct command));
+
+ if(!status)
+ {
+ /* Wait for cmd ack. */
+ wait_for_event();
+ if(status)
+ {
+ return -1;
+ }
+ for(i = 0, size=PAYLOAD_MIN_SIZE; i < NUM_PAYLOADS; i++, size++)
+ {
+ p_payload = malloc (sizeof(struct _payload) + size );
+
+ p_payload->num = i;
+ p_payload->size = size;
+
+ /* Setup the buffer with a pattern*/
+ memset(p_payload->data, 0xA5, size);
+
+ /* Send data to remote side. */
+ status = rpmsg_send(rpmsg_chnl, p_payload, sizeof(struct _payload) + size);
+
+ if(status != 0)
+ {
+ break;
+ }
+
+ /* Wait for echo. */
+ wait_for_event();
+
+ /* Validate the data integrity. */
+ for(idx = 0; idx < r_payload->size; idx++)
+ {
+ if(p_payload->data[idx] != r_payload->data[idx])
+ {
+ status = -1;
+ break;
+ }
+ }
+
+ if(status != 0)
+ {
+ break;
+ }
+
+ free(p_payload);
+
+ }
+ if(status)
+ {
+ return -1;
+ }
+ cmd.comm_start = CMD_START;
+ cmd.comm_code = STOP_ECHO;
+
+ status = rpmsg_send(rpmsg_chnl, &cmd, sizeof(struct command));
+ if(status)
+ if(status)
+ {
+ return -1;
+ }
+
+ /* Wait for echo. */
+ wait_for_event();
+
+ }
+
+ return status;
+}
+int test_rpmsg_send(struct rpmsg_channel *rpmsg_chnl)
+{
+ return test_rpmsg_send_impl(rpmsg_chnl);
+}
+
+int test_rpmsg_send_offchannel_impl(struct rpmsg_channel *rpmsg_chnl, unsigned long src, unsigned long dst)
+{
+ struct command cmd;
+ int status;
+ int i, size, idx;
+
+ /* Tell the remote to be prepared for echo payloads. */
+ cmd.comm_code = START_ECHO;
+ cmd.comm_start = CMD_START;
+ status = rpmsg_send(rpmsg_chnl, &cmd, sizeof(struct command));
+
+ if(!status)
+ {
+ /* Wait for cmd ack. */
+ wait_for_event();
+
+
+ for(i = 0, size=PAYLOAD_MIN_SIZE; i < NUM_PAYLOADS; i++, size++)
+ {
+ p_payload = malloc(sizeof(struct _payload) + size );
+
+ p_payload->num = i;
+ p_payload->size = size;
+
+ /* Setup the buffer with a pattern*/
+ memset(p_payload->data, 0xA5, size);
+
+ /* Send data to remote side. */
+ status = rpmsg_send_offchannel(app_rp_chnl, src, dst, p_payload ,
+ sizeof(struct _payload) + size);
+
+ if(status)
+ {
+ break;
+ }
+
+ /* Wait for echo. */
+ wait_for_event();
+
+ /* Validate the data integrity. */
+ for(idx = 0; idx < r_payload->size; idx++)
+ {
+ if(p_payload->data[idx] != r_payload->data[idx])
+ {
+ status = -1;
+ break;
+ }
+ }
+
+ if(status)
+ {
+ break;
+ }
+
+ free(p_payload);
+ }
+ cmd.comm_start = CMD_START;
+ cmd.comm_code = STOP_ECHO;
+
+ status = rpmsg_send(rpmsg_chnl, &cmd, sizeof(struct command));
+
+ /* Wait for cmd ack. */
+ wait_for_event();
+ }
+
+ return status;
+}
+
+int test_rpmsg_send_offchannel(struct rpmsg_channel *rpmsg_chnl, unsigned long src, unsigned long dst)
+{
+ return test_rpmsg_send_offchannel_impl(rpmsg_chnl, src, dst);
+}
diff --git a/apps/tests/master/baremetal/func_test_suite/make b/apps/tests/master/baremetal/func_test_suite/make
--- /dev/null
@@ -0,0 +1,49 @@
+
+include ../Makefile.commons
+
+SAMPLE_OUT := tests/master/baremetal/func_test_suite/func_test_suite.out
+SAMPLE_C_SRC := tests/master/baremetal/func_test_suite/func_test_suite.c
+REMOTE_OUT := func_test_suite.out
+DST_DIR := tests/master/baremetal/func_test_suite
+LINUX_SRC_DIR := firmware/$(PLAT)/linux
+
+SAMPLEOBJFILES := $(patsubst %.c, %.o, $(SAMPLE_C_SRC))
+SAMPLE_DEPS := $(patsubst %.c, %.d, $(SAMPLE_C_SRC))
+SAMPLE_MAP := $(patsubst %.out, %.map, $(SAMPLE_OUT))
+SAMPLE_BIN := $(patsubst %.out, %.bin, $(SAMPLE_OUT))
+
+$(SAMPLE_OUT): $(REMOTE_OUT)$(SAMPLEOBJFILES)
+
+ @echo 'Building func_test_suite test for nucleus : $@'
+
+ $(LD) -Wl,-Map=tests/master/baremetal/func_test_suite/func_test_suite.map -Wl,--gc-sections -T"$(OHOME)/libs/system/$(PLAT)/baremetal/linker_master.ld" -L"$(OHOME)/libs/open_amp" -L"$(OHOME)/libs/system/$(PLAT)/baremetal" -o "$(SAMPLE_OUT)" -Wl,--start-group $(SAMPLEOBJFILES) $(DST_DIR)/firmware1.o $(DST_DIR)/firmware2.o -lopen_amp -lbaremetal_master -lc -lm -lstdc++ -lcs3 -lcs3arm -lcs3unhosted -Wl,--end-group
+
+ $(OBJCPY) -O binary $(SAMPLE_OUT) $(SAMPLE_BIN)
+
+ @echo 'Finished building target: $@'
+
+%.o:%.c
+ @echo CC $(<:.c=.o)
+ @$(CC) $(CFLAGS) $(ARCH_CFLAGS) $(INCLUDE) -c $< -o $@
+
+%.o:%.S
+ @$(AS) -c -mcpu=cortex-a9 $(ARCH_ASFLAGS) $(INCLUDE) $< -o $@
+
+$(REMOTE_OUT):
+ cd $(LINUX_SRC_DIR)/; cp firmware firmware1; \
+ $(OBJCPY) -I binary -O elf32-littlearm -B arm firmware1 firmware1.o
+ mv $(LINUX_SRC_DIR)/firmware1.o $(DST_DIR)/firmware1.o
+ cd $(LINUX_SRC_DIR)/; cp firmware firmware2; \
+ $(OBJCPY) -I binary -O elf32-littlearm -B arm firmware2 firmware2.o
+ mv $(LINUX_SRC_DIR)/firmware2.o $(DST_DIR)/
+ cd $(LINUX_SRC_DIR)/; rm firmware1; rm firmware2;
+clean:
+ -$(RM) $(SAMPLEOBJFILES) $(SAMPLE_DEPS) $(SAMPLE_OUT) $(DST_DIR)/firmware1.o $(DST_DIR)/firmware2.o $(SAMPLE_MAP) $(SAMPLE_BIN)
+
+post-build:
+ -@echo ' '
+
+secondary-outputs:
+
+PHONY: all clean dependents
+.SECONDARY: post-build
diff --git a/apps/tests/master/baremetal/func_test_suite/test_suite.h b/apps/tests/master/baremetal/func_test_suite/test_suite.h
--- /dev/null
@@ -0,0 +1,67 @@
+/*
+ * m_ept_func_test.h
+ *
+ * Created on: Mar 14, 2014
+ * Author: etsam
+ */
+
+#ifndef M_EPT_FUNC_TEST_H_
+#define M_EPT_FUNC_TEST_H_
+
+struct command
+{
+ unsigned int comm_start;
+ unsigned int comm_code;
+ char data[0];
+}__attribute__((__packed__));
+
+struct ept_cmd_data
+{
+ unsigned int src;
+ unsigned int dst;
+};
+
+struct chnl_cmd_data
+{
+ char name[32];
+};
+
+/* Command Codes */
+
+#define CREATE_EPT 0x00000000
+#define DELETE_EPT 0x00000001
+#define CREATE_CHNL 0x00000002
+#define DELETE_CHNL 0x00000003
+#define START_ECHO 0x00000004
+#define STOP_ECHO 0x00000005
+#define QUERY_FW_NAME 0x00000006
+#define PRINT_RESULT 0x00000007
+
+#define CMD_START 0xEF56A55A
+
+/* Define the main task's stack size */
+#define STACK_SIZE (NU_MIN_STACK_SIZE * 400)
+
+/* Define the main task's priority */
+#define TASK_PRIORITY 26
+
+/* Define the main task's time slice */
+#define TASK_SLICE 20
+
+#define EPT_TEST_ADDR 59
+
+#define NUM_TEST_EPS 4
+
+#define MAX_RPMSG_BUFF_SIZE 512
+#define PAYLOAD_MIN_SIZE 1
+#define PAYLOAD_MAX_SIZE (MAX_RPMSG_BUFF_SIZE - 24)
+#define NUM_PAYLOADS (PAYLOAD_MAX_SIZE/PAYLOAD_MIN_SIZE)
+
+struct _payload {
+ unsigned long num;
+ unsigned long size;
+ char data[0];
+}__attribute__((__packed__));
+
+
+#endif /* M_EPT_FUNC_TEST_H_ */
diff --git a/apps/tests/master/linux/kernelspace/rpmsg_echo_test_kern_app/rpmsg_echo_test_kern_app.c b/apps/tests/master/linux/kernelspace/rpmsg_echo_test_kern_app/rpmsg_echo_test_kern_app.c
--- /dev/null
@@ -0,0 +1,204 @@
+/*
+ * RPMSG Echo Test Kernel Driver
+ *
+ * Copyright (C) 2014 Mentor Graphics Corporation
+ *
+ * Test application that validates data integraty of inter processor
+ * communication from linux userspace to a remote software
+ * context. The application sends chunks of data to the
+ * remote processor. The remote side echoes the data back
+ * to application which then validates the data returned.
+ *
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ */
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/rpmsg.h>
+#include <linux/slab.h>
+#include <linux/random.h>
+#include <linux/wait.h>
+#include <linux/mutex.h>
+#include <linux/kthread.h>
+#include <linux/delay.h>
+
+static DECLARE_WAIT_QUEUE_HEAD(wait_queue);
+static int flag;
+
+struct _payload {
+unsigned long num;
+unsigned long size;
+char data[];
+};
+
+#define MAX_RPMSG_BUFF_SIZE 512
+#define PAYLOAD_MIN_SIZE 1
+#define PAYLOAD_MAX_SIZE (MAX_RPMSG_BUFF_SIZE - 24)
+#define NUM_PAYLOADS (PAYLOAD_MAX_SIZE/PAYLOAD_MIN_SIZE)
+/* Shutdown message ID */
+#define SHUTDOWN_MSG 0xEF56A55A
+
+#define GIGA 1000000000L
+
+static const char * const shutdown_argv[]
+ = { "/sbin/shutdown", "-h", "-P", "now", NULL };
+
+struct rpmsg_endpoint *ept;
+
+struct _payload *p_payload;
+
+static const char init_msg[] = "init_msg";
+int err_cnt;
+
+static void rpmsg_echo_test_kern_app_rx_cb(struct rpmsg_channel *rpdev,
+ void *data, int len, void *priv, u32 src)
+{
+ struct _payload *local_payload = data;
+ int i;
+
+ if (p_payload) {
+
+ pr_err("\r\n Master : Linux Kernal Space : Received payload ");
+ pr_err("num %d of size %d \r\n", local_payload->num, len);
+
+ /* Shutdown Linux if such a message is received.
+ Only applicable when Linux is a remoteproc remote. */
+ if ((*(int *) data) == SHUTDOWN_MSG) {
+ call_usermodehelper(shutdown_argv[0], shutdown_argv,
+ NULL, UMH_NO_WAIT);
+ } else {
+
+ for (i = 0; i < local_payload->size; i++) {
+
+ if (local_payload->data[i] != 0xA5) {
+ pr_err("\r\n Data corruption ");
+ pr_cont("at index %d \r\n", i);
+ err_cnt++;
+ break;
+ }
+ }
+
+ /* Free memory allocated to payload buffer. */
+ kzfree(p_payload);
+
+ /* Wake up the application. */
+ flag = 1;
+ wake_up_interruptible(&wait_queue);
+ }
+ }
+}
+
+static int rpmsg_echo_test_kern_app_probe(struct rpmsg_channel *rpdev)
+{
+ int err, i, size;
+ int shutdown_msg = SHUTDOWN_MSG;
+
+ pr_err("\r\n Echo Test Start! \r\n");
+
+ /* Create endpoint for remote channel and register rx callabck */
+ ept = rpmsg_create_ept(rpdev, rpmsg_echo_test_kern_app_rx_cb, 0,
+ RPMSG_ADDR_ANY);
+
+ if (!ept) {
+ pr_err(" Endpoint creation for failed!\r\n");
+ return -ENOMEM;
+ }
+
+ /* Send init message to complete the connection loop */
+ err = rpmsg_send_offchannel(rpdev, ept->addr, rpdev->dst,
+ init_msg, sizeof(init_msg));
+
+ if (err) {
+ pr_err(" Init message send failed!\r\n");
+ return err;
+ }
+
+ for (i = 0, size = PAYLOAD_MIN_SIZE; i < NUM_PAYLOADS; i++, size++) {
+ p_payload = kzalloc(2 * sizeof(unsigned long) + size,
+ GFP_KERNEL);
+ p_payload->num = i;
+ p_payload->size = size;
+ memset(&(p_payload->data[0]), 0xA5, size);
+
+ pr_err("\r\n Master : Linux Kernal Space : Sending payload num %d of size %d \r\n",
+ p_payload->num, (2 * sizeof(unsigned long)) + size);
+
+ /* Send payload to remote. */
+ err = rpmsg_send_offchannel(rpdev, ept->addr, rpdev->dst,
+ p_payload, (2 * sizeof(unsigned long)) + size);
+
+ if (err) {
+ pr_err(" send failed!\r\n");
+ return err;
+ }
+
+ /* Wait till the data is echoed back. */
+ wait_event_interruptible(wait_queue, flag != 0);
+ flag = 0;
+ }
+
+ /* Send payload to remote. */
+ err = rpmsg_send_offchannel(rpdev, ept->addr, rpdev->dst,
+ &shutdown_msg, sizeof(int));
+
+ if (err) {
+ pr_err(" Shutdown message send failed!\r\n");
+ return err;
+ }
+
+ pr_err("\r\n *******************************************\r\n");
+ pr_err("\r\n Echo Test Results: Error count = %d\r\n", err_cnt);
+ pr_err("\r\n *******************************************\r\n");
+
+ return 0;
+}
+
+static void rpmsg_echo_test_kern_app_remove(struct rpmsg_channel *rpdev)
+{
+ rpmsg_destroy_ept(ept);
+}
+
+static void rpmsg_cb(struct rpmsg_channel *rpdev, void *data,
+ int len, void *priv, u32 src)
+{
+
+}
+
+static struct rpmsg_device_id rpmsg_echo_test_kern_app_id_table[] = {
+ { .name = "rpmsg-openamp-demo-channel" },
+ { },
+};
+MODULE_DEVICE_TABLE(rpmsg, rpmsg_echo_test_kern_app_id_table);
+
+static struct rpmsg_driver rpmsg_echo_test_kern_app = {
+ .drv.name = KBUILD_MODNAME,
+ .drv.owner = THIS_MODULE,
+ .id_table = rpmsg_echo_test_kern_app_id_table,
+ .probe = rpmsg_echo_test_kern_app_probe,
+ .callback = rpmsg_cb,
+ .remove = rpmsg_echo_test_kern_app_remove,
+};
+
+static int __init init(void)
+{
+ return register_rpmsg_driver(&rpmsg_echo_test_kern_app);
+}
+
+static void __exit fini(void)
+{
+ unregister_rpmsg_driver(&rpmsg_echo_test_kern_app);
+}
+
+module_init(init);
+module_exit(fini);
+
+MODULE_DESCRIPTION("rpmsg echo test kernel application");
+MODULE_LICENSE("GPL v2");
diff --git a/apps/tests/master/linux/kernelspace/rpmsg_func_test_kern_app/rpmsg_func_test_kern_app.c b/apps/tests/master/linux/kernelspace/rpmsg_func_test_kern_app/rpmsg_func_test_kern_app.c
--- /dev/null
@@ -0,0 +1,256 @@
+/*
+ * RPMSG Functional Test Suite Kernel Driver
+ *
+ * Copyright (C) 2014 Mentor Graphics Corporation
+ *
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ */
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/rpmsg.h>
+#include <linux/slab.h>
+#include <linux/random.h>
+#include <linux/wait.h>
+#include <linux/mutex.h>
+#include <linux/kthread.h>
+#include <linux/delay.h>
+
+static DECLARE_WAIT_QUEUE_HEAD(wait_queue);
+static int flag;
+
+struct _payload {
+ unsigned long num;
+ unsigned long size;
+ char data[];
+};
+
+struct command {
+ unsigned int comm_start;
+ unsigned int comm_code;
+ char data[0];
+} __attribute__((__packed__));
+
+struct ept_cmd_data {
+ unsigned int src;
+ unsigned int dst;
+};
+
+struct chnl_cmd_data {
+ char name[32];
+};
+
+#define MAX_RPMSG_BUFF_SIZE 512
+#define PAYLOAD_MIN_SIZE 1
+#define PAYLOAD_MAX_SIZE (MAX_RPMSG_BUFF_SIZE - 24)
+#define NUM_PAYLOADS (PAYLOAD_MAX_SIZE/PAYLOAD_MIN_SIZE)
+
+
+/* Command Codes */
+
+#define CREATE_EPT 0x00000000
+#define DELETE_EPT 0x00000001
+#define CREATE_CHNL 0x00000002
+#define DELETE_CHNL 0x00000003
+#define START_ECHO 0x00000004
+#define STOP_ECHO 0x00000005
+#define QUERY_FW_NAME 0x00000006
+#define PRINT_RESULT 0x00000007
+
+#define CMD_START 0xEF56A55A
+
+
+struct rpmsg_endpoint *ept;
+struct rpmsg_endpoint *rp_ept;
+
+struct _payload *p_payload;
+
+char firmware_name[] = "linux-fn-test-suite-remote-firmware";
+
+u32 source_buffer;
+int data_length;
+
+char r_buffer[512];
+
+static const char init_msg[] = "init_msg";
+static const char start_test[] = "start_test";
+
+int err_cnt;
+
+static const char * const shutdown_argv[]
+ = { "/sbin/shutdown", "-h", "-P", "now", NULL };
+
+
+static void rpmsg_func_test_default_rx_cb(struct rpmsg_channel *rpdev,
+ void *data, int len, void *priv, u32 src)
+{
+ if (data) {
+ memcpy(r_buffer, data, len);
+ source_buffer = src;
+ data_length = len;
+
+ /* Wake up the application. */
+ flag = 1;
+ wake_up_interruptible(&wait_queue);
+ }
+}
+
+static void rpmsg_func_test_ept_rx_cb(struct rpmsg_channel *rpdev,
+ void *data, int len, void *priv, u32 src)
+{
+ rpmsg_send_offchannel(rpdev, rp_ept->addr, src, data, len);
+}
+
+static int rpmsg_func_test_kern_app_probe(struct rpmsg_channel *rpdev)
+{
+ int err;
+ int uninit = 0;
+ struct ept_cmd_data *ept_data;
+ struct command *cmd;
+
+ pr_err("\r\nFunc Test Suite Start! \r\n");
+
+ /* Create endpoint for remote channel and register rx callabck */
+ ept = rpmsg_create_ept(rpdev, rpmsg_func_test_default_rx_cb, 0,
+ RPMSG_ADDR_ANY);
+
+ if (!ept) {
+ pr_err(" Endpoint creation for failed!\r\n");
+ return -ENOMEM;
+ }
+
+ /* Send init message to complete the connection loop */
+ err = rpmsg_send_offchannel(rpdev, ept->addr, rpdev->dst,
+ init_msg, sizeof(init_msg));
+
+ if (err) {
+ pr_err(" Init message send failed!\r\n");
+ return err;
+ }
+
+ /* Send a message to start tests */
+ err = rpmsg_send_offchannel(rpdev, ept->addr, rpdev->dst,
+ start_test, sizeof(start_test));
+
+ if (err) {
+ pr_err("Test start command failed!\r\n");
+ return err;
+ }
+
+
+ while (1) {
+ /* Wait till the data is echoed back. */
+ wait_event_interruptible(wait_queue, flag != 0);
+ flag = 0;
+
+ cmd = (struct command *)r_buffer;
+
+ if (cmd->comm_start == CMD_START) {
+ unsigned int cm_code = cmd->comm_code;
+ void *data = cmd->data;
+
+ switch (cm_code) {
+ case CREATE_EPT:
+ ept_data = (struct ept_cmd_data *)data;
+ rp_ept = rpmsg_create_ept(rpdev,
+ rpmsg_func_test_ept_rx_cb,
+ 0, ept_data->dst);
+ if (rp_ept)
+ /* Send data back to ack. */
+ rpmsg_send_offchannel(rpdev,
+ ept->addr, rpdev->dst,
+ r_buffer, data_length);
+ break;
+ case DELETE_EPT:
+ rpmsg_destroy_ept(rp_ept);
+ rpmsg_send_offchannel(rpdev, ept->addr,
+ rpdev->dst,
+ r_buffer, data_length);
+ break;
+ case CREATE_CHNL:
+ break;
+ case DELETE_CHNL:
+ rpmsg_send_offchannel(rpdev, ept->addr,
+ rpdev->dst,
+ r_buffer, data_length);
+ uninit = 1;
+ break;
+ case QUERY_FW_NAME:
+ rpmsg_send_offchannel(rpdev, ept->addr,
+ rpdev->dst,
+ &firmware_name[0],
+ strlen(firmware_name)+1);
+ break;
+ case PRINT_RESULT:
+ pr_err("%s", data);
+ rpmsg_send_offchannel(rpdev, ept->addr,
+ rpdev->dst,
+ r_buffer, data_length);
+ break;
+ default:
+ rpmsg_send_offchannel(rpdev, ept->addr,
+ rpdev->dst,
+ r_buffer, data_length);
+ break;
+ }
+ } else
+ rpmsg_send_offchannel(rpdev, ept->addr, rpdev->dst,
+ r_buffer, data_length);
+
+ if (uninit)
+ break;
+ }
+
+ call_usermodehelper(shutdown_argv[0], shutdown_argv, NULL, UMH_NO_WAIT);
+
+ return 0;
+}
+
+static void rpmsg_func_test_kern_app_remove(struct rpmsg_channel *rpdev)
+{
+ rpmsg_destroy_ept(ept);
+}
+
+static void rpmsg_cb(struct rpmsg_channel *rpdev, void *data,
+ int len, void *priv, u32 src)
+{
+
+}
+
+static struct rpmsg_device_id rpmsg_func_test_kern_app_id_table[] = {
+ { .name = "rpmsg-openamp-demo-channel" },
+ { },
+};
+MODULE_DEVICE_TABLE(rpmsg, rpmsg_func_test_kern_app_id_table);
+
+static struct rpmsg_driver rpmsg_func_test_kern_app = {
+ .drv.name = KBUILD_MODNAME,
+ .drv.owner = THIS_MODULE,
+ .id_table = rpmsg_func_test_kern_app_id_table,
+ .probe = rpmsg_func_test_kern_app_probe,
+ .callback = rpmsg_cb,
+ .remove = rpmsg_func_test_kern_app_remove,
+};
+
+static int __init init(void)
+{
+ return register_rpmsg_driver(&rpmsg_func_test_kern_app);
+}
+
+static void __exit fini(void)
+{
+ unregister_rpmsg_driver(&rpmsg_func_test_kern_app);
+}
+
+module_init(init);
+module_exit(fini);
+
+MODULE_DESCRIPTION("rpmsg functional test kernel application");
diff --git a/apps/tests/master/linux/userspace/echo_test/echo_test.c b/apps/tests/master/linux/userspace/echo_test/echo_test.c
--- /dev/null
@@ -0,0 +1,163 @@
+/*
+ * temp.c
+ *
+ * Created on: Oct 4, 2014
+ * Author: etsam
+ */
+
+/*
+ * Test application that data integraty of inter processor
+ * communication from linux userspace to a remote software
+ * context. The application sends chunks of data to the
+ * remote processor. The remote side echoes the data back
+ * to application which then validates the data returned.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <sys/ioctl.h>
+#include <time.h>
+#include <fcntl.h>
+#include <string.h>
+
+/* Shutdown message ID */
+#define SHUTDOWN_MSG 0xEF56A55A
+
+struct _payload {
+ unsigned long num;
+ unsigned long size;
+ char data[];
+};
+
+static int fd, err_cnt;
+
+struct _payload *i_payload;
+struct _payload *r_payload;
+
+#define RPMSG_GET_KFIFO_SIZE 1
+#define RPMSG_GET_AVAIL_DATA_SIZE 2
+#define RPMSG_GET_FREE_SPACE 3
+
+#define MAX_RPMSG_BUFF_SIZE 512
+#define PAYLOAD_MIN_SIZE 1
+#define PAYLOAD_MAX_SIZE (MAX_RPMSG_BUFF_SIZE - 24)
+#define NUM_PAYLOADS (PAYLOAD_MAX_SIZE/PAYLOAD_MIN_SIZE)
+
+int main(int argc, char *argv[])
+{
+ int flag = 1;
+ int shutdown_msg = SHUTDOWN_MSG;
+ int cmd, ret, i;
+ unsigned int size, bytes_rcvd, bytes_sent;
+ err_cnt = 0;
+
+ printf("\r\n Echo test start \r\n");
+
+ printf("\r\n Open rpmsg dev! \r\n");
+
+ fd = open("/dev/rpmsg", O_RDWR);
+
+ printf("\r\n Query internal info .. \r\n");
+
+ ioctl(fd, RPMSG_GET_KFIFO_SIZE, &size);
+
+ printf(" rpmsg kernel fifo size = %u \r\n", size);
+
+ ioctl(fd, RPMSG_GET_FREE_SPACE, &size);
+
+ printf(" rpmsg kernel fifo free space = %u \r\n", size);
+
+ while (flag == 1) {
+ printf("\r\n **************************************** \r\n");
+ printf(" Please enter command and press enter key\r\n");
+ printf(" **************************************** \r\n");
+ printf(" 1 - Send data to remote core, retrieve the echo");
+ printf(" and validate its integrity .. \r\n");
+ printf(" 2 - Quit this application .. \r\n");
+ printf(" CMD>");
+ ret = scanf("%d", &cmd);
+ if (!ret) {
+ while (1) {
+ if (getchar() == '\n')
+ break;
+ }
+
+ printf("\r\n invalid command\r\n");
+ continue;
+ }
+
+ if (cmd == 1) {
+ for (i = 0, size = PAYLOAD_MIN_SIZE; i < NUM_PAYLOADS;
+ i++, size++) {
+ i_payload = malloc(
+ 2 * sizeof(unsigned long) + size);
+ i_payload->num = i;
+ i_payload->size = size;
+
+ /* Mark the data buffer. */
+ memset(&(i_payload->data[0]), 0xA5, size);
+
+ printf("\r\n sending payload number");
+ printf(" %d of size %d \r\n", i_payload->num,
+ (2 * sizeof(unsigned long)) + size);
+
+ bytes_sent = write(fd, i_payload,
+ (2 * sizeof(unsigned long)) + size);
+
+ if (bytes_sent <= 0) {
+ printf("\r\n Error sending data");
+ printf(" .. \r\n");
+ free(i_payload);
+ break;
+ }
+
+ r_payload = malloc(
+ (2 * sizeof(unsigned long)) + i_payload->size);
+
+ bytes_rcvd = read(fd, r_payload,
+ (2 * sizeof(unsigned long)) + i_payload->size);
+
+ printf(" received payload number ");
+ printf("%d of size %d \r\n", r_payload->num,
+ bytes_rcvd);
+
+ /* Validate data buffer integrity. */
+ for (i = 0; i < r_payload->size; i++) {
+
+ if (r_payload->data[i] != 0xA5) {
+ printf(" \r\n Data corruption");
+ printf(" at index %d \r\n", i);
+ err_cnt++;
+ break;
+ }
+ }
+
+ free(i_payload);
+ free(r_payload);
+ }
+
+ printf("\r\n **********************************");
+ printf("****\r\n");
+ printf("\r\n Test Results: Error count = %d\r\n",
+ err_cnt);
+ printf("\r\n **********************************");
+ printf("****\r\n");
+ } else if (cmd == 2) {
+ flag = 0;
+ /* Send shutdown message to remote */
+ write(fd, &shutdown_msg, sizeof(int));
+ sleep(1);
+ printf("\r\n Quitting application .. \r\n");
+ printf(" Echo test end \r\n");
+ } else {
+ printf("\r\n invalid command! \r\n");
+ }
+ }
+
+ close(fd);
+
+ return 0;
+}
+
+
diff --git a/apps/tests/master/nucleus/echo_test/nucleus_linux/echo_test.c b/apps/tests/master/nucleus/echo_test/nucleus_linux/echo_test.c
--- /dev/null
@@ -0,0 +1,196 @@
+/* This is a sample demonstration application that showcases usage of remoteproc
+and rpmsg APIs. This application is meant to run on the master CPU running Nucleus
+and showcases booting of linux remote firmware using remoteproc and
+IPC with remote firmware using rpmsg; Nucleus on master core acts as a remoteproc master
+but as an rpmsg remote;It brings up a remote Linux based
+firmware which acts as an rpmsg master and transmits data payloads to Nucleus.
+Linux app sends paylaods of incremental sizes to Nucleus which echoes them back to Linux.
+Once Linux application is complete, it requests a shutdown from Nucleus.
+Nucleus acknowledges with a shutdown message which results in Linux starting a system halt.
+Nucleus shutsdown the remote core after a reasonable delay which allows
+Linux to gracefully shutdown. */
+
+/* Including required headers */
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include "open_amp.h"
+#include "nucleus.h"
+#include "kernel/nu_kernel.h"
+
+/* Define the main task's stack size */
+#define STACK_SIZE (NU_MIN_STACK_SIZE * 64)
+
+/* Define the main task's priority */
+#define TASK_PRIORITY 26
+
+/* Define the main task's time slice */
+#define TASK_SLICE 20
+
+#define MAX_RPMSG_BUFF_SIZE 512
+#define PAYLOAD_MIN_SIZE 1
+#define PAYLOAD_MAX_SIZE (MAX_RPMSG_BUFF_SIZE - 24)
+#define NUM_PAYLOADS (PAYLOAD_MAX_SIZE/PAYLOAD_MIN_SIZE)
+
+#define SHUTDOWN_MSG 0xEF56A55A
+
+/* Prototypes */
+static void Main_Task_Entry( UNSIGNED argc , VOID *argv );
+
+/* Application provided callbacks */
+void rpmsg_channel_created( struct rpmsg_channel *rp_chnl );
+void rpmsg_channel_deleted( struct rpmsg_channel *rp_chnl );
+void rpmsg_read_cb( struct rpmsg_channel *rp_chnl , void *data , int len , void * pric , unsigned long src );
+
+/* Globals */
+NU_TASK Task_Control_Block;
+NU_SEMAPHORE App_Sem;
+struct rpmsg_endpoint *rp_ept;
+struct rpmsg_channel *app_rp_chnl;
+char fw_name1 []= "firmware1";
+
+int global_count;
+
+/***********************************************************************
+ * *
+ * * FUNCTION
+ * *
+ * * Application_Initialize
+ * *
+ * * DESCRIPTION
+ * *
+ * * Demo application entry point
+ *
+ * ***********************************************************************/
+VOID Application_Initialize(NU_MEMORY_POOL* mem_pool , NU_MEMORY_POOL* uncached_mem_pool )
+{
+ VOID *pointer;
+ STATUS status = NU_SUCCESS;
+
+ /* Reference unused parameters to avoid toolset warnings */
+ NU_UNUSED_PARAM( uncached_mem_pool );
+
+ if (status == NU_SUCCESS)
+ {
+ status = NU_Allocate_Memory(mem_pool, &pointer, STACK_SIZE, NU_NO_SUSPEND);
+
+ /* Create the main task for matrix processing */
+ if ( status == NU_SUCCESS )
+ {
+ status = NU_Create_Task( &Task_Control_Block , "MAIN" , Main_Task_Entry , 0 ,
+ uncached_mem_pool , pointer , STACK_SIZE ,
+ TASK_PRIORITY , TASK_SLICE , NU_PREEMPT , NU_START );
+ }
+ if(status == NU_SUCCESS)
+ {
+ status = NU_Create_Semaphore(&App_Sem ,"APP_SEM", 0, NU_FIFO);
+ }
+ }
+
+ /* Check to see if previous operations were successful */
+ if ( status != NU_SUCCESS )
+ {
+ /* Loop forever */
+ while ( 1 );
+ }
+}
+
+/***********************************************************************
+ * *
+ * * FUNCTION
+ * *
+ * * Main_Task_Entry
+ * *
+ * * DESCRIPTION
+ * *
+ * * Entry function for the main task. This task prints a hello world
+ * * message.
+ * *
+ * ***********************************************************************/
+static VOID Main_Task_Entry( UNSIGNED argc , VOID *argv ) {
+
+ struct remote_proc *proc;
+ int status;
+ int shutdown_msg = SHUTDOWN_MSG;
+
+ printf("\n\n\r************************************");
+ printf("*******************************************\r\n");
+ printf("\r\n Echo Test Application \r\n");
+ printf("\r\n");
+ printf("\r\nThis test application will start a linux kernel on remote core and will act\r\n");
+ printf("\r\nas an RPMSG remote itself to echo back any data that it receives from Linux\r\n");
+
+ printf("\r\n******************************************");
+ printf("*************************************\n\r\n");
+
+ printf("\r\n******************************************");
+ printf("*************************************\n\r\n");
+ printf("\r\nLoading remote context : %s \r\n" , fw_name1);
+ printf("\r\n******************************************");
+ printf("*************************************\n\r\n");
+
+
+ status = remoteproc_init((void *) fw_name1, rpmsg_channel_created, rpmsg_channel_deleted, rpmsg_read_cb, &proc);
+
+ if(!status && (proc))
+ {
+ printf("\r\n\n********************************************\r\n");
+ printf("BOOTING LINUX REMOTE FIRMWARE");
+ printf("\r\n********************************************\r\n\n");
+ status = remoteproc_boot(proc);
+ }
+
+ if(!status)
+ {
+ /* Wait for shutdown message. */
+ NU_Obtain_Semaphore(&App_Sem, NU_SUSPEND);
+
+ /* Send shutdown message to remote */
+ rpmsg_send(app_rp_chnl, &shutdown_msg, sizeof(int));
+
+ /* The remote Linux kernel requires around ~15 seconds to shutdown itself. Wait. */
+ NU_Sleep(100 * 18);
+
+ remoteproc_shutdown(proc);
+
+ remoteproc_deinit(proc);
+
+ }
+ else
+ {
+ printf("\r\n\nLoading remote context: %s failed \r\n" , fw_name1);
+ }
+
+ printf("\r\nTest Completed \r\n");
+}
+
+/* This callback gets invoked when the remote chanl is created */
+void rpmsg_channel_created(struct rpmsg_channel *rp_chnl) {
+
+ app_rp_chnl = rp_chnl;
+
+ rp_ept = rpmsg_create_ept(rp_chnl , rpmsg_read_cb ,RPMSG_NULL , RPMSG_ADDR_ANY);
+}
+
+/* This callback gets invoked when the remote channel is deleted */
+void rpmsg_channel_deleted(struct rpmsg_channel *rp_chnl) {
+
+ rpmsg_destroy_ept(rp_ept);
+
+}
+
+/* This is the read callback, note we are in a task context when this callback
+is invoked, so kernel primitives can be used freely */
+void rpmsg_read_cb(struct rpmsg_channel *rp_chnl, void *data, int len,
+ void * priv, unsigned long src) {
+
+ if ((*(int *) data) == SHUTDOWN_MSG)
+ {
+ NU_Release_Semaphore(&App_Sem);
+ }
+ else
+ {
+ rpmsg_send(rp_chnl, data, len);
+ }
+}
+
diff --git a/apps/tests/master/nucleus/echo_test/nucleus_linux/make b/apps/tests/master/nucleus/echo_test/nucleus_linux/make
--- /dev/null
@@ -0,0 +1,49 @@
+
+include ../Makefile.commons
+
+SAMPLE_OUT := tests/master/nucleus/echo_test/nucleus_linux/echo_test.out
+SAMPLE_C_SRC := tests/master/nucleus/echo_test/nucleus_linux/echo_test.c
+REMOTE_OUT := echo_test.out
+DST_DIR := tests/master/nucleus/echo_test/nucleus_linux
+LINUX_SRC_DIR := firmware/$(PLAT)/linux
+
+SAMPLEOBJFILES := $(patsubst %.c, %.o, $(SAMPLE_C_SRC))
+SAMPLE_DEPS := $(patsubst %.c, %.d, $(SAMPLE_C_SRC))
+SAMPLE_MAP := $(patsubst %.out, %.map, $(SAMPLE_OUT))
+SAMPLE_BIN := $(patsubst %.out, %.bin, $(SAMPLE_OUT))
+
+$(SAMPLE_OUT): $(REMOTE_OUT)$(SAMPLEOBJFILES)
+
+ @echo 'Building echo_test test for nucleus : $@'
+
+ $(LD) -Wl,-Map=tests/master/nucleus/echo_test/nucleus_linux/echo_test.map -nostartfiles -Wl,--gc-sections -Wl,--wrap=malloc -Wl,--wrap=calloc -Wl,--wrap=realloc -Wl,--wrap=free -T"$(OHOME)/libs/system/$(PLAT)/nucleus/linker_master.ld" -L"$(OHOME)/libs/system/$(PLAT)/nucleus/lib/$(CROSS)/master" -L"$(OHOME)/libs/open_amp" -o "$(SAMPLE_OUT)" -Wl,--start-group $(SAMPLEOBJFILES) $(DST_DIR)/firmware1.o $(DST_DIR)/firmware2.o -lnucleus_master -lopen_amp -lc -lm -lstdc++ -Wl,--end-group
+
+ $(OBJCPY) -O binary $(SAMPLE_OUT) $(SAMPLE_BIN)
+
+ @echo 'Finished building target: $@'
+
+%.o:%.c
+ @echo CC $(<:.c=.o)
+ @$(CC) $(CFLAGS) $(ARCH_CFLAGS) $(INCLUDE) -c $< -o $@
+
+%.o:%.S
+ @$(AS) -c $(ARCH_ASFLAGS) $(INCLUDE) $< -o $@
+
+$(REMOTE_OUT):
+ cd $(LINUX_SRC_DIR)/; cp firmware firmware1; \
+ $(OBJCPY) -I binary -O elf32-littlearm -B arm firmware1 firmware1.o
+ mv $(LINUX_SRC_DIR)/firmware1.o $(DST_DIR)/firmware1.o
+ cd $(LINUX_SRC_DIR)/; cp firmware firmware2; \
+ $(OBJCPY) -I binary -O elf32-littlearm -B arm firmware2 firmware2.o
+ mv $(LINUX_SRC_DIR)/firmware2.o $(DST_DIR)/
+ cd $(LINUX_SRC_DIR)/; rm firmware1; rm firmware2;
+clean:
+ -$(RM) $(SAMPLEOBJFILES) $(SAMPLE_DEPS) $(SAMPLE_OUT) $(SAMPLE_BIN) $(DST_DIR)/firmware1.o $(DST_DIR)/firmware2.o $(SAMPLE_MAP)
+
+post-build:
+ -@echo ' '
+
+secondary-outputs:
+
+PHONY: all clean dependents
+.SECONDARY: post-build
diff --git a/apps/tests/master/nucleus/echo_test/nucleus_nucleusbm/echo_test.c b/apps/tests/master/nucleus/echo_test/nucleus_nucleusbm/echo_test.c
--- /dev/null
@@ -0,0 +1,338 @@
+/* This is a test demonstration application that showcases usage of remoteproc
+and rpmsg APIs. This application is meant to run on the master CPU running Nucleus
+and showcases booting of two sub-sequent remote firmware cycles using remoteproc and
+IPC with remote firmware using rpmsg; 1. It brings up a remote Nucleus based remote
+firmware which echoes back payload data, 2. It brings up a baremetal based
+remote firmware which echoes back payload data. Master app transmists paylaods of
+varying sizes to the remote core which echoes them back. The master core validates
+the data integrity and shutsdown the core once the test has been completed.*/
+
+/* Including required headers */
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include "open_amp.h"
+#include "nucleus.h"
+#include "kernel/nu_kernel.h"
+
+/* Define the main task's stack size */
+#define STACK_SIZE (NU_MIN_STACK_SIZE * 64)
+
+/* Define the main task's priority */
+#define TASK_PRIORITY 26
+
+/* Define the main task's time slice */
+#define TASK_SLICE 20
+
+#define MAX_RPMSG_BUFF_SIZE 512
+#define PAYLOAD_MIN_SIZE 1
+#define PAYLOAD_MAX_SIZE (MAX_RPMSG_BUFF_SIZE - 24)
+#define NUM_PAYLOADS (PAYLOAD_MAX_SIZE/PAYLOAD_MIN_SIZE)
+
+#define SHUTDOWN_MSG 0xEF56A55A
+
+struct _payload {
+ unsigned long num;
+ unsigned long size;
+ char data[];
+};
+
+/* Prototypes */
+static void Main_Task_Entry( UNSIGNED argc , VOID *argv );
+
+/* Application provided callbacks */
+void rpmsg_channel_created( struct rpmsg_channel *rp_chnl );
+void rpmsg_channel_deleted( struct rpmsg_channel *rp_chnl );
+void rpmsg_read_cb( struct rpmsg_channel *rp_chnl , void *data , int len , void * pric , unsigned long src );
+
+/* Globals */
+NU_TASK Task_Control_Block;
+NU_SEMAPHORE App_Sem;
+struct rpmsg_endpoint *rp_ept;
+struct rpmsg_channel *app_rp_chnl;
+char fw_name1 []= "firmware1";
+char fw_name2 []= "firmware2";
+
+struct _payload* p_payload = NULL;
+struct _payload* r_payload = NULL;
+
+/***********************************************************************
+ * *
+ * * FUNCTION
+ * *
+ * * Application_Initialize
+ * *
+ * * DESCRIPTION
+ * *
+ * * Demo application entry point
+ *
+ * ***********************************************************************/
+VOID Application_Initialize(NU_MEMORY_POOL* mem_pool , NU_MEMORY_POOL* uncached_mem_pool )
+{
+ VOID *pointer;
+ STATUS status = NU_SUCCESS;
+
+ /* Reference unused parameters to avoid toolset warnings */
+ NU_UNUSED_PARAM( uncached_mem_pool );
+
+ if (status == NU_SUCCESS)
+ {
+ status = NU_Allocate_Memory(mem_pool, &pointer, STACK_SIZE, NU_NO_SUSPEND);
+
+ /* Create the main task for matrix processing */
+ if ( status == NU_SUCCESS )
+ {
+ status = NU_Create_Task( &Task_Control_Block , "MAIN" , Main_Task_Entry , 0 ,
+ uncached_mem_pool , pointer , STACK_SIZE ,
+ TASK_PRIORITY , TASK_SLICE , NU_PREEMPT , NU_START );
+ }
+ if(status == NU_SUCCESS)
+ {
+ status = NU_Create_Semaphore(&App_Sem ,"APP_SEM", 0, NU_FIFO);
+ }
+ }
+
+ /* Check to see if previous operations were successful */
+ if ( status != NU_SUCCESS )
+ {
+ /* Loop forever */
+ while ( 1 );
+ }
+}
+
+/***********************************************************************
+ * *
+ * * FUNCTION
+ * *
+ * * Main_Task_Entry
+ * *
+ * * DESCRIPTION
+ * *
+ * * Entry function for the main task. This task prints a hello world
+ * * message.
+ * *
+ * ***********************************************************************/
+static VOID Main_Task_Entry( UNSIGNED argc , VOID *argv ) {
+
+ struct remote_proc *proc;
+ int idx ,i, size, status;
+ NU_MEMORY_POOL *sys_pool_ptr;
+ int shutdown_msg = SHUTDOWN_MSG;
+
+ NU_System_Memory_Get(&sys_pool_ptr, NU_NULL);
+
+ printf("\n\n\r************************************");
+ printf("*******************************************\r\n");
+ printf("\r\n Echo Test Application \r\n");
+ printf("\r\n");
+ printf("\r\nThis test application will send variable length data \r\n");
+ printf("\r\npackets to remote cores\r\n");
+
+ printf("\r\n******************************************");
+ printf("*************************************\n\r\n");
+
+ printf("\r\n******************************************");
+ printf("*************************************\n\r\n");
+ printf("\r\nLoading remote context : %s \r\n" , fw_name1);
+ printf("\r\n******************************************");
+ printf("*************************************\n\r\n");
+
+ NU_Allocate_Memory(sys_pool_ptr, (VOID **)&r_payload, (2 * sizeof(unsigned long) + PAYLOAD_MAX_SIZE), NU_NO_SUSPEND);
+
+ status = remoteproc_init((void *) fw_name1, rpmsg_channel_created, rpmsg_channel_deleted, rpmsg_read_cb, &proc);
+
+ if(!status && (proc))
+ {
+ printf("\r\n\n********************************************\r\n");
+ printf("BOOTING NUCLEUS REMOTE FIRMWARE");
+ printf("\r\n********************************************\r\n\n");
+ status = remoteproc_boot(proc);
+ }
+
+ if(!status)
+ {
+ /* Wait for channel creation complete callback. */
+ NU_Obtain_Semaphore(&App_Sem, NU_SUSPEND);
+
+ printf("\r\n******************************************");
+ printf("*************************************\n\r\n");
+ printf("\r\nStarting echo test on : %s \r\n" , fw_name1);
+ printf("\r\n******************************************");
+ printf("*************************************\n\r\n");
+
+ for(i = 0, size=PAYLOAD_MIN_SIZE; i < NUM_PAYLOADS; i++, size++)
+ {
+ NU_Allocate_Memory(sys_pool_ptr, (VOID **)&p_payload, (2 * sizeof(unsigned long) + size), NU_NO_SUSPEND);
+
+ p_payload->num = i;
+
+ p_payload->size = size;
+
+ /* Setup the buffer with a pattern*/
+ memset(&(p_payload->data[0]), 0xA5, size);
+
+ printf("\r\nSending data packet of size: %d to remote firmware : %s \r\n" , size, fw_name1);
+
+ /* Send data to remote side. */
+ rpmsg_send(app_rp_chnl, p_payload, (2 * sizeof(unsigned long)) + size);
+
+ /* Wait for echo. */
+ NU_Obtain_Semaphore(&App_Sem , NU_SUSPEND);
+
+ /* Validate packet number*/
+ if(p_payload->num != r_payload->num)
+ {
+ printf("\r\nError Echo packet number does not match with transmitted packet number: %d \r\n", (int)p_payload->num);
+ }
+
+ /* Validate the data integrity. */
+ for(idx = 0; idx < r_payload->size; idx++)
+ {
+ if(p_payload->data[idx] != r_payload->data[idx])
+ {
+ printf("\r\nError receiving data packet of size: %d at data index %d \r\n", size, idx);
+ break;
+ }
+ }
+
+ if(idx == size)
+ {
+ printf("\r\nReceived data packet of size: %d from remote successfully \r\n", size);
+ }
+
+ NU_Deallocate_Memory(p_payload);
+ }
+
+ printf("\r\n******************************************");
+ printf("*************************************\n\r\n");
+ printf("\r\nRemoving remote context : %s \r\n" , fw_name1);
+ printf("\r\n******************************************");
+ printf("*************************************\n\r\n");
+
+ /* Send termination message to remote */
+ rpmsg_send(app_rp_chnl, &shutdown_msg, sizeof(int));
+
+ /* Wait for channel deletion callback. */
+ NU_Obtain_Semaphore(&App_Sem , NU_SUSPEND);
+
+ remoteproc_shutdown(proc);
+
+ remoteproc_deinit(proc);
+
+ }
+ else
+ {
+ printf("\r\n\nLoading remote context: %s failed \r\n" , fw_name1);
+ }
+
+ printf("\r\n******************************************");
+ printf("*************************************\n\r\n");
+ printf("\r\nLoading remote context : %s \r\n" , fw_name2);
+ printf("\r\n******************************************");
+ printf("*************************************\n\r\n");
+
+ status = remoteproc_init((void *) fw_name2, rpmsg_channel_created, rpmsg_channel_deleted, rpmsg_read_cb, &proc);
+
+ if(!status && (proc))
+ {
+ printf("\r\n\n********************************************\r\n");
+ printf("BOOTING BAREMETAL REMOTE FIRMWARE");
+ printf("\r\n********************************************\r\n\n");
+ status = remoteproc_boot(proc);
+ }
+
+ if(!status)
+ {
+ NU_Obtain_Semaphore(&App_Sem, NU_SUSPEND);
+
+ printf("\r\n******************************************");
+ printf("*************************************\n\r\n");
+ printf("\r\nStarting echo test on : %s \r\n" , fw_name2);
+ printf("\r\n******************************************");
+ printf("*************************************\n\r\n");
+
+ for(i = 0, size=PAYLOAD_MIN_SIZE; i < NUM_PAYLOADS; i++, size++)
+ {
+ NU_Allocate_Memory(sys_pool_ptr, (VOID **)&p_payload, (2 * sizeof(unsigned long) + size), NU_NO_SUSPEND);
+
+ p_payload->num = i;
+
+ p_payload->size = size;
+
+ /* Setup the buffer with a pattern*/
+ memset(&(p_payload->data[0]), 0xA5, size);
+
+ printf("\r\nSending data packet of size: %d to remote firmware : %s \r\n" , size, fw_name2);
+
+ /* Send data to remote side. */
+ rpmsg_send(app_rp_chnl, p_payload, (2 * sizeof(unsigned long)) + size);
+
+ /* Wait for echo. */
+ NU_Obtain_Semaphore(&App_Sem , NU_SUSPEND);
+
+ /* Validate packet number*/
+ if(p_payload->num != r_payload->num)
+ {
+ printf("\r\nError Echo packet number does not match with transmitted packet number %d \r\n", (int)p_payload->num);
+ }
+
+ /* Validate the data integrity. */
+ for(idx = 0; idx < size; idx++)
+ {
+ if(p_payload->data[idx] != r_payload->data[idx])
+ {
+ printf("\r\nError receiving data packet of size: %d at data index %d \r\n", size, idx);
+ break;
+ }
+ }
+
+ if(idx == size)
+ {
+ printf("\r\nReceived data packet of size: %d from remote successfully \r\n", size);
+ }
+
+ NU_Deallocate_Memory(p_payload);
+ }
+
+ printf("\r\nRemoving remote context : %s \r\n" , fw_name2);
+
+ remoteproc_shutdown(proc);
+
+ remoteproc_deinit(proc);
+ }
+ else
+ {
+ printf("\r\n\nLoading remote context: %s failed \r\n" , fw_name2);
+ }
+
+ printf("\r\nTest Completed \r\n");
+}
+
+/* This callback gets invoked when the remote chanl is created */
+void rpmsg_channel_created(struct rpmsg_channel *rp_chnl) {
+
+ app_rp_chnl = rp_chnl;
+
+ rp_ept = rpmsg_create_ept(rp_chnl , rpmsg_read_cb ,RPMSG_NULL , RPMSG_ADDR_ANY);
+
+ NU_Release_Semaphore(&App_Sem);
+}
+
+/* This callback gets invoked when the remote channel is deleted */
+void rpmsg_channel_deleted(struct rpmsg_channel *rp_chnl) {
+
+ rpmsg_destroy_ept(rp_ept);
+ NU_Release_Semaphore(&App_Sem);
+
+}
+
+/* This is the read callback, note we are in a task context when this callback
+is invoked, so kernel primitives can be used freely */
+void rpmsg_read_cb(struct rpmsg_channel *rp_chnl, void *data, int len,
+ void * priv, unsigned long src) {
+
+ memcpy(r_payload,data,len);
+
+ NU_Release_Semaphore(&App_Sem);
+}
+
diff --git a/apps/tests/master/nucleus/echo_test/nucleus_nucleusbm/make b/apps/tests/master/nucleus/echo_test/nucleus_nucleusbm/make
--- /dev/null
@@ -0,0 +1,51 @@
+
+include ../Makefile.commons
+
+SAMPLE_OUT := tests/master/nucleus/echo_test/nucleus_nucleusbm/echo_test.out
+SAMPLE_C_SRC := tests/master/nucleus/echo_test/nucleus_nucleusbm/echo_test.c
+REMOTE_OUT := echo_test.out
+DST_DIR := tests/master/nucleus/echo_test/nucleus_nucleusbm
+NU_SRC_DIR := firmware/$(PLAT)/nucleus/echo_test
+BM_SRC_DIR := firmware/$(PLAT)/baremetal/echo_test
+
+SAMPLEOBJFILES := $(patsubst %.c, %.o, $(SAMPLE_C_SRC))
+SAMPLE_DEPS := $(patsubst %.c, %.d, $(SAMPLE_C_SRC))
+SAMPLE_MAP := $(patsubst %.out, %.map, $(SAMPLE_OUT))
+SAMPLE_BIN := $(patsubst %.out, %.bin, $(SAMPLE_OUT))
+
+$(SAMPLE_OUT): $(REMOTE_OUT)$(SAMPLEOBJFILES)
+
+ @echo 'Building echo_test test for nucleus : $@'
+
+ $(LD) -Wl,-Map=tests/master/nucleus/echo_test/nucleus_nucleusbm/echo_test.map -nostartfiles -Wl,--gc-sections -Wl,--wrap=malloc -Wl,--wrap=calloc -Wl,--wrap=realloc -Wl,--wrap=free -T"$(OHOME)/libs/system/$(PLAT)/nucleus/linker_master.ld" -L"$(OHOME)/libs/system/$(PLAT)/nucleus/lib/$(CROSS)/master" -L"$(OHOME)/libs/open_amp" -o "$(SAMPLE_OUT)" -Wl,--start-group $(SAMPLEOBJFILES) $(DST_DIR)/firmware1.o $(DST_DIR)/firmware2.o -lnucleus_master -lopen_amp -lc -lm -lstdc++ -Wl,--end-group
+
+ $(OBJCPY) -O binary $(SAMPLE_OUT) $(SAMPLE_BIN)
+
+ @echo 'Finished building target: $@'
+
+%.o:%.c
+ @echo CC $(<:.c=.o)
+ @$(CC) $(CFLAGS) $(ARCH_CFLAGS) $(INCLUDE) -c $< -o $@
+
+%.o:%.S
+ @$(AS) -c $(ARCH_ASFLAGS) $(INCLUDE) $< -o $@
+
+$(REMOTE_OUT):
+ cd $(NU_SRC_DIR)/; cp firmware firmware1; \
+ $(OBJCPY) -I binary -O elf32-littlearm -B arm firmware1 firmware1.o
+ mv $(NU_SRC_DIR)/firmware1.o $(DST_DIR)/
+ cd $(BM_SRC_DIR)/; cp firmware firmware2; \
+ $(OBJCPY) -I binary -O elf32-littlearm -B arm firmware2 firmware2.o
+ mv $(BM_SRC_DIR)/firmware2.o $(DST_DIR)/
+ cd $(NU_SRC_DIR)/; rm firmware1
+ cd $(BM_SRC_DIR)/; rm firmware2
+clean:
+ -$(RM) $(SAMPLEOBJFILES) $(SAMPLE_DEPS) $(SAMPLE_OUT) $(SAMPLE_BIN) $(DST_DIR)/firmware1.o $(DST_DIR)/firmware2.o $(SAMPLE_MAP)
+
+post-build:
+ -@echo ' '
+
+secondary-outputs:
+
+PHONY: all clean dependents
+.SECONDARY: post-build
diff --git a/apps/tests/master/nucleus/func_test_suite/nucleus_linux/func_test_suite.c b/apps/tests/master/nucleus/func_test_suite/nucleus_linux/func_test_suite.c
--- /dev/null
@@ -0,0 +1,644 @@
+/* Including required headers */
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include "open_amp.h"
+#include "test_suite.h"
+#include "nucleus.h"
+#include "kernel/nu_kernel.h"
+
+
+/* Prototypes */
+static void Main_Task_Entry( UNSIGNED argc , VOID *argv );
+
+/* Application provided callbacks */
+void rpmsg_channel_created( struct rpmsg_channel *rp_chnl );
+void rpmsg_channel_deleted( struct rpmsg_channel *rp_chnl );
+void rpmsg_read_default_cb( struct rpmsg_channel *rp_chnl , void *data , int len , void * pric ,
+ unsigned long src );
+void rpmsg_read_ept1_cb( struct rpmsg_channel *rp_chnl , void *data , int len , void * pric ,
+ unsigned long src );
+void rpmsg_read_ept2_cb( struct rpmsg_channel *rp_chnl , void *data , int len , void * pric ,
+ unsigned long src );
+
+int test_rpmsg_send(struct rpmsg_channel *rpmsg_chnl);
+int test_rpmsg_send_offchannel(struct rpmsg_channel *rpmsg_chnl, unsigned long src, unsigned long dst);
+
+int test_rpmsg_create_ept(struct rpmsg_channel *rpmsg_chnl);
+
+int test_remoteproc_multiple_lifecycles(char * firmware_name);
+
+int test_rpmsg_send_offchannel_impl(struct rpmsg_channel *rpmsg_chnl, unsigned long src, unsigned long dst);
+
+int test_rpmsg_send_impl(struct rpmsg_channel *rpmsg_chnl);
+
+int test_rpmsg_remote_channel_deletion(struct rpmsg_channel *rpmsg_chnl, char *channel_name);
+
+int test_execute_suite(char * firmware_name);
+
+
+/* Globals */
+NU_TASK Task_Control_Block;
+NU_SEMAPHORE App_Sem, Remote_Del_Sem;
+struct rpmsg_endpoint *rp_ept1 , *rp_ept2;
+struct rpmsg_channel *app_rp_chnl;
+char fw_name1[] = "firmware1";
+
+struct _payload* p_payload = NULL;
+struct _payload* r_payload = NULL;
+/***********************************************************************
+ * *
+ * * FUNCTION
+ * *
+ * * Application_Initialize
+ * *
+ * * DESCRIPTION
+ * *
+ * * Demo application entry point
+ *
+ * ***********************************************************************/
+VOID Application_Initialize(
+ NU_MEMORY_POOL* mem_pool , NU_MEMORY_POOL* uncached_mem_pool )
+{
+ VOID *pointer;
+ STATUS status = NU_SUCCESS;
+
+ /* Reference unused parameters to avoid toolset warnings */
+ NU_UNUSED_PARAM( uncached_mem_pool );
+
+ if ( status == NU_SUCCESS )
+ {
+ status = NU_Allocate_Memory(mem_pool, &pointer, STACK_SIZE, NU_NO_SUSPEND);
+
+ /* Create the main task for matrix processing */
+ if ( status == NU_SUCCESS )
+ {
+ status = NU_Create_Task( &Task_Control_Block , "MAIN" , Main_Task_Entry , 0 ,
+ uncached_mem_pool , pointer , STACK_SIZE , TASK_PRIORITY , TASK_SLICE ,
+ NU_PREEMPT , NU_START );
+ }
+ if ( status == NU_SUCCESS )
+ {
+ status = NU_Create_Semaphore( &App_Sem , "APP_SEM" , 0 , NU_FIFO );
+ }
+
+ if ( status == NU_SUCCESS )
+ {
+ status = NU_Create_Semaphore( &Remote_Del_Sem , "Del_SEM" , 0 , NU_FIFO );
+ }
+
+ NU_Allocate_Memory(uncached_mem_pool , (VOID **)&r_payload, 512 , NU_SUSPEND);
+ }
+
+ /* Check to see if previous operations were successful */
+ if ( status != NU_SUCCESS )
+ {
+ /* Loop forever */
+ while ( 1 );
+ }
+}
+
+/***********************************************************************
+ * *
+ * * FUNCTION
+ * *
+ * * Main_Task_Entry
+ * *
+ * * DESCRIPTION
+ * *
+ * * Entry function for the main task. This task prints a hello world
+ * * message.
+ * *
+ * ***********************************************************************/
+static VOID Main_Task_Entry( UNSIGNED argc , VOID *argv )
+{
+ printf("\n\n\r************************************");
+ printf("*******************************************\r\n");
+ printf("\r\n OpenAMP Test Suite \r\n");
+ printf("\r\n");
+ printf("\r\nThis test suite will execute multiple test cases for rpmsg and rempteproc \r\n");
+ printf("\r\nAPIs available within OpenAMP \r\n");
+
+ printf("\r\n******************************************");
+ printf("*************************************\n\r\n");
+
+ test_execute_suite(fw_name1);
+}
+
+/* This callback gets invoked when the remote chanl is created */
+void rpmsg_channel_created( struct rpmsg_channel *rp_chnl )
+{
+ app_rp_chnl = rp_chnl;
+
+ rp_ept1 = rpmsg_create_ept(rp_chnl , rpmsg_read_ept1_cb , RPMSG_NULL , RPMSG_ADDR_ANY);
+}
+
+/* This callback gets invoked when the remote channel is deleted */
+void rpmsg_channel_deleted( struct rpmsg_channel *rp_chnl )
+{
+ rpmsg_destroy_ept( rp_ept1 );
+
+ NU_Release_Semaphore( &Remote_Del_Sem );
+
+}
+
+/* This is the read callback, note we are in a task context when this callback
+ is invoked, so kernel primitives can be used freely */
+void rpmsg_read_default_cb( struct rpmsg_channel *rp_chnl , void *data , int len , void * priv ,
+ unsigned long src )
+{
+ memcpy( r_payload , data , len );
+ NU_Release_Semaphore( &App_Sem );
+}
+
+void rpmsg_read_ept1_cb( struct rpmsg_channel *rp_chnl , void *data , int len , void * priv ,
+ unsigned long src )
+{
+ memcpy( r_payload , data , len );
+ NU_Release_Semaphore( &App_Sem );
+}
+
+void rpmsg_read_ept2_cb( struct rpmsg_channel *rp_chnl , void *data , int len , void * priv ,
+ unsigned long src )
+{
+ memcpy( r_payload , data , len );
+ NU_Release_Semaphore( &App_Sem );
+}
+
+void send_test_case_report(char *result_string)
+{
+ struct command* cmd;
+ NU_MEMORY_POOL *sys_pool_ptr;
+ int status;
+
+ NU_System_Memory_Get(NU_NULL, &sys_pool_ptr);
+
+ status = NU_Allocate_Memory(sys_pool_ptr , (void **)&(cmd), sizeof(struct command) + strlen(result_string) + 1, NU_SUSPEND);
+
+ if(status == NU_SUCCESS)
+ {
+ cmd->comm_start=CMD_START;
+ cmd->comm_code = PRINT_RESULT;
+
+ strcpy(cmd->data, result_string);
+
+ status = rpmsg_send(app_rp_chnl, cmd, sizeof(struct command) + strlen(result_string) + 1);
+
+ NU_Deallocate_Memory(cmd);
+
+ /* Wait to receive echo*/
+ NU_Obtain_Semaphore( &App_Sem , NU_SUSPEND );
+ }
+}
+
+int test_execute_suite(char * firmware_name)
+{
+ struct remote_proc *proc;
+ int status;
+ char default_channel[] = "rpmsg-openamp-demo-channel";
+ struct command* cmd;
+ NU_MEMORY_POOL *sys_pool_ptr;
+
+ printf("\n\n\r************************************");
+ printf("*******************************************\r\n");
+ printf( "\r\nBoot remote context : %s \r\n" , firmware_name );
+ printf("\r\n******************************************");
+ printf("*************************************\n\r\n");
+
+ status = remoteproc_init( (void *) firmware_name ,rpmsg_channel_created, rpmsg_channel_deleted, rpmsg_read_default_cb, &proc);
+
+ if (status)
+ {
+ printf( "\r\n CRITICAL ERROR: remoteproc_init call for remote context %s failed \r\n", firmware_name);
+
+ return -1;
+ }
+
+ status = remoteproc_boot( proc );
+
+ if (status)
+ {
+ printf( "\r\n CRITICAL ERROR: remoteproc_boot call for remote context %s failed \r\n", firmware_name);
+
+ return -1;
+ }
+
+ /* Wait for channel creation event */
+ NU_Obtain_Semaphore( &App_Sem , NU_SUSPEND );
+
+ /* Obtain remote firmware name */
+ NU_System_Memory_Get(NU_NULL, &sys_pool_ptr);
+ status = NU_Allocate_Memory(sys_pool_ptr , (void **)&(cmd), sizeof(struct command), NU_SUSPEND);
+ cmd->comm_start=CMD_START;
+ cmd->comm_code = QUERY_FW_NAME;
+ status = rpmsg_send(app_rp_chnl, cmd, sizeof(struct command));
+ NU_Deallocate_Memory(cmd);
+
+ /* Wait to receive firmware name */
+ NU_Obtain_Semaphore( &App_Sem , NU_SUSPEND );
+
+ /* Test rpmsg_send API */
+ status = test_rpmsg_send(app_rp_chnl);
+
+ if(!status)
+ {
+ send_test_case_report("\r\nRPMSG Send Test: Passed\r\n");
+ }
+ else
+ {
+ send_test_case_report("\r\nRPMSG Send Test: Failed\r\n");
+ }
+
+ /* Test rpmsg_send_offchannel API. */
+ status = test_rpmsg_send_offchannel(app_rp_chnl, rp_ept1->addr, app_rp_chnl->dst);
+
+ if(!status)
+ {
+ send_test_case_report("\r\nRPMSG Send Offchannel Test: Passed\r\n");
+ }
+ else
+ {
+ send_test_case_report("\r\nRPMSG Send Offchannel: Failed\r\n");
+ }
+
+ status = test_rpmsg_create_ept(app_rp_chnl);
+
+ if(!status)
+ {
+ send_test_case_report("\r\nRPMSG Create EPT Test: Passed\r\n");
+ }
+ else
+ {
+ send_test_case_report("\r\nRPMSG Create EPT Test: Failed\r\n");
+ }
+
+ send_test_case_report("\r\nChannel Deletion. Shutdown would be next\r\n");
+
+ status = test_rpmsg_remote_channel_deletion(app_rp_chnl, default_channel);
+
+ NU_Sleep(100 * 18);
+
+ status = remoteproc_shutdown(proc);
+ if(!status)
+ {
+ status = remoteproc_deinit(proc);
+ }
+
+ /* The multiple life-cycles test has been disabled for remote Linux configuration
+ as it would require manual user input at linux console to complete
+ the rpmsg connection and would be cumbersome for the user. The multiple
+ lifecycles have been tested seperately. */
+
+
+ /*if(!status)
+ {
+ status = test_remoteproc_multiple_lifecycles(firmware_name);
+ }*/
+
+ return status;
+}
+
+int test_remoteproc_multiple_lifecycles(char * firmware_name)
+{
+ int i, status;
+ struct remote_proc *proc;
+
+ for(i = 0; i < 2; i++)
+ {
+ status = remoteproc_init( (void *) firmware_name ,rpmsg_channel_created, rpmsg_channel_deleted, rpmsg_read_default_cb, &proc);
+
+ if (status)
+ {
+ break;
+ }
+
+ status = remoteproc_boot( proc );
+
+ if (status)
+ {
+ break;
+ }
+
+ /* Wait for channel creation event */
+ status = NU_Obtain_Semaphore( &App_Sem , NU_SUSPEND );
+
+ if (!status)
+ {
+ status = test_rpmsg_send_impl(app_rp_chnl);
+ }
+
+ if(!status){
+ test_rpmsg_remote_channel_deletion(app_rp_chnl , app_rp_chnl->name);
+ }
+
+ NU_Sleep(100 * 18);
+
+ if (!status)
+ {
+ status = remoteproc_shutdown(proc);
+ }
+ if (status)
+ {
+ break;
+ }
+ status = remoteproc_deinit(proc);
+
+ if (status)
+ {
+ break;
+ }
+
+ }
+
+ return status;
+}
+
+int test_rpmsg_remote_channel_deletion(struct rpmsg_channel *rpmsg_chnl, char *channel_name)
+{
+ struct command *cmd;
+ int status;
+ NU_MEMORY_POOL *sys_pool_ptr;
+ struct chnl_cmd_data *chnl_data;
+
+ NU_System_Memory_Get(NU_NULL, &sys_pool_ptr);
+
+ status = NU_Allocate_Memory(sys_pool_ptr ,
+ (void **)&(cmd), sizeof(struct command)+ sizeof(struct chnl_cmd_data), NU_SUSPEND);
+
+ cmd->comm_code = DELETE_CHNL;
+ cmd->comm_start = CMD_START;
+
+ chnl_data = (struct chnl_cmd_data *)cmd->data;
+
+ strncpy(chnl_data->name , channel_name, sizeof(struct chnl_cmd_data));
+
+ /* Let the other side that uninit its resources */
+ status = rpmsg_send( rpmsg_chnl , cmd , sizeof(struct command) + sizeof(struct chnl_cmd_data) );
+ if(status)
+ {
+ return status;
+ }
+ /* Wait for echo back */
+ status = NU_Obtain_Semaphore( &App_Sem , NU_SUSPEND);
+
+ return status;
+}
+
+int test_rpmsg_create_ept(struct rpmsg_channel *rpmsg_chnl)
+{
+ struct command *cmd;
+ int status, i;
+ struct ept_cmd_data *ept_data;
+ NU_MEMORY_POOL *sys_pool_ptr;
+ struct rpmsg_endpoint *test_ept[NUM_TEST_EPS];
+
+ NU_System_Memory_Get(NU_NULL, &sys_pool_ptr);
+
+ status = NU_Allocate_Memory(sys_pool_ptr ,
+ (void **)&(cmd), sizeof(struct command) + sizeof(struct ept_cmd_data), NU_SUSPEND);
+
+ if(status != NU_SUCCESS)
+ {
+ return status;
+ }
+
+ for(i = 0; i < NUM_TEST_EPS; i++)
+ {
+ /* Tell the remote to create a new endpoint. */
+ cmd->comm_code = CREATE_EPT;
+ cmd->comm_start = CMD_START;
+
+ /* Send create endpoint command to remote */
+ ept_data = (struct ept_cmd_data *)cmd->data;
+ ept_data->dst= EPT_TEST_ADDR + i;
+ ept_data->src= EPT_TEST_ADDR + i;
+
+ /* Let the other side know that it needs to create endpoint with the given address */
+ status = rpmsg_send(rpmsg_chnl, cmd, sizeof(struct command) + sizeof(struct ept_cmd_data));
+
+ if(!status)
+ {
+ /* Wait for ack */
+ status = NU_Obtain_Semaphore(&App_Sem , NU_SUSPEND);
+ }
+
+ if(!status)
+ {
+ test_ept[i] = rpmsg_create_ept(rpmsg_chnl , rpmsg_read_ept2_cb , RPMSG_NULL , EPT_TEST_ADDR + i);
+
+ if ( !test_ept[i] )
+ {
+ status = -1;
+ }
+
+ }
+ if(!status)
+ {
+ status = test_rpmsg_send_offchannel_impl(rpmsg_chnl, test_ept[i]->addr, test_ept[i]->addr);
+ }
+
+ if(!status)
+ {
+ /* Tell the remote to delete the endpoint. */
+ cmd->comm_code = DELETE_EPT;
+ cmd->comm_start = CMD_START;
+ /* Send delete endpoint command to remote */
+ ept_data = (struct ept_cmd_data *)cmd->data;
+ ept_data->dst= EPT_TEST_ADDR + i;
+ ept_data->src= EPT_TEST_ADDR + i;
+
+ /* Let the other side know that it needs to delete endpoint with the given address */
+ status = rpmsg_send(rpmsg_chnl, cmd, sizeof(struct command) + sizeof(struct ept_cmd_data));
+ }
+
+ if(!status)
+ {
+ /* Wait for ack */
+ status = NU_Obtain_Semaphore(&App_Sem , NU_SUSPEND);
+ }
+
+ if(!status)
+ {
+ rpmsg_destroy_ept(test_ept[i]);
+ }
+ }
+
+ NU_Deallocate_Memory(cmd);
+ if(status)
+ {
+ return -1;
+ }
+
+ return status;
+}
+
+int test_rpmsg_send_impl(struct rpmsg_channel *rpmsg_chnl)
+{
+ struct command cmd;
+ int status;
+ int i, size, idx;
+ NU_MEMORY_POOL *sys_pool_ptr;
+
+ NU_System_Memory_Get(NU_NULL, &sys_pool_ptr);
+ /* Tell the remote to be prepared for echo payloads. */
+ cmd.comm_start = CMD_START;
+ cmd.comm_code = START_ECHO;
+
+ status = rpmsg_send(rpmsg_chnl, &cmd, sizeof(struct command));
+
+ if(!status)
+ {
+ /* Wait for cmd ack. */
+ status = NU_Obtain_Semaphore(&App_Sem , NU_SUSPEND);
+ if(status)
+ {
+ return -1;
+ }
+ for(i = 0, size=PAYLOAD_MIN_SIZE; i < NUM_PAYLOADS; i++, size++)
+ {
+ NU_Allocate_Memory(sys_pool_ptr , (void**)&p_payload, sizeof(struct _payload) + size , NU_SUSPEND );
+
+ p_payload->num = i;
+ p_payload->size = size;
+
+ /* Setup the buffer with a pattern*/
+ memset(p_payload->data, 0xA5, size);
+
+ /* Send data to remote side. */
+ status = rpmsg_send(rpmsg_chnl, p_payload, sizeof(struct _payload) + size);
+
+ if(status != 0)
+ {
+ break;
+ }
+
+ /* Wait for echo. */
+ status = NU_Obtain_Semaphore(&App_Sem , NU_SUSPEND);
+
+ /* Validate the data integrity. */
+ for(idx = 0; idx < r_payload->size; idx++)
+ {
+ if(p_payload->data[idx] != r_payload->data[idx])
+ {
+ status = -1;
+ break;
+ }
+ }
+
+ if(status != 0)
+ {
+ break;
+ }
+
+ NU_Deallocate_Memory(p_payload);
+
+ }
+ if(status)
+ {
+ return -1;
+ }
+ cmd.comm_start = CMD_START;
+ cmd.comm_code = STOP_ECHO;
+
+ status = rpmsg_send(rpmsg_chnl, &cmd, sizeof(struct command));
+ if(status)
+ if(status)
+ {
+ return -1;
+ }
+
+ /* Wait for echo. */
+ status = NU_Obtain_Semaphore(&App_Sem , NU_SUSPEND);
+
+ if(status)
+ {
+ return -1;
+ }
+ }
+
+ return status;
+}
+int test_rpmsg_send(struct rpmsg_channel *rpmsg_chnl)
+{
+ return test_rpmsg_send_impl(rpmsg_chnl);
+}
+
+int test_rpmsg_send_offchannel_impl(struct rpmsg_channel *rpmsg_chnl, unsigned long src, unsigned long dst)
+{
+ struct command cmd;
+ int status;
+ int i, size, idx;
+ NU_MEMORY_POOL *sys_pool_ptr;
+ NU_System_Memory_Get(NU_NULL, &sys_pool_ptr);
+
+ /* Tell the remote to be prepared for echo payloads. */
+ cmd.comm_code = START_ECHO;
+ cmd.comm_start = CMD_START;
+ status = rpmsg_send(rpmsg_chnl, &cmd, sizeof(struct command));
+
+ if(!status)
+ {
+ /* Wait for cmd ack. */
+ status = NU_Obtain_Semaphore(&App_Sem , NU_SUSPEND);
+ if(status)
+ {
+ return -1;
+ }
+
+ for(i = 0, size=PAYLOAD_MIN_SIZE; i < NUM_PAYLOADS; i++, size++)
+ {
+ NU_Allocate_Memory(sys_pool_ptr , (void**)&p_payload, sizeof(struct _payload) + size , NU_SUSPEND );
+ p_payload->num = i;
+ p_payload->size = size;
+
+ /* Setup the buffer with a pattern*/
+ memset(p_payload->data, 0xA5, size);
+
+ /* Send data to remote side. */
+ status = rpmsg_send_offchannel(app_rp_chnl, src, dst, p_payload ,
+ sizeof(struct _payload) + size);
+
+ if(status)
+ {
+ break;
+ }
+
+ /* Wait for echo. */
+ status = NU_Obtain_Semaphore(&App_Sem , NU_SUSPEND);
+
+ /* Validate the data integrity. */
+ for(idx = 0; idx < r_payload->size; idx++)
+ {
+ if(p_payload->data[idx] != r_payload->data[idx])
+ {
+ status = -1;
+ break;
+ }
+ }
+
+ if(status)
+ {
+ break;
+ }
+
+ NU_Deallocate_Memory(p_payload);
+ }
+ cmd.comm_start = CMD_START;
+ cmd.comm_code = STOP_ECHO;
+
+ status = rpmsg_send(rpmsg_chnl, &cmd, sizeof(struct command));
+ /* Wait for cmd ack. */
+ status = NU_Obtain_Semaphore(&App_Sem , NU_SUSPEND);
+ if(status)
+ {
+ return -1;
+ }
+ }
+
+ return status;
+}
+
+int test_rpmsg_send_offchannel(struct rpmsg_channel *rpmsg_chnl, unsigned long src, unsigned long dst)
+{
+ return test_rpmsg_send_offchannel_impl(rpmsg_chnl, src, dst);
+}
diff --git a/apps/tests/master/nucleus/func_test_suite/nucleus_linux/make b/apps/tests/master/nucleus/func_test_suite/nucleus_linux/make
--- /dev/null
@@ -0,0 +1,49 @@
+
+include ../Makefile.commons
+
+SAMPLE_OUT := tests/master/nucleus/func_test_suite/nucleus_linux/func_test_suite.out
+SAMPLE_C_SRC := tests/master/nucleus/func_test_suite/nucleus_linux/func_test_suite.c
+REMOTE_OUT := func_test_suite.out
+DST_DIR := tests/master/nucleus/func_test_suite/nucleus_linux
+LINUX_SRC_DIR := firmware/$(PLAT)/linux
+
+SAMPLEOBJFILES := $(patsubst %.c, %.o, $(SAMPLE_C_SRC))
+SAMPLE_DEPS := $(patsubst %.c, %.d, $(SAMPLE_C_SRC))
+SAMPLE_MAP := $(patsubst %.out, %.map, $(SAMPLE_OUT))
+SAMPLE_BIN := $(patsubst %.out, %.bin, $(SAMPLE_OUT))
+
+$(SAMPLE_OUT): $(REMOTE_OUT)$(SAMPLEOBJFILES)
+
+ @echo 'Building func_test_suite test for nucleus : $@'
+
+ $(LD) -Wl,-Map=tests/master/nucleus/func_test_suite/nucleus_linux/func_test_suite.map -nostartfiles -Wl,--gc-sections -Wl,--wrap=malloc -Wl,--wrap=calloc -Wl,--wrap=realloc -Wl,--wrap=free -T"$(OHOME)/libs/system/$(PLAT)/nucleus/linker_master.ld" -L"$(OHOME)/libs/system/$(PLAT)/nucleus/lib/$(CROSS)/master" -L"$(OHOME)/libs/open_amp" -o "$(SAMPLE_OUT)" -Wl,--start-group $(SAMPLEOBJFILES) $(DST_DIR)/firmware1.o $(DST_DIR)/firmware2.o -lnucleus_master -lopen_amp -lc -lm -lstdc++ -Wl,--end-group
+
+ $(OBJCPY) -O binary $(SAMPLE_OUT) $(SAMPLE_BIN)
+
+ @echo 'Finished building target: $@'
+
+%.o:%.c
+ @echo CC $(<:.c=.o)
+ @$(CC) $(CFLAGS) $(ARCH_CFLAGS) $(INCLUDE) -c $< -o $@
+
+%.o:%.S
+ @$(AS) -c -mcpu=cortex-a9 $(ARCH_ASFLAGS) $(INCLUDE) $< -o $@
+
+$(REMOTE_OUT):
+ cd $(LINUX_SRC_DIR)/; cp firmware firmware1; \
+ $(OBJCPY) -I binary -O elf32-littlearm -B arm firmware1 firmware1.o
+ mv $(LINUX_SRC_DIR)/firmware1.o $(DST_DIR)/firmware1.o
+ cd $(LINUX_SRC_DIR)/; cp firmware firmware2; \
+ $(OBJCPY) -I binary -O elf32-littlearm -B arm firmware2 firmware2.o
+ mv $(LINUX_SRC_DIR)/firmware2.o $(DST_DIR)/
+ cd $(LINUX_SRC_DIR)/; rm firmware1; rm firmware2;
+clean:
+ -$(RM) $(SAMPLEOBJFILES) $(SAMPLE_DEPS) $(SAMPLE_OUT) $(DST_DIR)/firmware1.o $(DST_DIR)/firmware2.o $(SAMPLE_MAP) $(SAMPLE_BIN)
+
+post-build:
+ -@echo ' '
+
+secondary-outputs:
+
+PHONY: all clean dependents
+.SECONDARY: post-build
diff --git a/apps/tests/master/nucleus/func_test_suite/nucleus_linux/test_suite.h b/apps/tests/master/nucleus/func_test_suite/nucleus_linux/test_suite.h
--- /dev/null
@@ -0,0 +1,67 @@
+/*
+ * m_ept_func_test.h
+ *
+ * Created on: Mar 14, 2014
+ * Author: etsam
+ */
+
+#ifndef M_EPT_FUNC_TEST_H_
+#define M_EPT_FUNC_TEST_H_
+
+struct command
+{
+ unsigned int comm_start;
+ unsigned int comm_code;
+ char data[0];
+}__attribute__((__packed__));
+
+struct ept_cmd_data
+{
+ unsigned int src;
+ unsigned int dst;
+};
+
+struct chnl_cmd_data
+{
+ char name[32];
+};
+
+/* Command Codes */
+
+#define CREATE_EPT 0x00000000
+#define DELETE_EPT 0x00000001
+#define CREATE_CHNL 0x00000002
+#define DELETE_CHNL 0x00000003
+#define START_ECHO 0x00000004
+#define STOP_ECHO 0x00000005
+#define QUERY_FW_NAME 0x00000006
+#define PRINT_RESULT 0x00000007
+
+#define CMD_START 0xEF56A55A
+
+/* Define the main task's stack size */
+#define STACK_SIZE (NU_MIN_STACK_SIZE * 400)
+
+/* Define the main task's priority */
+#define TASK_PRIORITY 26
+
+/* Define the main task's time slice */
+#define TASK_SLICE 20
+
+#define EPT_TEST_ADDR 59
+
+#define NUM_TEST_EPS 4
+
+#define MAX_RPMSG_BUFF_SIZE 512
+#define PAYLOAD_MIN_SIZE 1
+#define PAYLOAD_MAX_SIZE (MAX_RPMSG_BUFF_SIZE - 24)
+#define NUM_PAYLOADS (PAYLOAD_MAX_SIZE/PAYLOAD_MIN_SIZE)
+
+struct _payload {
+ unsigned long num;
+ unsigned long size;
+ char data[0];
+}__attribute__((__packed__));
+
+
+#endif /* M_EPT_FUNC_TEST_H_ */
diff --git a/apps/tests/master/nucleus/func_test_suite/nucleus_nucleusbm/func_test_suite.c b/apps/tests/master/nucleus/func_test_suite/nucleus_nucleusbm/func_test_suite.c
--- /dev/null
@@ -0,0 +1,700 @@
+/* This is a test demonstration application that tests usage of remoteproc
+and rpmsg APIs. This application is meant to run on the master CPU running Nucleus
+and showcases booting of two sub-sequent remote firmware cycles using remoteproc and
+IPC with remote firmware using rpmsg; 1. It brings up a remote Nucleus based remote
+firmware which can respond to test calls, 2. It brings up a baremetal based
+remote firmware which can respond to test calls. Master app executes tests to validate
+the rpmsg APIs and shutsdown the core once the test has been completed.*/
+
+/* Including required headers */
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include "open_amp.h"
+#include "test_suite.h"
+#include "nucleus.h"
+#include "kernel/nu_kernel.h"
+
+
+/* Prototypes */
+static void Main_Task_Entry( UNSIGNED argc , VOID *argv );
+
+/* Application provided callbacks */
+void rpmsg_channel_created( struct rpmsg_channel *rp_chnl );
+void rpmsg_channel_deleted( struct rpmsg_channel *rp_chnl );
+void rpmsg_read_default_cb( struct rpmsg_channel *rp_chnl , void *data , int len , void * pric ,
+ unsigned long src );
+void rpmsg_read_ept1_cb( struct rpmsg_channel *rp_chnl , void *data , int len , void * pric ,
+ unsigned long src );
+void rpmsg_read_ept2_cb( struct rpmsg_channel *rp_chnl , void *data , int len , void * pric ,
+ unsigned long src );
+
+int test_rpmsg_send(struct rpmsg_channel *rpmsg_chnl);
+int test_rpmsg_send_offchannel(struct rpmsg_channel *rpmsg_chnl, unsigned long src, unsigned long dst);
+
+int test_rpmsg_create_ept(struct rpmsg_channel *rpmsg_chnl);
+
+int test_remoteproc_multiple_lifecycles(char * firmware_name);
+
+int test_rpmsg_send_offchannel_impl(struct rpmsg_channel *rpmsg_chnl, unsigned long src, unsigned long dst);
+
+int test_rpmsg_send_impl(struct rpmsg_channel *rpmsg_chnl);
+
+int test_rpmsg_remote_channel_deletion(struct rpmsg_channel *rpmsg_chnl, char *channel_name);
+
+int test_execute_suite(char * firmware_name);
+
+
+/* Globals */
+NU_TASK Task_Control_Block;
+NU_SEMAPHORE App_Sem, Remote_Del_Sem;
+struct rpmsg_endpoint *rp_ept1 , *rp_ept2;
+struct rpmsg_channel *app_rp_chnl;
+char fw_name1[] = "firmware1";
+char fw_name2[] = "firmware2";
+
+struct _payload* p_payload = NULL;
+struct _payload* r_payload = NULL;
+static const char display_string[] = ".";
+/***********************************************************************
+ * *
+ * * FUNCTION
+ * *
+ * * Application_Initialize
+ * *
+ * * DESCRIPTION
+ * *
+ * * Demo application entry point
+ *
+ * ***********************************************************************/
+VOID Application_Initialize(
+ NU_MEMORY_POOL* mem_pool , NU_MEMORY_POOL* uncached_mem_pool )
+{
+ VOID *pointer;
+ STATUS status = NU_SUCCESS;
+
+ /* Reference unused parameters to avoid toolset warnings */
+ NU_UNUSED_PARAM( uncached_mem_pool );
+
+ if ( status == NU_SUCCESS )
+ {
+ status = NU_Allocate_Memory(mem_pool, &pointer, STACK_SIZE, NU_NO_SUSPEND);
+
+ /* Create the main task for matrix processing */
+ if ( status == NU_SUCCESS )
+ {
+ status = NU_Create_Task( &Task_Control_Block , "MAIN" , Main_Task_Entry , 0 ,
+ uncached_mem_pool , pointer , STACK_SIZE , TASK_PRIORITY , TASK_SLICE ,
+ NU_PREEMPT , NU_START );
+ }
+ if ( status == NU_SUCCESS )
+ {
+ status = NU_Create_Semaphore( &App_Sem , "APP_SEM" , 0 , NU_FIFO );
+ }
+
+ if ( status == NU_SUCCESS )
+ {
+ status = NU_Create_Semaphore( &Remote_Del_Sem , "Del_SEM" , 0 , NU_FIFO );
+ }
+
+ NU_Allocate_Memory(uncached_mem_pool , (VOID **)&r_payload, 512 , NU_SUSPEND);
+ }
+
+ /* Check to see if previous operations were successful */
+ if ( status != NU_SUCCESS )
+ {
+ /* Loop forever */
+ while ( 1 );
+ }
+}
+
+/***********************************************************************
+ * *
+ * * FUNCTION
+ * *
+ * * Main_Task_Entry
+ * *
+ * * DESCRIPTION
+ * *
+ * * Entry function for the main task. This task prints a hello world
+ * * message.
+ * *
+ * ***********************************************************************/
+static VOID Main_Task_Entry( UNSIGNED argc , VOID *argv )
+{
+ printf("\n\n\r************************************");
+ printf("*******************************************\r\n");
+ printf("\r\n OpenAMP Test Suite \r\n");
+ printf("\r\n");
+ printf("\r\nThis test suite will execute multiple test cases for rpmsg and rempteproc \r\n");
+ printf("\r\nAPIs available within OpenAMP \r\n");
+
+ printf("\r\n******************************************");
+ printf("*************************************\n\r\n");
+
+ test_execute_suite(fw_name1);
+
+ test_execute_suite(fw_name2);
+
+
+}
+
+/* This callback gets invoked when the remote chanl is created */
+void rpmsg_channel_created( struct rpmsg_channel *rp_chnl )
+{
+ app_rp_chnl = rp_chnl;
+
+ rp_ept1 = rpmsg_create_ept(rp_chnl , rpmsg_read_ept1_cb , RPMSG_NULL , RPMSG_ADDR_ANY);
+
+ NU_Release_Semaphore( &App_Sem );
+}
+
+/* This callback gets invoked when the remote channel is deleted */
+void rpmsg_channel_deleted( struct rpmsg_channel *rp_chnl )
+{
+ rpmsg_destroy_ept( rp_ept1 );
+
+ NU_Release_Semaphore( &Remote_Del_Sem );
+
+}
+
+/* This is the read callback, note we are in a task context when this callback
+ is invoked, so kernel primitives can be used freely */
+void rpmsg_read_default_cb( struct rpmsg_channel *rp_chnl , void *data , int len , void * priv ,
+ unsigned long src )
+{
+ memcpy( r_payload , data , len );
+ NU_Release_Semaphore( &App_Sem );
+}
+
+void rpmsg_read_ept1_cb( struct rpmsg_channel *rp_chnl , void *data , int len , void * priv ,
+ unsigned long src )
+{
+ memcpy( r_payload , data , len );
+ NU_Release_Semaphore( &App_Sem );
+}
+
+void rpmsg_read_ept2_cb( struct rpmsg_channel *rp_chnl , void *data , int len , void * priv ,
+ unsigned long src )
+{
+ memcpy( r_payload , data , len );
+ NU_Release_Semaphore( &App_Sem );
+}
+
+
+int test_execute_suite(char * firmware_name)
+{
+ struct remote_proc *proc;
+ int status;
+ char default_channel[] = "rpmsg-openamp-demo-channel";
+ struct command* cmd;
+ NU_MEMORY_POOL *sys_pool_ptr;
+
+ printf("\n\n\r************************************");
+ printf("*******************************************\r\n");
+ printf( "\r\nBoot remote context : %s \r\n" , firmware_name );
+ printf("\r\n******************************************");
+ printf("*************************************\n\r\n");
+
+ status = remoteproc_init( (void *) firmware_name ,rpmsg_channel_created, rpmsg_channel_deleted, rpmsg_read_default_cb, &proc);
+
+ if (status)
+ {
+ printf( "\r\n CRITICAL ERROR: remoteproc_init call for remote context %s failed \r\n", firmware_name);
+
+ return -1;
+ }
+
+ status = remoteproc_boot( proc );
+
+ if (status)
+ {
+ printf( "\r\n CRITICAL ERROR: remoteproc_boot call for remote context %s failed \r\n", firmware_name);
+
+ return -1;
+ }
+
+ /* Wait for channel creation event */
+ NU_Obtain_Semaphore( &App_Sem , NU_SUSPEND );
+
+ /* Obtain remote firmware name */
+ NU_System_Memory_Get(NU_NULL, &sys_pool_ptr);
+ status = NU_Allocate_Memory(sys_pool_ptr , (void **)&(cmd), sizeof(struct command), NU_SUSPEND);
+ cmd->comm_start=CMD_START;
+ cmd->comm_code = QUERY_FW_NAME;
+ status = rpmsg_send(app_rp_chnl, cmd, sizeof(struct command));
+ NU_Deallocate_Memory(cmd);
+
+ /* Wait to receive firmware name */
+ NU_Obtain_Semaphore( &App_Sem , NU_SUSPEND );
+
+ printf("\r\nREMOTE FIRMWARE NAME : %s \r\n", (char*)r_payload);
+
+ /* Test rpmsg_send API */
+ status = test_rpmsg_send(app_rp_chnl);
+
+ if(!status)
+ {
+ printf( "\r\nRESULT: PASSED \r\n" );
+ }
+ else
+ {
+ printf( "\r\nRESULT: FAILED \r\n" );
+ }
+
+ /* Test rpmsg_send_offchannel API. */
+ status = test_rpmsg_send_offchannel(app_rp_chnl, rp_ept1->addr, app_rp_chnl->dst);
+
+ if(!status)
+ {
+ printf( "\r\nRESULT: PASSED \r\n" );
+ }
+ else
+ {
+ printf( "\r\nRESULT: FAILED \r\n" );
+ }
+
+ status = test_rpmsg_create_ept(app_rp_chnl);
+
+ if(!status)
+ {
+ printf( "\r\nRESULT: PASSED \r\n" );
+ }
+ else
+ {
+ printf( "\r\nRESULT: FAILED \r\n" );
+ }
+
+ printf("\n\n\r************************************");
+ printf("*******************************************\r\n");
+ printf(" This test case will test channel deletion \r\n");
+ printf("******************************************");
+ printf("*************************************\r\n\n");
+
+ status = test_rpmsg_remote_channel_deletion(app_rp_chnl, default_channel);
+
+ if(!status)
+ {
+ printf( "\r\nRESULT: PASSED \r\n" );
+ }
+ else
+ {
+ printf( "\r\nRESULT: FAILED \r\n" );
+ }
+
+ printf("\n\n\r************************************");
+ printf("*******************************************\r\n");
+ printf( "\r\n\nShutdown remote context : %s \r\n" , firmware_name );
+ printf("******************************************");
+ printf("*************************************\r\n\n");
+
+ status = remoteproc_shutdown(proc);
+ if(!status)
+ {
+ status = remoteproc_deinit(proc);
+ }
+
+ if(!status)
+ {
+ status = test_remoteproc_multiple_lifecycles(firmware_name);
+ }
+
+ if(!status)
+ {
+ printf( "\r\nRESULT: PASSED \r\n" );
+ }
+ else
+ {
+ printf( "\r\nRESULT: FAILED \r\n" );
+ }
+
+ printf("\r\nFUNCTIONAL TEST SUITE COMPLETED EXECUTION! \r\n");
+
+ return status;
+}
+
+int test_remoteproc_multiple_lifecycles(char * firmware_name)
+{
+ int i, status;
+ struct remote_proc *proc;
+
+ printf("\n\n\r************************************");
+ printf("*******************************************\r\n");
+ printf(" This test case will test multiple lifecycles for firmware: %s \r\n", firmware_name);
+ printf("******************************************");
+ printf("*************************************\r\n\n");
+
+ for(i = 0; i < 10; i++)
+ {
+ status = remoteproc_init( (void *) firmware_name ,rpmsg_channel_created, rpmsg_channel_deleted, rpmsg_read_default_cb, &proc);
+
+ if (status)
+ {
+ printf( "\r\n ERROR: remoteproc_init failed\r\n");
+
+ break;
+ }
+
+ printf("\n\n\r************************************");
+ printf("*******************************************\r\n");
+ printf( "\r\n\nBoot remote context : %s \r\n" , firmware_name );
+ printf("******************************************");
+ printf("*************************************\r\n\n");
+
+ status = remoteproc_boot( proc );
+
+ if (status)
+ {
+ printf( "\r\n ERROR: remoteproc_boot failed\r\n");
+
+ break;
+ }
+
+ /* Wait for channel creation event */
+ status = NU_Obtain_Semaphore( &App_Sem , NU_SUSPEND );
+
+ if (!status)
+ {
+ status = test_rpmsg_send_impl(app_rp_chnl);
+ }
+
+ if(!status){
+ test_rpmsg_remote_channel_deletion(app_rp_chnl , app_rp_chnl->name);
+ }
+
+ printf("\n\n\r************************************");
+ printf("*******************************************\r\n");
+ printf( "\r\n\nShutdown remote context : %s \r\n" , firmware_name );
+ printf("******************************************");
+ printf("*************************************\r\n\n");
+
+ if (!status)
+ {
+ status = remoteproc_shutdown(proc);
+ }
+ if (status)
+ {
+ printf( "\r\n ERROR: remoteproc_shutdown failed\r\n");
+
+ break;
+ }
+ status = remoteproc_deinit(proc);
+
+ if (status)
+ {
+ printf( "\r\n ERROR: remoteproc_deinit failed\r\n");
+
+ break;
+ }
+
+ printf("%s", display_string);
+
+ }
+
+ return status;
+}
+
+int test_rpmsg_remote_channel_deletion(struct rpmsg_channel *rpmsg_chnl, char *channel_name)
+{
+ struct command *cmd;
+ int status;
+ NU_MEMORY_POOL *sys_pool_ptr;
+ struct chnl_cmd_data *chnl_data;
+
+ NU_System_Memory_Get(NU_NULL, &sys_pool_ptr);
+
+ status = NU_Allocate_Memory(sys_pool_ptr ,
+ (void **)&(cmd), sizeof(struct command)+ sizeof(struct chnl_cmd_data), NU_SUSPEND);
+
+ cmd->comm_code = DELETE_CHNL;
+ cmd->comm_start = CMD_START;
+
+ chnl_data = (struct chnl_cmd_data *)cmd->data;
+
+ strncpy(chnl_data->name , channel_name, sizeof(struct chnl_cmd_data));
+
+ /* Let the other side that uninit its resources */
+ status = rpmsg_send( rpmsg_chnl , cmd , sizeof(struct command) + sizeof(struct chnl_cmd_data) );
+ if(status)
+ {
+ return status;
+ }
+ /* Wait for echo back */
+ status = NU_Obtain_Semaphore( &App_Sem , NU_SUSPEND);
+ /* Wait for channel deletion event */
+ status = NU_Obtain_Semaphore( &Remote_Del_Sem , NU_SUSPEND);
+
+ return status;
+}
+
+int test_rpmsg_create_ept(struct rpmsg_channel *rpmsg_chnl)
+{
+ struct command *cmd;
+ int status, i;
+ struct ept_cmd_data *ept_data;
+ NU_MEMORY_POOL *sys_pool_ptr;
+ struct rpmsg_endpoint *test_ept[NUM_TEST_EPS];
+
+ NU_System_Memory_Get(NU_NULL, &sys_pool_ptr);
+
+ status = NU_Allocate_Memory(sys_pool_ptr ,
+ (void **)&(cmd), sizeof(struct command) + sizeof(struct ept_cmd_data), NU_SUSPEND);
+
+ if(status != NU_SUCCESS)
+ {
+ return status;
+ }
+ printf("\n\n\r************************************");
+ printf("*******************************************\r\n");
+ printf(" This test case will test rpmsg_create_ept API \r\n");
+ printf("******************************************");
+ printf("*************************************\r\n\n");
+
+ for(i = 0; i < NUM_TEST_EPS; i++)
+ {
+ /* Tell the remote to create a new endpoint. */
+ cmd->comm_code = CREATE_EPT;
+ cmd->comm_start = CMD_START;
+
+ /* Send create endpoint command to remote */
+ ept_data = (struct ept_cmd_data *)cmd->data;
+ ept_data->dst= EPT_TEST_ADDR + i;
+ ept_data->src= EPT_TEST_ADDR + i;
+
+ /* Let the other side know that it needs to create endpoint with the given address */
+ status = rpmsg_send(rpmsg_chnl, cmd, sizeof(struct command) + sizeof(struct ept_cmd_data));
+
+ if(!status)
+ {
+ /* Wait for ack */
+ status = NU_Obtain_Semaphore(&App_Sem , NU_SUSPEND);
+ }
+
+ if(!status)
+ {
+ printf("\r\nCreating an endpoint at address: %d \r\n", EPT_TEST_ADDR + i);
+
+ test_ept[i] = rpmsg_create_ept(rpmsg_chnl , rpmsg_read_ept2_cb , RPMSG_NULL , EPT_TEST_ADDR + i);
+
+ if ( !test_ept[i] )
+ {
+ status = -1;
+
+ printf("\r\n ERROR: rpmsg_create_ept API failed for endpoint address: %d \r\n", EPT_TEST_ADDR + i);
+ }
+
+ }
+ if(!status)
+ {
+ printf("\r\nTesting payloads on endpoint at address: %d \r\n", EPT_TEST_ADDR + i);
+
+ status = test_rpmsg_send_offchannel_impl(rpmsg_chnl, test_ept[i]->addr, test_ept[i]->addr);
+ }
+
+ if(!status)
+ {
+ /* Tell the remote to delete the endpoint. */
+ cmd->comm_code = DELETE_EPT;
+ cmd->comm_start = CMD_START;
+ /* Send delete endpoint command to remote */
+ ept_data = (struct ept_cmd_data *)cmd->data;
+ ept_data->dst= EPT_TEST_ADDR + i;
+ ept_data->src= EPT_TEST_ADDR + i;
+
+ /* Let the other side know that it needs to delete endpoint with the given address */
+ status = rpmsg_send(rpmsg_chnl, cmd, sizeof(struct command) + sizeof(struct ept_cmd_data));
+ }
+
+ if(!status)
+ {
+ /* Wait for ack */
+ status = NU_Obtain_Semaphore(&App_Sem , NU_SUSPEND);
+ }
+
+ if(!status)
+ {
+ rpmsg_destroy_ept(test_ept[i]);
+ }
+ }
+
+ NU_Deallocate_Memory(cmd);
+ if(status)
+ while(1);
+
+ return status;
+}
+
+int test_rpmsg_send_impl(struct rpmsg_channel *rpmsg_chnl)
+{
+ struct command cmd;
+ int status;
+ int i, size, idx;
+ NU_MEMORY_POOL *sys_pool_ptr;
+
+ NU_System_Memory_Get(NU_NULL, &sys_pool_ptr);
+ /* Tell the remote to be prepared for echo payloads. */
+ cmd.comm_start = CMD_START;
+ cmd.comm_code = START_ECHO;
+
+ status = rpmsg_send(rpmsg_chnl, &cmd, sizeof(struct command));
+
+ if(!status)
+ {
+ /* Wait for cmd ack. */
+ status = NU_Obtain_Semaphore(&App_Sem , NU_SUSPEND);
+ if(status)
+ while(1);
+
+ printf("\r\nTransmitting paylaods to remote \r\n");
+
+ for(i = 0, size=PAYLOAD_MIN_SIZE; i < NUM_PAYLOADS; i++, size++)
+ {
+ NU_Allocate_Memory(sys_pool_ptr , (void**)&p_payload, sizeof(struct _payload) + size , NU_SUSPEND );
+
+ p_payload->num = i;
+ p_payload->size = size;
+
+ /* Setup the buffer with a pattern*/
+ memset(p_payload->data, 0xA5, size);
+
+ /* Send data to remote side. */
+ status = rpmsg_send(rpmsg_chnl, p_payload, sizeof(struct _payload) + size);
+
+ if(status != 0)
+ {
+ break;
+ }
+
+ /* Wait for echo. */
+ status = NU_Obtain_Semaphore(&App_Sem , NU_SUSPEND);
+
+ /* Validate the data integrity. */
+ for(idx = 0; idx < r_payload->size; idx++)
+ {
+ if(p_payload->data[idx] != r_payload->data[idx])
+ {
+ status = -1;
+ break;
+ }
+ }
+
+ if(status != 0)
+ {
+ break;
+ }
+
+ NU_Deallocate_Memory(p_payload);
+ printf("%s", display_string);
+ }
+ if(status)
+ while(1);
+ cmd.comm_start = CMD_START;
+ cmd.comm_code = STOP_ECHO;
+
+ status = rpmsg_send(rpmsg_chnl, &cmd, sizeof(struct command));
+ if(status)
+ while(1);
+
+ /* Wait for echo. */
+ status = NU_Obtain_Semaphore(&App_Sem , NU_SUSPEND);
+ if(status)
+ while(1);
+ }
+
+
+ return status;
+}
+int test_rpmsg_send(struct rpmsg_channel *rpmsg_chnl)
+{
+ printf("\n\n\r************************************");
+ printf("*******************************************\r\n");
+ printf(" This test case will test rpmsg_send API \r\n");
+ printf("******************************************");
+ printf("*************************************\r\n\n");
+
+ return test_rpmsg_send_impl(rpmsg_chnl);
+}
+
+int test_rpmsg_send_offchannel_impl(struct rpmsg_channel *rpmsg_chnl, unsigned long src, unsigned long dst)
+{
+ struct command cmd;
+ int status;
+ int i, size, idx;
+ NU_MEMORY_POOL *sys_pool_ptr;
+ NU_System_Memory_Get(NU_NULL, &sys_pool_ptr);
+
+ /* Tell the remote to be prepared for echo payloads. */
+ cmd.comm_code = START_ECHO;
+ cmd.comm_start = CMD_START;
+ status = rpmsg_send(rpmsg_chnl, &cmd, sizeof(struct command));
+
+ if(!status)
+ {
+ /* Wait for cmd ack. */
+ status = NU_Obtain_Semaphore(&App_Sem , NU_SUSPEND);
+ if(status)
+ while(1);
+
+ for(i = 0, size=PAYLOAD_MIN_SIZE; i < NUM_PAYLOADS; i++, size++)
+ {
+ NU_Allocate_Memory(sys_pool_ptr , (void**)&p_payload, sizeof(struct _payload) + size , NU_SUSPEND );
+ p_payload->num = i;
+ p_payload->size = size;
+
+ /* Setup the buffer with a pattern*/
+ memset(p_payload->data, 0xA5, size);
+
+ /* Send data to remote side. */
+ status = rpmsg_send_offchannel(app_rp_chnl, src, dst, p_payload ,
+ sizeof(struct _payload) + size);
+
+ if(status)
+ {
+ break;
+ }
+
+ /* Wait for echo. */
+ status = NU_Obtain_Semaphore(&App_Sem , NU_SUSPEND);
+
+ /* Validate the data integrity. */
+ for(idx = 0; idx < r_payload->size; idx++)
+ {
+ if(p_payload->data[idx] != r_payload->data[idx])
+ {
+ status = -1;
+ break;
+ }
+ }
+
+ if(status)
+ {
+ break;
+ }
+
+ printf("%s", display_string);
+ NU_Deallocate_Memory(p_payload);
+ }
+ cmd.comm_start = CMD_START;
+ cmd.comm_code = STOP_ECHO;
+
+ status = rpmsg_send(rpmsg_chnl, &cmd, sizeof(struct command));
+ /* Wait for cmd ack. */
+ status = NU_Obtain_Semaphore(&App_Sem , NU_SUSPEND);
+ if(status)
+ while(1);
+ }
+
+ return status;
+}
+
+int test_rpmsg_send_offchannel(struct rpmsg_channel *rpmsg_chnl, unsigned long src, unsigned long dst)
+{
+ printf("\n\n\r************************************");
+ printf("*******************************************\r\n");
+ printf(" This test case will test rpmsg_send_offchannel API \r\n");
+ printf("******************************************");
+ printf("*************************************\r\n\n");
+
+ return test_rpmsg_send_offchannel_impl(rpmsg_chnl, src, dst);
+}
diff --git a/apps/tests/master/nucleus/func_test_suite/nucleus_nucleusbm/make b/apps/tests/master/nucleus/func_test_suite/nucleus_nucleusbm/make
--- /dev/null
@@ -0,0 +1,52 @@
+
+include ../Makefile.commons
+
+SAMPLE_OUT := tests/master/nucleus/func_test_suite/nucleus_nucleusbm/func_test_suite.out
+SAMPLE_C_SRC := tests/master/nucleus/func_test_suite/nucleus_nucleusbm/func_test_suite.c
+REMOTE_OUT := func_test_suite.out
+DST_DIR := tests/master/nucleus/func_test_suite/nucleus_nucleusbm
+NU_SRC_DIR := firmware/zc702evk/nucleus/func_test_suite
+BM_SRC_DIR := firmware/zc702evk/baremetal/func_test_suite
+
+SAMPLEOBJFILES := $(patsubst %.c, %.o, $(SAMPLE_C_SRC))
+SAMPLE_DEPS := $(patsubst %.c, %.d, $(SAMPLE_C_SRC))
+SAMPLE_MAP := $(patsubst %.out, %.map, $(SAMPLE_OUT))
+SAMPLE_BIN := $(patsubst %.out, %.bin, $(SAMPLE_OUT))
+
+$(SAMPLE_OUT): $(REMOTE_OUT)$(SAMPLEOBJFILES)
+
+ @echo 'Building func_test_suite test for nucleus : $@'
+
+ $(LD) -Wl,-Map=tests/master/nucleus/func_test_suite/nucleus_nucleusbm/func_test_suite.map -nostartfiles -Wl,--gc-sections -Wl,--wrap=malloc -Wl,--wrap=calloc -Wl,--wrap=realloc -Wl,--wrap=free -T"$(OHOME)/libs/system/$(PLAT)/nucleus/linker_master.ld" -L"$(OHOME)/libs/system/$(PLAT)/nucleus/lib/$(CROSS)/master" -L"$(OHOME)/libs/open_amp" -o "$(SAMPLE_OUT)" -Wl,--start-group $(SAMPLEOBJFILES) $(DST_DIR)/firmware1.o $(DST_DIR)/firmware2.o -lnucleus_master -lopen_amp -lc -lm -lstdc++ -Wl,--end-group
+
+ $(OBJCPY) -O binary $(SAMPLE_OUT) $(SAMPLE_BIN)
+
+ @echo 'Finished building target: $@'
+
+%.o:%.c
+ @echo CC $(<:.c=.o)
+ @$(CC) $(CFLAGS) $(ARCH_CFLAGS) $(INCLUDE) -c $< -o $@
+
+%.o:%.S
+ @$(AS) -c -mcpu=cortex-a9 $(ARCH_ASFLAGS) $(INCLUDE) $< -o $@
+
+$(REMOTE_OUT):
+ cd $(NU_SRC_DIR)/; cp firmware firmware1; \
+ $(OBJCPY) -I binary -O elf32-littlearm -B arm firmware1 firmware1.o
+ mv $(NU_SRC_DIR)/firmware1.o $(DST_DIR)/
+ cd $(BM_SRC_DIR)/; cp firmware firmware2; \
+ $(OBJCPY) -I binary -O elf32-littlearm -B arm firmware2 firmware2.o
+ mv $(BM_SRC_DIR)/firmware2.o $(DST_DIR)/
+ cd $(NU_SRC_DIR)/; rm firmware1
+ cd $(BM_SRC_DIR)/; rm firmware2
+
+clean:
+ -$(RM) $(SAMPLEOBJFILES) $(SAMPLE_DEPS) $(SAMPLE_OUT) $(DST_DIR)/firmware1.o $(DST_DIR)/firmware2.o $(SAMPLE_MAP) $(SAMPLE_BIN)
+
+post-build:
+ -@echo ' '
+
+secondary-outputs:
+
+PHONY: all clean dependents
+.SECONDARY: post-build
diff --git a/apps/tests/master/nucleus/func_test_suite/nucleus_nucleusbm/test_suite.h b/apps/tests/master/nucleus/func_test_suite/nucleus_nucleusbm/test_suite.h
--- /dev/null
@@ -0,0 +1,66 @@
+/*
+ * m_ept_func_test.h
+ *
+ * Created on: Mar 14, 2014
+ * Author: etsam
+ */
+
+#ifndef M_EPT_FUNC_TEST_H_
+#define M_EPT_FUNC_TEST_H_
+
+struct command
+{
+ unsigned int comm_start;
+ unsigned int comm_code;
+ char data[0];
+}__attribute__((__packed__));
+
+struct ept_cmd_data
+{
+ unsigned int src;
+ unsigned int dst;
+};
+
+struct chnl_cmd_data
+{
+ char name[32];
+};
+
+/* Command Codes */
+
+#define CREATE_EPT 0x00000000
+#define DELETE_EPT 0x00000001
+#define CREATE_CHNL 0x00000002
+#define DELETE_CHNL 0x00000003
+#define START_ECHO 0x00000004
+#define STOP_ECHO 0x00000005
+#define QUERY_FW_NAME 0x00000006
+
+#define CMD_START 0xEF56A55A
+
+/* Define the main task's stack size */
+#define STACK_SIZE (NU_MIN_STACK_SIZE * 400)
+
+/* Define the main task's priority */
+#define TASK_PRIORITY 26
+
+/* Define the main task's time slice */
+#define TASK_SLICE 20
+
+#define EPT_TEST_ADDR 59
+
+#define NUM_TEST_EPS 4
+
+#define MAX_RPMSG_BUFF_SIZE 512
+#define PAYLOAD_MIN_SIZE 1
+#define PAYLOAD_MAX_SIZE (MAX_RPMSG_BUFF_SIZE - 24)
+#define NUM_PAYLOADS (PAYLOAD_MAX_SIZE/PAYLOAD_MIN_SIZE)
+
+struct _payload {
+ unsigned long num;
+ unsigned long size;
+ char data[0];
+}__attribute__((__packed__));
+
+
+#endif /* M_EPT_FUNC_TEST_H_ */
diff --git a/apps/tests/master/nucleus/latency_test/nucleus_linux/latency_test.c b/apps/tests/master/nucleus/latency_test/nucleus_linux/latency_test.c
--- /dev/null
@@ -0,0 +1,249 @@
+/* This is a test demonstration application that mesaures performance of remoteproc
+and rpmsg APIs. This application is meant to run on the master CPU running Nucleus
+and showcases booting of two sub-sequent remote firmware cycles using remoteproc and
+IPC with remote firmware using rpmsg; It brings up a remote linux based remote
+firmware which can respond to test calls. Master app executes tests to caluclate the performance
+of the rpmsg and remoteproc APIs and shutsdown the core once the test has been completed.*/
+
+/* Including required headers */
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include "open_amp.h"
+#include "nucleus.h"
+#include "kernel/nu_kernel.h"
+
+/* Define the main task's stack size */
+#define STACK_SIZE (NU_MIN_STACK_SIZE * 64)
+
+/* Define the main task's priority */
+#define TASK_PRIORITY 26
+
+/* Define the main task's time slice */
+#define TASK_SLICE 20
+
+#define MAX_RPMSG_BUFF_SIZE 512
+#define PAYLOAD_MIN_SIZE 1
+#define PAYLOAD_MAX_SIZE (MAX_RPMSG_BUFF_SIZE - 24)
+#define NUM_PAYLOADS (PAYLOAD_MAX_SIZE/PAYLOAD_MIN_SIZE)
+
+struct _payload {
+ unsigned long num;
+ unsigned long size;
+ char data[];
+};
+
+/* Prototypes */
+static void Main_Task_Entry( UNSIGNED argc , VOID *argv );
+
+/* Application provided callbacks */
+void rpmsg_channel_created( struct rpmsg_channel *rp_chnl );
+void rpmsg_channel_deleted( struct rpmsg_channel *rp_chnl );
+void rpmsg_read_cb( struct rpmsg_channel *rp_chnl , void *data , int len , void * pric , unsigned long src );
+
+/* Globals */
+NU_TASK Task_Control_Block;
+NU_SEMAPHORE App_Sem;
+struct rpmsg_endpoint *rp_ept;
+struct rpmsg_channel *app_rp_chnl;
+
+char fw_name1 []= "firmware1";
+
+struct _payload* p_payload = NULL;
+struct _payload* r_payload = NULL;
+
+UINT64 time_start, time_end;
+UINT64 fw1_average_rtt, fw2_average_rtt;
+UINT64 fw1_boot_time, fw2_boot_time;
+UINT64 fw1_shutdown_time, fw2_shutdown_time;
+
+UINT64 payload_roundtrip_time[NUM_PAYLOADS];
+
+extern unsigned long long boot_time_stamp;
+extern unsigned long long shutdown_time_stamp;
+
+/***********************************************************************
+ * *
+ * * FUNCTION
+ * *
+ * * Application_Initialize
+ * *
+ * * DESCRIPTION
+ * *
+ * * Demo application entry point
+ *
+ * ***********************************************************************/
+VOID Application_Initialize(NU_MEMORY_POOL* mem_pool , NU_MEMORY_POOL* uncached_mem_pool)
+{
+ VOID *pointer;
+ STATUS status = NU_SUCCESS;
+
+ /* Reference unused parameters to avoid toolset warnings */
+ NU_UNUSED_PARAM( uncached_mem_pool );
+
+ if (status == NU_SUCCESS)
+ {
+ status = NU_Allocate_Memory(mem_pool, &pointer, STACK_SIZE, NU_NO_SUSPEND);
+
+ /* Create the main task for matrix processing */
+ if ( status == NU_SUCCESS )
+ {
+ status = NU_Create_Task( &Task_Control_Block , "MAIN" , Main_Task_Entry , 0 ,
+ uncached_mem_pool , pointer , STACK_SIZE ,
+ TASK_PRIORITY , TASK_SLICE , NU_PREEMPT , NU_START );
+ }
+ if(status == NU_SUCCESS)
+ {
+ status = NU_Create_Semaphore(&App_Sem ,"APP_SEM", 0, NU_FIFO);
+ }
+ }
+
+ /* Check to see if previous operations were successful */
+ if ( status != NU_SUCCESS )
+ {
+ /* Loop forever */
+ while ( 1 );
+ }
+}
+
+/***********************************************************************
+ * *
+ * * FUNCTION
+ * *
+ * * Main_Task_Entry
+ * *
+ * * DESCRIPTION
+ * *
+ * * Entry function for the main task. This task prints a hello world
+ * * message.
+ * *
+ * ***********************************************************************/
+static VOID Main_Task_Entry( UNSIGNED argc , VOID *argv )
+{
+ struct remote_proc *proc;
+ int i, size, status;
+ NU_MEMORY_POOL *sys_pool_ptr;
+
+ NU_System_Memory_Get(&sys_pool_ptr, NU_NULL);
+
+ printf("\r\n\nExecuting tests for remote context : %s. It corresponds to Linux remote firmware \r\n" , fw_name1);
+
+ /* Allocate memory for Rx buffer. */
+ NU_Allocate_Memory(sys_pool_ptr, (VOID **)&r_payload, (2 * sizeof(unsigned long) + PAYLOAD_MAX_SIZE), NU_NO_SUSPEND);
+
+ /* Initialize remoteproc for first firmware. */
+ status = remoteproc_init((void *) fw_name1, rpmsg_channel_created, rpmsg_channel_deleted, rpmsg_read_cb, &proc);
+
+ if(!status && (proc))
+ {
+ /* Note time stamp. */
+ time_start = NU_Get_Time_Stamp();
+
+ /* Boot firmware 1. */
+ status = remoteproc_boot(proc);
+ }
+
+ if(!status)
+ {
+ /* Firmware 1 boot time. */
+ fw1_boot_time = boot_time_stamp - time_start;
+
+ /* Wait for channel creation complete callback. */
+ NU_Obtain_Semaphore(&App_Sem, NU_SUSPEND);
+
+ /* Send paylaods of incremental data sizes. */
+ for(i = 0, size=PAYLOAD_MIN_SIZE; i < NUM_PAYLOADS; i++, size++)
+ {
+ NU_Allocate_Memory(sys_pool_ptr, (VOID **)&p_payload, (2 * sizeof(unsigned long) + size), NU_NO_SUSPEND);
+
+ /* Setup payload size and properties. */
+ p_payload->num = i;
+ p_payload->size = size;
+
+ /* Setup the buffer with a pattern*/
+ memset(&(p_payload->data[0]), 0xA5, size);
+
+ time_start = NU_Get_Time_Stamp();
+
+ /* Send data to remote side. */
+ rpmsg_send(app_rp_chnl, p_payload, (2 * sizeof(unsigned long)) + size);
+
+ /* Wait for echo. */
+ NU_Obtain_Semaphore(&App_Sem , NU_SUSPEND);
+
+ NU_Deallocate_Memory(p_payload);
+
+ /* Save payload round-trip time.*/
+ payload_roundtrip_time[i] = time_end - time_start;
+ }
+
+ /* Average out the payload round-trip time. */
+ for(i =0; i<NUM_PAYLOADS; i++)
+ {
+ fw1_average_rtt += payload_roundtrip_time[i];
+ }
+
+ fw1_average_rtt = fw1_average_rtt / NUM_PAYLOADS;
+
+ time_start = NU_Get_Time_Stamp();
+
+ remoteproc_shutdown(proc);
+
+ fw1_shutdown_time = shutdown_time_stamp - time_start;
+
+ remoteproc_deinit(proc);
+ }
+ else
+ {
+ printf("\r\n\nLoading remote context: %s failed \r\n" , fw_name1);
+ }
+
+ /* Convert the values into nano-seconds. */
+ fw1_average_rtt = (fw1_average_rtt * 1000000000)/ (NU_HW_Ticks_Per_SW_Tick * NU_PLUS_TICKS_PER_SEC);
+ fw1_boot_time = (fw1_boot_time * 1000000000) / (NU_HW_Ticks_Per_SW_Tick * NU_PLUS_TICKS_PER_SEC);
+ fw1_shutdown_time = (fw1_shutdown_time * 1000000000)/ (NU_HW_Ticks_Per_SW_Tick * NU_PLUS_TICKS_PER_SEC);
+ fw2_average_rtt = (fw2_average_rtt * 1000000000)/ (NU_HW_Ticks_Per_SW_Tick * NU_PLUS_TICKS_PER_SEC);
+ fw2_boot_time = (fw2_boot_time * 1000000000) / (NU_HW_Ticks_Per_SW_Tick * NU_PLUS_TICKS_PER_SEC);
+ fw2_shutdown_time = (fw2_shutdown_time * 1000000000)/ (NU_HW_Ticks_Per_SW_Tick * NU_PLUS_TICKS_PER_SEC);
+
+ printf("\r\n **************************************** \r\n");
+ printf(" OpenAMP Latency Test Results \r\n");
+ printf(" **************************************** \r\n");
+
+ printf("\r\n Nucleus Remote: Average rpmsg_send API Round-Trip: %d ns\r\n", (int)fw1_average_rtt);
+ printf("\r\n Nucleus Remote: remoteproc_boot API: %d ns\r\n", (int)fw1_boot_time);
+ printf("\r\n Nucleus Remote: remoteproc_shutdown API: %d ns\r\n", (int)fw1_shutdown_time);
+
+ printf("\r\n Baremetal Remote: Average rpmsg_send API Round-Trip: %d ns\r\n", (int)fw2_average_rtt);
+ printf("\r\n Baremetal Remote: remoteproc_boot API: %d ns\r\n", (int)fw2_boot_time);
+ printf("\r\n Baremetal Remote: remoteproc_shutdown API: %d ns\r\n", (int)fw2_shutdown_time);
+}
+
+/* This callback gets invoked when the remote channel is created */
+void rpmsg_channel_created(struct rpmsg_channel *rp_chnl)
+{
+ app_rp_chnl = rp_chnl;
+
+ rp_ept = rpmsg_create_ept(rp_chnl , rpmsg_read_cb ,RPMSG_NULL , RPMSG_ADDR_ANY);
+
+ NU_Release_Semaphore(&App_Sem);
+}
+
+/* This callback gets invoked when the remote channel is deleted */
+void rpmsg_channel_deleted(struct rpmsg_channel *rp_chnl)
+{
+ rpmsg_destroy_ept(rp_ept);
+}
+
+/* This is the read callback, note we are in a task context when this callback
+is invoked, so kernel primitives can be used freely */
+void rpmsg_read_cb(struct rpmsg_channel *rp_chnl, void *data, int len,
+ void * priv, unsigned long src)
+{
+ time_end = NU_Get_Time_Stamp();
+
+ memcpy(r_payload,data,len);
+
+ NU_Release_Semaphore(&App_Sem);
+}
+
diff --git a/apps/tests/master/nucleus/latency_test/nucleus_linux/make b/apps/tests/master/nucleus/latency_test/nucleus_linux/make
--- /dev/null
@@ -0,0 +1,49 @@
+
+include ../Makefile.commons
+
+SAMPLE_OUT := tests/master/nucleus/latency_test/nucleus_linux/latency_test.out
+SAMPLE_C_SRC := tests/master/nucleus/latency_test/nucleus_linux/latency_test.c
+REMOTE_OUT := latency_test.out
+DST_DIR := tests/master/nucleus/latency_test/nucleus_linux
+LINUX_SRC_DIR := firmware/$(PLAT)/linux
+
+SAMPLEOBJFILES := $(patsubst %.c, %.o, $(SAMPLE_C_SRC))
+SAMPLE_DEPS := $(patsubst %.c, %.d, $(SAMPLE_C_SRC))
+SAMPLE_MAP := $(patsubst %.out, %.map, $(SAMPLE_OUT))
+SAMPLE_BIN := $(patsubst %.out, %.bin, $(SAMPLE_OUT))
+
+$(SAMPLE_OUT): $(REMOTE_OUT)$(SAMPLEOBJFILES)
+
+ @echo 'Building latency test for nucleus : $@'
+
+ $(LD) -Wl,-Map=tests/master/nucleus/latency_test/nucleus_linux/latency_test.map -nostartfiles -Wl,--gc-sections -Wl,--wrap=malloc -Wl,--wrap=calloc -Wl,--wrap=realloc -Wl,--wrap=free -T"$(OHOME)/libs/system/$(PLAT)/nucleus/linker_master.ld" -L"$(OHOME)/libs/system/$(PLAT)/nucleus/lib/$(CROSS)/master" -L"$(OHOME)/libs/open_amp" -o "$(SAMPLE_OUT)" -Wl,--start-group $(SAMPLEOBJFILES) $(DST_DIR)/firmware1.o $(DST_DIR)/firmware2.o -lnucleus_master -lopen_amp -lc -lm -lstdc++ -Wl,--end-group
+
+ $(OBJCPY) -O binary $(SAMPLE_OUT) $(SAMPLE_BIN)
+
+ @echo 'Finished building target: $@'
+
+%.o:%.c
+ @echo CC $(<:.c=.o)
+ @$(CC) $(CFLAGS) $(ARCH_CFLAGS) $(INCLUDE) -c $< -o $@
+
+%.o:%.S
+ @$(AS) -c -mcpu=cortex-a9 $(ARCH_ASFLAGS) $(INCLUDE) $< -o $@
+
+$(REMOTE_OUT):
+ cd $(LINUX_SRC_DIR)/; cp firmware firmware1; \
+ $(OBJCPY) -I binary -O elf32-littlearm -B arm firmware1 firmware1.o
+ mv $(LINUX_SRC_DIR)/firmware1.o $(DST_DIR)/firmware1.o
+ cd $(LINUX_SRC_DIR)/; cp firmware firmware2; \
+ $(OBJCPY) -I binary -O elf32-littlearm -B arm firmware2 firmware2.o
+ mv $(LINUX_SRC_DIR)/firmware2.o $(DST_DIR)/
+ cd $(LINUX_SRC_DIR)/; rm firmware1; rm firmware2;
+clean:
+ -$(RM) $(SAMPLEOBJFILES) $(SAMPLE_DEPS) $(SAMPLE_OUT) $(SAMPLE_BIN) $(DST_DIR)/firmware1.o $(DST_DIR)/firmware2.o $(SAMPLE_MAP)
+
+post-build:
+ -@echo ' '
+
+secondary-outputs:
+
+PHONY: all clean dependents
+.SECONDARY: post-build
diff --git a/apps/tests/master/nucleus/latency_test/nucleus_nucleusbm/latency_test.c b/apps/tests/master/nucleus/latency_test/nucleus_nucleusbm/latency_test.c
--- /dev/null
@@ -0,0 +1,358 @@
+/* This is a test demonstration application that tests performance of remoteproc
+and rpmsg APIs. This application is meant to run on the master CPU running Nucleus
+and showcases booting of two sub-sequent remote firmware cycles using remoteproc and
+IPC with remote firmware using rpmsg; 1. It brings up a remote Nucleus based remote
+firmware which can respond to test calls, 2. It brings up a baremetal based
+remote firmware which can respond to test calls. Master app executes tests to measure
+performance of the rpmsg and remote proc APIs and shutsdown the core once the test has
+been completed.*/
+
+/* Including required headers */
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include "open_amp.h"
+#include "nucleus.h"
+#include "kernel/nu_kernel.h"
+
+/* Define the main task's stack size */
+#define STACK_SIZE (NU_MIN_STACK_SIZE * 64)
+
+/* Define the main task's priority */
+#define TASK_PRIORITY 26
+
+/* Define the main task's time slice */
+#define TASK_SLICE 20
+
+#define MAX_RPMSG_BUFF_SIZE 512
+#define PAYLOAD_MIN_SIZE 1
+#define PAYLOAD_MAX_SIZE (MAX_RPMSG_BUFF_SIZE - 24)
+#define NUM_PAYLOADS (PAYLOAD_MAX_SIZE/PAYLOAD_MIN_SIZE)
+#define SHUTDOWN_MSG 0xEF56A55A
+struct _payload {
+ unsigned long num;
+ unsigned long size;
+ char data[];
+};
+
+/* Prototypes */
+static void Main_Task_Entry( UNSIGNED argc , VOID *argv );
+
+/* Application provided callbacks */
+void rpmsg_channel_created( struct rpmsg_channel *rp_chnl );
+void rpmsg_channel_deleted( struct rpmsg_channel *rp_chnl );
+void rpmsg_read_cb( struct rpmsg_channel *rp_chnl , void *data , int len , void * pric , unsigned long src );
+
+/* Globals */
+NU_TASK Task_Control_Block;
+NU_SEMAPHORE App_Sem;
+struct rpmsg_endpoint *rp_ept;
+struct rpmsg_channel *app_rp_chnl;
+
+char fw_name1 []= "firmware1";
+char fw_name2 []= "firmware2";
+
+struct _payload* p_payload = NULL;
+struct _payload* r_payload = NULL;
+
+UINT64 time_start, time_end;
+UINT64 fw1_average_rtt = 0, fw2_average_rtt = 0;
+UINT64 fw1_boot_time = 0, fw2_boot_time = 0;
+UINT64 fw1_shutdown_time =0, fw2_shutdown_time =0;
+
+UINT64 payload_roundtrip_time[NUM_PAYLOADS];
+
+extern unsigned long long boot_time_stamp;
+extern unsigned long long shutdown_time_stamp;
+
+/***********************************************************************
+ * *
+ * * FUNCTION
+ * *
+ * * Application_Initialize
+ * *
+ * * DESCRIPTION
+ * *
+ * * Demo application entry point
+ *
+ * ***********************************************************************/
+VOID Application_Initialize(NU_MEMORY_POOL* mem_pool , NU_MEMORY_POOL* uncached_mem_pool)
+{
+ VOID *pointer;
+ STATUS status = NU_SUCCESS;
+
+ /* Reference unused parameters to avoid toolset warnings */
+ NU_UNUSED_PARAM( uncached_mem_pool );
+
+ if (status == NU_SUCCESS)
+ {
+ status = NU_Allocate_Memory(mem_pool, &pointer, STACK_SIZE, NU_NO_SUSPEND);
+
+ /* Create the main task for matrix processing */
+ if ( status == NU_SUCCESS )
+ {
+ status = NU_Create_Task( &Task_Control_Block , "MAIN" , Main_Task_Entry , 0 ,
+ uncached_mem_pool , pointer , STACK_SIZE ,
+ TASK_PRIORITY , TASK_SLICE , NU_PREEMPT , NU_START );
+ }
+ if(status == NU_SUCCESS)
+ {
+ status = NU_Create_Semaphore(&App_Sem ,"APP_SEM", 0, NU_FIFO);
+ }
+ }
+
+ /* Check to see if previous operations were successful */
+ if ( status != NU_SUCCESS )
+ {
+ /* Loop forever */
+ while ( 1 );
+ }
+}
+
+/***********************************************************************
+ * *
+ * * FUNCTION
+ * *
+ * * Main_Task_Entry
+ * *
+ * * DESCRIPTION
+ * *
+ * * Entry function for the main task. This task prints a hello world
+ * * message.
+ * *
+ * ***********************************************************************/
+static VOID Main_Task_Entry( UNSIGNED argc , VOID *argv )
+{
+ struct remote_proc *proc;
+ int idx,i, size;
+ NU_MEMORY_POOL *sys_pool_ptr;
+ STATUS status = NU_SUCCESS;
+ int shutdown_msg = SHUTDOWN_MSG;
+
+ NU_System_Memory_Get(&sys_pool_ptr, NU_NULL);
+
+ printf("\r\n\nExecuting tests for remote context : %s. It corresponds to Nucleus remote firmware \r\n" , fw_name1);
+
+ /* Allocate memory for Rx buffer. */
+ NU_Allocate_Memory(sys_pool_ptr, (VOID **)&r_payload, (2 * sizeof(unsigned long) + PAYLOAD_MAX_SIZE), NU_NO_SUSPEND);
+
+ /* Initialize remoteproc for first firmware. */
+ status = remoteproc_init((void *) fw_name1, rpmsg_channel_created, rpmsg_channel_deleted, rpmsg_read_cb, &proc);
+
+
+ if(!status && (proc))
+ {
+ /* Note time stamp. */
+ time_start = NU_Get_Time_Stamp();
+
+ /* Boot firmware 1. */
+ status = remoteproc_boot(proc);
+ }
+
+ if(!status)
+ {
+ /* Firmware 1 boot time. */
+ fw1_boot_time = boot_time_stamp - time_start;
+
+ /* Wait for channel creation complete callback. */
+ NU_Obtain_Semaphore(&App_Sem, NU_SUSPEND);
+
+ /* Send paylaods of incremental data sizes. */
+ for(i = 0, size=PAYLOAD_MIN_SIZE; i < NUM_PAYLOADS; i++, size++)
+ {
+ NU_Allocate_Memory(sys_pool_ptr, (VOID **)&p_payload, (2 * sizeof(unsigned long) + size), NU_NO_SUSPEND);
+
+ /* Setup payload size and properties. */
+ p_payload->num = i;
+ p_payload->size = size;
+
+ /* Setup the buffer with a pattern*/
+ memset(&(p_payload->data[0]), 0xA5, size);
+
+ time_start = NU_Get_Time_Stamp();
+
+ /* Send data to remote side. */
+ rpmsg_send(app_rp_chnl, p_payload, (2 * sizeof(unsigned long)) + size);
+
+ /* Wait for echo. */
+ NU_Obtain_Semaphore(&App_Sem , NU_SUSPEND);
+
+ /* Validate packet number*/
+ if(p_payload->num != r_payload->num)
+ {
+ printf("\r\nError Echo packet number does not match with transmitted packet number: %d \r\n", (int)p_payload->num);
+ }
+
+ /* Validate the data integrity. */
+ for(idx = 0; idx < r_payload->size; idx++)
+ {
+ if(p_payload->data[idx] != r_payload->data[idx])
+ {
+ printf("\r\nError receiving data packet of size: %d at data index %d \r\n", size, idx);
+ break;
+ }
+ }
+
+ NU_Deallocate_Memory(p_payload);
+
+ /* Save payload round-trip time.*/
+ payload_roundtrip_time[i] = time_end - time_start;
+ }
+
+ /* Average out the payload round-trip time. */
+ for(i =0; i<NUM_PAYLOADS; i++)
+ {
+ fw1_average_rtt += payload_roundtrip_time[i];
+ }
+
+ fw1_average_rtt = fw1_average_rtt / NUM_PAYLOADS;
+
+ /* Send termination message to remote */
+ rpmsg_send(app_rp_chnl, &shutdown_msg, sizeof(int));
+
+ /* Wait for channel deletion callback. */
+ NU_Obtain_Semaphore(&App_Sem , NU_SUSPEND);
+
+ time_start = NU_Get_Time_Stamp();
+
+ remoteproc_shutdown(proc);
+
+ fw1_shutdown_time = shutdown_time_stamp - time_start;
+
+ remoteproc_deinit(proc);
+ }
+ else
+ {
+ printf("\r\n\nLoading remote context: %s failed \r\n" , fw_name1);
+ }
+
+ printf("\r\n\nExecuting tests for remote context : %s. It corresponds to Baremetal remote firmware \r\n" , fw_name2);
+
+ status = remoteproc_init((void *) fw_name2, rpmsg_channel_created, rpmsg_channel_deleted, rpmsg_read_cb, &proc);
+
+ if(!status && (proc))
+ {
+ /* Note time stamp. */
+ time_start = NU_Get_Time_Stamp();
+
+ /* Boot firmware 2. */
+ status = remoteproc_boot(proc);
+
+ }
+
+ if(!status)
+ {
+ fw2_boot_time = boot_time_stamp - time_start;
+
+ NU_Obtain_Semaphore(&App_Sem, NU_SUSPEND);
+
+ for(i = 0, size=PAYLOAD_MIN_SIZE; i < NUM_PAYLOADS; i++, size++)
+ {
+ NU_Allocate_Memory(sys_pool_ptr, (VOID **)&p_payload, (2 * sizeof(unsigned long) + size), NU_NO_SUSPEND);
+
+ p_payload->num = i;
+
+ p_payload->size = size;
+
+ /* Setup the buffer with a pattern*/
+ memset(&(p_payload->data[0]), 0xA5, size);
+
+ time_start = NU_Get_Time_Stamp();
+
+ /* Send data to remote side. */
+ rpmsg_send(app_rp_chnl, p_payload, (2 * sizeof(unsigned long)) + size);
+
+ /* Wait for echo. */
+ NU_Obtain_Semaphore(&App_Sem , NU_SUSPEND);
+
+ /* Validate packet number*/
+ if(p_payload->num != r_payload->num)
+ {
+ printf("\r\nError Echo packet number does not match with transmitted packet number %d \r\n", (int)p_payload->num);
+ }
+
+ /* Validate the data integrity. */
+ for(idx = 0; idx < size; idx++)
+ {
+ if(p_payload->data[idx] != r_payload->data[idx])
+ {
+ printf("\r\nError receiving data packet of size: %d at data index %d \r\n", size, idx);
+ break;
+ }
+ }
+
+ NU_Deallocate_Memory(p_payload);
+
+ payload_roundtrip_time[i] = time_end - time_start;
+ }
+
+ for(i =0; i<NUM_PAYLOADS; i++)
+ {
+ fw2_average_rtt += payload_roundtrip_time[i];
+ }
+
+ fw2_average_rtt = fw2_average_rtt / NUM_PAYLOADS;
+
+ time_start = NU_Get_Time_Stamp();
+
+ remoteproc_shutdown(proc);
+
+ fw2_shutdown_time = shutdown_time_stamp - time_start;
+
+ remoteproc_deinit(proc);
+ }
+ else
+ {
+ printf("\r\n\nLoading remote context: %s failed \r\n" , fw_name2);
+ }
+
+ /* Convert the values into nano-seconds. */
+ fw1_average_rtt = (fw1_average_rtt * 1000000000)/ (NU_HW_Ticks_Per_SW_Tick * NU_PLUS_TICKS_PER_SEC);
+ fw1_boot_time = (fw1_boot_time * 1000000000) / (NU_HW_Ticks_Per_SW_Tick * NU_PLUS_TICKS_PER_SEC);
+ fw1_shutdown_time = (fw1_shutdown_time * 1000000000)/ (NU_HW_Ticks_Per_SW_Tick * NU_PLUS_TICKS_PER_SEC);
+ fw2_average_rtt = (fw2_average_rtt * 1000000000)/ (NU_HW_Ticks_Per_SW_Tick * NU_PLUS_TICKS_PER_SEC);
+ fw2_boot_time = (fw2_boot_time * 1000000000) / (NU_HW_Ticks_Per_SW_Tick * NU_PLUS_TICKS_PER_SEC);
+ fw2_shutdown_time = (fw2_shutdown_time * 1000000000)/ (NU_HW_Ticks_Per_SW_Tick * NU_PLUS_TICKS_PER_SEC);
+
+ printf("\r\n **************************************** \r\n");
+ printf(" OpenAMP Latency Test Results \r\n");
+ printf(" **************************************** \r\n");
+
+ printf("\r\n Nucleus Remote: Average rpmsg_send API Round-Trip: %d ns\r\n", (int)fw1_average_rtt);
+ printf("\r\n Nucleus Remote: remoteproc_boot API: %d ns\r\n", (int)fw1_boot_time);
+ printf("\r\n Nucleus Remote: remoteproc_shutdown API: %d ns\r\n", (int)fw1_shutdown_time);
+
+ printf("\r\n Baremetal Remote: Average rpmsg_send API Round-Trip: %d ns\r\n", (int)fw2_average_rtt);
+ printf("\r\n Baremetal Remote: remoteproc_boot API: %d ns\r\n", (int)fw2_boot_time);
+ printf("\r\n Baremetal Remote: remoteproc_shutdown API: %d ns\r\n", (int)fw2_shutdown_time);
+}
+
+/* This callback gets invoked when the remote channel is created */
+void rpmsg_channel_created(struct rpmsg_channel *rp_chnl)
+{
+ app_rp_chnl = rp_chnl;
+
+ rp_ept = rpmsg_create_ept(rp_chnl , rpmsg_read_cb ,RPMSG_NULL , RPMSG_ADDR_ANY);
+
+ NU_Release_Semaphore(&App_Sem);
+}
+
+/* This callback gets invoked when the remote channel is deleted */
+void rpmsg_channel_deleted(struct rpmsg_channel *rp_chnl)
+{
+ rpmsg_destroy_ept(rp_ept);
+ NU_Release_Semaphore(&App_Sem);
+}
+
+/* This is the read callback, note we are in a task context when this callback
+is invoked, so kernel primitives can be used freely */
+void rpmsg_read_cb(struct rpmsg_channel *rp_chnl, void *data, int len,
+ void * priv, unsigned long src)
+{
+ time_end = NU_Get_Time_Stamp();
+
+ memcpy(r_payload,data,len);
+
+ NU_Release_Semaphore(&App_Sem);
+}
+
diff --git a/apps/tests/master/nucleus/latency_test/nucleus_nucleusbm/make b/apps/tests/master/nucleus/latency_test/nucleus_nucleusbm/make
--- /dev/null
@@ -0,0 +1,51 @@
+
+include ../Makefile.commons
+
+SAMPLE_OUT := tests/master/nucleus/latency_test/nucleus_nucleusbm/latency_test.out
+SAMPLE_C_SRC := tests/master/nucleus/latency_test/nucleus_nucleusbm/latency_test.c
+REMOTE_OUT := latency_test.out
+DST_DIR := tests/master/nucleus/latency_test/nucleus_nucleusbm
+NU_SRC_DIR := firmware/$(PLAT)/nucleus/echo_test
+BM_SRC_DIR := firmware/$(PLAT)/baremetal/echo_test
+
+SAMPLEOBJFILES := $(patsubst %.c, %.o, $(SAMPLE_C_SRC))
+SAMPLE_DEPS := $(patsubst %.c, %.d, $(SAMPLE_C_SRC))
+SAMPLE_MAP := $(patsubst %.out, %.map, $(SAMPLE_OUT))
+SAMPLE_BIN := $(patsubst %.out, %.bin, $(SAMPLE_OUT))
+
+$(SAMPLE_OUT): $(REMOTE_OUT)$(SAMPLEOBJFILES)
+
+ @echo 'Building latency test for nucleus : $@'
+
+ $(LD) -Wl,-Map=tests/master/nucleus/latency_test/nucleus_nucleusbm/latency_test.map -nostartfiles -Wl,--gc-sections -Wl,--wrap=malloc -Wl,--wrap=calloc -Wl,--wrap=realloc -Wl,--wrap=free -T"$(OHOME)/libs/system/$(PLAT)/nucleus/linker_master.ld" -L"$(OHOME)/libs/system/$(PLAT)/nucleus/lib/$(CROSS)/master" -L"$(OHOME)/libs/open_amp" -o "$(SAMPLE_OUT)" -Wl,--start-group $(SAMPLEOBJFILES) $(DST_DIR)/firmware1.o $(DST_DIR)/firmware2.o -lnucleus_master -lopen_amp -lc -lm -lstdc++ -Wl,--end-group
+
+ $(OBJCPY) -O binary $(SAMPLE_OUT) $(SAMPLE_BIN)
+
+ @echo 'Finished building target: $@'
+
+%.o:%.c
+ @echo CC $(<:.c=.o)
+ @$(CC) $(CFLAGS) $(ARCH_CFLAGS) $(INCLUDE) -c $< -o $@
+
+%.o:%.S
+ @$(AS) -c -mcpu=cortex-a9 $(ARCH_ASFLAGS) $(INCLUDE) $< -o $@
+
+$(REMOTE_OUT):
+ cd $(NU_SRC_DIR)/; cp firmware firmware1; \
+ $(OBJCPY) -I binary -O elf32-littlearm -B arm firmware1 firmware1.o
+ mv $(NU_SRC_DIR)/firmware1.o $(DST_DIR)/
+ cd $(BM_SRC_DIR)/; cp firmware firmware2; \
+ $(OBJCPY) -I binary -O elf32-littlearm -B arm firmware2 firmware2.o
+ mv $(BM_SRC_DIR)/firmware2.o $(DST_DIR)/
+ cd $(NU_SRC_DIR)/; rm firmware1
+ cd $(BM_SRC_DIR)/; rm firmware2
+clean:
+ -$(RM) $(SAMPLEOBJFILES) $(SAMPLE_DEPS) $(SAMPLE_OUT) $(SAMPLE_BIN) $(DST_DIR)/firmware1.o $(DST_DIR)/firmware2.o $(SAMPLE_MAP)
+
+post-build:
+ -@echo ' '
+
+secondary-outputs:
+
+PHONY: all clean dependents
+.SECONDARY: post-build
diff --git a/apps/tests/remote/baremetal/echo_test/echo_test.c b/apps/tests/remote/baremetal/echo_test/echo_test.c
--- /dev/null
@@ -0,0 +1,90 @@
+/* This is a sample demonstration application that showcases usage of rpmsg
+This application is meant to run on the remote CPU running baremetal code.
+This application echoes back data that was sent to it by the master core. */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "open_amp.h"
+#include "rsc_table.h"
+#include "baremetal.h"
+
+#define SHUTDOWN_MSG 0xEF56A55A
+
+/* Internal functions */
+static void rpmsg_channel_created(struct rpmsg_channel *rp_chnl);
+static void rpmsg_channel_deleted(struct rpmsg_channel *rp_chnl);
+static void rpmsg_read_cb(struct rpmsg_channel *, void *, int, void *, unsigned long);
+static void sleep();
+static void init_system();
+
+/* Globals */
+static struct rpmsg_channel *app_rp_chnl;
+static struct rpmsg_endpoint *rp_ept;
+static struct remote_proc *proc = NULL;
+static struct rsc_table_info rsc_info;
+extern const struct remote_resource_table resources;
+
+/* Application entry point */
+int main() {
+
+ /* Switch to System Mode */
+ SWITCH_TO_SYS_MODE();
+
+ /* Initialize HW system components */
+ init_system();
+
+ rsc_info.rsc_tab = (struct resource_table *)&resources;
+ rsc_info.size = sizeof(resources);
+
+ /* Initialize RPMSG framework */
+ remoteproc_resource_init(&rsc_info, rpmsg_channel_created, rpmsg_channel_deleted, rpmsg_read_cb,
+ &proc);
+
+ while (1) {
+ sleep();
+ }
+
+ return 0;
+}
+
+static void rpmsg_channel_created(struct rpmsg_channel *rp_chnl) {
+ app_rp_chnl = rp_chnl;
+ rp_ept = rpmsg_create_ept(rp_chnl, rpmsg_read_cb, RPMSG_NULL,
+ RPMSG_ADDR_ANY);
+}
+
+static void rpmsg_channel_deleted(struct rpmsg_channel *rp_chnl) {
+
+}
+
+static void rpmsg_read_cb(struct rpmsg_channel *rp_chnl, void *data, int len,
+ void * priv, unsigned long src) {
+ if ((*(int *) data) == SHUTDOWN_MSG) {
+ remoteproc_resource_deinit(proc);
+ } else {
+ /* Send data back to master*/
+ rpmsg_send(rp_chnl, data, len);
+ }
+}
+
+void sleep() {
+ int i;
+ for (i = 0; i < 1000; i++);
+}
+
+
+static void init_system() {
+
+ /* Place the vector table at the image entry point */
+ arm_arch_install_isr_vector_table(RAM_VECTOR_TABLE_ADDR);
+
+ /* Enable MMU */
+ arm_ar_mem_enable_mmu();
+
+ /* Initialize ARM stacks */
+ init_arm_stacks();
+
+ /* Initialize GIC */
+ zc702evk_gic_initialize();
+}
diff --git a/apps/tests/remote/baremetal/echo_test/make b/apps/tests/remote/baremetal/echo_test/make
--- /dev/null
@@ -0,0 +1,37 @@
+
+include ../Makefile.commons
+
+SAMPLE_OUT := tests/remote/baremetal/echo_test/echo_test.out
+SAMPLE_SRC := tests/remote/baremetal/echo_test/echo_test.c tests/remote/baremetal/echo_test/rsc_table.c
+
+
+SAMPLEOBJFILES := $(patsubst %.c, %.o, $(SAMPLE_SRC))
+
+SAMPLE_DEPS := $(patsubst %.c, %.d, $(SAMPLE_SRC))
+
+SAMPLE_MAP := $(patsubst %.out, %.map, $(SAMPLE_OUT))
+
+$(SAMPLE_OUT): $(SAMPLEOBJFILES)
+
+ @echo 'Building echo test for baremetal : $@'
+
+ $(LD) -Wl,-Map=tests/remote/baremetal/echo_test/echo_test.map -Wl,--gc-sections -T"$(OHOME)/libs/system/$(PLAT)/baremetal/linker_remote.ld" -L"$(OHOME)/libs/open_amp" -L"$(OHOME)/libs/system/$(PLAT)/baremetal" -o "$(SAMPLE_OUT)" -Wl,--start-group $(SAMPLEOBJFILES) -lopen_amp -lbaremetal_remote -lc -lm -lstdc++ -lcs3 -lcs3arm -lcs3unhosted -Wl,--end-group
+
+ $(CP) $(SAMPLE_OUT) firmware/$(PLAT)/$(OS)/echo_test/firmware
+
+ @echo 'Finished building target: $@'
+
+%.o:%.c
+ @echo CC $(<:.c=.o)
+ @$(CC) $(CFLAGS) $(ARCH_CFLAGS) $(INCLUDE) -c $< -o $@
+
+clean:
+ -$(RM) $(SAMPLEOBJFILES) $(SAMPLE_DEPS) $(SAMPLE_OUT) $(SAMPLE_MAP)
+
+post-build:
+ -@echo ' '
+
+secondary-outputs:
+
+PHONY: all clean dependents
+.SECONDARY: post-build
diff --git a/apps/tests/remote/baremetal/echo_test/rsc_table.c b/apps/tests/remote/baremetal/echo_test/rsc_table.c
--- /dev/null
@@ -0,0 +1,90 @@
+/*\r
+ * Copyright (c) 2014, Mentor Graphics Corporation\r
+ * All rights reserved.\r
+ *\r
+ * Redistribution and use in source and binary forms, with or without\r
+ * modification, are permitted provided that the following conditions are met:\r
+ *\r
+ * 1. Redistributions of source code must retain the above copyright notice,\r
+ * this list of conditions and the following disclaimer.\r
+ * 2. Redistributions in binary form must reproduce the above copyright notice,\r
+ * this list of conditions and the following disclaimer in the documentation\r
+ * and/or other materials provided with the distribution.\r
+ * 3. Neither the name of Mentor Graphics Corporation nor the names of its\r
+ * contributors may be used to endorse or promote products derived from this\r
+ * software without specific prior written permission.\r
+ *\r
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"\r
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\r
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\r
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE\r
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\r
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\r
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\r
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\r
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\r
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\r
+ * POSSIBILITY OF SUCH DAMAGE.\r
+ */\r
+\r
+/* This file populates resource table for Nucleus and BM remotes\r
+ * for use by the Linux Master */\r
+\r
+#include "open_amp.h"\r
+#include "rsc_table.h"\r
+\r
+/* Place resource table in special ELF section */\r
+#define __section(S) __attribute__((__section__(#S)))\r
+#define __resource __section(.resource_table)\r
+\r
+#define RPMSG_IPU_C0_FEATURES 1\r
+\r
+/* VirtIO rpmsg device id */\r
+#define VIRTIO_ID_RPMSG_ 7\r
+\r
+/* Remote supports Name Service announcement */\r
+#define VIRTIO_RPMSG_F_NS 0\r
+\r
+/* Resource table entries */\r
+#define ELF_START 0x00000000\r
+#define ELF_END 0x08000000\r
+#define NUM_VRINGS 0x02\r
+#define VRING_ALIGN 0x1000\r
+#define RING_TX 0x08000000\r
+#define RING_RX 0x08004000\r
+#define VRING_SIZE 256\r
+\r
+const struct remote_resource_table __resource resources =\r
+{\r
+ /* Version */\r
+ 1,\r
+\r
+ /* NUmber of table entries */\r
+ 2,\r
+ /* reserved fields */\r
+ { 0, 0,},\r
+\r
+ /* Offsets of rsc entries */\r
+ {\r
+ offsetof(struct remote_resource_table, elf_cout),\r
+ offsetof(struct remote_resource_table, rpmsg_vdev),\r
+ },\r
+\r
+ /* End of ELF file */\r
+ {\r
+ RSC_CARVEOUT, ELF_START, ELF_START, ELF_END, 0, 0, "ELF_COUT",\r
+ },\r
+\r
+ /* Virtio device entry */\r
+ { RSC_VDEV, VIRTIO_ID_RPMSG_, 0, RPMSG_IPU_C0_FEATURES, 0, 0, 0, NUM_VRINGS, {0, 0},\r
+ },\r
+\r
+ /* Vring rsc entry - part of vdev rsc entry */\r
+ {\r
+ RING_TX, VRING_ALIGN, VRING_SIZE, 1, 0\r
+ },\r
+ {\r
+ RING_RX, VRING_ALIGN, VRING_SIZE, 2, 0\r
+ },\r
+};\r
+\r
diff --git a/apps/tests/remote/baremetal/echo_test/rsc_table.h b/apps/tests/remote/baremetal/echo_test/rsc_table.h
--- /dev/null
@@ -0,0 +1,51 @@
+/*\r
+ * Copyright (c) 2014, Mentor Graphics Corporation\r
+ * All rights reserved.\r
+ *\r
+ * Redistribution and use in source and binary forms, with or without\r
+ * modification, are permitted provided that the following conditions are met:\r
+ *\r
+ * 1. Redistributions of source code must retain the above copyright notice,\r
+ * this list of conditions and the following disclaimer.\r
+ * 2. Redistributions in binary form must reproduce the above copyright notice,\r
+ * this list of conditions and the following disclaimer in the documentation\r
+ * and/or other materials provided with the distribution.\r
+ * 3. Neither the name of Mentor Graphics Corporation nor the names of its\r
+ * contributors may be used to endorse or promote products derived from this\r
+ * software without specific prior written permission.\r
+ *\r
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"\r
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\r
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\r
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE\r
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\r
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\r
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\r
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\r
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\r
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\r
+ * POSSIBILITY OF SUCH DAMAGE.\r
+ */\r
+\r
+/* This file populates resource table for Nucleus and BM remotes\r
+ * for use by the Linux Master */\r
+\r
+#include <stddef.h>\r
+#include "open_amp.h"\r
+\r
+#define NO_RESOURCE_ENTRIES 8\r
+\r
+/* Resource table for the given remote */\r
+struct remote_resource_table {\r
+ unsigned int version;\r
+ unsigned int num;\r
+ unsigned int reserved[2];\r
+ unsigned int offset[NO_RESOURCE_ENTRIES];\r
+ /* text carveout entry */\r
+ struct fw_rsc_carveout elf_cout;\r
+ /* rpmsg vdev entry */\r
+ struct fw_rsc_vdev rpmsg_vdev;\r
+ struct fw_rsc_vdev_vring rpmsg_vring0;\r
+ struct fw_rsc_vdev_vring rpmsg_vring1;\r
+};\r
+\r
diff --git a/apps/tests/remote/baremetal/func_test_suite/func_test_suite.c b/apps/tests/remote/baremetal/func_test_suite/func_test_suite.c
--- /dev/null
@@ -0,0 +1,149 @@
+/* This is a test application that runs baremetal code on the remote core
+ and responds to commands from master core to test the usage of rpmsg APIs. */
+
+/* Including required headers */
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include "open_amp.h"
+#include "rsc_table.h"
+#include "test_suite.h"
+#include "baremetal.h"
+
+#define EPT_ADDR 59
+
+/* Application provided callbacks */
+void rpmsg_channel_created(struct rpmsg_channel *rp_chnl);
+void rpmsg_channel_deleted(struct rpmsg_channel *rp_chnl);
+void rpmsg_read_default_cb(struct rpmsg_channel *rp_chnl, void *data, int len,
+ void * pric, unsigned long src);
+void rpmsg_read_ept_cb(struct rpmsg_channel *rp_chnl, void *data, int len,
+ void * pric, unsigned long src);
+
+static void sleep();
+static void init_system();
+
+/* Globals */
+static volatile int intr_flag = 0;
+static struct rpmsg_endpoint *rp_ept;
+static struct rpmsg_channel *app_rp_chnl;
+static unsigned int Src;
+static unsigned int Len;
+static char firmware_name[] = "baremetal-fn-test-suite-remote-firmware";
+static char r_buffer[512];
+static struct rsc_table_info rsc_info;
+extern const struct remote_resource_table resources;
+
+int main() {
+ struct remote_proc *proc;
+ int uninit = 0;
+ struct ept_cmd_data *ept_data;
+
+ /* Switch to System Mode */
+ SWITCH_TO_SYS_MODE();
+
+ /* Initialize HW system components */
+ init_system();
+
+ rsc_info.rsc_tab = (struct resource_table *) &resources;
+ rsc_info.size = sizeof(resources);
+
+ /* This API creates the virtio devices for this remote node and initializes
+ other relevant resources defined in the resource table */
+ remoteproc_resource_init(&rsc_info, rpmsg_channel_created,
+ rpmsg_channel_deleted, rpmsg_read_default_cb, &proc);
+
+ for (;;) {
+
+ if (intr_flag) {
+ struct command *cmd = (struct command *) r_buffer;
+ if (cmd->comm_start == CMD_START) {
+ unsigned int cm_code = cmd->comm_code;
+ void *data = cmd->data;
+
+ switch (cm_code) {
+ case CREATE_EPT:
+ ept_data = (struct ept_cmd_data *) data;
+ rp_ept = rpmsg_create_ept(app_rp_chnl, rpmsg_read_ept_cb,
+ RPMSG_NULL, ept_data->dst);
+ if (rp_ept) {
+ /* Send data back to ack. */
+ rpmsg_sendto(app_rp_chnl, r_buffer, Len, Src);
+ }
+ break;
+ case DELETE_EPT:
+ rpmsg_destroy_ept(rp_ept);
+ rpmsg_sendto(app_rp_chnl, r_buffer, Len, Src);
+
+ break;
+ case CREATE_CHNL:
+ break;
+ case DELETE_CHNL:
+ rpmsg_sendto(app_rp_chnl, r_buffer, Len, Src);
+ remoteproc_resource_deinit(proc);
+ uninit = 1;
+ break;
+ case QUERY_FW_NAME:
+ rpmsg_send(app_rp_chnl, &firmware_name[0],
+ strlen(firmware_name) + 1);
+ break;
+ default:
+ rpmsg_sendto(app_rp_chnl, r_buffer, Len, Src);
+ break;
+ }
+ } else {
+ rpmsg_sendto(app_rp_chnl, r_buffer, Len, Src);
+ }
+ intr_flag = 0;
+ if (uninit)
+ break;
+ }
+
+ sleep();
+ }
+
+ return 0;
+}
+
+/* This callback gets invoked when the remote chanl is created */
+void rpmsg_channel_created(struct rpmsg_channel *rp_chnl) {
+ app_rp_chnl = rp_chnl;
+}
+
+/* This callback gets invoked when the remote channel is deleted */
+void rpmsg_channel_deleted(struct rpmsg_channel *rp_chnl) {
+
+}
+
+void rpmsg_read_default_cb(struct rpmsg_channel *rp_chnl, void *data, int len,
+ void * priv, unsigned long src) {
+ memcpy(r_buffer, data, len);
+ Src = src;
+ Len = len;
+ intr_flag = 1;
+}
+
+void rpmsg_read_ept_cb(struct rpmsg_channel *rp_chnl, void *data, int len,
+ void * priv, unsigned long src) {
+ rpmsg_send_offchannel(rp_chnl, rp_ept->addr, src, data, len);
+}
+
+void sleep() {
+ int i;
+ for (i = 0; i < 1000; i++);
+}
+
+static void init_system() {
+
+ /* Place the vector table at the image entry point */
+ arm_arch_install_isr_vector_table(RAM_VECTOR_TABLE_ADDR);
+
+ /* Enable MMU */
+ arm_ar_mem_enable_mmu();
+
+ /* Initialize ARM stacks */
+ init_arm_stacks();
+
+ /* Initialize GIC */
+ zc702evk_gic_initialize();
+}
diff --git a/apps/tests/remote/baremetal/func_test_suite/make b/apps/tests/remote/baremetal/func_test_suite/make
--- /dev/null
@@ -0,0 +1,37 @@
+
+include ../Makefile.commons
+
+SAMPLE_OUT := tests/remote/baremetal/func_test_suite/func_test_suite.out
+SAMPLE_SRC := tests/remote/baremetal/func_test_suite/func_test_suite.c tests/remote/baremetal/func_test_suite/rsc_table.c
+
+SAMPLEOBJFILES := $(patsubst %.c, %.o, $(SAMPLE_SRC))
+
+SAMPLE_DEPS := $(patsubst %.c, %.d, $(SAMPLE_SRC))
+
+SAMPLE_MAP := $(patsubst %.out, %.map, $(SAMPLE_OUT))
+
+$(SAMPLE_OUT): $(SAMPLEOBJFILES)
+
+ @echo 'Building remote test suite for baremetal : $@'
+
+ $(LD) -Wl,-Map=tests/remote/baremetal/func_test_suite/func_test_suite.map -Wl,--gc-sections -T"$(OHOME)/libs/system/$(PLAT)/baremetal/linker_remote.ld" -L"$(OHOME)/libs/open_amp" -L"$(OHOME)/libs/system/$(PLAT)/baremetal" -o "$(SAMPLE_OUT)" -Wl,--start-group $(SAMPLEOBJFILES) -lopen_amp -lbaremetal_remote -lc -lm -lstdc++ -lcs3 -lcs3arm -lcs3unhosted -Wl,--end-group
+
+ @echo 'Copying ELF image to firmware folder'
+ $(CP) $(SAMPLE_OUT) firmware/$(PLAT)/$(OS)/func_test_suite/firmware
+
+ @echo 'Finished building target: $@'
+
+%.o:%.c
+ @echo CC $(<:.c=.o)
+ @$(CC) $(CFLAGS) $(ARCH_CFLAGS) $(INCLUDE) -c $< -o $@
+
+clean:
+ -$(RM) $(SAMPLEOBJFILES) $(SAMPLE_DEPS) $(SAMPLE_OUT) $(SAMPLE_MAP)
+
+post-build:
+ -@echo ' '
+
+secondary-outputs:
+
+PHONY: all clean dependents
+.SECONDARY: post-build
diff --git a/apps/tests/remote/baremetal/func_test_suite/rsc_table.c b/apps/tests/remote/baremetal/func_test_suite/rsc_table.c
--- /dev/null
@@ -0,0 +1,89 @@
+/*\r
+ * Copyright (c) 2014, Mentor Graphics Corporation\r
+ * All rights reserved.\r
+ *\r
+ * Redistribution and use in source and binary forms, with or without\r
+ * modification, are permitted provided that the following conditions are met:\r
+ *\r
+ * 1. Redistributions of source code must retain the above copyright notice,\r
+ * this list of conditions and the following disclaimer.\r
+ * 2. Redistributions in binary form must reproduce the above copyright notice,\r
+ * this list of conditions and the following disclaimer in the documentation\r
+ * and/or other materials provided with the distribution.\r
+ * 3. Neither the name of Mentor Graphics Corporation nor the names of its\r
+ * contributors may be used to endorse or promote products derived from this\r
+ * software without specific prior written permission.\r
+ *\r
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"\r
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\r
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\r
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE\r
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\r
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\r
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\r
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\r
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\r
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\r
+ * POSSIBILITY OF SUCH DAMAGE.\r
+ */\r
+\r
+/* This file populates resource table for Nucleus and BM remotes\r
+ * for use by the Linux Master */\r
+\r
+#include "open_amp.h"\r
+#include "rsc_table.h"\r
+\r
+/* Place resource table in special ELF section */\r
+#define __section(S) __attribute__((__section__(#S)))\r
+#define __resource __section(.resource_table)\r
+\r
+#define RPMSG_IPU_C0_FEATURES 1\r
+\r
+/* VirtIO rpmsg device id */\r
+#define VIRTIO_ID_RPMSG_ 7\r
+\r
+/* Remote supports Name Service announcement */\r
+#define VIRTIO_RPMSG_F_NS 0\r
+\r
+/* Resource table entries */\r
+#define ELF_START 0x00000000\r
+#define ELF_END 0x08000000\r
+#define NUM_VRINGS 0x02\r
+#define VRING_ALIGN 0x1000\r
+#define RING_TX 0x08000000\r
+#define RING_RX 0x08004000\r
+#define VRING_SIZE 256\r
+\r
+const struct remote_resource_table __resource resources =\r
+{\r
+ /* Version */\r
+ 1,\r
+\r
+ /* NUmber of table entries */\r
+ 2,\r
+ /* reserved fields */\r
+ { 0, 0,},\r
+\r
+ /* Offsets of rsc entries */\r
+ {\r
+ offsetof(struct remote_resource_table, elf_cout),\r
+ offsetof(struct remote_resource_table, rpmsg_vdev),\r
+ },\r
+\r
+ /* End of ELF file */\r
+ {\r
+ RSC_CARVEOUT, ELF_START, ELF_START, ELF_END, 0, 0, "ELF_COUT",\r
+ },\r
+\r
+ /* Virtio device entry */\r
+ { RSC_VDEV, VIRTIO_ID_RPMSG_, 0, RPMSG_IPU_C0_FEATURES, 0, 0, 0, NUM_VRINGS, {0, 0},\r
+ },\r
+\r
+ /* Vring rsc entry - part of vdev rsc entry */\r
+ {\r
+ RING_TX, VRING_ALIGN, VRING_SIZE, 1, 0\r
+ },\r
+ {\r
+ RING_RX, VRING_ALIGN, VRING_SIZE, 2, 0\r
+ },\r
+};\r
diff --git a/apps/tests/remote/baremetal/func_test_suite/rsc_table.h b/apps/tests/remote/baremetal/func_test_suite/rsc_table.h
--- /dev/null
@@ -0,0 +1,51 @@
+/*\r
+ * Copyright (c) 2014, Mentor Graphics Corporation\r
+ * All rights reserved.\r
+ *\r
+ * Redistribution and use in source and binary forms, with or without\r
+ * modification, are permitted provided that the following conditions are met:\r
+ *\r
+ * 1. Redistributions of source code must retain the above copyright notice,\r
+ * this list of conditions and the following disclaimer.\r
+ * 2. Redistributions in binary form must reproduce the above copyright notice,\r
+ * this list of conditions and the following disclaimer in the documentation\r
+ * and/or other materials provided with the distribution.\r
+ * 3. Neither the name of Mentor Graphics Corporation nor the names of its\r
+ * contributors may be used to endorse or promote products derived from this\r
+ * software without specific prior written permission.\r
+ *\r
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"\r
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\r
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\r
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE\r
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\r
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\r
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\r
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\r
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\r
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\r
+ * POSSIBILITY OF SUCH DAMAGE.\r
+ */\r
+\r
+/* This file populates resource table for Nucleus and BM remotes\r
+ * for use by the Linux Master */\r
+\r
+#include <stddef.h>\r
+#include "open_amp.h"\r
+\r
+#define NO_RESOURCE_ENTRIES 8\r
+\r
+/* Resource table for the given remote */\r
+struct remote_resource_table {\r
+ unsigned int version;\r
+ unsigned int num;\r
+ unsigned int reserved[2];\r
+ unsigned int offset[NO_RESOURCE_ENTRIES];\r
+ /* text carveout entry */\r
+ struct fw_rsc_carveout elf_cout;\r
+ /* rpmsg vdev entry */\r
+ struct fw_rsc_vdev rpmsg_vdev;\r
+ struct fw_rsc_vdev_vring rpmsg_vring0;\r
+ struct fw_rsc_vdev_vring rpmsg_vring1;\r
+};\r
+\r
diff --git a/apps/tests/remote/baremetal/func_test_suite/test_suite.h b/apps/tests/remote/baremetal/func_test_suite/test_suite.h
--- /dev/null
@@ -0,0 +1,60 @@
+
+#ifndef M_EPT_FUNC_TEST_H_
+#define M_EPT_FUNC_TEST_H_
+
+struct command
+{
+ unsigned int comm_start;
+ unsigned int comm_code;
+ char data[0];
+}__attribute__((__packed__));
+
+struct ept_cmd_data
+{
+ unsigned int src;
+ unsigned int dst;
+};
+
+struct chnl_cmd_data
+{
+ char name[32];
+};
+
+/* Command Codes */
+
+#define CREATE_EPT 0x00000000
+#define DELETE_EPT 0x00000001
+#define CREATE_CHNL 0x00000002
+#define DELETE_CHNL 0x00000003
+#define START_ECHO 0x00000004
+#define STOP_ECHO 0x00000005
+#define QUERY_FW_NAME 0x00000006
+
+#define CMD_START 0xEF56A55A
+
+/* Define the main task's stack size */
+#define STACK_SIZE (NU_MIN_STACK_SIZE * 400)
+
+/* Define the main task's priority */
+#define TASK_PRIORITY 26
+
+/* Define the main task's time slice */
+#define TASK_SLICE 20
+
+#define EPT_TEST_ADDR 59
+
+#define NUM_TEST_EPS 4
+
+#define MAX_RPMSG_BUFF_SIZE 512
+#define PAYLOAD_MIN_SIZE 1
+#define PAYLOAD_MAX_SIZE (MAX_RPMSG_BUFF_SIZE - 24)
+#define NUM_PAYLOADS (PAYLOAD_MAX_SIZE/PAYLOAD_MIN_SIZE)
+
+struct _payload {
+ unsigned long num;
+ unsigned long size;
+ char data[0];
+}__attribute__((__packed__));
+
+
+#endif /* M_EPT_FUNC_TEST_H_ */
diff --git a/apps/tests/remote/nucleus/echo_test/echo_test.c b/apps/tests/remote/nucleus/echo_test/echo_test.c
--- /dev/null
@@ -0,0 +1,142 @@
+/* This is a sample demonstration application that showcases usage of rpmsg
+This application is meant to run on the remote CPU running Nucleus.
+This application echoes back data that was sent to it by the master core. */
+
+
+/* Including required headers */
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include "open_amp.h"
+#include "rsc_table.h"
+#include "nucleus.h"
+#include "kernel/nu_kernel.h"
+
+/* Define the main task's stack size */
+#define STACK_SIZE (NU_MIN_STACK_SIZE * 64)
+
+/* Define the main task's priority */
+#define TASK_PRIORITY 26
+
+/* Define the main task's time slice */
+#define TASK_SLICE 20
+
+#define SHUTDOWN_MSG 0xEF56A55A
+
+/* Prototypes */
+static void Main_Task_Entry( UNSIGNED argc , VOID *argv );
+
+/* Application provided callbacks */
+void rpmsg_channel_created( struct rpmsg_channel *rp_chnl );
+void rpmsg_channel_deleted( struct rpmsg_channel *rp_chnl );
+void rpmsg_read_default_cb(struct rpmsg_channel *rp_chnl, void *data, int len,
+ void * pric, unsigned long src);
+
+/* Globals */
+static NU_TASK Task_Control_Block;
+static struct rpmsg_endpoint *rp_ept;
+static struct rpmsg_channel *app_rp_chnl;
+static struct remote_proc *proc;
+static struct rsc_table_info rsc_info;
+extern const struct remote_resource_table resources;
+static volatile int shutdown_flag = 0;
+
+/***********************************************************************
+ * *
+ * * FUNCTION
+ * *
+ * * Application_Initialize
+ * *
+ * * DESCRIPTION
+ * *
+ * * Demo application entry point
+ *
+ * ***********************************************************************/
+VOID Application_Initialize(NU_MEMORY_POOL* mem_pool , NU_MEMORY_POOL* uncached_mem_pool )
+{
+ VOID *pointer;
+ STATUS status = NU_SUCCESS;
+
+ /* Reference unused parameters to avoid toolset warnings */
+ NU_UNUSED_PARAM( uncached_mem_pool );
+
+ if (status == NU_SUCCESS) {
+ status = NU_Allocate_Memory(mem_pool, &pointer, STACK_SIZE,
+ NU_NO_SUSPEND);
+
+ /* Create the main task for matrix processing */
+ if (status == NU_SUCCESS) {
+ status = NU_Create_Task(&Task_Control_Block, "MAIN",
+ Main_Task_Entry, 0, uncached_mem_pool, pointer,
+ STACK_SIZE, TASK_PRIORITY, TASK_SLICE,
+ NU_PREEMPT, NU_START);
+ }
+ }
+
+ /* Check to see if previous operations were successful */
+ if ( status != NU_SUCCESS )
+ {
+ /* Loop forever */
+ while ( 1 );
+ }
+}
+/***********************************************************************
+ * *
+ * * FUNCTION
+ * *
+ * * Main_Task_Entry
+ * *
+ * * DESCRIPTION
+ * *
+ * * Entry function for the main task. This task prints a hello world
+ * * message.
+ * *
+ * ***********************************************************************/
+static VOID Main_Task_Entry( UNSIGNED argc , VOID *argv ) {
+
+ rsc_info.rsc_tab = (struct resource_table *)&resources;
+ rsc_info.size = sizeof(struct remote_resource_table);
+
+ /* This API creates the virtio devices for this remote node and initializes
+ other relevant resources defined in the resource table */
+ remoteproc_resource_init(&rsc_info, rpmsg_channel_created,
+ rpmsg_channel_deleted, rpmsg_read_default_cb, &proc);
+
+ for ( ; ; )
+ {
+ if(shutdown_flag)
+ {
+ remoteproc_resource_deinit(proc);
+ break;
+ }
+ NU_Sleep(100);
+ }
+}
+
+/* This callback gets invoked when the remote chanl is created */
+void rpmsg_channel_created(struct rpmsg_channel *rp_chnl) {
+
+ app_rp_chnl = rp_chnl;
+ rp_ept = rpmsg_create_ept(rp_chnl, rpmsg_read_default_cb, RPMSG_NULL,
+ RPMSG_ADDR_ANY);
+}
+
+/* This callback gets invoked when the remote channel is deleted */
+void rpmsg_channel_deleted(struct rpmsg_channel *rp_chnl) {
+
+}
+
+/* This is the read callback, note we are in a task context when this callback
+is invoked, so kernel primitives can be used freely */
+void rpmsg_read_default_cb(struct rpmsg_channel *rp_chnl, void *data, int len,
+ void * priv, unsigned long src) {
+
+ if ((*((int *) data)) == SHUTDOWN_MSG) {
+ shutdown_flag = 1;
+ } else {
+ /* Send the result of matrix multiplication back to master. */
+ rpmsg_send(rp_chnl, data, len);
+ }
+}
+
+
diff --git a/apps/tests/remote/nucleus/echo_test/make b/apps/tests/remote/nucleus/echo_test/make
--- /dev/null
@@ -0,0 +1,39 @@
+
+include ../Makefile.commons
+
+SAMPLE_OUT := tests/remote/nucleus/echo_test/echo_test.out
+SAMPLE_SRC := tests/remote/nucleus/echo_test/echo_test.c tests/remote/nucleus/echo_test/rsc_table.c
+
+SAMPLEOBJFILES := $(patsubst %.c, %.o, $(SAMPLE_SRC))
+
+SAMPLE_DEPS := $(patsubst %.c, %.d, $(SAMPLE_SRC))
+
+SAMPLE_MAP := $(patsubst %.out, %.map, $(SAMPLE_OUT))
+
+$(SAMPLE_OUT): $(SAMPLEOBJFILES)
+
+ @echo 'Building echo test for nucleus : $@'
+
+ $(LD) -Wl,-Map=tests/remote/nucleus/echo_test/echo_test.map -nostartfiles -Wl,--gc-sections -Wl,--wrap=malloc -Wl,--wrap=calloc -Wl,--wrap=realloc -Wl,--wrap=free -T"$(OHOME)/libs/system/$(PLAT)/nucleus/linker_remote.ld" -L"$(OHOME)/libs/system/$(PLAT)/nucleus/lib/$(CROSS)/remote" -L"$(OHOME)/libs/open_amp" -o "$(SAMPLE_OUT)" -Wl,--start-group $(SAMPLEOBJFILES) -lnucleus_remote -lopen_amp -lc -lm -lstdc++ -Wl,--end-group
+
+ @echo 'Copying ELF image to firmware folder'
+ $(CP) $(SAMPLE_OUT) firmware/$(PLAT)/$(OS)/echo_test/firmware
+
+ @echo 'Finished building target: $@'
+
+%.o:%.c
+ @echo CC $(<:.c=.o)
+ @$(CC) $(CFLAGS) $(ARCH_CFLAGS) $(INCLUDE) -c $< -o $@
+
+clean:
+ -$(RM) $(SAMPLEOBJFILES) $(SAMPLE_DEPS) $(SAMPLE_OUT) $(SAMPLE_MAP)
+
+
+
+post-build:
+ -@echo ' '
+
+secondary-outputs:
+
+PHONY: all clean dependents
+.SECONDARY: post-build
diff --git a/apps/tests/remote/nucleus/echo_test/rsc_table.c b/apps/tests/remote/nucleus/echo_test/rsc_table.c
--- /dev/null
@@ -0,0 +1,89 @@
+/*\r
+ * Copyright (c) 2014, Mentor Graphics Corporation\r
+ * All rights reserved.\r
+ *\r
+ * Redistribution and use in source and binary forms, with or without\r
+ * modification, are permitted provided that the following conditions are met:\r
+ *\r
+ * 1. Redistributions of source code must retain the above copyright notice,\r
+ * this list of conditions and the following disclaimer.\r
+ * 2. Redistributions in binary form must reproduce the above copyright notice,\r
+ * this list of conditions and the following disclaimer in the documentation\r
+ * and/or other materials provided with the distribution.\r
+ * 3. Neither the name of Mentor Graphics Corporation nor the names of its\r
+ * contributors may be used to endorse or promote products derived from this\r
+ * software without specific prior written permission.\r
+ *\r
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"\r
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\r
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\r
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE\r
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\r
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\r
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\r
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\r
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\r
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\r
+ * POSSIBILITY OF SUCH DAMAGE.\r
+ */\r
+\r
+/* This file populates resource table for Nucleus and BM remotes\r
+ * for use by the Linux Master */\r
+\r
+#include "open_amp.h"\r
+#include "rsc_table.h"\r
+\r
+/* Place resource table in special ELF section */\r
+#define __section(S) __attribute__((__section__(#S)))\r
+#define __resource __section(.resource_table)\r
+\r
+#define RPMSG_IPU_C0_FEATURES 1\r
+\r
+/* VirtIO rpmsg device id */\r
+#define VIRTIO_ID_RPMSG_ 7\r
+\r
+/* Remote supports Name Service announcement */\r
+#define VIRTIO_RPMSG_F_NS 0\r
+\r
+/* Resource table entries */\r
+#define ELF_START 0x00000000\r
+#define ELF_END 0x08000000\r
+#define NUM_VRINGS 0x02\r
+#define VRING_ALIGN 0x1000\r
+#define RING_TX 0x08000000\r
+#define RING_RX 0x08004000\r
+#define VRING_SIZE 256\r
+\r
+const struct remote_resource_table __resource resources =\r
+{\r
+ /* Version */\r
+ 1,\r
+\r
+ /* NUmber of table entries */\r
+ 2,\r
+ /* reserved fields */\r
+ { 0, 0,},\r
+\r
+ /* Offsets of rsc entries */\r
+ {\r
+ offsetof(struct remote_resource_table, elf_cout),\r
+ offsetof(struct remote_resource_table, rpmsg_vdev),\r
+ },\r
+\r
+ /* End of ELF file */\r
+ {\r
+ RSC_CARVEOUT, ELF_START, ELF_START, ELF_END, 0, 0, "ELF_COUT",\r
+ },\r
+\r
+ /* Virtio device entry */\r
+ { RSC_VDEV, VIRTIO_ID_RPMSG_, 0, RPMSG_IPU_C0_FEATURES, 0, 0, 0, NUM_VRINGS, {0, 0},\r
+ },\r
+\r
+ /* Vring rsc entry - part of vdev rsc entry */\r
+ {\r
+ RING_TX, VRING_ALIGN, VRING_SIZE, 1, 0\r
+ },\r
+ {\r
+ RING_RX, VRING_ALIGN, VRING_SIZE, 2, 0\r
+ },\r
+};\r
diff --git a/apps/tests/remote/nucleus/echo_test/rsc_table.h b/apps/tests/remote/nucleus/echo_test/rsc_table.h
--- /dev/null
@@ -0,0 +1,51 @@
+/*\r
+ * Copyright (c) 2014, Mentor Graphics Corporation\r
+ * All rights reserved.\r
+ *\r
+ * Redistribution and use in source and binary forms, with or without\r
+ * modification, are permitted provided that the following conditions are met:\r
+ *\r
+ * 1. Redistributions of source code must retain the above copyright notice,\r
+ * this list of conditions and the following disclaimer.\r
+ * 2. Redistributions in binary form must reproduce the above copyright notice,\r
+ * this list of conditions and the following disclaimer in the documentation\r
+ * and/or other materials provided with the distribution.\r
+ * 3. Neither the name of Mentor Graphics Corporation nor the names of its\r
+ * contributors may be used to endorse or promote products derived from this\r
+ * software without specific prior written permission.\r
+ *\r
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"\r
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\r
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\r
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE\r
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\r
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\r
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\r
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\r
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\r
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\r
+ * POSSIBILITY OF SUCH DAMAGE.\r
+ */\r
+\r
+/* This file populates resource table for Nucleus and BM remotes\r
+ * for use by the Linux Master */\r
+\r
+#include <stddef.h>\r
+#include "open_amp.h"\r
+\r
+#define NO_RESOURCE_ENTRIES 8\r
+\r
+/* Resource table for the given remote */\r
+struct remote_resource_table {\r
+ unsigned int version;\r
+ unsigned int num;\r
+ unsigned int reserved[2];\r
+ unsigned int offset[NO_RESOURCE_ENTRIES];\r
+ /* text carveout entry */\r
+ struct fw_rsc_carveout elf_cout;\r
+ /* rpmsg vdev entry */\r
+ struct fw_rsc_vdev rpmsg_vdev;\r
+ struct fw_rsc_vdev_vring rpmsg_vring0;\r
+ struct fw_rsc_vdev_vring rpmsg_vring1;\r
+};\r
+\r
diff --git a/apps/tests/remote/nucleus/func_test_suite/func_test_suite.c b/apps/tests/remote/nucleus/func_test_suite/func_test_suite.c
--- /dev/null
@@ -0,0 +1,188 @@
+
+/* This is a test application that runs Nucleus on the remote core
+and responds to commands from master core to test the usage of rpmsg APIs. */
+
+/* Including required headers */
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include "open_amp.h"
+#include "rsc_table.h"
+#include "test_suite.h"
+#include "nucleus.h"
+#include "kernel/nu_kernel.h"
+
+/* Prototypes */
+static void Main_Task_Entry( UNSIGNED argc , VOID *argv );
+
+#define EPT_ADDR 59
+
+/* Application provided callbacks */
+void rpmsg_channel_created( struct rpmsg_channel *rp_chnl );
+void rpmsg_channel_deleted( struct rpmsg_channel *rp_chnl );
+void rpmsg_read_default_cb( struct rpmsg_channel *rp_chnl , void *data , int len , void * pric ,
+ unsigned long src );
+void rpmsg_read_ept_cb( struct rpmsg_channel *rp_chnl , void *data , int len , void * pric ,
+ unsigned long src );
+/* Globals */
+NU_TASK Task_Control_Block;
+NU_SEMAPHORE App_Sem;
+struct rpmsg_endpoint *rp_ept;
+struct rpmsg_channel *app_rp_chnl;
+UINT32 Src;
+UINT32 Len;
+CHAR firmware_name[] = "nucleus-fn-test-suite-remote-firmware";
+CHAR r_buffer[512];
+struct rsc_table_info rsc_info;
+extern const struct remote_resource_table resources;
+/***********************************************************************
+ * *
+ * * FUNCTION
+ * *
+ * * Application_Initialize
+ * *
+ * * DESCRIPTION
+ * *
+ * * Demo application entry point
+ *
+ * ***********************************************************************/
+VOID Application_Initialize(
+ NU_MEMORY_POOL* mem_pool , NU_MEMORY_POOL* uncached_mem_pool )
+{
+ VOID *pointer;
+ STATUS status = NU_SUCCESS;
+
+ /* Reference unused parameters to avoid toolset warnings */
+ NU_UNUSED_PARAM( uncached_mem_pool );
+
+ if ( status == NU_SUCCESS )
+ {
+ status = NU_Allocate_Memory(mem_pool, &pointer, STACK_SIZE, NU_NO_SUSPEND);
+
+ /* Create the main task for matrix processing */
+ if ( status == NU_SUCCESS )
+ {
+ status = NU_Create_Task( &Task_Control_Block , "MAIN" , Main_Task_Entry , 0 ,
+ uncached_mem_pool , pointer , STACK_SIZE , TASK_PRIORITY , TASK_SLICE ,
+ NU_PREEMPT , NU_START );
+ }
+ if ( status == NU_SUCCESS )
+ {
+ status = NU_Create_Semaphore( &App_Sem , "APP_SEM" , 0 , NU_FIFO );
+ }
+ }
+
+ /* Check to see if previous operations were successful */
+ if ( status != NU_SUCCESS )
+ {
+ /* Loop forever */
+ while ( 1 );
+ }
+}
+
+/***********************************************************************
+ * *
+ * * FUNCTION
+ * *
+ * * Main_Task_Entry
+ * *
+ * * DESCRIPTION
+ * *
+ * * Entry function for the main task. This task prints a hello world
+ * * message.
+ * *
+ * ***********************************************************************/
+static VOID Main_Task_Entry( UNSIGNED argc , VOID *argv )
+{
+
+ struct remote_proc *proc;
+ BOOLEAN uninit = NU_FALSE;
+ struct ept_cmd_data *ept_data;
+
+ rsc_info.rsc_tab = (struct resource_table *)&resources;
+ rsc_info.size = sizeof(struct remote_resource_table);
+
+ /* This API creates the virtio devices for this remote node and initializes
+ other relevant resources defined in the resource table */
+ remoteproc_resource_init( &rsc_info, rpmsg_channel_created , rpmsg_channel_deleted ,
+ rpmsg_read_default_cb , &proc );
+
+ for ( ; ; )
+ {
+
+ NU_Obtain_Semaphore( &App_Sem , NU_SUSPEND );
+
+ struct command *cmd = (struct command *)r_buffer;
+ if(cmd->comm_start == CMD_START)
+ {
+ unsigned int cm_code = cmd->comm_code;
+ void *data = cmd->data;
+
+ switch ( cm_code )
+ {
+ case CREATE_EPT :
+ ept_data = (struct ept_cmd_data *)data;
+ rp_ept = rpmsg_create_ept( app_rp_chnl , rpmsg_read_ept_cb , RPMSG_NULL ,
+ ept_data->dst );
+ if (rp_ept){
+ /* Send data back to ack. */
+ rpmsg_sendto( app_rp_chnl , r_buffer , Len , Src );
+ }
+ break;
+ case DELETE_EPT :
+ rpmsg_destroy_ept(rp_ept);
+ rpmsg_sendto( app_rp_chnl , r_buffer , Len , Src );
+
+ break;
+ case CREATE_CHNL :
+ break;
+ case DELETE_CHNL :
+ rpmsg_sendto( app_rp_chnl , r_buffer , Len , Src );
+ remoteproc_resource_deinit( proc );
+ uninit = NU_TRUE;
+ break;
+ case QUERY_FW_NAME :
+ rpmsg_send( app_rp_chnl , &firmware_name[0], strlen(firmware_name)+1);
+ break;
+ default :
+ rpmsg_sendto( app_rp_chnl , r_buffer , Len , Src );
+ break;
+ }
+ }else
+ {
+ rpmsg_sendto( app_rp_chnl , r_buffer , Len , Src );
+ }
+
+ if ( uninit )
+ break;
+ }
+}
+
+/* This callback gets invoked when the remote chanl is created */
+void rpmsg_channel_created( struct rpmsg_channel *rp_chnl )
+{
+ app_rp_chnl = rp_chnl;
+}
+
+/* This callback gets invoked when the remote channel is deleted */
+void rpmsg_channel_deleted( struct rpmsg_channel *rp_chnl )
+{
+
+}
+
+/* This is the read callback, note we are in a task context when this callback
+ is invoked, so kernel primitives can be used freely */
+void rpmsg_read_default_cb( struct rpmsg_channel *rp_chnl , void *data , int len , void * priv ,
+ unsigned long src )
+{
+ memcpy( r_buffer , data , len );
+ Src = src;
+ Len = len;
+ NU_Release_Semaphore( &App_Sem );
+}
+
+void rpmsg_read_ept_cb( struct rpmsg_channel *rp_chnl , void *data , int len , void * priv ,
+ unsigned long src )
+{
+ rpmsg_send_offchannel( rp_chnl , rp_ept->addr , src , data , len );
+}
diff --git a/apps/tests/remote/nucleus/func_test_suite/make b/apps/tests/remote/nucleus/func_test_suite/make
--- /dev/null
@@ -0,0 +1,37 @@
+
+include ../Makefile.commons
+
+SAMPLE_OUT := tests/remote/nucleus/func_test_suite/func_test_suite.out
+SAMPLE_SRC := tests/remote/nucleus/func_test_suite/func_test_suite.c tests/remote/nucleus/func_test_suite/rsc_table.c
+
+SAMPLEOBJFILES := $(patsubst %.c, %.o, $(SAMPLE_SRC))
+
+SAMPLE_DEPS := $(patsubst %.c, %.d, $(SAMPLE_SRC))
+
+SAMPLE_MAP := $(patsubst %.out, %.map, $(SAMPLE_OUT))
+
+$(SAMPLE_OUT): $(SAMPLEOBJFILES)
+
+ @echo 'Building echo test for nucleus : $@'
+
+ $(LD) -Wl,-Map=tests/remote/nucleus/func_test_suite/func_test_suite.map -nostartfiles -Wl,--gc-sections -Wl,--wrap=malloc -Wl,--wrap=calloc -Wl,--wrap=realloc -Wl,--wrap=free -T"$(OHOME)/libs/system/$(PLAT)/nucleus/linker_remote.ld" -L"$(OHOME)/libs/system/$(PLAT)/nucleus/lib/$(CROSS)/remote" -L"$(OHOME)/libs/open_amp" -o "$(SAMPLE_OUT)" -Wl,--start-group $(SAMPLEOBJFILES) -lnucleus_remote -lopen_amp -lc -lm -lstdc++ -Wl,--end-group
+
+ @echo 'Copying ELF image to firmware folder'
+ $(CP) $(SAMPLE_OUT) firmware/$(PLAT)/$(OS)/func_test_suite/firmware
+
+ @echo 'Finished building target: $@'
+
+%.o:%.c
+ @echo CC $(<:.c=.o)
+ @$(CC) $(CFLAGS) $(ARCH_CFLAGS) $(INCLUDE) -c $< -o $@
+
+clean:
+ -$(RM) $(SAMPLEOBJFILES) $(SAMPLE_DEPS) $(SAMPLE_OUT) $(SAMPLE_MAP)
+
+post-build:
+ -@echo ' '
+
+secondary-outputs:
+
+PHONY: all clean dependents
+.SECONDARY: post-build
diff --git a/apps/tests/remote/nucleus/func_test_suite/rsc_table.c b/apps/tests/remote/nucleus/func_test_suite/rsc_table.c
--- /dev/null
@@ -0,0 +1,89 @@
+/*\r
+ * Copyright (c) 2014, Mentor Graphics Corporation\r
+ * All rights reserved.\r
+ *\r
+ * Redistribution and use in source and binary forms, with or without\r
+ * modification, are permitted provided that the following conditions are met:\r
+ *\r
+ * 1. Redistributions of source code must retain the above copyright notice,\r
+ * this list of conditions and the following disclaimer.\r
+ * 2. Redistributions in binary form must reproduce the above copyright notice,\r
+ * this list of conditions and the following disclaimer in the documentation\r
+ * and/or other materials provided with the distribution.\r
+ * 3. Neither the name of Mentor Graphics Corporation nor the names of its\r
+ * contributors may be used to endorse or promote products derived from this\r
+ * software without specific prior written permission.\r
+ *\r
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"\r
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\r
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\r
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE\r
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\r
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\r
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\r
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\r
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\r
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\r
+ * POSSIBILITY OF SUCH DAMAGE.\r
+ */\r
+\r
+/* This file populates resource table for Nucleus and BM remotes\r
+ * for use by the Linux Master */\r
+\r
+#include "open_amp.h"\r
+#include "rsc_table.h"\r
+\r
+/* Place resource table in special ELF section */\r
+#define __section(S) __attribute__((__section__(#S)))\r
+#define __resource __section(.resource_table)\r
+\r
+#define RPMSG_IPU_C0_FEATURES 1\r
+\r
+/* VirtIO rpmsg device id */\r
+#define VIRTIO_ID_RPMSG_ 7\r
+\r
+/* Remote supports Name Service announcement */\r
+#define VIRTIO_RPMSG_F_NS 0\r
+\r
+/* Resource table entries */\r
+#define ELF_START 0x00000000\r
+#define ELF_END 0x08000000\r
+#define NUM_VRINGS 0x02\r
+#define VRING_ALIGN 0x1000\r
+#define RING_TX 0x08000000\r
+#define RING_RX 0x08004000\r
+#define VRING_SIZE 256\r
+\r
+const struct remote_resource_table __resource resources =\r
+{\r
+ /* Version */\r
+ 1,\r
+\r
+ /* NUmber of table entries */\r
+ 2,\r
+ /* reserved fields */\r
+ { 0, 0,},\r
+\r
+ /* Offsets of rsc entries */\r
+ {\r
+ offsetof(struct remote_resource_table, elf_cout),\r
+ offsetof(struct remote_resource_table, rpmsg_vdev),\r
+ },\r
+\r
+ /* End of ELF file */\r
+ {\r
+ RSC_CARVEOUT, ELF_START, ELF_START, ELF_END, 0, 0, "ELF_COUT",\r
+ },\r
+\r
+ /* Virtio device entry */\r
+ { RSC_VDEV, VIRTIO_ID_RPMSG_, 0, RPMSG_IPU_C0_FEATURES, 0, 0, 0, NUM_VRINGS, {0, 0},\r
+ },\r
+\r
+ /* Vring rsc entry - part of vdev rsc entry */\r
+ {\r
+ RING_TX, VRING_ALIGN, VRING_SIZE, 1, 0\r
+ },\r
+ {\r
+ RING_RX, VRING_ALIGN, VRING_SIZE, 2, 0\r
+ },\r
+};\r
diff --git a/apps/tests/remote/nucleus/func_test_suite/rsc_table.h b/apps/tests/remote/nucleus/func_test_suite/rsc_table.h
--- /dev/null
@@ -0,0 +1,51 @@
+/*\r
+ * Copyright (c) 2014, Mentor Graphics Corporation\r
+ * All rights reserved.\r
+ *\r
+ * Redistribution and use in source and binary forms, with or without\r
+ * modification, are permitted provided that the following conditions are met:\r
+ *\r
+ * 1. Redistributions of source code must retain the above copyright notice,\r
+ * this list of conditions and the following disclaimer.\r
+ * 2. Redistributions in binary form must reproduce the above copyright notice,\r
+ * this list of conditions and the following disclaimer in the documentation\r
+ * and/or other materials provided with the distribution.\r
+ * 3. Neither the name of Mentor Graphics Corporation nor the names of its\r
+ * contributors may be used to endorse or promote products derived from this\r
+ * software without specific prior written permission.\r
+ *\r
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"\r
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\r
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\r
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE\r
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\r
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\r
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\r
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\r
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\r
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\r
+ * POSSIBILITY OF SUCH DAMAGE.\r
+ */\r
+\r
+/* This file populates resource table for Nucleus and BM remotes\r
+ * for use by the Linux Master */\r
+\r
+#include <stddef.h>\r
+#include "open_amp.h"\r
+\r
+#define NO_RESOURCE_ENTRIES 8\r
+\r
+/* Resource table for the given remote */\r
+struct remote_resource_table {\r
+ unsigned int version;\r
+ unsigned int num;\r
+ unsigned int reserved[2];\r
+ unsigned int offset[NO_RESOURCE_ENTRIES];\r
+ /* text carveout entry */\r
+ struct fw_rsc_carveout elf_cout;\r
+ /* rpmsg vdev entry */\r
+ struct fw_rsc_vdev rpmsg_vdev;\r
+ struct fw_rsc_vdev_vring rpmsg_vring0;\r
+ struct fw_rsc_vdev_vring rpmsg_vring1;\r
+};\r
+\r
diff --git a/apps/tests/remote/nucleus/func_test_suite/test_suite.h b/apps/tests/remote/nucleus/func_test_suite/test_suite.h
--- /dev/null
@@ -0,0 +1,66 @@
+/*
+ * m_ept_func_test.h
+ *
+ * Created on: Mar 14, 2014
+ * Author: etsam
+ */
+
+#ifndef M_EPT_FUNC_TEST_H_
+#define M_EPT_FUNC_TEST_H_
+
+struct command
+{
+ unsigned int comm_start;
+ unsigned int comm_code;
+ char data[0];
+}__attribute__((__packed__));
+
+struct ept_cmd_data
+{
+ unsigned int src;
+ unsigned int dst;
+};
+
+struct chnl_cmd_data
+{
+ char name[32];
+};
+
+/* Command Codes */
+
+#define CREATE_EPT 0x00000000
+#define DELETE_EPT 0x00000001
+#define CREATE_CHNL 0x00000002
+#define DELETE_CHNL 0x00000003
+#define START_ECHO 0x00000004
+#define STOP_ECHO 0x00000005
+#define QUERY_FW_NAME 0x00000006
+
+#define CMD_START 0xEF56A55A
+
+/* Define the main task's stack size */
+#define STACK_SIZE (NU_MIN_STACK_SIZE * 400)
+
+/* Define the main task's priority */
+#define TASK_PRIORITY 26
+
+/* Define the main task's time slice */
+#define TASK_SLICE 20
+
+#define EPT_TEST_ADDR 59
+
+#define NUM_TEST_EPS 4
+
+#define MAX_RPMSG_BUFF_SIZE 512
+#define PAYLOAD_MIN_SIZE 1
+#define PAYLOAD_MAX_SIZE (MAX_RPMSG_BUFF_SIZE - 24)
+#define NUM_PAYLOADS (PAYLOAD_MAX_SIZE/PAYLOAD_MIN_SIZE)
+
+struct _payload {
+ unsigned long num;
+ unsigned long size;
+ char data[0];
+}__attribute__((__packed__));
+
+
+#endif /* M_EPT_FUNC_TEST_H_ */
diff --git a/common/hil/hil.c b/common/hil/hil.c
--- /dev/null
+++ b/common/hil/hil.c
@@ -0,0 +1,406 @@
+/*\r
+ * Copyright (c) 2014, Mentor Graphics Corporation\r
+ * All rights reserved.\r
+ *\r
+ * Redistribution and use in source and binary forms, with or without\r
+ * modification, are permitted provided that the following conditions are met:\r
+ *\r
+ * 1. Redistributions of source code must retain the above copyright notice,\r
+ * this list of conditions and the following disclaimer.\r
+ * 2. Redistributions in binary form must reproduce the above copyright notice,\r
+ * this list of conditions and the following disclaimer in the documentation\r
+ * and/or other materials provided with the distribution.\r
+ * 3. Neither the name of Mentor Graphics Corporation nor the names of its\r
+ * contributors may be used to endorse or promote products derived from this\r
+ * software without specific prior written permission.\r
+ *\r
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"\r
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\r
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\r
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE\r
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\r
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\r
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\r
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\r
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\r
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\r
+ * POSSIBILITY OF SUCH DAMAGE.\r
+ */\r
+\r
+/**************************************************************************\r
+ * FILE NAME\r
+ *\r
+ * hil.c\r
+ *\r
+ * COMPONENT\r
+ *\r
+ * OpenAMP Stack.\r
+ *\r
+ * DESCRIPTION\r
+ *\r
+ * This file is implementation of generic part of HIL.\r
+ *\r
+ *\r
+ *\r
+ **************************************************************************/\r
+\r
+#include "hil.h"\r
+\r
+/*--------------------------- Globals ---------------------------------- */\r
+struct hil_proc_list procs;\r
+\r
+#if defined (OPENAMP_BENCHMARK_ENABLE)\r
+\r
+unsigned long long boot_time_stamp;\r
+unsigned long long shutdown_time_stamp;\r
+\r
+#endif\r
+\r
+extern int platform_get_processor_info(struct hil_proc *proc, int cpu_id);\r
+extern int platform_get_processor_for_fw(char *fw_name);\r
+\r
+/**\r
+ * hil_create_proc\r
+ *\r
+ * This function creates a HIL proc instance for given CPU id and populates\r
+ * it with platform info.\r
+ *\r
+ * @param cpu_id - cpu id\r
+ *\r
+ * @return - pointer to proc instance\r
+ *\r
+ */\r
+struct hil_proc *hil_create_proc(int cpu_id) {\r
+ struct hil_proc *proc = NULL;\r
+ struct llist *node = NULL;\r
+ struct llist *proc_hd = procs.proc_list;\r
+ int status;\r
+\r
+ /* If proc already exists then return it */\r
+ while (proc_hd != NULL) {\r
+ proc = (struct hil_proc *) proc_hd->data;\r
+ if (proc->cpu_id == cpu_id) {\r
+ return proc;\r
+ }\r
+ proc_hd = proc_hd->next;\r
+ }\r
+\r
+ /* Allocate memory for proc instance */\r
+ proc = env_allocate_memory(sizeof(struct hil_proc));\r
+ if (!proc) {\r
+ return NULL;\r
+ }\r
+\r
+ /* Get HW specfic info */\r
+ status = platform_get_processor_info(proc, cpu_id);\r
+ if (status) {\r
+ env_free_memory(proc);\r
+ return NULL;\r
+ }\r
+\r
+ /* Enable mapping for the shared memory region */\r
+ env_map_memory((unsigned int) proc->sh_buff.start_addr,\r
+ (unsigned int) proc->sh_buff.start_addr, proc->sh_buff.size,\r
+ (SHARED_MEM | UNCACHED));\r
+\r
+ /* Put the new proc in the procs list */\r
+ node = env_allocate_memory(sizeof(struct llist));\r
+\r
+ if (!node) {\r
+ env_free_memory(proc);\r
+ return NULL;\r
+ }\r
+\r
+ node->data = proc;\r
+ add_to_list(&procs.proc_list, node);\r
+\r
+ return proc;\r
+}\r
+\r
+/**\r
+ * hil_get_cpuforfw\r
+ *\r
+ * This function provides the CPU ID for the given firmware.\r
+ *\r
+ * @param fw_name - name of firmware\r
+ *\r
+ * @return - cpu id\r
+ *\r
+ */\r
+int hil_get_cpuforfw(char *fw_name) {\r
+ return (platform_get_processor_for_fw(fw_name));\r
+}\r
+\r
+/**\r
+ * hil_delete_proc\r
+ *\r
+ * This function deletes the given proc instance and frees the\r
+ * associated resources.\r
+ *\r
+ * @param proc - pointer to hil remote_proc instance\r
+ *\r
+ */\r
+void hil_delete_proc(struct hil_proc *proc) {\r
+ struct llist *proc_hd = NULL;\r
+\r
+ if (!proc)\r
+ return;\r
+\r
+ proc_hd = procs.proc_list;\r
+\r
+ while (proc_hd != NULL) {\r
+ if (proc_hd->data == proc) {\r
+ remove_from_list(&procs.proc_list, proc_hd);\r
+ env_free_memory(proc_hd);\r
+ break;\r
+ }\r
+ proc_hd = proc_hd->next;\r
+ }\r
+\r
+ env_free_memory(proc);\r
+}\r
+\r
+\r
+/**\r
+ * hil_isr()\r
+ *\r
+ * This function is called when interrupt is received for the vring.\r
+ * This function gets the corresponding virtqueue and generates\r
+ * call back for it.\r
+ *\r
+ * @param vring_hw - pointer to vring control block\r
+ *\r
+ */\r
+void hil_isr(struct proc_vring *vring_hw){\r
+ virtqueue_notification(vring_hw->vq);\r
+}\r
+\r
+/**\r
+ * hil_get_proc\r
+ *\r
+ * This function finds the proc instance based on the given ID\r
+ * from the proc list and returns it to user.\r
+ *\r
+ * @param cpu_id - cpu id\r
+ *\r
+ * @return - pointer to hil proc instance\r
+ *\r
+ */\r
+struct hil_proc *hil_get_proc(int cpu_id) {\r
+ struct llist *proc_hd = procs.proc_list;\r
+\r
+ if (!proc_hd)\r
+ return NULL;\r
+\r
+ while (proc_hd != NULL) {\r
+ struct hil_proc *proc = (struct hil_proc *) proc_hd->data;\r
+ if (proc->cpu_id == cpu_id) {\r
+ return proc;\r
+ }\r
+ proc_hd = proc_hd->next;\r
+ }\r
+\r
+ return NULL;\r
+}\r
+\r
+/**\r
+ * hil_get_chnl_info\r
+ *\r
+ * This function returns channels info for given proc.\r
+ *\r
+ * @param proc - pointer to proc info struct\r
+ * @param num_chnls - pointer to integer variable to hold\r
+ * number of available channels\r
+ *\r
+ * @return - pointer to channel info control block\r
+ *\r
+ */\r
+struct proc_chnl *hil_get_chnl_info(struct hil_proc *proc, int *num_chnls) {\r
+ *num_chnls = proc->num_chnls;\r
+ return (proc->chnls);\r
+}\r
+\r
+/**\r
+ * hil_get_vdev_info\r
+ *\r
+ * This function return virtio device for remote core.\r
+ *\r
+ * @param proc - pointer to remote proc\r
+ *\r
+ * @return - pointer to virtio HW device.\r
+ *\r
+ */\r
+\r
+struct proc_vdev *hil_get_vdev_info(struct hil_proc *proc) {\r
+ return (&proc->vdev);\r
+\r
+}\r
+\r
+/**\r
+ * hil_get_vring_info\r
+ *\r
+ * This function returns vring_info_table. The caller will use\r
+ * this table to get the vring HW info which will be subsequently\r
+ * used to create virtqueues.\r
+ *\r
+ * @param vdev - pointer to virtio HW device\r
+ * @param num_vrings - pointer to hold number of vrings\r
+ *\r
+ * @return - pointer to vring hardware info table\r
+ */\r
+struct proc_vring *hil_get_vring_info(struct proc_vdev *vdev, int *num_vrings) {\r
+\r
+ *num_vrings = vdev->num_vrings;\r
+ return (vdev->vring_info);\r
+\r
+}\r
+\r
+/**\r
+ * hil_get_shm_info\r
+ *\r
+ * This function returns shared memory info control block. The caller\r
+ * will use this information to create and manage memory buffers for\r
+ * vring descriptor table.\r
+ *\r
+ * @param proc - pointer to proc instance\r
+ *\r
+ * @return - pointer to shared memory region used for buffers\r
+ *\r
+ */\r
+struct proc_shm *hil_get_shm_info(struct hil_proc *proc) {\r
+ return (&proc->sh_buff);\r
+}\r
+\r
+/**\r
+ * hil_enable_vring_notifications()\r
+ *\r
+ * This function is called after successful creation of virtqueues.\r
+ * This function saves queue handle in the vring_info_table which\r
+ * will be used during interrupt handling .This function setups\r
+ * interrupt handlers.\r
+ *\r
+ * @param vring_index - index to vring HW table\r
+ * @param vq - pointer to virtqueue to save in vring HW table\r
+ *\r
+ * @return - execution status\r
+ */\r
+int hil_enable_vring_notifications(int vring_index, struct virtqueue *vq) {\r
+ struct hil_proc *proc_hw = (struct hil_proc *) vq->vq_dev->device;\r
+ struct proc_vring *vring_hw = &proc_hw->vdev.vring_info[vring_index];\r
+ /* Save virtqueue pointer for later reference */\r
+ vring_hw->vq = vq;\r
+\r
+ if (proc_hw->ops->enable_interrupt) {\r
+ proc_hw->ops->enable_interrupt(vring_hw);\r
+ }\r
+\r
+ return 0;\r
+}\r
+\r
+/**\r
+ * hil_vring_notify()\r
+ *\r
+ * This function generates IPI to let the other side know that there is\r
+ * job available for it. The required information to achieve this, like interrupt\r
+ * vector, CPU id etc is be obtained from the proc_vring table.\r
+ *\r
+ * @param vq - pointer to virtqueue\r
+ *\r
+ */\r
+void hil_vring_notify(struct virtqueue *vq) {\r
+ struct hil_proc *proc_hw = (struct hil_proc *) vq->vq_dev->device;\r
+ struct proc_vring *vring_hw = &proc_hw->vdev.vring_info[vq->vq_queue_index];\r
+\r
+ if (proc_hw->ops->notify) {\r
+ proc_hw->ops->notify(proc_hw->cpu_id, &vring_hw->intr_info);\r
+ }\r
+}\r
+\r
+/**\r
+ * hil_get_status\r
+ *\r
+ * This function is used to check if the given core is up and running.\r
+ * This call will return after it is confirmed that remote core has\r
+ * started.\r
+ *\r
+ * @param proc - pointer to proc instance\r
+ *\r
+ * @return - execution status\r
+ */\r
+int hil_get_status(struct hil_proc *proc) {\r
+ /* For future use only.*/\r
+ return 0;\r
+}\r
+\r
+/**\r
+ * hil_set_status\r
+ *\r
+ * This function is used to update the status\r
+ * of the given core i.e it is ready for IPC.\r
+ *\r
+ * @param proc - pointer to remote proc\r
+ *\r
+ * @return - execution status\r
+ */\r
+int hil_set_status(struct hil_proc *proc) {\r
+ /* For future use only.*/\r
+ return 0;\r
+}\r
+\r
+/**\r
+ * hil_boot_cpu\r
+ *\r
+ * This function boots the remote processor.\r
+ *\r
+ * @param proc - pointer to remote proc\r
+ * @param start_addr - start address of remote cpu\r
+ *\r
+ * @return - execution status\r
+ */\r
+int hil_boot_cpu(struct hil_proc *proc, unsigned int start_addr) {\r
+\r
+ if (proc->ops->boot_cpu) {\r
+ proc->ops->boot_cpu(proc->cpu_id, start_addr);\r
+ }\r
+\r
+#if defined (OPENAMP_BENCHMARK_ENABLE)\r
+ boot_time_stamp = env_get_timestamp();\r
+#endif\r
+\r
+ return 0;\r
+}\r
+\r
+/**\r
+ * hil_shutdown_cpu\r
+ *\r
+ * This function shutdowns the remote processor\r
+ *\r
+ * @param proc - pointer to remote proc\r
+ *\r
+ */\r
+void hil_shutdown_cpu(struct hil_proc *proc) {\r
+ if (proc->ops->shutdown_cpu) {\r
+ proc->ops->shutdown_cpu(proc->cpu_id);\r
+ }\r
+\r
+#if defined (OPENAMP_BENCHMARK_ENABLE)\r
+ shutdown_time_stamp = env_get_timestamp();\r
+#endif\r
+}\r
+\r
+/**\r
+ * hil_get_firmware\r
+ *\r
+ * This function returns address and size of given firmware name passed as\r
+ * parameter.\r
+ *\r
+ * @param fw_name - name of the firmware\r
+ * @param start_addr - pointer t hold start address of firmware\r
+ * @param size - pointer to hold size of firmware\r
+ *\r
+ * returns - status of function execution\r
+ *\r
+ */\r
+int hil_get_firmware(char *fw_name, unsigned int *start_addr, unsigned int *size){\r
+ return (config_get_firmware(fw_name , start_addr, size));\r
+}\r
diff --git a/common/hil/hil.h b/common/hil/hil.h
--- /dev/null
+++ b/common/hil/hil.h
@@ -0,0 +1,486 @@
+#ifndef _HIL_H_\r
+#define _HIL_H_\r
+\r
+/*\r
+ * Copyright (c) 2014, Mentor Graphics Corporation\r
+ * All rights reserved.\r
+ *\r
+ * Redistribution and use in source and binary forms, with or without\r
+ * modification, are permitted provided that the following conditions are met:\r
+ *\r
+ * 1. Redistributions of source code must retain the above copyright notice,\r
+ * this list of conditions and the following disclaimer.\r
+ * 2. Redistributions in binary form must reproduce the above copyright notice,\r
+ * this list of conditions and the following disclaimer in the documentation\r
+ * and/or other materials provided with the distribution.\r
+ * 3. Neither the name of the <ORGANIZATION> nor the names of its contributors\r
+ * may be used to endorse or promote products derived from this software\r
+ * without specific prior written permission.\r
+ *\r
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"\r
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\r
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\r
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE\r
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\r
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\r
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\r
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\r
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\r
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\r
+ * POSSIBILITY OF SUCH DAMAGE.\r
+ */\r
+\r
+/**************************************************************************\r
+ * FILE NAME\r
+ *\r
+ * hil.h\r
+ *\r
+ * DESCRIPTION\r
+ *\r
+ * This file defines interface layer to access hardware features. This\r
+ * interface is used by both RPMSG and remoteproc components.\r
+ *\r
+ ***************************************************************************/\r
+\r
+#include "../../virtio/virtio.h"\r
+#include "../../porting/config/config.h"\r
+\r
+/* Configurable parameters */\r
+#define HIL_MAX_CORES 2\r
+#define HIL_MAX_NUM_VRINGS 2\r
+#define HIL_MAX_NUM_CHANNELS 1\r
+/* Reserved CPU id */\r
+#define HIL_RSVD_CPU_ID 0xffffffff\r
+\r
+/**\r
+ * struct proc_shm\r
+ *\r
+ * This structure is maintained by hardware interface layer for\r
+ * shared memory information. The shared memory provides buffers\r
+ * for use by the vring to exchange messages between the cores.\r
+ *\r
+ */\r
+struct proc_shm\r
+{\r
+ /* Start address of shared memory used for buffers. */\r
+ void *start_addr;\r
+ /* Size of shared memory. */\r
+ unsigned long size;\r
+ /* Attributes for shared memory - cached or uncached. */\r
+ unsigned long flags;\r
+};\r
+\r
+/**\r
+* struct proc_intr\r
+*\r
+* This structure is maintained by hardware interface layer for\r
+* notification(interrupts) mechanism. The most common notification mechanism\r
+* is Inter-Processor Interrupt(IPI). There can be other mechanism depending\r
+* on SoC architecture.\r
+*\r
+*/\r
+struct proc_intr\r
+{\r
+ /* Interrupt number for vring - use for IPI */\r
+ unsigned int vect_id;\r
+ /* Interrupt priority */\r
+ unsigned int priority;\r
+ /* Interrupt trigger type */\r
+ unsigned int trigger_type;\r
+ /* Private data */\r
+ void *data;\r
+};\r
+\r
+/**\r
+* struct proc_vring\r
+*\r
+* This structure is maintained by hardware interface layer to keep\r
+* vring physical memory and notification info.\r
+*\r
+*/\r
+struct proc_vring\r
+{\r
+ /* Pointer to virtqueue encapsulating the vring */\r
+ struct virtqueue *vq;\r
+ /* Vring physical address */\r
+ void *phy_addr;\r
+ /* Number of vring descriptors */\r
+ unsigned short num_descs;\r
+ /* Vring alignment*/\r
+ unsigned long align;\r
+ /* Vring interrupt control block */\r
+ struct proc_intr intr_info;\r
+};\r
+\r
+/**\r
+ * struct proc_vdev\r
+ *\r
+ * This structure represents a virtio HW device for remote processor.\r
+ * Currently only one virtio device per processor is supported.\r
+ *\r
+ */\r
+struct proc_vdev\r
+{\r
+ /* Number of vrings*/\r
+ unsigned int num_vrings;\r
+ /* Virtio device features */\r
+ unsigned int dfeatures;\r
+ /* Virtio gen features */\r
+ unsigned int gfeatures;\r
+ /* Vring info control blocks */\r
+ struct proc_vring vring_info[HIL_MAX_NUM_VRINGS];\r
+};\r
+\r
+/**\r
+ * struct proc_chnl\r
+ *\r
+ * This structure represents channel IDs that would be used by\r
+ * the remote in the name service message. This will be extended\r
+ * further to support static channel creation.\r
+ *\r
+ */\r
+struct proc_chnl\r
+{\r
+ /* Channel ID */\r
+ char name[32];\r
+};\r
+\r
+/**\r
+* struct hil_proc\r
+*\r
+* This structure represents a remote processor and encapsulates shared\r
+* memory and notification info required for IPC.\r
+*\r
+*/\r
+struct hil_proc\r
+{\r
+ /* CPU ID as defined by the platform */\r
+ unsigned long cpu_id;\r
+ /* Shared memory info */\r
+ struct proc_shm sh_buff;\r
+ /* Virtio device hardware info */\r
+ struct proc_vdev vdev;\r
+ /* Number of RPMSG channels */\r
+ unsigned long num_chnls;\r
+ /* RPMsg channels array */\r
+ struct proc_chnl chnls[HIL_MAX_NUM_CHANNELS];\r
+ /* HIL platform ops table */\r
+ struct hil_platform_ops *ops;\r
+ /* Attrbites to represent processor role, master or remote . This field is for\r
+ * future use. */\r
+ unsigned long attr;\r
+ /*\r
+ * CPU bitmask - shared variable updated by each core\r
+ * after it has been initialized. This field is for future use.\r
+ */\r
+ unsigned long cpu_bitmask;\r
+ /* Spin lock - This field is for future use. */\r
+ volatile unsigned int *slock;\r
+};\r
+\r
+/**\r
+ * struct hil_proc_list\r
+ *\r
+ * This structure serves as lists for cores present in the system.\r
+ * It provides entry point to access remote core parameters.\r
+ *\r
+ */\r
+struct hil_proc_list {\r
+ struct llist *proc_list;\r
+};\r
+\r
+/**\r
+ * hil_create_proc\r
+ *\r
+ * This function creates a HIL proc instance for given CPU id and populates\r
+ * it with platform info.\r
+ *\r
+ * @param cpu_id - cpu id\r
+ *\r
+ * @return - pointer to proc instance\r
+ *\r
+ */\r
+struct hil_proc *hil_create_proc(int cpu_id);\r
+\r
+/**\r
+ * hil_delete_proc\r
+ *\r
+ * This function deletes the given proc instance and frees the\r
+ * associated resources.\r
+ *\r
+ * @param proc - pointer to HIL proc instance\r
+ *\r
+ */\r
+void hil_delete_proc(struct hil_proc *proc);\r
+\r
+/**\r
+ * hil_get_proc\r
+ *\r
+ * This function finds the proc instance based on the given ID\r
+ * from the proc list and returns it to user.\r
+ *\r
+ * @param cpu_id - cpu id\r
+ *\r
+ * @return - pointer to proc instance\r
+ *\r
+ */\r
+struct hil_proc *hil_get_proc(int cpu_id);\r
+\r
+/**\r
+ * hil_isr()\r
+ *\r
+ * This function is called when interrupt is received for the vring.\r
+ * This function gets the corresponding virtqueue and generates\r
+ * call back for it.\r
+ *\r
+ * @param vring_hw - pointer to vring control block\r
+ *\r
+ */\r
+void hil_isr(struct proc_vring *vring_hw);\r
+\r
+/**\r
+ * hil_get_cpuforfw\r
+ *\r
+ * This function provides the CPU ID for the given firmware.\r
+ *\r
+ * @param fw_name - name of firmware\r
+ *\r
+ * @return - cpu id\r
+ *\r
+ */\r
+int hil_get_cpuforfw(char *fw_name);\r
+\r
+/**\r
+ * hil_get_vdev_info\r
+ *\r
+ * This function return virtio device for remote core.\r
+ *\r
+ * @param proc - pointer to remote proc\r
+ *\r
+ * @return - pointer to virtio HW device.\r
+ *\r
+ */\r
+struct proc_vdev *hil_get_vdev_info(struct hil_proc *proc);\r
+\r
+/**\r
+ * hil_get_chnl_info\r
+ *\r
+ * This function returns channels info for given proc.\r
+ *\r
+ * @param proc - pointer to proc info struct\r
+ * @param num_chnls - pointer to integer variable to hold\r
+ * number of available channels\r
+ *\r
+ * @return - pointer to channel info control block\r
+ *\r
+ */\r
+struct proc_chnl *hil_get_chnl_info(struct hil_proc *proc , int *num_chnls);\r
+\r
+/**\r
+ * hil_get_vring_info\r
+ *\r
+ * This function returns vring_info_table. The caller will use\r
+ * this table to get the vring HW info which will be subsequently\r
+ * used to create virtqueues.\r
+ *\r
+ * @param vdev - pointer to virtio HW device\r
+ * @param num_vrings - pointer to hold number of vrings\r
+ *\r
+ * @return - pointer to vring hardware info table\r
+ */\r
+struct proc_vring *hil_get_vring_info(struct proc_vdev *vdev, int *num_vrings);\r
+\r
+/**\r
+ * hil_get_shm_info\r
+ *\r
+ * This function returns shared memory info control block. The caller\r
+ * will use this information to create and manage memory buffers for\r
+ * vring descriptor table.\r
+ *\r
+ * @param proc - pointer to proc instance\r
+ *\r
+ * @return - pointer to shared memory region used for buffers\r
+ *\r
+ */\r
+struct proc_shm *hil_get_shm_info(struct hil_proc *proc);\r
+\r
+/**\r
+ * hil_enable_vring_notifications()\r
+ *\r
+ * This function is called after successful creation of virtqueues.\r
+ * This function saves queue handle in the vring_info_table which\r
+ * will be used during interrupt handling .This function setups\r
+ * interrupt handlers.\r
+ *\r
+ * @param vring_index - index to vring HW table\r
+ * @param vq - pointer to virtqueue to save in vring HW table\r
+ *\r
+ * @return - execution status\r
+ */\r
+int hil_enable_vring_notifications(int vring_index, struct virtqueue *vq);\r
+\r
+/**\r
+ * hil_vring_notify()\r
+ *\r
+ * This function generates IPI to let the other side know that there is\r
+ * job available for it. The required information to achieve this, like interrupt\r
+ * vector, CPU id etc is be obtained from the proc_vring table.\r
+ *\r
+ * @param vq - pointer to virtqueue\r
+ *\r
+ */\r
+void hil_vring_notify(struct virtqueue *vq);\r
+\r
+/**\r
+ * hil_get_status\r
+ *\r
+ * This function is used to check if the given core is up and running.\r
+ * This call will return after it is confirmed that remote core has\r
+ * started.\r
+ *\r
+ * @param proc - pointer to proc instance\r
+ *\r
+ * @return - execution status\r
+ */\r
+int hil_get_status(struct hil_proc *proc);\r
+\r
+/**\r
+ * hil_set_status\r
+ *\r
+ * This function is used to update the status\r
+ * of the given core i.e it is ready for IPC.\r
+ *\r
+ * @param proc - pointer to remote proc\r
+ *\r
+ * @return - execution status\r
+ */\r
+\r
+int hil_set_status(struct hil_proc *proc);\r
+\r
+/**\r
+ * hil_boot_cpu\r
+ *\r
+ * This function starts remote processor at given address.\r
+ *\r
+ * @param proc - pointer to remote proc\r
+ * @param load_addr - load address of remote firmware\r
+ *\r
+ * @return - execution status\r
+ */\r
+int hil_boot_cpu(struct hil_proc *proc , unsigned int load_addr);\r
+\r
+/**\r
+ * hil_shutdown_cpu\r
+ *\r
+ * This function shutdowns the remote processor\r
+ *\r
+ * @param proc - pointer to remote proc\r
+ *\r
+ */\r
+void hil_shutdown_cpu(struct hil_proc *proc);\r
+\r
+/**\r
+ * hil_get_firmware\r
+ *\r
+ * This function returns address and size of given firmware name passed as\r
+ * parameter.\r
+ *\r
+ * @param fw_name - name of the firmware\r
+ * @param start_addr - pointer t hold start address of firmware\r
+ * @param size - pointer to hold size of firmware\r
+ *\r
+ * returns - status of function execution\r
+ *\r
+ */\r
+int hil_get_firmware(char *fw_name, unsigned int *start_addr, unsigned int *size);\r
+\r
+/**\r
+ *\r
+ * This structure is an interface between HIL and platform porting\r
+ * component. It is required for the user to provide definitions of\r
+ * these functions when framework is ported to new hardware platform.\r
+ *\r
+ */\r
+struct hil_platform_ops\r
+{\r
+ /**\r
+ * enable_interrupt()\r
+ *\r
+ * This function enables interrupt(IPI) for given vring.\r
+ *\r
+ * @param vring_hw - pointer to vring control block\r
+ *\r
+ * @return - execution status\r
+ */\r
+ int (*enable_interrupt)(struct proc_vring *vring_hw);\r
+\r
+ /**\r
+ * notify()\r
+ *\r
+ * This function generates IPI to let the other side know that there is\r
+ * job available for it.\r
+ *\r
+ * @param cpu_id - ID of CPU which is to be notified\r
+ * @param intr_info - pointer to interrupt info control block\r
+ */\r
+ void (*notify)(int cpu_id , struct proc_intr *intr_info);\r
+\r
+ /**\r
+ * get_status\r
+ *\r
+ * This function is used to check if the given core is\r
+ * up and running. This call will return after it is confirmed\r
+ * that remote core is initialized.\r
+ *\r
+ * @param cpu_id - ID of CPU for which status is requested.\r
+ *\r
+ * @return - execution status\r
+ */\r
+ int (*get_status)(int cpu_id);\r
+\r
+ /**\r
+ * set_status\r
+ *\r
+ * This function is used to update the status\r
+ * of the given core i.e it is ready for IPC.\r
+ *\r
+ * @param cpu_id - ID of CPU for which status is to be set\r
+ *\r
+ * @return - execution status\r
+ */\r
+\r
+ int (*set_status)(int cpu_id);\r
+\r
+ /**\r
+ * boot_cpu\r
+ *\r
+ * This function boots the remote processor.\r
+ *\r
+ * @param cpu_id - ID of CPU to boot\r
+ * @param start_addr - start address of remote cpu\r
+ *\r
+ * @return - execution status\r
+ */\r
+ int (*boot_cpu)(int cpu_id , unsigned int start_addr);\r
+\r
+ /**\r
+ * shutdown_cpu\r
+ *\r
+ * This function shutdowns the remote processor.\r
+ *\r
+ * @param cpu_id - ID of CPU to shutdown\r
+ *\r
+ */\r
+ void (*shutdown_cpu)(int cpu_id);\r
+\r
+};\r
+\r
+/* Utility macros for register read/write */\r
+#define HIL_MEM_READ8(addr) *(volatile unsigned char *)(addr)\r
+#define HIL_MEM_READ16(addr) *(volatile unsigned short *)(addr)\r
+#define HIL_MEM_READ32(addr) *(volatile unsigned long *)(addr)\r
+#define HIL_MEM_WRITE8(addr,data) *(volatile unsigned char *)(addr) = (unsigned char)(data)\r
+#define HIL_MEM_WRITE16(addr,data) *(volatile unsigned short *)(addr) = (unsigned short)(data)\r
+#define HIL_MEM_WRITE32(addr,data) *(volatile unsigned long *)(addr) = (unsigned long)(data)\r
+\r
+#endif /* _HIL_H_ */\r
diff --git a/common/llist/llist.c b/common/llist/llist.c
--- /dev/null
+++ b/common/llist/llist.c
@@ -0,0 +1,100 @@
+/*\r
+ * Copyright (c) 2014, Mentor Graphics Corporation\r
+ * All rights reserved.\r
+ *\r
+ * Redistribution and use in source and binary forms, with or without\r
+ * modification, are permitted provided that the following conditions are met:\r
+ *\r
+ * 1. Redistributions of source code must retain the above copyright notice,\r
+ * this list of conditions and the following disclaimer.\r
+ * 2. Redistributions in binary form must reproduce the above copyright notice,\r
+ * this list of conditions and the following disclaimer in the documentation\r
+ * and/or other materials provided with the distribution.\r
+ * 3. Neither the name of Mentor Graphics Corporation nor the names of its\r
+ * contributors may be used to endorse or promote products derived from this\r
+ * software without specific prior written permission.\r
+ *\r
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"\r
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\r
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\r
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE\r
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\r
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\r
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\r
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\r
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\r
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\r
+ * POSSIBILITY OF SUCH DAMAGE.\r
+ */\r
+\r
+/**************************************************************************\r
+ * FILE NAME\r
+ *\r
+ * llist.c\r
+ *\r
+ * COMPONENT\r
+ *\r
+ * OpenAMP stack.\r
+ *\r
+ * DESCRIPTION\r
+ *\r
+ * Source file for basic linked list service.\r
+ *\r
+ **************************************************************************/\r
+#include "llist.h"\r
+\r
+#define LIST_NULL ((void *)0)\r
+/**\r
+ * add_to_list\r
+ *\r
+ * Places new element at the start of the list.\r
+ *\r
+ * @param head - list head\r
+ * @param node - new element to add\r
+ *\r
+ */\r
+void add_to_list(struct llist **head, struct llist *node) {\r
+\r
+ if (!node)\r
+ return;\r
+\r
+ if (*head) {\r
+ /* Place the new element at the start of list. */\r
+ node->next = *head;\r
+ node->prev = LIST_NULL;\r
+ (*head)->prev = node;\r
+ *head = node;\r
+ } else {\r
+ /* List is empty - assign new element to list head. */\r
+ *head = node;\r
+ (*head)->next = LIST_NULL;\r
+ (*head)->prev = LIST_NULL;\r
+ }\r
+}\r
+\r
+/**\r
+ * remove_from_list\r
+ *\r
+ * Removes the given element from the list.\r
+ *\r
+ * @param head - list head\r
+ * @param element - element to remove from list\r
+ *\r
+ */\r
+void remove_from_list(struct llist **head, struct llist *node) {\r
+\r
+ if (!(*head) || !(node))\r
+ return;\r
+\r
+ if (node == *head) {\r
+ /* First element has to be removed. */\r
+ *head = (*head)->next;\r
+ } else if (node->next == LIST_NULL) {\r
+ /* Last element has to be removed. */\r
+ node->prev->next = node->next;\r
+ } else {\r
+ /* Intermediate element has to be removed. */\r
+ node->prev->next = node->next;\r
+ node->next->prev = node->prev;\r
+ }\r
+}\r
diff --git a/common/llist/llist.h b/common/llist/llist.h
--- /dev/null
+++ b/common/llist/llist.h
@@ -0,0 +1,59 @@
+/*\r
+ * Copyright (c) 2014, Mentor Graphics Corporation\r
+ * All rights reserved.\r
+ *\r
+ * Redistribution and use in source and binary forms, with or without\r
+ * modification, are permitted provided that the following conditions are met:\r
+ *\r
+ * 1. Redistributions of source code must retain the above copyright notice,\r
+ * this list of conditions and the following disclaimer.\r
+ * 2. Redistributions in binary form must reproduce the above copyright notice,\r
+ * this list of conditions and the following disclaimer in the documentation\r
+ * and/or other materials provided with the distribution.\r
+ * 3. Neither the name of Mentor Graphics Corporation nor the names of its\r
+ * contributors may be used to endorse or promote products derived from this\r
+ * software without specific prior written permission.\r
+ *\r
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"\r
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\r
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\r
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE\r
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\r
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\r
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\r
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\r
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\r
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\r
+ * POSSIBILITY OF SUCH DAMAGE.\r
+ */\r
+\r
+\r
+/**************************************************************************\r
+ * FILE NAME\r
+ *\r
+ * llist.h\r
+ *\r
+ * COMPONENT\r
+ *\r
+ * OpenAMP stack.\r
+ *\r
+ * DESCRIPTION\r
+ *\r
+ * Header file for linked list service.\r
+ *\r
+ **************************************************************************/\r
+\r
+#ifndef LLIST_H_\r
+#define LLIST_H_\r
+\r
+struct llist {\r
+ void *data;\r
+ unsigned int attr;\r
+ struct llist *next;\r
+ struct llist *prev;\r
+};\r
+\r
+void add_to_list(struct llist **head, struct llist *node);\r
+void remove_from_list(struct llist **head, struct llist *node);\r
+\r
+#endif /* LLIST_H_ */\r
diff --git a/common/shm/sh_mem.c b/common/shm/sh_mem.c
--- /dev/null
+++ b/common/shm/sh_mem.c
@@ -0,0 +1,230 @@
+/*\r
+ * Copyright (c) 2014, Mentor Graphics Corporation\r
+ * All rights reserved.\r
+ *\r
+ * Redistribution and use in source and binary forms, with or without\r
+ * modification, are permitted provided that the following conditions are met:\r
+ *\r
+ * 1. Redistributions of source code must retain the above copyright notice,\r
+ * this list of conditions and the following disclaimer.\r
+ * 2. Redistributions in binary form must reproduce the above copyright notice,\r
+ * this list of conditions and the following disclaimer in the documentation\r
+ * and/or other materials provided with the distribution.\r
+ * 3. Neither the name of Mentor Graphics Corporation nor the names of its\r
+ * contributors may be used to endorse or promote products derived from this\r
+ * software without specific prior written permission.\r
+ *\r
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"\r
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\r
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\r
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE\r
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\r
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\r
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\r
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\r
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\r
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\r
+ * POSSIBILITY OF SUCH DAMAGE.\r
+ */\r
+/**************************************************************************\r
+ * FILE NAME\r
+ *\r
+ * sh_mem.c\r
+ *\r
+ * COMPONENT\r
+ *\r
+ * OpenAMP stack.\r
+ *\r
+ * DESCRIPTION\r
+ *\r
+ * Source file for fixed buffer size memory management service. Currently\r
+ * it is only being used to manage shared memory.\r
+ *\r
+ **************************************************************************/\r
+#include "sh_mem.h"\r
+\r
+/**\r
+ * sh_mem_create_pool\r
+ *\r
+ * Creates new memory pool with the given parameters.\r
+ *\r
+ * @param start_addr - start address of the memory region\r
+ * @param size - size of the memory\r
+ * @param buff_size - fixed buffer size\r
+ *\r
+ * @return - pointer to memory pool\r
+ *\r
+ */\r
+struct sh_mem_pool * sh_mem_create_pool(void *start_addr, unsigned int size,\r
+ unsigned int buff_size) {\r
+ struct sh_mem_pool *mem_pool;\r
+ int status, pool_size;\r
+ int num_buffs, bmp_size;\r
+\r
+ if (!start_addr || !size || !buff_size)\r
+ return NULL;\r
+\r
+ /* Word align the buffer size */\r
+ buff_size = WORD_ALIGN(buff_size);\r
+\r
+ /* Get number of buffers. */\r
+ num_buffs = (size / buff_size) + ((size % buff_size) == 0 ? 0 : 1);\r
+\r
+ /*\r
+ * Size of the bitmap required to maintain buffers info. One word(32 bit) can\r
+ * keep track of 32 buffers.\r
+ */\r
+ bmp_size = (num_buffs / BITMAP_WORD_SIZE)\r
+ + ((num_buffs % BITMAP_WORD_SIZE) == 0 ? 0 : 1);\r
+\r
+ /* Total size required for pool control block. */\r
+ pool_size = sizeof(struct sh_mem_pool) + WORD_SIZE * bmp_size;\r
+\r
+ /* Create pool control block. */\r
+ mem_pool = env_allocate_memory(pool_size);\r
+\r
+ if (mem_pool) {\r
+ /* Initialize pool parameters */\r
+ env_memset(mem_pool, 0x00, pool_size);\r
+ status = env_create_mutex(&mem_pool->lock , 1);\r
+ if (status){\r
+ env_free_memory(mem_pool);\r
+ return NULL;\r
+ }\r
+ mem_pool->start_addr = start_addr;\r
+ mem_pool->buff_size = buff_size;\r
+ mem_pool->bmp_size = bmp_size;\r
+ mem_pool->total_buffs = num_buffs;\r
+ }\r
+\r
+ return mem_pool;\r
+}\r
+\r
+/**\r
+ * sh_mem_get_buffer\r
+ *\r
+ * Allocates fixed size buffer from the given memory pool.\r
+ *\r
+ * @param pool - pointer to memory pool\r
+ *\r
+ * @return - pointer to allocated buffer\r
+ *\r
+ */\r
+void * sh_mem_get_buffer(struct sh_mem_pool *pool) {\r
+ void *buff = NULL;\r
+ int idx, bit_idx;\r
+\r
+ if (!pool)\r
+ return NULL;\r
+\r
+ env_lock_mutex(pool->lock);\r
+\r
+ if (pool->used_buffs >= pool->total_buffs) {\r
+ env_unlock_mutex(pool->lock);\r
+ return NULL;\r
+ }\r
+\r
+ for (idx = 0; idx < pool->bmp_size; idx++) {\r
+ /*\r
+ * Find the first 0 bit in the buffers bitmap. The 0th bit\r
+ * represents a free buffer.\r
+ */\r
+ bit_idx = get_first_zero_bit(pool->bitmap[idx]);\r
+ if (bit_idx < 32) {\r
+ /* Set bit to mark it as consumed. */\r
+ pool->bitmap[idx] |= (1 << bit_idx);\r
+ buff = (char *) pool->start_addr +\r
+ pool->buff_size * (idx * BITMAP_WORD_SIZE + bit_idx);\r
+ pool->used_buffs++;\r
+ break;\r
+ }\r
+ }\r
+\r
+ env_unlock_mutex(pool->lock);\r
+\r
+ return buff;\r
+}\r
+\r
+/**\r
+ * sh_mem_free_buffer\r
+ *\r
+ * Frees the given buffer.\r
+ *\r
+ * @param pool - pointer to memory pool\r
+ * @param buff - pointer to buffer\r
+ *\r
+ * @return - none\r
+ */\r
+void sh_mem_free_buffer(void *buff, struct sh_mem_pool *pool) {\r
+ unsigned long *bitmask;\r
+ int bmp_idx, bit_idx, buff_idx;\r
+\r
+ if (!pool || !buff)\r
+ return;\r
+\r
+ /* Acquire the pool lock */\r
+ env_lock_mutex(pool->lock);\r
+\r
+ /* Map the buffer address to its index. */\r
+ buff_idx = ((char *) buff - (char*) pool->start_addr) / pool->buff_size;\r
+\r
+ /* Translate the buffer index to bitmap index. */\r
+ bmp_idx = buff_idx / BITMAP_WORD_SIZE;\r
+ bit_idx = buff_idx % BITMAP_WORD_SIZE;\r
+ bitmask = &pool->bitmap[bmp_idx];\r
+\r
+ /* Mark the buffer as free */\r
+ *bitmask ^= (1 << bit_idx);\r
+\r
+ pool->used_buffs--;\r
+\r
+ /* Release the pool lock. */\r
+ env_unlock_mutex(pool->lock);\r
+\r
+}\r
+\r
+/**\r
+ * sh_mem_delete_pool\r
+ *\r
+ * Deletes the given memory pool.\r
+ *\r
+ * @param pool - pointer to memory pool\r
+ *\r
+ * @return - none\r
+ */\r
+void sh_mem_delete_pool(struct sh_mem_pool *pool) {\r
+\r
+ if (pool) {\r
+ env_delete_mutex(pool->lock);\r
+ env_free_memory(pool);\r
+ }\r
+}\r
+\r
+/**\r
+ * get_first_zero_bit\r
+ *\r
+ * Provides position of first 0 bit in a 32 bit value\r
+ *\r
+ * @param value - given value\r
+ *\r
+ * @return - 0th bit position\r
+ */\r
+unsigned int get_first_zero_bit(unsigned long value) {\r
+ unsigned int idx;\r
+ unsigned int tmp32;\r
+\r
+ /* Invert value */\r
+ value = ~value;\r
+\r
+ /* (~value) & (2's complement of value) */\r
+ value = (value & (-value)) - 1;\r
+\r
+ /* log2(value) */\r
+\r
+ tmp32 = value - ((value >> 1) & 033333333333)\r
+ - ((value >> 2) & 011111111111);\r
+\r
+ idx = ((tmp32 + (tmp32 >> 3)) & 030707070707) % 63;\r
+\r
+ return idx;\r
+}\r
diff --git a/common/shm/sh_mem.h b/common/shm/sh_mem.h
--- /dev/null
+++ b/common/shm/sh_mem.h
@@ -0,0 +1,89 @@
+/*\r
+ * Copyright (c) 2014, Mentor Graphics Corporation\r
+ * All rights reserved.\r
+ *\r
+ * Redistribution and use in source and binary forms, with or without\r
+ * modification, are permitted provided that the following conditions are met:\r
+ *\r
+ * 1. Redistributions of source code must retain the above copyright notice,\r
+ * this list of conditions and the following disclaimer.\r
+ * 2. Redistributions in binary form must reproduce the above copyright notice,\r
+ * this list of conditions and the following disclaimer in the documentation\r
+ * and/or other materials provided with the distribution.\r
+ * 3. Neither the name of Mentor Graphics Corporation nor the names of its\r
+ * contributors may be used to endorse or promote products derived from this\r
+ * software without specific prior written permission.\r
+ *\r
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"\r
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\r
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\r
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE\r
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\r
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\r
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\r
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\r
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\r
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\r
+ * POSSIBILITY OF SUCH DAMAGE.\r
+ */\r
+\r
+/**************************************************************************\r
+ * FILE NAME\r
+ *\r
+ * sh_mem.c\r
+ *\r
+ * COMPONENT\r
+ *\r
+ * IPC Stack for uAMP systems.\r
+ *\r
+ * DESCRIPTION\r
+ *\r
+ * Header file for fixed buffer size memory management service. Currently\r
+ * it is being used to manage shared memory.\r
+ *\r
+ **************************************************************************/\r
+#ifndef SH_MEM_H_\r
+#define SH_MEM_H_\r
+\r
+#include "../../porting/env/env.h"\r
+\r
+\r
+/* Macros */\r
+#define BITMAP_WORD_SIZE 32\r
+#define WORD_SIZE sizeof(unsigned long)\r
+#define WORD_ALIGN(a) (((a) & (WORD_SIZE-1)) != 0)? \\r
+ (((a) & (~(WORD_SIZE-1))) + 4):(a)\r
+/*\r
+ * This structure represents a shared memory pool.\r
+ *\r
+ * @start_addr - start address of shared memory region\r
+ * @lock - lock to ensure exclusive access\r
+ * @size - size of shared memory*\r
+ * @buff_size - size of each buffer\r
+ * @total_buffs - total number of buffers in shared memory region\r
+ * @used_buffs - number of used buffers\r
+ * @bmp_size - size of bitmap array\r
+ * @bitmap - array to keep record of free and used blocks\r
+ *\r
+ */\r
+\r
+struct sh_mem_pool {\r
+ void *start_addr;\r
+ LOCK *lock;\r
+ int size;\r
+ int buff_size;\r
+ int total_buffs;\r
+ int used_buffs;\r
+ int bmp_size;\r
+ unsigned long bitmap[0];\r
+};\r
+\r
+/* APIs */\r
+struct sh_mem_pool *sh_mem_create_pool(void *start_addr, unsigned int size,\r
+ unsigned int buff_size);\r
+void sh_mem_delete_pool(struct sh_mem_pool *pool);\r
+void *sh_mem_get_buffer(struct sh_mem_pool *pool);\r
+void sh_mem_free_buffer(void *ptr, struct sh_mem_pool *pool);\r
+unsigned int get_first_zero_bit(unsigned long value);\r
+\r
+#endif /* SH_MEM_H_ */\r
diff --git a/docs/openamp_gs.pdf b/docs/openamp_gs.pdf
new file mode 100644 (file)
index 0000000..1278764
Binary files /dev/null and b/docs/openamp_gs.pdf differ
index 0000000..1278764
Binary files /dev/null and b/docs/openamp_gs.pdf differ
diff --git a/docs/openamp_perf_meas_gd.pdf b/docs/openamp_perf_meas_gd.pdf
new file mode 100644 (file)
index 0000000..882442a
Binary files /dev/null and b/docs/openamp_perf_meas_gd.pdf differ
index 0000000..882442a
Binary files /dev/null and b/docs/openamp_perf_meas_gd.pdf differ
diff --git a/docs/openamp_ref.pdf b/docs/openamp_ref.pdf
new file mode 100644 (file)
index 0000000..47fc3f9
Binary files /dev/null and b/docs/openamp_ref.pdf differ
index 0000000..47fc3f9
Binary files /dev/null and b/docs/openamp_ref.pdf differ
diff --git a/include/open_amp.h b/include/open_amp.h
--- /dev/null
+++ b/include/open_amp.h
@@ -0,0 +1,37 @@
+/*\r
+ * Copyright (c) 2014, Mentor Graphics Corporation\r
+ * All rights reserved.\r
+ *\r
+ * Redistribution and use in source and binary forms, with or without\r
+ * modification, are permitted provided that the following conditions are met:\r
+ *\r
+ * 1. Redistributions of source code must retain the above copyright notice,\r
+ * this list of conditions and the following disclaimer.\r
+ * 2. Redistributions in binary form must reproduce the above copyright notice,\r
+ * this list of conditions and the following disclaimer in the documentation\r
+ * and/or other materials provided with the distribution.\r
+ * 3. Neither the name of Mentor Graphics Corporation nor the names of its\r
+ * contributors may be used to endorse or promote products derived from this\r
+ * software without specific prior written permission.\r
+ *\r
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"\r
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\r
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\r
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE\r
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\r
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\r
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\r
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\r
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\r
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\r
+ * POSSIBILITY OF SUCH DAMAGE.\r
+ */\r
+\r
+#ifndef MEMF_H_\r
+#define MEMF_H_\r
+\r
+#include "../rpmsg/rpmsg.h"\r
+#include "../remoteproc/remoteproc.h"\r
+\r
+\r
+#endif /* MEMF_H_ */\r
diff --git a/libs/system/zc702evk/baremetal/Makefile b/libs/system/zc702evk/baremetal/Makefile
--- /dev/null
@@ -0,0 +1,15 @@
+# Make file to create baremetal lib.\r
+\r
+\r
+all: \r
+ make -f make_remote\r
+ make -f make_remote clean\r
+ make -f make_master\r
+ make -f make_master clean\r
+ make -f make_remote_rpc\r
+clean:\r
+ make -f make_remote clean\r
+ make -f make_master clean\r
+ make -f make_remote_rpc clean\r
+\r
+PHONY: all clean\r
diff --git a/libs/system/zc702evk/baremetal/Makefile.commons b/libs/system/zc702evk/baremetal/Makefile.commons
--- /dev/null
@@ -0,0 +1,20 @@
+\r
+TOOLSET := csgnu\r
+CROSS := arm-xilinx-eabi-\r
+CFLAGS := -Wall -ffunction-sections -fdata-sections -O0 -g3 -MMD \r
+CXXFLAGS := -Wall -fno-enforce-eh-specs -MMD\r
+ASFLAGS := -gdwarf2 -meabi=4 -mcpu=cortex-a9 -mfpu=neon -MMD\r
+ARFLAGS := \r
+ARCH_CFLAGS := -gdwarf-2 -mthumb-interwork -mcpu=cortex-a9\r
+ARCH_CXXFLAGS := -gdwarf-2 -mthumb-interwork -mcpu=cortex-a9\r
+ARCH_ASFLAGS := -gdwarf-2 -mthumb-interwork -mcpu=cortex-a9\r
+ARCH_ARFLAGS := \r
+CC = $(CROSS)gcc\r
+CXX = $(CROSS)g++\r
+AS = $(CROSS)as\r
+AR = $(CROSS)ar\r
+LD = $(CROSS)gcc\r
+INCLUDE := \r
+RM := rm -f\r
+CP := cp\r
+\r
diff --git a/libs/system/zc702evk/baremetal/baremetal.c b/libs/system/zc702evk/baremetal/baremetal.c
--- /dev/null
@@ -0,0 +1,589 @@
+/*
+ * Copyright (c) 2014, Mentor Graphics Corporation
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * 3. Neither the name of the <ORGANIZATION> nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+#include <stdio.h>
+#include <string.h>
+#include "baremetal.h"
+
+unsigned char ARM_AR_ISR_IRQ_Data[ARM_AR_ISR_STACK_SIZE];
+unsigned char ARM_AR_ISR_FIQ_Data[ARM_AR_ISR_STACK_SIZE];
+unsigned char ARM_AR_ISR_SUP_Stack[ARM_AR_ISR_STACK_SIZE];
+unsigned char ARM_AR_ISR_SYS_Stack[ARM_AR_ISR_STACK_SIZE];
+
+static inline unsigned int get_cpu_id_arm(void);
+
+int zc702evk_gic_initialize() {
+
+ unsigned long reg_val;
+
+ /* Disable architecture interrupts (IRQ and FIQ)
+ * before initialization */
+ ARM_AR_CPSR_CXSF_READ(®_val);
+ reg_val |= (0x02 << 6);
+ ARM_AR_CPSR_CXSF_WRITE(reg_val);
+
+ zc702evk_gic_pr_int_initialize();
+
+ /* Enable architecture Interrupts */
+ ARM_AR_CPSR_CXSF_READ(®_val);
+ reg_val &= ~(0x02 << 6);
+ ARM_AR_CPSR_CXSF_WRITE(reg_val);
+
+ return 0;
+}
+
+/* Only applicable for remote/slave node */
+void zc702evk_gic_pr_int_initialize(void) {
+
+ /* Disable the GIC controller */
+ MEM_WRITE32(INT_GIC_DIST_BASE + INT_GIC_DIST_CTRL, 0x00000000);
+
+ /* Enable the interrupt distributor controller */
+ MEM_WRITE32(INT_GIC_DIST_BASE + INT_GIC_DIST_CTRL, INT_DIST_ENABLE);
+
+ /* Secondary cores just need to disable their private interrupts */
+ MEM_WRITE32(INT_GIC_DIST_BASE + INT_GIC_DIST_ENABLE_CLEAR + 0x00,
+ 0xffffffff);
+ /* 0 - 31 */
+
+ MEM_WRITE32(INT_GIC_DIST_BASE + INT_GIC_DIST_CONFIG + 0x00, 0xAAAAAAAA);
+ /* 0 - 15 */
+ MEM_WRITE32(INT_GIC_DIST_BASE + INT_GIC_DIST_CONFIG + 0x04, 0xAAAAAAAA);
+
+ /* Disable the CPU Interface */
+ MEM_WRITE32(INT_GIC_CPU_BASE + INT_GIC_CPU_CTRL, 0x00000000);
+
+ /* Allow interrupts with more priority (i.e. lower number) than FF */
+ MEM_WRITE32(INT_GIC_CPU_BASE + INT_GIC_CPU_PRIORITY, 0x000000FF);
+
+ /* No binary point */
+ MEM_WRITE32(INT_GIC_CPU_BASE + INT_GIC_CPU_POINT, 0x00000000);
+
+ /* Enable the CPU Interface */
+ MEM_WRITE32(INT_GIC_CPU_BASE + INT_GIC_CPU_CTRL, INT_CPU_ENABLE);
+}
+
+int zc702evk_gic_interrupt_enable(int vector_id, INT_TRIG_TYPE trigger_type,
+ int priority) {
+ unsigned long reg_offset;
+ unsigned long bit_shift;
+ unsigned long temp32 = 0;
+ unsigned long targ_cpu;
+
+ temp32 = get_cpu_id_arm();
+
+ /* Determine the necessary bit shift in this target / priority register
+ for this interrupt vector ID */
+ bit_shift = ((vector_id) % 4) * 8;
+
+ /* Build a target value based on the bit shift calculated above and the CPU core
+ that this code is executing on */
+ targ_cpu = (1 << temp32) << bit_shift;
+
+ /* Determine the Global interrupt controller target / priority register
+ offset for this interrupt vector ID
+ NOTE: Each target / priority register supports 4 interrupts */
+ reg_offset = ((vector_id) / 4) * 4;
+
+ /* Read-modify-write the priority register for this interrupt */
+ temp32 = MEM_READ32(INT_GIC_DIST_BASE + INT_GIC_DIST_PRI + reg_offset);
+
+ /* Set new priority. */
+ temp32 |= (priority << (bit_shift + 4));
+ MEM_WRITE32(INT_GIC_DIST_BASE + INT_GIC_DIST_PRI + reg_offset, temp32);
+
+ /* Read-modify-write the target register for this interrupt to allow this
+ cpu to accept this interrupt */
+ temp32 = MEM_READ32(INT_GIC_DIST_BASE + INT_GIC_DIST_TARGET + reg_offset);
+ temp32 |= targ_cpu;
+ MEM_WRITE32(INT_GIC_DIST_BASE + INT_GIC_DIST_TARGET + reg_offset, temp32);
+
+ /* Determine the Global interrupt controller enable set register offset
+ for this vector ID
+ NOTE: There are 32 interrupts in each enable set register */
+ reg_offset = (vector_id / 32) * 4;
+
+ /* Write to the appropriate bit in the enable set register for this
+ vector ID to enable the interrupt */
+
+ temp32 = (1UL << (vector_id - (reg_offset * 0x08)));
+ MEM_WRITE32(INT_GIC_DIST_BASE + INT_GIC_DIST_ENABLE_SET + reg_offset,
+ temp32);
+
+ /* Return the vector ID */
+ return (vector_id);
+}
+
+int zc702evk_gic_interrupt_disable(int vector_id) {
+ unsigned long reg_offset;
+ unsigned long bit_shift;
+ unsigned long temp32 = 0;
+ unsigned long targ_cpu;
+
+ temp32 = get_cpu_id_arm();
+
+ /* Determine the Global interrupt controller enable set register offset
+ for this vector ID
+ NOTE: There are 32 interrupts in each enable set register */
+ reg_offset = (vector_id / 32) * 4;
+
+ /* Write to the appropriate bit in the enable clear register for this
+ vector ID to disable the interrupt */
+
+ MEM_WRITE32(INT_GIC_DIST_BASE + INT_GIC_DIST_ENABLE_CLEAR + reg_offset,
+ (1UL << (vector_id - (reg_offset * 0x08))));
+
+ /* Determine the Global interrupt controller target register offset for
+ this interrupt vector ID
+ NOTE: Each target register supports 4 interrupts */
+ reg_offset = (vector_id / 4) * 4;
+
+ /* Determine the necessary bit shift in this target register for this
+ vector ID */
+ bit_shift = (vector_id % 4) * 8;
+
+ /* Build a value based on the bit shift calculated above and the CPU core
+ that this code is executing on */
+ targ_cpu = (1 << temp32) << bit_shift;
+
+ /* Read-modify-write the target register for this interrupt and remove this cpu from
+ accepting this interrupt */
+ temp32 = MEM_READ32(INT_GIC_DIST_BASE + INT_GIC_DIST_TARGET + reg_offset);
+ temp32 &= ~targ_cpu;
+
+ MEM_WRITE32(INT_GIC_DIST_BASE + INT_GIC_DIST_TARGET + reg_offset, temp32);
+
+ /* Return the vector ID */
+ return (vector_id);
+}
+
+void arm_arch_install_isr_vector_table(unsigned long addr) {
+ unsigned long arch = 0;
+ void *dst_addr;
+
+ /* Assign destination address of vector table to RAM address */
+ dst_addr = (void *) addr;
+ /* Read Main ID Register (MIRD) */
+ ARM_AR_CP_READ(p15, 0, &arch, c0, c0, 0);
+
+ /* Check if Cortex-A series of ARMv7 architecture. */
+ if (((arch & MIDR_ARCH_MASK) >> 16) == MIDR_ARCH_ARMV7
+ && ((arch & MIDR_PART_NO_MASK) >> 4)
+ == MIDR_PART_NO_CORTEX_A) {
+ /* Set vector base address */
+ ARM_AR_CP_WRITE(p15, 0, dst_addr, c12, c0, 0);
+ ARM_AR_NOP_EXECUTE();
+ ARM_AR_NOP_EXECUTE();
+ ARM_AR_NOP_EXECUTE();
+ }
+}
+
+extern void bm_env_isr(int vector);
+
+/* IRQ handler */
+void __attribute__ ((interrupt("IRQ"))) __cs3_isr_irq() {
+ unsigned long raw_irq;
+ int irq_vector;
+
+ /* Read the Interrupt ACK register */
+ raw_irq = MEM_READ32(INT_GIC_CPU_BASE + INT_GIC_CPU_ACK);
+
+ /* mask interrupt to get vector */
+ irq_vector = raw_irq & INT_ACK_MASK;
+
+ bm_env_isr(irq_vector);
+
+ /* Clear the interrupt */
+ MEM_WRITE32(INT_GIC_CPU_BASE + INT_GIC_CPU_ENDINT, raw_irq);
+}
+
+/* FIQ Handler */
+void __attribute__ ((interrupt("FIQ"))) __cs3_isr_fiq() {
+ while (1);
+}
+
+static inline unsigned int get_cpu_id_arm(void) {
+ unsigned long cpu_id = 0;
+
+ asm volatile("MRC p15 ,"
+ "0,"
+ "%0,"
+ "c0,"
+ "c0,"
+ "5"
+ : [cpu_id] "=&r"(cpu_id)
+ : /* No inputs */);
+
+ /*
+ * Return cpu id to caller, extract last two bits from Multiprocessor
+ * Affinity Register */
+ return (cpu_id & 0x03);
+}
+
+int old_value = 0;
+
+void restore_global_interrupts() {
+ ARM_AR_INT_BITS_SET(old_value);
+}
+
+void disable_global_interrupts() {
+ int value = 0;
+ ARM_AR_INT_BITS_GET(&value);
+ if (value != old_value) {
+ ARM_AR_INT_BITS_SET(ARM_AR_INTERRUPTS_DISABLE_BITS);
+ old_value = value;
+ }
+}
+
+void init_arm_stacks(void) {
+
+ /* Switch to IRQ mode (keeping interrupts disabled) */
+ ARM_AR_CPSR_C_WRITE(
+ ARM_AR_INT_CPSR_IRQ_MODE | ARM_AR_INTERRUPTS_DISABLE_BITS);
+
+ /* Set IRQ stack pointer */
+ ARM_AR_SP_WRITE(
+ ARM_GE_STK_ALIGN(&ARM_AR_ISR_IRQ_Data[ARM_AR_ISR_STACK_SIZE-1]));
+
+ /* Switch to FIQ mode (keeping interrupts disabled) */
+ ARM_AR_CPSR_C_WRITE(
+ ARM_AR_INT_CPSR_FIQ_MODE | ARM_AR_INTERRUPTS_DISABLE_BITS);
+
+ /* Set FIQ stack pointer */
+ ARM_AR_SP_WRITE(
+ ARM_GE_STK_ALIGN(ARM_AR_ISR_FIQ_Data[ARM_AR_ISR_STACK_SIZE-1]));
+
+ /* Switch to Supervisor mode (keeping interrupts disabled) */
+ ARM_AR_CPSR_C_WRITE(
+ ARM_AR_INT_CPSR_SUP_MODE | ARM_AR_INTERRUPTS_DISABLE_BITS);
+
+ /* Set Supervisor stack pointer */
+ ARM_AR_SP_WRITE(
+ ARM_GE_STK_ALIGN(&ARM_AR_ISR_SUP_Stack[ARM_AR_ISR_STACK_SIZE-1]));
+
+ /* Switch to System mode (keeping interrupts disabled) */
+ ARM_AR_CPSR_C_WRITE(ARM_AR_INT_CPSR_SYS_DISABLED);
+}
+
+/***********************************************************************
+ *
+ * arm_ar_mem_enable_mmu
+ *
+ * Enables MMU and MAP the required memory regions.
+ *
+ ***********************************************************************/
+int arm_ar_mem_enable_mmu() {
+ unsigned int cp15_ctrl_val;
+ void *tlb_mem = (void*)TLB_MEM_START;
+
+ ARM_AR_MEM_CACHE_ALL_INVALIDATE();
+
+ /* Read current CP15 control register value */
+ ARM_AR_CP_READ(ARM_AR_CP15, 0, &cp15_ctrl_val, ARM_AR_C1,
+ ARM_AR_C0, 0);
+
+ /* Clear the V bit(13) to set Normal exception vectors range. */
+ cp15_ctrl_val &= ~(ARM_AR_MEM_CP15_CTRL_V);
+
+ /* Clear the alignment bit(1) to enable unaligned memory accesses*/
+ cp15_ctrl_val &= ~(ARM_AR_MEM_CP15_CTRL_A);
+
+ /* Write updated CP15 control register value */
+ ARM_AR_CP_WRITE(ARM_AR_CP15, 0, cp15_ctrl_val, ARM_AR_C1,
+ ARM_AR_C0, 0);
+
+ ARM_AR_NOP_EXECUTE();
+ ARM_AR_NOP_EXECUTE();
+ ARM_AR_NOP_EXECUTE();
+
+ /* Check alignment of available memory pointer */
+ if (!(MEM_ALIGNED_CHECK(tlb_mem,ARM_AR_MEM_TTB_SIZE))) {
+ /* Align the pointer to the required boundary */
+ tlb_mem = MEM_PTR_ALIGN(tlb_mem,ARM_AR_MEM_TTB_SIZE);
+ }
+
+ /* Clear the entire translation table */
+ memset(tlb_mem, 0x00, ARM_AR_MEM_TTB_SIZE);
+
+ /* Set translation table base address */
+ ARM_AR_CP_WRITE(ARM_AR_CP15, 0, tlb_mem, ARM_AR_C2,
+ ARM_AR_C0, 0);
+
+ ARM_AR_CP_READ(ARM_AR_CP15, 0, &cp15_ctrl_val, ARM_AR_C2,
+ ARM_AR_C0, 0);
+
+ /* Map the given memory regions here */
+ arm_ar_map_mem_region(ELF_START, ELF_START, ELF_END, 0, WRITEBACK);
+ arm_ar_map_mem_region((unsigned int) tlb_mem, (unsigned int) tlb_mem,
+ TLB_SIZE, 0, NOCACHE);
+ arm_ar_map_mem_region(PERIPH_BASE, PERIPH_BASE,
+ PERIPH_SIZE, 1, NOCACHE);
+ arm_ar_map_mem_region(SLCR_BASE, SLCR_BASE, SLCR_SIZE, 1, NOCACHE);
+ arm_ar_map_mem_region(CPU_BASE, CPU_BASE, CPU_SIZE, 1, NOCACHE);
+
+ /* Set the domain access for domain D0 */
+ ARM_AR_CP_WRITE(ARM_AR_CP15, 0, ARM_AR_MEM_DOMAIN_D0_MANAGER_ACCESS,
+ ARM_AR_C3, ARM_AR_C0, 0);
+
+ ARM_AR_CP_READ(ARM_AR_CP15, 0, &cp15_ctrl_val, ARM_AR_C3,
+ ARM_AR_C0, 0);
+
+ /* Invalidate all TLB entries before enabling the MMU */
+ ARM_AR_CP_WRITE(ARM_AR_CP15, 0, 0, ARM_AR_C8, ARM_AR_C7, 0);
+
+ /* Read current CP15 control register value */
+ ARM_AR_CP_READ(ARM_AR_CP15, 0, &cp15_ctrl_val, ARM_AR_C1,
+ ARM_AR_C0, 0);
+
+ /* Set instruction cache enable / data cache enable / MMU enable bits */
+ cp15_ctrl_val |= (ARM_AR_MEM_CP15_CTRL_I | ARM_AR_MEM_CP15_CTRL_C
+ | ARM_AR_MEM_CP15_CTRL_M | ARM_AR_MEM_CP15_CTRL_Z);
+
+ /* Write updated CP15 control register value */
+ ARM_AR_CP_WRITE(ARM_AR_CP15, 0, cp15_ctrl_val, ARM_AR_C1,
+ ARM_AR_C0, 0);
+
+ ARM_AR_NOP_EXECUTE();
+ ARM_AR_NOP_EXECUTE();
+ ARM_AR_NOP_EXECUTE();
+
+ return 0;
+}
+
+/***********************************************************************
+ *
+ *
+ * arm_ar_map_mem_region
+ *
+ *
+ * This function sets-up the region of memory based on the given
+ * attributes
+
+ *
+ * @param vrt_addr - virtual address of region
+ * @param phy_addr - physical address of region
+ * @parma size - size of region
+ * @param is_mem_mapped - memory mapped or not
+
+ * @param cache_type - cache type of region
+ *
+ *
+ * OUTPUTS
+ *
+ * None
+ *
+ ***********************************************************************/
+void arm_ar_map_mem_region(unsigned int vrt_addr, unsigned int phy_addr,
+ unsigned int size, int is_mem_mapped,
+ CACHE_TYPE cache_type) {
+ unsigned int section_offset;
+ unsigned int ttb_offset;
+ unsigned int ttb_value;
+ unsigned int ttb_base;
+
+ /* Read ttb base address */
+ ARM_AR_CP_READ(ARM_AR_CP15, 0, &ttb_base, ARM_AR_C2,
+ ARM_AR_C0, 0);
+
+ /* Ensure the virtual and physical addresses are aligned on a
+ section boundary */
+ vrt_addr &= ARM_AR_MEM_TTB_SECT_SIZE_MASK;
+ phy_addr &= ARM_AR_MEM_TTB_SECT_SIZE_MASK;
+
+ /* Loop through entire region of memory (one MMU section at a time).
+ Each section requires a TTB entry. */
+ for (section_offset = 0; section_offset < size; section_offset +=
+ ARM_AR_MEM_TTB_SECT_SIZE) {
+
+ /* Calculate translation table entry offset for this memory section */
+ ttb_offset = ((vrt_addr + section_offset)
+ >> ARM_AR_MEM_TTB_SECT_TO_DESC_SHIFT);
+
+ /* Build translation table entry value */
+ ttb_value = (phy_addr + section_offset)
+ | ARM_AR_MEM_TTB_DESC_ALL_ACCESS;
+
+ if (!is_mem_mapped) {
+
+ /* Set cache related bits in translation table entry.
+ NOTE: Default is uncached instruction and data. */
+ if (cache_type == WRITEBACK) {
+ /* Update translation table entry value */
+ ttb_value |= (ARM_AR_MEM_TTB_DESC_B | ARM_AR_MEM_TTB_DESC_C);
+ } else if (cache_type == WRITETHROUGH) {
+ /* Update translation table entry value */
+ ttb_value |= ARM_AR_MEM_TTB_DESC_C;
+ }
+ /* In case of un-cached memory, set TEX 0 bit to set memory
+ attribute to normal. */
+ else if (cache_type == NOCACHE) {
+ ttb_value |= ARM_AR_MEM_TTB_DESC_TEX;
+ }
+ }
+
+ /* Write translation table entry value to entry address */
+ MEM_WRITE32(ttb_base + ttb_offset, ttb_value);
+
+ } /* for loop */
+}
+
+/*==================================================================*/
+/* The function definitions below are provided to prevent the build */
+/* warnings for missing I/O function stubs in case of unhosted libs */
+/*==================================================================*/
+
+#include <sys/stat.h>
+
+/**
+ * _fstat
+ *
+ * Status of an open file. For consistency with other minimal
+ * implementations in these examples, all files are regarded
+ * as character special devices.
+ *
+ * @param file - Unused.
+ * @param st - Status structure.
+ *
+ *
+ * A constant value of 0.
+ *
+ **/
+int _fstat(int file, struct stat * st)
+{
+ return(0);
+}
+
+/**
+ * isatty
+ *
+ *
+ * Query whether output stream is a terminal. For consistency
+ * with the other minimal implementations, which only support
+ * output to stdout, this minimal implementation is suggested
+ *
+ * @param file - Unused
+ *
+ * @return s - A constant value of 1.
+ *
+ */
+int _isatty(int file)
+{
+ return(1);
+}
+
+/**
+ *_lseek
+ *
+ * Set position in a file. Minimal implementation.
+
+ *
+ * @param file - Unused
+ *
+ * @param ptr - Unused
+ *
+ * @param dir - Unused
+ *
+ * @return - A constant value of 0.
+ *
+ */
+int _lseek(int file, int ptr, int dir)
+{
+ return(0);
+}
+
+#if (RTL_RPC == 0)
+/**
+ * _open
+ *
+ * Open a file. Minimal implementation
+ *
+ * @param filename - Unused
+ * @param flags - Unused
+ * @param mode - Unused
+ *
+ * return - A constant value of 1.
+ *
+ */
+int _open(const char * filename, int flags, int mode)
+{
+ /* Any number will work. */
+ return(1);
+}
+
+/**
+ * _close
+ *
+ * Close a file. Minimal implementation.
+ *
+ *
+ * @param file - Unused
+ *
+ *
+ * return A constant value of -1.
+ *
+ */
+int _close(int file)
+{
+ return(-1);
+}
+
+/**
+ * _read
+ *
+ * Low level function to redirect IO to serial.
+ *
+ * @param fd - Unused
+ * @param buffer - Buffer where read data will be placed.
+ * @param buflen - Size (in bytes) of buffer.
+ *
+ * return - A constant value of 1.
+ *
+ */
+int _read(int fd, char * buffer, int buflen)
+{
+ return -1;
+}
+
+/**
+ * _write
+ *
+ * Low level function to redirect IO to serial.
+ *
+ *
+ * @param file - Unused
+ * @param CHAR *ptr - String to output
+ * @param len - Length of the string
+ *
+ * return len - The length of the string
+ *
+ */
+int _write (int file, const char * ptr, int len)
+{
+ return 0;
+}
+#endif
diff --git a/libs/system/zc702evk/baremetal/baremetal.h b/libs/system/zc702evk/baremetal/baremetal.h
--- /dev/null
@@ -0,0 +1,668 @@
+/*
+ * Copyright (c) 2014, Mentor Graphics Corporation
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * 3. Neither the name of the <ORGANIZATION> nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _BAREMETAL_H
+#define _BAREMETAL_H
+
+#define MEM_READ8(addr) *(volatile unsigned char *)(addr)
+#define MEM_READ16(addr) *(volatile unsigned short *)(addr)
+#define MEM_READ32(addr) *(volatile unsigned long *)(addr)
+#define MEM_WRITE8(addr,data) *(volatile unsigned char *)(addr) = (unsigned char)(data)
+#define MEM_WRITE16(addr,data) *(volatile unsigned short *)(addr) = (unsigned short)(data)
+#define MEM_WRITE32(addr,data) *(volatile unsigned long *)(addr) = (unsigned long)(data)
+
+/* Define bit values for the architecture's status register / machine state register /
+ etc that are used to enable and disable interrupts for the given architecture. */
+#define ARM_AR_INTERRUPTS_DISABLE_BITS 0x000000C0
+#define ARM_AR_INTERRUPTS_ENABLE_BITS 0x00000000
+
+/* This define is used to add quotes to anything passed in */
+#define ARM_AR_QUOTES(x) #x
+
+/* This macro writes to a coprocessor register */
+#define ARM_AR_CP_WRITE(cp, op1, cp_value, crn, crm, op2) \
+ { \
+ asm volatile(" MCR " ARM_AR_QUOTES(cp) "," \
+ #op1 \
+ ", %0, " \
+ ARM_AR_QUOTES(crn) "," \
+ ARM_AR_QUOTES(crm) "," \
+ #op2 \
+ : /* No outputs */ \
+ : "r" (cp_value)); \
+ }
+
+/* This macro reads from a coprocessor register */
+#define ARM_AR_CP_READ(cp, op1, cp_value_ptr, crn, crm, op2) \
+ { \
+ asm volatile(" MRC " ARM_AR_QUOTES(cp) "," \
+ #op1 \
+ ", %0, " \
+ ARM_AR_QUOTES(crn) "," \
+ ARM_AR_QUOTES(crm) "," \
+ #op2 \
+ : "=r" (*(unsigned long *)(cp_value_ptr)) \
+ : /* No inputs */ ); \
+ }
+
+/* This macro executes a NOP instruction */
+#define ARM_AR_NOP_EXECUTE() \
+ { \
+ asm volatile(" NOP"); \
+ }
+
+/* This macro writes the c (control) bits of the current program status register (CPSR) */
+#define ARM_AR_CPSR_C_WRITE(c_bits) \
+ { \
+ asm volatile(" MSR CPSR_c, %0" \
+ : /* No outputs */ \
+ : "I" (c_bits) ); \
+ }
+
+/* This macro reads the current program status register (CPSR - all fields) */
+#define ARM_AR_CPSR_CXSF_READ(cpsr_cxsf_ptr) \
+ { \
+ asm volatile(" MRS %0, CPSR" \
+ : "=r" (*(cpsr_cxsf_ptr)) \
+ : /* No inputs */ ); \
+ }
+
+/* This macro writes the current program status register (CPSR - all fields) */
+#define ARM_AR_CPSR_CXSF_WRITE(cpsr_cxsf_value) \
+ { \
+ asm volatile(" MSR CPSR_cxsf, %0" \
+ : /* No outputs */ \
+ : "r" (cpsr_cxsf_value) ); \
+ }
+
+/* This macro sets the interrupt related bits in the status register / control
+ register to the specified value. */
+#define ARM_AR_INT_BITS_SET(set_bits) \
+ { \
+ int tmp_val; \
+ \
+ ARM_AR_CPSR_CXSF_READ(&tmp_val); \
+ tmp_val &= ~ARM_AR_INTERRUPTS_DISABLE_BITS; \
+ tmp_val |= set_bits; \
+ ARM_AR_CPSR_CXSF_WRITE(tmp_val); \
+ }
+
+/* This macro gets the interrupt related bits from the status register / control
+ register. */
+#define ARM_AR_INT_BITS_GET(get_bits_ptr) \
+ { \
+ int tmp_val; \
+ \
+ ARM_AR_CPSR_CXSF_READ(&tmp_val); \
+ tmp_val &= ARM_AR_INTERRUPTS_DISABLE_BITS; \
+ *get_bits_ptr = tmp_val; \
+ }
+
+/* This macro writes the stack pointer. */
+#define ARM_AR_SP_WRITE(stack_ptr) \
+ { \
+ /* Set hardware stack pointer to passed in address */ \
+ asm volatile(" MOV sp, %0" \
+ : : "r" (stack_ptr) ); \
+ }
+
+/* This macro writes the stack pointer. */
+#define ARM_AR_SP_WRITE(stack_ptr) \
+ { \
+ /* Set hardware stack pointer to passed in address */ \
+ asm volatile(" MOV sp, %0" \
+ : : "r" (stack_ptr) ); \
+ }
+
+/* This macro executes a ISB instruction */
+#define ARM_AR_ISB_EXECUTE() \
+ { \
+ asm volatile(" ISB"); \
+ }
+
+/* This macro executes a DSB instruction */
+#define ARM_AR_DSB_EXECUTE() \
+ { \
+ asm volatile(" DSB"); \
+ }
+
+#define MIDR_ARCH_MASK 0x000F0000 /* Main ID register's architecture mask */
+#define MIDR_ARCH_ARMV7 0xF /* ARMv7 */
+#define MIDR_PART_NO_CORTEX_A 0xC00 /* Primary part number of Cortex-A series. */
+#define MIDR_PART_NO_MASK 0x0000FF00 /* Primary part number mask */
+#define ARM_AR_INTERRUPTS_DISABLE_BITS 0x000000C0
+#define ARM_AR_INTERRUPTS_ENABLE_BITS 0x00000000
+
+/* Macro used to make a 32-bit value with the specified bit set */
+#define ESAL_GE_MEM_32BIT_SET(bit_num) (1UL<<(bit_num))
+
+/* Macro used to make a 32-bit value with the specified bit clear */
+#define ESAL_GE_MEM_32BIT_CLEAR(bit_num) ~(1UL<<(bit_num))
+
+/* CPSR bit defines / masks */
+#define ARM_AR_INT_CPSR_THUMB MEM_32BIT_SET(5)
+#define ARM_AR_INT_CPSR_MODE_MASK 0x0000001F
+#define ARM_AR_INT_CPSR_SYS_MODE 0x0000001F
+#define ARM_AR_INT_CPSR_IRQ_MODE 0x00000012
+#define ARM_AR_INT_CPSR_FIQ_MODE 0x00000011
+#define ARM_AR_INT_CPSR_SUP_MODE 0x00000013
+#define ARM_AR_INT_CPSR_E_BIT 0x00000200
+#define ARM_AR_INT_CPSR_IRQ_BIT MEM_32BIT_SET(7)
+#define ARM_AR_INT_CPSR_FIQ_BIT MEM_32BIT_SET(6)
+#define ARM_AR_INT_CPSR_SYS_DISABLED (ARM_AR_INT_CPSR_SYS_MODE | \
+ ARM_AR_INTERRUPTS_DISABLE_BITS)
+
+#define ARM_AR_STK_ALIGNMENT 8
+/* Define a generic alignment mask used to obtain a specified toolset required alignment */
+#define ARM_GE_STK_ALIGN_MASK (~(ARM_AR_STK_ALIGNMENT - 1))
+
+/* Generic macro to align stack end address when stack grows down */
+#define ARM_GE_STK_ALIGN(end_stk_addr) \
+ (void *)((unsigned int)end_stk_addr & (unsigned int)ARM_GE_STK_ALIGN_MASK)
+
+#define ARM_AR_PERIPH_BASE 0xF8F00000
+#define INT_GIC_CPU_BASE (ARM_AR_PERIPH_BASE + 0x00000100)
+#define INT_GIC_DIST_BASE (ARM_AR_PERIPH_BASE + 0x00001000)
+
+/* CPU Interface Register Offsets */
+#define INT_GIC_CPU_CTRL 0x00
+#define INT_GIC_CPU_PRIORITY 0x04
+#define INT_GIC_CPU_POINT 0x08
+#define INT_GIC_CPU_ACK 0x0c
+#define INT_GIC_CPU_ENDINT 0x10
+#define INT_GIC_CPU_RUNNING 0x14
+#define INT_IC_CPU_HIGHEST_PENDING 0x18
+#define INT_IC_CPU_NON_SECURE_POINT 0x1C
+#define INT_IC_CPU_IMPLEMENTOR 0xFC
+
+/* Distribution Register Offsets */
+#define INT_GIC_DIST_CTRL 0x000
+#define INT_GIC_DIST_CTR 0x004
+#define INT_GIC_DIST_ISR 0x080
+#define INT_GIC_DIST_ENABLE_SET 0x100
+#define INT_GIC_DIST_ENABLE_CLEAR 0x180
+#define INT_GIC_DIST_PENDING_SET 0x200
+#define INT_GIC_DIST_PENDING_CLEAR 0x280
+#define INT_GIC_DIST_ACTIVE_BIT 0x300
+#define INT_GIC_DIST_PRI 0x400
+#define INT_GIC_DIST_TARGET 0x800
+#define INT_GIC_DIST_CONFIG 0xC00
+#define INT_GIC_DIST_PPI_STATUS 0xD00
+#define INT_GIC_DIST_SPI_STATUS 0xD04
+#define INT_GIC_DIST_SOFTINT 0xF00
+
+/* Define value to disable all interrupts */
+#define INT_IRQ_DISABLE_ALL 0x00000000
+
+/* Define value to enable interrupts on cpu */
+#define INT_CPU_ENABLE 0x00000001
+#define INT_DIST_ENABLE 0x00000001
+
+/* Define Interrupt Ack Mask */
+#define INT_ACK_MASK 0x000003FF
+
+/* Define Spurious Int value */
+#define INT_SPURIOUS_INT 1023
+
+#define ESAL_PR_ISR_GIC_NUM_PRI_REG 16
+
+/* Define number of GIC target registers */
+#define ESAL_PR_ISR_GIC_NUM_TARGET_REG 16
+
+/* Define value to disable all interrupts */
+#define INT_DISABLE 0x00000000
+
+/* Define value to clear interrupt registers */
+#define INT_CLEAR 0xFFFFFFFF
+
+#define GIC_SFI_TRIG_CPU_MASK 0x00FF0000
+#define GIC_SFI_TRIG_SATT_MASK 0x00008000
+#define GIC_SFI_TRIG_INTID_MASK 0x0000000F
+#define GIC_CPU_ID_BASE (1 << 4)
+
+/* Translation table is 16K in size */
+#define ARM_AR_MEM_TTB_SIZE 16*1024
+
+/* Each TTB descriptor covers a 1MB region */
+#define ARM_AR_MEM_TTB_SECT_SIZE 1024*1024
+
+/* Mask off lower bits of addr */
+#define ARM_AR_MEM_TTB_SECT_SIZE_MASK (~(ARM_AR_MEM_TTB_SECT_SIZE-1UL))
+
+/* Define shift to convert memory address to index of translation table entry (descriptor).
+ Shift 20 bits (for a 1MB section) - 2 bits (for a 4 byte TTB descriptor) */
+#define ARM_AR_MEM_TTB_SECT_TO_DESC_SHIFT (20-2)
+
+/* Define domain access values */
+#define ARM_AR_MEM_DOMAIN_D0_MANAGER_ACCESS 0x3
+
+#define ARM_AR_MEM_TTB_DESC_BACKWARDS ESAL_GE_MEM_32BIT_SET(4)
+#define ARM_AR_MEM_TTB_DESC_AP_MANAGER (ESAL_GE_MEM_32BIT_SET(10) | \
+ ESAL_GE_MEM_32BIT_SET(11))
+#define ARM_AR_MEM_TTB_DESC_SECT ESAL_GE_MEM_32BIT_SET(1)
+
+/* Define translation table descriptor bits */
+#define ARM_AR_MEM_TTB_DESC_B ESAL_GE_MEM_32BIT_SET(2)
+#define ARM_AR_MEM_TTB_DESC_C ESAL_GE_MEM_32BIT_SET(3)
+#define ARM_AR_MEM_TTB_DESC_TEX ESAL_GE_MEM_32BIT_SET(12)
+#define ARM_AR_MEM_TTB_DESC_S ESAL_GE_MEM_32BIT_SET(16)
+
+/*********************************************
+ * Common definitions
+ *********************************************/
+/* Define CP15 Register 1: control register bits */
+#define ARM_AR_MEM_CP15_CTRL_V ESAL_GE_MEM_32BIT_SET(13)
+#define ARM_AR_MEM_CP15_CTRL_I ESAL_GE_MEM_32BIT_SET(12)
+#define ARM_AR_MEM_CP15_CTRL_Z ESAL_GE_MEM_32BIT_SET(11)
+#define ARM_AR_MEM_CP15_CTRL_W ESAL_GE_MEM_32BIT_SET(3)
+#define ARM_AR_MEM_CP15_CTRL_C ESAL_GE_MEM_32BIT_SET(2)
+#define ARM_AR_MEM_CP15_CTRL_A ESAL_GE_MEM_32BIT_SET(1)
+#define ARM_AR_MEM_CP15_CTRL_M ESAL_GE_MEM_32BIT_SET(0)
+
+/* MVA Format SBZ mask */
+#define ARM_AR_MEM_MVA_SBZ_MASK ~(ARM_AR_MEM_CACHE_LINE_SIZE - 1UL)
+
+/* Defines related to Cache Level ID Register */
+#define ARM_AR_MEM_DCACHE_SIZE_SHIFT 16
+#define ARM_AR_MEM_CACHE_SIZE_BIT 4
+#define ARM_AR_MEM_CACHE_SIZE_MASK 0xF
+
+/* Define all access (manager access permission / not cachable / not bufferd) */
+#define ARM_AR_MEM_TTB_DESC_ALL_ACCESS (ARM_AR_MEM_TTB_DESC_AP_MANAGER | \
+ ARM_AR_MEM_TTB_DESC_SECT)
+
+/* Macro used to check if a value is aligned to the required boundary.
+ Returns NU_TRUE if aligned; NU_FALSE if not aligned. The required alignment must be a power of 2 (2, 4, 8, 16, 32, etc) */
+#define MEM_ALIGNED_CHECK(value, req_align) \
+ (((unsigned int)(value) & ((unsigned int)(req_align) - (unsigned int)1)) == (unsigned int)0)
+
+/* Macro used to align a data pointer to next address that meets the specified
+ required alignment. The required alignment must be a power of 2 (2, 4, 8, 16, 32, etc) */
+#define MEM_PTR_ALIGN(ptr_addr, req_align) \
+ ((MEM_ALIGNED_CHECK(ptr_addr, req_align)) ? (void *)ptr_addr : \
+ (void *)(((unsigned int)(ptr_addr) & (unsigned int)(~((req_align) - 1))) + (unsigned int)(req_align)))
+
+/* Coprocessor registers */
+#define ARM_AR_CP0 p0
+#define ARM_AR_CP1 p1
+#define ARM_AR_CP2 p2
+#define ARM_AR_CP3 p3
+#define ARM_AR_CP4 p4
+#define ARM_AR_CP5 p5
+#define ARM_AR_CP6 p6
+#define ARM_AR_CP7 p7
+#define ARM_AR_CP8 p8
+#define ARM_AR_CP9 p9
+#define ARM_AR_CP10 p10
+#define ARM_AR_CP11 p11
+#define ARM_AR_CP12 p12
+#define ARM_AR_CP13 p13
+#define ARM_AR_CP14 p14
+#define ARM_AR_CP15 p15
+
+/* CRn and CRm register values */
+#define ARM_AR_C0 c0
+#define ARM_AR_C1 c1
+#define ARM_AR_C2 c2
+#define ARM_AR_C3 c3
+#define ARM_AR_C4 c4
+#define ARM_AR_C5 c5
+#define ARM_AR_C6 c6
+#define ARM_AR_C7 c7
+#define ARM_AR_C8 c8
+#define ARM_AR_C9 c9
+#define ARM_AR_C10 c10
+#define ARM_AR_C11 c11
+#define ARM_AR_C12 c12
+#define ARM_AR_C13 c13
+#define ARM_AR_C14 c14
+#define ARM_AR_C15 c15
+
+#define ARM_AR_ISR_STACK_SIZE 2 * 1024
+
+extern unsigned char ARM_AR_ISR_IRQ_Data[ARM_AR_ISR_STACK_SIZE];
+extern unsigned char ARM_AR_ISR_FIQ_Data[ARM_AR_ISR_STACK_SIZE];
+extern unsigned char ARM_AR_ISR_SUP_Stack[ARM_AR_ISR_STACK_SIZE];
+extern unsigned char ARM_AR_ISR_SYS_Stack[ARM_AR_ISR_STACK_SIZE];
+
+#define SWITCH_TO_SYS_MODE() ARM_AR_CPSR_C_WRITE(ARM_AR_INT_CPSR_SYS_DISABLED); \
+ ARM_AR_SP_WRITE(ARM_GE_STK_ALIGN(&ARM_AR_ISR_SYS_Stack[ARM_AR_ISR_STACK_SIZE-1]))
+
+#ifndef BAREMETAL_MASTER
+#define BAREMETAL_MASTER 0
+#endif
+
+/* Memory Regions for MMU Mapping */
+#if (BAREMETAL_MASTER == 1)
+
+#define ELF_START 0x10000000 /* Image entry point address */
+#define ELF_END 0x0FE00000 /* size of code,data,heap and stack sections */
+
+#define TLB_MEM_START 0x1FE00000 /* Address of TLB memory */
+
+#else
+
+#define ELF_START 0x00000000 /* Image entry point address */
+#define ELF_END 0x08000000 /* size of code,data,heap and stack sections */
+
+#define TLB_MEM_START 0x0FE00000 /* Address of TLB memory */
+
+#endif
+
+/* The vector table address is the same as image entry point */
+#define RAM_VECTOR_TABLE_ADDR ELF_START
+
+#define TLB_SIZE 2*1024*1024 /* TLB memory size */
+
+#define PERIPH_BASE 0xE0000000 /* Peripheral registers start */
+#define PERIPH_SIZE 3 *1024 *1024 /* size */
+
+#define SLCR_BASE 0xF8000000 /* SLCR registers start */
+#define SLCR_SIZE 3 * 1024 /* size */
+
+#define CPU_BASE 0xF8F00000 /* CPU registers start */
+#define CPU_SIZE 12 *1024 /* size */
+
+
+
+typedef enum {
+ TRIG_NOT_SUPPORTED,
+ TRIG_RISING_EDGE,
+ TRIG_FALLING_EDGE,
+ TRIG_LEVEL_LOW,
+ TRIG_LEVEL_HIGH,
+ TRIG_RISING_FALLING_EDGES,
+ TRIG_HIGH_LOW_RISING_FALLING_EDGES
+
+} INT_TRIG_TYPE;
+
+typedef enum {
+ NOCACHE,
+ WRITEBACK,
+ WRITETHROUGH
+} CACHE_TYPE;
+
+/* This macro executes a ISB instruction */
+#define ARM_AR_ISB_EXECUTE() \
+ { \
+ asm volatile(" ISB"); \
+ }
+
+/* This macro executes a DSB instruction */
+#define ARM_AR_DSB_EXECUTE() \
+ { \
+ asm volatile(" DSB"); \
+ }
+
+/* CLIDR and CCSIDR mask values */
+#define ARM_AR_MEM_CLIDR_LOC_MASK 0x7000000
+#define ARM_AR_MEM_CCSIDR_LINESIZE_MASK 0x7
+#define ARM_AR_MEM_CCSIDR_ASSOC_MASK 0x3FF
+#define ARM_AR_MEM_CCSIDR_NUMSET_MASK 0x7FFF
+
+/* CLIDR and CCSIDR shift values */
+#define ARM_AR_MEM_CLIDR_LOC_RSHT_OFFSET 24
+#define ARM_AR_MEM_CCSIDR_ASSOC_RSHT_OFFSET 3
+#define ARM_AR_MEM_CCSIDR_NUMSET_RSHT_OFFSET 13
+
+/* Extract 'encoded' line length of the cache */
+#define ARM_AR_MEM_CCSIDR_LINESIZE_GET(ccsidr_reg) (ccsidr_reg & \
+ ARM_AR_MEM_CCSIDR_LINESIZE_MASK)
+
+/* Extract 'encoded' way size of the cache */
+#define ARM_AR_MEM_CCSIDR_ASSOC_GET(ccsidr_reg) (ARM_AR_MEM_CCSIDR_ASSOC_MASK & \
+ (ccsidr_reg >> \
+ ARM_AR_MEM_CCSIDR_ASSOC_RSHT_OFFSET))
+
+/* Extract 'encoded' maximum number of index size */
+#define ARM_AR_MEM_CCSIDR_NUMSET_GET(ccsidr_reg) (ARM_AR_MEM_CCSIDR_NUMSET_MASK & \
+ (ccsidr_reg >> \
+ ARM_AR_MEM_CCSIDR_NUMSET_RSHT_OFFSET))
+
+/* Refer to chapter B3.12.31 c7, Cache and branch predictor maintenance functions in the
+ ARM Architecture Reference Manual ARMv7-A and ARMv7-R Edition 1360*/
+/* Calculate # of bits to be shifted for set size and way size */
+
+/* log2(line size in bytes) = ccsidr_linesize + 2 + logbase2(4) */
+#define ARM_AR_MEM_L_CALCULATE(linesize) (linesize + 2 + 2)
+
+/* log2(nsets) = 32 - way_size_bit_pos */
+
+/* Find the bit position of way size increment */
+#define ARM_AR_MEM_A_CALCULATE(assoc, a_offset_ref) \
+ { \
+ unsigned int temp_pos = 0x80000000; \
+ \
+ *a_offset_ref = 0; \
+ \
+ /* Logic to count the number of leading zeros before the first 1 */ \
+ while(!((assoc & temp_pos) == temp_pos)) \
+ { \
+ (*a_offset_ref)++; \
+ temp_pos = temp_pos >> 1; \
+ } \
+ }
+
+/* Factor way, cache number, index number */
+#define ARM_AR_MEM_DCCISW_SET(dccisw_ref, level, numsets, assoc, l_offset, a_offset) \
+ { \
+ *dccisw_ref = (level | (numsets << l_offset) | (assoc << a_offset)); \
+ }
+
+/* This macro extracts line size, assoc and set size from CCSIDR */
+#define ARM_AR_MEM_CCSIDR_VALS_GET(linesize_ref, assoc_ref, numsets_ref, \
+ l_offset_ref, a_offset_ref) \
+ { \
+ unsigned int ccsidr_val; \
+ \
+ /* Read the selected cache's CCSIDR */ \
+ ARM_AR_CP_READ(ARM_AR_CP15, 1, &ccsidr_val, \
+ ARM_AR_C0, ARM_AR_C0, 0); \
+ \
+ /* Extract 'encoded' line length of the cache */ \
+ *linesize_ref = ARM_AR_MEM_CCSIDR_LINESIZE_GET(ccsidr_val); \
+ \
+ /* Extract 'encoded' way size of the cache */ \
+ *assoc_ref = ARM_AR_MEM_CCSIDR_ASSOC_GET(ccsidr_val); \
+ \
+ /* Extract 'encoded' maximum number of index size */ \
+ *numsets_ref = ARM_AR_MEM_CCSIDR_NUMSET_GET(ccsidr_val); \
+ \
+ /* Calculate # of bits to be shifted for set size and way size */ \
+ \
+ /* log2(line size in bytes) = ccsidr_linesize + 2 + log2(4) */ \
+ *l_offset_ref = ARM_AR_MEM_L_CALCULATE(*linesize_ref); \
+ \
+ /* log2(nsets) = 32 - way_size_bit_pos */ \
+ ARM_AR_MEM_A_CALCULATE(*assoc_ref, a_offset_ref); \
+ }
+
+/* This macro invalidates all of the instruction cache at the core level. */
+#define ARM_AR_MEM_ICACHE_ALL_INVALIDATE() \
+ { \
+ ARM_AR_CP_WRITE(ARM_AR_CP15, 0, \
+ 0, ARM_AR_C7, \
+ ARM_AR_C5, 0); \
+ }
+
+/* This macro invalidates all of the cache at the core level. */
+#define ARM_AR_MEM_CACHE_ALL_INVALIDATE() \
+ { \
+ ARM_AR_MEM_ICACHE_ALL_INVALIDATE(); \
+ ARM_AR_MEM_DCACHE_ALL_INVALIDATE(); \
+ }
+
+/* This macro invalidates and flushes all of the cache at the core level. */
+#define ARM_AR_MEM_CACHE_ALL_FLUSH_INVALIDATE() \
+ { \
+ ARM_AR_MEM_DCACHE_ALL_FLUSH_INVALIDATE(); \
+ ARM_AR_MEM_ICACHE_ALL_INVALIDATE(); \
+ }
+
+/* This macro invalidates all of the data cache at the core level. */
+#define ARM_AR_MEM_DCACHE_ALL_OP(type) \
+ { \
+ unsigned int clidr_val = 0; \
+ unsigned int clidr_loc = 0; \
+ unsigned int cache_number = 0; \
+ unsigned int cache_type = 0; \
+ unsigned int ccsidr_linesize = 0; \
+ unsigned int ccsidr_assoc = 0; \
+ int ccsidr_numsets = 0; \
+ int way_size_copy = 0; \
+ unsigned int set_size_bit_pos = 0; \
+ unsigned int cache_number_pos = 0; \
+ unsigned int way_size_bit_pos = 0; \
+ unsigned int set_way_value = 0; \
+ \
+ \
+ /* Read CLIDR to extract level of coherence (LOC) */ \
+ ARM_AR_CP_READ(ARM_AR_CP15, 1, &clidr_val, \
+ ARM_AR_C0, ARM_AR_C0, 1); \
+ \
+ /* Extract LOC from CLIDR and align it at bit 1 */ \
+ clidr_loc = (clidr_val & ARM_AR_MEM_CLIDR_LOC_MASK) >> \
+ ARM_AR_MEM_CLIDR_LOC_RSHT_OFFSET; \
+ \
+ /* Proceed only iff LOC is non-zero */ \
+ if (clidr_loc != 0) \
+ { \
+ do \
+ { \
+ /* Extract cache type from CLIDR */ \
+ cache_number_pos = cache_number + (cache_number >> 1); \
+ cache_type = (clidr_val >> cache_number_pos) & 0x7; \
+ \
+ /* Continue only iff data cache */ \
+ if (cache_type >= 2) \
+ { \
+ /* Select desired cache level in CSSELR */ \
+ ARM_AR_CP_WRITE(ARM_AR_CP15, 2, cache_number, \
+ ARM_AR_C0, ARM_AR_C0, 0); \
+ \
+ ARM_AR_ISB_EXECUTE(); \
+ \
+ /* Get data like linesize, assoc and set size */ \
+ ARM_AR_MEM_CCSIDR_VALS_GET(&ccsidr_linesize, \
+ &ccsidr_assoc, \
+ &ccsidr_numsets, \
+ &set_size_bit_pos, \
+ &way_size_bit_pos); \
+ \
+ do \
+ { \
+ way_size_copy = ccsidr_assoc; \
+ \
+ do \
+ { \
+ /* Factor way, cache number, index number */ \
+ ARM_AR_MEM_DCCISW_SET(&set_way_value, cache_number, \
+ ccsidr_numsets, way_size_copy, \
+ set_size_bit_pos, \
+ way_size_bit_pos); \
+ \
+ /* Execute invalidate if type = 0 */ \
+ if (type == 0) \
+ { \
+ ARM_AR_CP_WRITE(ARM_AR_CP15, 0, \
+ set_way_value, \
+ ARM_AR_C7, \
+ ARM_AR_C6, 2); \
+ } \
+ else \
+ { \
+ ARM_AR_CP_WRITE(ARM_AR_CP15, 0, \
+ set_way_value, \
+ ARM_AR_C7, \
+ ARM_AR_C14, 2); \
+ } \
+ \
+ /* decrement the way */ \
+ } while((--way_size_copy) >= 0); \
+ \
+ /* decrement the set */ \
+ } while((--ccsidr_numsets) >= 0); \
+ \
+ } /* end if */ \
+ \
+ /* Increment cache number */ \
+ cache_number += 2; \
+ \
+ /* end do-while */ \
+ } while(clidr_loc >= cache_number); \
+ \
+ } \
+ \
+ /* Switch back to cache level 0 in CSSELR */ \
+ ARM_AR_CP_WRITE(ARM_AR_CP15, 2, 0, \
+ ARM_AR_C0, ARM_AR_C0, 0); \
+ \
+ /* Sync */ \
+ ARM_AR_DSB_EXECUTE(); \
+ ARM_AR_ISB_EXECUTE(); \
+ }
+
+/* This macro invalidates all of the data cache at the core level. */
+#define ARM_AR_MEM_DCACHE_ALL_INVALIDATE() ARM_AR_MEM_DCACHE_ALL_OP(0)
+
+/* This macro invalidates all of the data cache at the core level. */
+#define ARM_AR_MEM_DCACHE_ALL_FLUSH_INVALIDATE() ARM_AR_MEM_DCACHE_ALL_OP(1)
+
+#define ARM_AR_MEM_CACHE_DISABLE() \
+ { \
+ unsigned int cp15_ctrl_val; \
+ \
+ /* Read current CP15 control register value */ \
+ ARM_AR_CP_READ(ARM_AR_CP15, 0, &cp15_ctrl_val, ARM_AR_C1, ARM_AR_C0, 0); \
+ \
+ /* Clear instruction cache enable and data cache enable bits */ \
+ cp15_ctrl_val &= ~(ARM_AR_MEM_CP15_CTRL_I | ARM_AR_MEM_CP15_CTRL_C); \
+ \
+ /* Write updated CP15 control register value */ \
+ ARM_AR_CP_WRITE(ARM_AR_CP15, 0, cp15_ctrl_val, ARM_AR_C1, ARM_AR_C0, 0); \
+ ARM_AR_NOP_EXECUTE(); \
+ ARM_AR_NOP_EXECUTE(); \
+ ARM_AR_NOP_EXECUTE(); \
+ }
+
+int arm_ar_mem_enable_mmu();
+void arm_ar_map_mem_region(unsigned int vrt_addr, unsigned int phy_addr,
+ unsigned int size, int is_mem_mapped, CACHE_TYPE cache_type);
+
+int zc702evk_gic_initialize();
+int zc702evk_gic_interrupt_enable(int vector_id, INT_TRIG_TYPE trigger_type,
+ int priority);
+int zc702evk_gic_interrupt_disable(int vector_id);
+void zc702evk_gic_pr_int_initialize(void);
+void arm_arch_install_isr_vector_table(unsigned long addr);
+void restore_global_interrupts();
+void disable_global_interrupts();
+void init_arm_stacks(void);
+
+#endif /* _BAREMETAL_H */
diff --git a/libs/system/zc702evk/baremetal/libbaremetal_master.a b/libs/system/zc702evk/baremetal/libbaremetal_master.a
new file mode 100644 (file)
index 0000000..3eaa7cc
Binary files /dev/null and b/libs/system/zc702evk/baremetal/libbaremetal_master.a differ
index 0000000..3eaa7cc
Binary files /dev/null and b/libs/system/zc702evk/baremetal/libbaremetal_master.a differ
diff --git a/libs/system/zc702evk/baremetal/libbaremetal_remote.a b/libs/system/zc702evk/baremetal/libbaremetal_remote.a
new file mode 100644 (file)
index 0000000..3d2bbec
Binary files /dev/null and b/libs/system/zc702evk/baremetal/libbaremetal_remote.a differ
index 0000000..3d2bbec
Binary files /dev/null and b/libs/system/zc702evk/baremetal/libbaremetal_remote.a differ
diff --git a/libs/system/zc702evk/baremetal/libbaremetal_remote_rpc.a b/libs/system/zc702evk/baremetal/libbaremetal_remote_rpc.a
new file mode 100644 (file)
index 0000000..c74f0f3
Binary files /dev/null and b/libs/system/zc702evk/baremetal/libbaremetal_remote_rpc.a differ
index 0000000..c74f0f3
Binary files /dev/null and b/libs/system/zc702evk/baremetal/libbaremetal_remote_rpc.a differ
diff --git a/libs/system/zc702evk/baremetal/linker_master.ld b/libs/system/zc702evk/baremetal/linker_master.ld
--- /dev/null
@@ -0,0 +1,228 @@
+/* Linker script for Xilinx Zynq-7000\r
+ *\r
+ * Version: Sourcery CodeBench Lite 2013.11-24\r
+ * Support: https://sourcery.mentor.com/GNUToolchain/\r
+ *\r
+ * Copyright (c) 2007-2010 CodeSourcery, Inc.\r
+ * Copyright (c) 2010-2013 Mentor Graphics, Inc.\r
+ *\r
+ * The authors hereby grant permission to use, copy, modify, distribute,\r
+ * and license this software and its documentation for any purpose, provided\r
+ * that existing copyright notices are retained in all copies and that this\r
+ * notice is included verbatim in any distributions. No written agreement,\r
+ * license, or royalty fee is required for any of the authorized uses.\r
+ * Modifications to this software may be copyrighted by their authors\r
+ * and need not follow the licensing terms described here, provided that\r
+ * the new terms are clearly indicated on the first page of each file where\r
+ * they apply.\r
+ */\r
+OUTPUT_FORMAT ("elf32-littlearm", "elf32-bigarm", "elf32-littlearm")\r
+ENTRY(__cs3_reset)\r
+SEARCH_DIR(.)\r
+GROUP(-lgcc -lc -lcs3 -lcs3unhosted -lcs3arm)\r
+\r
+MEMORY\r
+{\r
+ ram (rwx) : ORIGIN = 0x10000000, LENGTH = 256M\r
+ rom (rx) : ORIGIN = 0xe4000000, LENGTH = 64M\r
+}\r
+\r
+/* These force the linker to search for particular symbols from\r
+ * the start of the link process and thus ensure the user's\r
+ * overrides are picked up\r
+ */\r
+EXTERN(__cs3_reset __cs3_reset_zynq7000_ram)\r
+EXTERN(__cs3_start_asm _start)\r
+/* Bring in the interrupt routines & vector */\r
+INCLUDE arm-names.inc\r
+EXTERN(__cs3_interrupt_vector_arm)\r
+EXTERN(__cs3_start_c main __cs3_stack __cs3_heap_end)\r
+\r
+/* Provide fall-back values */\r
+PROVIDE(__cs3_heap_start = _end);\r
+PROVIDE(__cs3_heap_end = __cs3_region_start_ram + __cs3_region_size_ram);\r
+PROVIDE(__cs3_region_num = (__cs3_regions_end - __cs3_regions) / 20);\r
+PROVIDE(__cs3_stack = __cs3_region_start_ram + __cs3_region_size_ram);\r
+\r
+SECTIONS\r
+{\r
+ .text :\r
+ {\r
+ CREATE_OBJECT_SYMBOLS\r
+ __cs3_region_start_ram = .;\r
+ _ftext = .;\r
+ *(.cs3.region-head.ram)\r
+ ASSERT (. == __cs3_region_start_ram, ".cs3.region-head.ram not permitted");\r
+ __cs3_interrupt_vector = __cs3_interrupt_vector_arm;\r
+ *(.cs3.interrupt_vector)\r
+ /* Make sure we pulled in an interrupt vector. */\r
+ ASSERT (. != __cs3_interrupt_vector_arm, "No interrupt vector");\r
+\r
+ PROVIDE(__cs3_reset = __cs3_reset_zynq7000_ram);\r
+ *(.cs3.reset)\r
+ _start = DEFINED(__cs3_start_asm) ? __cs3_start_asm : _start;\r
+\r
+ *(.text.cs3.init)\r
+ *(.text .text.* .gnu.linkonce.t.*)\r
+ *(.plt)\r
+ *(.gnu.warning)\r
+ *(.glue_7t) *(.glue_7) *(.vfp11_veneer)\r
+\r
+ *(.ARM.extab* .gnu.linkonce.armextab.*)\r
+ *(.gcc_except_table)\r
+ } >ram\r
+ .eh_frame_hdr : ALIGN (4)\r
+ {\r
+ KEEP (*(.eh_frame_hdr))\r
+ *(.eh_frame_entry .eh_frame_entry.*)\r
+ } >ram\r
+ .eh_frame : ALIGN (4)\r
+ {\r
+ KEEP (*(.eh_frame)) *(.eh_frame.*)\r
+ } >ram\r
+ /* .ARM.exidx is sorted, so has to go in its own output section. */\r
+ PROVIDE_HIDDEN (__exidx_start = .);\r
+ .ARM.exidx :\r
+ {\r
+ *(.ARM.exidx* .gnu.linkonce.armexidx.*)\r
+ } >ram\r
+ PROVIDE_HIDDEN (__exidx_end = .);\r
+ .rodata : ALIGN (4)\r
+ {\r
+ *(.rodata .rodata.* .gnu.linkonce.r.*)\r
+\r
+ . = ALIGN(4);\r
+ KEEP(*(.init))\r
+\r
+ . = ALIGN(4);\r
+ __preinit_array_start = .;\r
+ KEEP (*(.preinit_array))\r
+ __preinit_array_end = .;\r
+\r
+ . = ALIGN(4);\r
+ __init_array_start = .;\r
+ KEEP (*(SORT(.init_array.*)))\r
+ KEEP (*(.init_array))\r
+ __init_array_end = .;\r
+\r
+ . = ALIGN(4);\r
+ KEEP(*(.fini))\r
+\r
+ . = ALIGN(4);\r
+ __fini_array_start = .;\r
+ KEEP (*(.fini_array))\r
+ KEEP (*(SORT(.fini_array.*)))\r
+ __fini_array_end = .;\r
+\r
+ . = ALIGN(0x4);\r
+ KEEP (*crtbegin.o(.ctors))\r
+ KEEP (*(EXCLUDE_FILE (*crtend.o) .ctors))\r
+ KEEP (*(SORT(.ctors.*)))\r
+ KEEP (*crtend.o(.ctors))\r
+\r
+ . = ALIGN(0x4);\r
+ KEEP (*crtbegin.o(.dtors))\r
+ KEEP (*(EXCLUDE_FILE (*crtend.o) .dtors))\r
+ KEEP (*(SORT(.dtors.*)))\r
+ KEEP (*crtend.o(.dtors))\r
+\r
+ . = ALIGN(4);\r
+ __cs3_regions = .;\r
+ LONG (0)\r
+ LONG (__cs3_region_init_ram)\r
+ LONG (__cs3_region_start_ram)\r
+ LONG (__cs3_region_init_size_ram)\r
+ LONG (__cs3_region_zero_size_ram)\r
+ __cs3_regions_end = .;\r
+ . = ALIGN (8);\r
+ _etext = .;\r
+ } >ram\r
+\r
+ ASSERT (!(__cs3_region_init_ram & 7), "__cs3_region_init_ram not aligned")\r
+ ASSERT (!(__cs3_region_start_ram & 7), "__cs3_region_start_ram not aligned")\r
+ ASSERT (!(__cs3_region_init_size_ram & 7), "__cs3_region_init_size_ram not aligned")\r
+ ASSERT (!(__cs3_region_zero_size_ram & 7), "__cs3_region_zero_size_ram not aligned")\r
+ .cs3.rom : ALIGN (8)\r
+ {\r
+ __cs3_region_start_rom = .;\r
+ *(.cs3.region-head.rom)\r
+ *(.rom)\r
+ . = ALIGN (8);\r
+ } >rom\r
+ .cs3.rom.bss :\r
+ {\r
+ *(.rom.b .bss.rom)\r
+ . = ALIGN (8);\r
+ } >rom\r
+ /* __cs3_region_end_rom is deprecated */\r
+ __cs3_region_end_rom = __cs3_region_start_rom + LENGTH(rom);\r
+ __cs3_region_size_rom = LENGTH(rom);\r
+ __cs3_region_init_rom = LOADADDR (.cs3.rom);\r
+ __cs3_region_init_size_rom = LOADADDR (.cs3.rom.bss) - LOADADDR (.cs3.rom);\r
+ __cs3_region_zero_size_rom = SIZEOF(.cs3.rom.bss);\r
+\r
+ .data : ALIGN (8)\r
+ {\r
+ KEEP(*(.jcr))\r
+ *(.got.plt) *(.got)\r
+ *(.shdata)\r
+ *(.data .data.* .gnu.linkonce.d.*)\r
+ . = ALIGN (8);\r
+ *(.ram)\r
+ . = ALIGN (8);\r
+ _edata = .;\r
+ } >ram\r
+ .bss : ALIGN (8)\r
+ {\r
+ *(.shbss)\r
+ *(.bss .bss.* .gnu.linkonce.b.*)\r
+ *(COMMON)\r
+ . = ALIGN (8);\r
+ *(.ram.b .bss.ram)\r
+ . = ALIGN (8);\r
+ _end = .;\r
+ __end = .;\r
+ } >ram\r
+ /* __cs3_region_end_ram is deprecated */\r
+ __cs3_region_end_ram = __cs3_region_start_ram + LENGTH(ram);\r
+ __cs3_region_size_ram = LENGTH(ram);\r
+ __cs3_region_init_ram = LOADADDR (.text);\r
+ __cs3_region_init_size_ram = _edata - ADDR (.text);\r
+ __cs3_region_zero_size_ram = _end - _edata;\r
+\r
+ .stab 0 (NOLOAD) : { *(.stab) }\r
+ .stabstr 0 (NOLOAD) : { *(.stabstr) }\r
+ /* DWARF debug sections.\r
+ * Symbols in the DWARF debugging sections are relative to\r
+ * the beginning of the section so we begin them at 0.\r
+ */\r
+ /* DWARF 1 */\r
+ .debug 0 : { *(.debug) }\r
+ .line 0 : { *(.line) }\r
+ /* GNU DWARF 1 extensions */\r
+ .debug_srcinfo 0 : { *(.debug_srcinfo) }\r
+ .debug_sfnames 0 : { *(.debug_sfnames) }\r
+ /* DWARF 1.1 and DWARF 2 */\r
+ .debug_aranges 0 : { *(.debug_aranges) }\r
+ .debug_pubnames 0 : { *(.debug_pubnames) }\r
+ /* DWARF 2 */\r
+ .debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) }\r
+ .debug_abbrev 0 : { *(.debug_abbrev) }\r
+ .debug_line 0 : { *(.debug_line) }\r
+ .debug_frame 0 : { *(.debug_frame) }\r
+ .debug_str 0 : { *(.debug_str) }\r
+ .debug_loc 0 : { *(.debug_loc) }\r
+ .debug_macinfo 0 : { *(.debug_macinfo) }\r
+ /* DWARF 2.1 */\r
+ .debug_ranges 0 : { *(.debug_ranges) }\r
+ /* SGI/MIPS DWARF 2 extensions */\r
+ .debug_weaknames 0 : { *(.debug_weaknames) }\r
+ .debug_funcnames 0 : { *(.debug_funcnames) }\r
+ .debug_typenames 0 : { *(.debug_typenames) }\r
+ .debug_varnames 0 : { *(.debug_varnames) }\r
+\r
+ .note.gnu.arm.ident 0 : { KEEP (*(.note.gnu.arm.ident)) }\r
+ .ARM.attributes 0 : { KEEP (*(.ARM.attributes)) }\r
+ /DISCARD/ : { *(.note.GNU-stack) }\r
+}\r
+/* checksum: b15b0bf76673e544380111 */\r
diff --git a/libs/system/zc702evk/baremetal/linker_remote.ld b/libs/system/zc702evk/baremetal/linker_remote.ld
--- /dev/null
@@ -0,0 +1,233 @@
+/* Linker script for Xilinx Zynq-7000\r
+ *\r
+ * Version: Sourcery CodeBench Lite 2013.11-24\r
+ * Support: https://sourcery.mentor.com/GNUToolchain/\r
+ *\r
+ * Copyright (c) 2007-2010 CodeSourcery, Inc.\r
+ * Copyright (c) 2010-2013 Mentor Graphics, Inc.\r
+ *\r
+ * The authors hereby grant permission to use, copy, modify, distribute,\r
+ * and license this software and its documentation for any purpose, provided\r
+ * that existing copyright notices are retained in all copies and that this\r
+ * notice is included verbatim in any distributions. No written agreement,\r
+ * license, or royalty fee is required for any of the authorized uses.\r
+ * Modifications to this software may be copyrighted by their authors\r
+ * and need not follow the licensing terms described here, provided that\r
+ * the new terms are clearly indicated on the first page of each file where\r
+ * they apply.\r
+ */\r
+OUTPUT_FORMAT ("elf32-littlearm", "elf32-bigarm", "elf32-littlearm")\r
+ENTRY(__cs3_reset)\r
+SEARCH_DIR(.)\r
+GROUP(-lgcc -lc -lcs3 -lcs3unhosted -lcs3arm)\r
+\r
+MEMORY\r
+{\r
+ ram (rwx) : ORIGIN = 0x00000000, LENGTH = 256M\r
+ rom (rx) : ORIGIN = 0xe4000000, LENGTH = 64M\r
+}\r
+\r
+/* These force the linker to search for particular symbols from\r
+ * the start of the link process and thus ensure the user's\r
+ * overrides are picked up\r
+ */\r
+EXTERN(__cs3_reset __cs3_reset_zynq7000_ram)\r
+EXTERN(__cs3_start_asm _start)\r
+/* Bring in the interrupt routines & vector */\r
+INCLUDE arm-names.inc\r
+EXTERN(__cs3_interrupt_vector_arm)\r
+EXTERN(__cs3_start_c main __cs3_stack __cs3_heap_end)\r
+\r
+/* Provide fall-back values */\r
+PROVIDE(__cs3_heap_start = _end);\r
+PROVIDE(__cs3_heap_end = __cs3_region_start_ram + __cs3_region_size_ram);\r
+PROVIDE(__cs3_region_num = (__cs3_regions_end - __cs3_regions) / 20);\r
+PROVIDE(__cs3_stack = __cs3_region_start_ram + __cs3_region_size_ram);\r
+\r
+SECTIONS\r
+{\r
+ _binary_firmware1_start = 0;\r
+ _binary_firmware1_end = 0;\r
+ _binary_firmware2_start = 0;\r
+ _binary_firmware2_end = 0;\r
+\r
+ .text :\r
+ {\r
+ CREATE_OBJECT_SYMBOLS\r
+ __cs3_region_start_ram = .;\r
+ _ftext = .;\r
+ *(.cs3.region-head.ram)\r
+ ASSERT (. == __cs3_region_start_ram, ".cs3.region-head.ram not permitted");\r
+ __cs3_interrupt_vector = __cs3_interrupt_vector_arm;\r
+ *(.cs3.interrupt_vector)\r
+ /* Make sure we pulled in an interrupt vector. */\r
+ ASSERT (. != __cs3_interrupt_vector_arm, "No interrupt vector");\r
+\r
+ PROVIDE(__cs3_reset = __cs3_reset_zynq7000_ram);\r
+ *(.cs3.reset)\r
+ _start = DEFINED(__cs3_start_asm) ? __cs3_start_asm : _start;\r
+\r
+ *(.text.cs3.init)\r
+ *(.text .text.* .gnu.linkonce.t.*)\r
+ *(.plt)\r
+ *(.gnu.warning)\r
+ *(.glue_7t) *(.glue_7) *(.vfp11_veneer)\r
+\r
+ *(.ARM.extab* .gnu.linkonce.armextab.*)\r
+ *(.gcc_except_table)\r
+ } >ram\r
+ .eh_frame_hdr : ALIGN (4)\r
+ {\r
+ KEEP (*(.eh_frame_hdr))\r
+ *(.eh_frame_entry .eh_frame_entry.*)\r
+ } >ram\r
+ .eh_frame : ALIGN (4)\r
+ {\r
+ KEEP (*(.eh_frame)) *(.eh_frame.*)\r
+ } >ram\r
+ /* .ARM.exidx is sorted, so has to go in its own output section. */\r
+ PROVIDE_HIDDEN (__exidx_start = .);\r
+ .ARM.exidx :\r
+ {\r
+ *(.ARM.exidx* .gnu.linkonce.armexidx.*)\r
+ } >ram\r
+ PROVIDE_HIDDEN (__exidx_end = .);\r
+ .rodata : ALIGN (4)\r
+ {\r
+ *(.rodata .rodata.* .gnu.linkonce.r.*)\r
+\r
+ . = ALIGN(4);\r
+ KEEP(*(.init))\r
+\r
+ . = ALIGN(4);\r
+ __preinit_array_start = .;\r
+ KEEP (*(.preinit_array))\r
+ __preinit_array_end = .;\r
+\r
+ . = ALIGN(4);\r
+ __init_array_start = .;\r
+ KEEP (*(SORT(.init_array.*)))\r
+ KEEP (*(.init_array))\r
+ __init_array_end = .;\r
+\r
+ . = ALIGN(4);\r
+ KEEP(*(.fini))\r
+\r
+ . = ALIGN(4);\r
+ __fini_array_start = .;\r
+ KEEP (*(.fini_array))\r
+ KEEP (*(SORT(.fini_array.*)))\r
+ __fini_array_end = .;\r
+\r
+ . = ALIGN(0x4);\r
+ KEEP (*crtbegin.o(.ctors))\r
+ KEEP (*(EXCLUDE_FILE (*crtend.o) .ctors))\r
+ KEEP (*(SORT(.ctors.*)))\r
+ KEEP (*crtend.o(.ctors))\r
+\r
+ . = ALIGN(0x4);\r
+ KEEP (*crtbegin.o(.dtors))\r
+ KEEP (*(EXCLUDE_FILE (*crtend.o) .dtors))\r
+ KEEP (*(SORT(.dtors.*)))\r
+ KEEP (*crtend.o(.dtors))\r
+\r
+ . = ALIGN(4);\r
+ __cs3_regions = .;\r
+ LONG (0)\r
+ LONG (__cs3_region_init_ram)\r
+ LONG (__cs3_region_start_ram)\r
+ LONG (__cs3_region_init_size_ram)\r
+ LONG (__cs3_region_zero_size_ram)\r
+ __cs3_regions_end = .;\r
+ . = ALIGN (8);\r
+ _etext = .;\r
+ } >ram\r
+\r
+ ASSERT (!(__cs3_region_init_ram & 7), "__cs3_region_init_ram not aligned")\r
+ ASSERT (!(__cs3_region_start_ram & 7), "__cs3_region_start_ram not aligned")\r
+ ASSERT (!(__cs3_region_init_size_ram & 7), "__cs3_region_init_size_ram not aligned")\r
+ ASSERT (!(__cs3_region_zero_size_ram & 7), "__cs3_region_zero_size_ram not aligned")\r
+ .cs3.rom : ALIGN (8)\r
+ {\r
+ __cs3_region_start_rom = .;\r
+ *(.cs3.region-head.rom)\r
+ *(.rom)\r
+ . = ALIGN (8);\r
+ } >rom\r
+ .cs3.rom.bss :\r
+ {\r
+ *(.rom.b .bss.rom)\r
+ . = ALIGN (8);\r
+ } >rom\r
+ /* __cs3_region_end_rom is deprecated */\r
+ __cs3_region_end_rom = __cs3_region_start_rom + LENGTH(rom);\r
+ __cs3_region_size_rom = LENGTH(rom);\r
+ __cs3_region_init_rom = LOADADDR (.cs3.rom);\r
+ __cs3_region_init_size_rom = LOADADDR (.cs3.rom.bss) - LOADADDR (.cs3.rom);\r
+ __cs3_region_zero_size_rom = SIZEOF(.cs3.rom.bss);\r
+\r
+ .data : ALIGN (8)\r
+ {\r
+ KEEP(*(.jcr))\r
+ *(.got.plt) *(.got)\r
+ *(.shdata)\r
+ *(.data .data.* .gnu.linkonce.d.*)\r
+ . = ALIGN (8);\r
+ *(.ram)\r
+ . = ALIGN (8);\r
+ _edata = .;\r
+ } >ram\r
+ .bss : ALIGN (8)\r
+ {\r
+ *(.shbss)\r
+ *(.bss .bss.* .gnu.linkonce.b.*)\r
+ *(COMMON)\r
+ . = ALIGN (8);\r
+ *(.ram.b .bss.ram)\r
+ . = ALIGN (8);\r
+ _end = .;\r
+ __end = .;\r
+ } >ram\r
+ /* __cs3_region_end_ram is deprecated */\r
+ __cs3_region_end_ram = __cs3_region_start_ram + LENGTH(ram);\r
+ __cs3_region_size_ram = LENGTH(ram);\r
+ __cs3_region_init_ram = LOADADDR (.text);\r
+ __cs3_region_init_size_ram = _edata - ADDR (.text);\r
+ __cs3_region_zero_size_ram = _end - _edata;\r
+\r
+ .stab 0 (NOLOAD) : { *(.stab) }\r
+ .stabstr 0 (NOLOAD) : { *(.stabstr) }\r
+ /* DWARF debug sections.\r
+ * Symbols in the DWARF debugging sections are relative to\r
+ * the beginning of the section so we begin them at 0.\r
+ */\r
+ /* DWARF 1 */\r
+ .debug 0 : { *(.debug) }\r
+ .line 0 : { *(.line) }\r
+ /* GNU DWARF 1 extensions */\r
+ .debug_srcinfo 0 : { *(.debug_srcinfo) }\r
+ .debug_sfnames 0 : { *(.debug_sfnames) }\r
+ /* DWARF 1.1 and DWARF 2 */\r
+ .debug_aranges 0 : { *(.debug_aranges) }\r
+ .debug_pubnames 0 : { *(.debug_pubnames) }\r
+ /* DWARF 2 */\r
+ .debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) }\r
+ .debug_abbrev 0 : { *(.debug_abbrev) }\r
+ .debug_line 0 : { *(.debug_line) }\r
+ .debug_frame 0 : { *(.debug_frame) }\r
+ .debug_str 0 : { *(.debug_str) }\r
+ .debug_loc 0 : { *(.debug_loc) }\r
+ .debug_macinfo 0 : { *(.debug_macinfo) }\r
+ /* DWARF 2.1 */\r
+ .debug_ranges 0 : { *(.debug_ranges) }\r
+ /* SGI/MIPS DWARF 2 extensions */\r
+ .debug_weaknames 0 : { *(.debug_weaknames) }\r
+ .debug_funcnames 0 : { *(.debug_funcnames) }\r
+ .debug_typenames 0 : { *(.debug_typenames) }\r
+ .debug_varnames 0 : { *(.debug_varnames) }\r
+\r
+ .note.gnu.arm.ident 0 : { KEEP (*(.note.gnu.arm.ident)) }\r
+ .ARM.attributes 0 : { KEEP (*(.ARM.attributes)) }\r
+ /DISCARD/ : { *(.note.GNU-stack) }\r
+}\r
+/* checksum: b15b0bf76673e544380111 */\r
diff --git a/libs/system/zc702evk/baremetal/make_master b/libs/system/zc702evk/baremetal/make_master
--- /dev/null
@@ -0,0 +1,29 @@
+# Include commons make file to get platform and tool chain specific variables.
+include Makefile.commons
+
+LIB_MASTER := libbaremetal_master.a
+
+CFLAGS+=-D"BAREMETAL_MASTER=1"
+
+SRCFILES += \
+$(wildcard *.c)
+
+OBJFILES := $(patsubst %.c, %.o, $(SRCFILES))
+
+DEPFILES := $(patsubst %.c, %.d, $(SRCFILES))
+
+all: $(LIB_MASTER)
+
+$(LIB_MASTER): $(OBJFILES)
+
+ @echo AR $@
+ @$(AR) -r $@ $(OBJFILES)
+
+%.o:%.c $(HEADERS)
+ @echo CC $(<:.c=.o)
+ @$(CC) $(CFLAGS) $(ARCH_CFLAGS) $(INCLUDE) -c $< -o $@
+
+clean:
+ -$(RM) $(LIB) $(OBJFILES) $(DEPFILES)
+
+PHONY: all clean
diff --git a/libs/system/zc702evk/baremetal/make_remote b/libs/system/zc702evk/baremetal/make_remote
--- /dev/null
@@ -0,0 +1,29 @@
+# Include commons make file to get platform and tool chain specific variables.
+include Makefile.commons
+
+LIB_REMOTE := libbaremetal_remote.a
+
+CFLAGS+=-D"BAREMETAL_MASTER=0"
+
+SRCFILES += \
+$(wildcard *.c)
+
+OBJFILES := $(patsubst %.c, %.o, $(SRCFILES))
+
+DEPFILES := $(patsubst %.c, %.d, $(SRCFILES))
+
+all: $(LIB_REMOTE)
+
+$(LIB_REMOTE): $(OBJFILES)
+
+ @echo AR $@
+ @$(AR) -r $@ $(OBJFILES)
+
+%.o:%.c $(HEADERS)
+ @echo CC $(<:.c=.o)
+ @$(CC) $(CFLAGS) $(ARCH_CFLAGS) $(INCLUDE) -c $< -o $@
+
+clean:
+ -$(RM) $(LIB) $(OBJFILES) $(DEPFILES)
+
+PHONY: all clean
diff --git a/libs/system/zc702evk/baremetal/make_remote_rpc b/libs/system/zc702evk/baremetal/make_remote_rpc
--- /dev/null
@@ -0,0 +1,29 @@
+# Include commons make file to get platform and tool chain specific variables.
+include Makefile.commons
+
+LIB_REMOTE := libbaremetal_remote_rpc.a
+
+CFLAGS+=-D"RTL_RPC=1"
+
+SRCFILES += \
+$(wildcard *.c)
+
+OBJFILES := $(patsubst %.c, %.o, $(SRCFILES))
+
+DEPFILES := $(patsubst %.c, %.d, $(SRCFILES))
+
+all: $(LIB_REMOTE)
+
+$(LIB_REMOTE): $(OBJFILES)
+
+ @echo AR $@
+ @$(AR) -r $@ $(OBJFILES)
+
+%.o:%.c $(HEADERS)
+ @echo CC $(<:.c=.o)
+ @$(CC) $(CFLAGS) $(ARCH_CFLAGS) $(INCLUDE) -c $< -o $@
+
+clean:
+ -$(RM) $(LIB) $(OBJFILES) $(DEPFILES)
+
+PHONY: all clean
diff --git a/libs/system/zc702evk/linux/boot.c b/libs/system/zc702evk/linux/boot.c
--- /dev/null
@@ -0,0 +1,594 @@
+/*\r
+ * Copyright (c) 2014, Mentor Graphics Corporation\r
+ * All rights reserved.\r
+ *\r
+ * Redistribution and use in source and binary forms, with or without\r
+ * modification, are permitted provided that the following conditions are met:\r
+ *\r
+ * 1. Redistributions of source code must retain the above copyright notice,\r
+ * this list of conditions and the following disclaimer.\r
+ * 2. Redistributions in binary form must reproduce the above copyright notice,\r
+ * this list of conditions and the following disclaimer in the documentation\r
+ * and/or other materials provided with the distribution.\r
+ * 3. Neither the name of Mentor Graphics Corporation nor the names of its\r
+ * contributors may be used to endorse or promote products derived from this\r
+ * software without specific prior written permission.\r
+ *\r
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"\r
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\r
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\r
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE\r
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\r
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\r
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\r
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\r
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\r
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\r
+ * POSSIBILITY OF SUCH DAMAGE.\r
+ */\r
+\r
+#include "libfdt/types.h"\r
+#include "libfdt/libfdt.h"\r
+#include "zlib/zlib.h"\r
+\r
+/* External variables. */\r
+extern unsigned int _image_start;\r
+extern unsigned int _image_end;\r
+extern unsigned int _bss_start;\r
+extern unsigned int _bss_end;\r
+\r
+/* Definitions.*/\r
+#define FIT_IMAGE_START (void *)&_image_start\r
+#define FIT_IMAGE_END (void *)&_image_end\r
+\r
+#define BSS_START (void *)&_bss_start\r
+#define BSS_END (void *)&_bss_end\r
+\r
+#define BSS_SIZE (((unsigned int)BSS_END) - ((unsigned int)BSS_START))\r
+\r
+#define XILINX_ARM_MACHINE 3343\r
+\r
+#define KERNEL_RESERVED_SPACE 0x7FF2000\r
+\r
+#define PUTC(a) ((*((volatile unsigned int *) 0xE0001030)) = (a))\r
+\r
+/* Globals. */\r
+unsigned int linux_kernel_start, dtb_start, linux_kernel_size, dtb_size;\r
+\r
+/* Static functions. */\r
+static void boot_linux_fit_image(void);\r
+\r
+static int process_and_relocate_fit_image(char *image_start, unsigned int image_size);\r
+\r
+extern void start_linux_with_dtb (void);\r
+\r
+static void clear_bss(void);\r
+static void invalidate_cache(void);\r
+static void clean_system(void);\r
+\r
+void put_char(char c)\r
+{\r
+ PUTC(c);\r
+ \r
+ while (((*((volatile unsigned int *) 0xE000102C)) & 0x00000008) == 0 );\r
+}\r
+void putstring(const char *str)\r
+{\r
+ while (*str)\r
+ {\r
+ put_char(*str++);\r
+ }\r
+}\r
+\r
+/* Boots the linux kernel. */\r
+void boot_linux(void)\r
+{\r
+ /* Clear BSS*/\r
+ clear_bss();\r
+ \r
+ clean_system();\r
+ \r
+ putstring("\n\r********************************* \n\r");\r
+ putstring("OpenAMP Linux Bootstrap.");\r
+ putstring("\n\r********************************* \n\r");\r
+ \r
+ /* Currently supporting only FIT image format. */\r
+ boot_linux_fit_image();\r
+}\r
+\r
+/* Boots a FIT format linux image. */\r
+static void boot_linux_fit_image(void)\r
+{\r
+ unsigned int image_size, status;\r
+\r
+ char *image_start;\r
+\r
+ /* Retrieve linux image start and end addresses. */\r
+ image_start = (char *)FIT_IMAGE_START;\r
+\r
+ /* Retrieve linux image size. */\r
+ image_size = (FIT_IMAGE_END - FIT_IMAGE_START);\r
+\r
+ /* Check for a valid linux image size. */\r
+ if(image_size > 0){\r
+\r
+ /* let us parse and relocate the FIT image. */\r
+ status = process_and_relocate_fit_image(image_start, image_size);\r
+\r
+ /* Image processed and relocated successfully. */\r
+ if(!status){\r
+\r
+ putstring("\n\rLinux Bootstrap: Booting Linux. \n\r");\r
+ \r
+ /* Image has been processed and relocated. Now boot linux*/\r
+ start_linux_with_dtb();\r
+ }\r
+ else\r
+ {\r
+ /* Go into an error loop. */\r
+ while(1);\r
+ }\r
+ }\r
+ else\r
+ {\r
+ /* Go into an error loop. */\r
+ while (1);\r
+ }\r
+}\r
+\r
+\r
+/* Returns zero for success. */\r
+static int process_and_relocate_fit_image(char *image_start, unsigned int image_size)\r
+{\r
+ unsigned int fit_image_start, compressed = 0;\r
+ unsigned long kernel_address;\r
+ int size, load_size, load_address, dtb_address;\r
+ char *conf_name = NULL;\r
+ void *data;\r
+ int cfg_offset, offset, ret;\r
+ z_stream strm;\r
+\r
+\r
+ putstring("\n\rLinux Bootstrap: Locating Linux Kernel and DTB from FIT image.\n\r");\r
+ \r
+ fit_image_start = (unsigned int)image_start;\r
+\r
+ /* Retrieve default FIT image configuration node. */\r
+ offset = fdt_path_offset((const void *)fit_image_start, "/configurations");\r
+ \r
+ if (offset >= 0)\r
+ {\r
+ /* Retrieve default configuration name. */\r
+ conf_name = (char *)fdt_getprop((const void *)fit_image_start, offset, "default", &size);\r
+ }\r
+ \r
+ if(conf_name)\r
+ {\r
+ /* Retrieve the offset of configuration node. */\r
+ cfg_offset = fdt_subnode_offset((const void *)fit_image_start, offset, conf_name);\r
+ }\r
+ \r
+ /* Retrieve kernel node using the config node. */\r
+ conf_name = (char *)fdt_getprop((const void *)fit_image_start, cfg_offset, "kernel", &size);\r
+ \r
+ if(conf_name)\r
+ {\r
+ offset = fdt_path_offset((const void *)fit_image_start, "/images");\r
+ \r
+ if(offset >= 0)\r
+ {\r
+ offset = fdt_subnode_offset((const void *)fit_image_start, offset, conf_name);\r
+ }\r
+ }\r
+ \r
+ if (offset >= 0)\r
+ {\r
+ /* Retrieve kernel image address and size. */ \r
+ kernel_address = (unsigned long)fdt_getprop((const void *)fit_image_start, offset, "data", &load_size); \r
+ \r
+ /* Retrieve kernel load address. */\r
+ data = (void *)fdt_getprop((const void *)fit_image_start, offset, "load", &size);\r
+ \r
+ load_address = *((int *)data);\r
+ \r
+ load_address = be32_to_cpu(load_address);\r
+ \r
+ /* Check kernel image for compression. */\r
+ data = (void *)fdt_getprop((const void *)fit_image_start, offset, "compression", &size);\r
+ \r
+ if(data != NULL)\r
+ {\r
+ if(!(strcmp(data, "gzip")))\r
+ {\r
+ compressed =1; \r
+ } \r
+ }\r
+ }\r
+ \r
+ memset((void *)load_address, 0, 0x0600000 - load_address);\r
+ \r
+ if(compressed == 1)\r
+ {\r
+ putstring("\n\rLinux Bootstrap: Kernel image is compressed. Starting decompression process. It may take a while...\n\r");\r
+ \r
+ /* Initialize zlib stream. */\r
+ strm.zalloc = Z_NULL;\r
+ strm.zfree = Z_NULL;\r
+ strm.opaque = Z_NULL;\r
+ strm.avail_in = 0;\r
+ strm.next_in = Z_NULL;\r
+\r
+ /* Initialize the zlib state for de-compression. */\r
+ ret = inflateInit2(&strm, MAX_WBITS + 16);\r
+\r
+ if(ret == Z_OK)\r
+ {\r
+ strm.next_in = (Bytef*)kernel_address;\r
+ strm.avail_out = KERNEL_RESERVED_SPACE;\r
+ strm.avail_in = load_size;\r
+\r
+ /* Pointer to output space. */\r
+ strm.next_out = (Bytef*)load_address;\r
+\r
+ /* Call the de-compression engine. */\r
+ ret = inflate(&strm, Z_FINISH);\r
+ }\r
+\r
+ (void)inflateEnd(&strm);\r
+\r
+ if((ret != Z_OK) && (ret != Z_STREAM_END)){\r
+\r
+ /* return with an error. */\r
+ return 1;\r
+ }\r
+ \r
+ putstring("\n\rLinux Bootstrap: Linux image decompression complete. \n\r");\r
+\r
+ }\r
+ else\r
+ {\r
+ /* Uncompressed image. Just load to the load address. */\r
+ memcpy((void *)load_address, (void *)kernel_address, load_size);\r
+ }\r
+\r
+ putstring("\n\rLinux Bootstrap: Linux kernel image has been loaded into memory. \n\r");\r
+ \r
+ /* Save kernel load address and size. */\r
+ linux_kernel_start = load_address;\r
+ linux_kernel_size = load_size;\r
+\r
+\r
+ /* Retrieve DTB node using the config node. */\r
+ conf_name = (char *)fdt_getprop((const void *)fit_image_start, cfg_offset, "fdt", &size);\r
+ \r
+ if(conf_name)\r
+ {\r
+ offset = fdt_path_offset((const void *)fit_image_start, "/images");\r
+ \r
+ if(offset >= 0)\r
+ {\r
+ offset = fdt_subnode_offset((const void *)fit_image_start, offset, conf_name);\r
+ }\r
+ }\r
+ \r
+ if (offset >= 0)\r
+ {\r
+ /* Retrieve DTB address and size. */ \r
+ dtb_address = (unsigned long )fdt_getprop((const void *)fit_image_start, offset, "data", &load_size);\r
+ }\r
+ \r
+ dtb_start = (linux_kernel_start + KERNEL_RESERVED_SPACE) & 0xFFFFFF00;\r
+ dtb_size = load_size;\r
+\r
+ memcpy((void *)dtb_start, (void *)dtb_address, load_size);\r
+\r
+ putstring("\n\rLinux Bootstrap: Loaded DTB. \n\r");\r
+ \r
+ return 0;\r
+}\r
+\r
+static void clear_bss(void)\r
+{\r
+ memset(BSS_START, 0, BSS_SIZE);\r
+}\r
+\r
+/*\r
+ * The code in this section is for invalidating the cache at startup \r
+ * \r
+ */\r
+ \r
+/* ARM Coprocessor registers */\r
+#define ARM_AR_CP0 p0\r
+#define ARM_AR_CP1 p1\r
+#define ARM_AR_CP2 p2\r
+#define ARM_AR_CP3 p3\r
+#define ARM_AR_CP4 p4\r
+#define ARM_AR_CP5 p5\r
+#define ARM_AR_CP6 p6\r
+#define ARM_AR_CP7 p7\r
+#define ARM_AR_CP8 p8\r
+#define ARM_AR_CP9 p9\r
+#define ARM_AR_CP10 p10\r
+#define ARM_AR_CP11 p11\r
+#define ARM_AR_CP12 p12\r
+#define ARM_AR_CP13 p13\r
+#define ARM_AR_CP14 p14\r
+#define ARM_AR_CP15 p15\r
+\r
+/* CRn and CRm register values */\r
+#define ARM_AR_C0 c0\r
+#define ARM_AR_C1 c1\r
+#define ARM_AR_C2 c2\r
+#define ARM_AR_C3 c3\r
+#define ARM_AR_C4 c4\r
+#define ARM_AR_C5 c5\r
+#define ARM_AR_C6 c6\r
+#define ARM_AR_C7 c7\r
+#define ARM_AR_C8 c8\r
+#define ARM_AR_C9 c9\r
+#define ARM_AR_C10 c10\r
+#define ARM_AR_C11 c11\r
+#define ARM_AR_C12 c12\r
+#define ARM_AR_C13 c13\r
+#define ARM_AR_C14 c14\r
+#define ARM_AR_C15 c15\r
+\r
+/* This define is used to add quotes to anything passed in */\r
+#define ARM_AR_QUOTES(x) #x\r
+\r
+/* This macro writes to a coprocessor register */\r
+#define ARM_AR_CP_WRITE(cp, op1, cp_value, crn, crm, op2) \\r
+ { \\r
+ asm volatile(" MCR " ARM_AR_QUOTES(cp) "," \\r
+ #op1 \\r
+ ", %0, " \\r
+ ARM_AR_QUOTES(crn) "," \\r
+ ARM_AR_QUOTES(crm) "," \\r
+ #op2 \\r
+ : /* No outputs */ \\r
+ : "r" (cp_value)); \\r
+ }\r
+\r
+/* This macro reads from a coprocessor register */\r
+#define ARM_AR_CP_READ(cp, op1, cp_value_ptr, crn, crm, op2) \\r
+ { \\r
+ asm volatile(" MRC " ARM_AR_QUOTES(cp) "," \\r
+ #op1 \\r
+ ", %0, " \\r
+ ARM_AR_QUOTES(crn) "," \\r
+ ARM_AR_QUOTES(crm) "," \\r
+ #op2 \\r
+ : "=r" (*(unsigned long *)(cp_value_ptr)) \\r
+ : /* No inputs */ ); \\r
+ }\r
+\r
+/* This macro executes a ISB instruction */\r
+#define ARM_AR_ISB_EXECUTE() \\r
+ { \\r
+ asm volatile(" ISB"); \\r
+ }\r
+\r
+/* This macro executes a DSB instruction */\r
+#define ARM_AR_DSB_EXECUTE() \\r
+ { \\r
+ asm volatile(" DSB"); \\r
+ }\r
+\r
+/* CLIDR and CCSIDR mask values */\r
+#define ARM_AR_MEM_CLIDR_LOC_MASK 0x7000000\r
+#define ARM_AR_MEM_CCSIDR_LINESIZE_MASK 0x7\r
+#define ARM_AR_MEM_CCSIDR_ASSOC_MASK 0x3FF\r
+#define ARM_AR_MEM_CCSIDR_NUMSET_MASK 0x7FFF\r
+\r
+/* CLIDR and CCSIDR shift values */\r
+#define ARM_AR_MEM_CLIDR_LOC_RSHT_OFFSET 24\r
+#define ARM_AR_MEM_CCSIDR_ASSOC_RSHT_OFFSET 3\r
+#define ARM_AR_MEM_CCSIDR_NUMSET_RSHT_OFFSET 13\r
+\r
+/* Extract 'encoded' line length of the cache */\r
+#define ARM_AR_MEM_CCSIDR_LINESIZE_GET(ccsidr_reg) (ccsidr_reg & \\r
+ ARM_AR_MEM_CCSIDR_LINESIZE_MASK)\r
+\r
+/* Extract 'encoded' way size of the cache */\r
+#define ARM_AR_MEM_CCSIDR_ASSOC_GET(ccsidr_reg) (ARM_AR_MEM_CCSIDR_ASSOC_MASK & \\r
+ (ccsidr_reg >> \\r
+ ARM_AR_MEM_CCSIDR_ASSOC_RSHT_OFFSET))\r
+\r
+/* Extract 'encoded' maximum number of index size */\r
+#define ARM_AR_MEM_CCSIDR_NUMSET_GET(ccsidr_reg) (ARM_AR_MEM_CCSIDR_NUMSET_MASK & \\r
+ (ccsidr_reg >> \\r
+ ARM_AR_MEM_CCSIDR_NUMSET_RSHT_OFFSET))\r
+\r
+/* Refer to chapter B3.12.31 c7, Cache and branch predictor maintenance functions in the\r
+ ARM Architecture Reference Manual ARMv7-A and ARMv7-R Edition 1360*/\r
+/* Calculate # of bits to be shifted for set size and way size */\r
+\r
+/* log2(line size in bytes) = ccsidr_linesize + 2 + logbase2(4) */\r
+#define ARM_AR_MEM_L_CALCULATE(linesize) (linesize + 2 + 2)\r
+\r
+/* log2(nsets) = 32 - way_size_bit_pos */\r
+\r
+/* Find the bit position of way size increment */\r
+#define ARM_AR_MEM_A_CALCULATE(assoc, a_offset_ref) \\r
+ { \\r
+ unsigned int temp_pos = 0x80000000; \\r
+ \\r
+ *a_offset_ref = 0; \\r
+ \\r
+ /* Logic to count the number of leading zeros before the first 1 */ \\r
+ while(!((assoc & temp_pos) == temp_pos)) \\r
+ { \\r
+ (*a_offset_ref)++; \\r
+ temp_pos = temp_pos >> 1; \\r
+ } \\r
+ }\r
+\r
+/* Factor way, cache number, index number */\r
+#define ARM_AR_MEM_DCCISW_SET(dccisw_ref, level, numsets, assoc, l_offset, a_offset) \\r
+ { \\r
+ *dccisw_ref = (level | (numsets << l_offset) | (assoc << a_offset)); \\r
+ }\r
+\r
+/* This macro extracts line size, assoc and set size from CCSIDR */\r
+#define ARM_AR_MEM_CCSIDR_VALS_GET(linesize_ref, assoc_ref, numsets_ref, \\r
+ l_offset_ref, a_offset_ref) \\r
+ { \\r
+ unsigned int ccsidr_val; \\r
+ \\r
+ /* Read the selected cache's CCSIDR */ \\r
+ ARM_AR_CP_READ(ARM_AR_CP15, 1, &ccsidr_val, \\r
+ ARM_AR_C0, ARM_AR_C0, 0); \\r
+ \\r
+ /* Extract 'encoded' line length of the cache */ \\r
+ *linesize_ref = ARM_AR_MEM_CCSIDR_LINESIZE_GET(ccsidr_val); \\r
+ \\r
+ /* Extract 'encoded' way size of the cache */ \\r
+ *assoc_ref = ARM_AR_MEM_CCSIDR_ASSOC_GET(ccsidr_val); \\r
+ \\r
+ /* Extract 'encoded' maximum number of index size */ \\r
+ *numsets_ref = ARM_AR_MEM_CCSIDR_NUMSET_GET(ccsidr_val); \\r
+ \\r
+ /* Calculate # of bits to be shifted for set size and way size */ \\r
+ \\r
+ /* log2(line size in bytes) = ccsidr_linesize + 2 + log2(4) */ \\r
+ *l_offset_ref = ARM_AR_MEM_L_CALCULATE(*linesize_ref); \\r
+ \\r
+ /* log2(nsets) = 32 - way_size_bit_pos */ \\r
+ ARM_AR_MEM_A_CALCULATE(*assoc_ref, a_offset_ref); \\r
+ }\r
+\r
+/* This macro invalidates all of the instruction cache at the core level. */\r
+#define ARM_AR_MEM_ICACHE_ALL_INVALIDATE() \\r
+ { \\r
+ ARM_AR_CP_WRITE(ARM_AR_CP15, 0, \\r
+ 0, ARM_AR_C7, \\r
+ ARM_AR_C5, 0); \\r
+ }\r
+\r
+\r
+/* This macro invalidates all of the data cache at the core level. */\r
+void ARM_AR_MEM_DCACHE_ALL_OP( int type) \r
+{ \r
+ unsigned int clidr_val = 0; \r
+ unsigned int clidr_loc = 0; \r
+ unsigned int cache_number = 0; \r
+ unsigned int cache_type = 0; \r
+ unsigned int ccsidr_linesize = 0; \r
+ unsigned int ccsidr_assoc = 0; \r
+ int ccsidr_numsets = 0; \r
+ int way_size_copy = 0; \r
+ unsigned int set_size_bit_pos = 0; \r
+ unsigned int cache_number_pos = 0; \r
+ unsigned int way_size_bit_pos = 0; \r
+ unsigned int set_way_value = 0; \r
+ \r
+ \r
+ /* Read CLIDR to extract level of coherence (LOC) */ \r
+ ARM_AR_CP_READ(ARM_AR_CP15, 1, &clidr_val, \r
+ ARM_AR_C0, ARM_AR_C0, 1); \r
+ \r
+ /* Extract LOC from CLIDR and align it at bit 1 */ \r
+ clidr_loc = (clidr_val & ARM_AR_MEM_CLIDR_LOC_MASK) >> \r
+ ARM_AR_MEM_CLIDR_LOC_RSHT_OFFSET; \r
+ \r
+ /* Proceed only iff LOC is non-zero */ \r
+ if (clidr_loc != 0) \r
+ { \r
+ do \r
+ { \r
+ /* Extract cache type from CLIDR */ \r
+ cache_number_pos = cache_number + (cache_number >> 1); \r
+ cache_type = (clidr_val >> cache_number_pos) & 0x7; \r
+ \r
+ /* Continue only iff data cache */ \r
+ if (cache_type >= 2) \r
+ { \r
+ /* Select desired cache level in CSSELR */ \r
+ ARM_AR_CP_WRITE(ARM_AR_CP15, 2, cache_number, \r
+ ARM_AR_C0, ARM_AR_C0, 0); \r
+ \r
+ ARM_AR_ISB_EXECUTE(); \r
+ \r
+ /* Get data like linesize, assoc and set size */ \r
+ ARM_AR_MEM_CCSIDR_VALS_GET(&ccsidr_linesize, \r
+ &ccsidr_assoc, \r
+ &ccsidr_numsets, \r
+ &set_size_bit_pos, \r
+ &way_size_bit_pos); \r
+ \r
+ do \r
+ { \r
+ way_size_copy = ccsidr_assoc; \r
+ \r
+ do \r
+ { \r
+ /* Factor way, cache number, index number */ \r
+ ARM_AR_MEM_DCCISW_SET(&set_way_value, cache_number, \r
+ ccsidr_numsets, way_size_copy, \r
+ set_size_bit_pos, \r
+ way_size_bit_pos); \r
+ \r
+ /* Execute invalidate if type = 0 */ \r
+ if (type == 0) \r
+ { \r
+ ARM_AR_CP_WRITE(ARM_AR_CP15, 0, \r
+ set_way_value, \r
+ ARM_AR_C7, \r
+ ARM_AR_C6, 2); \r
+ } \r
+ else \r
+ { \r
+ ARM_AR_CP_WRITE(ARM_AR_CP15, 0, \r
+ set_way_value, \r
+ ARM_AR_C7, \r
+ ARM_AR_C14, 2); \r
+ } \r
+ \r
+ /* decrement the way */ \r
+ } while((--way_size_copy) >= 0); \r
+ \r
+ /* decrement the set */ \r
+ } while((--ccsidr_numsets) >= 0); \r
+ \r
+ } /* end if */ \r
+ \r
+ /* Increment cache number */ \r
+ cache_number += 2; \r
+ \r
+ /* end do-while */ \r
+ } while(clidr_loc >= cache_number); \r
+ \r
+ } \r
+ \r
+ /* Switch back to cache level 0 in CSSELR */ \r
+ ARM_AR_CP_WRITE(ARM_AR_CP15, 2, 0, \r
+ ARM_AR_C0, ARM_AR_C0, 0); \r
+ \r
+ /* Sync */ \r
+ ARM_AR_DSB_EXECUTE(); \r
+ ARM_AR_ISB_EXECUTE(); \r
+}\r
+\r
+/* This macro invalidates all of the data cache at the core level. */\r
+void ARM_AR_MEM_DCACHE_ALL_INVALIDATE(void) \r
+{\r
+ ARM_AR_MEM_DCACHE_ALL_OP(0);\r
+}\r
+\r
+/* This macro invalidates all of the cache at the core level. */\r
+void ARM_AR_MEM_CACHE_ALL_INVALIDATE(void) \r
+{ \r
+ ARM_AR_MEM_ICACHE_ALL_INVALIDATE(); \r
+ ARM_AR_MEM_DCACHE_ALL_INVALIDATE(); \r
+}\r
+\r
+\r
+static void clean_system(void){\r
+\r
+ invalidate_cache();\r
+\r
+}\r
+static void invalidate_cache(void)\r
+{\r
+ ARM_AR_MEM_CACHE_ALL_INVALIDATE();\r
+}\r
diff --git a/libs/system/zc702evk/linux/boot_wrapper.S b/libs/system/zc702evk/linux/boot_wrapper.S
--- /dev/null
@@ -0,0 +1,113 @@
+@*\r
+@* Copyright (c) 2014, Mentor Graphics Corporation\r
+@* All rights reserved.\r
+@*\r
+@* Redistribution and use in source and binary forms, with or without\r
+@* modification, are permitted provided that the following conditions are met:\r
+@*\r
+@* 1. Redistributions of source code must retain the above copyright notice,\r
+@* this list of conditions and the following disclaimer.\r
+@* 2. Redistributions in binary form must reproduce the above copyright notice,\r
+@* this list of conditions and the following disclaimer in the documentation\r
+@* and/or other materials provided with the distribution.\r
+@* 3. Neither the name of Mentor Graphics Corporation nor the names of its\r
+@* contributors may be used to endorse or promote products derived from this\r
+@* software without specific prior written permission.\r
+@*\r
+@* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"\r
+@* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\r
+@* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\r
+@* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE\r
+@* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\r
+@* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\r
+@* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\r
+@* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\r
+@* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\r
+@* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\r
+@* POSSIBILITY OF SUCH DAMAGE.\r
+\r
+\r
+\r
+ .extern boot_linux\r
+ .extern _bss_end\r
+ .extern linux_kernel_start\r
+ .extern dtb_start\r
+\r
+ @ include FIT format linux image\r
+ .section fit_image, "a"\r
+ .incbin "libs/system/zc702evk/linux/image.ub";\r
+\r
+ .section bootwrapper, "ax"\r
+\r
+ .code 32\r
+\r
+BOOTSTRAP_BSS_End:\r
+ .long _bss_end\r
+\r
+ .global bootwrapper_start\r
+bootwrapper_start:\r
+\r
+ MOV r0, #0xdF\r
+\r
+ @ Switch to SVC mode with IRQs and FIQs OFF\r
+ MSR CPSR_cxsf, r0\r
+\r
+ @ Disable MMU and caches\r
+\r
+ MRC p15,#0,r0,c1,c0,#0\r
+ BIC r0,r0,#0x00001000 @ Clear I bit to disable instruction cache\r
+ BIC r0,r0,#0x00000005 @ Clear C and M bits (-C-M)\r
+\r
+ @ Disable alignment checking\r
+ BIC r0,r0,#0x00000002 @ Clear alignement checking bit\r
+\r
+ MCR p15,#0,r0,c1,c0,#0\r
+ \r
+ MRC p15,#0,r0,c1,c0,#2\r
+ MOV r1,#0xF0\r
+ LSL r1,r1,#16\r
+ ORR r0,r0,r1\r
+ MCR p15,#0,r0,c1,c0,#2\r
+\r
+\r
+ MOV r0,#0x40000000\r
+ FMXR FPEXC,r0\r
+ \r
+\r
+ @ Setup stack pointer for function calls\r
+ LDR r0, BOOTSTRAP_BSS_End\r
+\r
+ ADD r0,r0,#64512\r
+\r
+ @ align stack pointer\r
+ BIC r0,r0,#0x07\r
+ MOV sp,r0\r
+\r
+ @ branch to C linux boot function\r
+ B boot_linux\r
+\r
+ .code 32\r
+ .global start_linux_with_dtb\r
+ .type start_linux_with_dtb, %function\r
+start_linux_with_dtb:\r
+\r
+ @ Set registers as per Linux boot requirements\r
+ @ For details see:\r
+ @ https://www.kernel.org/doc/Documentation/arm/Booting\r
+\r
+ MOV r0, #0 @ Set r0 =0\r
+\r
+ LDR r1, =3343 @ Set r1 = machine type (Xilinx)\r
+\r
+ LDR r4, =dtb_start\r
+\r
+ LDR r2, [r4] @ Point r2 to DTB\r
+\r
+ MOV r3, #0\r
+\r
+ LDR r4, =linux_kernel_start\r
+\r
+ LDR lr, [r4]\r
+\r
+ MOV pc, lr @ Jump to start of Linux kernel binary\r
+\r
diff --git a/libs/system/zc702evk/linux/image.ub b/libs/system/zc702evk/linux/image.ub
new file mode 100644 (file)
index 0000000..fd04adc
Binary files /dev/null and b/libs/system/zc702evk/linux/image.ub differ
index 0000000..fd04adc
Binary files /dev/null and b/libs/system/zc702evk/linux/image.ub differ
diff --git a/libs/system/zc702evk/linux/lib/arm-none-eabi-/libfdt.a b/libs/system/zc702evk/linux/lib/arm-none-eabi-/libfdt.a
new file mode 100644 (file)
index 0000000..5f4e23c
Binary files /dev/null and b/libs/system/zc702evk/linux/lib/arm-none-eabi-/libfdt.a differ
index 0000000..5f4e23c
Binary files /dev/null and b/libs/system/zc702evk/linux/lib/arm-none-eabi-/libfdt.a differ
diff --git a/libs/system/zc702evk/linux/lib/arm-none-eabi-/libzlib.a b/libs/system/zc702evk/linux/lib/arm-none-eabi-/libzlib.a
new file mode 100644 (file)
index 0000000..d979eae
Binary files /dev/null and b/libs/system/zc702evk/linux/lib/arm-none-eabi-/libzlib.a differ
index 0000000..d979eae
Binary files /dev/null and b/libs/system/zc702evk/linux/lib/arm-none-eabi-/libzlib.a differ
diff --git a/libs/system/zc702evk/linux/lib/arm-xilinx-eabi-/libfdt.a b/libs/system/zc702evk/linux/lib/arm-xilinx-eabi-/libfdt.a
new file mode 100644 (file)
index 0000000..cf318dd
Binary files /dev/null and b/libs/system/zc702evk/linux/lib/arm-xilinx-eabi-/libfdt.a differ
index 0000000..cf318dd
Binary files /dev/null and b/libs/system/zc702evk/linux/lib/arm-xilinx-eabi-/libfdt.a differ
diff --git a/libs/system/zc702evk/linux/lib/arm-xilinx-eabi-/libzlib.a b/libs/system/zc702evk/linux/lib/arm-xilinx-eabi-/libzlib.a
new file mode 100644 (file)
index 0000000..07d7a32
Binary files /dev/null and b/libs/system/zc702evk/linux/lib/arm-xilinx-eabi-/libzlib.a differ
index 0000000..07d7a32
Binary files /dev/null and b/libs/system/zc702evk/linux/lib/arm-xilinx-eabi-/libzlib.a differ
diff --git a/libs/system/zc702evk/linux/libfdt/fdt.h b/libs/system/zc702evk/linux/libfdt/fdt.h
--- /dev/null
@@ -0,0 +1,113 @@
+#ifndef _FDT_H
+#define _FDT_H
+/*
+ * libfdt - Flat Device Tree manipulation
+ * Copyright (C) 2006 David Gibson, IBM Corporation.
+ * Copyright 2012 Kim Phillips, Freescale Semiconductor.
+ *
+ * libfdt is dual licensed: you can use it either under the terms of
+ * the GPL, or the BSD license, at your option.
+ *
+ * a) This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this library; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
+ * MA 02110-1301 USA
+ *
+ * Alternatively,
+ *
+ * b) Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ * 2. Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "types.h"
+
+#ifndef __ASSEMBLY__
+
+struct fdt_header {
+ fdt32_t magic; /* magic word FDT_MAGIC */
+ fdt32_t totalsize; /* total size of DT block */
+ fdt32_t off_dt_struct; /* offset to structure */
+ fdt32_t off_dt_strings; /* offset to strings */
+ fdt32_t off_mem_rsvmap; /* offset to memory reserve map */
+ fdt32_t version; /* format version */
+ fdt32_t last_comp_version; /* last compatible version */
+
+ /* version 2 fields below */
+ fdt32_t boot_cpuid_phys; /* Which physical CPU id we're
+ booting on */
+ /* version 3 fields below */
+ fdt32_t size_dt_strings; /* size of the strings block */
+
+ /* version 17 fields below */
+ fdt32_t size_dt_struct; /* size of the structure block */
+};
+
+struct fdt_reserve_entry {
+ fdt64_t address;
+ fdt64_t size;
+};
+
+struct fdt_node_header {
+ fdt32_t tag;
+ char name[0];
+};
+
+struct fdt_property {
+ fdt32_t tag;
+ fdt32_t len;
+ fdt32_t nameoff;
+ char data[0];
+};
+
+#endif /* !__ASSEMBLY */
+
+#define FDT_MAGIC 0xd00dfeed /* 4: version, 4: total size */
+#define FDT_TAGSIZE sizeof(fdt32_t)
+
+#define FDT_BEGIN_NODE 0x1 /* Start node: full name */
+#define FDT_END_NODE 0x2 /* End node */
+#define FDT_PROP 0x3 /* Property: name off,
+ size, content */
+#define FDT_NOP 0x4 /* nop */
+#define FDT_END 0x9
+
+#define FDT_V1_SIZE (7*sizeof(fdt32_t))
+#define FDT_V2_SIZE (FDT_V1_SIZE + sizeof(fdt32_t))
+#define FDT_V3_SIZE (FDT_V2_SIZE + sizeof(fdt32_t))
+#define FDT_V16_SIZE FDT_V3_SIZE
+#define FDT_V17_SIZE (FDT_V16_SIZE + sizeof(fdt32_t))
+
+#endif /* _FDT_H */
diff --git a/libs/system/zc702evk/linux/libfdt/libfdt.h b/libs/system/zc702evk/linux/libfdt/libfdt.h
--- /dev/null
@@ -0,0 +1,1578 @@
+#ifndef _LIBFDT_H
+#define _LIBFDT_H
+/*
+ * libfdt - Flat Device Tree manipulation
+ * Copyright (C) 2006 David Gibson, IBM Corporation.
+ *
+ * libfdt is dual licensed: you can use it either under the terms of
+ * the GPL, or the BSD license, at your option.
+ *
+ * a) This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this library; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
+ * MA 02110-1301 USA
+ *
+ * Alternatively,
+ *
+ * b) Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ * 2. Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "types.h"
+#include "fdt.h"
+
+#define FDT_FIRST_SUPPORTED_VERSION 0x10
+#define FDT_LAST_SUPPORTED_VERSION 0x11
+
+/* Error codes: informative error codes */
+#define FDT_ERR_NOTFOUND 1
+ /* FDT_ERR_NOTFOUND: The requested node or property does not exist */
+#define FDT_ERR_EXISTS 2
+ /* FDT_ERR_EXISTS: Attemped to create a node or property which
+ * already exists */
+#define FDT_ERR_NOSPACE 3
+ /* FDT_ERR_NOSPACE: Operation needed to expand the device
+ * tree, but its buffer did not have sufficient space to
+ * contain the expanded tree. Use fdt_open_into() to move the
+ * device tree to a buffer with more space. */
+
+/* Error codes: codes for bad parameters */
+#define FDT_ERR_BADOFFSET 4
+ /* FDT_ERR_BADOFFSET: Function was passed a structure block
+ * offset which is out-of-bounds, or which points to an
+ * unsuitable part of the structure for the operation. */
+#define FDT_ERR_BADPATH 5
+ /* FDT_ERR_BADPATH: Function was passed a badly formatted path
+ * (e.g. missing a leading / for a function which requires an
+ * absolute path) */
+#define FDT_ERR_BADPHANDLE 6
+ /* FDT_ERR_BADPHANDLE: Function was passed an invalid phandle
+ * value. phandle values of 0 and -1 are not permitted. */
+#define FDT_ERR_BADSTATE 7
+ /* FDT_ERR_BADSTATE: Function was passed an incomplete device
+ * tree created by the sequential-write functions, which is
+ * not sufficiently complete for the requested operation. */
+
+/* Error codes: codes for bad device tree blobs */
+#define FDT_ERR_TRUNCATED 8
+ /* FDT_ERR_TRUNCATED: Structure block of the given device tree
+ * ends without an FDT_END tag. */
+#define FDT_ERR_BADMAGIC 9
+ /* FDT_ERR_BADMAGIC: Given "device tree" appears not to be a
+ * device tree at all - it is missing the flattened device
+ * tree magic number. */
+#define FDT_ERR_BADVERSION 10
+ /* FDT_ERR_BADVERSION: Given device tree has a version which
+ * can't be handled by the requested operation. For
+ * read-write functions, this may mean that fdt_open_into() is
+ * required to convert the tree to the expected version. */
+#define FDT_ERR_BADSTRUCTURE 11
+ /* FDT_ERR_BADSTRUCTURE: Given device tree has a corrupt
+ * structure block or other serious error (e.g. misnested
+ * nodes, or subnodes preceding properties). */
+#define FDT_ERR_BADLAYOUT 12
+ /* FDT_ERR_BADLAYOUT: For read-write functions, the given
+ * device tree has it's sub-blocks in an order that the
+ * function can't handle (memory reserve map, then structure,
+ * then strings). Use fdt_open_into() to reorganize the tree
+ * into a form suitable for the read-write operations. */
+
+/* "Can't happen" error indicating a bug in libfdt */
+#define FDT_ERR_INTERNAL 13
+ /* FDT_ERR_INTERNAL: libfdt has failed an internal assertion.
+ * Should never be returned, if it is, it indicates a bug in
+ * libfdt itself. */
+
+#define FDT_ERR_MAX 13
+
+/**********************************************************************/
+/* Low-level functions (you probably don't need these) */
+/**********************************************************************/
+
+const void *fdt_offset_ptr(const void *fdt, int offset, unsigned int checklen);
+static inline void *fdt_offset_ptr_w(void *fdt, int offset, int checklen)
+{
+ return (void *)(uintptr_t)fdt_offset_ptr(fdt, offset, checklen);
+}
+
+uint32_t fdt_next_tag(const void *fdt, int offset, int *nextoffset);
+
+/**********************************************************************/
+/* Traversal functions */
+/**********************************************************************/
+
+int fdt_next_node(const void *fdt, int offset, int *depth);
+
+/**
+ * fdt_first_subnode() - get offset of first direct subnode
+ *
+ * @fdt: FDT blob
+ * @offset: Offset of node to check
+ * @return offset of first subnode, or -FDT_ERR_NOTFOUND if there is none
+ */
+int fdt_first_subnode(const void *fdt, int offset);
+
+/**
+ * fdt_next_subnode() - get offset of next direct subnode
+ *
+ * After first calling fdt_first_subnode(), call this function repeatedly to
+ * get direct subnodes of a parent node.
+ *
+ * @fdt: FDT blob
+ * @offset: Offset of previous subnode
+ * @return offset of next subnode, or -FDT_ERR_NOTFOUND if there are no more
+ * subnodes
+ */
+int fdt_next_subnode(const void *fdt, int offset);
+
+/**********************************************************************/
+/* General functions */
+/**********************************************************************/
+
+#define fdt_get_header(fdt, field) \
+ (fdt32_to_cpu(((const struct fdt_header *)(fdt))->field))
+#define fdt_magic(fdt) (fdt_get_header(fdt, magic))
+#define fdt_totalsize(fdt) (fdt_get_header(fdt, totalsize))
+#define fdt_off_dt_struct(fdt) (fdt_get_header(fdt, off_dt_struct))
+#define fdt_off_dt_strings(fdt) (fdt_get_header(fdt, off_dt_strings))
+#define fdt_off_mem_rsvmap(fdt) (fdt_get_header(fdt, off_mem_rsvmap))
+#define fdt_version(fdt) (fdt_get_header(fdt, version))
+#define fdt_last_comp_version(fdt) (fdt_get_header(fdt, last_comp_version))
+#define fdt_boot_cpuid_phys(fdt) (fdt_get_header(fdt, boot_cpuid_phys))
+#define fdt_size_dt_strings(fdt) (fdt_get_header(fdt, size_dt_strings))
+#define fdt_size_dt_struct(fdt) (fdt_get_header(fdt, size_dt_struct))
+
+#define __fdt_set_hdr(name) \
+ static inline void fdt_set_##name(void *fdt, uint32_t val) \
+ { \
+ struct fdt_header *fdth = (struct fdt_header*)fdt; \
+ fdth->name = cpu_to_fdt32(val); \
+ }
+__fdt_set_hdr(magic);
+__fdt_set_hdr(totalsize);
+__fdt_set_hdr(off_dt_struct);
+__fdt_set_hdr(off_dt_strings);
+__fdt_set_hdr(off_mem_rsvmap);
+__fdt_set_hdr(version);
+__fdt_set_hdr(last_comp_version);
+__fdt_set_hdr(boot_cpuid_phys);
+__fdt_set_hdr(size_dt_strings);
+__fdt_set_hdr(size_dt_struct);
+#undef __fdt_set_hdr
+
+/**
+ * fdt_check_header - sanity check a device tree or possible device tree
+ * @fdt: pointer to data which might be a flattened device tree
+ *
+ * fdt_check_header() checks that the given buffer contains what
+ * appears to be a flattened device tree with sane information in its
+ * header.
+ *
+ * returns:
+ * 0, if the buffer appears to contain a valid device tree
+ * -FDT_ERR_BADMAGIC,
+ * -FDT_ERR_BADVERSION,
+ * -FDT_ERR_BADSTATE, standard meanings, as above
+ */
+int fdt_check_header(const void *fdt);
+
+/**
+ * fdt_move - move a device tree around in memory
+ * @fdt: pointer to the device tree to move
+ * @buf: pointer to memory where the device is to be moved
+ * @bufsize: size of the memory space at buf
+ *
+ * fdt_move() relocates, if possible, the device tree blob located at
+ * fdt to the buffer at buf of size bufsize. The buffer may overlap
+ * with the existing device tree blob at fdt. Therefore,
+ * fdt_move(fdt, fdt, fdt_totalsize(fdt))
+ * should always succeed.
+ *
+ * returns:
+ * 0, on success
+ * -FDT_ERR_NOSPACE, bufsize is insufficient to contain the device tree
+ * -FDT_ERR_BADMAGIC,
+ * -FDT_ERR_BADVERSION,
+ * -FDT_ERR_BADSTATE, standard meanings
+ */
+int fdt_move(const void *fdt, void *buf, int bufsize);
+
+/**********************************************************************/
+/* Read-only functions */
+/**********************************************************************/
+
+/**
+ * fdt_string - retrieve a string from the strings block of a device tree
+ * @fdt: pointer to the device tree blob
+ * @stroffset: offset of the string within the strings block (native endian)
+ *
+ * fdt_string() retrieves a pointer to a single string from the
+ * strings block of the device tree blob at fdt.
+ *
+ * returns:
+ * a pointer to the string, on success
+ * NULL, if stroffset is out of bounds
+ */
+const char *fdt_string(const void *fdt, int stroffset);
+
+/**
+ * fdt_num_mem_rsv - retrieve the number of memory reserve map entries
+ * @fdt: pointer to the device tree blob
+ *
+ * Returns the number of entries in the device tree blob's memory
+ * reservation map. This does not include the terminating 0,0 entry
+ * or any other (0,0) entries reserved for expansion.
+ *
+ * returns:
+ * the number of entries
+ */
+int fdt_num_mem_rsv(const void *fdt);
+
+/**
+ * fdt_get_mem_rsv - retrieve one memory reserve map entry
+ * @fdt: pointer to the device tree blob
+ * @address, @size: pointers to 64-bit variables
+ *
+ * On success, *address and *size will contain the address and size of
+ * the n-th reserve map entry from the device tree blob, in
+ * native-endian format.
+ *
+ * returns:
+ * 0, on success
+ * -FDT_ERR_BADMAGIC,
+ * -FDT_ERR_BADVERSION,
+ * -FDT_ERR_BADSTATE, standard meanings
+ */
+int fdt_get_mem_rsv(const void *fdt, int n, uint64_t *address, uint64_t *size);
+
+/**
+ * fdt_subnode_offset_namelen - find a subnode based on substring
+ * @fdt: pointer to the device tree blob
+ * @parentoffset: structure block offset of a node
+ * @name: name of the subnode to locate
+ * @namelen: number of characters of name to consider
+ *
+ * Identical to fdt_subnode_offset(), but only examine the first
+ * namelen characters of name for matching the subnode name. This is
+ * useful for finding subnodes based on a portion of a larger string,
+ * such as a full path.
+ */
+int fdt_subnode_offset_namelen(const void *fdt, int parentoffset,
+ const char *name, int namelen);
+/**
+ * fdt_subnode_offset - find a subnode of a given node
+ * @fdt: pointer to the device tree blob
+ * @parentoffset: structure block offset of a node
+ * @name: name of the subnode to locate
+ *
+ * fdt_subnode_offset() finds a subnode of the node at structure block
+ * offset parentoffset with the given name. name may include a unit
+ * address, in which case fdt_subnode_offset() will find the subnode
+ * with that unit address, or the unit address may be omitted, in
+ * which case fdt_subnode_offset() will find an arbitrary subnode
+ * whose name excluding unit address matches the given name.
+ *
+ * returns:
+ * structure block offset of the requested subnode (>=0), on success
+ * -FDT_ERR_NOTFOUND, if the requested subnode does not exist
+ * -FDT_ERR_BADOFFSET, if parentoffset did not point to an FDT_BEGIN_NODE tag
+ * -FDT_ERR_BADMAGIC,
+ * -FDT_ERR_BADVERSION,
+ * -FDT_ERR_BADSTATE,
+ * -FDT_ERR_BADSTRUCTURE,
+ * -FDT_ERR_TRUNCATED, standard meanings.
+ */
+int fdt_subnode_offset(const void *fdt, int parentoffset, const char *name);
+
+/**
+ * fdt_path_offset - find a tree node by its full path
+ * @fdt: pointer to the device tree blob
+ * @path: full path of the node to locate
+ *
+ * fdt_path_offset() finds a node of a given path in the device tree.
+ * Each path component may omit the unit address portion, but the
+ * results of this are undefined if any such path component is
+ * ambiguous (that is if there are multiple nodes at the relevant
+ * level matching the given component, differentiated only by unit
+ * address).
+ *
+ * returns:
+ * structure block offset of the node with the requested path (>=0), on success
+ * -FDT_ERR_BADPATH, given path does not begin with '/' or is invalid
+ * -FDT_ERR_NOTFOUND, if the requested node does not exist
+ * -FDT_ERR_BADMAGIC,
+ * -FDT_ERR_BADVERSION,
+ * -FDT_ERR_BADSTATE,
+ * -FDT_ERR_BADSTRUCTURE,
+ * -FDT_ERR_TRUNCATED, standard meanings.
+ */
+int fdt_path_offset(const void *fdt, const char *path);
+
+/**
+ * fdt_get_name - retrieve the name of a given node
+ * @fdt: pointer to the device tree blob
+ * @nodeoffset: structure block offset of the starting node
+ * @lenp: pointer to an integer variable (will be overwritten) or NULL
+ *
+ * fdt_get_name() retrieves the name (including unit address) of the
+ * device tree node at structure block offset nodeoffset. If lenp is
+ * non-NULL, the length of this name is also returned, in the integer
+ * pointed to by lenp.
+ *
+ * returns:
+ * pointer to the node's name, on success
+ * If lenp is non-NULL, *lenp contains the length of that name (>=0)
+ * NULL, on error
+ * if lenp is non-NULL *lenp contains an error code (<0):
+ * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag
+ * -FDT_ERR_BADMAGIC,
+ * -FDT_ERR_BADVERSION,
+ * -FDT_ERR_BADSTATE, standard meanings
+ */
+const char *fdt_get_name(const void *fdt, int nodeoffset, int *lenp);
+
+/**
+ * fdt_first_property_offset - find the offset of a node's first property
+ * @fdt: pointer to the device tree blob
+ * @nodeoffset: structure block offset of a node
+ *
+ * fdt_first_property_offset() finds the first property of the node at
+ * the given structure block offset.
+ *
+ * returns:
+ * structure block offset of the property (>=0), on success
+ * -FDT_ERR_NOTFOUND, if the requested node has no properties
+ * -FDT_ERR_BADOFFSET, if nodeoffset did not point to an FDT_BEGIN_NODE tag
+ * -FDT_ERR_BADMAGIC,
+ * -FDT_ERR_BADVERSION,
+ * -FDT_ERR_BADSTATE,
+ * -FDT_ERR_BADSTRUCTURE,
+ * -FDT_ERR_TRUNCATED, standard meanings.
+ */
+int fdt_first_property_offset(const void *fdt, int nodeoffset);
+
+/**
+ * fdt_next_property_offset - step through a node's properties
+ * @fdt: pointer to the device tree blob
+ * @offset: structure block offset of a property
+ *
+ * fdt_next_property_offset() finds the property immediately after the
+ * one at the given structure block offset. This will be a property
+ * of the same node as the given property.
+ *
+ * returns:
+ * structure block offset of the next property (>=0), on success
+ * -FDT_ERR_NOTFOUND, if the given property is the last in its node
+ * -FDT_ERR_BADOFFSET, if nodeoffset did not point to an FDT_PROP tag
+ * -FDT_ERR_BADMAGIC,
+ * -FDT_ERR_BADVERSION,
+ * -FDT_ERR_BADSTATE,
+ * -FDT_ERR_BADSTRUCTURE,
+ * -FDT_ERR_TRUNCATED, standard meanings.
+ */
+int fdt_next_property_offset(const void *fdt, int offset);
+
+/**
+ * fdt_get_property_by_offset - retrieve the property at a given offset
+ * @fdt: pointer to the device tree blob
+ * @offset: offset of the property to retrieve
+ * @lenp: pointer to an integer variable (will be overwritten) or NULL
+ *
+ * fdt_get_property_by_offset() retrieves a pointer to the
+ * fdt_property structure within the device tree blob at the given
+ * offset. If lenp is non-NULL, the length of the property value is
+ * also returned, in the integer pointed to by lenp.
+ *
+ * returns:
+ * pointer to the structure representing the property
+ * if lenp is non-NULL, *lenp contains the length of the property
+ * value (>=0)
+ * NULL, on error
+ * if lenp is non-NULL, *lenp contains an error code (<0):
+ * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_PROP tag
+ * -FDT_ERR_BADMAGIC,
+ * -FDT_ERR_BADVERSION,
+ * -FDT_ERR_BADSTATE,
+ * -FDT_ERR_BADSTRUCTURE,
+ * -FDT_ERR_TRUNCATED, standard meanings
+ */
+const struct fdt_property *fdt_get_property_by_offset(const void *fdt,
+ int offset,
+ int *lenp);
+
+/**
+ * fdt_get_property_namelen - find a property based on substring
+ * @fdt: pointer to the device tree blob
+ * @nodeoffset: offset of the node whose property to find
+ * @name: name of the property to find
+ * @namelen: number of characters of name to consider
+ * @lenp: pointer to an integer variable (will be overwritten) or NULL
+ *
+ * Identical to fdt_get_property_namelen(), but only examine the first
+ * namelen characters of name for matching the property name.
+ */
+const struct fdt_property *fdt_get_property_namelen(const void *fdt,
+ int nodeoffset,
+ const char *name,
+ int namelen, int *lenp);
+
+/**
+ * fdt_get_property - find a given property in a given node
+ * @fdt: pointer to the device tree blob
+ * @nodeoffset: offset of the node whose property to find
+ * @name: name of the property to find
+ * @lenp: pointer to an integer variable (will be overwritten) or NULL
+ *
+ * fdt_get_property() retrieves a pointer to the fdt_property
+ * structure within the device tree blob corresponding to the property
+ * named 'name' of the node at offset nodeoffset. If lenp is
+ * non-NULL, the length of the property value is also returned, in the
+ * integer pointed to by lenp.
+ *
+ * returns:
+ * pointer to the structure representing the property
+ * if lenp is non-NULL, *lenp contains the length of the property
+ * value (>=0)
+ * NULL, on error
+ * if lenp is non-NULL, *lenp contains an error code (<0):
+ * -FDT_ERR_NOTFOUND, node does not have named property
+ * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag
+ * -FDT_ERR_BADMAGIC,
+ * -FDT_ERR_BADVERSION,
+ * -FDT_ERR_BADSTATE,
+ * -FDT_ERR_BADSTRUCTURE,
+ * -FDT_ERR_TRUNCATED, standard meanings
+ */
+const struct fdt_property *fdt_get_property(const void *fdt, int nodeoffset,
+ const char *name, int *lenp);
+static inline struct fdt_property *fdt_get_property_w(void *fdt, int nodeoffset,
+ const char *name,
+ int *lenp)
+{
+ return (struct fdt_property *)(uintptr_t)
+ fdt_get_property(fdt, nodeoffset, name, lenp);
+}
+
+/**
+ * fdt_getprop_by_offset - retrieve the value of a property at a given offset
+ * @fdt: pointer to the device tree blob
+ * @ffset: offset of the property to read
+ * @namep: pointer to a string variable (will be overwritten) or NULL
+ * @lenp: pointer to an integer variable (will be overwritten) or NULL
+ *
+ * fdt_getprop_by_offset() retrieves a pointer to the value of the
+ * property at structure block offset 'offset' (this will be a pointer
+ * to within the device blob itself, not a copy of the value). If
+ * lenp is non-NULL, the length of the property value is also
+ * returned, in the integer pointed to by lenp. If namep is non-NULL,
+ * the property's namne will also be returned in the char * pointed to
+ * by namep (this will be a pointer to within the device tree's string
+ * block, not a new copy of the name).
+ *
+ * returns:
+ * pointer to the property's value
+ * if lenp is non-NULL, *lenp contains the length of the property
+ * value (>=0)
+ * if namep is non-NULL *namep contiains a pointer to the property
+ * name.
+ * NULL, on error
+ * if lenp is non-NULL, *lenp contains an error code (<0):
+ * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_PROP tag
+ * -FDT_ERR_BADMAGIC,
+ * -FDT_ERR_BADVERSION,
+ * -FDT_ERR_BADSTATE,
+ * -FDT_ERR_BADSTRUCTURE,
+ * -FDT_ERR_TRUNCATED, standard meanings
+ */
+const void *fdt_getprop_by_offset(const void *fdt, int offset,
+ const char **namep, int *lenp);
+
+/**
+ * fdt_getprop_namelen - get property value based on substring
+ * @fdt: pointer to the device tree blob
+ * @nodeoffset: offset of the node whose property to find
+ * @name: name of the property to find
+ * @namelen: number of characters of name to consider
+ * @lenp: pointer to an integer variable (will be overwritten) or NULL
+ *
+ * Identical to fdt_getprop(), but only examine the first namelen
+ * characters of name for matching the property name.
+ */
+const void *fdt_getprop_namelen(const void *fdt, int nodeoffset,
+ const char *name, int namelen, int *lenp);
+
+/**
+ * fdt_getprop - retrieve the value of a given property
+ * @fdt: pointer to the device tree blob
+ * @nodeoffset: offset of the node whose property to find
+ * @name: name of the property to find
+ * @lenp: pointer to an integer variable (will be overwritten) or NULL
+ *
+ * fdt_getprop() retrieves a pointer to the value of the property
+ * named 'name' of the node at offset nodeoffset (this will be a
+ * pointer to within the device blob itself, not a copy of the value).
+ * If lenp is non-NULL, the length of the property value is also
+ * returned, in the integer pointed to by lenp.
+ *
+ * returns:
+ * pointer to the property's value
+ * if lenp is non-NULL, *lenp contains the length of the property
+ * value (>=0)
+ * NULL, on error
+ * if lenp is non-NULL, *lenp contains an error code (<0):
+ * -FDT_ERR_NOTFOUND, node does not have named property
+ * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag
+ * -FDT_ERR_BADMAGIC,
+ * -FDT_ERR_BADVERSION,
+ * -FDT_ERR_BADSTATE,
+ * -FDT_ERR_BADSTRUCTURE,
+ * -FDT_ERR_TRUNCATED, standard meanings
+ */
+const void *fdt_getprop(const void *fdt, int nodeoffset,
+ const char *name, int *lenp);
+static inline void *fdt_getprop_w(void *fdt, int nodeoffset,
+ const char *name, int *lenp)
+{
+ return (void *)(uintptr_t)fdt_getprop(fdt, nodeoffset, name, lenp);
+}
+
+/**
+ * fdt_get_phandle - retrieve the phandle of a given node
+ * @fdt: pointer to the device tree blob
+ * @nodeoffset: structure block offset of the node
+ *
+ * fdt_get_phandle() retrieves the phandle of the device tree node at
+ * structure block offset nodeoffset.
+ *
+ * returns:
+ * the phandle of the node at nodeoffset, on success (!= 0, != -1)
+ * 0, if the node has no phandle, or another error occurs
+ */
+uint32_t fdt_get_phandle(const void *fdt, int nodeoffset);
+
+/**
+ * fdt_get_alias_namelen - get alias based on substring
+ * @fdt: pointer to the device tree blob
+ * @name: name of the alias th look up
+ * @namelen: number of characters of name to consider
+ *
+ * Identical to fdt_get_alias(), but only examine the first namelen
+ * characters of name for matching the alias name.
+ */
+const char *fdt_get_alias_namelen(const void *fdt,
+ const char *name, int namelen);
+
+/**
+ * fdt_get_alias - retreive the path referenced by a given alias
+ * @fdt: pointer to the device tree blob
+ * @name: name of the alias th look up
+ *
+ * fdt_get_alias() retrieves the value of a given alias. That is, the
+ * value of the property named 'name' in the node /aliases.
+ *
+ * returns:
+ * a pointer to the expansion of the alias named 'name', if it exists
+ * NULL, if the given alias or the /aliases node does not exist
+ */
+const char *fdt_get_alias(const void *fdt, const char *name);
+
+/**
+ * fdt_get_path - determine the full path of a node
+ * @fdt: pointer to the device tree blob
+ * @nodeoffset: offset of the node whose path to find
+ * @buf: character buffer to contain the returned path (will be overwritten)
+ * @buflen: size of the character buffer at buf
+ *
+ * fdt_get_path() computes the full path of the node at offset
+ * nodeoffset, and records that path in the buffer at buf.
+ *
+ * NOTE: This function is expensive, as it must scan the device tree
+ * structure from the start to nodeoffset.
+ *
+ * returns:
+ * 0, on success
+ * buf contains the absolute path of the node at
+ * nodeoffset, as a NUL-terminated string.
+ * -FDT_ERR_BADOFFSET, nodeoffset does not refer to a BEGIN_NODE tag
+ * -FDT_ERR_NOSPACE, the path of the given node is longer than (bufsize-1)
+ * characters and will not fit in the given buffer.
+ * -FDT_ERR_BADMAGIC,
+ * -FDT_ERR_BADVERSION,
+ * -FDT_ERR_BADSTATE,
+ * -FDT_ERR_BADSTRUCTURE, standard meanings
+ */
+int fdt_get_path(const void *fdt, int nodeoffset, char *buf, int buflen);
+
+/**
+ * fdt_supernode_atdepth_offset - find a specific ancestor of a node
+ * @fdt: pointer to the device tree blob
+ * @nodeoffset: offset of the node whose parent to find
+ * @supernodedepth: depth of the ancestor to find
+ * @nodedepth: pointer to an integer variable (will be overwritten) or NULL
+ *
+ * fdt_supernode_atdepth_offset() finds an ancestor of the given node
+ * at a specific depth from the root (where the root itself has depth
+ * 0, its immediate subnodes depth 1 and so forth). So
+ * fdt_supernode_atdepth_offset(fdt, nodeoffset, 0, NULL);
+ * will always return 0, the offset of the root node. If the node at
+ * nodeoffset has depth D, then:
+ * fdt_supernode_atdepth_offset(fdt, nodeoffset, D, NULL);
+ * will return nodeoffset itself.
+ *
+ * NOTE: This function is expensive, as it must scan the device tree
+ * structure from the start to nodeoffset.
+ *
+ * returns:
+
+ * structure block offset of the node at node offset's ancestor
+ * of depth supernodedepth (>=0), on success
+ * -FDT_ERR_BADOFFSET, nodeoffset does not refer to a BEGIN_NODE tag
+* -FDT_ERR_NOTFOUND, supernodedepth was greater than the depth of nodeoffset
+ * -FDT_ERR_BADMAGIC,
+ * -FDT_ERR_BADVERSION,
+ * -FDT_ERR_BADSTATE,
+ * -FDT_ERR_BADSTRUCTURE, standard meanings
+ */
+int fdt_supernode_atdepth_offset(const void *fdt, int nodeoffset,
+ int supernodedepth, int *nodedepth);
+
+/**
+ * fdt_node_depth - find the depth of a given node
+ * @fdt: pointer to the device tree blob
+ * @nodeoffset: offset of the node whose parent to find
+ *
+ * fdt_node_depth() finds the depth of a given node. The root node
+ * has depth 0, its immediate subnodes depth 1 and so forth.
+ *
+ * NOTE: This function is expensive, as it must scan the device tree
+ * structure from the start to nodeoffset.
+ *
+ * returns:
+ * depth of the node at nodeoffset (>=0), on success
+ * -FDT_ERR_BADOFFSET, nodeoffset does not refer to a BEGIN_NODE tag
+ * -FDT_ERR_BADMAGIC,
+ * -FDT_ERR_BADVERSION,
+ * -FDT_ERR_BADSTATE,
+ * -FDT_ERR_BADSTRUCTURE, standard meanings
+ */
+int fdt_node_depth(const void *fdt, int nodeoffset);
+
+/**
+ * fdt_parent_offset - find the parent of a given node
+ * @fdt: pointer to the device tree blob
+ * @nodeoffset: offset of the node whose parent to find
+ *
+ * fdt_parent_offset() locates the parent node of a given node (that
+ * is, it finds the offset of the node which contains the node at
+ * nodeoffset as a subnode).
+ *
+ * NOTE: This function is expensive, as it must scan the device tree
+ * structure from the start to nodeoffset, *twice*.
+ *
+ * returns:
+ * structure block offset of the parent of the node at nodeoffset
+ * (>=0), on success
+ * -FDT_ERR_BADOFFSET, nodeoffset does not refer to a BEGIN_NODE tag
+ * -FDT_ERR_BADMAGIC,
+ * -FDT_ERR_BADVERSION,
+ * -FDT_ERR_BADSTATE,
+ * -FDT_ERR_BADSTRUCTURE, standard meanings
+ */
+int fdt_parent_offset(const void *fdt, int nodeoffset);
+
+/**
+ * fdt_node_offset_by_prop_value - find nodes with a given property value
+ * @fdt: pointer to the device tree blob
+ * @startoffset: only find nodes after this offset
+ * @propname: property name to check
+ * @propval: property value to search for
+ * @proplen: length of the value in propval
+ *
+ * fdt_node_offset_by_prop_value() returns the offset of the first
+ * node after startoffset, which has a property named propname whose
+ * value is of length proplen and has value equal to propval; or if
+ * startoffset is -1, the very first such node in the tree.
+ *
+ * To iterate through all nodes matching the criterion, the following
+ * idiom can be used:
+ * offset = fdt_node_offset_by_prop_value(fdt, -1, propname,
+ * propval, proplen);
+ * while (offset != -FDT_ERR_NOTFOUND) {
+ * ... other code here ...
+ * offset = fdt_node_offset_by_prop_value(fdt, offset, propname,
+ * propval, proplen);
+ * }
+ *
+ * Note the -1 in the first call to the function, if 0 is used here
+ * instead, the function will never locate the root node, even if it
+ * matches the criterion.
+ *
+ * returns:
+ * structure block offset of the located node (>= 0, >startoffset),
+ * on success
+ * -FDT_ERR_NOTFOUND, no node matching the criterion exists in the
+ * tree after startoffset
+ * -FDT_ERR_BADOFFSET, nodeoffset does not refer to a BEGIN_NODE tag
+ * -FDT_ERR_BADMAGIC,
+ * -FDT_ERR_BADVERSION,
+ * -FDT_ERR_BADSTATE,
+ * -FDT_ERR_BADSTRUCTURE, standard meanings
+ */
+int fdt_node_offset_by_prop_value(const void *fdt, int startoffset,
+ const char *propname,
+ const void *propval, int proplen);
+
+/**
+ * fdt_node_offset_by_phandle - find the node with a given phandle
+ * @fdt: pointer to the device tree blob
+ * @phandle: phandle value
+ *
+ * fdt_node_offset_by_phandle() returns the offset of the node
+ * which has the given phandle value. If there is more than one node
+ * in the tree with the given phandle (an invalid tree), results are
+ * undefined.
+ *
+ * returns:
+ * structure block offset of the located node (>= 0), on success
+ * -FDT_ERR_NOTFOUND, no node with that phandle exists
+ * -FDT_ERR_BADPHANDLE, given phandle value was invalid (0 or -1)
+ * -FDT_ERR_BADMAGIC,
+ * -FDT_ERR_BADVERSION,
+ * -FDT_ERR_BADSTATE,
+ * -FDT_ERR_BADSTRUCTURE, standard meanings
+ */
+int fdt_node_offset_by_phandle(const void *fdt, uint32_t phandle);
+
+/**
+ * fdt_node_check_compatible: check a node's compatible property
+ * @fdt: pointer to the device tree blob
+ * @nodeoffset: offset of a tree node
+ * @compatible: string to match against
+ *
+ *
+ * fdt_node_check_compatible() returns 0 if the given node contains a
+ * 'compatible' property with the given string as one of its elements,
+ * it returns non-zero otherwise, or on error.
+ *
+ * returns:
+ * 0, if the node has a 'compatible' property listing the given string
+ * 1, if the node has a 'compatible' property, but it does not list
+ * the given string
+ * -FDT_ERR_NOTFOUND, if the given node has no 'compatible' property
+ * -FDT_ERR_BADOFFSET, if nodeoffset does not refer to a BEGIN_NODE tag
+ * -FDT_ERR_BADMAGIC,
+ * -FDT_ERR_BADVERSION,
+ * -FDT_ERR_BADSTATE,
+ * -FDT_ERR_BADSTRUCTURE, standard meanings
+ */
+int fdt_node_check_compatible(const void *fdt, int nodeoffset,
+ const char *compatible);
+
+/**
+ * fdt_node_offset_by_compatible - find nodes with a given 'compatible' value
+ * @fdt: pointer to the device tree blob
+ * @startoffset: only find nodes after this offset
+ * @compatible: 'compatible' string to match against
+ *
+ * fdt_node_offset_by_compatible() returns the offset of the first
+ * node after startoffset, which has a 'compatible' property which
+ * lists the given compatible string; or if startoffset is -1, the
+ * very first such node in the tree.
+ *
+ * To iterate through all nodes matching the criterion, the following
+ * idiom can be used:
+ * offset = fdt_node_offset_by_compatible(fdt, -1, compatible);
+ * while (offset != -FDT_ERR_NOTFOUND) {
+ * ... other code here ...
+ * offset = fdt_node_offset_by_compatible(fdt, offset, compatible);
+ * }
+ *
+ * Note the -1 in the first call to the function, if 0 is used here
+ * instead, the function will never locate the root node, even if it
+ * matches the criterion.
+ *
+ * returns:
+ * structure block offset of the located node (>= 0, >startoffset),
+ * on success
+ * -FDT_ERR_NOTFOUND, no node matching the criterion exists in the
+ * tree after startoffset
+ * -FDT_ERR_BADOFFSET, nodeoffset does not refer to a BEGIN_NODE tag
+ * -FDT_ERR_BADMAGIC,
+ * -FDT_ERR_BADVERSION,
+ * -FDT_ERR_BADSTATE,
+ * -FDT_ERR_BADSTRUCTURE, standard meanings
+ */
+int fdt_node_offset_by_compatible(const void *fdt, int startoffset,
+ const char *compatible);
+
+/**
+ * fdt_stringlist_contains - check a string list property for a string
+ * @strlist: Property containing a list of strings to check
+ * @listlen: Length of property
+ * @str: String to search for
+ *
+ * This is a utility function provided for convenience. The list contains
+ * one or more strings, each terminated by \0, as is found in a device tree
+ * "compatible" property.
+ *
+ * @return: 1 if the string is found in the list, 0 not found, or invalid list
+ */
+int fdt_stringlist_contains(const char *strlist, int listlen, const char *str);
+
+/**********************************************************************/
+/* Write-in-place functions */
+/**********************************************************************/
+
+/**
+ * fdt_setprop_inplace - change a property's value, but not its size
+ * @fdt: pointer to the device tree blob
+ * @nodeoffset: offset of the node whose property to change
+ * @name: name of the property to change
+ * @val: pointer to data to replace the property value with
+ * @len: length of the property value
+ *
+ * fdt_setprop_inplace() replaces the value of a given property with
+ * the data in val, of length len. This function cannot change the
+ * size of a property, and so will only work if len is equal to the
+ * current length of the property.
+ *
+ * This function will alter only the bytes in the blob which contain
+ * the given property value, and will not alter or move any other part
+ * of the tree.
+ *
+ * returns:
+ * 0, on success
+ * -FDT_ERR_NOSPACE, if len is not equal to the property's current length
+ * -FDT_ERR_NOTFOUND, node does not have the named property
+ * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag
+ * -FDT_ERR_BADMAGIC,
+ * -FDT_ERR_BADVERSION,
+ * -FDT_ERR_BADSTATE,
+ * -FDT_ERR_BADSTRUCTURE,
+ * -FDT_ERR_TRUNCATED, standard meanings
+ */
+int fdt_setprop_inplace(void *fdt, int nodeoffset, const char *name,
+ const void *val, int len);
+
+/**
+ * fdt_setprop_inplace_u32 - change the value of a 32-bit integer property
+ * @fdt: pointer to the device tree blob
+ * @nodeoffset: offset of the node whose property to change
+ * @name: name of the property to change
+ * @val: 32-bit integer value to replace the property with
+ *
+ * fdt_setprop_inplace_u32() replaces the value of a given property
+ * with the 32-bit integer value in val, converting val to big-endian
+ * if necessary. This function cannot change the size of a property,
+ * and so will only work if the property already exists and has length
+ * 4.
+ *
+ * This function will alter only the bytes in the blob which contain
+ * the given property value, and will not alter or move any other part
+ * of the tree.
+ *
+ * returns:
+ * 0, on success
+ * -FDT_ERR_NOSPACE, if the property's length is not equal to 4
+ * -FDT_ERR_NOTFOUND, node does not have the named property
+ * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag
+ * -FDT_ERR_BADMAGIC,
+ * -FDT_ERR_BADVERSION,
+ * -FDT_ERR_BADSTATE,
+ * -FDT_ERR_BADSTRUCTURE,
+ * -FDT_ERR_TRUNCATED, standard meanings
+ */
+static inline int fdt_setprop_inplace_u32(void *fdt, int nodeoffset,
+ const char *name, uint32_t val)
+{
+ fdt32_t tmp = cpu_to_fdt32(val);
+ return fdt_setprop_inplace(fdt, nodeoffset, name, &tmp, sizeof(tmp));
+}
+
+/**
+ * fdt_setprop_inplace_u64 - change the value of a 64-bit integer property
+ * @fdt: pointer to the device tree blob
+ * @nodeoffset: offset of the node whose property to change
+ * @name: name of the property to change
+ * @val: 64-bit integer value to replace the property with
+ *
+ * fdt_setprop_inplace_u64() replaces the value of a given property
+ * with the 64-bit integer value in val, converting val to big-endian
+ * if necessary. This function cannot change the size of a property,
+ * and so will only work if the property already exists and has length
+ * 8.
+ *
+ * This function will alter only the bytes in the blob which contain
+ * the given property value, and will not alter or move any other part
+ * of the tree.
+ *
+ * returns:
+ * 0, on success
+ * -FDT_ERR_NOSPACE, if the property's length is not equal to 8
+ * -FDT_ERR_NOTFOUND, node does not have the named property
+ * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag
+ * -FDT_ERR_BADMAGIC,
+ * -FDT_ERR_BADVERSION,
+ * -FDT_ERR_BADSTATE,
+ * -FDT_ERR_BADSTRUCTURE,
+ * -FDT_ERR_TRUNCATED, standard meanings
+ */
+static inline int fdt_setprop_inplace_u64(void *fdt, int nodeoffset,
+ const char *name, uint64_t val)
+{
+ fdt64_t tmp = cpu_to_fdt64(val);
+ return fdt_setprop_inplace(fdt, nodeoffset, name, &tmp, sizeof(tmp));
+}
+
+/**
+ * fdt_setprop_inplace_cell - change the value of a single-cell property
+ *
+ * This is an alternative name for fdt_setprop_inplace_u32()
+ */
+static inline int fdt_setprop_inplace_cell(void *fdt, int nodeoffset,
+ const char *name, uint32_t val)
+{
+ return fdt_setprop_inplace_u32(fdt, nodeoffset, name, val);
+}
+
+/**
+ * fdt_nop_property - replace a property with nop tags
+ * @fdt: pointer to the device tree blob
+ * @nodeoffset: offset of the node whose property to nop
+ * @name: name of the property to nop
+ *
+ * fdt_nop_property() will replace a given property's representation
+ * in the blob with FDT_NOP tags, effectively removing it from the
+ * tree.
+ *
+ * This function will alter only the bytes in the blob which contain
+ * the property, and will not alter or move any other part of the
+ * tree.
+ *
+ * returns:
+ * 0, on success
+ * -FDT_ERR_NOTFOUND, node does not have the named property
+ * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag
+ * -FDT_ERR_BADMAGIC,
+ * -FDT_ERR_BADVERSION,
+ * -FDT_ERR_BADSTATE,
+ * -FDT_ERR_BADSTRUCTURE,
+ * -FDT_ERR_TRUNCATED, standard meanings
+ */
+int fdt_nop_property(void *fdt, int nodeoffset, const char *name);
+
+/**
+ * fdt_nop_node - replace a node (subtree) with nop tags
+ * @fdt: pointer to the device tree blob
+ * @nodeoffset: offset of the node to nop
+ *
+ * fdt_nop_node() will replace a given node's representation in the
+ * blob, including all its subnodes, if any, with FDT_NOP tags,
+ * effectively removing it from the tree.
+ *
+ * This function will alter only the bytes in the blob which contain
+ * the node and its properties and subnodes, and will not alter or
+ * move any other part of the tree.
+ *
+ * returns:
+ * 0, on success
+ * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag
+ * -FDT_ERR_BADMAGIC,
+ * -FDT_ERR_BADVERSION,
+ * -FDT_ERR_BADSTATE,
+ * -FDT_ERR_BADSTRUCTURE,
+ * -FDT_ERR_TRUNCATED, standard meanings
+ */
+int fdt_nop_node(void *fdt, int nodeoffset);
+
+/**********************************************************************/
+/* Sequential write functions */
+/**********************************************************************/
+
+int fdt_create(void *buf, int bufsize);
+int fdt_add_reservemap_entry(void *fdt, uint64_t addr, uint64_t size);
+int fdt_finish_reservemap(void *fdt);
+int fdt_begin_node(void *fdt, const char *name);
+int fdt_property(void *fdt, const char *name, const void *val, int len);
+static inline int fdt_property_u32(void *fdt, const char *name, uint32_t val)
+{
+ fdt32_t tmp = cpu_to_fdt32(val);
+ return fdt_property(fdt, name, &tmp, sizeof(tmp));
+}
+static inline int fdt_property_u64(void *fdt, const char *name, uint64_t val)
+{
+ fdt64_t tmp = cpu_to_fdt64(val);
+ return fdt_property(fdt, name, &tmp, sizeof(tmp));
+}
+static inline int fdt_property_cell(void *fdt, const char *name, uint32_t val)
+{
+ return fdt_property_u32(fdt, name, val);
+}
+#define fdt_property_string(fdt, name, str) \
+ fdt_property(fdt, name, str, strlen(str)+1)
+int fdt_end_node(void *fdt);
+int fdt_finish(void *fdt);
+
+/**********************************************************************/
+/* Read-write functions */
+/**********************************************************************/
+
+int fdt_create_empty_tree(void *buf, int bufsize);
+int fdt_open_into(const void *fdt, void *buf, int bufsize);
+int fdt_pack(void *fdt);
+
+/**
+ * fdt_add_mem_rsv - add one memory reserve map entry
+ * @fdt: pointer to the device tree blob
+ * @address, @size: 64-bit values (native endian)
+ *
+ * Adds a reserve map entry to the given blob reserving a region at
+ * address address of length size.
+ *
+ * This function will insert data into the reserve map and will
+ * therefore change the indexes of some entries in the table.
+ *
+ * returns:
+ * 0, on success
+ * -FDT_ERR_NOSPACE, there is insufficient free space in the blob to
+ * contain the new reservation entry
+ * -FDT_ERR_BADMAGIC,
+ * -FDT_ERR_BADVERSION,
+ * -FDT_ERR_BADSTATE,
+ * -FDT_ERR_BADSTRUCTURE,
+ * -FDT_ERR_BADLAYOUT,
+ * -FDT_ERR_TRUNCATED, standard meanings
+ */
+int fdt_add_mem_rsv(void *fdt, uint64_t address, uint64_t size);
+
+/**
+ * fdt_del_mem_rsv - remove a memory reserve map entry
+ * @fdt: pointer to the device tree blob
+ * @n: entry to remove
+ *
+ * fdt_del_mem_rsv() removes the n-th memory reserve map entry from
+ * the blob.
+ *
+ * This function will delete data from the reservation table and will
+ * therefore change the indexes of some entries in the table.
+ *
+ * returns:
+ * 0, on success
+ * -FDT_ERR_NOTFOUND, there is no entry of the given index (i.e. there
+ * are less than n+1 reserve map entries)
+ * -FDT_ERR_BADMAGIC,
+ * -FDT_ERR_BADVERSION,
+ * -FDT_ERR_BADSTATE,
+ * -FDT_ERR_BADSTRUCTURE,
+ * -FDT_ERR_BADLAYOUT,
+ * -FDT_ERR_TRUNCATED, standard meanings
+ */
+int fdt_del_mem_rsv(void *fdt, int n);
+
+/**
+ * fdt_set_name - change the name of a given node
+ * @fdt: pointer to the device tree blob
+ * @nodeoffset: structure block offset of a node
+ * @name: name to give the node
+ *
+ * fdt_set_name() replaces the name (including unit address, if any)
+ * of the given node with the given string. NOTE: this function can't
+ * efficiently check if the new name is unique amongst the given
+ * node's siblings; results are undefined if this function is invoked
+ * with a name equal to one of the given node's siblings.
+ *
+ * This function may insert or delete data from the blob, and will
+ * therefore change the offsets of some existing nodes.
+ *
+ * returns:
+ * 0, on success
+ * -FDT_ERR_NOSPACE, there is insufficient free space in the blob
+ * to contain the new name
+ * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag
+ * -FDT_ERR_BADMAGIC,
+ * -FDT_ERR_BADVERSION,
+ * -FDT_ERR_BADSTATE, standard meanings
+ */
+int fdt_set_name(void *fdt, int nodeoffset, const char *name);
+
+/**
+ * fdt_setprop - create or change a property
+ * @fdt: pointer to the device tree blob
+ * @nodeoffset: offset of the node whose property to change
+ * @name: name of the property to change
+ * @val: pointer to data to set the property value to
+ * @len: length of the property value
+ *
+ * fdt_setprop() sets the value of the named property in the given
+ * node to the given value and length, creating the property if it
+ * does not already exist.
+ *
+ * This function may insert or delete data from the blob, and will
+ * therefore change the offsets of some existing nodes.
+ *
+ * returns:
+ * 0, on success
+ * -FDT_ERR_NOSPACE, there is insufficient free space in the blob to
+ * contain the new property value
+ * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag
+ * -FDT_ERR_BADLAYOUT,
+ * -FDT_ERR_BADMAGIC,
+ * -FDT_ERR_BADVERSION,
+ * -FDT_ERR_BADSTATE,
+ * -FDT_ERR_BADSTRUCTURE,
+ * -FDT_ERR_BADLAYOUT,
+ * -FDT_ERR_TRUNCATED, standard meanings
+ */
+int fdt_setprop(void *fdt, int nodeoffset, const char *name,
+ const void *val, int len);
+
+/**
+ * fdt_setprop_u32 - set a property to a 32-bit integer
+ * @fdt: pointer to the device tree blob
+ * @nodeoffset: offset of the node whose property to change
+ * @name: name of the property to change
+ * @val: 32-bit integer value for the property (native endian)
+ *
+ * fdt_setprop_u32() sets the value of the named property in the given
+ * node to the given 32-bit integer value (converting to big-endian if
+ * necessary), or creates a new property with that value if it does
+ * not already exist.
+ *
+ * This function may insert or delete data from the blob, and will
+ * therefore change the offsets of some existing nodes.
+ *
+ * returns:
+ * 0, on success
+ * -FDT_ERR_NOSPACE, there is insufficient free space in the blob to
+ * contain the new property value
+ * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag
+ * -FDT_ERR_BADLAYOUT,
+ * -FDT_ERR_BADMAGIC,
+ * -FDT_ERR_BADVERSION,
+ * -FDT_ERR_BADSTATE,
+ * -FDT_ERR_BADSTRUCTURE,
+ * -FDT_ERR_BADLAYOUT,
+ * -FDT_ERR_TRUNCATED, standard meanings
+ */
+static inline int fdt_setprop_u32(void *fdt, int nodeoffset, const char *name,
+ uint32_t val)
+{
+ fdt32_t tmp = cpu_to_fdt32(val);
+ return fdt_setprop(fdt, nodeoffset, name, &tmp, sizeof(tmp));
+}
+
+/**
+ * fdt_setprop_u64 - set a property to a 64-bit integer
+ * @fdt: pointer to the device tree blob
+ * @nodeoffset: offset of the node whose property to change
+ * @name: name of the property to change
+ * @val: 64-bit integer value for the property (native endian)
+ *
+ * fdt_setprop_u64() sets the value of the named property in the given
+ * node to the given 64-bit integer value (converting to big-endian if
+ * necessary), or creates a new property with that value if it does
+ * not already exist.
+ *
+ * This function may insert or delete data from the blob, and will
+ * therefore change the offsets of some existing nodes.
+ *
+ * returns:
+ * 0, on success
+ * -FDT_ERR_NOSPACE, there is insufficient free space in the blob to
+ * contain the new property value
+ * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag
+ * -FDT_ERR_BADLAYOUT,
+ * -FDT_ERR_BADMAGIC,
+ * -FDT_ERR_BADVERSION,
+ * -FDT_ERR_BADSTATE,
+ * -FDT_ERR_BADSTRUCTURE,
+ * -FDT_ERR_BADLAYOUT,
+ * -FDT_ERR_TRUNCATED, standard meanings
+ */
+static inline int fdt_setprop_u64(void *fdt, int nodeoffset, const char *name,
+ uint64_t val)
+{
+ fdt64_t tmp = cpu_to_fdt64(val);
+ return fdt_setprop(fdt, nodeoffset, name, &tmp, sizeof(tmp));
+}
+
+/**
+ * fdt_setprop_cell - set a property to a single cell value
+ *
+ * This is an alternative name for fdt_setprop_u32()
+ */
+static inline int fdt_setprop_cell(void *fdt, int nodeoffset, const char *name,
+ uint32_t val)
+{
+ return fdt_setprop_u32(fdt, nodeoffset, name, val);
+}
+
+/**
+ * fdt_setprop_string - set a property to a string value
+ * @fdt: pointer to the device tree blob
+ * @nodeoffset: offset of the node whose property to change
+ * @name: name of the property to change
+ * @str: string value for the property
+ *
+ * fdt_setprop_string() sets the value of the named property in the
+ * given node to the given string value (using the length of the
+ * string to determine the new length of the property), or creates a
+ * new property with that value if it does not already exist.
+ *
+ * This function may insert or delete data from the blob, and will
+ * therefore change the offsets of some existing nodes.
+ *
+ * returns:
+ * 0, on success
+ * -FDT_ERR_NOSPACE, there is insufficient free space in the blob to
+ * contain the new property value
+ * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag
+ * -FDT_ERR_BADLAYOUT,
+ * -FDT_ERR_BADMAGIC,
+ * -FDT_ERR_BADVERSION,
+ * -FDT_ERR_BADSTATE,
+ * -FDT_ERR_BADSTRUCTURE,
+ * -FDT_ERR_BADLAYOUT,
+ * -FDT_ERR_TRUNCATED, standard meanings
+ */
+#define fdt_setprop_string(fdt, nodeoffset, name, str) \
+ fdt_setprop((fdt), (nodeoffset), (name), (str), strlen(str)+1)
+
+/**
+ * fdt_appendprop - append to or create a property
+ * @fdt: pointer to the device tree blob
+ * @nodeoffset: offset of the node whose property to change
+ * @name: name of the property to append to
+ * @val: pointer to data to append to the property value
+ * @len: length of the data to append to the property value
+ *
+ * fdt_appendprop() appends the value to the named property in the
+ * given node, creating the property if it does not already exist.
+ *
+ * This function may insert data into the blob, and will therefore
+ * change the offsets of some existing nodes.
+ *
+ * returns:
+ * 0, on success
+ * -FDT_ERR_NOSPACE, there is insufficient free space in the blob to
+ * contain the new property value
+ * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag
+ * -FDT_ERR_BADLAYOUT,
+ * -FDT_ERR_BADMAGIC,
+ * -FDT_ERR_BADVERSION,
+ * -FDT_ERR_BADSTATE,
+ * -FDT_ERR_BADSTRUCTURE,
+ * -FDT_ERR_BADLAYOUT,
+ * -FDT_ERR_TRUNCATED, standard meanings
+ */
+int fdt_appendprop(void *fdt, int nodeoffset, const char *name,
+ const void *val, int len);
+
+/**
+ * fdt_appendprop_u32 - append a 32-bit integer value to a property
+ * @fdt: pointer to the device tree blob
+ * @nodeoffset: offset of the node whose property to change
+ * @name: name of the property to change
+ * @val: 32-bit integer value to append to the property (native endian)
+ *
+ * fdt_appendprop_u32() appends the given 32-bit integer value
+ * (converting to big-endian if necessary) to the value of the named
+ * property in the given node, or creates a new property with that
+ * value if it does not already exist.
+ *
+ * This function may insert data into the blob, and will therefore
+ * change the offsets of some existing nodes.
+ *
+ * returns:
+ * 0, on success
+ * -FDT_ERR_NOSPACE, there is insufficient free space in the blob to
+ * contain the new property value
+ * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag
+ * -FDT_ERR_BADLAYOUT,
+ * -FDT_ERR_BADMAGIC,
+ * -FDT_ERR_BADVERSION,
+ * -FDT_ERR_BADSTATE,
+ * -FDT_ERR_BADSTRUCTURE,
+ * -FDT_ERR_BADLAYOUT,
+ * -FDT_ERR_TRUNCATED, standard meanings
+ */
+static inline int fdt_appendprop_u32(void *fdt, int nodeoffset,
+ const char *name, uint32_t val)
+{
+ fdt32_t tmp = cpu_to_fdt32(val);
+ return fdt_appendprop(fdt, nodeoffset, name, &tmp, sizeof(tmp));
+}
+
+/**
+ * fdt_appendprop_u64 - append a 64-bit integer value to a property
+ * @fdt: pointer to the device tree blob
+ * @nodeoffset: offset of the node whose property to change
+ * @name: name of the property to change
+ * @val: 64-bit integer value to append to the property (native endian)
+ *
+ * fdt_appendprop_u64() appends the given 64-bit integer value
+ * (converting to big-endian if necessary) to the value of the named
+ * property in the given node, or creates a new property with that
+ * value if it does not already exist.
+ *
+ * This function may insert data into the blob, and will therefore
+ * change the offsets of some existing nodes.
+ *
+ * returns:
+ * 0, on success
+ * -FDT_ERR_NOSPACE, there is insufficient free space in the blob to
+ * contain the new property value
+ * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag
+ * -FDT_ERR_BADLAYOUT,
+ * -FDT_ERR_BADMAGIC,
+ * -FDT_ERR_BADVERSION,
+ * -FDT_ERR_BADSTATE,
+ * -FDT_ERR_BADSTRUCTURE,
+ * -FDT_ERR_BADLAYOUT,
+ * -FDT_ERR_TRUNCATED, standard meanings
+ */
+static inline int fdt_appendprop_u64(void *fdt, int nodeoffset,
+ const char *name, uint64_t val)
+{
+ fdt64_t tmp = cpu_to_fdt64(val);
+ return fdt_appendprop(fdt, nodeoffset, name, &tmp, sizeof(tmp));
+}
+
+/**
+ * fdt_appendprop_cell - append a single cell value to a property
+ *
+ * This is an alternative name for fdt_appendprop_u32()
+ */
+static inline int fdt_appendprop_cell(void *fdt, int nodeoffset,
+ const char *name, uint32_t val)
+{
+ return fdt_appendprop_u32(fdt, nodeoffset, name, val);
+}
+
+/**
+ * fdt_appendprop_string - append a string to a property
+ * @fdt: pointer to the device tree blob
+ * @nodeoffset: offset of the node whose property to change
+ * @name: name of the property to change
+ * @str: string value to append to the property
+ *
+ * fdt_appendprop_string() appends the given string to the value of
+ * the named property in the given node, or creates a new property
+ * with that value if it does not already exist.
+ *
+ * This function may insert data into the blob, and will therefore
+ * change the offsets of some existing nodes.
+ *
+ * returns:
+ * 0, on success
+ * -FDT_ERR_NOSPACE, there is insufficient free space in the blob to
+ * contain the new property value
+ * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag
+ * -FDT_ERR_BADLAYOUT,
+ * -FDT_ERR_BADMAGIC,
+ * -FDT_ERR_BADVERSION,
+ * -FDT_ERR_BADSTATE,
+ * -FDT_ERR_BADSTRUCTURE,
+ * -FDT_ERR_BADLAYOUT,
+ * -FDT_ERR_TRUNCATED, standard meanings
+ */
+#define fdt_appendprop_string(fdt, nodeoffset, name, str) \
+ fdt_appendprop((fdt), (nodeoffset), (name), (str), strlen(str)+1)
+
+/**
+ * fdt_delprop - delete a property
+ * @fdt: pointer to the device tree blob
+ * @nodeoffset: offset of the node whose property to nop
+ * @name: name of the property to nop
+ *
+ * fdt_del_property() will delete the given property.
+ *
+ * This function will delete data from the blob, and will therefore
+ * change the offsets of some existing nodes.
+ *
+ * returns:
+ * 0, on success
+ * -FDT_ERR_NOTFOUND, node does not have the named property
+ * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag
+ * -FDT_ERR_BADLAYOUT,
+ * -FDT_ERR_BADMAGIC,
+ * -FDT_ERR_BADVERSION,
+ * -FDT_ERR_BADSTATE,
+ * -FDT_ERR_BADSTRUCTURE,
+ * -FDT_ERR_TRUNCATED, standard meanings
+ */
+int fdt_delprop(void *fdt, int nodeoffset, const char *name);
+
+/**
+ * fdt_add_subnode_namelen - creates a new node based on substring
+ * @fdt: pointer to the device tree blob
+ * @parentoffset: structure block offset of a node
+ * @name: name of the subnode to locate
+ * @namelen: number of characters of name to consider
+ *
+ * Identical to fdt_add_subnode(), but use only the first namelen
+ * characters of name as the name of the new node. This is useful for
+ * creating subnodes based on a portion of a larger string, such as a
+ * full path.
+ */
+int fdt_add_subnode_namelen(void *fdt, int parentoffset,
+ const char *name, int namelen);
+
+/**
+ * fdt_add_subnode - creates a new node
+ * @fdt: pointer to the device tree blob
+ * @parentoffset: structure block offset of a node
+ * @name: name of the subnode to locate
+ *
+ * fdt_add_subnode() creates a new node as a subnode of the node at
+ * structure block offset parentoffset, with the given name (which
+ * should include the unit address, if any).
+ *
+ * This function will insert data into the blob, and will therefore
+ * change the offsets of some existing nodes.
+
+ * returns:
+ * structure block offset of the created nodeequested subnode (>=0), on success
+ * -FDT_ERR_NOTFOUND, if the requested subnode does not exist
+ * -FDT_ERR_BADOFFSET, if parentoffset did not point to an FDT_BEGIN_NODE tag
+ * -FDT_ERR_EXISTS, if the node at parentoffset already has a subnode of
+ * the given name
+ * -FDT_ERR_NOSPACE, if there is insufficient free space in the
+ * blob to contain the new node
+ * -FDT_ERR_NOSPACE
+ * -FDT_ERR_BADLAYOUT
+ * -FDT_ERR_BADMAGIC,
+ * -FDT_ERR_BADVERSION,
+ * -FDT_ERR_BADSTATE,
+ * -FDT_ERR_BADSTRUCTURE,
+ * -FDT_ERR_TRUNCATED, standard meanings.
+ */
+int fdt_add_subnode(void *fdt, int parentoffset, const char *name);
+
+/**
+ * fdt_del_node - delete a node (subtree)
+ * @fdt: pointer to the device tree blob
+ * @nodeoffset: offset of the node to nop
+ *
+ * fdt_del_node() will remove the given node, including all its
+ * subnodes if any, from the blob.
+ *
+ * This function will delete data from the blob, and will therefore
+ * change the offsets of some existing nodes.
+ *
+ * returns:
+ * 0, on success
+ * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag
+ * -FDT_ERR_BADLAYOUT,
+ * -FDT_ERR_BADMAGIC,
+ * -FDT_ERR_BADVERSION,
+ * -FDT_ERR_BADSTATE,
+ * -FDT_ERR_BADSTRUCTURE,
+ * -FDT_ERR_TRUNCATED, standard meanings
+ */
+int fdt_del_node(void *fdt, int nodeoffset);
+
+/**********************************************************************/
+/* Debugging / informational functions */
+/**********************************************************************/
+
+const char *fdt_strerror(int errval);
+
+struct fdt_region {
+ int offset;
+ int size;
+};
+
+/**
+ * fdt_find_regions() - find regions in device tree
+ *
+ * Given a list of nodes to include and properties to exclude, find
+ * the regions of the device tree which describe those included parts.
+ *
+ * The intent is to get a list of regions which will be invariant provided
+ * those parts are invariant. For example, if you request a list of regions
+ * for all nodes but exclude the property "data", then you will get the
+ * same region contents regardless of any change to "data" properties.
+ *
+ * This function can be used to produce a byte-stream to send to a hashing
+ * function to verify that critical parts of the FDT have not changed.
+ *
+ * Nodes which are given in 'inc' are included in the region list, as
+ * are the names of the immediate subnodes nodes (but not the properties
+ * or subnodes of those subnodes).
+ *
+ * For eaxample "/" means to include the root node, all root properties
+ * and the FDT_BEGIN_NODE and FDT_END_NODE of all subnodes of /. The latter
+ * ensures that we capture the names of the subnodes. In a hashing situation
+ * it prevents the root node from changing at all Any change to non-excluded
+ * properties, names of subnodes or number of subnodes would be detected.
+ *
+ * When used with FITs this provides the ability to hash and sign parts of
+ * the FIT based on different configurations in the FIT. Then it is
+ * impossible to change anything about that configuration (include images
+ * attached to the configuration), but it may be possible to add new
+ * configurations, new images or new signatures within the existing
+ * framework.
+ *
+ * Adding new properties to a device tree may result in the string table
+ * being extended (if the new property names are different from those
+ * already added). This function can optionally include a region for
+ * the string table so that this can be part of the hash too.
+ *
+ * The device tree header is not included in the list.
+ *
+ * @fdt: Device tree to check
+ * @inc: List of node paths to included
+ * @inc_count: Number of node paths in list
+ * @exc_prop: List of properties names to exclude
+ * @exc_prop_count: Number of properties in exclude list
+ * @region: Returns list of regions
+ * @max_region: Maximum length of region list
+ * @path: Pointer to a temporary string for the function to use for
+ * building path names
+ * @path_len: Length of path, must be large enough to hold the longest
+ * path in the tree
+ * @add_string_tab: 1 to add a region for the string table
+ * @return number of regions in list. If this is >max_regions then the
+ * region array was exhausted. You should increase max_regions and try
+ * the call again.
+ */
+int fdt_find_regions(const void *fdt, char * const inc[], int inc_count,
+ char * const exc_prop[], int exc_prop_count,
+ struct fdt_region region[], int max_regions,
+ char *path, int path_len, int add_string_tab);
+
+#endif /* _LIBFDT_H */
diff --git a/libs/system/zc702evk/linux/libfdt/libfdt_internal.h b/libs/system/zc702evk/linux/libfdt/libfdt_internal.h
--- /dev/null
@@ -0,0 +1,95 @@
+#ifndef _LIBFDT_INTERNAL_H
+#define _LIBFDT_INTERNAL_H
+/*
+ * libfdt - Flat Device Tree manipulation
+ * Copyright (C) 2006 David Gibson, IBM Corporation.
+ *
+ * libfdt is dual licensed: you can use it either under the terms of
+ * the GPL, or the BSD license, at your option.
+ *
+ * a) This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this library; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
+ * MA 02110-1301 USA
+ *
+ * Alternatively,
+ *
+ * b) Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ * 2. Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "fdt.h"
+
+#define FDT_ALIGN(x, a) (((x) + (a) - 1) & ~((a) - 1))
+#define FDT_TAGALIGN(x) (FDT_ALIGN((x), FDT_TAGSIZE))
+
+#define FDT_CHECK_HEADER(fdt) \
+ { \
+ int err; \
+ if ((err = fdt_check_header(fdt)) != 0) \
+ return err; \
+ }
+
+int _fdt_check_node_offset(const void *fdt, int offset);
+int _fdt_check_prop_offset(const void *fdt, int offset);
+const char *_fdt_find_string(const char *strtab, int tabsize, const char *s);
+int _fdt_node_end_offset(void *fdt, int nodeoffset);
+
+static inline const void *_fdt_offset_ptr(const void *fdt, int offset)
+{
+ return (const char *)fdt + fdt_off_dt_struct(fdt) + offset;
+}
+
+static inline void *_fdt_offset_ptr_w(void *fdt, int offset)
+{
+ return (void *)(uintptr_t)_fdt_offset_ptr(fdt, offset);
+}
+
+static inline const struct fdt_reserve_entry *_fdt_mem_rsv(const void *fdt, int n)
+{
+ const struct fdt_reserve_entry *rsv_table =
+ (const struct fdt_reserve_entry *)
+ ((const char *)fdt + fdt_off_mem_rsvmap(fdt));
+
+ return rsv_table + n;
+}
+static inline struct fdt_reserve_entry *_fdt_mem_rsv_w(void *fdt, int n)
+{
+ return (void *)(uintptr_t)_fdt_mem_rsv(fdt, n);
+}
+
+#define FDT_SW_MAGIC (~FDT_MAGIC)
+
+#endif /* _LIBFDT_INTERNAL_H */
diff --git a/libs/system/zc702evk/linux/libfdt/types.h b/libs/system/zc702evk/linux/libfdt/types.h
--- /dev/null
@@ -0,0 +1,73 @@
+#ifndef _LINUX_TYPES_H
+#define _LINUX_TYPES_H
+
+#include <stddef.h>
+#include <stdlib.h>
+#include <string.h>
+
+# define cpu_to_be32(x) \
+ ((((x) & 0xff000000) >> 24) | \
+ (((x) & 0x00ff0000) >> 8) | \
+ (((x) & 0x0000ff00) << 8) | \
+ (((x) & 0x000000ff) << 24))
+
+# define be32_to_cpu(x) \
+ ((((x) & 0xff000000) >> 24) | \
+ (((x) & 0x00ff0000) >> 8) | \
+ (((x) & 0x0000ff00) << 8) | \
+ (((x) & 0x000000ff) << 24))
+
+
+# define cpu_to_be64(x) \
+ ((((x) & 0xff00000000000000ull) >> 56) | \
+ (((x) & 0x00ff000000000000ull) >> 40) | \
+ (((x) & 0x0000ff0000000000ull) >> 24) | \
+ (((x) & 0x000000ff00000000ull) >> 8) | \
+ (((x) & 0x00000000ff000000ull) << 8) | \
+ (((x) & 0x0000000000ff0000ull) << 24) | \
+ (((x) & 0x000000000000ff00ull) << 40) | \
+ (((x) & 0x00000000000000ffull) << 56))
+
+# define be64_to_cpu(x) \
+ ((((x) & 0xff00000000000000ull) >> 56) | \
+ (((x) & 0x00ff000000000000ull) >> 40) | \
+ (((x) & 0x0000ff0000000000ull) >> 24) | \
+ (((x) & 0x000000ff00000000ull) >> 8) | \
+ (((x) & 0x00000000ff000000ull) << 8) | \
+ (((x) & 0x0000000000ff0000ull) << 24) | \
+ (((x) & 0x000000000000ff00ull) << 40) | \
+ (((x) & 0x00000000000000ffull) << 56))
+
+#ifndef _STDINT_H
+
+typedef unsigned char u_int8_t;
+typedef char int8_t;
+typedef unsigned short u_int16_t;
+typedef short int16_t;
+typedef unsigned int u_int32_t;
+typedef int int32_t;
+typedef unsigned char uint8_t;
+typedef unsigned short uint16_t;
+typedef unsigned int uint32_t;
+typedef unsigned long long uint64_t;
+typedef unsigned long long u_int64_t;
+typedef long long int64_t;
+
+typedef long intptr_t;
+typedef unsigned long uintptr_t;
+typedef unsigned int size_t;
+
+#endif
+
+typedef unsigned short fdt16_t;
+typedef unsigned int fdt32_t;
+typedef unsigned long long fdt64_t;
+
+
+
+#define fdt32_to_cpu(x) be32_to_cpu(x)
+#define cpu_to_fdt32(x) cpu_to_be32(x)
+#define fdt64_to_cpu(x) be64_to_cpu(x)
+#define cpu_to_fdt64(x) cpu_to_be64(x)
+
+#endif /* _LINUX_TYPES_H */
diff --git a/libs/system/zc702evk/linux/link_remote.ld b/libs/system/zc702evk/linux/link_remote.ld
--- /dev/null
@@ -0,0 +1,86 @@
+
+MEMORY
+{
+ ram : ORIGIN = 0x06000000, LENGTH = 1024M
+
+}
+
+SECTIONS
+{
+ .text :
+ {
+ KEEP (*(bootwrapper)) ;
+
+ *(.text .text*) ;
+ *(.glue_7t) ;
+ *(.glue_7) ;
+ *(.gnu.linkonce.t*)
+
+ *(.dtors);
+ LONG (0);
+
+ } > ram
+
+ .ARM.extab :
+ {
+ *(.ARM.extab* .gnu.linkonce.armextab.*)
+
+ } > ram
+
+ __exidx_start = .;
+ .ARM.exidx :
+ {
+ *(.ARM.exidx* .gnu.linkonce.armexidx.*)
+ } > ram
+ __exidx_end = .;
+
+ .rodata :
+ {
+ *(.rodata*) ;
+
+ } > ram
+
+ fit_image :
+ {
+ . = ALIGN(8) ;
+ _image_start = .;
+ KEEP(*(fit_image fit_image*));
+ _image_end = .;
+
+ } > ram
+
+ .data :
+ {
+ . = ALIGN(4) ;
+ *(.data) ;
+ *(.data*) ;
+ *(.gnu.linkonce.d*)
+ . = ALIGN(4) ;
+ } > ram
+
+ .heap :
+ {
+ . = ALIGN(8) ;
+ _heap_start = .;
+
+ . += 0x100000;
+
+ . = ALIGN(8) ;
+ _heap_end = .;
+ } > ram
+
+
+ .bss (NOLOAD) :
+ {
+ . = ALIGN(8) ;
+ _bss_start = . ;
+ *(.bss) ;
+ *(.bss*) ;
+ *(COMMON) ;
+ . = ALIGN(8) ;
+ _bss_end = . ;
+
+ } > ram
+
+ __bootwrapper_end = .;
+}
diff --git a/libs/system/zc702evk/linux/make b/libs/system/zc702evk/linux/make
--- /dev/null
@@ -0,0 +1,44 @@
+
+include Makefile.commons
+
+BOOTSTRAP_OUT := libs/system/zc702evk/linux/firmware
+
+BOOTSTRAP_SRC := libs/system/zc702evk/linux/boot.c libs/system/zc702evk/linux/rsc_table.c
+
+AS_SRCFILES := libs/system/zc702evk/linux/boot_wrapper.S
+
+BOOTSTRAPOBJFILES := $(patsubst %.c, %.o, $(BOOTSTRAP_SRC)) $(patsubst %.S, %.o, $(AS_SRCFILES))
+
+BOOTSTRAPDEPS := $(patsubst %.o, %.d, $(BOOTSTRAPOBJFILES))
+
+
+$(BOOTSTRAP_OUT): $(BOOTSTRAPOBJFILES)
+
+ @echo 'Building linux aggregate image : $@'
+
+ $(LD) -nostartfiles -T"$(OHOME)/libs/system/$(PLAT)/linux/link_remote.ld" -L"$(OHOME)/libs/system/$(PLAT)/linux/lib/$(CROSS)" -o "$(BOOTSTRAP_OUT)" -Wl,--start-group $(BOOTSTRAPOBJFILES) -lc -lm -lstdc++ -lzlib -lfdt -Wl,--end-group
+
+ @echo 'Copying ELF image to firmware folder'
+
+ $(CP) $(BOOTSTRAP_OUT) apps/firmware/zc702evk/linux/firmware
+
+ @echo 'Finished building target: $@'
+
+%.o:%.c
+ @echo CC $(<:.c=.o)
+ @$(CC) $(CFLAGS) $(ARCH_CFLAGS) $(INCLUDE) -c $< -o $@
+
+%.o:%.S
+ @echo AS $(<:.S=.o)
+ @$(AS) $(ASFLAGS) $(INCLUDE) $< -o $@
+
+clean:
+ -$(RM) $(BOOTSTRAPOBJFILES) $(BOOTSTRAPDEPS) $(BOOTSTRAP_OUT)
+
+post-build:
+ -@echo ' '
+
+secondary-outputs:
+
+PHONY: all clean dependents
+.SECONDARY: post-build
diff --git a/libs/system/zc702evk/linux/patches/linux/petalinux2013.10/devtree.patch b/libs/system/zc702evk/linux/patches/linux/petalinux2013.10/devtree.patch
--- /dev/null
@@ -0,0 +1,11 @@
+--- devtree.c 2014-05-16 21:20:12.000000000 +0500
++++ devtree_modified.c 2014-05-20 13:52:34.000000000 +0500
+@@ -80,7 +80,7 @@
+ */
+ struct device_node *cpu, *cpus;
+ u32 i, j, cpuidx = 1;
+- u32 mpidr = is_smp() ? read_cpuid_mpidr() & MPIDR_HWID_BITMASK : 0;
++ u32 mpidr = read_cpuid_mpidr() & MPIDR_HWID_BITMASK;
+
+ u32 tmp_map[NR_CPUS] = { [0 ... NR_CPUS-1] = UINT_MAX };
+ bool bootcpu_valid = false;
diff --git a/libs/system/zc702evk/linux/patches/linux/petalinux2013.10/gic.patch b/libs/system/zc702evk/linux/patches/linux/petalinux2013.10/gic.patch
--- /dev/null
@@ -0,0 +1,111 @@
+--- gic.c 2013-11-21 11:47:12.000000000 +0500
++++ gic_modified.c 2014-06-18 12:59:23.241004626 +0500
+@@ -294,6 +294,59 @@
+ #define gic_set_wake NULL
+ #endif
+
++#ifndef CONFIG_SMP
++
++struct ipi {
++ void (*handler)(void);
++};
++
++static struct ipi ipi_types[8];
++
++void handle_IPI(int ipinr, struct pt_regs *regs)
++{
++ struct pt_regs *old_regs = set_irq_regs(regs);
++
++ if (ipi_types[ipinr].handler) {
++ irq_enter();
++ (*ipi_types[ipinr].handler)();
++ irq_exit();
++ } else
++ pr_debug("CPU%u: Unknown IPI message %x\n", ipinr);
++
++ set_irq_regs(old_regs);
++}
++
++
++/*
++ * set_ipi_handler:
++ * Interface provided for a kernel module to specify an IPI handler function.
++ */
++int set_ipi_handler(int ipinr, void *handler, char *desc)
++{
++ if (ipi_types[ipinr].handler) {
++ pr_crit("IPI handler 0x%x already registered to %pf\n",
++ ipinr, ipi_types[ipinr].handler);
++ return -1;
++ }
++
++ ipi_types[ipinr].handler = handler;
++
++ return 0;
++}
++EXPORT_SYMBOL(set_ipi_handler);
++
++/*
++ * clear_ipi_handler:
++ * Interface provided for a kernel module to clear an IPI handler function.
++ */
++void clear_ipi_handler(int ipinr)
++{
++ ipi_types[ipinr].handler = NULL;
++}
++EXPORT_SYMBOL(clear_ipi_handler);
++
++#endif
++
+ asmlinkage void __exception_irq_entry gic_handle_irq(struct pt_regs *regs)
+ {
+ u32 irqstat, irqnr;
+@@ -311,9 +364,9 @@
+ }
+ if (irqnr < 16) {
+ writel_relaxed(irqstat, cpu_base + GIC_CPU_EOI);
+-#ifdef CONFIG_SMP
++
+ handle_IPI(irqnr, regs);
+-#endif
++
+ continue;
+ }
+ break;
+@@ -418,6 +471,7 @@
+ for (i = 32; i < gic_irqs; i += 4)
+ writel_relaxed(0xa0a0a0a0, base + GIC_DIST_PRI + i * 4 / 4);
+
++
+ /*
+ * Disable all interrupts. Leave the PPI and SGIs alone
+ * as these enables are banked registers.
+@@ -815,8 +869,28 @@
+ writel_relaxed(map << 16 | irq, gic_data_dist_base(&gic_data[0]) + GIC_DIST_SOFTINT);
+ }
+ EXPORT_SYMBOL(gic_raise_softirq);
++
++#else
++void gic_raise_softirq_unicore(unsigned long cpu, unsigned int irq)
++{
++ unsigned long map = 0;
++
++ map |= 1 << cpu;
++
++ /*
++ * Ensure that stores to Normal memory are visible to the
++ * other CPUs before issuing the IPI.
++ */
++ dsb();
++
++ /* this always happens on GIC0 */
++ writel_relaxed(map << 16 | irq,
++ gic_data_dist_base(&gic_data[0]) + GIC_DIST_SOFTINT);
++}
++EXPORT_SYMBOL(gic_raise_softirq_unicore);
+ #endif
+
++
+ #ifdef CONFIG_OF
+ static int gic_cnt __initdata = 0;
+
diff --git a/libs/system/zc702evk/linux/patches/linux/petalinux2013.10/readme.txt b/libs/system/zc702evk/linux/patches/linux/petalinux2013.10/readme.txt
--- /dev/null
@@ -0,0 +1,23 @@
+
+
+GIC Patch
+---------------
+
+The patch file gic.patch updates the xlnx-3.8/arch/arm/common/gic.c file within the Petalinux kernel to support Linux remote kernel in unicore mode.
+
+DevTree Patch
+---------------
+
+The patch file devtree.patch updates the xlnx-3.8/arch/arm/kernel/devtree.c file within the Petalinux kernel to support Linux remote kernel in unicore mode.
+
+The above patches are applicable for the following linux version:
+
+Distribution: petalinux-v2013.10-final (Xilinx-ZC702-2013_3)
+
+Linux kernel: 3.8.11
+
+
+Device Tree File
+---------------
+
+The file system.dts is an example device tree source file used with PetaLinux unicore remote kernel build to demonstrate the Linux remote use case.
diff --git a/libs/system/zc702evk/linux/patches/linux/petalinux2013.10/system.dts b/libs/system/zc702evk/linux/patches/linux/petalinux2013.10/system.dts
--- /dev/null
@@ -0,0 +1,421 @@
+/*
+ * Device Tree Generator version: 1.1
+ *
+ * (C) Copyright 2007-2013 Xilinx, Inc.
+ * (C) Copyright 2007-2013 Michal Simek
+ * (C) Copyright 2007-2012 PetaLogix Qld Pty Ltd
+ *
+ * Michal SIMEK <monstr@monstr.eu>
+ *
+ * CAUTION: This file is automatically generated by libgen.
+ * Version: Xilinx EDK 2013.3 EDK_P.20131013
+ * Today is: Friday, the 15 of November, 2013; 14:38:16
+ *
+ * XPS project directory: .
+ */
+
+/dts-v1/;
+/ {
+ #address-cells = <1>;
+ #size-cells = <1>;
+ compatible = "xlnx,zynq-7000";
+ model = ".";
+ aliases {
+ ethernet0 = &ps7_ethernet_0;
+ i2c0 = &ps7_i2c_0;
+ serial0 = &ps7_uart_1;
+ spi0 = &ps7_qspi_0;
+ } ;
+ chosen {
+ bootargs = "console=ttyPS0,115200";
+ linux,stdout-path = "/amba@0/serial@e0001000";
+ } ;
+ cpus {
+ #address-cells = <1>;
+ #size-cells = <0>;
+ ps7_cortexa9_0: cpu@0 {
+ bus-handle = <&ps7_axi_interconnect_0>;
+ compatible = "arm,cortex-a9";
+ d-cache-line-size = <0x20>;
+ d-cache-size = <0x8000>;
+ device_type = "cpu";
+ i-cache-line-size = <0x20>;
+ i-cache-size = <0x8000>;
+ interrupt-handle = <&ps7_scugic_0>;
+ reg = <0x1>;
+ } ;
+ } ;
+ pmu {
+ compatible = "arm,cortex-a9-pmu";
+ interrupt-parent = <&ps7_scugic_0>;
+ interrupts = <0 5 4>, <0 6 4>;
+ reg = <0xf8891000 0x1000>, <0xf8893000 0x1000>;
+ reg-names = "cpu1";
+ } ;
+ ps7_ddr_0: memory@0 {
+ device_type = "memory";
+ reg = <0x0 0x08000000>;
+ } ;
+ ps7_axi_interconnect_0: amba@0 {
+ #address-cells = <1>;
+ #size-cells = <1>;
+ compatible = "xlnx,ps7-axi-interconnect-1.00.a", "simple-bus";
+ ranges ;
+ leds_4bits: gpio@41200000 {
+ #gpio-cells = <2>;
+ compatible = "xlnx,axi-gpio-2.0", "xlnx,xps-gpio-1.00.a";
+ gpio-controller ;
+ reg = <0x41200000 0x10000>;
+ xlnx,all-inputs = <0x0>;
+ xlnx,all-inputs-2 = <0x0>;
+ xlnx,all-outputs = <0x1>;
+ xlnx,all-outputs-2 = <0x0>;
+ xlnx,dout-default = <0x0>;
+ xlnx,dout-default-2 = <0x0>;
+ xlnx,gpio-width = <0x4>;
+ xlnx,gpio2-width = <0x20>;
+ xlnx,interrupt-present = <0x0>;
+ xlnx,is-dual = <0x0>;
+ xlnx,tri-default = <0xffffffff>;
+ xlnx,tri-default-2 = <0xffffffff>;
+ } ;
+ ps7_afi_0: ps7-afi@f8008000 {
+ compatible = "xlnx,ps7-afi-1.00.a";
+ reg = <0xf8008000 0x1000>;
+ } ;
+ ps7_afi_1: ps7-afi@f8009000 {
+ compatible = "xlnx,ps7-afi-1.00.a";
+ reg = <0xf8009000 0x1000>;
+ } ;
+ ps7_afi_2: ps7-afi@f800a000 {
+ compatible = "xlnx,ps7-afi-1.00.a";
+ reg = <0xf800a000 0x1000>;
+ } ;
+ ps7_afi_3: ps7-afi@f800b000 {
+ compatible = "xlnx,ps7-afi-1.00.a";
+ reg = <0xf800b000 0x1000>;
+ } ;
+ ps7_can_0: ps7-can@e0008000 {
+ clock-names = "ref_clk", "aper_clk";
+ clocks = <&clkc 19>, <&clkc 36>;
+ compatible = "xlnx,ps7-can-1.00.a", "xlnx,ps7-can";
+ interrupt-parent = <&ps7_scugic_0>;
+ interrupts = <0 28 4>;
+ reg = <0xe0008000 0x1000>;
+ } ;
+ ps7_coresight_comp_0: ps7-coresight-comp@f8800000 {
+ compatible = "xlnx,ps7-coresight-comp-1.00.a";
+ reg = <0xf8800000 0x100000>;
+ } ;
+ ps7_ddrc_0: ps7-ddrc@f8006000 {
+ compatible = "xlnx,ps7-ddrc-1.00.a", "xlnx,ps7-ddrc";
+ reg = <0xf8006000 0x1000>;
+ xlnx,has-ecc = <0x0>;
+ } ;
+ ps7_dev_cfg_0: ps7-dev-cfg@f8007000 {
+ clock-names = "ref_clk", "fclk0", "fclk1", "fclk2", "fclk3";
+ clocks = <&clkc 12>, <&clkc 15>, <&clkc 16>, <&clkc 17>, <&clkc 18>;
+ compatible = "xlnx,ps7-dev-cfg-1.00.a";
+ interrupt-parent = <&ps7_scugic_0>;
+ interrupts = <0 8 4>;
+ reg = <0xf8007000 0x100>;
+ } ;
+ ps7_dma_s: ps7-dma@f8003000 {
+ #dma-cells = <1>;
+ #dma-channels = <8>;
+ #dma-requests = <4>;
+ arm,primecell-periphid = <0x41330>;
+ clock-names = "apb_pclk";
+ clocks = <&clkc 27>;
+ compatible = "xlnx,ps7-dma-1.00.a", "arm,primecell", "arm,pl330";
+ interrupt-names = "abort", "dma0", "dma1", "dma2", "dma3",
+ "dma4", "dma5", "dma6", "dma7";
+ interrupt-parent = <&ps7_scugic_0>;
+ interrupts = <0 13 4>, <0 14 4>, <0 15 4>, <0 16 4>, <0 17 4>, <0 40 4>, <0 41 4>, <0 42 4>, <0 43 4>;
+ reg = <0xf8003000 0x1000>;
+ } ;
+ ps7_ethernet_0: ps7-ethernet@e000b000 {
+ #address-cells = <1>;
+ #size-cells = <0>;
+ clock-names = "ref_clk", "aper_clk";
+ clocks = <&clkc 13>, <&clkc 30>;
+ compatible = "xlnx,ps7-ethernet-1.00.a";
+ interrupt-parent = <&ps7_scugic_0>;
+ interrupts = <0 22 4>;
+ local-mac-address = [ 00 0a 35 00 ac 79 ];
+ phy-handle = <&phy0>;
+ phy-mode = "rgmii-id";
+ reg = <0xe000b000 0x1000>;
+ xlnx,enet-reset = "MIO 11";
+ xlnx,eth-mode = <0x1>;
+ xlnx,has-mdio = <0x1>;
+ xlnx,ptp-enet-clock = <111111115>;
+ mdio {
+ #address-cells = <1>;
+ #size-cells = <0>;
+ phy0: phy@7 {
+ compatible = "marvell,88e1116r";
+ device_type = "ethernet-phy";
+ reg = <7>;
+ } ;
+ } ;
+ } ;
+ ps7_globaltimer_0: ps7-globaltimer@f8f00200 {
+ compatible = "xlnx,ps7-globaltimer-1.00.a";
+ reg = <0xf8f00200 0x100>;
+ } ;
+ ps7_gpio_0: ps7-gpio@e000a000 {
+ #gpio-cells = <2>;
+ clocks = <&clkc 42>;
+ compatible = "xlnx,ps7-gpio-1.00.a";
+ emio-gpio-width = <64>;
+ gpio-controller ;
+ gpio-mask-high = <0x0>;
+ gpio-mask-low = <0x5600>;
+ interrupt-parent = <&ps7_scugic_0>;
+ interrupts = <0 20 4>;
+ reg = <0xe000a000 0x1000>;
+ } ;
+ ps7_gpv_0: ps7-gpv@f8900000 {
+ compatible = "xlnx,ps7-gpv-1.00.a";
+ reg = <0xf8900000 0x100000>;
+ } ;
+ ps7_i2c_0: ps7-i2c@e0004000 {
+ bus-id = <0>;
+ clocks = <&clkc 38>;
+ compatible = "xlnx,ps7-i2c-1.00.a";
+ i2c-clk = <400000>;
+ interrupt-parent = <&ps7_scugic_0>;
+ interrupts = <0 25 4>;
+ reg = <0xe0004000 0x1000>;
+ xlnx,has-interrupt = <0x0>;
+ xlnx,i2c-reset = "MIO 13";
+ #address-cells = <1>;
+ #size-cells = <0>;
+ i2cswitch@74 {
+ compatible = "nxp,pca9548";
+ #address-cells = <1>;
+ #size-cells = <0>;
+ reg = <0x74>;
+ i2c@2 {
+ #address-cells = <1>;
+ #size-cells = <0>;
+ reg = <2>;
+ eeprom@54 {
+ compatible = "at,24c08";
+ reg = <0x54>;
+ };
+ };
+ i2c@7 {
+ #address-cells = <1>;
+ #size-cells = <0>;
+ reg = <7>;
+ hwmon@52{
+ compatible = "pmbus,ucd9248";
+ reg = <52>;
+ };
+ hwmon@53{
+ compatible = "pmbus,ucd9248";
+ reg = <53>;
+ };
+ hwmon@54{
+ compatible = "pmbus,ucd9248";
+ reg = <54>;
+ };
+ };
+ };
+ } ;
+ ps7_intc_dist_0: ps7-intc-dist@f8f01000 {
+ compatible = "xlnx,ps7-intc-dist-1.00.a";
+ reg = <0xf8f01000 0x1000>;
+ } ;
+ ps7_iop_bus_config_0: ps7-iop-bus-config@e0200000 {
+ compatible = "xlnx,ps7-iop-bus-config-1.00.a";
+ reg = <0xe0200000 0x1000>;
+ } ;
+ ps7_l2cachec_0: ps7-l2cachec@f8f02000 {
+ compatible = "xlnx,ps7-l2cachec-1.00.a";
+ reg = <0xf8f02000 0x1000>;
+ } ;
+ ps7_ocmc_0: ps7-ocmc@f800c000 {
+ compatible = "xlnx,ps7-ocmc-1.00.a";
+ reg = <0xf800c000 0x1000>;
+ } ;
+ ps7_pl310_0: ps7-pl310@f8f02000 {
+ arm,data-latency = <3 2 2>;
+ arm,tag-latency = <2 2 2>;
+ cache-level = <2>;
+ cache-unified ;
+ compatible = "xlnx,ps7-pl310-1.00.a", "arm,pl310-cache";
+ interrupt-parent = <&ps7_scugic_0>;
+ interrupts = <0 2 4>;
+ reg = <0xf8f02000 0x1000>;
+ } ;
+ ps7_qspi_0: ps7-qspi@e000d000 {
+ #address-cells = <1>;
+ #size-cells = <0>;
+ clock-names = "ref_clk", "aper_clk";
+ clocks = <&clkc 10>, <&clkc 43>;
+ compatible = "xlnx,ps7-qspi-1.00.a";
+ interrupt-parent = <&ps7_scugic_0>;
+ interrupts = <0 19 4>;
+ is-dual = <0>;
+ num-chip-select = <1>;
+ reg = <0xe000d000 0x1000>;
+ xlnx,fb-clk = <0x1>;
+ xlnx,qspi-mode = <0x0>;
+ primary_flash: ps7-qspi@0 {
+ #address-cells = <1>;
+ #size-cells = <1>;
+ reg = <0x0>;
+ spi-max-frequency = <50000000>;
+ compatible = "micron,n25q128";
+ partition@0x00000000 {
+ label = "boot";
+ reg = <0x00000000 0x00500000>;
+ };
+ partition@0x00500000 {
+ label = "bootenv";
+ reg = <0x00500000 0x00020000>;
+ };
+ partition@0x00520000 {
+ label = "image";
+ reg = <0x00520000 0x00a80000>;
+ };
+ partition@0x00fa0000 {
+ label = "spare";
+ reg = <0x00fa0000 0x00000000>;
+ };
+ } ;
+ } ;
+ ps7_qspi_linear_0: ps7-qspi-linear@fc000000 {
+ clock-names = "ref_clk", "aper_clk";
+ clocks = <&clkc 10>, <&clkc 43>;
+ compatible = "xlnx,ps7-qspi-linear-1.00.a";
+ reg = <0xfc000000 0x1000000>;
+ } ;
+ ps7_ram_0: ps7-ram@0 {
+ compatible = "xlnx,ps7-ram-1.00.a", "xlnx,ps7-ocm";
+ interrupt-parent = <&ps7_scugic_0>;
+ interrupts = <0 3 4>;
+ reg = <0xfffc0000 0x40000>;
+ } ;
+ ps7_scuc_0: ps7-scuc@f8f00000 {
+ compatible = "xlnx,ps7-scuc-1.00.a";
+ reg = <0xf8f00000 0xfd>;
+ } ;
+ ps7_scugic_0: ps7-scugic@f8f01000 {
+ #address-cells = <2>;
+ #interrupt-cells = <3>;
+ #size-cells = <1>;
+ compatible = "xlnx,ps7-scugic-1.00.a", "arm,cortex-a9-gic", "arm,gic";
+ interrupt-controller ;
+ num_cpus = <1>;
+ num_interrupts = <96>;
+ reg = <0xf8f01000 0x1000>, <0xf8f00100 0x100>;
+ } ;
+ ps7_scutimer_0: ps7-scutimer@f8f00600 {
+ clocks = <&clkc 4>;
+ compatible = "xlnx,ps7-scutimer-1.00.a", "arm,cortex-a9-twd-timer";
+ interrupt-parent = <&ps7_scugic_0>;
+ interrupts = <1 13 0x301>;
+ reg = <0xf8f00600 0x20>;
+ } ;
+ ps7_scuwdt_0: ps7-scuwdt@f8f00620 {
+ clocks = <&clkc 4>;
+ compatible = "xlnx,ps7-scuwdt-1.00.a";
+ device_type = "watchdog";
+ interrupt-parent = <&ps7_scugic_0>;
+ interrupts = <1 14 0x301>;
+ reg = <0xf8f00620 0xe0>;
+ } ;
+ ps7_sd_0: ps7-sdio@e0100000 {
+ clock-frequency = <50000000>;
+ clock-names = "ref_clk", "aper_clk";
+ clocks = <&clkc 21>, <&clkc 32>;
+ compatible = "xlnx,ps7-sdio-1.00.a", "generic-sdhci", "arasan,sdhci";
+ interrupt-parent = <&ps7_scugic_0>;
+ interrupts = <0 24 4>;
+ reg = <0xe0100000 0x1000>;
+ xlnx,has-cd = <0x1>;
+ xlnx,has-power = <0x0>;
+ xlnx,has-wp = <0x1>;
+ } ;
+ ps7_slcr_0: ps7-slcr@f8000000 {
+ compatible = "xlnx,ps7-slcr-1.00.a", "xlnx,zynq-slcr";
+ reg = <0xf8000000 0x1000>;
+ clocks {
+ #address-cells = <1>;
+ #size-cells = <0>;
+ clkc: clkc {
+ #clock-cells = <1>;
+ clock-output-names = "armpll", "ddrpll", "iopll", "cpu_6or4x", "cpu_3or2x",
+ "cpu_2x", "cpu_1x", "ddr2x", "ddr3x", "dci",
+ "lqspi", "smc", "pcap", "gem0", "gem1",
+ "fclk0", "fclk1", "fclk2", "fclk3", "can0",
+ "can1", "sdio0", "sdio1", "uart0", "uart1",
+ "spi0", "spi1", "dma", "usb0_aper", "usb1_aper",
+ "gem0_aper", "gem1_aper", "sdio0_aper", "sdio1_aper", "spi0_aper",
+ "spi1_aper", "can0_aper", "can1_aper", "i2c0_aper", "i2c1_aper",
+ "uart0_aper", "uart1_aper", "gpio_aper", "lqspi_aper", "smc_aper",
+ "swdt", "dbg_trc", "dbg_apb";
+ compatible = "xlnx,ps7-clkc";
+ fclk-enable = <0xf>;
+ ps-clk-frequency = <33333333>;
+ } ;
+ } ;
+ } ;
+ ps7_ttc_0: ps7-ttc@f8001000 {
+ clocks = <&clkc 6>;
+ compatible = "xlnx,ps7-ttc-1.00.a", "cdns,ttc";
+ interrupt-names = "ttc0", "ttc1", "ttc2";
+ interrupt-parent = <&ps7_scugic_0>;
+ interrupts = <0 10 4>, <0 11 4>, <0 12 4>;
+ reg = <0xf8001000 0x1000>;
+ } ;
+ ps7_uart_1: serial@e0001000 {
+ clock-names = "ref_clk", "aper_clk";
+ clocks = <&clkc 24>, <&clkc 41>;
+ compatible = "xlnx,ps7-uart-1.00.a", "xlnx,xuartps";
+ current-speed = <115200>;
+ device_type = "serial";
+ interrupt-parent = <&ps7_scugic_0>;
+ interrupts = <0 50 4>;
+ port-number = <0>;
+ reg = <0xe0001000 0x1000>;
+ xlnx,has-modem = <0x0>;
+ } ;
+ ps7_usb_0: ps7-usb@e0002000 {
+ clocks = <&clkc 28>;
+ compatible = "xlnx,ps7-usb-1.00.a";
+ dr_mode = "host";
+ interrupt-parent = <&ps7_scugic_0>;
+ interrupts = <0 21 4>;
+ phy_type = "ulpi";
+ reg = <0xe0002000 0x1000>;
+ usb-reset = <&ps7_gpio_0 7 0>;
+ } ;
+ ps7_xadc: ps7-xadc@f8007100 {
+ clocks = <&clkc 12>;
+ compatible = "xlnx,ps7-xadc-1.00.a";
+ interrupt-parent = <&ps7_scugic_0>;
+ interrupts = <0 7 4>;
+ reg = <0xf8007100 0x20>;
+ } ;
+
+ zynq_rpmsg_instance: zynq-rpmsg_driver@0 {
+ compatible = "xlnx,zynq_rpmsg_driver";
+ reg = < 0x08000000 0x00208000 >;
+ dev-feature = <0x00000001>;
+ gen-feature = <0x00000000>;
+ num-vrings = <2>;
+ num-descs = <256>;
+ alignment = <4096>;
+ vring0 = <6>;
+ vring1 = <3>;
+ virtioid = <7>;
+ ringtx = <0x08000000>;
+ ringrx = <0x08004000>;
+ } ;
+ } ;
+} ;
diff --git a/libs/system/zc702evk/linux/rsc_table.c b/libs/system/zc702evk/linux/rsc_table.c
--- /dev/null
@@ -0,0 +1,89 @@
+/*\r
+ * Copyright (c) 2014, Mentor Graphics Corporation\r
+ * All rights reserved.\r
+ *\r
+ * Redistribution and use in source and binary forms, with or without\r
+ * modification, are permitted provided that the following conditions are met:\r
+ *\r
+ * 1. Redistributions of source code must retain the above copyright notice,\r
+ * this list of conditions and the following disclaimer.\r
+ * 2. Redistributions in binary form must reproduce the above copyright notice,\r
+ * this list of conditions and the following disclaimer in the documentation\r
+ * and/or other materials provided with the distribution.\r
+ * 3. Neither the name of Mentor Graphics Corporation nor the names of its\r
+ * contributors may be used to endorse or promote products derived from this\r
+ * software without specific prior written permission.\r
+ *\r
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"\r
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\r
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\r
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE\r
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\r
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\r
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\r
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\r
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\r
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\r
+ * POSSIBILITY OF SUCH DAMAGE.\r
+ */\r
+\r
+/* This file populates resource table for Nucleus and BM remotes\r
+ * for use by the Linux Master */\r
+\r
+#include "open_amp.h"\r
+#include "rsc_table.h"\r
+\r
+/* Place resource table in special ELF section */\r
+#define __section(S) __attribute__((__section__(#S)))\r
+#define __resource __section(.resource_table)\r
+\r
+#define RPMSG_IPU_C0_FEATURES 1\r
+\r
+/* VirtIO rpmsg device id */\r
+#define VIRTIO_ID_RPMSG_ 7\r
+\r
+/* Remote supports Name Service announcement */\r
+#define VIRTIO_RPMSG_F_NS 0\r
+\r
+/* Resource table entries */\r
+#define ELF_START 0x00000000\r
+#define ELF_END 0x08000000\r
+#define NUM_VRINGS 0x02\r
+#define VRING_ALIGN 0x1000\r
+#define RING_TX 0x08000000\r
+#define RING_RX 0x08004000\r
+#define VRING_SIZE 256\r
+\r
+const struct remote_resource_table __resource resources =\r
+{\r
+ /* Version */\r
+ 1,\r
+\r
+ /* NUmber of table entries */\r
+ 2,\r
+ /* reserved fields */\r
+ { 0, 0,},\r
+\r
+ /* Offsets of rsc entries */\r
+ {\r
+ offsetof(struct remote_resource_table, elf_cout),\r
+ offsetof(struct remote_resource_table, rpmsg_vdev),\r
+ },\r
+\r
+ /* End of ELF file */\r
+ {\r
+ RSC_CARVEOUT, ELF_START, ELF_START, ELF_END, 0, 0, "ELF_COUT",\r
+ },\r
+\r
+ /* Virtio device entry */\r
+ { RSC_VDEV, VIRTIO_ID_RPMSG_, 0, RPMSG_IPU_C0_FEATURES, 0, 0, 0, NUM_VRINGS, {0, 0},\r
+ },\r
+\r
+ /* Vring rsc entry - part of vdev rsc entry */\r
+ {\r
+ RING_TX, VRING_ALIGN, VRING_SIZE, 1, 0\r
+ },\r
+ {\r
+ RING_RX, VRING_ALIGN, VRING_SIZE, 2, 0\r
+ },\r
+};\r
diff --git a/libs/system/zc702evk/linux/rsc_table.h b/libs/system/zc702evk/linux/rsc_table.h
--- /dev/null
@@ -0,0 +1,51 @@
+/*\r
+ * Copyright (c) 2014, Mentor Graphics Corporation\r
+ * All rights reserved.\r
+ *\r
+ * Redistribution and use in source and binary forms, with or without\r
+ * modification, are permitted provided that the following conditions are met:\r
+ *\r
+ * 1. Redistributions of source code must retain the above copyright notice,\r
+ * this list of conditions and the following disclaimer.\r
+ * 2. Redistributions in binary form must reproduce the above copyright notice,\r
+ * this list of conditions and the following disclaimer in the documentation\r
+ * and/or other materials provided with the distribution.\r
+ * 3. Neither the name of Mentor Graphics Corporation nor the names of its\r
+ * contributors may be used to endorse or promote products derived from this\r
+ * software without specific prior written permission.\r
+ *\r
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"\r
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\r
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\r
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE\r
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\r
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\r
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\r
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\r
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\r
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\r
+ * POSSIBILITY OF SUCH DAMAGE.\r
+ */\r
+\r
+/* This file populates resource table for Nucleus and BM remotes\r
+ * for use by the Linux Master */\r
+\r
+#include <stddef.h>\r
+#include "open_amp.h"\r
+\r
+#define NO_RESOURCE_ENTRIES 8\r
+\r
+/* Resource table for the given remote */\r
+struct remote_resource_table {\r
+ unsigned int version;\r
+ unsigned int num;\r
+ unsigned int reserved[2];\r
+ unsigned int offset[NO_RESOURCE_ENTRIES];\r
+ /* text carveout entry */\r
+ struct fw_rsc_carveout elf_cout;\r
+ /* rpmsg vdev entry */\r
+ struct fw_rsc_vdev rpmsg_vdev;\r
+ struct fw_rsc_vdev_vring rpmsg_vring0;\r
+ struct fw_rsc_vdev_vring rpmsg_vring1;\r
+};\r
+\r
diff --git a/libs/system/zc702evk/linux/scripts/makefiles/echo_test_baremetal_fw/Makefile b/libs/system/zc702evk/linux/scripts/makefiles/echo_test_baremetal_fw/Makefile
--- /dev/null
@@ -0,0 +1,6 @@
+include $(PETALINUX)/components/apps/apps.common.mk
+
+FIRMWARE=firmware
+install:
+ $(TARGETINST) -d data/$(FIRMWARE) /lib/firmware/zc702evk/baremetal/echo_test/$(FIRMWARE)
+
diff --git a/libs/system/zc702evk/linux/scripts/makefiles/echo_test_nucleus_fw/Makefile b/libs/system/zc702evk/linux/scripts/makefiles/echo_test_nucleus_fw/Makefile
--- /dev/null
@@ -0,0 +1,6 @@
+include $(PETALINUX)/components/apps/apps.common.mk
+
+FIRMWARE=firmware
+install:
+ $(TARGETINST) -d data/$(FIRMWARE) /lib/firmware/zc702evk/nucleus/echo_test/$(FIRMWARE)
+
diff --git a/libs/system/zc702evk/linux/scripts/makefiles/mat_mul_baremetal_fw/Makefile b/libs/system/zc702evk/linux/scripts/makefiles/mat_mul_baremetal_fw/Makefile
--- /dev/null
@@ -0,0 +1,7 @@
+include $(PETALINUX)/components/apps/apps.common.mk
+
+FIRMWARE=firmware
+install:
+ $(TARGETINST) -d data/$(FIRMWARE) /lib/firmware/zc702evk/baremetal/matrix_multiply/$(FIRMWARE)
+
+
diff --git a/libs/system/zc702evk/linux/scripts/makefiles/mat_mul_demo/Makefile b/libs/system/zc702evk/linux/scripts/makefiles/mat_mul_demo/Makefile
--- /dev/null
@@ -0,0 +1,30 @@
+ifndef PETALINUX
+$(error "Error: PETALINUX environment variable not set. Change to the root of your PetaLinux install, and source the settings.sh file")
+endif
+
+include apps.common.mk
+
+APP = mat_mul_demo
+
+# Add any other object files to this list below
+APP_OBJS = mat_mul_demo.o
+
+all: build install
+
+build: $(APP)
+
+$(APP): $(APP_OBJS)
+ $(CC) $(LDFLAGS) -lpthread -o $@ $(APP_OBJS) $(LDLIBS)
+
+clean:
+ -rm -f $(APP) *.elf *.gdb *.o
+
+.PHONY: install image
+
+install: $(APP)
+ $(TARGETINST) -d $(APP) /bin/$(APP)
+
+%.o: %.c
+ $(CC) -c $(CFLAGS) -o $@ $<
+
+
diff --git a/libs/system/zc702evk/linux/scripts/makefiles/mat_mul_nucleus_fw/Makefile b/libs/system/zc702evk/linux/scripts/makefiles/mat_mul_nucleus_fw/Makefile
--- /dev/null
@@ -0,0 +1,5 @@
+include $(PETALINUX)/components/apps/apps.common.mk
+
+FIRMWARE=firmware
+install:
+ $(TARGETINST) -d data/$(FIRMWARE) /lib/firmware/zc702evk/nucleus/matrix_multiply/$(FIRMWARE)
diff --git a/libs/system/zc702evk/linux/scripts/makefiles/readme b/libs/system/zc702evk/linux/scripts/makefiles/readme
--- /dev/null
@@ -0,0 +1,5 @@
+
+This folder contains makefiles for PetaLinux applicatiosn and modules
+which need to be updated before the build process. These files are only
+for the process of build automation and do not constitute the standard
+part of MEMF.
diff --git a/libs/system/zc702evk/linux/scripts/makefiles/rpc_demo_baremetal_fw/Makefile b/libs/system/zc702evk/linux/scripts/makefiles/rpc_demo_baremetal_fw/Makefile
--- /dev/null
@@ -0,0 +1,6 @@
+include $(PETALINUX)/components/apps/apps.common.mk
+
+FIRMWARE=firmware
+install:
+ $(TARGETINST) -d data/$(FIRMWARE) /lib/firmware/zc702evk/baremetal/rpc_demo/$(FIRMWARE)
+
diff --git a/libs/system/zc702evk/linux/scripts/makefiles/rpc_demo_nucleus_fw/Makefile b/libs/system/zc702evk/linux/scripts/makefiles/rpc_demo_nucleus_fw/Makefile
--- /dev/null
@@ -0,0 +1,5 @@
+include $(PETALINUX)/components/apps/apps.common.mk
+
+FIRMWARE=firmware
+install:
+ $(TARGETINST) -d data/$(FIRMWARE) /lib/firmware/zc702evk/nucleus/rpc_demo/$(FIRMWARE)
diff --git a/libs/system/zc702evk/linux/scripts/open_amp_create_projects.sh b/libs/system/zc702evk/linux/scripts/open_amp_create_projects.sh
--- /dev/null
@@ -0,0 +1,172 @@
+
+# This scripts automates the process of PetaLinux project creation.
+
+PRESENT=$(pwd)
+
+if [ "$1" == "master" ]; then
+
+ # Change directory to the master PetaLinux project directory
+ cd "$2"
+
+ #Matrix multiply userspace application
+ petalinux-create -t apps --template c --name mat_mul_demo --enable
+
+ cp $OPENAMP/apps/samples/master/linux/userspace/matrix_multiply/mat_mul_demo.c ./components/apps/mat_mul_demo/mat_mul_demo.c
+
+ cp $OPENAMP/libs/system/zc702evk/linux/scripts/makefiles/mat_mul_demo/Makefile ./components/apps/mat_mul_demo/Makefile
+
+ #Echo Test userspace application
+ petalinux-create -t apps --template c --name echo_test --enable
+
+ cp $OPENAMP/apps/tests/master/linux/userspace/echo_test/echo_test.c ./components/apps/echo_test/echo_test.c
+
+ #Proxy application
+ petalinux-create -t apps --template c --name proxy_app --enable
+
+ cp $OPENAMP/proxy/master/linux/userspace/proxy_app.c ./components/apps/proxy_app/proxy_app.c
+
+ cp $OPENAMP/proxy/master/linux/userspace/proxy_app.h ./components/apps/proxy_app/proxy_app.h
+
+ #Zynq Remoteproc driver
+ petalinux-create -t modules -n zynq_remoteproc_driver --enable
+
+ cp $OPENAMP/apps/samples/master/linux/kernelspace/zynq_remoteproc_driver/zynq_remoteproc_driver.c ./components/modules/zynq_remoteproc_driver/zynq_remoteproc_driver.c
+
+ cp $OPENAMP/apps/samples/master/linux/kernelspace/zynq_remoteproc_driver/remoteproc_internal.h ./components/modules/zynq_remoteproc_driver/remoteproc_internal.h
+
+
+ #Matrix multiply kernel-space module
+
+ petalinux-create -t modules -n rpmsg_mat_mul_kern_app --enable
+
+ cp $OPENAMP/apps/samples/master/linux/kernelspace/rpmsg_mat_mul_kern_app/rpmsg_mat_mul_kern_app.c ./components/modules/rpmsg_mat_mul_kern_app/rpmsg_mat_mul_kern_app.c
+
+ #Echo Test kernel-space module
+
+ petalinux-create -t modules -n rpmsg_echo_test_kern_app --enable
+
+ cp $OPENAMP/apps/tests/master/linux/kernelspace/rpmsg_echo_test_kern_app/rpmsg_echo_test_kern_app.c ./components/modules/rpmsg_echo_test_kern_app/rpmsg_echo_test_kern_app.c
+
+
+ #RPMSG User Device Driver module
+
+ petalinux-create -t modules -n rpmsg_user_dev_driver --enable
+
+ cp $OPENAMP/apps/samples/master/linux/kernelspace/rpmsg_user_dev_driver/rpmsg_user_dev_driver.c ./components/modules/rpmsg_user_dev_driver/rpmsg_user_dev_driver.c
+
+
+ #Proxy Device Driver module
+
+ petalinux-create -t modules -n rpmsg_proxy_dev_driver --enable
+
+ cp $OPENAMP/proxy/master/linux/kernelspace/rpmsg_proxy_dev_driver.c ./components/modules/rpmsg_proxy_dev_driver/rpmsg_proxy_dev_driver.c
+
+
+ #Firmware Installation
+
+ #Nucleus Matrix Multiply Sample
+
+ petalinux-create -t apps --template install -n mat_mul_nucleus_fw --enable
+
+ cp $OPENAMP/apps/firmware/zc702evk/nucleus/matrix_multiply/firmware ./components/apps/mat_mul_nucleus_fw/data/firmware
+
+ cp $OPENAMP/libs/system/zc702evk/linux/scripts/makefiles/mat_mul_nucleus_fw/Makefile ./components/apps/mat_mul_nucleus_fw/Makefile
+
+ #Nucleus Echo Test
+
+ petalinux-create -t apps --template install -n echo_test_nucleus_fw --enable
+
+ cp $OPENAMP/apps/firmware/zc702evk/nucleus/echo_test/firmware ./components/apps/echo_test_nucleus_fw/data/firmware
+
+ cp $OPENAMP/libs/system/zc702evk/linux/scripts/makefiles/echo_test_nucleus_fw/Makefile ./components/apps/echo_test_nucleus_fw/Makefile
+
+ #Nucleus RPC Demo
+
+ petalinux-create -t apps --template install -n rpc_demo_nucleus_fw --enable
+
+ cp $OPENAMP/apps/firmware/zc702evk/nucleus/rpc_demo/firmware ./components/apps/rpc_demo_nucleus_fw/data/firmware
+
+ cp $OPENAMP/libs/system/zc702evk/linux/scripts/makefiles/rpc_demo_nucleus_fw/Makefile ./components/apps/rpc_demo_nucleus_fw/Makefile
+
+ #Bare-metal Matrix Multiply Sample
+
+ petalinux-create -t apps --template install -n mat_mul_baremetal_fw --enable
+
+ cp $OPENAMP/apps/firmware/zc702evk/baremetal/matrix_multiply/firmware ./components/apps/mat_mul_baremetal_fw/data/firmware
+
+ cp $OPENAMP/libs/system/zc702evk/linux/scripts/makefiles/mat_mul_baremetal_fw/Makefile ./components/apps/mat_mul_baremetal_fw/Makefile
+
+ #Bare-metal Echo Test
+
+ petalinux-create -t apps --template install -n echo_test_baremetal_fw --enable
+
+ cp $OPENAMP/apps/firmware/zc702evk/baremetal/echo_test/firmware ./components/apps/echo_test_baremetal_fw/data/firmware
+
+ cp $OPENAMP/libs/system/zc702evk/linux/scripts/makefiles/echo_test_baremetal_fw/Makefile ./components/apps/echo_test_baremetal_fw/Makefile
+
+ #Baremetal RPC Demo
+
+ petalinux-create -t apps --template install -n rpc_demo_baremetal_fw --enable
+
+ cp $OPENAMP/apps/firmware/zc702evk/baremetal/rpc_demo/firmware ./components/apps/rpc_demo_baremetal_fw/data/firmware
+
+ cp $OPENAMP/libs/system/zc702evk/linux/scripts/makefiles/rpc_demo_baremetal_fw/Makefile ./components/apps/rpc_demo_baremetal_fw/Makefile
+
+else
+
+ # Change directory to the remote PetaLinux project directory
+ cd "$2"
+
+ #Matrix multiply user-space application
+ petalinux-create -t apps --template c --name mat_mul_demo --enable
+
+ cp $OPENAMP/apps/samples/master/linux/userspace/matrix_multiply/mat_mul_demo.c ./components/apps/mat_mul_demo/mat_mul_demo.c
+
+ cp $OPENAMP/libs/system/zc702evk/linux/scripts/makefiles/mat_mul_demo/Makefile ./components/apps/mat_mul_demo/Makefile
+
+ #Echo Test user-space application
+
+ petalinux-create -t apps --template c --name echo_test --enable
+
+ cp $OPENAMP/apps/tests/master/linux/userspace/echo_test/echo_test.c ./components/apps/echo_test/echo_test.c
+
+ #Create Kernel Modules
+
+ #Zynq RPMSG Driver module
+
+ petalinux-create -t modules -n zynq_rpmsg_driver --enable
+
+ cp $OPENAMP/apps/samples/master/linux/kernelspace/zynq_rpmsg_driver/zynq_rpmsg_driver.c ./components/modules/zynq_rpmsg_driver/zynq_rpmsg_driver.c
+ cp $OPENAMP/apps/samples/master/linux/kernelspace/zynq_rpmsg_driver/zynq_rpmsg_internals.h ./components/modules/zynq_rpmsg_driver/zynq_rpmsg_internals.h
+
+ #Matrix multiply kernel-space module
+
+ petalinux-create -t modules -n rpmsg_mat_mul_kern_app --enable
+
+ cp $OPENAMP/apps/samples/master/linux/kernelspace/rpmsg_mat_mul_kern_app/rpmsg_mat_mul_kern_app.c ./components/modules/rpmsg_mat_mul_kern_app/rpmsg_mat_mul_kern_app.c
+
+ #Echo Test kernel-space module
+
+ petalinux-create -t modules -n rpmsg_echo_test_kern_app --enable
+
+ cp $OPENAMP/apps/tests/master/linux/kernelspace/rpmsg_echo_test_kern_app/rpmsg_echo_test_kern_app.c ./components/modules/rpmsg_echo_test_kern_app/rpmsg_echo_test_kern_app.c
+
+ #RPMSG User Device Driver module
+
+ petalinux-create -t modules -n rpmsg_user_dev_driver --enable
+
+ cp $OPENAMP/apps/samples/master/linux/kernelspace/rpmsg_user_dev_driver/rpmsg_user_dev_driver.c ./components/modules/rpmsg_user_dev_driver/rpmsg_user_dev_driver.c
+
+ #Functional Test Driver module
+
+ petalinux-create -t modules -n rpmsg_func_test_kern_app --enable
+
+ cp $OPENAMP/apps/tests/master/linux/kernelspace/rpmsg_func_test_kern_app/rpmsg_func_test_kern_app.c ./components/modules/rpmsg_func_test_kern_app/rpmsg_func_test_kern_app.c
+
+ #DTS File
+ cp $OPENAMP/libs/system/zc702evk/linux/patches/linux/petalinux2013.10/system.dts ./subsystems/linux/hw-description/system.dts
+
+fi
+
+# Return
+cd $PRESENT
diff --git a/libs/system/zc702evk/linux/zlib/crc32.h b/libs/system/zc702evk/linux/zlib/crc32.h
--- /dev/null
@@ -0,0 +1,441 @@
+/* crc32.h -- tables for rapid CRC calculation
+ * Generated automatically by crc32.c
+ */
+
+local const unsigned long FAR crc_table[TBLS][256] =
+{
+ {
+ 0x00000000UL, 0x77073096UL, 0xee0e612cUL, 0x990951baUL, 0x076dc419UL,
+ 0x706af48fUL, 0xe963a535UL, 0x9e6495a3UL, 0x0edb8832UL, 0x79dcb8a4UL,
+ 0xe0d5e91eUL, 0x97d2d988UL, 0x09b64c2bUL, 0x7eb17cbdUL, 0xe7b82d07UL,
+ 0x90bf1d91UL, 0x1db71064UL, 0x6ab020f2UL, 0xf3b97148UL, 0x84be41deUL,
+ 0x1adad47dUL, 0x6ddde4ebUL, 0xf4d4b551UL, 0x83d385c7UL, 0x136c9856UL,
+ 0x646ba8c0UL, 0xfd62f97aUL, 0x8a65c9ecUL, 0x14015c4fUL, 0x63066cd9UL,
+ 0xfa0f3d63UL, 0x8d080df5UL, 0x3b6e20c8UL, 0x4c69105eUL, 0xd56041e4UL,
+ 0xa2677172UL, 0x3c03e4d1UL, 0x4b04d447UL, 0xd20d85fdUL, 0xa50ab56bUL,
+ 0x35b5a8faUL, 0x42b2986cUL, 0xdbbbc9d6UL, 0xacbcf940UL, 0x32d86ce3UL,
+ 0x45df5c75UL, 0xdcd60dcfUL, 0xabd13d59UL, 0x26d930acUL, 0x51de003aUL,
+ 0xc8d75180UL, 0xbfd06116UL, 0x21b4f4b5UL, 0x56b3c423UL, 0xcfba9599UL,
+ 0xb8bda50fUL, 0x2802b89eUL, 0x5f058808UL, 0xc60cd9b2UL, 0xb10be924UL,
+ 0x2f6f7c87UL, 0x58684c11UL, 0xc1611dabUL, 0xb6662d3dUL, 0x76dc4190UL,
+ 0x01db7106UL, 0x98d220bcUL, 0xefd5102aUL, 0x71b18589UL, 0x06b6b51fUL,
+ 0x9fbfe4a5UL, 0xe8b8d433UL, 0x7807c9a2UL, 0x0f00f934UL, 0x9609a88eUL,
+ 0xe10e9818UL, 0x7f6a0dbbUL, 0x086d3d2dUL, 0x91646c97UL, 0xe6635c01UL,
+ 0x6b6b51f4UL, 0x1c6c6162UL, 0x856530d8UL, 0xf262004eUL, 0x6c0695edUL,
+ 0x1b01a57bUL, 0x8208f4c1UL, 0xf50fc457UL, 0x65b0d9c6UL, 0x12b7e950UL,
+ 0x8bbeb8eaUL, 0xfcb9887cUL, 0x62dd1ddfUL, 0x15da2d49UL, 0x8cd37cf3UL,
+ 0xfbd44c65UL, 0x4db26158UL, 0x3ab551ceUL, 0xa3bc0074UL, 0xd4bb30e2UL,
+ 0x4adfa541UL, 0x3dd895d7UL, 0xa4d1c46dUL, 0xd3d6f4fbUL, 0x4369e96aUL,
+ 0x346ed9fcUL, 0xad678846UL, 0xda60b8d0UL, 0x44042d73UL, 0x33031de5UL,
+ 0xaa0a4c5fUL, 0xdd0d7cc9UL, 0x5005713cUL, 0x270241aaUL, 0xbe0b1010UL,
+ 0xc90c2086UL, 0x5768b525UL, 0x206f85b3UL, 0xb966d409UL, 0xce61e49fUL,
+ 0x5edef90eUL, 0x29d9c998UL, 0xb0d09822UL, 0xc7d7a8b4UL, 0x59b33d17UL,
+ 0x2eb40d81UL, 0xb7bd5c3bUL, 0xc0ba6cadUL, 0xedb88320UL, 0x9abfb3b6UL,
+ 0x03b6e20cUL, 0x74b1d29aUL, 0xead54739UL, 0x9dd277afUL, 0x04db2615UL,
+ 0x73dc1683UL, 0xe3630b12UL, 0x94643b84UL, 0x0d6d6a3eUL, 0x7a6a5aa8UL,
+ 0xe40ecf0bUL, 0x9309ff9dUL, 0x0a00ae27UL, 0x7d079eb1UL, 0xf00f9344UL,
+ 0x8708a3d2UL, 0x1e01f268UL, 0x6906c2feUL, 0xf762575dUL, 0x806567cbUL,
+ 0x196c3671UL, 0x6e6b06e7UL, 0xfed41b76UL, 0x89d32be0UL, 0x10da7a5aUL,
+ 0x67dd4accUL, 0xf9b9df6fUL, 0x8ebeeff9UL, 0x17b7be43UL, 0x60b08ed5UL,
+ 0xd6d6a3e8UL, 0xa1d1937eUL, 0x38d8c2c4UL, 0x4fdff252UL, 0xd1bb67f1UL,
+ 0xa6bc5767UL, 0x3fb506ddUL, 0x48b2364bUL, 0xd80d2bdaUL, 0xaf0a1b4cUL,
+ 0x36034af6UL, 0x41047a60UL, 0xdf60efc3UL, 0xa867df55UL, 0x316e8eefUL,
+ 0x4669be79UL, 0xcb61b38cUL, 0xbc66831aUL, 0x256fd2a0UL, 0x5268e236UL,
+ 0xcc0c7795UL, 0xbb0b4703UL, 0x220216b9UL, 0x5505262fUL, 0xc5ba3bbeUL,
+ 0xb2bd0b28UL, 0x2bb45a92UL, 0x5cb36a04UL, 0xc2d7ffa7UL, 0xb5d0cf31UL,
+ 0x2cd99e8bUL, 0x5bdeae1dUL, 0x9b64c2b0UL, 0xec63f226UL, 0x756aa39cUL,
+ 0x026d930aUL, 0x9c0906a9UL, 0xeb0e363fUL, 0x72076785UL, 0x05005713UL,
+ 0x95bf4a82UL, 0xe2b87a14UL, 0x7bb12baeUL, 0x0cb61b38UL, 0x92d28e9bUL,
+ 0xe5d5be0dUL, 0x7cdcefb7UL, 0x0bdbdf21UL, 0x86d3d2d4UL, 0xf1d4e242UL,
+ 0x68ddb3f8UL, 0x1fda836eUL, 0x81be16cdUL, 0xf6b9265bUL, 0x6fb077e1UL,
+ 0x18b74777UL, 0x88085ae6UL, 0xff0f6a70UL, 0x66063bcaUL, 0x11010b5cUL,
+ 0x8f659effUL, 0xf862ae69UL, 0x616bffd3UL, 0x166ccf45UL, 0xa00ae278UL,
+ 0xd70dd2eeUL, 0x4e048354UL, 0x3903b3c2UL, 0xa7672661UL, 0xd06016f7UL,
+ 0x4969474dUL, 0x3e6e77dbUL, 0xaed16a4aUL, 0xd9d65adcUL, 0x40df0b66UL,
+ 0x37d83bf0UL, 0xa9bcae53UL, 0xdebb9ec5UL, 0x47b2cf7fUL, 0x30b5ffe9UL,
+ 0xbdbdf21cUL, 0xcabac28aUL, 0x53b39330UL, 0x24b4a3a6UL, 0xbad03605UL,
+ 0xcdd70693UL, 0x54de5729UL, 0x23d967bfUL, 0xb3667a2eUL, 0xc4614ab8UL,
+ 0x5d681b02UL, 0x2a6f2b94UL, 0xb40bbe37UL, 0xc30c8ea1UL, 0x5a05df1bUL,
+ 0x2d02ef8dUL
+#ifdef BYFOUR
+ },
+ {
+ 0x00000000UL, 0x191b3141UL, 0x32366282UL, 0x2b2d53c3UL, 0x646cc504UL,
+ 0x7d77f445UL, 0x565aa786UL, 0x4f4196c7UL, 0xc8d98a08UL, 0xd1c2bb49UL,
+ 0xfaefe88aUL, 0xe3f4d9cbUL, 0xacb54f0cUL, 0xb5ae7e4dUL, 0x9e832d8eUL,
+ 0x87981ccfUL, 0x4ac21251UL, 0x53d92310UL, 0x78f470d3UL, 0x61ef4192UL,
+ 0x2eaed755UL, 0x37b5e614UL, 0x1c98b5d7UL, 0x05838496UL, 0x821b9859UL,
+ 0x9b00a918UL, 0xb02dfadbUL, 0xa936cb9aUL, 0xe6775d5dUL, 0xff6c6c1cUL,
+ 0xd4413fdfUL, 0xcd5a0e9eUL, 0x958424a2UL, 0x8c9f15e3UL, 0xa7b24620UL,
+ 0xbea97761UL, 0xf1e8e1a6UL, 0xe8f3d0e7UL, 0xc3de8324UL, 0xdac5b265UL,
+ 0x5d5daeaaUL, 0x44469febUL, 0x6f6bcc28UL, 0x7670fd69UL, 0x39316baeUL,
+ 0x202a5aefUL, 0x0b07092cUL, 0x121c386dUL, 0xdf4636f3UL, 0xc65d07b2UL,
+ 0xed705471UL, 0xf46b6530UL, 0xbb2af3f7UL, 0xa231c2b6UL, 0x891c9175UL,
+ 0x9007a034UL, 0x179fbcfbUL, 0x0e848dbaUL, 0x25a9de79UL, 0x3cb2ef38UL,
+ 0x73f379ffUL, 0x6ae848beUL, 0x41c51b7dUL, 0x58de2a3cUL, 0xf0794f05UL,
+ 0xe9627e44UL, 0xc24f2d87UL, 0xdb541cc6UL, 0x94158a01UL, 0x8d0ebb40UL,
+ 0xa623e883UL, 0xbf38d9c2UL, 0x38a0c50dUL, 0x21bbf44cUL, 0x0a96a78fUL,
+ 0x138d96ceUL, 0x5ccc0009UL, 0x45d73148UL, 0x6efa628bUL, 0x77e153caUL,
+ 0xbabb5d54UL, 0xa3a06c15UL, 0x888d3fd6UL, 0x91960e97UL, 0xded79850UL,
+ 0xc7cca911UL, 0xece1fad2UL, 0xf5facb93UL, 0x7262d75cUL, 0x6b79e61dUL,
+ 0x4054b5deUL, 0x594f849fUL, 0x160e1258UL, 0x0f152319UL, 0x243870daUL,
+ 0x3d23419bUL, 0x65fd6ba7UL, 0x7ce65ae6UL, 0x57cb0925UL, 0x4ed03864UL,
+ 0x0191aea3UL, 0x188a9fe2UL, 0x33a7cc21UL, 0x2abcfd60UL, 0xad24e1afUL,
+ 0xb43fd0eeUL, 0x9f12832dUL, 0x8609b26cUL, 0xc94824abUL, 0xd05315eaUL,
+ 0xfb7e4629UL, 0xe2657768UL, 0x2f3f79f6UL, 0x362448b7UL, 0x1d091b74UL,
+ 0x04122a35UL, 0x4b53bcf2UL, 0x52488db3UL, 0x7965de70UL, 0x607eef31UL,
+ 0xe7e6f3feUL, 0xfefdc2bfUL, 0xd5d0917cUL, 0xcccba03dUL, 0x838a36faUL,
+ 0x9a9107bbUL, 0xb1bc5478UL, 0xa8a76539UL, 0x3b83984bUL, 0x2298a90aUL,
+ 0x09b5fac9UL, 0x10aecb88UL, 0x5fef5d4fUL, 0x46f46c0eUL, 0x6dd93fcdUL,
+ 0x74c20e8cUL, 0xf35a1243UL, 0xea412302UL, 0xc16c70c1UL, 0xd8774180UL,
+ 0x9736d747UL, 0x8e2de606UL, 0xa500b5c5UL, 0xbc1b8484UL, 0x71418a1aUL,
+ 0x685abb5bUL, 0x4377e898UL, 0x5a6cd9d9UL, 0x152d4f1eUL, 0x0c367e5fUL,
+ 0x271b2d9cUL, 0x3e001cddUL, 0xb9980012UL, 0xa0833153UL, 0x8bae6290UL,
+ 0x92b553d1UL, 0xddf4c516UL, 0xc4eff457UL, 0xefc2a794UL, 0xf6d996d5UL,
+ 0xae07bce9UL, 0xb71c8da8UL, 0x9c31de6bUL, 0x852aef2aUL, 0xca6b79edUL,
+ 0xd37048acUL, 0xf85d1b6fUL, 0xe1462a2eUL, 0x66de36e1UL, 0x7fc507a0UL,
+ 0x54e85463UL, 0x4df36522UL, 0x02b2f3e5UL, 0x1ba9c2a4UL, 0x30849167UL,
+ 0x299fa026UL, 0xe4c5aeb8UL, 0xfdde9ff9UL, 0xd6f3cc3aUL, 0xcfe8fd7bUL,
+ 0x80a96bbcUL, 0x99b25afdUL, 0xb29f093eUL, 0xab84387fUL, 0x2c1c24b0UL,
+ 0x350715f1UL, 0x1e2a4632UL, 0x07317773UL, 0x4870e1b4UL, 0x516bd0f5UL,
+ 0x7a468336UL, 0x635db277UL, 0xcbfad74eUL, 0xd2e1e60fUL, 0xf9ccb5ccUL,
+ 0xe0d7848dUL, 0xaf96124aUL, 0xb68d230bUL, 0x9da070c8UL, 0x84bb4189UL,
+ 0x03235d46UL, 0x1a386c07UL, 0x31153fc4UL, 0x280e0e85UL, 0x674f9842UL,
+ 0x7e54a903UL, 0x5579fac0UL, 0x4c62cb81UL, 0x8138c51fUL, 0x9823f45eUL,
+ 0xb30ea79dUL, 0xaa1596dcUL, 0xe554001bUL, 0xfc4f315aUL, 0xd7626299UL,
+ 0xce7953d8UL, 0x49e14f17UL, 0x50fa7e56UL, 0x7bd72d95UL, 0x62cc1cd4UL,
+ 0x2d8d8a13UL, 0x3496bb52UL, 0x1fbbe891UL, 0x06a0d9d0UL, 0x5e7ef3ecUL,
+ 0x4765c2adUL, 0x6c48916eUL, 0x7553a02fUL, 0x3a1236e8UL, 0x230907a9UL,
+ 0x0824546aUL, 0x113f652bUL, 0x96a779e4UL, 0x8fbc48a5UL, 0xa4911b66UL,
+ 0xbd8a2a27UL, 0xf2cbbce0UL, 0xebd08da1UL, 0xc0fdde62UL, 0xd9e6ef23UL,
+ 0x14bce1bdUL, 0x0da7d0fcUL, 0x268a833fUL, 0x3f91b27eUL, 0x70d024b9UL,
+ 0x69cb15f8UL, 0x42e6463bUL, 0x5bfd777aUL, 0xdc656bb5UL, 0xc57e5af4UL,
+ 0xee530937UL, 0xf7483876UL, 0xb809aeb1UL, 0xa1129ff0UL, 0x8a3fcc33UL,
+ 0x9324fd72UL
+ },
+ {
+ 0x00000000UL, 0x01c26a37UL, 0x0384d46eUL, 0x0246be59UL, 0x0709a8dcUL,
+ 0x06cbc2ebUL, 0x048d7cb2UL, 0x054f1685UL, 0x0e1351b8UL, 0x0fd13b8fUL,
+ 0x0d9785d6UL, 0x0c55efe1UL, 0x091af964UL, 0x08d89353UL, 0x0a9e2d0aUL,
+ 0x0b5c473dUL, 0x1c26a370UL, 0x1de4c947UL, 0x1fa2771eUL, 0x1e601d29UL,
+ 0x1b2f0bacUL, 0x1aed619bUL, 0x18abdfc2UL, 0x1969b5f5UL, 0x1235f2c8UL,
+ 0x13f798ffUL, 0x11b126a6UL, 0x10734c91UL, 0x153c5a14UL, 0x14fe3023UL,
+ 0x16b88e7aUL, 0x177ae44dUL, 0x384d46e0UL, 0x398f2cd7UL, 0x3bc9928eUL,
+ 0x3a0bf8b9UL, 0x3f44ee3cUL, 0x3e86840bUL, 0x3cc03a52UL, 0x3d025065UL,
+ 0x365e1758UL, 0x379c7d6fUL, 0x35dac336UL, 0x3418a901UL, 0x3157bf84UL,
+ 0x3095d5b3UL, 0x32d36beaUL, 0x331101ddUL, 0x246be590UL, 0x25a98fa7UL,
+ 0x27ef31feUL, 0x262d5bc9UL, 0x23624d4cUL, 0x22a0277bUL, 0x20e69922UL,
+ 0x2124f315UL, 0x2a78b428UL, 0x2bbade1fUL, 0x29fc6046UL, 0x283e0a71UL,
+ 0x2d711cf4UL, 0x2cb376c3UL, 0x2ef5c89aUL, 0x2f37a2adUL, 0x709a8dc0UL,
+ 0x7158e7f7UL, 0x731e59aeUL, 0x72dc3399UL, 0x7793251cUL, 0x76514f2bUL,
+ 0x7417f172UL, 0x75d59b45UL, 0x7e89dc78UL, 0x7f4bb64fUL, 0x7d0d0816UL,
+ 0x7ccf6221UL, 0x798074a4UL, 0x78421e93UL, 0x7a04a0caUL, 0x7bc6cafdUL,
+ 0x6cbc2eb0UL, 0x6d7e4487UL, 0x6f38fadeUL, 0x6efa90e9UL, 0x6bb5866cUL,
+ 0x6a77ec5bUL, 0x68315202UL, 0x69f33835UL, 0x62af7f08UL, 0x636d153fUL,
+ 0x612bab66UL, 0x60e9c151UL, 0x65a6d7d4UL, 0x6464bde3UL, 0x662203baUL,
+ 0x67e0698dUL, 0x48d7cb20UL, 0x4915a117UL, 0x4b531f4eUL, 0x4a917579UL,
+ 0x4fde63fcUL, 0x4e1c09cbUL, 0x4c5ab792UL, 0x4d98dda5UL, 0x46c49a98UL,
+ 0x4706f0afUL, 0x45404ef6UL, 0x448224c1UL, 0x41cd3244UL, 0x400f5873UL,
+ 0x4249e62aUL, 0x438b8c1dUL, 0x54f16850UL, 0x55330267UL, 0x5775bc3eUL,
+ 0x56b7d609UL, 0x53f8c08cUL, 0x523aaabbUL, 0x507c14e2UL, 0x51be7ed5UL,
+ 0x5ae239e8UL, 0x5b2053dfUL, 0x5966ed86UL, 0x58a487b1UL, 0x5deb9134UL,
+ 0x5c29fb03UL, 0x5e6f455aUL, 0x5fad2f6dUL, 0xe1351b80UL, 0xe0f771b7UL,
+ 0xe2b1cfeeUL, 0xe373a5d9UL, 0xe63cb35cUL, 0xe7fed96bUL, 0xe5b86732UL,
+ 0xe47a0d05UL, 0xef264a38UL, 0xeee4200fUL, 0xeca29e56UL, 0xed60f461UL,
+ 0xe82fe2e4UL, 0xe9ed88d3UL, 0xebab368aUL, 0xea695cbdUL, 0xfd13b8f0UL,
+ 0xfcd1d2c7UL, 0xfe976c9eUL, 0xff5506a9UL, 0xfa1a102cUL, 0xfbd87a1bUL,
+ 0xf99ec442UL, 0xf85cae75UL, 0xf300e948UL, 0xf2c2837fUL, 0xf0843d26UL,
+ 0xf1465711UL, 0xf4094194UL, 0xf5cb2ba3UL, 0xf78d95faUL, 0xf64fffcdUL,
+ 0xd9785d60UL, 0xd8ba3757UL, 0xdafc890eUL, 0xdb3ee339UL, 0xde71f5bcUL,
+ 0xdfb39f8bUL, 0xddf521d2UL, 0xdc374be5UL, 0xd76b0cd8UL, 0xd6a966efUL,
+ 0xd4efd8b6UL, 0xd52db281UL, 0xd062a404UL, 0xd1a0ce33UL, 0xd3e6706aUL,
+ 0xd2241a5dUL, 0xc55efe10UL, 0xc49c9427UL, 0xc6da2a7eUL, 0xc7184049UL,
+ 0xc25756ccUL, 0xc3953cfbUL, 0xc1d382a2UL, 0xc011e895UL, 0xcb4dafa8UL,
+ 0xca8fc59fUL, 0xc8c97bc6UL, 0xc90b11f1UL, 0xcc440774UL, 0xcd866d43UL,
+ 0xcfc0d31aUL, 0xce02b92dUL, 0x91af9640UL, 0x906dfc77UL, 0x922b422eUL,
+ 0x93e92819UL, 0x96a63e9cUL, 0x976454abUL, 0x9522eaf2UL, 0x94e080c5UL,
+ 0x9fbcc7f8UL, 0x9e7eadcfUL, 0x9c381396UL, 0x9dfa79a1UL, 0x98b56f24UL,
+ 0x99770513UL, 0x9b31bb4aUL, 0x9af3d17dUL, 0x8d893530UL, 0x8c4b5f07UL,
+ 0x8e0de15eUL, 0x8fcf8b69UL, 0x8a809decUL, 0x8b42f7dbUL, 0x89044982UL,
+ 0x88c623b5UL, 0x839a6488UL, 0x82580ebfUL, 0x801eb0e6UL, 0x81dcdad1UL,
+ 0x8493cc54UL, 0x8551a663UL, 0x8717183aUL, 0x86d5720dUL, 0xa9e2d0a0UL,
+ 0xa820ba97UL, 0xaa6604ceUL, 0xaba46ef9UL, 0xaeeb787cUL, 0xaf29124bUL,
+ 0xad6fac12UL, 0xacadc625UL, 0xa7f18118UL, 0xa633eb2fUL, 0xa4755576UL,
+ 0xa5b73f41UL, 0xa0f829c4UL, 0xa13a43f3UL, 0xa37cfdaaUL, 0xa2be979dUL,
+ 0xb5c473d0UL, 0xb40619e7UL, 0xb640a7beUL, 0xb782cd89UL, 0xb2cddb0cUL,
+ 0xb30fb13bUL, 0xb1490f62UL, 0xb08b6555UL, 0xbbd72268UL, 0xba15485fUL,
+ 0xb853f606UL, 0xb9919c31UL, 0xbcde8ab4UL, 0xbd1ce083UL, 0xbf5a5edaUL,
+ 0xbe9834edUL
+ },
+ {
+ 0x00000000UL, 0xb8bc6765UL, 0xaa09c88bUL, 0x12b5afeeUL, 0x8f629757UL,
+ 0x37def032UL, 0x256b5fdcUL, 0x9dd738b9UL, 0xc5b428efUL, 0x7d084f8aUL,
+ 0x6fbde064UL, 0xd7018701UL, 0x4ad6bfb8UL, 0xf26ad8ddUL, 0xe0df7733UL,
+ 0x58631056UL, 0x5019579fUL, 0xe8a530faUL, 0xfa109f14UL, 0x42acf871UL,
+ 0xdf7bc0c8UL, 0x67c7a7adUL, 0x75720843UL, 0xcdce6f26UL, 0x95ad7f70UL,
+ 0x2d111815UL, 0x3fa4b7fbUL, 0x8718d09eUL, 0x1acfe827UL, 0xa2738f42UL,
+ 0xb0c620acUL, 0x087a47c9UL, 0xa032af3eUL, 0x188ec85bUL, 0x0a3b67b5UL,
+ 0xb28700d0UL, 0x2f503869UL, 0x97ec5f0cUL, 0x8559f0e2UL, 0x3de59787UL,
+ 0x658687d1UL, 0xdd3ae0b4UL, 0xcf8f4f5aUL, 0x7733283fUL, 0xeae41086UL,
+ 0x525877e3UL, 0x40edd80dUL, 0xf851bf68UL, 0xf02bf8a1UL, 0x48979fc4UL,
+ 0x5a22302aUL, 0xe29e574fUL, 0x7f496ff6UL, 0xc7f50893UL, 0xd540a77dUL,
+ 0x6dfcc018UL, 0x359fd04eUL, 0x8d23b72bUL, 0x9f9618c5UL, 0x272a7fa0UL,
+ 0xbafd4719UL, 0x0241207cUL, 0x10f48f92UL, 0xa848e8f7UL, 0x9b14583dUL,
+ 0x23a83f58UL, 0x311d90b6UL, 0x89a1f7d3UL, 0x1476cf6aUL, 0xaccaa80fUL,
+ 0xbe7f07e1UL, 0x06c36084UL, 0x5ea070d2UL, 0xe61c17b7UL, 0xf4a9b859UL,
+ 0x4c15df3cUL, 0xd1c2e785UL, 0x697e80e0UL, 0x7bcb2f0eUL, 0xc377486bUL,
+ 0xcb0d0fa2UL, 0x73b168c7UL, 0x6104c729UL, 0xd9b8a04cUL, 0x446f98f5UL,
+ 0xfcd3ff90UL, 0xee66507eUL, 0x56da371bUL, 0x0eb9274dUL, 0xb6054028UL,
+ 0xa4b0efc6UL, 0x1c0c88a3UL, 0x81dbb01aUL, 0x3967d77fUL, 0x2bd27891UL,
+ 0x936e1ff4UL, 0x3b26f703UL, 0x839a9066UL, 0x912f3f88UL, 0x299358edUL,
+ 0xb4446054UL, 0x0cf80731UL, 0x1e4da8dfUL, 0xa6f1cfbaUL, 0xfe92dfecUL,
+ 0x462eb889UL, 0x549b1767UL, 0xec277002UL, 0x71f048bbUL, 0xc94c2fdeUL,
+ 0xdbf98030UL, 0x6345e755UL, 0x6b3fa09cUL, 0xd383c7f9UL, 0xc1366817UL,
+ 0x798a0f72UL, 0xe45d37cbUL, 0x5ce150aeUL, 0x4e54ff40UL, 0xf6e89825UL,
+ 0xae8b8873UL, 0x1637ef16UL, 0x048240f8UL, 0xbc3e279dUL, 0x21e91f24UL,
+ 0x99557841UL, 0x8be0d7afUL, 0x335cb0caUL, 0xed59b63bUL, 0x55e5d15eUL,
+ 0x47507eb0UL, 0xffec19d5UL, 0x623b216cUL, 0xda874609UL, 0xc832e9e7UL,
+ 0x708e8e82UL, 0x28ed9ed4UL, 0x9051f9b1UL, 0x82e4565fUL, 0x3a58313aUL,
+ 0xa78f0983UL, 0x1f336ee6UL, 0x0d86c108UL, 0xb53aa66dUL, 0xbd40e1a4UL,
+ 0x05fc86c1UL, 0x1749292fUL, 0xaff54e4aUL, 0x322276f3UL, 0x8a9e1196UL,
+ 0x982bbe78UL, 0x2097d91dUL, 0x78f4c94bUL, 0xc048ae2eUL, 0xd2fd01c0UL,
+ 0x6a4166a5UL, 0xf7965e1cUL, 0x4f2a3979UL, 0x5d9f9697UL, 0xe523f1f2UL,
+ 0x4d6b1905UL, 0xf5d77e60UL, 0xe762d18eUL, 0x5fdeb6ebUL, 0xc2098e52UL,
+ 0x7ab5e937UL, 0x680046d9UL, 0xd0bc21bcUL, 0x88df31eaUL, 0x3063568fUL,
+ 0x22d6f961UL, 0x9a6a9e04UL, 0x07bda6bdUL, 0xbf01c1d8UL, 0xadb46e36UL,
+ 0x15080953UL, 0x1d724e9aUL, 0xa5ce29ffUL, 0xb77b8611UL, 0x0fc7e174UL,
+ 0x9210d9cdUL, 0x2aacbea8UL, 0x38191146UL, 0x80a57623UL, 0xd8c66675UL,
+ 0x607a0110UL, 0x72cfaefeUL, 0xca73c99bUL, 0x57a4f122UL, 0xef189647UL,
+ 0xfdad39a9UL, 0x45115eccUL, 0x764dee06UL, 0xcef18963UL, 0xdc44268dUL,
+ 0x64f841e8UL, 0xf92f7951UL, 0x41931e34UL, 0x5326b1daUL, 0xeb9ad6bfUL,
+ 0xb3f9c6e9UL, 0x0b45a18cUL, 0x19f00e62UL, 0xa14c6907UL, 0x3c9b51beUL,
+ 0x842736dbUL, 0x96929935UL, 0x2e2efe50UL, 0x2654b999UL, 0x9ee8defcUL,
+ 0x8c5d7112UL, 0x34e11677UL, 0xa9362eceUL, 0x118a49abUL, 0x033fe645UL,
+ 0xbb838120UL, 0xe3e09176UL, 0x5b5cf613UL, 0x49e959fdUL, 0xf1553e98UL,
+ 0x6c820621UL, 0xd43e6144UL, 0xc68bceaaUL, 0x7e37a9cfUL, 0xd67f4138UL,
+ 0x6ec3265dUL, 0x7c7689b3UL, 0xc4caeed6UL, 0x591dd66fUL, 0xe1a1b10aUL,
+ 0xf3141ee4UL, 0x4ba87981UL, 0x13cb69d7UL, 0xab770eb2UL, 0xb9c2a15cUL,
+ 0x017ec639UL, 0x9ca9fe80UL, 0x241599e5UL, 0x36a0360bUL, 0x8e1c516eUL,
+ 0x866616a7UL, 0x3eda71c2UL, 0x2c6fde2cUL, 0x94d3b949UL, 0x090481f0UL,
+ 0xb1b8e695UL, 0xa30d497bUL, 0x1bb12e1eUL, 0x43d23e48UL, 0xfb6e592dUL,
+ 0xe9dbf6c3UL, 0x516791a6UL, 0xccb0a91fUL, 0x740cce7aUL, 0x66b96194UL,
+ 0xde0506f1UL
+ },
+ {
+ 0x00000000UL, 0x96300777UL, 0x2c610eeeUL, 0xba510999UL, 0x19c46d07UL,
+ 0x8ff46a70UL, 0x35a563e9UL, 0xa395649eUL, 0x3288db0eUL, 0xa4b8dc79UL,
+ 0x1ee9d5e0UL, 0x88d9d297UL, 0x2b4cb609UL, 0xbd7cb17eUL, 0x072db8e7UL,
+ 0x911dbf90UL, 0x6410b71dUL, 0xf220b06aUL, 0x4871b9f3UL, 0xde41be84UL,
+ 0x7dd4da1aUL, 0xebe4dd6dUL, 0x51b5d4f4UL, 0xc785d383UL, 0x56986c13UL,
+ 0xc0a86b64UL, 0x7af962fdUL, 0xecc9658aUL, 0x4f5c0114UL, 0xd96c0663UL,
+ 0x633d0ffaUL, 0xf50d088dUL, 0xc8206e3bUL, 0x5e10694cUL, 0xe44160d5UL,
+ 0x727167a2UL, 0xd1e4033cUL, 0x47d4044bUL, 0xfd850dd2UL, 0x6bb50aa5UL,
+ 0xfaa8b535UL, 0x6c98b242UL, 0xd6c9bbdbUL, 0x40f9bcacUL, 0xe36cd832UL,
+ 0x755cdf45UL, 0xcf0dd6dcUL, 0x593dd1abUL, 0xac30d926UL, 0x3a00de51UL,
+ 0x8051d7c8UL, 0x1661d0bfUL, 0xb5f4b421UL, 0x23c4b356UL, 0x9995bacfUL,
+ 0x0fa5bdb8UL, 0x9eb80228UL, 0x0888055fUL, 0xb2d90cc6UL, 0x24e90bb1UL,
+ 0x877c6f2fUL, 0x114c6858UL, 0xab1d61c1UL, 0x3d2d66b6UL, 0x9041dc76UL,
+ 0x0671db01UL, 0xbc20d298UL, 0x2a10d5efUL, 0x8985b171UL, 0x1fb5b606UL,
+ 0xa5e4bf9fUL, 0x33d4b8e8UL, 0xa2c90778UL, 0x34f9000fUL, 0x8ea80996UL,
+ 0x18980ee1UL, 0xbb0d6a7fUL, 0x2d3d6d08UL, 0x976c6491UL, 0x015c63e6UL,
+ 0xf4516b6bUL, 0x62616c1cUL, 0xd8306585UL, 0x4e0062f2UL, 0xed95066cUL,
+ 0x7ba5011bUL, 0xc1f40882UL, 0x57c40ff5UL, 0xc6d9b065UL, 0x50e9b712UL,
+ 0xeab8be8bUL, 0x7c88b9fcUL, 0xdf1ddd62UL, 0x492dda15UL, 0xf37cd38cUL,
+ 0x654cd4fbUL, 0x5861b24dUL, 0xce51b53aUL, 0x7400bca3UL, 0xe230bbd4UL,
+ 0x41a5df4aUL, 0xd795d83dUL, 0x6dc4d1a4UL, 0xfbf4d6d3UL, 0x6ae96943UL,
+ 0xfcd96e34UL, 0x468867adUL, 0xd0b860daUL, 0x732d0444UL, 0xe51d0333UL,
+ 0x5f4c0aaaUL, 0xc97c0dddUL, 0x3c710550UL, 0xaa410227UL, 0x10100bbeUL,
+ 0x86200cc9UL, 0x25b56857UL, 0xb3856f20UL, 0x09d466b9UL, 0x9fe461ceUL,
+ 0x0ef9de5eUL, 0x98c9d929UL, 0x2298d0b0UL, 0xb4a8d7c7UL, 0x173db359UL,
+ 0x810db42eUL, 0x3b5cbdb7UL, 0xad6cbac0UL, 0x2083b8edUL, 0xb6b3bf9aUL,
+ 0x0ce2b603UL, 0x9ad2b174UL, 0x3947d5eaUL, 0xaf77d29dUL, 0x1526db04UL,
+ 0x8316dc73UL, 0x120b63e3UL, 0x843b6494UL, 0x3e6a6d0dUL, 0xa85a6a7aUL,
+ 0x0bcf0ee4UL, 0x9dff0993UL, 0x27ae000aUL, 0xb19e077dUL, 0x44930ff0UL,
+ 0xd2a30887UL, 0x68f2011eUL, 0xfec20669UL, 0x5d5762f7UL, 0xcb676580UL,
+ 0x71366c19UL, 0xe7066b6eUL, 0x761bd4feUL, 0xe02bd389UL, 0x5a7ada10UL,
+ 0xcc4add67UL, 0x6fdfb9f9UL, 0xf9efbe8eUL, 0x43beb717UL, 0xd58eb060UL,
+ 0xe8a3d6d6UL, 0x7e93d1a1UL, 0xc4c2d838UL, 0x52f2df4fUL, 0xf167bbd1UL,
+ 0x6757bca6UL, 0xdd06b53fUL, 0x4b36b248UL, 0xda2b0dd8UL, 0x4c1b0aafUL,
+ 0xf64a0336UL, 0x607a0441UL, 0xc3ef60dfUL, 0x55df67a8UL, 0xef8e6e31UL,
+ 0x79be6946UL, 0x8cb361cbUL, 0x1a8366bcUL, 0xa0d26f25UL, 0x36e26852UL,
+ 0x95770cccUL, 0x03470bbbUL, 0xb9160222UL, 0x2f260555UL, 0xbe3bbac5UL,
+ 0x280bbdb2UL, 0x925ab42bUL, 0x046ab35cUL, 0xa7ffd7c2UL, 0x31cfd0b5UL,
+ 0x8b9ed92cUL, 0x1daede5bUL, 0xb0c2649bUL, 0x26f263ecUL, 0x9ca36a75UL,
+ 0x0a936d02UL, 0xa906099cUL, 0x3f360eebUL, 0x85670772UL, 0x13570005UL,
+ 0x824abf95UL, 0x147ab8e2UL, 0xae2bb17bUL, 0x381bb60cUL, 0x9b8ed292UL,
+ 0x0dbed5e5UL, 0xb7efdc7cUL, 0x21dfdb0bUL, 0xd4d2d386UL, 0x42e2d4f1UL,
+ 0xf8b3dd68UL, 0x6e83da1fUL, 0xcd16be81UL, 0x5b26b9f6UL, 0xe177b06fUL,
+ 0x7747b718UL, 0xe65a0888UL, 0x706a0fffUL, 0xca3b0666UL, 0x5c0b0111UL,
+ 0xff9e658fUL, 0x69ae62f8UL, 0xd3ff6b61UL, 0x45cf6c16UL, 0x78e20aa0UL,
+ 0xeed20dd7UL, 0x5483044eUL, 0xc2b30339UL, 0x612667a7UL, 0xf71660d0UL,
+ 0x4d476949UL, 0xdb776e3eUL, 0x4a6ad1aeUL, 0xdc5ad6d9UL, 0x660bdf40UL,
+ 0xf03bd837UL, 0x53aebca9UL, 0xc59ebbdeUL, 0x7fcfb247UL, 0xe9ffb530UL,
+ 0x1cf2bdbdUL, 0x8ac2bacaUL, 0x3093b353UL, 0xa6a3b424UL, 0x0536d0baUL,
+ 0x9306d7cdUL, 0x2957de54UL, 0xbf67d923UL, 0x2e7a66b3UL, 0xb84a61c4UL,
+ 0x021b685dUL, 0x942b6f2aUL, 0x37be0bb4UL, 0xa18e0cc3UL, 0x1bdf055aUL,
+ 0x8def022dUL
+ },
+ {
+ 0x00000000UL, 0x41311b19UL, 0x82623632UL, 0xc3532d2bUL, 0x04c56c64UL,
+ 0x45f4777dUL, 0x86a75a56UL, 0xc796414fUL, 0x088ad9c8UL, 0x49bbc2d1UL,
+ 0x8ae8effaUL, 0xcbd9f4e3UL, 0x0c4fb5acUL, 0x4d7eaeb5UL, 0x8e2d839eUL,
+ 0xcf1c9887UL, 0x5112c24aUL, 0x1023d953UL, 0xd370f478UL, 0x9241ef61UL,
+ 0x55d7ae2eUL, 0x14e6b537UL, 0xd7b5981cUL, 0x96848305UL, 0x59981b82UL,
+ 0x18a9009bUL, 0xdbfa2db0UL, 0x9acb36a9UL, 0x5d5d77e6UL, 0x1c6c6cffUL,
+ 0xdf3f41d4UL, 0x9e0e5acdUL, 0xa2248495UL, 0xe3159f8cUL, 0x2046b2a7UL,
+ 0x6177a9beUL, 0xa6e1e8f1UL, 0xe7d0f3e8UL, 0x2483dec3UL, 0x65b2c5daUL,
+ 0xaaae5d5dUL, 0xeb9f4644UL, 0x28cc6b6fUL, 0x69fd7076UL, 0xae6b3139UL,
+ 0xef5a2a20UL, 0x2c09070bUL, 0x6d381c12UL, 0xf33646dfUL, 0xb2075dc6UL,
+ 0x715470edUL, 0x30656bf4UL, 0xf7f32abbUL, 0xb6c231a2UL, 0x75911c89UL,
+ 0x34a00790UL, 0xfbbc9f17UL, 0xba8d840eUL, 0x79dea925UL, 0x38efb23cUL,
+ 0xff79f373UL, 0xbe48e86aUL, 0x7d1bc541UL, 0x3c2ade58UL, 0x054f79f0UL,
+ 0x447e62e9UL, 0x872d4fc2UL, 0xc61c54dbUL, 0x018a1594UL, 0x40bb0e8dUL,
+ 0x83e823a6UL, 0xc2d938bfUL, 0x0dc5a038UL, 0x4cf4bb21UL, 0x8fa7960aUL,
+ 0xce968d13UL, 0x0900cc5cUL, 0x4831d745UL, 0x8b62fa6eUL, 0xca53e177UL,
+ 0x545dbbbaUL, 0x156ca0a3UL, 0xd63f8d88UL, 0x970e9691UL, 0x5098d7deUL,
+ 0x11a9ccc7UL, 0xd2fae1ecUL, 0x93cbfaf5UL, 0x5cd76272UL, 0x1de6796bUL,
+ 0xdeb55440UL, 0x9f844f59UL, 0x58120e16UL, 0x1923150fUL, 0xda703824UL,
+ 0x9b41233dUL, 0xa76bfd65UL, 0xe65ae67cUL, 0x2509cb57UL, 0x6438d04eUL,
+ 0xa3ae9101UL, 0xe29f8a18UL, 0x21cca733UL, 0x60fdbc2aUL, 0xafe124adUL,
+ 0xeed03fb4UL, 0x2d83129fUL, 0x6cb20986UL, 0xab2448c9UL, 0xea1553d0UL,
+ 0x29467efbUL, 0x687765e2UL, 0xf6793f2fUL, 0xb7482436UL, 0x741b091dUL,
+ 0x352a1204UL, 0xf2bc534bUL, 0xb38d4852UL, 0x70de6579UL, 0x31ef7e60UL,
+ 0xfef3e6e7UL, 0xbfc2fdfeUL, 0x7c91d0d5UL, 0x3da0cbccUL, 0xfa368a83UL,
+ 0xbb07919aUL, 0x7854bcb1UL, 0x3965a7a8UL, 0x4b98833bUL, 0x0aa99822UL,
+ 0xc9fab509UL, 0x88cbae10UL, 0x4f5def5fUL, 0x0e6cf446UL, 0xcd3fd96dUL,
+ 0x8c0ec274UL, 0x43125af3UL, 0x022341eaUL, 0xc1706cc1UL, 0x804177d8UL,
+ 0x47d73697UL, 0x06e62d8eUL, 0xc5b500a5UL, 0x84841bbcUL, 0x1a8a4171UL,
+ 0x5bbb5a68UL, 0x98e87743UL, 0xd9d96c5aUL, 0x1e4f2d15UL, 0x5f7e360cUL,
+ 0x9c2d1b27UL, 0xdd1c003eUL, 0x120098b9UL, 0x533183a0UL, 0x9062ae8bUL,
+ 0xd153b592UL, 0x16c5f4ddUL, 0x57f4efc4UL, 0x94a7c2efUL, 0xd596d9f6UL,
+ 0xe9bc07aeUL, 0xa88d1cb7UL, 0x6bde319cUL, 0x2aef2a85UL, 0xed796bcaUL,
+ 0xac4870d3UL, 0x6f1b5df8UL, 0x2e2a46e1UL, 0xe136de66UL, 0xa007c57fUL,
+ 0x6354e854UL, 0x2265f34dUL, 0xe5f3b202UL, 0xa4c2a91bUL, 0x67918430UL,
+ 0x26a09f29UL, 0xb8aec5e4UL, 0xf99fdefdUL, 0x3accf3d6UL, 0x7bfde8cfUL,
+ 0xbc6ba980UL, 0xfd5ab299UL, 0x3e099fb2UL, 0x7f3884abUL, 0xb0241c2cUL,
+ 0xf1150735UL, 0x32462a1eUL, 0x73773107UL, 0xb4e17048UL, 0xf5d06b51UL,
+ 0x3683467aUL, 0x77b25d63UL, 0x4ed7facbUL, 0x0fe6e1d2UL, 0xccb5ccf9UL,
+ 0x8d84d7e0UL, 0x4a1296afUL, 0x0b238db6UL, 0xc870a09dUL, 0x8941bb84UL,
+ 0x465d2303UL, 0x076c381aUL, 0xc43f1531UL, 0x850e0e28UL, 0x42984f67UL,
+ 0x03a9547eUL, 0xc0fa7955UL, 0x81cb624cUL, 0x1fc53881UL, 0x5ef42398UL,
+ 0x9da70eb3UL, 0xdc9615aaUL, 0x1b0054e5UL, 0x5a314ffcUL, 0x996262d7UL,
+ 0xd85379ceUL, 0x174fe149UL, 0x567efa50UL, 0x952dd77bUL, 0xd41ccc62UL,
+ 0x138a8d2dUL, 0x52bb9634UL, 0x91e8bb1fUL, 0xd0d9a006UL, 0xecf37e5eUL,
+ 0xadc26547UL, 0x6e91486cUL, 0x2fa05375UL, 0xe836123aUL, 0xa9070923UL,
+ 0x6a542408UL, 0x2b653f11UL, 0xe479a796UL, 0xa548bc8fUL, 0x661b91a4UL,
+ 0x272a8abdUL, 0xe0bccbf2UL, 0xa18dd0ebUL, 0x62defdc0UL, 0x23efe6d9UL,
+ 0xbde1bc14UL, 0xfcd0a70dUL, 0x3f838a26UL, 0x7eb2913fUL, 0xb924d070UL,
+ 0xf815cb69UL, 0x3b46e642UL, 0x7a77fd5bUL, 0xb56b65dcUL, 0xf45a7ec5UL,
+ 0x370953eeUL, 0x763848f7UL, 0xb1ae09b8UL, 0xf09f12a1UL, 0x33cc3f8aUL,
+ 0x72fd2493UL
+ },
+ {
+ 0x00000000UL, 0x376ac201UL, 0x6ed48403UL, 0x59be4602UL, 0xdca80907UL,
+ 0xebc2cb06UL, 0xb27c8d04UL, 0x85164f05UL, 0xb851130eUL, 0x8f3bd10fUL,
+ 0xd685970dUL, 0xe1ef550cUL, 0x64f91a09UL, 0x5393d808UL, 0x0a2d9e0aUL,
+ 0x3d475c0bUL, 0x70a3261cUL, 0x47c9e41dUL, 0x1e77a21fUL, 0x291d601eUL,
+ 0xac0b2f1bUL, 0x9b61ed1aUL, 0xc2dfab18UL, 0xf5b56919UL, 0xc8f23512UL,
+ 0xff98f713UL, 0xa626b111UL, 0x914c7310UL, 0x145a3c15UL, 0x2330fe14UL,
+ 0x7a8eb816UL, 0x4de47a17UL, 0xe0464d38UL, 0xd72c8f39UL, 0x8e92c93bUL,
+ 0xb9f80b3aUL, 0x3cee443fUL, 0x0b84863eUL, 0x523ac03cUL, 0x6550023dUL,
+ 0x58175e36UL, 0x6f7d9c37UL, 0x36c3da35UL, 0x01a91834UL, 0x84bf5731UL,
+ 0xb3d59530UL, 0xea6bd332UL, 0xdd011133UL, 0x90e56b24UL, 0xa78fa925UL,
+ 0xfe31ef27UL, 0xc95b2d26UL, 0x4c4d6223UL, 0x7b27a022UL, 0x2299e620UL,
+ 0x15f32421UL, 0x28b4782aUL, 0x1fdeba2bUL, 0x4660fc29UL, 0x710a3e28UL,
+ 0xf41c712dUL, 0xc376b32cUL, 0x9ac8f52eUL, 0xada2372fUL, 0xc08d9a70UL,
+ 0xf7e75871UL, 0xae591e73UL, 0x9933dc72UL, 0x1c259377UL, 0x2b4f5176UL,
+ 0x72f11774UL, 0x459bd575UL, 0x78dc897eUL, 0x4fb64b7fUL, 0x16080d7dUL,
+ 0x2162cf7cUL, 0xa4748079UL, 0x931e4278UL, 0xcaa0047aUL, 0xfdcac67bUL,
+ 0xb02ebc6cUL, 0x87447e6dUL, 0xdefa386fUL, 0xe990fa6eUL, 0x6c86b56bUL,
+ 0x5bec776aUL, 0x02523168UL, 0x3538f369UL, 0x087faf62UL, 0x3f156d63UL,
+ 0x66ab2b61UL, 0x51c1e960UL, 0xd4d7a665UL, 0xe3bd6464UL, 0xba032266UL,
+ 0x8d69e067UL, 0x20cbd748UL, 0x17a11549UL, 0x4e1f534bUL, 0x7975914aUL,
+ 0xfc63de4fUL, 0xcb091c4eUL, 0x92b75a4cUL, 0xa5dd984dUL, 0x989ac446UL,
+ 0xaff00647UL, 0xf64e4045UL, 0xc1248244UL, 0x4432cd41UL, 0x73580f40UL,
+ 0x2ae64942UL, 0x1d8c8b43UL, 0x5068f154UL, 0x67023355UL, 0x3ebc7557UL,
+ 0x09d6b756UL, 0x8cc0f853UL, 0xbbaa3a52UL, 0xe2147c50UL, 0xd57ebe51UL,
+ 0xe839e25aUL, 0xdf53205bUL, 0x86ed6659UL, 0xb187a458UL, 0x3491eb5dUL,
+ 0x03fb295cUL, 0x5a456f5eUL, 0x6d2fad5fUL, 0x801b35e1UL, 0xb771f7e0UL,
+ 0xeecfb1e2UL, 0xd9a573e3UL, 0x5cb33ce6UL, 0x6bd9fee7UL, 0x3267b8e5UL,
+ 0x050d7ae4UL, 0x384a26efUL, 0x0f20e4eeUL, 0x569ea2ecUL, 0x61f460edUL,
+ 0xe4e22fe8UL, 0xd388ede9UL, 0x8a36abebUL, 0xbd5c69eaUL, 0xf0b813fdUL,
+ 0xc7d2d1fcUL, 0x9e6c97feUL, 0xa90655ffUL, 0x2c101afaUL, 0x1b7ad8fbUL,
+ 0x42c49ef9UL, 0x75ae5cf8UL, 0x48e900f3UL, 0x7f83c2f2UL, 0x263d84f0UL,
+ 0x115746f1UL, 0x944109f4UL, 0xa32bcbf5UL, 0xfa958df7UL, 0xcdff4ff6UL,
+ 0x605d78d9UL, 0x5737bad8UL, 0x0e89fcdaUL, 0x39e33edbUL, 0xbcf571deUL,
+ 0x8b9fb3dfUL, 0xd221f5ddUL, 0xe54b37dcUL, 0xd80c6bd7UL, 0xef66a9d6UL,
+ 0xb6d8efd4UL, 0x81b22dd5UL, 0x04a462d0UL, 0x33cea0d1UL, 0x6a70e6d3UL,
+ 0x5d1a24d2UL, 0x10fe5ec5UL, 0x27949cc4UL, 0x7e2adac6UL, 0x494018c7UL,
+ 0xcc5657c2UL, 0xfb3c95c3UL, 0xa282d3c1UL, 0x95e811c0UL, 0xa8af4dcbUL,
+ 0x9fc58fcaUL, 0xc67bc9c8UL, 0xf1110bc9UL, 0x740744ccUL, 0x436d86cdUL,
+ 0x1ad3c0cfUL, 0x2db902ceUL, 0x4096af91UL, 0x77fc6d90UL, 0x2e422b92UL,
+ 0x1928e993UL, 0x9c3ea696UL, 0xab546497UL, 0xf2ea2295UL, 0xc580e094UL,
+ 0xf8c7bc9fUL, 0xcfad7e9eUL, 0x9613389cUL, 0xa179fa9dUL, 0x246fb598UL,
+ 0x13057799UL, 0x4abb319bUL, 0x7dd1f39aUL, 0x3035898dUL, 0x075f4b8cUL,
+ 0x5ee10d8eUL, 0x698bcf8fUL, 0xec9d808aUL, 0xdbf7428bUL, 0x82490489UL,
+ 0xb523c688UL, 0x88649a83UL, 0xbf0e5882UL, 0xe6b01e80UL, 0xd1dadc81UL,
+ 0x54cc9384UL, 0x63a65185UL, 0x3a181787UL, 0x0d72d586UL, 0xa0d0e2a9UL,
+ 0x97ba20a8UL, 0xce0466aaUL, 0xf96ea4abUL, 0x7c78ebaeUL, 0x4b1229afUL,
+ 0x12ac6fadUL, 0x25c6adacUL, 0x1881f1a7UL, 0x2feb33a6UL, 0x765575a4UL,
+ 0x413fb7a5UL, 0xc429f8a0UL, 0xf3433aa1UL, 0xaafd7ca3UL, 0x9d97bea2UL,
+ 0xd073c4b5UL, 0xe71906b4UL, 0xbea740b6UL, 0x89cd82b7UL, 0x0cdbcdb2UL,
+ 0x3bb10fb3UL, 0x620f49b1UL, 0x55658bb0UL, 0x6822d7bbUL, 0x5f4815baUL,
+ 0x06f653b8UL, 0x319c91b9UL, 0xb48adebcUL, 0x83e01cbdUL, 0xda5e5abfUL,
+ 0xed3498beUL
+ },
+ {
+ 0x00000000UL, 0x6567bcb8UL, 0x8bc809aaUL, 0xeeafb512UL, 0x5797628fUL,
+ 0x32f0de37UL, 0xdc5f6b25UL, 0xb938d79dUL, 0xef28b4c5UL, 0x8a4f087dUL,
+ 0x64e0bd6fUL, 0x018701d7UL, 0xb8bfd64aUL, 0xddd86af2UL, 0x3377dfe0UL,
+ 0x56106358UL, 0x9f571950UL, 0xfa30a5e8UL, 0x149f10faUL, 0x71f8ac42UL,
+ 0xc8c07bdfUL, 0xada7c767UL, 0x43087275UL, 0x266fcecdUL, 0x707fad95UL,
+ 0x1518112dUL, 0xfbb7a43fUL, 0x9ed01887UL, 0x27e8cf1aUL, 0x428f73a2UL,
+ 0xac20c6b0UL, 0xc9477a08UL, 0x3eaf32a0UL, 0x5bc88e18UL, 0xb5673b0aUL,
+ 0xd00087b2UL, 0x6938502fUL, 0x0c5fec97UL, 0xe2f05985UL, 0x8797e53dUL,
+ 0xd1878665UL, 0xb4e03addUL, 0x5a4f8fcfUL, 0x3f283377UL, 0x8610e4eaUL,
+ 0xe3775852UL, 0x0dd8ed40UL, 0x68bf51f8UL, 0xa1f82bf0UL, 0xc49f9748UL,
+ 0x2a30225aUL, 0x4f579ee2UL, 0xf66f497fUL, 0x9308f5c7UL, 0x7da740d5UL,
+ 0x18c0fc6dUL, 0x4ed09f35UL, 0x2bb7238dUL, 0xc518969fUL, 0xa07f2a27UL,
+ 0x1947fdbaUL, 0x7c204102UL, 0x928ff410UL, 0xf7e848a8UL, 0x3d58149bUL,
+ 0x583fa823UL, 0xb6901d31UL, 0xd3f7a189UL, 0x6acf7614UL, 0x0fa8caacUL,
+ 0xe1077fbeUL, 0x8460c306UL, 0xd270a05eUL, 0xb7171ce6UL, 0x59b8a9f4UL,
+ 0x3cdf154cUL, 0x85e7c2d1UL, 0xe0807e69UL, 0x0e2fcb7bUL, 0x6b4877c3UL,
+ 0xa20f0dcbUL, 0xc768b173UL, 0x29c70461UL, 0x4ca0b8d9UL, 0xf5986f44UL,
+ 0x90ffd3fcUL, 0x7e5066eeUL, 0x1b37da56UL, 0x4d27b90eUL, 0x284005b6UL,
+ 0xc6efb0a4UL, 0xa3880c1cUL, 0x1ab0db81UL, 0x7fd76739UL, 0x9178d22bUL,
+ 0xf41f6e93UL, 0x03f7263bUL, 0x66909a83UL, 0x883f2f91UL, 0xed589329UL,
+ 0x546044b4UL, 0x3107f80cUL, 0xdfa84d1eUL, 0xbacff1a6UL, 0xecdf92feUL,
+ 0x89b82e46UL, 0x67179b54UL, 0x027027ecUL, 0xbb48f071UL, 0xde2f4cc9UL,
+ 0x3080f9dbUL, 0x55e74563UL, 0x9ca03f6bUL, 0xf9c783d3UL, 0x176836c1UL,
+ 0x720f8a79UL, 0xcb375de4UL, 0xae50e15cUL, 0x40ff544eUL, 0x2598e8f6UL,
+ 0x73888baeUL, 0x16ef3716UL, 0xf8408204UL, 0x9d273ebcUL, 0x241fe921UL,
+ 0x41785599UL, 0xafd7e08bUL, 0xcab05c33UL, 0x3bb659edUL, 0x5ed1e555UL,
+ 0xb07e5047UL, 0xd519ecffUL, 0x6c213b62UL, 0x094687daUL, 0xe7e932c8UL,
+ 0x828e8e70UL, 0xd49eed28UL, 0xb1f95190UL, 0x5f56e482UL, 0x3a31583aUL,
+ 0x83098fa7UL, 0xe66e331fUL, 0x08c1860dUL, 0x6da63ab5UL, 0xa4e140bdUL,
+ 0xc186fc05UL, 0x2f294917UL, 0x4a4ef5afUL, 0xf3762232UL, 0x96119e8aUL,
+ 0x78be2b98UL, 0x1dd99720UL, 0x4bc9f478UL, 0x2eae48c0UL, 0xc001fdd2UL,
+ 0xa566416aUL, 0x1c5e96f7UL, 0x79392a4fUL, 0x97969f5dUL, 0xf2f123e5UL,
+ 0x05196b4dUL, 0x607ed7f5UL, 0x8ed162e7UL, 0xebb6de5fUL, 0x528e09c2UL,
+ 0x37e9b57aUL, 0xd9460068UL, 0xbc21bcd0UL, 0xea31df88UL, 0x8f566330UL,
+ 0x61f9d622UL, 0x049e6a9aUL, 0xbda6bd07UL, 0xd8c101bfUL, 0x366eb4adUL,
+ 0x53090815UL, 0x9a4e721dUL, 0xff29cea5UL, 0x11867bb7UL, 0x74e1c70fUL,
+ 0xcdd91092UL, 0xa8beac2aUL, 0x46111938UL, 0x2376a580UL, 0x7566c6d8UL,
+ 0x10017a60UL, 0xfeaecf72UL, 0x9bc973caUL, 0x22f1a457UL, 0x479618efUL,
+ 0xa939adfdUL, 0xcc5e1145UL, 0x06ee4d76UL, 0x6389f1ceUL, 0x8d2644dcUL,
+ 0xe841f864UL, 0x51792ff9UL, 0x341e9341UL, 0xdab12653UL, 0xbfd69aebUL,
+ 0xe9c6f9b3UL, 0x8ca1450bUL, 0x620ef019UL, 0x07694ca1UL, 0xbe519b3cUL,
+ 0xdb362784UL, 0x35999296UL, 0x50fe2e2eUL, 0x99b95426UL, 0xfcdee89eUL,
+ 0x12715d8cUL, 0x7716e134UL, 0xce2e36a9UL, 0xab498a11UL, 0x45e63f03UL,
+ 0x208183bbUL, 0x7691e0e3UL, 0x13f65c5bUL, 0xfd59e949UL, 0x983e55f1UL,
+ 0x2106826cUL, 0x44613ed4UL, 0xaace8bc6UL, 0xcfa9377eUL, 0x38417fd6UL,
+ 0x5d26c36eUL, 0xb389767cUL, 0xd6eecac4UL, 0x6fd61d59UL, 0x0ab1a1e1UL,
+ 0xe41e14f3UL, 0x8179a84bUL, 0xd769cb13UL, 0xb20e77abUL, 0x5ca1c2b9UL,
+ 0x39c67e01UL, 0x80fea99cUL, 0xe5991524UL, 0x0b36a036UL, 0x6e511c8eUL,
+ 0xa7166686UL, 0xc271da3eUL, 0x2cde6f2cUL, 0x49b9d394UL, 0xf0810409UL,
+ 0x95e6b8b1UL, 0x7b490da3UL, 0x1e2eb11bUL, 0x483ed243UL, 0x2d596efbUL,
+ 0xc3f6dbe9UL, 0xa6916751UL, 0x1fa9b0ccUL, 0x7ace0c74UL, 0x9461b966UL,
+ 0xf10605deUL
+#endif
+ }
+};
diff --git a/libs/system/zc702evk/linux/zlib/deflate.h b/libs/system/zc702evk/linux/zlib/deflate.h
--- /dev/null
@@ -0,0 +1,342 @@
+/* deflate.h -- internal compression state
+ * Copyright (C) 1995-2010 Jean-loup Gailly
+ * For conditions of distribution and use, see copyright notice in zlib.h
+ */
+
+/* WARNING: this file should *not* be used by applications. It is
+ part of the implementation of the compression library and is
+ subject to change. Applications should only use zlib.h.
+ */
+
+/* @(#) $Id$ */
+
+#ifndef DEFLATE_H
+#define DEFLATE_H
+
+#include "zutil.h"
+
+/* define NO_GZIP when compiling if you want to disable gzip header and
+ trailer creation by deflate(). NO_GZIP would be used to avoid linking in
+ the crc code when it is not needed. For shared libraries, gzip encoding
+ should be left enabled. */
+#ifndef NO_GZIP
+# define GZIP
+#endif
+
+/* ===========================================================================
+ * Internal compression state.
+ */
+
+#define LENGTH_CODES 29
+/* number of length codes, not counting the special END_BLOCK code */
+
+#define LITERALS 256
+/* number of literal bytes 0..255 */
+
+#define L_CODES (LITERALS+1+LENGTH_CODES)
+/* number of Literal or Length codes, including the END_BLOCK code */
+
+#define D_CODES 30
+/* number of distance codes */
+
+#define BL_CODES 19
+/* number of codes used to transfer the bit lengths */
+
+#define HEAP_SIZE (2*L_CODES+1)
+/* maximum heap size */
+
+#define MAX_BITS 15
+/* All codes must not exceed MAX_BITS bits */
+
+#define INIT_STATE 42
+#define EXTRA_STATE 69
+#define NAME_STATE 73
+#define COMMENT_STATE 91
+#define HCRC_STATE 103
+#define BUSY_STATE 113
+#define FINISH_STATE 666
+/* Stream status */
+
+
+/* Data structure describing a single value and its code string. */
+typedef struct ct_data_s {
+ union {
+ ush freq; /* frequency count */
+ ush code; /* bit string */
+ } fc;
+ union {
+ ush dad; /* father node in Huffman tree */
+ ush len; /* length of bit string */
+ } dl;
+} FAR ct_data;
+
+#define Freq fc.freq
+#define Code fc.code
+#define Dad dl.dad
+#define Len dl.len
+
+typedef struct static_tree_desc_s static_tree_desc;
+
+typedef struct tree_desc_s {
+ ct_data *dyn_tree; /* the dynamic tree */
+ int max_code; /* largest code with non zero frequency */
+ static_tree_desc *stat_desc; /* the corresponding static tree */
+} FAR tree_desc;
+
+typedef ush Pos;
+typedef Pos FAR Posf;
+typedef unsigned IPos;
+
+/* A Pos is an index in the character window. We use short instead of int to
+ * save space in the various tables. IPos is used only for parameter passing.
+ */
+
+typedef struct internal_state {
+ z_streamp strm; /* pointer back to this zlib stream */
+ int status; /* as the name implies */
+ Bytef *pending_buf; /* output still pending */
+ ulg pending_buf_size; /* size of pending_buf */
+ Bytef *pending_out; /* next pending byte to output to the stream */
+ uInt pending; /* nb of bytes in the pending buffer */
+ int wrap; /* bit 0 true for zlib, bit 1 true for gzip */
+ gz_headerp gzhead; /* gzip header information to write */
+ uInt gzindex; /* where in extra, name, or comment */
+ Byte method; /* STORED (for zip only) or DEFLATED */
+ int last_flush; /* value of flush param for previous deflate call */
+
+ /* used by deflate.c: */
+
+ uInt w_size; /* LZ77 window size (32K by default) */
+ uInt w_bits; /* log2(w_size) (8..16) */
+ uInt w_mask; /* w_size - 1 */
+
+ Bytef *window;
+ /* Sliding window. Input bytes are read into the second half of the window,
+ * and move to the first half later to keep a dictionary of at least wSize
+ * bytes. With this organization, matches are limited to a distance of
+ * wSize-MAX_MATCH bytes, but this ensures that IO is always
+ * performed with a length multiple of the block size. Also, it limits
+ * the window size to 64K, which is quite useful on MSDOS.
+ * To do: use the user input buffer as sliding window.
+ */
+
+ ulg window_size;
+ /* Actual size of window: 2*wSize, except when the user input buffer
+ * is directly used as sliding window.
+ */
+
+ Posf *prev;
+ /* Link to older string with same hash index. To limit the size of this
+ * array to 64K, this link is maintained only for the last 32K strings.
+ * An index in this array is thus a window index modulo 32K.
+ */
+
+ Posf *head; /* Heads of the hash chains or NIL. */
+
+ uInt ins_h; /* hash index of string to be inserted */
+ uInt hash_size; /* number of elements in hash table */
+ uInt hash_bits; /* log2(hash_size) */
+ uInt hash_mask; /* hash_size-1 */
+
+ uInt hash_shift;
+ /* Number of bits by which ins_h must be shifted at each input
+ * step. It must be such that after MIN_MATCH steps, the oldest
+ * byte no longer takes part in the hash key, that is:
+ * hash_shift * MIN_MATCH >= hash_bits
+ */
+
+ long block_start;
+ /* Window position at the beginning of the current output block. Gets
+ * negative when the window is moved backwards.
+ */
+
+ uInt match_length; /* length of best match */
+ IPos prev_match; /* previous match */
+ int match_available; /* set if previous match exists */
+ uInt strstart; /* start of string to insert */
+ uInt match_start; /* start of matching string */
+ uInt lookahead; /* number of valid bytes ahead in window */
+
+ uInt prev_length;
+ /* Length of the best match at previous step. Matches not greater than this
+ * are discarded. This is used in the lazy match evaluation.
+ */
+
+ uInt max_chain_length;
+ /* To speed up deflation, hash chains are never searched beyond this
+ * length. A higher limit improves compression ratio but degrades the
+ * speed.
+ */
+
+ uInt max_lazy_match;
+ /* Attempt to find a better match only when the current match is strictly
+ * smaller than this value. This mechanism is used only for compression
+ * levels >= 4.
+ */
+# define max_insert_length max_lazy_match
+ /* Insert new strings in the hash table only if the match length is not
+ * greater than this length. This saves time but degrades compression.
+ * max_insert_length is used only for compression levels <= 3.
+ */
+
+ int level; /* compression level (1..9) */
+ int strategy; /* favor or force Huffman coding*/
+
+ uInt good_match;
+ /* Use a faster search when the previous match is longer than this */
+
+ int nice_match; /* Stop searching when current match exceeds this */
+
+ /* used by trees.c: */
+ /* Didn't use ct_data typedef below to supress compiler warning */
+ struct ct_data_s dyn_ltree[HEAP_SIZE]; /* literal and length tree */
+ struct ct_data_s dyn_dtree[2*D_CODES+1]; /* distance tree */
+ struct ct_data_s bl_tree[2*BL_CODES+1]; /* Huffman tree for bit lengths */
+
+ struct tree_desc_s l_desc; /* desc. for literal tree */
+ struct tree_desc_s d_desc; /* desc. for distance tree */
+ struct tree_desc_s bl_desc; /* desc. for bit length tree */
+
+ ush bl_count[MAX_BITS+1];
+ /* number of codes at each bit length for an optimal tree */
+
+ int heap[2*L_CODES+1]; /* heap used to build the Huffman trees */
+ int heap_len; /* number of elements in the heap */
+ int heap_max; /* element of largest frequency */
+ /* The sons of heap[n] are heap[2*n] and heap[2*n+1]. heap[0] is not used.
+ * The same heap array is used to build all trees.
+ */
+
+ uch depth[2*L_CODES+1];
+ /* Depth of each subtree used as tie breaker for trees of equal frequency
+ */
+
+ uchf *l_buf; /* buffer for literals or lengths */
+
+ uInt lit_bufsize;
+ /* Size of match buffer for literals/lengths. There are 4 reasons for
+ * limiting lit_bufsize to 64K:
+ * - frequencies can be kept in 16 bit counters
+ * - if compression is not successful for the first block, all input
+ * data is still in the window so we can still emit a stored block even
+ * when input comes from standard input. (This can also be done for
+ * all blocks if lit_bufsize is not greater than 32K.)
+ * - if compression is not successful for a file smaller than 64K, we can
+ * even emit a stored file instead of a stored block (saving 5 bytes).
+ * This is applicable only for zip (not gzip or zlib).
+ * - creating new Huffman trees less frequently may not provide fast
+ * adaptation to changes in the input data statistics. (Take for
+ * example a binary file with poorly compressible code followed by
+ * a highly compressible string table.) Smaller buffer sizes give
+ * fast adaptation but have of course the overhead of transmitting
+ * trees more frequently.
+ * - I can't count above 4
+ */
+
+ uInt last_lit; /* running index in l_buf */
+
+ ushf *d_buf;
+ /* Buffer for distances. To simplify the code, d_buf and l_buf have
+ * the same number of elements. To use different lengths, an extra flag
+ * array would be necessary.
+ */
+
+ ulg opt_len; /* bit length of current block with optimal trees */
+ ulg static_len; /* bit length of current block with static trees */
+ uInt matches; /* number of string matches in current block */
+ int last_eob_len; /* bit length of EOB code for last block */
+
+#ifdef DEBUG
+ ulg compressed_len; /* total bit length of compressed file mod 2^32 */
+ ulg bits_sent; /* bit length of compressed data sent mod 2^32 */
+#endif
+
+ ush bi_buf;
+ /* Output buffer. bits are inserted starting at the bottom (least
+ * significant bits).
+ */
+ int bi_valid;
+ /* Number of valid bits in bi_buf. All bits above the last valid bit
+ * are always zero.
+ */
+
+ ulg high_water;
+ /* High water mark offset in window for initialized bytes -- bytes above
+ * this are set to zero in order to avoid memory check warnings when
+ * longest match routines access bytes past the input. This is then
+ * updated to the new high water mark.
+ */
+
+} FAR deflate_state;
+
+/* Output a byte on the stream.
+ * IN assertion: there is enough room in pending_buf.
+ */
+#define put_byte(s, c) {s->pending_buf[s->pending++] = (c);}
+
+
+#define MIN_LOOKAHEAD (MAX_MATCH+MIN_MATCH+1)
+/* Minimum amount of lookahead, except at the end of the input file.
+ * See deflate.c for comments about the MIN_MATCH+1.
+ */
+
+#define MAX_DIST(s) ((s)->w_size-MIN_LOOKAHEAD)
+/* In order to simplify the code, particularly on 16 bit machines, match
+ * distances are limited to MAX_DIST instead of WSIZE.
+ */
+
+#define WIN_INIT MAX_MATCH
+/* Number of bytes after end of data in window to initialize in order to avoid
+ memory checker errors from longest match routines */
+
+ /* in trees.c */
+void ZLIB_INTERNAL _tr_init OF((deflate_state *s));
+int ZLIB_INTERNAL _tr_tally OF((deflate_state *s, unsigned dist, unsigned lc));
+void ZLIB_INTERNAL _tr_flush_block OF((deflate_state *s, charf *buf,
+ ulg stored_len, int last));
+void ZLIB_INTERNAL _tr_align OF((deflate_state *s));
+void ZLIB_INTERNAL _tr_stored_block OF((deflate_state *s, charf *buf,
+ ulg stored_len, int last));
+
+#define d_code(dist) \
+ ((dist) < 256 ? _dist_code[dist] : _dist_code[256+((dist)>>7)])
+/* Mapping from a distance to a distance code. dist is the distance - 1 and
+ * must not have side effects. _dist_code[256] and _dist_code[257] are never
+ * used.
+ */
+
+#ifndef DEBUG
+/* Inline versions of _tr_tally for speed: */
+
+#if defined(GEN_TREES_H) || !defined(STDC)
+ extern uch ZLIB_INTERNAL _length_code[];
+ extern uch ZLIB_INTERNAL _dist_code[];
+#else
+ extern const uch ZLIB_INTERNAL _length_code[];
+ extern const uch ZLIB_INTERNAL _dist_code[];
+#endif
+
+# define _tr_tally_lit(s, c, flush) \
+ { uch cc = (c); \
+ s->d_buf[s->last_lit] = 0; \
+ s->l_buf[s->last_lit++] = cc; \
+ s->dyn_ltree[cc].Freq++; \
+ flush = (s->last_lit == s->lit_bufsize-1); \
+ }
+# define _tr_tally_dist(s, distance, length, flush) \
+ { uch len = (length); \
+ ush dist = (distance); \
+ s->d_buf[s->last_lit] = dist; \
+ s->l_buf[s->last_lit++] = len; \
+ dist--; \
+ s->dyn_ltree[_length_code[len]+LITERALS+1].Freq++; \
+ s->dyn_dtree[d_code(dist)].Freq++; \
+ flush = (s->last_lit == s->lit_bufsize-1); \
+ }
+#else
+# define _tr_tally_lit(s, c, flush) flush = _tr_tally(s, 0, c)
+# define _tr_tally_dist(s, distance, length, flush) \
+ flush = _tr_tally(s, distance, length)
+#endif
+
+#endif /* DEFLATE_H */
diff --git a/libs/system/zc702evk/linux/zlib/inffast.h b/libs/system/zc702evk/linux/zlib/inffast.h
--- /dev/null
@@ -0,0 +1,11 @@
+/* inffast.h -- header to use inffast.c
+ * Copyright (C) 1995-2003, 2010 Mark Adler
+ * For conditions of distribution and use, see copyright notice in zlib.h
+ */
+
+/* WARNING: this file should *not* be used by applications. It is
+ part of the implementation of the compression library and is
+ subject to change. Applications should only use zlib.h.
+ */
+
+void ZLIB_INTERNAL inflate_fast OF((z_streamp strm, unsigned start));
diff --git a/libs/system/zc702evk/linux/zlib/inffixed.h b/libs/system/zc702evk/linux/zlib/inffixed.h
--- /dev/null
@@ -0,0 +1,94 @@
+ /* inffixed.h -- table for decoding fixed codes
+ * Generated automatically by makefixed().
+ */
+
+ /* WARNING: this file should *not* be used by applications. It
+ is part of the implementation of the compression library and
+ is subject to change. Applications should only use zlib.h.
+ */
+
+ static const code lenfix[512] = {
+ {96,7,0},{0,8,80},{0,8,16},{20,8,115},{18,7,31},{0,8,112},{0,8,48},
+ {0,9,192},{16,7,10},{0,8,96},{0,8,32},{0,9,160},{0,8,0},{0,8,128},
+ {0,8,64},{0,9,224},{16,7,6},{0,8,88},{0,8,24},{0,9,144},{19,7,59},
+ {0,8,120},{0,8,56},{0,9,208},{17,7,17},{0,8,104},{0,8,40},{0,9,176},
+ {0,8,8},{0,8,136},{0,8,72},{0,9,240},{16,7,4},{0,8,84},{0,8,20},
+ {21,8,227},{19,7,43},{0,8,116},{0,8,52},{0,9,200},{17,7,13},{0,8,100},
+ {0,8,36},{0,9,168},{0,8,4},{0,8,132},{0,8,68},{0,9,232},{16,7,8},
+ {0,8,92},{0,8,28},{0,9,152},{20,7,83},{0,8,124},{0,8,60},{0,9,216},
+ {18,7,23},{0,8,108},{0,8,44},{0,9,184},{0,8,12},{0,8,140},{0,8,76},
+ {0,9,248},{16,7,3},{0,8,82},{0,8,18},{21,8,163},{19,7,35},{0,8,114},
+ {0,8,50},{0,9,196},{17,7,11},{0,8,98},{0,8,34},{0,9,164},{0,8,2},
+ {0,8,130},{0,8,66},{0,9,228},{16,7,7},{0,8,90},{0,8,26},{0,9,148},
+ {20,7,67},{0,8,122},{0,8,58},{0,9,212},{18,7,19},{0,8,106},{0,8,42},
+ {0,9,180},{0,8,10},{0,8,138},{0,8,74},{0,9,244},{16,7,5},{0,8,86},
+ {0,8,22},{64,8,0},{19,7,51},{0,8,118},{0,8,54},{0,9,204},{17,7,15},
+ {0,8,102},{0,8,38},{0,9,172},{0,8,6},{0,8,134},{0,8,70},{0,9,236},
+ {16,7,9},{0,8,94},{0,8,30},{0,9,156},{20,7,99},{0,8,126},{0,8,62},
+ {0,9,220},{18,7,27},{0,8,110},{0,8,46},{0,9,188},{0,8,14},{0,8,142},
+ {0,8,78},{0,9,252},{96,7,0},{0,8,81},{0,8,17},{21,8,131},{18,7,31},
+ {0,8,113},{0,8,49},{0,9,194},{16,7,10},{0,8,97},{0,8,33},{0,9,162},
+ {0,8,1},{0,8,129},{0,8,65},{0,9,226},{16,7,6},{0,8,89},{0,8,25},
+ {0,9,146},{19,7,59},{0,8,121},{0,8,57},{0,9,210},{17,7,17},{0,8,105},
+ {0,8,41},{0,9,178},{0,8,9},{0,8,137},{0,8,73},{0,9,242},{16,7,4},
+ {0,8,85},{0,8,21},{16,8,258},{19,7,43},{0,8,117},{0,8,53},{0,9,202},
+ {17,7,13},{0,8,101},{0,8,37},{0,9,170},{0,8,5},{0,8,133},{0,8,69},
+ {0,9,234},{16,7,8},{0,8,93},{0,8,29},{0,9,154},{20,7,83},{0,8,125},
+ {0,8,61},{0,9,218},{18,7,23},{0,8,109},{0,8,45},{0,9,186},{0,8,13},
+ {0,8,141},{0,8,77},{0,9,250},{16,7,3},{0,8,83},{0,8,19},{21,8,195},
+ {19,7,35},{0,8,115},{0,8,51},{0,9,198},{17,7,11},{0,8,99},{0,8,35},
+ {0,9,166},{0,8,3},{0,8,131},{0,8,67},{0,9,230},{16,7,7},{0,8,91},
+ {0,8,27},{0,9,150},{20,7,67},{0,8,123},{0,8,59},{0,9,214},{18,7,19},
+ {0,8,107},{0,8,43},{0,9,182},{0,8,11},{0,8,139},{0,8,75},{0,9,246},
+ {16,7,5},{0,8,87},{0,8,23},{64,8,0},{19,7,51},{0,8,119},{0,8,55},
+ {0,9,206},{17,7,15},{0,8,103},{0,8,39},{0,9,174},{0,8,7},{0,8,135},
+ {0,8,71},{0,9,238},{16,7,9},{0,8,95},{0,8,31},{0,9,158},{20,7,99},
+ {0,8,127},{0,8,63},{0,9,222},{18,7,27},{0,8,111},{0,8,47},{0,9,190},
+ {0,8,15},{0,8,143},{0,8,79},{0,9,254},{96,7,0},{0,8,80},{0,8,16},
+ {20,8,115},{18,7,31},{0,8,112},{0,8,48},{0,9,193},{16,7,10},{0,8,96},
+ {0,8,32},{0,9,161},{0,8,0},{0,8,128},{0,8,64},{0,9,225},{16,7,6},
+ {0,8,88},{0,8,24},{0,9,145},{19,7,59},{0,8,120},{0,8,56},{0,9,209},
+ {17,7,17},{0,8,104},{0,8,40},{0,9,177},{0,8,8},{0,8,136},{0,8,72},
+ {0,9,241},{16,7,4},{0,8,84},{0,8,20},{21,8,227},{19,7,43},{0,8,116},
+ {0,8,52},{0,9,201},{17,7,13},{0,8,100},{0,8,36},{0,9,169},{0,8,4},
+ {0,8,132},{0,8,68},{0,9,233},{16,7,8},{0,8,92},{0,8,28},{0,9,153},
+ {20,7,83},{0,8,124},{0,8,60},{0,9,217},{18,7,23},{0,8,108},{0,8,44},
+ {0,9,185},{0,8,12},{0,8,140},{0,8,76},{0,9,249},{16,7,3},{0,8,82},
+ {0,8,18},{21,8,163},{19,7,35},{0,8,114},{0,8,50},{0,9,197},{17,7,11},
+ {0,8,98},{0,8,34},{0,9,165},{0,8,2},{0,8,130},{0,8,66},{0,9,229},
+ {16,7,7},{0,8,90},{0,8,26},{0,9,149},{20,7,67},{0,8,122},{0,8,58},
+ {0,9,213},{18,7,19},{0,8,106},{0,8,42},{0,9,181},{0,8,10},{0,8,138},
+ {0,8,74},{0,9,245},{16,7,5},{0,8,86},{0,8,22},{64,8,0},{19,7,51},
+ {0,8,118},{0,8,54},{0,9,205},{17,7,15},{0,8,102},{0,8,38},{0,9,173},
+ {0,8,6},{0,8,134},{0,8,70},{0,9,237},{16,7,9},{0,8,94},{0,8,30},
+ {0,9,157},{20,7,99},{0,8,126},{0,8,62},{0,9,221},{18,7,27},{0,8,110},
+ {0,8,46},{0,9,189},{0,8,14},{0,8,142},{0,8,78},{0,9,253},{96,7,0},
+ {0,8,81},{0,8,17},{21,8,131},{18,7,31},{0,8,113},{0,8,49},{0,9,195},
+ {16,7,10},{0,8,97},{0,8,33},{0,9,163},{0,8,1},{0,8,129},{0,8,65},
+ {0,9,227},{16,7,6},{0,8,89},{0,8,25},{0,9,147},{19,7,59},{0,8,121},
+ {0,8,57},{0,9,211},{17,7,17},{0,8,105},{0,8,41},{0,9,179},{0,8,9},
+ {0,8,137},{0,8,73},{0,9,243},{16,7,4},{0,8,85},{0,8,21},{16,8,258},
+ {19,7,43},{0,8,117},{0,8,53},{0,9,203},{17,7,13},{0,8,101},{0,8,37},
+ {0,9,171},{0,8,5},{0,8,133},{0,8,69},{0,9,235},{16,7,8},{0,8,93},
+ {0,8,29},{0,9,155},{20,7,83},{0,8,125},{0,8,61},{0,9,219},{18,7,23},
+ {0,8,109},{0,8,45},{0,9,187},{0,8,13},{0,8,141},{0,8,77},{0,9,251},
+ {16,7,3},{0,8,83},{0,8,19},{21,8,195},{19,7,35},{0,8,115},{0,8,51},
+ {0,9,199},{17,7,11},{0,8,99},{0,8,35},{0,9,167},{0,8,3},{0,8,131},
+ {0,8,67},{0,9,231},{16,7,7},{0,8,91},{0,8,27},{0,9,151},{20,7,67},
+ {0,8,123},{0,8,59},{0,9,215},{18,7,19},{0,8,107},{0,8,43},{0,9,183},
+ {0,8,11},{0,8,139},{0,8,75},{0,9,247},{16,7,5},{0,8,87},{0,8,23},
+ {64,8,0},{19,7,51},{0,8,119},{0,8,55},{0,9,207},{17,7,15},{0,8,103},
+ {0,8,39},{0,9,175},{0,8,7},{0,8,135},{0,8,71},{0,9,239},{16,7,9},
+ {0,8,95},{0,8,31},{0,9,159},{20,7,99},{0,8,127},{0,8,63},{0,9,223},
+ {18,7,27},{0,8,111},{0,8,47},{0,9,191},{0,8,15},{0,8,143},{0,8,79},
+ {0,9,255}
+ };
+
+ static const code distfix[32] = {
+ {16,5,1},{23,5,257},{19,5,17},{27,5,4097},{17,5,5},{25,5,1025},
+ {21,5,65},{29,5,16385},{16,5,3},{24,5,513},{20,5,33},{28,5,8193},
+ {18,5,9},{26,5,2049},{22,5,129},{64,5,0},{16,5,2},{23,5,385},
+ {19,5,25},{27,5,6145},{17,5,7},{25,5,1537},{21,5,97},{29,5,24577},
+ {16,5,4},{24,5,769},{20,5,49},{28,5,12289},{18,5,13},{26,5,3073},
+ {22,5,193},{64,5,0}
+ };
diff --git a/libs/system/zc702evk/linux/zlib/inflate.h b/libs/system/zc702evk/linux/zlib/inflate.h
--- /dev/null
@@ -0,0 +1,122 @@
+/* inflate.h -- internal inflate state definition
+ * Copyright (C) 1995-2009 Mark Adler
+ * For conditions of distribution and use, see copyright notice in zlib.h
+ */
+
+/* WARNING: this file should *not* be used by applications. It is
+ part of the implementation of the compression library and is
+ subject to change. Applications should only use zlib.h.
+ */
+
+/* define NO_GZIP when compiling if you want to disable gzip header and
+ trailer decoding by inflate(). NO_GZIP would be used to avoid linking in
+ the crc code when it is not needed. For shared libraries, gzip decoding
+ should be left enabled. */
+#ifndef NO_GZIP
+# define GUNZIP
+#endif
+
+/* Possible inflate modes between inflate() calls */
+typedef enum {
+ HEAD, /* i: waiting for magic header */
+ FLAGS, /* i: waiting for method and flags (gzip) */
+ TIME, /* i: waiting for modification time (gzip) */
+ OS, /* i: waiting for extra flags and operating system (gzip) */
+ EXLEN, /* i: waiting for extra length (gzip) */
+ EXTRA, /* i: waiting for extra bytes (gzip) */
+ NAME, /* i: waiting for end of file name (gzip) */
+ COMMENT, /* i: waiting for end of comment (gzip) */
+ HCRC, /* i: waiting for header crc (gzip) */
+ DICTID, /* i: waiting for dictionary check value */
+ DICT, /* waiting for inflateSetDictionary() call */
+ TYPE, /* i: waiting for type bits, including last-flag bit */
+ TYPEDO, /* i: same, but skip check to exit inflate on new block */
+ STORED, /* i: waiting for stored size (length and complement) */
+ COPY_, /* i/o: same as COPY below, but only first time in */
+ COPY, /* i/o: waiting for input or output to copy stored block */
+ TABLE, /* i: waiting for dynamic block table lengths */
+ LENLENS, /* i: waiting for code length code lengths */
+ CODELENS, /* i: waiting for length/lit and distance code lengths */
+ LEN_, /* i: same as LEN below, but only first time in */
+ LEN, /* i: waiting for length/lit/eob code */
+ LENEXT, /* i: waiting for length extra bits */
+ DIST, /* i: waiting for distance code */
+ DISTEXT, /* i: waiting for distance extra bits */
+ MATCH, /* o: waiting for output space to copy string */
+ LIT, /* o: waiting for output space to write literal */
+ CHECK, /* i: waiting for 32-bit check value */
+ LENGTH, /* i: waiting for 32-bit length (gzip) */
+ DONE, /* finished check, done -- remain here until reset */
+ BAD, /* got a data error -- remain here until reset */
+ MEM, /* got an inflate() memory error -- remain here until reset */
+ SYNC /* looking for synchronization bytes to restart inflate() */
+} inflate_mode;
+
+/*
+ State transitions between above modes -
+
+ (most modes can go to BAD or MEM on error -- not shown for clarity)
+
+ Process header:
+ HEAD -> (gzip) or (zlib) or (raw)
+ (gzip) -> FLAGS -> TIME -> OS -> EXLEN -> EXTRA -> NAME -> COMMENT ->
+ HCRC -> TYPE
+ (zlib) -> DICTID or TYPE
+ DICTID -> DICT -> TYPE
+ (raw) -> TYPEDO
+ Read deflate blocks:
+ TYPE -> TYPEDO -> STORED or TABLE or LEN_ or CHECK
+ STORED -> COPY_ -> COPY -> TYPE
+ TABLE -> LENLENS -> CODELENS -> LEN_
+ LEN_ -> LEN
+ Read deflate codes in fixed or dynamic block:
+ LEN -> LENEXT or LIT or TYPE
+ LENEXT -> DIST -> DISTEXT -> MATCH -> LEN
+ LIT -> LEN
+ Process trailer:
+ CHECK -> LENGTH -> DONE
+ */
+
+/* state maintained between inflate() calls. Approximately 10K bytes. */
+struct inflate_state {
+ inflate_mode mode; /* current inflate mode */
+ int last; /* true if processing last block */
+ int wrap; /* bit 0 true for zlib, bit 1 true for gzip */
+ int havedict; /* true if dictionary provided */
+ int flags; /* gzip header method and flags (0 if zlib) */
+ unsigned dmax; /* zlib header max distance (INFLATE_STRICT) */
+ unsigned long check; /* protected copy of check value */
+ unsigned long total; /* protected copy of output count */
+ gz_headerp head; /* where to save gzip header information */
+ /* sliding window */
+ unsigned wbits; /* log base 2 of requested window size */
+ unsigned wsize; /* window size or zero if not using window */
+ unsigned whave; /* valid bytes in the window */
+ unsigned wnext; /* window write index */
+ unsigned char FAR *window; /* allocated sliding window, if needed */
+ /* bit accumulator */
+ unsigned long hold; /* input bit accumulator */
+ unsigned bits; /* number of bits in "in" */
+ /* for string and stored block copying */
+ unsigned length; /* literal or length of data to copy */
+ unsigned offset; /* distance back to copy string from */
+ /* for table and code decoding */
+ unsigned extra; /* extra bits needed */
+ /* fixed and dynamic code tables */
+ code const FAR *lencode; /* starting table for length/literal codes */
+ code const FAR *distcode; /* starting table for distance codes */
+ unsigned lenbits; /* index bits for lencode */
+ unsigned distbits; /* index bits for distcode */
+ /* dynamic table building */
+ unsigned ncode; /* number of code length code lengths */
+ unsigned nlen; /* number of length code lengths */
+ unsigned ndist; /* number of distance code lengths */
+ unsigned have; /* number of code lengths in lens[] */
+ code FAR *next; /* next available space in codes[] */
+ unsigned short lens[320]; /* temporary storage for code lengths */
+ unsigned short work[288]; /* work area for code table building */
+ code codes[ENOUGH]; /* space for code tables */
+ int sane; /* if false, allow invalid distance too far */
+ int back; /* bits back of last unprocessed length/lit */
+ unsigned was; /* initial length of match */
+};
diff --git a/libs/system/zc702evk/linux/zlib/inftrees.h b/libs/system/zc702evk/linux/zlib/inftrees.h
--- /dev/null
@@ -0,0 +1,62 @@
+/* inftrees.h -- header to use inftrees.c
+ * Copyright (C) 1995-2005, 2010 Mark Adler
+ * For conditions of distribution and use, see copyright notice in zlib.h
+ */
+
+/* WARNING: this file should *not* be used by applications. It is
+ part of the implementation of the compression library and is
+ subject to change. Applications should only use zlib.h.
+ */
+
+/* Structure for decoding tables. Each entry provides either the
+ information needed to do the operation requested by the code that
+ indexed that table entry, or it provides a pointer to another
+ table that indexes more bits of the code. op indicates whether
+ the entry is a pointer to another table, a literal, a length or
+ distance, an end-of-block, or an invalid code. For a table
+ pointer, the low four bits of op is the number of index bits of
+ that table. For a length or distance, the low four bits of op
+ is the number of extra bits to get after the code. bits is
+ the number of bits in this code or part of the code to drop off
+ of the bit buffer. val is the actual byte to output in the case
+ of a literal, the base length or distance, or the offset from
+ the current table to the next table. Each entry is four bytes. */
+typedef struct {
+ unsigned char op; /* operation, extra bits, table bits */
+ unsigned char bits; /* bits in this part of the code */
+ unsigned short val; /* offset in table or code value */
+} code;
+
+/* op values as set by inflate_table():
+ 00000000 - literal
+ 0000tttt - table link, tttt != 0 is the number of table index bits
+ 0001eeee - length or distance, eeee is the number of extra bits
+ 01100000 - end of block
+ 01000000 - invalid code
+ */
+
+/* Maximum size of the dynamic table. The maximum number of code structures is
+ 1444, which is the sum of 852 for literal/length codes and 592 for distance
+ codes. These values were found by exhaustive searches using the program
+ examples/enough.c found in the zlib distribtution. The arguments to that
+ program are the number of symbols, the initial root table size, and the
+ maximum bit length of a code. "enough 286 9 15" for literal/length codes
+ returns returns 852, and "enough 30 6 15" for distance codes returns 592.
+ The initial root table size (9 or 6) is found in the fifth argument of the
+ inflate_table() calls in inflate.c and infback.c. If the root table size is
+ changed, then these maximum sizes would be need to be recalculated and
+ updated. */
+#define ENOUGH_LENS 852
+#define ENOUGH_DISTS 592
+#define ENOUGH (ENOUGH_LENS+ENOUGH_DISTS)
+
+/* Type of code to build for inflate_table() */
+typedef enum {
+ CODES,
+ LENS,
+ DISTS
+} codetype;
+
+int ZLIB_INTERNAL inflate_table OF((codetype type, unsigned short FAR *lens,
+ unsigned codes, code FAR * FAR *table,
+ unsigned FAR *bits, unsigned short FAR *work));
diff --git a/libs/system/zc702evk/linux/zlib/trees.h b/libs/system/zc702evk/linux/zlib/trees.h
--- /dev/null
@@ -0,0 +1,128 @@
+/* header created automatically with -DGEN_TREES_H */
+
+local const ct_data static_ltree[L_CODES+2] = {
+{{ 12},{ 8}}, {{140},{ 8}}, {{ 76},{ 8}}, {{204},{ 8}}, {{ 44},{ 8}},
+{{172},{ 8}}, {{108},{ 8}}, {{236},{ 8}}, {{ 28},{ 8}}, {{156},{ 8}},
+{{ 92},{ 8}}, {{220},{ 8}}, {{ 60},{ 8}}, {{188},{ 8}}, {{124},{ 8}},
+{{252},{ 8}}, {{ 2},{ 8}}, {{130},{ 8}}, {{ 66},{ 8}}, {{194},{ 8}},
+{{ 34},{ 8}}, {{162},{ 8}}, {{ 98},{ 8}}, {{226},{ 8}}, {{ 18},{ 8}},
+{{146},{ 8}}, {{ 82},{ 8}}, {{210},{ 8}}, {{ 50},{ 8}}, {{178},{ 8}},
+{{114},{ 8}}, {{242},{ 8}}, {{ 10},{ 8}}, {{138},{ 8}}, {{ 74},{ 8}},
+{{202},{ 8}}, {{ 42},{ 8}}, {{170},{ 8}}, {{106},{ 8}}, {{234},{ 8}},
+{{ 26},{ 8}}, {{154},{ 8}}, {{ 90},{ 8}}, {{218},{ 8}}, {{ 58},{ 8}},
+{{186},{ 8}}, {{122},{ 8}}, {{250},{ 8}}, {{ 6},{ 8}}, {{134},{ 8}},
+{{ 70},{ 8}}, {{198},{ 8}}, {{ 38},{ 8}}, {{166},{ 8}}, {{102},{ 8}},
+{{230},{ 8}}, {{ 22},{ 8}}, {{150},{ 8}}, {{ 86},{ 8}}, {{214},{ 8}},
+{{ 54},{ 8}}, {{182},{ 8}}, {{118},{ 8}}, {{246},{ 8}}, {{ 14},{ 8}},
+{{142},{ 8}}, {{ 78},{ 8}}, {{206},{ 8}}, {{ 46},{ 8}}, {{174},{ 8}},
+{{110},{ 8}}, {{238},{ 8}}, {{ 30},{ 8}}, {{158},{ 8}}, {{ 94},{ 8}},
+{{222},{ 8}}, {{ 62},{ 8}}, {{190},{ 8}}, {{126},{ 8}}, {{254},{ 8}},
+{{ 1},{ 8}}, {{129},{ 8}}, {{ 65},{ 8}}, {{193},{ 8}}, {{ 33},{ 8}},
+{{161},{ 8}}, {{ 97},{ 8}}, {{225},{ 8}}, {{ 17},{ 8}}, {{145},{ 8}},
+{{ 81},{ 8}}, {{209},{ 8}}, {{ 49},{ 8}}, {{177},{ 8}}, {{113},{ 8}},
+{{241},{ 8}}, {{ 9},{ 8}}, {{137},{ 8}}, {{ 73},{ 8}}, {{201},{ 8}},
+{{ 41},{ 8}}, {{169},{ 8}}, {{105},{ 8}}, {{233},{ 8}}, {{ 25},{ 8}},
+{{153},{ 8}}, {{ 89},{ 8}}, {{217},{ 8}}, {{ 57},{ 8}}, {{185},{ 8}},
+{{121},{ 8}}, {{249},{ 8}}, {{ 5},{ 8}}, {{133},{ 8}}, {{ 69},{ 8}},
+{{197},{ 8}}, {{ 37},{ 8}}, {{165},{ 8}}, {{101},{ 8}}, {{229},{ 8}},
+{{ 21},{ 8}}, {{149},{ 8}}, {{ 85},{ 8}}, {{213},{ 8}}, {{ 53},{ 8}},
+{{181},{ 8}}, {{117},{ 8}}, {{245},{ 8}}, {{ 13},{ 8}}, {{141},{ 8}},
+{{ 77},{ 8}}, {{205},{ 8}}, {{ 45},{ 8}}, {{173},{ 8}}, {{109},{ 8}},
+{{237},{ 8}}, {{ 29},{ 8}}, {{157},{ 8}}, {{ 93},{ 8}}, {{221},{ 8}},
+{{ 61},{ 8}}, {{189},{ 8}}, {{125},{ 8}}, {{253},{ 8}}, {{ 19},{ 9}},
+{{275},{ 9}}, {{147},{ 9}}, {{403},{ 9}}, {{ 83},{ 9}}, {{339},{ 9}},
+{{211},{ 9}}, {{467},{ 9}}, {{ 51},{ 9}}, {{307},{ 9}}, {{179},{ 9}},
+{{435},{ 9}}, {{115},{ 9}}, {{371},{ 9}}, {{243},{ 9}}, {{499},{ 9}},
+{{ 11},{ 9}}, {{267},{ 9}}, {{139},{ 9}}, {{395},{ 9}}, {{ 75},{ 9}},
+{{331},{ 9}}, {{203},{ 9}}, {{459},{ 9}}, {{ 43},{ 9}}, {{299},{ 9}},
+{{171},{ 9}}, {{427},{ 9}}, {{107},{ 9}}, {{363},{ 9}}, {{235},{ 9}},
+{{491},{ 9}}, {{ 27},{ 9}}, {{283},{ 9}}, {{155},{ 9}}, {{411},{ 9}},
+{{ 91},{ 9}}, {{347},{ 9}}, {{219},{ 9}}, {{475},{ 9}}, {{ 59},{ 9}},
+{{315},{ 9}}, {{187},{ 9}}, {{443},{ 9}}, {{123},{ 9}}, {{379},{ 9}},
+{{251},{ 9}}, {{507},{ 9}}, {{ 7},{ 9}}, {{263},{ 9}}, {{135},{ 9}},
+{{391},{ 9}}, {{ 71},{ 9}}, {{327},{ 9}}, {{199},{ 9}}, {{455},{ 9}},
+{{ 39},{ 9}}, {{295},{ 9}}, {{167},{ 9}}, {{423},{ 9}}, {{103},{ 9}},
+{{359},{ 9}}, {{231},{ 9}}, {{487},{ 9}}, {{ 23},{ 9}}, {{279},{ 9}},
+{{151},{ 9}}, {{407},{ 9}}, {{ 87},{ 9}}, {{343},{ 9}}, {{215},{ 9}},
+{{471},{ 9}}, {{ 55},{ 9}}, {{311},{ 9}}, {{183},{ 9}}, {{439},{ 9}},
+{{119},{ 9}}, {{375},{ 9}}, {{247},{ 9}}, {{503},{ 9}}, {{ 15},{ 9}},
+{{271},{ 9}}, {{143},{ 9}}, {{399},{ 9}}, {{ 79},{ 9}}, {{335},{ 9}},
+{{207},{ 9}}, {{463},{ 9}}, {{ 47},{ 9}}, {{303},{ 9}}, {{175},{ 9}},
+{{431},{ 9}}, {{111},{ 9}}, {{367},{ 9}}, {{239},{ 9}}, {{495},{ 9}},
+{{ 31},{ 9}}, {{287},{ 9}}, {{159},{ 9}}, {{415},{ 9}}, {{ 95},{ 9}},
+{{351},{ 9}}, {{223},{ 9}}, {{479},{ 9}}, {{ 63},{ 9}}, {{319},{ 9}},
+{{191},{ 9}}, {{447},{ 9}}, {{127},{ 9}}, {{383},{ 9}}, {{255},{ 9}},
+{{511},{ 9}}, {{ 0},{ 7}}, {{ 64},{ 7}}, {{ 32},{ 7}}, {{ 96},{ 7}},
+{{ 16},{ 7}}, {{ 80},{ 7}}, {{ 48},{ 7}}, {{112},{ 7}}, {{ 8},{ 7}},
+{{ 72},{ 7}}, {{ 40},{ 7}}, {{104},{ 7}}, {{ 24},{ 7}}, {{ 88},{ 7}},
+{{ 56},{ 7}}, {{120},{ 7}}, {{ 4},{ 7}}, {{ 68},{ 7}}, {{ 36},{ 7}},
+{{100},{ 7}}, {{ 20},{ 7}}, {{ 84},{ 7}}, {{ 52},{ 7}}, {{116},{ 7}},
+{{ 3},{ 8}}, {{131},{ 8}}, {{ 67},{ 8}}, {{195},{ 8}}, {{ 35},{ 8}},
+{{163},{ 8}}, {{ 99},{ 8}}, {{227},{ 8}}
+};
+
+local const ct_data static_dtree[D_CODES] = {
+{{ 0},{ 5}}, {{16},{ 5}}, {{ 8},{ 5}}, {{24},{ 5}}, {{ 4},{ 5}},
+{{20},{ 5}}, {{12},{ 5}}, {{28},{ 5}}, {{ 2},{ 5}}, {{18},{ 5}},
+{{10},{ 5}}, {{26},{ 5}}, {{ 6},{ 5}}, {{22},{ 5}}, {{14},{ 5}},
+{{30},{ 5}}, {{ 1},{ 5}}, {{17},{ 5}}, {{ 9},{ 5}}, {{25},{ 5}},
+{{ 5},{ 5}}, {{21},{ 5}}, {{13},{ 5}}, {{29},{ 5}}, {{ 3},{ 5}},
+{{19},{ 5}}, {{11},{ 5}}, {{27},{ 5}}, {{ 7},{ 5}}, {{23},{ 5}}
+};
+
+const uch ZLIB_INTERNAL _dist_code[DIST_CODE_LEN] = {
+ 0, 1, 2, 3, 4, 4, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8,
+ 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10,
+10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
+11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
+12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 13, 13, 13, 13,
+13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
+13, 13, 13, 13, 13, 13, 13, 13, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
+14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
+14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
+14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 15, 15, 15, 15, 15, 15, 15, 15,
+15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
+15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
+15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 0, 0, 16, 17,
+18, 18, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 22, 22, 22, 22, 22, 22, 22, 22,
+23, 23, 23, 23, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
+24, 24, 24, 24, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
+26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26,
+26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 27, 27, 27, 27, 27, 27, 27, 27,
+27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,
+27, 27, 27, 27, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
+28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
+28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
+28, 28, 28, 28, 28, 28, 28, 28, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
+29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
+29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
+29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29
+};
+
+const uch ZLIB_INTERNAL _length_code[MAX_MATCH-MIN_MATCH+1]= {
+ 0, 1, 2, 3, 4, 5, 6, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 12, 12,
+13, 13, 13, 13, 14, 14, 14, 14, 15, 15, 15, 15, 16, 16, 16, 16, 16, 16, 16, 16,
+17, 17, 17, 17, 17, 17, 17, 17, 18, 18, 18, 18, 18, 18, 18, 18, 19, 19, 19, 19,
+19, 19, 19, 19, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
+21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 22, 22, 22, 22,
+22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 23, 23, 23, 23, 23, 23, 23, 23,
+23, 23, 23, 23, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
+24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
+25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
+25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 26, 26, 26, 26, 26, 26, 26, 26,
+26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26,
+26, 26, 26, 26, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,
+27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 28
+};
+
+local const int base_length[LENGTH_CODES] = {
+0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 12, 14, 16, 20, 24, 28, 32, 40, 48, 56,
+64, 80, 96, 112, 128, 160, 192, 224, 0
+};
+
+local const int base_dist[D_CODES] = {
+ 0, 1, 2, 3, 4, 6, 8, 12, 16, 24,
+ 32, 48, 64, 96, 128, 192, 256, 384, 512, 768,
+ 1024, 1536, 2048, 3072, 4096, 6144, 8192, 12288, 16384, 24576
+};
+
diff --git a/libs/system/zc702evk/linux/zlib/zconf.h b/libs/system/zc702evk/linux/zlib/zconf.h
--- /dev/null
@@ -0,0 +1,428 @@
+/* zconf.h -- configuration of the zlib compression library
+ * Copyright (C) 1995-2010 Jean-loup Gailly.
+ * For conditions of distribution and use, see copyright notice in zlib.h
+ */
+
+/* @(#) $Id$ */
+
+#ifndef ZCONF_H
+#define ZCONF_H
+
+/*
+ * If you *really* need a unique prefix for all types and library functions,
+ * compile with -DZ_PREFIX. The "standard" zlib should be compiled without it.
+ * Even better than compiling with -DZ_PREFIX would be to use configure to set
+ * this permanently in zconf.h using "./configure --zprefix".
+ */
+#ifdef Z_PREFIX /* may be set to #if 1 by ./configure */
+
+/* all linked symbols */
+# define _dist_code z__dist_code
+# define _length_code z__length_code
+# define _tr_align z__tr_align
+# define _tr_flush_block z__tr_flush_block
+# define _tr_init z__tr_init
+# define _tr_stored_block z__tr_stored_block
+# define _tr_tally z__tr_tally
+# define adler32 z_adler32
+# define adler32_combine z_adler32_combine
+# define adler32_combine64 z_adler32_combine64
+# define compress z_compress
+# define compress2 z_compress2
+# define compressBound z_compressBound
+# define crc32 z_crc32
+# define crc32_combine z_crc32_combine
+# define crc32_combine64 z_crc32_combine64
+# define deflate z_deflate
+# define deflateBound z_deflateBound
+# define deflateCopy z_deflateCopy
+# define deflateEnd z_deflateEnd
+# define deflateInit2_ z_deflateInit2_
+# define deflateInit_ z_deflateInit_
+# define deflateParams z_deflateParams
+# define deflatePrime z_deflatePrime
+# define deflateReset z_deflateReset
+# define deflateSetDictionary z_deflateSetDictionary
+# define deflateSetHeader z_deflateSetHeader
+# define deflateTune z_deflateTune
+# define deflate_copyright z_deflate_copyright
+# define get_crc_table z_get_crc_table
+# define gz_error z_gz_error
+# define gz_intmax z_gz_intmax
+# define gz_strwinerror z_gz_strwinerror
+# define gzbuffer z_gzbuffer
+# define gzclearerr z_gzclearerr
+# define gzclose z_gzclose
+# define gzclose_r z_gzclose_r
+# define gzclose_w z_gzclose_w
+# define gzdirect z_gzdirect
+# define gzdopen z_gzdopen
+# define gzeof z_gzeof
+# define gzerror z_gzerror
+# define gzflush z_gzflush
+# define gzgetc z_gzgetc
+# define gzgets z_gzgets
+# define gzoffset z_gzoffset
+# define gzoffset64 z_gzoffset64
+# define gzopen z_gzopen
+# define gzopen64 z_gzopen64
+# define gzprintf z_gzprintf
+# define gzputc z_gzputc
+# define gzputs z_gzputs
+# define gzread z_gzread
+# define gzrewind z_gzrewind
+# define gzseek z_gzseek
+# define gzseek64 z_gzseek64
+# define gzsetparams z_gzsetparams
+# define gztell z_gztell
+# define gztell64 z_gztell64
+# define gzungetc z_gzungetc
+# define gzwrite z_gzwrite
+# define inflate z_inflate
+# define inflateBack z_inflateBack
+# define inflateBackEnd z_inflateBackEnd
+# define inflateBackInit_ z_inflateBackInit_
+# define inflateCopy z_inflateCopy
+# define inflateEnd z_inflateEnd
+# define inflateGetHeader z_inflateGetHeader
+# define inflateInit2_ z_inflateInit2_
+# define inflateInit_ z_inflateInit_
+# define inflateMark z_inflateMark
+# define inflatePrime z_inflatePrime
+# define inflateReset z_inflateReset
+# define inflateReset2 z_inflateReset2
+# define inflateSetDictionary z_inflateSetDictionary
+# define inflateSync z_inflateSync
+# define inflateSyncPoint z_inflateSyncPoint
+# define inflateUndermine z_inflateUndermine
+# define inflate_copyright z_inflate_copyright
+# define inflate_fast z_inflate_fast
+# define inflate_table z_inflate_table
+# define uncompress z_uncompress
+# define zError z_zError
+# define zcalloc z_zcalloc
+# define zcfree z_zcfree
+# define zlibCompileFlags z_zlibCompileFlags
+# define zlibVersion z_zlibVersion
+
+/* all zlib typedefs in zlib.h and zconf.h */
+# define Byte z_Byte
+# define Bytef z_Bytef
+# define alloc_func z_alloc_func
+# define charf z_charf
+# define free_func z_free_func
+# define gzFile z_gzFile
+# define gz_header z_gz_header
+# define gz_headerp z_gz_headerp
+# define in_func z_in_func
+# define intf z_intf
+# define out_func z_out_func
+# define uInt z_uInt
+# define uIntf z_uIntf
+# define uLong z_uLong
+# define uLongf z_uLongf
+# define voidp z_voidp
+# define voidpc z_voidpc
+# define voidpf z_voidpf
+
+/* all zlib structs in zlib.h and zconf.h */
+# define gz_header_s z_gz_header_s
+# define internal_state z_internal_state
+
+#endif
+
+#if defined(__MSDOS__) && !defined(MSDOS)
+# define MSDOS
+#endif
+#if (defined(OS_2) || defined(__OS2__)) && !defined(OS2)
+# define OS2
+#endif
+#if defined(_WINDOWS) && !defined(WINDOWS)
+# define WINDOWS
+#endif
+#if defined(_WIN32) || defined(_WIN32_WCE) || defined(__WIN32__)
+# ifndef WIN32
+# define WIN32
+# endif
+#endif
+#if (defined(MSDOS) || defined(OS2) || defined(WINDOWS)) && !defined(WIN32)
+# if !defined(__GNUC__) && !defined(__FLAT__) && !defined(__386__)
+# ifndef SYS16BIT
+# define SYS16BIT
+# endif
+# endif
+#endif
+
+/*
+ * Compile with -DMAXSEG_64K if the alloc function cannot allocate more
+ * than 64k bytes at a time (needed on systems with 16-bit int).
+ */
+#ifdef SYS16BIT
+# define MAXSEG_64K
+#endif
+#ifdef MSDOS
+# define UNALIGNED_OK
+#endif
+
+#ifdef __STDC_VERSION__
+# ifndef STDC
+# define STDC
+# endif
+# if __STDC_VERSION__ >= 199901L
+# ifndef STDC99
+# define STDC99
+# endif
+# endif
+#endif
+#if !defined(STDC) && (defined(__STDC__) || defined(__cplusplus))
+# define STDC
+#endif
+#if !defined(STDC) && (defined(__GNUC__) || defined(__BORLANDC__))
+# define STDC
+#endif
+#if !defined(STDC) && (defined(MSDOS) || defined(WINDOWS) || defined(WIN32))
+# define STDC
+#endif
+#if !defined(STDC) && (defined(OS2) || defined(__HOS_AIX__))
+# define STDC
+#endif
+
+#if defined(__OS400__) && !defined(STDC) /* iSeries (formerly AS/400). */
+# define STDC
+#endif
+
+#ifndef STDC
+# ifndef const /* cannot use !defined(STDC) && !defined(const) on Mac */
+# define const /* note: need a more gentle solution here */
+# endif
+#endif
+
+/* Some Mac compilers merge all .h files incorrectly: */
+#if defined(__MWERKS__)||defined(applec)||defined(THINK_C)||defined(__SC__)
+# define NO_DUMMY_DECL
+#endif
+
+/* Maximum value for memLevel in deflateInit2 */
+#ifndef MAX_MEM_LEVEL
+# ifdef MAXSEG_64K
+# define MAX_MEM_LEVEL 8
+# else
+# define MAX_MEM_LEVEL 9
+# endif
+#endif
+
+/* Maximum value for windowBits in deflateInit2 and inflateInit2.
+ * WARNING: reducing MAX_WBITS makes minigzip unable to extract .gz files
+ * created by gzip. (Files created by minigzip can still be extracted by
+ * gzip.)
+ */
+#ifndef MAX_WBITS
+# define MAX_WBITS 15 /* 32K LZ77 window */
+#endif
+
+/* The memory requirements for deflate are (in bytes):
+ (1 << (windowBits+2)) + (1 << (memLevel+9))
+ that is: 128K for windowBits=15 + 128K for memLevel = 8 (default values)
+ plus a few kilobytes for small objects. For example, if you want to reduce
+ the default memory requirements from 256K to 128K, compile with
+ make CFLAGS="-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7"
+ Of course this will generally degrade compression (there's no free lunch).
+
+ The memory requirements for inflate are (in bytes) 1 << windowBits
+ that is, 32K for windowBits=15 (default value) plus a few kilobytes
+ for small objects.
+*/
+
+ /* Type declarations */
+
+#ifndef OF /* function prototypes */
+# ifdef STDC
+# define OF(args) args
+# else
+# define OF(args) ()
+# endif
+#endif
+
+/* The following definitions for FAR are needed only for MSDOS mixed
+ * model programming (small or medium model with some far allocations).
+ * This was tested only with MSC; for other MSDOS compilers you may have
+ * to define NO_MEMCPY in zutil.h. If you don't need the mixed model,
+ * just define FAR to be empty.
+ */
+#ifdef SYS16BIT
+# if defined(M_I86SM) || defined(M_I86MM)
+ /* MSC small or medium model */
+# define SMALL_MEDIUM
+# ifdef _MSC_VER
+# define FAR _far
+# else
+# define FAR far
+# endif
+# endif
+# if (defined(__SMALL__) || defined(__MEDIUM__))
+ /* Turbo C small or medium model */
+# define SMALL_MEDIUM
+# ifdef __BORLANDC__
+# define FAR _far
+# else
+# define FAR far
+# endif
+# endif
+#endif
+
+#if defined(WINDOWS) || defined(WIN32)
+ /* If building or using zlib as a DLL, define ZLIB_DLL.
+ * This is not mandatory, but it offers a little performance increase.
+ */
+# ifdef ZLIB_DLL
+# if defined(WIN32) && (!defined(__BORLANDC__) || (__BORLANDC__ >= 0x500))
+# ifdef ZLIB_INTERNAL
+# define ZEXTERN extern __declspec(dllexport)
+# else
+# define ZEXTERN extern __declspec(dllimport)
+# endif
+# endif
+# endif /* ZLIB_DLL */
+ /* If building or using zlib with the WINAPI/WINAPIV calling convention,
+ * define ZLIB_WINAPI.
+ * Caution: the standard ZLIB1.DLL is NOT compiled using ZLIB_WINAPI.
+ */
+# ifdef ZLIB_WINAPI
+# ifdef FAR
+# undef FAR
+# endif
+# include <windows.h>
+ /* No need for _export, use ZLIB.DEF instead. */
+ /* For complete Windows compatibility, use WINAPI, not __stdcall. */
+# define ZEXPORT WINAPI
+# ifdef WIN32
+# define ZEXPORTVA WINAPIV
+# else
+# define ZEXPORTVA FAR CDECL
+# endif
+# endif
+#endif
+
+#if defined (__BEOS__)
+# ifdef ZLIB_DLL
+# ifdef ZLIB_INTERNAL
+# define ZEXPORT __declspec(dllexport)
+# define ZEXPORTVA __declspec(dllexport)
+# else
+# define ZEXPORT __declspec(dllimport)
+# define ZEXPORTVA __declspec(dllimport)
+# endif
+# endif
+#endif
+
+#ifndef ZEXTERN
+# define ZEXTERN extern
+#endif
+#ifndef ZEXPORT
+# define ZEXPORT
+#endif
+#ifndef ZEXPORTVA
+# define ZEXPORTVA
+#endif
+
+#ifndef FAR
+# define FAR
+#endif
+
+#if !defined(__MACTYPES__)
+typedef unsigned char Byte; /* 8 bits */
+#endif
+typedef unsigned int uInt; /* 16 bits or more */
+typedef unsigned long uLong; /* 32 bits or more */
+
+#ifdef SMALL_MEDIUM
+ /* Borland C/C++ and some old MSC versions ignore FAR inside typedef */
+# define Bytef Byte FAR
+#else
+ typedef Byte FAR Bytef;
+#endif
+typedef char FAR charf;
+typedef int FAR intf;
+typedef uInt FAR uIntf;
+typedef uLong FAR uLongf;
+
+#ifdef STDC
+ typedef void const *voidpc;
+ typedef void FAR *voidpf;
+ typedef void *voidp;
+#else
+ typedef Byte const *voidpc;
+ typedef Byte FAR *voidpf;
+ typedef Byte *voidp;
+#endif
+
+#ifdef HAVE_UNISTD_H /* may be set to #if 1 by ./configure */
+# define Z_HAVE_UNISTD_H
+#endif
+
+#ifdef STDC
+//# include <sys/types.h> /* for off_t */
+#endif
+
+/* a little trick to accommodate both "#define _LARGEFILE64_SOURCE" and
+ * "#define _LARGEFILE64_SOURCE 1" as requesting 64-bit operations, (even
+ * though the former does not conform to the LFS document), but considering
+ * both "#undef _LARGEFILE64_SOURCE" and "#define _LARGEFILE64_SOURCE 0" as
+ * equivalently requesting no 64-bit operations
+ */
+#if -_LARGEFILE64_SOURCE - -1 == 1
+# undef _LARGEFILE64_SOURCE
+#endif
+
+#if defined(Z_HAVE_UNISTD_H) || defined(_LARGEFILE64_SOURCE)
+//# include <unistd.h> /* for SEEK_* and off_t */
+# ifdef VMS
+//# include <unixio.h> /* for off_t */
+# endif
+# ifndef z_off_t
+# define z_off_t long
+# endif
+#endif
+
+#ifndef SEEK_SET
+# define SEEK_SET 0 /* Seek from beginning of file. */
+# define SEEK_CUR 1 /* Seek from current position. */
+# define SEEK_END 2 /* Set file pointer to EOF plus "offset" */
+#endif
+
+#ifndef z_off_t
+# define z_off_t long
+#endif
+
+#if defined(_LARGEFILE64_SOURCE) && _LFS64_LARGEFILE-0
+# define z_off64_t off64_t
+#else
+# define z_off64_t z_off_t
+#endif
+
+#if defined(__OS400__)
+# define NO_vsnprintf
+#endif
+
+#if defined(__MVS__)
+# define NO_vsnprintf
+#endif
+
+/* MVS linker does not support external names larger than 8 bytes */
+#if defined(__MVS__)
+ #pragma map(deflateInit_,"DEIN")
+ #pragma map(deflateInit2_,"DEIN2")
+ #pragma map(deflateEnd,"DEEND")
+ #pragma map(deflateBound,"DEBND")
+ #pragma map(inflateInit_,"ININ")
+ #pragma map(inflateInit2_,"ININ2")
+ #pragma map(inflateEnd,"INEND")
+ #pragma map(inflateSync,"INSY")
+ #pragma map(inflateSetDictionary,"INSEDI")
+ #pragma map(compressBound,"CMBND")
+ #pragma map(inflate_table,"INTABL")
+ #pragma map(inflate_fast,"INFA")
+ #pragma map(inflate_copyright,"INCOPY")
+#endif
+
+#endif /* ZCONF_H */
diff --git a/libs/system/zc702evk/linux/zlib/zlib.h b/libs/system/zc702evk/linux/zlib/zlib.h
--- /dev/null
@@ -0,0 +1,1613 @@
+/* zlib.h -- interface of the 'zlib' general purpose compression library
+ version 1.2.5, April 19th, 2010
+
+ Copyright (C) 1995-2010 Jean-loup Gailly and Mark Adler
+
+ This software is provided 'as-is', without any express or implied
+ warranty. In no event will the authors be held liable for any damages
+ arising from the use of this software.
+
+ Permission is granted to anyone to use this software for any purpose,
+ including commercial applications, and to alter it and redistribute it
+ freely, subject to the following restrictions:
+
+ 1. The origin of this software must not be misrepresented; you must not
+ claim that you wrote the original software. If you use this software
+ in a product, an acknowledgment in the product documentation would be
+ appreciated but is not required.
+ 2. Altered source versions must be plainly marked as such, and must not be
+ misrepresented as being the original software.
+ 3. This notice may not be removed or altered from any source distribution.
+
+ Jean-loup Gailly Mark Adler
+ jloup@gzip.org madler@alumni.caltech.edu
+
+
+ The data format used by the zlib library is described by RFCs (Request for
+ Comments) 1950 to 1952 in the files http://www.ietf.org/rfc/rfc1950.txt
+ (zlib format), rfc1951.txt (deflate format) and rfc1952.txt (gzip format).
+*/
+
+#ifndef ZLIB_H
+#define ZLIB_H
+
+#include "zconf.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define ZLIB_VERSION "1.2.5"
+#define ZLIB_VERNUM 0x1250
+#define ZLIB_VER_MAJOR 1
+#define ZLIB_VER_MINOR 2
+#define ZLIB_VER_REVISION 5
+#define ZLIB_VER_SUBREVISION 0
+
+/*
+ The 'zlib' compression library provides in-memory compression and
+ decompression functions, including integrity checks of the uncompressed data.
+ This version of the library supports only one compression method (deflation)
+ but other algorithms will be added later and will have the same stream
+ interface.
+
+ Compression can be done in a single step if the buffers are large enough,
+ or can be done by repeated calls of the compression function. In the latter
+ case, the application must provide more input and/or consume the output
+ (providing more output space) before each call.
+
+ The compressed data format used by default by the in-memory functions is
+ the zlib format, which is a zlib wrapper documented in RFC 1950, wrapped
+ around a deflate stream, which is itself documented in RFC 1951.
+
+ The library also supports reading and writing files in gzip (.gz) format
+ with an interface similar to that of stdio using the functions that start
+ with "gz". The gzip format is different from the zlib format. gzip is a
+ gzip wrapper, documented in RFC 1952, wrapped around a deflate stream.
+
+ This library can optionally read and write gzip streams in memory as well.
+
+ The zlib format was designed to be compact and fast for use in memory
+ and on communications channels. The gzip format was designed for single-
+ file compression on file systems, has a larger header than zlib to maintain
+ directory information, and uses a different, slower check method than zlib.
+
+ The library does not install any signal handler. The decoder checks
+ the consistency of the compressed data, so the library should never crash
+ even in case of corrupted input.
+*/
+
+typedef voidpf (*alloc_func) OF((voidpf opaque, uInt items, uInt size));
+typedef void (*free_func) OF((voidpf opaque, voidpf address));
+
+struct internal_state;
+
+typedef struct z_stream_s {
+ Bytef *next_in; /* next input byte */
+ uInt avail_in; /* number of bytes available at next_in */
+ uLong total_in; /* total nb of input bytes read so far */
+
+ Bytef *next_out; /* next output byte should be put there */
+ uInt avail_out; /* remaining free space at next_out */
+ uLong total_out; /* total nb of bytes output so far */
+
+ char *msg; /* last error message, NULL if no error */
+ struct internal_state FAR *state; /* not visible by applications */
+
+ alloc_func zalloc; /* used to allocate the internal state */
+ free_func zfree; /* used to free the internal state */
+ voidpf opaque; /* private data object passed to zalloc and zfree */
+
+ int data_type; /* best guess about the data type: binary or text */
+ uLong adler; /* adler32 value of the uncompressed data */
+ uLong reserved; /* reserved for future use */
+} z_stream;
+
+typedef z_stream FAR *z_streamp;
+
+/*
+ gzip header information passed to and from zlib routines. See RFC 1952
+ for more details on the meanings of these fields.
+*/
+typedef struct gz_header_s {
+ int text; /* true if compressed data believed to be text */
+ uLong time; /* modification time */
+ int xflags; /* extra flags (not used when writing a gzip file) */
+ int os; /* operating system */
+ Bytef *extra; /* pointer to extra field or Z_NULL if none */
+ uInt extra_len; /* extra field length (valid if extra != Z_NULL) */
+ uInt extra_max; /* space at extra (only when reading header) */
+ Bytef *name; /* pointer to zero-terminated file name or Z_NULL */
+ uInt name_max; /* space at name (only when reading header) */
+ Bytef *comment; /* pointer to zero-terminated comment or Z_NULL */
+ uInt comm_max; /* space at comment (only when reading header) */
+ int hcrc; /* true if there was or will be a header crc */
+ int done; /* true when done reading gzip header (not used
+ when writing a gzip file) */
+} gz_header;
+
+typedef gz_header FAR *gz_headerp;
+
+/*
+ The application must update next_in and avail_in when avail_in has dropped
+ to zero. It must update next_out and avail_out when avail_out has dropped
+ to zero. The application must initialize zalloc, zfree and opaque before
+ calling the init function. All other fields are set by the compression
+ library and must not be updated by the application.
+
+ The opaque value provided by the application will be passed as the first
+ parameter for calls of zalloc and zfree. This can be useful for custom
+ memory management. The compression library attaches no meaning to the
+ opaque value.
+
+ zalloc must return Z_NULL if there is not enough memory for the object.
+ If zlib is used in a multi-threaded application, zalloc and zfree must be
+ thread safe.
+
+ On 16-bit systems, the functions zalloc and zfree must be able to allocate
+ exactly 65536 bytes, but will not be required to allocate more than this if
+ the symbol MAXSEG_64K is defined (see zconf.h). WARNING: On MSDOS, pointers
+ returned by zalloc for objects of exactly 65536 bytes *must* have their
+ offset normalized to zero. The default allocation function provided by this
+ library ensures this (see zutil.c). To reduce memory requirements and avoid
+ any allocation of 64K objects, at the expense of compression ratio, compile
+ the library with -DMAX_WBITS=14 (see zconf.h).
+
+ The fields total_in and total_out can be used for statistics or progress
+ reports. After compression, total_in holds the total size of the
+ uncompressed data and may be saved for use in the decompressor (particularly
+ if the decompressor wants to decompress everything in a single step).
+*/
+
+ /* constants */
+
+#define Z_NO_FLUSH 0
+#define Z_PARTIAL_FLUSH 1
+#define Z_SYNC_FLUSH 2
+#define Z_FULL_FLUSH 3
+#define Z_FINISH 4
+#define Z_BLOCK 5
+#define Z_TREES 6
+/* Allowed flush values; see deflate() and inflate() below for details */
+
+#define Z_OK 0
+#define Z_STREAM_END 1
+#define Z_NEED_DICT 2
+#define Z_ERRNO (-1)
+#define Z_STREAM_ERROR (-2)
+#define Z_DATA_ERROR (-3)
+#define Z_MEM_ERROR (-4)
+#define Z_BUF_ERROR (-5)
+#define Z_VERSION_ERROR (-6)
+/* Return codes for the compression/decompression functions. Negative values
+ * are errors, positive values are used for special but normal events.
+ */
+
+#define Z_NO_COMPRESSION 0
+#define Z_BEST_SPEED 1
+#define Z_BEST_COMPRESSION 9
+#define Z_DEFAULT_COMPRESSION (-1)
+/* compression levels */
+
+#define Z_FILTERED 1
+#define Z_HUFFMAN_ONLY 2
+#define Z_RLE 3
+#define Z_FIXED 4
+#define Z_DEFAULT_STRATEGY 0
+/* compression strategy; see deflateInit2() below for details */
+
+#define Z_BINARY 0
+#define Z_TEXT 1
+#define Z_ASCII Z_TEXT /* for compatibility with 1.2.2 and earlier */
+#define Z_UNKNOWN 2
+/* Possible values of the data_type field (though see inflate()) */
+
+#define Z_DEFLATED 8
+/* The deflate compression method (the only one supported in this version) */
+
+#define Z_NULL 0 /* for initializing zalloc, zfree, opaque */
+
+#define zlib_version zlibVersion()
+/* for compatibility with versions < 1.0.2 */
+
+
+ /* basic functions */
+
+ZEXTERN const char * ZEXPORT zlibVersion OF((void));
+/* The application can compare zlibVersion and ZLIB_VERSION for consistency.
+ If the first character differs, the library code actually used is not
+ compatible with the zlib.h header file used by the application. This check
+ is automatically made by deflateInit and inflateInit.
+ */
+
+/*
+ZEXTERN int ZEXPORT deflateInit OF((z_streamp strm, int level));
+
+ Initializes the internal stream state for compression. The fields
+ zalloc, zfree and opaque must be initialized before by the caller. If
+ zalloc and zfree are set to Z_NULL, deflateInit updates them to use default
+ allocation functions.
+
+ The compression level must be Z_DEFAULT_COMPRESSION, or between 0 and 9:
+ 1 gives best speed, 9 gives best compression, 0 gives no compression at all
+ (the input data is simply copied a block at a time). Z_DEFAULT_COMPRESSION
+ requests a default compromise between speed and compression (currently
+ equivalent to level 6).
+
+ deflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enough
+ memory, Z_STREAM_ERROR if level is not a valid compression level, or
+ Z_VERSION_ERROR if the zlib library version (zlib_version) is incompatible
+ with the version assumed by the caller (ZLIB_VERSION). msg is set to null
+ if there is no error message. deflateInit does not perform any compression:
+ this will be done by deflate().
+*/
+
+
+ZEXTERN int ZEXPORT deflate OF((z_streamp strm, int flush));
+/*
+ deflate compresses as much data as possible, and stops when the input
+ buffer becomes empty or the output buffer becomes full. It may introduce
+ some output latency (reading input without producing any output) except when
+ forced to flush.
+
+ The detailed semantics are as follows. deflate performs one or both of the
+ following actions:
+
+ - Compress more input starting at next_in and update next_in and avail_in
+ accordingly. If not all input can be processed (because there is not
+ enough room in the output buffer), next_in and avail_in are updated and
+ processing will resume at this point for the next call of deflate().
+
+ - Provide more output starting at next_out and update next_out and avail_out
+ accordingly. This action is forced if the parameter flush is non zero.
+ Forcing flush frequently degrades the compression ratio, so this parameter
+ should be set only when necessary (in interactive applications). Some
+ output may be provided even if flush is not set.
+
+ Before the call of deflate(), the application should ensure that at least
+ one of the actions is possible, by providing more input and/or consuming more
+ output, and updating avail_in or avail_out accordingly; avail_out should
+ never be zero before the call. The application can consume the compressed
+ output when it wants, for example when the output buffer is full (avail_out
+ == 0), or after each call of deflate(). If deflate returns Z_OK and with
+ zero avail_out, it must be called again after making room in the output
+ buffer because there might be more output pending.
+
+ Normally the parameter flush is set to Z_NO_FLUSH, which allows deflate to
+ decide how much data to accumulate before producing output, in order to
+ maximize compression.
+
+ If the parameter flush is set to Z_SYNC_FLUSH, all pending output is
+ flushed to the output buffer and the output is aligned on a byte boundary, so
+ that the decompressor can get all input data available so far. (In
+ particular avail_in is zero after the call if enough output space has been
+ provided before the call.) Flushing may degrade compression for some
+ compression algorithms and so it should be used only when necessary. This
+ completes the current deflate block and follows it with an empty stored block
+ that is three bits plus filler bits to the next byte, followed by four bytes
+ (00 00 ff ff).
+
+ If flush is set to Z_PARTIAL_FLUSH, all pending output is flushed to the
+ output buffer, but the output is not aligned to a byte boundary. All of the
+ input data so far will be available to the decompressor, as for Z_SYNC_FLUSH.
+ This completes the current deflate block and follows it with an empty fixed
+ codes block that is 10 bits long. This assures that enough bytes are output
+ in order for the decompressor to finish the block before the empty fixed code
+ block.
+
+ If flush is set to Z_BLOCK, a deflate block is completed and emitted, as
+ for Z_SYNC_FLUSH, but the output is not aligned on a byte boundary, and up to
+ seven bits of the current block are held to be written as the next byte after
+ the next deflate block is completed. In this case, the decompressor may not
+ be provided enough bits at this point in order to complete decompression of
+ the data provided so far to the compressor. It may need to wait for the next
+ block to be emitted. This is for advanced applications that need to control
+ the emission of deflate blocks.
+
+ If flush is set to Z_FULL_FLUSH, all output is flushed as with
+ Z_SYNC_FLUSH, and the compression state is reset so that decompression can
+ restart from this point if previous compressed data has been damaged or if
+ random access is desired. Using Z_FULL_FLUSH too often can seriously degrade
+ compression.
+
+ If deflate returns with avail_out == 0, this function must be called again
+ with the same value of the flush parameter and more output space (updated
+ avail_out), until the flush is complete (deflate returns with non-zero
+ avail_out). In the case of a Z_FULL_FLUSH or Z_SYNC_FLUSH, make sure that
+ avail_out is greater than six to avoid repeated flush markers due to
+ avail_out == 0 on return.
+
+ If the parameter flush is set to Z_FINISH, pending input is processed,
+ pending output is flushed and deflate returns with Z_STREAM_END if there was
+ enough output space; if deflate returns with Z_OK, this function must be
+ called again with Z_FINISH and more output space (updated avail_out) but no
+ more input data, until it returns with Z_STREAM_END or an error. After
+ deflate has returned Z_STREAM_END, the only possible operations on the stream
+ are deflateReset or deflateEnd.
+
+ Z_FINISH can be used immediately after deflateInit if all the compression
+ is to be done in a single step. In this case, avail_out must be at least the
+ value returned by deflateBound (see below). If deflate does not return
+ Z_STREAM_END, then it must be called again as described above.
+
+ deflate() sets strm->adler to the adler32 checksum of all input read
+ so far (that is, total_in bytes).
+
+ deflate() may update strm->data_type if it can make a good guess about
+ the input data type (Z_BINARY or Z_TEXT). In doubt, the data is considered
+ binary. This field is only for information purposes and does not affect the
+ compression algorithm in any manner.
+
+ deflate() returns Z_OK if some progress has been made (more input
+ processed or more output produced), Z_STREAM_END if all input has been
+ consumed and all output has been produced (only when flush is set to
+ Z_FINISH), Z_STREAM_ERROR if the stream state was inconsistent (for example
+ if next_in or next_out was Z_NULL), Z_BUF_ERROR if no progress is possible
+ (for example avail_in or avail_out was zero). Note that Z_BUF_ERROR is not
+ fatal, and deflate() can be called again with more input and more output
+ space to continue compressing.
+*/
+
+
+ZEXTERN int ZEXPORT deflateEnd OF((z_streamp strm));
+/*
+ All dynamically allocated data structures for this stream are freed.
+ This function discards any unprocessed input and does not flush any pending
+ output.
+
+ deflateEnd returns Z_OK if success, Z_STREAM_ERROR if the
+ stream state was inconsistent, Z_DATA_ERROR if the stream was freed
+ prematurely (some input or output was discarded). In the error case, msg
+ may be set but then points to a static string (which must not be
+ deallocated).
+*/
+
+
+/*
+ZEXTERN int ZEXPORT inflateInit OF((z_streamp strm));
+
+ Initializes the internal stream state for decompression. The fields
+ next_in, avail_in, zalloc, zfree and opaque must be initialized before by
+ the caller. If next_in is not Z_NULL and avail_in is large enough (the
+ exact value depends on the compression method), inflateInit determines the
+ compression method from the zlib header and allocates all data structures
+ accordingly; otherwise the allocation will be deferred to the first call of
+ inflate. If zalloc and zfree are set to Z_NULL, inflateInit updates them to
+ use default allocation functions.
+
+ inflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enough
+ memory, Z_VERSION_ERROR if the zlib library version is incompatible with the
+ version assumed by the caller, or Z_STREAM_ERROR if the parameters are
+ invalid, such as a null pointer to the structure. msg is set to null if
+ there is no error message. inflateInit does not perform any decompression
+ apart from possibly reading the zlib header if present: actual decompression
+ will be done by inflate(). (So next_in and avail_in may be modified, but
+ next_out and avail_out are unused and unchanged.) The current implementation
+ of inflateInit() does not process any header information -- that is deferred
+ until inflate() is called.
+*/
+
+
+ZEXTERN int ZEXPORT inflate OF((z_streamp strm, int flush));
+/*
+ inflate decompresses as much data as possible, and stops when the input
+ buffer becomes empty or the output buffer becomes full. It may introduce
+ some output latency (reading input without producing any output) except when
+ forced to flush.
+
+ The detailed semantics are as follows. inflate performs one or both of the
+ following actions:
+
+ - Decompress more input starting at next_in and update next_in and avail_in
+ accordingly. If not all input can be processed (because there is not
+ enough room in the output buffer), next_in is updated and processing will
+ resume at this point for the next call of inflate().
+
+ - Provide more output starting at next_out and update next_out and avail_out
+ accordingly. inflate() provides as much output as possible, until there is
+ no more input data or no more space in the output buffer (see below about
+ the flush parameter).
+
+ Before the call of inflate(), the application should ensure that at least
+ one of the actions is possible, by providing more input and/or consuming more
+ output, and updating the next_* and avail_* values accordingly. The
+ application can consume the uncompressed output when it wants, for example
+ when the output buffer is full (avail_out == 0), or after each call of
+ inflate(). If inflate returns Z_OK and with zero avail_out, it must be
+ called again after making room in the output buffer because there might be
+ more output pending.
+
+ The flush parameter of inflate() can be Z_NO_FLUSH, Z_SYNC_FLUSH, Z_FINISH,
+ Z_BLOCK, or Z_TREES. Z_SYNC_FLUSH requests that inflate() flush as much
+ output as possible to the output buffer. Z_BLOCK requests that inflate()
+ stop if and when it gets to the next deflate block boundary. When decoding
+ the zlib or gzip format, this will cause inflate() to return immediately
+ after the header and before the first block. When doing a raw inflate,
+ inflate() will go ahead and process the first block, and will return when it
+ gets to the end of that block, or when it runs out of data.
+
+ The Z_BLOCK option assists in appending to or combining deflate streams.
+ Also to assist in this, on return inflate() will set strm->data_type to the
+ number of unused bits in the last byte taken from strm->next_in, plus 64 if
+ inflate() is currently decoding the last block in the deflate stream, plus
+ 128 if inflate() returned immediately after decoding an end-of-block code or
+ decoding the complete header up to just before the first byte of the deflate
+ stream. The end-of-block will not be indicated until all of the uncompressed
+ data from that block has been written to strm->next_out. The number of
+ unused bits may in general be greater than seven, except when bit 7 of
+ data_type is set, in which case the number of unused bits will be less than
+ eight. data_type is set as noted here every time inflate() returns for all
+ flush options, and so can be used to determine the amount of currently
+ consumed input in bits.
+
+ The Z_TREES option behaves as Z_BLOCK does, but it also returns when the
+ end of each deflate block header is reached, before any actual data in that
+ block is decoded. This allows the caller to determine the length of the
+ deflate block header for later use in random access within a deflate block.
+ 256 is added to the value of strm->data_type when inflate() returns
+ immediately after reaching the end of the deflate block header.
+
+ inflate() should normally be called until it returns Z_STREAM_END or an
+ error. However if all decompression is to be performed in a single step (a
+ single call of inflate), the parameter flush should be set to Z_FINISH. In
+ this case all pending input is processed and all pending output is flushed;
+ avail_out must be large enough to hold all the uncompressed data. (The size
+ of the uncompressed data may have been saved by the compressor for this
+ purpose.) The next operation on this stream must be inflateEnd to deallocate
+ the decompression state. The use of Z_FINISH is never required, but can be
+ used to inform inflate that a faster approach may be used for the single
+ inflate() call.
+
+ In this implementation, inflate() always flushes as much output as
+ possible to the output buffer, and always uses the faster approach on the
+ first call. So the only effect of the flush parameter in this implementation
+ is on the return value of inflate(), as noted below, or when it returns early
+ because Z_BLOCK or Z_TREES is used.
+
+ If a preset dictionary is needed after this call (see inflateSetDictionary
+ below), inflate sets strm->adler to the adler32 checksum of the dictionary
+ chosen by the compressor and returns Z_NEED_DICT; otherwise it sets
+ strm->adler to the adler32 checksum of all output produced so far (that is,
+ total_out bytes) and returns Z_OK, Z_STREAM_END or an error code as described
+ below. At the end of the stream, inflate() checks that its computed adler32
+ checksum is equal to that saved by the compressor and returns Z_STREAM_END
+ only if the checksum is correct.
+
+ inflate() can decompress and check either zlib-wrapped or gzip-wrapped
+ deflate data. The header type is detected automatically, if requested when
+ initializing with inflateInit2(). Any information contained in the gzip
+ header is not retained, so applications that need that information should
+ instead use raw inflate, see inflateInit2() below, or inflateBack() and
+ perform their own processing of the gzip header and trailer.
+
+ inflate() returns Z_OK if some progress has been made (more input processed
+ or more output produced), Z_STREAM_END if the end of the compressed data has
+ been reached and all uncompressed output has been produced, Z_NEED_DICT if a
+ preset dictionary is needed at this point, Z_DATA_ERROR if the input data was
+ corrupted (input stream not conforming to the zlib format or incorrect check
+ value), Z_STREAM_ERROR if the stream structure was inconsistent (for example
+ next_in or next_out was Z_NULL), Z_MEM_ERROR if there was not enough memory,
+ Z_BUF_ERROR if no progress is possible or if there was not enough room in the
+ output buffer when Z_FINISH is used. Note that Z_BUF_ERROR is not fatal, and
+ inflate() can be called again with more input and more output space to
+ continue decompressing. If Z_DATA_ERROR is returned, the application may
+ then call inflateSync() to look for a good compression block if a partial
+ recovery of the data is desired.
+*/
+
+
+ZEXTERN int ZEXPORT inflateEnd OF((z_streamp strm));
+/*
+ All dynamically allocated data structures for this stream are freed.
+ This function discards any unprocessed input and does not flush any pending
+ output.
+
+ inflateEnd returns Z_OK if success, Z_STREAM_ERROR if the stream state
+ was inconsistent. In the error case, msg may be set but then points to a
+ static string (which must not be deallocated).
+*/
+
+
+ /* Advanced functions */
+
+/*
+ The following functions are needed only in some special applications.
+*/
+
+/*
+ZEXTERN int ZEXPORT deflateInit2 OF((z_streamp strm,
+ int level,
+ int method,
+ int windowBits,
+ int memLevel,
+ int strategy));
+
+ This is another version of deflateInit with more compression options. The
+ fields next_in, zalloc, zfree and opaque must be initialized before by the
+ caller.
+
+ The method parameter is the compression method. It must be Z_DEFLATED in
+ this version of the library.
+
+ The windowBits parameter is the base two logarithm of the window size
+ (the size of the history buffer). It should be in the range 8..15 for this
+ version of the library. Larger values of this parameter result in better
+ compression at the expense of memory usage. The default value is 15 if
+ deflateInit is used instead.
+
+ windowBits can also be -8..-15 for raw deflate. In this case, -windowBits
+ determines the window size. deflate() will then generate raw deflate data
+ with no zlib header or trailer, and will not compute an adler32 check value.
+
+ windowBits can also be greater than 15 for optional gzip encoding. Add
+ 16 to windowBits to write a simple gzip header and trailer around the
+ compressed data instead of a zlib wrapper. The gzip header will have no
+ file name, no extra data, no comment, no modification time (set to zero), no
+ header crc, and the operating system will be set to 255 (unknown). If a
+ gzip stream is being written, strm->adler is a crc32 instead of an adler32.
+
+ The memLevel parameter specifies how much memory should be allocated
+ for the internal compression state. memLevel=1 uses minimum memory but is
+ slow and reduces compression ratio; memLevel=9 uses maximum memory for
+ optimal speed. The default value is 8. See zconf.h for total memory usage
+ as a function of windowBits and memLevel.
+
+ The strategy parameter is used to tune the compression algorithm. Use the
+ value Z_DEFAULT_STRATEGY for normal data, Z_FILTERED for data produced by a
+ filter (or predictor), Z_HUFFMAN_ONLY to force Huffman encoding only (no
+ string match), or Z_RLE to limit match distances to one (run-length
+ encoding). Filtered data consists mostly of small values with a somewhat
+ random distribution. In this case, the compression algorithm is tuned to
+ compress them better. The effect of Z_FILTERED is to force more Huffman
+ coding and less string matching; it is somewhat intermediate between
+ Z_DEFAULT_STRATEGY and Z_HUFFMAN_ONLY. Z_RLE is designed to be almost as
+ fast as Z_HUFFMAN_ONLY, but give better compression for PNG image data. The
+ strategy parameter only affects the compression ratio but not the
+ correctness of the compressed output even if it is not set appropriately.
+ Z_FIXED prevents the use of dynamic Huffman codes, allowing for a simpler
+ decoder for special applications.
+
+ deflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough
+ memory, Z_STREAM_ERROR if any parameter is invalid (such as an invalid
+ method), or Z_VERSION_ERROR if the zlib library version (zlib_version) is
+ incompatible with the version assumed by the caller (ZLIB_VERSION). msg is
+ set to null if there is no error message. deflateInit2 does not perform any
+ compression: this will be done by deflate().
+*/
+
+ZEXTERN int ZEXPORT deflateSetDictionary OF((z_streamp strm,
+ const Bytef *dictionary,
+ uInt dictLength));
+/*
+ Initializes the compression dictionary from the given byte sequence
+ without producing any compressed output. This function must be called
+ immediately after deflateInit, deflateInit2 or deflateReset, before any call
+ of deflate. The compressor and decompressor must use exactly the same
+ dictionary (see inflateSetDictionary).
+
+ The dictionary should consist of strings (byte sequences) that are likely
+ to be encountered later in the data to be compressed, with the most commonly
+ used strings preferably put towards the end of the dictionary. Using a
+ dictionary is most useful when the data to be compressed is short and can be
+ predicted with good accuracy; the data can then be compressed better than
+ with the default empty dictionary.
+
+ Depending on the size of the compression data structures selected by
+ deflateInit or deflateInit2, a part of the dictionary may in effect be
+ discarded, for example if the dictionary is larger than the window size
+ provided in deflateInit or deflateInit2. Thus the strings most likely to be
+ useful should be put at the end of the dictionary, not at the front. In
+ addition, the current implementation of deflate will use at most the window
+ size minus 262 bytes of the provided dictionary.
+
+ Upon return of this function, strm->adler is set to the adler32 value
+ of the dictionary; the decompressor may later use this value to determine
+ which dictionary has been used by the compressor. (The adler32 value
+ applies to the whole dictionary even if only a subset of the dictionary is
+ actually used by the compressor.) If a raw deflate was requested, then the
+ adler32 value is not computed and strm->adler is not set.
+
+ deflateSetDictionary returns Z_OK if success, or Z_STREAM_ERROR if a
+ parameter is invalid (e.g. dictionary being Z_NULL) or the stream state is
+ inconsistent (for example if deflate has already been called for this stream
+ or if the compression method is bsort). deflateSetDictionary does not
+ perform any compression: this will be done by deflate().
+*/
+
+ZEXTERN int ZEXPORT deflateCopy OF((z_streamp dest,
+ z_streamp source));
+/*
+ Sets the destination stream as a complete copy of the source stream.
+
+ This function can be useful when several compression strategies will be
+ tried, for example when there are several ways of pre-processing the input
+ data with a filter. The streams that will be discarded should then be freed
+ by calling deflateEnd. Note that deflateCopy duplicates the internal
+ compression state which can be quite large, so this strategy is slow and can
+ consume lots of memory.
+
+ deflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not
+ enough memory, Z_STREAM_ERROR if the source stream state was inconsistent
+ (such as zalloc being Z_NULL). msg is left unchanged in both source and
+ destination.
+*/
+
+ZEXTERN int ZEXPORT deflateReset OF((z_streamp strm));
+/*
+ This function is equivalent to deflateEnd followed by deflateInit,
+ but does not free and reallocate all the internal compression state. The
+ stream will keep the same compression level and any other attributes that
+ may have been set by deflateInit2.
+
+ deflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source
+ stream state was inconsistent (such as zalloc or state being Z_NULL).
+*/
+
+ZEXTERN int ZEXPORT deflateParams OF((z_streamp strm,
+ int level,
+ int strategy));
+/*
+ Dynamically update the compression level and compression strategy. The
+ interpretation of level and strategy is as in deflateInit2. This can be
+ used to switch between compression and straight copy of the input data, or
+ to switch to a different kind of input data requiring a different strategy.
+ If the compression level is changed, the input available so far is
+ compressed with the old level (and may be flushed); the new level will take
+ effect only at the next call of deflate().
+
+ Before the call of deflateParams, the stream state must be set as for
+ a call of deflate(), since the currently available input may have to be
+ compressed and flushed. In particular, strm->avail_out must be non-zero.
+
+ deflateParams returns Z_OK if success, Z_STREAM_ERROR if the source
+ stream state was inconsistent or if a parameter was invalid, Z_BUF_ERROR if
+ strm->avail_out was zero.
+*/
+
+ZEXTERN int ZEXPORT deflateTune OF((z_streamp strm,
+ int good_length,
+ int max_lazy,
+ int nice_length,
+ int max_chain));
+/*
+ Fine tune deflate's internal compression parameters. This should only be
+ used by someone who understands the algorithm used by zlib's deflate for
+ searching for the best matching string, and even then only by the most
+ fanatic optimizer trying to squeeze out the last compressed bit for their
+ specific input data. Read the deflate.c source code for the meaning of the
+ max_lazy, good_length, nice_length, and max_chain parameters.
+
+ deflateTune() can be called after deflateInit() or deflateInit2(), and
+ returns Z_OK on success, or Z_STREAM_ERROR for an invalid deflate stream.
+ */
+
+ZEXTERN uLong ZEXPORT deflateBound OF((z_streamp strm,
+ uLong sourceLen));
+/*
+ deflateBound() returns an upper bound on the compressed size after
+ deflation of sourceLen bytes. It must be called after deflateInit() or
+ deflateInit2(), and after deflateSetHeader(), if used. This would be used
+ to allocate an output buffer for deflation in a single pass, and so would be
+ called before deflate().
+*/
+
+ZEXTERN int ZEXPORT deflatePrime OF((z_streamp strm,
+ int bits,
+ int value));
+/*
+ deflatePrime() inserts bits in the deflate output stream. The intent
+ is that this function is used to start off the deflate output with the bits
+ leftover from a previous deflate stream when appending to it. As such, this
+ function can only be used for raw deflate, and must be used before the first
+ deflate() call after a deflateInit2() or deflateReset(). bits must be less
+ than or equal to 16, and that many of the least significant bits of value
+ will be inserted in the output.
+
+ deflatePrime returns Z_OK if success, or Z_STREAM_ERROR if the source
+ stream state was inconsistent.
+*/
+
+ZEXTERN int ZEXPORT deflateSetHeader OF((z_streamp strm,
+ gz_headerp head));
+/*
+ deflateSetHeader() provides gzip header information for when a gzip
+ stream is requested by deflateInit2(). deflateSetHeader() may be called
+ after deflateInit2() or deflateReset() and before the first call of
+ deflate(). The text, time, os, extra field, name, and comment information
+ in the provided gz_header structure are written to the gzip header (xflag is
+ ignored -- the extra flags are set according to the compression level). The
+ caller must assure that, if not Z_NULL, name and comment are terminated with
+ a zero byte, and that if extra is not Z_NULL, that extra_len bytes are
+ available there. If hcrc is true, a gzip header crc is included. Note that
+ the current versions of the command-line version of gzip (up through version
+ 1.3.x) do not support header crc's, and will report that it is a "multi-part
+ gzip file" and give up.
+
+ If deflateSetHeader is not used, the default gzip header has text false,
+ the time set to zero, and os set to 255, with no extra, name, or comment
+ fields. The gzip header is returned to the default state by deflateReset().
+
+ deflateSetHeader returns Z_OK if success, or Z_STREAM_ERROR if the source
+ stream state was inconsistent.
+*/
+
+/*
+ZEXTERN int ZEXPORT inflateInit2 OF((z_streamp strm,
+ int windowBits));
+
+ This is another version of inflateInit with an extra parameter. The
+ fields next_in, avail_in, zalloc, zfree and opaque must be initialized
+ before by the caller.
+
+ The windowBits parameter is the base two logarithm of the maximum window
+ size (the size of the history buffer). It should be in the range 8..15 for
+ this version of the library. The default value is 15 if inflateInit is used
+ instead. windowBits must be greater than or equal to the windowBits value
+ provided to deflateInit2() while compressing, or it must be equal to 15 if
+ deflateInit2() was not used. If a compressed stream with a larger window
+ size is given as input, inflate() will return with the error code
+ Z_DATA_ERROR instead of trying to allocate a larger window.
+
+ windowBits can also be zero to request that inflate use the window size in
+ the zlib header of the compressed stream.
+
+ windowBits can also be -8..-15 for raw inflate. In this case, -windowBits
+ determines the window size. inflate() will then process raw deflate data,
+ not looking for a zlib or gzip header, not generating a check value, and not
+ looking for any check values for comparison at the end of the stream. This
+ is for use with other formats that use the deflate compressed data format
+ such as zip. Those formats provide their own check values. If a custom
+ format is developed using the raw deflate format for compressed data, it is
+ recommended that a check value such as an adler32 or a crc32 be applied to
+ the uncompressed data as is done in the zlib, gzip, and zip formats. For
+ most applications, the zlib format should be used as is. Note that comments
+ above on the use in deflateInit2() applies to the magnitude of windowBits.
+
+ windowBits can also be greater than 15 for optional gzip decoding. Add
+ 32 to windowBits to enable zlib and gzip decoding with automatic header
+ detection, or add 16 to decode only the gzip format (the zlib format will
+ return a Z_DATA_ERROR). If a gzip stream is being decoded, strm->adler is a
+ crc32 instead of an adler32.
+
+ inflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough
+ memory, Z_VERSION_ERROR if the zlib library version is incompatible with the
+ version assumed by the caller, or Z_STREAM_ERROR if the parameters are
+ invalid, such as a null pointer to the structure. msg is set to null if
+ there is no error message. inflateInit2 does not perform any decompression
+ apart from possibly reading the zlib header if present: actual decompression
+ will be done by inflate(). (So next_in and avail_in may be modified, but
+ next_out and avail_out are unused and unchanged.) The current implementation
+ of inflateInit2() does not process any header information -- that is
+ deferred until inflate() is called.
+*/
+
+ZEXTERN int ZEXPORT inflateSetDictionary OF((z_streamp strm,
+ const Bytef *dictionary,
+ uInt dictLength));
+/*
+ Initializes the decompression dictionary from the given uncompressed byte
+ sequence. This function must be called immediately after a call of inflate,
+ if that call returned Z_NEED_DICT. The dictionary chosen by the compressor
+ can be determined from the adler32 value returned by that call of inflate.
+ The compressor and decompressor must use exactly the same dictionary (see
+ deflateSetDictionary). For raw inflate, this function can be called
+ immediately after inflateInit2() or inflateReset() and before any call of
+ inflate() to set the dictionary. The application must insure that the
+ dictionary that was used for compression is provided.
+
+ inflateSetDictionary returns Z_OK if success, Z_STREAM_ERROR if a
+ parameter is invalid (e.g. dictionary being Z_NULL) or the stream state is
+ inconsistent, Z_DATA_ERROR if the given dictionary doesn't match the
+ expected one (incorrect adler32 value). inflateSetDictionary does not
+ perform any decompression: this will be done by subsequent calls of
+ inflate().
+*/
+
+ZEXTERN int ZEXPORT inflateSync OF((z_streamp strm));
+/*
+ Skips invalid compressed data until a full flush point (see above the
+ description of deflate with Z_FULL_FLUSH) can be found, or until all
+ available input is skipped. No output is provided.
+
+ inflateSync returns Z_OK if a full flush point has been found, Z_BUF_ERROR
+ if no more input was provided, Z_DATA_ERROR if no flush point has been
+ found, or Z_STREAM_ERROR if the stream structure was inconsistent. In the
+ success case, the application may save the current current value of total_in
+ which indicates where valid compressed data was found. In the error case,
+ the application may repeatedly call inflateSync, providing more input each
+ time, until success or end of the input data.
+*/
+
+ZEXTERN int ZEXPORT inflateCopy OF((z_streamp dest,
+ z_streamp source));
+/*
+ Sets the destination stream as a complete copy of the source stream.
+
+ This function can be useful when randomly accessing a large stream. The
+ first pass through the stream can periodically record the inflate state,
+ allowing restarting inflate at those points when randomly accessing the
+ stream.
+
+ inflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not
+ enough memory, Z_STREAM_ERROR if the source stream state was inconsistent
+ (such as zalloc being Z_NULL). msg is left unchanged in both source and
+ destination.
+*/
+
+ZEXTERN int ZEXPORT inflateReset OF((z_streamp strm));
+/*
+ This function is equivalent to inflateEnd followed by inflateInit,
+ but does not free and reallocate all the internal decompression state. The
+ stream will keep attributes that may have been set by inflateInit2.
+
+ inflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source
+ stream state was inconsistent (such as zalloc or state being Z_NULL).
+*/
+
+ZEXTERN int ZEXPORT inflateReset2 OF((z_streamp strm,
+ int windowBits));
+/*
+ This function is the same as inflateReset, but it also permits changing
+ the wrap and window size requests. The windowBits parameter is interpreted
+ the same as it is for inflateInit2.
+
+ inflateReset2 returns Z_OK if success, or Z_STREAM_ERROR if the source
+ stream state was inconsistent (such as zalloc or state being Z_NULL), or if
+ the windowBits parameter is invalid.
+*/
+
+ZEXTERN int ZEXPORT inflatePrime OF((z_streamp strm,
+ int bits,
+ int value));
+/*
+ This function inserts bits in the inflate input stream. The intent is
+ that this function is used to start inflating at a bit position in the
+ middle of a byte. The provided bits will be used before any bytes are used
+ from next_in. This function should only be used with raw inflate, and
+ should be used before the first inflate() call after inflateInit2() or
+ inflateReset(). bits must be less than or equal to 16, and that many of the
+ least significant bits of value will be inserted in the input.
+
+ If bits is negative, then the input stream bit buffer is emptied. Then
+ inflatePrime() can be called again to put bits in the buffer. This is used
+ to clear out bits leftover after feeding inflate a block description prior
+ to feeding inflate codes.
+
+ inflatePrime returns Z_OK if success, or Z_STREAM_ERROR if the source
+ stream state was inconsistent.
+*/
+
+ZEXTERN long ZEXPORT inflateMark OF((z_streamp strm));
+/*
+ This function returns two values, one in the lower 16 bits of the return
+ value, and the other in the remaining upper bits, obtained by shifting the
+ return value down 16 bits. If the upper value is -1 and the lower value is
+ zero, then inflate() is currently decoding information outside of a block.
+ If the upper value is -1 and the lower value is non-zero, then inflate is in
+ the middle of a stored block, with the lower value equaling the number of
+ bytes from the input remaining to copy. If the upper value is not -1, then
+ it is the number of bits back from the current bit position in the input of
+ the code (literal or length/distance pair) currently being processed. In
+ that case the lower value is the number of bytes already emitted for that
+ code.
+
+ A code is being processed if inflate is waiting for more input to complete
+ decoding of the code, or if it has completed decoding but is waiting for
+ more output space to write the literal or match data.
+
+ inflateMark() is used to mark locations in the input data for random
+ access, which may be at bit positions, and to note those cases where the
+ output of a code may span boundaries of random access blocks. The current
+ location in the input stream can be determined from avail_in and data_type
+ as noted in the description for the Z_BLOCK flush parameter for inflate.
+
+ inflateMark returns the value noted above or -1 << 16 if the provided
+ source stream state was inconsistent.
+*/
+
+ZEXTERN int ZEXPORT inflateGetHeader OF((z_streamp strm,
+ gz_headerp head));
+/*
+ inflateGetHeader() requests that gzip header information be stored in the
+ provided gz_header structure. inflateGetHeader() may be called after
+ inflateInit2() or inflateReset(), and before the first call of inflate().
+ As inflate() processes the gzip stream, head->done is zero until the header
+ is completed, at which time head->done is set to one. If a zlib stream is
+ being decoded, then head->done is set to -1 to indicate that there will be
+ no gzip header information forthcoming. Note that Z_BLOCK or Z_TREES can be
+ used to force inflate() to return immediately after header processing is
+ complete and before any actual data is decompressed.
+
+ The text, time, xflags, and os fields are filled in with the gzip header
+ contents. hcrc is set to true if there is a header CRC. (The header CRC
+ was valid if done is set to one.) If extra is not Z_NULL, then extra_max
+ contains the maximum number of bytes to write to extra. Once done is true,
+ extra_len contains the actual extra field length, and extra contains the
+ extra field, or that field truncated if extra_max is less than extra_len.
+ If name is not Z_NULL, then up to name_max characters are written there,
+ terminated with a zero unless the length is greater than name_max. If
+ comment is not Z_NULL, then up to comm_max characters are written there,
+ terminated with a zero unless the length is greater than comm_max. When any
+ of extra, name, or comment are not Z_NULL and the respective field is not
+ present in the header, then that field is set to Z_NULL to signal its
+ absence. This allows the use of deflateSetHeader() with the returned
+ structure to duplicate the header. However if those fields are set to
+ allocated memory, then the application will need to save those pointers
+ elsewhere so that they can be eventually freed.
+
+ If inflateGetHeader is not used, then the header information is simply
+ discarded. The header is always checked for validity, including the header
+ CRC if present. inflateReset() will reset the process to discard the header
+ information. The application would need to call inflateGetHeader() again to
+ retrieve the header from the next gzip stream.
+
+ inflateGetHeader returns Z_OK if success, or Z_STREAM_ERROR if the source
+ stream state was inconsistent.
+*/
+
+/*
+ZEXTERN int ZEXPORT inflateBackInit OF((z_streamp strm, int windowBits,
+ unsigned char FAR *window));
+
+ Initialize the internal stream state for decompression using inflateBack()
+ calls. The fields zalloc, zfree and opaque in strm must be initialized
+ before the call. If zalloc and zfree are Z_NULL, then the default library-
+ derived memory allocation routines are used. windowBits is the base two
+ logarithm of the window size, in the range 8..15. window is a caller
+ supplied buffer of that size. Except for special applications where it is
+ assured that deflate was used with small window sizes, windowBits must be 15
+ and a 32K byte window must be supplied to be able to decompress general
+ deflate streams.
+
+ See inflateBack() for the usage of these routines.
+
+ inflateBackInit will return Z_OK on success, Z_STREAM_ERROR if any of
+ the paramaters are invalid, Z_MEM_ERROR if the internal state could not be
+ allocated, or Z_VERSION_ERROR if the version of the library does not match
+ the version of the header file.
+*/
+
+typedef unsigned (*in_func) OF((void FAR *, unsigned char FAR * FAR *));
+typedef int (*out_func) OF((void FAR *, unsigned char FAR *, unsigned));
+
+ZEXTERN int ZEXPORT inflateBack OF((z_streamp strm,
+ in_func in, void FAR *in_desc,
+ out_func out, void FAR *out_desc));
+/*
+ inflateBack() does a raw inflate with a single call using a call-back
+ interface for input and output. This is more efficient than inflate() for
+ file i/o applications in that it avoids copying between the output and the
+ sliding window by simply making the window itself the output buffer. This
+ function trusts the application to not change the output buffer passed by
+ the output function, at least until inflateBack() returns.
+
+ inflateBackInit() must be called first to allocate the internal state
+ and to initialize the state with the user-provided window buffer.
+ inflateBack() may then be used multiple times to inflate a complete, raw
+ deflate stream with each call. inflateBackEnd() is then called to free the
+ allocated state.
+
+ A raw deflate stream is one with no zlib or gzip header or trailer.
+ This routine would normally be used in a utility that reads zip or gzip
+ files and writes out uncompressed files. The utility would decode the
+ header and process the trailer on its own, hence this routine expects only
+ the raw deflate stream to decompress. This is different from the normal
+ behavior of inflate(), which expects either a zlib or gzip header and
+ trailer around the deflate stream.
+
+ inflateBack() uses two subroutines supplied by the caller that are then
+ called by inflateBack() for input and output. inflateBack() calls those
+ routines until it reads a complete deflate stream and writes out all of the
+ uncompressed data, or until it encounters an error. The function's
+ parameters and return types are defined above in the in_func and out_func
+ typedefs. inflateBack() will call in(in_desc, &buf) which should return the
+ number of bytes of provided input, and a pointer to that input in buf. If
+ there is no input available, in() must return zero--buf is ignored in that
+ case--and inflateBack() will return a buffer error. inflateBack() will call
+ out(out_desc, buf, len) to write the uncompressed data buf[0..len-1]. out()
+ should return zero on success, or non-zero on failure. If out() returns
+ non-zero, inflateBack() will return with an error. Neither in() nor out()
+ are permitted to change the contents of the window provided to
+ inflateBackInit(), which is also the buffer that out() uses to write from.
+ The length written by out() will be at most the window size. Any non-zero
+ amount of input may be provided by in().
+
+ For convenience, inflateBack() can be provided input on the first call by
+ setting strm->next_in and strm->avail_in. If that input is exhausted, then
+ in() will be called. Therefore strm->next_in must be initialized before
+ calling inflateBack(). If strm->next_in is Z_NULL, then in() will be called
+ immediately for input. If strm->next_in is not Z_NULL, then strm->avail_in
+ must also be initialized, and then if strm->avail_in is not zero, input will
+ initially be taken from strm->next_in[0 .. strm->avail_in - 1].
+
+ The in_desc and out_desc parameters of inflateBack() is passed as the
+ first parameter of in() and out() respectively when they are called. These
+ descriptors can be optionally used to pass any information that the caller-
+ supplied in() and out() functions need to do their job.
+
+ On return, inflateBack() will set strm->next_in and strm->avail_in to
+ pass back any unused input that was provided by the last in() call. The
+ return values of inflateBack() can be Z_STREAM_END on success, Z_BUF_ERROR
+ if in() or out() returned an error, Z_DATA_ERROR if there was a format error
+ in the deflate stream (in which case strm->msg is set to indicate the nature
+ of the error), or Z_STREAM_ERROR if the stream was not properly initialized.
+ In the case of Z_BUF_ERROR, an input or output error can be distinguished
+ using strm->next_in which will be Z_NULL only if in() returned an error. If
+ strm->next_in is not Z_NULL, then the Z_BUF_ERROR was due to out() returning
+ non-zero. (in() will always be called before out(), so strm->next_in is
+ assured to be defined if out() returns non-zero.) Note that inflateBack()
+ cannot return Z_OK.
+*/
+
+ZEXTERN int ZEXPORT inflateBackEnd OF((z_streamp strm));
+/*
+ All memory allocated by inflateBackInit() is freed.
+
+ inflateBackEnd() returns Z_OK on success, or Z_STREAM_ERROR if the stream
+ state was inconsistent.
+*/
+
+ZEXTERN uLong ZEXPORT zlibCompileFlags OF((void));
+/* Return flags indicating compile-time options.
+
+ Type sizes, two bits each, 00 = 16 bits, 01 = 32, 10 = 64, 11 = other:
+ 1.0: size of uInt
+ 3.2: size of uLong
+ 5.4: size of voidpf (pointer)
+ 7.6: size of z_off_t
+
+ Compiler, assembler, and debug options:
+ 8: DEBUG
+ 9: ASMV or ASMINF -- use ASM code
+ 10: ZLIB_WINAPI -- exported functions use the WINAPI calling convention
+ 11: 0 (reserved)
+
+ One-time table building (smaller code, but not thread-safe if true):
+ 12: BUILDFIXED -- build static block decoding tables when needed
+ 13: DYNAMIC_CRC_TABLE -- build CRC calculation tables when needed
+ 14,15: 0 (reserved)
+
+ Library content (indicates missing functionality):
+ 16: NO_GZCOMPRESS -- gz* functions cannot compress (to avoid linking
+ deflate code when not needed)
+ 17: NO_GZIP -- deflate can't write gzip streams, and inflate can't detect
+ and decode gzip streams (to avoid linking crc code)
+ 18-19: 0 (reserved)
+
+ Operation variations (changes in library functionality):
+ 20: PKZIP_BUG_WORKAROUND -- slightly more permissive inflate
+ 21: FASTEST -- deflate algorithm with only one, lowest compression level
+ 22,23: 0 (reserved)
+
+ The sprintf variant used by gzprintf (zero is best):
+ 24: 0 = vs*, 1 = s* -- 1 means limited to 20 arguments after the format
+ 25: 0 = *nprintf, 1 = *printf -- 1 means gzprintf() not secure!
+ 26: 0 = returns value, 1 = void -- 1 means inferred string length returned
+
+ Remainder:
+ 27-31: 0 (reserved)
+ */
+
+
+ /* utility functions */
+
+/*
+ The following utility functions are implemented on top of the basic
+ stream-oriented functions. To simplify the interface, some default options
+ are assumed (compression level and memory usage, standard memory allocation
+ functions). The source code of these utility functions can be modified if
+ you need special options.
+*/
+
+ZEXTERN int ZEXPORT compress OF((Bytef *dest, uLongf *destLen,
+ const Bytef *source, uLong sourceLen));
+/*
+ Compresses the source buffer into the destination buffer. sourceLen is
+ the byte length of the source buffer. Upon entry, destLen is the total size
+ of the destination buffer, which must be at least the value returned by
+ compressBound(sourceLen). Upon exit, destLen is the actual size of the
+ compressed buffer.
+
+ compress returns Z_OK if success, Z_MEM_ERROR if there was not
+ enough memory, Z_BUF_ERROR if there was not enough room in the output
+ buffer.
+*/
+
+ZEXTERN int ZEXPORT compress2 OF((Bytef *dest, uLongf *destLen,
+ const Bytef *source, uLong sourceLen,
+ int level));
+/*
+ Compresses the source buffer into the destination buffer. The level
+ parameter has the same meaning as in deflateInit. sourceLen is the byte
+ length of the source buffer. Upon entry, destLen is the total size of the
+ destination buffer, which must be at least the value returned by
+ compressBound(sourceLen). Upon exit, destLen is the actual size of the
+ compressed buffer.
+
+ compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough
+ memory, Z_BUF_ERROR if there was not enough room in the output buffer,
+ Z_STREAM_ERROR if the level parameter is invalid.
+*/
+
+ZEXTERN uLong ZEXPORT compressBound OF((uLong sourceLen));
+/*
+ compressBound() returns an upper bound on the compressed size after
+ compress() or compress2() on sourceLen bytes. It would be used before a
+ compress() or compress2() call to allocate the destination buffer.
+*/
+
+ZEXTERN int ZEXPORT uncompress OF((Bytef *dest, uLongf *destLen,
+ const Bytef *source, uLong sourceLen));
+/*
+ Decompresses the source buffer into the destination buffer. sourceLen is
+ the byte length of the source buffer. Upon entry, destLen is the total size
+ of the destination buffer, which must be large enough to hold the entire
+ uncompressed data. (The size of the uncompressed data must have been saved
+ previously by the compressor and transmitted to the decompressor by some
+ mechanism outside the scope of this compression library.) Upon exit, destLen
+ is the actual size of the uncompressed buffer.
+
+ uncompress returns Z_OK if success, Z_MEM_ERROR if there was not
+ enough memory, Z_BUF_ERROR if there was not enough room in the output
+ buffer, or Z_DATA_ERROR if the input data was corrupted or incomplete.
+*/
+
+
+ /* gzip file access functions */
+
+/*
+ This library supports reading and writing files in gzip (.gz) format with
+ an interface similar to that of stdio, using the functions that start with
+ "gz". The gzip format is different from the zlib format. gzip is a gzip
+ wrapper, documented in RFC 1952, wrapped around a deflate stream.
+*/
+
+typedef voidp gzFile; /* opaque gzip file descriptor */
+
+/*
+ZEXTERN gzFile ZEXPORT gzopen OF((const char *path, const char *mode));
+
+ Opens a gzip (.gz) file for reading or writing. The mode parameter is as
+ in fopen ("rb" or "wb") but can also include a compression level ("wb9") or
+ a strategy: 'f' for filtered data as in "wb6f", 'h' for Huffman-only
+ compression as in "wb1h", 'R' for run-length encoding as in "wb1R", or 'F'
+ for fixed code compression as in "wb9F". (See the description of
+ deflateInit2 for more information about the strategy parameter.) Also "a"
+ can be used instead of "w" to request that the gzip stream that will be
+ written be appended to the file. "+" will result in an error, since reading
+ and writing to the same gzip file is not supported.
+
+ gzopen can be used to read a file which is not in gzip format; in this
+ case gzread will directly read from the file without decompression.
+
+ gzopen returns NULL if the file could not be opened, if there was
+ insufficient memory to allocate the gzFile state, or if an invalid mode was
+ specified (an 'r', 'w', or 'a' was not provided, or '+' was provided).
+ errno can be checked to determine if the reason gzopen failed was that the
+ file could not be opened.
+*/
+
+ZEXTERN gzFile ZEXPORT gzdopen OF((int fd, const char *mode));
+/*
+ gzdopen associates a gzFile with the file descriptor fd. File descriptors
+ are obtained from calls like open, dup, creat, pipe or fileno (if the file
+ has been previously opened with fopen). The mode parameter is as in gzopen.
+
+ The next call of gzclose on the returned gzFile will also close the file
+ descriptor fd, just like fclose(fdopen(fd, mode)) closes the file descriptor
+ fd. If you want to keep fd open, use fd = dup(fd_keep); gz = gzdopen(fd,
+ mode);. The duplicated descriptor should be saved to avoid a leak, since
+ gzdopen does not close fd if it fails.
+
+ gzdopen returns NULL if there was insufficient memory to allocate the
+ gzFile state, if an invalid mode was specified (an 'r', 'w', or 'a' was not
+ provided, or '+' was provided), or if fd is -1. The file descriptor is not
+ used until the next gz* read, write, seek, or close operation, so gzdopen
+ will not detect if fd is invalid (unless fd is -1).
+*/
+
+ZEXTERN int ZEXPORT gzbuffer OF((gzFile file, unsigned size));
+/*
+ Set the internal buffer size used by this library's functions. The
+ default buffer size is 8192 bytes. This function must be called after
+ gzopen() or gzdopen(), and before any other calls that read or write the
+ file. The buffer memory allocation is always deferred to the first read or
+ write. Two buffers are allocated, either both of the specified size when
+ writing, or one of the specified size and the other twice that size when
+ reading. A larger buffer size of, for example, 64K or 128K bytes will
+ noticeably increase the speed of decompression (reading).
+
+ The new buffer size also affects the maximum length for gzprintf().
+
+ gzbuffer() returns 0 on success, or -1 on failure, such as being called
+ too late.
+*/
+
+ZEXTERN int ZEXPORT gzsetparams OF((gzFile file, int level, int strategy));
+/*
+ Dynamically update the compression level or strategy. See the description
+ of deflateInit2 for the meaning of these parameters.
+
+ gzsetparams returns Z_OK if success, or Z_STREAM_ERROR if the file was not
+ opened for writing.
+*/
+
+ZEXTERN int ZEXPORT gzread OF((gzFile file, voidp buf, unsigned len));
+/*
+ Reads the given number of uncompressed bytes from the compressed file. If
+ the input file was not in gzip format, gzread copies the given number of
+ bytes into the buffer.
+
+ After reaching the end of a gzip stream in the input, gzread will continue
+ to read, looking for another gzip stream, or failing that, reading the rest
+ of the input file directly without decompression. The entire input file
+ will be read if gzread is called until it returns less than the requested
+ len.
+
+ gzread returns the number of uncompressed bytes actually read, less than
+ len for end of file, or -1 for error.
+*/
+
+ZEXTERN int ZEXPORT gzwrite OF((gzFile file,
+ voidpc buf, unsigned len));
+/*
+ Writes the given number of uncompressed bytes into the compressed file.
+ gzwrite returns the number of uncompressed bytes written or 0 in case of
+ error.
+*/
+
+ZEXTERN int ZEXPORTVA gzprintf OF((gzFile file, const char *format, ...));
+/*
+ Converts, formats, and writes the arguments to the compressed file under
+ control of the format string, as in fprintf. gzprintf returns the number of
+ uncompressed bytes actually written, or 0 in case of error. The number of
+ uncompressed bytes written is limited to 8191, or one less than the buffer
+ size given to gzbuffer(). The caller should assure that this limit is not
+ exceeded. If it is exceeded, then gzprintf() will return an error (0) with
+ nothing written. In this case, there may also be a buffer overflow with
+ unpredictable consequences, which is possible only if zlib was compiled with
+ the insecure functions sprintf() or vsprintf() because the secure snprintf()
+ or vsnprintf() functions were not available. This can be determined using
+ zlibCompileFlags().
+*/
+
+ZEXTERN int ZEXPORT gzputs OF((gzFile file, const char *s));
+/*
+ Writes the given null-terminated string to the compressed file, excluding
+ the terminating null character.
+
+ gzputs returns the number of characters written, or -1 in case of error.
+*/
+
+ZEXTERN char * ZEXPORT gzgets OF((gzFile file, char *buf, int len));
+/*
+ Reads bytes from the compressed file until len-1 characters are read, or a
+ newline character is read and transferred to buf, or an end-of-file
+ condition is encountered. If any characters are read or if len == 1, the
+ string is terminated with a null character. If no characters are read due
+ to an end-of-file or len < 1, then the buffer is left untouched.
+
+ gzgets returns buf which is a null-terminated string, or it returns NULL
+ for end-of-file or in case of error. If there was an error, the contents at
+ buf are indeterminate.
+*/
+
+ZEXTERN int ZEXPORT gzputc OF((gzFile file, int c));
+/*
+ Writes c, converted to an unsigned char, into the compressed file. gzputc
+ returns the value that was written, or -1 in case of error.
+*/
+
+ZEXTERN int ZEXPORT gzgetc OF((gzFile file));
+/*
+ Reads one byte from the compressed file. gzgetc returns this byte or -1
+ in case of end of file or error.
+*/
+
+ZEXTERN int ZEXPORT gzungetc OF((int c, gzFile file));
+/*
+ Push one character back onto the stream to be read as the first character
+ on the next read. At least one character of push-back is allowed.
+ gzungetc() returns the character pushed, or -1 on failure. gzungetc() will
+ fail if c is -1, and may fail if a character has been pushed but not read
+ yet. If gzungetc is used immediately after gzopen or gzdopen, at least the
+ output buffer size of pushed characters is allowed. (See gzbuffer above.)
+ The pushed character will be discarded if the stream is repositioned with
+ gzseek() or gzrewind().
+*/
+
+ZEXTERN int ZEXPORT gzflush OF((gzFile file, int flush));
+/*
+ Flushes all pending output into the compressed file. The parameter flush
+ is as in the deflate() function. The return value is the zlib error number
+ (see function gzerror below). gzflush is only permitted when writing.
+
+ If the flush parameter is Z_FINISH, the remaining data is written and the
+ gzip stream is completed in the output. If gzwrite() is called again, a new
+ gzip stream will be started in the output. gzread() is able to read such
+ concatented gzip streams.
+
+ gzflush should be called only when strictly necessary because it will
+ degrade compression if called too often.
+*/
+
+/*
+ZEXTERN z_off_t ZEXPORT gzseek OF((gzFile file,
+ z_off_t offset, int whence));
+
+ Sets the starting position for the next gzread or gzwrite on the given
+ compressed file. The offset represents a number of bytes in the
+ uncompressed data stream. The whence parameter is defined as in lseek(2);
+ the value SEEK_END is not supported.
+
+ If the file is opened for reading, this function is emulated but can be
+ extremely slow. If the file is opened for writing, only forward seeks are
+ supported; gzseek then compresses a sequence of zeroes up to the new
+ starting position.
+
+ gzseek returns the resulting offset location as measured in bytes from
+ the beginning of the uncompressed stream, or -1 in case of error, in
+ particular if the file is opened for writing and the new starting position
+ would be before the current position.
+*/
+
+ZEXTERN int ZEXPORT gzrewind OF((gzFile file));
+/*
+ Rewinds the given file. This function is supported only for reading.
+
+ gzrewind(file) is equivalent to (int)gzseek(file, 0L, SEEK_SET)
+*/
+
+/*
+ZEXTERN z_off_t ZEXPORT gztell OF((gzFile file));
+
+ Returns the starting position for the next gzread or gzwrite on the given
+ compressed file. This position represents a number of bytes in the
+ uncompressed data stream, and is zero when starting, even if appending or
+ reading a gzip stream from the middle of a file using gzdopen().
+
+ gztell(file) is equivalent to gzseek(file, 0L, SEEK_CUR)
+*/
+
+/*
+ZEXTERN z_off_t ZEXPORT gzoffset OF((gzFile file));
+
+ Returns the current offset in the file being read or written. This offset
+ includes the count of bytes that precede the gzip stream, for example when
+ appending or when using gzdopen() for reading. When reading, the offset
+ does not include as yet unused buffered input. This information can be used
+ for a progress indicator. On error, gzoffset() returns -1.
+*/
+
+ZEXTERN int ZEXPORT gzeof OF((gzFile file));
+/*
+ Returns true (1) if the end-of-file indicator has been set while reading,
+ false (0) otherwise. Note that the end-of-file indicator is set only if the
+ read tried to go past the end of the input, but came up short. Therefore,
+ just like feof(), gzeof() may return false even if there is no more data to
+ read, in the event that the last read request was for the exact number of
+ bytes remaining in the input file. This will happen if the input file size
+ is an exact multiple of the buffer size.
+
+ If gzeof() returns true, then the read functions will return no more data,
+ unless the end-of-file indicator is reset by gzclearerr() and the input file
+ has grown since the previous end of file was detected.
+*/
+
+ZEXTERN int ZEXPORT gzdirect OF((gzFile file));
+/*
+ Returns true (1) if file is being copied directly while reading, or false
+ (0) if file is a gzip stream being decompressed. This state can change from
+ false to true while reading the input file if the end of a gzip stream is
+ reached, but is followed by data that is not another gzip stream.
+
+ If the input file is empty, gzdirect() will return true, since the input
+ does not contain a gzip stream.
+
+ If gzdirect() is used immediately after gzopen() or gzdopen() it will
+ cause buffers to be allocated to allow reading the file to determine if it
+ is a gzip file. Therefore if gzbuffer() is used, it should be called before
+ gzdirect().
+*/
+
+ZEXTERN int ZEXPORT gzclose OF((gzFile file));
+/*
+ Flushes all pending output if necessary, closes the compressed file and
+ deallocates the (de)compression state. Note that once file is closed, you
+ cannot call gzerror with file, since its structures have been deallocated.
+ gzclose must not be called more than once on the same file, just as free
+ must not be called more than once on the same allocation.
+
+ gzclose will return Z_STREAM_ERROR if file is not valid, Z_ERRNO on a
+ file operation error, or Z_OK on success.
+*/
+
+ZEXTERN int ZEXPORT gzclose_r OF((gzFile file));
+ZEXTERN int ZEXPORT gzclose_w OF((gzFile file));
+/*
+ Same as gzclose(), but gzclose_r() is only for use when reading, and
+ gzclose_w() is only for use when writing or appending. The advantage to
+ using these instead of gzclose() is that they avoid linking in zlib
+ compression or decompression code that is not used when only reading or only
+ writing respectively. If gzclose() is used, then both compression and
+ decompression code will be included the application when linking to a static
+ zlib library.
+*/
+
+ZEXTERN const char * ZEXPORT gzerror OF((gzFile file, int *errnum));
+/*
+ Returns the error message for the last error which occurred on the given
+ compressed file. errnum is set to zlib error number. If an error occurred
+ in the file system and not in the compression library, errnum is set to
+ Z_ERRNO and the application may consult errno to get the exact error code.
+
+ The application must not modify the returned string. Future calls to
+ this function may invalidate the previously returned string. If file is
+ closed, then the string previously returned by gzerror will no longer be
+ available.
+
+ gzerror() should be used to distinguish errors from end-of-file for those
+ functions above that do not distinguish those cases in their return values.
+*/
+
+ZEXTERN void ZEXPORT gzclearerr OF((gzFile file));
+/*
+ Clears the error and end-of-file flags for file. This is analogous to the
+ clearerr() function in stdio. This is useful for continuing to read a gzip
+ file that is being written concurrently.
+*/
+
+
+ /* checksum functions */
+
+/*
+ These functions are not related to compression but are exported
+ anyway because they might be useful in applications using the compression
+ library.
+*/
+
+ZEXTERN uLong ZEXPORT adler32 OF((uLong adler, const Bytef *buf, uInt len));
+/*
+ Update a running Adler-32 checksum with the bytes buf[0..len-1] and
+ return the updated checksum. If buf is Z_NULL, this function returns the
+ required initial value for the checksum.
+
+ An Adler-32 checksum is almost as reliable as a CRC32 but can be computed
+ much faster.
+
+ Usage example:
+
+ uLong adler = adler32(0L, Z_NULL, 0);
+
+ while (read_buffer(buffer, length) != EOF) {
+ adler = adler32(adler, buffer, length);
+ }
+ if (adler != original_adler) error();
+*/
+
+/*
+ZEXTERN uLong ZEXPORT adler32_combine OF((uLong adler1, uLong adler2,
+ z_off_t len2));
+
+ Combine two Adler-32 checksums into one. For two sequences of bytes, seq1
+ and seq2 with lengths len1 and len2, Adler-32 checksums were calculated for
+ each, adler1 and adler2. adler32_combine() returns the Adler-32 checksum of
+ seq1 and seq2 concatenated, requiring only adler1, adler2, and len2.
+*/
+
+ZEXTERN uLong ZEXPORT crc32 OF((uLong crc, const Bytef *buf, uInt len));
+/*
+ Update a running CRC-32 with the bytes buf[0..len-1] and return the
+ updated CRC-32. If buf is Z_NULL, this function returns the required
+ initial value for the for the crc. Pre- and post-conditioning (one's
+ complement) is performed within this function so it shouldn't be done by the
+ application.
+
+ Usage example:
+
+ uLong crc = crc32(0L, Z_NULL, 0);
+
+ while (read_buffer(buffer, length) != EOF) {
+ crc = crc32(crc, buffer, length);
+ }
+ if (crc != original_crc) error();
+*/
+
+/*
+ZEXTERN uLong ZEXPORT crc32_combine OF((uLong crc1, uLong crc2, z_off_t len2));
+
+ Combine two CRC-32 check values into one. For two sequences of bytes,
+ seq1 and seq2 with lengths len1 and len2, CRC-32 check values were
+ calculated for each, crc1 and crc2. crc32_combine() returns the CRC-32
+ check value of seq1 and seq2 concatenated, requiring only crc1, crc2, and
+ len2.
+*/
+
+
+ /* various hacks, don't look :) */
+
+/* deflateInit and inflateInit are macros to allow checking the zlib version
+ * and the compiler's view of z_stream:
+ */
+ZEXTERN int ZEXPORT deflateInit_ OF((z_streamp strm, int level,
+ const char *version, int stream_size));
+ZEXTERN int ZEXPORT inflateInit_ OF((z_streamp strm,
+ const char *version, int stream_size));
+ZEXTERN int ZEXPORT deflateInit2_ OF((z_streamp strm, int level, int method,
+ int windowBits, int memLevel,
+ int strategy, const char *version,
+ int stream_size));
+ZEXTERN int ZEXPORT inflateInit2_ OF((z_streamp strm, int windowBits,
+ const char *version, int stream_size));
+ZEXTERN int ZEXPORT inflateBackInit_ OF((z_streamp strm, int windowBits,
+ unsigned char FAR *window,
+ const char *version,
+ int stream_size));
+#define deflateInit(strm, level) \
+ deflateInit_((strm), (level), ZLIB_VERSION, sizeof(z_stream))
+#define inflateInit(strm) \
+ inflateInit_((strm), ZLIB_VERSION, sizeof(z_stream))
+#define deflateInit2(strm, level, method, windowBits, memLevel, strategy) \
+ deflateInit2_((strm),(level),(method),(windowBits),(memLevel),\
+ (strategy), ZLIB_VERSION, sizeof(z_stream))
+#define inflateInit2(strm, windowBits) \
+ inflateInit2_((strm), (windowBits), ZLIB_VERSION, sizeof(z_stream))
+#define inflateBackInit(strm, windowBits, window) \
+ inflateBackInit_((strm), (windowBits), (window), \
+ ZLIB_VERSION, sizeof(z_stream))
+
+/* provide 64-bit offset functions if _LARGEFILE64_SOURCE defined, and/or
+ * change the regular functions to 64 bits if _FILE_OFFSET_BITS is 64 (if
+ * both are true, the application gets the *64 functions, and the regular
+ * functions are changed to 64 bits) -- in case these are set on systems
+ * without large file support, _LFS64_LARGEFILE must also be true
+ */
+#if defined(_LARGEFILE64_SOURCE) && _LFS64_LARGEFILE-0
+ ZEXTERN gzFile ZEXPORT gzopen64 OF((const char *, const char *));
+ ZEXTERN z_off64_t ZEXPORT gzseek64 OF((gzFile, z_off64_t, int));
+ ZEXTERN z_off64_t ZEXPORT gztell64 OF((gzFile));
+ ZEXTERN z_off64_t ZEXPORT gzoffset64 OF((gzFile));
+ ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, z_off64_t));
+ ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off64_t));
+#endif
+
+#if !defined(ZLIB_INTERNAL) && _FILE_OFFSET_BITS-0 == 64 && _LFS64_LARGEFILE-0
+# define gzopen gzopen64
+# define gzseek gzseek64
+# define gztell gztell64
+# define gzoffset gzoffset64
+# define adler32_combine adler32_combine64
+# define crc32_combine crc32_combine64
+# ifdef _LARGEFILE64_SOURCE
+ ZEXTERN gzFile ZEXPORT gzopen64 OF((const char *, const char *));
+ ZEXTERN z_off_t ZEXPORT gzseek64 OF((gzFile, z_off_t, int));
+ ZEXTERN z_off_t ZEXPORT gztell64 OF((gzFile));
+ ZEXTERN z_off_t ZEXPORT gzoffset64 OF((gzFile));
+ ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, z_off_t));
+ ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off_t));
+# endif
+#else
+ ZEXTERN gzFile ZEXPORT gzopen OF((const char *, const char *));
+ ZEXTERN z_off_t ZEXPORT gzseek OF((gzFile, z_off_t, int));
+ ZEXTERN z_off_t ZEXPORT gztell OF((gzFile));
+ ZEXTERN z_off_t ZEXPORT gzoffset OF((gzFile));
+ ZEXTERN uLong ZEXPORT adler32_combine OF((uLong, uLong, z_off_t));
+ ZEXTERN uLong ZEXPORT crc32_combine OF((uLong, uLong, z_off_t));
+#endif
+
+/* hack for buggy compilers */
+#if !defined(ZUTIL_H) && !defined(NO_DUMMY_DECL)
+ struct internal_state {int dummy;};
+#endif
+
+/* undocumented functions */
+ZEXTERN const char * ZEXPORT zError OF((int));
+ZEXTERN int ZEXPORT inflateSyncPoint OF((z_streamp));
+ZEXTERN const uLongf * ZEXPORT get_crc_table OF((void));
+ZEXTERN int ZEXPORT inflateUndermine OF((z_streamp, int));
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* ZLIB_H */
diff --git a/libs/system/zc702evk/linux/zlib/zutil.h b/libs/system/zc702evk/linux/zlib/zutil.h
--- /dev/null
@@ -0,0 +1,274 @@
+/* zutil.h -- internal interface and configuration of the compression library
+ * Copyright (C) 1995-2010 Jean-loup Gailly.
+ * For conditions of distribution and use, see copyright notice in zlib.h
+ */
+
+/* WARNING: this file should *not* be used by applications. It is
+ part of the implementation of the compression library and is
+ subject to change. Applications should only use zlib.h.
+ */
+
+/* @(#) $Id$ */
+
+#ifndef ZUTIL_H
+#define ZUTIL_H
+
+#if ((__GNUC__-0) * 10 + __GNUC_MINOR__-0 >= 33) && !defined(NO_VIZ)
+# define ZLIB_INTERNAL __attribute__((visibility ("hidden")))
+#else
+# define ZLIB_INTERNAL
+#endif
+
+#include "zlib.h"
+
+#ifdef STDC
+# if !(defined(_WIN32_WCE) && defined(_MSC_VER))
+# include <stddef.h>
+# endif
+# include <string.h>
+# include <stdlib.h>
+#endif
+
+#ifndef local
+# define local static
+#endif
+/* compile with -Dlocal if your debugger can't find static symbols */
+
+typedef unsigned char uch;
+typedef uch FAR uchf;
+typedef unsigned short ush;
+typedef ush FAR ushf;
+typedef unsigned long ulg;
+
+extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
+/* (size given to avoid silly warnings with Visual C++) */
+
+#define ERR_MSG(err) z_errmsg[Z_NEED_DICT-(err)]
+
+#define ERR_RETURN(strm,err) \
+ return (strm->msg = (char*)ERR_MSG(err), (err))
+/* To be used only when the state is known to be valid */
+
+ /* common constants */
+
+#ifndef DEF_WBITS
+# define DEF_WBITS MAX_WBITS
+#endif
+/* default windowBits for decompression. MAX_WBITS is for compression only */
+
+#if MAX_MEM_LEVEL >= 8
+# define DEF_MEM_LEVEL 8
+#else
+# define DEF_MEM_LEVEL MAX_MEM_LEVEL
+#endif
+/* default memLevel */
+
+#define STORED_BLOCK 0
+#define STATIC_TREES 1
+#define DYN_TREES 2
+/* The three kinds of block type */
+
+#define MIN_MATCH 3
+#define MAX_MATCH 258
+/* The minimum and maximum match lengths */
+
+#define PRESET_DICT 0x20 /* preset dictionary flag in zlib header */
+
+ /* target dependencies */
+
+#if defined(MSDOS) || (defined(WINDOWS) && !defined(WIN32))
+# define OS_CODE 0x00
+# if defined(__TURBOC__) || defined(__BORLANDC__)
+# if (__STDC__ == 1) && (defined(__LARGE__) || defined(__COMPACT__))
+ /* Allow compilation with ANSI keywords only enabled */
+ void _Cdecl farfree( void *block );
+ void *_Cdecl farmalloc( unsigned long nbytes );
+# else
+# include <alloc.h>
+# endif
+# else /* MSC or DJGPP */
+# include <malloc.h>
+# endif
+#endif
+
+#ifdef AMIGA
+# define OS_CODE 0x01
+#endif
+
+#if defined(VAXC) || defined(VMS)
+# define OS_CODE 0x02
+# define F_OPEN(name, mode) \
+ fopen((name), (mode), "mbc=60", "ctx=stm", "rfm=fix", "mrs=512")
+#endif
+
+#if defined(ATARI) || defined(atarist)
+# define OS_CODE 0x05
+#endif
+
+#ifdef OS2
+# define OS_CODE 0x06
+# ifdef M_I86
+# include <malloc.h>
+# endif
+#endif
+
+#if defined(MACOS) || defined(TARGET_OS_MAC)
+# define OS_CODE 0x07
+# if defined(__MWERKS__) && __dest_os != __be_os && __dest_os != __win32_os
+# include <unix.h> /* for fdopen */
+# else
+# ifndef fdopen
+# define fdopen(fd,mode) NULL /* No fdopen() */
+# endif
+# endif
+#endif
+
+#ifdef TOPS20
+# define OS_CODE 0x0a
+#endif
+
+#ifdef WIN32
+# ifndef __CYGWIN__ /* Cygwin is Unix, not Win32 */
+# define OS_CODE 0x0b
+# endif
+#endif
+
+#ifdef __50SERIES /* Prime/PRIMOS */
+# define OS_CODE 0x0f
+#endif
+
+#if defined(_BEOS_) || defined(RISCOS)
+# define fdopen(fd,mode) NULL /* No fdopen() */
+#endif
+
+#if (defined(_MSC_VER) && (_MSC_VER > 600)) && !defined __INTERIX
+# if defined(_WIN32_WCE)
+# define fdopen(fd,mode) NULL /* No fdopen() */
+# ifndef _PTRDIFF_T_DEFINED
+ typedef int ptrdiff_t;
+# define _PTRDIFF_T_DEFINED
+# endif
+# else
+# define fdopen(fd,type) _fdopen(fd,type)
+# endif
+#endif
+
+#if defined(__BORLANDC__)
+ #pragma warn -8004
+ #pragma warn -8008
+ #pragma warn -8066
+#endif
+
+/* provide prototypes for these when building zlib without LFS */
+#if !defined(_LARGEFILE64_SOURCE) || _LFS64_LARGEFILE-0 == 0
+ ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, z_off_t));
+ ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off_t));
+#endif
+
+ /* common defaults */
+
+#ifndef OS_CODE
+# define OS_CODE 0x03 /* assume Unix */
+#endif
+
+#ifndef F_OPEN
+# define F_OPEN(name, mode) fopen((name), (mode))
+#endif
+
+ /* functions */
+
+#if defined(STDC99) || (defined(__TURBOC__) && __TURBOC__ >= 0x550)
+# ifndef HAVE_VSNPRINTF
+# define HAVE_VSNPRINTF
+# endif
+#endif
+#if defined(__CYGWIN__)
+# ifndef HAVE_VSNPRINTF
+# define HAVE_VSNPRINTF
+# endif
+#endif
+#ifndef HAVE_VSNPRINTF
+# ifdef MSDOS
+ /* vsnprintf may exist on some MS-DOS compilers (DJGPP?),
+ but for now we just assume it doesn't. */
+# define NO_vsnprintf
+# endif
+# ifdef __TURBOC__
+# define NO_vsnprintf
+# endif
+# ifdef WIN32
+ /* In Win32, vsnprintf is available as the "non-ANSI" _vsnprintf. */
+# if !defined(vsnprintf) && !defined(NO_vsnprintf)
+# if !defined(_MSC_VER) || ( defined(_MSC_VER) && _MSC_VER < 1500 )
+# define vsnprintf _vsnprintf
+# endif
+# endif
+# endif
+# ifdef __SASC
+# define NO_vsnprintf
+# endif
+#endif
+#ifdef VMS
+# define NO_vsnprintf
+#endif
+
+#if defined(pyr)
+# define NO_MEMCPY
+#endif
+#if defined(SMALL_MEDIUM) && !defined(_MSC_VER) && !defined(__SC__)
+ /* Use our own functions for small and medium model with MSC <= 5.0.
+ * You may have to use the same strategy for Borland C (untested).
+ * The __SC__ check is for Symantec.
+ */
+# define NO_MEMCPY
+#endif
+#if defined(STDC) && !defined(HAVE_MEMCPY) && !defined(NO_MEMCPY)
+# define HAVE_MEMCPY
+#endif
+#ifdef HAVE_MEMCPY
+# ifdef SMALL_MEDIUM /* MSDOS small or medium model */
+# define zmemcpy _fmemcpy
+# define zmemcmp _fmemcmp
+# define zmemzero(dest, len) _fmemset(dest, 0, len)
+# else
+# define zmemcpy memcpy
+# define zmemcmp memcmp
+# define zmemzero(dest, len) memset(dest, 0, len)
+# endif
+#else
+ void ZLIB_INTERNAL zmemcpy OF((Bytef* dest, const Bytef* source, uInt len));
+ int ZLIB_INTERNAL zmemcmp OF((const Bytef* s1, const Bytef* s2, uInt len));
+ void ZLIB_INTERNAL zmemzero OF((Bytef* dest, uInt len));
+#endif
+
+/* Diagnostic functions */
+#ifdef DEBUG
+# include <stdio.h>
+ extern int ZLIB_INTERNAL z_verbose;
+ extern void ZLIB_INTERNAL z_error OF((char *m));
+# define Assert(cond,msg) {if(!(cond)) z_error(msg);}
+# define Trace(x) {if (z_verbose>=0) fprintf x ;}
+# define Tracev(x) {if (z_verbose>0) fprintf x ;}
+# define Tracevv(x) {if (z_verbose>1) fprintf x ;}
+# define Tracec(c,x) {if (z_verbose>0 && (c)) fprintf x ;}
+# define Tracecv(c,x) {if (z_verbose>1 && (c)) fprintf x ;}
+#else
+# define Assert(cond,msg)
+# define Trace(x)
+# define Tracev(x)
+# define Tracevv(x)
+# define Tracec(c,x)
+# define Tracecv(c,x)
+#endif
+
+
+voidpf ZLIB_INTERNAL zcalloc OF((voidpf opaque, unsigned items,
+ unsigned size));
+void ZLIB_INTERNAL zcfree OF((voidpf opaque, voidpf ptr));
+
+#define ZALLOC(strm, items, size) \
+ (*((strm)->zalloc))((strm)->opaque, (items), (size))
+#define ZFREE(strm, addr) (*((strm)->zfree))((strm)->opaque, (voidpf)(addr))
+#define TRY_FREE(s, p) {if (p) ZFREE(s, p);}
+
+#endif /* ZUTIL_H */
diff --git a/libs/system/zc702evk/nucleus/arch/arm/arch.h b/libs/system/zc702evk/nucleus/arch/arm/arch.h
--- /dev/null
@@ -0,0 +1,44 @@
+/***********************************************************************\r
+*\r
+* Copyright 2010 Mentor Graphics Corporation\r
+* All Rights Reserved.\r
+*\r
+* THIS WORK CONTAINS TRADE SECRET AND PROPRIETARY INFORMATION WHICH IS\r
+* THE PROPERTY OF MENTOR GRAPHICS CORPORATION OR ITS LICENSORS AND IS\r
+* SUBJECT TO LICENSE TERMS.\r
+*\r
+************************************************************************\r
+\r
+************************************************************************\r
+*\r
+* FILE NAME\r
+*\r
+* arch.h\r
+*\r
+* DESCRIPTION\r
+*\r
+* This file is a wrapper header file that includes all the necessary\r
+* header files for the given architecture\r
+*\r
+* DATA STRUCTURES\r
+*\r
+* None\r
+*\r
+* DEPENDENCIES\r
+*\r
+* None\r
+*\r
+***********************************************************************/\r
+\r
+#ifndef ARCH_H\r
+#define ARCH_H\r
+\r
+/* Include configuration header file */\r
+#include "nucleus_gen_cfg.h"\r
+\r
+/* Include ARM common header files */\r
+#include "arm_debug_defs.h"\r
+#include "arm_defs.h"\r
+#include "arm_mmu_defs.h"\r
+\r
+#endif /* ARCH_H */\r
diff --git a/libs/system/zc702evk/nucleus/arch/arm/arm_debug_defs.h b/libs/system/zc702evk/nucleus/arch/arm/arm_debug_defs.h
--- /dev/null
@@ -0,0 +1,139 @@
+/***********************************************************************\r
+*\r
+* Copyright 2006 Mentor Graphics Corporation\r
+* All Rights Reserved.\r
+*\r
+* THIS WORK CONTAINS TRADE SECRET AND PROPRIETARY INFORMATION WHICH IS\r
+* THE PROPERTY OF MENTOR GRAPHICS CORPORATION OR ITS LICENSORS AND IS\r
+* SUBJECT TO LICENSE TERMS.\r
+*\r
+************************************************************************\r
+\r
+************************************************************************\r
+*\r
+* FILE NAME\r
+*\r
+* arm_debug_defs.h\r
+*\r
+* DESCRIPTION\r
+*\r
+* This file contains all definitions, structures, etc for the\r
+* ARM Debug.\r
+*\r
+* DATA STRUCTURES\r
+*\r
+* None\r
+*\r
+* DEPENDENCIES\r
+*\r
+* None\r
+*\r
+***********************************************************************/\r
+\r
+#ifndef ARM_DEBUG_DEFS_H\r
+#define ARM_DEBUG_DEFS_H\r
+\r
+/* External functions */\r
+extern VOID ESAL_AR_DBG_Exception_Exit(VOID);\r
+\r
+/* Debug Support flags */\r
+#define ESAL_GE_DBG_SUPPORT_HW_STEP (0x1 << 0)\r
+\r
+/* Protocol specific register model definitions */\r
+#define NU_REG_RSP_MODE 1 \r
+#define NU_REG_MDP_MODE 2\r
+\r
+/* Remote Serial Protocol for GNU Debugger */\r
+#define ESAL_AR_DBG_RSP_NUM_REGS 26\r
+#define ESAL_AR_DBG_RSP_BLOCK_REGS 16\r
+#define ESAL_AR_DBG_STACK_PTR_REGID 13\r
+#define ESAL_AR_DBG_PC_IDX_REGID 15\r
+\r
+/* Register Mapping values (positive values are register offsets) */\r
+#define ESAL_AR_DBG_REG_NOT_MAPPED -1\r
+#define ESAL_AR_DBG_REG_STACK_POINTER -2\r
+\r
+/* Register definition */\r
+#define ESAL_AR_DBG_REG_R0 0x00\r
+#define ESAL_AR_DBG_REG_R1 0x01\r
+#define ESAL_AR_DBG_REG_R2 0x02\r
+#define ESAL_AR_DBG_REG_R3 0x03\r
+#define ESAL_AR_DBG_REG_R4 0x04\r
+#define ESAL_AR_DBG_REG_R5 0x05\r
+#define ESAL_AR_DBG_REG_R6 0x06\r
+#define ESAL_AR_DBG_REG_R7 0x07\r
+#define ESAL_AR_DBG_REG_R8 0x08\r
+#define ESAL_AR_DBG_REG_R9 0x09\r
+#define ESAL_AR_DBG_REG_R10 0x0A\r
+#define ESAL_AR_DBG_REG_R11 0x0B\r
+#define ESAL_AR_DBG_REG_R12 0x0C\r
+#define ESAL_AR_DBG_REG_R13 0x0D\r
+#define ESAL_AR_DBG_REG_R14 0x0E\r
+#define ESAL_AR_DBG_REG_R15 0x0F\r
+#define ESAL_AR_DBG_REG_FPR0 0x10\r
+#define ESAL_AR_DBG_REG_FPR1 0x11\r
+#define ESAL_AR_DBG_REG_FPR2 0x12\r
+#define ESAL_AR_DBG_REG_FPR3 0x13\r
+#define ESAL_AR_DBG_REG_FPR4 0x14\r
+#define ESAL_AR_DBG_REG_FPR5 0x15\r
+#define ESAL_AR_DBG_REG_FPR6 0x16\r
+#define ESAL_AR_DBG_REG_FPR7 0x17\r
+#define ESAL_AR_DBG_REG_FPS 0x18\r
+#define ESAL_AR_DBG_REG_CPSR 0x19\r
+\r
+/* Number of maximum registers in stack frame */\r
+#define ESAL_AR_DBG_NUM_REGS ESAL_AR_DBG_RSP_NUM_REGS\r
+\r
+/* Number of expedited registers */\r
+#define ESAL_AR_DBG_EXP_NUM_REGS 3\r
+\r
+/* breakpoint instructions for specific instruction replacement */\r
+#define ESAL_AR_DBG_ARM_BRK_OPCODE 0xE7FDDEFE\r
+#define ESAL_AR_DBG_THUMB_BRK_OPCODE 0x0000DEFE\r
+\r
+/* NOP instructions for specific instruction replacement */\r
+#define ESAL_AR_DBG_ARM_NOP_OPCODE 0xE1A00000 \r
+#define ESAL_AR_DBG_THUMB_NOP_OPCODE 0x1C00\r
+\r
+/* Define flags for PSR */\r
+#define ESAL_AR_DBG_PSR_N ESAL_GE_MEM_32BIT_SET(31)\r
+#define ESAL_AR_DBG_PSR_Z ESAL_GE_MEM_32BIT_SET(30)\r
+#define ESAL_AR_DBG_PSR_C ESAL_GE_MEM_32BIT_SET(29)\r
+#define ESAL_AR_DBG_PSR_V ESAL_GE_MEM_32BIT_SET(28)\r
+#define ESAL_AR_DBG_PSR_Q ESAL_GE_MEM_32BIT_SET(27) \r
+#define ESAL_AR_DBG_PSR_I ESAL_GE_MEM_32BIT_SET(7)\r
+#define ESAL_AR_DBG_PSR_F ESAL_GE_MEM_32BIT_SET(6)\r
+#define ESAL_AR_DBG_PSR_T ESAL_GE_MEM_32BIT_SET(5)\r
+#define ESAL_AR_DBG_PSR_M 0x0000001f\r
+#define ESAL_AR_DBG_PSR_M32 0x00000010\r
+#define ESAL_AR_DBG_PSR_M_USER 0x00000000\r
+#define ESAL_AR_DBG_PSR_M_FIQ 0x00000001\r
+#define ESAL_AR_DBG_PSR_M_IRQ 0x00000002\r
+#define ESAL_AR_DBG_PSR_M_SVC 0x00000003\r
+#define ESAL_AR_DBG_PSR_M_ABORT 0x00000007\r
+#define ESAL_AR_DBG_PSR_M_UNDEF 0x0000000b\r
+#define ESAL_AR_DBG_PSR_M_SYSTEM 0x0000000f\r
+#define ESAL_AR_DBG_PSR_32_IF (ESAL_ARM_PSR_I+ESAL_ARM_PSR_F)\r
+\r
+/* Macro definitions for helping decoding instruction */\r
+#define ESAL_AR_DBG_ToPsr(x) (((x) & ~ESAL_AR_DBG_ARM_PSR_32_IF) | (((x) & ESAL_AR_DBG_ARM_PSR_32_IF) << 20))\r
+#define ESAL_AR_DBG_PcplusPsr(pc_val, psr_val)((psr_val & ESAL_AR_DBG_ARM_PSR_M32) ? (pc_val) : \\r
+ (pc_val) | ESAL_AR_DBG_ToPsr(psr_val))\r
+\r
+/* Defines ARM shift type */\r
+typedef enum\r
+{\r
+ ESAL_ST_LSL, \r
+ ESAL_ST_LSR, \r
+ ESAL_ST_ASR, \r
+ ESAL_ST_ROR\r
+\r
+} ESAL_AR_DBG_SHIFT_TYPE;\r
+\r
+/* Define Opcode type */\r
+typedef UINT32 ESAL_AR_DBG_OPCODE;\r
+\r
+/* Define Register type */\r
+typedef UINT32 ESAL_AR_DBG_REG;\r
+\r
+#endif /* ARM_DEBUG_DEFS_H */\r
diff --git a/libs/system/zc702evk/nucleus/arch/arm/arm_defs.h b/libs/system/zc702evk/nucleus/arch/arm/arm_defs.h
--- /dev/null
@@ -0,0 +1,345 @@
+/***********************************************************************\r
+*\r
+* Copyright 2006 Mentor Graphics Corporation\r
+* All Rights Reserved.\r
+*\r
+* THIS WORK CONTAINS TRADE SECRET AND PROPRIETARY INFORMATION WHICH IS\r
+* THE PROPERTY OF MENTOR GRAPHICS CORPORATION OR ITS LICENSORS AND IS\r
+* SUBJECT TO LICENSE TERMS.\r
+*\r
+************************************************************************\r
+\r
+************************************************************************\r
+*\r
+* FILE NAME\r
+*\r
+* arm_defs.h\r
+*\r
+* DESCRIPTION\r
+*\r
+* This file contains all definitions, structures, etc for the\r
+* base ARM architecture.\r
+*\r
+* DATA STRUCTURES\r
+*\r
+* None\r
+*\r
+* DEPENDENCIES\r
+*\r
+* None\r
+*\r
+***********************************************************************/\r
+\r
+#ifndef ARM_DEFS_H\r
+#define ARM_DEFS_H\r
+\r
+/* Define if the OS timer is part of the architecture (NU_TRUE)\r
+ NOTE: The OS timer can be located at only one of the following levels of\r
+ abstraction: the processor level or the architecture level. \r
+ If ESAL_AR_OS_TIMER_USED is NU_TRUE, the OS timer is contained\r
+ within the architecture. If ESAL_AR_OS_TIMER_USED is NU_FALSE,\r
+ the OS timer is contained within the processor component. */\r
+#define ESAL_AR_OS_TIMER_USED NU_FALSE\r
+\r
+/* Define if architecture supports unaligned 16-bit accesses to memory. */\r
+#define ESAL_AR_UNALIGNED_16BIT_SPT NU_FALSE\r
+\r
+/* Define if architecture supports unaligned 32-bit accesses to memory. */\r
+#define ESAL_AR_UNALIGNED_32BIT_SPT NU_FALSE\r
+\r
+/* Define number of accesses required to read or write a pointer */\r
+#define ESAL_AR_PTR_ACCESS 1\r
+\r
+/* Define number of accesses required to read or write a 32-bit value */\r
+#define ESAL_AR_32BIT_ACCESS 1\r
+\r
+/* Size, in bytes, of architecture system stack. This stack will be\r
+ utilized when servicing interrupts. */\r
+#define ESAL_AR_SYSTEM_STACK_SIZE CFG_NU_OS_ARCH_ARM_COM_SYSTEM_STACK_SIZE\r
+\r
+#if (CFG_NU_OS_ARCH_ARM_COM_FPU_SUPPORT == 2)\r
+\r
+/* Define number of single-precision floating point registers */\r
+#define ESAL_AR_STK_NUM_FPU_REGS 64\r
+\r
+#else\r
+\r
+/* Define number of single-precision floating point registers */\r
+#define ESAL_AR_STK_NUM_FPU_REGS 32\r
+\r
+#endif /* (CFG_NU_OS_ARCH_ARM_COM_FPU_SUPPORT == 2) */\r
+\r
+/* Define number of single-precision floating point registers required to\r
+ be saved within a toolset stack frame (s16-s31) */\r
+#define ESAL_TS_STK_NUM_FPU_REGS 16\r
+\r
+/* Define bit mask used to determine if THUMB state for a given code pointer */\r
+#define ESAL_AR_STK_THUMB_MASK ESAL_GE_MEM_32BIT_SET(0)\r
+\r
+/* Define stack frame structure for minimum architecture registers required\r
+ to be saved in order to enter a C environment during in interrupt / exception.\r
+ These registers are the "scratch" registers that will not be preserved across \r
+ a function call boundary and any interrupt state registers that must preserved\r
+ to allow interrupt nesting. */\r
+typedef struct\r
+{\r
+ UINT32 r0;\r
+ UINT32 r1;\r
+ UINT32 r2;\r
+ UINT32 r3;\r
+ UINT32 r12;\r
+ UINT32 spsr; \r
+ UINT32 lr;\r
+ UINT32 rtn_address;\r
+\r
+} ESAL_AR_STK_MIN;\r
+\r
+/* Define stack frame structure for the architecture supported. \r
+ This stack frame contains all registers that must be preserved\r
+ across an (unsolicited) interrupt context switch.\r
+ NOTE: This stack frame includes the minimum stack frame\r
+ defined above AND all other registers for the given\r
+ architecture. */\r
+typedef struct ESAL_AR_STK_STRUCT\r
+{\r
+ UINT32 stack_type;\r
+ UINT32 r4;\r
+ UINT32 r5;\r
+ UINT32 r6;\r
+ UINT32 r7;\r
+ UINT32 r8;\r
+ UINT32 r9;\r
+ UINT32 r10;\r
+ UINT32 r11;\r
+\r
+#if (CFG_NU_OS_ARCH_ARM_COM_FPU_SUPPORT > 0)\r
+\r
+ UINT32 fpscr;\r
+ UINT32 s[ESAL_AR_STK_NUM_FPU_REGS];\r
+\r
+#endif /* CFG_NU_OS_ARCH_ARM_COM_FPU_SUPPORT > 0 */\r
+\r
+ ESAL_AR_STK_MIN min_stack;\r
+\r
+} ESAL_AR_STK;\r
+\r
+/* Define stack frame structure for the toolset / architecture supported. */\r
+typedef struct ESAL_TS_STK_STRUCT\r
+{\r
+ UINT32 stack_type;\r
+ UINT32 r4;\r
+ UINT32 r5;\r
+ UINT32 r6;\r
+ UINT32 r7;\r
+ UINT32 r8;\r
+ UINT32 r9;\r
+ UINT32 r10;\r
+ UINT32 r11;\r
+ UINT32 rtn_address;\r
+\r
+#if (CFG_NU_OS_ARCH_ARM_COM_FPU_SUPPORT > 0)\r
+\r
+ UINT32 fpscr;\r
+ UINT32 s[ESAL_TS_STK_NUM_FPU_REGS];\r
+\r
+#endif /* CFG_NU_OS_ARCH_ARM_COM_FPU_SUPPORT > 0 */\r
+\r
+} ESAL_TS_STK;\r
+\r
+/* Coprocessor registers */\r
+#define ESAL_TS_RTE_CP0 p0\r
+#define ESAL_TS_RTE_CP1 p1\r
+#define ESAL_TS_RTE_CP2 p2\r
+#define ESAL_TS_RTE_CP3 p3\r
+#define ESAL_TS_RTE_CP4 p4\r
+#define ESAL_TS_RTE_CP5 p5\r
+#define ESAL_TS_RTE_CP6 p6\r
+#define ESAL_TS_RTE_CP7 p7\r
+#define ESAL_TS_RTE_CP8 p8\r
+#define ESAL_TS_RTE_CP9 p9\r
+#define ESAL_TS_RTE_CP10 p10\r
+#define ESAL_TS_RTE_CP11 p11\r
+#define ESAL_TS_RTE_CP12 p12\r
+#define ESAL_TS_RTE_CP13 p13\r
+#define ESAL_TS_RTE_CP14 p14\r
+#define ESAL_TS_RTE_CP15 p15\r
+\r
+/* CRn and CRm register values */\r
+#define ESAL_TS_RTE_C0 c0\r
+#define ESAL_TS_RTE_C1 c1\r
+#define ESAL_TS_RTE_C2 c2\r
+#define ESAL_TS_RTE_C3 c3\r
+#define ESAL_TS_RTE_C4 c4\r
+#define ESAL_TS_RTE_C5 c5\r
+#define ESAL_TS_RTE_C6 c6\r
+#define ESAL_TS_RTE_C7 c7\r
+#define ESAL_TS_RTE_C8 c8\r
+#define ESAL_TS_RTE_C9 c9\r
+#define ESAL_TS_RTE_C10 c10\r
+#define ESAL_TS_RTE_C11 c11\r
+#define ESAL_TS_RTE_C12 c12\r
+#define ESAL_TS_RTE_C13 c13\r
+#define ESAL_TS_RTE_C14 c14\r
+#define ESAL_TS_RTE_C15 c15\r
+\r
+/* Size, in bytes, of architecture exception stack. This stack will be\r
+ utilized when servicing exceptions. */\r
+#define ESAL_AR_EXCEPTION_STACK_SIZE 2048\r
+\r
+/* Define if interrupt servicing initialization is required at the \r
+ architecture level. */\r
+#define ESAL_AR_ISR_INIT_REQUIRED NU_TRUE\r
+\r
+/* Define if architecture mandates that all interrupt handlers perform a\r
+ "return from interrupt" (RTI) instruction in order for the hardware to\r
+ correctly restore the state of execution to the pre-interrupt condition.\r
+ NOTE: Most architectures allow the state of execution to be restored \r
+ without needing to perform an RTI. In most cases, this will be set \r
+ to NU_FALSE */\r
+#define ESAL_AR_ISR_RTI_MANDATORY NU_FALSE\r
+\r
+/* Define bit values for the architecture's status register / machine state register /\r
+ etc that are used to enable and disable interrupts for the given architecture. */\r
+#define ESAL_AR_INTERRUPTS_DISABLE_BITS 0x000000C0\r
+#define ESAL_AR_INTERRUPTS_ENABLE_BITS 0x00000000\r
+\r
+/* CPSR bit defines / masks */\r
+#define ESAL_AR_INT_CPSR_THUMB ESAL_GE_MEM_32BIT_SET(5)\r
+#define ESAL_AR_INT_CPSR_MODE_MASK 0x0000001F\r
+#define ESAL_AR_INT_CPSR_SYS_MODE 0x0000001F\r
+#define ESAL_AR_INT_CPSR_IRQ_MODE 0x00000012\r
+#define ESAL_AR_INT_CPSR_FIQ_MODE 0x00000011\r
+#define ESAL_AR_INT_CPSR_SUP_MODE 0x00000013\r
+#define ESAL_AR_INT_CPSR_E_BIT 0x00000200 \r
+#define ESAL_AR_INT_CPSR_IRQ_BIT ESAL_GE_MEM_32BIT_SET(7)\r
+#define ESAL_AR_INT_CPSR_FIQ_BIT ESAL_GE_MEM_32BIT_SET(6)\r
+#define ESAL_AR_INT_CPSR_SYS_DISABLED (ESAL_AR_INT_CPSR_SYS_MODE | \\r
+ ESAL_AR_INTERRUPTS_DISABLE_BITS)\r
+\r
+/* Defines used to specify an interrupt source type as FIQ or IRQ. This value\r
+ can be bitwise OR'd with the priority field when enabling an interrupt source via\r
+ the ESAL_GE_INT_Enable API to specify if an interrupt will be routed as an FIQ or IRQ.\r
+ The default for all interrupt sources is IRQ routed (interrupt will be IRQ routed if\r
+ no value is bitwise OR'd with the priority).\r
+ NOTE: This operation is not supported by all ARM processor implementations - some \r
+ processors allow any interrupt source to be either FIQ or IRQ while other\r
+ do not allow this functionality. */\r
+#define ESAL_AR_INT_IRQ_ROUTED (INT)0x00001000\r
+#define ESAL_AR_INT_FIQ_ROUTED (INT)0x00002000\r
+\r
+/* Define ESAL interrupt vector IDs for this architecture.\r
+ These IDs match up with architecture interrupts.\r
+ Values correspond to the index of entries in ESAL_GE_ISR_Interrupt_Handler[].\r
+ Names are of the form ESAL_AR_<Name>_INT_VECTOR_ID, where <Name> comes\r
+ directly from the hardware documentation */\r
+#define ESAL_AR_IRQ_INT_VECTOR_ID 0\r
+#define ESAL_AR_FIQ_INT_VECTOR_ID 1\r
+\r
+/* Define the last ESAL interrupt vector ID for this architecture + 1 */\r
+#define ESAL_AR_INT_VECTOR_ID_DELIMITER (ESAL_AR_FIQ_INT_VECTOR_ID + 1)\r
+\r
+/* Define ESAL exception vector IDs for the architecture.\r
+ These IDs match up with architecture exceptions.\r
+ Values correspond to the index of entries in ESAL_GE_ISR_Exception_Handler[].\r
+ Names are of the form ESAL_AR_<Name>_EXCEPT_VECTOR_ID, where <Name> comes\r
+ directly from the hardware documentation */\r
+#define ESAL_AR_UNDEF_EXCEPT_VECTOR_ID 0\r
+#define ESAL_AR_SWI_EXCEPT_VECTOR_ID 1\r
+#define ESAL_AR_PREFETCH_EXCEPT_VECTOR_ID 2\r
+#define ESAL_AR_DATA_EXCEPT_VECTOR_ID 3\r
+\r
+/* Define the last ESAL exception vector ID for this architecture + 1 */\r
+#define ESAL_AR_EXCEPT_VECTOR_ID_DELIMITER (ESAL_AR_DATA_EXCEPT_VECTOR_ID + 1)\r
+\r
+/* Define variable(s) required to save / restore architecture interrupt state.\r
+ These variable(s) are used in conjunction with the ESAL_AR_INT_ALL_DISABLE() and\r
+ ESAL_AR_INT_ALL_RESTORE() macros to hold any data that must be preserved in\r
+ order to allow these macros to function correctly. */\r
+#define ESAL_AR_INT_CONTROL_VARS INT esal_ar_int_tmp;\r
+\r
+/* This macro locks out interrupts and saves the current\r
+ architecture status register / state register to the specified\r
+ address. This function does not attempt to mask any bits in\r
+ the return register value and can be used as a quick method\r
+ to guard a critical section.\r
+ NOTE: This macro is used in conjunction with ESAL_AR_INT_ALL_RESTORE\r
+ defined below and ESAL_AR_INT_CONTROL_VARS defined above. */\r
+#define ESAL_AR_INT_ALL_DISABLE() \\r
+ { \\r
+ ESAL_TS_RTE_CPSR_CXSF_READ(&esal_ar_int_tmp); \\r
+ ESAL_TS_RTE_CPSR_C_WRITE(ESAL_AR_INT_CPSR_SYS_DISABLED); \\r
+ }\r
+\r
+/* This macro restores the architecture status / state register\r
+ used to lockout interrupts to the value provided. The\r
+ intent of this function is to be a fast mechanism to restore the\r
+ interrupt level at the end of a critical section to its\r
+ original level.\r
+ NOTE: This macro is used in conjunction with ESAL_AR_INT_ALL_DISABLE\r
+ and ESAL_AR_INT_CONTROL_VARS defined above. */\r
+#define ESAL_AR_INT_ALL_RESTORE() \\r
+ { \\r
+ ESAL_TS_RTE_CPSR_CXSF_WRITE(esal_ar_int_tmp); \\r
+ }\r
+\r
+/* This macro locks-out interrupts but doesn't save the status\r
+ register / control register value. */\r
+#define ESAL_AR_INT_FAST_ALL_DISABLE() \\r
+ { \\r
+ ESAL_TS_RTE_CPSR_C_WRITE(ESAL_AR_INT_CPSR_SYS_DISABLED); \\r
+ }\r
+\r
+/* This macro unlocks interrupts but doesn't save the status\r
+ register / control register value. */\r
+#define ESAL_AR_INT_FAST_ALL_ENABLE() \\r
+ { \\r
+ ESAL_TS_RTE_CPSR_C_WRITE(ESAL_AR_INT_CPSR_SYS_MODE); \\r
+ }\r
+\r
+/* This macro sets the interrupt related bits in the status register / control\r
+ register to the specified value. */\r
+#define ESAL_AR_INT_BITS_SET(set_bits) \\r
+ { \\r
+ INT tmp_val; \\r
+ \\r
+ ESAL_TS_RTE_CPSR_CXSF_READ(&tmp_val); \\r
+ tmp_val &= ~ESAL_AR_INTERRUPTS_DISABLE_BITS; \\r
+ tmp_val |= set_bits; \\r
+ ESAL_TS_RTE_CPSR_CXSF_WRITE(tmp_val); \\r
+ }\r
+\r
+/* This macro gets the interrupt related bits from the status register / control\r
+ register. */\r
+#define ESAL_AR_INT_BITS_GET(get_bits_ptr) \\r
+ { \\r
+ INT tmp_val; \\r
+ \\r
+ ESAL_TS_RTE_CPSR_CXSF_READ(&tmp_val); \\r
+ tmp_val &= ESAL_AR_INTERRUPTS_DISABLE_BITS; \\r
+ *get_bits_ptr = tmp_val; \\r
+ }\r
+\r
+/* Vector table address for ARM when running from ROM */\r
+#define ESAL_AR_ISR_VECTOR_TABLE_DEST_ADDR_ROM 0x00000000\r
+\r
+/* Size of ARM vector table (in bytes) */\r
+#define ESAL_AR_ISR_VECTOR_TABLE_SIZE 64\r
+\r
+/* Number of 32-bit registers saved on interrupt stack */\r
+#define ESAL_AR_ISR_STACK_SIZE 3\r
+\r
+/* Size, in bytes, of supervisor stack */\r
+#define ESAL_AR_ISR_SUP_STACK_SIZE 256\r
+\r
+/* Define breakpoint instruction used for XScale \r
+ processors (after vector table installation) */\r
+#define ESAL_AR_ISR_XSCALE_VECT_INSTALL_BRK 0x1234\r
+\r
+/* Determines where the ISR nesting counter is incremented. \r
+ When set to 0 the increment occurs in assembly files, when \r
+ set to 1 the increment will occur in c files. */\r
+#define ESAL_AR_ISR_INCREMENT_IN_C NU_TRUE\r
+\r
+\r
+#endif /* ARM_DEFS_H */\r
+\r
diff --git a/libs/system/zc702evk/nucleus/arch/arm/arm_mmu_defs.h b/libs/system/zc702evk/nucleus/arch/arm/arm_mmu_defs.h
--- /dev/null
@@ -0,0 +1,775 @@
+/***********************************************************************\r
+*\r
+* Copyright 2006 Mentor Graphics Corporation\r
+* All Rights Reserved.\r
+*\r
+* THIS WORK CONTAINS TRADE SECRET AND PROPRIETARY INFORMATION WHICH IS\r
+* THE PROPERTY OF MENTOR GRAPHICS CORPORATION OR ITS LICENSORS AND IS\r
+* SUBJECT TO LICENSE TERMS.\r
+*\r
+************************************************************************\r
+\r
+************************************************************************\r
+*\r
+* FILE NAME\r
+*\r
+* arm_mmu_defs.h\r
+*\r
+* DESCRIPTION\r
+*\r
+* This file contains all definitions, structures, etc for the\r
+* ARM MMU.\r
+*\r
+* DATA STRUCTURES\r
+*\r
+* None\r
+*\r
+* DEPENDENCIES\r
+*\r
+* None\r
+*\r
+***********************************************************************/\r
+\r
+#ifndef ARM_MMU_DEFS_H\r
+#define ARM_MMU_DEFS_H\r
+\r
+/* Define core cache availability\r
+ NOTE: A differentiation is made in ESAL between cache that\r
+ is contained on a processor and cache that is\r
+ inherent as part of a core (L2 vs L1 cache). */\r
+#define ESAL_CO_CACHE_AVAILABLE NU_TRUE\r
+\r
+/*********************************************\r
+* ARM v4/5 & v6/7 MMU Variant definitions\r
+*********************************************/\r
+\r
+#if (CFG_NU_OS_ARCH_ARM_COM_MMU_VARIANT != 2)\r
+\r
+/* Translation table is 16K in size */\r
+#define ESAL_CO_MEM_TTB_SIZE ESAL_GE_MEM_16K\r
+\r
+/* Each TTB descriptor covers a 1MB region */\r
+#define ESAL_CO_MEM_TTB_SECT_SIZE ESAL_GE_MEM_1M\r
+\r
+/* Mask off lower bits of addr */\r
+#define ESAL_CO_MEM_TTB_SECT_SIZE_MASK (~(ESAL_CO_MEM_TTB_SECT_SIZE-1UL))\r
+\r
+/* Define shift to convert memory address to index of translation table entry (descriptor).\r
+ Shift 20 bits (for a 1MB section) - 2 bits (for a 4 byte TTB descriptor) */\r
+#define ESAL_CO_MEM_TTB_SECT_TO_DESC_SHIFT (20-2)\r
+\r
+/* Define domain access values */\r
+#define ESAL_CO_MEM_DOMAIN_D0_MANAGER_ACCESS 0x3\r
+\r
+#define ESAL_CO_MEM_TTB_DESC_BACKWARDS ESAL_GE_MEM_32BIT_SET(4)\r
+#define ESAL_CO_MEM_TTB_DESC_AP_MANAGER (ESAL_GE_MEM_32BIT_SET(10) | \\r
+ ESAL_GE_MEM_32BIT_SET(11))\r
+#define ESAL_CO_MEM_TTB_DESC_SECT ESAL_GE_MEM_32BIT_SET(1)\r
+\r
+/* Define translation table descriptor bits */\r
+#define ESAL_CO_MEM_TTB_DESC_B ESAL_GE_MEM_32BIT_SET(2)\r
+#define ESAL_CO_MEM_TTB_DESC_C ESAL_GE_MEM_32BIT_SET(3)\r
+#define ESAL_CO_MEM_TTB_DESC_TEX ESAL_GE_MEM_32BIT_SET(12)\r
+#define ESAL_CO_MEM_TTB_DESC_S ESAL_GE_MEM_32BIT_SET(16)\r
+\r
+#endif /* (CFG_NU_OS_ARCH_ARM_COM_MMU_VARIANT != 2) */\r
+\r
+/*********************************************\r
+* ARM v7-R MPU definitions\r
+*********************************************/\r
+#if (CFG_NU_OS_ARCH_ARM_COM_MMU_VARIANT == 2)\r
+\r
+/* Define MPU region attribute bits. */\r
+#define ESAL_CO_MEM_MPU_ATTR_B ESAL_GE_MEM_32BIT_SET(0)\r
+#define ESAL_CO_MEM_MPU_ATTR_C ESAL_GE_MEM_32BIT_SET(1)\r
+#define ESAL_CO_MEM_MPU_ATTR_S ESAL_GE_MEM_32BIT_SET(2)\r
+#define ESAL_CO_MEM_MPU_ATTR_TEX ESAL_GE_MEM_32BIT_SET(3)\r
+#define ESAL_CO_MEM_MPU_AP_XN ESAL_GE_MEM_32BIT_SET(12)\r
+#define ESAL_CO_MEM_MPU_AP_FULL (ESAL_GE_MEM_32BIT_SET(8) | \\r
+ ESAL_GE_MEM_32BIT_SET(9))\r
+#define ESAL_CO_MEM_MPU_AP_RO (ESAL_GE_MEM_32BIT_SET(9) | \\r
+ ESAL_GE_MEM_32BIT_SET(10))\r
+#define ESAL_CO_MEM_MPU_REG_ENABLE ESAL_GE_MEM_32BIT_SET(0)\r
+#define ESAL_CO_MEM_MPU_REG_COUNT_MASK 0xFF00\r
+\r
+#endif /* (CFG_NU_OS_ARCH_ARM_COM_MMU_VARIANT == 2) */\r
+\r
+/*********************************************\r
+* Common definitions\r
+*********************************************/\r
+/* Define CP15 Register 1: control register bits */\r
+#define ESAL_CO_MEM_CP15_CTRL_V ESAL_GE_MEM_32BIT_SET(13)\r
+#define ESAL_CO_MEM_CP15_CTRL_I ESAL_GE_MEM_32BIT_SET(12)\r
+#define ESAL_CO_MEM_CP15_CTRL_Z ESAL_GE_MEM_32BIT_SET(11)\r
+#define ESAL_CO_MEM_CP15_CTRL_W ESAL_GE_MEM_32BIT_SET(3)\r
+#define ESAL_CO_MEM_CP15_CTRL_C ESAL_GE_MEM_32BIT_SET(2)\r
+#define ESAL_CO_MEM_CP15_CTRL_A ESAL_GE_MEM_32BIT_SET(1)\r
+#define ESAL_CO_MEM_CP15_CTRL_M ESAL_GE_MEM_32BIT_SET(0)\r
+\r
+/* MVA Format SBZ mask */\r
+#define ESAL_CO_MEM_MVA_SBZ_MASK ~(ESAL_CO_MEM_CACHE_LINE_SIZE - 1UL)\r
+\r
+/* Defines related to Cache Level ID Register */\r
+#define ESAL_CO_MEM_DCACHE_SIZE_SHIFT 16\r
+#define ESAL_CO_MEM_CACHE_SIZE_BIT 4\r
+#define ESAL_CO_MEM_CACHE_SIZE_MASK 0xF\r
+\r
+/*********************************************\r
+* ARM v4/5 MMU Variant definitions\r
+*********************************************/\r
+#if (CFG_NU_OS_ARCH_ARM_COM_MMU_VARIANT == 0)\r
+\r
+/* Define all access (manager access permission / not cachable / not buffered) */\r
+#define ESAL_CO_MEM_TTB_DESC_ALL_ACCESS (ESAL_CO_MEM_TTB_DESC_AP_MANAGER | \\r
+ ESAL_CO_MEM_TTB_DESC_BACKWARDS | \\r
+ ESAL_CO_MEM_TTB_DESC_SECT)\r
+\r
+/* The size of each cache segment (in bytes) */\r
+#define ESAL_CO_MEM_CACHE_LINE_SIZE 32\r
+\r
+/* Define the set and way sizes and bit shift values */\r
+#define ESAL_CO_MEM_CACHE_WAY_SIZE 4\r
+#define ESAL_CO_MEM_DSIZE_BITSHIFT 18\r
+#define ESAL_CO_MEM_CACHE_SET_SHIFT 2\r
+#define ESAL_CO_MEM_CACHE_WAY_SHIFT 30\r
+\r
+#if (ESAL_CO_CACHE_AVAILABLE == NU_TRUE)\r
+\r
+/* This macro invalidates all of the cache at the core level. */\r
+#define ESAL_CO_MEM_CACHE_ALL_INVALIDATE() \\r
+ { \\r
+ ESAL_TS_RTE_CP_WRITE(ESAL_TS_RTE_CP15, 0, \\r
+ 0, ESAL_TS_RTE_C7, \\r
+ ESAL_TS_RTE_C7, 0); \\r
+ }\r
+\r
+/* This macro invalidates all of the data cache at the core level. */\r
+#define ESAL_CO_MEM_DCACHE_ALL_INVALIDATE() \\r
+ { \\r
+ ESAL_TS_RTE_CP_WRITE(ESAL_TS_RTE_CP15, 0, \\r
+ 0, ESAL_TS_RTE_C7, \\r
+ ESAL_TS_RTE_C6, 0); \\r
+ }\r
+\r
+/* This macro flushes all data cache to physical memory (writeback cache)\r
+ and invalidates all data cache entries at the core level. */\r
+#define ESAL_CO_MEM_DCACHE_ALL_FLUSH_INVAL() \\r
+ { \\r
+ UINT32 cache_nsets; \\r
+ UINT32 cache_way; \\r
+ UINT32 cache_val; \\r
+ UINT32 cache_sets; \\r
+ \\r
+ /* Get cache info */ \\r
+ ESAL_TS_RTE_CP_READ(ESAL_TS_RTE_CP15, 0, &cache_sets, \\r
+ ESAL_TS_RTE_C0, ESAL_TS_RTE_C0, 1); \\r
+ \\r
+ /* Isolate data cache size bits */ \\r
+ cache_sets >>= ESAL_CO_MEM_DSIZE_BITSHIFT; \\r
+ cache_sets &= ESAL_CO_MEM_CACHE_SIZE_MASK; \\r
+ \\r
+ /* Calculate number of sets from this size value */ \\r
+ cache_sets = (1UL << (cache_sets + \\r
+ ESAL_CO_MEM_CACHE_SET_SHIFT)); \\r
+ \\r
+ /* Loop through each cache way */ \\r
+ for (cache_way = 0; \\r
+ cache_way < ESAL_CO_MEM_CACHE_WAY_SIZE; \\r
+ cache_way++) \\r
+ { \\r
+ /* Update the 'way' bit and clear the 'set' bits */ \\r
+ cache_val = (cache_way << ESAL_CO_MEM_CACHE_WAY_SHIFT); \\r
+ \\r
+ /* Loop through each cache set */ \\r
+ for (cache_nsets = 0; \\r
+ cache_nsets < cache_sets; \\r
+ cache_nsets++) \\r
+ { \\r
+ /* Clean and invalidate the DCache */ \\r
+ ESAL_TS_RTE_CP_WRITE(ESAL_TS_RTE_CP15, 0, \\r
+ cache_val, ESAL_TS_RTE_C7, \\r
+ ESAL_TS_RTE_C14, 2); \\r
+ \\r
+ /* Move to the next cache 'set' */ \\r
+ cache_val += ESAL_CO_MEM_CACHE_LINE_SIZE; \\r
+ } \\r
+ } \\r
+ }\r
+\r
+#endif /* (ESAL_CO_CACHE_AVAILABLE == NU_TRUE) */\r
+\r
+#endif /* (CFG_NU_OS_ARCH_ARM_COM_MMU_VARIANT == 0) */\r
+\r
+/*************************************************\r
+* ARM v6/7 MMU and ARMv7-R MPU Variant definitions\r
+*************************************************/\r
+#if (CFG_NU_OS_ARCH_ARM_COM_MMU_VARIANT != 0)\r
+\r
+/* Define all access (manager access permission / not cachable / not bufferd) */\r
+#define ESAL_CO_MEM_TTB_DESC_ALL_ACCESS (ESAL_CO_MEM_TTB_DESC_AP_MANAGER | \\r
+ ESAL_CO_MEM_TTB_DESC_SECT)\r
+\r
+/* The size of each cache segment (in bytes) */\r
+#define ESAL_CO_MEM_CACHE_LINE_SIZE (UINT)(CFG_NU_OS_ARCH_ARM_COM_V6V7_CACHE_LINE_SIZE)\r
+\r
+/* This mask is used to align the virtual address to cache line size */\r
+#define ESAL_CO_MEM_ADDR_ALIGN_MASK (~(ESAL_CO_MEM_CACHE_LINE_SIZE-1UL))\r
+\r
+/* CLIDR and CCSIDR mask values */\r
+#define ESAL_CO_MEM_CLIDR_LOC_MASK 0x7000000\r
+#define ESAL_CO_MEM_CCSIDR_LINESIZE_MASK 0x7\r
+#define ESAL_CO_MEM_CCSIDR_ASSOC_MASK 0x3FF\r
+#define ESAL_CO_MEM_CCSIDR_NUMSET_MASK 0x7FFF\r
+\r
+/* CLIDR and CCSIDR shift values */\r
+#define ESAL_CO_MEM_CLIDR_LOC_RSHT_OFFSET 24\r
+#define ESAL_CO_MEM_CCSIDR_ASSOC_RSHT_OFFSET 3\r
+#define ESAL_CO_MEM_CCSIDR_NUMSET_RSHT_OFFSET 13\r
+\r
+/* Extract 'encoded' line length of the cache */\r
+#define ESAL_CO_MEM_CCSIDR_LINESIZE_GET(ccsidr_reg) (ccsidr_reg & \\r
+ ESAL_CO_MEM_CCSIDR_LINESIZE_MASK)\r
+\r
+/* Extract 'encoded' way size of the cache */\r
+#define ESAL_CO_MEM_CCSIDR_ASSOC_GET(ccsidr_reg) (ESAL_CO_MEM_CCSIDR_ASSOC_MASK & \\r
+ (ccsidr_reg >> \\r
+ ESAL_CO_MEM_CCSIDR_ASSOC_RSHT_OFFSET))\r
+\r
+/* Extract 'encoded' maximum number of index size */\r
+#define ESAL_CO_MEM_CCSIDR_NUMSET_GET(ccsidr_reg) (ESAL_CO_MEM_CCSIDR_NUMSET_MASK & \\r
+ (ccsidr_reg >> \\r
+ ESAL_CO_MEM_CCSIDR_NUMSET_RSHT_OFFSET))\r
+\r
+/* Refer to chapter B3.12.31 c7, Cache and branch predictor maintenance functions in the\r
+ ARM Architecture Reference Manual ARMv7-A and ARMv7-R Edition 1360*/\r
+/* Calculate # of bits to be shifted for set size and way size */\r
+\r
+/* log2(line size in bytes) = ccsidr_linesize + 2 + logbase2(4) */\r
+#define ESAL_CO_MEM_L_CALCULATE(linesize) (linesize + 2 + 2)\r
+\r
+/* log2(nsets) = 32 - way_size_bit_pos */\r
+\r
+/* Find the bit position of way size increment */\r
+#define ESAL_CO_MEM_A_CALCULATE(assoc, a_offset_ref) \\r
+ { \\r
+ UINT32 temp_pos = 0x80000000; \\r
+ \\r
+ *a_offset_ref = 0; \\r
+ \\r
+ /* Logic to count the number of leading zeros before the first 1 */ \\r
+ while(!((assoc & temp_pos) == temp_pos)) \\r
+ { \\r
+ (*a_offset_ref)++; \\r
+ temp_pos = temp_pos >> 1; \\r
+ } \\r
+ }\r
+\r
+/* Factor way, cache number, index number */\r
+#define ESAL_CO_MEM_DCCISW_SET(dccisw_ref, level, numsets, assoc, l_offset, a_offset) \\r
+ { \\r
+ *dccisw_ref = (level | (numsets << l_offset) | (assoc << a_offset)); \\r
+ }\r
+\r
+/* This macro extracts line size, assoc and set size from CCSIDR */\r
+#define ESAL_CO_MEM_CCSIDR_VALS_GET(linesize_ref, assoc_ref, numsets_ref, \\r
+ l_offset_ref, a_offset_ref) \\r
+ { \\r
+ UINT32 ccsidr_val; \\r
+ \\r
+ /* Read the selected cache's CCSIDR */ \\r
+ ESAL_TS_RTE_CP_READ(ESAL_TS_RTE_CP15, 1, &ccsidr_val, \\r
+ ESAL_TS_RTE_C0, ESAL_TS_RTE_C0, 0); \\r
+ \\r
+ /* Extract 'encoded' line length of the cache */ \\r
+ *linesize_ref = ESAL_CO_MEM_CCSIDR_LINESIZE_GET(ccsidr_val); \\r
+ \\r
+ /* Extract 'encoded' way size of the cache */ \\r
+ *assoc_ref = ESAL_CO_MEM_CCSIDR_ASSOC_GET(ccsidr_val); \\r
+ \\r
+ /* Extract 'encoded' maximum number of index size */ \\r
+ *numsets_ref = ESAL_CO_MEM_CCSIDR_NUMSET_GET(ccsidr_val); \\r
+ \\r
+ /* Calculate # of bits to be shifted for set size and way size */ \\r
+ \\r
+ /* log2(line size in bytes) = ccsidr_linesize + 2 + log2(4) */ \\r
+ *l_offset_ref = ESAL_CO_MEM_L_CALCULATE(*linesize_ref); \\r
+ \\r
+ /* log2(nsets) = 32 - way_size_bit_pos */ \\r
+ ESAL_CO_MEM_A_CALCULATE(*assoc_ref, a_offset_ref); \\r
+ }\r
+\r
+#if (ESAL_CO_CACHE_AVAILABLE == NU_TRUE)\r
+\r
+/* This macro invalidates all of the cache at the core level. */\r
+#define ESAL_CO_MEM_CACHE_ALL_INVALIDATE() \\r
+ { \\r
+ ESAL_CO_MEM_ICACHE_ALL_INVALIDATE(); \\r
+ ESAL_CO_MEM_DCACHE_ALL_INVALIDATE(); \\r
+ }\r
+\r
+/* This macro invalidates all of the data cache at the core level. */\r
+#define ESAL_CO_MEM_DCACHE_ALL_OP(type) \\r
+ { \\r
+ UINT32 clidr_val = 0; \\r
+ UINT32 clidr_loc = 0; \\r
+ UINT32 cache_number = 0; \\r
+ UINT32 cache_type = 0; \\r
+ UINT32 ccsidr_linesize = 0; \\r
+ UINT32 ccsidr_assoc = 0; \\r
+ INT32 ccsidr_numsets = 0; \\r
+ INT32 way_size_copy = 0; \\r
+ UINT32 set_size_bit_pos = 0; \\r
+ UINT32 cache_number_pos = 0; \\r
+ UINT32 way_size_bit_pos = 0; \\r
+ UINT32 set_way_value = 0; \\r
+ \\r
+ \\r
+ /* Read CLIDR to extract level of coherence (LOC) */ \\r
+ ESAL_TS_RTE_CP_READ(ESAL_TS_RTE_CP15, 1, &clidr_val, \\r
+ ESAL_TS_RTE_C0, ESAL_TS_RTE_C0, 1); \\r
+ \\r
+ /* Extract LOC from CLIDR and align it at bit 1 */ \\r
+ clidr_loc = (clidr_val & ESAL_CO_MEM_CLIDR_LOC_MASK) >> \\r
+ ESAL_CO_MEM_CLIDR_LOC_RSHT_OFFSET; \\r
+ \\r
+ /* Proceed only iff LOC is non-zero */ \\r
+ if (clidr_loc != 0) \\r
+ { \\r
+ do \\r
+ { \\r
+ /* Extract cache type from CLIDR */ \\r
+ cache_number_pos = cache_number + (cache_number >> 1); \\r
+ cache_type = (clidr_val >> cache_number_pos) & 0x7; \\r
+ \\r
+ /* Continue only iff data cache */ \\r
+ if (cache_type >= 2) \\r
+ { \\r
+ /* Select desired cache level in CSSELR */ \\r
+ ESAL_TS_RTE_CP_WRITE(ESAL_TS_RTE_CP15, 2, cache_number, \\r
+ ESAL_TS_RTE_C0, ESAL_TS_RTE_C0, 0); \\r
+ \\r
+ ESAL_TS_RTE_ISB_EXECUTE(); \\r
+ \\r
+ /* Get data like linesize, assoc and set size */ \\r
+ ESAL_CO_MEM_CCSIDR_VALS_GET(&ccsidr_linesize, \\r
+ &ccsidr_assoc, \\r
+ &ccsidr_numsets, \\r
+ &set_size_bit_pos, \\r
+ &way_size_bit_pos); \\r
+ \\r
+ do \\r
+ { \\r
+ way_size_copy = ccsidr_assoc; \\r
+ \\r
+ do \\r
+ { \\r
+ /* Factor way, cache number, index number */ \\r
+ ESAL_CO_MEM_DCCISW_SET(&set_way_value, cache_number, \\r
+ ccsidr_numsets, way_size_copy, \\r
+ set_size_bit_pos, \\r
+ way_size_bit_pos); \\r
+ \\r
+ /* Execute invalidate if type = 0 */ \\r
+ if (type == 0) \\r
+ { \\r
+ ESAL_TS_RTE_CP_WRITE(ESAL_TS_RTE_CP15, 0, \\r
+ set_way_value, \\r
+ ESAL_TS_RTE_C7, \\r
+ ESAL_TS_RTE_C6, 2); \\r
+ } \\r
+ else \\r
+ { \\r
+ ESAL_TS_RTE_CP_WRITE(ESAL_TS_RTE_CP15, 0, \\r
+ set_way_value, \\r
+ ESAL_TS_RTE_C7, \\r
+ ESAL_TS_RTE_C14, 2); \\r
+ } \\r
+ \\r
+ /* decrement the way */ \\r
+ } while((--way_size_copy) >= 0); \\r
+ \\r
+ /* decrement the set */ \\r
+ } while((--ccsidr_numsets) >= 0); \\r
+ \\r
+ } /* end if */ \\r
+ \\r
+ /* Increment cache number */ \\r
+ cache_number += 2; \\r
+ \\r
+ /* end do-while */ \\r
+ } while(clidr_loc >= cache_number); \\r
+ \\r
+ } \\r
+ \\r
+ /* Switch back to cache level 0 in CSSELR */ \\r
+ ESAL_TS_RTE_CP_WRITE(ESAL_TS_RTE_CP15, 2, 0, \\r
+ ESAL_TS_RTE_C0, ESAL_TS_RTE_C0, 0); \\r
+ \\r
+ /* Sync */ \\r
+ ESAL_TS_RTE_DSB_EXECUTE(); \\r
+ ESAL_TS_RTE_ISB_EXECUTE(); \\r
+ }\r
+\r
+/* This macro flushes all data cache to physical memory (writeback cache)\r
+ and invalidates all data cache entries at the core level. */\r
+#define ESAL_CO_MEM_DCACHE_ALL_FLUSH_INVAL() ESAL_CO_MEM_DCACHE_ALL_OP(1)\r
+\r
+#if (CFG_NU_OS_ARCH_ARM_COM_MMU_VARIANT == 1)\r
+\r
+/* This macro invalidates all of the data cache at the core level. */\r
+#define ESAL_CO_MEM_DCACHE_ALL_INVALIDATE() ESAL_CO_MEM_DCACHE_ALL_OP(0)\r
+\r
+#elif (CFG_NU_OS_ARCH_ARM_COM_MMU_VARIANT == 2)\r
+\r
+/* This macro invalidates all of the data caches at the core level. */\r
+#define ESAL_CO_MEM_DCACHE_ALL_INVALIDATE() \\r
+ { \\r
+ ESAL_TS_RTE_CP_WRITE(ESAL_TS_RTE_CP15, 0, \\r
+ 0, ESAL_TS_RTE_C15, \\r
+ ESAL_TS_RTE_C5, 0); \\r
+ /* Sync */ \\r
+ ESAL_TS_RTE_DSB_EXECUTE(); \\r
+ ESAL_TS_RTE_ISB_EXECUTE(); \\r
+ }\r
+\r
+#endif /* (CFG_NU_OS_ARCH_ARM_COM_MMU_VARIANT == 1) */\r
+\r
+#endif /* (ESAL_CO_CACHE_AVAILABLE == NU_TRUE) */\r
+\r
+#endif /* (CFG_NU_OS_ARCH_ARM_COM_MMU_VARIANT != 0) */\r
+\r
+/*********************************************\r
+* Common cache operation macros\r
+*********************************************/\r
+\r
+#if (ESAL_CO_CACHE_AVAILABLE == NU_TRUE)\r
+\r
+/* This macro invalidates all of the instruction cache at the core level. */\r
+#define ESAL_CO_MEM_ICACHE_ALL_INVALIDATE() \\r
+ { \\r
+ ESAL_TS_RTE_CP_WRITE(ESAL_TS_RTE_CP15, 0, \\r
+ 0, ESAL_TS_RTE_C7, \\r
+ ESAL_TS_RTE_C5, 0); \\r
+ }\r
+\r
+/* This macro invalidates all instruction cache for the specified address\r
+ range at the core level. */\r
+#define ESAL_CO_MEM_ICACHE_INVALIDATE(addr, size) \\r
+ { \\r
+ UINT32 addr_v=(UINT32)addr & ESAL_CO_MEM_MVA_SBZ_MASK; \\r
+ UINT32 l_size = 0; \\r
+ UINT32 align_size = ((UINT32)size + ((UINT32)addr & \\r
+ (ESAL_CO_MEM_CACHE_LINE_SIZE-1)));\\r
+ \\r
+ /* This is to prevent compiler warnings. */ \\r
+ NU_UNUSED_PARAM(align_size); \\r
+ \\r
+ do \\r
+ { \\r
+ /* Invalidate Icache in MVA format */ \\r
+ ESAL_TS_RTE_CP_WRITE(ESAL_TS_RTE_CP15, 0, \\r
+ (addr_v), ESAL_TS_RTE_C7, \\r
+ ESAL_TS_RTE_C5, 1); \\r
+ \\r
+ /* Move to the next way */ \\r
+ addr_v += ESAL_CO_MEM_CACHE_LINE_SIZE; \\r
+ l_size += ESAL_CO_MEM_CACHE_LINE_SIZE; \\r
+ \\r
+ } while (l_size < align_size); \\r
+ }\r
+\r
+/* This macro invalidates all data cache for the specified address\r
+ range at the core level. */\r
+#define ESAL_CO_MEM_DCACHE_INVALIDATE(addr, size) \\r
+ { \\r
+ UINT32 addr_v=(UINT32)addr & ESAL_CO_MEM_MVA_SBZ_MASK; \\r
+ UINT32 l_size = 0; \\r
+ UINT32 align_size = ((UINT32)size + ((UINT32)addr & \\r
+ (ESAL_CO_MEM_CACHE_LINE_SIZE-1)));\\r
+ \\r
+ /* This is to prevent compiler warnings. */ \\r
+ NU_UNUSED_PARAM(align_size); \\r
+ \\r
+ do \\r
+ { \\r
+ /* Invalidate Dcache in MVA format */ \\r
+ ESAL_TS_RTE_CP_WRITE(ESAL_TS_RTE_CP15, 0, \\r
+ (addr_v), ESAL_TS_RTE_C7, \\r
+ ESAL_TS_RTE_C6, 1); \\r
+ \\r
+ /* Move to the next way */ \\r
+ addr_v += ESAL_CO_MEM_CACHE_LINE_SIZE; \\r
+ l_size += ESAL_CO_MEM_CACHE_LINE_SIZE; \\r
+ \\r
+ } while (l_size < align_size); \\r
+ }\r
+\r
+/* This macro flushes all data cache to physical memory (writeback cache)\r
+ for the given address range, then invalidates all data cache entries\r
+ at the core level. */\r
+#define ESAL_CO_MEM_DCACHE_FLUSH_INVAL(addr, size) \\r
+ { \\r
+ UINT32 addr_v=(UINT32)addr & ESAL_CO_MEM_MVA_SBZ_MASK; \\r
+ UINT32 l_size = 0; \\r
+ UINT32 align_size = ((UINT32)size + ((UINT32)addr & \\r
+ (ESAL_CO_MEM_CACHE_LINE_SIZE-1)));\\r
+ \\r
+ /* This is to prevent compiler warnings. */ \\r
+ NU_UNUSED_PARAM(align_size); \\r
+ \\r
+ do \\r
+ { \\r
+ /* Clean (flush) and invalidate the Dcache */ \\r
+ ESAL_TS_RTE_CP_WRITE(ESAL_TS_RTE_CP15, 0, \\r
+ (addr_v), ESAL_TS_RTE_C7, \\r
+ ESAL_TS_RTE_C14, 1); \\r
+ \\r
+ /* Move to the next way */ \\r
+ addr_v += ESAL_CO_MEM_CACHE_LINE_SIZE; \\r
+ l_size += ESAL_CO_MEM_CACHE_LINE_SIZE; \\r
+ \\r
+ } while (l_size < align_size); \\r
+ }\r
+\r
+/* This macro disables instruction and data cache */\r
+#define ESAL_CO_MEM_CACHE_DISABLE() \\r
+ { \\r
+ UINT32 cp15_ctrl_val; \\r
+ \\r
+ /* Read current CP15 control register value */ \\r
+ ESAL_TS_RTE_CP_READ(ESAL_TS_RTE_CP15, 0, &cp15_ctrl_val, ESAL_TS_RTE_C1, ESAL_TS_RTE_C0, 0); \\r
+ \\r
+ /* Clear instruction cache enable and data cache enable bits */ \\r
+ cp15_ctrl_val &= ~(ESAL_CO_MEM_CP15_CTRL_I | ESAL_CO_MEM_CP15_CTRL_C); \\r
+ \\r
+ /* Write updated CP15 control register value */ \\r
+ ESAL_TS_RTE_CP_WRITE(ESAL_TS_RTE_CP15, 0, cp15_ctrl_val, ESAL_TS_RTE_C1, ESAL_TS_RTE_C0, 0); \\r
+ ESAL_TS_RTE_NOP_EXECUTE(); \\r
+ ESAL_TS_RTE_NOP_EXECUTE(); \\r
+ ESAL_TS_RTE_NOP_EXECUTE(); \\r
+ }\r
+#if (CFG_NU_OS_ARCH_ARM_COM_MMU_VARIANT == 1)\r
+/* This macro flushes data cache and invalidate instruction cache */\r
+#define ESAL_CO_MEM_ICACHE_FLUSH_INVAL(addr, size) \\r
+ { \\r
+ UINT32 cache_info; \\r
+ UINT32 line_size; \\r
+ UINT32 current_addr; \\r
+ \\r
+ /* Read cache level ID register value */ \\r
+ ESAL_TS_RTE_CP_READ(ESAL_TS_RTE_CP15, 0, &cache_info, \\r
+ ESAL_TS_RTE_C0, ESAL_TS_RTE_C0, 1); \\r
+ \\r
+ /* Calculate the size */ \\r
+ line_size = cache_info >> ESAL_CO_MEM_DCACHE_SIZE_SHIFT; \\r
+ line_size = line_size & ESAL_CO_MEM_CACHE_SIZE_MASK; \\r
+ line_size = ESAL_CO_MEM_CACHE_SIZE_BIT << line_size; \\r
+ \\r
+ /* Force alignment with current cache line */ \\r
+ current_addr = (UINT32)addr & ~(line_size - 1); \\r
+ \\r
+ do \\r
+ { \\r
+ /* Clean dcache to PoU */ \\r
+ ESAL_TS_RTE_CP_WRITE(ESAL_TS_RTE_CP15, 0, current_addr, \\r
+ ESAL_TS_RTE_C7, ESAL_TS_RTE_C11, 1); \\r
+ current_addr += line_size; \\r
+ } while (current_addr < ((UINT32)addr + size)); \\r
+ \\r
+ /* Data barrier */ \\r
+ ESAL_TS_RTE_DSB_EXECUTE(); \\r
+ \\r
+ /* Calculate the size */ \\r
+ line_size = cache_info & ESAL_CO_MEM_CACHE_SIZE_MASK; \\r
+ line_size = ESAL_CO_MEM_CACHE_SIZE_BIT << line_size; \\r
+ \\r
+ /* Force alignment with current cache line */ \\r
+ current_addr = (UINT32)addr & ~(line_size - 1); \\r
+ \\r
+ do \\r
+ { \\r
+ /* Invalidate icache line */ \\r
+ ESAL_TS_RTE_CP_WRITE(ESAL_TS_RTE_CP15, 0, current_addr, \\r
+ ESAL_TS_RTE_C7, ESAL_TS_RTE_C5, 1); \\r
+ current_addr += line_size; \\r
+ } while (current_addr < ((UINT32)addr + size)); \\r
+ \\r
+ /* Invalidate BTB */ \\r
+ ESAL_TS_RTE_CP_WRITE(ESAL_TS_RTE_CP15, 0, 0, ESAL_TS_RTE_C7, \\r
+ ESAL_TS_RTE_C5, 6); \\r
+ ESAL_TS_RTE_DSB_EXECUTE(); \\r
+ ESAL_TS_RTE_ISB_EXECUTE(); \\r
+ }\r
+#else\r
+#define ESAL_CO_MEM_ICACHE_FLUSH_INVAL(addr, size) \\r
+ { \\r
+ ESAL_CO_MEM_DCACHE_FLUSH_INVAL(addr, size); \\r
+ ESAL_CO_MEM_ICACHE_INVALIDATE(addr, size); \\r
+ }\r
+#endif\r
+\r
+#endif /* (ESAL_CO_CACHE_AVAILABLE == NU_TRUE) */\r
+\r
+/*********************************************\r
+* ARM Architecture MMU definitions\r
+*********************************************/\r
+\r
+/* All domains in client mode */\r
+#define ESAL_AR_DACR_CLIENT 0x55555555UL\r
+\r
+/* All domains in manager mode */\r
+#define ESAL_AR_DACR_MANAGER 0xFFFFFFFFUL\r
+\r
+#if (CFG_NU_OS_ARCH_ARM_COM_MMU_VARIANT == 1)\r
+#define ESAL_AR_MMU_ENABLE_BITS (ESAL_CO_MEM_CP15_CTRL_M | \\r
+ ESAL_CO_MEM_CP15_CTRL_C | \\r
+ ESAL_CO_MEM_CP15_CTRL_W | \\r
+ ESAL_CO_MEM_CP15_CTRL_Z | \\r
+ ESAL_CO_MEM_CP15_CTRL_I)\r
+#else\r
+#define ESAL_AR_MMU_ENABLE_BITS (ESAL_CO_MEM_CP15_CTRL_M | \\r
+ ESAL_CO_MEM_CP15_CTRL_C | \\r
+ ESAL_CO_MEM_CP15_CTRL_W | \\r
+ ESAL_CO_MEM_CP15_CTRL_I)\r
+\r
+#endif\r
+\r
+#define ESAL_AR_MMU_DISABLE_BITS (~(ESAL_AR_MMU_ENABLE_BITS))\r
+\r
+/* This macro provides a slight delay to make sure instructions\r
+ have finished. */\r
+#if (CFG_NU_OS_ARCH_ARM_COM_MMU_VARIANT == 1)\r
+\r
+#define ESAL_AR_BARRIER() \\r
+ { \\r
+ ESAL_TS_RTE_ISB_EXECUTE(); \\r
+ ESAL_TS_RTE_DSB_EXECUTE(); \\r
+ }\r
+\r
+#else\r
+\r
+#define ESAL_AR_BARRIER() \\r
+ { \\r
+ ESAL_TS_RTE_NOP_EXECUTE(); \\r
+ ESAL_TS_RTE_NOP_EXECUTE(); \\r
+ ESAL_TS_RTE_NOP_EXECUTE(); \\r
+ }\r
+\r
+#endif\r
+\r
+#if (CFG_NU_OS_ARCH_ARM_COM_MMU_VARIANT == 0)\r
+/* This macro drains cache write buffers. */\r
+#define ESAL_AR_DRAIN_WRITE_BUFFERS() \\r
+ { \\r
+ ESAL_TS_RTE_CP_WRITE(ESAL_TS_RTE_CP15, 0, 0, ESAL_TS_RTE_C7, \\r
+ ESAL_TS_RTE_C10, 4); \\r
+ }\r
+#endif\r
+\r
+/* This macro modifies the value of the Translation Table Base\r
+ Register. */\r
+#define ESAL_AR_SET_TRANSLATION_TABLE(ttbr_value) \\r
+ { \\r
+ /* Write to translation table */ \\r
+ ESAL_TS_RTE_CP_WRITE(ESAL_TS_RTE_CP15, 0, ttbr_value, \\r
+ ESAL_TS_RTE_C2, ESAL_TS_RTE_C0, 0); \\r
+ ESAL_AR_BARRIER(); \\r
+ }\r
+\r
+/* This macro invalidates TLBs. */\r
+#define ESAL_AR_INVALIDATE_TLB() \\r
+ { \\r
+ ESAL_TS_RTE_CP_WRITE(ESAL_TS_RTE_CP15, 0, 0, ESAL_TS_RTE_C8, \\r
+ ESAL_TS_RTE_C7, 0); \\r
+ ESAL_AR_BARRIER(); \\r
+ }\r
+\r
+/* This macro sets the domain access register to Manager mode. */\r
+#define ESAL_AR_SET_DOMAIN(dacr) \\r
+ { \\r
+ ESAL_TS_RTE_CP_WRITE(ESAL_TS_RTE_CP15, 0, dacr, \\r
+ ESAL_TS_RTE_C3, ESAL_TS_RTE_C0, 0); \\r
+ ESAL_AR_BARRIER(); \\r
+ }\r
+\r
+#if (CFG_NU_OS_ARCH_ARM_COM_MMU_VARIANT == 0)\r
+#define ESAL_AR_MMU_ENABLE_COMPLETE() \\r
+ { \\r
+ /* Flush all of data cache on the core.*/ \\r
+ ESAL_GE_MEM_DCACHE_ALL_FLUSH_INVAL(); \\r
+ ESAL_AR_BARRIER(); \\r
+ \\r
+ /* Invalidate the cache immediately following an MMU enable */ \\r
+ /* Interrupts should be disabled during these instructions. */ \\r
+ \\r
+ /* Invalidate all cache */ \\r
+ ESAL_GE_MEM_CACHE_ALL_INVALIDATE(); \\r
+ \\r
+ /* Drain Write buffer */ \\r
+ ESAL_AR_DRAIN_WRITE_BUFFERS(); \\r
+ \\r
+ /* Invalidate all TLBs */ \\r
+ ESAL_AR_INVALIDATE_TLB(); \\r
+ }\r
+#else\r
+#define ESAL_AR_MMU_ENABLE_COMPLETE() \\r
+ { \\r
+ /* Invalidate all TLBs */ \\r
+ ESAL_AR_INVALIDATE_TLB(); \\r
+ }\r
+#endif\r
+\r
+/* This macro turns the MMU on using the Default bits for operation. */\r
+#define ESAL_AR_MMU_ENABLE() \\r
+ { \\r
+ UNSIGNED tmp_val; \\r
+ ESAL_TS_RTE_CP_READ(ESAL_TS_RTE_CP15, 0, &tmp_val, \\r
+ ESAL_TS_RTE_C1, ESAL_TS_RTE_C0, 0); \\r
+ \\r
+ /* Clear high vectors */ \\r
+ tmp_val &= ~(ESAL_CO_MEM_CP15_CTRL_V); \\r
+ \\r
+ /* Clean alignment bit */ \\r
+ tmp_val &= ~(ESAL_CO_MEM_CP15_CTRL_A); \\r
+ \\r
+ /* Or with enable bits */ \\r
+ tmp_val |= ESAL_AR_MMU_ENABLE_BITS; \\r
+ ESAL_TS_RTE_CP_WRITE(ESAL_TS_RTE_CP15, 0, tmp_val, \\r
+ ESAL_TS_RTE_C1, ESAL_TS_RTE_C0, 0); \\r
+ ESAL_AR_BARRIER(); \\r
+ \\r
+ /* Complete the MMU enable process */ \\r
+ ESAL_AR_MMU_ENABLE_COMPLETE(); \\r
+ }\r
+\r
+/* Turn OFF the MMU using the Default bits for the operation. */\r
+#define ESAL_AR_MMU_DISABLE() \\r
+ { \\r
+ UNSIGNED tmp_val; \\r
+ \\r
+ /* Read CP15 reg 1 */ \\r
+ ESAL_TS_RTE_CP_READ(ESAL_TS_RTE_CP15, 0, &tmp_val, \\r
+ ESAL_TS_RTE_C1, ESAL_TS_RTE_C0, 0); \\r
+ \\r
+ /* And in disable bits */ \\r
+ tmp_val &= ESAL_AR_MMU_DISABLE_BITS; \\r
+ \\r
+ /* Write value back */ \\r
+ ESAL_TS_RTE_CP_WRITE(ESAL_TS_RTE_CP15, 0, tmp_val, \\r
+ ESAL_TS_RTE_C1, ESAL_TS_RTE_C0, 0); \\r
+ ESAL_AR_BARRIER(); \\r
+ }\r
+\r
+#if (CFG_NU_OS_ARCH_ARM_COM_MMU_VARIANT == 1)\r
+\r
+/* This macro writes to the address space identifier. */\r
+#define ESAL_AR_SET_ASID(asid_value) \\r
+ { \\r
+ ESAL_TS_RTE_CP_WRITE(ESAL_TS_RTE_CP15, 0, asid_value, \\r
+ ESAL_TS_RTE_C13, ESAL_TS_RTE_C0, 1); \\r
+ ESAL_AR_BARRIER(); \\r
+ }\r
+\r
+#endif\r
+\r
+#endif /* ARM_MMU_DEFS_H */\r
diff --git a/libs/system/zc702evk/nucleus/arch/arm/tool-csgnu_arm/csgnu_arm_defs.h b/libs/system/zc702evk/nucleus/arch/arm/tool-csgnu_arm/csgnu_arm_defs.h
--- /dev/null
@@ -0,0 +1,364 @@
+/***********************************************************************\r
+*\r
+* Copyright 2006 Mentor Graphics Corporation\r
+* All Rights Reserved.\r
+*\r
+* THIS WORK CONTAINS TRADE SECRET AND PROPRIETARY INFORMATION WHICH IS\r
+* THE PROPERTY OF MENTOR GRAPHICS CORPORATION OR ITS LICENSORS AND IS\r
+* SUBJECT TO LICENSE TERMS.\r
+*\r
+************************************************************************\r
+\r
+************************************************************************\r
+*\r
+* FILE NAME\r
+*\r
+* csgnu_arm_defs.h\r
+*\r
+* DESCRIPTION\r
+*\r
+* This file contains all definitions, structures, etc for the\r
+* CS GNU for ARM toolset\r
+*\r
+* DATA STRUCTURES\r
+*\r
+* None\r
+*\r
+* DEPENDENCIES\r
+*\r
+* None\r
+*\r
+***********************************************************************/\r
+\r
+#ifndef CSGNU_ARM_DEFS_H\r
+#define CSGNU_ARM_DEFS_H\r
+\r
+/* Define required stack pointer alignment for the given toolset.*/\r
+#define ESAL_TS_REQ_STK_ALIGNMENT 8\r
+\r
+/* Define if toolset supports 64-bit data types (long long) */\r
+#define ESAL_TS_64BIT_SUPPORT NU_TRUE\r
+\r
+/* Define, in bytes, toolset minimum required alignment for structures */\r
+#define ESAL_TS_STRUCT_ALIGNMENT 4\r
+\r
+/* Size, in bits, of integers for the given toolset / architecture */\r
+#define ESAL_TS_INTEGER_SIZE 32\r
+\r
+/* Size, in bits, of code pointer for the given toolset / architecture */\r
+#define ESAL_TS_CODE_PTR_SIZE 32\r
+\r
+/* Size, in bits, of data pointer for the given toolset / architecture */\r
+#define ESAL_TS_DATA_PTR_SIZE 32\r
+\r
+/* Define if necessary to copy code / data from ROM to RAM */\r
+#define ESAL_TS_ROM_TO_RAM_COPY_SUPPORT CFG_NU_OS_KERN_PLUS_CORE_ROM_TO_RAM_COPY\r
+\r
+/* Define, in bytes, toolset maximum alignment for data types. */\r
+#define ESAL_TS_MAX_TYPE_ALIGNMENT ESAL_TS_REQ_STK_ALIGNMENT\r
+\r
+/* Define tool specific type for HUGE and FAR data pointers - these will usually\r
+ be defined to nothing. Some 16-bit architectures may require these\r
+ to be defined differently to access data across memory pages */\r
+#define ESAL_TS_HUGE_PTR_TYPE\r
+#define ESAL_TS_FAR_PTR_TYPE\r
+\r
+/* Define if position-independent code / data (PIC/PID) support (if available)\r
+ is enabled.\r
+ NOTE: This may be required to be set to NU_TRUE when utilizing any\r
+ OS components requiring position-independent code / data */\r
+#define ESAL_TS_PIC_PID_SUPPORT NU_FALSE\r
+\r
+/* External variable declarations */\r
+extern UINT32 _ld_bss_start;\r
+extern UINT32 _ld_bss_end;\r
+extern UINT32 _ld_ram_data_start;\r
+extern UINT32 _ld_ram_data_end;\r
+extern UINT32 _ld_rom_data_start;\r
+\r
+/* Macros for memory definitions */\r
+#define TOOLSET_BSS_START_ADDR (VOID *)&_ld_bss_start\r
+#define TOOLSET_BSS_END_ADDR (VOID *)&_ld_bss_end\r
+#define TOOLSET_BSS_SIZE ((UINT32)&_ld_bss_end - (UINT32)&_ld_bss_start)\r
+#define TOOLSET_DATA_SRC_ADDR (VOID *)&_ld_rom_data_start\r
+#define TOOLSET_DATA_DST_ADDR (VOID *)&_ld_ram_data_start\r
+#define TOOLSET_DATA_SIZE ((UINT32)&_ld_ram_data_end - (UINT32)&_ld_ram_data_start)\r
+\r
+/* This define is used to add quotes to anything passed in */\r
+#define ESAL_TS_RTE_QUOTES(x) #x\r
+\r
+/* This macro reads the program counter. */\r
+#define ESAL_TS_RTE_PC_READ() \\r
+ ({ \\r
+ VOID * pc_ptr; \\r
+ asm(" MOV %0,pc": "=r" (pc_ptr)); \\r
+ pc_ptr; \\r
+ })\r
+\r
+/* This macro writes the stack pointer. */\r
+#define ESAL_TS_RTE_SP_WRITE(stack_ptr) \\r
+ { \\r
+ /* Set hardware stack pointer to passed in address */ \\r
+ asm volatile(" MOV sp, %0" \\r
+ : : "r" (stack_ptr) ); \\r
+ }\r
+\r
+/* This macro reads the stack pointer. */\r
+#define ESAL_TS_RTE_SP_READ() \\r
+ ({ \\r
+ VOID * stk_ptr; \\r
+ asm(" MOV %0,sp": "=r" (stk_ptr)); \\r
+ stk_ptr; \\r
+ })\r
+\r
+#if defined(__thumb__) && !defined(__ARM_ARCH_7R__) && !defined(__ARM_ARCH_7A__)\r
+\r
+/* Must do function call to CPSR read/write functions written in assembly */\r
+VOID ESAL_TS_RTE_CPSR_CXSF_Read(INT *);\r
+VOID ESAL_TS_RTE_CPSR_CXSF_Write(INT);\r
+VOID ESAL_TS_RTE_CPSR_C_Write(UINT32);\r
+#define ESAL_TS_RTE_CPSR_CXSF_READ ESAL_TS_RTE_CPSR_CXSF_Read\r
+#define ESAL_TS_RTE_CPSR_CXSF_WRITE ESAL_TS_RTE_CPSR_CXSF_Write\r
+#define ESAL_TS_RTE_CPSR_C_WRITE ESAL_TS_RTE_CPSR_C_Write\r
+\r
+#else\r
+\r
+/* This macro reads the current program status register (CPSR - all fields) */\r
+#define ESAL_TS_RTE_CPSR_CXSF_READ(cpsr_cxsf_ptr) \\r
+ { \\r
+ asm volatile(" MRS %0, CPSR" \\r
+ : "=r" (*(cpsr_cxsf_ptr)) \\r
+ : /* No inputs */ ); \\r
+ }\r
+\r
+/* This macro writes the current program status register (CPSR - all fields) */\r
+#define ESAL_TS_RTE_CPSR_CXSF_WRITE(cpsr_cxsf_value) \\r
+ { \\r
+ asm volatile(" MSR CPSR_cxsf, %0" \\r
+ : /* No outputs */ \\r
+ : "r" (cpsr_cxsf_value) ); \\r
+ }\r
+\r
+#ifdef __thumb__\r
+/* This macro writes the c (control) bits of the current program status register (CPSR) */\r
+#define ESAL_TS_RTE_CPSR_C_WRITE(c_bits) \\r
+ { \\r
+ UINT32 __temp; \\r
+ \\r
+ ESAL_TS_RTE_CPSR_CXSF_READ(&__temp); \\r
+ __temp &= ~(ESAL_AR_INT_CPSR_MODE_MASK|ESAL_AR_INTERRUPTS_DISABLE_BITS);\\r
+ __temp |= c_bits; \\r
+ asm volatile(" MSR CPSR_cxsf, %0" \\r
+ : /* No outputs */ \\r
+ : "r" (__temp) ); \\r
+ }\r
+#else\r
+\r
+/* This macro writes the c (control) bits of the current program status register (CPSR) */\r
+#define ESAL_TS_RTE_CPSR_C_WRITE(c_bits) \\r
+ { \\r
+ asm volatile(" MSR CPSR_c, %0" \\r
+ : /* No outputs */ \\r
+ : "I" (c_bits) ); \\r
+ }\r
+\r
+#endif /* __thumb__ */\r
+#endif /* __thumb && !__ARM_ARCH_7R__ && !__ARM_ARCH_7A__ */\r
+\r
+#if defined(__thumb__) && !defined(__ARM_ARCH_7R__) && !defined(__ARM_ARCH_7A__)\r
+\r
+/* This macro writes to a coprocessor register */\r
+#define ESAL_TS_RTE_CP_WRITE(cp, op1, cp_value, crn, crm, op2) \\r
+ { \\r
+ asm volatile(" .align \n\t" \\r
+ "MOV r0, pc \n\t" \\r
+ "BX r0 \n\t" \\r
+ ".arm \n\t" \\r
+ "MCR " ESAL_TS_RTE_QUOTES(cp) "," \\r
+ #op1 \\r
+ ", %0, " \\r
+ ESAL_TS_RTE_QUOTES(crn) "," \\r
+ ESAL_TS_RTE_QUOTES(crm) "," \\r
+ #op2 " \n\t" \\r
+ "ADD r0, pc, #1 \n\t" \\r
+ "BX r0 \n\t" \\r
+ ".thumb \n\t" \\r
+ : /* No outputs */ \\r
+ : "r" (cp_value) \\r
+ : "r0"); \\r
+ }\r
+\r
+/* This macro reads from a coprocessor register */\r
+#define ESAL_TS_RTE_CP_READ(cp, op1, cp_value_ptr, crn, crm, op2) \\r
+ { \\r
+ asm volatile(" .align \n\t" \\r
+ "MOV r0, pc \n\t" \\r
+ "BX r0 \n\t" \\r
+ ".arm \n\t" \\r
+ "MRC " ESAL_TS_RTE_QUOTES(cp) "," \\r
+ #op1 \\r
+ ", %0, " \\r
+ ESAL_TS_RTE_QUOTES(crn) "," \\r
+ ESAL_TS_RTE_QUOTES(crm) "," \\r
+ #op2" \n\t" \\r
+ "ADD r0, pc, #1 \n\t" \\r
+ "BX r0 \n\t" \\r
+ ".thumb \n\t" \\r
+ : "=r" (*(UINT32 *)(cp_value_ptr)) \\r
+ : /* No inputs */ \\r
+ : "r0"); \\r
+ }\r
+\r
+#else\r
+\r
+/* This macro writes to a coprocessor register */\r
+#define ESAL_TS_RTE_CP_WRITE(cp, op1, cp_value, crn, crm, op2) \\r
+ { \\r
+ asm volatile(" MCR " ESAL_TS_RTE_QUOTES(cp) "," \\r
+ #op1 \\r
+ ", %0, " \\r
+ ESAL_TS_RTE_QUOTES(crn) "," \\r
+ ESAL_TS_RTE_QUOTES(crm) "," \\r
+ #op2 \\r
+ : /* No outputs */ \\r
+ : "r" (cp_value)); \\r
+ }\r
+\r
+/* This macro reads from a coprocessor register */\r
+#define ESAL_TS_RTE_CP_READ(cp, op1, cp_value_ptr, crn, crm, op2) \\r
+ { \\r
+ asm volatile(" MRC " ESAL_TS_RTE_QUOTES(cp) "," \\r
+ #op1 \\r
+ ", %0, " \\r
+ ESAL_TS_RTE_QUOTES(crn) "," \\r
+ ESAL_TS_RTE_QUOTES(crm) "," \\r
+ #op2 \\r
+ : "=r" (*(UINT32 *)(cp_value_ptr)) \\r
+ : /* No inputs */ ); \\r
+ }\r
+\r
+#endif /* __thumb && !__ARM_ARCH_7R__ && !__ARM_ARCH_7A__ */\r
+\r
+/* This macro executes a ISB instruction */\r
+#define ESAL_TS_RTE_ISB_EXECUTE() \\r
+ { \\r
+ asm volatile(" ISB"); \\r
+ }\r
+\r
+/* This macro executes a DSB instruction */\r
+#define ESAL_TS_RTE_DSB_EXECUTE() \\r
+ { \\r
+ asm volatile(" DSB"); \\r
+ }\r
+\r
+/* This macro executes a NOP instruction */\r
+#define ESAL_TS_RTE_NOP_EXECUTE() \\r
+ { \\r
+ asm volatile(" NOP"); \\r
+ }\r
+\r
+/* This macro executes a WFI instruction */\r
+#define ESAL_TS_RTE_WFI_EXECUTE() \\r
+ { \\r
+ asm volatile(" WFI"); \\r
+ }\r
+\r
+/* This macro executes a breakpoint instruction\r
+ NOTE: This instruction is only usable by ARM v5 cores. */\r
+#define ESAL_TS_RTE_BRK_EXECUTE(brk_point_val) \\r
+ { \\r
+ asm volatile(" BKPT %0" \\r
+ : /* No Outputs */ \\r
+ : "n" (brk_point_val) ); \\r
+ }\r
+\r
+/* This macro executes an ARM undefined (breakpoint) instruction. */\r
+#define ESAL_TS_RTE_UNDEF_BRK_EXECUTE() \\r
+ { \\r
+ asm volatile(" .long 0xE7FDDEFE"); \\r
+ }\r
+\r
+/* This macro executes SMI for the OMAP35xx device.\r
+ NOTE: The ROM code provides three primitive services. These services are\r
+ implemented in monitor mode and do not use any resources outside the\r
+ MPU subsystem. The services are described below. To call a service,\r
+ a register r12 must be set to service ID and the SMI instruction must\r
+ be executed.\r
+ - r12=1: To use the L2 cache, all L2 line data must be invalidated\r
+ through the CP15 registers. This service invalidates the\r
+ entire L2 cache and must be performed after a POR or a loss\r
+ of L2 cache after reset. This register can also be read.\r
+ - r12=2: This service writes the value of the central processing unit (CPU)\r
+ register R0 in the L2 cache auxiliary control register. This\r
+ register can also be read.\r
+ - r12=3: This service writes the value of the CPU register R0 in the\r
+ auxiliary control. This register can also be read.\r
+ For more information about ARM L2 cache and registers, see\r
+ the Cortex-A8 Technical Reference Manual. For more information\r
+ about ARM CP15 registers, see the ARM Architecture Reference Manual. */\r
+#define ESAL_TS_RTE_SMI_EXECUTE(r0_val, r12_op) \\r
+ { \\r
+ asm volatile(" MOV r0, %0\n\t" \\r
+ " MOV r12, %1\n\t" \\r
+ " SMC #0" \\r
+ : /* No Output */ \\r
+ : "r" (r0_val), "r" (r12_op) \\r
+ : "r0", "r12"); \\r
+ ESAL_TS_RTE_ISB_EXECUTE(); \\r
+ }\r
+\r
+#if (ESAL_TS_PIC_PID_SUPPORT == NU_TRUE)\r
+\r
+/* This macro sets the PIC/PID base address register */\r
+#define ESAL_TS_RTE_PIC_PID_BASE_SET(pic_base, pid_base) \\r
+ { \\r
+ /* Access unused param */ \\r
+ NU_UNUSED_PARAM(pic_base); \\r
+ \\r
+ /* Set the PIC/PID register (r9) */ \\r
+ asm volatile(" MOV r9, %0" \\r
+ : : "r" (pid_base) ); \\r
+ }\r
+\r
+/* This macro gets the PIC/PID base address register */\r
+#define ESAL_TS_RTE_PIC_PID_BASE_GET(pic_base_ptr, pid_base_ptr) \\r
+ { \\r
+ /* Access unused param */ \\r
+ NU_UNUSED_PARAM(pic_base_ptr); \\r
+ \\r
+ /* Read the PIC/PID register (r9) */ \\r
+ asm volatile(" MOV %0,r9": "=r" (*pid_base_ptr)); \\r
+ }\r
+\r
+#endif /* ESAL_TS_PIC_PID_SUPPORT == NU_TRUE */\r
+\r
+/* This macro gets the current function's return address, see GCC manual for argument usage */\r
+#define ESAL_GET_RETURN_ADDRESS(level) __builtin_return_address(level)\r
+\r
+/* This macro marks a symbol declaration as weakly linked */\r
+#define ESAL_TS_WEAK_REF(decl) decl __attribute((weak))\r
+\r
+/* This macro marks a symbol definition as weakly linked */\r
+#define ESAL_TS_WEAK_DEF(decl) __attribute((weak)) decl\r
+\r
+/* This macro returns the passed value */\r
+#define ESAL_TS_NO_RETURN(return_val) return(return_val)\r
+\r
+/* This macro generates deprecation warnings */\r
+#define ESAL_TS_RTE_DEPRECATED __attribute__((deprecated))\r
+\r
+/* This macro places a compiler memory barrier to ensure read / write commands\r
+ * cannot be re-ordered around it */\r
+#define ESAL_TS_RTE_COMPILE_MEM_BARRIER() asm volatile("" ::: "memory")\r
+\r
+/* This macro returns the 2-byte value with the order of the bytes reversed */\r
+#define ESAL_TS_BYTE_SWAP16(temp16) __builtin_bswap16(temp16)\r
+\r
+/* This macro returns the 4-byte value with the order of the bytes reversed */\r
+#define ESAL_TS_BYTE_SWAP32(temp32) __builtin_bswap32(temp32)\r
+\r
+/* This macro returns the 8-byte value with the order of the bytes reversed */\r
+#define ESAL_TS_BYTE_SWAP64(temp64) __builtin_bswap64(temp64)\r
+\r
+#endif /* CSGNU_ARM_DEFS_H */\r
+\r
diff --git a/libs/system/zc702evk/nucleus/arch/arm/tool-csgnu_arm/toolset.h b/libs/system/zc702evk/nucleus/arch/arm/tool-csgnu_arm/toolset.h
--- /dev/null
@@ -0,0 +1,39 @@
+/***********************************************************************\r
+*\r
+* Copyright 2010 Mentor Graphics Corporation\r
+* All Rights Reserved.\r
+*\r
+* THIS WORK CONTAINS TRADE SECRET AND PROPRIETARY INFORMATION WHICH IS\r
+* THE PROPERTY OF MENTOR GRAPHICS CORPORATION OR ITS LICENSORS AND IS\r
+* SUBJECT TO LICENSE TERMS.\r
+*\r
+************************************************************************\r
+\r
+************************************************************************\r
+*\r
+* FILE NAME\r
+*\r
+* toolset.h\r
+*\r
+* DESCRIPTION\r
+*\r
+* This file is a wrapper header file that includes all the necessary\r
+* header files for the configured toolset\r
+*\r
+* DATA STRUCTURES\r
+*\r
+* None\r
+*\r
+* DEPENDENCIES\r
+*\r
+* None\r
+*\r
+***********************************************************************/\r
+\r
+#ifndef TOOLSET_H\r
+#define TOOLSET_H\r
+\r
+/* Include header file(s) for processor */\r
+#include "csgnu_arm_defs.h"\r
+\r
+#endif /* TOOLSET_H */\r
diff --git a/libs/system/zc702evk/nucleus/bsp/arch/plat-zynq7000/platform.h b/libs/system/zc702evk/nucleus/bsp/arch/plat-zynq7000/platform.h
--- /dev/null
@@ -0,0 +1,60 @@
+/***********************************************************************\r
+*\r
+* Copyright 2013 Mentor Graphics Corporation\r
+* All Rights Reserved.\r
+*\r
+* THIS WORK CONTAINS TRADE SECRET AND PROPRIETARY INFORMATION WHICH IS\r
+* THE PROPERTY OF MENTOR GRAPHICS CORPORATION OR ITS LICENSORS AND IS\r
+* SUBJECT TO LICENSE TERMS.\r
+*\r
+************************************************************************\r
+\r
+************************************************************************\r
+*\r
+* FILE NAME\r
+*\r
+* platform.h\r
+*\r
+* DESCRIPTION\r
+*\r
+* This file is a wrapper header file that includes all the necessary\r
+* header files for the configured platform\r
+*\r
+* DATA STRUCTURES\r
+*\r
+* None\r
+*\r
+* DEPENDENCIES\r
+*\r
+* nucleus_gen_cfg.h\r
+* zynq7000_defs.h\r
+* zc702evk_defs.h\r
+* zedboard.h\r
+*\r
+***********************************************************************/\r
+\r
+#ifndef PLATFORM_H\r
+#define PLATFORM_H\r
+\r
+/* Include configuration header file */\r
+#include "nucleus_gen_cfg.h"\r
+\r
+/* Include header file for Xilinx ZYNQ-7000 architecture */\r
+#include "zynq7000_defs.h"\r
+\r
+#ifdef CFG_NU_BSP_ZC702EVK_ENABLE\r
+\r
+/* Include header file for Xilinx ZC702 EVK Board */\r
+#include "bsp/zc702evk_defs.h"\r
+\r
+#endif /* CFG_NU_BSP_ZC702EVK_ENABLE */\r
+\r
+#ifdef CFG_NU_BSP_ZEDBOARD_ENABLE\r
+\r
+/* Include header file for Xilinx ZC702 EVK Board */\r
+#include "bsp/zedboard.h"\r
+\r
+#endif /* CFG_NU_BSP_ZEDBOARD_ENABLE */\r
+\r
+\r
+#endif /* PLATFORM_H */\r
diff --git a/libs/system/zc702evk/nucleus/bsp/arch/plat-zynq7000/zynq7000_defs.h b/libs/system/zc702evk/nucleus/bsp/arch/plat-zynq7000/zynq7000_defs.h
--- /dev/null
@@ -0,0 +1,491 @@
+/***********************************************************************\r
+*\r
+* Copyright 2012 Mentor Graphics Corporation\r
+* All Rights Reserved.\r
+*\r
+* THIS WORK CONTAINS TRADE SECRET AND PROPRIETARY INFORMATION WHICH IS\r
+* THE PROPERTY OF MENTOR GRAPHICS CORPORATION OR ITS LICENSORS AND IS\r
+* SUBJECT TO LICENSE TERMS.\r
+*\r
+************************************************************************\r
+\r
+************************************************************************\r
+*\r
+* FILE NAME\r
+*\r
+* zynq7000_defs.h\r
+*\r
+* DESCRIPTION\r
+*\r
+* This file contains required configuration settings for the\r
+* given processor. These configuration settings are used by\r
+* generic ESAL components and can be used by external components.\r
+*\r
+* DATA STRUCTURES\r
+*\r
+* None\r
+*\r
+* DEPENDENCIES\r
+*\r
+* None\r
+*\r
+***********************************************************************/\r
+\r
+#ifndef ZYNQ7000_DEFS_H\r
+#define ZYNQ7000_DEFS_H\r
+\r
+/* Define processor execution endianess\r
+ (ESAL_LITTLE_ENDIAN or ESAL_BIG_ENDIAN) */\r
+#define ESAL_PR_ENDIANESS ESAL_LITTLE_ENDIAN\r
+\r
+/* Define processor cache availability\r
+ NOTE: A differentiation is made in ESAL between cache that\r
+ is contained on a processor and cache that is\r
+ inherent as part of a core (L2 vs L1 cache). */\r
+#define ESAL_PR_CACHE_AVAILABLE NU_FALSE\r
+\r
+/* Define if an interrupt controller exists on the processor and\r
+ controlling / handling of interrupts from this interrupt controller must\r
+ be accommodated for. Setting this to NU_FALSE means processor level interrupts\r
+ will NOT be controlled or handled. Setting this to NU_TRUE means processor level\r
+ interrupts will be controlled and handled */\r
+#define ESAL_PR_INTERRUPTS_AVAILABLE NU_TRUE\r
+\r
+/* Define if Interrupt Affinity support is available */\r
+#define ESAL_PR_INT_AFFINITY_AVAILABLE NU_TRUE\r
+\r
+#ifndef ESAL_CO_PERIPH_BASE\r
+#define ESAL_CO_PERIPH_BASE 0xF8F00000\r
+#endif\r
+\r
+/* Define EB primary interrupt controller base registers */\r
+#define ESAL_PR_INT_GIC_CPU_BASE (ESAL_CO_PERIPH_BASE + 0x00000100)\r
+#define ESAL_PR_INT_GIC_DIST_BASE (ESAL_CO_PERIPH_BASE + 0x00001000)\r
+\r
+/* CPU Interface Register Offsets */\r
+#define ESAL_PR_INT_GIC_CPU_CTRL 0x00\r
+#define ESAL_PR_INT_GIC_CPU_PRIORITY 0x04\r
+#define ESAL_PR_INT_GIC_CPU_POINT 0x08\r
+#define ESAL_PR_INT_GIC_CPU_ACK 0x0c\r
+#define ESAL_PR_INT_GIC_CPU_ENDINT 0x10\r
+#define ESAL_PR_INT_GIC_CPU_RUNNING 0x14\r
+#define ESAL_PR_INT_IC_CPU_HIGHEST_PENDING 0x18\r
+#define ESAL_PR_INT_IC_CPU_NON_SECURE_POINT 0x1C\r
+#define ESAL_PR_INT_IC_CPU_IMPLEMENTOR 0xFC\r
+\r
+/* Distribution Register Offsets */\r
+#define ESAL_PR_INT_GIC_DIST_CTRL 0x000\r
+#define ESAL_PR_INT_GIC_DIST_CTR 0x004\r
+#define ESAL_PR_INT_GIC_DIST_ISR 0x080\r
+#define ESAL_PR_INT_GIC_DIST_ENABLE_SET 0x100\r
+#define ESAL_PR_INT_GIC_DIST_ENABLE_CLEAR 0x180\r
+#define ESAL_PR_INT_GIC_DIST_PENDING_SET 0x200\r
+#define ESAL_PR_INT_GIC_DIST_PENDING_CLEAR 0x280\r
+#define ESAL_PR_INT_GIC_DIST_ACTIVE_BIT 0x300\r
+#define ESAL_PR_INT_GIC_DIST_PRI 0x400\r
+#define ESAL_PR_INT_GIC_DIST_TARGET 0x800\r
+#define ESAL_PR_INT_GIC_DIST_CONFIG 0xC00\r
+#define ESAL_PR_INT_GIC_DIST_PPI_STATUS 0xD00\r
+#define ESAL_PR_INT_GIC_DIST_SPI_STATUS 0xD04\r
+#define ESAL_PR_INT_GIC_DIST_SOFTINT 0xF00\r
+\r
+/* Define value to disable all interrupts */\r
+#define ESAL_PR_INT_IRQ_DISABLE_ALL 0x00000000\r
+\r
+/* Define value to enable interrupts on cpu */\r
+#define ESAL_PR_INT_CPU_ENABLE 0x00000001\r
+#define ESAL_PR_INT_DIST_ENABLE 0x00000001\r
+\r
+/* Define Interrupt Ack Mask */\r
+#define ESAL_PR_INT_ACK_MASK 0x000003FF\r
+\r
+/* Define Spurious Int value */\r
+#define ESAL_PR_INT_SPURIOUS_INT 1023\r
+\r
+/* Define ESAL interrupt vector IDs for this processor.\r
+ These IDs match up with processor interrupts.\r
+ Values correspond to the index of entries in ESAL_GE_ISR_Interrupt_Handler[].\r
+ Names are of the form ESAL_PR_<Name>_INT_VECTOR_ID, where <Name> comes\r
+ directly from the hardware documentation */\r
+\r
+/* Private Software Generated Interrupts (SGI). */\r
+#define ESAL_PR_SOFTWARE0_INT_VECTOR_ID (ESAL_AR_INT_VECTOR_ID_DELIMITER + 0)\r
+#define ESAL_PR_SOFTWARE1_INT_VECTOR_ID (ESAL_AR_INT_VECTOR_ID_DELIMITER + 1)\r
+#define ESAL_PR_SOFTWARE2_INT_VECTOR_ID (ESAL_AR_INT_VECTOR_ID_DELIMITER + 2)\r
+#define ESAL_PR_SOFTWARE3_INT_VECTOR_ID (ESAL_AR_INT_VECTOR_ID_DELIMITER + 3)\r
+#define ESAL_PR_SOFTWARE4_INT_VECTOR_ID (ESAL_AR_INT_VECTOR_ID_DELIMITER + 4)\r
+#define ESAL_PR_SOFTWARE5_INT_VECTOR_ID (ESAL_AR_INT_VECTOR_ID_DELIMITER + 5)\r
+#define ESAL_PR_SOFTWARE6_INT_VECTOR_ID (ESAL_AR_INT_VECTOR_ID_DELIMITER + 6)\r
+#define ESAL_PR_SOFTWARE7_INT_VECTOR_ID (ESAL_AR_INT_VECTOR_ID_DELIMITER + 7)\r
+#define ESAL_PR_SOFTWARE8_INT_VECTOR_ID (ESAL_AR_INT_VECTOR_ID_DELIMITER + 8)\r
+#define ESAL_PR_SOFTWARE9_INT_VECTOR_ID (ESAL_AR_INT_VECTOR_ID_DELIMITER + 9)\r
+#define ESAL_PR_SOFTWARE10_INT_VECTOR_ID (ESAL_AR_INT_VECTOR_ID_DELIMITER + 10)\r
+#define ESAL_PR_SOFTWARE11_INT_VECTOR_ID (ESAL_AR_INT_VECTOR_ID_DELIMITER + 11)\r
+#define ESAL_PR_SOFTWARE12_INT_VECTOR_ID (ESAL_AR_INT_VECTOR_ID_DELIMITER + 12)\r
+#define ESAL_PR_SOFTWARE13_INT_VECTOR_ID (ESAL_AR_INT_VECTOR_ID_DELIMITER + 13)\r
+#define ESAL_PR_SOFTWARE14_INT_VECTOR_ID (ESAL_AR_INT_VECTOR_ID_DELIMITER + 14)\r
+#define ESAL_PR_SOFTWARE15_INT_VECTOR_ID (ESAL_AR_INT_VECTOR_ID_DELIMITER + 15)\r
+\r
+/* Reserved Interrupt Vectors. */\r
+#define ESAL_PR_RESERVED16_INT_VECTOR_ID (ESAL_AR_INT_VECTOR_ID_DELIMITER + 16)\r
+#define ESAL_PR_RESERVED17_INT_VECTOR_ID (ESAL_AR_INT_VECTOR_ID_DELIMITER + 17)\r
+#define ESAL_PR_RESERVED18_INT_VECTOR_ID (ESAL_AR_INT_VECTOR_ID_DELIMITER + 18)\r
+#define ESAL_PR_RESERVED19_INT_VECTOR_ID (ESAL_AR_INT_VECTOR_ID_DELIMITER + 19)\r
+#define ESAL_PR_RESERVED20_INT_VECTOR_ID (ESAL_AR_INT_VECTOR_ID_DELIMITER + 20)\r
+#define ESAL_PR_RESERVED21_INT_VECTOR_ID (ESAL_AR_INT_VECTOR_ID_DELIMITER + 21)\r
+#define ESAL_PR_RESERVED22_INT_VECTOR_ID (ESAL_AR_INT_VECTOR_ID_DELIMITER + 22)\r
+#define ESAL_PR_RESERVED23_INT_VECTOR_ID (ESAL_AR_INT_VECTOR_ID_DELIMITER + 23)\r
+#define ESAL_PR_RESERVED24_INT_VECTOR_ID (ESAL_AR_INT_VECTOR_ID_DELIMITER + 24)\r
+#define ESAL_PR_RESERVED25_INT_VECTOR_ID (ESAL_AR_INT_VECTOR_ID_DELIMITER + 25)\r
+#define ESAL_PR_RESERVED26_INT_VECTOR_ID (ESAL_AR_INT_VECTOR_ID_DELIMITER + 26)\r
+\r
+/* Private Peripheral Interrupts (PPI). */\r
+#define ESAL_PR_GLOBTIMER_INT_VECTOR_ID (ESAL_AR_INT_VECTOR_ID_DELIMITER + 27)\r
+#define ESAL_PR_NFIQ_INT_VECTOR_ID (ESAL_AR_INT_VECTOR_ID_DELIMITER + 28)\r
+#define ESAL_PR_PRIVTIMER_INT_VECTOR_ID (ESAL_AR_INT_VECTOR_ID_DELIMITER + 29)\r
+#define ESAL_PR_PRIVWATCHDOG_INT_VECTOR_ID (ESAL_AR_INT_VECTOR_ID_DELIMITER + 30)\r
+#define ESAL_PR_NIRQ_INT_VECTOR_ID (ESAL_AR_INT_VECTOR_ID_DELIMITER + 31)\r
+\r
+/* Shared Peripheral Interrupts (SPI). */\r
+#define ESAL_PR_CPU0_INT_VECTOR_ID (ESAL_AR_INT_VECTOR_ID_DELIMITER + 32)\r
+#define ESAL_PR_CPU1_INT_VECTOR_ID (ESAL_AR_INT_VECTOR_ID_DELIMITER + 33)\r
+#define ESAL_PR_L2CACHE_INT_VECTOR_ID (ESAL_AR_INT_VECTOR_ID_DELIMITER + 34)\r
+#define ESAL_PR_OCM_INT_VECTOR_ID (ESAL_AR_INT_VECTOR_ID_DELIMITER + 35)\r
+#define ESAL_PR_RESERVED36_INT_VECTOR_ID (ESAL_AR_INT_VECTOR_ID_DELIMITER + 36)\r
+#define ESAL_PR_PMU0_INT_VECTOR_ID (ESAL_AR_INT_VECTOR_ID_DELIMITER + 37)\r
+#define ESAL_PR_PMU1_INT_VECTOR_ID (ESAL_AR_INT_VECTOR_ID_DELIMITER + 38)\r
+#define ESAL_PR_XADC_INT_VECTOR_ID (ESAL_AR_INT_VECTOR_ID_DELIMITER + 39)\r
+#define ESAL_PR_DVI_INT_VECTOR_ID (ESAL_AR_INT_VECTOR_ID_DELIMITER + 40)\r
+#define ESAL_PR_SWDT_INT_VECTOR_ID (ESAL_AR_INT_VECTOR_ID_DELIMITER + 41)\r
+#define ESAL_PR_TTC00_INT_VECTOR_ID (ESAL_AR_INT_VECTOR_ID_DELIMITER + 42)\r
+#define ESAL_PR_TTC01_INT_VECTOR_ID (ESAL_AR_INT_VECTOR_ID_DELIMITER + 43)\r
+#define ESAL_PR_RESERVED44_INT_VECTOR_ID (ESAL_AR_INT_VECTOR_ID_DELIMITER + 44)\r
+#define ESAL_PR_DMACABORT_INT_VECTOR_ID (ESAL_AR_INT_VECTOR_ID_DELIMITER + 45)\r
+#define ESAL_PR_DMAC0_INT_VECTOR_ID (ESAL_AR_INT_VECTOR_ID_DELIMITER + 46)\r
+#define ESAL_PR_DMAC1_INT_VECTOR_ID (ESAL_AR_INT_VECTOR_ID_DELIMITER + 47)\r
+#define ESAL_PR_DMAC2_INT_VECTOR_ID (ESAL_AR_INT_VECTOR_ID_DELIMITER + 48)\r
+#define ESAL_PR_DMAC3_INT_VECTOR_ID (ESAL_AR_INT_VECTOR_ID_DELIMITER + 49)\r
+#define ESAL_PR_SMC_INT_VECTOR_ID (ESAL_AR_INT_VECTOR_ID_DELIMITER + 50)\r
+#define ESAL_PR_QUADSPI_INT_VECTOR_ID (ESAL_AR_INT_VECTOR_ID_DELIMITER + 51)\r
+#define ESAL_PR_GPIO_INT_VECTOR_ID (ESAL_AR_INT_VECTOR_ID_DELIMITER + 52)\r
+#define ESAL_PR_USB0_INT_VECTOR_ID (ESAL_AR_INT_VECTOR_ID_DELIMITER + 53)\r
+#define ESAL_PR_ETHERNET0_INT_VECTOR_ID (ESAL_AR_INT_VECTOR_ID_DELIMITER + 54)\r
+#define ESAL_PR_ETH0WAKEUP_INT_VECTOR_ID (ESAL_AR_INT_VECTOR_ID_DELIMITER + 55)\r
+#define ESAL_PR_SDIO0_INT_VECTOR_ID (ESAL_AR_INT_VECTOR_ID_DELIMITER + 56)\r
+#define ESAL_PR_I2C0_INT_VECTOR_ID (ESAL_AR_INT_VECTOR_ID_DELIMITER + 57)\r
+#define ESAL_PR_SPI0_INT_VECTOR_ID (ESAL_AR_INT_VECTOR_ID_DELIMITER + 58)\r
+#define ESAL_PR_UART0_INT_VECTOR_ID (ESAL_AR_INT_VECTOR_ID_DELIMITER + 59)\r
+#define ESAL_PR_CAN0_INT_VECTOR_ID (ESAL_AR_INT_VECTOR_ID_DELIMITER + 60)\r
+#define ESAL_PR_FPGA0_INT_VECTOR_ID (ESAL_AR_INT_VECTOR_ID_DELIMITER + 61)\r
+#define ESAL_PR_FPGA1_INT_VECTOR_ID (ESAL_AR_INT_VECTOR_ID_DELIMITER + 62)\r
+#define ESAL_PR_FPGA2_INT_VECTOR_ID (ESAL_AR_INT_VECTOR_ID_DELIMITER + 63)\r
+#define ESAL_PR_FPGA3_INT_VECTOR_ID (ESAL_AR_INT_VECTOR_ID_DELIMITER + 64)\r
+#define ESAL_PR_FPGA4_INT_VECTOR_ID (ESAL_AR_INT_VECTOR_ID_DELIMITER + 65)\r
+#define ESAL_PR_FPGA5_INT_VECTOR_ID (ESAL_AR_INT_VECTOR_ID_DELIMITER + 66)\r
+#define ESAL_PR_FPGA6_INT_VECTOR_ID (ESAL_AR_INT_VECTOR_ID_DELIMITER + 67)\r
+#define ESAL_PR_FPGA7_INT_VECTOR_ID (ESAL_AR_INT_VECTOR_ID_DELIMITER + 68)\r
+#define ESAL_PR_TTC10_INT_VECTOR_ID (ESAL_AR_INT_VECTOR_ID_DELIMITER + 69)\r
+#define ESAL_PR_TTC11_INT_VECTOR_ID (ESAL_AR_INT_VECTOR_ID_DELIMITER + 70)\r
+#define ESAL_PR_TTC12_INT_VECTOR_ID (ESAL_AR_INT_VECTOR_ID_DELIMITER + 71)\r
+#define ESAL_PR_DMAC4_INT_VECTOR_ID (ESAL_AR_INT_VECTOR_ID_DELIMITER + 72)\r
+#define ESAL_PR_DMAC5_INT_VECTOR_ID (ESAL_AR_INT_VECTOR_ID_DELIMITER + 73)\r
+#define ESAL_PR_DMAC6_INT_VECTOR_ID (ESAL_AR_INT_VECTOR_ID_DELIMITER + 74)\r
+#define ESAL_PR_DMAC7_INT_VECTOR_ID (ESAL_AR_INT_VECTOR_ID_DELIMITER + 75)\r
+#define ESAL_PR_USB1_INT_VECTOR_ID (ESAL_AR_INT_VECTOR_ID_DELIMITER + 76)\r
+#define ESAL_PR_ETHERNET1_INT_VECTOR_ID (ESAL_AR_INT_VECTOR_ID_DELIMITER + 77)\r
+#define ESAL_PR_ETH1WAKEUP_INT_VECTOR_ID (ESAL_AR_INT_VECTOR_ID_DELIMITER + 78)\r
+#define ESAL_PR_SDIO1_INT_VECTOR_ID (ESAL_AR_INT_VECTOR_ID_DELIMITER + 79)\r
+#define ESAL_PR_I2C1_INT_VECTOR_ID (ESAL_AR_INT_VECTOR_ID_DELIMITER + 80)\r
+#define ESAL_PR_SPI1_INT_VECTOR_ID (ESAL_AR_INT_VECTOR_ID_DELIMITER + 81)\r
+#define ESAL_PR_UART1_INT_VECTOR_ID (ESAL_AR_INT_VECTOR_ID_DELIMITER + 82)\r
+#define ESAL_PR_CAN1_INT_VECTOR_ID (ESAL_AR_INT_VECTOR_ID_DELIMITER + 83)\r
+#define ESAL_PR_FPGA8_INT_VECTOR_ID (ESAL_AR_INT_VECTOR_ID_DELIMITER + 84)\r
+#define ESAL_PR_FPGA9_INT_VECTOR_ID (ESAL_AR_INT_VECTOR_ID_DELIMITER + 85)\r
+#define ESAL_PR_FPGA10_INT_VECTOR_ID (ESAL_AR_INT_VECTOR_ID_DELIMITER + 86)\r
+#define ESAL_PR_FPGA11_INT_VECTOR_ID (ESAL_AR_INT_VECTOR_ID_DELIMITER + 87)\r
+#define ESAL_PR_FPGA12_INT_VECTOR_ID (ESAL_AR_INT_VECTOR_ID_DELIMITER + 88)\r
+#define ESAL_PR_FPGA13_INT_VECTOR_ID (ESAL_AR_INT_VECTOR_ID_DELIMITER + 89)\r
+#define ESAL_PR_FPGA14_INT_VECTOR_ID (ESAL_AR_INT_VECTOR_ID_DELIMITER + 90)\r
+#define ESAL_PR_FPGA15_INT_VECTOR_ID (ESAL_AR_INT_VECTOR_ID_DELIMITER + 91)\r
+#define ESAL_PR_PARITY_INT_VECTOR_ID (ESAL_AR_INT_VECTOR_ID_DELIMITER + 92)\r
+\r
+/* Define the last ESAL interrupt vector ID for this processor + 1 */\r
+#define ESAL_PR_INT_VECTOR_ID_DELIMITER (ESAL_PR_PARITY_INT_VECTOR_ID + 1)\r
+\r
+/* Define number of GIC priority registers */\r
+#define ESAL_PR_ISR_GIC_NUM_PRI_REG 16\r
+\r
+/* Define number of GIC target registers */\r
+#define ESAL_PR_ISR_GIC_NUM_TARGET_REG 16\r
+\r
+/* Define value to disable all interrupts */\r
+#define ESAL_PR_INT_DISABLE 0x00000000\r
+\r
+/* Define value to clear interrupt registers */\r
+#define ESAL_PR_INT_CLEAR 0xFFFFFFFF\r
+\r
+/* Define value to route interrupts to Core Tile 1 */\r
+#define ESAL_PR_ROUTE_CORE_TILE 0x00000000\r
+\r
+/* Define base address for status and system control registers */\r
+#define ESAL_PR_ISR_SSC_BASE 0x10000000\r
+\r
+/* Number of interrupts implemented on the EB */\r
+#define NO_OF_INTERRUPTS_IMPLEMENTED 96\r
+\r
+/* Location to install the hardware (exception/interrupt) vector table when\r
+ executing from RAM */\r
+#if (CFG_NU_BSP_ZC702EVK_AMP_REMOTE == 1)\r
+#define ESAL_PR_ISR_VECTOR_TABLE_DEST_ADDR_RAM 0x00000000\r
+#else\r
+#define ESAL_PR_ISR_VECTOR_TABLE_DEST_ADDR_RAM 0x10000000\r
+#endif\r
+\r
+/* Define timer register base address */\r
+#define ESAL_PR_TMR_TIMER_BASE_ADDR (ESAL_CO_PERIPH_BASE + 0x00000600) /* Private Timer base address */\r
+\r
+/* Define timer interrupt priority (0 - highest / 15 - lowest) */\r
+#define ESAL_PR_TMR_PRIORITY 0\r
+\r
+/* Define timer register offsets */\r
+#define ESAL_PR_TMR_TIMER_LOAD_OFFSET 0x00\r
+#define ESAL_PR_TMR_TIMER_VALUE_OFFSET 0x04\r
+#define ESAL_PR_TMR_TIMER_CTRL_OFFSET 0x08\r
+#define ESAL_PR_TMR_TIMER_INTCLR_OFFSET 0x0C\r
+\r
+/* Bit defines for timer clear register */\r
+#define ESAL_PR_TMR_TIMER_CLR ESAL_GE_MEM_32BIT_SET(0)\r
+\r
+/* Bit defines for timer control register */\r
+#define ESAL_PR_TMR_TIMER_CTRL_ENABLE ESAL_GE_MEM_32BIT_SET(0)\r
+#define ESAL_PR_TMR_TIMER_CTRL_AUTO ESAL_GE_MEM_32BIT_SET(1)\r
+#define ESAL_PR_TMR_TIMER_CTRL_IT ESAL_GE_MEM_32BIT_SET(2)\r
+\r
+/* Initialization values */\r
+#define ESAL_PR_TMR_TIMER_CTRL_INIT_VALUE (ESAL_PR_TMR_TIMER_CTRL_ENABLE | \\r
+ ESAL_PR_TMR_TIMER_CTRL_AUTO | \\r
+ ESAL_PR_TMR_TIMER_CTRL_IT)\r
+\r
+#define ESAL_PR_SYS_CTRL_OFFSET 0x1000\r
+#define ESAL_PR_TMR_ENABLE 0x00E2\r
+\r
+\r
+/* Define the clock rate for the OS timer. This value should hold\r
+ this relation MAIN_CPU_CLOCK = ESAL_PR_TMR_OS_CLOCK_RATE * N\r
+ where N should be greater or equal to 2. */\r
+\r
+#define ESAL_PR_TMR_OS_CLOCK_RATE 333000000UL\r
+\r
+/* Define the clock prescaler for the OS timer\r
+ NOTE: The prescaler is used to adjust the processor clock rate to a lower clock\r
+ rate suitable for the timer */\r
+#define ESAL_PR_TMR_OS_CLOCK_PRESCALE 1\r
+\r
+/* The following definitions / macros / etc are only used if the processor\r
+ is configured (this is only if the architecture is NOT configured to\r
+ contain the OS timer in esal_ar_cfg.h) to use a processor level timer\r
+ for the OS timer. */\r
+#if (ESAL_AR_OS_TIMER_USED == NU_FALSE)\r
+\r
+/* Define the processor OS timer type (count-down or count-up) */\r
+#define ESAL_PR_TMR_OS_COUNT_DIR ESAL_COUNT_DOWN\r
+\r
+/* Define for the processor OS timer interrupt vector */\r
+#define ESAL_PR_TMR_OS_VECTOR ESAL_PR_PRIVTIMER_INT_VECTOR_ID\r
+\r
+/* Define a macro to read the processor OS timer hardware count. The\r
+ resultant size of the count must be 32-bits, regardless of the actual\r
+ size of the timer used (8-bit, 16-bit, 32-bit, etc). */\r
+#define ESAL_PR_TMR_OS_COUNT_READ() \\r
+ ESAL_GE_MEM_READ32(ESAL_PR_TMR_TIMER_BASE_ADDR + ESAL_PR_TMR_TIMER_VALUE_OFFSET)\r
+\r
+/* Define the EOI logic for the processor OS timer */\r
+#define ESAL_PR_TMR_OS_TIMER_EOI(vector) \\r
+ ESAL_GE_MEM_WRITE32(ESAL_PR_TMR_TIMER_BASE_ADDR + \\r
+ ESAL_PR_TMR_TIMER_INTCLR_OFFSET, \\r
+ ESAL_PR_TMR_TIMER_CLR);\r
+\r
+/* Define the logic for checking if interrupt pending */\r
+#define ESAL_PR_TMR_PENDING() \\r
+ (ESAL_GE_MEM_READ32(ESAL_PR_TMR_TIMER_BASE_ADDR + \\r
+ ESAL_PR_TMR_TIMER_INTCLR_OFFSET) & 0x1)\r
+\r
+\r
+#endif /* ESAL_PR_OS_TIMER_USED == NU_TRUE */\r
+\r
+/* Define SCU register base address and offsets */\r
+#define ESAL_PR_MEM_SCU_BASE (ESAL_CO_PERIPH_BASE)\r
+#define ESAL_PR_MEM_SCU_CTRL 0x00\r
+#define ESAL_PR_MEM_SCU_INVAL 0x0C\r
+\r
+/* Define SCU register bits */\r
+#define ESAL_PR_MEM_SCU_CTRL_EN_BIT ESAL_GE_MEM_32BIT_SET(0)\r
+#define ESAL_PR_MEM_SCU_INVAL_ALL 0xFFFFFFFF\r
+\r
+/* Define auxiliary control unit SMP bit */\r
+#define ESAL_PR_MEM_AUX_CTRL_SMP_BIT ESAL_GE_MEM_32BIT_SET(6)\r
+\r
+#if (ESAL_PR_CACHE_AVAILABLE == NU_TRUE)\r
+\r
+/* This macro invalidates all of the cache at the processor level. */\r
+#define ESAL_PR_MEM_CACHE_ALL_INVALIDATE() \\r
+ { \\r
+ }\r
+\r
+/* This macro invalidates all of the instruction cache at the processor level. */\r
+#define ESAL_PR_MEM_ICACHE_ALL_INVALIDATE() \\r
+ { \\r
+ }\r
+\r
+/* This macro invalidates all of the data cache at the processor level. */\r
+#define ESAL_PR_MEM_DCACHE_ALL_INVALIDATE() \\r
+ { \\r
+ }\r
+\r
+/* This macro invalidates all instruction cache for the specified address\r
+ range at the processor level. */\r
+#define ESAL_PR_MEM_ICACHE_INVALIDATE(addr, size) \\r
+ { \\r
+ }\r
+\r
+/* This macro invalidates all data cache for the specified address\r
+ range at the processor level. */\r
+#define ESAL_PR_MEM_DCACHE_INVALIDATE(addr, size) \\r
+ { \\r
+ }\r
+\r
+/* This macro flushes all data cache to physical memory (writeback cache)\r
+ and invalidates all data cache entries at the processor level. */\r
+#define ESAL_PR_MEM_DCACHE_ALL_FLUSH_INVAL() \\r
+ { \\r
+ }\r
+\r
+/* This macro flushes all data cache to physical memory (writeback cache)\r
+ for the given address range, then invalidates all data cache entries\r
+ at the processor level. */\r
+#define ESAL_PR_MEM_DCACHE_FLUSH_INVAL(addr, size) \\r
+ { \\r
+ }\r
+\r
+#endif /* ESAL_PR_CACHE_AVAILABLE == NU_TRUE */\r
+\r
+/* L2Cpl310 L2 cache controller base address. */\r
+#define ESAL_PR_L2CPL310_BASE 0xF8F02000\r
+\r
+/* L2Cpl310 L2 cache controller register offsets. */\r
+#define ESAL_PR_L2CPL310_REG1_CONTROL 0x100\r
+#define ESAL_PR_L2CPL310_REG1_AUX_CONTROL 0x104\r
+\r
+/* L2Cpl310 L2 cache controller control register bit defines . */\r
+#define ESAL_PR_L2CPL310_REG1_CONTROL_ENABLE 0x1\r
+\r
+\r
+#if (NU_SMP_CPU_COUNT > 1)\r
+\r
+/* Define macros */\r
+#define ESAL_PR_SMP_CPU_ID_GET ESAL_PR_SMP_CPU_ID_Get\r
+\r
+/* Inter-Processor Interrupt Vector Number */\r
+#define ESAL_PR_SMP_IPI_VECTOR_ID ESAL_PR_PRIVATE0_INT_VECTOR_ID\r
+#define ESAL_PR_SMP_IPI_TRIG ESAL_TRIG_LEVEL_HIGH\r
+#define ESAL_PR_SMP_IPI_PRIORITY 0xE\r
+\r
+/* IPI target filter, options */\r
+#define ESAL_PR_IPI_TARGET_MASK 0\r
+#define ESAL_PR_IPI_TARGET_ALL_OTHERS 1\r
+#define ESAL_PR_IPI_TARGET_SELF 2\r
+#define ESAL_PR_SMP_IPI_Clear(cpu_num)\r
+VOID ESAL_PR_SMP_IPI_Send (UINT32* cpu_mask);\r
+UINT32 ESAL_PR_SMP_CPU_ID_Get(VOID);\r
+\r
+#else /* For uni-core processor */\r
+#define ESAL_PR_SMP_CPU_ID_GET 0\r
+#define ESAL_PR_SMP_IPI_Send(x)\r
+\r
+#endif /* (NU_SMP_CPU_COUNT > 1) */\r
+\r
+/* Define macros for interrupt affinity */\r
+#define ESAL_PR_NUM_PVT_INTS 32\r
+\r
+\r
+/*\r
+ * MAX_TICKS_PER_INTERVAL is the maximum multiple of system ticks\r
+ * to which the tick hardware timer can be set to.\r
+ * MAX_TICKS_PER_INTERVAL = 2^(number of bits in tick counter)-1 / (counts per tick)\r
+*/\r
+#define MAX_TICKS_PER_INTERVAL 2147\r
+\r
+/* Define for setting the processor tick value */\r
+#define ESAL_PR_TMR_TICK_VALUE_SET(value) \\r
+ ESAL_GE_MEM_WRITE32((ESAL_PR_TMR_TIMER_BASE_ADDR + \\r
+ ESAL_PR_TMR_TIMER_LOAD_OFFSET), value)\r
+\r
+/* Define the logic for setting the processor timer tick value */\r
+#define ESAL_PR_TMR_PMS_SET_HW_TICK_VALUE(interval) \\r
+ ESAL_GE_MEM_WRITE32((ESAL_PR_TMR_TIMER_BASE_ADDR + ESAL_PR_TMR_TIMER_LOAD_OFFSET), interval)\r
+\r
+/* Define method for which PMS will work with the counter. In most cases this will\r
+ match the OS timer direction. On some rarer cases it may be needed to differ, such\r
+ cases include timers that don't start at 0 but count up. */\r
+#define ESAL_PR_TMR_PMS_COUNT_METHOD ESAL_PR_TMR_OS_COUNT_DIR\r
+\r
+/*\r
+ * ESAL_PR_TMR_PMS_IS_TIMER_INT_PENDING() checks whether a hardware tick timer interrupt is\r
+ * pending at this time.\r
+ * It is used to check if a race condition occurred, CPU woke up due to\r
+ * other HW interrupt but a tick occurred between the interrupt and any\r
+ * hardware tick counter sampling.\r
+ */\r
+#define ESAL_PR_TMR_PMS_IS_TIMER_INT_PENDING() ESAL_GE_TMR_OS_PENDING()\r
+\r
+/*\r
+ * ESAL_PR_TMR_PMS_SET_HW_TICK_INTERVAL(interval) sets the hardware tick timer interval\r
+ * It is used and required only for UP counting hardware timer counters.\r
+ */\r
+#if(ESAL_PR_TMR_PMS_COUNT_METHOD == ESAL_COUNT_UP)\r
+#define ESAL_PR_TMR_PMS_SET_HW_TICK_INTERVAL(interval)\r
+#endif\r
+\r
+/*\r
+ * ESAL_PR_TMR_PMS_GET_HW_TICK_CNT_VALUE() reads the current hardware tick timer counter value\r
+ * This typically can be left mapped to ESAL_GE_TMR_OS_COUNT_READ\r
+ */\r
+#define ESAL_PR_TMR_PMS_GET_HW_TICK_CNT_VALUE() ESAL_GE_TMR_OS_COUNT_READ()\r
+\r
+/* Define for adjusting the processor tick value */\r
+#define ESAL_PR_TMR_TICK_ADJUST_SET(adjustment) \\r
+ { \\r
+ UINT32 _temp_ticks = ESAL_PR_TMR_PMS_GET_HW_TICK_CNT_VALUE(); \\r
+ /* Clear any pending timer interrupts */ \\r
+ ESAL_GE_MEM_WRITE32(ESAL_PR_TMR_TIMER_BASE_ADDR + \\r
+ ESAL_PR_TMR_TIMER_INTCLR_OFFSET, ESAL_PR_TMR_TIMER_CLR); \\r
+ ESAL_GE_MEM_WRITE32((ESAL_PR_TMR_TIMER_BASE_ADDR + \\r
+ ESAL_PR_TMR_TIMER_VALUE_OFFSET), (_temp_ticks + (adjustment))); \\r
+ }\r
+\r
+/*\r
+ * ESAL_PR_TMR_PMS_ADJUST_HW_TICK_VALUE(adjustment) adjust the current hardware tick timer value\r
+ * by the adjustment value. POSITIVE OR NEGATIVE adjustments must be handled.\r
+ * ESAL_PR_TMR_PMS_ADJUST_HW_TICK_VALUE is used only with DOWN counting hardware timer counters\r
+ * and is the preferred method for tick suppression (vs. ESAL_PMS_SET_HW_TICK_VALUE)\r
+ */\r
+#if(ESAL_PR_TMR_PMS_COUNT_METHOD == ESAL_COUNT_DOWN)\r
+#define ESAL_PR_TMR_PMS_ADJUST_HW_TICK_VALUE(adjustment) ESAL_PR_TMR_TICK_ADJUST_SET(adjustment)\r
+#endif\r
+\r
+/* This macro sets the current hardware tick timer counter value\r
+ * It is used and required only for DOWN counting hardware timer counters\r
+ * and only if ESAL_PR_TMR_PMS_ADJUST_HW_TICK_VALUE is not defined.\r
+ * ESAL_PR_TMR_PMS_SET_HW_TICK_VALUE should only be used if ESAL_PMS_ADJUST_HW_TICK function\r
+ * in unachievable because it potentially introduces small tick drift\r
+ * when the software does read-modify-write adjustments to the counter value.\r
+ */\r
+\r
+#if(ESAL_PR_TMR_PMS_COUNT_METHOD == ESAL_COUNT_DOWN)\r
+#ifndef ESAL_PR_TMR_PMS_ADJUST_HW_TICK_VALUE\r
+#define ESAL_PR_TMR_PMS_SET_HW_TICK_VALUE(value) ESAL_PR_TMR_TICK_VALUE_SET(value)\r
+#endif /*ESAL_PR_TMR_PMS_ADJUST_HW_TICK_VALUE*/\r
+#endif /*(ESAL_PR_TMR_PMS_COUNT_METHOD == ESAL_COUNT_DOWN)*/\r
+\r
+\r
+#endif /* ZYNQ7000_DEFS_H */\r
diff --git a/libs/system/zc702evk/nucleus/bsp/zc702evk_defs.h b/libs/system/zc702evk/nucleus/bsp/zc702evk_defs.h
--- /dev/null
@@ -0,0 +1,69 @@
+/***********************************************************************\r
+*\r
+* Copyright 2013 Mentor Graphics Corporation\r
+* All Rights Reserved.\r
+*\r
+* THIS WORK CONTAINS TRADE SECRET AND PROPRIETARY INFORMATION WHICH IS\r
+* THE PROPERTY OF MENTOR GRAPHICS CORPORATION OR ITS LICENSORS AND IS\r
+* SUBJECT TO LICENSE TERMS.\r
+*\r
+************************************************************************\r
+\r
+************************************************************************\r
+*\r
+* FILE NAME\r
+*\r
+* zc702evk_defs.h\r
+*\r
+* DESCRIPTION\r
+*\r
+* This file contains platform definitions for the Xilinx ZC702 EVK board\r
+*\r
+* DATA STRUCTURES\r
+*\r
+* None\r
+*\r
+* DEPENDENCIES\r
+*\r
+* None\r
+*\r
+***********************************************************************/\r
+\r
+#ifndef ZC702EVK_DEFS_H\r
+#define ZC702EVK_DEFS_H\r
+\r
+/* Define the board clock rate (in hertz).\r
+ NOTE: This clock rate is used to calculate the rate of the OS timer.\r
+ Therefore, if multiple clock sources are fed to the processor,\r
+ this clock rate value must represent the source used\r
+ by the on-chip timer unit. */\r
+#define ESAL_DP_REF_CLOCK_RATE 33333333UL\r
+\r
+/* Define number of memory regions contained on the given development platform */\r
+#define ESAL_DP_MEM_NUM_REGIONS 6\r
+\r
+/* Define if an interrupt controller (off processor) exists on the board and\r
+ controlling / handling of interrupts from this interrupt controller must\r
+ be accommodated for. Setting this to NU_FALSE means off-chip interrupts\r
+ will NOT be controlled or handled. Setting this to NU_TRUE means off-chip\r
+ interrupts will be controlled and handled */\r
+#define ESAL_DP_INTERRUPTS_AVAILABLE NU_FALSE\r
+\r
+/* Define the base of address on-chip peripheral registers */\r
+#define ESAL_DP_PERIPH_BASE 0xE0000000\r
+\r
+/* Define ESAL interrupt vector IDs for this development platform.\r
+ These IDs match up with development platform interrupts.\r
+ Values correspond to the index of entries in ESAL_GE_ISR_Interrupt_Handler[].\r
+ Names are of the form ESAL_DP_<Name>_INT_VECTOR_ID, where <Name> comes\r
+ directly from the hardware documentation */\r
+\r
+\r
+/* Define the last ESAL interrupt vector ID for this development platform + 1 */\r
+#define ESAL_DP_INT_VECTOR_ID_DELIMITER (ESAL_PR_INT_VECTOR_ID_DELIMITER + 1)\r
+\r
+/* Define the system level control registers address*/\r
+#define ESAL_DP_SLCR_BASE 0xF8000000\r
+\r
+\r
+#endif /* ZC702EVK_DEFS_H */\r
diff --git a/libs/system/zc702evk/nucleus/kernel/dev_mgr.h b/libs/system/zc702evk/nucleus/kernel/dev_mgr.h
--- /dev/null
@@ -0,0 +1,261 @@
+/*************************************************************************\r
+*\r
+* Copyright 2010 Mentor Graphics Corporation\r
+* All Rights Reserved.\r
+*\r
+* THIS WORK CONTAINS TRADE SECRET AND PROPRIETARY INFORMATION WHICH IS\r
+* THE PROPERTY OF MENTOR GRAPHICS CORPORATION OR ITS LICENSORS AND IS\r
+* SUBJECT TO LICENSE TERMS.\r
+*\r
+*************************************************************************/\r
+\r
+/*************************************************************************\r
+*\r
+* DESCRIPTION\r
+*\r
+* This file contains function prototypes of all functions\r
+* accessible to other components.\r
+*\r
+*************************************************************************/\r
+\r
+/* Check to see if the file has been included already. */\r
+#ifndef DEV_MGR_H\r
+#define DEV_MGR_H\r
+\r
+#include <string.h>\r
+\r
+#ifdef __cplusplus\r
+\r
+/* C declarations in C++ */\r
+extern "C" {\r
+\r
+#endif\r
+\r
+#ifndef CFG_NU_OS_KERN_DEVMGR_MAX_DEV_LABEL_CNT\r
+#define CFG_NU_OS_KERN_DEVMGR_MAX_DEV_LABEL_CNT 1\r
+#endif\r
+\r
+#ifndef CFG_NU_OS_KERN_DEVMGR_DISCOVERY_TASK_MAX_ID_CNT\r
+#define CFG_NU_OS_KERN_DEVMGR_DISCOVERY_TASK_MAX_ID_CNT 1\r
+#endif\r
+\r
+#ifndef CFG_NU_OS_KERN_DEVMGR_DISCOVERY_TASK_ENABLE\r
+#define CFG_NU_OS_KERN_DEVMGR_DISCOVERY_TASK_ENABLE NU_FALSE\r
+#endif\r
+\r
+#ifndef CFG_NU_OS_KERN_DEVMGR_MAX_DEVICE_LISTENERS\r
+#define CFG_NU_OS_KERN_DEVMGR_MAX_DEVICE_LISTENERS 1\r
+#endif\r
+\r
+#ifndef CFG_NU_OS_KERN_DEVMGR_MAX_DEV_SESSION_CNT\r
+#define CFG_NU_OS_KERN_DEVMGR_MAX_DEV_SESSION_CNT 1\r
+#endif\r
+\r
+/***** BEGIN User Configurable Parameters Section *****/\r
+\r
+/* Maximum number of labels a device can have */\r
+#define DV_MAX_DEV_LABEL_CNT CFG_NU_OS_KERN_DEVMGR_MAX_DEV_LABEL_CNT\r
+\r
+/* Maximum number of device ids that can be returned by DVI_Device_Discovery_Task */\r
+#define DV_DISCOVERY_TASK_MAX_ID_CNT CFG_NU_OS_KERN_DEVMGR_DISCOVERY_TASK_MAX_ID_CNT\r
+\r
+/* Device manager discovery task enable. */\r
+#define DV_DEV_DISCOVERY_TASK_ENB CFG_NU_OS_KERN_DEVMGR_DISCOVERY_TASK_ENABLE\r
+\r
+/* Limit for maximum device listeners. */\r
+#define DV_MAX_DEVICE_LISTENERS CFG_NU_OS_KERN_DEVMGR_MAX_DEVICE_LISTENERS\r
+\r
+/***** END User Configurable Parameters Section *****/\r
+\r
+/* Define common IOCTL constants*/\r
+#define DV_IOCTL0 0\r
+\r
+#define DV_IOCTL_INVALID_LENGTH -1\r
+#define DV_IOCTL_INVALID_MODE -2\r
+#define DV_IOCTL_INVALID_CMD -3\r
+\r
+/* Define illegal dev id, session id and dev handle flag values */\r
+#define DV_INVALID_DEV ((DV_DEV_ID)-1)\r
+#define DV_INVALID_HANDLE ((DV_DEV_HANDLE)-1)\r
+#define DV_INVALID_SES ((INT32)-1)\r
+\r
+/* Define system errors */\r
+#define DV_INVALID_INPUT_PARAMS -1\r
+#define DV_DEV_LIST_TOO_SMALL -2\r
+#define DV_LABEL_LIST_TOO_SMALL -3\r
+#define DV_REG_LIST_TOO_SMALL -4\r
+#define DV_UNREG_LIST_TOO_SMALL -5\r
+#define DV_INVALID_REG_PARAMS -6\r
+#define DV_INVALID_UNREG_PARAMS -7\r
+#define DV_NO_AVAILABLE_DEV_ID -8\r
+#define DV_NO_AVAILABLE_SESSION -9\r
+#define DV_DEV_NOT_REGISTERED -10\r
+#define DV_SESSION_NOT_OPEN -11\r
+#define DV_LABEL_NOT_FOUND -12\r
+#define DV_UNEXPECTED_ERROR -13\r
+#define DV_MAX_LISTENER_LIMIT_EXCEEDED -14\r
+\r
+/* Define a macro to compare two labels */\r
+#define DV_COMPARE_LABELS(label1,label2) (memcmp((VOID*)label1, (VOID*)label2, 16) == 0)\r
+\r
+/* Define a macro to calculate the size of the label array */\r
+#define DV_GET_LABEL_COUNT(label_array) ((INT)(sizeof(label_array)/sizeof(DV_DEV_LABEL)))\r
+\r
+/* Define a macro to clear a label */\r
+#define DV_CLEAR_LABEL(label) ((VOID)memset(label, 0, 16))\r
+\r
+\r
+/* Device Manager Device ID definition */\r
+typedef INT32 DV_DEV_ID;\r
+\r
+/* Device Manager Device Handle definition */\r
+typedef INT32 DV_DEV_HANDLE;\r
+\r
+/* Device Label definition */\r
+typedef struct _dv_dev_label_struct\r
+{\r
+ UINT8 data[16];\r
+\r
+} DV_DEV_LABEL;\r
+\r
+/* Typedefs for driver open, close, read, write and ioctl functions. */\r
+typedef STATUS (*DV_DRV_OPEN_FUNCTION)(VOID* instance_handle, DV_DEV_LABEL label_list[], INT label_cnt, VOID* *session_handle_ptr);\r
+typedef STATUS (*DV_DRV_CLOSE_FUNCTION)(VOID* session_handle);\r
+typedef STATUS (*DV_DRV_READ_FUNCTION)(VOID* session_handle, VOID *buffer, UINT32 numbyte, OFFSET_T byte_offset, UINT32 *bytes_read_ptr);\r
+typedef STATUS (*DV_DRV_WRITE_FUNCTION)(VOID* session_handle, const VOID *buffer, UINT32 numbyte, OFFSET_T byte_offset, UINT32 *bytes_written_ptr);\r
+typedef STATUS (*DV_DRV_IOCTL_FUNCTION)(VOID* session_handle, INT ioctl_num, VOID* ioctl_data, INT ioctl_data_len);\r
+\r
+/* Typedefs for device register/unregister listeners. */\r
+typedef STATUS (*DEV_REGISTER_CALLBACK)(DV_DEV_ID, VOID *);\r
+typedef STATUS (*DEV_UNREGISTER_CALLBACK)(DV_DEV_ID, VOID *);\r
+typedef UINT32 DV_LISTENER_HANDLE;\r
+\r
+/* Application level structure for DVC_Dev_Register() */\r
+typedef struct _dv_drv_functions_struct\r
+{\r
+ DV_DRV_OPEN_FUNCTION drv_open_ptr;\r
+ DV_DRV_CLOSE_FUNCTION drv_close_ptr;\r
+ DV_DRV_READ_FUNCTION drv_read_ptr;\r
+ DV_DRV_WRITE_FUNCTION drv_write_ptr;\r
+ DV_DRV_IOCTL_FUNCTION drv_ioctl_ptr;\r
+\r
+} DV_DRV_FUNCTIONS;\r
+\r
+/* Application level structure for DV_IOCTL0 */\r
+typedef struct _dv_ioctl0_struct\r
+{\r
+ DV_DEV_LABEL label;\r
+ INT base;\r
+\r
+} DV_IOCTL0_STRUCT;\r
+\r
+/* Application level structure for DVC_Reg_Change_Check() */\r
+typedef struct _dv_app_registry_change_struct\r
+{\r
+ INT max_id_cnt;\r
+ INT registry_changes;\r
+ DV_DEV_LABEL *dev_label_list_ptr;\r
+ INT dev_label_cnt;\r
+ DV_DEV_ID *known_id_list_ptr;\r
+ INT *known_id_cnt_ptr;\r
+ DV_DEV_ID *reg_id_list_ptr;\r
+ INT *reg_id_cnt_ptr;\r
+ DV_DEV_ID *unreg_id_list_ptr;\r
+ INT *unreg_id_cnt_ptr;\r
+\r
+} DV_APP_REGISTRY_CHANGE;\r
+\r
+/* Device listener definition */\r
+typedef struct _dv_dev_listener_struct\r
+{\r
+ DV_DEV_LABEL dev_label_list[DV_MAX_DEV_LABEL_CNT];\r
+ DV_DEV_ID known_id_list[DV_DISCOVERY_TASK_MAX_ID_CNT];\r
+ INT known_id_cnt;\r
+ INT dev_label_cnt;\r
+ DEV_REGISTER_CALLBACK device_register_callback;\r
+ DEV_UNREGISTER_CALLBACK device_unregister_callback;\r
+ VOID *context;\r
+\r
+} DV_DEV_LISTENER;\r
+\r
+\r
+/* Core processing functions. */\r
+\r
+STATUS DVC_Dev_Register (VOID* instance_handle,\r
+ DV_DEV_LABEL dev_label_list[], INT dev_label_cnt,\r
+ DV_DRV_FUNCTIONS *drv_functions_ptr,\r
+ DV_DEV_ID *dev_id_ptr);\r
+\r
+STATUS DVC_Dev_Unregister (DV_DEV_ID dev_id,\r
+ VOID* *instance_handle_ptr);\r
+\r
+STATUS DVC_Dev_ID_Open (DV_DEV_ID dev_id,\r
+ DV_DEV_LABEL dev_label_list[], INT dev_label_cnt,\r
+ DV_DEV_HANDLE *dev_handle_ptr);\r
+\r
+STATUS DVC_Dev_Open (DV_DEV_LABEL *dev_name_ptr,\r
+ DV_DEV_HANDLE *dev_handle_ptr);\r
+\r
+STATUS DVC_Dev_Close (DV_DEV_HANDLE dev_handle);\r
+\r
+STATUS DVC_Dev_Read (DV_DEV_HANDLE dev_handle,\r
+ VOID *buffer_ptr,\r
+ UINT32 numbyte,\r
+ OFFSET_T byte_offset,\r
+ UINT32 *bytes_read_ptr);\r
+\r
+STATUS DVC_Dev_Write (DV_DEV_HANDLE dev_handle,\r
+ VOID *buffer_ptr,\r
+ UINT32 numbyte,\r
+ OFFSET_T byte_offset,\r
+ UINT32 *bytes_written_ptr);\r
+\r
+STATUS DVC_Dev_Ioctl (DV_DEV_HANDLE dev_handle,\r
+ INT ioctl_num,\r
+ VOID* ioctl_data,\r
+ INT ioctl_data_len);\r
+\r
+STATUS DVC_Reg_Change_Notify(DV_DEV_LABEL dev_label_list[],\r
+ INT dev_label_cnt,\r
+ DEV_REGISTER_CALLBACK register_cb,\r
+ DEV_UNREGISTER_CALLBACK unregister_cb,\r
+ VOID *context,\r
+ DV_LISTENER_HANDLE *listener_id);\r
+\r
+STATUS DVC_Reg_Change_Check (DV_APP_REGISTRY_CHANGE *app_struct_ptr,\r
+ UNSIGNED suspend);\r
+\r
+STATUS DVC_Dev_ID_Get (DV_DEV_LABEL dev_label_list[], INT dev_label_cnt,\r
+ DV_DEV_ID dev_id_list[], INT *dev_id_cnt_ptr);\r
+\r
+STATUS DVC_Dev_Labels_Get (DV_DEV_ID dev_id,\r
+ DV_DEV_LABEL dev_label_list[], INT *dev_label_cnt_ptr);\r
+\r
+/* Supplemental processing functions. */\r
+\r
+STATUS DVS_Label_Append (DV_DEV_LABEL new_label_list[], INT new_label_max,\r
+ DV_DEV_LABEL old_label_list[], INT old_label_cnt,\r
+ DV_DEV_LABEL app_label_list[], INT app_label_cnt);\r
+\r
+STATUS DVS_Label_Append_Instance (DV_DEV_LABEL new_label_list[], INT new_label_max,\r
+ DV_DEV_LABEL old_label_list[], INT old_label_cnt,\r
+ const CHAR* key);\r
+\r
+STATUS DVS_Label_Copy (DV_DEV_LABEL to_label_list[], INT to_label_max,\r
+ DV_DEV_LABEL from_label_list[], INT from_label_cnt);\r
+\r
+STATUS DVS_Label_List_Contains (DV_DEV_LABEL label_list[], INT label_cnt,\r
+ DV_DEV_LABEL search_label);\r
+\r
+STATUS DVS_Label_Remove (DV_DEV_LABEL label_list[], INT label_cnt,\r
+ DV_DEV_LABEL remove_label);\r
+\r
+STATUS DVS_Label_Replace (DV_DEV_LABEL label_list[], INT label_cnt,\r
+ DV_DEV_LABEL search_label, DV_DEV_LABEL new_label);\r
+\r
+\r
+#ifdef __cplusplus\r
+}\r
+#endif /* _cplusplus */\r
+\r
+#endif\r
diff --git a/libs/system/zc702evk/nucleus/kernel/eh_defs.h b/libs/system/zc702evk/nucleus/kernel/eh_defs.h
--- /dev/null
@@ -0,0 +1,73 @@
+/*************************************************************************\r
+*\r
+* Copyright Mentor Graphics Corporation 1999\r
+* All Rights Reserved.\r
+*\r
+* THIS WORK CONTAINS TRADE SECRET AND PROPRIETARY INFORMATION WHICH IS\r
+* THE PROPERTY OF MENTOR GRAPHICS CORPORATION OR ITS LICENSORS AND IS\r
+* SUBJECT TO LICENSE TERMS.\r
+*\r
+**************************************************************************\r
+\r
+**************************************************************************\r
+*\r
+* FILE NAME \r
+*\r
+* eh_defs.h \r
+*\r
+* COMPONENT\r
+*\r
+* EH - Exception Handling\r
+*\r
+* DESCRIPTION\r
+*\r
+* Type definitions for Exception Handling\r
+*\r
+* DATA STRUCTURES\r
+*\r
+* None\r
+*\r
+* PUBLIC FUNCTIONS\r
+*\r
+* None\r
+*\r
+* PRIVATE FUNCTIONS\r
+*\r
+* None\r
+*\r
+* DEPENDENCIES\r
+*\r
+* None\r
+*\r
+*************************************************************************/\r
+\r
+#ifndef EH_DEFS_H\r
+#define EH_DEFS_H\r
+\r
+\r
+#ifdef __cplusplus\r
+extern "C" {\r
+#endif\r
+\r
+/* Exception control block identifier is 'EXCE' */\r
+#define EH_EXCEPTION_ID 0x45584345UL\r
+\r
+struct EH_EXCEPTION\r
+{\r
+ UNSIGNED eh_id; /* Internal exception ID */\r
+ VOID *eh_thread; /* Offending thread */\r
+ VOID *eh_address; /* Address where error occurred */\r
+ INT eh_type; /* Type of error that occurred */\r
+};\r
+\r
+#ifndef __cplusplus\r
+typedef struct EH_EXCEPTION EH_EXCEPTION;\r
+#endif\r
+\r
+#ifdef __cplusplus\r
+}\r
+#endif\r
+\r
+#endif /* #ifndef EH_DEFS_H */\r
+\r
+\r
diff --git a/libs/system/zc702evk/nucleus/kernel/eh_extr.h b/libs/system/zc702evk/nucleus/kernel/eh_extr.h
--- /dev/null
@@ -0,0 +1,74 @@
+/*************************************************************************\r
+*\r
+* Copyright Mentor Graphics Corporation 1999\r
+* All Rights Reserved.\r
+*\r
+* THIS WORK CONTAINS TRADE SECRET AND PROPRIETARY INFORMATION WHICH IS\r
+* THE PROPERTY OF MENTOR GRAPHICS CORPORATION OR ITS LICENSORS AND IS\r
+* SUBJECT TO LICENSE TERMS.\r
+*\r
+**************************************************************************\r
+\r
+**************************************************************************\r
+*\r
+* FILE NAME \r
+*\r
+* eh_extr.h \r
+*\r
+* COMPONENT\r
+*\r
+* EH - Exception Handling\r
+*\r
+* DESCRIPTION\r
+*\r
+* Interface to Exception Handling routines\r
+*\r
+* DATA STRUCTURES\r
+*\r
+* None\r
+*\r
+* PUBLIC FUNCTIONS\r
+*\r
+* None\r
+*\r
+* PRIVATE FUNCTIONS\r
+*\r
+* None\r
+*\r
+* DEPENDENCIES\r
+*\r
+* eh_defs.h\r
+* ms_defs.h\r
+*\r
+*************************************************************************/\r
+\r
+#ifndef EH_EXTR_H\r
+#define EH_EXTR_H\r
+\r
+#include "eh_defs.h"\r
+#include "ms_defs.h"\r
+\r
+#ifdef __cplusplus\r
+extern "C" {\r
+#endif\r
+\r
+STATUS EHC_Register_Exception_Handler(MS_MODULE *module_ptr,\r
+ VOID(*exception_entry)(MS_MODULE *,EH_EXCEPTION *),\r
+ VOID(**old_exception)(MS_MODULE *,EH_EXCEPTION *));\r
+\r
+STATUS EHC_Set_Default_Exception_Handler(VOID(*exception_entry)(MS_MODULE *,EH_EXCEPTION *),\r
+ VOID(**old_exception)(MS_MODULE *,EH_EXCEPTION *));\r
+\r
+STATUS EHF_Get_Default_Exception_Handler(VOID(**exception_ptr)(MS_MODULE *,EH_EXCEPTION *));\r
+\r
+STATUS EHFM_Module_Exception_Handler(MS_MODULE *module_ptr,\r
+ VOID(**exception_ptr)(MS_MODULE *,EH_EXCEPTION *));\r
+\r
+#ifdef __cplusplus\r
+}\r
+#endif\r
+\r
+\r
+#endif /* #ifndef EH_EXTR_H */\r
+\r
+\r
diff --git a/libs/system/zc702evk/nucleus/kernel/eqm.h b/libs/system/zc702evk/nucleus/kernel/eqm.h
--- /dev/null
@@ -0,0 +1,124 @@
+/***********************************************************************\r
+*\r
+* Copyright 2011 Mentor Graphics Corporation\r
+* All Rights Reserved.\r
+*\r
+* THIS WORK CONTAINS TRADE SECRET AND PROPRIETARY INFORMATION WHICH IS\r
+* THE PROPERTY OF MENTOR GRAPHICS CORPORATION OR ITS LICENSORS AND IS\r
+* SUBJECT TO LICENSE TERMS.\r
+*\r
+************************************************************************\r
+\r
+************************************************************************\r
+*\r
+* FILE NAME\r
+*\r
+* eqm.h\r
+*\r
+* COMPONENT\r
+*\r
+* Event Queue Manager\r
+*\r
+* DESCRIPTION\r
+*\r
+* This file contains Event Queue Manager information.\r
+*\r
+* DATA STRUCTURES\r
+*\r
+* EQM_EVENT Structure to hold the event type.\r
+* If user wants to pass the event\r
+* data as well user will create a\r
+* new structure using this structure\r
+* as template and add data members\r
+* to his own structure. Obviously\r
+* the first parameter of his\r
+* structure would be event type.\r
+* EQM_EVENT_NODE Structure to store event along\r
+* with data\r
+* EQM_EVENT_QUEUE Structure to hold the event queue\r
+* attributes.\r
+*\r
+*************************************************************************/\r
+#ifndef EQM_H\r
+#define EQM_H\r
+\r
+\r
+#ifdef __cplusplus\r
+extern "C" { /* C declarations in C++ */\r
+#endif /* _cplusplus */\r
+\r
+/* Datatypes */\r
+typedef UINT32 EQM_EVENT_ID;\r
+typedef UINT32 EQM_EVENT_HANDLE;\r
+\r
+typedef struct EQM_EVENT_STRUCT\r
+{\r
+ /* Event type. */\r
+ UINT32 eqm_event_type;\r
+\r
+} EQM_EVENT;\r
+\r
+typedef struct EQM_EVENT_NODE_STRUCT\r
+{\r
+ /* Unique ID assigned to a posted event. */\r
+ EQM_EVENT_ID eqm_event_id;\r
+\r
+ /* Size of the associated event data. */\r
+ UINT16 eqm_event_data_size;\r
+\r
+ /* Associated event data. */\r
+ UINT8 *eqm_event_data;\r
+\r
+} EQM_EVENT_NODE;\r
+\r
+typedef struct EQM_EVENT_QUEUE_STRUCT\r
+{\r
+ /* Maximum number of events stored in event queue */\r
+ UINT32 eqm_max_events;\r
+\r
+ /* Maximum size of event data */\r
+ UINT16 eqm_max_event_data_size;\r
+\r
+ /* The ID that will be assigned to the incoming event in the system.\r
+ '0' will not be assigned to any event. */\r
+ EQM_EVENT_ID eqm_current_event_id;\r
+\r
+ /* eqm_buffer_index is the array index that is used as an handle to avoid\r
+ searching overhead while reading the data associated with the event. */\r
+ EQM_EVENT_HANDLE eqm_buffer_index;\r
+\r
+ /* eqm_event_data_buffer is an array of EQM_Event_NODE. Each element of\r
+ the array will hold a new event. */\r
+ EQM_EVENT_NODE *eqm_event_data_buffer;\r
+\r
+ /* EQM_Event_Group is used to signal the event to the waiting\r
+ components. */\r
+ NU_EVENT_GROUP eqm_event_group;\r
+\r
+} EQM_EVENT_QUEUE;\r
+\r
+\r
+STATUS NU_EQM_Create (EQM_EVENT_QUEUE *event_queue_ptr,\r
+ UINT32 queue_size,\r
+ UINT16 max_event_data_size,\r
+ NU_MEMORY_POOL *memory_pool_ptr);\r
+STATUS NU_EQM_Delete (EQM_EVENT_QUEUE *event_queue_ptr);\r
+STATUS NU_EQM_Post_Event (EQM_EVENT_QUEUE *event_queue_ptr,\r
+ EQM_EVENT *event_ptr, UINT16 event_data_size,\r
+ EQM_EVENT_ID *posted_event_id_ptr);\r
+STATUS NU_EQM_Wait_Event (EQM_EVENT_QUEUE *event_queue_ptr,\r
+ UINT32 requested_events_mask,\r
+ UINT32 *recvd_event_type_ptr,\r
+ EQM_EVENT_ID *recvd_event_id_ptr,\r
+ EQM_EVENT_HANDLE *recvd_event_handle_ptr);\r
+STATUS NU_EQM_Get_Event_Data(EQM_EVENT_QUEUE *event_queue_ptr,\r
+ EQM_EVENT_ID event_id,\r
+ EQM_EVENT_HANDLE event_handle,\r
+ EQM_EVENT *event_ptr);\r
+\r
+\r
+#ifdef __cplusplus\r
+}\r
+#endif /* _cplusplus */\r
+\r
+#endif /* EQM_H */\r
diff --git a/libs/system/zc702evk/nucleus/kernel/esal_extr.h b/libs/system/zc702evk/nucleus/kernel/esal_extr.h
--- /dev/null
@@ -0,0 +1,870 @@
+/***********************************************************************\r
+*\r
+* Copyright 2011 Mentor Graphics Corporation\r
+* All Rights Reserved.\r
+*\r
+* THIS WORK CONTAINS TRADE SECRET AND PROPRIETARY INFORMATION WHICH IS\r
+* THE PROPERTY OF MENTOR GRAPHICS CORPORATION OR ITS LICENSORS AND IS\r
+* SUBJECT TO LICENSE TERMS.\r
+*\r
+************************************************************************\r
+\r
+************************************************************************\r
+*\r
+* DESCRIPTION\r
+*\r
+* This file provides the external interface to the Embedded\r
+* Software Abstraction Layer components\r
+*\r
+***********************************************************************/\r
+\r
+#ifndef ESAL_EXTR_H\r
+#define ESAL_EXTR_H\r
+\r
+#ifdef __cplusplus\r
+\r
+/* C declarations in C++ */\r
+extern "C" {\r
+#endif\r
+\r
+/* Include configuration header files */\r
+#include <string.h>\r
+#include "services/nu_trace_os_mark.h"\r
+\r
+/************************************************************************/\r
+/* Other GENERIC ESAL macros/defines needed by PLUS */\r
+/************************************************************************/\r
+\r
+/* Define all externally accessible, interrupt related function prototypes */\r
+INT ESAL_GE_INT_Global_Set(INT new_value);\r
+\r
+\r
+/************************************************************************/\r
+/* Nucleus Toolset specific macros */\r
+/************************************************************************/\r
+\r
+#define ESAL_GE_INT_DISABLE_BITS ESAL_AR_INTERRUPTS_DISABLE_BITS\r
+#define ESAL_GE_INT_ENABLE_BITS ESAL_AR_INTERRUPTS_ENABLE_BITS\r
+\r
+\r
+/************************************************************************/\r
+/* Memory */\r
+/************************************************************************/\r
+\r
+/* Define memory common read/write macros */\r
+#define ESAL_GE_MEM_READ8(addr) *(volatile UINT8 *)(addr)\r
+#define ESAL_GE_MEM_READ16(addr) *(volatile UINT16 *)(addr)\r
+#define ESAL_GE_MEM_READ32(addr) *(volatile UINT32 *)(addr)\r
+#define ESAL_GE_MEM_WRITE8(addr,data) *(volatile UINT8 *)(addr) = (UINT8)(data)\r
+#define ESAL_GE_MEM_WRITE16(addr,data) *(volatile UINT16 *)(addr) = (UINT16)(data)\r
+#define ESAL_GE_MEM_WRITE32(addr,data) *(volatile UINT32 *)(addr) = (UINT32)(data)\r
+\r
+#if (ESAL_TS_64BIT_SUPPORT == NU_TRUE)\r
+\r
+#define ESAL_GE_MEM_READ64(addr) *(volatile UINT64 *)(addr)\r
+#define ESAL_GE_MEM_WRITE64(addr,data) *(volatile UINT64 *)(addr) = (UINT64)(data)\r
+\r
+#endif /* ESAL_TS_64BIT_SUPPORT == NU_TRUE */\r
+\r
+/* Defines for big endian and little endian */\r
+#define ESAL_BIG_ENDIAN 0\r
+#define ESAL_LITTLE_ENDIAN 1\r
+\r
+/* Defines used for common memory sizes */\r
+#define ESAL_GE_MEM_1K 1024UL\r
+#define ESAL_GE_MEM_2K (ESAL_GE_MEM_1K * 2UL)\r
+#define ESAL_GE_MEM_4K (ESAL_GE_MEM_1K * 4UL)\r
+#define ESAL_GE_MEM_8K (ESAL_GE_MEM_1K * 8UL)\r
+#define ESAL_GE_MEM_16K (ESAL_GE_MEM_1K * 16UL)\r
+#define ESAL_GE_MEM_32K (ESAL_GE_MEM_1K * 32UL)\r
+#define ESAL_GE_MEM_64K (ESAL_GE_MEM_1K * 64UL)\r
+#define ESAL_GE_MEM_128K (ESAL_GE_MEM_1K * 128UL)\r
+#define ESAL_GE_MEM_256K (ESAL_GE_MEM_1K * 256UL)\r
+#define ESAL_GE_MEM_512K (ESAL_GE_MEM_1K * 512UL)\r
+#define ESAL_GE_MEM_1M (ESAL_GE_MEM_1K * 1024UL)\r
+#define ESAL_GE_MEM_2M (ESAL_GE_MEM_1M * 2UL)\r
+#define ESAL_GE_MEM_4M (ESAL_GE_MEM_1M * 4UL)\r
+#define ESAL_GE_MEM_8M (ESAL_GE_MEM_1M * 8UL)\r
+#define ESAL_GE_MEM_16M (ESAL_GE_MEM_1M * 16UL)\r
+#define ESAL_GE_MEM_32M (ESAL_GE_MEM_1M * 32UL)\r
+#define ESAL_GE_MEM_64M (ESAL_GE_MEM_1M * 64UL)\r
+#define ESAL_GE_MEM_128M (ESAL_GE_MEM_1M * 128UL)\r
+#define ESAL_GE_MEM_256M (ESAL_GE_MEM_1M * 256UL)\r
+#define ESAL_GE_MEM_512M (ESAL_GE_MEM_1M * 512UL)\r
+#define ESAL_GE_MEM_1G (ESAL_GE_MEM_1M * 1024UL)\r
+#define ESAL_GE_MEM_2G (ESAL_GE_MEM_1G * 2UL)\r
+#define ESAL_GE_MEM_3G (ESAL_GE_MEM_1G * 3UL)\r
+#define ESAL_GE_MEM_4G (ESAL_GE_MEM_1G * 4UL)\r
+\r
+/* Check if architecture uses reverse bit-ordering (most-significant bit is bit 0\r
+ instead of bit 31) */\r
+#ifdef ESAL_AR_REVERSE_BIT_ORDERING\r
+\r
+/* Macro used to make a 32-bit value with the specified bit set (reverse ordering) */\r
+#define ESAL_GE_MEM_32BIT_SET(bit_num) (1UL<<(31-bit_num))\r
+\r
+/* Macro used to make a 32-bit value with the specified bit clear (reverse ordering) */\r
+#define ESAL_GE_MEM_32BIT_CLEAR(bit_num) ~(1UL<<(31-bit_num))\r
+\r
+/* Macro used to get the value of the bits starting at start_bit up to\r
+ end_bit (reverse ordering) */\r
+#define ESAL_GE_MEM_32BIT_VAL_GET(value,start_bit,end_bit) \\r
+ (UINT32)(((UINT32)(value) & \\r
+ (ESAL_GE_MEM_32BIT_SET(31-start_bit) - 1 + \\r
+ ESAL_GE_MEM_32BIT_SET(31-start_bit))) >> \\r
+ (31-end_bit))\r
+\r
+/* Macro used to test if the specified bit number is set\r
+ (returns NU_TRUE if set / NU_FALSE if not set) (reverse ordering) */\r
+#define ESAL_GE_MEM_32BIT_TEST(value,bit_num) \\r
+ (((UINT32)(value) & ESAL_GE_MEM_32BIT_SET(31-bit_num)) ? NU_TRUE : NU_FALSE)\r
+\r
+#else\r
+\r
+/* Macro used to make a 32-bit value with the specified bit set */\r
+#define ESAL_GE_MEM_32BIT_SET(bit_num) (1UL<<(bit_num))\r
+\r
+/* Macro used to make a 32-bit value with the specified bit clear */\r
+#define ESAL_GE_MEM_32BIT_CLEAR(bit_num) ~(1UL<<(bit_num))\r
+\r
+/* Macro used to get the value of the bits starting from start_bit up to\r
+ end_bit */\r
+#define ESAL_GE_MEM_32BIT_VAL_GET(value,start_bit,end_bit) \\r
+ (UINT32)(((UINT32)(value) & \\r
+ (ESAL_GE_MEM_32BIT_SET(end_bit) - 1 + \\r
+ ESAL_GE_MEM_32BIT_SET(end_bit))) >> \\r
+ (start_bit))\r
+\r
+/* Macro used to test if the specified bit number is set\r
+ (returns NU_TRUE if set / NU_FALSE if not set) */\r
+#define ESAL_GE_MEM_32BIT_TEST(value,bit_num) \\r
+ (((UINT32)(value) & ESAL_GE_MEM_32BIT_SET(bit_num)) ? NU_TRUE : NU_FALSE)\r
+\r
+#endif /* ESAL_AR_REVERSE_BIT_ORDERING */\r
+\r
+/* Macro used to test if the specified bit mask is set within the given value\r
+ (returns NU_TRUE if entire bit mask is set / NU_FALSE if entire bitmask not set) */\r
+#define ESAL_GE_MEM_32BIT_MASK_TEST(value,bit_mask) \\r
+ (((UINT32)(value) & (bit_mask)) == (bit_mask) ? NU_TRUE : NU_FALSE)\r
+\r
+/* Define for size of 4 unsigned longs */\r
+#define ESAL_GE_MEM_4_X_32BIT_SIZE (UINT32)(sizeof(UINT32) << 2)\r
+\r
+/* Define for size of 1 unsigned long */\r
+#define ESAL_GE_MEM_1_X_32BIT_SIZE (UINT32)(sizeof(UINT32))\r
+\r
+/* Define macros used to align pointers / check for alignment based on data pointer size */\r
+#if (ESAL_TS_DATA_PTR_SIZE <= 16)\r
+\r
+/* Macro used to check if a value is aligned to the required boundary.\r
+ Returns NU_TRUE if aligned; NU_FALSE if not aligned\r
+ NOTE: The required alignment must be a power of 2 (2, 4, 8, 16, 32, etc) */\r
+#define ESAL_GE_MEM_ALIGNED_CHECK(value, req_align) \\r
+ (((UINT16)(value) & ((UINT16)(req_align) - (UINT16)1)) == (UINT16)0)\r
+\r
+/* Macro used to align a data pointer to next address that meets the specified\r
+ required alignment.\r
+ NOTE: The required alignment must be a power of 2 (2, 4, 8, 16, 32, etc) */\r
+#define ESAL_GE_MEM_PTR_ALIGN(ptr_addr, req_align) \\r
+ ((ESAL_GE_MEM_ALIGNED_CHECK(ptr_addr, req_align)) ? (VOID *)ptr_addr : \\r
+ (VOID *)(((UINT16)(ptr_addr) & (UINT16)(~((req_align) - 1))) + (UINT16)(req_align)))\r
+\r
+#elif (ESAL_TS_DATA_PTR_SIZE <= 32)\r
+\r
+/* Macro used to check if a value is aligned to the required boundary.\r
+ Returns NU_TRUE if aligned; NU_FALSE if not aligned\r
+ NOTE: The required alignment must be a power of 2 (2, 4, 8, 16, 32, etc) */\r
+#define ESAL_GE_MEM_ALIGNED_CHECK(value, req_align) \\r
+ (((UINT32)(value) & ((UINT32)(req_align) - (UINT32)1)) == (UINT32)0)\r
+\r
+/* Macro used to align a data pointer to next address that meets the specified\r
+ required alignment.\r
+ NOTE: The required alignment must be a power of 2 (2, 4, 8, 16, 32, etc) */\r
+#define ESAL_GE_MEM_PTR_ALIGN(ptr_addr, req_align) \\r
+ ((ESAL_GE_MEM_ALIGNED_CHECK(ptr_addr, req_align)) ? (VOID *)ptr_addr : \\r
+ (VOID *)(((UINT32)(ptr_addr) & (UINT32)(~((req_align) - 1))) + (UINT32)(req_align)))\r
+\r
+#elif (ESAL_TS_DATA_PTR_SIZE <= 64)\r
+\r
+#if (ESAL_TS_64BIT_SUPPORT == NU_TRUE)\r
+\r
+/* Macro used to check if a value is aligned to the required boundary.\r
+ Returns NU_TRUE if aligned; NU_FALSE if not aligned\r
+ NOTE: The required alignment must be a power of 2 (2, 4, 8, 16, 32, etc) */\r
+#define ESAL_GE_MEM_ALIGNED_CHECK(value, req_align) \\r
+ (((UINT64)(value) & ((UINT64)(req_align) - (UINT64)1)) == (UINT64)0)\r
+\r
+/* Macro used to align a data pointer to next address that meets the specified\r
+ required alignment.\r
+ NOTE: The required alignment must be a power of 2 (2, 4, 8, 16, 32, etc) */\r
+#define ESAL_GE_MEM_PTR_ALIGN(ptr_addr, req_align) \\r
+ ((ESAL_GE_MEM_ALIGNED_CHECK(ptr_addr, req_align)) ? (VOID *)ptr_addr : \\r
+ (VOID *)(((UINT64)(ptr_addr) & (UINT64)(~((req_align) - 1))) + (UINT64)(req_align)))\r
+\r
+#else\r
+\r
+/* Generate error - toolset doesn't support 64-bit operations */\r
+#error Toolset does not support 64-bit operations (esal_ts_cfg.h)\r
+\r
+#endif /* ESAL_TS_64BIT_SUPPORT == NU_TRUE */\r
+\r
+#endif /* ESAL_TS_DATA_PTR_SIZE <= 16 */\r
+\r
+/* Define memory clear */\r
+#define ESAL_GE_MEM_Clear(x,y) memset(x,0,y)\r
+#define ESAL_GE_MEM_Set(x,y,z) memset(x,y,z)\r
+#define ESAL_GE_MEM_Copy(dst, src, size) memcpy(dst, src, size)\r
+\r
+/* Define enumerated type for cache types */\r
+typedef enum\r
+{\r
+ ESAL_NOCACHE,\r
+ ESAL_WRITEBACK,\r
+ ESAL_WRITETHROUGH\r
+\r
+} ESAL_GE_CACHE_TYPE;\r
+\r
+/* Define enumerated type for memory types */\r
+typedef enum\r
+{\r
+ ESAL_ROM,\r
+ ESAL_RAM,\r
+ ESAL_MEM_MAPPED,\r
+ ESAL_IO_MAPPED,\r
+ ESAL_SHARED_RAM,\r
+ ESAL_TLB_MEM\r
+\r
+} ESAL_GE_MEMORY_TYPE;\r
+\r
+/* Define error value for memory related functions */\r
+#define ESAL_GE_MEM_ERROR 0xFFFFFFFFUL\r
+\r
+/* Define values for memory access types */\r
+#define ESAL_INST 0x00000001UL\r
+#define ESAL_DATA 0x00000002UL\r
+#define ESAL_INST_AND_DATA (ESAL_INST|ESAL_DATA)\r
+\r
+/* Define generic structure used to define memory region */\r
+typedef struct\r
+{\r
+ VOID *physical_start_addr;\r
+ VOID *virtual_start_addr;\r
+ UINT32 size;\r
+ ESAL_GE_CACHE_TYPE cache_type;\r
+ ESAL_GE_MEMORY_TYPE mem_type;\r
+ UINT32 access_type;\r
+\r
+} ESAL_GE_MEM_REGION;\r
+\r
+/* Externally accessible global data */\r
+extern UINT32 ESAL_DP_MEM_Num_Regions;\r
+\r
+/* Externally accessible global data */\r
+extern const ESAL_GE_MEM_REGION ESAL_DP_MEM_Region_Data[ESAL_DP_MEM_NUM_REGIONS];\r
+\r
+/* Define all memory related function prototypes */\r
+UINT32 ESAL_GE_MEM_Remaining_Size_Get(VOID *start_addr);\r
+VOID *ESAL_GE_MEM_Next_Match_Find(VOID *start_addr,\r
+ ESAL_GE_CACHE_TYPE cache_type,\r
+ ESAL_GE_MEMORY_TYPE mem_type,\r
+ UINT32 access_type);\r
+VOID *ESAL_TS_MEM_First_Avail_Get(VOID);\r
+VOID ESAL_TS_MEM_BSS_Clear(VOID);\r
+VOID ESAL_TS_MEM_ROM_To_RAM_Copy(VOID);\r
+\r
+/* Define core cache memory macros to do nothing if cache is not available */\r
+#if (ESAL_CO_CACHE_AVAILABLE == NU_FALSE)\r
+\r
+#define ESAL_CO_MEM_CACHE_ALL_INVALIDATE()\r
+#define ESAL_CO_MEM_ICACHE_ALL_INVALIDATE()\r
+#define ESAL_CO_MEM_DCACHE_ALL_INVALIDATE()\r
+#define ESAL_CO_MEM_ICACHE_INVALIDATE(addr, size) (VOID)((UINT32)addr + size)\r
+#define ESAL_CO_MEM_DCACHE_INVALIDATE(addr, size) (VOID)((UINT32)addr + size)\r
+#define ESAL_CO_MEM_DCACHE_ALL_FLUSH_INVAL()\r
+#define ESAL_CO_MEM_DCACHE_FLUSH_INVAL(addr, size) (VOID)((UINT32)addr + size)\r
+\r
+#endif /* ESAL_CO_CACHE_AVAILABLE == NU_FALSE */\r
+\r
+/* Define processor cache memory macros to do nothing if cache is not available */\r
+#if (ESAL_PR_CACHE_AVAILABLE == NU_FALSE)\r
+\r
+#define ESAL_PR_MEM_CACHE_ALL_INVALIDATE()\r
+#define ESAL_PR_MEM_ICACHE_ALL_INVALIDATE()\r
+#define ESAL_PR_MEM_DCACHE_ALL_INVALIDATE()\r
+#define ESAL_PR_MEM_ICACHE_INVALIDATE(addr, size) (VOID)((UINT32)addr + size)\r
+#define ESAL_PR_MEM_DCACHE_INVALIDATE(addr, size) (VOID)((UINT32)addr + size)\r
+#define ESAL_PR_MEM_DCACHE_ALL_FLUSH_INVAL()\r
+#define ESAL_PR_MEM_DCACHE_FLUSH_INVAL(addr, size) (VOID)((UINT32)addr + size)\r
+\r
+#endif /* ESAL_PR_CACHE_AVAILABLE == NU_FALSE */\r
+\r
+/* Generic defines used for cache related routines */\r
+#define ESAL_GE_MEM_CACHE_ALL_INVALIDATE() \\r
+ ESAL_CO_MEM_CACHE_ALL_INVALIDATE(); \\r
+ ESAL_PR_MEM_CACHE_ALL_INVALIDATE()\r
+\r
+#define ESAL_GE_MEM_ICACHE_ALL_INVALIDATE() \\r
+ ESAL_CO_MEM_ICACHE_ALL_INVALIDATE(); \\r
+ ESAL_PR_MEM_ICACHE_ALL_INVALIDATE()\r
+\r
+#define ESAL_GE_MEM_DCACHE_ALL_INVALIDATE() \\r
+ ESAL_CO_MEM_DCACHE_ALL_INVALIDATE(); \\r
+ ESAL_PR_MEM_DCACHE_ALL_INVALIDATE()\r
+\r
+#define ESAL_GE_MEM_ICACHE_INVALIDATE(addr, size) \\r
+ ESAL_CO_MEM_ICACHE_INVALIDATE(addr, size); \\r
+ ESAL_PR_MEM_ICACHE_INVALIDATE(addr, size)\r
+\r
+#define ESAL_GE_MEM_DCACHE_INVALIDATE(addr, size) \\r
+ ESAL_CO_MEM_DCACHE_INVALIDATE(addr, size); \\r
+ ESAL_PR_MEM_DCACHE_INVALIDATE(addr, size)\r
+\r
+#define ESAL_GE_MEM_DCACHE_ALL_FLUSH_INVAL() \\r
+ ESAL_CO_MEM_DCACHE_ALL_FLUSH_INVAL(); \\r
+ ESAL_PR_MEM_DCACHE_ALL_FLUSH_INVAL()\r
+\r
+#define ESAL_GE_MEM_DCACHE_FLUSH_INVAL(addr, size) \\r
+ ESAL_CO_MEM_DCACHE_FLUSH_INVAL(addr, size); \\r
+ ESAL_PR_MEM_DCACHE_FLUSH_INVAL(addr, size)\r
+\r
+/**********************************************************************************/\r
+/* Debug */\r
+/**********************************************************************************/\r
+\r
+/* Map generic opcode type to architecture specific opcode type */\r
+typedef ESAL_AR_DBG_OPCODE ESAL_GE_DBG_OPCODE;\r
+typedef ESAL_AR_DBG_REG ESAL_GE_DBG_REG;\r
+\r
+/* Define Stack Frame types */\r
+typedef enum _esal_ge_dbg_stack_frame_type_enum\r
+{\r
+ ESAL_GE_DBG_STACK_FRAME_TYPE_THREAD,\r
+ ESAL_GE_DBG_STACK_FRAME_TYPE_EXCEPTION\r
+\r
+} ESAL_GE_DBG_STACK_FRAME_TYPE;\r
+\r
+/* Map generic APIs to lower-level components */\r
+#define ESAL_GE_DBG_Reg_Read ESAL_AR_DBG_Reg_Read\r
+#define ESAL_GE_DBG_Reg_Write ESAL_AR_DBG_Reg_Write\r
+#define ESAL_GE_DBG_Opcode_Read ESAL_AR_DBG_Opcode_Read\r
+#define ESAL_GE_DBG_Opcode_Write ESAL_AR_DBG_Opcode_Write\r
+#define ESAL_GE_DBG_Opcode_Brk_Get ESAL_AR_DBG_Opcode_Brk_Get\r
+#define ESAL_GE_DBG_Opcode_Nop_Get ESAL_AR_DBG_Opcode_Nop_Get\r
+#define ESAL_GE_DBG_Step_Addr_Get ESAL_AR_DBG_Step_Addr_Get\r
+#define ESAL_GE_DBG_Hardware_Step ESAL_AR_DBG_Hardware_Step\r
+#define ESAL_GE_DBG_Get_Support_Flags ESAL_AR_DBG_Get_Support_Flags\r
+#define ESAL_GE_DBG_Int_Read ESAL_AR_DBG_Int_Read\r
+#define ESAL_GE_DBG_Int_Write ESAL_AR_DBG_Int_Write\r
+#define ESAL_GE_DBG_Int_Enable ESAL_AR_DBG_Int_Enable\r
+#define ESAL_GE_DBG_Int_Disable ESAL_AR_DBG_Int_Disable\r
+\r
+/* Provide means of causing an immediate breakpoint. */\r
+#define ESAL_GE_DBG_BREAK_EXECUTE ESAL_TS_RTE_UNDEF_BRK_EXECUTE\r
+\r
+/* Define all debugging related external variables */\r
+extern INT ESAL_GE_DBG_Debug_Operation;\r
+\r
+/* Define all debugging related function prototypes */\r
+VOID ESAL_GE_DBG_Terminate(VOID);\r
+VOID ESAL_AR_DBG_Terminate(VOID);\r
+INT ESAL_AR_DBG_Set_Protocol(UINT8 dbg_prot, UINT8* stk_ptr, UINT8* pc);\r
+INT ESAL_AR_DBG_Reg_Read(VOID *p_stack_frame, INT stack_frame_type, INT reg_no, ESAL_GE_DBG_REG *reg_val);\r
+INT ESAL_AR_DBG_Reg_Write(VOID *p_stack_frame, INT stack_frame_type, INT reg_no, ESAL_GE_DBG_REG *reg_val);\r
+INT ESAL_AR_DBG_Reg_Block_Read(VOID *p_stack_frame, INT stack_frame_type, VOID* reg_buff, UINT32* blk_size);\r
+INT ESAL_AR_DBG_Reg_Block_Write(VOID *p_stack_frame, INT stack_frame_type, VOID* reg_buff);\r
+INT ESAL_AR_DBG_Reg_Expedite_Read(VOID *p_stack_frame, INT stack_frame_type, VOID* reg_buff, UINT32* blk_size);\r
+ESAL_GE_DBG_OPCODE ESAL_AR_DBG_Opcode_Read(VOID *read_addr);\r
+VOID ESAL_AR_DBG_Opcode_Write(VOID *write_addr, ESAL_GE_DBG_OPCODE value);\r
+ESAL_GE_DBG_OPCODE ESAL_AR_DBG_Opcode_Nop_Get(VOID *addr);\r
+ESAL_GE_DBG_OPCODE ESAL_AR_DBG_Opcode_Brk_Get(VOID *addr);\r
+VOID *ESAL_AR_DBG_Step_Addr_Get(VOID *addr, VOID *p_stack_frame, INT stack_frame_type);\r
+INT ESAL_AR_DBG_Hardware_Step(VOID * p_stack_frame, INT stack_frame_type);\r
+INT ESAL_AR_DBG_Get_Support_Flags(UINT32 * flags);\r
+INT ESAL_AR_DBG_Int_Read(VOID * p_stack_frame, INT stack_frame_type, UINT32 * int_state);\r
+INT ESAL_AR_DBG_Int_Write(VOID * p_stack_frame, INT stack_frame_type, UINT32 int_state);\r
+INT ESAL_AR_DBG_Int_Enable(VOID * p_stack_frame, INT stack_frame_type);\r
+INT ESAL_AR_DBG_Int_Disable(VOID * p_stack_frame, INT stack_frame_type);\r
+\r
+/**********************************************************************************/\r
+/* Interrupt Controller */\r
+/**********************************************************************************/\r
+\r
+/* Map generic APIs to lower-level component */\r
+#define ESAL_GE_INT_FAST_ALL_ENABLE ESAL_AR_INT_FAST_ALL_ENABLE\r
+#define ESAL_GE_INT_FAST_ALL_DISABLE ESAL_AR_INT_FAST_ALL_DISABLE\r
+#define ESAL_GE_INT_ALL_DISABLE ESAL_AR_INT_ALL_DISABLE\r
+#define ESAL_GE_INT_ALL_RESTORE ESAL_AR_INT_ALL_RESTORE\r
+#define ESAL_GE_INT_CONTROL_VARS ESAL_AR_INT_CONTROL_VARS\r
+#define ESAL_GE_INT_BITS_SET ESAL_AR_INT_BITS_SET\r
+\r
+/* Define enumerated type for interrupt trigger types */\r
+typedef enum\r
+{\r
+ ESAL_TRIG_NOT_SUPPORTED,\r
+ ESAL_TRIG_RISING_EDGE,\r
+ ESAL_TRIG_FALLING_EDGE,\r
+ ESAL_TRIG_LEVEL_LOW,\r
+ ESAL_TRIG_LEVEL_HIGH,\r
+ ESAL_TRIG_RISING_FALLING_EDGES,\r
+ ESAL_TRIG_HIGH_LOW_RISING_FALLING_EDGES\r
+\r
+} ESAL_GE_INT_TRIG_TYPE;\r
+\r
+/* Define constant to use if priorities being assigned to interrupt sources\r
+ is not supported */\r
+#define ESAL_PRI_NOT_SUPPORTED (INT)0x00000FFF\r
+\r
+/* Define max vector ID if no off-chip interrupt controller */\r
+#if (ESAL_DP_INTERRUPTS_AVAILABLE == NU_FALSE)\r
+\r
+/* Max vector ID is processor delimiter */\r
+#undef ESAL_DP_INT_VECTOR_ID_DELIMITER\r
+#define ESAL_DP_INT_VECTOR_ID_DELIMITER ESAL_PR_INT_VECTOR_ID_DELIMITER\r
+\r
+#endif /* ESAL_DP_INTERRUPTS_AVAILABLE == NU_FALSE */\r
+\r
+/* Define macro used to get maximum ESAL interrupt vector ID */\r
+#define ESAL_GE_INT_MAX_VECTOR_ID_GET() (ESAL_DP_INT_VECTOR_ID_DELIMITER-1)\r
+\r
+/* Check if processor level macro exists to wait for an interrupt */\r
+#ifdef ESAL_PR_INT_WAIT\r
+\r
+/* Set generic macro to use the processor specific macro to wait for an interrupt */\r
+#define ESAL_GE_INT_WAIT ESAL_PR_INT_WAIT\r
+\r
+#else\r
+\r
+/* Define generic way to wait for an interrupt */\r
+#define ESAL_GE_INT_WAIT() while(1){}\r
+\r
+#endif /* ESAL_PR_INT_WAIT */\r
+\r
+/* Define all externally accessible, interrupt related function prototypes */\r
+VOID ESAL_GE_INT_All_Disable(VOID);\r
+INT ESAL_GE_INT_Enable(INT vector_id,\r
+ ESAL_GE_INT_TRIG_TYPE trigger_type,\r
+ INT priority);\r
+INT ESAL_GE_INT_Disable(INT vector_id);\r
+INT ESAL_AR_INT_Enable(INT vector_id,\r
+ ESAL_GE_INT_TRIG_TYPE trigger_type,\r
+ INT priority);\r
+INT ESAL_AR_INT_Disable(INT vector_id);\r
+VOID ESAL_PR_INT_All_Disable(VOID);\r
+INT ESAL_PR_INT_Enable(INT vector_id,\r
+ ESAL_GE_INT_TRIG_TYPE trigger_type,\r
+ INT priority);\r
+INT ESAL_PR_INT_Disable(INT vector_id);\r
+VOID ESAL_DP_INT_All_Disable(VOID);\r
+INT ESAL_DP_INT_Enable(INT vector_id,\r
+ ESAL_GE_INT_TRIG_TYPE trigger_type,\r
+ INT priority);\r
+INT ESAL_DP_INT_Disable(INT vector_id);\r
+\r
+/**********************************************************************************/\r
+/* Interrupt Service */\r
+/**********************************************************************************/\r
+\r
+/* Externally referenced global data */\r
+extern VOID **(*ESAL_GE_ISR_OS_Entry)(INT vector, VOID *stack_ptr);\r
+extern VOID (*ESAL_GE_ISR_OS_Nested_Entry)(INT vector);\r
+extern VOID (*ESAL_GE_ISR_Interrupt_Handler[])(INT vector);\r
+extern VOID (*ESAL_GE_ISR_Exception_Handler[])(INT except_num, VOID *frame_ptr);\r
+extern INT ESAL_GE_ISR_Executing;\r
+extern VOID *ESAL_GE_ISR_Interrupt_Vector_Data[ESAL_DP_INT_VECTOR_ID_DELIMITER];\r
+extern VOID *ESAL_GE_ISR_Exception_Vector_Data[ESAL_AR_EXCEPT_VECTOR_ID_DELIMITER];\r
+extern VOID (*ESAL_GE_ISR_Execute_Hook)(INT vector);\r
+\r
+/* Define macro used to return back to the OS after interrupt handling. If the OS\r
+ must be returned to instead of returning to the point of interrupt, this macro\r
+ will perform this operation based on the architectural requirements.\r
+ NOTE: Some architectures require a "return from interrupt" to be execute in\r
+ order for the execution state to be restored when returning to the\r
+ OS. This is configured in esal_ar_cfg.h */\r
+#if (ESAL_AR_ISR_RTI_MANDATORY == NU_FALSE)\r
+\r
+/* No special requirements for this architecture - simply expand this macro into\r
+ a function call */\r
+#define ESAL_GE_ISR_OS_RETURN(os_return_func_ptr) \\r
+ os_return_func_ptr()\r
+\r
+#else\r
+\r
+/* Define function prototype for architecture specific return from ISR function */\r
+VOID ESAL_AR_ISR_Return(VOID (*)(VOID));\r
+\r
+/* This architecture must return to the OS using "return from interrupt" or equivalent\r
+ method - expand this macro to call ESAL service to perform this function */\r
+#define ESAL_GE_ISR_OS_RETURN(os_return_func_ptr) \\r
+ ESAL_AR_ISR_Return(os_return_func_ptr)\r
+\r
+#endif /* ESAL_AR_ISR_RTI_MANDATORY == NU_FALSE */\r
+\r
+/* Define macro used to determine if within interrupt service routine */\r
+#ifndef ESAL_GE_ISR_EXECUTING\r
+#define ESAL_GE_ISR_EXECUTING() (ESAL_GE_ISR_Executing > 0)\r
+#endif /* !ESAL_GE_ISR_EXECUTING */\r
+\r
+/* Define macros used to identify start / end of interrupt service routine */\r
+#ifndef ESAL_GE_ISR_START\r
+\r
+#if (ESAL_AR_ISR_INCREMENT_IN_C == NU_TRUE)\r
+#define ESAL_GE_ISR_START() (ESAL_GE_ISR_Executing++)\r
+#else \r
+#define ESAL_GE_ISR_START() \r
+#endif /* ESAL_AR_ISR_INCREMENT_IN_C == NU_TRUE */ \r
+ \r
+#endif /* !ESAL_GE_ISR_START */\r
+\r
+#ifndef ESAL_GE_ISR_END\r
+#define ESAL_GE_ISR_END() ESAL_AR_INT_FAST_ALL_DISABLE(); \\r
+ (ESAL_GE_ISR_Executing--)\r
+#endif /* !ESAL_GE_ISR_END */\r
+\r
+/* Define macros to get / set / execute interrupt service routine for ESAL interrupt vectors */\r
+#define ESAL_GE_ISR_EXECUTE_HOOK_SET(ptr) ESAL_GE_ISR_Execute_Hook = (ptr)\r
+#define ESAL_GE_ISR_HANDLER_GET(num) (ESAL_GE_ISR_Interrupt_Handler[(num)])\r
+#define ESAL_GE_ISR_HANDLER_SET(num,ptr) ESAL_GE_ISR_Interrupt_Handler[(num)]=(ptr)\r
+\r
+#if (CFG_NU_OS_SVCS_TRACE_CORE_TRACE_SUPPORT == NU_TRUE)\r
+\r
+#define ESAL_GE_ISR_HANDLER_EXECUTE(num) \\r
+ { \\r
+ /* Trace log */ \\r
+ T_IDLE_EXIT(); \\r
+ \\r
+ /* Check if ESAL_GE_ISR_Wake_Up has been set */ \\r
+ if (ESAL_GE_ISR_Execute_Hook != NU_NULL) \\r
+ { \\r
+ /* Execute ESAL_GE_ISR_Wake_Up function pointer */ \\r
+ ESAL_GE_ISR_Execute_Hook(num); \\r
+ } \\r
+ \\r
+ if ((num > ESAL_AR_INT_VECTOR_ID_DELIMITER)||(num == ESAL_GE_TMR_OS_VECTOR))\\r
+ { \\r
+ /* Trace log */ \\r
+ T_LISR_ENTRY(num); \\r
+ \\r
+ /* Execute Interrupt Handler */ \\r
+ ESAL_GE_ISR_Interrupt_Handler[(num)](num); \\r
+ \\r
+ /* Trace log */ \\r
+ T_LISR_EXIT(num); \\r
+ } \\r
+ else \\r
+ { \\r
+ /* Execute Interrupt Handler */ \\r
+ ESAL_GE_ISR_Interrupt_Handler[(num)](num); \\r
+ } \\r
+ }\r
+#else\r
+\r
+#define ESAL_GE_ISR_HANDLER_EXECUTE(num) \\r
+ { \\r
+ /* Check if ESAL_GE_ISR_Wake_Up has been set */ \\r
+ if (ESAL_GE_ISR_Execute_Hook != NU_NULL) \\r
+ { \\r
+ /* Execute ESAL_GE_ISR_Wake_Up function pointer */ \\r
+ ESAL_GE_ISR_Execute_Hook(num); \\r
+ } \\r
+ /* Execute Interrupt Handler */ \\r
+ ESAL_GE_ISR_Interrupt_Handler[(num)](num); \\r
+ }\r
+#endif\r
+\r
+/* Define macros for get / set exception handlers for ESAL exception vectors */\r
+#define ESAL_GE_EXCEPT_HANDLER_SET(num,ptr) ESAL_GE_ISR_Exception_Handler[(num)]=(ptr)\r
+#define ESAL_GE_EXCEPT_HANDLER_GET(num) (ESAL_GE_ISR_Exception_Handler[(num)])\r
+\r
+/* Define macros to get / set data associated with each interrupt service routine vector */\r
+#define ESAL_GE_ISR_VECTOR_DATA_GET(vector) ESAL_GE_ISR_Interrupt_Vector_Data[(vector)]\r
+#define ESAL_GE_ISR_VECTOR_DATA_SET(vector,data) ESAL_GE_ISR_Interrupt_Vector_Data[(vector)]=(data)\r
+\r
+/* Define macros for get / set data associated with each exception vector */\r
+#define ESAL_GE_EXCEPT_VECTOR_DATA_GET(vector) ESAL_GE_ISR_Exception_Vector_Data[(vector)]\r
+#define ESAL_GE_EXCEPT_VECTOR_DATA_SET(vector,data) ESAL_GE_ISR_Exception_Vector_Data[(vector)]=(data)\r
+\r
+/**********************************************************************************/\r
+/* Run-time Environment */\r
+/**********************************************************************************/\r
+\r
+/* Map generic APIs to lower-level component */\r
+#define ESAL_GE_RTE_SP_READ ESAL_TS_RTE_SP_READ\r
+#define ESAL_GE_RTE_Cxx_Info ESAL_TS_RTE_Cxx_Info\r
+#ifndef ESAL_TS_RTE_COMPILE_MEM_BARRIER\r
+#define ESAL_GE_RTE_COMPILE_MEM_BARRIER()\r
+#else\r
+#define ESAL_GE_RTE_COMPILE_MEM_BARRIER() ESAL_TS_RTE_COMPILE_MEM_BARRIER()\r
+#endif\r
+\r
+/* Define all run-time environment related function prototypes */\r
+extern INT (*ESAL_GE_RTE_Byte_Write)(INT);\r
+extern INT (*ESAL_GE_RTE_Byte_Read)(VOID);\r
+\r
+/**********************************************************************************/\r
+/* Stack */\r
+/**********************************************************************************/\r
+\r
+/* Define the maximum and minimum sizes of a stack frame */\r
+#define ESAL_GE_STK_MAX_FRAME_SIZE sizeof(ESAL_AR_STK)\r
+#define ESAL_GE_STK_MIN_FRAME_SIZE sizeof(ESAL_TS_STK)\r
+\r
+\r
+/* Map generic APIs to lower-level component */\r
+#define ESAL_GE_STK_Unsolicited_Set ESAL_AR_STK_Unsolicited_Set\r
+#define ESAL_GE_STK_Unsolicited_Restore ESAL_AR_STK_Unsolicited_Restore\r
+#define ESAL_GE_STK_SYSTEM_SIZE ESAL_AR_SYSTEM_STACK_SIZE\r
+#define ESAL_GE_STK_Solicited_Set ESAL_TS_STK_Solicited_Set\r
+#define ESAL_GE_STK_Solicited_Restore ESAL_TS_STK_Solicited_Restore\r
+#define ESAL_GE_STK_Solicited_Switch ESAL_TS_STK_Solicited_Switch\r
+\r
+/* Define all externally accessible, stack related function prototypes */\r
+VOID *ESAL_GE_STK_System_SP_Start_Get(VOID);\r
+VOID *ESAL_GE_STK_System_SP_End_Get(VOID);\r
+VOID *ESAL_AR_STK_Unsolicited_Set(VOID *start_addr,\r
+ VOID *end_addr,\r
+ VOID (*entry_function)(VOID));\r
+VOID ESAL_AR_STK_Unsolicited_Restore(VOID *stack_ptr);\r
+VOID ESAL_AR_STK_Unsolicited_Switch(VOID **stack_ptr);\r
+VOID *ESAL_TS_STK_Solicited_Set(VOID *start_addr,\r
+ VOID *end_addr,\r
+ VOID (*entry_function)(VOID));\r
+VOID ESAL_TS_STK_Solicited_Restore(VOID *stack_ptr);\r
+VOID ESAL_TS_STK_Solicited_Switch(VOID *call_back_param,\r
+ VOID (*call_back)(VOID),\r
+ VOID **stack_ptr);\r
+VOID ESAL_AR_STK_Startup_SP_Set(VOID);\r
+\r
+/* Define externally accessed data */\r
+extern VOID (*ESAL_GE_STK_Unsol_Switch_OS_Entry)(VOID);\r
+extern VOID *ESAL_GE_STK_System_SP;\r
+extern INT ESAL_GE_STK_Unsol_Switch_Req;\r
+\r
+/* Map generic system stack switch to appropriate ESAL function */\r
+#define ESAL_GE_STK_SYSTEM_SP_SET() ESAL_TS_RTE_SP_WRITE(ESAL_GE_STK_System_SP)\r
+\r
+/* Define macros to get offsets of various registers within the stack frame structures */\r
+#define ESAL_GE_STK_UNSOL_OFFSET(reg_name) ((INT)&(((ESAL_AR_STK *)NU_NULL)->reg_name))\r
+#define ESAL_GE_STK_SOL_OFFSET(reg_name) ((INT)&(((ESAL_TS_STK *)NU_NULL)->reg_name))\r
+\r
+/* Define macro to set / clear flag showing an unsolicited switch is required */\r
+#define ESAL_GE_STK_UNSOL_SWITCH_ENABLE() ESAL_GE_STK_Unsol_Switch_Req = NU_TRUE\r
+#define ESAL_GE_STK_UNSOL_SWITCH_DISABLE() ESAL_GE_STK_Unsol_Switch_Req = NU_FALSE\r
+\r
+/* Defines for stack types */\r
+#define ESAL_GE_STK_TS_TYPE 0\r
+#define ESAL_GE_STK_AR_TYPE 1\r
+\r
+/* Define a generic alignment mask used to obtain a specified toolset required alignment */\r
+#define ESAL_GE_STK_ALIGN_MASK (~(ESAL_TS_REQ_STK_ALIGNMENT - 1))\r
+\r
+/* Define generic macro (based on architecture integer size) to read the\r
+ stack type from top of stack */\r
+#if (ESAL_TS_INTEGER_SIZE == 16)\r
+\r
+/* Read 16 bit stack type */\r
+#define ESAL_GE_STK_TYPE_GET(stack_ptr) ESAL_GE_MEM_READ16(stack_ptr)\r
+\r
+#elif (ESAL_TS_INTEGER_SIZE == 32)\r
+\r
+/* Read 32 bit stack type */\r
+#define ESAL_GE_STK_TYPE_GET(stack_ptr) ESAL_GE_MEM_READ32(stack_ptr)\r
+\r
+#elif (ESAL_TS_INTEGER_SIZE == 64)\r
+\r
+#if (ESAL_TS_64BIT_SUPPORT == NU_TRUE)\r
+\r
+/* Read 64 bit stack type */\r
+#define ESAL_GE_STK_TYPE_GET(stack_ptr) ESAL_GE_MEM_READ64(stack_ptr)\r
+\r
+#else\r
+\r
+/* Generate error - tools don't support 64 bit data type */\r
+#error Toolset does not support 64-bit types (esal_ts_cfg.h)\r
+\r
+#endif /* ESAL_TS_64BIT_SUPPORT == NU_TRUE */\r
+\r
+#else\r
+\r
+/* Generate error - no valid method to retrieve stack type */\r
+#error No valid method to get stack type (esal_ge_stk_defs.h)\r
+\r
+#endif /* ESAL_TS_INTEGER_SIZE */\r
+\r
+/* Define macro used to align stack end address based on data pointer size */\r
+#if (ESAL_TS_DATA_PTR_SIZE <= 16)\r
+\r
+/* Generic macro to align stack end address when stack grows down */\r
+#define ESAL_GE_STK_ALIGN(end_stk_addr) \\r
+ (VOID *)((UINT16)end_stk_addr & (UINT16)ESAL_GE_STK_ALIGN_MASK)\r
+\r
+#elif (ESAL_TS_DATA_PTR_SIZE <= 32)\r
+\r
+/* Generic macro to align stack end address when stack grows down */\r
+#define ESAL_GE_STK_ALIGN(end_stk_addr) \\r
+ (VOID *)((UINT32)end_stk_addr & (UINT32)ESAL_GE_STK_ALIGN_MASK)\r
+\r
+#elif (ESAL_TS_DATA_PTR_SIZE <= 64)\r
+\r
+#if (ESAL_TS_64BIT_SUPPORT == NU_TRUE)\r
+\r
+/* Generic macro to align stack end address when stack grows down */\r
+#define ESAL_GE_STK_ALIGN(end_stk_addr) \\r
+ (VOID *)((UINT64)end_stk_addr & (UINT64)ESAL_GE_STK_ALIGN_MASK)\r
+\r
+#else\r
+\r
+/* Generate error - toolset doesn't support 64-bit operations */\r
+#error Toolset does not support 64-bit operations (esal_ts_cfg.h)\r
+\r
+#endif /* ESAL_TS_64BIT_SUPPORT == NU_TRUE */\r
+\r
+#endif /* ESAL_TS_DATA_PTR_SIZE */\r
+\r
+/* Check if toolset has specific macro for preventing return optimizations */\r
+#ifdef ESAL_TS_STK_NO_RETURN\r
+\r
+/* Use toolset specific method for generic macro */\r
+#define ESAL_GE_STK_NO_RETURN ESAL_TS_STK_NO_RETURN\r
+\r
+#else\r
+\r
+/* Define generic method to prevent return optimizations */\r
+#define ESAL_GE_STK_NO_RETURN() while(1){}\r
+\r
+#endif /* ESAL_TS_STK_NO_RETURN */\r
+\r
+/* Check if toolset solicited stack reset exists */\r
+#ifndef ESAL_TS_STK_SOLICITED_RESET\r
+\r
+/* Define the solicited stack reset to just use the solicited stack set\r
+ routine */\r
+#define ESAL_GE_STK_SOLICITED_RESET ESAL_TS_STK_Solicited_Set\r
+\r
+#else\r
+\r
+/* Define the solicited stack reset to just use the solicited stack reset\r
+ routine */\r
+#define ESAL_GE_STK_SOLICITED_RESET ESAL_TS_STK_SOLICITED_RESET\r
+\r
+#endif /* !ESAL_TS_STK_SOLICITED_RESET */\r
+\r
+/**********************************************************************************/\r
+/* Timer */\r
+/**********************************************************************************/\r
+\r
+/* Define a generic macro for the OS clock rate and prescaler. */\r
+#define ESAL_GE_TMR_OS_CLOCK_RATE ESAL_PR_TMR_OS_CLOCK_RATE\r
+#define ESAL_GE_TMR_OS_CLOCK_PRESCALE ESAL_PR_TMR_OS_CLOCK_PRESCALE\r
+\r
+/* Generic macro to calculate timer count value for timer with a given clock rate,\r
+ clock prescale and period.\r
+ NOTE: This macro will work for count-down (underflow) timers and match timers\r
+ (count-up or count-down timers). If using a count-up timer that generates\r
+ an interrupt upon overflow, the value produced by this macro must be\r
+ subtracted from the maximum timer count. */\r
+#define ESAL_GE_TMR_COUNT_CALC(clock_rate, clock_prescale, ticksPerSec) \\r
+ (UINT32)( ((UINT32)clock_rate) / \\r
+ ((UINT32)clock_prescale) / \\r
+ ((UINT32)ticksPerSec) )\r
+\r
+/* Define all externally accessible, timer related function prototypes */\r
+VOID ESAL_GE_TMR_OS_Timer_Start(UINT32 ticks_per_sec);\r
+VOID ESAL_GE_TMR_OS_ISR_Register(VOID (*isr_func_ptr)(INT));\r
+VOID ESAL_AR_TMR_OS_Timer_Start(UINT32 ticks_per_sec);\r
+VOID ESAL_PR_TMR_OS_Timer_Start(UINT32 ticks_per_sec);\r
+\r
+/* Defines for counter types (count-down or count-up) */\r
+#define ESAL_COUNT_DOWN 0\r
+#define ESAL_COUNT_UP 1\r
+\r
+/**********************\r
+* ARCHITECTURE OS TIMER\r
+**********************/\r
+#if (ESAL_AR_OS_TIMER_USED == NU_TRUE)\r
+\r
+/* Define a generic macro that reads the architecture OS timer hardware count */\r
+#define ESAL_GE_TMR_OS_COUNT_READ() ESAL_AR_TMR_OS_COUNT_READ()\r
+\r
+/* Define generic macro for count direction using the architecture settings */\r
+#define ESAL_GE_TMR_OS_COUNT_DIR ESAL_AR_TMR_OS_COUNT_DIR\r
+\r
+/* Define generic macro for OS timer end-of-interrupt */\r
+#define ESAL_GE_TMR_OS_TIMER_EOI ESAL_AR_TMR_OS_TIMER_EOI\r
+\r
+/* Define generic macro for OS timer vector number */\r
+#define ESAL_GE_TMR_OS_VECTOR ESAL_AR_TMR_OS_VECTOR\r
+\r
+/* Define generic macro for OS timer pending */\r
+#define ESAL_GE_TMR_OS_PENDING() ESAL_AR_TMR_PENDING()\r
+\r
+/* Define generic macros for PMS timer functionality. */\r
+#define ESAL_GE_TMR_PMS_COUNT_METHOD ESAL_AR_TMR_PMS_COUNT_METHOD\r
+#define ESAL_GE_TMR_PMS_IS_TIMER_INT_PENDING() ESAL_AR_TMR_PMS_IS_TIMER_INT_PENDING()\r
+#define ESAL_GE_TMR_PMS_GET_HW_TICK_CNT_VALUE() ESAL_AR_TMR_PMS_GET_HW_TICK_CNT_VALUE()\r
+\r
+#if (ESAL_GE_TMR_PMS_COUNT_METHOD == ESAL_COUNT_UP)\r
+/* Define generic macro for OS interval setting */\r
+#define ESAL_GE_TMR_PMS_SET_HW_TICK_INTERVAL(interval) ESAL_AR_TMR_PMS_SET_HW_TICK_INTERVAL(interval)\r
+#endif\r
+\r
+#if (ESAL_GE_TMR_PMS_COUNT_METHOD == ESAL_COUNT_DOWN)\r
+/* Define for setting the processor tick value */\r
+#define ESAL_GE_TMR_PMS_SET_HW_TICK_VALUE(value) ESAL_AR_TMR_PMS_SET_HW_TICK_VALUE(value)\r
+#endif\r
+\r
+#ifdef ESAL_AR_TMR_PMS_ADJUST_HW_TICK_VALUE\r
+/* Define for adjusting the processor tick value */\r
+#define ESAL_GE_TMR_PMS_ADJUST_HW_TICK_VALUE(adjustment) ESAL_AR_TMR_PMS_ADJUST_HW_TICK_VALUE(adjustment)\r
+#endif\r
+\r
+#else\r
+\r
+/**********************\r
+* PROCESSOR OS TIMER\r
+**********************/\r
+\r
+/* Define a generic macro that reads the processor OS timer hardware count */\r
+#define ESAL_GE_TMR_OS_COUNT_READ() ESAL_PR_TMR_OS_COUNT_READ()\r
+\r
+/* Define generic macro for count direction using the processor settings */\r
+#define ESAL_GE_TMR_OS_COUNT_DIR ESAL_PR_TMR_OS_COUNT_DIR\r
+\r
+/* Define generic macro for OS timer end-of-interrupt */\r
+#define ESAL_GE_TMR_OS_TIMER_EOI ESAL_PR_TMR_OS_TIMER_EOI\r
+\r
+/* Define generic macro for OS timer vector number */\r
+#define ESAL_GE_TMR_OS_VECTOR ESAL_PR_TMR_OS_VECTOR\r
+\r
+/* Define generic macro for OS timer pending */\r
+#define ESAL_GE_TMR_OS_PENDING() ESAL_PR_TMR_PENDING()\r
+\r
+/* Define generic macros for PMS timer functionality. */\r
+#define ESAL_GE_TMR_PMS_COUNT_METHOD ESAL_PR_TMR_PMS_COUNT_METHOD\r
+#define ESAL_GE_TMR_PMS_IS_TIMER_INT_PENDING() ESAL_PR_TMR_PMS_IS_TIMER_INT_PENDING()\r
+#define ESAL_GE_TMR_PMS_GET_HW_TICK_CNT_VALUE() ESAL_PR_TMR_PMS_GET_HW_TICK_CNT_VALUE()\r
+#if (ESAL_GE_TMR_PMS_COUNT_METHOD == ESAL_COUNT_UP)\r
+/* Define generic macro for OS interval setting */\r
+#define ESAL_GE_TMR_PMS_SET_HW_TICK_INTERVAL(interval) ESAL_PR_TMR_PMS_SET_HW_TICK_INTERVAL(interval)\r
+#endif\r
+\r
+#if (ESAL_GE_TMR_PMS_COUNT_METHOD == ESAL_COUNT_DOWN)\r
+/* Define for setting the processor tick value */\r
+#define ESAL_GE_TMR_PMS_SET_HW_TICK_VALUE(value) ESAL_PR_TMR_PMS_SET_HW_TICK_VALUE(value)\r
+#endif\r
+\r
+#ifdef ESAL_PR_TMR_PMS_ADJUST_HW_TICK_VALUE\r
+/* Define for adjusting the processor tick value */\r
+#define ESAL_GE_TMR_PMS_ADJUST_HW_TICK_VALUE(adjustment) ESAL_PR_TMR_PMS_ADJUST_HW_TICK_VALUE(adjustment)\r
+#endif\r
+\r
+#endif /* ESAL_AR_OS_TIMER_USED == NU_TRUE */\r
+\r
+#ifdef __cplusplus\r
+\r
+/* End of C declarations */\r
+}\r
+\r
+#endif /* __cplusplus */\r
+\r
+#endif /* ESAL_EXTR_H */\r
+\r
diff --git a/libs/system/zc702evk/nucleus/kernel/nu_kernel.h b/libs/system/zc702evk/nucleus/kernel/nu_kernel.h
--- /dev/null
@@ -0,0 +1,196 @@
+/***********************************************************************\r
+*\r
+* Copyright 2011 Mentor Graphics Corporation\r
+* All Rights Reserved.\r
+*\r
+* THIS WORK CONTAINS TRADE SECRET AND PROPRIETARY INFORMATION WHICH IS\r
+* THE PROPERTY OF MENTOR GRAPHICS CORPORATION OR ITS LICENSORS AND IS\r
+* SUBJECT TO LICENSE TERMS.\r
+*\r
+************************************************************************\r
+\r
+************************************************************************\r
+*\r
+* DESCRIPTION\r
+*\r
+* This file contains kernel constants common to both the\r
+* application and the actual Nucleus PLUS kernel.\r
+*\r
+***********************************************************************/\r
+\r
+/* Check to see if this file has been included already. */\r
+\r
+#ifndef NU_KERNEL\r
+#ifdef __cplusplus\r
+/* C declarations in C++ */\r
+extern "C" {\r
+#endif\r
+#define NU_KERNEL\r
+\r
+\r
+/**********************************************************************/\r
+/* Service Paramaeters */\r
+/**********************************************************************/\r
+/* Define constants for use in service parameters. */\r
+#define NU_AND 2\r
+#define NU_AND_CONSUME 3\r
+#define NU_DISABLE_TIMER 4\r
+#define NU_ENABLE_TIMER 5\r
+#define NU_FIFO 6\r
+#define NU_FIXED_SIZE 7\r
+#define NU_NO_PREEMPT 8\r
+#define NU_NO_START 9\r
+#define NU_NO_SUSPEND 0\r
+#define NU_OR 0\r
+#define NU_OR_CONSUME 1\r
+#define NU_PREEMPT 10\r
+#define NU_PRIORITY 11\r
+#define NU_START 12\r
+#define NU_SUSPEND 0xFFFFFFFFUL\r
+#define NU_VARIABLE_SIZE 13\r
+#define NU_PRIORITY_INHERIT 14\r
+\r
+/* Define service completion status constants. */\r
+#define NU_SUCCESS 0\r
+#define NU_END_OF_LOG -1\r
+#define NU_GROUP_DELETED -2\r
+#define NU_INVALID_DELETE -3\r
+#define NU_INVALID_DRIVER -4\r
+#define NU_INVALID_ENABLE -5\r
+#define NU_INVALID_ENTRY -6\r
+#define NU_INVALID_FUNCTION -7\r
+#define NU_INVALID_GROUP -8\r
+#define NU_INVALID_HISR -9\r
+#define NU_INVALID_MAILBOX -10\r
+#define NU_INVALID_MEMORY -11\r
+#define NU_INVALID_MESSAGE -12\r
+#define NU_INVALID_OPERATION -13\r
+#define NU_INVALID_PIPE -14\r
+#define NU_INVALID_POINTER -15\r
+#define NU_INVALID_POOL -16\r
+#define NU_INVALID_PREEMPT -17\r
+#define NU_INVALID_PRIORITY -18\r
+#define NU_INVALID_QUEUE -19\r
+#define NU_INVALID_RESUME -20\r
+#define NU_INVALID_SEMAPHORE -21\r
+#define NU_INVALID_SIZE -22\r
+#define NU_INVALID_START -23\r
+#define NU_INVALID_SUSPEND -24\r
+#define NU_INVALID_TASK -25\r
+#define NU_INVALID_TIMER -26\r
+#define NU_INVALID_VECTOR -27\r
+#define NU_MAILBOX_DELETED -28\r
+#define NU_MAILBOX_EMPTY -29\r
+#define NU_MAILBOX_FULL -30\r
+#define NU_MAILBOX_RESET -31\r
+#define NU_NO_MEMORY -32\r
+#define NU_NO_MORE_LISRS -33\r
+#define NU_NO_PARTITION -34\r
+#define NU_NOT_DISABLED -35\r
+#define NU_NOT_PRESENT -36\r
+#define NU_NOT_REGISTERED -37\r
+#define NU_NOT_TERMINATED -38\r
+#define NU_PIPE_DELETED -39\r
+#define NU_PIPE_EMPTY -40\r
+#define NU_PIPE_FULL -41\r
+#define NU_PIPE_RESET -42\r
+#define NU_POOL_DELETED -43\r
+#define NU_QUEUE_DELETED -44\r
+#define NU_QUEUE_EMPTY -45\r
+#define NU_QUEUE_FULL -46\r
+#define NU_QUEUE_RESET -47\r
+#define NU_SEMAPHORE_DELETED -48\r
+#define NU_SEMAPHORE_RESET -49\r
+#define NU_TIMEOUT -50\r
+#define NU_UNAVAILABLE -51\r
+#define NU_INVALID_DESCRIPTION -52\r
+#define NU_INVALID_REGION -53\r
+#define NU_MEMORY_CORRUPT -54\r
+#define NU_INVALID_DEBUG_ALLOCATION -55\r
+#define NU_EMPTY_DEBUG_ALLOCATION_LIST -56\r
+#define NU_HISR_ACTIVATION_COUNT_ERROR -57\r
+#define NU_ZC_INVALID_PTR -58\r
+#define NU_ZC_INVALID_BUF_ID -59\r
+#define NU_ZC_BUF_SEG_MISMATCH -60\r
+#define NU_ZC_INVALID_SEG_OFFSET -61\r
+#define NU_ZC_BUF_EMPTY -62\r
+#define NU_ZC_INSUFFICIENT_MEMORY -63\r
+#define NU_ZC_INIT_ALREADY_COMPLETE -64\r
+#define NU_EN_INVALID_INPUT_PARAMS -65\r
+#define NU_EN_ALREADY_LISTENING -66\r
+#define NU_EN_NO_AVAIL_LISTEN_ENTRY -67\r
+#define NU_EN_NO_ACTIVE_LISTENERS -68\r
+#define NU_EN_LISTENER_NOT_FOUND -69\r
+#define NU_INVALID_RESUME_TIMER -70\r
+#define NU_INVALID_PAUSE_TIMER -71\r
+#define NU_TIMER_PAUSED -72\r
+#define NU_INVALID_COUNT -73\r
+#define NU_SEMAPHORE_INVALID_OWNER -74\r
+#define NU_NO_WAITING_TASKS -75\r
+#define NU_SEMAPHORE_ALREADY_OWNED -76\r
+#define NU_EQM_INVALID_EVENT_SIZE -77\r
+#define NU_EQM_INVALID_HANDLE -78\r
+#define NU_EQM_EVENT_EXPIRED -79\r
+#define NU_EQM_EVENT_WITHOUT_DATA -80\r
+#define NU_EQM_INVALID_INPUT -81\r
+#define NU_NOT_ALIGNED -82\r
+#define NU_SEMAPHORE_COUNT_ROLLOVER -83\r
+#define NU_INVALID_PROCESS -84\r
+#define NU_INVALID_STATE -85\r
+#define NU_PROCESS_IN_TRANSITION -86\r
+#define NU_SEMAPHORE_OWNER_DEAD -87\r
+#define NU_SYMBOLS_IN_USE -88\r
+#define NU_INVALID_MEMORY_REGION -89\r
+#define NU_MEMORY_IS_SHARED -90\r
+#define NU_MEMORY_OVERLAPS -91\r
+#define NU_INVALID_OPTIONS -92\r
+\r
+/**********************************************************************/\r
+/* Processes Configuration */\r
+/**********************************************************************/\r
+\r
+#include "kernel/proc_extern.h"\r
+\r
+/* Legacy macros */\r
+#define NU_SUPERVISOR_MODE()\r
+#define NU_USER_MODE()\r
+#define NU_SUPERV_USER_VARIABLES\r
+#define NU_SUPERVISOR_MODE_ISR()\r
+#define NU_USER_MODE_ISR()\r
+#define NU_BIND_TASK_TO_KERNEL(task) NU_SUCCESS\r
+#define NU_BIND_HISR_TO_KERNEL(hisr) NU_SUCCESS\r
+\r
+/**********************************************************************/\r
+/* Kernel Support */\r
+/**********************************************************************/\r
+\r
+/* Define the basic data structure templates. */\r
+#include "kernel/plus_core.h"\r
+#include "kernel/dev_mgr.h"\r
+#include "kernel/eqm.h"\r
+#include "kernel/rtl_extr.h"\r
+#include "kernel/esal_extr.h"\r
+\r
+#ifdef CFG_NU_OS_KERN_PLUS_SUPPLEMENT_ENABLE\r
+#include "kernel/plus_supplement.h"\r
+#endif /* CFG_NU_OS_KERN_PLUS_SUPPLEMENT_ENABLE */\r
+\r
+/* Define Nucleus PLUS system interface */\r
+VOID Application_Initialize(NU_MEMORY_POOL*, NU_MEMORY_POOL*);\r
+NU_WEAK_REF(VOID Pre_Kernel_Init_Hook(NU_MEMORY_POOL*, NU_MEMORY_POOL*));\r
+\r
+/**********************************************************************/\r
+/* Support Definitions */\r
+/**********************************************************************/\r
+/* Include Nucleus PLUS configuration settings */\r
+#include "kernel/plus_cfg.h"\r
+\r
+\r
+#ifdef __cplusplus\r
+\r
+/* End of C declarations */\r
+}\r
+\r
+#endif /* __cplusplus */\r
+\r
+#endif /* !NU_KERNEL */\r
diff --git a/libs/system/zc702evk/nucleus/kernel/plus_cfg.h b/libs/system/zc702evk/nucleus/kernel/plus_cfg.h
--- /dev/null
@@ -0,0 +1,52 @@
+/***********************************************************************\r
+*\r
+* Copyright 1993 Mentor Graphics Corporation\r
+* All Rights Reserved.\r
+*\r
+* THIS WORK CONTAINS TRADE SECRET AND PROPRIETARY INFORMATION WHICH IS\r
+* THE PROPERTY OF MENTOR GRAPHICS CORPORATION OR ITS LICENSORS AND IS\r
+* SUBJECT TO LICENSE TERMS.\r
+*\r
+************************************************************************\r
+\r
+************************************************************************\r
+*\r
+* DESCRIPTION\r
+*\r
+* This file contains Nucleus PLUS configuration settings,\r
+* compile-time options, etc\r
+*\r
+************************************************************************/\r
+\r
+/* Check to see if this file has been included already. */\r
+\r
+#ifndef PLUS_CFG\r
+#define PLUS_CFG\r
+\r
+#ifdef __cplusplus\r
+\r
+/* C declarations in C++ */\r
+extern "C" {\r
+\r
+#endif\r
+\r
+/* DEFINE: NU_POSIX_INCLUDED\r
+ DEFAULT: NU_FALSE\r
+ DESCRIPTION: POSIX specific code changes are compiled into Nucleus PLUS when this\r
+ define is set to NU_TRUE. These POSIX related items will not be included\r
+ when set to NU_FALSE.\r
+ NOTE: The Nucleus Posix software is required to utilize this option.\r
+ The Nucleus PLUS library and application must be rebuilt after changing\r
+ this define. */\r
+#ifndef NU_POSIX_INCLUDED\r
+#define NU_POSIX_INCLUDED NU_FALSE\r
+#endif\r
+\r
+#ifdef __cplusplus\r
+\r
+/* End of C declarations */\r
+}\r
+\r
+#endif /* __cplusplus */\r
+\r
+#endif /* !PLUS_CFG */\r
diff --git a/libs/system/zc702evk/nucleus/kernel/plus_core.h b/libs/system/zc702evk/nucleus/kernel/plus_core.h
--- /dev/null
@@ -0,0 +1,1047 @@
+/***********************************************************************\r
+*\r
+* Copyright 2011 Mentor Graphics Corporation\r
+* All Rights Reserved.\r
+*\r
+* THIS WORK CONTAINS TRADE SECRET AND PROPRIETARY INFORMATION WHICH IS\r
+* THE PROPERTY OF MENTOR GRAPHICS CORPORATION OR ITS LICENSORS AND IS\r
+* SUBJECT TO LICENSE TERMS.\r
+************************************************************************\r
+\r
+************************************************************************\r
+*\r
+* DESCRIPTION\r
+*\r
+* This file contains external data structures and definitions of\r
+* all PLUS core components.\r
+*\r
+***********************************************************************/\r
+\r
+#ifndef PLUS_CORE_H\r
+#define PLUS_CORE_H\r
+\r
+#ifdef __cplusplus\r
+\r
+/* C declarations in C++ */\r
+extern "C" {\r
+\r
+#endif\r
+\r
+\r
+/***********************************************************************/\r
+/* PLUS Release string macros */\r
+/***********************************************************************/\r
+\r
+/* Define Nucleus PLUS release string */\r
+#define PLUS_RELEASE_STRING "Nucleus PLUS 2.3"\r
+\r
+/* Define major, minor, and patch release numbers for Nucleus PLUS */\r
+#define NU_PLUS_RELEASE_MAJOR_VERSION 2\r
+#define NU_PLUS_RELEASE_MINOR_VERSION 3\r
+#define NU_PLUS_RELEASE_PATCH_VERSION 0\r
+\r
+/* Starting with PLUS 2.0, PLUS_VERSION_COMP reflects the actual\r
+ version number. PLUS_VERSION_COMP is MMNNPP, where MM is the major version,\r
+ NN is the minor version, and PP is the patch version */\r
+\r
+/* Define Nucleus PLUS version numbering */\r
+#define PLUS_1_11 1\r
+#define PLUS_1_13 2\r
+#define PLUS_1_14 3\r
+#define PLUS_1_15 4\r
+#define PLUS_2_0 NU_RELEASE_VERSION_MAKE(2,0,0)\r
+#define PLUS_2_1 NU_RELEASE_VERSION_MAKE(2,1,0)\r
+#define PLUS_2_2 NU_RELEASE_VERSION_MAKE(2,2,0)\r
+#define PLUS_2_3 NU_RELEASE_VERSION_MAKE(2,3,0)\r
+\r
+/* Current version */\r
+#define PLUS_VERSION_COMP NU_RELEASE_VERSION_MAKE( \\r
+ NU_PLUS_RELEASE_MAJOR_VERSION, \\r
+ NU_PLUS_RELEASE_MINOR_VERSION, \\r
+ NU_PLUS_RELEASE_PATCH_VERSION)\r
+ \r
+ \r
+/**********************************************************************/\r
+/* Other Configuration Settings */\r
+/**********************************************************************/\r
+\r
+/* DEFINE: NU_PLUS_INLINING\r
+ DEFAULT: NU_FALSE\r
+ DESCRIPTION: Frequently used Nucleus PLUS code is inlined (using macros) when this\r
+ define is set to NU_TRUE. Setting this define to NU_FALSE results in no\r
+ inlining (using macros) - actual function declarations are called in\r
+ this case.\r
+ NOTE: The Nucleus PLUS library, Nucleus Middleware Initialization library,\r
+ and application must be rebuilt after changing\r
+ this define. */\r
+#ifndef NU_PLUS_INLINING\r
+#define NU_PLUS_INLINING CFG_NU_OS_KERN_PLUS_CORE_INLINING\r
+#endif\r
+\r
+/* DEFINE: NU_STACK_CHECKING\r
+ DEFAULT: NU_FALSE\r
+ DESCRIPTION: Stack checking code is included for all Nucleus PLUS API calls when this\r
+ define is set to NU_TRUE. Setting this define to NU_FALSE will turn-off\r
+ stack checking code.\r
+ NOTE: If NU_STACK_FILL is enabled below (NU_TRUE), an additional check for\r
+ stack overflow will occur in the scheduler using the stack fill pattern.\r
+ NOTE: The Nucleus PLUS library and application must be rebuilt after changing\r
+ this define. */\r
+#ifndef NU_STACK_CHECKING\r
+#define NU_STACK_CHECKING CFG_NU_OS_KERN_PLUS_CORE_STACK_CHECKING\r
+#endif\r
+\r
+/* DEFINE: NU_STACK_FILL\r
+ DEFAULT: NU_FALSE\r
+ DESCRIPTION: Stack fill code is included for all Nucleus PLUS API calls when this\r
+ define is set to NU_TRUE. Setting this define to NU_FALSE will turn-off\r
+ stack fill code.\r
+ NOTE: The fill pattern used is defined by NU_STACK_FILL_PATTERN found within\r
+ this file\r
+ NOTE: The Nucleus PLUS library and application must be rebuilt after changing\r
+ this define. */\r
+#ifndef NU_STACK_FILL\r
+#define NU_STACK_FILL CFG_NU_OS_KERN_PLUS_CORE_STACK_FILL\r
+#endif\r
+\r
+/* Define the stack fill pattern used when NU_STACK_FILL (defined above) is set to NU_TRUE */\r
+#ifndef NU_STACK_FILL_PATTERN\r
+#define NU_STACK_FILL_PATTERN 0xA5\r
+#endif\r
+\r
+/* DEFINE: NU_GLOBAL_INT_LOCKING\r
+ DEFAULT: NU_FALSE\r
+ DESCRIPTION: Global interrupt locking is allowed (interrupt lock-out controlled at\r
+ global level instead of thread / task level) when this define is set\r
+ to NU_TRUE. Interrupts are controlled at thread / task level if this\r
+ define is set to NU_FALSE (interrupts not controlled at global level)\r
+ NOTE: Nucleus PLUS library and application must be rebuilt after changing\r
+ this define. */\r
+#ifndef NU_GLOBAL_INT_LOCKING\r
+#define NU_GLOBAL_INT_LOCKING CFG_NU_OS_KERN_PLUS_CORE_GLOBAL_INT_LOCKING\r
+#endif\r
+\r
+/* DEFINE: NU_MIN_RAM_ENABLED\r
+ DEFAULT: NU_FALSE\r
+ DESCRIPTION: This define is used to minimize the use of RAM by Nucleus PLUS. The\r
+ trade-off for minimizing RAM usage is a decrease in speed / performance.\r
+ Setting this define to NU_TRUE will reduce RAM usage.\r
+ NOTE: The Nucleus PLUS library and application must be rebuilt after changing\r
+ this define. */\r
+#ifndef NU_MIN_RAM_ENABLED\r
+#define NU_MIN_RAM_ENABLED CFG_NU_OS_KERN_PLUS_CORE_MIN_RAM\r
+#endif\r
+\r
+#ifndef NU_TICK_SUPPRESSION\r
+#define NU_TICK_SUPPRESSION CFG_NU_OS_KERN_PLUS_CORE_TICK_SUPPRESSION\r
+#endif\r
+\r
+/* Define the number of Nucleus PLUS ticks that will occur every second.\r
+ By default, the PLUS timer generates an interrupt every 10ms causing the\r
+ PLUS System Clock to tick 100 times in one second */\r
+#ifndef NU_PLUS_TICKS_PER_SEC\r
+#define NU_PLUS_TICKS_PER_SEC CFG_NU_OS_KERN_PLUS_CORE_TICKS_PER_SEC\r
+#endif\r
+\r
+/* Define the minimum stack size accepted when creating a task or HISR */\r
+#ifndef NU_MIN_STACK_SIZE\r
+#define NU_MIN_STACK_SIZE CFG_NU_OS_KERN_PLUS_CORE_MIN_STACK_SIZE \r
+#endif\r
+\r
+/* Define size of Nucleus Timer HISR stack and priority of Nucleus Timer HISR (0-2) */\r
+#ifndef NU_TIMER_HISR_STACK_SIZE\r
+#define NU_TIMER_HISR_STACK_SIZE CFG_NU_OS_KERN_PLUS_CORE_TIMER_HISR_STACK_SIZE\r
+#endif\r
+#ifndef NU_TIMER_HISR_PRIORITY\r
+#define NU_TIMER_HISR_PRIORITY 2\r
+#endif\r
+\r
+/**********************************************************************/\r
+/* Service Parameters */\r
+/**********************************************************************/\r
+\r
+/* Define TASK suspension constants. */\r
+#define NU_EVENT_SUSPEND 7\r
+#define NU_FINISHED 11\r
+#define NU_MAILBOX_SUSPEND 3\r
+#define NU_MEMORY_SUSPEND 9\r
+#define NU_PARTITION_SUSPEND 8\r
+#define NU_PIPE_SUSPEND 5\r
+#define NU_PURE_SUSPEND 1\r
+#define NU_QUEUE_SUSPEND 4\r
+#define NU_READY 0\r
+#define NU_SEMAPHORE_SUSPEND 6\r
+#define NU_SLEEP_SUSPEND 2\r
+#define NU_TERMINATED 12\r
+#define NU_DEBUG_SUSPEND 13\r
+\r
+/* Internal HISR queue control block buf_status values */\r
+#define NU_HISR_QUEUE_EMPTY 0\r
+#define NU_HISR_QUEUE_FULL 1\r
+#define NU_HISR_QUEUE_DATA 2\r
+\r
+/* Used within NU_Send_To_HISR_Queue to either activate the HISR once or every time */\r
+#define NU_ACTIVATE_HISR 1\r
+#define NU_ACTIVATE_HISR_ONCE 2\r
+\r
+\r
+/**********************************************************************/\r
+/* ERROR MANAGEMENT Definitions */\r
+/**********************************************************************/\r
+\r
+/* DEFINE: NU_ERROR_CHECKING\r
+ DEFAULT: NU_TRUE\r
+ DESCRIPTION: Error checking code is included for all applicable Nucleus PLUS API calls\r
+ when this define is set to NU_TRUE. Setting this define to NU_FALSE will\r
+ cause Nucleus PLUS API calls to skip / bypass error checking code.\r
+ NOTE: The Nucleus PLUS library and application must be rebuilt after changing\r
+ this define. */\r
+#ifndef NU_ERROR_CHECKING\r
+#define NU_ERROR_CHECKING CFG_NU_OS_KERN_PLUS_CORE_ERROR_CHECKING\r
+#endif\r
+\r
+/* DEFINE: NU_ASSERT_ENABLE\r
+ DEFAULT: NU_FALSE\r
+ DESCRIPTION: Setting NU_ASSERT_ENABLE to NU_TRUE includes additional debugging services\r
+ (NU_ASSERT / NU_CHECK). With NU_ASSERT_ENABLE set to NU_FALSE, these services\r
+ are not compiled as part of the Nucleus PLUS library.\r
+ NOTE: The Nucleus PLUS library and application must be rebuilt after changing\r
+ this define. */\r
+#ifndef NU_ASSERT_ENABLE\r
+#define NU_ASSERT_ENABLE CFG_NU_OS_KERN_PLUS_CORE_ASSERT\r
+#endif\r
+\r
+/* DEFINE: NU_ERROR_STRING\r
+ DEFAULT: NU_FALSE\r
+ DESCRIPTION: Setting NU_ERROR_STRING to NU_TRUE includes an additional set of\r
+ error strings used within ERC_System_Error. With NU_ERROR_STRING set\r
+ to NU_FALSE, these strings and corresponding logic are not compiled\r
+ as part of the Nucleus PLUS library.\r
+ NOTE: The Nucleus PLUS library and application must be rebuilt after changing\r
+ this define. */\r
+#ifndef NU_ERROR_STRING\r
+#define NU_ERROR_STRING CFG_NU_OS_KERN_PLUS_CORE_ERROR_STRING\r
+#endif\r
+\r
+#if (NU_ERROR_CHECKING == NU_TRUE)\r
+\r
+/* Define macro for NU_ERROR_CHECK with error checking enabled.\r
+ This macro is used to test any expression as long as the status\r
+ variable is set to NU_SUCCESS */\r
+#define NU_ERROR_CHECK(expression, status_var, status_err) \\r
+ if ((status_var == NU_SUCCESS) && (expression)) \\r
+ { \\r
+ status_var = status_err; \\r
+ }\r
+\r
+/* Define macro for NU_PARAM_CHECK with error checking enabled.\r
+ This macro is simple in nature */\r
+#define NU_PARAM_CHECK(expression, name, value) \\r
+ if (expression) \\r
+ { \\r
+ name = value; \\r
+ }\r
+\r
+#else\r
+\r
+/* Define macro for NU_ERROR_CHECK with error checking disabled */\r
+#define NU_ERROR_CHECK(expression, status_var, status_err)\r
+\r
+/* Define macro for NU_PARAM_CHECK with error checking disabled */\r
+#define NU_PARAM_CHECK(expression, name, value)\r
+\r
+#endif /* NU_ERROR_CHECKING == NU_TRUE */\r
+\r
+\r
+/* Ensure that NU_ASSERT and NU_CHECK are not currently defined */\r
+\r
+#ifdef NU_ASSERT\r
+#undef NU_ASSERT\r
+#endif\r
+\r
+#ifdef NU_CHECK\r
+#undef NU_CHECK\r
+#endif\r
+\r
+#if (NU_ASSERT_ENABLE == NU_TRUE)\r
+\r
+/* External function declarations */\r
+void ERC_Assert(CHAR *test, CHAR *name, UNSIGNED line);\r
+\r
+/* Define macro for ASSERT */\r
+#define NU_ASSERT(test) \\r
+ if ( !(test) ) \\r
+ { \\r
+ ERC_Assert( #test, __FILE__, __LINE__ ); \\r
+ } \\r
+ ((VOID) 0)\r
+\r
+/* Define macro for ASSERT2 */\r
+#define NU_ASSERT2(test) \\r
+ if ( !(test) ) \\r
+ { \\r
+ ERC_Assert( #test, __FILE__, __LINE__ ); \\r
+ } \\r
+ ((VOID) 0)\r
+\r
+#else\r
+\r
+/* Define macros for ASSERT and ASSERT2 as VOID */\r
+#define NU_ASSERT(test) \r
+#define NU_ASSERT2(test)\r
+\r
+#endif /* NU_ASSERT_ENABLE == NU_TRUE */\r
+\r
+#if (NU_ERROR_CHECKING == NU_TRUE)\r
+\r
+/* Define macro for NU_CHECK with error checking enabled */\r
+#define NU_CHECK(test, statement) \\r
+ NU_ASSERT2( test ); \\r
+ if ( !(test) ) \\r
+ { \\r
+ statement; \\r
+ } \\r
+ ((void) 0)\r
+\r
+#else\r
+\r
+/* Define macro for NU_CHECK with error checking disabled */\r
+#define NU_CHECK(test, statement) NU_ASSERT2( test )\r
+\r
+#endif /* NU_ERROR_CHECKING == NU_TRUE */\r
+\r
+\r
+/**********************************************************************/\r
+/* Other GENERIC ESAL macros/defines needed by PLUS */\r
+/**********************************************************************/\r
+/* Define all externally accessible, interrupt related function prototypes */\r
+INT ESAL_GE_INT_Global_Set(INT new_value);\r
+\r
+\r
+/**********************************************************************************/\r
+/* Nucleus Toolset specific macros used by the Kernel */\r
+/**********************************************************************************/\r
+\r
+/* Define interrupt lockout and enable constants. */\r
+#define ESAL_GE_INT_DISABLE_BITS ESAL_AR_INTERRUPTS_DISABLE_BITS\r
+#define ESAL_GE_INT_ENABLE_BITS ESAL_AR_INTERRUPTS_ENABLE_BITS\r
+\r
+#define NU_DISABLE_INTERRUPTS ESAL_GE_INT_DISABLE_BITS\r
+#define NU_ENABLE_INTERRUPTS ESAL_GE_INT_ENABLE_BITS\r
+\r
+/* Ensure HUGE / FAR pointer type specified - required for\r
+ some 16-bit architectures for pointer crossing page boundaries */\r
+#ifndef HUGE\r
+#define HUGE ESAL_TS_HUGE_PTR_TYPE\r
+#endif\r
+\r
+#ifndef FAR\r
+#define FAR ESAL_TS_FAR_PTR_TYPE\r
+#endif\r
+\r
+\r
+/* Define macro to read OS timer count */\r
+#define NU_HW_TIMER_COUNT_READ() ESAL_GE_TMR_OS_COUNT_READ()\r
+\r
+#ifdef CFG_NU_OS_SVCS_PWR_CORE_ENABLE\r
+\r
+/* Provide data structure for targets that vary during OP changes */\r
+extern UINT32 PMS_Single_Tick;\r
+#define NU_HW_TIMER_TICKS_PER_SEC (PMS_Single_Tick * NU_PLUS_TICKS_PER_SEC)\r
+\r
+#else\r
+\r
+/* Define constant for number of hardware ticks per second */\r
+#define NU_HW_TIMER_TICKS_PER_SEC (ESAL_GE_TMR_OS_CLOCK_RATE / \\r
+ ESAL_GE_TMR_OS_CLOCK_PRESCALE)\r
+\r
+#endif\r
+\r
+/* Define the number of hardware timer ticks that occur for each Nucleus PLUS\r
+ software tick */\r
+#define NU_HW_TIMER_TICKS_PER_SW_TICK (NU_HW_TIMER_TICKS_PER_SEC / \\r
+ NU_PLUS_TICKS_PER_SEC)\r
+\r
+ \r
+/**********************************************************************/\r
+/* COMMON NODE Definitions */\r
+/**********************************************************************/\r
+/* Define a common node data structure that can be included inside of \r
+ other system data structures. */\r
+ \r
+typedef struct CS_NODE_STRUCT\r
+{\r
+ struct CS_NODE_STRUCT *cs_previous;\r
+ struct CS_NODE_STRUCT *cs_next;\r
+ DATA_ELEMENT cs_priority;\r
+\r
+#if PAD_1\r
+ DATA_ELEMENT cs_padding[PAD_1];\r
+#endif\r
+\r
+} CS_NODE;\r
+\r
+\r
+#if (NU_PLUS_INLINING == NU_FALSE)\r
+\r
+/* Use declared functions */\r
+VOID NU_Place_On_List(CS_NODE **head, CS_NODE *new_node);\r
+VOID NU_Remove_From_List(CS_NODE **head, CS_NODE *node);\r
+\r
+#else\r
+\r
+/* Inlining enabled - use macros */\r
+#define NU_Place_On_List(head, new_node); \\r
+ if (*((CS_NODE **) (head))) \\r
+ { \\r
+ ((CS_NODE *) (new_node)) -> cs_previous= \\r
+ (*((CS_NODE **) (head))) -> cs_previous; \\r
+ (((CS_NODE *) (new_node)) -> cs_previous) -> cs_next = \\r
+ (CS_NODE *) (new_node); \\r
+ ((CS_NODE *) (new_node)) -> cs_next = \\r
+ (*((CS_NODE **) (head))); \\r
+ (((CS_NODE *) (new_node)) -> cs_next) -> cs_previous = \\r
+ ((CS_NODE *) (new_node)); \\r
+ } \\r
+ else \\r
+ { \\r
+ (*((CS_NODE **) (head))) = ((CS_NODE *) (new_node)); \\r
+ ((CS_NODE *) (new_node)) -> cs_previous = \\r
+ ((CS_NODE *) (new_node)); \\r
+ ((CS_NODE *) (new_node)) -> cs_next = \\r
+ ((CS_NODE *) (new_node)); \\r
+ }\r
+\r
+#define NU_Remove_From_List(head, node); \\r
+ if (((CS_NODE *) (node)) -> cs_previous == \\r
+ ((CS_NODE *) (node))) \\r
+ { \\r
+ (*((CS_NODE **) (head))) = NU_NULL; \\r
+ } \\r
+ else \\r
+ { \\r
+ (((CS_NODE *) (node)) -> cs_previous) -> cs_next = \\r
+ ((CS_NODE *) (node)) -> cs_next; \\r
+ (((CS_NODE *) (node)) -> cs_next) -> cs_previous = \\r
+ ((CS_NODE *) (node)) -> cs_previous; \\r
+ if (((CS_NODE *) (node)) == *((CS_NODE **) (head))) \\r
+ *((CS_NODE **) (head)) = \\r
+ ((CS_NODE *) (node)) -> cs_next; \\r
+ }\r
+\r
+#endif /* NU_PLUS_INLINING == NU_FALSE */\r
+\r
+/* This function is used regarless of inlining */\r
+VOID NU_Priority_Place_On_List(CS_NODE **head, CS_NODE *new_node);\r
+\r
+/**********************************************************************/\r
+/* TIMER MANAGEMENT Definitions */\r
+/**********************************************************************/\r
+\r
+/* Define the Timer Control Block data type. */\r
+typedef struct TM_TCB_STRUCT\r
+{\r
+ INT tm_timer_type; /* Application/Task */\r
+ UNSIGNED tm_remaining_time; /* Remaining time */\r
+ VOID *tm_information; /* Information pointer */\r
+ struct TM_TCB_STRUCT\r
+ *tm_next_timer, /* Next timer in list */\r
+ *tm_previous_timer; /* Previous timer in list*/\r
+} TM_TCB;\r
+\r
+\r
+/* Define Application's Timer Control Block data type. */\r
+\r
+typedef struct TM_APP_TCB_STRUCT\r
+{\r
+ CS_NODE tm_created; /* Node for linking to */\r
+ /* created timer list */\r
+ UNSIGNED tm_id; /* Internal TCB ID */\r
+ CHAR tm_name[NU_MAX_NAME]; /* Timer name */\r
+ VOID (*tm_expiration_routine)(UNSIGNED); /* Expiration function */\r
+ UNSIGNED tm_expiration_id; /* Expiration ID */\r
+ BOOLEAN tm_enabled; /* Timer enabled flag */\r
+ BOOLEAN tm_paused_status; /* Pause status */\r
+#if PAD_2\r
+ DATA_ELEMENT tm_padding[PAD_2];\r
+#endif\r
+\r
+ UNSIGNED tm_expirations; /* Number of expirations */\r
+ UNSIGNED tm_initial_time; /* Initial time */\r
+ UNSIGNED tm_reschedule_time; /* Reschedule time */\r
+ TM_TCB tm_actual_timer; /* Actual timer internals*/\r
+ UNSIGNED tm_paused_time; /* Pause remaining time */\r
+} TM_APP_TCB;\r
+\r
+/* Target dependent functions. */\r
+VOID TMCT_Timer_Interrupt(INT vector);\r
+\r
+/**********************************************************************/\r
+/* TASK CONTROL Definitions */\r
+/**********************************************************************/\r
+\r
+/* Define the Task Control Block data type. */\r
+typedef struct TC_TCB_STRUCT\r
+{\r
+ /* Standard thread information first. This information is used by\r
+ the target dependent portion of this component. Changes made\r
+ to this area of the structure can have undesirable side effects. */\r
+\r
+ CS_NODE tc_created; /* Node for linking to */\r
+ /* created task list */\r
+ UNSIGNED tc_id; /* Internal TCB ID */\r
+ CHAR tc_name[NU_MAX_NAME]; /* Task name */\r
+ DATA_ELEMENT tc_status; /* Task status */\r
+ BOOLEAN tc_delayed_suspend; /* Delayed task suspension*/\r
+ DATA_ELEMENT tc_priority; /* Task priority */\r
+ BOOLEAN tc_preemption; /* Task preemption enable */\r
+ UNSIGNED tc_scheduled; /* Task scheduled count */\r
+ UNSIGNED tc_cur_time_slice; /* Current time slice */\r
+ VOID *tc_stack_start; /* Stack starting address */\r
+ VOID *tc_stack_end; /* Stack ending address */\r
+ VOID *tc_stack_pointer; /* Task stack pointer */\r
+ UNSIGNED tc_stack_size; /* Task stack's size */\r
+ UNSIGNED tc_stack_minimum; /* Minimum stack size */\r
+ UNSIGNED tc_grp_id; /* Group id */\r
+\r
+ /* Process related structure members */\r
+ VOID *tc_process; /* Pointer to process CB */\r
+ CS_NODE tc_proc_node; /* Node element for process tracking */\r
+ VOID *tc_return_addr; /* Return address of service call */\r
+ VOID *tc_saved_return_addr; /* Previous return address of service call */\r
+\r
+ VOID *tc_saved_stack_ptr; /* Previous stack pointer */\r
+ UNSIGNED tc_time_slice; /* Task time slice value */\r
+\r
+ /* Information after this point is not used in the target dependent\r
+ portion of this component. Hence, changes in the following section\r
+ should not impact assembly language routines. */\r
+ struct TC_TCB_STRUCT\r
+ *tc_ready_previous, /* Previously ready TCB */\r
+ *tc_ready_next; /* next and previous ptrs */\r
+\r
+ /* Task control information follows. */\r
+\r
+ UNSIGNED tc_priority_group; /* Priority group mask bit*/\r
+ struct TC_TCB_STRUCT\r
+ **tc_priority_head; /* Pointer to list head */\r
+ DATA_ELEMENT *tc_sub_priority_ptr; /* Pointer to sub-group */\r
+ DATA_ELEMENT tc_sub_priority; /* Mask of sub-group bit */\r
+ DATA_ELEMENT tc_saved_status; /* Previous task status */\r
+ BOOLEAN tc_signal_active; /* Signal active flag */\r
+\r
+ BOOLEAN tc_auto_clean; /* Terminate/Delete at */\r
+ /* task completion */\r
+\r
+ /* Task entry function */\r
+ VOID (*tc_entry)(UNSIGNED, VOID *);\r
+ UNSIGNED tc_argc; /* Optional task argument */\r
+ VOID *tc_argv; /* Optional task argument */\r
+ VOID (*tc_cleanup) (VOID *);/* Clean-up routine */\r
+ VOID *tc_cleanup_info; /* Clean-up information */\r
+\r
+ /* Task timer information. */\r
+ INT tc_timer_active; /* Active timer flag */\r
+ TM_TCB tc_timer_control; /* Timer control block */\r
+\r
+ /* Task signal control information. */\r
+\r
+ UNSIGNED tc_signals; /* Current signals */\r
+ UNSIGNED tc_enabled_signals; /* Enabled signals */\r
+\r
+ /* tc_saved_status and tc_signal_active are now defined above in an\r
+ attempt to keep DATA_ELEMENT types together. */\r
+\r
+ /* Signal handling routine. */\r
+ VOID (*tc_signal_handler) (UNSIGNED);\r
+\r
+ /* Reserved words for the system and a single reserved word for the\r
+ application. */\r
+ UNSIGNED tc_system_reserved_1; /* System reserved word */\r
+ UNSIGNED tc_system_reserved_2; /* System reserved word */\r
+ UNSIGNED tc_system_reserved_3; /* System reserved word */\r
+ UNSIGNED tc_app_reserved_1; /* Application reserved */\r
+ \r
+ CS_NODE *tc_semaphore_list; /* Pointer to list of PI */\r
+ /* semaphores this task */\r
+ /* owns. */\r
+ DATA_ELEMENT tc_base_priority; /* Base priority of task */\r
+ /* for PI semaphores */\r
+ DATA_ELEMENT tc_semaphore_count; /* Number of priority */\r
+ /* modifying resources */\r
+ /* that the task has */\r
+ /* acquired */\r
+ \r
+ struct TC_TCB_STRUCT \r
+ *tc_grp_next; /* Next app or sys task */\r
+ struct TC_TCB_STRUCT\r
+ *tc_grp_prev; /* Last app or sys task */\r
+ \r
+ DATA_ELEMENT tc_debug_suspend; /* Debug suspension */\r
+\r
+} TC_TCB;\r
+\r
+\r
+/* Define the High-Level Interrupt Service Routine Control Block data type. */\r
+\r
+typedef struct TC_HCB_STRUCT\r
+{\r
+ /* Standard thread information first. This information is used by\r
+ the target dependent portion of this component. Changes made\r
+ to this area of the structure can have undesirable side effects. */\r
+\r
+ CS_NODE tc_created; /* Node for linking to */\r
+ /* created task list */\r
+ UNSIGNED tc_id; /* Internal TCB ID */\r
+ CHAR tc_name[NU_MAX_NAME]; /* HISR name */\r
+ DATA_ELEMENT tc_not_used_1; /* Not used field */\r
+ DATA_ELEMENT tc_not_used_2; /* Not used field */\r
+ DATA_ELEMENT tc_priority; /* HISR priority */\r
+ DATA_ELEMENT tc_not_used_3; /* Not used field */\r
+ UNSIGNED tc_scheduled; /* HISR scheduled count */\r
+ UNSIGNED tc_cur_time_slice; /* Not used in HISR */\r
+ VOID *tc_stack_start; /* Stack starting address */\r
+ VOID *tc_stack_end; /* Stack ending address */\r
+ VOID *tc_stack_pointer; /* HISR stack pointer */\r
+ UNSIGNED tc_stack_size; /* HISR stack's size */\r
+ UNSIGNED tc_stack_minimum; /* Minimum stack size */\r
+ UNSIGNED tc_grp_id; /* Group id */\r
+\r
+ /* Process related structure members */\r
+ VOID *tc_process; /* Pointer to process CB */\r
+\r
+ struct TC_HCB_STRUCT\r
+ *tc_active_next; /* Next activated HISR */\r
+ UNSIGNED tc_activation_count; /* Activation counter */\r
+ VOID (*tc_entry)(VOID); /* HISR entry function */\r
+ VOID *tc_hisr_queue; /* HISR Queue control\r
+ block pointer */\r
+\r
+ /* Information after this point is not used in the target dependent\r
+ portion of this component. Hence, changes in the following section\r
+ should not impact assembly language routines. */\r
+\r
+\r
+ /* Reserved words for the system and a single reserved word for the\r
+ application. */\r
+ UNSIGNED tc_system_reserved_1; /* System reserved word */\r
+ UNSIGNED tc_system_reserved_2; /* System reserved word */\r
+ UNSIGNED tc_system_reserved_3; /* System reserved word */\r
+ UNSIGNED tc_app_reserved_1; /* Application reserved */\r
+\r
+} TC_HCB;\r
+\r
+\r
+/* Define externally referenced variables. */\r
+extern VOID * volatile TCD_Current_Thread;\r
+extern TC_TCB * volatile TCD_Execute_Task;\r
+extern TC_HCB * volatile TCD_Execute_HISR;\r
+extern TC_TCB * volatile TCD_Current_App_Task;\r
+extern TC_TCB *TCD_App_Task_List;\r
+extern UNSIGNED TCD_Total_App_Tasks;\r
+\r
+/**********************************************************************/\r
+/* DYNAMIC MEMORY Definitions */\r
+/**********************************************************************/\r
+\r
+/* Define the Dynamic Pool Control Block data type. */\r
+\r
+typedef struct DM_PCB_STRUCT\r
+{\r
+ CS_NODE dm_created; /* Node for linking to */\r
+ /* created dynamic pools */\r
+ UNSIGNED dm_id; /* Internal PCB ID */\r
+ CHAR dm_name[NU_MAX_NAME]; /* Dynamic Pool name */\r
+ VOID *dm_start_address; /* Starting pool address */\r
+ UNSIGNED dm_pool_size; /* Size of pool */\r
+ UNSIGNED dm_min_allocation; /* Minimum allocate size */\r
+ UNSIGNED dm_available; /* Total available bytes */\r
+ struct DM_HEADER_STRUCT\r
+ *dm_memory_list; /* Memory list */\r
+ BOOLEAN dm_fifo_suspend; /* Suspension type flag */\r
+#if PAD_1\r
+ DATA_ELEMENT dm_padding[PAD_1];\r
+#endif\r
+ UNSIGNED dm_tasks_waiting; /* Number of waiting tasks*/\r
+ struct DM_SUSPEND_STRUCT\r
+ *dm_suspension_list; /* Suspension list */\r
+} DM_PCB;\r
+\r
+\r
+/**********************************************************************/\r
+/* EVENT GROUP Definitions */\r
+/**********************************************************************/\r
+\r
+/* Define the Event Group Control Block data type. */\r
+typedef struct EV_GCB_STRUCT\r
+{\r
+ CS_NODE ev_created; /* Node for linking to */\r
+ /* created Events list */\r
+ UNSIGNED ev_id; /* Internal EV ID */\r
+ CHAR ev_name[NU_MAX_NAME]; /* Event group name */\r
+ UNSIGNED ev_current_events; /* Current event flags */\r
+ UNSIGNED ev_tasks_waiting; /* Number of waiting tasks*/\r
+ struct EV_SUSPEND_STRUCT\r
+ *ev_suspension_list; /* Suspension list */\r
+} EV_GCB;\r
+\r
+\r
+/**********************************************************************/\r
+/* QUEUE Definitions */\r
+/**********************************************************************/\r
+\r
+/* Define the Queue Control Block data type. */\r
+typedef struct QU_QCB_STRUCT\r
+{\r
+ CS_NODE qu_created; /* Node for linking to */\r
+ /* created queue list */\r
+ UNSIGNED qu_id; /* Internal QCB ID */\r
+ CHAR qu_name[NU_MAX_NAME]; /* Queue name */\r
+ BOOLEAN qu_fixed_size; /* Fixed-size messages? */\r
+ BOOLEAN qu_fifo_suspend; /* Suspension type flag */\r
+#if PAD_2\r
+ DATA_ELEMENT qu_padding[PAD_2];\r
+#endif\r
+ UNSIGNED qu_queue_size; /* Total size of queue */\r
+ UNSIGNED qu_messages; /* Messages in queue */\r
+ UNSIGNED qu_message_size; /* Size of each message */\r
+ UNSIGNED qu_available; /* Available words */\r
+ UNSIGNED_PTR qu_start; /* Start of queue area */\r
+ UNSIGNED_PTR qu_end; /* End of queue area + 1 */\r
+ UNSIGNED_PTR qu_read; /* Read pointer */\r
+ UNSIGNED_PTR qu_write; /* Write pointer */\r
+ UNSIGNED qu_tasks_waiting; /* Number of waiting tasks*/\r
+ struct QU_SUSPEND_STRUCT\r
+ *qu_urgent_list; /* Urgent message suspend */\r
+ struct QU_SUSPEND_STRUCT\r
+ *qu_suspension_list; /* Suspension list */\r
+} QU_QCB;\r
+\r
+\r
+/**********************************************************************/\r
+/* SEMAPHORE Definitions */\r
+/**********************************************************************/\r
+\r
+/* Define the Semaphore Control Block data type. */\r
+typedef struct SM_SCB_STRUCT\r
+{\r
+ CS_NODE sm_created; /* Node for linking to */\r
+ /* created semaphore list */\r
+ UNSIGNED sm_id; /* Internal SCB ID */\r
+ CHAR sm_name[NU_MAX_NAME]; /* Semaphore name */\r
+ UNSIGNED sm_semaphore_count; /* Counting semaphore */\r
+ OPTION sm_suspend_type; /* Suspension type */\r
+ BOOLEAN sm_owner_killed; /* Flag if owner killed */\r
+#if PAD_2\r
+ DATA_ELEMENT sm_padding[PAD_2];\r
+#endif\r
+ TC_TCB *sm_semaphore_owner; /* Task that owns the */\r
+ /* semaphore */\r
+ UNSIGNED sm_tasks_waiting; /* Number of waiting */\r
+ /* tasks */\r
+ CS_NODE sm_semaphore_list; /* Node for linking owned */\r
+ /* semaphores */ \r
+ struct SM_SUSPEND_STRUCT\r
+ *sm_suspension_list; /* Suspension list */\r
+} SM_SCB;\r
+\r
+\r
+/**********************************************************************/\r
+/* PLUS Definitions */\r
+/**********************************************************************/\r
+\r
+/* Define application data types to actual internal data structures */\r
+typedef TC_TCB NU_TASK;\r
+typedef TC_HCB NU_HISR;\r
+typedef DM_PCB NU_MEMORY_POOL;\r
+typedef TM_APP_TCB NU_TIMER;\r
+typedef UINT8 NU_PROTECT;\r
+typedef QU_QCB NU_QUEUE;\r
+typedef SM_SCB NU_SEMAPHORE;\r
+typedef EV_GCB NU_EVENT_GROUP;\r
+\r
+/* External declarations */\r
+extern INT TCD_Interrupt_Level;\r
+extern volatile INT TMD_Timer_State;\r
+\r
+/**********************************************************************/\r
+/* Other TIMER MANAGEMENT Definitions */\r
+/**********************************************************************/\r
+\r
+/* Externally reference global data */\r
+extern volatile UNSIGNED TMD_Timer;\r
+extern volatile UNSIGNED TMD_System_Clock;\r
+extern volatile UNSIGNED TMD_System_Clock_Upper;\r
+extern volatile INT TMD_Timer_State;\r
+extern TC_TCB *volatile TMD_Time_Slice_Task;\r
+\r
+/*********** START BACKWARDS COMPATIBILITY DEFINITIONS FOR NUCLEUS PLUS 2.0 **********/\r
+\r
+/* NOTE: The following definitions were created as part of\r
+ Nucleus PLUS 2.0 to allow backwards compatibility\r
+ of all Nucleus PLUS internal functions accessed\r
+ by applications and any configuration settings modified\r
+ by Nucleus PLUS 2.0 */\r
+\r
+/* Hardware timer / clock related backwards compatibility */\r
+#define NU_Retrieve_Hardware_Clock(val) val = NU_HW_TIMER_COUNT_READ()\r
+#define NU_PLUS_Ticks_Per_Second NU_PLUS_TICKS_PER_SEC\r
+#define NU_HW_Ticks_Per_Second NU_HW_TIMER_TICKS_PER_SEC\r
+#define NU_HW_Ticks_Per_SW_Tick NU_HW_TIMER_TICKS_PER_SW_TICK\r
+\r
+#if (ESAL_GE_TMR_OS_COUNT_DIR == ESAL_COUNT_DOWN)\r
+\r
+#define NU_COUNT_DOWN\r
+\r
+#else\r
+\r
+#undef NU_COUNT_DOWN\r
+\r
+#endif /* ESAL_GE_TMR_OS_COUNT_DIR == ESAL_COUNT_DOWN */\r
+\r
+/* Re-map old internal timer and thread control function names to new internal names */\r
+#define TCT_Current_Thread TCCT_Current_Thread\r
+#define CSC_Place_On_List NU_Place_On_List\r
+#define CSC_Remove_From_List NU_Remove_From_List\r
+\r
+/*********** END BACKWARDS COMPATIBILITY DEFINITIONS FOR NUCLEUS PLUS 2.0 **********/\r
+\r
+extern INT TCD_Protect_Save;\r
+\r
+/* Map the following common service API to control functions */\r
+\r
+#ifndef NU_PROCESS\r
+/* For kernel, use macros */\r
+#define NU_Protect(x) NU_UNUSED_PARAM(x); \\r
+ TCD_Protect_Save = NU_Local_Control_Interrupts(NU_DISABLE_INTERRUPTS)\r
+#define NU_Unprotect() NU_Local_Control_Interrupts(TCD_Protect_Save)\r
+#else\r
+/* For processes, these functions are included in process user lib */\r
+VOID NU_Protect(NU_PROTECT *);\r
+VOID NU_Unprotect(VOID);\r
+#endif\r
+\r
+#define NU_Local_Control_Interrupts ESAL_GE_INT_Global_Set\r
+#define NU_Restore_Interrupts() ESAL_GE_INT_Global_Set(TCD_Interrupt_Level)\r
+\r
+#if (NU_STACK_CHECKING == NU_TRUE)\r
+UNSIGNED NU_Check_Stack(VOID);\r
+#else\r
+#define NU_Check_Stack() 0\r
+#endif\r
+\r
+/* Define task control functions. */\r
+STATUS NU_Create_Task(NU_TASK *task, CHAR *name,\r
+ VOID (*task_entry)(UNSIGNED, VOID *), UNSIGNED argc,\r
+ VOID *argv, VOID *stack_address, UNSIGNED stack_size,\r
+ OPTION priority, UNSIGNED time_slice,\r
+ OPTION preempt, OPTION auto_start);\r
+STATUS NU_Delete_Task(NU_TASK *task);\r
+STATUS NU_Reset_Task(NU_TASK *task, UNSIGNED argc, VOID *argv);\r
+STATUS NU_Terminate_Task(NU_TASK *task);\r
+STATUS NU_Resume_Task(NU_TASK *task);\r
+STATUS NU_Suspend_Task(NU_TASK *task);\r
+VOID NU_Relinquish(VOID);\r
+VOID NU_Sleep(UNSIGNED ticks);\r
+OPTION NU_Change_Priority(NU_TASK *task, OPTION new_priority);\r
+OPTION NU_Change_Preemption(OPTION preempt);\r
+UNSIGNED NU_Change_Time_Slice(NU_TASK *task, UNSIGNED time_slice);\r
+NU_TASK *NU_Current_Task_Pointer(VOID);\r
+UNSIGNED NU_Established_Tasks(VOID);\r
+STATUS NU_Task_Information(NU_TASK *task, CHAR *name,\r
+ DATA_ELEMENT *status, UNSIGNED *scheduled_count,\r
+ OPTION *priority, OPTION *preempt,\r
+ UNSIGNED *time_slice, VOID **stack_base,\r
+ UNSIGNED *stack_size, UNSIGNED *minimum_stack);\r
+UNSIGNED NU_Task_Pointers(NU_TASK **pointer_list,\r
+ UNSIGNED maximum_pointers);\r
+\r
+STATUS NU_Create_Auto_Clean_Task(NU_TASK **task_ptr, CHAR *name,\r
+ VOID (*task_entry)(UNSIGNED, VOID *),\r
+ UNSIGNED argc, VOID *argv,\r
+ NU_MEMORY_POOL *pool_ptr, \r
+ UNSIGNED stack_size,\r
+ OPTION priority, UNSIGNED time_slice,\r
+ OPTION preempt, OPTION auto_start);\r
+\r
+/* Define Queue management functions. */\r
+STATUS NU_Create_Queue(NU_QUEUE *queue, CHAR *name,\r
+ VOID *start_address, UNSIGNED queue_size,\r
+ OPTION message_type, UNSIGNED message_size,\r
+ OPTION suspend_type);\r
+STATUS NU_Delete_Queue(NU_QUEUE *queue);\r
+STATUS NU_Reset_Queue(NU_QUEUE *queue);\r
+STATUS NU_Send_To_Front_Of_Queue(NU_QUEUE *queue, VOID *message,\r
+ UNSIGNED size, UNSIGNED suspend);\r
+STATUS NU_Send_To_Queue(NU_QUEUE *queue, VOID *message,\r
+ UNSIGNED size, UNSIGNED suspend);\r
+STATUS NU_Broadcast_To_Queue(NU_QUEUE *queue, VOID *message,\r
+ UNSIGNED size, UNSIGNED suspend);\r
+STATUS NU_Receive_From_Queue(NU_QUEUE *queue, VOID *message,\r
+ UNSIGNED size, UNSIGNED *actual_size,\r
+ UNSIGNED suspend);\r
+UNSIGNED NU_Established_Queues(VOID);\r
+STATUS NU_Queue_Information(NU_QUEUE *queue, CHAR *name,\r
+ VOID **start_address, UNSIGNED *queue_size,\r
+ UNSIGNED *available, UNSIGNED *messages,\r
+ OPTION *message_type, UNSIGNED *message_size,\r
+ OPTION *suspend_type, UNSIGNED *tasks_waiting,\r
+ NU_TASK **first_task);\r
+UNSIGNED NU_Queue_Pointers(NU_QUEUE **pointer_list,\r
+ UNSIGNED maximum_pointers);\r
+\r
+/* Define Semaphore management functions. */\r
+STATUS NU_Create_Semaphore(NU_SEMAPHORE *semaphore, CHAR *name,\r
+ UNSIGNED initial_count, OPTION suspend_type);\r
+STATUS NU_Delete_Semaphore(NU_SEMAPHORE *semaphore);\r
+STATUS NU_Reset_Semaphore(NU_SEMAPHORE *semaphore,\r
+ UNSIGNED initial_count);\r
+STATUS NU_Obtain_Semaphore(NU_SEMAPHORE *semaphore, UNSIGNED suspend);\r
+STATUS NU_Release_Semaphore(NU_SEMAPHORE *semaphore);\r
+UNSIGNED NU_Established_Semaphores(VOID);\r
+STATUS NU_Semaphore_Information(NU_SEMAPHORE *semaphore, CHAR *name,\r
+ UNSIGNED *current_count, OPTION *suspend_type,\r
+ UNSIGNED *tasks_waiting, NU_TASK **first_task);\r
+UNSIGNED NU_Semaphore_Pointers(NU_SEMAPHORE **pointer_list,\r
+ UNSIGNED maximum_pointers);\r
+STATUS NU_Get_Semaphore_Owner(NU_SEMAPHORE *semaphore_ptr, NU_TASK **task); \r
+\r
+\r
+/* Define Event Group management functions. */\r
+STATUS NU_Create_Event_Group(NU_EVENT_GROUP *group, CHAR *name);\r
+STATUS NU_Delete_Event_Group(NU_EVENT_GROUP *group);\r
+STATUS NU_Set_Events(NU_EVENT_GROUP *group, UNSIGNED events,\r
+ OPTION operation);\r
+STATUS NU_Retrieve_Events(NU_EVENT_GROUP *group,\r
+ UNSIGNED requested_flags, OPTION operation,\r
+ UNSIGNED *retrieved_flags, UNSIGNED suspend);\r
+UNSIGNED NU_Established_Event_Groups(VOID);\r
+STATUS NU_Event_Group_Information(NU_EVENT_GROUP *group, CHAR *name,\r
+ UNSIGNED *event_flags, UNSIGNED *tasks_waiting,\r
+ NU_TASK **first_task);\r
+UNSIGNED NU_Event_Group_Pointers(NU_EVENT_GROUP **pointer_list,\r
+ UNSIGNED maximum_pointers); \r
+\r
+/* Define Dynamic memory management functions. */\r
+STATUS NU_Create_Memory_Pool(NU_MEMORY_POOL *pool, CHAR *name,\r
+ VOID *start_address, UNSIGNED pool_size,\r
+ UNSIGNED min_allocation, OPTION suspend_type);\r
+STATUS NU_Delete_Memory_Pool(NU_MEMORY_POOL *pool);\r
+\r
+#define NU_Allocate_Memory(pool_ptr, return_pointer, size, suspend) \\r
+ NU_Allocate_Aligned_Memory(pool_ptr, return_pointer, size, 0, suspend)\r
+\r
+STATUS NU_Add_Memory(NU_MEMORY_POOL *pool_ptr, VOID *memory_start_address,\r
+ UNSIGNED memory_size);\r
+#define NU_Reallocate_Memory(pool_ptr, memory_ptr, size, suspend) \\r
+ NU_Reallocate_Aligned_Memory(pool_ptr, memory_ptr, size, 0, suspend)\r
+\r
+STATUS NU_Reallocate_Aligned_Memory(NU_MEMORY_POOL *pool_ptr, VOID **return_pointer,\r
+ UNSIGNED size, UNSIGNED alignment,\r
+ UNSIGNED suspend);\r
+\r
+STATUS NU_Allocate_Aligned_Memory(NU_MEMORY_POOL *pool_ptr,\r
+ VOID **return_pointer, UNSIGNED size,\r
+ UNSIGNED alignment, UNSIGNED suspend);\r
+\r
+STATUS NU_Deallocate_Memory(VOID *memory);\r
+UNSIGNED NU_Established_Memory_Pools(VOID);\r
+STATUS NU_Memory_Pool_Information(NU_MEMORY_POOL *pool, CHAR *name,\r
+ VOID **start_address, UNSIGNED *pool_size,\r
+ UNSIGNED *min_allocation, UNSIGNED *available,\r
+ OPTION *suspend_type, UNSIGNED *tasks_waiting,\r
+ NU_TASK **first_task);\r
+UNSIGNED NU_Memory_Pool_Pointers(NU_MEMORY_POOL **pointer_list,\r
+ UNSIGNED maximum_pointers);\r
+\r
+/* Define Interrupt management functions. */\r
+INT NU_Control_Interrupts(INT new_level);\r
+STATUS NU_Register_LISR(INT vector,\r
+ VOID (*new_lisr)(INT),\r
+ VOID (**old_lisr)(INT));\r
+STATUS NU_Activate_HISR(NU_HISR *hisr);\r
+STATUS NU_Create_HISR(NU_HISR *hisr, CHAR *name,\r
+ VOID (*hisr_entry)(VOID), OPTION priority,\r
+ VOID *stack_address, UNSIGNED stack_size);\r
+STATUS NU_Delete_HISR(NU_HISR *hisr);\r
+NU_HISR *NU_Current_HISR_Pointer(VOID);\r
+UNSIGNED NU_Established_HISRs(VOID);\r
+STATUS NU_HISR_Information(NU_HISR *hisr, CHAR *name,\r
+ UNSIGNED *scheduled_count, DATA_ELEMENT *priority,\r
+ VOID **stack_base, UNSIGNED *stack_size,\r
+ UNSIGNED *minimum_stack);\r
+UNSIGNED NU_HISR_Pointers(NU_HISR **pointer_list,\r
+ UNSIGNED maximum_pointers);\r
+STATUS NU_Create_HISR_Queue(NU_HISR * hisr_ptr, UINT queue_size,\r
+ BOOLEAN overwrite_when_full);\r
+STATUS NU_Delete_HISR_Queue(NU_HISR * hisr_ptr);\r
+STATUS NU_Send_To_HISR_Queue(NU_HISR * hisr_ptr, VOID * data_ptr, UINT activate_hisr);\r
+STATUS NU_Receive_From_HISR_Queue(NU_HISR * hisr_ptr, VOID ** data_ptr);\r
+\r
+/* Timer management functions. */\r
+STATUS NU_Create_Timer(NU_TIMER *timer, CHAR *name, VOID(*expiration_routine)(UNSIGNED),\r
+ UNSIGNED id, UNSIGNED initial_time, UNSIGNED reschedule_time,\r
+ OPTION enable);\r
+STATUS NU_Delete_Timer(NU_TIMER *timer);\r
+STATUS NU_Reset_Timer(NU_TIMER *timer,\r
+ VOID (*expiration_routine)(UNSIGNED),\r
+ UNSIGNED initial_time, UNSIGNED reschedule_timer,\r
+ OPTION enable);\r
+STATUS NU_Control_Timer(NU_TIMER *timer, OPTION enable);\r
+UNSIGNED NU_Established_Timers(VOID);\r
+STATUS NU_Timer_Information(NU_TIMER *timer, CHAR *name,\r
+ OPTION *enable, UNSIGNED *expirations, UNSIGNED *id,\r
+ UNSIGNED *initial_time, UNSIGNED *reschedule_time);\r
+STATUS NU_Get_Remaining_Time(NU_TIMER *timer_ptr, UNSIGNED *remaining_time);\r
+STATUS NU_Pause_Timer(NU_TIMER *timer_ptr);\r
+STATUS NU_Resume_Timer(NU_TIMER *timer_ptr);\r
+UNSIGNED NU_Timer_Pointers(NU_TIMER **pointer_list,\r
+ UNSIGNED maximum_pointers);\r
+\r
+UINT64 NU_Get_Time_Stamp(VOID);\r
+\r
+extern VOID ESAL_CO_MEM_Region_Setup(INT region_num,\r
+ UINT32 vrt_addr,\r
+ UINT32 phy_addr,\r
+ UINT32 size,\r
+ ESAL_GE_MEMORY_TYPE mem_type,\r
+ ESAL_GE_CACHE_TYPE cache_type,\r
+ UINT32 access_type);\r
+\r
+/* Determine if pointers / 32-bit values are accessible with a single instruction.\r
+ If so, just reference the pointer / 32-bit value directly. Otherwise, call\r
+ the target dependent service. */\r
+#if ((NU_32BIT_ACCESS == 1) && (NU_PLUS_INLINING == 1) && !defined(CFG_NU_OS_KERN_PROCESS_ENABLE))\r
+\r
+/* Macro definition for architectures supporting single instruction\r
+ access to 32-bit values */\r
+#define NU_Retrieve_Clock() TMD_System_Clock\r
+\r
+#else\r
+\r
+/* Define function prototype */\r
+UNSIGNED NU_Retrieve_Clock(VOID);\r
+\r
+#endif /* ((NU_32BIT_ACCESS == 1) && (NU_PLUS_INLINING == 1) && !defined(CFG_NU_OS_KERN_PROCESS_ENABLE)) */\r
+\r
+#ifndef CFG_NU_OS_ARCH_SH_RENESAS_ENABLE\r
+#include <time.h>\r
+#endif\r
+VOID NU_Set_Clock(UNSIGNED new_value) ESAL_TS_RTE_DEPRECATED;\r
+VOID NU_Set_Clock64(UINT64 new_value);\r
+UINT64 NU_Retrieve_Clock64(VOID);\r
+time_t NU_Ticks_To_Time(UINT64 ticks);\r
+UINT64 NU_Time_To_Ticks(time_t cal_time);\r
+\r
+/* System memory functions */\r
+STATUS NU_System_Memory_Get(NU_MEMORY_POOL ** sys_pool_ptr, \r
+ NU_MEMORY_POOL ** usys_pool_ptr); \r
+\r
+#ifdef __cplusplus\r
+\r
+/* End of C declarations */\r
+}\r
+\r
+#endif /* __cplusplus */\r
+\r
+#endif \r
diff --git a/libs/system/zc702evk/nucleus/kernel/plus_supplement.h b/libs/system/zc702evk/nucleus/kernel/plus_supplement.h
--- /dev/null
@@ -0,0 +1,394 @@
+/***********************************************************************\r
+*\r
+* Copyright 2011 Mentor Graphics Corporation\r
+* All Rights Reserved.\r
+*\r
+* THIS WORK CONTAINS TRADE SECRET AND PROPRIETARY INFORMATION WHICH IS\r
+* THE PROPERTY OF MENTOR GRAPHICS CORPORATION OR ITS LICENSORS AND IS\r
+* SUBJECT TO LICENSE TERMS.\r
+*\r
+************************************************************************\r
+\r
+************************************************************************\r
+*\r
+* DESCRIPTION\r
+*\r
+* This file contains external data structures and definitions of\r
+* all PLUS Supplementary components.\r
+*\r
+***********************************************************************/\r
+\r
+#ifndef PLUS_SUPPLEMENT_H\r
+#define PLUS_SUPPLEMENT_H\r
+\r
+#ifdef __cplusplus\r
+\r
+/* C declarations in C++ */\r
+extern "C" {\r
+\r
+#endif\r
+\r
+/**********************************************************************/\r
+/* Test Configuration Settings */\r
+/**********************************************************************/\r
+\r
+/* DEFINE: NU_TIME_TEST1MIN_ENABLE\r
+ DEFAULT: NU_FALSE\r
+ DESCRIPTION: This define is used to perform the minimum code / data size tests that are\r
+ part of the Nucleus PLUS timing test. Setting this define to NU_TRUE will\r
+ allow the minimal sized PLUS code and data to be built.\r
+ NOTE: The Nucleus PLUS library and timing test must be rebuilt after changing\r
+ this define. */\r
+#ifndef NU_TIME_TEST1MIN_ENABLE\r
+#define NU_TIME_TEST1MIN_ENABLE CFG_NU_OS_KERN_PLUS_SUPPLEMENT_TIME_TEST1MIN\r
+#endif\r
+\r
+/* DEFINE: NU_TIME_TEST1MAX_ENABLE\r
+ DEFAULT: NU_FALSE\r
+ DESCRIPTION: This define is used to perform the maximum code / data size tests that are\r
+ part of the Nucleus PLUS timing test. Setting this define to NU_TRUE will\r
+ allow the maximum sized PLUS code and data to be built.\r
+ NOTE: The Nucleus PLUS library and timing test must be rebuilt after changing\r
+ this define. */\r
+#ifndef NU_TIME_TEST1MAX_ENABLE\r
+#define NU_TIME_TEST1MAX_ENABLE CFG_NU_OS_KERN_PLUS_SUPPLEMENT_TIME_TEST1MAX\r
+#endif\r
+\r
+/* DEFINE: NU_TIME_TEST2_ENABLE\r
+ DEFAULT: NU_FALSE\r
+ DESCRIPTION: This define is used to include code used for the Nucleus PLUS timing\r
+ test #2. Setting this define to NU_TRUE will include the necessary\r
+ timing related code.\r
+ NOTE: The Nucleus PLUS library and timing test must be rebuilt after changing\r
+ this define. */\r
+#ifndef NU_TIME_TEST2_ENABLE\r
+#define NU_TIME_TEST2_ENABLE CFG_NU_OS_KERN_PLUS_SUPPLEMENT_TIME_TEST2\r
+#endif\r
+\r
+/* DEFINE: NU_TIME_TEST3_ENABLE\r
+ DEFAULT: NU_FALSE\r
+ DESCRIPTION: This define is used to include code used for the Nucleus PLUS timing\r
+ test #3. Setting this define to NU_TRUE will include the necessary\r
+ timing related code.\r
+ NOTE: The Nucleus PLUS library and timing test must be rebuilt after changing\r
+ this define. */\r
+#ifndef NU_TIME_TEST3_ENABLE\r
+#define NU_TIME_TEST3_ENABLE CFG_NU_OS_KERN_PLUS_SUPPLEMENT_TIME_TEST3\r
+#endif\r
+\r
+/* DEFINE: NU_STATIC_TEST_ENABLE\r
+ DEFAULT: NU_FALSE\r
+ DESCRIPTION: This define allows visibility of static data / functions during debug\r
+ sessions by changing their scope from static to global when enabled.\r
+ NOTE: The Nucleus PLUS library, all middleware, and application must be rebuilt\r
+ after changing this define. */\r
+#ifndef NU_STATIC_TEST_ENABLE\r
+#define NU_STATIC_TEST_ENABLE CFG_NU_OS_KERN_PLUS_SUPPLEMENT_STATIC_TEST\r
+#endif\r
+\r
+/**********************************************************************/\r
+/* Other Configuration Settings */\r
+/**********************************************************************/\r
+/* DEFINE: NU_PLUS_OBJECT_LISTS_INCLUDE\r
+ DEFAULT: NU_FALSE\r
+ DESCRIPTION: This define is used to include ALL of the Nucleus PLUS created object lists\r
+ within the executable image of Nucleus PLUS. Setting this define to NU_TRUE\r
+ will explicitly include each of the object list pointers during\r
+ initialization. Setting this define to NU_FALSE will only include the\r
+ object lists required for the given application.\r
+ NOTE: This define may need to be set to NU_TRUE to allow kernel awareness to\r
+ correctly function on certain third party debuggers.. Some kernel aware\r
+ debuggers are not able to display any list of OS objects unless all lists are\r
+ in the image.\r
+ NOTE: The Nucleus PLUS library and application must be rebuilt after changing\r
+ this define. */\r
+#ifndef NU_PLUS_OBJECT_LISTS_INCLUDE\r
+#define NU_PLUS_OBJECT_LISTS_INCLUDE CFG_NU_OS_KERN_PLUS_SUPPLEMENT_PLUS_OBJECT_LISTS\r
+#endif\r
+\r
+/**********************************************************************/\r
+/* Support Definitions */\r
+/**********************************************************************/\r
+\r
+/* Define for "static" variables / data used to allow testing\r
+ of internal functions using external drivers / stub functions */\r
+#if (NU_STATIC_TEST_ENABLE == NU_TRUE)\r
+\r
+/* Define STATIC as nothing to make internal functions / variables\r
+ globally visible */\r
+#define STATIC\r
+\r
+#else\r
+\r
+/* Define STATIC as static to make internal functions / variables\r
+ have file level scope */\r
+#define STATIC static\r
+\r
+#endif /* NU_STATIC_TEST_ENABLE == NU_TRUE */\r
+\r
+/* Check if multiple timing tests being configured */\r
+#if ((NU_TIME_TEST1MIN_ENABLE + NU_TIME_TEST1MAX_ENABLE + \\r
+ NU_TIME_TEST2_ENABLE + NU_TIME_TEST3_ENABLE) > 1)\r
+\r
+/* Show an error - only 1 timing test can be configured */\r
+#error Only 1 timing test may be configured\r
+\r
+#endif\r
+\r
+/* Check if timing test 1 (minimum code / data) is enabled */\r
+#if (NU_TIME_TEST1MIN_ENABLE == NU_TRUE)\r
+\r
+/* Ensure all configuration settings build minimal code / data */\r
+#undef NU_ERROR_CHECKING\r
+#define NU_ERROR_CHECKING NU_FALSE\r
+#undef NU_PLUS_INLINING\r
+#define NU_PLUS_INLINING NU_FALSE\r
+#undef NU_MIN_RAM_ENABLED\r
+#define NU_MIN_RAM_ENABLED NU_TRUE\r
+#undef NU_PLUS_OBJECT_LISTS_INCLUDE\r
+#define NU_PLUS_OBJECT_LISTS_INCLUDE NU_FALSE\r
+\r
+#endif /* NU_TIME_TEST1MIN_ENABLE == NU_TRUE */\r
+\r
+/* Check if timing test 1 (maximum code / data) is enabled */\r
+#if (NU_TIME_TEST1MAX_ENABLE == NU_TRUE)\r
+\r
+/* Ensure all configuration settings build maximum code / data */\r
+#undef NU_ERROR_CHECKING\r
+#define NU_ERROR_CHECKING NU_TRUE\r
+#undef NU_PLUS_INLINING\r
+#define NU_PLUS_INLINING NU_TRUE\r
+#undef NU_MIN_RAM_ENABLED\r
+#define NU_MIN_RAM_ENABLED NU_FALSE\r
+#undef NU_PLUS_OBJECT_LISTS_INCLUDE\r
+#define NU_PLUS_OBJECT_LISTS_INCLUDE NU_TRUE\r
+\r
+#endif /* NU_TIME_TEST1MAX_ENABLE == NU_TRUE */\r
+\r
+/* Check if timing test 2 (API timing) or timing test 3 (interrupt latency)\r
+ is enabled */\r
+#if (NU_TIME_TEST2_ENABLE == NU_TRUE) || (NU_TIME_TEST3_ENABLE == NU_TRUE)\r
+\r
+/* Ensure all configuration settings build for speed */\r
+#undef NU_ERROR_CHECKING\r
+#define NU_ERROR_CHECKING NU_FALSE\r
+#undef NU_PLUS_INLINING\r
+#define NU_PLUS_INLINING NU_TRUE\r
+#undef NU_MIN_RAM_ENABLED\r
+#define NU_MIN_RAM_ENABLED NU_FALSE\r
+\r
+#endif /* NU_TIME_TEST2_ENABLE == NU_TRUE */\r
+\r
+\r
+/**********************************************************************/\r
+/* EVENT NOTIFICATIONS Definitions */\r
+/**********************************************************************/\r
+\r
+/* Maximum number of listeners */\r
+#define EN_MAX_LISTEN_CNT 10\r
+\r
+/* Minimum number of notification messages per pipe */\r
+#define EN_MIN_MSG_CNT 4\r
+\r
+/* Maximum length of notification message */\r
+#define EN_MAX_MSG_LEN 255\r
+\r
+/**********************************************************************/\r
+/* MAILBOX Definitions */\r
+/**********************************************************************/\r
+#define MB_MESSAGE_SIZE 4\r
+\r
+/* Define the Mailbox Control Block data type. */\r
+typedef struct MB_MCB_STRUCT\r
+{\r
+ CS_NODE mb_created; /* Node for linking to */\r
+ /* created mailbox list */\r
+ UNSIGNED mb_id; /* Internal MCB ID */\r
+ CHAR mb_name[NU_MAX_NAME]; /* Mailbox name */\r
+ BOOLEAN mb_message_present; /* Message present flag */\r
+ BOOLEAN mb_fifo_suspend; /* Suspension type flag */\r
+#if PAD_2\r
+ DATA_ELEMENT mb_padding[PAD_2];\r
+#endif\r
+ UNSIGNED mb_tasks_waiting; /* Number of waiting tasks*/\r
+ UNSIGNED /* Message area */\r
+ mb_message_area[MB_MESSAGE_SIZE];\r
+ struct MB_SUSPEND_STRUCT\r
+ *mb_suspension_list; /* Suspension list */\r
+} MB_MCB;\r
+\r
+\r
+/**********************************************************************/\r
+/* PIPE Definitions */\r
+/**********************************************************************/\r
+\r
+/* Define the Pipe Control Block data type. */\r
+typedef struct PI_PCB_STRUCT\r
+{\r
+ CS_NODE pi_created; /* Node for linking to */\r
+ /* created pipe list */\r
+ UNSIGNED pi_id; /* Internal PCB ID */\r
+ CHAR pi_name[NU_MAX_NAME]; /* Pipe name */\r
+ BOOLEAN pi_fixed_size; /* Fixed-size messages? */\r
+ BOOLEAN pi_fifo_suspend; /* Suspension type flag */\r
+#if PAD_2\r
+ DATA_ELEMENT pi_padding[PAD_2];\r
+#endif\r
+ UNSIGNED pi_pipe_size; /* Total size of pipe */\r
+ UNSIGNED pi_messages; /* Messages in pipe */\r
+ UNSIGNED pi_message_size; /* Size of each message */\r
+ UNSIGNED pi_available; /* Available bytes */\r
+ BYTE_PTR pi_start; /* Start of pipe area */\r
+ BYTE_PTR pi_end; /* End of pipe area + 1 */\r
+ BYTE_PTR pi_read; /* Read pointer */\r
+ BYTE_PTR pi_write; /* Write pointer */\r
+ UNSIGNED pi_tasks_waiting; /* Number of waiting tasks*/\r
+ struct PI_SUSPEND_STRUCT\r
+ *pi_urgent_list; /* Urgent message suspend */\r
+ struct PI_SUSPEND_STRUCT\r
+ *pi_suspension_list; /* Suspension list */\r
+} PI_PCB;\r
+\r
+/**********************************************************************/\r
+/* PARTITION MEMORY Definitions */\r
+/**********************************************************************/\r
+\r
+/* Define the Partition Pool Control Block data type. */\r
+typedef struct PM_PCB_STRUCT\r
+{\r
+ CS_NODE pm_created; /* Node for linking to */\r
+ /* created partition list */\r
+ UNSIGNED pm_id; /* Internal PCB ID */\r
+ CHAR pm_name[NU_MAX_NAME]; /* Partition Pool name */\r
+ VOID *pm_start_address; /* Starting pool address */\r
+ UNSIGNED pm_pool_size; /* Size of pool */\r
+ UNSIGNED pm_partition_size; /* Size of each partition */\r
+ UNSIGNED pm_available; /* Available partitions */\r
+ UNSIGNED pm_allocated; /* Allocated partitions */\r
+ struct PM_HEADER_STRUCT\r
+ *pm_available_list; /* Available list */\r
+ BOOLEAN pm_fifo_suspend; /* Suspension type flag */\r
+#if PAD_1\r
+ DATA_ELEMENT pm_padding[PAD_1];\r
+#endif\r
+ UNSIGNED pm_tasks_waiting; /* Number of waiting tasks*/\r
+ struct PM_SUSPEND_STRUCT\r
+ *pm_suspension_list; /* Suspension list */\r
+} PM_PCB;\r
+\r
+/**********************************************************************/\r
+/* PLUS Definitions */\r
+/**********************************************************************/\r
+typedef MB_MCB NU_MAILBOX;\r
+typedef PI_PCB NU_PIPE;\r
+typedef PM_PCB NU_PARTITION_POOL;\r
+\r
+#define NU_Release_Information() PLUS_RELEASE_STRING\r
+\r
+#if (CFG_NU_OS_KERN_PLUS_SUPPLEMENT_EVT_NOTIFY == NU_TRUE)\r
+\r
+#define ENC_Notification_Send NU_Notification_Send\r
+\r
+#endif /* CFG_NU_OS_KERN_PLUS_SUPPLEMENT_EVT_NOTIFY == NU_TRUE */\r
+\r
+/* Define Mailbox management functions. */\r
+STATUS NU_Create_Mailbox(NU_MAILBOX *mailbox, CHAR *name,\r
+ OPTION suspend_type);\r
+STATUS NU_Delete_Mailbox(NU_MAILBOX *mailbox);\r
+STATUS NU_Reset_Mailbox(NU_MAILBOX *mailbox);\r
+STATUS NU_Send_To_Mailbox(NU_MAILBOX *mailbox, VOID *message,\r
+ UNSIGNED suspend);\r
+STATUS NU_Broadcast_To_Mailbox(NU_MAILBOX *mailbox, VOID *message,\r
+ UNSIGNED suspend);\r
+STATUS NU_Receive_From_Mailbox(NU_MAILBOX *mailbox, VOID *message,\r
+ UNSIGNED suspend);\r
+UNSIGNED NU_Established_Mailboxes(VOID);\r
+STATUS NU_Mailbox_Information(NU_MAILBOX *mailbox, CHAR *name,\r
+ OPTION *suspend_type, OPTION *message_present,\r
+ UNSIGNED *tasks_waiting, NU_TASK **first_task);\r
+UNSIGNED NU_Mailbox_Pointers(NU_MAILBOX **pointer_list,\r
+ UNSIGNED maximum_pointers);\r
+\r
+/* Define Pipe management functions. */\r
+STATUS NU_Create_Pipe(NU_PIPE *pipe, CHAR *name,\r
+ VOID *start_address, UNSIGNED pipe_size,\r
+ OPTION message_type, UNSIGNED message_size,\r
+ OPTION suspend_type);\r
+STATUS NU_Delete_Pipe(NU_PIPE *pipe);\r
+STATUS NU_Reset_Pipe(NU_PIPE *pipe);\r
+STATUS NU_Send_To_Front_Of_Pipe(NU_PIPE *pipe, VOID *message,\r
+ UNSIGNED size, UNSIGNED suspend);\r
+STATUS NU_Send_To_Pipe(NU_PIPE *pipe, VOID *message,\r
+ UNSIGNED size, UNSIGNED suspend);\r
+STATUS NU_Broadcast_To_Pipe(NU_PIPE *pipe, VOID *message,\r
+ UNSIGNED size, UNSIGNED suspend);\r
+STATUS NU_Receive_From_Pipe(NU_PIPE *pipe, VOID *message,\r
+ UNSIGNED size, UNSIGNED *actual_size,\r
+ UNSIGNED suspend);\r
+UNSIGNED NU_Established_Pipes(VOID);\r
+STATUS NU_Pipe_Information(NU_PIPE *pipe, CHAR *name,\r
+ VOID **start_address, UNSIGNED *pipe_size,\r
+ UNSIGNED *available, UNSIGNED *messages,\r
+ OPTION *message_type, UNSIGNED *message_size,\r
+ OPTION *suspend_type, UNSIGNED *tasks_waiting,\r
+ NU_TASK **first_task);\r
+UNSIGNED NU_Pipe_Pointers(NU_PIPE **pointer_list,\r
+ UNSIGNED maximum_pointers);\r
+\r
+/* Define Signal processing functions. */\r
+UNSIGNED NU_Control_Signals(UNSIGNED signal_enable_mask);\r
+UNSIGNED NU_Receive_Signals(VOID);\r
+STATUS NU_Register_Signal_Handler(VOID (*signal_handler)(UNSIGNED));\r
+STATUS NU_Send_Signals(NU_TASK *task, UNSIGNED signal_mask);\r
+\r
+/* Define Partition memory management functions. */\r
+STATUS NU_Create_Partition_Pool(NU_PARTITION_POOL *pool, CHAR *name,\r
+ VOID *start_address, UNSIGNED pool_size,\r
+ UNSIGNED partition_size, OPTION suspend_type);\r
+STATUS NU_Delete_Partition_Pool(NU_PARTITION_POOL *pool);\r
+STATUS NU_Allocate_Partition(NU_PARTITION_POOL *pool,\r
+ VOID **return_pointer, UNSIGNED suspend);\r
+STATUS NU_Deallocate_Partition(VOID *partition);\r
+UNSIGNED NU_Established_Partition_Pools(VOID);\r
+STATUS NU_Partition_Pool_Information(NU_PARTITION_POOL *pool,\r
+ CHAR *name,\r
+ VOID **start_address,\r
+ UNSIGNED *pool_size,\r
+ UNSIGNED *partition_size,\r
+ UNSIGNED *available,\r
+ UNSIGNED *allocated,\r
+ OPTION *suspend_type,\r
+ UNSIGNED *tasks_waiting,\r
+ NU_TASK **first_task);\r
+UNSIGNED NU_Partition_Pool_Pointers(NU_PARTITION_POOL **pointer_list,\r
+ UNSIGNED maximum_pointers);\r
+\r
+/* Development support functions. */\r
+VOID NU_Get_Release_Version(UINT* major, UINT* minor);\r
+\r
+#if (CFG_NU_OS_KERN_PLUS_SUPPLEMENT_EVT_NOTIFY == NU_TRUE)\r
+\r
+/* Event notification functions. */\r
+VOID *NU_Notification_Queue_Create (VOID) ESAL_TS_RTE_DEPRECATED;\r
+STATUS NU_Notification_Listen_Start (VOID* handle, DV_DEV_ID dev_id,\r
+ UINT32 type, UINT32 type_mask) ESAL_TS_RTE_DEPRECATED;\r
+STATUS NU_Notification_Send (DV_DEV_ID dev_id, UINT32 type, VOID* msg, UINT8 msg_len) ESAL_TS_RTE_DEPRECATED;\r
+STATUS NU_Notification_Get (VOID *handle, DV_DEV_ID *dev_id_ptr, UINT32 *type_ptr,\r
+ VOID **msg_ptr, UINT8 *msg_len_ptr, UNSIGNED suspend) ESAL_TS_RTE_DEPRECATED;\r
+STATUS NU_Notification_Listen_Stop (VOID* handle, DV_DEV_ID dev_id) ESAL_TS_RTE_DEPRECATED;\r
+STATUS NU_Notification_Queue_Delete (VOID* handle) ESAL_TS_RTE_DEPRECATED;\r
+STATUS NU_Notification_Register (DV_DEV_LABEL label, DV_DEV_ID* sender_id) ESAL_TS_RTE_DEPRECATED;\r
+STATUS NU_Notification_Unregister (DV_DEV_ID sender_id) ESAL_TS_RTE_DEPRECATED;\r
+STATUS NU_Notification_Find_Sender (DV_DEV_LABEL label_list[], UINT32 label_cnt,\r
+ DV_DEV_ID sender_id_list[], UINT32* sender_id_cnt) ESAL_TS_RTE_DEPRECATED;\r
+\r
+#endif /* CFG_NU_OS_KERN_PLUS_SUPPLEMENT_EVT_NOTIFY == NU_TRUE */\r
+\r
+#ifdef __cplusplus\r
+\r
+/* End of C declarations */\r
+}\r
+\r
+#endif /* __cplusplus */\r
+\r
+#endif\r
diff --git a/libs/system/zc702evk/nucleus/kernel/proc_extern.h b/libs/system/zc702evk/nucleus/kernel/proc_extern.h
--- /dev/null
@@ -0,0 +1,343 @@
+/*************************************************************************\r
+*\r
+* Copyright Mentor Graphics Corporation 2013\r
+* All Rights Reserved.\r
+*\r
+* THIS WORK CONTAINS TRADE SECRET AND PROPRIETARY INFORMATION WHICH IS\r
+* THE PROPERTY OF MENTOR GRAPHICS CORPORATION OR ITS LICENSORS AND IS\r
+* SUBJECT TO LICENSE TERMS.\r
+*\r
+*************************************************************************/\r
+/*************************************************************************\r
+*\r
+* FILE NAME\r
+*\r
+* proc_extern.h\r
+*\r
+* COMPONENT\r
+*\r
+* Nucleus Processes\r
+*\r
+* DESCRIPTION\r
+*\r
+* Nucleus Processes API.\r
+*\r
+* DATA STRUCTURES\r
+*\r
+* None\r
+*\r
+* FUNCTIONS\r
+*\r
+* NU_EXPORT_SYMBOL\r
+* NU_SYMBOL_COMPONENT\r
+* NU_KEEP_COMPONENT_SYMBOLS\r
+*\r
+*************************************************************************/\r
+\r
+#ifndef PROC_EXTERN_H\r
+#define PROC_EXTERN_H\r
+\r
+#include "nucleus.h"\r
+#include "kernel/plus_core.h"\r
+\r
+/****************************************/\r
+/* Symbol Table Export Macros */\r
+/****************************************/\r
+\r
+#ifdef CFG_NU_OS_KERN_PROCESS_CORE_ENABLE\r
+\r
+/* Symbol Entry - An entry in a Nucleus symbol table. */\r
+typedef struct NU_SYMBOL_ENTRY_STRUCT\r
+{\r
+ VOID * symbol_address;\r
+ const CHAR * symbol_name;\r
+\r
+} NU_SYMBOL_ENTRY;\r
+\r
+/* No trampoline for process symbols and kernel data */\r
+#define NU_SYM_TRAMP_PROCESS_DATA(symbol_name, export_name)\r
+\r
+/* Use actual symbol address in process symbol table and kernel symbol table for data */\r
+#define NU_SYM_ADDR_PROCESS_DATA(symbol_name, export_name) symbol_name\r
+\r
+/* Kernel symbols (functions) use trampoline */\r
+#define NU_SYM_TRAMP_KERNEL_FUNC(symbol_name, export_name) \\r
+ /* Create trampoline function for this symbol */ \\r
+ static void __nutramp_##export_name(void) __attribute__((section("nutramp"),naked)); \\r
+ static void __nutramp_##export_name(void) \\r
+ { \\r
+ /* Perform architecture specific trampoline code */ \\r
+ PROC_AR_TRAMPOLINE(symbol_name); \\r
+ }\r
+\r
+/* Use trampoline symbol address in kernel process symbol table */\r
+#define NU_SYM_ADDR_KERNEL_FUNC(symbol_name, export_name) __nutramp_##export_name\r
+\r
+/* This macro, ultimately, exports a symbol. There are 3 different scenarios needing to be accounted for:\r
+ 1. Process functions and data - all symbols get put into the process symbol table "as is"\r
+ 2. Kernel data - all kernel data symbols get put into the kernel symbol table "as is"\r
+ 3. Kernel functions - all kernel function symbols get put into the kernel symbol table using a\r
+ "trampoline" function that switches modes (user/kernel) and performs MMU ops */\r
+#define PROC_EXPORT_SYMBOL(symbol_name, export_name, trampoline_macro, symbol_addr_macro) \\r
+ /* First, extern the symbol */ \\r
+ extern typeof(symbol_name) symbol_name; \\r
+ \\r
+ /* Place a "stringified" version of the symbol into a string table */ \\r
+ static const char __nusymstr_##export_name[] \\r
+ __attribute__((section("nusymstr"), aligned(1))) = #export_name; \\r
+ \\r
+ /* Trampoline (if needed) */ \\r
+ trampoline_macro(symbol_name, export_name); \\r
+ \\r
+ /* Place symbol entry into symbol table */ \\r
+ static const NU_SYMBOL_ENTRY __nusymtab_##export_name \\r
+ __attribute__((section("nusymtab"), used)) = \\r
+ {(VOID *)&symbol_addr_macro(symbol_name, export_name), __nusymstr_##export_name }\r
+\r
+/* Thic macro exports a symbol for use by kernel mode processes. It uses a separate symbol table and\r
+ bypasses the trampoline. */\r
+#define PROC_EXPORT_KSYMBOL(symbol_name, export_name) \\r
+ /* First, extern the symbol */ \\r
+ extern typeof(symbol_name) symbol_name; \\r
+ \\r
+ /* Place a "stringified" version of the symbol into a string table */ \\r
+ static const char __nuksymstr_##export_name[] \\r
+ __attribute__((section("nuksymstr"), aligned(1))) = #export_name; \\r
+ \\r
+ /* Place symbol entry into symbol table */ \\r
+ static const NU_SYMBOL_ENTRY __nuksymtab_##export_name \\r
+ __attribute__((section("nuksymtab"), used)) = \\r
+ {(VOID *)&(symbol_name), __nuksymstr_##export_name }\r
+\r
+#if (!defined(NU_PROCESS) || (defined(NU_PROCESS) && defined(NU_KERNEL_MODE)))\r
+\r
+#if ((CFG_NU_OS_KERN_PROCESS_CORE_SUP_USER_MODE == NU_TRUE) || defined(CFG_NU_OS_KERN_PROCESS_MEM_MGMT_ENABLE))\r
+\r
+/* Macro to export functions when mode switching or MMU support enabled */\r
+#define NU_EXPORT_SYMBOL_ALIAS(symbol, alias) \\r
+ PROC_EXPORT_SYMBOL(symbol, alias, NU_SYM_TRAMP_KERNEL_FUNC, NU_SYM_ADDR_KERNEL_FUNC); \\r
+ PROC_EXPORT_KSYMBOL(symbol, alias)\r
+\r
+/* Macro to export functions for other kernel mode processes. This uses no trampoline regardless of enablement of mode\r
+ switching or MMU support. */\r
+#define NU_EXPORT_KSYMBOL_ALIAS(symbol, alias) PROC_EXPORT_KSYMBOL(symbol, alias)\r
+\r
+#else\r
+\r
+/* Macro used by process to export functions and data and by kernel to export functions when mode switching & MMU support off\r
+ NOTE: Since supervisor / user mode switching is off, no trampoline is used for kernel functions */\r
+#define NU_EXPORT_SYMBOL_ALIAS(symbol, alias) PROC_EXPORT_SYMBOL(symbol, alias, NU_SYM_TRAMP_PROCESS_DATA, NU_SYM_ADDR_PROCESS_DATA)\r
+\r
+/* With mode switching disabled, kernel mode symbol table is not used. */\r
+#define NU_EXPORT_KSYMBOL_ALIAS(symbol, alias) NU_EXPORT_SYMBOL_ALIAS(symbol, alias)\r
+\r
+#endif\r
+\r
+/* Macro to export data symbols. */\r
+#define NU_EXPORT_DATA_SYMBOL_ALIAS(symbol, alias) \\r
+ PROC_EXPORT_SYMBOL(symbol, alias, NU_SYM_TRAMP_PROCESS_DATA, NU_SYM_ADDR_PROCESS_DATA); \\r
+ PROC_EXPORT_KSYMBOL(symbol, alias)\r
+\r
+/* Macro to export data symbols to kernel-mode processes only. */\r
+#define NU_EXPORT_DATA_KSYMBOL_ALIAS(symbol, alias) \\r
+ PROC_EXPORT_KSYMBOL(symbol, alias)\r
+\r
+#else\r
+\r
+/* Non-kernel mode processes need not use trampoline since they are already behind trampoline. */\r
+#define NU_EXPORT_SYMBOL_ALIAS(symbol, alias) PROC_EXPORT_SYMBOL(symbol, alias, NU_SYM_TRAMP_PROCESS_DATA, NU_SYM_ADDR_PROCESS_DATA)\r
+\r
+/* Macro to export data symbols. User-mode processes do not have the kernel-mode symbol table so\r
+ the symbol is exported only to user-mode symbol table. */\r
+#define NU_EXPORT_DATA_SYMBOL_ALIAS(symbol, alias) \\r
+ PROC_EXPORT_SYMBOL(symbol, alias, NU_SYM_TRAMP_PROCESS_DATA, NU_SYM_ADDR_PROCESS_DATA);\r
+\r
+#endif\r
+\r
+/* Regular export macros that use symbol name as the export name */\r
+#define NU_EXPORT_SYMBOL(symbol) NU_EXPORT_SYMBOL_ALIAS(symbol, symbol)\r
+#define NU_EXPORT_KSYMBOL(symbol) NU_EXPORT_KSYMBOL_ALIAS(symbol, symbol)\r
+#define NU_EXPORT_DATA_SYMBOL(symbol) NU_EXPORT_DATA_SYMBOL_ALIAS(symbol, symbol)\r
+#define NU_EXPORT_DATA_KSYMBOL(symbol) NU_EXPORT_DATA_KSYMBOL_ALIAS(symbol, symbol)\r
+\r
+/* Symbol Component - Used at the start of a symbol file to define the component in which the\r
+ symbols are defined. This is used in conjunction with NU_KEEP_COMPONENT_SYMBOLS. */\r
+#define NU_SYMBOL_COMPONENT(component_name) \\r
+ /* Define global for this component */ \\r
+ UINT8 nusymtab_keep_##component_name;\r
+\r
+/* Keep Component Symbols - This macro will ensure the symbols for the given component are included as\r
+ long as the NU_SYMBOL_COMPONENT macro is used as well. */\r
+#define NU_KEEP_COMPONENT_SYMBOLS(component_name) \\r
+ /* Extern the global associated with this component's symbols */ \\r
+ extern UINT8 nusymtab_keep_##component_name; \\r
+ \\r
+ /* Assign a value to the global */ \\r
+ nusymtab_keep_##component_name = 1;\r
+\r
+/* Return NU_SUCCESS to these now unused macros */\r
+#define NU_BIND_TASK_TO_KERNEL(task) NU_SUCCESS\r
+#define NU_BIND_HISR_TO_KERNEL(hisr) NU_SUCCESS\r
+\r
+/* Process exit codes specific to Nucleus (based on 128 + POSIX signal value that is closest to what Nucleus is doing) */\r
+#include <signal.h>\r
+#define EXIT_ABORT (128 + SIGABRT) /* Exit code returned when abort() is called */\r
+#define EXIT_FPU_ERROR (128 + SIGFPE) /* Exit code returned when a floating point error occurs */\r
+#define EXIT_ILLEGAL_INST (128 + SIGILL) /* Exit code returned when illegal instruction executed */\r
+#define EXIT_KILL (128 + SIGKILL) /* Exit code returned when NU_Kill() is called */\r
+#define EXIT_BUS_ERROR (128 + SIGBUS) /* Exit code returned for bus error */\r
+#define EXIT_INVALID_MEM (128 + SIGSEGV) /* Exit code returned for invalid memory access */\r
+#define EXIT_STOP (128 + SIGSTOP) /* Exit code returned when NU_Stop() is called indirectly via shell or symbol usage */\r
+#define EXIT_CONTINUE (128 + SIGCONT) /* If returned by main(), root task is suspended instead of doing normal exit() */\r
+\r
+/* Process action definitions */\r
+#define PROC_CMD_START 0 /* Start the process */\r
+#define PROC_CMD_STOP 1 /* Stop the process */\r
+\r
+/* Process names will be file names */\r
+#define PROC_NAME_LENGTH CFG_NU_OS_KERN_PROCESS_CORE_MAX_NAME_LENGTH\r
+\r
+/*******************************************************/\r
+/* Structure for process information */\r
+/*******************************************************/\r
+typedef struct\r
+{\r
+ INT pid;\r
+ CHAR name[PROC_NAME_LENGTH];\r
+ INT state;\r
+ VOID * load_addr;\r
+ VOID (*entry_addr)(INT, VOID *);\r
+ INT exit_code;\r
+ BOOLEAN kernel_mode;\r
+\r
+} NU_PROCESS_INFO;\r
+\r
+/*******************************************************/\r
+/* Structure for memory map information */\r
+/*******************************************************/\r
+typedef struct\r
+{\r
+ CHAR name[NU_MAX_NAME];\r
+ VOID *phys_base;\r
+ VOID *virt_base;\r
+ UNSIGNED size;\r
+ UNSIGNED attributes;\r
+} NU_MEMORY_MAP_INFO;\r
+\r
+/*******************************************************/\r
+/* Structure for exception handling */\r
+/*******************************************************/\r
+typedef struct\r
+{\r
+ INT pid; /* Process ID */\r
+ NU_TASK *task; /* Offending thread */\r
+ VOID *address; /* Address where error occurred */\r
+ VOID *return_address; /* Point of exception and return address */\r
+ UNSIGNED type; /* Type of error that occurred */\r
+ BOOLEAN interrupt_context; /* Did exception occur in interrupt context? */\r
+ BOOLEAN kernel_process; /* Did exception occur in kernel process / module? */\r
+ VOID *exception_information; /* Additional information such as stack frame (arch specific) */\r
+} NU_PROCESS_EXCEPTION;\r
+\r
+/* Return values from exception handler */\r
+#define NU_PROC_SCHEDULE 0 /* Returning this from Process_Exception_Handler\r
+ will have the system return to the scheduler\r
+ when exception handling is complete */\r
+#define NU_PROC_RESUME_TASK 1 /* Returning this from Process_Exception_Handler\r
+ will have the system return to the point of\r
+ exception */\r
+#define NU_PROC_UNRECOVERABLE 2 /* Returning this from Process_Exception_Handler\r
+ will result in execution going to the system error\r
+ handler trap / while(1) */\r
+\r
+/*******************************************************/\r
+/* Defines that will only work properly with processes */\r
+/*******************************************************/\r
+\r
+/* Public interfaces */\r
+STATUS NU_Load(CHAR * name, INT * pid, VOID * load_addr, VOID * extension, UNSIGNED suspend);\r
+STATUS NU_Start(INT pid, VOID * args, UNSIGNED suspend);\r
+STATUS NU_Stop(INT pid, INT exit_code, UNSIGNED suspend);\r
+STATUS NU_Unload(INT pid, UNSIGNED suspend);\r
+STATUS NU_Kill(INT pid, UNSIGNED suspend);\r
+STATUS NU_Symbol(INT pid, CHAR * sym_name, VOID ** sym_addr);\r
+STATUS NU_Symbol_Close (INT pid, BOOLEAN stop, BOOLEAN * stopped);\r
+INT NU_Getpid(VOID);\r
+STATUS NU_Get_Exit_Code(INT pid, INT * exit_code);\r
+STATUS NU_Memory_Map(INT *mem_id, CHAR *name, VOID *phys_addr, VOID **actual_addr, UNSIGNED size, UNSIGNED options);\r
+STATUS NU_Memory_Unmap(INT mem_id);\r
+STATUS NU_Memory_Get_ID(INT *mem_id, VOID *phys_addr, CHAR *name);\r
+STATUS NU_Memory_Share(INT *mem_id, INT source_id, CHAR *name);\r
+UNSIGNED NU_Established_Processes(VOID);\r
+STATUS NU_Processes_Information(UNSIGNED * max_processes, NU_PROCESS_INFO info_array[]);\r
+STATUS NU_Process_Information(INT pid, NU_PROCESS_INFO * info);\r
+STATUS NU_Memory_Map_Information(INT mem_id, NU_MEMORY_MAP_INFO *info);\r
+\r
+NU_WEAK_REF(UNSIGNED Process_Exception_Handler(NU_PROCESS_EXCEPTION *exception_info));\r
+\r
+/* Structure definition for load extension */\r
+typedef struct\r
+{\r
+ UNSIGNED heap_size; /* size (in bytes) of process memory pool */\r
+ UNSIGNED stack_size; /* size (in bytes) of process root thread stack */\r
+ BOOLEAN kernel_mode; /* indicates if process loaded in kernel mode */\r
+\r
+} NU_LOAD_EXTENSION;\r
+\r
+/* Definitions */\r
+#define NU_LOAD_DYNAMIC (VOID *)0xFFFFFFFF\r
+\r
+/* Kernel process ID */\r
+#define PROC_KERNEL_ID 0\r
+\r
+/* Memory region attributes */\r
+#define NU_MEM_READ (1 << 0)\r
+#define NU_MEM_WRITE (1 << 1)\r
+#define NU_MEM_EXEC (1 << 2)\r
+#define NU_SHARE_READ (1 << 3)\r
+#define NU_SHARE_WRITE (1 << 4)\r
+#define NU_SHARE_EXEC (1 << 5)\r
+#define NU_CACHE_INHIBIT (1 << 6)\r
+#define NU_CACHE_WRITE_THROUGH (1 << 7)\r
+#define NU_CACHE_NO_COHERENT (1 << 8)\r
+\r
+#define NU_MEMORY_UNDEFINED (VOID *)0xFFFFFFFF\r
+\r
+/* Internal global functions */\r
+STATUS PROC_Kernel_Initialize(VOID);\r
+STATUS PROC_Get_Memory_Pool(NU_MEMORY_POOL **memory_pool_ptr);\r
+STATUS PROC_Bind_Task(NU_TASK *task_ptr);\r
+STATUS PROC_Unbind_Task(NU_TASK *task_ptr);\r
+STATUS PROC_Bind_HISR(NU_HISR *hisr_ptr);\r
+VOID PROC_Stopped(VOID);\r
+BOOLEAN PROC_Get_Abort_Flag(VOID);\r
+\r
+#ifndef NU_PROCESS\r
+\r
+#include "process/core/arch_proc_mode.h"\r
+\r
+#endif /* !NU_PROCESS */\r
+\r
+/* Define process set-up function */\r
+VOID PROC_Schedule(VOID);\r
+#define NU_PROCESS_SETUP() PROC_Schedule()\r
+\r
+#else /* CFG_NU_OS_KERN_PROCESS_CORE_ENABLE */\r
+\r
+/* Versions of various macros used if process support disabled. */\r
+#define NU_EXPORT_SYMBOL(symbol_name)\r
+#define NU_EXPORT_KSYMBOL(symbol_name)\r
+#define NU_EXPORT_DATA_SYMBOL(symbol_name)\r
+#define NU_EXPORT_DATA_KSYMBOL(symbol_name)\r
+#define NU_EXPORT_SYMBOL_ALIAS(symbol_name)\r
+#define NU_EXPORT_KSYMBOL_ALIAS(symbol_name)\r
+#define NU_EXPORT_DATA_SYMBOL_ALIAS(symbol_name)\r
+#define NU_EXPORT_DATA_KSYMBOL_ALIAS(symbol_name)\r
+#define NU_SYMBOL_COMPONENT(component_name)\r
+#define NU_KEEP_COMPONENT_SYMBOLS(component_name)\r
+#define NU_PROCESS_SETUP()\r
+#define NU_Getpid() 0\r
+\r
+#endif /* CFG_NU_OS_KERN_PROCESS_CORE_ENABLE */\r
+\r
+#endif /* PROC_EXTERN_H */\r
diff --git a/libs/system/zc702evk/nucleus/kernel/rtl.h b/libs/system/zc702evk/nucleus/kernel/rtl.h
--- /dev/null
@@ -0,0 +1,80 @@
+/*************************************************************************\r
+*\r
+* Copyright 2010 Mentor Graphics Corporation\r
+* All Rights Reserved.\r
+*\r
+* THIS WORK CONTAINS TRADE SECRET AND PROPRIETARY INFORMATION WHICH IS\r
+* THE PROPERTY OF MENTOR GRAPHICS CORPORATION OR ITS LICENSORS AND IS\r
+* SUBJECT TO LICENSE TERMS.\r
+*\r
+*************************************************************************/\r
+/*************************************************************************\r
+*\r
+* FILE NAME\r
+*\r
+* rtl.h\r
+*\r
+* DESCRIPTION\r
+*\r
+* This file contains the Nucleus run-time library functionality\r
+*\r
+* DATA STRUCTURES\r
+*\r
+* None\r
+*\r
+* FUNCTIONS\r
+*\r
+* None\r
+*\r
+* DEPENDENCIES\r
+*\r
+* string.h String functions\r
+*\r
+*************************************************************************/\r
+\r
+#include <string.h>\r
+\r
+#ifndef RTL_H\r
+#define RTL_H\r
+\r
+#ifdef __cplusplus\r
+\r
+/* C declarations in C++ */\r
+extern "C" {\r
+\r
+#endif\r
+\r
+/* This macro sets the Nucleus memory pool used for Nucleus malloc\r
+ operations. */\r
+\r
+#if (CFG_NU_OS_KERN_RTL_MALLOC_POOL == 0)\r
+#define RTL_MALLOC_POOL System_Memory\r
+#endif /* CFG_NU_OS_KERN_RTL_MALLOC_POOL == 0 */\r
+\r
+#if (CFG_NU_OS_KERN_RTL_MALLOC_POOL == 1)\r
+#define RTL_MALLOC_POOL Uncached_System_Memory\r
+#endif /* CFG_NU_OS_KERN_RTL_MALLOC_POOL == 1 */\r
+\r
+#if (CFG_NU_OS_KERN_RTL_MALLOC_POOL == 2)\r
+#define RTL_MALLOC_POOL NU_Malloc_User_Mem_Pool\r
+#endif /* CFG_NU_OS_KERN_RTL_MALLOC_POOL == 2 */\r
+\r
+#ifndef RTL_MALLOC_POOL\r
+#error ERROR: No Nucleus memory pool for Nucleus malloc support.\r
+#endif /* RTL_MALLOC_POOL */\r
+\r
+/* Macros for time.h sub-routines */\r
+#define RTL_SEC_PER_YEAR 31536000\r
+#define RTL_SEC_PER_DAY 86400\r
+#define RTL_SEC_PER_HOUR 3600\r
+#define RTL_SEC_PER_MIN 60\r
+#define RTL_EPOCH_YEAR 1970\r
+\r
+#ifdef __cplusplus\r
+\r
+/* End of C declarations */\r
+}\r
+\r
+#endif /* __cplusplus */\r
+\r
+#endif /* RTL_H */\r
diff --git a/libs/system/zc702evk/nucleus/kernel/rtl_extr.h b/libs/system/zc702evk/nucleus/kernel/rtl_extr.h
--- /dev/null
@@ -0,0 +1,70 @@
+/*************************************************************************\r
+*\r
+* Copyright 2010 Mentor Graphics Corporation\r
+* All Rights Reserved.\r
+*\r
+* THIS WORK CONTAINS TRADE SECRET AND PROPRIETARY INFORMATION WHICH IS\r
+* THE PROPERTY OF MENTOR GRAPHICS CORPORATION OR ITS LICENSORS AND IS\r
+* SUBJECT TO LICENSE TERMS.\r
+*\r
+*************************************************************************/\r
+/*************************************************************************\r
+*\r
+* FILE NAME\r
+*\r
+* rtl_extr.h\r
+*\r
+* DESCRIPTION\r
+*\r
+* This file contains the Nucleus run-time library functionality\r
+* external interface.\r
+*\r
+* DATA STRUCTURES\r
+*\r
+* None\r
+*\r
+* FUNCTIONS\r
+*\r
+* RTL_malloc\r
+* RTL_calloc\r
+* RTL_realloc\r
+* RTL_free\r
+*\r
+* DEPENDENCIES\r
+*\r
+* None\r
+*\r
+*************************************************************************/\r
+\r
+#ifndef RTL_EXTR_H\r
+#define RTL_EXTR_H\r
+\r
+#ifdef __cplusplus\r
+\r
+/* C declarations in C++ */\r
+extern "C" {\r
+\r
+#endif\r
+\r
+/* Nucleus malloc functions */\r
+\r
+void * RTL_malloc (size_t size);\r
+void * RTL_calloc (size_t nmemb, size_t size);\r
+void * RTL_realloc (void * ptr, size_t size);\r
+void RTL_free (void * ptr);\r
+\r
+/* API to seed random number generator */\r
+\r
+VOID NU_RTL_Rand_Seed(VOID);\r
+\r
+/* Nucleus epoch function used by gettimeofday */\r
+UINT64 RTL_Calc_Time_Since_Epoch(struct tm *time_ptr);\r
+\r
+#ifdef __cplusplus\r
+\r
+/* End of C declarations */\r
+}\r
+\r
+#endif /* __cplusplus */\r
+\r
+#endif /* RTL_EXTR_H */\r
diff --git a/libs/system/zc702evk/nucleus/lib/arm-none-eabi-/master/libnucleus_master.a b/libs/system/zc702evk/nucleus/lib/arm-none-eabi-/master/libnucleus_master.a
new file mode 100644 (file)
index 0000000..53ecb0b
Binary files /dev/null and b/libs/system/zc702evk/nucleus/lib/arm-none-eabi-/master/libnucleus_master.a differ
index 0000000..53ecb0b
Binary files /dev/null and b/libs/system/zc702evk/nucleus/lib/arm-none-eabi-/master/libnucleus_master.a differ
diff --git a/libs/system/zc702evk/nucleus/lib/arm-none-eabi-/master/nucleus_gen_cfg.h b/libs/system/zc702evk/nucleus/lib/arm-none-eabi-/master/nucleus_gen_cfg.h
--- /dev/null
@@ -0,0 +1,350 @@
+/***********************************************************************
+*
+* Copyright 1993 Mentor Graphics Corporation
+* All Rights Reserved.
+*
+* THIS WORK CONTAINS TRADE SECRET AND PROPRIETARY INFORMATION WHICH IS
+* THE PROPERTY OF MENTOR GRAPHICS CORPORATION OR ITS LICENSORS AND IS
+* SUBJECT TO LICENSE TERMS.
+*
+************************************************************************
+
+************************************************************************
+*
+* FILE NAME
+*
+* nucleus_gen_cfg.h
+*
+* COMPONENT
+*
+* Nucleus OS
+*
+* DESCRIPTION
+*
+* This file contains auto-generated configuration settings for
+* the Nucleus OS. DO NOT MODIFY.
+*
+* DATA STRUCTURES
+*
+* None
+*
+* DEPENDENCIES
+*
+* None
+*
+************************************************************************/
+/* Generated: Thu Sep 25 15:20:09 +0500 2014 */
+/* DO NOT MODIFY - This file is auto-generated */
+#ifndef NUCLEUS_GEN_CFG_H
+#define NUCLEUS_GEN_CFG_H
+#define CFG_NU_OS_SVCS_REGISTRY_MAX_KEY_LEN 52
+#define CFG_TOOLSETS_ENABLE
+#define CFG_TOOLSETS_ZC702EVK_ENABLE
+#define CFG_TOOLSETS_ZC702EVK_CSGNU_ARM_ENABLE
+#define CFG_TOOLSETS_ZC702EVK_CSGNU_ARM_ARCH_CFLAGS "-gdwarf-2 -mthumb-interwork -mcpu=cortex-a9"
+#define CFG_TOOLSETS_ZC702EVK_CSGNU_ARM_ARCH_CXXFLAGS "-gdwarf-2 -mthumb-interwork -mcpu=cortex-a9"
+#define CFG_TOOLSETS_ZC702EVK_CSGNU_ARM_ARCH_ASFLAGS "-gdwarf2 -meabi=4 -mcpu=cortex-a9 -mfpu=neon"
+#define CFG_TOOLSETS_ZC702EVK_CSGNU_ARM_ARCH_LDFLAGS ""
+#define CFG_TOOLSETS_ZC702EVK_CSGNU_ARM_ARCH_LDSCRIPT "$(TOOLSETS_HOME)/csgnu_arm.zc702evk.link_ram.ld"
+#define CFG_TOOLSETS_ZC702EVK_CSGNU_ARM_ARCH_ARFLAGS ""
+#define CFG_TOOLSETS_CSGNU_ARM_ENABLE
+#define CFG_TOOLSETS_CSGNU_ARM_CROSS "arm-none-eabi-"
+#define CFG_TOOLSETS_CSGNU_ARM_CC "$(CROSS)gcc"
+#define CFG_TOOLSETS_CSGNU_ARM_CFLAGS "-Wall -ffunction-sections -fdata-sections"
+#define CFG_TOOLSETS_CSGNU_ARM_PROC_CFLAGS "-Wall -ffunction-sections -fdata-sections -fPIC -DNU_PROCESS"
+#define CFG_TOOLSETS_CSGNU_ARM_COMPILE "$(CC) $(patsubst %, -isystem %, $(SYSTEM_INCLUDE_PATH)) $(patsubst %, -I%, $(INCLUDE_PATH)) -I. -Wp,-MD,$(2:.o=.d.tmp) -c $(CFLAGS) $(ARCH_CFLAGS) $(CFLAGS_$(1)) $(1) -o $(2)"
+#define CFG_TOOLSETS_CSGNU_ARM_PROC_COMPILE "$(CC) $(patsubst %, -I%, $(INCLUDE_PATH)) -I. -Wp,-MD,$(2:.po=.pd.tmp) -c $(PROC_CFLAGS) $(ARCH_CFLAGS) $(CFLAGS_$(1)) $(1) -o $(2)"
+#define CFG_TOOLSETS_CSGNU_ARM_CXX "$(CROSS)g++"
+#define CFG_TOOLSETS_CSGNU_ARM_CXXFLAGS "-Wall -fno-enforce-eh-specs"
+#define CFG_TOOLSETS_CSGNU_ARM_PROC_CXXFLAGS "-Wall -fno-enforce-eh-specs -fPIC -DNU_PROCESS"
+#define CFG_TOOLSETS_CSGNU_ARM_COMPILECXX "$(CXX) $(patsubst %, -isystem %, $(SYSTEM_INCLUDE_PATH)) $(patsubst %, -I%, $(INCLUDE_PATH)) -I. -Wp,-MD,$(2:.o=.d.tmp) -c $(CXXFLAGS) $(ARCH_CXXFLAGS) $(CXXFLAGS_$(1)) $(1) -o $(2)"
+#define CFG_TOOLSETS_CSGNU_ARM_PROC_COMPILECXX "$(CXX) $(patsubst %, -I%, $(INCLUDE_PATH)) -I. -Wp,-MD,$(2:.po=.pd.tmp) -c $(PROC_CXXFLAGS) $(ARCH_CXXFLAGS) $(CXXFLAGS_$(1)) $(1) -o $(2)"
+#define CFG_TOOLSETS_CSGNU_ARM_AS "$(CROSS)as"
+#define CFG_TOOLSETS_CSGNU_ARM_ASFLAGS ""
+#define CFG_TOOLSETS_CSGNU_ARM_PROC_ASFLAGS ""
+#define CFG_TOOLSETS_CSGNU_ARM_ASSEMBLE "$(AS) $(patsubst %, -I%, $(INCLUDE_PATH)) -I. --MD $(2:.o=.d.tmp) $(ASFLAGS) $(ARCH_ASFLAGS) $(ASFLAGS_$(1)) $(1) -o $(2)"
+#define CFG_TOOLSETS_CSGNU_ARM_CPPASSEMBLE "$(CC) $(patsubst %, -I%, $(INCLUDE_PATH)) -I. -Wp,-MD,$(2:.o=.d.tmp) $(addprefix -Wa$(comma),$(ASFLAGS)) $(addprefix -Wa$(comma),$(ARCH_ASFLAGS)) $(addprefix -Wa$(comma),$(ASFLAGS_$(1))) -c -x assembler-with-cpp $(1) -o $(2)"
+#define CFG_TOOLSETS_CSGNU_ARM_PROC_ASSEMBLE "$(AS) $(patsubst %, -I%, $(INCLUDE_PATH)) -I. --MD $(2:.po=.pd.tmp) $(ASFLAGS) $(ARCH_ASFLAGS) $(ASFLAGS_$(1)) $(1) -o $(2)"
+#define CFG_TOOLSETS_CSGNU_ARM_PROC_CPPASSEMBLE "$(CC) $(patsubst %, -I%, $(INCLUDE_PATH)) -I. -Wp,-MD,$(2:.po=.pd.tmp) $(addprefix -Wa$(comma),$(ASFLAGS)) $(addprefix -Wa$(comma),$(ARCH_ASFLAGS)) $(addprefix -Wa$(comma),$(ASFLAGS_$(1))) -c $(1) -o $(2)"
+#define CFG_TOOLSETS_CSGNU_ARM_LD "$(CROSS)gcc"
+#define CFG_TOOLSETS_CSGNU_ARM_LDFLAGS "-nostartfiles -Wl,--gc-sections -Wl,--wrap=malloc -Wl,--wrap=calloc -Wl,--wrap=realloc -Wl,--wrap=free -Wl,--defsym -Wl,PAGE_SIZE=$(PAGE_SIZE)"
+#define CFG_TOOLSETS_CSGNU_ARM_PROC_LDFLAGS "-nostdlib -nostartfiles -Wl,--gc-sections -Wl,-pie -Wl,--warn-unresolved-symbols -Wl,--no-demangle -Wl,--nmagic -Wl,--defsym -Wl,PAGE_SIZE=$(PAGE_SIZE) -Wl,--defsym -Wl,NUCLEUS_VERSION=$(NUCLEUS_VERSION)"
+#define CFG_TOOLSETS_CSGNU_ARM_PROC_LDSCRIPT "$(SYSTEM_HOME)/os/toolset/csgnu_arm.process.ld"
+#define CFG_TOOLSETS_CSGNU_ARM_LINK "$(LD) -Wl,-Map=$(basename $(1)).map -o $(1) $(LDFLAGS) $(ARCH_LDFLAGS) $(LDFLAGS_$(notdir $(1))) -T$(LDSCRIPT_$(notdir $(1))) -Wl,--start-group $(2) -lc -lm -lstdc++ -Wl,--end-group"
+#define CFG_TOOLSETS_CSGNU_ARM_PROC_LINK "$(CROSS)nuproclink $(LD) $(basename $(1)).out $(basename $(1)).map -Wl,-Map=$(basename $(1)).map -o $(basename $(1)).out $(PROC_LDFLAGS) $(ARCH_PROC_LDFLAGS) $(LDFLAGS_$(notdir $(1))) -T$(PROC_LDSCRIPT) -Wl,--start-group @$(2) @$(3) -lstdc++ -lgcc -Wl,--end-group"
+#define CFG_TOOLSETS_CSGNU_ARM_AR "$(CROSS)ar"
+#define CFG_TOOLSETS_CSGNU_ARM_ARFLAGS ""
+#define CFG_TOOLSETS_CSGNU_ARM_ARCHIVE "$(AR) $(ARFLAGS) $(ARCH_ARFLAGS) -rc $(1) $(2)"
+#define CFG_TOOLSETS_CSGNU_ARM_POSTLD "$(CROSS)objcopy"
+#define CFG_TOOLSETS_CSGNU_ARM_PROC_POSTLD "$(CROSS)strip"
+#define CFG_TOOLSETS_CSGNU_ARM_POSTLINK "$(POSTLD) -O binary $(1) $(basename $(1)).bin"
+#define CFG_TOOLSETS_CSGNU_ARM_PROC_POSTLINK "$(PROC_POSTLD) -g --strip-unneeded -R .interp -R .dynamic -R .comment $(basename $(1)).out -o $(1)"
+#define CFG_NU_ENABLE
+#define CFG_NU_MAJOR_VERSION 2013
+#define CFG_NU_MINOR_VERSION 8
+#define CFG_NU_PATCH_VERSION 1
+#define CFG_NU_OS_ENABLE
+#undef CFG_NU_OS_NET_ENABLE
+#undef CFG_NU_OS_NET_SSL_ENABLE
+#undef CFG_NU_OS_NET_SSL_OPENSSL_ENABLE
+#undef CFG_NU_OS_NET_SSL_OPENSSL_SSL_ENABLE
+#undef CFG_NU_OS_NET_SSL_OPENSSL_CRYPTO_ENABLE
+#undef CFG_NU_OS_NET_SSL_OPENSSL_OPENSSL_UNIT_TESTS_ENABLE
+#undef CFG_NU_OS_NET_SSL_LITE_ENABLE
+#undef CFG_NU_OS_NET_DHCP_ENABLE
+#undef CFG_NU_OS_NET_DHCP_SERVER_ENABLE
+#undef CFG_NU_OS_NET_PROT_ENABLE
+#undef CFG_NU_OS_NET_PROT_TELNET_ENABLE
+#undef CFG_NU_OS_NET_PROT_TELNET_SHELL_ENABLE
+#undef CFG_NU_OS_NET_PROT_TELNET_SERVER_ENABLE
+#undef CFG_NU_OS_NET_PROT_TELNET_CORE_ENABLE
+#undef CFG_NU_OS_NET_PROT_TELNET_CLIENT_ENABLE
+#undef CFG_NU_OS_NET_PROT_TFTP_ENABLE
+#undef CFG_NU_OS_NET_PROT_TFTP_SHELL_ENABLE
+#undef CFG_NU_OS_NET_PROT_TFTP_SERVER_ENABLE
+#undef CFG_NU_OS_NET_PROT_TFTP_CLIENT_ENABLE
+#undef CFG_NU_OS_NET_PROT_FTP_ENABLE
+#undef CFG_NU_OS_NET_EMAIL_ENABLE
+#undef CFG_NU_OS_NET_EMAIL_SMTPC_ENABLE
+#undef CFG_NU_OS_NET_WPA_SUPP_ENABLE
+#undef CFG_NU_OS_NET_WPA_SUPP_SRC_ENABLE
+#undef CFG_NU_OS_NET_SSH_ENABLE
+#undef CFG_NU_OS_NET_SSH_LIBTOMMATH_ENABLE
+#undef CFG_NU_OS_NET_SSH_LIBTOMCRYPT_ENABLE
+#undef CFG_NU_OS_NET_SSH_DB_SSHSERVER_ENABLE
+#undef CFG_NU_OS_NET_SHELL_ENABLE
+#undef CFG_NU_OS_NET_SNMP_ENABLE
+#undef CFG_NU_OS_NET_SNTPC_ENABLE
+#undef CFG_NU_OS_NET_JSON_ENABLE
+#undef CFG_NU_OS_NET_STACK_ENABLE
+#undef CFG_NU_OS_NET_IPV6_ENABLE
+#undef CFG_NU_OS_NET_WEB_ENABLE
+#undef CFG_NU_OS_NET_NAT_ENABLE
+#undef CFG_NU_OS_NET_WSOX_ENABLE
+#undef CFG_NU_OS_NET_HTTP_ENABLE
+#undef CFG_NU_OS_NET_IKE_ENABLE
+#undef CFG_NU_OS_NET_IPSEC_ENABLE
+#undef CFG_NU_OS_CONN_ENABLE
+#undef CFG_NU_OS_CONN_USB_ENABLE
+#undef CFG_NU_OS_CONN_USB_FUNC_ENABLE
+#undef CFG_NU_OS_CONN_USB_FUNC_HID_ENABLE
+#undef CFG_NU_OS_CONN_USB_FUNC_HID_MSE_ENABLE
+#undef CFG_NU_OS_CONN_USB_FUNC_HID_CLASS_ENABLE
+#undef CFG_NU_OS_CONN_USB_FUNC_HID_KBD_ENABLE
+#undef CFG_NU_OS_CONN_USB_FUNC_COMM_ENABLE
+#undef CFG_NU_OS_CONN_USB_FUNC_COMM_CLASS_ENABLE
+#undef CFG_NU_OS_CONN_USB_FUNC_COMM_MDM_ENABLE
+#undef CFG_NU_OS_CONN_USB_FUNC_COMM_ETH_ENABLE
+#undef CFG_NU_OS_CONN_USB_FUNC_MS_ENABLE
+#undef CFG_NU_OS_CONN_USB_FUNC_MS_CLASS_ENABLE
+#undef CFG_NU_OS_CONN_USB_FUNC_MS_USER_ENABLE
+#undef CFG_NU_OS_CONN_USB_FUNC_DFU_ENABLE
+#undef CFG_NU_OS_CONN_USB_FUNC_STACK_ENABLE
+#undef CFG_NU_OS_CONN_USB_COM_ENABLE
+#undef CFG_NU_OS_CONN_USB_COM_STACK_ENABLE
+#undef CFG_NU_OS_CONN_USB_HOST_ENABLE
+#undef CFG_NU_OS_CONN_USB_HOST_COMM_ENABLE
+#undef CFG_NU_OS_CONN_USB_HOST_COMM_CLASS_ENABLE
+#undef CFG_NU_OS_CONN_USB_HOST_COMM_MDM_ENABLE
+#undef CFG_NU_OS_CONN_USB_HOST_COMM_ETH_ENABLE
+#undef CFG_NU_OS_CONN_USB_HOST_MS_ENABLE
+#undef CFG_NU_OS_CONN_USB_HOST_MS_CLASS_ENABLE
+#undef CFG_NU_OS_CONN_USB_HOST_MS_USER_ENABLE
+#undef CFG_NU_OS_CONN_USB_HOST_AUDIO_ENABLE
+#undef CFG_NU_OS_CONN_USB_HOST_AUDIO_CLASS_ENABLE
+#undef CFG_NU_OS_CONN_USB_HOST_AUDIO_USER_ENABLE
+#undef CFG_NU_OS_CONN_USB_HOST_HID_ENABLE
+#undef CFG_NU_OS_CONN_USB_HOST_HID_MOUSE_ENABLE
+#undef CFG_NU_OS_CONN_USB_HOST_HID_CLASS_ENABLE
+#undef CFG_NU_OS_CONN_USB_HOST_HID_KEYBOARD_ENABLE
+#undef CFG_NU_OS_CONN_USB_HOST_STACK_ENABLE
+#undef CFG_NU_OS_CONN_SDIO_ENABLE
+#undef CFG_NU_OS_CONN_I2C_ENABLE
+#undef CFG_NU_OS_CONN_SPI_ENABLE
+#undef CFG_NU_OS_CONN_LWSPI_ENABLE
+#undef CFG_NU_OS_CONN_CAN_ENABLE
+#define CFG_NU_OS_DRVR_ENABLE
+#undef CFG_NU_OS_DRVR_WLAN_ENABLE
+#undef CFG_NU_OS_DRVR_WLAN_AR4100_ENABLE
+#undef CFG_NU_OS_DRVR_WLAN_AR6K3_ENABLE
+#undef CFG_NU_OS_DRVR_WLAN_AR6K2_ENABLE
+#undef CFG_NU_OS_DRVR_USB_ENABLE
+#undef CFG_NU_OS_DRVR_USB_FUNC_ENABLE
+#undef CFG_NU_OS_DRVR_USB_FUNC_NET_IF_ENABLE
+#undef CFG_NU_OS_DRVR_USB_FUNC_HWCTRL_ENABLE
+#undef CFG_NU_OS_DRVR_USB_HOST_ENABLE
+#undef CFG_NU_OS_DRVR_USB_HOST_FILE_IF_ENABLE
+#undef CFG_NU_OS_DRVR_USB_HOST_NET_IF_ENABLE
+#undef CFG_NU_OS_DRVR_USB_HOST_OHCI_ENABLE
+#undef CFG_NU_OS_DRVR_USB_HOST_EHCI_ENABLE
+#undef CFG_NU_OS_DRVR_USB_HOST_USB_INPUT_ENABLE
+#undef CFG_NU_OS_DRVR_USB_HOST_HWCTRL_ENABLE
+#undef CFG_NU_OS_DRVR_USB_HOST_XHCI_ENABLE
+#undef CFG_NU_OS_DRVR_USB_OTG_ENABLE
+#undef CFG_NU_OS_DRVR_USB_OTG_HWCTRL_ENABLE
+#undef CFG_NU_OS_DRVR_SAFE_ENABLE
+#undef CFG_NU_OS_DRVR_SAFE_SRA_ENABLE
+#undef CFG_NU_OS_DRVR_SAFE_BASE_ENABLE
+#undef CFG_NU_OS_DRVR_SDIO_ENABLE
+#undef CFG_NU_OS_DRVR_SDIO_FUNC_ENABLE
+#undef CFG_NU_OS_DRVR_SDIO_FUNC_SD_ENABLE
+#undef CFG_NU_OS_DRVR_SDIO_HOST_ENABLE
+#undef CFG_NU_OS_DRVR_SDIO_HOST_HCD_ENABLE
+#undef CFG_NU_OS_DRVR_I2C_ENABLE
+#define CFG_NU_OS_DRVR_SERIAL_ENABLE
+#define CFG_NU_OS_DRVR_SERIAL_RUNLEVEL 5
+#define CFG_NU_OS_DRVR_SERIAL_BLOCKING_SUPPORT 1
+#define CFG_NU_OS_DRVR_SERIAL_MAX_DEVS_SUPPORTED 4
+#undef CFG_NU_OS_DRVR_SPI_ENABLE
+#undef CFG_NU_OS_DRVR_LWSPI_ENABLE
+#undef CFG_NU_OS_DRVR_SYSLOGGER_ENABLE
+#undef CFG_NU_OS_DRVR_PPP_ENABLE
+#undef CFG_NU_OS_DRVR_TOUCHPANEL_ENABLE
+#define CFG_NU_OS_DRVR_CPU_ENABLE
+#define CFG_NU_OS_DRVR_CPU_VOLTAGE_SCALING 0
+#undef CFG_NU_OS_DRVR_HIBERNATE_ENABLE
+#undef CFG_NU_OS_DRVR_DISPLAY_ENABLE
+#undef CFG_NU_OS_DRVR_KEYPAD_ENABLE
+#undef CFG_NU_OS_DRVR_PWR_INTRF_ENABLE
+#undef CFG_NU_OS_DRVR_CAN_ENABLE
+#undef CFG_NU_OS_DRVR_DMA_ENABLE
+#undef CFG_NU_OS_DRVR_RTC_ENABLE
+#undef CFG_NU_OS_DRVR_FAT_RD_ENABLE
+#undef CFG_NU_OS_DRVR_ETH_ENABLE
+#define CFG_NU_OS_SVCS_ENABLE
+#undef CFG_NU_OS_SVCS_TRACE_ENABLE
+#undef CFG_NU_OS_SVCS_TRACE_CORE_ENABLE
+#undef CFG_NU_OS_SVCS_TRACE_COMMS_ENABLE
+#undef CFG_NU_OS_SVCS_PWR_ENABLE
+#undef CFG_NU_OS_SVCS_PWR_CORE_ENABLE
+#undef CFG_NU_OS_SVCS_POSIX_ENABLE
+#undef CFG_NU_OS_SVCS_POSIX_AIO_ENABLE
+#undef CFG_NU_OS_SVCS_POSIX_RTL_ENABLE
+#undef CFG_NU_OS_SVCS_POSIX_NET_ENABLE
+#undef CFG_NU_OS_SVCS_POSIX_FS_ENABLE
+#undef CFG_NU_OS_SVCS_POSIX_CORE_ENABLE
+#undef CFG_NU_OS_SVCS_SHELL_ENABLE
+#define CFG_NU_OS_SVCS_REGISTRY_ENABLE
+#define CFG_NU_OS_SVCS_REGISTRY_EXPORT_SYMBOLS 1
+#define CFG_NU_OS_SVCS_INIT_ENABLE
+#undef CFG_NU_OS_SVCS_CXX_ENABLE
+#undef CFG_NU_OS_SVCS_DBG_ENABLE
+#undef CFG_NU_OS_SVCS_SYSLOG_ENABLE
+#define CFG_NU_OS_SVCS_APPINIT_ENABLE
+#define CFG_NU_OS_SVCS_APPINIT_RUNLEVEL 31
+#undef CFG_NU_OS_SVCS_DBG_ADV_ENABLE
+#define CFG_NU_OS_KERN_ENABLE
+#undef CFG_NU_OS_KERN_PROCESS_ENABLE
+#undef CFG_NU_OS_KERN_PROCESS_MEM_MGMT_ENABLE
+#undef CFG_NU_OS_KERN_PROCESS_SHELL_ENABLE
+#undef CFG_NU_OS_KERN_PROCESS_USER_ENABLE
+#undef CFG_NU_OS_KERN_PROCESS_LINKLOAD_ENABLE
+#undef CFG_NU_OS_KERN_PROCESS_CORE_ENABLE
+#define CFG_NU_OS_KERN_PLUS_ENABLE
+#define CFG_NU_OS_KERN_PLUS_CORE_ENABLE
+#define CFG_NU_OS_KERN_PLUS_CORE_MIN_STACK_SIZE 250
+#define CFG_NU_OS_KERN_PLUS_CORE_STACK_CHECKING 0
+#define CFG_NU_OS_KERN_PLUS_CORE_STACK_FILL 0
+#define CFG_NU_OS_KERN_PLUS_CORE_ERROR_CHECKING 1
+#define CFG_NU_OS_KERN_PLUS_CORE_ASSERT 0
+#define CFG_NU_OS_KERN_PLUS_CORE_ERROR_STRING 0
+#define CFG_NU_OS_KERN_PLUS_CORE_GLOBAL_INT_LOCKING 0
+#define CFG_NU_OS_KERN_PLUS_CORE_MIN_RAM 0
+#define CFG_NU_OS_KERN_PLUS_CORE_TICK_SUPPRESSION 0
+#define CFG_NU_OS_KERN_PLUS_CORE_INLINING 0
+#define CFG_NU_OS_KERN_PLUS_CORE_ROM_TO_RAM_COPY 0
+#define CFG_NU_OS_KERN_PLUS_CORE_ROM_SUPPORT 0
+#define CFG_NU_OS_KERN_PLUS_CORE_NUM_TASK_PRIORITIES 256
+#define CFG_NU_OS_KERN_PLUS_CORE_LV_TIMEOUT 0
+#define CFG_NU_OS_KERN_PLUS_CORE_AUTO_CLEAR_CB 1
+#define CFG_NU_OS_KERN_PLUS_CORE_TIMER_HISR_STACK_SIZE 2048
+#define CFG_NU_OS_KERN_PLUS_CORE_TICKS_PER_SEC 100
+#define CFG_NU_OS_KERN_PLUS_CORE_EXPORT_SYMBOLS 1
+#define CFG_NU_OS_KERN_PLUS_CORE_DEBUG_SCHED_LOCK 0
+#define CFG_NU_OS_KERN_PLUS_SUPPLEMENT_ENABLE
+#define CFG_NU_OS_KERN_PLUS_SUPPLEMENT_PLUS_OBJECT_LISTS 0
+#define CFG_NU_OS_KERN_PLUS_SUPPLEMENT_TIME_TEST1MIN 0
+#define CFG_NU_OS_KERN_PLUS_SUPPLEMENT_TIME_TEST1MAX 0
+#define CFG_NU_OS_KERN_PLUS_SUPPLEMENT_TIME_TEST2 0
+#define CFG_NU_OS_KERN_PLUS_SUPPLEMENT_TIME_TEST3 0
+#define CFG_NU_OS_KERN_PLUS_SUPPLEMENT_STATIC_TEST 0
+#define CFG_NU_OS_KERN_PLUS_SUPPLEMENT_EVT_NOTIFY 1
+#define CFG_NU_OS_KERN_PLUS_SUPPLEMENT_EXPORT_SYMBOLS 1
+#undef CFG_NU_OS_KERN_IPC_ENABLE
+#undef CFG_NU_OS_KERN_IPC_MCAPI_ENABLE
+#undef CFG_NU_OS_KERN_IPC_MCAPI_SHM_ENABLE
+#define CFG_NU_OS_KERN_RTL_ENABLE
+#define CFG_NU_OS_KERN_RTL_MALLOC_POOL 0
+#define CFG_NU_OS_KERN_RTL_FP_OVERRIDE 0
+#define CFG_NU_OS_KERN_RTL_HEAP_SIZE 512
+#define CFG_NU_OS_KERN_RTL_EXPORT_SYMBOLS 1
+#define CFG_NU_OS_KERN_EQM_ENABLE
+#define CFG_NU_OS_KERN_DEVMGR_ENABLE
+#define CFG_NU_OS_KERN_DEVMGR_RUNLEVEL 1
+#define CFG_NU_OS_KERN_DEVMGR_MAX_DEV_LABEL_CNT 5
+#define CFG_NU_OS_KERN_DEVMGR_MAX_DEV_SESSION_CNT 3
+#define CFG_NU_OS_KERN_DEVMGR_MAX_DEVICE_LISTENERS 15
+#define CFG_NU_OS_KERN_DEVMGR_ERR_CHECK_ENABLE 1
+#define CFG_NU_OS_KERN_DEVMGR_DISCOVERY_TASK_ENABLE 1
+#define CFG_NU_OS_KERN_DEVMGR_DISCOVERY_TASK_MAX_ID_CNT 30
+#define CFG_NU_OS_KERN_DEVMGR_DISCOVERY_TASK_STACK_SIZE 10240
+#define CFG_NU_OS_KERN_DEVMGR_EXPORT_SYMBOLS 1
+#undef CFG_NU_OS_UI_ENABLE
+#undef CFG_NU_OS_UI_IFX_ENABLE
+#undef CFG_NU_OS_UI_IFX_MOD_ENABLE
+#undef CFG_NU_OS_UI_IFX_MOD_SIMPLEEDIT_ENABLE
+#undef CFG_NU_OS_UI_IFX_FRAMEWORK_ENABLE
+#undef CFG_NU_OS_UI_IFX_ENG_ENABLE
+#undef CFG_NU_OS_UI_IFX_PORT_ENABLE
+#undef CFG_NU_OS_UI_IFX_UCDN_ENABLE
+#undef CFG_NU_OS_UI_IFX_HARFBUZZ_ENABLE
+#undef CFG_NU_OS_UI_IFX_FREETYPE_ENABLE
+#undef CFG_NU_OS_UI_IFX_NUBIDI_ENABLE
+#undef CFG_NU_OS_UI_IMAGE_ENABLE
+#undef CFG_NU_OS_UI_INPUT_MGMT_ENABLE
+#undef CFG_NU_OS_UI_GRAFIXRS_ENABLE
+#undef CFG_NU_OS_STOR_ENABLE
+#undef CFG_NU_OS_STOR_FILE_ENABLE
+#undef CFG_NU_OS_STOR_FILE_FS_ENABLE
+#undef CFG_NU_OS_STOR_FILE_FS_FAT_ENABLE
+#undef CFG_NU_OS_STOR_FILE_FS_SAFE_ENABLE
+#undef CFG_NU_OS_STOR_FILE_SHELL_ENABLE
+#undef CFG_NU_OS_STOR_FILE_VFS_ENABLE
+#undef CFG_NU_OS_STOR_DB_ENABLE
+#undef CFG_NU_OS_STOR_DB_SQLITE_ENABLE
+#define CFG_NU_OS_ARCH_ENABLE
+#define CFG_NU_OS_ARCH_ARM_ENABLE
+#undef CFG_NU_OS_ARCH_ARM_PROCESS_ENABLE
+#undef CFG_NU_OS_ARCH_ARM_PROCESS_MEM_MGMT_ENABLE
+#undef CFG_NU_OS_ARCH_ARM_PROCESS_LINKLOAD_ENABLE
+#undef CFG_NU_OS_ARCH_ARM_PROCESS_CORE_ENABLE
+#define CFG_NU_OS_ARCH_ARM_CSGNU_ENABLE
+#define CFG_NU_OS_ARCH_ARM_COM_ENABLE
+#define CFG_NU_OS_ARCH_ARM_COM_MMU_VARIANT 1
+#define CFG_NU_OS_ARCH_ARM_COM_SYSTEM_STACK_SIZE 2048
+#define CFG_NU_OS_ARCH_ARM_COM_FPU_SUPPORT 2
+#define CFG_NU_OS_ARCH_ARM_COM_V6V7_CACHE_LINE_SIZE 64
+#define CFG_NU_BSP_ENABLE
+#define CFG_NU_BSP_DRVR_ENABLE
+#define CFG_NU_BSP_DRVR_SERIAL_ENABLE
+#define CFG_NU_BSP_DRVR_SERIAL_ZYNQ_UART_ENABLE
+#undef CFG_NU_BSP_DRVR_CPU_ENABLE
+#define CFG_NU_BSP_DRVR_CPU_ZYNQ7000_ENABLE
+#undef CFG_NU_BSP_DRVR_CAN_ENABLE
+#undef CFG_NU_BSP_DRVR_CAN_ZYNQ_CAN_ENABLE
+#undef CFG_NU_BSP_DRVR_ETHERNET_ENABLE
+#undef CFG_NU_BSP_DRVR_ETHERNET_ZYNQ_ETH_ENABLE
+#define CFG_NU_BSP_ZC702EVK_ENABLE
+#define CFG_NU_BSP_ZC702EVK_AMP_REMOTE 0
+#define CFG_NU_BSP_ARCH_ENABLE
+#define CFG_ZC702EVK_ENABLE
+#define CFG_ZC702EVK_SERIAL0_ENABLE
+#define CFG_ZC702EVK_SERIAL0_RUNLEVEL 11
+#define CFG_ZC702EVK_CPU0_ENABLE
+#define CFG_ZC702EVK_CPU0_RUNLEVEL 2
+#undef CFG_ZC702EVK_CAN0_ENABLE
+#undef CFG_ZC702EVK_ETHERNET0_ENABLE
+#define CFG_ZC702EVK_REMOTE_PROC0_ENABLE
+#define CFG_ZC702EVK_REMOTE_PROC1_ENABLE
+#undef CFG_ZC702EVK_RAMDISK0_ENABLE
+#endif /* NUCLEUS_GEN_CFG_H */
diff --git a/libs/system/zc702evk/nucleus/lib/arm-none-eabi-/remote/libnucleus_remote.a b/libs/system/zc702evk/nucleus/lib/arm-none-eabi-/remote/libnucleus_remote.a
new file mode 100644 (file)
index 0000000..711a156
Binary files /dev/null and b/libs/system/zc702evk/nucleus/lib/arm-none-eabi-/remote/libnucleus_remote.a differ
index 0000000..711a156
Binary files /dev/null and b/libs/system/zc702evk/nucleus/lib/arm-none-eabi-/remote/libnucleus_remote.a differ
diff --git a/libs/system/zc702evk/nucleus/lib/arm-none-eabi-/remote/nucleus_gen_cfg.h b/libs/system/zc702evk/nucleus/lib/arm-none-eabi-/remote/nucleus_gen_cfg.h
--- /dev/null
@@ -0,0 +1,346 @@
+/***********************************************************************
+*
+* Copyright 1993 Mentor Graphics Corporation
+* All Rights Reserved.
+*
+* THIS WORK CONTAINS TRADE SECRET AND PROPRIETARY INFORMATION WHICH IS
+* THE PROPERTY OF MENTOR GRAPHICS CORPORATION OR ITS LICENSORS AND IS
+* SUBJECT TO LICENSE TERMS.
+*
+************************************************************************
+
+************************************************************************
+*
+* FILE NAME
+*
+* nucleus_gen_cfg.h
+*
+* COMPONENT
+*
+* Nucleus OS
+*
+* DESCRIPTION
+*
+* This file contains auto-generated configuration settings for
+* the Nucleus OS. DO NOT MODIFY.
+*
+* DATA STRUCTURES
+*
+* None
+*
+* DEPENDENCIES
+*
+* None
+*
+************************************************************************/
+/* Generated: Thu Sep 25 15:23:04 +0500 2014 */
+/* DO NOT MODIFY - This file is auto-generated */
+#ifndef NUCLEUS_GEN_CFG_H
+#define NUCLEUS_GEN_CFG_H
+#define CFG_NU_OS_SVCS_REGISTRY_MAX_KEY_LEN 49
+#define CFG_TOOLSETS_ENABLE
+#define CFG_TOOLSETS_ZC702EVK_ENABLE
+#define CFG_TOOLSETS_ZC702EVK_CSGNU_ARM_ENABLE
+#define CFG_TOOLSETS_ZC702EVK_CSGNU_ARM_ARCH_CFLAGS "-gdwarf-2 -mthumb-interwork -mcpu=cortex-a9"
+#define CFG_TOOLSETS_ZC702EVK_CSGNU_ARM_ARCH_CXXFLAGS "-gdwarf-2 -mthumb-interwork -mcpu=cortex-a9"
+#define CFG_TOOLSETS_ZC702EVK_CSGNU_ARM_ARCH_ASFLAGS "-gdwarf2 -meabi=4 -mcpu=cortex-a9 -mfpu=neon"
+#define CFG_TOOLSETS_ZC702EVK_CSGNU_ARM_ARCH_LDFLAGS ""
+#define CFG_TOOLSETS_ZC702EVK_CSGNU_ARM_ARCH_LDSCRIPT "$(TOOLSETS_HOME)/csgnu_arm.zc702evk.link_ram.ld"
+#define CFG_TOOLSETS_ZC702EVK_CSGNU_ARM_ARCH_ARFLAGS ""
+#define CFG_TOOLSETS_CSGNU_ARM_ENABLE
+#define CFG_TOOLSETS_CSGNU_ARM_CROSS "arm-none-eabi-"
+#define CFG_TOOLSETS_CSGNU_ARM_CC "$(CROSS)gcc"
+#define CFG_TOOLSETS_CSGNU_ARM_CFLAGS "-Wall -ffunction-sections -fdata-sections"
+#define CFG_TOOLSETS_CSGNU_ARM_PROC_CFLAGS "-Wall -ffunction-sections -fdata-sections -fPIC -DNU_PROCESS"
+#define CFG_TOOLSETS_CSGNU_ARM_COMPILE "$(CC) $(patsubst %, -isystem %, $(SYSTEM_INCLUDE_PATH)) $(patsubst %, -I%, $(INCLUDE_PATH)) -I. -Wp,-MD,$(2:.o=.d.tmp) -c $(CFLAGS) $(ARCH_CFLAGS) $(CFLAGS_$(1)) $(1) -o $(2)"
+#define CFG_TOOLSETS_CSGNU_ARM_PROC_COMPILE "$(CC) $(patsubst %, -I%, $(INCLUDE_PATH)) -I. -Wp,-MD,$(2:.po=.pd.tmp) -c $(PROC_CFLAGS) $(ARCH_CFLAGS) $(CFLAGS_$(1)) $(1) -o $(2)"
+#define CFG_TOOLSETS_CSGNU_ARM_CXX "$(CROSS)g++"
+#define CFG_TOOLSETS_CSGNU_ARM_CXXFLAGS "-Wall -fno-enforce-eh-specs"
+#define CFG_TOOLSETS_CSGNU_ARM_PROC_CXXFLAGS "-Wall -fno-enforce-eh-specs -fPIC -DNU_PROCESS"
+#define CFG_TOOLSETS_CSGNU_ARM_COMPILECXX "$(CXX) $(patsubst %, -isystem %, $(SYSTEM_INCLUDE_PATH)) $(patsubst %, -I%, $(INCLUDE_PATH)) -I. -Wp,-MD,$(2:.o=.d.tmp) -c $(CXXFLAGS) $(ARCH_CXXFLAGS) $(CXXFLAGS_$(1)) $(1) -o $(2)"
+#define CFG_TOOLSETS_CSGNU_ARM_PROC_COMPILECXX "$(CXX) $(patsubst %, -I%, $(INCLUDE_PATH)) -I. -Wp,-MD,$(2:.po=.pd.tmp) -c $(PROC_CXXFLAGS) $(ARCH_CXXFLAGS) $(CXXFLAGS_$(1)) $(1) -o $(2)"
+#define CFG_TOOLSETS_CSGNU_ARM_AS "$(CROSS)as"
+#define CFG_TOOLSETS_CSGNU_ARM_ASFLAGS ""
+#define CFG_TOOLSETS_CSGNU_ARM_PROC_ASFLAGS ""
+#define CFG_TOOLSETS_CSGNU_ARM_ASSEMBLE "$(AS) $(patsubst %, -I%, $(INCLUDE_PATH)) -I. --MD $(2:.o=.d.tmp) $(ASFLAGS) $(ARCH_ASFLAGS) $(ASFLAGS_$(1)) $(1) -o $(2)"
+#define CFG_TOOLSETS_CSGNU_ARM_CPPASSEMBLE "$(CC) $(patsubst %, -I%, $(INCLUDE_PATH)) -I. -Wp,-MD,$(2:.o=.d.tmp) $(addprefix -Wa$(comma),$(ASFLAGS)) $(addprefix -Wa$(comma),$(ARCH_ASFLAGS)) $(addprefix -Wa$(comma),$(ASFLAGS_$(1))) -c -x assembler-with-cpp $(1) -o $(2)"
+#define CFG_TOOLSETS_CSGNU_ARM_PROC_ASSEMBLE "$(AS) $(patsubst %, -I%, $(INCLUDE_PATH)) -I. --MD $(2:.po=.pd.tmp) $(ASFLAGS) $(ARCH_ASFLAGS) $(ASFLAGS_$(1)) $(1) -o $(2)"
+#define CFG_TOOLSETS_CSGNU_ARM_PROC_CPPASSEMBLE "$(CC) $(patsubst %, -I%, $(INCLUDE_PATH)) -I. -Wp,-MD,$(2:.po=.pd.tmp) $(addprefix -Wa$(comma),$(ASFLAGS)) $(addprefix -Wa$(comma),$(ARCH_ASFLAGS)) $(addprefix -Wa$(comma),$(ASFLAGS_$(1))) -c $(1) -o $(2)"
+#define CFG_TOOLSETS_CSGNU_ARM_LD "$(CROSS)gcc"
+#define CFG_TOOLSETS_CSGNU_ARM_LDFLAGS "-nostartfiles -Wl,--gc-sections -Wl,--wrap=malloc -Wl,--wrap=calloc -Wl,--wrap=realloc -Wl,--wrap=free -Wl,--defsym -Wl,PAGE_SIZE=$(PAGE_SIZE)"
+#define CFG_TOOLSETS_CSGNU_ARM_PROC_LDFLAGS "-nostdlib -nostartfiles -Wl,--gc-sections -Wl,-pie -Wl,--warn-unresolved-symbols -Wl,--no-demangle -Wl,--nmagic -Wl,--defsym -Wl,PAGE_SIZE=$(PAGE_SIZE) -Wl,--defsym -Wl,NUCLEUS_VERSION=$(NUCLEUS_VERSION)"
+#define CFG_TOOLSETS_CSGNU_ARM_PROC_LDSCRIPT "$(SYSTEM_HOME)/os/toolset/csgnu_arm.process.ld"
+#define CFG_TOOLSETS_CSGNU_ARM_LINK "$(LD) -Wl,-Map=$(basename $(1)).map -o $(1) $(LDFLAGS) $(ARCH_LDFLAGS) $(LDFLAGS_$(notdir $(1))) -T$(LDSCRIPT_$(notdir $(1))) -Wl,--start-group $(2) -lc -lm -lstdc++ -Wl,--end-group"
+#define CFG_TOOLSETS_CSGNU_ARM_PROC_LINK "$(CROSS)nuproclink $(LD) $(basename $(1)).out $(basename $(1)).map -Wl,-Map=$(basename $(1)).map -o $(basename $(1)).out $(PROC_LDFLAGS) $(ARCH_PROC_LDFLAGS) $(LDFLAGS_$(notdir $(1))) -T$(PROC_LDSCRIPT) -Wl,--start-group @$(2) @$(3) -lstdc++ -lgcc -Wl,--end-group"
+#define CFG_TOOLSETS_CSGNU_ARM_AR "$(CROSS)ar"
+#define CFG_TOOLSETS_CSGNU_ARM_ARFLAGS ""
+#define CFG_TOOLSETS_CSGNU_ARM_ARCHIVE "$(AR) $(ARFLAGS) $(ARCH_ARFLAGS) -rc $(1) $(2)"
+#define CFG_TOOLSETS_CSGNU_ARM_POSTLD "$(CROSS)objcopy"
+#define CFG_TOOLSETS_CSGNU_ARM_PROC_POSTLD "$(CROSS)strip"
+#define CFG_TOOLSETS_CSGNU_ARM_POSTLINK "$(POSTLD) -O binary $(1) $(basename $(1)).bin"
+#define CFG_TOOLSETS_CSGNU_ARM_PROC_POSTLINK "$(PROC_POSTLD) -g --strip-unneeded -R .interp -R .dynamic -R .comment $(basename $(1)).out -o $(1)"
+#define CFG_NU_ENABLE
+#define CFG_NU_MAJOR_VERSION 2013
+#define CFG_NU_MINOR_VERSION 8
+#define CFG_NU_PATCH_VERSION 1
+#define CFG_NU_OS_ENABLE
+#undef CFG_NU_OS_NET_ENABLE
+#undef CFG_NU_OS_NET_SSL_ENABLE
+#undef CFG_NU_OS_NET_SSL_OPENSSL_ENABLE
+#undef CFG_NU_OS_NET_SSL_OPENSSL_SSL_ENABLE
+#undef CFG_NU_OS_NET_SSL_OPENSSL_CRYPTO_ENABLE
+#undef CFG_NU_OS_NET_SSL_OPENSSL_OPENSSL_UNIT_TESTS_ENABLE
+#undef CFG_NU_OS_NET_SSL_LITE_ENABLE
+#undef CFG_NU_OS_NET_DHCP_ENABLE
+#undef CFG_NU_OS_NET_DHCP_SERVER_ENABLE
+#undef CFG_NU_OS_NET_PROT_ENABLE
+#undef CFG_NU_OS_NET_PROT_TELNET_ENABLE
+#undef CFG_NU_OS_NET_PROT_TELNET_SHELL_ENABLE
+#undef CFG_NU_OS_NET_PROT_TELNET_SERVER_ENABLE
+#undef CFG_NU_OS_NET_PROT_TELNET_CORE_ENABLE
+#undef CFG_NU_OS_NET_PROT_TELNET_CLIENT_ENABLE
+#undef CFG_NU_OS_NET_PROT_TFTP_ENABLE
+#undef CFG_NU_OS_NET_PROT_TFTP_SHELL_ENABLE
+#undef CFG_NU_OS_NET_PROT_TFTP_SERVER_ENABLE
+#undef CFG_NU_OS_NET_PROT_TFTP_CLIENT_ENABLE
+#undef CFG_NU_OS_NET_PROT_FTP_ENABLE
+#undef CFG_NU_OS_NET_EMAIL_ENABLE
+#undef CFG_NU_OS_NET_EMAIL_SMTPC_ENABLE
+#undef CFG_NU_OS_NET_WPA_SUPP_ENABLE
+#undef CFG_NU_OS_NET_WPA_SUPP_SRC_ENABLE
+#undef CFG_NU_OS_NET_SSH_ENABLE
+#undef CFG_NU_OS_NET_SSH_LIBTOMMATH_ENABLE
+#undef CFG_NU_OS_NET_SSH_LIBTOMCRYPT_ENABLE
+#undef CFG_NU_OS_NET_SSH_DB_SSHSERVER_ENABLE
+#undef CFG_NU_OS_NET_SHELL_ENABLE
+#undef CFG_NU_OS_NET_SNMP_ENABLE
+#undef CFG_NU_OS_NET_SNTPC_ENABLE
+#undef CFG_NU_OS_NET_JSON_ENABLE
+#undef CFG_NU_OS_NET_STACK_ENABLE
+#undef CFG_NU_OS_NET_IPV6_ENABLE
+#undef CFG_NU_OS_NET_WEB_ENABLE
+#undef CFG_NU_OS_NET_NAT_ENABLE
+#undef CFG_NU_OS_NET_WSOX_ENABLE
+#undef CFG_NU_OS_NET_HTTP_ENABLE
+#undef CFG_NU_OS_NET_IKE_ENABLE
+#undef CFG_NU_OS_NET_IPSEC_ENABLE
+#undef CFG_NU_OS_CONN_ENABLE
+#undef CFG_NU_OS_CONN_USB_ENABLE
+#undef CFG_NU_OS_CONN_USB_FUNC_ENABLE
+#undef CFG_NU_OS_CONN_USB_FUNC_HID_ENABLE
+#undef CFG_NU_OS_CONN_USB_FUNC_HID_MSE_ENABLE
+#undef CFG_NU_OS_CONN_USB_FUNC_HID_CLASS_ENABLE
+#undef CFG_NU_OS_CONN_USB_FUNC_HID_KBD_ENABLE
+#undef CFG_NU_OS_CONN_USB_FUNC_COMM_ENABLE
+#undef CFG_NU_OS_CONN_USB_FUNC_COMM_CLASS_ENABLE
+#undef CFG_NU_OS_CONN_USB_FUNC_COMM_MDM_ENABLE
+#undef CFG_NU_OS_CONN_USB_FUNC_COMM_ETH_ENABLE
+#undef CFG_NU_OS_CONN_USB_FUNC_MS_ENABLE
+#undef CFG_NU_OS_CONN_USB_FUNC_MS_CLASS_ENABLE
+#undef CFG_NU_OS_CONN_USB_FUNC_MS_USER_ENABLE
+#undef CFG_NU_OS_CONN_USB_FUNC_DFU_ENABLE
+#undef CFG_NU_OS_CONN_USB_FUNC_STACK_ENABLE
+#undef CFG_NU_OS_CONN_USB_COM_ENABLE
+#undef CFG_NU_OS_CONN_USB_COM_STACK_ENABLE
+#undef CFG_NU_OS_CONN_USB_HOST_ENABLE
+#undef CFG_NU_OS_CONN_USB_HOST_COMM_ENABLE
+#undef CFG_NU_OS_CONN_USB_HOST_COMM_CLASS_ENABLE
+#undef CFG_NU_OS_CONN_USB_HOST_COMM_MDM_ENABLE
+#undef CFG_NU_OS_CONN_USB_HOST_COMM_ETH_ENABLE
+#undef CFG_NU_OS_CONN_USB_HOST_MS_ENABLE
+#undef CFG_NU_OS_CONN_USB_HOST_MS_CLASS_ENABLE
+#undef CFG_NU_OS_CONN_USB_HOST_MS_USER_ENABLE
+#undef CFG_NU_OS_CONN_USB_HOST_AUDIO_ENABLE
+#undef CFG_NU_OS_CONN_USB_HOST_AUDIO_CLASS_ENABLE
+#undef CFG_NU_OS_CONN_USB_HOST_AUDIO_USER_ENABLE
+#undef CFG_NU_OS_CONN_USB_HOST_HID_ENABLE
+#undef CFG_NU_OS_CONN_USB_HOST_HID_MOUSE_ENABLE
+#undef CFG_NU_OS_CONN_USB_HOST_HID_CLASS_ENABLE
+#undef CFG_NU_OS_CONN_USB_HOST_HID_KEYBOARD_ENABLE
+#undef CFG_NU_OS_CONN_USB_HOST_STACK_ENABLE
+#undef CFG_NU_OS_CONN_SDIO_ENABLE
+#undef CFG_NU_OS_CONN_I2C_ENABLE
+#undef CFG_NU_OS_CONN_SPI_ENABLE
+#undef CFG_NU_OS_CONN_LWSPI_ENABLE
+#undef CFG_NU_OS_CONN_CAN_ENABLE
+#define CFG_NU_OS_DRVR_ENABLE
+#undef CFG_NU_OS_DRVR_WLAN_ENABLE
+#undef CFG_NU_OS_DRVR_WLAN_AR4100_ENABLE
+#undef CFG_NU_OS_DRVR_WLAN_AR6K3_ENABLE
+#undef CFG_NU_OS_DRVR_WLAN_AR6K2_ENABLE
+#undef CFG_NU_OS_DRVR_USB_ENABLE
+#undef CFG_NU_OS_DRVR_USB_FUNC_ENABLE
+#undef CFG_NU_OS_DRVR_USB_FUNC_NET_IF_ENABLE
+#undef CFG_NU_OS_DRVR_USB_FUNC_HWCTRL_ENABLE
+#undef CFG_NU_OS_DRVR_USB_HOST_ENABLE
+#undef CFG_NU_OS_DRVR_USB_HOST_FILE_IF_ENABLE
+#undef CFG_NU_OS_DRVR_USB_HOST_NET_IF_ENABLE
+#undef CFG_NU_OS_DRVR_USB_HOST_OHCI_ENABLE
+#undef CFG_NU_OS_DRVR_USB_HOST_EHCI_ENABLE
+#undef CFG_NU_OS_DRVR_USB_HOST_USB_INPUT_ENABLE
+#undef CFG_NU_OS_DRVR_USB_HOST_HWCTRL_ENABLE
+#undef CFG_NU_OS_DRVR_USB_HOST_XHCI_ENABLE
+#undef CFG_NU_OS_DRVR_USB_OTG_ENABLE
+#undef CFG_NU_OS_DRVR_USB_OTG_HWCTRL_ENABLE
+#undef CFG_NU_OS_DRVR_SAFE_ENABLE
+#undef CFG_NU_OS_DRVR_SAFE_SRA_ENABLE
+#undef CFG_NU_OS_DRVR_SAFE_BASE_ENABLE
+#undef CFG_NU_OS_DRVR_SDIO_ENABLE
+#undef CFG_NU_OS_DRVR_SDIO_FUNC_ENABLE
+#undef CFG_NU_OS_DRVR_SDIO_FUNC_SD_ENABLE
+#undef CFG_NU_OS_DRVR_SDIO_HOST_ENABLE
+#undef CFG_NU_OS_DRVR_SDIO_HOST_HCD_ENABLE
+#undef CFG_NU_OS_DRVR_I2C_ENABLE
+#undef CFG_NU_OS_DRVR_SERIAL_ENABLE
+#undef CFG_NU_OS_DRVR_SPI_ENABLE
+#undef CFG_NU_OS_DRVR_LWSPI_ENABLE
+#undef CFG_NU_OS_DRVR_SYSLOGGER_ENABLE
+#undef CFG_NU_OS_DRVR_PPP_ENABLE
+#undef CFG_NU_OS_DRVR_TOUCHPANEL_ENABLE
+#define CFG_NU_OS_DRVR_CPU_ENABLE
+#define CFG_NU_OS_DRVR_CPU_VOLTAGE_SCALING 0
+#undef CFG_NU_OS_DRVR_HIBERNATE_ENABLE
+#undef CFG_NU_OS_DRVR_DISPLAY_ENABLE
+#undef CFG_NU_OS_DRVR_KEYPAD_ENABLE
+#undef CFG_NU_OS_DRVR_PWR_INTRF_ENABLE
+#undef CFG_NU_OS_DRVR_CAN_ENABLE
+#undef CFG_NU_OS_DRVR_DMA_ENABLE
+#undef CFG_NU_OS_DRVR_RTC_ENABLE
+#undef CFG_NU_OS_DRVR_FAT_RD_ENABLE
+#undef CFG_NU_OS_DRVR_ETH_ENABLE
+#define CFG_NU_OS_SVCS_ENABLE
+#undef CFG_NU_OS_SVCS_TRACE_ENABLE
+#undef CFG_NU_OS_SVCS_TRACE_CORE_ENABLE
+#undef CFG_NU_OS_SVCS_TRACE_COMMS_ENABLE
+#undef CFG_NU_OS_SVCS_PWR_ENABLE
+#undef CFG_NU_OS_SVCS_PWR_CORE_ENABLE
+#undef CFG_NU_OS_SVCS_POSIX_ENABLE
+#undef CFG_NU_OS_SVCS_POSIX_AIO_ENABLE
+#undef CFG_NU_OS_SVCS_POSIX_RTL_ENABLE
+#undef CFG_NU_OS_SVCS_POSIX_NET_ENABLE
+#undef CFG_NU_OS_SVCS_POSIX_FS_ENABLE
+#undef CFG_NU_OS_SVCS_POSIX_CORE_ENABLE
+#undef CFG_NU_OS_SVCS_SHELL_ENABLE
+#define CFG_NU_OS_SVCS_REGISTRY_ENABLE
+#define CFG_NU_OS_SVCS_REGISTRY_EXPORT_SYMBOLS 1
+#define CFG_NU_OS_SVCS_INIT_ENABLE
+#undef CFG_NU_OS_SVCS_CXX_ENABLE
+#undef CFG_NU_OS_SVCS_DBG_ENABLE
+#undef CFG_NU_OS_SVCS_SYSLOG_ENABLE
+#define CFG_NU_OS_SVCS_APPINIT_ENABLE
+#define CFG_NU_OS_SVCS_APPINIT_RUNLEVEL 31
+#undef CFG_NU_OS_SVCS_DBG_ADV_ENABLE
+#define CFG_NU_OS_KERN_ENABLE
+#undef CFG_NU_OS_KERN_PROCESS_ENABLE
+#undef CFG_NU_OS_KERN_PROCESS_MEM_MGMT_ENABLE
+#undef CFG_NU_OS_KERN_PROCESS_SHELL_ENABLE
+#undef CFG_NU_OS_KERN_PROCESS_USER_ENABLE
+#undef CFG_NU_OS_KERN_PROCESS_LINKLOAD_ENABLE
+#undef CFG_NU_OS_KERN_PROCESS_CORE_ENABLE
+#define CFG_NU_OS_KERN_PLUS_ENABLE
+#define CFG_NU_OS_KERN_PLUS_CORE_ENABLE
+#define CFG_NU_OS_KERN_PLUS_CORE_MIN_STACK_SIZE 250
+#define CFG_NU_OS_KERN_PLUS_CORE_STACK_CHECKING 0
+#define CFG_NU_OS_KERN_PLUS_CORE_STACK_FILL 0
+#define CFG_NU_OS_KERN_PLUS_CORE_ERROR_CHECKING 1
+#define CFG_NU_OS_KERN_PLUS_CORE_ASSERT 0
+#define CFG_NU_OS_KERN_PLUS_CORE_ERROR_STRING 0
+#define CFG_NU_OS_KERN_PLUS_CORE_GLOBAL_INT_LOCKING 0
+#define CFG_NU_OS_KERN_PLUS_CORE_MIN_RAM 0
+#define CFG_NU_OS_KERN_PLUS_CORE_TICK_SUPPRESSION 0
+#define CFG_NU_OS_KERN_PLUS_CORE_INLINING 0
+#define CFG_NU_OS_KERN_PLUS_CORE_ROM_TO_RAM_COPY 0
+#define CFG_NU_OS_KERN_PLUS_CORE_ROM_SUPPORT 0
+#define CFG_NU_OS_KERN_PLUS_CORE_NUM_TASK_PRIORITIES 256
+#define CFG_NU_OS_KERN_PLUS_CORE_LV_TIMEOUT 0
+#define CFG_NU_OS_KERN_PLUS_CORE_AUTO_CLEAR_CB 1
+#define CFG_NU_OS_KERN_PLUS_CORE_TIMER_HISR_STACK_SIZE 2048
+#define CFG_NU_OS_KERN_PLUS_CORE_TICKS_PER_SEC 100
+#define CFG_NU_OS_KERN_PLUS_CORE_EXPORT_SYMBOLS 1
+#define CFG_NU_OS_KERN_PLUS_CORE_DEBUG_SCHED_LOCK 0
+#define CFG_NU_OS_KERN_PLUS_SUPPLEMENT_ENABLE
+#define CFG_NU_OS_KERN_PLUS_SUPPLEMENT_PLUS_OBJECT_LISTS 0
+#define CFG_NU_OS_KERN_PLUS_SUPPLEMENT_TIME_TEST1MIN 0
+#define CFG_NU_OS_KERN_PLUS_SUPPLEMENT_TIME_TEST1MAX 0
+#define CFG_NU_OS_KERN_PLUS_SUPPLEMENT_TIME_TEST2 0
+#define CFG_NU_OS_KERN_PLUS_SUPPLEMENT_TIME_TEST3 0
+#define CFG_NU_OS_KERN_PLUS_SUPPLEMENT_STATIC_TEST 0
+#define CFG_NU_OS_KERN_PLUS_SUPPLEMENT_EVT_NOTIFY 1
+#define CFG_NU_OS_KERN_PLUS_SUPPLEMENT_EXPORT_SYMBOLS 1
+#undef CFG_NU_OS_KERN_IPC_ENABLE
+#undef CFG_NU_OS_KERN_IPC_MCAPI_ENABLE
+#undef CFG_NU_OS_KERN_IPC_MCAPI_SHM_ENABLE
+#define CFG_NU_OS_KERN_RTL_ENABLE
+#define CFG_NU_OS_KERN_RTL_MALLOC_POOL 0
+#define CFG_NU_OS_KERN_RTL_FP_OVERRIDE 0
+#define CFG_NU_OS_KERN_RTL_HEAP_SIZE 4096
+#define CFG_NU_OS_KERN_RTL_EXPORT_SYMBOLS 1
+#define CFG_NU_OS_KERN_EQM_ENABLE
+#define CFG_NU_OS_KERN_DEVMGR_ENABLE
+#define CFG_NU_OS_KERN_DEVMGR_RUNLEVEL 1
+#define CFG_NU_OS_KERN_DEVMGR_MAX_DEV_LABEL_CNT 5
+#define CFG_NU_OS_KERN_DEVMGR_MAX_DEV_SESSION_CNT 3
+#define CFG_NU_OS_KERN_DEVMGR_MAX_DEVICE_LISTENERS 15
+#define CFG_NU_OS_KERN_DEVMGR_ERR_CHECK_ENABLE 1
+#define CFG_NU_OS_KERN_DEVMGR_DISCOVERY_TASK_ENABLE 1
+#define CFG_NU_OS_KERN_DEVMGR_DISCOVERY_TASK_MAX_ID_CNT 30
+#define CFG_NU_OS_KERN_DEVMGR_DISCOVERY_TASK_STACK_SIZE 10240
+#define CFG_NU_OS_KERN_DEVMGR_EXPORT_SYMBOLS 1
+#undef CFG_NU_OS_UI_ENABLE
+#undef CFG_NU_OS_UI_IFX_ENABLE
+#undef CFG_NU_OS_UI_IFX_MOD_ENABLE
+#undef CFG_NU_OS_UI_IFX_MOD_SIMPLEEDIT_ENABLE
+#undef CFG_NU_OS_UI_IFX_FRAMEWORK_ENABLE
+#undef CFG_NU_OS_UI_IFX_ENG_ENABLE
+#undef CFG_NU_OS_UI_IFX_PORT_ENABLE
+#undef CFG_NU_OS_UI_IFX_UCDN_ENABLE
+#undef CFG_NU_OS_UI_IFX_HARFBUZZ_ENABLE
+#undef CFG_NU_OS_UI_IFX_FREETYPE_ENABLE
+#undef CFG_NU_OS_UI_IFX_NUBIDI_ENABLE
+#undef CFG_NU_OS_UI_IMAGE_ENABLE
+#undef CFG_NU_OS_UI_INPUT_MGMT_ENABLE
+#undef CFG_NU_OS_UI_GRAFIXRS_ENABLE
+#undef CFG_NU_OS_STOR_ENABLE
+#undef CFG_NU_OS_STOR_FILE_ENABLE
+#undef CFG_NU_OS_STOR_FILE_FS_ENABLE
+#undef CFG_NU_OS_STOR_FILE_FS_FAT_ENABLE
+#undef CFG_NU_OS_STOR_FILE_FS_SAFE_ENABLE
+#undef CFG_NU_OS_STOR_FILE_SHELL_ENABLE
+#undef CFG_NU_OS_STOR_FILE_VFS_ENABLE
+#undef CFG_NU_OS_STOR_DB_ENABLE
+#undef CFG_NU_OS_STOR_DB_SQLITE_ENABLE
+#define CFG_NU_OS_ARCH_ENABLE
+#define CFG_NU_OS_ARCH_ARM_ENABLE
+#undef CFG_NU_OS_ARCH_ARM_PROCESS_ENABLE
+#undef CFG_NU_OS_ARCH_ARM_PROCESS_MEM_MGMT_ENABLE
+#undef CFG_NU_OS_ARCH_ARM_PROCESS_LINKLOAD_ENABLE
+#undef CFG_NU_OS_ARCH_ARM_PROCESS_CORE_ENABLE
+#define CFG_NU_OS_ARCH_ARM_CSGNU_ENABLE
+#define CFG_NU_OS_ARCH_ARM_COM_ENABLE
+#define CFG_NU_OS_ARCH_ARM_COM_MMU_VARIANT 1
+#define CFG_NU_OS_ARCH_ARM_COM_SYSTEM_STACK_SIZE 2048
+#define CFG_NU_OS_ARCH_ARM_COM_FPU_SUPPORT 2
+#define CFG_NU_OS_ARCH_ARM_COM_V6V7_CACHE_LINE_SIZE 64
+#define CFG_NU_BSP_ENABLE
+#undef CFG_NU_BSP_DRVR_ENABLE
+#undef CFG_NU_BSP_DRVR_SERIAL_ENABLE
+#undef CFG_NU_BSP_DRVR_SERIAL_ZYNQ_UART_ENABLE
+#undef CFG_NU_BSP_DRVR_CPU_ENABLE
+#define CFG_NU_BSP_DRVR_CPU_ZYNQ7000_ENABLE
+#undef CFG_NU_BSP_DRVR_CAN_ENABLE
+#undef CFG_NU_BSP_DRVR_CAN_ZYNQ_CAN_ENABLE
+#undef CFG_NU_BSP_DRVR_ETHERNET_ENABLE
+#undef CFG_NU_BSP_DRVR_ETHERNET_ZYNQ_ETH_ENABLE
+#define CFG_NU_BSP_ZC702EVK_ENABLE
+#define CFG_NU_BSP_ZC702EVK_AMP_REMOTE 1
+#define CFG_NU_BSP_ARCH_ENABLE
+#define CFG_ZC702EVK_ENABLE
+#undef CFG_ZC702EVK_SERIAL0_ENABLE
+#define CFG_ZC702EVK_CPU0_ENABLE
+#define CFG_ZC702EVK_CPU0_RUNLEVEL 2
+#undef CFG_ZC702EVK_CAN0_ENABLE
+#undef CFG_ZC702EVK_ETHERNET0_ENABLE
+#define CFG_ZC702EVK_REMOTE_PROC0_ENABLE
+#define CFG_ZC702EVK_REMOTE_PROC1_ENABLE
+#undef CFG_ZC702EVK_RAMDISK0_ENABLE
+#endif /* NUCLEUS_GEN_CFG_H */
diff --git a/libs/system/zc702evk/nucleus/lib/arm-none-eabi-/remote_proxy/libnucleus_remote.a b/libs/system/zc702evk/nucleus/lib/arm-none-eabi-/remote_proxy/libnucleus_remote.a
new file mode 100644 (file)
index 0000000..f973962
Binary files /dev/null and b/libs/system/zc702evk/nucleus/lib/arm-none-eabi-/remote_proxy/libnucleus_remote.a differ
index 0000000..f973962
Binary files /dev/null and b/libs/system/zc702evk/nucleus/lib/arm-none-eabi-/remote_proxy/libnucleus_remote.a differ
diff --git a/libs/system/zc702evk/nucleus/lib/arm-none-eabi-/remote_proxy/nucleus_gen_cfg.h b/libs/system/zc702evk/nucleus/lib/arm-none-eabi-/remote_proxy/nucleus_gen_cfg.h
--- /dev/null
@@ -0,0 +1,346 @@
+/***********************************************************************
+*
+* Copyright 1993 Mentor Graphics Corporation
+* All Rights Reserved.
+*
+* THIS WORK CONTAINS TRADE SECRET AND PROPRIETARY INFORMATION WHICH IS
+* THE PROPERTY OF MENTOR GRAPHICS CORPORATION OR ITS LICENSORS AND IS
+* SUBJECT TO LICENSE TERMS.
+*
+************************************************************************
+
+************************************************************************
+*
+* FILE NAME
+*
+* nucleus_gen_cfg.h
+*
+* COMPONENT
+*
+* Nucleus OS
+*
+* DESCRIPTION
+*
+* This file contains auto-generated configuration settings for
+* the Nucleus OS. DO NOT MODIFY.
+*
+* DATA STRUCTURES
+*
+* None
+*
+* DEPENDENCIES
+*
+* None
+*
+************************************************************************/
+/* Generated: Thu Sep 25 15:25:18 +0500 2014 */
+/* DO NOT MODIFY - This file is auto-generated */
+#ifndef NUCLEUS_GEN_CFG_H
+#define NUCLEUS_GEN_CFG_H
+#define CFG_NU_OS_SVCS_REGISTRY_MAX_KEY_LEN 49
+#define CFG_TOOLSETS_ENABLE
+#define CFG_TOOLSETS_ZC702EVK_ENABLE
+#define CFG_TOOLSETS_ZC702EVK_CSGNU_ARM_ENABLE
+#define CFG_TOOLSETS_ZC702EVK_CSGNU_ARM_ARCH_CFLAGS "-gdwarf-2 -mthumb-interwork -mcpu=cortex-a9"
+#define CFG_TOOLSETS_ZC702EVK_CSGNU_ARM_ARCH_CXXFLAGS "-gdwarf-2 -mthumb-interwork -mcpu=cortex-a9"
+#define CFG_TOOLSETS_ZC702EVK_CSGNU_ARM_ARCH_ASFLAGS "-gdwarf2 -meabi=4 -mcpu=cortex-a9 -mfpu=neon"
+#define CFG_TOOLSETS_ZC702EVK_CSGNU_ARM_ARCH_LDFLAGS ""
+#define CFG_TOOLSETS_ZC702EVK_CSGNU_ARM_ARCH_LDSCRIPT "$(TOOLSETS_HOME)/csgnu_arm.zc702evk.link_ram.ld"
+#define CFG_TOOLSETS_ZC702EVK_CSGNU_ARM_ARCH_ARFLAGS ""
+#define CFG_TOOLSETS_CSGNU_ARM_ENABLE
+#define CFG_TOOLSETS_CSGNU_ARM_CROSS "arm-none-eabi-"
+#define CFG_TOOLSETS_CSGNU_ARM_CC "$(CROSS)gcc"
+#define CFG_TOOLSETS_CSGNU_ARM_CFLAGS "-Wall -ffunction-sections -fdata-sections"
+#define CFG_TOOLSETS_CSGNU_ARM_PROC_CFLAGS "-Wall -ffunction-sections -fdata-sections -fPIC -DNU_PROCESS"
+#define CFG_TOOLSETS_CSGNU_ARM_COMPILE "$(CC) $(patsubst %, -isystem %, $(SYSTEM_INCLUDE_PATH)) $(patsubst %, -I%, $(INCLUDE_PATH)) -I. -Wp,-MD,$(2:.o=.d.tmp) -c $(CFLAGS) $(ARCH_CFLAGS) $(CFLAGS_$(1)) $(1) -o $(2)"
+#define CFG_TOOLSETS_CSGNU_ARM_PROC_COMPILE "$(CC) $(patsubst %, -I%, $(INCLUDE_PATH)) -I. -Wp,-MD,$(2:.po=.pd.tmp) -c $(PROC_CFLAGS) $(ARCH_CFLAGS) $(CFLAGS_$(1)) $(1) -o $(2)"
+#define CFG_TOOLSETS_CSGNU_ARM_CXX "$(CROSS)g++"
+#define CFG_TOOLSETS_CSGNU_ARM_CXXFLAGS "-Wall -fno-enforce-eh-specs"
+#define CFG_TOOLSETS_CSGNU_ARM_PROC_CXXFLAGS "-Wall -fno-enforce-eh-specs -fPIC -DNU_PROCESS"
+#define CFG_TOOLSETS_CSGNU_ARM_COMPILECXX "$(CXX) $(patsubst %, -isystem %, $(SYSTEM_INCLUDE_PATH)) $(patsubst %, -I%, $(INCLUDE_PATH)) -I. -Wp,-MD,$(2:.o=.d.tmp) -c $(CXXFLAGS) $(ARCH_CXXFLAGS) $(CXXFLAGS_$(1)) $(1) -o $(2)"
+#define CFG_TOOLSETS_CSGNU_ARM_PROC_COMPILECXX "$(CXX) $(patsubst %, -I%, $(INCLUDE_PATH)) -I. -Wp,-MD,$(2:.po=.pd.tmp) -c $(PROC_CXXFLAGS) $(ARCH_CXXFLAGS) $(CXXFLAGS_$(1)) $(1) -o $(2)"
+#define CFG_TOOLSETS_CSGNU_ARM_AS "$(CROSS)as"
+#define CFG_TOOLSETS_CSGNU_ARM_ASFLAGS ""
+#define CFG_TOOLSETS_CSGNU_ARM_PROC_ASFLAGS ""
+#define CFG_TOOLSETS_CSGNU_ARM_ASSEMBLE "$(AS) $(patsubst %, -I%, $(INCLUDE_PATH)) -I. --MD $(2:.o=.d.tmp) $(ASFLAGS) $(ARCH_ASFLAGS) $(ASFLAGS_$(1)) $(1) -o $(2)"
+#define CFG_TOOLSETS_CSGNU_ARM_CPPASSEMBLE "$(CC) $(patsubst %, -I%, $(INCLUDE_PATH)) -I. -Wp,-MD,$(2:.o=.d.tmp) $(addprefix -Wa$(comma),$(ASFLAGS)) $(addprefix -Wa$(comma),$(ARCH_ASFLAGS)) $(addprefix -Wa$(comma),$(ASFLAGS_$(1))) -c -x assembler-with-cpp $(1) -o $(2)"
+#define CFG_TOOLSETS_CSGNU_ARM_PROC_ASSEMBLE "$(AS) $(patsubst %, -I%, $(INCLUDE_PATH)) -I. --MD $(2:.po=.pd.tmp) $(ASFLAGS) $(ARCH_ASFLAGS) $(ASFLAGS_$(1)) $(1) -o $(2)"
+#define CFG_TOOLSETS_CSGNU_ARM_PROC_CPPASSEMBLE "$(CC) $(patsubst %, -I%, $(INCLUDE_PATH)) -I. -Wp,-MD,$(2:.po=.pd.tmp) $(addprefix -Wa$(comma),$(ASFLAGS)) $(addprefix -Wa$(comma),$(ARCH_ASFLAGS)) $(addprefix -Wa$(comma),$(ASFLAGS_$(1))) -c $(1) -o $(2)"
+#define CFG_TOOLSETS_CSGNU_ARM_LD "$(CROSS)gcc"
+#define CFG_TOOLSETS_CSGNU_ARM_LDFLAGS "-nostartfiles -Wl,--gc-sections -Wl,--wrap=malloc -Wl,--wrap=calloc -Wl,--wrap=realloc -Wl,--wrap=free -Wl,--defsym -Wl,PAGE_SIZE=$(PAGE_SIZE)"
+#define CFG_TOOLSETS_CSGNU_ARM_PROC_LDFLAGS "-nostdlib -nostartfiles -Wl,--gc-sections -Wl,-pie -Wl,--warn-unresolved-symbols -Wl,--no-demangle -Wl,--nmagic -Wl,--defsym -Wl,PAGE_SIZE=$(PAGE_SIZE) -Wl,--defsym -Wl,NUCLEUS_VERSION=$(NUCLEUS_VERSION)"
+#define CFG_TOOLSETS_CSGNU_ARM_PROC_LDSCRIPT "$(SYSTEM_HOME)/os/toolset/csgnu_arm.process.ld"
+#define CFG_TOOLSETS_CSGNU_ARM_LINK "$(LD) -Wl,-Map=$(basename $(1)).map -o $(1) $(LDFLAGS) $(ARCH_LDFLAGS) $(LDFLAGS_$(notdir $(1))) -T$(LDSCRIPT_$(notdir $(1))) -Wl,--start-group $(2) -lc -lm -lstdc++ -Wl,--end-group"
+#define CFG_TOOLSETS_CSGNU_ARM_PROC_LINK "$(CROSS)nuproclink $(LD) $(basename $(1)).out $(basename $(1)).map -Wl,-Map=$(basename $(1)).map -o $(basename $(1)).out $(PROC_LDFLAGS) $(ARCH_PROC_LDFLAGS) $(LDFLAGS_$(notdir $(1))) -T$(PROC_LDSCRIPT) -Wl,--start-group @$(2) @$(3) -lstdc++ -lgcc -Wl,--end-group"
+#define CFG_TOOLSETS_CSGNU_ARM_AR "$(CROSS)ar"
+#define CFG_TOOLSETS_CSGNU_ARM_ARFLAGS ""
+#define CFG_TOOLSETS_CSGNU_ARM_ARCHIVE "$(AR) $(ARFLAGS) $(ARCH_ARFLAGS) -rc $(1) $(2)"
+#define CFG_TOOLSETS_CSGNU_ARM_POSTLD "$(CROSS)objcopy"
+#define CFG_TOOLSETS_CSGNU_ARM_PROC_POSTLD "$(CROSS)strip"
+#define CFG_TOOLSETS_CSGNU_ARM_POSTLINK "$(POSTLD) -O binary $(1) $(basename $(1)).bin"
+#define CFG_TOOLSETS_CSGNU_ARM_PROC_POSTLINK "$(PROC_POSTLD) -g --strip-unneeded -R .interp -R .dynamic -R .comment $(basename $(1)).out -o $(1)"
+#define CFG_NU_ENABLE
+#define CFG_NU_MAJOR_VERSION 2013
+#define CFG_NU_MINOR_VERSION 8
+#define CFG_NU_PATCH_VERSION 1
+#define CFG_NU_OS_ENABLE
+#undef CFG_NU_OS_NET_ENABLE
+#undef CFG_NU_OS_NET_SSL_ENABLE
+#undef CFG_NU_OS_NET_SSL_OPENSSL_ENABLE
+#undef CFG_NU_OS_NET_SSL_OPENSSL_SSL_ENABLE
+#undef CFG_NU_OS_NET_SSL_OPENSSL_CRYPTO_ENABLE
+#undef CFG_NU_OS_NET_SSL_OPENSSL_OPENSSL_UNIT_TESTS_ENABLE
+#undef CFG_NU_OS_NET_SSL_LITE_ENABLE
+#undef CFG_NU_OS_NET_DHCP_ENABLE
+#undef CFG_NU_OS_NET_DHCP_SERVER_ENABLE
+#undef CFG_NU_OS_NET_PROT_ENABLE
+#undef CFG_NU_OS_NET_PROT_TELNET_ENABLE
+#undef CFG_NU_OS_NET_PROT_TELNET_SHELL_ENABLE
+#undef CFG_NU_OS_NET_PROT_TELNET_SERVER_ENABLE
+#undef CFG_NU_OS_NET_PROT_TELNET_CORE_ENABLE
+#undef CFG_NU_OS_NET_PROT_TELNET_CLIENT_ENABLE
+#undef CFG_NU_OS_NET_PROT_TFTP_ENABLE
+#undef CFG_NU_OS_NET_PROT_TFTP_SHELL_ENABLE
+#undef CFG_NU_OS_NET_PROT_TFTP_SERVER_ENABLE
+#undef CFG_NU_OS_NET_PROT_TFTP_CLIENT_ENABLE
+#undef CFG_NU_OS_NET_PROT_FTP_ENABLE
+#undef CFG_NU_OS_NET_EMAIL_ENABLE
+#undef CFG_NU_OS_NET_EMAIL_SMTPC_ENABLE
+#undef CFG_NU_OS_NET_WPA_SUPP_ENABLE
+#undef CFG_NU_OS_NET_WPA_SUPP_SRC_ENABLE
+#undef CFG_NU_OS_NET_SSH_ENABLE
+#undef CFG_NU_OS_NET_SSH_LIBTOMMATH_ENABLE
+#undef CFG_NU_OS_NET_SSH_LIBTOMCRYPT_ENABLE
+#undef CFG_NU_OS_NET_SSH_DB_SSHSERVER_ENABLE
+#undef CFG_NU_OS_NET_SHELL_ENABLE
+#undef CFG_NU_OS_NET_SNMP_ENABLE
+#undef CFG_NU_OS_NET_SNTPC_ENABLE
+#undef CFG_NU_OS_NET_JSON_ENABLE
+#undef CFG_NU_OS_NET_STACK_ENABLE
+#undef CFG_NU_OS_NET_IPV6_ENABLE
+#undef CFG_NU_OS_NET_WEB_ENABLE
+#undef CFG_NU_OS_NET_NAT_ENABLE
+#undef CFG_NU_OS_NET_WSOX_ENABLE
+#undef CFG_NU_OS_NET_HTTP_ENABLE
+#undef CFG_NU_OS_NET_IKE_ENABLE
+#undef CFG_NU_OS_NET_IPSEC_ENABLE
+#undef CFG_NU_OS_CONN_ENABLE
+#undef CFG_NU_OS_CONN_USB_ENABLE
+#undef CFG_NU_OS_CONN_USB_FUNC_ENABLE
+#undef CFG_NU_OS_CONN_USB_FUNC_HID_ENABLE
+#undef CFG_NU_OS_CONN_USB_FUNC_HID_MSE_ENABLE
+#undef CFG_NU_OS_CONN_USB_FUNC_HID_CLASS_ENABLE
+#undef CFG_NU_OS_CONN_USB_FUNC_HID_KBD_ENABLE
+#undef CFG_NU_OS_CONN_USB_FUNC_COMM_ENABLE
+#undef CFG_NU_OS_CONN_USB_FUNC_COMM_CLASS_ENABLE
+#undef CFG_NU_OS_CONN_USB_FUNC_COMM_MDM_ENABLE
+#undef CFG_NU_OS_CONN_USB_FUNC_COMM_ETH_ENABLE
+#undef CFG_NU_OS_CONN_USB_FUNC_MS_ENABLE
+#undef CFG_NU_OS_CONN_USB_FUNC_MS_CLASS_ENABLE
+#undef CFG_NU_OS_CONN_USB_FUNC_MS_USER_ENABLE
+#undef CFG_NU_OS_CONN_USB_FUNC_DFU_ENABLE
+#undef CFG_NU_OS_CONN_USB_FUNC_STACK_ENABLE
+#undef CFG_NU_OS_CONN_USB_COM_ENABLE
+#undef CFG_NU_OS_CONN_USB_COM_STACK_ENABLE
+#undef CFG_NU_OS_CONN_USB_HOST_ENABLE
+#undef CFG_NU_OS_CONN_USB_HOST_COMM_ENABLE
+#undef CFG_NU_OS_CONN_USB_HOST_COMM_CLASS_ENABLE
+#undef CFG_NU_OS_CONN_USB_HOST_COMM_MDM_ENABLE
+#undef CFG_NU_OS_CONN_USB_HOST_COMM_ETH_ENABLE
+#undef CFG_NU_OS_CONN_USB_HOST_MS_ENABLE
+#undef CFG_NU_OS_CONN_USB_HOST_MS_CLASS_ENABLE
+#undef CFG_NU_OS_CONN_USB_HOST_MS_USER_ENABLE
+#undef CFG_NU_OS_CONN_USB_HOST_AUDIO_ENABLE
+#undef CFG_NU_OS_CONN_USB_HOST_AUDIO_CLASS_ENABLE
+#undef CFG_NU_OS_CONN_USB_HOST_AUDIO_USER_ENABLE
+#undef CFG_NU_OS_CONN_USB_HOST_HID_ENABLE
+#undef CFG_NU_OS_CONN_USB_HOST_HID_MOUSE_ENABLE
+#undef CFG_NU_OS_CONN_USB_HOST_HID_CLASS_ENABLE
+#undef CFG_NU_OS_CONN_USB_HOST_HID_KEYBOARD_ENABLE
+#undef CFG_NU_OS_CONN_USB_HOST_STACK_ENABLE
+#undef CFG_NU_OS_CONN_SDIO_ENABLE
+#undef CFG_NU_OS_CONN_I2C_ENABLE
+#undef CFG_NU_OS_CONN_SPI_ENABLE
+#undef CFG_NU_OS_CONN_LWSPI_ENABLE
+#undef CFG_NU_OS_CONN_CAN_ENABLE
+#define CFG_NU_OS_DRVR_ENABLE
+#undef CFG_NU_OS_DRVR_WLAN_ENABLE
+#undef CFG_NU_OS_DRVR_WLAN_AR4100_ENABLE
+#undef CFG_NU_OS_DRVR_WLAN_AR6K3_ENABLE
+#undef CFG_NU_OS_DRVR_WLAN_AR6K2_ENABLE
+#undef CFG_NU_OS_DRVR_USB_ENABLE
+#undef CFG_NU_OS_DRVR_USB_FUNC_ENABLE
+#undef CFG_NU_OS_DRVR_USB_FUNC_NET_IF_ENABLE
+#undef CFG_NU_OS_DRVR_USB_FUNC_HWCTRL_ENABLE
+#undef CFG_NU_OS_DRVR_USB_HOST_ENABLE
+#undef CFG_NU_OS_DRVR_USB_HOST_FILE_IF_ENABLE
+#undef CFG_NU_OS_DRVR_USB_HOST_NET_IF_ENABLE
+#undef CFG_NU_OS_DRVR_USB_HOST_OHCI_ENABLE
+#undef CFG_NU_OS_DRVR_USB_HOST_EHCI_ENABLE
+#undef CFG_NU_OS_DRVR_USB_HOST_USB_INPUT_ENABLE
+#undef CFG_NU_OS_DRVR_USB_HOST_HWCTRL_ENABLE
+#undef CFG_NU_OS_DRVR_USB_HOST_XHCI_ENABLE
+#undef CFG_NU_OS_DRVR_USB_OTG_ENABLE
+#undef CFG_NU_OS_DRVR_USB_OTG_HWCTRL_ENABLE
+#undef CFG_NU_OS_DRVR_SAFE_ENABLE
+#undef CFG_NU_OS_DRVR_SAFE_SRA_ENABLE
+#undef CFG_NU_OS_DRVR_SAFE_BASE_ENABLE
+#undef CFG_NU_OS_DRVR_SDIO_ENABLE
+#undef CFG_NU_OS_DRVR_SDIO_FUNC_ENABLE
+#undef CFG_NU_OS_DRVR_SDIO_FUNC_SD_ENABLE
+#undef CFG_NU_OS_DRVR_SDIO_HOST_ENABLE
+#undef CFG_NU_OS_DRVR_SDIO_HOST_HCD_ENABLE
+#undef CFG_NU_OS_DRVR_I2C_ENABLE
+#undef CFG_NU_OS_DRVR_SERIAL_ENABLE
+#undef CFG_NU_OS_DRVR_SPI_ENABLE
+#undef CFG_NU_OS_DRVR_LWSPI_ENABLE
+#undef CFG_NU_OS_DRVR_SYSLOGGER_ENABLE
+#undef CFG_NU_OS_DRVR_PPP_ENABLE
+#undef CFG_NU_OS_DRVR_TOUCHPANEL_ENABLE
+#define CFG_NU_OS_DRVR_CPU_ENABLE
+#define CFG_NU_OS_DRVR_CPU_VOLTAGE_SCALING 0
+#undef CFG_NU_OS_DRVR_HIBERNATE_ENABLE
+#undef CFG_NU_OS_DRVR_DISPLAY_ENABLE
+#undef CFG_NU_OS_DRVR_KEYPAD_ENABLE
+#undef CFG_NU_OS_DRVR_PWR_INTRF_ENABLE
+#undef CFG_NU_OS_DRVR_CAN_ENABLE
+#undef CFG_NU_OS_DRVR_DMA_ENABLE
+#undef CFG_NU_OS_DRVR_RTC_ENABLE
+#undef CFG_NU_OS_DRVR_FAT_RD_ENABLE
+#undef CFG_NU_OS_DRVR_ETH_ENABLE
+#define CFG_NU_OS_SVCS_ENABLE
+#undef CFG_NU_OS_SVCS_TRACE_ENABLE
+#undef CFG_NU_OS_SVCS_TRACE_CORE_ENABLE
+#undef CFG_NU_OS_SVCS_TRACE_COMMS_ENABLE
+#undef CFG_NU_OS_SVCS_PWR_ENABLE
+#undef CFG_NU_OS_SVCS_PWR_CORE_ENABLE
+#undef CFG_NU_OS_SVCS_POSIX_ENABLE
+#undef CFG_NU_OS_SVCS_POSIX_AIO_ENABLE
+#undef CFG_NU_OS_SVCS_POSIX_RTL_ENABLE
+#undef CFG_NU_OS_SVCS_POSIX_NET_ENABLE
+#undef CFG_NU_OS_SVCS_POSIX_FS_ENABLE
+#undef CFG_NU_OS_SVCS_POSIX_CORE_ENABLE
+#undef CFG_NU_OS_SVCS_SHELL_ENABLE
+#define CFG_NU_OS_SVCS_REGISTRY_ENABLE
+#define CFG_NU_OS_SVCS_REGISTRY_EXPORT_SYMBOLS 1
+#define CFG_NU_OS_SVCS_INIT_ENABLE
+#undef CFG_NU_OS_SVCS_CXX_ENABLE
+#undef CFG_NU_OS_SVCS_DBG_ENABLE
+#undef CFG_NU_OS_SVCS_SYSLOG_ENABLE
+#define CFG_NU_OS_SVCS_APPINIT_ENABLE
+#define CFG_NU_OS_SVCS_APPINIT_RUNLEVEL 31
+#undef CFG_NU_OS_SVCS_DBG_ADV_ENABLE
+#define CFG_NU_OS_KERN_ENABLE
+#undef CFG_NU_OS_KERN_PROCESS_ENABLE
+#undef CFG_NU_OS_KERN_PROCESS_MEM_MGMT_ENABLE
+#undef CFG_NU_OS_KERN_PROCESS_SHELL_ENABLE
+#undef CFG_NU_OS_KERN_PROCESS_USER_ENABLE
+#undef CFG_NU_OS_KERN_PROCESS_LINKLOAD_ENABLE
+#undef CFG_NU_OS_KERN_PROCESS_CORE_ENABLE
+#define CFG_NU_OS_KERN_PLUS_ENABLE
+#define CFG_NU_OS_KERN_PLUS_CORE_ENABLE
+#define CFG_NU_OS_KERN_PLUS_CORE_MIN_STACK_SIZE 250
+#define CFG_NU_OS_KERN_PLUS_CORE_STACK_CHECKING 0
+#define CFG_NU_OS_KERN_PLUS_CORE_STACK_FILL 0
+#define CFG_NU_OS_KERN_PLUS_CORE_ERROR_CHECKING 1
+#define CFG_NU_OS_KERN_PLUS_CORE_ASSERT 0
+#define CFG_NU_OS_KERN_PLUS_CORE_ERROR_STRING 0
+#define CFG_NU_OS_KERN_PLUS_CORE_GLOBAL_INT_LOCKING 0
+#define CFG_NU_OS_KERN_PLUS_CORE_MIN_RAM 0
+#define CFG_NU_OS_KERN_PLUS_CORE_TICK_SUPPRESSION 0
+#define CFG_NU_OS_KERN_PLUS_CORE_INLINING 0
+#define CFG_NU_OS_KERN_PLUS_CORE_ROM_TO_RAM_COPY 0
+#define CFG_NU_OS_KERN_PLUS_CORE_ROM_SUPPORT 0
+#define CFG_NU_OS_KERN_PLUS_CORE_NUM_TASK_PRIORITIES 256
+#define CFG_NU_OS_KERN_PLUS_CORE_LV_TIMEOUT 0
+#define CFG_NU_OS_KERN_PLUS_CORE_AUTO_CLEAR_CB 1
+#define CFG_NU_OS_KERN_PLUS_CORE_TIMER_HISR_STACK_SIZE 2048
+#define CFG_NU_OS_KERN_PLUS_CORE_TICKS_PER_SEC 100
+#define CFG_NU_OS_KERN_PLUS_CORE_EXPORT_SYMBOLS 1
+#define CFG_NU_OS_KERN_PLUS_CORE_DEBUG_SCHED_LOCK 0
+#define CFG_NU_OS_KERN_PLUS_SUPPLEMENT_ENABLE
+#define CFG_NU_OS_KERN_PLUS_SUPPLEMENT_PLUS_OBJECT_LISTS 0
+#define CFG_NU_OS_KERN_PLUS_SUPPLEMENT_TIME_TEST1MIN 0
+#define CFG_NU_OS_KERN_PLUS_SUPPLEMENT_TIME_TEST1MAX 0
+#define CFG_NU_OS_KERN_PLUS_SUPPLEMENT_TIME_TEST2 0
+#define CFG_NU_OS_KERN_PLUS_SUPPLEMENT_TIME_TEST3 0
+#define CFG_NU_OS_KERN_PLUS_SUPPLEMENT_STATIC_TEST 0
+#define CFG_NU_OS_KERN_PLUS_SUPPLEMENT_EVT_NOTIFY 1
+#define CFG_NU_OS_KERN_PLUS_SUPPLEMENT_EXPORT_SYMBOLS 1
+#undef CFG_NU_OS_KERN_IPC_ENABLE
+#undef CFG_NU_OS_KERN_IPC_MCAPI_ENABLE
+#undef CFG_NU_OS_KERN_IPC_MCAPI_SHM_ENABLE
+#define CFG_NU_OS_KERN_RTL_ENABLE
+#define CFG_NU_OS_KERN_RTL_MALLOC_POOL 0
+#define CFG_NU_OS_KERN_RTL_FP_OVERRIDE 0
+#define CFG_NU_OS_KERN_RTL_HEAP_SIZE 4096
+#define CFG_NU_OS_KERN_RTL_EXPORT_SYMBOLS 1
+#define CFG_NU_OS_KERN_EQM_ENABLE
+#define CFG_NU_OS_KERN_DEVMGR_ENABLE
+#define CFG_NU_OS_KERN_DEVMGR_RUNLEVEL 1
+#define CFG_NU_OS_KERN_DEVMGR_MAX_DEV_LABEL_CNT 5
+#define CFG_NU_OS_KERN_DEVMGR_MAX_DEV_SESSION_CNT 3
+#define CFG_NU_OS_KERN_DEVMGR_MAX_DEVICE_LISTENERS 15
+#define CFG_NU_OS_KERN_DEVMGR_ERR_CHECK_ENABLE 1
+#define CFG_NU_OS_KERN_DEVMGR_DISCOVERY_TASK_ENABLE 1
+#define CFG_NU_OS_KERN_DEVMGR_DISCOVERY_TASK_MAX_ID_CNT 30
+#define CFG_NU_OS_KERN_DEVMGR_DISCOVERY_TASK_STACK_SIZE 10240
+#define CFG_NU_OS_KERN_DEVMGR_EXPORT_SYMBOLS 1
+#undef CFG_NU_OS_UI_ENABLE
+#undef CFG_NU_OS_UI_IFX_ENABLE
+#undef CFG_NU_OS_UI_IFX_MOD_ENABLE
+#undef CFG_NU_OS_UI_IFX_MOD_SIMPLEEDIT_ENABLE
+#undef CFG_NU_OS_UI_IFX_FRAMEWORK_ENABLE
+#undef CFG_NU_OS_UI_IFX_ENG_ENABLE
+#undef CFG_NU_OS_UI_IFX_PORT_ENABLE
+#undef CFG_NU_OS_UI_IFX_UCDN_ENABLE
+#undef CFG_NU_OS_UI_IFX_HARFBUZZ_ENABLE
+#undef CFG_NU_OS_UI_IFX_FREETYPE_ENABLE
+#undef CFG_NU_OS_UI_IFX_NUBIDI_ENABLE
+#undef CFG_NU_OS_UI_IMAGE_ENABLE
+#undef CFG_NU_OS_UI_INPUT_MGMT_ENABLE
+#undef CFG_NU_OS_UI_GRAFIXRS_ENABLE
+#undef CFG_NU_OS_STOR_ENABLE
+#undef CFG_NU_OS_STOR_FILE_ENABLE
+#undef CFG_NU_OS_STOR_FILE_FS_ENABLE
+#undef CFG_NU_OS_STOR_FILE_FS_FAT_ENABLE
+#undef CFG_NU_OS_STOR_FILE_FS_SAFE_ENABLE
+#undef CFG_NU_OS_STOR_FILE_SHELL_ENABLE
+#undef CFG_NU_OS_STOR_FILE_VFS_ENABLE
+#undef CFG_NU_OS_STOR_DB_ENABLE
+#undef CFG_NU_OS_STOR_DB_SQLITE_ENABLE
+#define CFG_NU_OS_ARCH_ENABLE
+#define CFG_NU_OS_ARCH_ARM_ENABLE
+#undef CFG_NU_OS_ARCH_ARM_PROCESS_ENABLE
+#undef CFG_NU_OS_ARCH_ARM_PROCESS_MEM_MGMT_ENABLE
+#undef CFG_NU_OS_ARCH_ARM_PROCESS_LINKLOAD_ENABLE
+#undef CFG_NU_OS_ARCH_ARM_PROCESS_CORE_ENABLE
+#define CFG_NU_OS_ARCH_ARM_CSGNU_ENABLE
+#define CFG_NU_OS_ARCH_ARM_COM_ENABLE
+#define CFG_NU_OS_ARCH_ARM_COM_MMU_VARIANT 1
+#define CFG_NU_OS_ARCH_ARM_COM_SYSTEM_STACK_SIZE 2048
+#define CFG_NU_OS_ARCH_ARM_COM_FPU_SUPPORT 2
+#define CFG_NU_OS_ARCH_ARM_COM_V6V7_CACHE_LINE_SIZE 64
+#define CFG_NU_BSP_ENABLE
+#undef CFG_NU_BSP_DRVR_ENABLE
+#undef CFG_NU_BSP_DRVR_SERIAL_ENABLE
+#undef CFG_NU_BSP_DRVR_SERIAL_ZYNQ_UART_ENABLE
+#undef CFG_NU_BSP_DRVR_CPU_ENABLE
+#define CFG_NU_BSP_DRVR_CPU_ZYNQ7000_ENABLE
+#undef CFG_NU_BSP_DRVR_CAN_ENABLE
+#undef CFG_NU_BSP_DRVR_CAN_ZYNQ_CAN_ENABLE
+#undef CFG_NU_BSP_DRVR_ETHERNET_ENABLE
+#undef CFG_NU_BSP_DRVR_ETHERNET_ZYNQ_ETH_ENABLE
+#define CFG_NU_BSP_ZC702EVK_ENABLE
+#define CFG_NU_BSP_ZC702EVK_AMP_REMOTE 1
+#define CFG_NU_BSP_ARCH_ENABLE
+#define CFG_ZC702EVK_ENABLE
+#undef CFG_ZC702EVK_SERIAL0_ENABLE
+#define CFG_ZC702EVK_CPU0_ENABLE
+#define CFG_ZC702EVK_CPU0_RUNLEVEL 2
+#undef CFG_ZC702EVK_CAN0_ENABLE
+#undef CFG_ZC702EVK_ETHERNET0_ENABLE
+#define CFG_ZC702EVK_REMOTE_PROC0_ENABLE
+#define CFG_ZC702EVK_REMOTE_PROC1_ENABLE
+#undef CFG_ZC702EVK_RAMDISK0_ENABLE
+#endif /* NUCLEUS_GEN_CFG_H */
diff --git a/libs/system/zc702evk/nucleus/lib/arm-xilinx-eabi-/master/libnucleus_master.a b/libs/system/zc702evk/nucleus/lib/arm-xilinx-eabi-/master/libnucleus_master.a
new file mode 100644 (file)
index 0000000..ef612e3
Binary files /dev/null and b/libs/system/zc702evk/nucleus/lib/arm-xilinx-eabi-/master/libnucleus_master.a differ
index 0000000..ef612e3
Binary files /dev/null and b/libs/system/zc702evk/nucleus/lib/arm-xilinx-eabi-/master/libnucleus_master.a differ
diff --git a/libs/system/zc702evk/nucleus/lib/arm-xilinx-eabi-/master/nucleus_gen_cfg.h b/libs/system/zc702evk/nucleus/lib/arm-xilinx-eabi-/master/nucleus_gen_cfg.h
--- /dev/null
@@ -0,0 +1,350 @@
+/***********************************************************************
+*
+* Copyright 1993 Mentor Graphics Corporation
+* All Rights Reserved.
+*
+* THIS WORK CONTAINS TRADE SECRET AND PROPRIETARY INFORMATION WHICH IS
+* THE PROPERTY OF MENTOR GRAPHICS CORPORATION OR ITS LICENSORS AND IS
+* SUBJECT TO LICENSE TERMS.
+*
+************************************************************************
+
+************************************************************************
+*
+* FILE NAME
+*
+* nucleus_gen_cfg.h
+*
+* COMPONENT
+*
+* Nucleus OS
+*
+* DESCRIPTION
+*
+* This file contains auto-generated configuration settings for
+* the Nucleus OS. DO NOT MODIFY.
+*
+* DATA STRUCTURES
+*
+* None
+*
+* DEPENDENCIES
+*
+* None
+*
+************************************************************************/
+/* Generated: Thu Sep 25 14:57:42 +0500 2014 */
+/* DO NOT MODIFY - This file is auto-generated */
+#ifndef NUCLEUS_GEN_CFG_H
+#define NUCLEUS_GEN_CFG_H
+#define CFG_NU_OS_SVCS_REGISTRY_MAX_KEY_LEN 52
+#define CFG_TOOLSETS_ENABLE
+#define CFG_TOOLSETS_ZC702EVK_ENABLE
+#define CFG_TOOLSETS_ZC702EVK_CSGNU_ARM_ENABLE
+#define CFG_TOOLSETS_ZC702EVK_CSGNU_ARM_ARCH_CFLAGS "-gdwarf-2 -mthumb-interwork -mcpu=cortex-a9"
+#define CFG_TOOLSETS_ZC702EVK_CSGNU_ARM_ARCH_CXXFLAGS "-gdwarf-2 -mthumb-interwork -mcpu=cortex-a9"
+#define CFG_TOOLSETS_ZC702EVK_CSGNU_ARM_ARCH_ASFLAGS "-gdwarf2 -meabi=4 -mcpu=cortex-a9 -mfpu=neon"
+#define CFG_TOOLSETS_ZC702EVK_CSGNU_ARM_ARCH_LDFLAGS ""
+#define CFG_TOOLSETS_ZC702EVK_CSGNU_ARM_ARCH_LDSCRIPT "$(TOOLSETS_HOME)/csgnu_arm.zc702evk.link_ram.ld"
+#define CFG_TOOLSETS_ZC702EVK_CSGNU_ARM_ARCH_ARFLAGS ""
+#define CFG_TOOLSETS_CSGNU_ARM_ENABLE
+#define CFG_TOOLSETS_CSGNU_ARM_CROSS "arm-xilinx-eabi-"
+#define CFG_TOOLSETS_CSGNU_ARM_CC "$(CROSS)gcc"
+#define CFG_TOOLSETS_CSGNU_ARM_CFLAGS "-Wall -ffunction-sections -fdata-sections"
+#define CFG_TOOLSETS_CSGNU_ARM_PROC_CFLAGS "-Wall -ffunction-sections -fdata-sections -fPIC -DNU_PROCESS"
+#define CFG_TOOLSETS_CSGNU_ARM_COMPILE "$(CC) $(patsubst %, -isystem %, $(SYSTEM_INCLUDE_PATH)) $(patsubst %, -I%, $(INCLUDE_PATH)) -I. -Wp,-MD,$(2:.o=.d.tmp) -c $(CFLAGS) $(ARCH_CFLAGS) $(CFLAGS_$(1)) $(1) -o $(2)"
+#define CFG_TOOLSETS_CSGNU_ARM_PROC_COMPILE "$(CC) $(patsubst %, -I%, $(INCLUDE_PATH)) -I. -Wp,-MD,$(2:.po=.pd.tmp) -c $(PROC_CFLAGS) $(ARCH_CFLAGS) $(CFLAGS_$(1)) $(1) -o $(2)"
+#define CFG_TOOLSETS_CSGNU_ARM_CXX "$(CROSS)g++"
+#define CFG_TOOLSETS_CSGNU_ARM_CXXFLAGS "-Wall -fno-enforce-eh-specs"
+#define CFG_TOOLSETS_CSGNU_ARM_PROC_CXXFLAGS "-Wall -fno-enforce-eh-specs -fPIC -DNU_PROCESS"
+#define CFG_TOOLSETS_CSGNU_ARM_COMPILECXX "$(CXX) $(patsubst %, -isystem %, $(SYSTEM_INCLUDE_PATH)) $(patsubst %, -I%, $(INCLUDE_PATH)) -I. -Wp,-MD,$(2:.o=.d.tmp) -c $(CXXFLAGS) $(ARCH_CXXFLAGS) $(CXXFLAGS_$(1)) $(1) -o $(2)"
+#define CFG_TOOLSETS_CSGNU_ARM_PROC_COMPILECXX "$(CXX) $(patsubst %, -I%, $(INCLUDE_PATH)) -I. -Wp,-MD,$(2:.po=.pd.tmp) -c $(PROC_CXXFLAGS) $(ARCH_CXXFLAGS) $(CXXFLAGS_$(1)) $(1) -o $(2)"
+#define CFG_TOOLSETS_CSGNU_ARM_AS "$(CROSS)as"
+#define CFG_TOOLSETS_CSGNU_ARM_ASFLAGS ""
+#define CFG_TOOLSETS_CSGNU_ARM_PROC_ASFLAGS ""
+#define CFG_TOOLSETS_CSGNU_ARM_ASSEMBLE "$(AS) $(patsubst %, -I%, $(INCLUDE_PATH)) -I. --MD $(2:.o=.d.tmp) $(ASFLAGS) $(ARCH_ASFLAGS) $(ASFLAGS_$(1)) $(1) -o $(2)"
+#define CFG_TOOLSETS_CSGNU_ARM_CPPASSEMBLE "$(CC) $(patsubst %, -I%, $(INCLUDE_PATH)) -I. -Wp,-MD,$(2:.o=.d.tmp) $(addprefix -Wa$(comma),$(ASFLAGS)) $(addprefix -Wa$(comma),$(ARCH_ASFLAGS)) $(addprefix -Wa$(comma),$(ASFLAGS_$(1))) -c -x assembler-with-cpp $(1) -o $(2)"
+#define CFG_TOOLSETS_CSGNU_ARM_PROC_ASSEMBLE "$(AS) $(patsubst %, -I%, $(INCLUDE_PATH)) -I. --MD $(2:.po=.pd.tmp) $(ASFLAGS) $(ARCH_ASFLAGS) $(ASFLAGS_$(1)) $(1) -o $(2)"
+#define CFG_TOOLSETS_CSGNU_ARM_PROC_CPPASSEMBLE "$(CC) $(patsubst %, -I%, $(INCLUDE_PATH)) -I. -Wp,-MD,$(2:.po=.pd.tmp) $(addprefix -Wa$(comma),$(ASFLAGS)) $(addprefix -Wa$(comma),$(ARCH_ASFLAGS)) $(addprefix -Wa$(comma),$(ASFLAGS_$(1))) -c $(1) -o $(2)"
+#define CFG_TOOLSETS_CSGNU_ARM_LD "$(CROSS)gcc"
+#define CFG_TOOLSETS_CSGNU_ARM_LDFLAGS "-nostartfiles -Wl,--gc-sections -Wl,--wrap=malloc -Wl,--wrap=calloc -Wl,--wrap=realloc -Wl,--wrap=free -Wl,--defsym -Wl,PAGE_SIZE=$(PAGE_SIZE)"
+#define CFG_TOOLSETS_CSGNU_ARM_PROC_LDFLAGS "-nostdlib -nostartfiles -Wl,--gc-sections -Wl,-pie -Wl,--warn-unresolved-symbols -Wl,--no-demangle -Wl,--nmagic -Wl,--defsym -Wl,PAGE_SIZE=$(PAGE_SIZE) -Wl,--defsym -Wl,NUCLEUS_VERSION=$(NUCLEUS_VERSION)"
+#define CFG_TOOLSETS_CSGNU_ARM_PROC_LDSCRIPT "$(SYSTEM_HOME)/os/toolset/csgnu_arm.process.ld"
+#define CFG_TOOLSETS_CSGNU_ARM_LINK "$(LD) -Wl,-Map=$(basename $(1)).map -o $(1) $(LDFLAGS) $(ARCH_LDFLAGS) $(LDFLAGS_$(notdir $(1))) -T$(LDSCRIPT_$(notdir $(1))) -Wl,--start-group $(2) -lc -lm -lstdc++ -Wl,--end-group"
+#define CFG_TOOLSETS_CSGNU_ARM_PROC_LINK "$(CROSS)nuproclink $(LD) $(basename $(1)).out $(basename $(1)).map -Wl,-Map=$(basename $(1)).map -o $(basename $(1)).out $(PROC_LDFLAGS) $(ARCH_PROC_LDFLAGS) $(LDFLAGS_$(notdir $(1))) -T$(PROC_LDSCRIPT) -Wl,--start-group @$(2) @$(3) -lstdc++ -lgcc -Wl,--end-group"
+#define CFG_TOOLSETS_CSGNU_ARM_AR "$(CROSS)ar"
+#define CFG_TOOLSETS_CSGNU_ARM_ARFLAGS ""
+#define CFG_TOOLSETS_CSGNU_ARM_ARCHIVE "$(AR) $(ARFLAGS) $(ARCH_ARFLAGS) -rc $(1) $(2)"
+#define CFG_TOOLSETS_CSGNU_ARM_POSTLD "$(CROSS)objcopy"
+#define CFG_TOOLSETS_CSGNU_ARM_PROC_POSTLD "$(CROSS)strip"
+#define CFG_TOOLSETS_CSGNU_ARM_POSTLINK "$(POSTLD) -O binary $(1) $(basename $(1)).bin"
+#define CFG_TOOLSETS_CSGNU_ARM_PROC_POSTLINK "$(PROC_POSTLD) -g --strip-unneeded -R .interp -R .dynamic -R .comment $(basename $(1)).out -o $(1)"
+#define CFG_NU_ENABLE
+#define CFG_NU_MAJOR_VERSION 2013
+#define CFG_NU_MINOR_VERSION 8
+#define CFG_NU_PATCH_VERSION 1
+#define CFG_NU_OS_ENABLE
+#undef CFG_NU_OS_NET_ENABLE
+#undef CFG_NU_OS_NET_SSL_ENABLE
+#undef CFG_NU_OS_NET_SSL_OPENSSL_ENABLE
+#undef CFG_NU_OS_NET_SSL_OPENSSL_SSL_ENABLE
+#undef CFG_NU_OS_NET_SSL_OPENSSL_CRYPTO_ENABLE
+#undef CFG_NU_OS_NET_SSL_OPENSSL_OPENSSL_UNIT_TESTS_ENABLE
+#undef CFG_NU_OS_NET_SSL_LITE_ENABLE
+#undef CFG_NU_OS_NET_DHCP_ENABLE
+#undef CFG_NU_OS_NET_DHCP_SERVER_ENABLE
+#undef CFG_NU_OS_NET_PROT_ENABLE
+#undef CFG_NU_OS_NET_PROT_TELNET_ENABLE
+#undef CFG_NU_OS_NET_PROT_TELNET_SHELL_ENABLE
+#undef CFG_NU_OS_NET_PROT_TELNET_SERVER_ENABLE
+#undef CFG_NU_OS_NET_PROT_TELNET_CORE_ENABLE
+#undef CFG_NU_OS_NET_PROT_TELNET_CLIENT_ENABLE
+#undef CFG_NU_OS_NET_PROT_TFTP_ENABLE
+#undef CFG_NU_OS_NET_PROT_TFTP_SHELL_ENABLE
+#undef CFG_NU_OS_NET_PROT_TFTP_SERVER_ENABLE
+#undef CFG_NU_OS_NET_PROT_TFTP_CLIENT_ENABLE
+#undef CFG_NU_OS_NET_PROT_FTP_ENABLE
+#undef CFG_NU_OS_NET_EMAIL_ENABLE
+#undef CFG_NU_OS_NET_EMAIL_SMTPC_ENABLE
+#undef CFG_NU_OS_NET_WPA_SUPP_ENABLE
+#undef CFG_NU_OS_NET_WPA_SUPP_SRC_ENABLE
+#undef CFG_NU_OS_NET_SSH_ENABLE
+#undef CFG_NU_OS_NET_SSH_LIBTOMMATH_ENABLE
+#undef CFG_NU_OS_NET_SSH_LIBTOMCRYPT_ENABLE
+#undef CFG_NU_OS_NET_SSH_DB_SSHSERVER_ENABLE
+#undef CFG_NU_OS_NET_SHELL_ENABLE
+#undef CFG_NU_OS_NET_SNMP_ENABLE
+#undef CFG_NU_OS_NET_SNTPC_ENABLE
+#undef CFG_NU_OS_NET_JSON_ENABLE
+#undef CFG_NU_OS_NET_STACK_ENABLE
+#undef CFG_NU_OS_NET_IPV6_ENABLE
+#undef CFG_NU_OS_NET_WEB_ENABLE
+#undef CFG_NU_OS_NET_NAT_ENABLE
+#undef CFG_NU_OS_NET_WSOX_ENABLE
+#undef CFG_NU_OS_NET_HTTP_ENABLE
+#undef CFG_NU_OS_NET_IKE_ENABLE
+#undef CFG_NU_OS_NET_IPSEC_ENABLE
+#undef CFG_NU_OS_CONN_ENABLE
+#undef CFG_NU_OS_CONN_USB_ENABLE
+#undef CFG_NU_OS_CONN_USB_FUNC_ENABLE
+#undef CFG_NU_OS_CONN_USB_FUNC_HID_ENABLE
+#undef CFG_NU_OS_CONN_USB_FUNC_HID_MSE_ENABLE
+#undef CFG_NU_OS_CONN_USB_FUNC_HID_CLASS_ENABLE
+#undef CFG_NU_OS_CONN_USB_FUNC_HID_KBD_ENABLE
+#undef CFG_NU_OS_CONN_USB_FUNC_COMM_ENABLE
+#undef CFG_NU_OS_CONN_USB_FUNC_COMM_CLASS_ENABLE
+#undef CFG_NU_OS_CONN_USB_FUNC_COMM_MDM_ENABLE
+#undef CFG_NU_OS_CONN_USB_FUNC_COMM_ETH_ENABLE
+#undef CFG_NU_OS_CONN_USB_FUNC_MS_ENABLE
+#undef CFG_NU_OS_CONN_USB_FUNC_MS_CLASS_ENABLE
+#undef CFG_NU_OS_CONN_USB_FUNC_MS_USER_ENABLE
+#undef CFG_NU_OS_CONN_USB_FUNC_DFU_ENABLE
+#undef CFG_NU_OS_CONN_USB_FUNC_STACK_ENABLE
+#undef CFG_NU_OS_CONN_USB_COM_ENABLE
+#undef CFG_NU_OS_CONN_USB_COM_STACK_ENABLE
+#undef CFG_NU_OS_CONN_USB_HOST_ENABLE
+#undef CFG_NU_OS_CONN_USB_HOST_COMM_ENABLE
+#undef CFG_NU_OS_CONN_USB_HOST_COMM_CLASS_ENABLE
+#undef CFG_NU_OS_CONN_USB_HOST_COMM_MDM_ENABLE
+#undef CFG_NU_OS_CONN_USB_HOST_COMM_ETH_ENABLE
+#undef CFG_NU_OS_CONN_USB_HOST_MS_ENABLE
+#undef CFG_NU_OS_CONN_USB_HOST_MS_CLASS_ENABLE
+#undef CFG_NU_OS_CONN_USB_HOST_MS_USER_ENABLE
+#undef CFG_NU_OS_CONN_USB_HOST_AUDIO_ENABLE
+#undef CFG_NU_OS_CONN_USB_HOST_AUDIO_CLASS_ENABLE
+#undef CFG_NU_OS_CONN_USB_HOST_AUDIO_USER_ENABLE
+#undef CFG_NU_OS_CONN_USB_HOST_HID_ENABLE
+#undef CFG_NU_OS_CONN_USB_HOST_HID_MOUSE_ENABLE
+#undef CFG_NU_OS_CONN_USB_HOST_HID_CLASS_ENABLE
+#undef CFG_NU_OS_CONN_USB_HOST_HID_KEYBOARD_ENABLE
+#undef CFG_NU_OS_CONN_USB_HOST_STACK_ENABLE
+#undef CFG_NU_OS_CONN_SDIO_ENABLE
+#undef CFG_NU_OS_CONN_I2C_ENABLE
+#undef CFG_NU_OS_CONN_SPI_ENABLE
+#undef CFG_NU_OS_CONN_LWSPI_ENABLE
+#undef CFG_NU_OS_CONN_CAN_ENABLE
+#define CFG_NU_OS_DRVR_ENABLE
+#undef CFG_NU_OS_DRVR_WLAN_ENABLE
+#undef CFG_NU_OS_DRVR_WLAN_AR4100_ENABLE
+#undef CFG_NU_OS_DRVR_WLAN_AR6K3_ENABLE
+#undef CFG_NU_OS_DRVR_WLAN_AR6K2_ENABLE
+#undef CFG_NU_OS_DRVR_USB_ENABLE
+#undef CFG_NU_OS_DRVR_USB_FUNC_ENABLE
+#undef CFG_NU_OS_DRVR_USB_FUNC_NET_IF_ENABLE
+#undef CFG_NU_OS_DRVR_USB_FUNC_HWCTRL_ENABLE
+#undef CFG_NU_OS_DRVR_USB_HOST_ENABLE
+#undef CFG_NU_OS_DRVR_USB_HOST_FILE_IF_ENABLE
+#undef CFG_NU_OS_DRVR_USB_HOST_NET_IF_ENABLE
+#undef CFG_NU_OS_DRVR_USB_HOST_OHCI_ENABLE
+#undef CFG_NU_OS_DRVR_USB_HOST_EHCI_ENABLE
+#undef CFG_NU_OS_DRVR_USB_HOST_USB_INPUT_ENABLE
+#undef CFG_NU_OS_DRVR_USB_HOST_HWCTRL_ENABLE
+#undef CFG_NU_OS_DRVR_USB_HOST_XHCI_ENABLE
+#undef CFG_NU_OS_DRVR_USB_OTG_ENABLE
+#undef CFG_NU_OS_DRVR_USB_OTG_HWCTRL_ENABLE
+#undef CFG_NU_OS_DRVR_SAFE_ENABLE
+#undef CFG_NU_OS_DRVR_SAFE_SRA_ENABLE
+#undef CFG_NU_OS_DRVR_SAFE_BASE_ENABLE
+#undef CFG_NU_OS_DRVR_SDIO_ENABLE
+#undef CFG_NU_OS_DRVR_SDIO_FUNC_ENABLE
+#undef CFG_NU_OS_DRVR_SDIO_FUNC_SD_ENABLE
+#undef CFG_NU_OS_DRVR_SDIO_HOST_ENABLE
+#undef CFG_NU_OS_DRVR_SDIO_HOST_HCD_ENABLE
+#undef CFG_NU_OS_DRVR_I2C_ENABLE
+#define CFG_NU_OS_DRVR_SERIAL_ENABLE
+#define CFG_NU_OS_DRVR_SERIAL_RUNLEVEL 5
+#define CFG_NU_OS_DRVR_SERIAL_BLOCKING_SUPPORT 1
+#define CFG_NU_OS_DRVR_SERIAL_MAX_DEVS_SUPPORTED 4
+#undef CFG_NU_OS_DRVR_SPI_ENABLE
+#undef CFG_NU_OS_DRVR_LWSPI_ENABLE
+#undef CFG_NU_OS_DRVR_SYSLOGGER_ENABLE
+#undef CFG_NU_OS_DRVR_PPP_ENABLE
+#undef CFG_NU_OS_DRVR_TOUCHPANEL_ENABLE
+#define CFG_NU_OS_DRVR_CPU_ENABLE
+#define CFG_NU_OS_DRVR_CPU_VOLTAGE_SCALING 0
+#undef CFG_NU_OS_DRVR_HIBERNATE_ENABLE
+#undef CFG_NU_OS_DRVR_DISPLAY_ENABLE
+#undef CFG_NU_OS_DRVR_KEYPAD_ENABLE
+#undef CFG_NU_OS_DRVR_PWR_INTRF_ENABLE
+#undef CFG_NU_OS_DRVR_CAN_ENABLE
+#undef CFG_NU_OS_DRVR_DMA_ENABLE
+#undef CFG_NU_OS_DRVR_RTC_ENABLE
+#undef CFG_NU_OS_DRVR_FAT_RD_ENABLE
+#undef CFG_NU_OS_DRVR_ETH_ENABLE
+#define CFG_NU_OS_SVCS_ENABLE
+#undef CFG_NU_OS_SVCS_TRACE_ENABLE
+#undef CFG_NU_OS_SVCS_TRACE_CORE_ENABLE
+#undef CFG_NU_OS_SVCS_TRACE_COMMS_ENABLE
+#undef CFG_NU_OS_SVCS_PWR_ENABLE
+#undef CFG_NU_OS_SVCS_PWR_CORE_ENABLE
+#undef CFG_NU_OS_SVCS_POSIX_ENABLE
+#undef CFG_NU_OS_SVCS_POSIX_AIO_ENABLE
+#undef CFG_NU_OS_SVCS_POSIX_RTL_ENABLE
+#undef CFG_NU_OS_SVCS_POSIX_NET_ENABLE
+#undef CFG_NU_OS_SVCS_POSIX_FS_ENABLE
+#undef CFG_NU_OS_SVCS_POSIX_CORE_ENABLE
+#undef CFG_NU_OS_SVCS_SHELL_ENABLE
+#define CFG_NU_OS_SVCS_REGISTRY_ENABLE
+#define CFG_NU_OS_SVCS_REGISTRY_EXPORT_SYMBOLS 1
+#define CFG_NU_OS_SVCS_INIT_ENABLE
+#undef CFG_NU_OS_SVCS_CXX_ENABLE
+#undef CFG_NU_OS_SVCS_DBG_ENABLE
+#undef CFG_NU_OS_SVCS_SYSLOG_ENABLE
+#define CFG_NU_OS_SVCS_APPINIT_ENABLE
+#define CFG_NU_OS_SVCS_APPINIT_RUNLEVEL 31
+#undef CFG_NU_OS_SVCS_DBG_ADV_ENABLE
+#define CFG_NU_OS_KERN_ENABLE
+#undef CFG_NU_OS_KERN_PROCESS_ENABLE
+#undef CFG_NU_OS_KERN_PROCESS_MEM_MGMT_ENABLE
+#undef CFG_NU_OS_KERN_PROCESS_SHELL_ENABLE
+#undef CFG_NU_OS_KERN_PROCESS_USER_ENABLE
+#undef CFG_NU_OS_KERN_PROCESS_LINKLOAD_ENABLE
+#undef CFG_NU_OS_KERN_PROCESS_CORE_ENABLE
+#define CFG_NU_OS_KERN_PLUS_ENABLE
+#define CFG_NU_OS_KERN_PLUS_CORE_ENABLE
+#define CFG_NU_OS_KERN_PLUS_CORE_MIN_STACK_SIZE 250
+#define CFG_NU_OS_KERN_PLUS_CORE_STACK_CHECKING 0
+#define CFG_NU_OS_KERN_PLUS_CORE_STACK_FILL 0
+#define CFG_NU_OS_KERN_PLUS_CORE_ERROR_CHECKING 1
+#define CFG_NU_OS_KERN_PLUS_CORE_ASSERT 0
+#define CFG_NU_OS_KERN_PLUS_CORE_ERROR_STRING 0
+#define CFG_NU_OS_KERN_PLUS_CORE_GLOBAL_INT_LOCKING 0
+#define CFG_NU_OS_KERN_PLUS_CORE_MIN_RAM 0
+#define CFG_NU_OS_KERN_PLUS_CORE_TICK_SUPPRESSION 0
+#define CFG_NU_OS_KERN_PLUS_CORE_INLINING 0
+#define CFG_NU_OS_KERN_PLUS_CORE_ROM_TO_RAM_COPY 0
+#define CFG_NU_OS_KERN_PLUS_CORE_ROM_SUPPORT 0
+#define CFG_NU_OS_KERN_PLUS_CORE_NUM_TASK_PRIORITIES 256
+#define CFG_NU_OS_KERN_PLUS_CORE_LV_TIMEOUT 0
+#define CFG_NU_OS_KERN_PLUS_CORE_AUTO_CLEAR_CB 1
+#define CFG_NU_OS_KERN_PLUS_CORE_TIMER_HISR_STACK_SIZE 2048
+#define CFG_NU_OS_KERN_PLUS_CORE_TICKS_PER_SEC 100
+#define CFG_NU_OS_KERN_PLUS_CORE_EXPORT_SYMBOLS 1
+#define CFG_NU_OS_KERN_PLUS_CORE_DEBUG_SCHED_LOCK 0
+#define CFG_NU_OS_KERN_PLUS_SUPPLEMENT_ENABLE
+#define CFG_NU_OS_KERN_PLUS_SUPPLEMENT_PLUS_OBJECT_LISTS 0
+#define CFG_NU_OS_KERN_PLUS_SUPPLEMENT_TIME_TEST1MIN 0
+#define CFG_NU_OS_KERN_PLUS_SUPPLEMENT_TIME_TEST1MAX 0
+#define CFG_NU_OS_KERN_PLUS_SUPPLEMENT_TIME_TEST2 0
+#define CFG_NU_OS_KERN_PLUS_SUPPLEMENT_TIME_TEST3 0
+#define CFG_NU_OS_KERN_PLUS_SUPPLEMENT_STATIC_TEST 0
+#define CFG_NU_OS_KERN_PLUS_SUPPLEMENT_EVT_NOTIFY 1
+#define CFG_NU_OS_KERN_PLUS_SUPPLEMENT_EXPORT_SYMBOLS 1
+#undef CFG_NU_OS_KERN_IPC_ENABLE
+#undef CFG_NU_OS_KERN_IPC_MCAPI_ENABLE
+#undef CFG_NU_OS_KERN_IPC_MCAPI_SHM_ENABLE
+#define CFG_NU_OS_KERN_RTL_ENABLE
+#define CFG_NU_OS_KERN_RTL_MALLOC_POOL 0
+#define CFG_NU_OS_KERN_RTL_FP_OVERRIDE 0
+#define CFG_NU_OS_KERN_RTL_HEAP_SIZE 512
+#define CFG_NU_OS_KERN_RTL_EXPORT_SYMBOLS 1
+#define CFG_NU_OS_KERN_EQM_ENABLE
+#define CFG_NU_OS_KERN_DEVMGR_ENABLE
+#define CFG_NU_OS_KERN_DEVMGR_RUNLEVEL 1
+#define CFG_NU_OS_KERN_DEVMGR_MAX_DEV_LABEL_CNT 5
+#define CFG_NU_OS_KERN_DEVMGR_MAX_DEV_SESSION_CNT 3
+#define CFG_NU_OS_KERN_DEVMGR_MAX_DEVICE_LISTENERS 15
+#define CFG_NU_OS_KERN_DEVMGR_ERR_CHECK_ENABLE 1
+#define CFG_NU_OS_KERN_DEVMGR_DISCOVERY_TASK_ENABLE 1
+#define CFG_NU_OS_KERN_DEVMGR_DISCOVERY_TASK_MAX_ID_CNT 30
+#define CFG_NU_OS_KERN_DEVMGR_DISCOVERY_TASK_STACK_SIZE 10240
+#define CFG_NU_OS_KERN_DEVMGR_EXPORT_SYMBOLS 1
+#undef CFG_NU_OS_UI_ENABLE
+#undef CFG_NU_OS_UI_IFX_ENABLE
+#undef CFG_NU_OS_UI_IFX_MOD_ENABLE
+#undef CFG_NU_OS_UI_IFX_MOD_SIMPLEEDIT_ENABLE
+#undef CFG_NU_OS_UI_IFX_FRAMEWORK_ENABLE
+#undef CFG_NU_OS_UI_IFX_ENG_ENABLE
+#undef CFG_NU_OS_UI_IFX_PORT_ENABLE
+#undef CFG_NU_OS_UI_IFX_UCDN_ENABLE
+#undef CFG_NU_OS_UI_IFX_HARFBUZZ_ENABLE
+#undef CFG_NU_OS_UI_IFX_FREETYPE_ENABLE
+#undef CFG_NU_OS_UI_IFX_NUBIDI_ENABLE
+#undef CFG_NU_OS_UI_IMAGE_ENABLE
+#undef CFG_NU_OS_UI_INPUT_MGMT_ENABLE
+#undef CFG_NU_OS_UI_GRAFIXRS_ENABLE
+#undef CFG_NU_OS_STOR_ENABLE
+#undef CFG_NU_OS_STOR_FILE_ENABLE
+#undef CFG_NU_OS_STOR_FILE_FS_ENABLE
+#undef CFG_NU_OS_STOR_FILE_FS_FAT_ENABLE
+#undef CFG_NU_OS_STOR_FILE_FS_SAFE_ENABLE
+#undef CFG_NU_OS_STOR_FILE_SHELL_ENABLE
+#undef CFG_NU_OS_STOR_FILE_VFS_ENABLE
+#undef CFG_NU_OS_STOR_DB_ENABLE
+#undef CFG_NU_OS_STOR_DB_SQLITE_ENABLE
+#define CFG_NU_OS_ARCH_ENABLE
+#define CFG_NU_OS_ARCH_ARM_ENABLE
+#undef CFG_NU_OS_ARCH_ARM_PROCESS_ENABLE
+#undef CFG_NU_OS_ARCH_ARM_PROCESS_MEM_MGMT_ENABLE
+#undef CFG_NU_OS_ARCH_ARM_PROCESS_LINKLOAD_ENABLE
+#undef CFG_NU_OS_ARCH_ARM_PROCESS_CORE_ENABLE
+#define CFG_NU_OS_ARCH_ARM_CSGNU_ENABLE
+#define CFG_NU_OS_ARCH_ARM_COM_ENABLE
+#define CFG_NU_OS_ARCH_ARM_COM_MMU_VARIANT 1
+#define CFG_NU_OS_ARCH_ARM_COM_SYSTEM_STACK_SIZE 2048
+#define CFG_NU_OS_ARCH_ARM_COM_FPU_SUPPORT 2
+#define CFG_NU_OS_ARCH_ARM_COM_V6V7_CACHE_LINE_SIZE 64
+#define CFG_NU_BSP_ENABLE
+#define CFG_NU_BSP_DRVR_ENABLE
+#define CFG_NU_BSP_DRVR_SERIAL_ENABLE
+#define CFG_NU_BSP_DRVR_SERIAL_ZYNQ_UART_ENABLE
+#undef CFG_NU_BSP_DRVR_CPU_ENABLE
+#define CFG_NU_BSP_DRVR_CPU_ZYNQ7000_ENABLE
+#undef CFG_NU_BSP_DRVR_CAN_ENABLE
+#undef CFG_NU_BSP_DRVR_CAN_ZYNQ_CAN_ENABLE
+#undef CFG_NU_BSP_DRVR_ETHERNET_ENABLE
+#undef CFG_NU_BSP_DRVR_ETHERNET_ZYNQ_ETH_ENABLE
+#define CFG_NU_BSP_ZC702EVK_ENABLE
+#define CFG_NU_BSP_ZC702EVK_AMP_REMOTE 0
+#define CFG_NU_BSP_ARCH_ENABLE
+#define CFG_ZC702EVK_ENABLE
+#define CFG_ZC702EVK_SERIAL0_ENABLE
+#define CFG_ZC702EVK_SERIAL0_RUNLEVEL 11
+#define CFG_ZC702EVK_CPU0_ENABLE
+#define CFG_ZC702EVK_CPU0_RUNLEVEL 2
+#undef CFG_ZC702EVK_CAN0_ENABLE
+#undef CFG_ZC702EVK_ETHERNET0_ENABLE
+#define CFG_ZC702EVK_REMOTE_PROC0_ENABLE
+#define CFG_ZC702EVK_REMOTE_PROC1_ENABLE
+#undef CFG_ZC702EVK_RAMDISK0_ENABLE
+#endif /* NUCLEUS_GEN_CFG_H */
diff --git a/libs/system/zc702evk/nucleus/lib/arm-xilinx-eabi-/remote/libnucleus_remote.a b/libs/system/zc702evk/nucleus/lib/arm-xilinx-eabi-/remote/libnucleus_remote.a
new file mode 100644 (file)
index 0000000..06d467a
Binary files /dev/null and b/libs/system/zc702evk/nucleus/lib/arm-xilinx-eabi-/remote/libnucleus_remote.a differ
index 0000000..06d467a
Binary files /dev/null and b/libs/system/zc702evk/nucleus/lib/arm-xilinx-eabi-/remote/libnucleus_remote.a differ
diff --git a/libs/system/zc702evk/nucleus/lib/arm-xilinx-eabi-/remote/nucleus_gen_cfg.h b/libs/system/zc702evk/nucleus/lib/arm-xilinx-eabi-/remote/nucleus_gen_cfg.h
--- /dev/null
@@ -0,0 +1,346 @@
+/***********************************************************************
+*
+* Copyright 1993 Mentor Graphics Corporation
+* All Rights Reserved.
+*
+* THIS WORK CONTAINS TRADE SECRET AND PROPRIETARY INFORMATION WHICH IS
+* THE PROPERTY OF MENTOR GRAPHICS CORPORATION OR ITS LICENSORS AND IS
+* SUBJECT TO LICENSE TERMS.
+*
+************************************************************************
+
+************************************************************************
+*
+* FILE NAME
+*
+* nucleus_gen_cfg.h
+*
+* COMPONENT
+*
+* Nucleus OS
+*
+* DESCRIPTION
+*
+* This file contains auto-generated configuration settings for
+* the Nucleus OS. DO NOT MODIFY.
+*
+* DATA STRUCTURES
+*
+* None
+*
+* DEPENDENCIES
+*
+* None
+*
+************************************************************************/
+/* Generated: Thu Sep 25 15:09:44 +0500 2014 */
+/* DO NOT MODIFY - This file is auto-generated */
+#ifndef NUCLEUS_GEN_CFG_H
+#define NUCLEUS_GEN_CFG_H
+#define CFG_NU_OS_SVCS_REGISTRY_MAX_KEY_LEN 49
+#define CFG_TOOLSETS_ENABLE
+#define CFG_TOOLSETS_ZC702EVK_ENABLE
+#define CFG_TOOLSETS_ZC702EVK_CSGNU_ARM_ENABLE
+#define CFG_TOOLSETS_ZC702EVK_CSGNU_ARM_ARCH_CFLAGS "-gdwarf-2 -mthumb-interwork -mcpu=cortex-a9"
+#define CFG_TOOLSETS_ZC702EVK_CSGNU_ARM_ARCH_CXXFLAGS "-gdwarf-2 -mthumb-interwork -mcpu=cortex-a9"
+#define CFG_TOOLSETS_ZC702EVK_CSGNU_ARM_ARCH_ASFLAGS "-gdwarf2 -meabi=4 -mcpu=cortex-a9 -mfpu=neon"
+#define CFG_TOOLSETS_ZC702EVK_CSGNU_ARM_ARCH_LDFLAGS ""
+#define CFG_TOOLSETS_ZC702EVK_CSGNU_ARM_ARCH_LDSCRIPT "$(TOOLSETS_HOME)/csgnu_arm.zc702evk.link_ram.ld"
+#define CFG_TOOLSETS_ZC702EVK_CSGNU_ARM_ARCH_ARFLAGS ""
+#define CFG_TOOLSETS_CSGNU_ARM_ENABLE
+#define CFG_TOOLSETS_CSGNU_ARM_CROSS "arm-xilinx-eabi-"
+#define CFG_TOOLSETS_CSGNU_ARM_CC "$(CROSS)gcc"
+#define CFG_TOOLSETS_CSGNU_ARM_CFLAGS "-Wall -ffunction-sections -fdata-sections"
+#define CFG_TOOLSETS_CSGNU_ARM_PROC_CFLAGS "-Wall -ffunction-sections -fdata-sections -fPIC -DNU_PROCESS"
+#define CFG_TOOLSETS_CSGNU_ARM_COMPILE "$(CC) $(patsubst %, -isystem %, $(SYSTEM_INCLUDE_PATH)) $(patsubst %, -I%, $(INCLUDE_PATH)) -I. -Wp,-MD,$(2:.o=.d.tmp) -c $(CFLAGS) $(ARCH_CFLAGS) $(CFLAGS_$(1)) $(1) -o $(2)"
+#define CFG_TOOLSETS_CSGNU_ARM_PROC_COMPILE "$(CC) $(patsubst %, -I%, $(INCLUDE_PATH)) -I. -Wp,-MD,$(2:.po=.pd.tmp) -c $(PROC_CFLAGS) $(ARCH_CFLAGS) $(CFLAGS_$(1)) $(1) -o $(2)"
+#define CFG_TOOLSETS_CSGNU_ARM_CXX "$(CROSS)g++"
+#define CFG_TOOLSETS_CSGNU_ARM_CXXFLAGS "-Wall -fno-enforce-eh-specs"
+#define CFG_TOOLSETS_CSGNU_ARM_PROC_CXXFLAGS "-Wall -fno-enforce-eh-specs -fPIC -DNU_PROCESS"
+#define CFG_TOOLSETS_CSGNU_ARM_COMPILECXX "$(CXX) $(patsubst %, -isystem %, $(SYSTEM_INCLUDE_PATH)) $(patsubst %, -I%, $(INCLUDE_PATH)) -I. -Wp,-MD,$(2:.o=.d.tmp) -c $(CXXFLAGS) $(ARCH_CXXFLAGS) $(CXXFLAGS_$(1)) $(1) -o $(2)"
+#define CFG_TOOLSETS_CSGNU_ARM_PROC_COMPILECXX "$(CXX) $(patsubst %, -I%, $(INCLUDE_PATH)) -I. -Wp,-MD,$(2:.po=.pd.tmp) -c $(PROC_CXXFLAGS) $(ARCH_CXXFLAGS) $(CXXFLAGS_$(1)) $(1) -o $(2)"
+#define CFG_TOOLSETS_CSGNU_ARM_AS "$(CROSS)as"
+#define CFG_TOOLSETS_CSGNU_ARM_ASFLAGS ""
+#define CFG_TOOLSETS_CSGNU_ARM_PROC_ASFLAGS ""
+#define CFG_TOOLSETS_CSGNU_ARM_ASSEMBLE "$(AS) $(patsubst %, -I%, $(INCLUDE_PATH)) -I. --MD $(2:.o=.d.tmp) $(ASFLAGS) $(ARCH_ASFLAGS) $(ASFLAGS_$(1)) $(1) -o $(2)"
+#define CFG_TOOLSETS_CSGNU_ARM_CPPASSEMBLE "$(CC) $(patsubst %, -I%, $(INCLUDE_PATH)) -I. -Wp,-MD,$(2:.o=.d.tmp) $(addprefix -Wa$(comma),$(ASFLAGS)) $(addprefix -Wa$(comma),$(ARCH_ASFLAGS)) $(addprefix -Wa$(comma),$(ASFLAGS_$(1))) -c -x assembler-with-cpp $(1) -o $(2)"
+#define CFG_TOOLSETS_CSGNU_ARM_PROC_ASSEMBLE "$(AS) $(patsubst %, -I%, $(INCLUDE_PATH)) -I. --MD $(2:.po=.pd.tmp) $(ASFLAGS) $(ARCH_ASFLAGS) $(ASFLAGS_$(1)) $(1) -o $(2)"
+#define CFG_TOOLSETS_CSGNU_ARM_PROC_CPPASSEMBLE "$(CC) $(patsubst %, -I%, $(INCLUDE_PATH)) -I. -Wp,-MD,$(2:.po=.pd.tmp) $(addprefix -Wa$(comma),$(ASFLAGS)) $(addprefix -Wa$(comma),$(ARCH_ASFLAGS)) $(addprefix -Wa$(comma),$(ASFLAGS_$(1))) -c $(1) -o $(2)"
+#define CFG_TOOLSETS_CSGNU_ARM_LD "$(CROSS)gcc"
+#define CFG_TOOLSETS_CSGNU_ARM_LDFLAGS "-nostartfiles -Wl,--gc-sections -Wl,--wrap=malloc -Wl,--wrap=calloc -Wl,--wrap=realloc -Wl,--wrap=free -Wl,--defsym -Wl,PAGE_SIZE=$(PAGE_SIZE)"
+#define CFG_TOOLSETS_CSGNU_ARM_PROC_LDFLAGS "-nostdlib -nostartfiles -Wl,--gc-sections -Wl,-pie -Wl,--warn-unresolved-symbols -Wl,--no-demangle -Wl,--nmagic -Wl,--defsym -Wl,PAGE_SIZE=$(PAGE_SIZE) -Wl,--defsym -Wl,NUCLEUS_VERSION=$(NUCLEUS_VERSION)"
+#define CFG_TOOLSETS_CSGNU_ARM_PROC_LDSCRIPT "$(SYSTEM_HOME)/os/toolset/csgnu_arm.process.ld"
+#define CFG_TOOLSETS_CSGNU_ARM_LINK "$(LD) -Wl,-Map=$(basename $(1)).map -o $(1) $(LDFLAGS) $(ARCH_LDFLAGS) $(LDFLAGS_$(notdir $(1))) -T$(LDSCRIPT_$(notdir $(1))) -Wl,--start-group $(2) -lc -lm -lstdc++ -Wl,--end-group"
+#define CFG_TOOLSETS_CSGNU_ARM_PROC_LINK "$(CROSS)nuproclink $(LD) $(basename $(1)).out $(basename $(1)).map -Wl,-Map=$(basename $(1)).map -o $(basename $(1)).out $(PROC_LDFLAGS) $(ARCH_PROC_LDFLAGS) $(LDFLAGS_$(notdir $(1))) -T$(PROC_LDSCRIPT) -Wl,--start-group @$(2) @$(3) -lstdc++ -lgcc -Wl,--end-group"
+#define CFG_TOOLSETS_CSGNU_ARM_AR "$(CROSS)ar"
+#define CFG_TOOLSETS_CSGNU_ARM_ARFLAGS ""
+#define CFG_TOOLSETS_CSGNU_ARM_ARCHIVE "$(AR) $(ARFLAGS) $(ARCH_ARFLAGS) -rc $(1) $(2)"
+#define CFG_TOOLSETS_CSGNU_ARM_POSTLD "$(CROSS)objcopy"
+#define CFG_TOOLSETS_CSGNU_ARM_PROC_POSTLD "$(CROSS)strip"
+#define CFG_TOOLSETS_CSGNU_ARM_POSTLINK "$(POSTLD) -O binary $(1) $(basename $(1)).bin"
+#define CFG_TOOLSETS_CSGNU_ARM_PROC_POSTLINK "$(PROC_POSTLD) -g --strip-unneeded -R .interp -R .dynamic -R .comment $(basename $(1)).out -o $(1)"
+#define CFG_NU_ENABLE
+#define CFG_NU_MAJOR_VERSION 2013
+#define CFG_NU_MINOR_VERSION 8
+#define CFG_NU_PATCH_VERSION 1
+#define CFG_NU_OS_ENABLE
+#undef CFG_NU_OS_NET_ENABLE
+#undef CFG_NU_OS_NET_SSL_ENABLE
+#undef CFG_NU_OS_NET_SSL_OPENSSL_ENABLE
+#undef CFG_NU_OS_NET_SSL_OPENSSL_SSL_ENABLE
+#undef CFG_NU_OS_NET_SSL_OPENSSL_CRYPTO_ENABLE
+#undef CFG_NU_OS_NET_SSL_OPENSSL_OPENSSL_UNIT_TESTS_ENABLE
+#undef CFG_NU_OS_NET_SSL_LITE_ENABLE
+#undef CFG_NU_OS_NET_DHCP_ENABLE
+#undef CFG_NU_OS_NET_DHCP_SERVER_ENABLE
+#undef CFG_NU_OS_NET_PROT_ENABLE
+#undef CFG_NU_OS_NET_PROT_TELNET_ENABLE
+#undef CFG_NU_OS_NET_PROT_TELNET_SHELL_ENABLE
+#undef CFG_NU_OS_NET_PROT_TELNET_SERVER_ENABLE
+#undef CFG_NU_OS_NET_PROT_TELNET_CORE_ENABLE
+#undef CFG_NU_OS_NET_PROT_TELNET_CLIENT_ENABLE
+#undef CFG_NU_OS_NET_PROT_TFTP_ENABLE
+#undef CFG_NU_OS_NET_PROT_TFTP_SHELL_ENABLE
+#undef CFG_NU_OS_NET_PROT_TFTP_SERVER_ENABLE
+#undef CFG_NU_OS_NET_PROT_TFTP_CLIENT_ENABLE
+#undef CFG_NU_OS_NET_PROT_FTP_ENABLE
+#undef CFG_NU_OS_NET_EMAIL_ENABLE
+#undef CFG_NU_OS_NET_EMAIL_SMTPC_ENABLE
+#undef CFG_NU_OS_NET_WPA_SUPP_ENABLE
+#undef CFG_NU_OS_NET_WPA_SUPP_SRC_ENABLE
+#undef CFG_NU_OS_NET_SSH_ENABLE
+#undef CFG_NU_OS_NET_SSH_LIBTOMMATH_ENABLE
+#undef CFG_NU_OS_NET_SSH_LIBTOMCRYPT_ENABLE
+#undef CFG_NU_OS_NET_SSH_DB_SSHSERVER_ENABLE
+#undef CFG_NU_OS_NET_SHELL_ENABLE
+#undef CFG_NU_OS_NET_SNMP_ENABLE
+#undef CFG_NU_OS_NET_SNTPC_ENABLE
+#undef CFG_NU_OS_NET_JSON_ENABLE
+#undef CFG_NU_OS_NET_STACK_ENABLE
+#undef CFG_NU_OS_NET_IPV6_ENABLE
+#undef CFG_NU_OS_NET_WEB_ENABLE
+#undef CFG_NU_OS_NET_NAT_ENABLE
+#undef CFG_NU_OS_NET_WSOX_ENABLE
+#undef CFG_NU_OS_NET_HTTP_ENABLE
+#undef CFG_NU_OS_NET_IKE_ENABLE
+#undef CFG_NU_OS_NET_IPSEC_ENABLE
+#undef CFG_NU_OS_CONN_ENABLE
+#undef CFG_NU_OS_CONN_USB_ENABLE
+#undef CFG_NU_OS_CONN_USB_FUNC_ENABLE
+#undef CFG_NU_OS_CONN_USB_FUNC_HID_ENABLE
+#undef CFG_NU_OS_CONN_USB_FUNC_HID_MSE_ENABLE
+#undef CFG_NU_OS_CONN_USB_FUNC_HID_CLASS_ENABLE
+#undef CFG_NU_OS_CONN_USB_FUNC_HID_KBD_ENABLE
+#undef CFG_NU_OS_CONN_USB_FUNC_COMM_ENABLE
+#undef CFG_NU_OS_CONN_USB_FUNC_COMM_CLASS_ENABLE
+#undef CFG_NU_OS_CONN_USB_FUNC_COMM_MDM_ENABLE
+#undef CFG_NU_OS_CONN_USB_FUNC_COMM_ETH_ENABLE
+#undef CFG_NU_OS_CONN_USB_FUNC_MS_ENABLE
+#undef CFG_NU_OS_CONN_USB_FUNC_MS_CLASS_ENABLE
+#undef CFG_NU_OS_CONN_USB_FUNC_MS_USER_ENABLE
+#undef CFG_NU_OS_CONN_USB_FUNC_DFU_ENABLE
+#undef CFG_NU_OS_CONN_USB_FUNC_STACK_ENABLE
+#undef CFG_NU_OS_CONN_USB_COM_ENABLE
+#undef CFG_NU_OS_CONN_USB_COM_STACK_ENABLE
+#undef CFG_NU_OS_CONN_USB_HOST_ENABLE
+#undef CFG_NU_OS_CONN_USB_HOST_COMM_ENABLE
+#undef CFG_NU_OS_CONN_USB_HOST_COMM_CLASS_ENABLE
+#undef CFG_NU_OS_CONN_USB_HOST_COMM_MDM_ENABLE
+#undef CFG_NU_OS_CONN_USB_HOST_COMM_ETH_ENABLE
+#undef CFG_NU_OS_CONN_USB_HOST_MS_ENABLE
+#undef CFG_NU_OS_CONN_USB_HOST_MS_CLASS_ENABLE
+#undef CFG_NU_OS_CONN_USB_HOST_MS_USER_ENABLE
+#undef CFG_NU_OS_CONN_USB_HOST_AUDIO_ENABLE
+#undef CFG_NU_OS_CONN_USB_HOST_AUDIO_CLASS_ENABLE
+#undef CFG_NU_OS_CONN_USB_HOST_AUDIO_USER_ENABLE
+#undef CFG_NU_OS_CONN_USB_HOST_HID_ENABLE
+#undef CFG_NU_OS_CONN_USB_HOST_HID_MOUSE_ENABLE
+#undef CFG_NU_OS_CONN_USB_HOST_HID_CLASS_ENABLE
+#undef CFG_NU_OS_CONN_USB_HOST_HID_KEYBOARD_ENABLE
+#undef CFG_NU_OS_CONN_USB_HOST_STACK_ENABLE
+#undef CFG_NU_OS_CONN_SDIO_ENABLE
+#undef CFG_NU_OS_CONN_I2C_ENABLE
+#undef CFG_NU_OS_CONN_SPI_ENABLE
+#undef CFG_NU_OS_CONN_LWSPI_ENABLE
+#undef CFG_NU_OS_CONN_CAN_ENABLE
+#define CFG_NU_OS_DRVR_ENABLE
+#undef CFG_NU_OS_DRVR_WLAN_ENABLE
+#undef CFG_NU_OS_DRVR_WLAN_AR4100_ENABLE
+#undef CFG_NU_OS_DRVR_WLAN_AR6K3_ENABLE
+#undef CFG_NU_OS_DRVR_WLAN_AR6K2_ENABLE
+#undef CFG_NU_OS_DRVR_USB_ENABLE
+#undef CFG_NU_OS_DRVR_USB_FUNC_ENABLE
+#undef CFG_NU_OS_DRVR_USB_FUNC_NET_IF_ENABLE
+#undef CFG_NU_OS_DRVR_USB_FUNC_HWCTRL_ENABLE
+#undef CFG_NU_OS_DRVR_USB_HOST_ENABLE
+#undef CFG_NU_OS_DRVR_USB_HOST_FILE_IF_ENABLE
+#undef CFG_NU_OS_DRVR_USB_HOST_NET_IF_ENABLE
+#undef CFG_NU_OS_DRVR_USB_HOST_OHCI_ENABLE
+#undef CFG_NU_OS_DRVR_USB_HOST_EHCI_ENABLE
+#undef CFG_NU_OS_DRVR_USB_HOST_USB_INPUT_ENABLE
+#undef CFG_NU_OS_DRVR_USB_HOST_HWCTRL_ENABLE
+#undef CFG_NU_OS_DRVR_USB_HOST_XHCI_ENABLE
+#undef CFG_NU_OS_DRVR_USB_OTG_ENABLE
+#undef CFG_NU_OS_DRVR_USB_OTG_HWCTRL_ENABLE
+#undef CFG_NU_OS_DRVR_SAFE_ENABLE
+#undef CFG_NU_OS_DRVR_SAFE_SRA_ENABLE
+#undef CFG_NU_OS_DRVR_SAFE_BASE_ENABLE
+#undef CFG_NU_OS_DRVR_SDIO_ENABLE
+#undef CFG_NU_OS_DRVR_SDIO_FUNC_ENABLE
+#undef CFG_NU_OS_DRVR_SDIO_FUNC_SD_ENABLE
+#undef CFG_NU_OS_DRVR_SDIO_HOST_ENABLE
+#undef CFG_NU_OS_DRVR_SDIO_HOST_HCD_ENABLE
+#undef CFG_NU_OS_DRVR_I2C_ENABLE
+#undef CFG_NU_OS_DRVR_SERIAL_ENABLE
+#undef CFG_NU_OS_DRVR_SPI_ENABLE
+#undef CFG_NU_OS_DRVR_LWSPI_ENABLE
+#undef CFG_NU_OS_DRVR_SYSLOGGER_ENABLE
+#undef CFG_NU_OS_DRVR_PPP_ENABLE
+#undef CFG_NU_OS_DRVR_TOUCHPANEL_ENABLE
+#define CFG_NU_OS_DRVR_CPU_ENABLE
+#define CFG_NU_OS_DRVR_CPU_VOLTAGE_SCALING 0
+#undef CFG_NU_OS_DRVR_HIBERNATE_ENABLE
+#undef CFG_NU_OS_DRVR_DISPLAY_ENABLE
+#undef CFG_NU_OS_DRVR_KEYPAD_ENABLE
+#undef CFG_NU_OS_DRVR_PWR_INTRF_ENABLE
+#undef CFG_NU_OS_DRVR_CAN_ENABLE
+#undef CFG_NU_OS_DRVR_DMA_ENABLE
+#undef CFG_NU_OS_DRVR_RTC_ENABLE
+#undef CFG_NU_OS_DRVR_FAT_RD_ENABLE
+#undef CFG_NU_OS_DRVR_ETH_ENABLE
+#define CFG_NU_OS_SVCS_ENABLE
+#undef CFG_NU_OS_SVCS_TRACE_ENABLE
+#undef CFG_NU_OS_SVCS_TRACE_CORE_ENABLE
+#undef CFG_NU_OS_SVCS_TRACE_COMMS_ENABLE
+#undef CFG_NU_OS_SVCS_PWR_ENABLE
+#undef CFG_NU_OS_SVCS_PWR_CORE_ENABLE
+#undef CFG_NU_OS_SVCS_POSIX_ENABLE
+#undef CFG_NU_OS_SVCS_POSIX_AIO_ENABLE
+#undef CFG_NU_OS_SVCS_POSIX_RTL_ENABLE
+#undef CFG_NU_OS_SVCS_POSIX_NET_ENABLE
+#undef CFG_NU_OS_SVCS_POSIX_FS_ENABLE
+#undef CFG_NU_OS_SVCS_POSIX_CORE_ENABLE
+#undef CFG_NU_OS_SVCS_SHELL_ENABLE
+#define CFG_NU_OS_SVCS_REGISTRY_ENABLE
+#define CFG_NU_OS_SVCS_REGISTRY_EXPORT_SYMBOLS 1
+#define CFG_NU_OS_SVCS_INIT_ENABLE
+#undef CFG_NU_OS_SVCS_CXX_ENABLE
+#undef CFG_NU_OS_SVCS_DBG_ENABLE
+#undef CFG_NU_OS_SVCS_SYSLOG_ENABLE
+#define CFG_NU_OS_SVCS_APPINIT_ENABLE
+#define CFG_NU_OS_SVCS_APPINIT_RUNLEVEL 31
+#undef CFG_NU_OS_SVCS_DBG_ADV_ENABLE
+#define CFG_NU_OS_KERN_ENABLE
+#undef CFG_NU_OS_KERN_PROCESS_ENABLE
+#undef CFG_NU_OS_KERN_PROCESS_MEM_MGMT_ENABLE
+#undef CFG_NU_OS_KERN_PROCESS_SHELL_ENABLE
+#undef CFG_NU_OS_KERN_PROCESS_USER_ENABLE
+#undef CFG_NU_OS_KERN_PROCESS_LINKLOAD_ENABLE
+#undef CFG_NU_OS_KERN_PROCESS_CORE_ENABLE
+#define CFG_NU_OS_KERN_PLUS_ENABLE
+#define CFG_NU_OS_KERN_PLUS_CORE_ENABLE
+#define CFG_NU_OS_KERN_PLUS_CORE_MIN_STACK_SIZE 250
+#define CFG_NU_OS_KERN_PLUS_CORE_STACK_CHECKING 0
+#define CFG_NU_OS_KERN_PLUS_CORE_STACK_FILL 0
+#define CFG_NU_OS_KERN_PLUS_CORE_ERROR_CHECKING 1
+#define CFG_NU_OS_KERN_PLUS_CORE_ASSERT 0
+#define CFG_NU_OS_KERN_PLUS_CORE_ERROR_STRING 0
+#define CFG_NU_OS_KERN_PLUS_CORE_GLOBAL_INT_LOCKING 0
+#define CFG_NU_OS_KERN_PLUS_CORE_MIN_RAM 0
+#define CFG_NU_OS_KERN_PLUS_CORE_TICK_SUPPRESSION 0
+#define CFG_NU_OS_KERN_PLUS_CORE_INLINING 0
+#define CFG_NU_OS_KERN_PLUS_CORE_ROM_TO_RAM_COPY 0
+#define CFG_NU_OS_KERN_PLUS_CORE_ROM_SUPPORT 0
+#define CFG_NU_OS_KERN_PLUS_CORE_NUM_TASK_PRIORITIES 256
+#define CFG_NU_OS_KERN_PLUS_CORE_LV_TIMEOUT 0
+#define CFG_NU_OS_KERN_PLUS_CORE_AUTO_CLEAR_CB 1
+#define CFG_NU_OS_KERN_PLUS_CORE_TIMER_HISR_STACK_SIZE 2048
+#define CFG_NU_OS_KERN_PLUS_CORE_TICKS_PER_SEC 100
+#define CFG_NU_OS_KERN_PLUS_CORE_EXPORT_SYMBOLS 1
+#define CFG_NU_OS_KERN_PLUS_CORE_DEBUG_SCHED_LOCK 0
+#define CFG_NU_OS_KERN_PLUS_SUPPLEMENT_ENABLE
+#define CFG_NU_OS_KERN_PLUS_SUPPLEMENT_PLUS_OBJECT_LISTS 0
+#define CFG_NU_OS_KERN_PLUS_SUPPLEMENT_TIME_TEST1MIN 0
+#define CFG_NU_OS_KERN_PLUS_SUPPLEMENT_TIME_TEST1MAX 0
+#define CFG_NU_OS_KERN_PLUS_SUPPLEMENT_TIME_TEST2 0
+#define CFG_NU_OS_KERN_PLUS_SUPPLEMENT_TIME_TEST3 0
+#define CFG_NU_OS_KERN_PLUS_SUPPLEMENT_STATIC_TEST 0
+#define CFG_NU_OS_KERN_PLUS_SUPPLEMENT_EVT_NOTIFY 1
+#define CFG_NU_OS_KERN_PLUS_SUPPLEMENT_EXPORT_SYMBOLS 1
+#undef CFG_NU_OS_KERN_IPC_ENABLE
+#undef CFG_NU_OS_KERN_IPC_MCAPI_ENABLE
+#undef CFG_NU_OS_KERN_IPC_MCAPI_SHM_ENABLE
+#define CFG_NU_OS_KERN_RTL_ENABLE
+#define CFG_NU_OS_KERN_RTL_MALLOC_POOL 0
+#define CFG_NU_OS_KERN_RTL_FP_OVERRIDE 0
+#define CFG_NU_OS_KERN_RTL_HEAP_SIZE 4096
+#define CFG_NU_OS_KERN_RTL_EXPORT_SYMBOLS 1
+#define CFG_NU_OS_KERN_EQM_ENABLE
+#define CFG_NU_OS_KERN_DEVMGR_ENABLE
+#define CFG_NU_OS_KERN_DEVMGR_RUNLEVEL 1
+#define CFG_NU_OS_KERN_DEVMGR_MAX_DEV_LABEL_CNT 5
+#define CFG_NU_OS_KERN_DEVMGR_MAX_DEV_SESSION_CNT 3
+#define CFG_NU_OS_KERN_DEVMGR_MAX_DEVICE_LISTENERS 15
+#define CFG_NU_OS_KERN_DEVMGR_ERR_CHECK_ENABLE 1
+#define CFG_NU_OS_KERN_DEVMGR_DISCOVERY_TASK_ENABLE 1
+#define CFG_NU_OS_KERN_DEVMGR_DISCOVERY_TASK_MAX_ID_CNT 30
+#define CFG_NU_OS_KERN_DEVMGR_DISCOVERY_TASK_STACK_SIZE 10240
+#define CFG_NU_OS_KERN_DEVMGR_EXPORT_SYMBOLS 1
+#undef CFG_NU_OS_UI_ENABLE
+#undef CFG_NU_OS_UI_IFX_ENABLE
+#undef CFG_NU_OS_UI_IFX_MOD_ENABLE
+#undef CFG_NU_OS_UI_IFX_MOD_SIMPLEEDIT_ENABLE
+#undef CFG_NU_OS_UI_IFX_FRAMEWORK_ENABLE
+#undef CFG_NU_OS_UI_IFX_ENG_ENABLE
+#undef CFG_NU_OS_UI_IFX_PORT_ENABLE
+#undef CFG_NU_OS_UI_IFX_UCDN_ENABLE
+#undef CFG_NU_OS_UI_IFX_HARFBUZZ_ENABLE
+#undef CFG_NU_OS_UI_IFX_FREETYPE_ENABLE
+#undef CFG_NU_OS_UI_IFX_NUBIDI_ENABLE
+#undef CFG_NU_OS_UI_IMAGE_ENABLE
+#undef CFG_NU_OS_UI_INPUT_MGMT_ENABLE
+#undef CFG_NU_OS_UI_GRAFIXRS_ENABLE
+#undef CFG_NU_OS_STOR_ENABLE
+#undef CFG_NU_OS_STOR_FILE_ENABLE
+#undef CFG_NU_OS_STOR_FILE_FS_ENABLE
+#undef CFG_NU_OS_STOR_FILE_FS_FAT_ENABLE
+#undef CFG_NU_OS_STOR_FILE_FS_SAFE_ENABLE
+#undef CFG_NU_OS_STOR_FILE_SHELL_ENABLE
+#undef CFG_NU_OS_STOR_FILE_VFS_ENABLE
+#undef CFG_NU_OS_STOR_DB_ENABLE
+#undef CFG_NU_OS_STOR_DB_SQLITE_ENABLE
+#define CFG_NU_OS_ARCH_ENABLE
+#define CFG_NU_OS_ARCH_ARM_ENABLE
+#undef CFG_NU_OS_ARCH_ARM_PROCESS_ENABLE
+#undef CFG_NU_OS_ARCH_ARM_PROCESS_MEM_MGMT_ENABLE
+#undef CFG_NU_OS_ARCH_ARM_PROCESS_LINKLOAD_ENABLE
+#undef CFG_NU_OS_ARCH_ARM_PROCESS_CORE_ENABLE
+#define CFG_NU_OS_ARCH_ARM_CSGNU_ENABLE
+#define CFG_NU_OS_ARCH_ARM_COM_ENABLE
+#define CFG_NU_OS_ARCH_ARM_COM_MMU_VARIANT 1
+#define CFG_NU_OS_ARCH_ARM_COM_SYSTEM_STACK_SIZE 2048
+#define CFG_NU_OS_ARCH_ARM_COM_FPU_SUPPORT 2
+#define CFG_NU_OS_ARCH_ARM_COM_V6V7_CACHE_LINE_SIZE 64
+#define CFG_NU_BSP_ENABLE
+#undef CFG_NU_BSP_DRVR_ENABLE
+#undef CFG_NU_BSP_DRVR_SERIAL_ENABLE
+#undef CFG_NU_BSP_DRVR_SERIAL_ZYNQ_UART_ENABLE
+#undef CFG_NU_BSP_DRVR_CPU_ENABLE
+#define CFG_NU_BSP_DRVR_CPU_ZYNQ7000_ENABLE
+#undef CFG_NU_BSP_DRVR_CAN_ENABLE
+#undef CFG_NU_BSP_DRVR_CAN_ZYNQ_CAN_ENABLE
+#undef CFG_NU_BSP_DRVR_ETHERNET_ENABLE
+#undef CFG_NU_BSP_DRVR_ETHERNET_ZYNQ_ETH_ENABLE
+#define CFG_NU_BSP_ZC702EVK_ENABLE
+#define CFG_NU_BSP_ZC702EVK_AMP_REMOTE 1
+#define CFG_NU_BSP_ARCH_ENABLE
+#define CFG_ZC702EVK_ENABLE
+#undef CFG_ZC702EVK_SERIAL0_ENABLE
+#define CFG_ZC702EVK_CPU0_ENABLE
+#define CFG_ZC702EVK_CPU0_RUNLEVEL 2
+#undef CFG_ZC702EVK_CAN0_ENABLE
+#undef CFG_ZC702EVK_ETHERNET0_ENABLE
+#define CFG_ZC702EVK_REMOTE_PROC0_ENABLE
+#define CFG_ZC702EVK_REMOTE_PROC1_ENABLE
+#undef CFG_ZC702EVK_RAMDISK0_ENABLE
+#endif /* NUCLEUS_GEN_CFG_H */
diff --git a/libs/system/zc702evk/nucleus/lib/arm-xilinx-eabi-/remote_proxy/libnucleus_remote.a b/libs/system/zc702evk/nucleus/lib/arm-xilinx-eabi-/remote_proxy/libnucleus_remote.a
new file mode 100644 (file)
index 0000000..a0c94fe
Binary files /dev/null and b/libs/system/zc702evk/nucleus/lib/arm-xilinx-eabi-/remote_proxy/libnucleus_remote.a differ
index 0000000..a0c94fe
Binary files /dev/null and b/libs/system/zc702evk/nucleus/lib/arm-xilinx-eabi-/remote_proxy/libnucleus_remote.a differ
diff --git a/libs/system/zc702evk/nucleus/lib/arm-xilinx-eabi-/remote_proxy/nucleus_gen_cfg.h b/libs/system/zc702evk/nucleus/lib/arm-xilinx-eabi-/remote_proxy/nucleus_gen_cfg.h
--- /dev/null
@@ -0,0 +1,346 @@
+/***********************************************************************
+*
+* Copyright 1993 Mentor Graphics Corporation
+* All Rights Reserved.
+*
+* THIS WORK CONTAINS TRADE SECRET AND PROPRIETARY INFORMATION WHICH IS
+* THE PROPERTY OF MENTOR GRAPHICS CORPORATION OR ITS LICENSORS AND IS
+* SUBJECT TO LICENSE TERMS.
+*
+************************************************************************
+
+************************************************************************
+*
+* FILE NAME
+*
+* nucleus_gen_cfg.h
+*
+* COMPONENT
+*
+* Nucleus OS
+*
+* DESCRIPTION
+*
+* This file contains auto-generated configuration settings for
+* the Nucleus OS. DO NOT MODIFY.
+*
+* DATA STRUCTURES
+*
+* None
+*
+* DEPENDENCIES
+*
+* None
+*
+************************************************************************/
+/* Generated: Thu Sep 25 15:14:43 +0500 2014 */
+/* DO NOT MODIFY - This file is auto-generated */
+#ifndef NUCLEUS_GEN_CFG_H
+#define NUCLEUS_GEN_CFG_H
+#define CFG_NU_OS_SVCS_REGISTRY_MAX_KEY_LEN 49
+#define CFG_TOOLSETS_ENABLE
+#define CFG_TOOLSETS_ZC702EVK_ENABLE
+#define CFG_TOOLSETS_ZC702EVK_CSGNU_ARM_ENABLE
+#define CFG_TOOLSETS_ZC702EVK_CSGNU_ARM_ARCH_CFLAGS "-gdwarf-2 -mthumb-interwork -mcpu=cortex-a9"
+#define CFG_TOOLSETS_ZC702EVK_CSGNU_ARM_ARCH_CXXFLAGS "-gdwarf-2 -mthumb-interwork -mcpu=cortex-a9"
+#define CFG_TOOLSETS_ZC702EVK_CSGNU_ARM_ARCH_ASFLAGS "-gdwarf2 -meabi=4 -mcpu=cortex-a9 -mfpu=neon"
+#define CFG_TOOLSETS_ZC702EVK_CSGNU_ARM_ARCH_LDFLAGS ""
+#define CFG_TOOLSETS_ZC702EVK_CSGNU_ARM_ARCH_LDSCRIPT "$(TOOLSETS_HOME)/csgnu_arm.zc702evk.link_ram.ld"
+#define CFG_TOOLSETS_ZC702EVK_CSGNU_ARM_ARCH_ARFLAGS ""
+#define CFG_TOOLSETS_CSGNU_ARM_ENABLE
+#define CFG_TOOLSETS_CSGNU_ARM_CROSS "arm-xilinx-eabi-"
+#define CFG_TOOLSETS_CSGNU_ARM_CC "$(CROSS)gcc"
+#define CFG_TOOLSETS_CSGNU_ARM_CFLAGS "-Wall -ffunction-sections -fdata-sections"
+#define CFG_TOOLSETS_CSGNU_ARM_PROC_CFLAGS "-Wall -ffunction-sections -fdata-sections -fPIC -DNU_PROCESS"
+#define CFG_TOOLSETS_CSGNU_ARM_COMPILE "$(CC) $(patsubst %, -isystem %, $(SYSTEM_INCLUDE_PATH)) $(patsubst %, -I%, $(INCLUDE_PATH)) -I. -Wp,-MD,$(2:.o=.d.tmp) -c $(CFLAGS) $(ARCH_CFLAGS) $(CFLAGS_$(1)) $(1) -o $(2)"
+#define CFG_TOOLSETS_CSGNU_ARM_PROC_COMPILE "$(CC) $(patsubst %, -I%, $(INCLUDE_PATH)) -I. -Wp,-MD,$(2:.po=.pd.tmp) -c $(PROC_CFLAGS) $(ARCH_CFLAGS) $(CFLAGS_$(1)) $(1) -o $(2)"
+#define CFG_TOOLSETS_CSGNU_ARM_CXX "$(CROSS)g++"
+#define CFG_TOOLSETS_CSGNU_ARM_CXXFLAGS "-Wall -fno-enforce-eh-specs"
+#define CFG_TOOLSETS_CSGNU_ARM_PROC_CXXFLAGS "-Wall -fno-enforce-eh-specs -fPIC -DNU_PROCESS"
+#define CFG_TOOLSETS_CSGNU_ARM_COMPILECXX "$(CXX) $(patsubst %, -isystem %, $(SYSTEM_INCLUDE_PATH)) $(patsubst %, -I%, $(INCLUDE_PATH)) -I. -Wp,-MD,$(2:.o=.d.tmp) -c $(CXXFLAGS) $(ARCH_CXXFLAGS) $(CXXFLAGS_$(1)) $(1) -o $(2)"
+#define CFG_TOOLSETS_CSGNU_ARM_PROC_COMPILECXX "$(CXX) $(patsubst %, -I%, $(INCLUDE_PATH)) -I. -Wp,-MD,$(2:.po=.pd.tmp) -c $(PROC_CXXFLAGS) $(ARCH_CXXFLAGS) $(CXXFLAGS_$(1)) $(1) -o $(2)"
+#define CFG_TOOLSETS_CSGNU_ARM_AS "$(CROSS)as"
+#define CFG_TOOLSETS_CSGNU_ARM_ASFLAGS ""
+#define CFG_TOOLSETS_CSGNU_ARM_PROC_ASFLAGS ""
+#define CFG_TOOLSETS_CSGNU_ARM_ASSEMBLE "$(AS) $(patsubst %, -I%, $(INCLUDE_PATH)) -I. --MD $(2:.o=.d.tmp) $(ASFLAGS) $(ARCH_ASFLAGS) $(ASFLAGS_$(1)) $(1) -o $(2)"
+#define CFG_TOOLSETS_CSGNU_ARM_CPPASSEMBLE "$(CC) $(patsubst %, -I%, $(INCLUDE_PATH)) -I. -Wp,-MD,$(2:.o=.d.tmp) $(addprefix -Wa$(comma),$(ASFLAGS)) $(addprefix -Wa$(comma),$(ARCH_ASFLAGS)) $(addprefix -Wa$(comma),$(ASFLAGS_$(1))) -c -x assembler-with-cpp $(1) -o $(2)"
+#define CFG_TOOLSETS_CSGNU_ARM_PROC_ASSEMBLE "$(AS) $(patsubst %, -I%, $(INCLUDE_PATH)) -I. --MD $(2:.po=.pd.tmp) $(ASFLAGS) $(ARCH_ASFLAGS) $(ASFLAGS_$(1)) $(1) -o $(2)"
+#define CFG_TOOLSETS_CSGNU_ARM_PROC_CPPASSEMBLE "$(CC) $(patsubst %, -I%, $(INCLUDE_PATH)) -I. -Wp,-MD,$(2:.po=.pd.tmp) $(addprefix -Wa$(comma),$(ASFLAGS)) $(addprefix -Wa$(comma),$(ARCH_ASFLAGS)) $(addprefix -Wa$(comma),$(ASFLAGS_$(1))) -c $(1) -o $(2)"
+#define CFG_TOOLSETS_CSGNU_ARM_LD "$(CROSS)gcc"
+#define CFG_TOOLSETS_CSGNU_ARM_LDFLAGS "-nostartfiles -Wl,--gc-sections -Wl,--wrap=malloc -Wl,--wrap=calloc -Wl,--wrap=realloc -Wl,--wrap=free -Wl,--defsym -Wl,PAGE_SIZE=$(PAGE_SIZE)"
+#define CFG_TOOLSETS_CSGNU_ARM_PROC_LDFLAGS "-nostdlib -nostartfiles -Wl,--gc-sections -Wl,-pie -Wl,--warn-unresolved-symbols -Wl,--no-demangle -Wl,--nmagic -Wl,--defsym -Wl,PAGE_SIZE=$(PAGE_SIZE) -Wl,--defsym -Wl,NUCLEUS_VERSION=$(NUCLEUS_VERSION)"
+#define CFG_TOOLSETS_CSGNU_ARM_PROC_LDSCRIPT "$(SYSTEM_HOME)/os/toolset/csgnu_arm.process.ld"
+#define CFG_TOOLSETS_CSGNU_ARM_LINK "$(LD) -Wl,-Map=$(basename $(1)).map -o $(1) $(LDFLAGS) $(ARCH_LDFLAGS) $(LDFLAGS_$(notdir $(1))) -T$(LDSCRIPT_$(notdir $(1))) -Wl,--start-group $(2) -lc -lm -lstdc++ -Wl,--end-group"
+#define CFG_TOOLSETS_CSGNU_ARM_PROC_LINK "$(CROSS)nuproclink $(LD) $(basename $(1)).out $(basename $(1)).map -Wl,-Map=$(basename $(1)).map -o $(basename $(1)).out $(PROC_LDFLAGS) $(ARCH_PROC_LDFLAGS) $(LDFLAGS_$(notdir $(1))) -T$(PROC_LDSCRIPT) -Wl,--start-group @$(2) @$(3) -lstdc++ -lgcc -Wl,--end-group"
+#define CFG_TOOLSETS_CSGNU_ARM_AR "$(CROSS)ar"
+#define CFG_TOOLSETS_CSGNU_ARM_ARFLAGS ""
+#define CFG_TOOLSETS_CSGNU_ARM_ARCHIVE "$(AR) $(ARFLAGS) $(ARCH_ARFLAGS) -rc $(1) $(2)"
+#define CFG_TOOLSETS_CSGNU_ARM_POSTLD "$(CROSS)objcopy"
+#define CFG_TOOLSETS_CSGNU_ARM_PROC_POSTLD "$(CROSS)strip"
+#define CFG_TOOLSETS_CSGNU_ARM_POSTLINK "$(POSTLD) -O binary $(1) $(basename $(1)).bin"
+#define CFG_TOOLSETS_CSGNU_ARM_PROC_POSTLINK "$(PROC_POSTLD) -g --strip-unneeded -R .interp -R .dynamic -R .comment $(basename $(1)).out -o $(1)"
+#define CFG_NU_ENABLE
+#define CFG_NU_MAJOR_VERSION 2013
+#define CFG_NU_MINOR_VERSION 8
+#define CFG_NU_PATCH_VERSION 1
+#define CFG_NU_OS_ENABLE
+#undef CFG_NU_OS_NET_ENABLE
+#undef CFG_NU_OS_NET_SSL_ENABLE
+#undef CFG_NU_OS_NET_SSL_OPENSSL_ENABLE
+#undef CFG_NU_OS_NET_SSL_OPENSSL_SSL_ENABLE
+#undef CFG_NU_OS_NET_SSL_OPENSSL_CRYPTO_ENABLE
+#undef CFG_NU_OS_NET_SSL_OPENSSL_OPENSSL_UNIT_TESTS_ENABLE
+#undef CFG_NU_OS_NET_SSL_LITE_ENABLE
+#undef CFG_NU_OS_NET_DHCP_ENABLE
+#undef CFG_NU_OS_NET_DHCP_SERVER_ENABLE
+#undef CFG_NU_OS_NET_PROT_ENABLE
+#undef CFG_NU_OS_NET_PROT_TELNET_ENABLE
+#undef CFG_NU_OS_NET_PROT_TELNET_SHELL_ENABLE
+#undef CFG_NU_OS_NET_PROT_TELNET_SERVER_ENABLE
+#undef CFG_NU_OS_NET_PROT_TELNET_CORE_ENABLE
+#undef CFG_NU_OS_NET_PROT_TELNET_CLIENT_ENABLE
+#undef CFG_NU_OS_NET_PROT_TFTP_ENABLE
+#undef CFG_NU_OS_NET_PROT_TFTP_SHELL_ENABLE
+#undef CFG_NU_OS_NET_PROT_TFTP_SERVER_ENABLE
+#undef CFG_NU_OS_NET_PROT_TFTP_CLIENT_ENABLE
+#undef CFG_NU_OS_NET_PROT_FTP_ENABLE
+#undef CFG_NU_OS_NET_EMAIL_ENABLE
+#undef CFG_NU_OS_NET_EMAIL_SMTPC_ENABLE
+#undef CFG_NU_OS_NET_WPA_SUPP_ENABLE
+#undef CFG_NU_OS_NET_WPA_SUPP_SRC_ENABLE
+#undef CFG_NU_OS_NET_SSH_ENABLE
+#undef CFG_NU_OS_NET_SSH_LIBTOMMATH_ENABLE
+#undef CFG_NU_OS_NET_SSH_LIBTOMCRYPT_ENABLE
+#undef CFG_NU_OS_NET_SSH_DB_SSHSERVER_ENABLE
+#undef CFG_NU_OS_NET_SHELL_ENABLE
+#undef CFG_NU_OS_NET_SNMP_ENABLE
+#undef CFG_NU_OS_NET_SNTPC_ENABLE
+#undef CFG_NU_OS_NET_JSON_ENABLE
+#undef CFG_NU_OS_NET_STACK_ENABLE
+#undef CFG_NU_OS_NET_IPV6_ENABLE
+#undef CFG_NU_OS_NET_WEB_ENABLE
+#undef CFG_NU_OS_NET_NAT_ENABLE
+#undef CFG_NU_OS_NET_WSOX_ENABLE
+#undef CFG_NU_OS_NET_HTTP_ENABLE
+#undef CFG_NU_OS_NET_IKE_ENABLE
+#undef CFG_NU_OS_NET_IPSEC_ENABLE
+#undef CFG_NU_OS_CONN_ENABLE
+#undef CFG_NU_OS_CONN_USB_ENABLE
+#undef CFG_NU_OS_CONN_USB_FUNC_ENABLE
+#undef CFG_NU_OS_CONN_USB_FUNC_HID_ENABLE
+#undef CFG_NU_OS_CONN_USB_FUNC_HID_MSE_ENABLE
+#undef CFG_NU_OS_CONN_USB_FUNC_HID_CLASS_ENABLE
+#undef CFG_NU_OS_CONN_USB_FUNC_HID_KBD_ENABLE
+#undef CFG_NU_OS_CONN_USB_FUNC_COMM_ENABLE
+#undef CFG_NU_OS_CONN_USB_FUNC_COMM_CLASS_ENABLE
+#undef CFG_NU_OS_CONN_USB_FUNC_COMM_MDM_ENABLE
+#undef CFG_NU_OS_CONN_USB_FUNC_COMM_ETH_ENABLE
+#undef CFG_NU_OS_CONN_USB_FUNC_MS_ENABLE
+#undef CFG_NU_OS_CONN_USB_FUNC_MS_CLASS_ENABLE
+#undef CFG_NU_OS_CONN_USB_FUNC_MS_USER_ENABLE
+#undef CFG_NU_OS_CONN_USB_FUNC_DFU_ENABLE
+#undef CFG_NU_OS_CONN_USB_FUNC_STACK_ENABLE
+#undef CFG_NU_OS_CONN_USB_COM_ENABLE
+#undef CFG_NU_OS_CONN_USB_COM_STACK_ENABLE
+#undef CFG_NU_OS_CONN_USB_HOST_ENABLE
+#undef CFG_NU_OS_CONN_USB_HOST_COMM_ENABLE
+#undef CFG_NU_OS_CONN_USB_HOST_COMM_CLASS_ENABLE
+#undef CFG_NU_OS_CONN_USB_HOST_COMM_MDM_ENABLE
+#undef CFG_NU_OS_CONN_USB_HOST_COMM_ETH_ENABLE
+#undef CFG_NU_OS_CONN_USB_HOST_MS_ENABLE
+#undef CFG_NU_OS_CONN_USB_HOST_MS_CLASS_ENABLE
+#undef CFG_NU_OS_CONN_USB_HOST_MS_USER_ENABLE
+#undef CFG_NU_OS_CONN_USB_HOST_AUDIO_ENABLE
+#undef CFG_NU_OS_CONN_USB_HOST_AUDIO_CLASS_ENABLE
+#undef CFG_NU_OS_CONN_USB_HOST_AUDIO_USER_ENABLE
+#undef CFG_NU_OS_CONN_USB_HOST_HID_ENABLE
+#undef CFG_NU_OS_CONN_USB_HOST_HID_MOUSE_ENABLE
+#undef CFG_NU_OS_CONN_USB_HOST_HID_CLASS_ENABLE
+#undef CFG_NU_OS_CONN_USB_HOST_HID_KEYBOARD_ENABLE
+#undef CFG_NU_OS_CONN_USB_HOST_STACK_ENABLE
+#undef CFG_NU_OS_CONN_SDIO_ENABLE
+#undef CFG_NU_OS_CONN_I2C_ENABLE
+#undef CFG_NU_OS_CONN_SPI_ENABLE
+#undef CFG_NU_OS_CONN_LWSPI_ENABLE
+#undef CFG_NU_OS_CONN_CAN_ENABLE
+#define CFG_NU_OS_DRVR_ENABLE
+#undef CFG_NU_OS_DRVR_WLAN_ENABLE
+#undef CFG_NU_OS_DRVR_WLAN_AR4100_ENABLE
+#undef CFG_NU_OS_DRVR_WLAN_AR6K3_ENABLE
+#undef CFG_NU_OS_DRVR_WLAN_AR6K2_ENABLE
+#undef CFG_NU_OS_DRVR_USB_ENABLE
+#undef CFG_NU_OS_DRVR_USB_FUNC_ENABLE
+#undef CFG_NU_OS_DRVR_USB_FUNC_NET_IF_ENABLE
+#undef CFG_NU_OS_DRVR_USB_FUNC_HWCTRL_ENABLE
+#undef CFG_NU_OS_DRVR_USB_HOST_ENABLE
+#undef CFG_NU_OS_DRVR_USB_HOST_FILE_IF_ENABLE
+#undef CFG_NU_OS_DRVR_USB_HOST_NET_IF_ENABLE
+#undef CFG_NU_OS_DRVR_USB_HOST_OHCI_ENABLE
+#undef CFG_NU_OS_DRVR_USB_HOST_EHCI_ENABLE
+#undef CFG_NU_OS_DRVR_USB_HOST_USB_INPUT_ENABLE
+#undef CFG_NU_OS_DRVR_USB_HOST_HWCTRL_ENABLE
+#undef CFG_NU_OS_DRVR_USB_HOST_XHCI_ENABLE
+#undef CFG_NU_OS_DRVR_USB_OTG_ENABLE
+#undef CFG_NU_OS_DRVR_USB_OTG_HWCTRL_ENABLE
+#undef CFG_NU_OS_DRVR_SAFE_ENABLE
+#undef CFG_NU_OS_DRVR_SAFE_SRA_ENABLE
+#undef CFG_NU_OS_DRVR_SAFE_BASE_ENABLE
+#undef CFG_NU_OS_DRVR_SDIO_ENABLE
+#undef CFG_NU_OS_DRVR_SDIO_FUNC_ENABLE
+#undef CFG_NU_OS_DRVR_SDIO_FUNC_SD_ENABLE
+#undef CFG_NU_OS_DRVR_SDIO_HOST_ENABLE
+#undef CFG_NU_OS_DRVR_SDIO_HOST_HCD_ENABLE
+#undef CFG_NU_OS_DRVR_I2C_ENABLE
+#undef CFG_NU_OS_DRVR_SERIAL_ENABLE
+#undef CFG_NU_OS_DRVR_SPI_ENABLE
+#undef CFG_NU_OS_DRVR_LWSPI_ENABLE
+#undef CFG_NU_OS_DRVR_SYSLOGGER_ENABLE
+#undef CFG_NU_OS_DRVR_PPP_ENABLE
+#undef CFG_NU_OS_DRVR_TOUCHPANEL_ENABLE
+#define CFG_NU_OS_DRVR_CPU_ENABLE
+#define CFG_NU_OS_DRVR_CPU_VOLTAGE_SCALING 0
+#undef CFG_NU_OS_DRVR_HIBERNATE_ENABLE
+#undef CFG_NU_OS_DRVR_DISPLAY_ENABLE
+#undef CFG_NU_OS_DRVR_KEYPAD_ENABLE
+#undef CFG_NU_OS_DRVR_PWR_INTRF_ENABLE
+#undef CFG_NU_OS_DRVR_CAN_ENABLE
+#undef CFG_NU_OS_DRVR_DMA_ENABLE
+#undef CFG_NU_OS_DRVR_RTC_ENABLE
+#undef CFG_NU_OS_DRVR_FAT_RD_ENABLE
+#undef CFG_NU_OS_DRVR_ETH_ENABLE
+#define CFG_NU_OS_SVCS_ENABLE
+#undef CFG_NU_OS_SVCS_TRACE_ENABLE
+#undef CFG_NU_OS_SVCS_TRACE_CORE_ENABLE
+#undef CFG_NU_OS_SVCS_TRACE_COMMS_ENABLE
+#undef CFG_NU_OS_SVCS_PWR_ENABLE
+#undef CFG_NU_OS_SVCS_PWR_CORE_ENABLE
+#undef CFG_NU_OS_SVCS_POSIX_ENABLE
+#undef CFG_NU_OS_SVCS_POSIX_AIO_ENABLE
+#undef CFG_NU_OS_SVCS_POSIX_RTL_ENABLE
+#undef CFG_NU_OS_SVCS_POSIX_NET_ENABLE
+#undef CFG_NU_OS_SVCS_POSIX_FS_ENABLE
+#undef CFG_NU_OS_SVCS_POSIX_CORE_ENABLE
+#undef CFG_NU_OS_SVCS_SHELL_ENABLE
+#define CFG_NU_OS_SVCS_REGISTRY_ENABLE
+#define CFG_NU_OS_SVCS_REGISTRY_EXPORT_SYMBOLS 1
+#define CFG_NU_OS_SVCS_INIT_ENABLE
+#undef CFG_NU_OS_SVCS_CXX_ENABLE
+#undef CFG_NU_OS_SVCS_DBG_ENABLE
+#undef CFG_NU_OS_SVCS_SYSLOG_ENABLE
+#define CFG_NU_OS_SVCS_APPINIT_ENABLE
+#define CFG_NU_OS_SVCS_APPINIT_RUNLEVEL 31
+#undef CFG_NU_OS_SVCS_DBG_ADV_ENABLE
+#define CFG_NU_OS_KERN_ENABLE
+#undef CFG_NU_OS_KERN_PROCESS_ENABLE
+#undef CFG_NU_OS_KERN_PROCESS_MEM_MGMT_ENABLE
+#undef CFG_NU_OS_KERN_PROCESS_SHELL_ENABLE
+#undef CFG_NU_OS_KERN_PROCESS_USER_ENABLE
+#undef CFG_NU_OS_KERN_PROCESS_LINKLOAD_ENABLE
+#undef CFG_NU_OS_KERN_PROCESS_CORE_ENABLE
+#define CFG_NU_OS_KERN_PLUS_ENABLE
+#define CFG_NU_OS_KERN_PLUS_CORE_ENABLE
+#define CFG_NU_OS_KERN_PLUS_CORE_MIN_STACK_SIZE 250
+#define CFG_NU_OS_KERN_PLUS_CORE_STACK_CHECKING 0
+#define CFG_NU_OS_KERN_PLUS_CORE_STACK_FILL 0
+#define CFG_NU_OS_KERN_PLUS_CORE_ERROR_CHECKING 1
+#define CFG_NU_OS_KERN_PLUS_CORE_ASSERT 0
+#define CFG_NU_OS_KERN_PLUS_CORE_ERROR_STRING 0
+#define CFG_NU_OS_KERN_PLUS_CORE_GLOBAL_INT_LOCKING 0
+#define CFG_NU_OS_KERN_PLUS_CORE_MIN_RAM 0
+#define CFG_NU_OS_KERN_PLUS_CORE_TICK_SUPPRESSION 0
+#define CFG_NU_OS_KERN_PLUS_CORE_INLINING 0
+#define CFG_NU_OS_KERN_PLUS_CORE_ROM_TO_RAM_COPY 0
+#define CFG_NU_OS_KERN_PLUS_CORE_ROM_SUPPORT 0
+#define CFG_NU_OS_KERN_PLUS_CORE_NUM_TASK_PRIORITIES 256
+#define CFG_NU_OS_KERN_PLUS_CORE_LV_TIMEOUT 0
+#define CFG_NU_OS_KERN_PLUS_CORE_AUTO_CLEAR_CB 1
+#define CFG_NU_OS_KERN_PLUS_CORE_TIMER_HISR_STACK_SIZE 2048
+#define CFG_NU_OS_KERN_PLUS_CORE_TICKS_PER_SEC 100
+#define CFG_NU_OS_KERN_PLUS_CORE_EXPORT_SYMBOLS 1
+#define CFG_NU_OS_KERN_PLUS_CORE_DEBUG_SCHED_LOCK 0
+#define CFG_NU_OS_KERN_PLUS_SUPPLEMENT_ENABLE
+#define CFG_NU_OS_KERN_PLUS_SUPPLEMENT_PLUS_OBJECT_LISTS 0
+#define CFG_NU_OS_KERN_PLUS_SUPPLEMENT_TIME_TEST1MIN 0
+#define CFG_NU_OS_KERN_PLUS_SUPPLEMENT_TIME_TEST1MAX 0
+#define CFG_NU_OS_KERN_PLUS_SUPPLEMENT_TIME_TEST2 0
+#define CFG_NU_OS_KERN_PLUS_SUPPLEMENT_TIME_TEST3 0
+#define CFG_NU_OS_KERN_PLUS_SUPPLEMENT_STATIC_TEST 0
+#define CFG_NU_OS_KERN_PLUS_SUPPLEMENT_EVT_NOTIFY 1
+#define CFG_NU_OS_KERN_PLUS_SUPPLEMENT_EXPORT_SYMBOLS 1
+#undef CFG_NU_OS_KERN_IPC_ENABLE
+#undef CFG_NU_OS_KERN_IPC_MCAPI_ENABLE
+#undef CFG_NU_OS_KERN_IPC_MCAPI_SHM_ENABLE
+#define CFG_NU_OS_KERN_RTL_ENABLE
+#define CFG_NU_OS_KERN_RTL_MALLOC_POOL 0
+#define CFG_NU_OS_KERN_RTL_FP_OVERRIDE 0
+#define CFG_NU_OS_KERN_RTL_HEAP_SIZE 4096
+#define CFG_NU_OS_KERN_RTL_EXPORT_SYMBOLS 1
+#define CFG_NU_OS_KERN_EQM_ENABLE
+#define CFG_NU_OS_KERN_DEVMGR_ENABLE
+#define CFG_NU_OS_KERN_DEVMGR_RUNLEVEL 1
+#define CFG_NU_OS_KERN_DEVMGR_MAX_DEV_LABEL_CNT 5
+#define CFG_NU_OS_KERN_DEVMGR_MAX_DEV_SESSION_CNT 3
+#define CFG_NU_OS_KERN_DEVMGR_MAX_DEVICE_LISTENERS 15
+#define CFG_NU_OS_KERN_DEVMGR_ERR_CHECK_ENABLE 1
+#define CFG_NU_OS_KERN_DEVMGR_DISCOVERY_TASK_ENABLE 1
+#define CFG_NU_OS_KERN_DEVMGR_DISCOVERY_TASK_MAX_ID_CNT 30
+#define CFG_NU_OS_KERN_DEVMGR_DISCOVERY_TASK_STACK_SIZE 10240
+#define CFG_NU_OS_KERN_DEVMGR_EXPORT_SYMBOLS 1
+#undef CFG_NU_OS_UI_ENABLE
+#undef CFG_NU_OS_UI_IFX_ENABLE
+#undef CFG_NU_OS_UI_IFX_MOD_ENABLE
+#undef CFG_NU_OS_UI_IFX_MOD_SIMPLEEDIT_ENABLE
+#undef CFG_NU_OS_UI_IFX_FRAMEWORK_ENABLE
+#undef CFG_NU_OS_UI_IFX_ENG_ENABLE
+#undef CFG_NU_OS_UI_IFX_PORT_ENABLE
+#undef CFG_NU_OS_UI_IFX_UCDN_ENABLE
+#undef CFG_NU_OS_UI_IFX_HARFBUZZ_ENABLE
+#undef CFG_NU_OS_UI_IFX_FREETYPE_ENABLE
+#undef CFG_NU_OS_UI_IFX_NUBIDI_ENABLE
+#undef CFG_NU_OS_UI_IMAGE_ENABLE
+#undef CFG_NU_OS_UI_INPUT_MGMT_ENABLE
+#undef CFG_NU_OS_UI_GRAFIXRS_ENABLE
+#undef CFG_NU_OS_STOR_ENABLE
+#undef CFG_NU_OS_STOR_FILE_ENABLE
+#undef CFG_NU_OS_STOR_FILE_FS_ENABLE
+#undef CFG_NU_OS_STOR_FILE_FS_FAT_ENABLE
+#undef CFG_NU_OS_STOR_FILE_FS_SAFE_ENABLE
+#undef CFG_NU_OS_STOR_FILE_SHELL_ENABLE
+#undef CFG_NU_OS_STOR_FILE_VFS_ENABLE
+#undef CFG_NU_OS_STOR_DB_ENABLE
+#undef CFG_NU_OS_STOR_DB_SQLITE_ENABLE
+#define CFG_NU_OS_ARCH_ENABLE
+#define CFG_NU_OS_ARCH_ARM_ENABLE
+#undef CFG_NU_OS_ARCH_ARM_PROCESS_ENABLE
+#undef CFG_NU_OS_ARCH_ARM_PROCESS_MEM_MGMT_ENABLE
+#undef CFG_NU_OS_ARCH_ARM_PROCESS_LINKLOAD_ENABLE
+#undef CFG_NU_OS_ARCH_ARM_PROCESS_CORE_ENABLE
+#define CFG_NU_OS_ARCH_ARM_CSGNU_ENABLE
+#define CFG_NU_OS_ARCH_ARM_COM_ENABLE
+#define CFG_NU_OS_ARCH_ARM_COM_MMU_VARIANT 1
+#define CFG_NU_OS_ARCH_ARM_COM_SYSTEM_STACK_SIZE 2048
+#define CFG_NU_OS_ARCH_ARM_COM_FPU_SUPPORT 2
+#define CFG_NU_OS_ARCH_ARM_COM_V6V7_CACHE_LINE_SIZE 64
+#define CFG_NU_BSP_ENABLE
+#undef CFG_NU_BSP_DRVR_ENABLE
+#undef CFG_NU_BSP_DRVR_SERIAL_ENABLE
+#undef CFG_NU_BSP_DRVR_SERIAL_ZYNQ_UART_ENABLE
+#undef CFG_NU_BSP_DRVR_CPU_ENABLE
+#define CFG_NU_BSP_DRVR_CPU_ZYNQ7000_ENABLE
+#undef CFG_NU_BSP_DRVR_CAN_ENABLE
+#undef CFG_NU_BSP_DRVR_CAN_ZYNQ_CAN_ENABLE
+#undef CFG_NU_BSP_DRVR_ETHERNET_ENABLE
+#undef CFG_NU_BSP_DRVR_ETHERNET_ZYNQ_ETH_ENABLE
+#define CFG_NU_BSP_ZC702EVK_ENABLE
+#define CFG_NU_BSP_ZC702EVK_AMP_REMOTE 1
+#define CFG_NU_BSP_ARCH_ENABLE
+#define CFG_ZC702EVK_ENABLE
+#undef CFG_ZC702EVK_SERIAL0_ENABLE
+#define CFG_ZC702EVK_CPU0_ENABLE
+#define CFG_ZC702EVK_CPU0_RUNLEVEL 2
+#undef CFG_ZC702EVK_CAN0_ENABLE
+#undef CFG_ZC702EVK_ETHERNET0_ENABLE
+#define CFG_ZC702EVK_REMOTE_PROC0_ENABLE
+#define CFG_ZC702EVK_REMOTE_PROC1_ENABLE
+#undef CFG_ZC702EVK_RAMDISK0_ENABLE
+#endif /* NUCLEUS_GEN_CFG_H */
diff --git a/libs/system/zc702evk/nucleus/linker_master.ld b/libs/system/zc702evk/nucleus/linker_master.ld
--- /dev/null
@@ -0,0 +1,143 @@
+/*************************************************************************\r
+*\r
+* FILE NAME\r
+*\r
+* nucleus.ld\r
+*\r
+* DESCRIPTION\r
+*\r
+* Linker description (RAM) file for the following:\r
+*\r
+* BOARD: Xilinx ZC702 EVK Board (Cortex A9)\r
+*\r
+*************************************************************************/\r
+\r
+MEMORY\r
+{\r
+ ram : ORIGIN = 0x10000000, LENGTH = 0x10000000\r
+}\r
+\r
+SECTIONS \r
+\r
+{ \r
+ .text ALIGN(ORIGIN(ram), 0x100000):\r
+ {\r
+ _ld_text_start = . ;\r
+ KEEP (*(esal_vectors)) ;\r
+ KEEP (*(esal_code)) ;\r
+ *(.text .text*) ;\r
+ *(.glue_7t) ;\r
+ *(.glue_7) ;\r
+ *(.gnu.linkonce.t*)\r
+\r
+ /* Place process mode-switching support. */\r
+ KEEP (*(nutramp)) ;\r
+\r
+ . = ALIGN(4) ;\r
+ PROVIDE (_rtl_init_start = .) ;\r
+\r
+ /* Place only C RTL support initializers. */\r
+ KEEP (*libc.a:(.init_array*)) ;\r
+\r
+ PROVIDE (_rtl_init_end = .) ;\r
+\r
+ . = ALIGN(4) ;\r
+ PROVIDE (_cxx_ctor_start = .);\r
+\r
+ /* Place all C++ constructors (initializers). */\r
+ *(.ctors);\r
+ KEEP (*(.init_array*)) ;\r
+\r
+ PROVIDE (_cxx_ctor_end = .);\r
+ *(.dtors);\r
+ LONG (0);\r
+\r
+ _ld_text_end = . ;\r
+\r
+ } > ram\r
+\r
+ .ARM.extab :\r
+ {\r
+ *(.ARM.extab* .gnu.linkonce.armextab.*)\r
+\r
+ } > ram\r
+\r
+ .ARM.exidx :\r
+ {\r
+ __exidx_start = .;\r
+ *(.ARM.exidx* .gnu.linkonce.armexidx.*)\r
+ __exidx_end = .;\r
+\r
+ } > ram\r
+\r
+ nusymstr :\r
+ {\r
+ KEEP(*(nusymstr)) ;\r
+\r
+ } > ram\r
+\r
+ nusymtab :\r
+ {\r
+ PROVIDE (_nu_symbol_table_start = .) ;\r
+ KEEP(*(nusymtab)) ;\r
+ LONG(0x00000000) ;\r
+\r
+ } > ram\r
+\r
+ nuksymstr :\r
+ {\r
+ KEEP(*(nuksymstr)) ;\r
+\r
+ } > ram\r
+ \r
+ nuksymtab :\r
+ {\r
+ PROVIDE (_nu_ksymbol_table_start = .) ;\r
+ KEEP(*(nuksymtab)) ;\r
+ LONG(0x00000000) ;\r
+\r
+ } > ram\r
+ \r
+ .rodata ALIGN(0x100000):\r
+ {\r
+ _ld_rodata_start = . ;\r
+ *(.rodata*) ;\r
+ _ld_rodata_end = . ;\r
+ \r
+ } > ram\r
+\r
+ .rtl ALIGN(0x100000):\r
+ {\r
+ _ld_rtl_start = . ;\r
+ *libc.a:lib_a-impure.o (.data)\r
+ *libc.a:lib_a-mallocr.o (.data)\r
+ *libc.a:lib_a-mallocr.o (.bss)\r
+ *libc.a:lib_a-sglueg.o (.bss)\r
+ *libc.a:lib_a-stdout.o (.bss)\r
+ *libc.a:lib_a-gdtoa-gethex.o (COMMON)\r
+ *libc.a:lib_a-reent.o (COMMON)\r
+ _ld_rtl_end = . ;\r
+\r
+ } > ram\r
+\r
+ .data ALIGN(0x100000):\r
+ {\r
+ _ld_rom_data_start = . ;\r
+ _ld_ram_data_start = . ;\r
+ *(.data) ;\r
+ *(.data*) ;\r
+ *(.gnu.linkonce.d*)\r
+ _ld_ram_data_end = . ;\r
+\r
+ } > ram\r
+\r
+ .bss (NOLOAD) :\r
+ {\r
+ _ld_bss_start = . ;\r
+ *(.bss) ;\r
+ *(.bss*) ;\r
+ *(COMMON) ;\r
+ _ld_bss_end = . ;\r
+\r
+ } > ram\r
+}\r
diff --git a/libs/system/zc702evk/nucleus/linker_remote.ld b/libs/system/zc702evk/nucleus/linker_remote.ld
--- /dev/null
@@ -0,0 +1,149 @@
+/*************************************************************************\r
+*\r
+* FILE NAME\r
+*\r
+* nucleus.ld\r
+*\r
+* DESCRIPTION\r
+*\r
+* Linker description (RAM) file for the following:\r
+*\r
+* BOARD: Xilinx ZC702 EVK Board (Cortex A9)\r
+*\r
+*************************************************************************/\r
+\r
+MEMORY\r
+{\r
+ ram : ORIGIN = 0x00000000, LENGTH = 0x10000000\r
+}\r
+\r
+\r
+SECTIONS \r
+\r
+{ \r
+ _binary_firmware1_start = 0;\r
+ _binary_firmware1_end = 0;\r
+ _binary_firmware2_start = 0;\r
+ _binary_firmware2_end = 0;\r
+\r
+ .text ALIGN(ORIGIN(ram), 0x100000):\r
+ {\r
+ _ld_text_start = . ;\r
+ KEEP (*(esal_vectors)) ;\r
+ KEEP (*(esal_code)) ;\r
+ *(.text .text*) ;\r
+ *(.glue_7t) ;\r
+ *(.glue_7) ;\r
+ *(.gnu.linkonce.t*)\r
+\r
+ /* Place process mode-switching support. */\r
+ KEEP (*(nutramp)) ;\r
+\r
+ . = ALIGN(4) ;\r
+ PROVIDE (_rtl_init_start = .) ;\r
+\r
+ /* Place only C RTL support initializers. */\r
+ KEEP (*libc.a:(.init_array*)) ;\r
+\r
+ PROVIDE (_rtl_init_end = .) ;\r
+\r
+ . = ALIGN(4) ;\r
+ PROVIDE (_cxx_ctor_start = .);\r
+\r
+ /* Place all C++ constructors (initializers). */\r
+ *(.ctors);\r
+ KEEP (*(.init_array*)) ;\r
+\r
+ PROVIDE (_cxx_ctor_end = .);\r
+ *(.dtors);\r
+ LONG (0);\r
+\r
+ _ld_text_end = . ;\r
+\r
+ } > ram\r
+\r
+ .ARM.extab :\r
+ {\r
+ *(.ARM.extab* .gnu.linkonce.armextab.*)\r
+\r
+ } > ram\r
+\r
+ .ARM.exidx :\r
+ {\r
+ __exidx_start = .;\r
+ *(.ARM.exidx* .gnu.linkonce.armexidx.*)\r
+ __exidx_end = .;\r
+\r
+ } > ram\r
+\r
+ nusymstr :\r
+ {\r
+ KEEP(*(nusymstr)) ;\r
+\r
+ } > ram\r
+\r
+ nusymtab :\r
+ {\r
+ PROVIDE (_nu_symbol_table_start = .) ;\r
+ KEEP(*(nusymtab)) ;\r
+ LONG(0x00000000) ;\r
+\r
+ } > ram\r
+\r
+ nuksymstr :\r
+ {\r
+ KEEP(*(nuksymstr)) ;\r
+\r
+ } > ram\r
+ \r
+ nuksymtab :\r
+ {\r
+ PROVIDE (_nu_ksymbol_table_start = .) ;\r
+ KEEP(*(nuksymtab)) ;\r
+ LONG(0x00000000) ;\r
+\r
+ } > ram\r
+ \r
+ .rodata ALIGN(0x100000):\r
+ {\r
+ _ld_rodata_start = . ;\r
+ *(.rodata*) ;\r
+ _ld_rodata_end = . ;\r
+ \r
+ } > ram\r
+\r
+ .rtl ALIGN(0x100000):\r
+ {\r
+ _ld_rtl_start = . ;\r
+ *libc.a:lib_a-impure.o (.data)\r
+ *libc.a:lib_a-mallocr.o (.data)\r
+ *libc.a:lib_a-mallocr.o (.bss)\r
+ *libc.a:lib_a-sglueg.o (.bss)\r
+ *libc.a:lib_a-stdout.o (.bss)\r
+ *libc.a:lib_a-gdtoa-gethex.o (COMMON)\r
+ *libc.a:lib_a-reent.o (COMMON)\r
+ _ld_rtl_end = . ;\r
+\r
+ } > ram\r
+\r
+ .data ALIGN(0x100000):\r
+ {\r
+ _ld_rom_data_start = . ;\r
+ _ld_ram_data_start = . ;\r
+ *(.data) ;\r
+ *(.data*) ;\r
+ *(.gnu.linkonce.d*)\r
+ _ld_ram_data_end = . ;\r
+\r
+ } > ram\r
+\r
+ .bss (NOLOAD) :\r
+ {\r
+ _ld_bss_start = . ;\r
+ *(.bss) ;\r
+ *(.bss*) ;\r
+ *(COMMON) ;\r
+ _ld_bss_end = . ;\r
+\r
+ } > ram\r
+}\r
diff --git a/libs/system/zc702evk/nucleus/nucleus.h b/libs/system/zc702evk/nucleus/nucleus.h
--- /dev/null
@@ -0,0 +1,220 @@
+/***********************************************************************\r
+*\r
+* Copyright 1993 Mentor Graphics Corporation\r
+* All Rights Reserved.\r
+*\r
+* THIS WORK CONTAINS TRADE SECRET AND PROPRIETARY INFORMATION WHICH IS\r
+* THE PROPERTY OF MENTOR GRAPHICS CORPORATION OR ITS LICENSORS AND IS\r
+* SUBJECT TO LICENSE TERMS.\r
+*\r
+************************************************************************\r
+\r
+************************************************************************\r
+*\r
+* DESCRIPTION\r
+*\r
+* This file contains system constants common to both the\r
+* application and the actual Nucleus PLUS components.\r
+*\r
+***********************************************************************/\r
+\r
+/* Check to see if this file has been included already. */\r
+\r
+#ifndef NUCLEUS_H\r
+\r
+#ifdef __cplusplus\r
+/* C declarations in C++ */\r
+extern "C" {\r
+#endif\r
+#define NUCLEUS_H\r
+\r
+/* Include auto-generated configuration file */\r
+#include "nucleus_gen_cfg.h"\r
+\r
+/* Macro for generating a release version from major, minor, and patch version */\r
+#define NU_RELEASE_VERSION_MAKE(m,n,p) ((m*10000)+(n*100)+p)\r
+\r
+/* Define major, minor, and patch release numbers for Nucleus. */\r
+#define NUCLEUS_RELEASE_MAJOR_VERSION CFG_NU_MAJOR_VERSION\r
+#define NUCLEUS_RELEASE_MINOR_VERSION CFG_NU_MINOR_VERSION\r
+#define NUCLEUS_RELEASE_PATCH_VERSION CFG_NU_PATCH_VERSION\r
+\r
+/* Temporary macro to zero append the minor version, if it is less than 10. */\r
+#if (NUCLEUS_RELEASE_MINOR_VERSION < 10)\r
+#define ZERO_APPEND 0\r
+#else\r
+#define ZERO_APPEND\r
+#endif /* (NUCLEUS_RELEASE_MINOR_VERSION < 10) */\r
+\r
+/* Temporary macros to convert a number to string. */\r
+#define STR_PASTE(x) #x\r
+#define STR(x) STR_PASTE(x)\r
+\r
+/* Define Nucleus release string. NOTE: this is the version number\r
+ for the whole operating system. */\r
+#define NUCLEUS_RELEASE_STRING "Nucleus " STR(NUCLEUS_RELEASE_MAJOR_VERSION) "." \\r
+ STR(ZERO_APPEND) STR(NUCLEUS_RELEASE_MINOR_VERSION) "." \\r
+ STR(NUCLEUS_RELEASE_PATCH_VERSION)\r
+/* Undefine the temporary macros. */\r
+#undef ZERO_APPEND\r
+#undef STR_PASTE\r
+#undef STR\r
+\r
+/* Define Nucleus numbering */\r
+#define NUCLEUS_1_0 NU_RELEASE_VERSION_MAKE(1,0,0)\r
+#define NUCLEUS_2_0 NU_RELEASE_VERSION_MAKE(2,0,0)\r
+#define NUCLEUS_3_1 NU_RELEASE_VERSION_MAKE(3,1,0)\r
+#define NUCLEUS_3_2 NU_RELEASE_VERSION_MAKE(3,2,0)\r
+#define NUCLEUS_3_2_1 NU_RELEASE_VERSION_MAKE(3,2,1)\r
+#define NUCLEUS_3_3_0 NU_RELEASE_VERSION_MAKE(3,3,0)\r
+\r
+/* Current version */\r
+#define NUCLEUS_VERSION NU_RELEASE_VERSION_MAKE( \\r
+ NUCLEUS_RELEASE_MAJOR_VERSION, \\r
+ NUCLEUS_RELEASE_MINOR_VERSION, \\r
+ NUCLEUS_RELEASE_PATCH_VERSION)\r
+ \r
+/* Define NULL value */\r
+#define NU_NULL 0\r
+\r
+/* Defines for TRUE / FALSE conditions */\r
+#define NU_FALSE 0\r
+#define NU_TRUE 1\r
+\r
+/* Define standard data types. These definitions allow software components\r
+ to perform in the same manner on different target platforms. */\r
+typedef signed int INT;\r
+typedef unsigned int UINT;\r
+typedef signed char INT8;\r
+typedef unsigned char UINT8;\r
+typedef signed short INT16;\r
+typedef unsigned short UINT16;\r
+typedef signed long INT32;\r
+typedef unsigned long UINT32;\r
+#define VOID void\r
+typedef unsigned long long UINT64;\r
+typedef signed long long INT64;\r
+\r
+/* Define type used to cast void pointers when doing pointer math */\r
+typedef UINT8 * VOID_CAST;\r
+/* Define register variable definition. This define\r
+ can be used to specify local variables and parameters\r
+ that could be placed into registers to increase performance\r
+ (speed and size) */\r
+#define NU_REG register\r
+\r
+/* Define macro to eliminate warnings for unused parameters */\r
+#define NU_UNUSED_PARAM(parameter) (VOID)parameter\r
+\r
+/* Get address of structure using structure member and type */\r
+#include <stddef.h>\r
+#define NU_STRUCT_BASE(pointer, member, type) \\r
+ ((type *)((size_t)(pointer) - offsetof(type, member)))\r
+\r
+/* Common types utilized within Nucleus code */\r
+typedef UINT32 UNSIGNED;\r
+typedef INT32 SIGNED;\r
+typedef UINT8 DATA_ELEMENT;\r
+typedef UINT8 OPTION;\r
+typedef UINT8 BOOLEAN;\r
+typedef INT STATUS;\r
+typedef UINT8 UNSIGNED_CHAR;\r
+typedef char CHAR;\r
+typedef UINT UNSIGNED_INT;\r
+typedef UINT32 * UNSIGNED_PTR;\r
+typedef UINT8 * BYTE_PTR;\r
+\r
+\r
+/* Define register defines. R1, R2, R3, and R4 are used in the Nucleus PLUS\r
+ source code in front of variables that are referenced often. In some\r
+ ports, defining them as "register" will improve performance. */\r
+#define R1 NU_REG\r
+#define R2 NU_REG\r
+#define R3 NU_REG\r
+#define R4 NU_REG\r
+\r
+/* Define the maximum object string name size in the system */\r
+#define NU_MAX_NAME 8\r
+\r
+/* Define system errors. */\r
+#define NU_ERROR_CREATING_TIMER_HISR 1\r
+#define NU_ERROR_CREATING_TIMER_TASK 2\r
+#define NU_STACK_OVERFLOW 3\r
+#define NU_UNHANDLED_INTERRUPT 4\r
+#define NU_NOT_IN_SUPERVISOR_MODE 5\r
+#define NU_NOT_ENOUGH_DTLBS 6\r
+#define NU_NOT_ENOUGH_ITLBS 7\r
+#define NU_STACK_UNDERFLOW 8\r
+#define NU_UNHANDLED_EXCEPTION 9\r
+#define NU_RUNLEVEL_INIT_ERROR 10\r
+#define NU_MPU_CONFIG_ERROR 11\r
+#define NU_INVALID_LOCK_USAGE 12\r
+\r
+/* Define I/O driver constants. */\r
+#define NU_IO_ERROR -1\r
+\r
+/**********************************************************************/\r
+/* Nucleus Toolset specific macros */\r
+/**********************************************************************/ \r
+/* Include architecture and toolset specific headers */ \r
+#include "arch.h"\r
+#include "toolset.h"\r
+#include "platform.h"\r
+#include "kernel/esal_extr.h"\r
+\r
+/* Define number of accesses required to read or write a 32-bit value */\r
+#define NU_32BIT_ACCESS ESAL_AR_32BIT_ACCESS\r
+\r
+/* Define number of accesses required to read or write a pointer */\r
+#define NU_PTR_ACCESS ESAL_AR_PTR_ACCESS\r
+\r
+#define NU_WEAK_REF ESAL_TS_WEAK_REF\r
+\r
+/* Defines used to align / pad structure members of various Nucleus structures. Certain\r
+ architectures may require alignment */\r
+#ifndef ESAL_TS_PAD_1BYTE_ALIGN\r
+#define PAD_1 0\r
+#else\r
+#define PAD_1 ESAL_TS_PAD_1BYTE_ALIGN\r
+#endif /* !ESAL_TS_PAD_1BYTE_ALIGN */\r
+\r
+#ifndef ESAL_TS_PAD_2BYTE_ALIGN\r
+#define PAD_2 0\r
+#else\r
+#define PAD_2 ESAL_TS_PAD_2BYTE_ALIGN\r
+#endif /* !ESAL_TS_PAD_2BYTE_ALIGN */\r
+\r
+#ifndef ESAL_TS_PAD_3BYTE_ALIGN\r
+#define PAD_3 0\r
+#else\r
+#define PAD_3 ESAL_TS_PAD_3BYTE_ALIGN\r
+#endif /* !ESAL_TS_PAD_3BYTE_ALIGN */\r
+\r
+/* Common types utilized within Nucleus code - toolset specific */\r
+#if (ESAL_TS_64BIT_SUPPORT == NU_TRUE)\r
+typedef UINT64 OFFSET_T;\r
+#else\r
+typedef UINT32 OFFSET_T;\r
+#endif /* (ESAL_TS_64BIT_SUPPORT == NU_TRUE) */\r
+\r
+\r
+/* Check if debug agent support is enabled */\r
+#ifdef CFG_NU_OS_SVCS_DBG_ENABLE\r
+\r
+/* Include debug agent definitions */\r
+#include "services/dbg_extr.h"\r
+\r
+#endif /* CFG_NU_OS_SVCS_DBG_ENABLE */\r
+\r
+/* Include System Logging interface */\r
+#include "services/syslog_extern.h"\r
+ \r
+#ifdef __cplusplus\r
+\r
+/* End of C declarations */\r
+}\r
+\r
+#endif /* __cplusplus */\r
+\r
+#endif /* !NUCLEUS_H */\r
+\r
diff --git a/libs/system/zc702evk/nucleus/os/kernel/plus/core/inc/thread_control.h b/libs/system/zc702evk/nucleus/os/kernel/plus/core/inc/thread_control.h
--- /dev/null
@@ -0,0 +1,239 @@
+/***********************************************************************\r
+*\r
+* Copyright 1993 Mentor Graphics Corporation\r
+* All Rights Reserved.\r
+*\r
+* THIS WORK CONTAINS TRADE SECRET AND PROPRIETARY INFORMATION WHICH IS\r
+* THE PROPERTY OF MENTOR GRAPHICS CORPORATION OR ITS LICENSORS AND IS\r
+* SUBJECT TO LICENSE TERMS.\r
+*\r
+************************************************************************\r
+\r
+************************************************************************\r
+*\r
+* DESCRIPTION\r
+*\r
+* This file contains data structure definitions and constants for\r
+* the component that controls the various threads of execution in\r
+* system. Threads include tasks, HISRs, signal handlers, etc.\r
+*\r
+***********************************************************************/\r
+\r
+/* Check to see if the file has been included already. */\r
+\r
+#ifndef THREAD_CONTROL_H\r
+#define THREAD_CONTROL_H\r
+\r
+#ifdef __cplusplus\r
+\r
+/* C declarations in C++ */\r
+extern "C" {\r
+\r
+#endif\r
+\r
+/* Define constants local to this component. */\r
+\r
+#define TC_TASK_ID 0x5441534bUL\r
+#define TC_HISR_ID 0x48495352UL\r
+#define TC_PRIORITIES CFG_NU_OS_KERN_PLUS_CORE_NUM_TASK_PRIORITIES\r
+#define TC_HISR_PRIORITIES 3\r
+#define TC_MAX_GROUPS (TC_PRIORITIES/8)\r
+#define TC_HIGHEST_MASK 0x000000FFUL\r
+#define TC_NEXT_HIGHEST_MASK 0x0000FF00UL\r
+#define TC_NEXT_LOWEST_MASK 0x00FF0000UL\r
+#define TC_LOWEST_MASK 0xFF000000UL\r
+#define TC_MAX_HISR_ACTIVATIONS 0xFFFFFFFFUL\r
+#define TC_NO_THREAD_WAITING 0\r
+#define TC_THREAD_WAITING 1\r
+#define TC_GRP_ID_SYS 0\r
+#define TC_GRP_ID_APP 1\r
+\r
+\r
+/* Core error checking functions. */\r
+\r
+STATUS TCCE_Validate_Resume(OPTION resume_type, NU_TASK *task_ptr);\r
+INT TCCE_Suspend_Error(VOID);\r
+\r
+/* Core processing functions. */\r
+\r
+STATUS TCC_Resume_Task(NU_TASK *task_ptr, OPTION suspend_type);\r
+STATUS TCC_Debug_Resume_Service(NU_TASK *task_ptr);\r
+VOID TCC_Suspend_Task(NU_TASK *task_ptr, OPTION suspend_type,\r
+ VOID (*cleanup)(VOID *),\r
+ VOID *information, UNSIGNED timeout);\r
+STATUS TCC_Debug_Suspend_Service(NU_TASK *task_ptr);\r
+VOID TCC_Task_Timeout(NU_TASK *task_ptr);\r
+VOID TCC_Time_Slice(NU_TASK *task_ptr);\r
+\r
+/* Core functions with target dependencies */\r
+VOID TCCT_Schedule(VOID);\r
+\r
+extern BOOLEAN TCD_Schedule_Lock;\r
+#if (CFG_NU_OS_KERN_PLUS_CORE_DEBUG_SCHED_LOCK == NU_TRUE)\r
+extern VOID ERC_System_Error(INT error_code);\r
+#define TCCT_Schedule_Lock() \\r
+ { \\r
+ /* Ensure lock not set (if set, invalid usage / nesting) */ \\r
+ if (TCD_Schedule_Lock != NU_FALSE) \\r
+ { \\r
+ /* System error */ \\r
+ ERC_System_Error(NU_INVALID_LOCK_USAGE); \\r
+ } \\r
+ \\r
+ TCD_Schedule_Lock = NU_TRUE; \\r
+ ESAL_GE_RTE_COMPILE_MEM_BARRIER(); \\r
+ }\r
+#else\r
+#define TCCT_Schedule_Lock() \\r
+ { \\r
+ TCD_Schedule_Lock = NU_TRUE; \\r
+ ESAL_GE_RTE_COMPILE_MEM_BARRIER(); \\r
+ }\r
+#endif /* CFG_NU_OS_KERN_PLUS_CORE_DEBUG_SCHED_LOCK == NU_TRUE */\r
+\r
+VOID TCCT_Schedule_Unlock(VOID);\r
+\r
+VOID TCCT_Control_To_System(VOID);\r
+\r
+/* OS State Functions */\r
+UNSIGNED TCS_Task_Group_ID(NU_TASK *task_ptr);\r
+UNSIGNED TCS_Change_Group_ID(NU_TASK *task_ptr, UNSIGNED group_id);\r
+NU_TASK *TCC_Current_Application_Task_Pointer(VOID);\r
+UNSIGNED TCF_Established_Application_Tasks(VOID);\r
+UNSIGNED TCF_Application_Task_Pointers(NU_TASK ** pointer_list,\r
+ UNSIGNED maximum_pointers);\r
+\r
+#define TCC_Application_Task_Add(task); \\r
+ task->tc_grp_id = TC_GRP_ID_APP; \\r
+ if(TCD_App_Task_List == NU_NULL) \\r
+ { \\r
+ TCD_App_Task_List = task; \\r
+ task->tc_grp_next = task; \\r
+ task->tc_grp_prev = task; \\r
+ } \\r
+ else \\r
+ { \\r
+ task->tc_grp_next = TCD_App_Task_List; \\r
+ task->tc_grp_prev = TCD_App_Task_List->tc_grp_prev; \\r
+ TCD_App_Task_List->tc_grp_prev->tc_grp_next = task; \\r
+ TCD_App_Task_List->tc_grp_prev = task; \\r
+ } \\r
+ TCD_Total_App_Tasks++;\r
+\r
+#define TCC_Application_Task_Remove(task); \\r
+ if(task->tc_grp_next == task) \\r
+ { \\r
+ TCD_App_Task_List = NU_NULL; \\r
+ } \\r
+ else \\r
+ { \\r
+ if(task == TCD_App_Task_List) \\r
+ { \\r
+ TCD_App_Task_List = task->tc_grp_next; \\r
+ } \\r
+ task->tc_grp_next->tc_grp_prev = task->tc_grp_prev; \\r
+ task->tc_grp_prev->tc_grp_next = task->tc_grp_next; \\r
+ } \\r
+ TCD_Total_App_Tasks--;\r
+\r
+#define TCC_Current_App_Task_Set(task_ptr); \\r
+ /* Check if an application task */ \\r
+ if(task_ptr->tc_grp_id == TC_GRP_ID_APP) \\r
+ { \\r
+ /* Set this task as the current application task */ \\r
+ TCD_Current_App_Task = task_ptr; \\r
+ }\r
+\r
+/* Determine if pointers are accessible with a single instruction. If so,\r
+ just reference the pointer directly. Otherwise, call the target dependent\r
+ service */\r
+\r
+#if (NU_PTR_ACCESS == 1)\r
+\r
+/* Macro definitions for architectures supporting single instruction\r
+ access to pointers */\r
+#define TCCT_Current_Thread() TCD_Current_Thread\r
+#define TCCT_Set_Execute_Task(task) TCD_Execute_Task = task\r
+\r
+#else\r
+\r
+VOID *TCCT_Current_Thread(VOID);\r
+VOID TCCT_Set_Execute_Task(TC_TCB *task);\r
+\r
+#endif /* NU_PTR_ACCESS == 1 */\r
+\r
+#define TCC_Task_Priority(task) \\r
+ ((TC_TCB *) (task)) -> tc_priority\r
+\r
+/* Define macro, for internal components, to access current HISR pointer */\r
+\r
+#define TCC_CURRENT_HISR_PTR \\r
+ ((TC_HCB *)TCD_Current_Thread)\r
+\r
+/* Define interrupt locking / unlocking macros based on the interrupt locking\r
+ method used */\r
+#if (NU_GLOBAL_INT_LOCKING == NU_TRUE)\r
+\r
+/* The following macro sets the interrupt lock-out level to the globally defined\r
+ level (TCD_Interrupt_Level). This macro is used in the scheduler and within\r
+ the HISR shell routine. */\r
+#define TCC_INTERRUPTS_GLOBAL_ENABLE() \\r
+ ESAL_GE_INT_BITS_SET(TCD_Interrupt_Level)\r
+\r
+/* The following macro locks out interrupts without saving the state before\r
+ locking-out. It is used to guard critical sections of code and is always\r
+ paired with the macro TCC_INTERRUPTS_RESTORE defined below. */\r
+#define TCC_INTERRUPTS_DISABLE() \\r
+ ESAL_GE_INT_FAST_ALL_DISABLE()\r
+\r
+/* The following macro sets the interrupt lock-out level to the globally defined\r
+ level (TCD_Interrupt_Level). This macro is used at the end of critical\r
+ sections where a context switch may have occurred. This macro is always\r
+ paired with the macro TCC_INTERRUPTS_ENABLE defined above. */\r
+#define TCC_INTERRUPTS_RESTORE() \\r
+ ESAL_GE_INT_BITS_SET(TCD_Interrupt_Level)\r
+\r
+#else\r
+\r
+/* The following macro is used to enable interrupts globally. This macro is used\r
+ in the scheduler and within the HISR shell routine. */\r
+#define TCC_INTERRUPTS_GLOBAL_ENABLE() \\r
+ ESAL_GE_INT_FAST_ALL_ENABLE()\r
+\r
+/* The following macro locks out interrupts and saves the state before\r
+ locking-out. It is used to guard critical sections of code and is always\r
+ paired with the macro TCC_INTERRUPTS_RESTORE defined below. */\r
+#define TCC_INTERRUPTS_DISABLE() \\r
+ ESAL_GE_INT_CONTROL_VARS \\r
+ ESAL_GE_INT_ALL_DISABLE()\r
+\r
+/* The following macro sets the interrupt lock-out level to entry level saved\r
+ by TCC_INTERRUPTS_LOCK. This macro is used at the end of critical\r
+ sections where a context switch may have occurred. This macro is always\r
+ paired with the macro TCC_INTERRUPTS_LOCK defined above. */\r
+#define TCC_INTERRUPTS_RESTORE() \\r
+ ESAL_GE_INT_ALL_RESTORE()\r
+\r
+#endif /* NU_GLOBAL_INT_LOCKING == NU_TRUE */\r
+\r
+/* Nucleus PLUS Timing Test 2 macros / external declarations */\r
+#if (NU_TIME_TEST2_ENABLE == NU_TRUE)\r
+\r
+/* Include timing test header file */\r
+#include "test2_defs.h"\r
+\r
+#else\r
+\r
+/* Define macro to do nothing */\r
+#define NU_PLUS_TIMING_TEST2()\r
+\r
+#endif /* (NU_TIME_TEST2_ENABLE == NU_TRUE) */\r
+\r
+#ifdef __cplusplus\r
+\r
+/* End of C declarations */\r
+}\r
+\r
+#endif /* __cplusplus */\r
+\r
+#endif\r
diff --git a/libs/system/zc702evk/nucleus/services/cpu_dvfs.h b/libs/system/zc702evk/nucleus/services/cpu_dvfs.h
--- /dev/null
@@ -0,0 +1,108 @@
+/*************************************************************************\r
+*\r
+* Copyright 2010 Mentor Graphics Corporation\r
+* All Rights Reserved.\r
+*\r
+* THIS WORK CONTAINS TRADE SECRET AND PROPRIETARY INFORMATION WHICH IS\r
+* THE PROPERTY OF MENTOR GRAPHICS CORPORATION OR ITS LICENSORS AND IS\r
+* SUBJECT TO LICENSE TERMS.\r
+*\r
+*************************************************************************/\r
+\r
+/*************************************************************************\r
+*\r
+* FILE NAME\r
+*\r
+* cpu_dvfs.h\r
+*\r
+* COMPONENT\r
+*\r
+* CPU DVFS\r
+*\r
+* DESCRIPTION\r
+*\r
+* Contains data structures and IOCTLs for the DVFS component\r
+*\r
+* DATA STRUCTURES\r
+*\r
+* CPU_DVFS_OP\r
+* CPU_DVFS_GET_OP\r
+* CPU_DVFS_FROM_TO\r
+* CPU_DVFS_ADDITIONAL\r
+*\r
+* DEPENDENCIES\r
+*\r
+* nucleus.h\r
+*\r
+*************************************************************************/\r
+#ifndef CPU_DVFS_H\r
+#define CPU_DVFS_H\r
+\r
+#ifdef __cplusplus\r
+extern "C" {\r
+#endif\r
+\r
+/* Class Label */\r
+#define CPU_DVFS_CLASS_LABEL {0x30,0x4b,0xc2,0xbc,0x29,0xaa,0x49,0xe5,0xaa,0x69,0x36,0x36,0xaa,0xb5,0xac,0xc7}\r
+\r
+/* CPU IOCTL offset codes */\r
+#define CPU_DVFS_IOCTL_GET_OP_COUNT 0 /* Get the current number of operating points */\r
+#define CPU_DVFS_IOCTL_GET_OP 1 /* Get a specific operating point with the PM_CPU_GET_OP structure */\r
+#define CPU_DVFS_IOCTL_SET_OP 2 /* Set a specific operating point based on an index from 0..n-1 as derived from get op count */\r
+#define CPU_DVFS_IOCTL_GET_CURRENT_OP 3 /* Get the index of the current operating point in use */\r
+#define CPU_DVFS_IOCTL_FROM_TO 4 /* Get the amount of time to make a switch, time returned in ns */\r
+#define CPU_DVFS_IOCTL_ADDITIONAL 5 /* If any extra information is available it will be returned using a structure defined by the cpu driver */\r
+#define CPU_DVFS_IOCTL_SPECIFIC 6 /* If any extra information is available it will be returned using a structure defined by the cpu driver */\r
+\r
+#define CPU_DVFS_IOCTL_TOTAL 7\r
+\r
+/* This structure is passed in to IOCTL "Get OP" */\r
+typedef struct CPU_DVFS_GET_OP_CB\r
+{\r
+ UINT8 pm_op_index; /* The OP index being requested by PM */\r
+ UINT16 pm_voltage; /* Voltage in mHz */\r
+#if PAD_3\r
+ UINT8 pm_padding[PAD_3];\r
+#endif\r
+ UINT32 pm_frequency; /* Frequency in HZ */\r
+} CPU_DVFS_GET_OP;\r
+\r
+/* This structure is passed in to IOCTL "from to" */\r
+typedef struct CPU_DVFS_FROM_TO_CB\r
+{\r
+ UINT8 pm_op_from; /* The OP index being starting from */\r
+ UINT8 pm_op_to; /* The OP index switching to */\r
+#if PAD_2\r
+ UINT8 pm_padding[PAD_2];\r
+#endif\r
+ UINT32 pm_time; /* Required time to make the switch in nanoseconds */\r
+} CPU_DVFS_FROM_TO;\r
+\r
+/* This structure is passed in to IOCTL "additional info" */\r
+typedef struct CPU_DVFS_ADDITIONAL_CB\r
+{\r
+ UINT8 pm_op_id; /* The OP index requested */\r
+#if PAD_1\r
+ UINT8 pm_padding[PAD_1];\r
+#endif\r
+ VOID *pm_info; /* Pointer to CPU defined structure */\r
+ UINT32 pm_size; /* Size of the information pointer */\r
+} CPU_DVFS_ADDITIONAL;\r
+\r
+/* This structure is passed in to IOCTL "additional info" */\r
+typedef struct CPU_DVFS_SPECIFIC_CB\r
+{\r
+ UINT8 pm_op_id; /* The OP index requested */\r
+#if PAD_1\r
+ UINT8 pm_padding[PAD_1];\r
+#endif\r
+ CHAR *pm_identifier;\r
+ VOID *pm_info; /* Pointer to CPU defined structure */\r
+ UINT32 pm_size; /* Size of the information pointer */\r
+} CPU_DVFS_SPECIFIC;\r
+\r
+#ifdef __cplusplus\r
+}\r
+#endif\r
+\r
+#endif /* CPU_DVFS_H */\r
diff --git a/libs/system/zc702evk/nucleus/services/cpu_idle.h b/libs/system/zc702evk/nucleus/services/cpu_idle.h
--- /dev/null
@@ -0,0 +1,65 @@
+/*************************************************************************\r
+*\r
+* Copyright 2010 Mentor Graphics Corporation\r
+* All Rights Reserved.\r
+*\r
+* THIS WORK CONTAINS TRADE SECRET AND PROPRIETARY INFORMATION WHICH IS\r
+* THE PROPERTY OF MENTOR GRAPHICS CORPORATION OR ITS LICENSORS AND IS\r
+* SUBJECT TO LICENSE TERMS.\r
+*\r
+*************************************************************************/\r
+\r
+/*************************************************************************\r
+*\r
+* FILE NAME\r
+*\r
+* cpu_idle.h\r
+*\r
+* COMPONENT\r
+*\r
+* CPU driver\r
+*\r
+* DESCRIPTION\r
+*\r
+* Contains definitions of the CPU idle component\r
+*\r
+* DATA STRUCTURES\r
+*\r
+* None\r
+*\r
+* DEPENDENCIES\r
+*\r
+* None\r
+*\r
+*************************************************************************/\r
+#ifndef CPU_IDLE_H\r
+#define CPU_IDLE_H\r
+\r
+#ifdef __cplusplus\r
+extern "C" {\r
+#endif\r
+\r
+#define CPU_IDLE_CLASS_LABEL {0xf2,0x07,0x01,0xf4,0x3f,0xb3,0x4e,0x5b,0x9e,0x99,0xf5,0xe8,0xbf,0xe7,0x6a,0x57}\r
+#define CPU_DRAM_CTRL_CLASS_LABEL {0x14,0x11,0xf7,0xdf,0x72,0x76,0x4c,0xf1,0x87,0xbc,0x77,0xdd,0x07,0xdc,0x16,0x55}\r
+\r
+/* CPU Idle IOCTL offset codes */\r
+#define CPU_IDLE_IOCTL_GET_IDLE 0\r
+#define CPU_IDLE_IOCTL_GET_WAKEUP 1\r
+\r
+/* CPU DRAM self refresh IOCTL offset codes */\r
+#define CPU_DRAM_IOCTL_DISABLE_SELF_REFRESH 0\r
+#define CPU_DRAM_IOCTL_ENABLE_SELF_REFRESH 1\r
+#define CPU_DRAM_IOCTL_GET_SELF_REFRESH_STATUS 2\r
+\r
+/* CPU Idle total number of ioctl */\r
+#define CPU_IDLE_IOCTL_TOTAL 2\r
+#define CPU_DRAM_IOCTL_TOTAL 3\r
+\r
+/* flag to test tick suppression */\r
+#define TEST_TICK_SUPPRESS NU_TRUE\r
+\r
+#ifdef __cplusplus\r
+}\r
+#endif\r
+\r
+#endif /* CPU_IDLE_H */\r
diff --git a/libs/system/zc702evk/nucleus/services/cpu_selfrefresh.h b/libs/system/zc702evk/nucleus/services/cpu_selfrefresh.h
--- /dev/null
@@ -0,0 +1,66 @@
+/*************************************************************************\r
+*\r
+* Copyright 2012 Mentor Graphics Corporation\r
+* All Rights Reserved.\r
+*\r
+* THIS WORK CONTAINS TRADE SECRET AND PROPRIETARY INFORMATION WHICH IS\r
+* THE PROPERTY OF MENTOR GRAPHICS CORPORATION OR ITS LICENSORS AND IS\r
+* SUBJECT TO LICENSE TERMS.\r
+*\r
+*************************************************************************/\r
+\r
+/*************************************************************************\r
+*\r
+* FILE NAME\r
+*\r
+* cpu_selfrefresh.h\r
+*\r
+* COMPONENT\r
+*\r
+* CPU driver\r
+*\r
+* DESCRIPTION\r
+*\r
+* Contains definitions of the CPU self-refresh component\r
+*\r
+* DATA STRUCTURES\r
+*\r
+* None\r
+*\r
+* DEPENDENCIES\r
+*\r
+* None\r
+*\r
+*************************************************************************/\r
+#ifndef CPU_SELFREFRESH_H\r
+#define CPU_SELFREFRESH_H\r
+\r
+#ifdef __cplusplus\r
+extern "C" {\r
+#endif\r
+\r
+#define CPU_SELFREFRESH_CLASS_LABEL {0x05,0x32,0xbd,0x5f,0x32,0xc6,0x42,0x0f,0x80,0x0d,0x6b,0xfe,0xc9,0xbc,0xc1,0x92}\r
+\r
+/* Self Refresh IOCTL offset codes */\r
+#define CPU_SELFREFRESH_IOCTL_INIT 0 /* */\r
+\r
+#define CPU_SELFREFRESH_IOCTL_TOTAL 1\r
+\r
+/* Self-Refresh Function type */\r
+typedef VOID (*SELF_REFRESH_FUNC)(VOID);\r
+\r
+/* Self-Refresh control block */\r
+typedef struct CPU_SELF_REFRESH_CB_STRUCT\r
+{\r
+ BOOLEAN self_refresh;\r
+ SELF_REFRESH_FUNC selfrefresh_enter_func;\r
+ SELF_REFRESH_FUNC selfrefresh_exit_func;\r
+\r
+} CPU_SELF_REFRESH_CB;\r
+\r
+\r
+#ifdef __cplusplus\r
+}\r
+#endif\r
+\r
+#endif /* CPU_SELFREFRESH_H */\r
diff --git a/libs/system/zc702evk/nucleus/services/nu_services.h b/libs/system/zc702evk/nucleus/services/nu_services.h
--- /dev/null
@@ -0,0 +1,208 @@
+/***********************************************************************\r
+*\r
+* Copyright 2011 Mentor Graphics Corporation\r
+* All Rights Reserved.\r
+*\r
+* THIS WORK CONTAINS TRADE SECRET AND PROPRIETARY INFORMATION WHICH IS\r
+* THE PROPERTY OF MENTOR GRAPHICS CORPORATION OR ITS LICENSORS AND IS\r
+* SUBJECT TO LICENSE TERMS.\r
+*\r
+************************************************************************\r
+\r
+************************************************************************\r
+* \r
+* DESCRIPTION\r
+* \r
+* This file contains services constants common to both the\r
+* application and the actual Nucleus Services.\r
+*\r
+***********************************************************************/\r
+\r
+/* Check to see if this file has been included already. */\r
+\r
+#ifndef NU_SERVICES\r
+#ifdef __cplusplus\r
+/* C declarations in C++ */\r
+extern "C" {\r
+#endif\r
+#define NU_SERVICES\r
+\r
+\r
+/**********************************************************************/\r
+/* POSIX Services */\r
+/**********************************************************************/\r
+#ifdef CFG_NU_OS_SVCS_POSIX_ENABLE\r
+#include "services/posix.h"\r
+#include "services/stdint.h"\r
+#include "services/compiler.h"\r
+#include "services/config.h"\r
+#include "services/dirent.h"\r
+#include "services/errno.h"\r
+#include "services/posixinit.h"\r
+#include "services/fcntl.h"\r
+#include "services/file_util.h"\r
+#include "services/net/if.h"\r
+#include "services/inet/in.h"\r
+#include "services/netinet/in.h"\r
+#include "services/arpa/inet.h"\r
+#include "services/inttypes.h"\r
+#ifdef CFG_NU_OS_NET_IPV6_ENABLE\r
+#include "services/inv6.h"\r
+#include "services/inv6_extr.h"\r
+#endif /*CFG_NU_OS_NET_IPV6_ENABLE*/\r
+#include "services/limits.h"\r
+#include "services/sys/mman.h"\r
+#include "services/mqueue.h"\r
+#include "services/netdb.h"\r
+#include "services/aio.h"\r
+#include "services/aio_helper.h"\r
+#include "services/pdir.h"\r
+#include "services/pfile.h"\r
+#include "services/pfile_error.h"\r
+#include "services/pfileres.h"\r
+#include "services/pnet.h"\r
+#include "services/pnet_sr.h"\r
+#include "services/pprocres.h"\r
+#include "services/pres_defs.h"\r
+#include "services/psx_defs.h"\r
+#include "services/psx_extr.h"\r
+#include "services/ptdflt.h"\r
+#include "services/pthread.h"\r
+#include "services/putil.h"\r
+#include "services/rtldflt.h"\r
+#include "services/sched.h"\r
+#include "services/sys/select.h"\r
+#include "services/semaphore.h"\r
+#include "services/setjmp.h"\r
+#include "services/sigdflt.h"\r
+#include "services/signal.h"\r
+#include "services/sys/socket.h"\r
+#include "services/sys/stat.h"\r
+#include "services/stddef.h"\r
+#include "services/stdio.h"\r
+#include "services/stdiodflt.h"\r
+#include "services/stdlib.h"\r
+#include "services/string.h"\r
+#include "services/strings.h"\r
+#include "services/stropts.h"\r
+#include "services/sys/time.h"\r
+#include "services/sys/types.h"\r
+#include "services/sys/uio.h"\r
+#include "services/sys/un.h"\r
+#include "services/unistd.h"\r
+#include "services/utime.h"\r
+#include "services/sys/utsname.h"\r
+#include "services/xtype.h"\r
+#include "services/convert.h"\r
+#include "services/ctype.h"\r
+#include "services/fenv.h"\r
+#include "services/locale.h"\r
+#include "services/math.h"\r
+#endif /* CFG_NU_OS_SVCS_POSIX_ENABLE */\r
+\r
+\r
+/**********************************************************************/\r
+/* CPU Include Files */\r
+/**********************************************************************/\r
+#include "services/cpu_dvfs.h"\r
+#include "services/cpu_idle.h"\r
+#include "services/cpu_selfrefresh.h"\r
+\r
+/**********************************************************************/\r
+/* CXX Services */\r
+/**********************************************************************/\r
+#ifdef CFG_NU_OS_SVCS_CXX_ENABLE\r
+#include "services/cxx_rte.h"\r
+#endif /* CFG_NU_OS_SVCS_CXX_ENABLE */\r
+\r
+\r
+/**********************************************************************/\r
+/* DEBUG Services */\r
+/**********************************************************************/\r
+#ifdef CFG_NU_OS_SVCS_DBG_ENABLE\r
+#include "services/dbg.h"\r
+#include "services/dbg_cfg.h"\r
+#include "services/dbg_com.h"\r
+#include "services/dbg_com_serial.h"\r
+#include "services/dbg_com_tcp.h"\r
+#include "services/dbg_eng.h"\r
+#include "services/dbg_eng_api.h"\r
+#include "services/dbg_eng_bkpt.h"\r
+#include "services/dbg_eng_evt.h"\r
+#include "services/dbg_eng_exec.h"\r
+#include "services/dbg_eng_mem.h"\r
+#include "services/dbg_eng_reg.h"\r
+#include "services/dbg_extr.h"\r
+#include "services/dbg_mem.h"\r
+#include "services/dbg_os.h"\r
+#include "services/dbg_rsp.h"\r
+#include "services/dbg_rsp_defs.h"\r
+#include "services/dbg_rsp_extr.h"\r
+#include "services/dbg_rsp_thd.h"\r
+#include "services/dbg_rsp_tmr.h"\r
+#include "services/dbg_rsp_utils.h"\r
+#include "services/dbg_set.h"\r
+#include "services/dbg_str.h"\r
+#include "services/dbg_sts.h"\r
+#endif /* CFG_NU_OS_SVCS_DBG_ENABLE */\r
+\r
+#ifdef CFG_NU_OS_SVCS_DBG_ADV_ENABLE\r
+#include "services/dbg_adv_extr.h"\r
+#endif /* CFG_NU_OS_SVCS_DBG_ADV_ENABLE */\r
+\r
+/**********************************************************************/\r
+/* Trace and profile service */\r
+/**********************************************************************/\r
+#include "services/nu_trace.h"\r
+\r
+/**********************************************************************/\r
+/* Power Services */\r
+/**********************************************************************/\r
+#ifdef CFG_NU_OS_SVCS_PWR_ENABLE\r
+#include "services/power_core.h"\r
+#endif /* CFG_NU_OS_SVCS_PWR_ENABLE */\r
+\r
+\r
+/**********************************************************************/\r
+/* Registry Services */\r
+/**********************************************************************/\r
+#ifdef CFG_NU_OS_SVCS_REGISTRY_ENABLE\r
+#include "services/reg_api.h"\r
+#include "services/reg_impl.h"\r
+#include "services/reg_impl_mem_node.h"\r
+#include "services/reg_status.h"\r
+#endif /* CFG_NU_OS_SVCS_REGISTRY_ENABLE */\r
+\r
+\r
+/**********************************************************************/\r
+/* Runlevel Init Services */\r
+/**********************************************************************/\r
+#ifdef CFG_NU_OS_SVCS_INIT_ENABLE\r
+#include "services/runlevel_init.h"\r
+#endif /* CFG_NU_OS_SVCS_INIT_ENABLE */\r
+\r
+\r
+/**********************************************************************/\r
+/* Syslog Services */\r
+/**********************************************************************/\r
+#ifdef CFG_NU_OS_SVCS_SYSLOG_ENABLE\r
+#include "services/syslog_extern.h"\r
+#endif /* CFG_NU_OS_SVCS_SYSLOG_ENABLE */\r
+\r
+\r
+/**********************************************************************/\r
+/* SHELL Services */\r
+/**********************************************************************/\r
+#ifdef CFG_NU_OS_SVCS_SHELL_ENABLE\r
+#include "services/shell_extern.h"\r
+#endif /* CFG_NU_OS_SVCS_SHELL_ENABLE */\r
+\r
+#ifdef __cplusplus\r
+\r
+/* End of C declarations */\r
+}\r
+\r
+#endif /* __cplusplus */\r
+\r
+#endif /* !NU_SERVICES */\r
+\r
diff --git a/libs/system/zc702evk/nucleus/services/nu_trace.h b/libs/system/zc702evk/nucleus/services/nu_trace.h
--- /dev/null
@@ -0,0 +1,170 @@
+/***********************************************************************\r
+*\r
+* Copyright 2012 Mentor Graphics Corporation\r
+* All Rights Reserved.\r
+*\r
+* THIS WORK CONTAINS TRADE SECRET AND PROPRIETARY INFORMATION WHICH IS\r
+* THE PROPERTY OF MENTOR GRAPHICS CORPORATION OR ITS LICENSORS AND IS\r
+* SUBJECT TO LICENSE TERMS.\r
+************************************************************************\r
+\r
+************************************************************************\r
+*\r
+* DESCRIPTION\r
+*\r
+* This file contains external data structures and definitions of\r
+* TRACE components.\r
+*\r
+***********************************************************************/\r
+\r
+#ifndef _NU_TRACE_H_\r
+#define _NU_TRACE_H_\r
+\r
+#ifdef __cplusplus\r
+extern "C" { /* C declarations in C++ */\r
+#endif\r
+\r
+#include <stdarg.h>\r
+\r
+/* Mask definitions for each kernel object */\r
+#define NU_TRACE_ALL 0xFFFFFFFF\r
+#define NU_TRACE_APP (1<<0x0)\r
+#define NU_TRACE_KERN (~NU_TRACE_APP) /* Enable all kernel hooks */\r
+#define NU_TRACE_LISRS (1<<0x1)\r
+#define NU_TRACE_HISRS (1<<0x2)\r
+#define NU_TRACE_TASKS (1<<0x3)\r
+#define NU_TRACE_DMEM (1<<0x4)\r
+#define NU_TRACE_PMEM (1<<0x5)\r
+#define NU_TRACE_MAILBOX (1<<0x6)\r
+#define NU_TRACE_QUEUE (1<<0x7)\r
+#define NU_TRACE_PIPE (1<<0x8)\r
+#define NU_TRACE_SEMAPHORE (1<<0x9)\r
+#define NU_TRACE_EVENT (1<<0xA)\r
+#define NU_TRACE_SIGNAL (1<<0xB)\r
+#define NU_TRACE_TIMER (1<<0xC)\r
+#define NU_TRACE_CPU_STATE (1<<0xD)\r
+#define NU_TRACE_PMS_INFO (1<<0xE)\r
+#define NU_TRACE_STOR_INFO (1<<0XF)\r
+#define NU_TRACE_NET_INFO (1<<0X10)\r
+\r
+#define NU_TRACE_KERN_INFO (NU_TRACE_LISRS | NU_TRACE_HISRS | NU_TRACE_TASKS | \\r
+ NU_TRACE_DMEM | NU_TRACE_PMEM | NU_TRACE_MAILBOX | \\r
+ NU_TRACE_QUEUE | NU_TRACE_PIPE | NU_TRACE_SEMAPHORE | \\r
+ NU_TRACE_EVENT | NU_TRACE_SIGNAL | NU_TRACE_TIMER | \\r
+ NU_TRACE_CPU_STATE)\r
+\r
+/* Definitions for trace communications */\r
+#define NU_TRACE_TRANSMIT_ALL 0xFFFFFFFF\r
+\r
+/* Error definitions */\r
+#define NU_TRACE_INIT_ERROR -1\r
+#define NU_TRACE_ALREADY_INITIALIZED (NU_TRACE_INIT_ERROR - 1)\r
+#define NU_TRACE_NOT_INITIALIZED (NU_TRACE_ALREADY_INITIALIZED - 1)\r
+#define NU_TRACE_BUFF_FULL (NU_TRACE_NOT_INITIALIZED - 1)\r
+#define NU_TRACE_BUFF_EMPTY (NU_TRACE_BUFF_FULL - 1)\r
+#define NU_TRACE_INVALID_ARGS (NU_TRACE_BUFF_EMPTY - 1)\r
+#define NU_TRACE_COMMS_ERROR (NU_TRACE_INVALID_ARGS -1)\r
+#define NU_TRACE_COMMS_NOT_INITIALIZED (NU_TRACE_COMMS_ERROR - 1)\r
+#define NU_TRACE_COMMS_ALREADY_STARTED (NU_TRACE_COMMS_NOT_INITIALIZED - 1)\r
+#define NU_TRACE_COMMS_NOT_STARTED (NU_TRACE_COMMS_ALREADY_STARTED - 1)\r
+#define NU_TRACE_KERN_NOT_AVAILABLE (NU_TRACE_COMMS_NOT_STARTED - 1)\r
+#define NU_TRACE_ERROR_CODE_DELIMITER (NU_TRACE_KERN_NOT_AVAILABLE - 1)\r
+\r
+#ifdef CFG_NU_OS_SVCS_TRACE_ENABLE\r
+\r
+/* This macro invoke trace log if global mask is enabled for the kernel object requested */\r
+extern unsigned long Gbl_Trace_Mask;\r
+\r
+#if ((CFG_NU_OS_SVCS_TRACE_CORE_TRACE_SUPPORT == NU_TRUE) && (CFG_NU_OS_SVCS_TRACE_CORE_TRACK_TRACE_OVERHEAD == NU_TRUE))\r
+\r
+/* Trace log function prototype */\r
+extern void Log_pCU64U64(unsigned short evt_id, char* pC, unsigned long long u64_1, unsigned long long u64_2);\r
+extern UINT64 NU_Get_Time_Stamp();\r
+\r
+/* API latency trace event ID */\r
+#define TRACE_APPLY_MASK(_msk_bit_, _evt_str_, _trace_fn_) \\r
+{ \\r
+ unsigned long long _start; \\r
+ unsigned long long _finish; \\r
+ \\r
+ if(_msk_bit_ & Gbl_Trace_Mask) \\r
+ { \\r
+ _start = NU_Get_Time_Stamp(); \\r
+ _trace_fn_; \\r
+ _finish = NU_Get_Time_Stamp(); \\r
+ Log_pCU64U64(0xFE, _evt_str_, _finish, _start); \\r
+ } \\r
+}\r
+#else\r
+#define TRACE_APPLY_MASK(_msk_bit_, _evt_str_, _trace_fn_) \\r
+{ \\r
+ if(_msk_bit_ & Gbl_Trace_Mask) \\r
+ { \\r
+ _trace_fn_; \\r
+ } \\r
+}\r
+#endif /* ((CFG_NU_OS_SVCS_TRACE_CORE_TRACE_SUPPORT == NU_TRUE) && (CFG_NU_OS_SVCS_TRACE_CORE_TRACK_TRACE_OVERHEAD == NU_TRUE)) */\r
+\r
+/* User API interface */\r
+STATUS NU_Trace_Initialize(VOID);\r
+STATUS NU_Trace_Deinitialize(VOID);\r
+STATUS NU_Trace_Arm(UINT32 mask);\r
+STATUS NU_Trace_Disarm(UINT32 mask);\r
+UINT32 NU_Trace_Get_Mask(VOID);\r
+\r
+/* External definitions */\r
+extern void Trace_Mark_I32(char* evt_str, signed int i32_val);\r
+extern void Trace_Mark_U32(char* evt_str, unsigned int u32_val);\r
+extern void Trace_Mark_Float(char* evt_str, float float_val);\r
+extern void Trace_Mark_String(char* evt_str, char* str_val);\r
+extern void Trace_Mark(char *event_type, char* format, ...);\r
+\r
+#define NU_Trace_Mark_I32(evt_str, i32_val) TRACE_APPLY_MASK(NU_TRACE_APP, evt_str, Trace_Mark_I32(evt_str, i32_val))\r
+#define NU_Trace_Mark_U32(evt_str, u32_val) TRACE_APPLY_MASK(NU_TRACE_APP, evt_str, Trace_Mark_U32(evt_str, u32_val))\r
+#define NU_Trace_Mark_Float(evt_str, float_val) TRACE_APPLY_MASK(NU_TRACE_APP, evt_str, Trace_Mark_Float(evt_str, float_val))\r
+#define NU_Trace_Mark_String(evt_str, str_val) TRACE_APPLY_MASK(NU_TRACE_APP, evt_str, Trace_Mark_String(evt_str, str_val))\r
+#define NU_Trace_Mark Trace_Mark\r
+\r
+#if(defined(CFG_NU_OS_SVCS_TRACE_COMMS_ENABLE) && (CFG_NU_OS_SVCS_TRACE_COMMS_CHANNEL != DBG_INTERFACE))\r
+\r
+STATUS Trace_Comms_Start(OPTION comms_tsk_priority, UINT32 comms_tx_period);\r
+STATUS Trace_Comms_Stop(VOID);\r
+STATUS Trace_Comms_Flush(VOID);\r
+STATUS Trace_Comms_Transmit_N_Packets(UINT32 num_packets, UINT32* num_pkts_transmitted);\r
+\r
+#define NU_Trace_Comms_Start Trace_Comms_Start\r
+#define NU_Trace_Comms_Stop Trace_Comms_Stop\r
+#define NU_Trace_Comms_Flush Trace_Comms_Flush\r
+#define NU_Trace_Comms_Transmit_N_Packets Trace_Comms_Transmit_N_Packets\r
+\r
+#else\r
+\r
+#define NU_Trace_Comms_Start\r
+#define NU_Trace_Comms_Stop\r
+#define NU_Trace_Comms_Flush\r
+#define NU_Trace_Comms_Transmit_N_Packets\r
+\r
+#endif /* (defined(CFG_NU_OS_SVCS_TRACE_COMMS_ENABLE) && (CFG_NU_OS_SVCS_TRACE_COMMS_CHANNEL != DBG_INTERFACE)) */\r
+\r
+#else\r
+\r
+/* Dummy definitions to avoid build errors when Trace is disabled at build-time */\r
+#define NU_Trace_Initialize() NU_SUCCESS\r
+#define NU_Trace_Deinitialize() NU_SUCCESS\r
+#define NU_Trace_Arm(mask) NU_SUCCESS\r
+#define NU_Trace_Disarm(mask) NU_SUCCESS\r
+#define NU_Trace_Get_Mask() 0\r
+\r
+#define NU_Trace_Mark_I32(evt_str, i32_val)\r
+#define NU_Trace_Mark_U32(evt_str, u32_val)\r
+#define NU_Trace_Mark_Float(evt_str, float_val)\r
+#define NU_Trace_Mark_String(evt_str, str_val)\r
+#define NU_Trace_Mark\r
+\r
+#endif /* CFG_NU_OS_SVCS_TRACE_ENABLE */\r
+\r
+#ifdef __cplusplus\r
+} /* End of C declarations */\r
+#endif /* __cplusplus */\r
+\r
+#endif /* _NU_TRACE_H_ */\r
diff --git a/libs/system/zc702evk/nucleus/services/nu_trace_os_mark.h b/libs/system/zc702evk/nucleus/services/nu_trace_os_mark.h
--- /dev/null
@@ -0,0 +1,1218 @@
+/***********************************************************************\r
+*\r
+* Copyright 2012 Mentor Graphics Corporation\r
+* All Rights Reserved.\r
+*\r
+* THIS WORK CONTAINS TRADE SECRET AND PROPRIETARY INFORMATION WHICH IS\r
+* THE PROPERTY OF MENTOR GRAPHICS CORPORATION OR ITS LICENSORS AND IS\r
+* SUBJECT TO LICENSE TERMS.\r
+************************************************************************\r
+\r
+************************************************************************\r
+*\r
+* DESCRIPTION\r
+*\r
+* This file contains external data structures and definitions of\r
+* TRACE components.\r
+*\r
+***********************************************************************/\r
+\r
+#ifndef _OS_MARK_H_\r
+#define _OS_MARK_H_\r
+\r
+#ifdef __cplusplus\r
+extern "C" { /* C declarations in C++ */\r
+#endif\r
+\r
+#include "nucleus.h"\r
+#include "services/nu_trace.h"\r
+\r
+/* Build configuration that enables or disables kernel markers */\r
+#if (CFG_NU_OS_SVCS_TRACE_CORE_TRACE_SUPPORT == NU_TRUE)\r
+\r
+extern unsigned int idle_flag;\r
+\r
+/*******************/\r
+/* Event ID MACROs */\r
+/*******************/\r
+\r
+/* Event ID definitions for various kernel markers */\r
+#define KRN_EID_BASE 0x0\r
+\r
+/* IRQs */\r
+#define IRQ_ENABLE_EID (KRN_EID_BASE + 1)\r
+#define IRQ_DSABLE_EID (KRN_EID_BASE + 2)\r
+\r
+/* LISRs */\r
+#define LISR_REGED_EID (KRN_EID_BASE + 3)\r
+#define LISR_ENTRY_EID (KRN_EID_BASE + 4)\r
+#define LISR_EXITT_EID (KRN_EID_BASE + 5)\r
+\r
+/* HISRs */\r
+#define HISR_CREAT_EID (KRN_EID_BASE + 6)\r
+#define HISR_DELET_EID (KRN_EID_BASE + 7)\r
+#define HISR_ACTIV_EID (KRN_EID_BASE + 8)\r
+#define HISR_RUNIG_EID (KRN_EID_BASE + 9)\r
+#define HISR_STOPD_EID (KRN_EID_BASE + 10)\r
+\r
+/* Tasks */\r
+#define TASK_CREAT_EID (KRN_EID_BASE + 11)\r
+#define TASK_RESET_EID (KRN_EID_BASE + 12)\r
+#define TASK_READY_EID (KRN_EID_BASE + 13)\r
+#define TASK_RUNIG_EID (KRN_EID_BASE + 14)\r
+#define TASK_SSUSP_EID (KRN_EID_BASE + 15)\r
+#define TASK_TERMT_EID (KRN_EID_BASE + 16)\r
+#define TASK_DELET_EID (KRN_EID_BASE + 17)\r
+#define TASK_CHPRE_EID (KRN_EID_BASE + 18)\r
+#define TASK_CHPRO_EID (KRN_EID_BASE + 19)\r
+#define TASK_CHSLC_EID (KRN_EID_BASE + 20)\r
+\r
+/* Idle */\r
+#define IDLE_ENTRY_EID (KRN_EID_BASE + 21)\r
+#define IDLE_EXIT_EID (KRN_EID_BASE + 22)\r
+\r
+/* Dynamic memory */\r
+#define MEM_CREATE_EID (KRN_EID_BASE + 23)\r
+#define MEM_DELETE_EID (KRN_EID_BASE + 24)\r
+#define MEM_ADD_EID (KRN_EID_BASE + 25)\r
+#define DMEM_ALLOC_EID (KRN_EID_BASE + 26)\r
+#define DMEM_DALLO_EID (KRN_EID_BASE + 27)\r
+#define DMEM_RALLO_EID (KRN_EID_BASE + 28)\r
+\r
+/* Partitioned memory */\r
+#define PMEM_CREAT_EID (KRN_EID_BASE + 29)\r
+#define PMEM_DELET_EID (KRN_EID_BASE + 30)\r
+#define PMEM_ALLOC_EID (KRN_EID_BASE + 31)\r
+#define PMEM_DEALL_EID (KRN_EID_BASE + 32)\r
+\r
+/* Semaphores */\r
+#define SEMA_CREAT_EID (KRN_EID_BASE + 33)\r
+#define SEMA_RESET_EID (KRN_EID_BASE + 34)\r
+#define SEMA_OBTAI_EID (KRN_EID_BASE + 35)\r
+#define SEMA_RELSE_EID (KRN_EID_BASE + 36)\r
+#define SEMA_DELET_EID (KRN_EID_BASE + 37)\r
+\r
+/* Events */\r
+#define EVEN_CREAT_EID (KRN_EID_BASE + 38)\r
+#define EVEN_SET_EID (KRN_EID_BASE + 39)\r
+#define EVEN_RETRV_EID (KRN_EID_BASE + 40)\r
+#define EVEN_DELET_EID (KRN_EID_BASE + 41)\r
+\r
+/* Queues */\r
+#define QUEU_CREAT_EID (KRN_EID_BASE + 42)\r
+#define QUEU_RESET_EID (KRN_EID_BASE + 43)\r
+#define QUEU_BRBND_EID (KRN_EID_BASE + 44)\r
+#define QUEU_SEND_EID (KRN_EID_BASE + 45)\r
+#define QUEU_SD2FT_EID (KRN_EID_BASE + 46)\r
+#define QUEU_RECVE_EID (KRN_EID_BASE + 47)\r
+#define QUEU_DELET_EID (KRN_EID_BASE + 48)\r
+\r
+/* Pipes */\r
+#define PIPE_CREAT_EID (KRN_EID_BASE + 49)\r
+#define PIPE_RESET_EID (KRN_EID_BASE + 50)\r
+#define PIPE_BRBND_EID (KRN_EID_BASE + 51)\r
+#define PIPE_SEND_EID (KRN_EID_BASE + 52)\r
+#define PIPE_SD2FT_EID (KRN_EID_BASE + 53)\r
+#define PIPE_RECVE_EID (KRN_EID_BASE + 54)\r
+#define PIPE_DELET_EID (KRN_EID_BASE + 55)\r
+\r
+/* Mailbox */\r
+#define MBOX_CREAT_EID (KRN_EID_BASE + 56)\r
+#define MBOX_RESET_EID (KRN_EID_BASE + 57)\r
+#define MBOX_BRBND_EID (KRN_EID_BASE + 58)\r
+#define MBOX_SEND_EID (KRN_EID_BASE + 59)\r
+#define MBOX_RECVE_EID (KRN_EID_BASE + 60)\r
+#define MBOX_DELET_EID (KRN_EID_BASE + 61)\r
+\r
+/* Signals */\r
+#define SGNL_REGSR_EID (KRN_EID_BASE + 62)\r
+#define SGNL_CNTRL_EID (KRN_EID_BASE + 63)\r
+#define SGNL_SEND_EID (KRN_EID_BASE + 64)\r
+#define SGNL_RECVE_EID (KRN_EID_BASE + 65)\r
+#define SGNL_RUNIN_EID (KRN_EID_BASE + 66)\r
+#define SGNL_STOPD_EID (KRN_EID_BASE + 67)\r
+\r
+/* Timers */\r
+#define TIME_CREAT_EID (KRN_EID_BASE + 68)\r
+#define TIME_DELET_EID (KRN_EID_BASE + 69)\r
+#define TIME_RESET_EID (KRN_EID_BASE + 70)\r
+#define TIME_CNTRL_EID (KRN_EID_BASE + 71)\r
+#define TIME_PAUSE_EID (KRN_EID_BASE + 72)\r
+#define TIME_RESUM_EID (KRN_EID_BASE + 73)\r
+#define TIME_RUNIN_EID (KRN_EID_BASE + 74)\r
+#define TIME_STOPD_EID (KRN_EID_BASE + 75)\r
+\r
+/* Power Services */\r
+#define PWR_OP_INFO_EID (KRN_EID_BASE + 76)\r
+#define PWR_OP_TRANS_EID (KRN_EID_BASE + 77)\r
+#define PWR_HIB_ENTER_EID (KRN_EID_BASE + 78)\r
+#define PWR_HIB_EXIT_EID (KRN_EID_BASE + 79)\r
+#define PWR_HIB_EXIT_OP_EID (KRN_EID_BASE + 80)\r
+#define PWR_SYS_CNT_EID (KRN_EID_BASE + 81)\r
+#define PWR_SYS_MAP_EID (KRN_EID_BASE + 82)\r
+#define PWR_SYS_UNMAP_EID (KRN_EID_BASE + 83)\r
+#define PWR_SYS_TRANS_EID (KRN_EID_BASE + 84)\r
+#define PWR_DEV_TRANS_EID (KRN_EID_BASE + 85)\r
+#define PWR_WD_CREATE_EID (KRN_EID_BASE + 86)\r
+#define PWR_WD_ACTIVE_EID (KRN_EID_BASE + 87)\r
+#define PWR_WD_EXPIRE_EID (KRN_EID_BASE + 88)\r
+#define PWR_WD_DELETE_EID (KRN_EID_BASE + 89)\r
+#define PWR_TICK_SUP_EID (KRN_EID_BASE + 90)\r
+#define PWR_DEV_NAME_EID (KRN_EID_BASE + 91)\r
+#define PWR_OP_TL_START_EID (KRN_EID_BASE + 92)\r
+#define PWR_OP_TL_STOP_EID (KRN_EID_BASE + 93)\r
+#define PWR_HIB_TL_START_EID (KRN_EID_BASE + 94)\r
+#define PWR_HIB_TL_STOP_EID (KRN_EID_BASE + 95)\r
+#define PWR_SYS_TL_START_EID (KRN_EID_BASE + 96)\r
+#define PWR_SYS_TL_STOP_EID (KRN_EID_BASE + 97)\r
+#define PWR_DEV_TL_START_EID (KRN_EID_BASE + 98)\r
+#define PWR_DEV_TL_STOP_EID (KRN_EID_BASE + 99)\r
+\r
+/* Nucleus Storage */\r
+#define STOR_PHY_DEV_LIST_EID (KRN_EID_BASE + 100)\r
+#define STOR_PHY_DEV_REMOVAL_EID (KRN_EID_BASE + 101)\r
+#define STOR_LOG_DEV_REMOVAL_EID (KRN_EID_BASE + 102)\r
+#define STOR_LOG_DEV_INFO_EID (KRN_EID_BASE + 103)\r
+#define STOR_DIR_CREATE_INFO_EID (KRN_EID_BASE + 104)\r
+#define STOR_DIR_CREATE_STAT_EID (KRN_EID_BASE + 105)\r
+#define STOR_DIR_DEL_STAT_EID (KRN_EID_BASE + 106)\r
+#define STOR_FILE_OPEN_INFO_EID (KRN_EID_BASE + 107)\r
+#define STOR_FILE_OPEN_STAT_EID (KRN_EID_BASE + 108)\r
+#define STOR_FILE_CLOSE_STAT_EID (KRN_EID_BASE + 109)\r
+#define STOR_FILE_READ_START_EID (KRN_EID_BASE + 110)\r
+#define STOR_FILE_READ_STOP_EID (KRN_EID_BASE + 111)\r
+#define STOR_FILE_WRITE_START_EID (KRN_EID_BASE + 112)\r
+#define STOR_FILE_WRITE_STOP_EID (KRN_EID_BASE + 113)\r
+#define STOR_FILE_SEEK_START_EID (KRN_EID_BASE + 114)\r
+#define STOR_FILE_SEEK_STOP_EID (KRN_EID_BASE + 115)\r
+#define STOR_FILE_FLUSH_START_EID (KRN_EID_BASE + 116)\r
+#define STOR_FILE_FLUSH_STOP_EID (KRN_EID_BASE + 117)\r
+#define STOR_FILE_TRUNC_START_EID (KRN_EID_BASE + 118)\r
+#define STOR_FILE_TRUNC_STOP_EID (KRN_EID_BASE + 119)\r
+#define STOR_FILE_RENAME_STAT_EID (KRN_EID_BASE + 120)\r
+#define STOR_FILE_DEL_STAT_EID (KRN_EID_BASE + 121)\r
+\r
+/* Nucleus Networking */\r
+#define NET_STACK_INIT_STATUS_EID (KRN_EID_BASE + 122)\r
+#define NET_DEV_LIST_EID (KRN_EID_BASE + 123)\r
+#define NET_DEV_REMOVAL_EID (KRN_EID_BASE + 124)\r
+#define NET_DEV_IPv4_IP_EID (KRN_EID_BASE + 125)\r
+#define NET_DEV_IPv4_DHCP_IP_EID (KRN_EID_BASE + 126)\r
+#define NET_DEV_IPv6_IP_EID (KRN_EID_BASE + 127)\r
+#define NET_DEV_REMOVE_IP_EID (KRN_EID_BASE + 128)\r
+#define NET_DEV_DETACH_IP_EID (KRN_EID_BASE + 129)\r
+#define NET_DEV_LINK_UP_EID (KRN_EID_BASE + 130)\r
+#define NET_DEV_LINK_DOWN_EID (KRN_EID_BASE + 131)\r
+#define NET_DEV_UP_STATUS_EID (KRN_EID_BASE + 132)\r
+#define NET_SOCK_LIST_EID (KRN_EID_BASE + 133)\r
+#define NET_SOCK_STATUS_EID (KRN_EID_BASE + 134)\r
+#define NET_SOCK_ENQ_EID (KRN_EID_BASE + 135)\r
+#define NET_SOCK_TX_START_EID (KRN_EID_BASE + 136)\r
+#define NET_SOCK_TX_STOP_EID (KRN_EID_BASE + 137)\r
+#define NET_SOCK_RX_EID (KRN_EID_BASE + 138)\r
+#define NET_ADD_ROUTE_EID (KRN_EID_BASE + 139)\r
+#define NET_ADD_ROUTE6_EID (KRN_EID_BASE + 140)\r
+#define NET_DEL_ROUTE_EID (KRN_EID_BASE + 141)\r
+#define NET_DEL_ROUTE6_EID (KRN_EID_BASE + 142)\r
+#define NET_BUFF_USAGE_EID (KRN_EID_BASE + 143)\r
+#define NET_DEV_TX_LAT_START_EID (KRN_EID_BASE + 144)\r
+#define NET_DEV_TX_LAT_STOP_EID (KRN_EID_BASE + 145)\r
+#define NET_DEV_RX_ACT_EID (KRN_EID_BASE + 146)\r
+#define NET_DEV_TRANSQ_LEN_EID (KRN_EID_BASE + 147)\r
+#define NET_DEV_REMOVE_IP6_EID (KRN_EID_BASE + 148)\r
+\r
+/* Trace status definitions */\r
+#define OBJ_ACTION_SUCCESS 0\r
+#define OBJ_BLKD_CTXT 1\r
+#define OBJ_UNBLKD_CTXT 2\r
+\r
+#if (CFG_NU_OS_SVCS_TRACE_CORE_TRACK_TRACE_OVERHEAD == NU_TRUE)\r
+void Log_pCU64U64(unsigned short evt_id, char* evt_str, unsigned long long u64_1, unsigned long long u64_2);\r
+void Log_U64U64I(unsigned short evt_id, unsigned long long u64_1, unsigned long long u64_2, int status);\r
+\r
+#define LATENCY_IED 0xFF\r
+#define LATENCY_START_IED 0x2FF\r
+#define LATENCY_FINISH_IED 0x3FF\r
+#define TIMER_LOAD_VAL 0x1FF\r
+\r
+/* Define max timer count. */\r
+#define MAX_TIMER_COUNT \\r
+ ESAL_GE_TMR_COUNT_CALC(ESAL_GE_TMR_OS_CLOCK_RATE, \\r
+ ESAL_GE_TMR_OS_CLOCK_PRESCALE, \\r
+ NU_PLUS_TICKS_PER_SEC) \\r
+\r
+/* This macro invoke trace log if global mask is enabled for the kernel object requested */\r
+#define APPLY_MASK(_msk_bit_, _eid_, _trace_fn_) \\r
+{ \\r
+ unsigned long long _start; \\r
+ unsigned long long _finish; \\r
+ \\r
+ if(_msk_bit_ & Gbl_Trace_Mask) \\r
+ { \\r
+ _start = NU_Get_Time_Stamp(); \\r
+ _trace_fn_; \\r
+ _finish = NU_Get_Time_Stamp(); \\r
+ Log_U64U64I(LATENCY_IED, _finish, _start, _eid_); \\r
+ } \\r
+}\r
+\r
+#else\r
+\r
+/* This macro invoke trace log if global mask is enabled for the kernel object requested */\r
+#define APPLY_MASK(_msk_bit_, _eid_, _trace_fn_) \\r
+{ \\r
+ NU_UNUSED_PARAM(_eid_); \\r
+ \\r
+ if(_msk_bit_ & Gbl_Trace_Mask) \\r
+ { \\r
+ _trace_fn_; \\r
+ } \\r
+}\r
+\r
+#endif\r
+\r
+/* Size definitions for various trace signatures */\r
+#define I_SIZE sizeof(int)\r
+#define UL_SIZE sizeof(unsigned long)\r
+#define UC_SIZE sizeof(unsigned char)\r
+#define pV_SIZE sizeof(void*)\r
+#define US_SIZE sizeof(unsigned short)\r
+#define IS_SIZE sizeof(signed short)\r
+#define IL_SIZE sizeof(signed long)\r
+\r
+#define TH_SIZE sizeof(TRACE_MARK_HDR)\r
+#define TH_I_SIZE (TH_SIZE + sizeof(int))\r
+#define TH_pVI_SIZE (TH_SIZE + sizeof(void*) + sizeof(int))\r
+#define TH_pVU8I_SIZE (TH_SIZE + sizeof(void*) + sizeof(unsigned char) + sizeof(int))\r
+#define TH_pVU32I_SIZE (TH_SIZE + sizeof(void*) + sizeof(unsigned long) + sizeof(int))\r
+#define TH_pVU32U8I_SIZE (TH_SIZE + sizeof(void*) + sizeof(unsigned long) + \\r
+ sizeof(unsigned char) + sizeof(int))\r
+#define TH_pVpVU32I_SIZE (TH_SIZE + sizeof(void*) + sizeof(void*) + \\r
+ sizeof(unsigned long) + sizeof(int))\r
+#define TH_pVpVU32U8I_SIZE (TH_SIZE + sizeof(void*) + sizeof(void*) + \\r
+ sizeof(unsigned long) + sizeof(unsigned char) + sizeof(int))\r
+#define TH_pVpVpVU32U8I_SIZE (TH_SIZE + sizeof(void*) + sizeof(void*) + sizeof(void*) + \\r
+ sizeof(unsigned long) + sizeof(unsigned char) + sizeof(int))\r
+#define TH_pVpVU32U32U8I_SIZE (TH_SIZE + sizeof(void*) + sizeof(void*) + \\r
+ sizeof(unsigned long) + sizeof(unsigned long) + \\r
+ sizeof(unsigned char) + sizeof(int))\r
+#define TH_pVU32U32U32U8I_SIZE (TH_SIZE + sizeof(void*) + sizeof(unsigned long) + \\r
+ sizeof(unsigned long) + sizeof(unsigned long) + \\r
+ sizeof(unsigned char) + sizeof(int))\r
+#define TH_pVpVU32U32U8U8I_SIZE (TH_SIZE + sizeof(void*) + sizeof(void*) + \\r
+ sizeof(unsigned long) + sizeof(unsigned long) + \\r
+ sizeof(unsigned char) + sizeof(unsigned char) + sizeof(int))\r
+#define TH_pVpVU32U32U32U8I_SIZE (TH_SIZE + sizeof(void*) + sizeof(void*) + sizeof(unsigned long) +\\r
+ sizeof(unsigned long) + sizeof(unsigned long) + sizeof(unsigned char) + \\r
+ sizeof(int))\r
+#define TH_pVpVpVU32U32U8U8I_SIZE (TH_SIZE + sizeof(void*) + sizeof(void*) + sizeof(void*) + \\r
+ sizeof(unsigned long) + sizeof(unsigned long) + \\r
+ sizeof(unsigned char) + sizeof(unsigned char) + sizeof(int))\r
+#define TH_pVpVU32U32U32I_SIZE (TH_SIZE + sizeof(void*) + sizeof(void*) + \\r
+ sizeof(unsigned long) + sizeof(unsigned long) + \\r
+ sizeof(unsigned long) + sizeof(int))\r
+#define TH_pVpVpVU32U32U8U8U8I_SIZE (TH_SIZE + sizeof(void*) + sizeof(void*) + sizeof(void*) + \\r
+ sizeof(unsigned long) + sizeof(unsigned long) + \\r
+ sizeof(unsigned char) + sizeof(unsigned char) + \\r
+ sizeof(unsigned char) + sizeof(int))\r
+#define TH_pVpVpVU32U32U32I_SIZE (TH_SIZE + sizeof(void*) + sizeof(void*) + sizeof(void*) + \\r
+ sizeof(unsigned long) + sizeof(unsigned long) + \\r
+ sizeof(unsigned long) + sizeof(int))\r
+#define TH_pVpVpVU32U32U32U32I_SIZE (TH_SIZE + sizeof(void*) + sizeof(void*) + sizeof(void*) + \\r
+ sizeof(unsigned long) + sizeof(unsigned long) + \\r
+ sizeof(unsigned long) + sizeof(unsigned long) + \\r
+ sizeof(int))\r
+#define TH_pVpVpVU32U32U32U32U32I_SIZE (TH_SIZE + sizeof(void*) + sizeof(void*) + sizeof(void*) + \\r
+ sizeof(unsigned long) + sizeof(unsigned long) + \\r
+ sizeof(unsigned long) + sizeof(unsigned long) + \\r
+ sizeof(unsigned long) + sizeof(int))\r
+#define TH_I32U32U8I_SIZE (TH_SIZE + sizeof(signed long) + sizeof(unsigned long) + \\r
+ sizeof(unsigned char) + sizeof(int))\r
+#define TH_U32U8I32_SIZE (TH_SIZE + sizeof(unsigned long) + sizeof(unsigned char) + \\r
+ sizeof(signed long))\r
+#define TH_U8U32U32I_SIZE (TH_SIZE + sizeof(unsigned char) + sizeof(unsigned long) + \\r
+ sizeof(unsigned long) + sizeof(int))\r
+#define TH_U16U16_SIZE (TH_SIZE + sizeof(unsigned short) + sizeof(unsigned short))\r
+#define TH_U16U16I_SIZE (TH_SIZE + sizeof(unsigned short) + sizeof(unsigned short) + sizeof(int))\r
+#define TH_U8U32I_SIZE (TH_SIZE + sizeof(unsigned char) + sizeof(unsigned long) + sizeof(int))\r
+#define TH_U8I_SIZE (TH_SIZE + sizeof(unsigned char) + sizeof(int))\r
+#define TH_I16I_SIZE (TH_SIZE + sizeof(signed short) + sizeof(int))\r
+#define TH_U32U32I_SIZE (TH_SIZE + sizeof(unsigned long) + sizeof(unsigned long) + sizeof(int))\r
+#define TH_U32I_SIZE (TH_SIZE + sizeof(unsigned long) + sizeof(int))\r
+\r
+\r
+/* Internal function prototypes for kernel markers */\r
+void Log_V(unsigned short evt_id);\r
+void Log_I(unsigned short evt_id, int irq_num);\r
+void Log_II(unsigned short evt_id, int irq_num, int status);\r
+void Log_U32(unsigned short evt_id, unsigned long u32);\r
+void Log_U32I(unsigned short evt_id, unsigned long u32, int status);\r
+void Log_pV(unsigned short evt_id, void* pV);\r
+void Log_pVU32(unsigned short evt_id, void* pV, unsigned long u32);\r
+void Log_pVI(unsigned short evt_id, void* pV, int status);\r
+void Log_pVpV(unsigned short evt_id, void* pV1, void* pV2);\r
+void Log_pVpVI(unsigned short evt_id, void* pV1, void* pV2, int status);\r
+void Log_pVpCI(unsigned short evt_id, void* pV, char* pC, int status);\r
+void Log_pVU8I(unsigned short evt_id, void* pV, unsigned char u8, int status);\r
+void Log_pVU32I(unsigned short evt_id, void* pV, unsigned long u32, int status);\r
+void Log_pVU32U8I(unsigned short evt_id, void* pV, unsigned long u32, unsigned char u8, int status);\r
+void Log_pVpCU32I(unsigned short evt_id, void* pV, char* pC, unsigned long u32, int status);\r
+void Log_pVU8U8(unsigned short evt_id, void* pV, unsigned char u8_1, unsigned char u8_2);\r
+void Log_pVU32U32(unsigned short evt_id, void* pV, unsigned long u32_1, unsigned long u32_2);\r
+void Log_pVpCU32U8I(unsigned short evt_id, void* pV, char* pC, unsigned long u32, unsigned char u8, int status);\r
+void Log_pVpVU8I(unsigned short evt_id, void* pV1, void* pV2, unsigned char u8, int status);\r
+void Log_pVpCU8I(unsigned short evt_id, void* pV, char* pC, unsigned char u8, int status);\r
+void Log_pVpVU32I(unsigned short evt_id, void* pV1, void* pV2, unsigned long u32, int status);\r
+void Log_pVpVpCU32I(unsigned short evt_id, void* pV1, void* pV2, char* pC, unsigned long u32, int status);\r
+void Log_pVpVU32U8I(unsigned short evt_id, void* pV1, void* pV2, unsigned long u32, unsigned char u8, int status);\r
+void Log_pVpVU32U32I(unsigned short evt_id, void* pV1, void* pV2, unsigned long u32_1, unsigned long u32_2, int status);\r
+void Log_pVpVpCU32U8I(unsigned short evt_id, void* pV1, void* pV2, char* pC, unsigned long u32, unsigned char u8, int status);\r
+void Log_pVpVpVU32I(unsigned short evt_id, void* pV1, void* pV2, void* pV3, unsigned long u32_1, int status);\r
+void Log_pVpVpVU32U32I(unsigned short evt_id, void* pV1, void* pV2, void* pV3, unsigned long u32_1, unsigned long u32_2, int status);\r
+void Log_pVpVpVpCU32U8I(unsigned short evt_id, void* pV1, void* pV2, void* pV3, char* pC, unsigned long u32, unsigned char u8, int status);\r
+void Log_pVpVpCU32U32U8I(unsigned short evt_id, void* pV1, void* pV3, char* pC, unsigned long u32_1,\r
+ unsigned long u32_2, unsigned char u8, int status);\r
+void Log_pVpVU32U32U32I(unsigned short evt_id, void* pV1, void* pV2, unsigned long u32_1, unsigned long u32_2, unsigned long u32_3, int status);\r
+void Log_pVpVU32U32U8I(unsigned short evt_id, void* pV1, void* pV2, unsigned long u32_1, unsigned long u32_2, unsigned char u8, int status);\r
+void Log_pVU32U32U32U8I(unsigned short evt_id, void* pV, unsigned long u32_1, unsigned long u32_2, unsigned long u32_3,\r
+ unsigned char u8, int status);\r
+void Log_pVpVpCU32U32U32U8I(unsigned short evt_id, void* pV1, void* pV2, char* pC,unsigned long u32_1, unsigned long u32_2,\r
+ unsigned long u32_3, unsigned char u8, int status);\r
+void Log_pVpVpVU32U32U8U8I(unsigned short evt_id, void* pV1, void* pV2, void* pV3, unsigned long u32_1, unsigned long u32_2,\r
+ unsigned char u8_1, unsigned char u8_2, int status);\r
+void Log_pVpVpCU32U32U8U8I(unsigned short evt_id, void* pV1, void* pV2, char* pC, unsigned long u32_1, unsigned long u32_2,\r
+ unsigned char u8_1, unsigned char u8_2, int status);\r
+void Log_pVpVpVpCU32U32U8U8U8I(unsigned short evt_id, void* pV1, void* pV2, void* pV3, char* pC1, unsigned long u32_1,\r
+ unsigned long u32_2, unsigned char u8_1, unsigned char u8_2, unsigned char u8_3, int status);\r
+void Log_pVpVpVU32U32U32I(unsigned short evt_id, void* pV1, void* pV2, void* pV3, unsigned long u32_1, unsigned long u32_2,\r
+ unsigned long u32_3, int status);\r
+void Log_pVpVpVU32U32U32U32I(unsigned short evt_id, void* pV1, void* pV2, void* pV3, unsigned long u32_1, unsigned long u32_2,\r
+ unsigned long u32_3, unsigned long u32_4, int status);\r
+void Log_pVpVpVU32U32U32U32U32I(unsigned short evt_id, void* pV1, void* pV2, void* pV3, unsigned long u32_1, unsigned long u32_2,\r
+ unsigned long u32_3, unsigned long u32_4, unsigned long u32_5, int status);\r
+void Log_U8U8U16U8U32(unsigned short evt_id, unsigned char u8_1, unsigned char u8_2, unsigned short u16, unsigned char u8_3, unsigned long u32);\r
+void Log_U8I(unsigned short evt_id, unsigned char u8, int status);\r
+void Log_U8(unsigned short evt_id, unsigned char u8);\r
+void Log_I32U32U8I(unsigned short evt_id, signed long i32, unsigned long u32, unsigned char u8,int status);\r
+void Log_I32U32I(unsigned short evt_id, signed long i32, unsigned long u32, int status);\r
+void Log_I32I(unsigned short evt_id, signed long i32, int status);\r
+void Log_I32II(unsigned short evt_id, signed long i32, int fd, int status);\r
+void Log_I32I16I(unsigned short evt_id, signed long i32, signed short i16, int fd);\r
+void Log_I32II32(unsigned short evt_id, signed long i32_1, int fd, signed long i32_2);\r
+void Log_pCU32U8I32(unsigned short evt_id, char* pC, unsigned long u32, unsigned char u8, signed long i32);\r
+void Log_I32(unsigned short evt_id, signed long i32);\r
+void Log_pC(unsigned short evt_id, char* pC);\r
+void Log_pCI(unsigned short evt_id, char* pC, int status);\r
+void Log_pCpCpCU8U32U32I(unsigned short evt_id, char* pC1, char* pC2, char* pC3,\r
+ unsigned char u8, unsigned long u32_1, unsigned long u32_2, int status);\r
+void Log_pCpCI(unsigned short evt_id, char* pC1, char* pC2, int fd);\r
+void Log_pCpCpC(unsigned short evt_id, char* pC1, char* pC2, char* pC3);\r
+void Log_pCpCpCU16U16I(unsigned short evt_id, char* pC1, char* pC2, char* pC3, unsigned short u16_1, unsigned short u16_2, int fd);\r
+void Log_pCU16U16I(unsigned short evt_id, char* pC, unsigned short u16_1, unsigned short u16_2, int fd);\r
+void Log_I32I16II32(unsigned short evt_id, signed long i32_1, signed short i16, int fd, signed long i32_2);\r
+void Log_pCpU8U8U32I_pU8ArraySize(unsigned short evt_id, char* pC, unsigned char* pU8, unsigned char u8,\r
+ unsigned long u32, int status, unsigned char pu8_array_size);\r
+void Log_pCpU8pU8I_pU8ArraySize(unsigned short evt_id, char* pC, unsigned char* pU8_1,\r
+ unsigned char* pU8_2, int status, unsigned char pu8_array_size);\r
+void Log_pCpU8pU8pU8I_pU8ArraySize(unsigned short evt_id, char* pC, unsigned char* pU8_1,\r
+ unsigned char* pU8_2, unsigned char* pU8_3, int status, unsigned char pu8_array_size);\r
+void Log_pCpU8I_pU8ArraySize(unsigned short evt_id, char* pC, unsigned char* pU8, int status, unsigned char pu8_array_size);\r
+void Log_pCpU8U8I_pU8ArraySize(unsigned short evt_id, char* pC, unsigned char* pU8, unsigned char u8,\r
+ int status, unsigned char u8_array_size);\r
+void Log_pCpU8pU8U8I_pU8ArraySize(unsigned short evt_id, char* pC, unsigned char* pU8_1, unsigned char* pU8_2,\r
+ unsigned char u8, int status, unsigned char u8_array_size);\r
+void Log_pCpU8I16I_pU8ArraySize(unsigned short evt_id, char* pC, unsigned char* pU8, signed short i16, int status, unsigned char pu8_array_size);\r
+void Log_pCU8I(unsigned short evt_id, char* pC, unsigned char u8, int status);\r
+void Log_I16I16I16I(unsigned short evt_id, signed short i16_1, signed short i16_2, signed short i16_3, int status);\r
+void Log_U16II(unsigned short evt_id, unsigned short u16, int sd, int status);\r
+void Log_U32U32I(unsigned short evt_id, unsigned long u32_1, unsigned long u32_2, int sd);\r
+void Log_U16II32(unsigned short evt_id, unsigned short u16, int sd, signed long i32);\r
+void Log_pU8pU8I_pU8ArraySize(unsigned short evt_id, unsigned char* pU8_1, unsigned char* pU8_2, int status, unsigned char pu8_array_size);\r
+void Log_U16(unsigned short evt_id, unsigned short u16);\r
+void Log_pCU32U32I(unsigned short evt_id, char* pC, unsigned long u32_1, unsigned long u32_2, int status);\r
+void Log_pCU32I(unsigned short evt_id, char* pC, unsigned long u32, int status);\r
+void Log_pCU32(unsigned short evt_id, char* pC, unsigned long u32);\r
+\r
+\r
+/* Build configuration that enables or disables kernel markers */\r
+#if (CFG_NU_OS_SVCS_TRACE_CORE_PC_HOTSPOT_SUPPORT == NU_TRUE)\r
+\r
+extern void *Trace_PC_Sample;\r
+\r
+/********************************/\r
+/* Nucleus PC Hot Spot Analysis */\r
+/********************************/\r
+#define T_PC_SAMPLE() Log_pV(0xFFFF, Trace_PC_Sample)\r
+\r
+#else\r
+\r
+/********************************/\r
+/* Nucleus PC Hot Spot Analysis */\r
+/********************************/\r
+#define T_PC_SAMPLE()\r
+\r
+#endif /* (CFG_NU_OS_SVCS_TRACE_CORE_PC_HOTSPOT_SUPPORT == NU_TRUE) */\r
+\r
+/*********/\r
+/* LISRs */\r
+/*********/\r
+#define T_IRQ_ENABLED(irq_num, status) APPLY_MASK(NU_TRACE_LISRS, IRQ_ENABLE_EID, \\r
+ Log_II(IRQ_ENABLE_EID, irq_num, status))\r
+#define T_IRQ_DISABLED(irq_num, status) APPLY_MASK(NU_TRACE_LISRS, IRQ_DSABLE_EID, \\r
+ Log_II(IRQ_DSABLE_EID, irq_num, status))\r
+#define T_LISR_REGISTERED(irq_num, status) APPLY_MASK(NU_TRACE_LISRS, LISR_REGED_EID, \\r
+ Log_II(LISR_REGED_EID, irq_num, status))\r
+#define T_LISR_ENTRY(irq_num) APPLY_MASK(NU_TRACE_LISRS, LISR_ENTRY_EID, \\r
+ Log_I(LISR_ENTRY_EID, irq_num))\r
+#define T_LISR_EXIT(irq_num) APPLY_MASK(NU_TRACE_LISRS, LISR_EXITT_EID, \\r
+ Log_I(LISR_EXITT_EID, irq_num))\r
+/*********/\r
+/* HISRs */\r
+/*********/\r
+#define T_HISR_CREATED(p_hcb, p_hisr_entry, p_stack, p_hisr_name, p_size, priority, status)\\r
+ APPLY_MASK(NU_TRACE_HISRS, HISR_CREAT_EID, \\r
+ Log_pVpVpVpCU32U8I(HISR_CREAT_EID, p_hcb, \\r
+ p_hisr_entry, p_stack, p_hisr_name, p_size, \\r
+ priority, status))\r
+#define T_HISR_DELETED(p_hcb, status) APPLY_MASK(NU_TRACE_HISRS, HISR_DELET_EID, \\r
+ Log_pVI(HISR_DELET_EID, p_hcb, status))\r
+#define T_HISR_ACTIVATED(p_hcb, status) APPLY_MASK(NU_TRACE_HISRS, HISR_ACTIV_EID, \\r
+ Log_pVI(HISR_ACTIV_EID, p_hcb, status))\r
+#define T_HISR_RUNNING(p_hcb) APPLY_MASK(NU_TRACE_HISRS, HISR_RUNIG_EID, \\r
+ Log_pV(HISR_RUNIG_EID, p_hcb))\r
+#define T_HISR_STOPPED(p_hcb) APPLY_MASK(NU_TRACE_HISRS, HISR_STOPD_EID, \\r
+ Log_pV(HISR_STOPD_EID, p_hcb))\r
+/*********/\r
+/* Tasks */\r
+/*********/\r
+#define T_TASK_CREATED(p_tcb, p_task, p_stk, p_name, stk_size, time_slice, priority, \\r
+ preempt_opt, strt_opt, status) \\r
+ APPLY_MASK(NU_TRACE_TASKS, TASK_CREAT_EID, \\r
+ Log_pVpVpVpCU32U32U8U8U8I(TASK_CREAT_EID, \\r
+ p_tcb, p_task, p_stk, p_name, stk_size, \\r
+ time_slice, priority, preempt_opt, strt_opt, status))\r
+#define T_TASK_RESET(p_tcb, status) APPLY_MASK(NU_TRACE_TASKS, TASK_RESET_EID, \\r
+ Log_pVI(TASK_RESET_EID, p_tcb, status))\r
+#define T_TASK_READY(p_tcb) APPLY_MASK(NU_TRACE_TASKS, TASK_READY_EID, \\r
+ Log_pV(TASK_READY_EID, p_tcb))\r
+#define T_TASK_RUNNING(p_tcb) APPLY_MASK(NU_TRACE_TASKS, TASK_RUNIG_EID, \\r
+ Log_pV(TASK_RUNIG_EID, p_tcb))\r
+#define T_TASK_SUSPEND(p_tcb, sus_type) APPLY_MASK(NU_TRACE_TASKS, TASK_SSUSP_EID, \\r
+ Log_pVU32(TASK_SSUSP_EID, p_tcb, sus_type))\r
+#define T_TASK_TERMINATED(p_tcb, status) APPLY_MASK(NU_TRACE_TASKS, TASK_TERMT_EID, \\r
+ Log_pVI(TASK_TERMT_EID, p_tcb, status))\r
+#define T_TASK_DELETED(p_tcb, status) APPLY_MASK(NU_TRACE_TASKS, TASK_DELET_EID, \\r
+ Log_pVI(TASK_DELET_EID, p_tcb, status))\r
+#define T_TASK_CHG_PREMPTION(p_tcb, new_prempt_state, old_prempt_state) \\r
+ APPLY_MASK(NU_TRACE_TASKS, TASK_CHPRE_EID, \\r
+ Log_pVU8U8(TASK_CHPRE_EID, p_tcb, \\r
+ new_prempt_state, old_prempt_state))\r
+#define T_TASK_CHG_PRIORITY(p_tcb, new_priority, old_priority) \\r
+ APPLY_MASK(NU_TRACE_TASKS, TASK_CHPRO_EID, \\r
+ Log_pVU8U8(TASK_CHPRO_EID, p_tcb, \\r
+ new_priority, old_priority))\r
+#define T_TASK_CHG_TIMESLICE(p_tcb, new_timeslice, old_timeslice) \\r
+ APPLY_MASK(NU_TRACE_TASKS, TASK_CHSLC_EID, \\r
+ Log_pVU32U32(TASK_CHSLC_EID, p_tcb, \\r
+ new_timeslice, old_timeslice))\r
+\r
+/******************/\r
+/* Dynamic memory */\r
+/******************/\r
+#define T_MEM_POOL_CREATE(p_mpcb, p_start_add, p_name, size, available_size, min_size, \\r
+ sus_typ, status) \\r
+ APPLY_MASK(NU_TRACE_DMEM, MEM_CREATE_EID, \\r
+ Log_pVpVpCU32U32U32U8I(MEM_CREATE_EID, \\r
+ p_mpcb, p_start_add, p_name, size, available_size, \\r
+ min_size, sus_typ, status))\r
+#define T_MEM_POOL_DELETE(p_mpcb, status) APPLY_MASK(NU_TRACE_DMEM, MEM_DELETE_EID, \\r
+ Log_pVI(MEM_DELETE_EID, p_mpcb, status))\r
+#define T_MEM_ADD(p_mpcb, p_start_add, p_caller, total_size, available_size, added_size, \\r
+ status) \\r
+ APPLY_MASK(NU_TRACE_DMEM, MEM_ADD_EID, \\r
+ Log_pVpVpVU32U32U32I(MEM_ADD_EID, p_mpcb, \\r
+ p_start_add, p_caller, total_size, available_size, \\r
+ added_size, status))\r
+#define T_DMEM_ALLOCATE(p_mpcb, p_start, p_caller, total_size, available_size, \\r
+ size, sus_type, status) \\r
+ APPLY_MASK(NU_TRACE_DMEM, DMEM_ALLOC_EID, \\r
+ Log_pVpVpVU32U32U32U32I(DMEM_ALLOC_EID, \\r
+ p_mpcb, p_start, p_caller, total_size, \\r
+ available_size, size, sus_type, status))\r
+#define T_DMEM_DEALLOCATE(p_mpcb, p_start, p_caller, total_size, available_size, status) \\r
+ APPLY_MASK(NU_TRACE_DMEM, DMEM_DALLO_EID, \\r
+ Log_pVpVpVU32U32I(DMEM_DALLO_EID, p_mpcb, \\r
+ p_start, p_caller, total_size, available_size, status))\r
+#define T_DMEM_REALLOCATE(p_mpcb, p_orig_mem, p_caller, total_size, available_size, new_size,\\r
+ susp_type, status) \\r
+ APPLY_MASK(NU_TRACE_DMEM, DMEM_RALLO_EID, \\r
+ Log_pVpVpVU32U32U32U32I(DMEM_RALLO_EID, \\r
+ p_mpcb, p_orig_mem, p_caller, total_size, \\r
+ available_size, new_size, susp_type, status))\r
+\r
+/********************/\r
+/* Partition memory */\r
+/********************/\r
+#define T_PMEM_CREATE(p_pmpcb, p_start_add, p_name, p_avail, p_size, sus_type, status) \\r
+ APPLY_MASK(NU_TRACE_PMEM, PMEM_CREAT_EID, \\r
+ Log_pVpVpCU32U32U8I(PMEM_CREAT_EID, \\r
+ p_pmpcb, p_start_add, p_name, p_avail, p_size, \\r
+ sus_type, status))\r
+#define T_PMEM_ALLOCATE(p_pmpcb, p_partition, p_caller, poolsize, partition_size, \\r
+ available_size, allocated_size, susp_type, status) \\r
+ APPLY_MASK(NU_TRACE_PMEM, PMEM_ALLOC_EID, \\r
+ Log_pVpVpVU32U32U32U32U32I(PMEM_ALLOC_EID, \\r
+ p_pmpcb, p_partition, p_caller, poolsize, \\r
+ partition_size, available_size, allocated_size, \\r
+ susp_type, status))\r
+#define T_PMEM_DEALLOCATE(p_pmpcb, p_partition, p_caller, poolsize, partition_size, \\r
+ available_size, allocated_size, status) \\r
+ APPLY_MASK(NU_TRACE_PMEM, PMEM_DEALL_EID, \\r
+ Log_pVpVpVU32U32U32U32I(PMEM_DEALL_EID, \\r
+ p_pmpcb, p_partition, p_caller, poolsize, \\r
+ partition_size, available_size, allocated_size, status))\r
+#define T_PMEM_DELETE(p_pmpcb, status) APPLY_MASK(NU_TRACE_PMEM, PMEM_DELET_EID, \\r
+ Log_pVI(PMEM_DELET_EID, p_pmpcb, status))\r
+\r
+/**************/\r
+/* Semaphores */\r
+/**************/\r
+#define T_SEM_CREATE(p_scb, p_name, ini_count, susp_type, status) \\r
+ APPLY_MASK(NU_TRACE_SEMAPHORE, SEMA_CREAT_EID, \\r
+ Log_pVpCU32U8I(SEMA_CREAT_EID, \\r
+ p_scb, p_name, ini_count, susp_type, status))\r
+#define T_SEM_DELETE(p_pcb, p_tcb, status) \\r
+ APPLY_MASK(NU_TRACE_SEMAPHORE, SEMA_DELET_EID, \\r
+ Log_pVpVI(SEMA_DELET_EID, p_pcb, p_tcb, status))\r
+#define T_SEM_RESET(p_pcb, p_tcb, init_count, status) \\r
+ APPLY_MASK(NU_TRACE_SEMAPHORE, SEMA_RESET_EID, \\r
+ Log_pVpVU32I(SEMA_RESET_EID, p_pcb, \\r
+ p_tcb, init_count, status))\r
+#define T_SEM_OBTAIN(p_pcb, p_tcb, suspend, status) \\r
+ APPLY_MASK(NU_TRACE_SEMAPHORE, SEMA_OBTAI_EID, \\r
+ Log_pVpVU32I(SEMA_OBTAI_EID, p_pcb, \\r
+ p_tcb, suspend, status))\r
+#define T_SEM_RELEASE(p_pcb, p_tcb, status)APPLY_MASK(NU_TRACE_SEMAPHORE, SEMA_RELSE_EID, \\r
+ Log_pVpVI(SEMA_RELSE_EID, p_pcb, p_tcb, status))\r
+\r
+/****************/\r
+/* Event groups */\r
+/****************/\r
+#define T_EVT_GRP_CREATE(p_evt_grp, p_name, status) \\r
+ APPLY_MASK(NU_TRACE_EVENT, EVEN_CREAT_EID, \\r
+ Log_pVpCI(EVEN_CREAT_EID, p_evt_grp, \\r
+ p_name, status))\r
+#define T_EVT_SET(p_evt_grp, evt_flags, operation, status) \\r
+ APPLY_MASK(NU_TRACE_EVENT, EVEN_SET_EID, \\r
+ Log_pVU32U8I(EVEN_SET_EID, p_evt_grp, \\r
+ evt_flags, operation, status))\r
+#define T_EVT_RETRIEVE(p_evt_grp, req_evt, ret_events, suspend, operation, status) \\r
+ APPLY_MASK(NU_TRACE_EVENT, EVEN_RETRV_EID, \\r
+ Log_pVU32U32U32U8I(EVEN_RETRV_EID, \\r
+ p_evt_grp, req_evt, ret_events, suspend, \\r
+ operation, status))\r
+#define T_EVT_GRP_DELETE(p_evt_grp, status) APPLY_MASK(NU_TRACE_EVENT, EVEN_DELET_EID, \\r
+ Log_pVI(EVEN_DELET_EID, p_evt_grp, status))\r
+\r
+/**********/\r
+/* Queues */\r
+/**********/\r
+#define T_Q_CREATE(p_qcb, p_start, p_name, q_size, msg_size, msg_type, susp_type, status) \\r
+ APPLY_MASK(NU_TRACE_QUEUE, QUEU_CREAT_EID, \\r
+ Log_pVpVpCU32U32U8U8I(QUEU_CREAT_EID, \\r
+ p_qcb, p_start, p_name, q_size, msg_size, \\r
+ msg_type, susp_type, status))\r
+#define T_Q_RESET(p_qcb, status) APPLY_MASK(NU_TRACE_QUEUE, QUEU_RESET_EID, \\r
+ Log_pVI(QUEU_RESET_EID, p_qcb, status))\r
+#define T_Q_BCAST(p_qcb, p_msg, size, susp, status) \\r
+ APPLY_MASK(NU_TRACE_QUEUE, QUEU_BRBND_EID, \\r
+ Log_pVpVU32U32I(QUEU_BRBND_EID, p_qcb, \\r
+ p_msg, size, susp, status))\r
+#define T_Q_SEND(p_qcb, p_msg, size, susp, status) \\r
+ APPLY_MASK(NU_TRACE_QUEUE, QUEU_SEND_EID, \\r
+ Log_pVpVU32U32I(QUEU_SEND_EID, p_qcb, \\r
+ p_msg, size, susp, status))\r
+#define T_Q_SEND2FRONT(p_qcb, p_msg, size, susp, status) \\r
+ APPLY_MASK(NU_TRACE_QUEUE, QUEU_SD2FT_EID, \\r
+ Log_pVpVU32U32I(QUEU_SD2FT_EID, p_qcb, \\r
+ p_msg, size, susp, status))\r
+#define T_Q_RECV(p_qcb, p_msg, q_size, a_size, susp, status) \\r
+ APPLY_MASK(NU_TRACE_QUEUE, QUEU_RECVE_EID, \\r
+ Log_pVpVU32U32U32I(QUEU_RECVE_EID, p_qcb, \\r
+ p_msg, q_size, a_size, susp, status))\r
+#define T_Q_DELETE(p_qcb, status) APPLY_MASK(NU_TRACE_QUEUE, QUEU_DELET_EID, \\r
+ Log_pVI(QUEU_DELET_EID, p_qcb, status))\r
+\r
+/*********/\r
+/* Pipes */\r
+/*********/\r
+#define T_PIPE_CREATE(p_pcb, p_start, p_name, pip_size, msg_size, msg_type, susp, status) \\r
+ APPLY_MASK(NU_TRACE_PIPE, PIPE_CREAT_EID, \\r
+ Log_pVpVpCU32U32U8U8I(PIPE_CREAT_EID, \\r
+ p_pcb, p_start, p_name, pip_size, msg_size, \\r
+ msg_type, susp, status))\r
+#define T_PIPE_RESET(p_pcb, status) APPLY_MASK(NU_TRACE_PIPE, PIPE_RESET_EID, \\r
+ Log_pVI(PIPE_RESET_EID, p_pcb, status))\r
+#define T_PIPE_BCAST(p_pcb, p_msg, size, suspend, status) \\r
+ APPLY_MASK(NU_TRACE_PIPE, PIPE_BRBND_EID, \\r
+ Log_pVpVU32U32I(PIPE_BRBND_EID, \\r
+ p_pcb, p_msg, size, suspend, status))\r
+#define T_PIPE_SEND(p_pcb, p_msg, size, suspend, status) \\r
+ APPLY_MASK(NU_TRACE_PIPE, PIPE_SEND_EID, \\r
+ Log_pVpVU32U32I(PIPE_SEND_EID, p_pcb, \\r
+ p_msg, size, suspend, status))\r
+#define T_PIPE_SEND2FRONT(p_pcb, p_msg, size, suspend, status) \\r
+ APPLY_MASK(NU_TRACE_PIPE, PIPE_SD2FT_EID, \\r
+ Log_pVpVU32U32I(PIPE_SD2FT_EID, p_pcb, \\r
+ p_msg, size, suspend, status))\r
+#define T_PIPE_RECV(p_pcb, p_msg, p_size, a_size, suspend, status) \\r
+ APPLY_MASK(NU_TRACE_PIPE, PIPE_RECVE_EID, \\r
+ Log_pVpVU32U32U32I(PIPE_RECVE_EID, p_pcb, \\r
+ p_msg, p_size, a_size, suspend, status))\r
+#define T_PIPE_DELETE(p_pcb, status) APPLY_MASK(NU_TRACE_PIPE, PIPE_DELET_EID, \\r
+ Log_pVI(PIPE_DELET_EID, p_pcb, status))\r
+\r
+/***********/\r
+/* Mailbox */\r
+/***********/\r
+#define T_MBOX_CREATE(p_mcb, p_name, susp_type, status) \\r
+ APPLY_MASK(NU_TRACE_MAILBOX, MBOX_CREAT_EID, \\r
+ Log_pVpCU8I(MBOX_CREAT_EID, \\r
+ p_mcb, p_name, susp_type, status))\r
+#define T_MBOX_RESET(p_mcb, status) APPLY_MASK(NU_TRACE_MAILBOX, MBOX_RESET_EID, \\r
+ Log_pVI(MBOX_RESET_EID, p_mcb, status))\r
+#define T_MBOX_BCAST(p_mcb, p_msg, susp_type, status) \\r
+ APPLY_MASK(NU_TRACE_MAILBOX, MBOX_BRBND_EID, \\r
+ Log_pVpVU32I(MBOX_BRBND_EID, p_mcb, \\r
+ p_msg, susp_type, status))\r
+#define T_MBOX_SEND(p_mcb, p_msg, susp_type, status) \\r
+ APPLY_MASK(NU_TRACE_MAILBOX, MBOX_SEND_EID, \\r
+ Log_pVpVU32I(MBOX_SEND_EID, p_mcb, \\r
+ p_msg, susp_type, status))\r
+#define T_MBOX_RECV(p_mcb, p_msg, susp_type, status) \\r
+ APPLY_MASK(NU_TRACE_MAILBOX, MBOX_RECVE_EID, \\r
+ Log_pVpVU32I(MBOX_RECVE_EID, p_mcb, \\r
+ p_msg, susp_type, status))\r
+#define T_MBOX_DELETE(p_mcb, status) APPLY_MASK(NU_TRACE_MAILBOX, MBOX_DELET_EID, \\r
+ Log_pVI(MBOX_DELET_EID, p_mcb, status))\r
+\r
+/***********/\r
+/* Signals */\r
+/***********/\r
+#define T_SIG_REG_HANDLER(p_tcb, p_sig_hdlr, status) \\r
+ APPLY_MASK(NU_TRACE_SIGNAL, SGNL_REGSR_EID, \\r
+ Log_pVpVI(SGNL_REGSR_EID, p_tcb, p_sig_hdlr, \\r
+ status))\r
+#define T_SIG_CONTROL(p_tcb, enbl_signal_mask, old_signal_mask) \\r
+ APPLY_MASK(NU_TRACE_SIGNAL, SGNL_CNTRL_EID, \\r
+ Log_pVU32U32(SGNL_CNTRL_EID, \\r
+ p_tcb, enbl_signal_mask, old_signal_mask))\r
+#define T_SIG_SEND(p_tcb, signals, status) APPLY_MASK(NU_TRACE_SIGNAL, SGNL_SEND_EID, \\r
+ Log_pVU32I(SGNL_SEND_EID, p_tcb, \\r
+ signals, status))\r
+#define T_SIG_RECV(p_tcb, signals) APPLY_MASK(NU_TRACE_SIGNAL, SGNL_RECVE_EID, \\r
+ Log_pVU32(SGNL_RECVE_EID, p_tcb, signals))\r
+#define T_SIG_HANDLER_RUNNING(p_tcb, p_sig_hdlr) APPLY_MASK(NU_TRACE_SIGNAL, SGNL_RUNIN_EID,\\r
+ Log_pVpV(SGNL_RUNIN_EID, p_tcb, p_sig_hdlr))\r
+#define T_SIG_HANDLER_STOPPED(p_tcb, p_sig_hdlr) APPLY_MASK(NU_TRACE_SIGNAL, SGNL_STOPD_EID,\\r
+ Log_pVpV(SGNL_STOPD_EID, p_tcb, p_sig_hdlr))\r
+\r
+\r
+/**********/\r
+/* Timers */\r
+/**********/\r
+#define T_TIMER_CREATE(p_tcb, p_exp_routine, p_name, id, init_time, \\r
+ resched_time, enable, status) \\r
+ APPLY_MASK(NU_TRACE_TIMER, TIME_CREAT_EID, \\r
+ Log_pVpVpCU32U32U32U8I(TIME_CREAT_EID, \\r
+ p_tcb, p_exp_routine, p_name, id, init_time, \\r
+ resched_time, enable, status))\r
+#define T_TIMER_DELETE(p_tcb, status) APPLY_MASK(NU_TRACE_TIMER, TIME_DELET_EID, \\r
+ Log_pVI(TIME_DELET_EID, p_tcb, status))\r
+#define T_TIMER_RESET(p_tcb, p_exp_routine, init_time, resched_time, enable, status) \\r
+ APPLY_MASK(NU_TRACE_TIMER, TIME_RESET_EID, \\r
+ Log_pVpVU32U32U8I(TIME_RESET_EID, \\r
+ p_tcb, p_exp_routine, init_time, \\r
+ resched_time, enable, status))\r
+#define T_TIMER_CONTROL(p_tcb, enable, status) \\r
+ APPLY_MASK(NU_TRACE_TIMER, TIME_CNTRL_EID, \\r
+ Log_pVU8I(TIME_CNTRL_EID, p_tcb, enable, status))\r
+#define T_TIMER_PAUSE(p_tcb, status) APPLY_MASK(NU_TRACE_TIMER, TIME_PAUSE_EID, \\r
+ Log_pVI(TIME_PAUSE_EID, p_tcb, status))\r
+#define T_TIMER_RESUME(p_tcb, status) APPLY_MASK(NU_TRACE_TIMER, TIME_RESUM_EID, \\r
+ Log_pVI(TIME_RESUM_EID, p_tcb, status))\r
+#define T_TIMER_EXP_ROUTIN_RUNNING(p_tcb, id) APPLY_MASK(NU_TRACE_TIMER, TIME_RUNIN_EID, \\r
+ Log_pVU32(TIME_RUNIN_EID, p_tcb, id))\r
+#define T_TIMER_EXP_ROUTIN_STOPPED(p_tcb, id) APPLY_MASK(NU_TRACE_TIMER, TIME_STOPD_EID, \\r
+ Log_pVU32(TIME_STOPD_EID, p_tcb, id))\r
+\r
+\r
+/********/\r
+/* Idle */\r
+/********/\r
+#define T_IDLE_ENTRY() idle_flag = 1; APPLY_MASK(NU_TRACE_CPU_STATE, IDLE_ENTRY_EID, Log_U32(IDLE_ENTRY_EID,0))\r
+#define T_IDLE_EXIT() if(idle_flag == 1) {idle_flag = 0; APPLY_MASK(NU_TRACE_CPU_STATE, IDLE_EXIT_EID, Log_U32(IDLE_EXIT_EID,0))}\r
+\r
+/******************/\r
+/* Power Services */\r
+/******************/\r
+#define T_OP_INFO(op_id, volt_id, volt_val, freq_id, freq_val) \\r
+ APPLY_MASK(NU_TRACE_PMS_INFO, PWR_OP_INFO_EID, \\r
+ Log_U8U8U16U8U32(PWR_OP_INFO_EID, op_id, \\r
+ volt_id, volt_val, freq_id, freq_val))\r
+#define T_OP_TRANS(op_id, status) APPLY_MASK(NU_TRACE_PMS_INFO, PWR_OP_TRANS_EID, \\r
+ Log_U8I(PWR_OP_TRANS_EID, op_id, status))\r
+#define T_HIB_ENTER(level, status) APPLY_MASK(NU_TRACE_PMS_INFO, PWR_HIB_ENTER_EID, \\r
+ Log_U8I(PWR_HIB_ENTER_EID, level, status))\r
+#define T_HIB_EXIT(boot_state, status) APPLY_MASK(NU_TRACE_PMS_INFO, PWR_HIB_EXIT_EID, \\r
+ Log_U32I(PWR_HIB_EXIT_EID, boot_state, status))\r
+#define T_HIB_EXIT_OP(op_id, status) APPLY_MASK(NU_TRACE_PMS_INFO, PWR_HIB_EXIT_OP_EID,\\r
+ Log_U8I(PWR_HIB_EXIT_OP_EID, op_id, status))\r
+#define T_SYS_COUNT(state_count, status) APPLY_MASK(NU_TRACE_PMS_INFO, PWR_SYS_CNT_EID, \\r
+ Log_U8I(PWR_SYS_CNT_EID, state_count, \\r
+ status))\r
+#define T_SYS_TRANS(state, status) APPLY_MASK(NU_TRACE_PMS_INFO, PWR_SYS_TRANS_EID, \\r
+ Log_U8I(PWR_SYS_TRANS_EID, state, status))\r
+#define T_SYS_MAP(dev_id, dev_state, sys_state, status) \\r
+ APPLY_MASK(NU_TRACE_PMS_INFO, PWR_SYS_MAP_EID, \\r
+ Log_I32U32U8I(PWR_SYS_MAP_EID, dev_id, \\r
+ dev_state, sys_state, status))\r
+#define T_SYS_UNMAP(dev_id, status) APPLY_MASK(NU_TRACE_PMS_INFO, PWR_SYS_UNMAP_EID, \\r
+ Log_I32I(PWR_SYS_UNMAP_EID, dev_id, status))\r
+#define T_DEV_TRANS(dev_id, state, status) APPLY_MASK(NU_TRACE_PMS_INFO, PWR_DEV_TRANS_EID, \\r
+ Log_I32U32I(PWR_DEV_TRANS_EID, dev_id, \\r
+ state, status))\r
+#define T_WD_CREATE(wd, status) APPLY_MASK(NU_TRACE_PMS_INFO, PWR_WD_CREATE_EID, \\r
+ Log_pVI(PWR_WD_CREATE_EID, wd, status))\r
+#define T_WD_ACTIVE(wd) APPLY_MASK(NU_TRACE_PMS_INFO, PWR_WD_ACTIVE_EID, \\r
+ Log_pV(PWR_WD_ACTIVE_EID, wd))\r
+#define T_WD_EXPIRE(wd) APPLY_MASK(NU_TRACE_PMS_INFO, PWR_WD_EXPIRE_EID, \\r
+ Log_pV(PWR_WD_EXPIRE_EID, wd))\r
+#define T_WD_DELETE(wd, status) APPLY_MASK(NU_TRACE_PMS_INFO, PWR_WD_DELETE_EID, \\r
+ Log_pVI(PWR_WD_DELETE_EID, wd, status))\r
+#define T_TICK_SUPPRESS(flag) APPLY_MASK(NU_TRACE_PMS_INFO, PWR_TICK_SUP_EID, \\r
+ Log_U8(PWR_TICK_SUP_EID, flag))\r
+#define T_DEV_NAME(key, state, state_count, dev_id) \\r
+ APPLY_MASK(NU_TRACE_PMS_INFO, PWR_DEV_NAME_EID, \\r
+ Log_pCU32U8I32(PWR_DEV_NAME_EID, key, state, \\r
+ state_count, dev_id))\r
+\r
+/* Power Services Transition Latency */\r
+#define T_DEV_TRANS_START(dev_id) APPLY_MASK(NU_TRACE_PMS_INFO, \\r
+ PWR_DEV_TL_START_EID, \\r
+ Log_I32(PWR_DEV_TL_START_EID, dev_id))\r
+#define T_DEV_TRANS_STOP(dev_id) APPLY_MASK(NU_TRACE_PMS_INFO, \\r
+ PWR_DEV_TL_STOP_EID, \\r
+ Log_I32(PWR_DEV_TL_STOP_EID, dev_id))\r
+#define T_OP_TL_START() APPLY_MASK(NU_TRACE_PMS_INFO, PWR_OP_TL_START_EID, \\r
+ Log_V(PWR_OP_TL_START_EID))\r
+#define T_OP_TL_STOP() APPLY_MASK(NU_TRACE_PMS_INFO, PWR_OP_TL_STOP_EID, \\r
+ Log_V(PWR_OP_TL_STOP_EID))\r
+#define T_HIB_TL_START() APPLY_MASK(NU_TRACE_PMS_INFO, PWR_HIB_TL_START_EID, \\r
+ Log_V(PWR_HIB_TL_START_EID))\r
+#define T_HIB_TL_STOP() APPLY_MASK(NU_TRACE_PMS_INFO, PWR_HIB_TL_STOP_EID, \\r
+ Log_V(PWR_HIB_TL_STOP_EID, dev_id))\r
+#define T_SYS_TL_START() APPLY_MASK(NU_TRACE_PMS_INFO, PWR_SYS_TL_START_EID, \\r
+ Log_V(PWR_SYS_TL_START_EID))\r
+#define T_SYS_TL_STOP() APPLY_MASK(NU_TRACE_PMS_INFO, PWR_SYS_TL_STOP_EID, \\r
+ Log_V(PWR_SYS_TL_STOP_EID))\r
+\r
+/*******************/\r
+/* Nucleus Storage */\r
+/*******************/\r
+#define T_PHY_DEV_LIST(dev_name) APPLY_MASK(NU_TRACE_STOR_INFO, STOR_PHY_DEV_LIST_EID, \\r
+ Log_pC(STOR_PHY_DEV_LIST_EID, dev_name))\r
+#define T_PHY_DEV_REMOVAL(dev_name, status) APPLY_MASK(NU_TRACE_STOR_INFO, STOR_PHY_DEV_REMOVAL_EID, \\r
+ Log_pCI(STOR_PHY_DEV_REMOVAL_EID, dev_name, status))\r
+#define T_LOG_DEV_REMOVAL(dev_name, status) APPLY_MASK(NU_TRACE_STOR_INFO, STOR_LOG_DEV_REMOVAL_EID, \\r
+ Log_pCI(STOR_LOG_DEV_REMOVAL_EID, dev_name, status))\r
+#define T_LOG_DEV_INFO(dev_name, fs, mp, auto_fmt, sect_start, sect_end, status) \\r
+ APPLY_MASK(NU_TRACE_STOR_INFO, STOR_LOG_DEV_INFO_EID, \\r
+ Log_pCpCpCU8U32U32I(STOR_LOG_DEV_INFO_EID, \\r
+ dev_name, fs, mp, auto_fmt, sect_start, sect_end, status))\r
+#define T_DIR_CREATE_INFO(mp, dev_name, dir_name) \\r
+ APPLY_MASK(NU_TRACE_STOR_INFO, STOR_DIR_CREATE_INFO_EID, \\r
+ Log_pCpCpC(STOR_DIR_CREATE_INFO_EID, mp, dev_name, \\r
+ dir_name))\r
+#define T_DIR_CREATE_STAT(dir_name, status) APPLY_MASK(NU_TRACE_STOR_INFO, STOR_DIR_CREATE_STAT_EID, \\r
+ Log_pCI(STOR_DIR_CREATE_STAT_EID, dir_name, status))\r
+#define T_DIR_DEL_STAT(dir_name, status) APPLY_MASK(NU_TRACE_STOR_INFO, STOR_DIR_DEL_STAT_EID, \\r
+ Log_pCI(STOR_DIR_DEL_STAT_EID, dir_name, status))\r
+#define T_FILE_OPEN_INFO(mp, dev_name, file_name, flag, mode, vfs_fd) \\r
+ APPLY_MASK(NU_TRACE_STOR_INFO, STOR_FILE_OPEN_INFO_EID, \\r
+ Log_pCpCpCU16U16I(STOR_FILE_OPEN_INFO_EID, mp, \\r
+ dev_name, file_name, flag, mode, vfs_fd))\r
+#define T_FILE_OPEN_STAT(file_name, flag, mode, vfs_fd) \\r
+ APPLY_MASK(NU_TRACE_STOR_INFO, STOR_FILE_OPEN_STAT_EID, \\r
+ Log_pCU16U16I(STOR_FILE_OPEN_STAT_EID, file_name, \\r
+ flag, mode, vfs_fd))\r
+#define T_FILE_CLOSE_STAT(vfs_fd, status) APPLY_MASK(NU_TRACE_STOR_INFO, STOR_FILE_CLOSE_STAT_EID, \\r
+ Log_II(STOR_FILE_CLOSE_STAT_EID, vfs_fd, status))\r
+#define T_FILE_READ_START(byte_count, vfs_fd) \\r
+ APPLY_MASK(NU_TRACE_STOR_INFO, STOR_FILE_READ_START_EID, \\r
+ Log_I32I(STOR_FILE_READ_START_EID, byte_count, vfs_fd))\r
+#define T_FILE_READ_STOP(byte_count, vfs_fd, ret_val) \\r
+ APPLY_MASK(NU_TRACE_STOR_INFO, STOR_FILE_READ_STOP_EID, \\r
+ Log_I32II32(STOR_FILE_READ_STOP_EID, byte_count, \\r
+ vfs_fd, ret_val))\r
+#define T_FILE_WRITE_START(byte_count, vfs_fd) \\r
+ APPLY_MASK(NU_TRACE_STOR_INFO, STOR_FILE_WRITE_START_EID, \\r
+ Log_I32I(STOR_FILE_WRITE_START_EID, byte_count, vfs_fd))\r
+#define T_FILE_WRITE_STOP(byte_count, vfs_fd, ret_val) \\r
+ APPLY_MASK(NU_TRACE_STOR_INFO, STOR_FILE_WRITE_STOP_EID, \\r
+ Log_I32II32(STOR_FILE_WRITE_STOP_EID, byte_count, \\r
+ vfs_fd, ret_val))\r
+#define T_FILE_SEEK_START(offset_bytes, origin, vfs_fd) \\r
+ APPLY_MASK(NU_TRACE_STOR_INFO, STOR_FILE_SEEK_START_EID, \\r
+ Log_I32I16I(STOR_FILE_SEEK_START_EID, \\r
+ offset_bytes, origin, vfs_fd))\r
+#define T_FILE_SEEK_STOP(offset_bytes, origin, vfs_fd, ret_val) \\r
+ APPLY_MASK(NU_TRACE_STOR_INFO, STOR_FILE_SEEK_STOP_EID, \\r
+ Log_I32I16II32(STOR_FILE_SEEK_STOP_EID, \\r
+ offset_bytes, origin, vfs_fd, ret_val))\r
+#define T_FILE_FLUSH_START(vfs_fd) APPLY_MASK(NU_TRACE_STOR_INFO, STOR_FILE_FLUSH_START_EID, \\r
+ Log_I(STOR_FILE_FLUSH_START_EID, vfs_fd))\r
+#define T_FILE_FLUSH_STOP(vfs_fd, status) APPLY_MASK(NU_TRACE_STOR_INFO, STOR_FILE_FLUSH_STOP_EID, \\r
+ Log_II(STOR_FILE_FLUSH_STOP_EID, vfs_fd, status))\r
+#define T_FILE_TRUNC_START(offset_bytes, vfs_fd) \\r
+ APPLY_MASK(NU_TRACE_STOR_INFO, STOR_FILE_TRUNC_START_EID, \\r
+ Log_I32I(STOR_FILE_TRUNC_START_EID, offset_bytes, vfs_fd))\r
+#define T_FILE_TRUNC_STOP(offset_bytes, vfs_fd, status) \\r
+ APPLY_MASK(NU_TRACE_STOR_INFO, STOR_FILE_TRUNC_STOP_EID, \\r
+ Log_I32II(STOR_FILE_TRUNC_STOP_EID, offset_bytes, vfs_fd, \\r
+ status))\r
+#define T_FILE_RENAME_STAT(file_name, newname, status) \\r
+ APPLY_MASK(NU_TRACE_STOR_INFO, STOR_FILE_RENAME_STAT_EID, \\r
+ Log_pCpCI(STOR_FILE_RENAME_STAT_EID, file_name, \\r
+ newname, status))\r
+#define T_FILE_DEL_STAT(file_name, status) \\r
+ APPLY_MASK(NU_TRACE_STOR_INFO, STOR_FILE_DEL_STAT_EID, \\r
+ Log_pCI(STOR_FILE_DEL_STAT_EID, file_name, status))\r
+\r
+/**********************/\r
+/* Nucleus Networking */\r
+/**********************/\r
+#define T_NET_INIT_STAT(status) APPLY_MASK(NU_TRACE_NET_INFO, NET_STACK_INIT_STATUS_EID, \\r
+ Log_I(NET_STACK_INIT_STATUS_EID, status))\r
+#define T_DEV_LIST(dev_name, macaddr, type, flags, status, size) \\r
+ APPLY_MASK(NU_TRACE_NET_INFO, NET_DEV_LIST_EID, \\r
+ Log_pCpU8U8U32I_pU8ArraySize(NET_DEV_LIST_EID, dev_name, \\r
+ macaddr, type, flags, status, size))\r
+#define T_DEV_REMOVAL(dev_name, status) APPLY_MASK(NU_TRACE_NET_INFO, NET_DEV_REMOVAL_EID, \\r
+ Log_pCI(NET_DEV_REMOVAL_EID, dev_name, status))\r
+#define T_DEV_IPv4_IP(dev_name, ip, subnet, status, size) \\r
+ APPLY_MASK(NU_TRACE_NET_INFO, NET_DEV_IPv4_IP_EID, \\r
+ Log_pCpU8pU8I_pU8ArraySize(NET_DEV_IPv4_IP_EID, dev_name, \\r
+ ip, subnet, status, size))\r
+#define T_DEV_IPv4_DHCP_IP(dev_name, ip, status, size) \\r
+ APPLY_MASK(NU_TRACE_NET_INFO, NET_DEV_IPv4_DHCP_IP_EID, \\r
+ Log_pCpU8I_pU8ArraySize(NET_DEV_IPv4_DHCP_IP_EID, dev_name,\\r
+ ip, status, size))\r
+#define T_DEV_IPv6_IP(dev_name, ip, prefix_len, status, size) \\r
+ APPLY_MASK(NU_TRACE_NET_INFO, NET_DEV_IPv6_IP_EID, \\r
+ Log_pCpU8U8I_pU8ArraySize(NET_DEV_IPv6_IP_EID, dev_name, \\r
+ ip, prefix_len, status, size))\r
+#define T_REMOVE_IP(dev_name, ip, family, status, size) \\r
+{ \\r
+ if (family == NU_FAMILY_IP6) \\r
+ { \\r
+ APPLY_MASK(NU_TRACE_NET_INFO, NET_DEV_REMOVE_IP6_EID, \\r
+ Log_pCpU8I16I_pU8ArraySize(NET_DEV_REMOVE_IP6_EID, dev_name, \\r
+ ip, family, status, size)); \\r
+ } \\r
+ else \\r
+ { \\r
+ APPLY_MASK(NU_TRACE_NET_INFO, NET_DEV_REMOVE_IP_EID, \\r
+ Log_pCpU8I16I_pU8ArraySize(NET_DEV_REMOVE_IP_EID, dev_name, \\r
+ ip, family, status, size)); \\r
+ } \\r
+}\r
+#define T_DETACH_IP(dev_name, status) APPLY_MASK(NU_TRACE_NET_INFO, NET_DEV_DETACH_IP_EID, \\r
+ Log_pCI(NET_DEV_DETACH_IP_EID, dev_name, status))\r
+#define T_DEV_LINK_UP(dev_name, status) APPLY_MASK(NU_TRACE_NET_INFO, NET_DEV_LINK_UP_EID, \\r
+ Log_pCI(NET_DEV_LINK_UP_EID, dev_name, status))\r
+#define T_DEV_LINK_DOWN(dev_name, status) APPLY_MASK(NU_TRACE_NET_INFO, NET_DEV_LINK_DOWN_EID, \\r
+ Log_pCI(NET_DEV_LINK_DOWN_EID, dev_name, status))\r
+#define T_DEV_UP_STATUS(dev_name, status) APPLY_MASK(NU_TRACE_NET_INFO, NET_DEV_UP_STATUS_EID, \\r
+ Log_pCI(NET_DEV_UP_STATUS_EID, dev_name, status))\r
+#define T_SOCK_LIST(family, type, protocol, sd) \\r
+ APPLY_MASK(NU_TRACE_NET_INFO, NET_SOCK_LIST_EID, \\r
+ Log_I16I16I16I(NET_SOCK_LIST_EID, family, type, protocol, sd))\r
+#define T_SOCK_STATUS(state, sd, status) APPLY_MASK(NU_TRACE_NET_INFO, NET_SOCK_STATUS_EID, \\r
+ Log_U16II(NET_SOCK_STATUS_EID, state, sd, status))\r
+#define T_SOCK_ENQ(packets, total_bytes, sd) APPLY_MASK(NU_TRACE_NET_INFO, NET_SOCK_ENQ_EID, \\r
+ Log_U32U32I(NET_SOCK_ENQ_EID, packets, total_bytes, sd))\r
+#define T_SOCK_TX_LAT_START(sd) APPLY_MASK(NU_TRACE_NET_INFO, NET_SOCK_TX_START_EID, \\r
+ Log_I(NET_SOCK_TX_START_EID, sd)) \r
+#define T_SOCK_TX_LAT_STOP(bytes, sd, status) APPLY_MASK(NU_TRACE_NET_INFO, NET_SOCK_TX_STOP_EID, \\r
+ Log_U16II32(NET_SOCK_TX_STOP_EID, bytes, sd, status))\r
+#define T_SOCK_RX(bytes, sd, status) APPLY_MASK(NU_TRACE_NET_INFO, NET_SOCK_RX_EID, \\r
+ Log_U16II32(NET_SOCK_RX_EID, bytes, sd, status))\r
+#define T_ADD_ROUTE(dev_name, dest, subnet, gateway, status, size) \\r
+{ \\r
+ UINT8 t_gateway[IP_ADDR_LEN]; \\r
+ PUT32(t_gateway, 0, gateway); \\r
+ APPLY_MASK(NU_TRACE_NET_INFO, NET_ADD_ROUTE_EID, \\r
+ Log_pCpU8pU8pU8I_pU8ArraySize(NET_ADD_ROUTE_EID, dev_name, \\r
+ dest, subnet, t_gateway, status, size)); \\r
+ \\r
+}\r
+#define T_ADD_ROUTE6(dev_name, dest, next_hop, prefix_len, status, size) \\r
+ APPLY_MASK(NU_TRACE_NET_INFO, NET_ADD_ROUTE6_EID, \\r
+ Log_pCpU8pU8U8I_pU8ArraySize(NET_ADD_ROUTE6_EID, dev_name, \\r
+ dest, next_hop, prefix_len, status, size))\r
+#define T_DEL_ROUTE(dest, next_hop, status, size) \\r
+ APPLY_MASK(NU_TRACE_NET_INFO, NET_DEL_ROUTE_EID, \\r
+ Log_pU8pU8I_pU8ArraySize(NET_DEL_ROUTE_EID, dest, next_hop, status, size))\r
+#define T_DEL_ROUTE6(dest, next_hop, status, size) \\r
+ APPLY_MASK(NU_TRACE_NET_INFO, NET_DEL_ROUTE6_EID, \\r
+ Log_pU8pU8I_pU8ArraySize(NET_DEL_ROUTE6_EID, dest, next_hop, status, size))\r
+#define T_BUFF_USAGE(buff_count) APPLY_MASK(NU_TRACE_NET_INFO, NET_BUFF_USAGE_EID, \\r
+ Log_U16(NET_BUFF_USAGE_EID, buff_count))\r
+#define T_DEV_TX_LAT_START(dev_name) APPLY_MASK(NU_TRACE_NET_INFO, NET_DEV_TX_LAT_START_EID, \\r
+ Log_pC(NET_DEV_TX_LAT_START_EID, dev_name))\r
+#define T_DEV_TX_LAT_STOP(dev_name, data_len, bytes_written, status) \\r
+ APPLY_MASK(NU_TRACE_NET_INFO, NET_DEV_TX_LAT_STOP_EID, \\r
+ Log_pCU32U32I(NET_DEV_TX_LAT_STOP_EID, dev_name, data_len, \\r
+ bytes_written, status))\r
+#define T_DEV_RX_ACT(dev_name, data_len, status) \\r
+ APPLY_MASK(NU_TRACE_NET_INFO, NET_DEV_RX_ACT_EID, \\r
+ Log_pCU32I(NET_DEV_RX_ACT_EID, dev_name, data_len, status))\r
+#define T_DEV_TRANSQ_LEN(dev_name, q_len) APPLY_MASK(NU_TRACE_NET_INFO, NET_DEV_TRANSQ_LEN_EID, \\r
+ Log_pCU32(NET_DEV_TRANSQ_LEN_EID, dev_name, q_len))\r
+\r
+#else\r
+\r
+/********************************/\r
+/* Nucleus PC Hot Spot Analysis */\r
+/********************************/\r
+#define T_PC_SAMPLE()\r
+\r
+/*********/\r
+/* LISRs */\r
+/*********/\r
+#define T_IRQ_ENABLED(irq_num, status)\r
+#define T_IRQ_DISABLED(irq_num, status)\r
+#define T_LISR_REGISTERED(irq_num, status)\r
+#define T_LISR_ENTRY(irq_num)\r
+#define T_LISR_EXIT(irq_num)\r
+\r
+/*********/\r
+/* HISRs */\r
+/*********/\r
+#define T_HISR_CREATED(p_hcb, p_hisr_entry, p_stack, p_hisr_name, p_size, priority, status)\r
+#define T_HISR_DELETED(p_hcb, status)\r
+#define T_HISR_ACTIVATED(p_hcb, status)\r
+#define T_HISR_RUNNING(p_hcb)\r
+#define T_HISR_STOPPED(p_hcb)\r
+\r
+/*********/\r
+/* Tasks */\r
+/*********/\r
+#define T_TASK_CREATED(p_tcb, p_task, p_stk, p_name, stk_size, time_slice, priority, \\r
+ preempt_opt, strt_opt, status)\r
+#define T_TASK_RESET(p_tcb, status)\r
+#define T_TASK_READY(p_tcb)\r
+#define T_TASK_RUNNING(p_tcb)\r
+#define T_TASK_SUSPEND(p_tcb, sus_type)\r
+#define T_TASK_TERMINATED(p_tcb, status)\r
+#define T_TASK_DELETED(p_tcb, status)\r
+#define T_TASK_CHG_PREMPTION(p_tcb, new_prempt_state, old_prempt_state)\r
+#define T_TASK_CHG_PRIORITY(p_tcb, new_priority, old_priority)\r
+#define T_TASK_CHG_TIMESLICE(p_tcb, new_timeslice, old_timeslice)\r
+\r
+/****************/\r
+/* Memory pools */\r
+/****************/\r
+#define T_MEM_POOL_CREATE(p_mpcb, p_start_add, p_name, size, available_size, min_size, sus_typ, status)\r
+#define T_MEM_POOL_DELETE(p_mpcb, status)\r
+#define T_MEM_ADD(p_mpcb, p_start_add, p_caller, total_size, available_size, added_size, status)\r
+\r
+/******************/\r
+/* Dynamic memory */\r
+/******************/\r
+#define T_DMEM_ALLOCATE(p_mpcb, p_start, p_caller, toatl_size, available_size, size, sus_type, status)\r
+#define T_DMEM_DEALLOCATE(p_mpcb, p_start, p_caller, total_size, available_size, status)\r
+#define T_DMEM_REALLOCATE(p_mpcb, p_orig_mem, p_caller, total_size, available_size, new_size, susp_type, status)\r
+\r
+/********************/\r
+/* Partition memory */\r
+/********************/\r
+#define T_PMEM_CREATE(p_pmpcb, p_start_add, p_name, p_avail, p_size, sus_type, status)\r
+#define T_PMEM_ALLOCATE(p_pmpcb, p_partition, p_caller, p_poolsize, partition_size, available_size,\\r
+ allocated_size, susp_type, status)\r
+#define T_PMEM_DEALLOCATE(p_pmpcb, p_partition, p_caller, p_poolsize, partition_size, available_size, \\r
+ allocated_size, status)\r
+#define T_PMEM_DELETE(p_pmpcb, status)\r
+\r
+/**************/\r
+/* Semaphores */\r
+/**************/\r
+#define T_SEM_CREATE(p_scb, p_name, ini_count, susp_type, status)\r
+#define T_SEM_DELETE(p_pcb, p_tcb, status)\r
+#define T_SEM_RESET(p_pcb, p_tcb, init_count, status)\r
+#define T_SEM_OBTAIN(p_pcb, p_tcb, suspend, status)\r
+#define T_SEM_RELEASE(p_pcb, p_tcb, status)\r
+\r
+/***********/\r
+/* Mailbox */\r
+/***********/\r
+#define T_MBOX_CREATE(p_mcb, p_name, susp_type, status)\r
+#define T_MBOX_RESET(p_mcb, status)\r
+#define T_MBOX_BCAST(p_mcb, p_msg, susp_type, status)\r
+#define T_MBOX_SEND(p_mcb, p_msg, susp_type, status)\r
+#define T_MBOX_RECV(p_mcb, p_msg, susp_type, status)\r
+#define T_MBOX_DELETE(p_mcb, status)\r
+\r
+/**********/\r
+/* Queues */\r
+/**********/\r
+#define T_Q_CREATE(p_qcb, p_start, p_name, q_size, msg_size, msg_type, susp_type, status)\r
+#define T_Q_RESET(p_qcb, status)\r
+#define T_Q_BCAST(p_qcb, p_msg, size, susp, status)\r
+#define T_Q_SEND(p_qcb, p_msg, size, susp, status)\r
+#define T_Q_SEND2FRONT(p_qcb, p_msg, size, susp, status)\r
+#define T_Q_RECV(p_qcb, p_msg, q_size, a_size, susp, status)\r
+#define T_Q_DELETE(p_qcb, status)\r
+\r
+/*********/\r
+/* Pipes */\r
+/*********/\r
+#define T_PIPE_CREATE(p_pcb, p_start, p_name, pip_size, msg_size, msg_type, susp, status)\r
+#define T_PIPE_RESET(p_pcb, status)\r
+#define T_PIPE_BCAST(p_pcb, p_msg, size, suspend, status)\r
+#define T_PIPE_SEND(p_pcb, p_msg, size, suspend, status)\r
+#define T_PIPE_SEND2FRONT(p_pcb, p_msg, size, suspend, status)\r
+#define T_PIPE_RECV(p_pcb, p_msg, p_size, a_size, suspend, status)\r
+#define T_PIPE_DELETE(p_pcb, status)\r
+\r
+/****************/\r
+/* Event groups */\r
+/****************/\r
+#define T_EVT_GRP_CREATE(p_evt_grp, p_name, status)\r
+#define T_EVT_SET(p_evt_grp, evt_flags, operation, status)\r
+#define T_EVT_RETRIEVE(p_evt_grp, req_evt, ret_events, suspend, operation, status)\r
+#define T_EVT_GRP_DELETE(p_evt_grp, status)\r
+\r
+/***********/\r
+/* Signals */\r
+/***********/\r
+#define T_SIG_REG_HANDLER(p_tcb, p_sig_hdlr, status)\r
+#define T_SIG_CONTROL(p_tcb, enbl_signal_mask, old_signal_mask)\r
+#define T_SIG_SEND(p_tcb, signals, status)\r
+#define T_SIG_RECV(p_tcb, signals)\r
+#define T_SIG_HANDLER_RUNNING(p_tcb, p_sig_hdlr)\r
+#define T_SIG_HANDLER_STOPPED(p_tcb, p_sig_hdlr)\r
+\r
+/**********/\r
+/* Timers */\r
+/**********/\r
+#define T_TIMER_CREATE(p_tcb, p_exp_routine, p_name, id, init_time, \\r
+ resched_time, enable, status)\r
+#define T_TIMER_DELETE(p_tcb, status)\r
+#define T_TIMER_RESET(p_tcb, p_exp_routine, init_time, resched_time, enable, status)\r
+#define T_TIMER_CONTROL(p_tcb, enable, status)\r
+#define T_TIMER_PAUSE(p_tcb, status)\r
+#define T_TIMER_RESUME(p_tcb, status)\r
+#define T_TIMER_EXP_ROUTIN_RUNNING(p_tcb, id)\r
+#define T_TIMER_EXP_ROUTIN_STOPPED(p_tcb, id)\r
+\r
+/********/\r
+/* Idle */\r
+/********/\r
+#define T_IDLE_ENTRY()\r
+#define T_IDLE_EXIT()\r
+\r
+/******************/\r
+/* Power Services */\r
+/******************/\r
+#define T_OP_INFO(op_id, volt_id, volt_val, freq_id, freq_val)\r
+#define T_OP_TRANS(op_id, status)\r
+#define T_HIB_ENTER(level, status)\r
+#define T_HIB_EXIT(state, status)\r
+#define T_HIB_EXIT_OP(op_id, status)\r
+#define T_HIB_BOOT(boot_state)\r
+#define T_SYS_COUNT(state_count, status)\r
+#define T_SYS_TRANS(state, status)\r
+#define T_SYS_MAP(dev_id, dev_state, sys_state, status)\r
+#define T_SYS_UNMAP(dev_id, status)\r
+#define T_DEV_TRANS(dev_id, state, status)\r
+#define T_WD_CREATE(wd, status)\r
+#define T_WD_ACTIVE(wd)\r
+#define T_WD_EXPIRE(wd)\r
+#define T_WD_DELETE(wd, status)\r
+#define T_TICK_SUPPRESS(flag)\r
+#define T_DEV_NAME(key, state, state_count, dev_id)\r
+/* Power Services Transition Latency */\r
+#define T_DEV_TRANS_START(dev_id)\r
+#define T_DEV_TRANS_STOP(dev_id)\r
+#define T_OP_TL_START()\r
+#define T_OP_TL_STOP()\r
+#define T_HIB_TL_START()\r
+#define T_HIB_TL_STOP()\r
+#define T_SYS_TL_START()\r
+#define T_SYS_TL_STOP()\r
+\r
+/*******************/\r
+/* Nucleus Storage */\r
+/*******************/\r
+#define T_PHY_DEV_LIST(dev_name)\r
+#define T_PHY_DEV_REMOVAL(dev_name, status)\r
+#define T_LOG_DEV_REMOVAL(dev_name, status)\r
+#define T_LOG_DEV_INFO(dev_name, fs, mp, auto_fmt, sect_start, sect_end, status)\r
+#define T_DIR_CREATE_INFO(mp, dev_name, dir_name)\r
+#define T_DIR_CREATE_STAT(dir_name, status)\r
+#define T_DIR_DEL_STAT(dir_name, status)\r
+#define T_FILE_OPEN_INFO(mp, dev_name, file_name, flag, mode, vfs_fd)\r
+#define T_FILE_OPEN_STAT(file_name, flag, mode, vfs_fd)\r
+#define T_FILE_CLOSE_STAT(vfs_fd, status)\r
+#define T_FILE_READ_START(byte_count, vfs_fd)\r
+#define T_FILE_READ_STOP(byte_count, vfs_fd, ret_val)\r
+#define T_FILE_WRITE_START(byte_count, vfs_fd)\r
+#define T_FILE_WRITE_STOP(byte_count, vfs_fd, ret_val)\r
+#define T_FILE_SEEK_START(offset_bytes, origin, vfs_fd)\r
+#define T_FILE_SEEK_STOP(offset_bytes, origin, vfs_fd, ret_val)\r
+#define T_FILE_FLUSH_START(vfs_fd)\r
+#define T_FILE_FLUSH_STOP(vfs_fd, status)\r
+#define T_FILE_TRUNC_START(offset_bytes, vfs_fd)\r
+#define T_FILE_TRUNC_STOP(offset_bytes, vfs_fd, status)\r
+#define T_FILE_RENAME_STAT(file_name, newname, status)\r
+#define T_FILE_DEL_STAT(file_name, status)\r
+\r
+/**********************/\r
+/* Nucleus Networking */\r
+/**********************/\r
+#define T_NET_INIT_STAT(status)\r
+#define T_DEV_LIST(dev_name, macaddr, type, flags, status, size)\r
+#define T_DEV_REMOVAL(dev_name, status)\r
+#define T_DEV_IPv4_IP(dev_name, ip, subnet, status, size)\r
+#define T_DEV_IPv4_DHCP_IP(dev_name, ip, status, size)\r
+#define T_DEV_IPv6_IP(dev_name, ip, prefix_len, status, size)\r
+#define T_REMOVE_IP(dev_name, ip, family, status, size)\r
+#define T_DETACH_IP(dev_name, status)\r
+#define T_DEV_LINK_UP(dev_name, status)\r
+#define T_DEV_LINK_DOWN(dev_name, status)\r
+#define T_DEV_UP_STATUS(dev_name, status)\r
+#define T_SOCK_LIST(family, type, protocol, sd)\r
+#define T_SOCK_STATUS(state, sd, status)\r
+#define T_SOCK_ENQ(packets, total_bytes, sd)\r
+#define T_SOCK_TX_LAT_START(sd)\r
+#define T_SOCK_TX_LAT_STOP(bytes, sd, status)\r
+#define T_SOCK_RX(bytes, sd, status)\r
+#define T_ADD_ROUTE(dev_name, dest, subnet, gateway, status, size)\r
+#define T_ADD_ROUTE6(dev_name, dest, next_hop, prefix_len, status, size)\r
+#define T_DEL_ROUTE(dest, next_hop, status, size)\r
+#define T_DEL_ROUTE6(dest, next_hop, status, size)\r
+#define T_BUFF_USAGE(buff_count)\r
+#define T_DEV_TX_LAT_START(dev_name)\r
+#define T_DEV_TX_LAT_STOP(dev_name, data_len, bytes_written, status)\r
+#define T_DEV_RX_ACT(dev_name, data_len, status)\r
+#define T_DEV_TRANSQ_LEN(dev_name, q_len)\r
+\r
+#endif /* (CFG_NU_OS_SVCS_TRACE_CORE_TRACE_SUPPORT == NU_TRUE) */\r
+\r
+#ifdef __cplusplus\r
+} /* End of C declarations */\r
+#endif /* __cplusplus */\r
+\r
+#endif /* _OS_MARK_H_ */\r
diff --git a/libs/system/zc702evk/nucleus/services/reg_api.h b/libs/system/zc702evk/nucleus/services/reg_api.h
--- /dev/null
@@ -0,0 +1,100 @@
+/*************************************************************************
+*
+* Copyright 2010 Mentor Graphics Corporation
+* All Rights Reserved.
+*
+* THIS WORK CONTAINS TRADE SECRET AND PROPRIETARY INFORMATION WHICH IS
+* THE PROPERTY OF MENTOR GRAPHICS CORPORATION OR ITS LICENSORS AND IS
+* SUBJECT TO LICENSE TERMS.
+*
+*************************************************************************/
+
+/*************************************************************************
+*
+* FILE NAME
+*
+* reg_api.h
+*
+* COMPONENT
+*
+* Registry
+*
+* DESCRIPTION
+*
+* This file contains the external interface for interacting with
+* the registry.
+*
+* DATA STRUCTURES
+*
+* None.
+*
+* DEPENDENCIES
+*
+* nucleus.h
+* reg_status.h
+*
+*************************************************************************/
+
+#ifndef REG_API_H
+#define REG_API_H
+
+#include "nucleus.h"
+#include "services/reg_status.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* Definitions */
+
+/* Maximum length of a key in the registry. This value is automatically determined by FUSE for
+ the given build configuration. This is an implicitly defined configuration setting (ie there is
+ no metadata configuration option associated with this macro - FUSE just defines this macro in the
+ generated header file based on the longest key length in the configuration) */
+#define REG_MAX_KEY_LENGTH CFG_NU_OS_SVCS_REGISTRY_MAX_KEY_LEN
+
+/* Queries */
+BOOLEAN REG_Has_Key(const CHAR *key);
+BOOLEAN REG_Key_Is_Writable(const CHAR *key);
+STATUS REG_Num_Child_Keys_Value(const CHAR *key, const CHAR *sub_key, UINT *num);
+#define REG_Num_Child_Keys(key, num) REG_Num_Child_Keys_Value(key, NU_NULL, num)
+
+/* Reads and Writes */
+STATUS REG_Set_Boolean_Value(const CHAR *key, const CHAR *sub_key, BOOLEAN value);
+STATUS REG_Get_Boolean_Value(const CHAR *key, const CHAR *sub_key, BOOLEAN *value);
+#define REG_Set_Boolean(key, value) REG_Set_Boolean_Value(key, NU_NULL, value)
+#define REG_Get_Boolean(key, value) REG_Get_Boolean_Value(key, NU_NULL, value)
+
+STATUS REG_Set_UINT8_Value(const CHAR *key, const CHAR *sub_key, UINT8 value);
+STATUS REG_Get_UINT8_Value(const CHAR *key, const CHAR *sub_key, UINT8 *value);
+#define REG_Set_UINT8(key, value) REG_Set_UINT8_Value(key, NU_NULL, value)
+#define REG_Get_UINT8(key, value) REG_Get_UINT8_Value(key, NU_NULL, value)
+
+STATUS REG_Set_UINT16_Value(const CHAR *key, const CHAR *sub_key, UINT16 value);
+STATUS REG_Get_UINT16_Value(const CHAR *key, const CHAR *sub_key, UINT16 *value);
+#define REG_Set_UINT16(key, value) REG_Set_UINT16_Value(key, NU_NULL, value)
+#define REG_Get_UINT16(key, value) REG_Get_UINT16_Value(key, NU_NULL, value)
+
+STATUS REG_Set_UINT32_Value(const CHAR *key, const CHAR *sub_key, UINT32 value);
+STATUS REG_Get_UINT32_Value(const CHAR *key, const CHAR *sub_key, UINT32 *value);
+#define REG_Set_UINT32(key, value) REG_Set_UINT32_Value(key, NU_NULL, value)
+#define REG_Get_UINT32(key, value) REG_Get_UINT32_Value(key, NU_NULL, value)
+
+STATUS REG_Set_String_Value(const CHAR *key, const CHAR *sub_key, const CHAR *value, UINT length);
+STATUS REG_Get_String_Value(const CHAR *key, const CHAR *sub_key, CHAR *value, UINT length);
+#define REG_Set_String(key, value, length) REG_Set_String_Value(key, NU_NULL, value, length)
+#define REG_Get_String(key, value, length) REG_Get_String_Value(key, NU_NULL, value, length)
+
+STATUS REG_Set_Bytes_Value(const CHAR *key, const CHAR *sub_key, const UNSIGNED_CHAR *value, UINT length);
+STATUS REG_Get_Bytes_Value(const CHAR *key, const CHAR *sub_key, UNSIGNED_CHAR *value, UINT length);
+#define REG_Set_Bytes(key, value, length) REG_Set_Bytes_Value(key, NU_NULL, value, length)
+#define REG_Get_Bytes(key, value, length) REG_Get_Bytes_Value(key, NU_NULL, value, length)
+
+STATUS REG_Set_Writable_Value(const CHAR *key, const CHAR *sub_key, BOOLEAN is_writable);
+#define REG_Set_Writable(key, is_writable) REG_Set_Writable_Value(key, NU_NULL, is_writable)
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/libs/system/zc702evk/nucleus/services/reg_impl.h b/libs/system/zc702evk/nucleus/services/reg_impl.h
--- /dev/null
@@ -0,0 +1,113 @@
+/*************************************************************************
+*
+* Copyright 2010 Mentor Graphics Corporation
+* All Rights Reserved.
+*
+* THIS WORK CONTAINS TRADE SECRET AND PROPRIETARY INFORMATION WHICH IS
+* THE PROPERTY OF MENTOR GRAPHICS CORPORATION OR ITS LICENSORS AND IS
+* SUBJECT TO LICENSE TERMS.
+*
+*************************************************************************/
+
+/*************************************************************************
+*
+* FILE NAME
+*
+* reg_impl.h
+*
+* COMPONENT
+*
+* Registry
+*
+* DESCRIPTION
+*
+* This file defines a collection of types used to define a new
+* registry implementation.
+*
+* DATA STRUCTURES
+*
+* REG_Has_Key_Func
+* REG_Key_Is_Writable_Func
+* REG_Num_Child_Keys_Func
+* REG_Set_Boolean_Func
+* REG_Get_Boolean_Func
+* REG_Set_UINT8_Func
+* REG_Get_UINT8_Func
+* REG_Set_UINT16_Func
+* REG_Get_UINT16_Func
+* REG_Set_UINT32_Func
+* REG_Get_UINT32_Func
+* REG_Set_String_Func
+* REG_Get_String_Func
+* REG_Set_Bytes_Func
+* REG_Get_Bytes_Func
+* REG_Set_Writable_Func
+* REG_IMPL
+*
+* DEPENDENCIES
+*
+* nucleus.h
+* reg_status.h
+*
+*************************************************************************/
+
+#ifndef REG_IMPL_H
+#define REG_IMPL_H
+
+#include "nucleus.h"
+#include "services/reg_status.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef BOOLEAN (*REG_Has_Key_Func)(const CHAR *key);
+typedef BOOLEAN (*REG_Key_Is_Writable_Func)(const CHAR *key);
+typedef STATUS (*REG_Num_Child_Keys_Func)(const CHAR *key, UINT *num);
+typedef STATUS (*REG_Set_Boolean_Func)(const CHAR *key, BOOLEAN value);
+typedef STATUS (*REG_Get_Boolean_Func)(const CHAR *key, BOOLEAN *value);
+typedef STATUS (*REG_Set_UINT8_Func)(const CHAR *key, UINT8 value);
+typedef STATUS (*REG_Get_UINT8_Func)(const CHAR *key, UINT8 *value);
+typedef STATUS (*REG_Set_UINT16_Func)(const CHAR *key, UINT16 value);
+typedef STATUS (*REG_Get_UINT16_Func)(const CHAR *key, UINT16 *value);
+typedef STATUS (*REG_Set_UINT32_Func)(const CHAR *key, UINT32 value);
+typedef STATUS (*REG_Get_UINT32_Func)(const CHAR *key, UINT32 *value);
+typedef STATUS (*REG_Set_String_Func)(const CHAR *key, const CHAR *value,
+ UINT length);
+typedef STATUS (*REG_Get_String_Func)(const CHAR *key, CHAR *value,
+ UINT length);
+typedef STATUS (*REG_Set_Bytes_Func)(const CHAR *key,
+ const UNSIGNED_CHAR *value,
+ UINT length);
+typedef STATUS (*REG_Get_Bytes_Func)(const CHAR *key, UNSIGNED_CHAR *value,
+ UINT length);
+typedef STATUS (*REG_Set_Writable_Func)(const CHAR *key,
+ BOOLEAN is_writable);
+
+typedef struct
+{
+ REG_Has_Key_Func REG_Has_Key;
+ REG_Key_Is_Writable_Func REG_Key_Is_Writable;
+ REG_Num_Child_Keys_Func REG_Num_Child_Keys_Value;
+ REG_Set_Boolean_Func REG_Set_Boolean_Value;
+ REG_Get_Boolean_Func REG_Get_Boolean_Value;
+ REG_Set_UINT8_Func REG_Set_UINT8_Value;
+ REG_Get_UINT8_Func REG_Get_UINT8_Value;
+ REG_Set_UINT16_Func REG_Set_UINT16_Value;
+ REG_Get_UINT16_Func REG_Get_UINT16_Value;
+ REG_Set_UINT32_Func REG_Set_UINT32_Value;
+ REG_Get_UINT32_Func REG_Get_UINT32_Value;
+ REG_Set_String_Func REG_Set_String_Value;
+ REG_Get_String_Func REG_Get_String_Value;
+ REG_Set_Bytes_Func REG_Set_Bytes_Value;
+ REG_Get_Bytes_Func REG_Get_Bytes_Value;
+ REG_Set_Writable_Func REG_Set_Writable_Value;
+} REG_IMPL;
+
+extern REG_IMPL *impl;
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/libs/system/zc702evk/nucleus/services/reg_impl_mem_node.h b/libs/system/zc702evk/nucleus/services/reg_impl_mem_node.h
--- /dev/null
@@ -0,0 +1,67 @@
+/*************************************************************************
+*
+* Copyright 2010 Mentor Graphics Corporation
+* All Rights Reserved.
+*
+* THIS WORK CONTAINS TRADE SECRET AND PROPRIETARY INFORMATION WHICH IS
+* THE PROPERTY OF MENTOR GRAPHICS CORPORATION OR ITS LICENSORS AND IS
+* SUBJECT TO LICENSE TERMS.
+*
+*************************************************************************/
+
+/*************************************************************************
+*
+* FILE NAME
+*
+* reg_impl_mem_node.h
+*
+* COMPONENT
+*
+* Registry
+*
+* DESCRIPTION
+*
+* This file defines the data structure used to build an in-memory
+* registry.
+*
+* DATA STRUCTURES
+*
+* REG_Memory_Node
+*
+* DEPENDENCIES
+*
+* nucleus.h
+*
+*************************************************************************/
+
+#ifndef REG_IMPL_MEM_NODE_H
+#define REG_IMPL_MEM_NODE_H
+
+#include "nucleus.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef const struct REG_Memory_Node_Struct
+{
+ const CHAR *key;
+ union
+ {
+ UNSIGNED_CHAR *bytes;
+ CHAR *str;
+ UINT32 u32;
+ UINT16 u16;
+ UINT8 u8;
+ BOOLEAN b;
+ } value;
+ const struct REG_Memory_Node_Struct *children;
+} REG_Memory_Node;
+
+extern REG_Memory_Node *root;
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/libs/system/zc702evk/nucleus/services/reg_status.h b/libs/system/zc702evk/nucleus/services/reg_status.h
--- /dev/null
@@ -0,0 +1,52 @@
+/*************************************************************************
+*
+* Copyright 2010 Mentor Graphics Corporation
+* All Rights Reserved.
+*
+* THIS WORK CONTAINS TRADE SECRET AND PROPRIETARY INFORMATION WHICH IS
+* THE PROPERTY OF MENTOR GRAPHICS CORPORATION OR ITS LICENSORS AND IS
+* SUBJECT TO LICENSE TERMS.
+*
+*************************************************************************/
+
+/*************************************************************************
+*
+* FILE NAME
+*
+* reg_status.h
+*
+* COMPONENT
+*
+* Registry
+*
+* DESCRIPTION
+*
+* This file defines the error codes used by the registry API.
+*
+* DATA STRUCTURES
+*
+* None
+*
+* DEPENDENCIES
+*
+* None.
+*
+*************************************************************************/
+
+#ifndef REG_STATUS_H
+#define REG_STATUS_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* Registry Error Codes */
+#define REG_TYPE_ERROR -1
+#define REG_NOT_WRITABLE -2
+#define REG_BAD_PATH -3
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/libs/system/zc702evk/nucleus/services/runlevel_init.h b/libs/system/zc702evk/nucleus/services/runlevel_init.h
--- /dev/null
@@ -0,0 +1,57 @@
+/***********************************************************************\r
+*\r
+* Copyright 2010 Mentor Graphics Corporation\r
+* All Rights Reserved.\r
+*\r
+* THIS WORK CONTAINS TRADE SECRET AND PROPRIETARY INFORMATION WHICH IS\r
+* THE PROPERTY OF MENTOR GRAPHICS CORPORATION OR ITS LICENSORS AND IS\r
+* SUBJECT TO LICENSE TERMS.\r
+*\r
+************************************************************************/\r
+\r
+/***********************************************************************\r
+*\r
+* DESCRIPTION\r
+*\r
+* This file contains external interfaces, defines, etc for the\r
+* run-level component\r
+*\r
+***********************************************************************/\r
+\r
+#ifndef RUNLEVEL_INIT_H\r
+#define RUNLEVEL_INIT_H\r
+\r
+#ifdef __cplusplus\r
+extern "C" { /* C declarations in C++ */\r
+#endif\r
+\r
+\r
+/* Maximum supported run-level value (limit is number of event group bits: 32-bits = run-levels 0-31) */\r
+#define NU_RUNLEVEL_MAX 31\r
+\r
+/* External definitions */\r
+#define NU_RUNLEVEL_NOT_STARTED 1\r
+#define NU_RUNLEVEL_IN_PROGRESS 2\r
+\r
+/* Define Runlevel component control values */\r
+#define RUNLEVEL_STOP 0\r
+#define RUNLEVEL_START 1\r
+#define RUNLEVEL_HIBERNATE 2\r
+#define RUNLEVEL_RESUME 3\r
+\r
+/* External function prototypes */\r
+STATUS NU_RunLevel_Current(INT * runlevel);\r
+STATUS NU_RunLevel_Status(INT runlevel);\r
+STATUS NU_RunLevel_Complete_Wait(INT runlevel, UNSIGNED timeout);\r
+STATUS NU_RunLevel_Next_Start(VOID);\r
+STATUS NU_RunLevel_0_Init(const CHAR * compregpath);\r
+\r
+#ifdef __cplusplus\r
+\r
+/* End of C declarations */\r
+}\r
+\r
+#endif /* __cplusplus */\r
+\r
+#endif /* RUNLEVEL_INIT_H */\r
+\r
diff --git a/libs/system/zc702evk/nucleus/services/semaphore.h b/libs/system/zc702evk/nucleus/services/semaphore.h
--- /dev/null
@@ -0,0 +1,101 @@
+/************************************************************************\r
+*\r
+* Copyright 2003 Mentor Graphics Corporation\r
+* All Rights Reserved.\r
+*\r
+* THIS WORK CONTAINS TRADE SECRET AND PROPRIETARY INFORMATION WHICH IS THE\r
+* PROPERTY OF MENTOR GRAPHICS CORPORATION OR ITS LICENSORS AND IS SUBJECT\r
+* TO LICENSE TERMS.\r
+*\r
+*************************************************************************\r
+\r
+*************************************************************************\r
+* FILE NAME\r
+*\r
+* semaphore.h\r
+*\r
+* COMPONENT\r
+*\r
+* SM - Semaphore.\r
+*\r
+* DESCRIPTION\r
+*\r
+* This file contains the declaration of various routines about\r
+* semaphores.\r
+*\r
+* DATA STRUCTURES\r
+*\r
+* None\r
+*\r
+* DEPENDENCIES\r
+*\r
+* "fcntl.h" Contains the requests and\r
+* arguments for use by the\r
+* functions fcntl( ) and\r
+* open( ).\r
+*\r
+************************************************************************/\r
+#ifndef __SEMAPHORE_H_\r
+#define __SEMAPHORE_H_\r
+\r
+#if (_POSIX_SEMAPHORES != -1)\r
+\r
+#include "services/fcntl.h"\r
+\r
+/* Semaphore mode of operations */\r
+#ifndef POSIX_FLAG_PROCESS_PRIVATE\r
+#define POSIX_FLAG_PROCESS_PRIVATE 0\r
+#endif\r
+#ifndef POSIX_FLAG_PROCESS_SHARED\r
+#define POSIX_FLAG_PROCESS_SHARED 1\r
+#endif\r
+\r
+typedef int sem_t;\r
+\r
+#define SEM_FAILED ((sem_t *) -1)\r
+\r
+/* Function Declarations. */\r
+\r
+#ifdef __cplusplus\r
+extern "C" {\r
+#endif\r
+\r
+int sem_close(sem_t *);\r
+\r
+int sem_destroy(sem_t *);\r
+\r
+int sem_getvalue(sem_t *, int *);\r
+\r
+int sem_init(sem_t *, int, unsigned);\r
+\r
+sem_t* sem_open(const char *,\r
+ int\r
+ ,... /* mode_t mode,\r
+ unsigned value */\r
+ );\r
+\r
+int sem_post(sem_t *);\r
+\r
+int sem_trywait(sem_t *);\r
+\r
+#if(_POSIX_TIMEOUTS != -1)\r
+\r
+int sem_timedwait(sem_t* sem, const struct timespec* abs_timeout);\r
+\r
+#endif\r
+\r
+int sem_unlink(const char *);\r
+\r
+int sem_wait(sem_t *);\r
+\r
+#ifdef __cplusplus\r
+}\r
+#endif\r
+\r
+#endif /* _POSIX_SEMAPHORES */\r
+\r
+#endif /* __SEMAPHORE_H_ */\r
+\r
+\r
+\r
+\r
diff --git a/libs/system/zc702evk/nucleus/services/syslog_extern.h b/libs/system/zc702evk/nucleus/services/syslog_extern.h
--- /dev/null
@@ -0,0 +1,79 @@
+/***********************************************************************\r
+*\r
+* Copyright 1993 Mentor Graphics Corporation\r
+* All Rights Reserved.\r
+*\r
+* THIS WORK CONTAINS TRADE SECRET AND PROPRIETARY INFORMATION WHICH IS\r
+* THE PROPERTY OF MENTOR GRAPHICS CORPORATION OR ITS LICENSORS AND IS\r
+* SUBJECT TO LICENSE TERMS.\r
+*\r
+************************************************************************\r
+\r
+************************************************************************\r
+*\r
+* FILE NAME\r
+*\r
+* syslog_extern.h\r
+*\r
+* DESCRIPTION\r
+*\r
+* This file contains external interfaces, defines, etc for the\r
+* system logging component\r
+*\r
+* DATA STRUCTURES\r
+*\r
+* SYSLOG_HANDLE\r
+*\r
+* DEPENDENCIES\r
+*\r
+* device_manager.h\r
+*\r
+***********************************************************************/\r
+#ifndef SYSLOG_EXTERN_H\r
+#define SYSLOG_EXTERN_H\r
+\r
+#ifdef CFG_NU_OS_SVCS_SYSLOG_ENABLE\r
+\r
+#include "kernel/dev_mgr.h"\r
+\r
+/* Typedef for system logging handle */\r
+typedef DV_DEV_HANDLE SYSLOG_HANDLE;\r
+\r
+#else\r
+\r
+/* Typedef for system logging handle */\r
+typedef INT32 SYSLOG_HANDLE;\r
+\r
+#endif /* CFG_NU_OS_SVCS_SYSLOG_ENABLE */\r
+\r
+\r
+/* Define system logging device class label */\r
+#define SYSLOGGER_CLASS_LABEL {0xaf,0x77,0x94,0xed,0x2c,0x12,0x46,0xdd,0x9c,0xa6,0x87,0xab,0xad,0xe8,0x26,0xb7}\r
+ \r
+/* Define supported IOCTLs */\r
+#define SYSLOG_CMD_BASE (DV_IOCTL0 + 1)\r
+#define SYSLOG_SET_NAME_CMD 1\r
+#define SYSLOG_SET_MASK_CMD 2\r
+\r
+/* Define for invalid device handle */\r
+#define SYSLOG_INVALID_HANDLE (0xFFFFFFFF)\r
+\r
+#ifdef CFG_NU_OS_SVCS_SYSLOG_ENABLE\r
+\r
+/* External function prototypes */\r
+SYSLOG_HANDLE SysLogOpen(const char * name);\r
+VOID SysLogSetMask(SYSLOG_HANDLE handle, UINT32 logmask);\r
+VOID SysLog(SYSLOG_HANDLE handle, const char * msg, UINT32 loglevel);\r
+VOID SysLogClose(SYSLOG_HANDLE handle);\r
+\r
+#else\r
+\r
+/* Define empty macros to allow use of System logging calls within code when component doesn't exist */\r
+#define SysLogOpen(x) 0\r
+#define SysLogSetMask(x,y)\r
+#define SysLog(x,y,z)\r
+#define SysLogClose(x)\r
+\r
+#endif /* CFG_NU_OS_SVCS_SYSLOG_ENABLE */\r
+\r
+#endif /* SYSLOG_EXTERN_H */\r
diff --git a/open_amp_build.sh b/open_amp_build.sh
--- /dev/null
+++ b/open_amp_build.sh
@@ -0,0 +1,303 @@
+
+# This scripts performs all steps necessary to build Nucleus master apps
+
+# Check if the user wants to clean everything
+if [ "$1" == "-c" ]; then
+ make clean
+
+ make -f libs/system/zc702evk/linux/make clean
+
+ cd apps
+
+ make OS=nucleus PLAT=zc702evk ROLE=remote clean
+
+ make OS=baremetal PLAT=zc702evk ROLE=remote clean
+
+ make OS=nucleus PLAT=zc702evk ROLE=master clean
+
+ make OS=baremetal PLAT=zc702evk ROLE=master clean
+
+ make cleanbenchmark OS=nucleus PLAT=zc702evk ROLE=master
+
+ make clean_linux_remote OS=nucleus PLAT=zc702evk ROLE=master
+
+ make clean_linux_remote OS=baremetal PLAT=zc702evk ROLE=master
+
+ make clean_linux_remote_benchmark OS=nucleus PLAT=zc702evk ROLE=master
+
+ cd firmware
+
+ find . -name "firmware" -delete
+
+ cd ../..
+
+elif [ "$1" == "-p" ]; then
+
+ # Build OPENAMP library for Nucleus master with benchmarking enabled
+
+ make clean
+
+ echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ echo Building open AMP components..
+ echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+ make OS=nucleus PLAT=zc702evk ROLE=remote
+
+ echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ echo Build remote Nucleus applications
+ echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+ cd apps
+
+ echo ~~~~~~~~~~~~~~~~~~~~~~~
+ echo Cleaning applications..
+ echo ~~~~~~~~~~~~~~~~~~~~~~~
+
+ make OS=nucleus PLAT=zc702evk ROLE=remote clean
+
+ echo ~~~~~~~~~~~~~~~~~~~~~~~
+ echo Building applications..
+ echo ~~~~~~~~~~~~~~~~~~~~~~~
+
+ make OS=nucleus PLAT=zc702evk ROLE=remote
+
+ cd ..
+
+ echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ echo Build OPENAMP library for remote baremetal
+ echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+ make clean
+
+ make OS=baremetal PLAT=zc702evk ROLE=remote
+
+ echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ echo Build remote baremetal applications
+ echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+ cd apps
+
+ make OS=baremetal PLAT=zc702evk ROLE=remote clean
+
+ make OS=baremetal PLAT=zc702evk ROLE=remote
+
+ cd ..
+
+ make clean
+
+ make OS=nucleus PLAT=zc702evk ROLE=master BENCHMARK=1
+
+ # Build nucleus master benchmark
+ cd apps
+
+ make cleanbenchmark OS=nucleus PLAT=zc702evk ROLE=master
+
+ make benchmark OS=nucleus PLAT=zc702evk ROLE=master
+
+ cd ..
+
+ make -f libs/system/zc702evk/linux/make clean
+
+ echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ echo Building Linux Bootstrap
+ echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+ make -f libs/system/zc702evk/linux/make
+
+ make clean
+
+ make OS=nucleus PLAT=zc702evk ROLE=master BENCHMARK=1 LINUXREMOTE=1
+
+ # Build nucleus master benchmark
+ cd apps
+
+ make clean_linux_remote_benchmark OS=nucleus PLAT=zc702evk ROLE=master
+
+ make linux_remote_benchmark OS=nucleus PLAT=zc702evk ROLE=master
+
+ cd ..
+
+else
+ echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ echo Build OPENAMP library for remote Nucleus
+ echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+ echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ echo Cleaning open AMP components..
+ echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+ make clean
+
+ echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ echo Building open AMP components..
+ echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+ make OS=nucleus PLAT=zc702evk ROLE=remote
+
+ echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ echo Build remote Nucleus applications
+ echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+ cd apps
+
+ echo ~~~~~~~~~~~~~~~~~~~~~~~
+ echo Cleaning applications..
+ echo ~~~~~~~~~~~~~~~~~~~~~~~
+
+ make OS=nucleus PLAT=zc702evk ROLE=remote clean
+
+ echo ~~~~~~~~~~~~~~~~~~~~~~~
+ echo Building applications..
+ echo ~~~~~~~~~~~~~~~~~~~~~~~
+
+ make OS=nucleus PLAT=zc702evk ROLE=remote
+
+ cd ..
+
+ echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ echo Build OPENAMP library for remote baremetal
+ echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+ echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ echo Cleaning open AMP components..
+ echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+ make clean
+
+ echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ echo Building open AMP components..
+ echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+ make OS=baremetal PLAT=zc702evk ROLE=remote
+
+ echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ echo Build remote baremetal applications
+ echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+ cd apps
+
+ echo ~~~~~~~~~~~~~~~~~~~~~~~
+ echo Cleaning applications..
+ echo ~~~~~~~~~~~~~~~~~~~~~~~
+
+ make OS=baremetal PLAT=zc702evk ROLE=remote clean
+
+ echo ~~~~~~~~~~~~~~~~~~~~~~~
+ echo Building applications..
+ echo ~~~~~~~~~~~~~~~~~~~~~~~
+
+ make OS=baremetal PLAT=zc702evk ROLE=remote
+
+ cd ..
+
+ echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ echo Cleaning Linux Bootstrap
+ echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+ make -f libs/system/zc702evk/linux/make clean
+
+ echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ echo Building Linux Bootstrap
+ echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+ make -f libs/system/zc702evk/linux/make
+
+ echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ echo Build OPENAMP library for master Nucleus
+ echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+ echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ echo Cleaning open AMP components..
+ echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+ make clean
+
+ echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ echo Building open AMP components..
+ echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+ make OS=nucleus PLAT=zc702evk ROLE=master
+
+ echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ echo Build master nucleus applications
+ echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+ cd apps
+
+ echo ~~~~~~~~~~~~~~~~~~~~~~~
+ echo Cleaning applications..
+ echo ~~~~~~~~~~~~~~~~~~~~~~~
+
+ make OS=nucleus PLAT=zc702evk ROLE=master clean
+
+ echo ~~~~~~~~~~~~~~~~~~~~~~~
+ echo Building applications..
+ echo ~~~~~~~~~~~~~~~~~~~~~~~
+
+ make OS=nucleus PLAT=zc702evk ROLE=master
+
+ cd ..
+
+
+ echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ echo Build OPENAMP library for master Nucleus and remote Linux
+ echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ echo Cleaning open AMP components..
+ echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ make clean
+
+ echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ echo Building open AMP components..
+ echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ make OS=nucleus PLAT=zc702evk ROLE=master LINUXREMOTE=1
+
+ # Build nucleus master with linux remote
+ cd apps
+
+ echo ~~~~~~~~~~~~~~~~~~~~~~~
+ echo Cleaning applications..
+ echo ~~~~~~~~~~~~~~~~~~~~~~~
+
+ make clean_linux_remote OS=nucleus PLAT=zc702evk ROLE=master
+
+
+ echo ~~~~~~~~~~~~~~~~~~~~~~~
+ echo Building applications..
+ echo ~~~~~~~~~~~~~~~~~~~~~~~
+ make linux_remote OS=nucleus PLAT=zc702evk ROLE=master
+
+ cd ..
+
+
+ echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ echo Build OPENAMP library for master baremetal and remote Linux
+ echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ echo Cleaning open AMP components..
+ echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ make clean
+
+ echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ echo Building open AMP components..
+ echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ make OS=baremetal PLAT=zc702evk ROLE=master LINUXREMOTE=1
+
+ # Build nucleus master with linux remote
+ cd apps
+
+ echo ~~~~~~~~~~~~~~~~~~~~~~~
+ echo Cleaning applications..
+ echo ~~~~~~~~~~~~~~~~~~~~~~~
+
+ make clean_linux_remote OS=baremetal PLAT=zc702evk ROLE=master
+
+
+ echo ~~~~~~~~~~~~~~~~~~~~~~~
+ echo Building applications..
+ echo ~~~~~~~~~~~~~~~~~~~~~~~
+ make linux_remote OS=baremetal PLAT=zc702evk ROLE=master
+
+ cd ..
+
+fi
diff --git a/porting/config/config.c b/porting/config/config.c
--- /dev/null
+++ b/porting/config/config.c
@@ -0,0 +1,95 @@
+/*\r
+ * Copyright (c) 2014, Mentor Graphics Corporation\r
+ * All rights reserved.\r
+ *\r
+ * Redistribution and use in source and binary forms, with or without\r
+ * modification, are permitted provided that the following conditions are met:\r
+ *\r
+ * 1. Redistributions of source code must retain the above copyright notice,\r
+ * this list of conditions and the following disclaimer.\r
+ * 2. Redistributions in binary form must reproduce the above copyright notice,\r
+ * this list of conditions and the following disclaimer in the documentation\r
+ * and/or other materials provided with the distribution.\r
+ * 3. Neither the name of Mentor Graphics Corporation nor the names of its\r
+ * contributors may be used to endorse or promote products derived from this\r
+ * software without specific prior written permission.\r
+ *\r
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"\r
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\r
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\r
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE\r
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\r
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\r
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\r
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\r
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\r
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\r
+ * POSSIBILITY OF SUCH DAMAGE.\r
+ */\r
+\r
+/**************************************************************************\r
+ * FILE NAME\r
+ *\r
+ * config.c\r
+ *\r
+ * COMPONENT\r
+ *\r
+ * OpenAMP stack.\r
+ *\r
+ * DESCRIPTION\r
+ *\r
+ *\r
+ **************************************************************************/\r
+\r
+#include "config.h"\r
+\r
+/* Start and end addresses of firmware image for remotes. These are defined in the\r
+ * object files that are obtained by converting the remote ELF Image into object\r
+ * files. These symbols are not used for remotes.\r
+ */\r
+extern unsigned char _binary_firmware1_start;\r
+extern unsigned char _binary_firmware1_end;\r
+\r
+extern unsigned char _binary_firmware2_start;\r
+extern unsigned char _binary_firmware2_end;\r
+\r
+#define FIRMWARE1_START (void *)&_binary_firmware1_start\r
+#define FIRMWARE1_END (void *)&_binary_firmware1_end\r
+\r
+#define FIRMWARE2_START (void *)&_binary_firmware2_start\r
+#define FIRMWARE2_END (void *)&_binary_firmware2_end\r
+\r
+/* Init firmware table */\r
+\r
+const struct firmware_info fw_table[] = { { "firmware1",\r
+ (unsigned int) FIRMWARE1_START, (unsigned int) FIRMWARE1_END },\r
+ { "firmware2", (unsigned int) FIRMWARE2_START,\r
+ (unsigned int) FIRMWARE2_END } };\r
+\r
+/**\r
+ * config_get_firmware\r
+ *\r
+ * Searches the given firmware in firmware table list and provides\r
+ * it to caller.\r
+ *\r
+ * @param fw_name - name of the firmware\r
+ * @param start_addr - pointer t hold start address of firmware\r
+ * @param size - pointer to hold size of firmware\r
+ *\r
+ * returns - status of function execution\r
+ *\r
+ */\r
+\r
+int config_get_firmware(char *fw_name, unsigned int *start_addr, unsigned int *size) {\r
+ int idx;\r
+ for (idx = 0; idx < sizeof(fw_table) / (sizeof(struct firmware_info));\r
+ idx++) {\r
+ if (!env_strncmp((char *) fw_table[idx].name, fw_name,\r
+ sizeof(fw_table[idx].name))) {\r
+ *start_addr = fw_table[idx].start_addr;\r
+ *size = fw_table[idx].end_addr - fw_table[idx].start_addr + 1;\r
+ return 0;\r
+ }\r
+ }\r
+ return -1;\r
+}
diff --git a/porting/config/config.h b/porting/config/config.h
--- /dev/null
+++ b/porting/config/config.h
@@ -0,0 +1,59 @@
+/*\r
+ * Copyright (c) 2014, Mentor Graphics Corporation\r
+ * All rights reserved.\r
+ *\r
+ * Redistribution and use in source and binary forms, with or without\r
+ * modification, are permitted provided that the following conditions are met:\r
+ *\r
+ * 1. Redistributions of source code must retain the above copyright notice,\r
+ * this list of conditions and the following disclaimer.\r
+ * 2. Redistributions in binary form must reproduce the above copyright notice,\r
+ * this list of conditions and the following disclaimer in the documentation\r
+ * and/or other materials provided with the distribution.\r
+ * 3. Neither the name of Mentor Graphics Corporation nor the names of its\r
+ * contributors may be used to endorse or promote products derived from this\r
+ * software without specific prior written permission.\r
+ *\r
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"\r
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\r
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\r
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE\r
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\r
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\r
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\r
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\r
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\r
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\r
+ * POSSIBILITY OF SUCH DAMAGE.\r
+ */\r
+\r
+#ifndef CONFIG_H\r
+#define CONFIG_H\r
+\r
+#include "../env/env.h"\r
+\r
+/* Max supprted ISR counts */\r
+#define ISR_COUNT 4\r
+\r
+/* Max supported firmwares */\r
+#define FW_COUNT 4\r
+/**\r
+ * Structure to keep track of registered ISR's.\r
+ */\r
+struct isr_info {\r
+ int vector;\r
+ int priority;\r
+ int type;\r
+ void *data;\r
+ void (*isr)(int vector, void *data);\r
+};\r
+\r
+struct firmware_info {\r
+ char name[32];\r
+ unsigned int start_addr;\r
+ unsigned int end_addr;\r
+};\r
+\r
+int config_get_firmware(char *fw_name, unsigned int *start_addr, unsigned int *size);\r
+\r
+#endif\r
diff --git a/porting/env/bm_env.c b/porting/env/bm_env.c
--- /dev/null
+++ b/porting/env/bm_env.c
@@ -0,0 +1,560 @@
+/*\r
+ * Copyright (c) 2014, Mentor Graphics Corporation\r
+ * All rights reserved.\r
+ *\r
+ * Redistribution and use in source and binary forms, with or without\r
+ * modification, are permitted provided that the following conditions are met:\r
+ *\r
+ * 1. Redistributions of source code must retain the above copyright notice,\r
+ * this list of conditions and the following disclaimer.\r
+ * 2. Redistributions in binary form must reproduce the above copyright notice,\r
+ * this list of conditions and the following disclaimer in the documentation\r
+ * and/or other materials provided with the distribution.\r
+ * 3. Neither the name of Mentor Graphics Corporation nor the names of its\r
+ * contributors may be used to endorse or promote products derived from this\r
+ * software without specific prior written permission.\r
+ *\r
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"\r
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\r
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\r
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE\r
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\r
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\r
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\r
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\r
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\r
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\r
+ * POSSIBILITY OF SUCH DAMAGE.\r
+ */\r
+\r
+/**************************************************************************\r
+ * FILE NAME\r
+ *\r
+ * bm_env.c\r
+ *\r
+ *\r
+ * DESCRIPTION\r
+ *\r
+ * This file is Bare Metal Implementation of env layer for OpenAMP.\r
+ *\r
+ *\r
+ **************************************************************************/\r
+\r
+#include "env.h"\r
+#include "../config/config.h"\r
+\r
+#if (ENV == BM_ENV)\r
+\r
+#include <stdlib.h>\r
+#include <string.h>\r
+\r
+#include "baremetal.h"\r
+\r
+#if (defined(__CC_ARM))\r
+#define MEM_BARRIER() __schedule_barrier()\r
+#elif (defined(__GNUC__))\r
+#define MEM_BARRIER() asm volatile("" ::: "memory")\r
+#else\r
+#define MEM_BARRIER()\r
+#endif\r
+static void acquire_spin_lock(void *plock);\r
+static void release_spin_lock(void *plock);\r
+\r
+struct isr_info isr_table[ISR_COUNT];\r
+int Intr_Count = 0;\r
+/* Flag to show status of global interrupts. 0 for disabled and 1 for enabled. This\r
+ * is added to prevent recursive global interrupts enablement/disablement.\r
+ */\r
+int Intr_Enable_Flag = 1;\r
+\r
+/**\r
+ * env_init\r
+ *\r
+ * Initializes OS/BM environment.\r
+ *\r
+ */\r
+int env_init() {\r
+ return 0;\r
+}\r
+\r
+/**\r
+ * env_deinit\r
+ *\r
+ * Uninitializes OS/BM environment.\r
+ *\r
+ * @returns - execution status\r
+ */\r
+\r
+int env_deinit() {\r
+ return 0;\r
+}\r
+/**\r
+ * env_allocate_memory - implementation\r
+ *\r
+ * @param size\r
+ */\r
+void *env_allocate_memory(unsigned int size)\r
+{\r
+ return (malloc(size));\r
+}\r
+\r
+/**\r
+ * env_free_memory - implementation\r
+ *\r
+ * @param ptr\r
+ */\r
+void env_free_memory(void *ptr)\r
+{\r
+ if (ptr != NULL)\r
+ {\r
+ free(ptr);\r
+ }\r
+}\r
+\r
+/**\r
+ *\r
+ * env_memset - implementation\r
+ *\r
+ * @param ptr\r
+ * @param value\r
+ * @param size\r
+ */\r
+void env_memset(void *ptr, int value, unsigned long size)\r
+{\r
+ memset(ptr, value, size);\r
+}\r
+\r
+/**\r
+ *\r
+ * env_memcpy - implementation\r
+ *\r
+ * @param dst\r
+ * @param src\r
+ * @param len\r
+ */\r
+void env_memcpy(void *dst, void const * src, unsigned long len) {\r
+ memcpy(dst,src,len);\r
+}\r
+\r
+/**\r
+ *\r
+ * env_strcmp - implementation\r
+ *\r
+ * @param dst\r
+ * @param src\r
+ */\r
+\r
+int env_strcmp(const char *dst, const char *src){\r
+ return (strcmp(dst, src));\r
+}\r
+\r
+/**\r
+ *\r
+ * env_strncpy - implementation\r
+ *\r
+ * @param dest\r
+ * @param src\r
+ * @param len\r
+ */\r
+void env_strncpy(char * dest, const char *src, unsigned long len)\r
+{\r
+ strncpy(dest, src, len);\r
+}\r
+\r
+/**\r
+ *\r
+ * env_strncmp - implementation\r
+ *\r
+ * @param dest\r
+ * @param src\r
+ * @param len\r
+ */\r
+int env_strncmp(char * dest, const char *src, unsigned long len)\r
+{\r
+ return (strncmp(dest, src, len));\r
+}\r
+\r
+/**\r
+ *\r
+ * env_mb - implementation\r
+ *\r
+ */\r
+void env_mb()\r
+{\r
+ MEM_BARRIER();\r
+}\r
+\r
+/**\r
+ * osalr_mb - implementation\r
+ */\r
+void env_rmb()\r
+{\r
+ MEM_BARRIER();\r
+}\r
+\r
+/**\r
+ * env_wmb - implementation\r
+ */\r
+void env_wmb()\r
+{\r
+ MEM_BARRIER();\r
+}\r
+\r
+/**\r
+ * env_map_vatopa - implementation\r
+ *\r
+ * @param address\r
+ */\r
+unsigned long env_map_vatopa(void *address)\r
+{\r
+ return ((((unsigned long)address & (~( 0x0fff << 20))) | (0x08 << 24)));\r
+}\r
+\r
+/**\r
+ * env_map_patova - implementation\r
+ *\r
+ * @param address\r
+ */\r
+void *env_map_patova(unsigned long address)\r
+{\r
+ return ((void *)address);\r
+}\r
+\r
+/**\r
+ * env_create_mutex\r
+ *\r
+ * Creates a mutex with the given initial count.\r
+ *\r
+ */\r
+int env_create_mutex(void **lock, int count)\r
+{\r
+ return 0;\r
+}\r
+\r
+/**\r
+ * env_delete_mutex\r
+ *\r
+ * Deletes the given lock\r
+ *\r
+ */\r
+void env_delete_mutex(void *lock)\r
+{\r
+}\r
+\r
+/**\r
+ * env_lock_mutex\r
+ *\r
+ * Tries to acquire the lock, if lock is not available then call to\r
+ * this function will suspend.\r
+ */\r
+void env_lock_mutex(void *lock)\r
+{\r
+ env_disable_interrupts();\r
+}\r
+\r
+/**\r
+ * env_unlock_mutex\r
+ *\r
+ * Releases the given lock.\r
+ */\r
+\r
+void env_unlock_mutex(void *lock)\r
+{\r
+ env_restore_interrupts();\r
+}\r
+\r
+\r
+/**\r
+ * env_create_sync_lock\r
+ *\r
+ * Creates a synchronization lock primitive. It is used\r
+ * when signal has to be sent from the interrupt context to main\r
+ * thread context.\r
+ */\r
+int env_create_sync_lock(void **lock , int state) {\r
+ int *slock;\r
+\r
+ slock = (int *)malloc(sizeof(int));\r
+ if(slock){\r
+ *slock = state;\r
+ *lock = slock;\r
+ }\r
+ else{\r
+ *lock = NULL;\r
+ return -1;\r
+ }\r
+\r
+ return 0;\r
+}\r
+\r
+/**\r
+ * env_delete_sync_lock\r
+ *\r
+ * Deletes the given lock\r
+ *\r
+ */\r
+void env_delete_sync_lock(void *lock){\r
+ if(lock)\r
+ free(lock);\r
+}\r
+\r
+/**\r
+ * env_acquire_sync_lock\r
+ *\r
+ * Tries to acquire the lock, if lock is not available then call to\r
+ * this function waits for lock to become available.\r
+ */\r
+void env_acquire_sync_lock(void *lock){\r
+ acquire_spin_lock(lock);\r
+}\r
+\r
+/**\r
+ * env_release_sync_lock\r
+ *\r
+ * Releases the given lock.\r
+ */\r
+\r
+void env_release_sync_lock(void *lock){\r
+ release_spin_lock(lock);\r
+}\r
+\r
+/**\r
+ * env_sleep_msec\r
+ *\r
+ * Suspends the calling thread for given time , in msecs.\r
+ */\r
+\r
+void env_sleep_msec(int num_msec)\r
+{\r
+\r
+}\r
+\r
+/**\r
+ * env_disable_interrupts\r
+ *\r
+ * Disables system interrupts\r
+ *\r
+ */\r
+void env_disable_interrupts()\r
+{\r
+ if(Intr_Enable_Flag == 1) {\r
+ disable_global_interrupts();\r
+ Intr_Enable_Flag = 0;\r
+ }\r
+}\r
+\r
+/**\r
+ * env_restore_interrupts\r
+ *\r
+ * Enables system interrupts\r
+ *\r
+ */\r
+void env_restore_interrupts()\r
+{\r
+ if(Intr_Enable_Flag == 0) {\r
+ restore_global_interrupts();\r
+ Intr_Enable_Flag = 1;\r
+ }\r
+}\r
+\r
+/**\r
+ * env_register_isr\r
+ *\r
+ * Registers interrupt handler for the given interrupt vector.\r
+ *\r
+ * @param vector - interrupt vector number\r
+ * @param isr - interrupt handler\r
+ */\r
+void env_register_isr(int vector , void *data ,\r
+ void (*isr)(int vector , void *data))\r
+{\r
+ env_disable_interrupts();\r
+\r
+ if(Intr_Count < ISR_COUNT)\r
+ {\r
+ /* Save interrupt data */\r
+ isr_table[Intr_Count].vector = vector;\r
+ isr_table[Intr_Count].data = data;\r
+ isr_table[Intr_Count++].isr = isr;\r
+ }\r
+\r
+ env_restore_interrupts();\r
+}\r
+\r
+/**\r
+ * env_enable_interrupt\r
+ *\r
+ * Enables the given interrupt\r
+ *\r
+ * @param vector - interrupt vector number\r
+ * @param priority - interrupt priority\r
+ * @param polarity - interrupt polarity\r
+ */\r
+\r
+void env_enable_interrupt(unsigned int vector , unsigned int priority ,\r
+ unsigned int polarity)\r
+{\r
+ int idx;\r
+\r
+ env_disable_interrupts();\r
+\r
+ for(idx = 0; idx < ISR_COUNT; idx++)\r
+ {\r
+ if(isr_table[idx].vector == vector)\r
+ {\r
+ isr_table[idx].priority = priority;\r
+ isr_table[idx].type = polarity;\r
+ zc702evk_gic_interrupt_enable(vector, polarity, priority);\r
+ break;\r
+ }\r
+ }\r
+\r
+ env_restore_interrupts();\r
+}\r
+\r
+/**\r
+ * env_disable_interrupt\r
+ *\r
+ * Disables the given interrupt\r
+ *\r
+ * @param vector - interrupt vector number\r
+ */\r
+\r
+void env_disable_interrupt(unsigned int vector)\r
+{\r
+ zc702evk_gic_interrupt_disable(vector);\r
+}\r
+\r
+/**\r
+ * env_map_memory\r
+ *\r
+ * Enables memory mapping for given memory region.\r
+ *\r
+ * @param pa - physical address of memory\r
+ * @param va - logical address of memory\r
+ * @param size - memory size\r
+ * param flags - flags for cache/uncached and access type\r
+ */\r
+\r
+void env_map_memory(unsigned int pa, unsigned int va, unsigned int size,\r
+ unsigned int flags) {\r
+ int is_mem_mapped = 0;\r
+ int cache_type = 0;\r
+\r
+ if ((flags & (0x0f << 4 )) == MEM_MAPPED)\r
+ {\r
+ is_mem_mapped = 1;\r
+ }\r
+\r
+ if ((flags & 0x0f) == WB_CACHE) {\r
+ cache_type = WRITEBACK;\r
+ }\r
+ else if((flags & 0x0f) == WT_CACHE) {\r
+ cache_type = WRITETHROUGH;\r
+ }\r
+ else {\r
+ cache_type = NOCACHE;\r
+ }\r
+\r
+ arm_ar_map_mem_region(va, pa, size, is_mem_mapped, cache_type);\r
+}\r
+\r
+/**\r
+ * env_disable_cache\r
+ *\r
+ * Disables system caches.\r
+ *\r
+ */\r
+\r
+void env_disable_cache() {\r
+ ARM_AR_MEM_CACHE_ALL_FLUSH_INVALIDATE();\r
+ ARM_AR_MEM_CACHE_DISABLE();\r
+}\r
+\r
+/**\r
+ * \r
+ * env_get_timestamp\r
+ *\r
+ * Returns a 64 bit time stamp.\r
+ *\r
+ *\r
+ */\r
+unsigned long long env_get_timestamp(void) {\r
+\r
+ /* TODO: Provide implementation for baremetal*/\r
+ return 0;\r
+}\r
+\r
+/*========================================================= */\r
+/* Util data / functions for BM */\r
+\r
+void bm_env_isr(int vector) {\r
+ int idx;\r
+ struct isr_info *info;\r
+\r
+ env_disable_interrupt(vector);\r
+ for(idx = 0; idx < ISR_COUNT; idx++)\r
+ {\r
+ info = &isr_table[idx];\r
+ if(info->vector == vector)\r
+ {\r
+ info->isr(info->vector , info->data);\r
+ env_enable_interrupt(info->vector , info->priority, info->type);\r
+ break;\r
+ }\r
+ }\r
+}\r
+\r
+static inline unsigned int xchg(void* plock, unsigned int lockVal)\r
+{\r
+ volatile unsigned int retVal = 0;\r
+\r
+#ifdef __GNUC__\r
+\r
+\r
+ asm (\r
+ "1: \n\t"\r
+ "LDREX %[retVal], [%[plock]] \n\t"\r
+ "STREX r4, %[lockVal], [%[plock]] \n\t"\r
+ "CMP r4, #0 \n\t"\r
+ "BNE 1b \n\t"\r
+ "DMB \n\t"\r
+ : [retVal] "=&r"(retVal)\r
+ : [lockVal] "r"(lockVal), [plock] "r"(plock)\r
+ : "cc", "memory"\r
+ );\r
+\r
+#endif\r
+\r
+ return retVal;\r
+}\r
+\r
+/**\r
+ *\r
+ * acquire_spin_lock\r
+ *\r
+ */\r
+static void acquire_spin_lock(void *plock)\r
+{\r
+ const int lockVal = 0;\r
+ unsigned int retVal;\r
+\r
+ do {\r
+ retVal = xchg(plock, lockVal);\r
+ } while (retVal==lockVal);\r
+}\r
+\r
+/**\r
+ * release_spin_lock\r
+ */\r
+static void release_spin_lock(void *plock)\r
+{\r
+ MEM_BARRIER();\r
+\r
+ *((int *)plock) = 1;\r
+}\r
+\r
+#endif /* (ENV == BM_ENV) */\r
+\r
+\r
+\r
diff --git a/porting/env/env.h b/porting/env/env.h
--- /dev/null
+++ b/porting/env/env.h
@@ -0,0 +1,436 @@
+/*\r
+ * Copyright (c) 2014, Mentor Graphics Corporation\r
+ * All rights reserved.\r
+ *\r
+ * Redistribution and use in source and binary forms, with or without\r
+ * modification, are permitted provided that the following conditions are met:\r
+ *\r
+ * 1. Redistributions of source code must retain the above copyright notice,\r
+ * this list of conditions and the following disclaimer.\r
+ * 2. Redistributions in binary form must reproduce the above copyright notice,\r
+ * this list of conditions and the following disclaimer in the documentation\r
+ * and/or other materials provided with the distribution.\r
+ * 3. Neither the name of Mentor Graphics Corporation nor the names of its\r
+ * contributors may be used to endorse or promote products derived from this\r
+ * software without specific prior written permission.\r
+ *\r
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"\r
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\r
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\r
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE\r
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\r
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\r
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\r
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\r
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\r
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\r
+ * POSSIBILITY OF SUCH DAMAGE.\r
+ */\r
+\r
+ /**************************************************************************\r
+ * FILE NAME\r
+ *\r
+ * env.h\r
+ *\r
+ * COMPONENT\r
+ *\r
+ * OpenAMP stack.\r
+ *\r
+ * DESCRIPTION\r
+ *\r
+ * This file defines abstraction layer for OpenAMP stack. The implementor\r
+ * must provide definition of all the functions.\r
+ *\r
+ * DATA STRUCTURES\r
+ *\r
+ * none\r
+ *\r
+ * FUNCTIONS\r
+ *\r
+ * env_allocate_memory\r
+ * env_free_memory\r
+ * env_memset\r
+ * env_memcpy\r
+ * env_strlen\r
+ * env_strcpy\r
+ * env_strncpy\r
+ * env_print\r
+ * env_map_vatopa\r
+ * env_map_patova\r
+ * env_mb\r
+ * env_rmb\r
+ * env_wmb\r
+ * env_create_mutex\r
+ * env_delete_mutex\r
+ * env_lock_mutex\r
+ * env_unlock_mutex\r
+ * env_sleep_msec\r
+ * env_disable_interrupts\r
+ * env_restore_interrupts\r
+ *\r
+ **************************************************************************/\r
+#ifndef _ENV_H_\r
+#define _ENV_H_\r
+\r
+#include <stdio.h>\r
+\r
+/**\r
+ * env_init\r
+ *\r
+ * Initializes OS/BM environment.\r
+ *\r
+ * @returns - execution status\r
+ */\r
+\r
+int env_init();\r
+\r
+/**\r
+ * env_deinit\r
+ *\r
+ * Uninitializes OS/BM environment.\r
+ *\r
+ * @returns - execution status\r
+ */\r
+\r
+int env_deinit();\r
+/**\r
+ * -------------------------------------------------------------------------\r
+ *\r
+ * Dynamic memory management functions. The parameters\r
+ * are similar to standard c functions.\r
+ *\r
+ *-------------------------------------------------------------------------\r
+ **/\r
+\r
+/**\r
+ * env_allocate_memory\r
+ *\r
+ * Allocates memory with the given size.\r
+ *\r
+ * @param size - size of memory to allocate\r
+ *\r
+ * @return - pointer to allocated memory\r
+ */\r
+void *env_allocate_memory(unsigned int size);\r
+\r
+/**\r
+ * env_free_memory\r
+ *\r
+ * Frees memory pointed by the given parameter.\r
+ *\r
+ * @param ptr - pointer to memory to free\r
+ */\r
+void env_free_memory(void *ptr);\r
+\r
+/**\r
+ * -------------------------------------------------------------------------\r
+ *\r
+ * RTL Functions\r
+ *\r
+ *-------------------------------------------------------------------------\r
+ */\r
+\r
+void env_memset(void *, int, unsigned long);\r
+void env_memcpy(void *, void const *, unsigned long);\r
+size_t env_strlen(const char *);\r
+void env_strcpy(char *, const char *);\r
+int env_strcmp(const char *, const char *);\r
+void env_strncpy(char *, const char *, unsigned long);\r
+int env_strncmp(char *, const char *, unsigned long);\r
+#define env_print(...) printf(__VA_ARGS__)\r
+\r
+/**\r
+ *-----------------------------------------------------------------------------\r
+ *\r
+ * Functions to convert physical address to virtual address and vice versa.\r
+ *\r
+ *-----------------------------------------------------------------------------\r
+ */\r
+\r
+/**\r
+ * env_map_vatopa\r
+ *\r
+ * Converts logical address to physical address\r
+ *\r
+ * @param address - pointer to logical address\r
+ *\r
+ * @return - physical address\r
+ */\r
+unsigned long env_map_vatopa(void *address);\r
+\r
+/**\r
+ * env_map_patova\r
+ *\r
+ * Converts physical address to logical address\r
+ *\r
+ * @param address - pointer to physical address\r
+ *\r
+ * @return - logical address\r
+ *\r
+ */\r
+void *env_map_patova(unsigned long address);\r
+\r
+/**\r
+ *-----------------------------------------------------------------------------\r
+ *\r
+ * Abstractions for memory barrier instructions.\r
+ *\r
+ *-----------------------------------------------------------------------------\r
+ */\r
+\r
+/**\r
+ * env_mb\r
+ *\r
+ * Inserts memory barrier.\r
+ */\r
+\r
+void env_mb();\r
+\r
+/**\r
+ * env_rmb\r
+ *\r
+ * Inserts read memory barrier\r
+ */\r
+\r
+void env_rmb();\r
+\r
+/**\r
+ * env_wmb\r
+ *\r
+ * Inserts write memory barrier\r
+ */\r
+\r
+void env_wmb();\r
+\r
+/**\r
+ *-----------------------------------------------------------------------------\r
+ *\r
+ * Abstractions for OS lock primitives.\r
+ *\r
+ *-----------------------------------------------------------------------------\r
+ */\r
+\r
+/**\r
+ * env_create_mutex\r
+ *\r
+ * Creates a mutex with given initial count.\r
+ *\r
+ * @param lock - pointer to created mutex\r
+ * @param count - initial count 0 or 1\r
+ *\r
+ * @return - status of function execution\r
+ */\r
+int env_create_mutex(void **lock , int count);\r
+\r
+/**\r
+ * env_delete_mutex\r
+ *\r
+ * Deletes the given lock.\r
+ *\r
+ * @param lock - mutex to delete\r
+ */\r
+\r
+void env_delete_mutex(void *lock);\r
+\r
+/**\r
+ * env_lock_mutex\r
+ *\r
+ * Tries to acquire the lock, if lock is not available then call to\r
+ * this function will suspend.\r
+ *\r
+ * @param lock - mutex to lock\r
+ *\r
+ */\r
+\r
+void env_lock_mutex(void *lock);\r
+\r
+/**\r
+ * env_unlock_mutex\r
+ *\r
+ * Releases the given lock.\r
+ *\r
+ * @param lock - mutex to unlock\r
+ */\r
+\r
+void env_unlock_mutex(void *lock);\r
+\r
+/**\r
+ * env_create_sync_lock\r
+ *\r
+ * Creates a synchronization lock primitive. It is used\r
+ * when signal has to be sent from the interrupt context to main\r
+ * thread context.\r
+ *\r
+ * @param lock - pointer to created sync lock object\r
+ * @param state - initial state , lock or unlocked\r
+ *\r
+ * @returns - status of function execution\r
+ */\r
+#define LOCKED 0\r
+#define UNLOCKED 1\r
+\r
+int env_create_sync_lock(void **lock , int state);\r
+\r
+/**\r
+ * env_create_sync_lock\r
+ *\r
+ * Deletes given sync lock object.\r
+ *\r
+ * @param lock - sync lock to delete.\r
+ *\r
+ */\r
+\r
+void env_delete_sync_lock(void *lock);\r
+\r
+\r
+/**\r
+ * env_acquire_sync_lock\r
+ *\r
+ * Tries to acquire the sync lock.\r
+ *\r
+ * @param lock - sync lock to acquire.\r
+ */\r
+void env_acquire_sync_lock(void *lock);\r
+\r
+/**\r
+ * env_release_sync_lock\r
+ *\r
+ * Releases synchronization lock.\r
+ *\r
+ * @param lock - sync lock to release.\r
+ */\r
+void env_release_sync_lock(void *lock);\r
+\r
+/**\r
+ * env_sleep_msec\r
+ *\r
+ * Suspends the calling thread for given time in msecs.\r
+ *\r
+ * @param num_msec - delay in msecs\r
+ */\r
+void env_sleep_msec(int num_msec);\r
+\r
+/**\r
+ * env_disable_interrupts\r
+ *\r
+ * Disables system interrupts\r
+ *\r
+ */\r
+void env_disable_interrupts();\r
+\r
+/**\r
+ * env_restore_interrupts\r
+ *\r
+ * Enables system interrupts\r
+ *\r
+ */\r
+void env_restore_interrupts();\r
+\r
+/**\r
+ * env_register_isr\r
+ *\r
+ * Registers interrupt handler for the given interrupt vector.\r
+ *\r
+ * @param vector - interrupt vector number\r
+ * @param data - private data\r
+ * @param isr - interrupt handler\r
+ */\r
+\r
+void env_register_isr(int vector, void *data,\r
+ void (*isr)(int vector, void *data));\r
+\r
+/**\r
+ * env_enable_interrupt\r
+ *\r
+ * Enables the given interrupt.\r
+ *\r
+ * @param vector - interrupt vector number\r
+ * @param priority - interrupt priority\r
+ * @param polarity - interrupt polarity\r
+ */\r
+\r
+void env_enable_interrupt(unsigned int vector, unsigned int priority,\r
+ unsigned int polarity);\r
+\r
+/**\r
+ * env_disable_interrupt\r
+ *\r
+ * Disables the given interrupt.\r
+ *\r
+ * @param vector - interrupt vector number\r
+ */\r
+\r
+void env_disable_interrupt(unsigned int vector);\r
+\r
+/**\r
+ * env_map_memory\r
+ *\r
+ * Enables memory mapping for given memory region.\r
+ *\r
+ * @param pa - physical address of memory\r
+ * @param va - logical address of memory\r
+ * @param size - memory size\r
+ * param flags - flags for cache/uncached and access type\r
+ *\r
+ * Currently only first byte of flag parameter is used and bits mapping is defined as follow;\r
+ *\r
+ * Cache bits\r
+ * 0x0000_0001 = No cache\r
+ * 0x0000_0010 = Write back\r
+ * 0x0000_0100 = Write through\r
+ * 0x0000_x000 = Not used\r
+ *\r
+ * Memory types\r
+ *\r
+ * 0x0001_xxxx = Memory Mapped\r
+ * 0x0010_xxxx = IO Mapped\r
+ * 0x0100_xxxx = Shared\r
+ * 0x1000_xxxx = TLB\r
+ */\r
+\r
+/* Macros for caching scheme used by the shared memory */\r
+#define UNCACHED (1 << 0)\r
+#define WB_CACHE (1 << 1)\r
+#define WT_CACHE (1 << 2)\r
+\r
+/* Memory Types */\r
+#define MEM_MAPPED (1 << 4)\r
+#define IO_MAPPED (1 << 5)\r
+#define SHARED_MEM (1 << 6)\r
+#define TLB_MEM (1 << 7)\r
+\r
+void env_map_memory(unsigned int pa, unsigned int va, unsigned int size,\r
+ unsigned int flags);\r
+\r
+/**\r
+ * env_get_timestamp\r
+ *\r
+ * Returns a 64 bit time stamp.\r
+ *\r
+ *\r
+ */\r
+unsigned long long env_get_timestamp(void);\r
+\r
+/**
+ * env_disable_cache
+ *
+ * Disables system caches.
+ *
+ */
+\r
+void env_disable_cache();\r
+\r
+typedef void LOCK;\r
+\r
+/*\r
+ * Macros to enable BM or Nucleus environment.\r
+ */\r
+\r
+#define NU_ENV 0\r
+#define BM_ENV 1\r
+\r
+#ifndef ENV\r
+#define ENV NU_ENV\r
+#endif\r
+\r
+#endif /* _ENV_H_ */\r
diff --git a/porting/env/nu_env.c b/porting/env/nu_env.c
--- /dev/null
+++ b/porting/env/nu_env.c
@@ -0,0 +1,683 @@
+/*\r
+ * Copyright (c) 2014, Mentor Graphics Corporation\r
+ * All rights reserved.\r
+ *\r
+ * Redistribution and use in source and binary forms, with or without\r
+ * modification, are permitted provided that the following conditions are met:\r
+ *\r
+ * 1. Redistributions of source code must retain the above copyright notice,\r
+ * this list of conditions and the following disclaimer.\r
+ * 2. Redistributions in binary form must reproduce the above copyright notice,\r
+ * this list of conditions and the following disclaimer in the documentation\r
+ * and/or other materials provided with the distribution.\r
+ * 3. Neither the name of Mentor Graphics Corporation nor the names of its\r
+ * contributors may be used to endorse or promote products derived from this\r
+ * software without specific prior written permission.\r
+ *\r
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"\r
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\r
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\r
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE\r
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\r
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\r
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\r
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\r
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\r
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\r
+ * POSSIBILITY OF SUCH DAMAGE.\r
+ */\r
+\r
+ /**************************************************************************\r
+ * FILE NAME\r
+ *\r
+ * nu_env.c\r
+ *\r
+ * COMPONENT\r
+ *\r
+ * OpenAMP stack.\r
+ *\r
+ * DESCRIPTION\r
+ *\r
+ * This file is Nucleus Implementation of environment layer.\r
+ *\r
+ *\r
+ **************************************************************************/\r
+\r
+#include "env.h"\r
+#include "../config/config.h"\r
+\r
+#if (ENV == NU_ENV)\r
+\r
+#include <stdlib.h>\r
+#include <string.h>\r
+#include "nucleus.h"\r
+#include "kernel/nu_kernel.h"\r
+#include "os/kernel/plus/core/inc/thread_control.h"\r
+\r
+/* Configurable parameters */\r
+\r
+/* Main task's stack size */\r
+#define NU_ENV_STACK_SIZE (NU_MIN_STACK_SIZE * 64)\r
+\r
+/* Main task's priority */\r
+#define NU_ENV_TASK_PRIOIRTY 26\r
+\r
+/* Main task's time slice */\r
+#define NU_ENV_TASK_SLICE 20\r
+\r
+\r
+/* Queue message size */\r
+#define MSG_SIZE sizeof(struct isr_info)/sizeof(unsigned)\r
+\r
+/* Internal functions */\r
+static VOID NU_Env_Task_Entry(UNSIGNED argc, VOID *argv);\r
+static void NU_Env_HISR_Entry();\r
+static VOID NU_Env_LISR(int vector);\r
+\r
+/* Globals */\r
+static NU_HISR NU_Env_HISR;\r
+static NU_TASK NU_Env_Task;\r
+static NU_QUEUE NU_Env_Queue;\r
+static NU_SEMAPHORE NU_Env_Sem;\r
+static VOID *Queue_Mem = NU_NULL;\r
+static VOID *Task_Mem = NU_NULL;\r
+static VOID *Hisr_Mem = NU_NULL;\r
+static INT Intr_Count = 0;\r
+static INT ENV_INIT_COUNT = 0;\r
+static struct isr_info isr_table[ISR_COUNT];\r
+static INT Old_Level = 0;\r
+\r
+/**\r
+ * env_init\r
+ *\r
+ * Initializes OS/BM environment.\r
+ *\r
+ */\r
+int env_init(){\r
+ STATUS status = NU_SUCCESS;\r
+ NU_MEMORY_POOL *pool_ptr = NU_NULL;\r
+\r
+ if(!ENV_INIT_COUNT)\r
+ {\r
+ status = NU_System_Memory_Get(&pool_ptr, NU_NULL);\r
+ if(status == NU_SUCCESS)\r
+ {\r
+ status = NU_Allocate_Memory(pool_ptr, &Hisr_Mem, NU_ENV_STACK_SIZE,\r
+ NU_NO_SUSPEND);\r
+ if (status == NU_SUCCESS)\r
+ {\r
+ memset(Hisr_Mem , 0x00 , NU_ENV_STACK_SIZE);\r
+ status = NU_Create_HISR(&NU_Env_HISR, "NU_Env_Q", NU_Env_HISR_Entry, 2, Hisr_Mem,\r
+ NU_ENV_STACK_SIZE);\r
+ if (status == NU_SUCCESS)\r
+ {\r
+ status = NU_Create_HISR_Queue(&NU_Env_HISR,8,NU_TRUE);\r
+ if(status == NU_SUCCESS)\r
+ {\r
+ status = NU_Allocate_Memory(pool_ptr, &Queue_Mem,\r
+ 8*sizeof(struct isr_info), NU_NO_SUSPEND);\r
+ memset(Queue_Mem , 0x00 , 8*sizeof(struct isr_info));\r
+ if(status == NU_SUCCESS)\r
+ {\r
+ status = NU_Create_Queue(&NU_Env_Queue, "NU_Env_Q", Queue_Mem,\r
+ (8*MSG_SIZE), NU_FIXED_SIZE,\r
+ MSG_SIZE, NU_FIFO);\r
+ if (status == NU_SUCCESS)\r
+ {\r
+ status = NU_Create_Semaphore(&NU_Env_Sem, "ENV_MSEM", 1 , NU_FIFO);\r
+ if(status == NU_SUCCESS)\r
+ {\r
+ status = NU_Allocate_Memory(pool_ptr, &Task_Mem,\r
+ NU_ENV_STACK_SIZE, NU_NO_SUSPEND);\r
+ memset(Task_Mem , 0x00 , NU_ENV_STACK_SIZE);\r
+ if (status == NU_SUCCESS)\r
+ {\r
+ /* Create task 0. */\r
+ status = NU_Create_Task(&NU_Env_Task, "NU_Env_T", NU_Env_Task_Entry, 0,\r
+ pool_ptr, Task_Mem, NU_ENV_STACK_SIZE, NU_ENV_TASK_PRIOIRTY,\r
+ NU_ENV_TASK_SLICE, NU_PREEMPT, NU_START);\r
+ }\r
+ }\r
+ }\r
+ }\r
+ }\r
+ }\r
+ }\r
+ }\r
+ }\r
+\r
+ if(status == NU_SUCCESS){\r
+ NU_Obtain_Semaphore(&NU_Env_Sem, NU_SUSPEND);\r
+ ENV_INIT_COUNT++;\r
+ NU_Release_Semaphore(&NU_Env_Sem);\r
+ }\r
+\r
+ return status;\r
+}\r
+\r
+/**\r
+ * env_deinit\r
+ *\r
+ * Uninitializes OS/BM environment.\r
+ *\r
+ * @returns - execution status\r
+ */\r
+int env_deinit() {\r
+ int status = NU_SUCCESS;\r
+\r
+ NU_Obtain_Semaphore(&NU_Env_Sem, NU_SUSPEND);\r
+ ENV_INIT_COUNT--;\r
+ NU_Release_Semaphore(&NU_Env_Sem);\r
+\r
+ if (!ENV_INIT_COUNT) {\r
+ if (Task_Mem) {\r
+ status |= NU_Terminate_Task(&NU_Env_Task);\r
+ status |= NU_Delete_Task(&NU_Env_Task);\r
+ status |= NU_Deallocate_Memory(Task_Mem);\r
+ }\r
+\r
+ if (Queue_Mem) {\r
+ NU_Delete_Queue(&NU_Env_Queue);\r
+ status |= NU_Deallocate_Memory(Queue_Mem);\r
+ }\r
+\r
+ if (Hisr_Mem) {\r
+ status |= NU_Delete_HISR(&NU_Env_HISR);\r
+ status |= NU_Deallocate_Memory(Hisr_Mem);\r
+ }\r
+\r
+ status |= NU_Delete_Semaphore(&NU_Env_Sem);\r
+ Intr_Count = 0;\r
+\r
+ }\r
+ return status;\r
+}\r
+\r
+/**\r
+ * env_allocate_memory - implementation\r
+ *\r
+ * @param size\r
+ */\r
+void *env_allocate_memory(unsigned int size)\r
+{\r
+ STATUS status = NU_SUCCESS;\r
+ VOID *mem_ptr = NU_NULL;\r
+ NU_MEMORY_POOL *pool_ptr = NU_NULL;\r
+\r
+ /* Ensure valid allocation size. */\r
+ if (size != 0)\r
+ {\r
+ /* Get system cached memory pools pointer */\r
+ status = NU_System_Memory_Get(&pool_ptr, NU_NULL);\r
+ if (status == NU_SUCCESS)\r
+ {\r
+ /* Allocate requested memory from Nucleus memory system. */\r
+ status = NU_Allocate_Memory(pool_ptr, &mem_ptr,\r
+ (UNSIGNED)size, NU_NO_SUSPEND);\r
+ if(status == NU_SUCCESS)\r
+ {\r
+ memset(mem_ptr, 0x00 ,size);\r
+ }\r
+ }\r
+ }\r
+\r
+ return (mem_ptr);\r
+}\r
+\r
+/**\r
+ * env_free_memory - implementation\r
+ *\r
+ * @param ptr\r
+ */\r
+void env_free_memory(void *ptr)\r
+{\r
+ if (ptr != NU_NULL)\r
+ {\r
+ (VOID) NU_Deallocate_Memory(ptr);\r
+ }\r
+}\r
+\r
+\r
+/**\r
+ *\r
+ * env_memset - implementation\r
+ *\r
+ * @param ptr\r
+ * @param value\r
+ * @param size\r
+ */\r
+void env_memset(void *ptr, int value, unsigned long size)\r
+{\r
+ memset(ptr, value, size);\r
+}\r
+\r
+void env_memcpy(void *dst, void const * src, unsigned long len){\r
+ memcpy(dst,src,len);\r
+}\r
+/**\r
+ *\r
+ * env_strncpy - implementation\r
+ *\r
+ * @param dest\r
+ * @param src\r
+ * @param len\r
+ */\r
+void env_strncpy(char * dst, const char *src, unsigned long len)\r
+{\r
+ strncpy(dst, src, len);\r
+}\r
+\r
+int env_strncmp(char * dst, const char *src, unsigned long len)\r
+{\r
+ return (strncmp(dst, src, len));\r
+}\r
+\r
+/**\r
+ *\r
+ * env_strcmp - implementation\r
+ *\r
+ * @param dst\r
+ * @param src\r
+ */\r
+\r
+int env_strcmp(const char * dst, const char *src) {\r
+ return (strcmp(dst, src));\r
+}\r
+/**\r
+ *\r
+ * env_mb - implementation\r
+ *\r
+ */\r
+void env_mb()\r
+{\r
+ ESAL_TS_RTE_COMPILE_MEM_BARRIER();\r
+}\r
+\r
+/**\r
+ * osalr_mb - implementation\r
+ */\r
+void env_rmb()\r
+{\r
+ ESAL_TS_RTE_COMPILE_MEM_BARRIER();\r
+}\r
+\r
+/**\r
+ * env_wmb - implementation\r
+ */\r
+void env_wmb()\r
+{\r
+ ESAL_TS_RTE_COMPILE_MEM_BARRIER();\r
+}\r
+\r
+/**\r
+ * env_map_vatopa - implementation\r
+ *\r
+ * @param address\r
+ */\r
+unsigned long env_map_vatopa(void *address)\r
+{\r
+ return ((((unsigned long)address & (~( 0x0fff << 20))) | (0x08 << 24)));\r
+}\r
+\r
+/**\r
+ * env_map_patova - implementation\r
+ *\r
+ * @param address\r
+ */\r
+void *env_map_patova(unsigned long address)\r
+{\r
+ return ((void *)address);\r
+}\r
+\r
+/**\r
+ * env_create_mutex\r
+ *\r
+ * Creates a mutex with initial state being unlocked.\r
+ *\r
+ */\r
+int env_create_mutex(void **lock, int count)\r
+{\r
+\r
+ NU_SEMAPHORE *sem = NU_NULL;\r
+ NU_MEMORY_POOL *pool_ptr = NU_NULL;\r
+ STATUS status;\r
+\r
+ /* Get system cached memory pools pointer */\r
+ status = NU_System_Memory_Get(&pool_ptr, NU_NULL);\r
+ if (status == NU_SUCCESS)\r
+ {\r
+ /* Allocate requested memory from Nucleus semaphore object. */\r
+ status = NU_Allocate_Memory(pool_ptr, (VOID**)&sem,\r
+ sizeof(NU_SEMAPHORE), NU_NO_SUSPEND);\r
+ if (status == NU_SUCCESS){\r
+ memset(sem , 0x00 , sizeof(NU_SEMAPHORE));\r
+ status = NU_Create_Semaphore(sem, "Env_Sem", count, NU_PRIORITY);\r
+ if ( status == NU_SUCCESS){\r
+ *lock = sem;\r
+ }\r
+ }\r
+ }\r
+\r
+ return status;\r
+}\r
+\r
+/**\r
+ * env_delete_mutex\r
+ *\r
+ * Deletes the given lock\r
+ *\r
+ */\r
+void env_delete_mutex(void *lock)\r
+{\r
+ if (lock)\r
+ {\r
+ NU_Delete_Semaphore((NU_SEMAPHORE *)lock);\r
+ NU_Deallocate_Memory(lock);\r
+ }\r
+}\r
+\r
+/**\r
+ * env_lock_mutex\r
+ *\r
+ * Tries to acquire the lock, if lock is not available then call to\r
+ * this function will suspend.\r
+ */\r
+void env_lock_mutex(void *lock)\r
+{\r
+ NU_Obtain_Semaphore((NU_SEMAPHORE *)lock, NU_SUSPEND);\r
+}\r
+\r
+/**\r
+ * env_unlock_mutex\r
+ *\r
+ * Releases the given lock.\r
+ */\r
+\r
+void env_unlock_mutex(void *lock)\r
+{\r
+ NU_Release_Semaphore((NU_SEMAPHORE*)lock);\r
+}\r
+\r
+/**\r
+ * env_create_sync_lock\r
+ *\r
+ * Creates a synchronization lock primitive. It is required\r
+ * when signal is has to be sent from the interrupt context\r
+ * to main thread context.\r
+ *\r
+ */\r
+int env_create_sync_lock(void **lock , int state){\r
+ NU_SEMAPHORE *sem = NU_NULL;\r
+ NU_MEMORY_POOL *pool_ptr = NU_NULL;\r
+ STATUS status;\r
+\r
+ /* Get system cached memory pools pointer */\r
+ status = NU_System_Memory_Get(&pool_ptr, NU_NULL);\r
+ if (status == NU_SUCCESS)\r
+ {\r
+ /* Allocate requested memory from Nucleus semaphore object. */\r
+ status = NU_Allocate_Memory(pool_ptr, (VOID**)&sem,\r
+ sizeof(NU_SEMAPHORE), NU_NO_SUSPEND);\r
+ if (status == NU_SUCCESS){\r
+ memset(sem , 0x00 , sizeof(NU_SEMAPHORE));\r
+ status = NU_Create_Semaphore(sem, "Env_Sem", state, NU_PRIORITY);\r
+ if ( status == NU_SUCCESS){\r
+ *lock = sem;\r
+ }\r
+ }\r
+ }\r
+\r
+ return status;\r
+}\r
+\r
+/**\r
+ * env_delete_sync_lock\r
+ *\r
+ * Deletes the given lock\r
+ *\r
+ */\r
+void env_delete_sync_lock(void *lock)\r
+{\r
+ if (lock)\r
+ {\r
+ NU_Delete_Semaphore((NU_SEMAPHORE *)lock);\r
+ NU_Deallocate_Memory(lock);\r
+ }\r
+}\r
+\r
+/**\r
+ * env_acquire_sync_lock\r
+ *\r
+ * Tries to acquire the lock, if lock is not available then call to\r
+ * this function will suspend.\r
+ */\r
+void env_acquire_sync_lock(void *lock)\r
+{\r
+ NU_Obtain_Semaphore((NU_SEMAPHORE *)lock, NU_SUSPEND);\r
+}\r
+\r
+/**\r
+ * env_release_sync_lock\r
+ *\r
+ * Releases the given lock.\r
+ */\r
+void env_release_sync_lock(void *lock)\r
+{\r
+ NU_Release_Semaphore((NU_SEMAPHORE*)lock);\r
+}\r
+/**\r
+ * env_sleep_msec\r
+ *\r
+ * Suspends the calling thread for given time , in msecs.\r
+ */\r
+\r
+void env_sleep_msec(int num_msec)\r
+{\r
+ NU_Sleep(num_msec/10);\r
+}\r
+\r
+/**\r
+ * env_disable_interrupts\r
+ *\r
+ * Disables system interrupts\r
+ *\r
+ */\r
+void env_disable_interrupts()\r
+{\r
+ Old_Level = NU_Local_Control_Interrupts(NU_DISABLE_INTERRUPTS);\r
+}\r
+\r
+/**\r
+ * env_restore_interrupts\r
+ *\r
+ * Enables system interrupts\r
+ *\r
+ */\r
+void env_restore_interrupts()\r
+{\r
+ NU_Local_Control_Interrupts(Old_Level);\r
+}\r
+\r
+/**\r
+ * env_register_isr\r
+ *\r
+ * Registers interrupt handler for the given interrupt vector.\r
+ *\r
+ */\r
+void env_register_isr(int vector , void *data ,\r
+ void (*isr)(int vector , void *data))\r
+{\r
+ VOID (*old_lisr)(INT);\r
+\r
+ env_disable_interrupts();\r
+\r
+ if(Intr_Count < ISR_COUNT)\r
+ {\r
+ /* Save interrupt data */\r
+ isr_table[Intr_Count].vector = vector + ESAL_AR_INT_VECTOR_ID_DELIMITER;\r
+ isr_table[Intr_Count].data = data;\r
+ isr_table[Intr_Count++].isr = isr;\r
+\r
+ /* Register LISR */\r
+ NU_Register_LISR(vector + ESAL_AR_INT_VECTOR_ID_DELIMITER, NU_Env_LISR, &old_lisr);\r
+ }\r
+\r
+ env_restore_interrupts();\r
+\r
+}\r
+\r
+/**\r
+ * env_enable_interrupt\r
+ *\r
+ * Enables the given interrupt\r
+ *\r
+ * @param vector - interrupt vector number\r
+ * @param priority - interrupt priority\r
+ * @param polarity - interrupt polarity\r
+ */\r
+\r
+void env_enable_interrupt(unsigned int vector , unsigned int priority ,\r
+ unsigned int polarity)\r
+{\r
+ int idx;\r
+\r
+ env_disable_interrupts();\r
+\r
+ for(idx = 0 ; idx < ISR_COUNT ; idx++)\r
+ {\r
+ if(isr_table[idx].vector == vector + ESAL_AR_INT_VECTOR_ID_DELIMITER)\r
+ {\r
+ isr_table[idx].priority = priority;\r
+ isr_table[idx].type = polarity;\r
+ (VOID) ESAL_GE_INT_Enable(vector + ESAL_AR_INT_VECTOR_ID_DELIMITER, polarity, priority );\r
+ break;\r
+ }\r
+ }\r
+\r
+ env_restore_interrupts();\r
+}\r
+\r
+/**\r
+ * env_disable_interrupt\r
+ *\r
+ * Disables the given interrupt\r
+ *\r
+ * @param vector - interrupt vector number\r
+ */\r
+\r
+void env_disable_interrupt(unsigned int vector)\r
+{\r
+ ESAL_GE_INT_Disable(vector);\r
+}\r
+\r
+/**\r
+ * env_map_memory\r
+ *\r
+ * Enables memory mapping for given memory region.\r
+ *\r
+ * @param pa - physical address of memory\r
+ * @param va - logical address of memory\r
+ * @param size - memory size\r
+ * param flags - flags for cache/uncached and access type\r
+ */\r
+\r
+void env_map_memory(unsigned int pa, unsigned int va, unsigned int size,\r
+ unsigned int flags)\r
+{\r
+ int mem_type = ESAL_RAM;\r
+ int cache_type = ESAL_NOCACHE;\r
+\r
+ if ((flags & (0x0f << 4 )) == MEM_MAPPED)\r
+ {\r
+ mem_type = ESAL_MEM_MAPPED;\r
+ }\r
+\r
+ if ((flags & 0x0f) == WB_CACHE) {\r
+ cache_type = ESAL_WRITEBACK;\r
+ } else if ((flags & 0x0f) == WT_CACHE) {\r
+ cache_type = ESAL_WRITETHROUGH;\r
+ } else {\r
+ cache_type = ESAL_NOCACHE;\r
+ }\r
+\r
+ ESAL_CO_MEM_Region_Setup(0, va, pa, size, mem_type, cache_type , 0);\r
+}\r
+\r
+/**\r
+ * \r
+ * env_get_timestamp\r
+ *\r
+ * Returns a 64 bit time stamp.\r
+ *\r
+ *\r
+ */\r
+unsigned long long env_get_timestamp(void) {\r
+\r
+ return NU_Get_Time_Stamp();\r
+}\r
+/**\r
+ * env_disable_cache\r
+ * \r
+ * Disables system caches.\r
+ *\r
+ */\r
+\r
+void env_disable_cache() {\r
+ ESAL_CO_MEM_DCACHE_ALL_FLUSH_INVAL();\r
+ ESAL_CO_MEM_ICACHE_ALL_INVALIDATE();\r
+ ESAL_CO_MEM_CACHE_DISABLE();\r
+}\r
+\r
+/***********************************************************************\r
+ * *\r
+ * * FUNCTION\r
+ * *\r
+ * * Env_Task_Entry\r
+ * *\r
+ * * DESCRIPTION\r
+ * *\r
+ * * Entry function for the Nucleus Environment task.\r
+ *\r
+ * ***********************************************************************/\r
+static VOID NU_Env_Task_Entry(UNSIGNED argc, VOID *argv)\r
+{\r
+ STATUS status;\r
+ UNSIGNED size;\r
+ struct isr_info intr;\r
+\r
+ while (1)\r
+ {\r
+ /* Wait for the interrupt */\r
+ status = NU_Receive_From_Queue(&NU_Env_Queue, &intr,\r
+ MSG_SIZE, &size,NU_SUSPEND);\r
+ if(status == NU_SUCCESS)\r
+ {\r
+ intr.isr(intr.vector - ESAL_AR_INT_VECTOR_ID_DELIMITER, intr.data);\r
+ }\r
+ }\r
+}\r
+\r
+static void NU_Env_HISR_Entry()\r
+{\r
+ struct isr_info *info;\r
+ NU_Receive_From_HISR_Queue(&NU_Env_HISR, (VOID **)&info);\r
+ NU_Send_To_Queue(&NU_Env_Queue,info,MSG_SIZE,NU_NO_SUSPEND);\r
+ env_enable_interrupt(info->vector , info->priority, info->type);\r
+}\r
+\r
+static VOID NU_Env_LISR(int vector)\r
+{\r
+ int idx;\r
+ env_disable_interrupt(vector);\r
+\r
+ for(idx = 0 ; idx < ISR_COUNT ; idx++)\r
+ {\r
+ if(isr_table[idx].vector == vector)\r
+ {\r
+ NU_Send_To_HISR_Queue(&NU_Env_HISR , &isr_table[idx], NU_ACTIVATE_HISR);\r
+ break;\r
+ }\r
+ }\r
+}\r
+\r
+#endif /* (ENV == NU_ENV) */\r
diff --git a/porting/zc702evk/platform.c b/porting/zc702evk/platform.c
--- /dev/null
@@ -0,0 +1,132 @@
+/*\r
+ * Copyright (c) 2014, Mentor Graphics Corporation\r
+ * All rights reserved.\r
+ *\r
+ * Redistribution and use in source and binary forms, with or without\r
+ * modification, are permitted provided that the following conditions are met:\r
+ *\r
+ * 1. Redistributions of source code must retain the above copyright notice,\r
+ * this list of conditions and the following disclaimer.\r
+ * 2. Redistributions in binary form must reproduce the above copyright notice,\r
+ * this list of conditions and the following disclaimer in the documentation\r
+ * and/or other materials provided with the distribution.\r
+ * 3. Neither the name of Mentor Graphics Corporation nor the names of its\r
+ * contributors may be used to endorse or promote products derived from this\r
+ * software without specific prior written permission.\r
+ *\r
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"\r
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\r
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\r
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE\r
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\r
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\r
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\r
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\r
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\r
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\r
+ * POSSIBILITY OF SUCH DAMAGE.\r
+ */\r
+\r
+/**************************************************************************\r
+ * FILE NAME\r
+ *\r
+ * platform.c\r
+ *\r
+ * DESCRIPTION\r
+ *\r
+ * This file is Nucleus Implementation of IPC hardware layer interface\r
+ * for Xilinx Zynq ZC702EVK platform.\r
+ *\r
+ **************************************************************************/\r
+\r
+#include "platform.h"\r
+\r
+/*--------------------------- Globals ---------------------------------- */\r
+struct hil_platform_ops proc_ops = {\r
+ .enable_interrupt = _enable_interrupt,\r
+ .notify = _notify,\r
+ .boot_cpu = _boot_cpu,\r
+ .shutdown_cpu = _shutdown_cpu,\r
+};\r
+\r
+int _enable_interrupt(struct proc_vring *vring_hw) {\r
+\r
+ /* Register ISR*/\r
+ env_register_isr(vring_hw->intr_info.vect_id, vring_hw, platform_isr);\r
+\r
+ /* Enable the interrupts */\r
+ env_enable_interrupt(vring_hw->intr_info.vect_id,\r
+ vring_hw->intr_info.priority,\r
+ vring_hw->intr_info.trigger_type);\r
+ return 0;\r
+}\r
+\r
+void _notify(int cpu_id, struct proc_intr *intr_info) {\r
+\r
+ unsigned long mask = 0;\r
+\r
+ mask = ((1 << (GIC_CPU_ID_BASE + cpu_id)) | (intr_info->vect_id))\r
+ & (GIC_SFI_TRIG_CPU_MASK | GIC_SFI_TRIG_INTID_MASK);\r
+\r
+ HIL_MEM_WRITE32((GIC_DIST_BASE + GIC_DIST_SOFTINT), mask);\r
+}\r
+\r
+extern char zynq_trampoline;\r
+extern char zynq_trampoline_jump;\r
+extern char zynq_trampoline_end;\r
+\r
+int _boot_cpu(int cpu_id, unsigned int load_addr) {\r
+ unsigned int reg;\r
+ unsigned int tramp_size;\r
+ unsigned int tramp_addr = 0;\r
+\r
+ if (load_addr) {\r
+ tramp_size = zynq_trampoline_end - zynq_trampoline;\r
+ if ((load_addr < tramp_size) || (load_addr & 0x3)) {\r
+ return -1;\r
+ }\r
+\r
+ tramp_size = &zynq_trampoline_jump - &zynq_trampoline;\r
+\r
+ /*\r
+ * Trampoline code is copied to address 0 from where remote core is expected to\r
+ * fetch first instruction after reset.If master is using the address 0 then\r
+ * this mem copy will screwed the system. It is user responsibility to not\r
+ * copy trampoline code in such cases.\r
+ *\r
+ */\r
+ env_memcpy((char *)tramp_addr, &zynq_trampoline, tramp_size);\r
+ /* Write image address at the word reserved at the trampoline end */\r
+ HIL_MEM_WRITE32((char *)(tramp_addr + tramp_size), load_addr);\r
+ }\r
+\r
+ unlock_slcr();\r
+\r
+ reg = HIL_MEM_READ32(ESAL_DP_SLCR_BASE + A9_CPU_SLCR_RESET_CTRL);\r
+ reg &= ~(A9_CPU_SLCR_CLK_STOP << cpu_id);\r
+ HIL_MEM_WRITE32(ESAL_DP_SLCR_BASE + A9_CPU_SLCR_RESET_CTRL, reg);\r
+ /* De-assert reset signal and start clock to start the core */\r
+ reg &= ~(A9_CPU_SLCR_RST << cpu_id);\r
+ HIL_MEM_WRITE32(ESAL_DP_SLCR_BASE + A9_CPU_SLCR_RESET_CTRL, reg);\r
+\r
+ lock_slcr();\r
+\r
+ return 0;\r
+}\r
+\r
+void _shutdown_cpu(int cpu_id) {\r
+ unsigned int reg;\r
+\r
+ unlock_slcr();\r
+\r
+ reg = HIL_MEM_READ32(ESAL_DP_SLCR_BASE + A9_CPU_SLCR_RESET_CTRL);\r
+ /* Assert reset signal and stop clock to halt the core */\r
+ reg |= (A9_CPU_SLCR_CLK_STOP | A9_CPU_SLCR_RST) << cpu_id;\r
+ HIL_MEM_WRITE32(ESAL_DP_SLCR_BASE + A9_CPU_SLCR_RESET_CTRL, reg);\r
+\r
+ lock_slcr();\r
+}\r
+\r
+void platform_isr(int vect_id, void *data) {\r
+ hil_isr(((struct proc_vring *) data));\r
+}\r
diff --git a/porting/zc702evk/platform.h b/porting/zc702evk/platform.h
--- /dev/null
@@ -0,0 +1,124 @@
+/*\r
+ * Copyright (c) 2014, Mentor Graphics Corporation\r
+ * All rights reserved.\r
+ *\r
+ * Redistribution and use in source and binary forms, with or without\r
+ * modification, are permitted provided that the following conditions are met:\r
+ *\r
+ * 1. Redistributions of source code must retain the above copyright notice,\r
+ * this list of conditions and the following disclaimer.\r
+ * 2. Redistributions in binary form must reproduce the above copyright notice,\r
+ * this list of conditions and the following disclaimer in the documentation\r
+ * and/or other materials provided with the distribution.\r
+ * 3. Neither the name of Mentor Graphics Corporation nor the names of its\r
+ * contributors may be used to endorse or promote products derived from this\r
+ * software without specific prior written permission.\r
+ *\r
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"\r
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\r
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\r
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE\r
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\r
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\r
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\r
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\r
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\r
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\r
+ * POSSIBILITY OF SUCH DAMAGE.\r
+ */\r
+\r
+#ifndef PLATFORM_H_\r
+#define PLATFORM_H_\r
+\r
+#include <stdio.h>\r
+#include "../common/hil/hil.h"\r
+\r
+/* ------------------------- Macros --------------------------*/\r
+#define ESAL_DP_SLCR_BASE 0xF8000000\r
+#define PERIPH_BASE 0xF8F00000\r
+#define GIC_DIST_BASE (PERIPH_BASE + 0x00001000)\r
+#define GIC_DIST_SOFTINT 0xF00\r
+#define GIC_SFI_TRIG_CPU_MASK 0x00FF0000\r
+#define GIC_SFI_TRIG_SATT_MASK 0x00008000\r
+#define GIC_SFI_TRIG_INTID_MASK 0x0000000F\r
+#define GIC_CPU_ID_BASE (1 << 4)\r
+#define A9_CPU_SLCR_RESET_CTRL 0x244\r
+#define A9_CPU_SLCR_CLK_STOP (1 << 4)\r
+#define A9_CPU_SLCR_RST (1 << 0)\r
+\r
+#define unlock_slcr() HIL_MEM_WRITE32(ESAL_DP_SLCR_BASE + 0x08, 0xDF0DDF0D)\r
+#define lock_slcr() HIL_MEM_WRITE32(ESAL_DP_SLCR_BASE + 0x04, 0x767B767B)\r
+\r
+\r
+/* L2Cpl310 L2 cache controller base address. */\r
+#define HIL_PL130_BASE 0xF8F02000\r
+\r
+/********************/\r
+/* Register offsets */\r
+/********************/\r
+\r
+#define HIL_PL130_INVALLINE 0x770\r
+#define HIL_PL130_CLEANINVLINE 0x7F0\r
+\r
+\r
+#define HIL_PA_SBZ_MASK ~(HIL_CACHE_LINE_SIZE - 1UL)\r
+#define HIL_CACHE_LINE_SIZE 32\r
+#define HIL_CACHE_INV_ALL_WAYS 0xFF\r
+#define HIL_CACHE_UNLOCK_ALL_WAYS 0xFFFF0000\r
+#define HIL_CACHE_CLEAR_INT 0x1FF\r
+\r
+\r
+/* This macro invalidates all Data cache for the specified address\r
+ range at the processor level. */\r
+#define HIL_L2CACHE_INVALIDATE(addr, size) \\r
+ { \\r
+ \\r
+ unsigned int addr_v = (unsigned int)addr & HIL_PA_SBZ_MASK; \\r
+ unsigned int l_size = 0; \\r
+ unsigned int align_size = ((unsigned int)size + ((unsigned int)addr & \\r
+ (HIL_CACHE_LINE_SIZE-1UL))); \\r
+ \\r
+ do \\r
+ { \\r
+ /* Invalidate cache line by PA. */ \\r
+ HIL_MEM_WRITE32(HIL_PL130_BASE + HIL_PL130_INVALLINE, addr_v); \\r
+ \\r
+ /* Move to the next way */ \\r
+ addr_v += HIL_CACHE_LINE_SIZE; \\r
+ l_size += HIL_CACHE_LINE_SIZE; \\r
+ \\r
+ } while (l_size < align_size); \\r
+ }\r
+\r
+\r
+/* This macro flushes all data cache to physical memory (writeback cache)\r
+ for the given address range, then invalidates all data cache entries\r
+ at the processor level. */\r
+#define HIL_L2CACHE_FLUSH_INVAL(addr, size) \\r
+ { \\r
+ volatile unsigned int addr_v=(unsigned int)addr & HIL_PA_SBZ_MASK; \\r
+ volatile unsigned int align_size = ((unsigned int)size + ((unsigned int)addr & \\r
+ (HIL_CACHE_LINE_SIZE-1UL))); \\r
+ volatile unsigned int addr_end = addr_v + align_size; \\r
+ \\r
+ do \\r
+ { \\r
+ /* Invalidate cache line by PA. */ \\r
+ HIL_MEM_WRITE32(HIL_PL130_BASE + HIL_PL130_CLEANINVLINE, addr_v); \\r
+ \\r
+ asm volatile(" DSB"); \\r
+ \\r
+ /* Move to the next line. */ \\r
+ addr_v += HIL_CACHE_LINE_SIZE; \\r
+ \\r
+ } while (addr_v < addr_end); \\r
+ }\r
+\r
+\r
+int _enable_interrupt(struct proc_vring *vring_hw);\r
+void _notify(int cpu_id, struct proc_intr *intr_info);\r
+int _boot_cpu(int cpu_id, unsigned int load_addr);\r
+void _shutdown_cpu(int cpu_id);\r
+void platform_isr(int vect_id, void *data);\r
+\r
+#endif /* PLATFORM_H_ */\r
diff --git a/porting/zc702evk/platform_info.c b/porting/zc702evk/platform_info.c
--- /dev/null
@@ -0,0 +1,405 @@
+/*\r
+ * Copyright (c) 2014, Mentor Graphics Corporation\r
+ * All rights reserved.\r
+ *\r
+ * Redistribution and use in source and binary forms, with or without\r
+ * modification, are permitted provided that the following conditions are met:\r
+ *\r
+ * 1. Redistributions of source code must retain the above copyright notice,\r
+ * this list of conditions and the following disclaimer.\r
+ * 2. Redistributions in binary form must reproduce the above copyright notice,\r
+ * this list of conditions and the following disclaimer in the documentation\r
+ * and/or other materials provided with the distribution.\r
+ * 3. Neither the name of Mentor Graphics Corporation nor the names of its\r
+ * contributors may be used to endorse or promote products derived from this\r
+ * software without specific prior written permission.\r
+ *\r
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"\r
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\r
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\r
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE\r
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\r
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\r
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\r
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\r
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\r
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\r
+ * POSSIBILITY OF SUCH DAMAGE.\r
+ */\r
+\r
+/**************************************************************************\r
+ * FILE NAME\r
+ *\r
+ * platform_info.c\r
+ *\r
+ * DESCRIPTION\r
+ *\r
+ * This file implements APIs to get platform specific\r
+ * information for OpenAMP. \r
+ *\r
+ **************************************************************************/\r
+\r
+#include "platform.h"\r
+\r
+/* Reference implementation that show cases platform_get_cpu_info and \r
+ platform_get_for_firmware API implementation for Nucleus RTOS\r
+ and Bare metal environments */\r
+\r
+#if (ENV == NU_ENV)\r
+\r
+#include "nucleus.h"\r
+#include "kernel/nu_kernel.h"\r
+#include "services/nu_services.h"\r
+\r
+char base_key[] = "/zc702evk/remote_proc";\r
+\r
+extern struct hil_platform_ops proc_ops;\r
+\r
+/**\r
+ *\r
+ * platform_get_processor_info\r
+ *\r
+ * This function gets platform specific configuration parameters\r
+ * from the Nucleus platform definition file.\r
+ *\r
+ */\r
+int platform_get_processor_info(struct hil_proc *proc, int cpu_id) {\r
+ STATUS reg_status = NU_SUCCESS;\r
+ struct proc_shm *sb_info;\r
+ struct proc_intr *intr_info;\r
+ UINT32 num_vring;\r
+ UINT32 temp32;\r
+ UINT8 temp8;\r
+ CHAR key[REG_MAX_KEY_LENGTH];\r
+ CHAR reg_path[REG_MAX_KEY_LENGTH];\r
+ INT i;\r
+ struct hil_proc *rproc = proc;\r
+ struct proc_vdev *hil_vdev;\r
+ CHAR ch_name[32];\r
+ BOOLEAN dev_found = NU_FALSE;\r
+\r
+ if (cpu_id == HIL_RSVD_CPU_ID) {\r
+ sprintf(key, "%s%i", base_key, 0);\r
+ dev_found = NU_TRUE;\r
+ } else {\r
+ for (i = 0; (i < HIL_MAX_CORES) && (reg_status == NU_SUCCESS); i++) {\r
+ sprintf(key, "%s%i", base_key, i);\r
+ reg_status = REG_Get_UINT32_Value(key, "/dev_settings/cpu_id",\r
+ &temp32);\r
+ if (reg_status == NU_SUCCESS) {\r
+ if (temp32 == cpu_id) {\r
+ dev_found = NU_TRUE;\r
+ break;\r
+ }\r
+ }\r
+ }\r
+ }\r
+\r
+ if (!dev_found) {\r
+ return -1;\r
+ }\r
+ /* Get IPC device level features */\r
+ reg_status = REG_Get_UINT32_Value(key, "/dev_settings/cpu_id", &temp32);\r
+\r
+ if (reg_status == NU_SUCCESS) {\r
+ /* In case of reserved cpu id as parameter get the cpu id from the platform file and\r
+ * dont compare it with the given CPU ID.\r
+ */\r
+\r
+ rproc->cpu_id = temp32;\r
+ reg_status = REG_Get_UINT8_Value(key, "/dev_settings/num_chnls",\r
+ &temp8);\r
+ if (reg_status == NU_SUCCESS) {\r
+ rproc->num_chnls = temp8;\r
+ }\r
+ }\r
+\r
+ /* Get shared memory information - provides buffer that are used in vrings */\r
+ reg_status = REG_Get_UINT32_Value(key, "/shared_buffers/start_addr",\r
+ &temp32);\r
+ if (reg_status == NU_SUCCESS) {\r
+ sb_info = &rproc->sh_buff;\r
+ sb_info->start_addr = (void *) temp32;\r
+ reg_status = REG_Get_UINT32_Value(key, "/shared_buffers/size", &temp32);\r
+ if (reg_status == NU_SUCCESS) {\r
+ sb_info->size = temp32;\r
+ }\r
+ }\r
+\r
+ /* Get channels info */\r
+ for (i = 0; (i < rproc->num_chnls) && (reg_status == NU_SUCCESS); i++) {\r
+ sprintf(reg_path, "%s/%s%i", key, "channel", i);\r
+ reg_status = REG_Get_String_Value(reg_path, "/id", ch_name, 32);\r
+ if (reg_status == NU_SUCCESS) {\r
+ strncpy(rproc->chnls[i].name, ch_name,\r
+ sizeof(rproc->chnls[i].name));\r
+ }\r
+ }\r
+\r
+ /* Get vring attributes */\r
+ if (reg_status == NU_SUCCESS) {\r
+ hil_vdev = &rproc->vdev;\r
+ reg_status = REG_Get_UINT32_Value(key, "/vrings/num_vrings",\r
+ &num_vring);\r
+ if (reg_status == NU_SUCCESS) {\r
+ if (num_vring > (HIL_MAX_NUM_VRINGS)) {\r
+ reg_status = REG_TYPE_ERROR;\r
+ } else {\r
+ hil_vdev->num_vrings = num_vring;\r
+ }\r
+ for (i = 0; (reg_status == NU_SUCCESS) && (i < num_vring); i++) {\r
+ intr_info = &hil_vdev->vring_info[i].intr_info;\r
+ reg_status = REG_Get_UINT32_Value(key, "/vrings/ipi_priority",\r
+ &temp32);\r
+ if (reg_status == NU_SUCCESS) {\r
+ intr_info->priority = temp32;\r
+ reg_status = REG_Get_UINT32_Value(key,\r
+ "/vrings/ipi_trigger_type", &temp32);\r
+\r
+ if (reg_status == NU_SUCCESS) {\r
+ intr_info->trigger_type =\r
+ (ESAL_GE_INT_TRIG_TYPE) temp32;\r
+ if (reg_status == NU_SUCCESS) {\r
+ sprintf(reg_path, "%s/%s%i", key, "vrings/ipi", i);\r
+ reg_status = REG_Get_UINT32(reg_path , &temp32);\r
+ if (reg_status == NU_SUCCESS) {\r
+ intr_info->vect_id =\r
+ temp32 - ESAL_AR_INT_VECTOR_ID_DELIMITER;\r
+ }\r
+ }\r
+ }\r
+ }\r
+ }\r
+ }\r
+ }\r
+\r
+ if (reg_status == NU_SUCCESS) {\r
+ proc->ops = &proc_ops;\r
+ }\r
+\r
+ return reg_status;\r
+}\r
+\r
+int platform_get_processor_for_fw(char *fw_name) {\r
+ STATUS reg_status = NU_SUCCESS;\r
+ UINT32 temp32;\r
+ CHAR key[REG_MAX_KEY_LENGTH];\r
+ CHAR reg[REG_MAX_KEY_LENGTH];\r
+ CHAR fw_name_loc[32];\r
+ INT i, j;\r
+ UINT32 num_fws;\r
+\r
+ /* Get channels info */\r
+ for (i = 0; (i < HIL_MAX_CORES) && (reg_status == NU_SUCCESS); i++) {\r
+ sprintf(key, "%s%i", base_key, i);\r
+ reg_status = REG_Get_UINT32_Value(key, "/dev_settings/num_fws",\r
+ &num_fws);\r
+ for (j = 0; j < num_fws; j++) {\r
+ sprintf(reg, "%s%s%i", key, "/dev_settings/fw_name", j);\r
+ reg_status = REG_Get_String(reg, fw_name_loc ,32);\r
+ if (reg_status == NU_SUCCESS) {\r
+ if (!strncmp(fw_name_loc, fw_name, 32)) {\r
+ reg_status = REG_Get_UINT32_Value(key,\r
+ "/dev_settings/cpu_id", &temp32);\r
+ if (reg_status == NU_SUCCESS) {\r
+ return temp32;\r
+ }\r
+ }\r
+ }\r
+ }\r
+ }\r
+\r
+ return -1;\r
+}\r
+\r
+#elif (ENV == BM_ENV)\r
+\r
+extern struct hil_platform_ops proc_ops;\r
+\r
+/* IPC Device parameters */\r
+#define SHM_ADDR (void *)0x08008000\r
+#define SHM_SIZE 0x00200000\r
+#define VRING0_IPI_VECT 6\r
+#define VRING1_IPI_VECT 3\r
+#define MASTER_CPU_ID 0\r
+#define REMOTE_CPU_ID 1\r
+\r
+/**\r
+ * This array provdes defnition of CPU nodes for master and remote\r
+ * context. It contains two nodes beacuse the same file is intended\r
+ * to use with both master and remote configurations. On zynq platform\r
+ * only one node defintion is required for master/remote as there\r
+ * are only two cores present in the platform.\r
+ *\r
+ * Only platform specific info is populated here. Rest of information
+ * is obtained during resource table parsing.The platform specific\r
+ * information includes;\r
+ *\r
+ * -CPU ID\r
+ * -Shared Memory\r
+ * -Interrupts\r
+ * -Channel info.\r
+ *\r
+ * Although the channel info is not platform specific information\r
+ * but it is conveneient to keep it in HIL so that user can easily\r
+ * provide it without modifying the generic part.\r
+ *\r
+ * It is good idea to define hil_proc structure with platform\r
+ * specific fields populated as this can be easily copied to hil_proc\r
+ * structure passed as parameter in platform_get_processor_info. The\r
+ * other option is to populate the required structures individually\r
+ * and copy them one by one to hil_proc structure in platform_get_processor_info\r
+ * function. The first option is adopted here.\r
+ *\r
+ *\r
+ * 1) First node in the array is intended for the remote contexts and it\r
+ * defines Master CPU ID, shared memory, interrupts info, number of channels\r
+ * and there names. This node defines only one channel\r
+ * "rpmsg-openamp-demo-channel".\r
+ *\r
+ * 2)Second node is required by the master and it defines remote CPU ID,\r
+ * shared memory and interrupts info. In general no channel info is required by the\r
+ * Master node, however in baremetal/Nucleus master and linux remote case the linux\r
+ * rpmsg bus driver behaves as master so the rpmsg driver on linux side still needs\r
+ * channel info. This information is not required by the masters for Nucleus\r
+ * and baremetal remotes. \r
+ *\r
+ */\r
+struct hil_proc proc_table []=\r
+{\r
+\r
+ /* CPU node for remote context */\r
+ {\r
+ /* CPU ID of master */\r
+ MASTER_CPU_ID,\r
+\r
+ /* Shared memory info - Last field is not used currently */\r
+ {\r
+ SHM_ADDR, SHM_SIZE, 0x00\r
+ },\r
+\r
+ /* VirtIO device info */\r
+ {\r
+ /* Leave these three fields empty as these are obtained from rsc\r
+ * table.\r
+ */\r
+ 0, 0, 0,\r
+\r
+ /* Vring info */\r
+ {\r
+\r
+ {\r
+ /* Provide only vring interrupts info here. Other fields are\r
+ * obtained from the resource table so leave them empty.\r
+ */\r
+ NULL, NULL, 0, 0,\r
+ {\r
+ VRING0_IPI_VECT,0x1006,1,NULL\r
+ }\r
+ },\r
+ {\r
+ NULL, NULL, 0, 0,\r
+ {\r
+ VRING1_IPI_VECT,0x1006,1,NULL\r
+ }\r
+ }\r
+ }\r
+ },\r
+\r
+ /* Number of RPMSG channels */\r
+ 1,\r
+\r
+ /* RPMSG channel info - Only channel name is expected currently */\r
+ {\r
+ {"rpmsg-openamp-demo-channel"}\r
+ },\r
+\r
+ /* HIL platform ops table. */\r
+ &proc_ops,\r
+\r
+ /* Next three fields are for future use only */\r
+ 0,\r
+ 0,\r
+ NULL\r
+ },\r
+\r
+ /* CPU node for remote context */\r
+ {\r
+ /* CPU ID of remote */\r
+ REMOTE_CPU_ID,\r
+\r
+ /* Shared memory info - Last field is not used currently */\r
+ {\r
+ SHM_ADDR, SHM_SIZE, 0x00\r
+ },\r
+\r
+ /* VirtIO device info */\r
+ {\r
+ 0, 0, 0,\r
+ {\r
+ {\r
+ /* Provide vring interrupts info here. Other fields are obtained\r
+ * from the rsc table so leave them empty.\r
+ */\r
+ NULL, NULL, 0, 0,\r
+ {\r
+ VRING0_IPI_VECT,0x1006,1\r
+ }\r
+ },\r
+ {\r
+ NULL, NULL, 0, 0,\r
+ {\r
+ VRING1_IPI_VECT,0x1006,1\r
+ }\r
+ }\r
+ }\r
+ },\r
+\r
+ /* Number of RPMSG channels */\r
+ 1,\r
+\r
+ /* RPMSG channel info - Only channel name is expected currently */\r
+ {\r
+ {"rpmsg-openamp-demo-channel"}\r
+ },\r
+\r
+ /* HIL platform ops table. */\r
+ &proc_ops,\r
+\r
+ /* Next three fields are for future use only */\r
+ 0,\r
+ 0,\r
+ NULL\r
+ }\r
+};\r
+\r
+/**\r
+ * platform_get_processor_info\r
+ *\r
+ * Copies the target info from the user defined data structures to\r
+ * HIL proc data structure.In case of remote contexts this function\r
+ * is called with the reserved CPU ID HIL_RSVD_CPU_ID, because for\r
+ * remotes there is only one master.\r
+ *\r
+ * @param proc - HIL proc to populate\r
+ * @param cpu_id - CPU ID\r
+ *\r
+ * return - status of execution\r
+ */\r
+int platform_get_processor_info(struct hil_proc *proc , int cpu_id) {\r
+ int idx;\r
+ for(idx = 0; idx < sizeof(proc_table)/sizeof(struct hil_proc); idx++) {\r
+ if((cpu_id == HIL_RSVD_CPU_ID) || (proc_table[idx].cpu_id == cpu_id) ) {\r
+ env_memcpy(proc,&proc_table[idx], sizeof(struct hil_proc));\r
+ return 0;\r
+ }\r
+ }\r
+ return -1;\r
+}\r
+\r
+int platform_get_processor_for_fw(char *fw_name) {\r
+\r
+ return 1;\r
+}\r
+#endif /* #if (ENV == NU_ENV) */\r
+\r
diff --git a/porting/zc702evk/zynq_trampoline.S b/porting/zc702evk/zynq_trampoline.S
--- /dev/null
@@ -0,0 +1,39 @@
+/*\r
+ * Copyright (c) 2014, Mentor Graphics Corporation\r
+ * All rights reserved.\r
+ *\r
+ * Redistribution and use in source and binary forms, with or without\r
+ * modification, are permitted provided that the following conditions are met:\r
+ *\r
+ * 1. Redistributions of source code must retain the above copyright notice,\r
+ * this list of conditions and the following disclaimer.\r
+ * 2. Redistributions in binary form must reproduce the above copyright notice,\r
+ * this list of conditions and the following disclaimer in the documentation\r
+ * and/or other materials provided with the distribution.\r
+ * 3. Neither the name of Mentor Graphics Corporation nor the names of its\r
+ * contributors may be used to endorse or promote products derived from this\r
+ * software without specific prior written permission.\r
+ *\r
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"\r
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\r
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\r
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE\r
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\r
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\r
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\r
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\r
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\r
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\r
+ * POSSIBILITY OF SUCH DAMAGE.\r
+ */\r
+\r
+.global zynq_trampoline\r
+zynq_trampoline:\r
+ ldr r0, [pc]\r
+ bx r0\r
+.global zynq_trampoline_jump\r
+zynq_trampoline_jump:\r
+ .word\r
+.global zynq_trampoline_end\r
+zynq_trampoline_end:\r
+ \r
diff --git a/proxy/master/linux/kernelspace/rpmsg_proxy_dev_driver.c b/proxy/master/linux/kernelspace/rpmsg_proxy_dev_driver.c
--- /dev/null
@@ -0,0 +1,375 @@
+/*
+ * RPMSG Proxy Device Kernel Driver
+ *
+ * Copyright (C) 2014 Mentor Graphics Corporation
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ */
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/rpmsg.h>
+#include <linux/slab.h>
+#include <linux/device.h>
+#include <linux/cdev.h>
+#include <linux/mutex.h>
+#include <linux/wait.h>
+#include <linux/fs.h>
+#include <linux/kfifo.h>
+#include <linux/uaccess.h>
+#include <linux/kthread.h>
+#include <linux/ioctl.h>
+#include <linux/errno.h>
+
+#define PROXY_ENDPOINT 127
+
+static struct class *rpmsg_class;
+static dev_t rpmsg_dev;
+
+struct _rpmsg_dev_params {
+ int rpmsg_major;
+ int rpmsg_minor;
+ struct device *rpmsg_dev;
+ struct cdev cdev;
+ struct rpmsg_channel *rpmsg_chnl;
+};
+
+struct _rpmsg_dev_instance {
+ struct rpmsg_endpoint *ept;
+ struct _rpmsg_dev_params *dev_params;
+ wait_queue_head_t usr_wait_q;
+ struct mutex sync_lock;
+};
+
+#define MAX_RPMSG_BUFF_SIZE 512
+#define RPMSG_KFIFO_SIZE (MAX_RPMSG_BUFF_SIZE * 4)
+
+#define IOCTL_CMD_GET_KFIFO_SIZE 1
+#define IOCTL_CMD_GET_AVAIL_DATA_SIZE 2
+#define IOCTL_CMD_GET_FREE_BUFF_SIZE 3
+
+static struct kfifo rpmsg_kfifo;
+static int block_flag;
+
+/* This callback gets invoked when we received data from the remot enode */
+static void rpmsg_proxy_dev_drv_rx_cb(struct rpmsg_channel *rpdev,
+ void *data, int len, void *priv, u32 src)
+{
+ struct _rpmsg_dev_instance *rpmsg_dev_instance = priv;
+
+ /* Push data received into rpmsg kfifo */
+ mutex_lock_interruptible(&rpmsg_dev_instance->sync_lock);
+ kfifo_in(&rpmsg_kfifo, data, (unsigned int)len);
+ mutex_unlock(&rpmsg_dev_instance->sync_lock);
+
+ /* Wake up any blocking contexts waiting for data */
+ block_flag = 1;
+ wake_up_interruptible(&rpmsg_dev_instance->usr_wait_q);
+}
+
+
+static int rpmsg_dev_open(struct inode *inode, struct file *p_file)
+{
+ struct _rpmsg_dev_instance *rpmsg_dev_instance;
+ struct _rpmsg_dev_params *rpmsg_dev_params;
+ int retval, err;
+ unsigned int dummy_data = 0xffffffff;
+
+ /* Create and initialize rpmsg device instance */
+ rpmsg_dev_instance = kzalloc(sizeof(struct _rpmsg_dev_instance),
+ GFP_KERNEL);
+
+ if (!rpmsg_dev_instance) {
+ pr_err("\r\n cannot allocate memory for rpmsg device instance \r\n");
+ return -ENOMEM;
+ }
+
+ /* Initialize rpmsg instance with device params from inode */
+ rpmsg_dev_instance->dev_params = container_of(inode->i_cdev,
+ struct _rpmsg_dev_params, cdev);
+
+ rpmsg_dev_params = rpmsg_dev_instance->dev_params;
+
+ /* Allocate kfifo for rpmsg */
+ retval = kfifo_alloc(&rpmsg_kfifo, RPMSG_KFIFO_SIZE, GFP_KERNEL);
+ kfifo_reset(&rpmsg_kfifo);
+
+ if (retval) {
+ pr_err("\r\n error in kfifo_alloc for rpmsg \r\n");
+
+ return retval;
+ }
+
+ /* Initialize mutex */
+ mutex_init(&rpmsg_dev_instance->sync_lock);
+
+ /* Initialize wait queue head that provides blocking rx for userspace */
+ init_waitqueue_head(&rpmsg_dev_instance->usr_wait_q);
+
+ p_file->private_data = rpmsg_dev_instance;
+
+ /* Create endpoint for proxy service */
+ rpmsg_dev_instance->ept = rpmsg_create_ept(rpmsg_dev_params->rpmsg_chnl,
+ rpmsg_proxy_dev_drv_rx_cb,
+ rpmsg_dev_instance,
+ PROXY_ENDPOINT);
+
+ /* Send dummy data to the default endpoint to close loop on rpmsg
+ channel establishment */
+ rpmsg_send(rpmsg_dev_params->rpmsg_chnl, &dummy_data,
+ sizeof(unsigned int));
+
+ if (!rpmsg_dev_instance->ept) {
+ pr_err(" Endpoint creation for failed!\r\n");
+ return -ENOMEM;
+ }
+
+ return 0;
+}
+
+static ssize_t rpmsg_dev_write(struct file *p_file, const char __user *ubuff,
+ size_t len, loff_t *p_off)
+{
+ struct _rpmsg_dev_instance *rpmsg_dev_instance
+ = p_file->private_data;
+ struct _rpmsg_dev_params *rpmsg_dev_params
+ = rpmsg_dev_instance->dev_params;
+ int err;
+ unsigned int size;
+ char *tmp_buff;
+
+ if (len < MAX_RPMSG_BUFF_SIZE)
+ size = len;
+ else
+ size = MAX_RPMSG_BUFF_SIZE;
+
+ tmp_buff = kzalloc(size, GFP_KERNEL);
+
+ if (copy_from_user(tmp_buff, ubuff, size)) {
+ pr_err("\r\n user to kernel buff copy error \r\n");
+ return -1;
+ }
+
+ err = rpmsg_sendto(rpmsg_dev_params->rpmsg_chnl, tmp_buff, size,
+ PROXY_ENDPOINT);
+
+ if (err) {
+ size = 0;
+ pr_err("\r\n rpmsg_send_off_channel error \r\n");
+ }
+
+ return size;
+}
+
+static ssize_t rpmsg_dev_read(struct file *p_file, char __user *ubuff,
+ size_t len, loff_t *p_off)
+{
+ struct _rpmsg_dev_instance *rpmsg_dev_instance = p_file->private_data;
+ int retval;
+ unsigned int data_available, data_used, bytes_copied;
+
+ /* Acquire lock to access rpmsg kfifo */
+ if (mutex_lock_interruptible(&rpmsg_dev_instance->sync_lock))
+ return -ERESTARTSYS;
+
+ data_available = kfifo_len(&rpmsg_kfifo);
+
+ if (data_available == 0) {
+ /* Release lock */
+ mutex_unlock(&rpmsg_dev_instance->sync_lock);
+
+ /* if non-blocking read is requested return error */
+ if (p_file->f_flags & O_NONBLOCK)
+ return -EAGAIN;
+
+ /* Block the calling context till data becomes available */
+ wait_event_interruptible(rpmsg_dev_instance->usr_wait_q,
+ block_flag != 0);
+
+ /* Acquire lock to access rpmsg kfifo */
+ if (mutex_lock_interruptible(&rpmsg_dev_instance->sync_lock))
+ return -ERESTARTSYS;
+ }
+
+ /* Reset block flag */
+ block_flag = 0;
+
+ /* Provide requested data size to user space */
+ data_available = kfifo_len(&rpmsg_kfifo);
+ retval = kfifo_to_user(&rpmsg_kfifo, ubuff, data_available,
+ &bytes_copied);
+
+ /* Release lock on rpmsg kfifo */
+ mutex_unlock(&rpmsg_dev_instance->sync_lock);
+
+ return bytes_copied;
+}
+
+static long rpmsg_dev_ioctl(struct file *p_file, unsigned int cmd,
+ unsigned long arg)
+{
+ unsigned int tmp;
+
+ switch (cmd) {
+ case IOCTL_CMD_GET_KFIFO_SIZE:
+ tmp = kfifo_size(&rpmsg_kfifo);
+ if (copy_to_user((unsigned int *)arg, &tmp, sizeof(int)))
+ return -EACCES;
+ break;
+
+ case IOCTL_CMD_GET_AVAIL_DATA_SIZE:
+ tmp = kfifo_len(&rpmsg_kfifo);
+ pr_err("kfifo len ioctl = %d ", kfifo_len(&rpmsg_kfifo));
+ if (copy_to_user((unsigned int *)arg, &tmp, sizeof(int)))
+ return -EACCES;
+ break;
+ case IOCTL_CMD_GET_FREE_BUFF_SIZE:
+ tmp = kfifo_avail(&rpmsg_kfifo);
+ if (copy_to_user((unsigned int *)arg, &tmp, sizeof(int)))
+ return -EACCES;
+ break;
+
+ default:
+ return -EINVAL;
+ }
+
+ return 0;
+}
+
+static int rpmsg_dev_release(struct inode *inode, struct file *p_file)
+{
+ struct _rpmsg_dev_instance *rpmsg_dev_instance = p_file->private_data;
+
+ rpmsg_destroy_ept(rpmsg_dev_instance->ept);
+ kfree(rpmsg_dev_instance);
+
+ return 0;
+}
+
+static const struct file_operations rpmsg_dev_fops = {
+ .owner = THIS_MODULE,
+ .read = rpmsg_dev_read,
+ .write = rpmsg_dev_write,
+ .open = rpmsg_dev_open,
+ .unlocked_ioctl = rpmsg_dev_ioctl,
+ .release = rpmsg_dev_release,
+};
+
+static int rpmsg_proxy_dev_drv_probe(struct rpmsg_channel *rpdev)
+{
+ struct _rpmsg_dev_params *rpmsg_dev_params;
+
+ /* Allocate memory for the rpmsg device parameters data structure */
+ rpmsg_dev_params = kzalloc(sizeof(struct _rpmsg_dev_params),
+ GFP_KERNEL);
+
+ if (!rpmsg_dev_params) {
+ pr_err
+ ("\r\n cannot allocate memory for rpmsg device params \r\n");
+ return -ENOMEM;
+ }
+
+ /* Initialize rpmsg device parameters data structure */
+ rpmsg_dev_params->rpmsg_major = MAJOR(rpmsg_dev);
+ rpmsg_dev_params->rpmsg_minor = 0;
+ /* Create device */
+ rpmsg_dev_params->rpmsg_dev = device_create(rpmsg_class,
+ &rpdev->dev,
+ rpmsg_dev,
+ NULL,
+ "rpmsg_proxy");
+ if (rpmsg_dev_params->rpmsg_dev == NULL) {
+ class_destroy(rpmsg_class);
+ unregister_chrdev_region(rpmsg_dev, 1);
+ return -1;
+ }
+ /* Initialize character device */
+ cdev_init(&rpmsg_dev_params->cdev, &rpmsg_dev_fops);
+ rpmsg_dev_params->cdev.owner = THIS_MODULE;
+ if (cdev_add(&rpmsg_dev_params->cdev, rpmsg_dev, 1) == -1) {
+ device_destroy(rpmsg_class, rpmsg_dev);
+ class_destroy(rpmsg_class);
+ unregister_chrdev_region(rpmsg_dev, 1);
+ return -1;
+ }
+ rpmsg_dev_params->rpmsg_chnl = rpdev;
+
+ dev_set_drvdata(&rpdev->dev, rpmsg_dev_params);
+
+ dev_info(&rpdev->dev, "new channel: 0x%x -> 0x%x!\n",
+ rpdev->src, rpdev->dst);
+
+ return 0;
+}
+
+static void rpmsg_proxy_dev_drv_remove(struct rpmsg_channel *rpdev)
+{
+ struct _rpmsg_dev_params *rpmsg_dev_params
+ = dev_get_drvdata(&rpdev->dev);
+
+ device_destroy(rpmsg_class, rpmsg_dev);
+ cdev_del(&rpmsg_dev_params->cdev);
+ kfree(rpmsg_dev_params);
+}
+
+static void rpmsg_cb(struct rpmsg_channel *rpdev, void *data,
+ int len, void *priv, u32 src)
+{
+
+}
+
+static struct rpmsg_device_id rpmsg_proxy_dev_drv_id_table[] = {
+ { .name = "rpmsg-openamp-demo-channel" },
+ { },
+};
+MODULE_DEVICE_TABLE(rpmsg, rpmsg_proxy_dev_drv_id_table);
+
+static struct rpmsg_driver rpmsg_proxy_dev_drv = {
+ .drv.name = KBUILD_MODNAME,
+ .drv.owner = THIS_MODULE,
+ .id_table = rpmsg_proxy_dev_drv_id_table,
+ .probe = rpmsg_proxy_dev_drv_probe,
+ .callback = rpmsg_cb,
+ .remove = rpmsg_proxy_dev_drv_remove,
+};
+
+static int __init init(void)
+{
+ /* Allocate char device for this rpmsg driver */
+ if (alloc_chrdev_region(&rpmsg_dev, 0, 1, KBUILD_MODNAME) < 0) {
+ pr_err("\r\n Error allocating char device \r\n");
+ return -1;
+ }
+
+ /* Create device class for this device */
+ rpmsg_class = class_create(THIS_MODULE, KBUILD_MODNAME);
+
+ if (rpmsg_class == NULL) {
+ unregister_chrdev_region(rpmsg_dev, 1);
+ pr_err("\r\n Error allocating char device \r\n");
+ return -1;
+ }
+
+ /* Register this rpmsg driver with the rpmsg bus layer */
+ return register_rpmsg_driver(&rpmsg_proxy_dev_drv);
+}
+
+static void __exit fini(void)
+{
+ unregister_rpmsg_driver(&rpmsg_proxy_dev_drv);
+ class_destroy(rpmsg_class);
+ unregister_chrdev_region(rpmsg_dev, 1);
+}
+
+module_init(init);
+module_exit(fini);
+
+MODULE_DESCRIPTION("Sample driver to exposes rpmsg svcs to userspace via a char device");
+MODULE_LICENSE("GPL v2");
diff --git a/proxy/master/linux/userspace/proxy_app.c b/proxy/master/linux/userspace/proxy_app.c
--- /dev/null
@@ -0,0 +1,310 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <time.h>
+#include <fcntl.h>
+#include <string.h>
+#include <sys/ioctl.h>
+#include <signal.h>
+#include "proxy_app.h"
+
+#define RPC_BUFF_SIZE 512
+
+struct _proxy_data {
+ int active;
+ int rpmsg_proxy_fd;
+ struct _sys_rpc *rpc;
+ struct _sys_rpc *rpc_response;
+ char *firmware_path;
+};
+
+static struct _proxy_data *proxy;
+char fw_dst_path[] = "/lib/firmware/firmware";
+char cp_cmd[512];
+
+int handle_open(struct _sys_rpc *rpc)
+{
+ int fd, bytes_written;
+
+ /* Open remote fd */
+ fd = open(rpc->sys_call_args.data, rpc->sys_call_args.int_field1,
+ rpc->sys_call_args.int_field2);
+
+ /* Construct rpc response */
+ proxy->rpc_response->id = OPEN_SYSCALL_ID;
+ proxy->rpc_response->sys_call_args.int_field1 = fd;
+ proxy->rpc_response->sys_call_args.int_field2 = 0; /*not used*/
+ proxy->rpc_response->sys_call_args.data_len = 0; /*not used*/
+
+ /* Transmit rpc response */
+ bytes_written = write(proxy->rpmsg_proxy_fd, proxy->rpc_response,
+ sizeof(struct _sys_rpc));
+
+ return (bytes_written != sizeof(struct _sys_rpc)) ? -1 : 0;
+}
+
+int handle_close(struct _sys_rpc *rpc)
+{
+ int retval, bytes_written;
+
+ /* Close remote fd */
+ retval = close(rpc->sys_call_args.int_field1);
+
+ /* Construct rpc response */
+ proxy->rpc_response->id = CLOSE_SYSCALL_ID;
+ proxy->rpc_response->sys_call_args.int_field1 = retval;
+ proxy->rpc_response->sys_call_args.int_field2 = 0; /*not used*/
+ proxy->rpc_response->sys_call_args.data_len = 0; /*not used*/
+
+ /* Transmit rpc response */
+ bytes_written = write(proxy->rpmsg_proxy_fd, proxy->rpc_response,
+ sizeof(struct _sys_rpc));
+
+ return (bytes_written != sizeof(struct _sys_rpc)) ? -1 : 0;
+}
+
+int handle_read(struct _sys_rpc *rpc)
+{
+ int bytes_read, bytes_written, payload_size;
+ char *buff;
+
+ /* Allocate buffer for requested data size */
+ buff = malloc(rpc->sys_call_args.int_field2);
+
+ if (rpc->sys_call_args.int_field1 == 0)
+ /* Perform read from fd for large size since this is a
+ STD/I request */
+ bytes_read = read(rpc->sys_call_args.int_field1, buff, 512);
+ else
+ /* Perform read from fd */
+ bytes_read = read(rpc->sys_call_args.int_field1, buff,
+ rpc->sys_call_args.int_field2);
+
+ /* Construct rpc response */
+ proxy->rpc_response->id = READ_SYSCALL_ID;
+ proxy->rpc_response->sys_call_args.int_field1 = bytes_read;
+ proxy->rpc_response->sys_call_args.int_field2 = 0; /* not used */
+ proxy->rpc_response->sys_call_args.data_len = bytes_read;
+ if (bytes_read > 0)
+ memcpy(proxy->rpc_response->sys_call_args.data, buff,
+ bytes_read);
+
+ payload_size = sizeof(struct _sys_rpc) +
+ ((bytes_read > 0) ? bytes_read : 0);
+
+ /* Transmit rpc response */
+ bytes_written = write(proxy->rpmsg_proxy_fd, proxy->rpc_response,
+ payload_size);
+
+ return (bytes_written != payload_size) ? -1 : 0;
+}
+
+int handle_write(struct _sys_rpc *rpc)
+{
+ int bytes_written;
+
+ /* Write to remote fd */
+ bytes_written = write(rpc->sys_call_args.int_field1,
+ rpc->sys_call_args.data,
+ rpc->sys_call_args.int_field2);
+
+ /* Construct rpc response */
+ proxy->rpc_response->id = WRITE_SYSCALL_ID;
+ proxy->rpc_response->sys_call_args.int_field1 = bytes_written;
+ proxy->rpc_response->sys_call_args.int_field2 = 0; /*not used*/
+ proxy->rpc_response->sys_call_args.data_len = 0; /*not used*/
+
+ /* Transmit rpc response */
+ bytes_written = write(proxy->rpmsg_proxy_fd, proxy->rpc_response,
+ sizeof(struct _sys_rpc));
+
+ return (bytes_written != sizeof(struct _sys_rpc)) ? -1 : 0;
+}
+
+int handle_rpc(struct _sys_rpc *rpc)
+{
+ int retval;
+
+ /* Handle RPC */
+ switch (rpc->id) {
+ case OPEN_SYSCALL_ID:
+ {
+ retval = handle_open(rpc);
+ break;
+ }
+ case CLOSE_SYSCALL_ID:
+ {
+ retval = handle_close(rpc);
+ break;
+ }
+ case READ_SYSCALL_ID:
+ {
+ retval = handle_read(rpc);
+ break;
+ }
+ case WRITE_SYSCALL_ID:
+ {
+ retval = handle_write(rpc);
+ break;
+ }
+ default:
+ {
+ printf("\r\nMaster>Err:Invalid RPC sys call ID! \r\n");
+ retval = -1;
+ break;
+ }
+ }
+
+ return retval;
+}
+
+int terminate_rpc_app()
+{
+ int bytes_written;
+ int msg = TERM_SYSCALL_ID;
+ bytes_written = write(proxy->rpmsg_proxy_fd, &msg, sizeof(int));
+ return bytes_written;
+}
+
+void exit_action_handler(int signum)
+{
+ proxy->active = 0;
+}
+
+void kill_action_handler(int signum)
+{
+ printf("\r\nMaster>RPC service killed !!\r\n");
+
+ /* Send shutdown signal to remote application */
+ terminate_rpc_app();
+ /* Close proxy rpmsg device */
+ close(proxy->rpmsg_proxy_fd);
+
+ /* Free up resources */
+ free(proxy->rpc);
+ free(proxy->rpc_response);
+ free(proxy);
+
+ /* Unload drivers */
+ system("modprobe -r rpmsg_proxy_dev_driver");
+ system("modprobe -r virtio_rpmsg_bus");
+ system("modprobe -r zynq_remoteproc_driver");
+ system("modprobe -r remoteproc");
+ system("modprobe -r virtio_ring");
+ system("modprobe -r virtio");
+}
+
+void display_help_msg()
+{
+ printf("\r\nLinux proxy application.\r\n");
+ printf("-r Displays proxy application version.\n");
+ printf("-f Accepts path of firmware to load on remote core.\n");
+ printf("-h Displays this help message.\n");
+}
+int main(int argc, char *argv[])
+{
+ struct sigaction exit_action;
+ struct sigaction kill_action;
+ unsigned int bytes_rcvd;
+ int i = 0;
+
+ /* Initialize signalling infrastructure */
+ memset(&exit_action, 0, sizeof(struct sigaction));
+ memset(&kill_action, 0, sizeof(struct sigaction));
+ exit_action.sa_handler = exit_action_handler;
+ kill_action.sa_handler = kill_action_handler;
+ sigaction(SIGTERM, &exit_action, NULL);
+ sigaction(SIGINT, &exit_action, NULL);
+ sigaction(SIGKILL, &kill_action, NULL);
+ sigaction(SIGHUP, &kill_action, NULL);
+
+ /* Parse and process input args */
+ for (i = 1; i < argc; i++) {
+ if (strcmp(argv[i], "-r") == 0) {
+ printf("\r\nLinux proxy application version 1.0\r\n");
+ return 0;
+ } else if (strcmp(argv[i], "-h") == 0) {
+ display_help_msg();
+ return 0;
+ } else if (strcmp(argv[i], "-f") == 0) {
+ if (i+1 < argc)
+ /* Construct file copy command string */
+ sprintf(cp_cmd , "cp %s %s", argv[i+1],
+ fw_dst_path);
+ }
+ }
+
+ /* Bring up remote firmware */
+ printf("\r\nMaster>Loading remote firmware\r\n");
+ system(cp_cmd);
+ system("modprobe zynq_remoteproc_driver");
+
+ /* Create rpmsg proxy device */
+ printf("\r\nMaster>Create rpmsg proxy device\r\n");
+ system("modprobe rpmsg_proxy_dev_driver");
+
+ /* Allocate memory for proxy data structure */
+ proxy = malloc(sizeof(struct _proxy_data));
+
+ /* Open proxy rpmsg device */
+ printf("\r\nMaster>Opening rpmsg proxy device\r\n");
+ do {
+ proxy->rpmsg_proxy_fd = open("/dev/rpmsg_proxy", O_RDWR);
+
+ } while (proxy->rpmsg_proxy_fd < 0);
+
+ /* Allocate memory for rpc payloads */
+ proxy->active = 1;
+ proxy->rpc = malloc(RPC_BUFF_SIZE);
+ proxy->rpc_response = malloc(RPC_BUFF_SIZE);
+
+ /* RPC service starts */
+ printf("\r\nMaster>RPC service started !!\r\n");
+ while (proxy->active) {
+ /* Block on read for rpc requests from remote context */
+ bytes_rcvd = read(proxy->rpmsg_proxy_fd, proxy->rpc,
+ RPC_BUFF_SIZE);
+
+ /* User event, break! */
+ if (!proxy->active)
+ break;
+
+ /* Handle rpc */
+ if (handle_rpc(proxy->rpc)) {
+ printf("\r\nMaster>Err:Handling remote procedure");
+ printf(" call!\r\n");
+ printf("\r\nrpc id %d\r\n", proxy->rpc->id);
+ printf("\r\nrpc int field1 %d\r\n",
+ proxy->rpc->sys_call_args.int_field1);
+ printf("\r\nrpc int field2 %d\r\n",
+ proxy->rpc->sys_call_args.int_field2);
+ break;
+ }
+ }
+
+ printf("\r\nMaster>RPC service exiting !!\r\n");
+
+ /* Send shutdown signal to remote application */
+ terminate_rpc_app();
+ /* FIXME: May be wait here for sometime to allow remote application
+ to complete its uninitialization. */
+
+ /* Close proxy rpmsg device */
+ close(proxy->rpmsg_proxy_fd);
+
+ /* Free up resources */
+ free(proxy->rpc);
+ free(proxy->rpc_response);
+ free(proxy);
+
+ /* Unload drivers */
+ system("modprobe -r rpmsg_proxy_dev_driver");
+ system("modprobe -r virtio_rpmsg_bus");
+ system("modprobe -r zynq_remoteproc_driver");
+ system("modprobe -r remoteproc");
+ system("modprobe -r virtio_ring");
+ system("modprobe -r virtio");
+
+ return 0;
+}
+
diff --git a/proxy/master/linux/userspace/proxy_app.h b/proxy/master/linux/userspace/proxy_app.h
--- /dev/null
@@ -0,0 +1,32 @@
+/* System call definitions */
+#define OPEN_SYSCALL_ID 1
+#define CLOSE_SYSCALL_ID 2
+#define WRITE_SYSCALL_ID 3
+#define READ_SYSCALL_ID 4
+#define ACK_STATUS_ID 5
+#define TERM_SYSCALL_ID 6
+
+
+#define FILE_NAME_LEN 50
+
+struct _rpc_data {
+ struct rpmsg_channel *rpmsg_chnl;
+ struct rpmsg_endpoint *rp_ept;
+ void *rpc_lock;
+ void *sync_lock;
+ void *data;
+};
+
+struct _sys_call_args {
+ int int_field1;
+ int int_field2;
+ unsigned long data_len;
+ char data[0];
+};
+
+/* System call rpc data structure */
+struct _sys_rpc {
+ unsigned long id;
+ struct _sys_call_args sys_call_args;
+};
+
diff --git a/proxy/remote/rpmsg_retarget/rpmsg_retarget.c b/proxy/remote/rpmsg_retarget/rpmsg_retarget.c
--- /dev/null
@@ -0,0 +1,233 @@
+#include "open_amp.h"
+#include "rpmsg_retarget.h"
+#include <stdio.h>
+#include <string.h>
+#include <fcntl.h>
+
+/*************************************************************************
+ * Description
+ * This files contains rpmsg based redefinitions for C RTL system calls
+ * such as _open, _read, _write, _close.
+ *************************************************************************/
+static struct _rpc_data* rpc_data;
+
+int send_rpc(void *data, int len);
+
+void rpc_cb(struct rpmsg_channel *rtl_rp_chnl, void *data, int len, void * priv,
+ unsigned long src) {
+ memcpy(rpc_data->rpc_response, data, len);
+ env_release_sync_lock(rpc_data->sync_lock);
+
+ if ((*((int *) data)) == TERM_SYSCALL_ID) {
+ /* Application terminate signal is received from the proxy app,
+ * so let the application know of terminate message.
+ */
+ rpc_data->shutdown_cb(rtl_rp_chnl);
+ }
+}
+
+int send_rpc(void *data, int len) {
+ int retval;
+
+ retval = rpmsg_sendto(rpc_data->rpmsg_chnl, data, len, PROXY_ENDPOINT);
+ return retval;
+}
+
+int rpmsg_retarget_init(struct rpmsg_channel *rp_chnl, rpc_shutdown_cb cb) {
+ int status;
+
+ /* Allocate memory for rpc control block */
+ rpc_data = (struct _rpc_data*) env_allocate_memory(
+ sizeof(struct _rpc_data));
+
+ /* Create a mutex for synchronization */
+ status = env_create_mutex(&rpc_data->rpc_lock, 1);
+
+ /* Create a mutex for synchronization */
+ status = env_create_sync_lock(&rpc_data->sync_lock, LOCKED);
+
+ /* Create a endpoint to handle rpc response from master */
+ rpc_data->rpmsg_chnl = rp_chnl;
+ rpc_data->rp_ept = rpmsg_create_ept(rpc_data->rpmsg_chnl, rpc_cb,
+ RPMSG_NULL, PROXY_ENDPOINT);
+ rpc_data->rpc = env_allocate_memory(RPC_BUFF_SIZE);
+ rpc_data->rpc_response = env_allocate_memory(RPC_BUFF_SIZE);
+ rpc_data->shutdown_cb = cb;
+
+ return status;
+}
+
+int rpmsg_retarget_deinit(struct rpmsg_channel *rp_chnl) {
+ env_free_memory(rpc_data->rpc);
+ env_free_memory(rpc_data->rpc_response);
+ env_delete_mutex(rpc_data->rpc_lock);
+ env_delete_sync_lock(rpc_data->sync_lock);
+ rpmsg_destroy_ept(rpc_data->rp_ept);
+ env_free_memory(rpc_data);
+
+ return 0;
+}
+
+/*************************************************************************
+ *
+ * FUNCTION
+ *
+ * _open
+ *
+ * DESCRIPTION
+ *
+ * Open a file. Minimal implementation
+ *
+ *************************************************************************/
+int _open(const char * filename, int flags, int mode) {
+ int filename_len = strlen(filename) + 1;
+ int payload_size = sizeof(struct _sys_rpc) + filename_len;
+ int retval = -1;
+
+ if ((!filename) || (filename_len > FILE_NAME_LEN)) {
+ return -1;
+ }
+
+ /* Construct rpc payload */
+ rpc_data->rpc->id = OPEN_SYSCALL_ID;
+ rpc_data->rpc->sys_call_args.int_field1 = flags;
+ rpc_data->rpc->sys_call_args.int_field2 = mode;
+ rpc_data->rpc->sys_call_args.data_len = filename_len;
+ memcpy(&rpc_data->rpc->sys_call_args.data, filename, filename_len);
+
+ /* Transmit rpc request */
+ env_lock_mutex(rpc_data->rpc_lock);
+ send_rpc((void*) rpc_data->rpc, payload_size);
+ env_unlock_mutex(rpc_data->rpc_lock);
+
+ /* Wait for response from proxy on master */
+ env_acquire_sync_lock(rpc_data->sync_lock);
+
+ /* Obtain return args and return to caller */
+ if (rpc_data->rpc_response->id == OPEN_SYSCALL_ID) {
+ retval = rpc_data->rpc_response->sys_call_args.int_field1;
+ }
+
+ return retval;
+}
+
+/*************************************************************************
+ *
+ * FUNCTION
+ *
+ * _read
+ *
+ * DESCRIPTION
+ *
+ * Low level function to redirect IO to serial.
+ *
+ *************************************************************************/
+int _read(int fd, char * buffer, int buflen) {
+ int payload_size = sizeof(struct _sys_rpc);
+ int retval = -1;
+
+ if (!buffer || !buflen)
+ return retval;
+
+ /* Construct rpc payload */
+ rpc_data->rpc->id = READ_SYSCALL_ID;
+ rpc_data->rpc->sys_call_args.int_field1 = fd;
+ rpc_data->rpc->sys_call_args.int_field2 = buflen;
+ rpc_data->rpc->sys_call_args.data_len = 0; /*not used*/
+
+ /* Transmit rpc request */
+ env_lock_mutex(rpc_data->rpc_lock);
+ send_rpc((void*) rpc_data->rpc, payload_size);
+ env_unlock_mutex(rpc_data->rpc_lock);
+
+ /* Wait for response from proxy on master */
+ env_acquire_sync_lock(rpc_data->sync_lock);
+
+ /* Obtain return args and return to caller */
+ if (rpc_data->rpc_response->id == READ_SYSCALL_ID) {
+ if (rpc_data->rpc_response->sys_call_args.int_field1 > 0) {
+ memcpy(buffer, rpc_data->rpc_response->sys_call_args.data,
+ rpc_data->rpc_response->sys_call_args.data_len);
+ }
+
+ retval = rpc_data->rpc_response->sys_call_args.int_field1;
+ }
+
+ return retval;
+}
+
+/*************************************************************************
+ *
+ * FUNCTION
+ *
+ * _write
+ *
+ * DESCRIPTION
+ *
+ * Low level function to redirect IO to serial.
+ *
+ *************************************************************************/
+int _write(int fd, const char * ptr, int len) {
+ int retval = -1;
+ int payload_size = sizeof(struct _sys_rpc) + len;
+ int null_term = 0;
+
+ if (fd == 1) {
+ null_term = 1;
+ }
+
+ rpc_data->rpc->id = WRITE_SYSCALL_ID;
+ rpc_data->rpc->sys_call_args.int_field1 = fd;
+ rpc_data->rpc->sys_call_args.int_field2 = len;
+ rpc_data->rpc->sys_call_args.data_len = len + null_term;
+ memcpy(rpc_data->rpc->sys_call_args.data, ptr, len);
+ if (null_term) {
+ *(char*) (rpc_data->rpc->sys_call_args.data + len + null_term) = 0;
+ }
+
+ env_lock_mutex(rpc_data->rpc_lock);
+ send_rpc((void*) rpc_data->rpc, payload_size);
+ env_unlock_mutex(rpc_data->rpc_lock);
+
+ env_acquire_sync_lock(rpc_data->sync_lock);
+
+ if (rpc_data->rpc_response->id == WRITE_SYSCALL_ID) {
+ retval = rpc_data->rpc_response->sys_call_args.int_field1;
+ }
+
+ return retval;
+
+}
+
+/*************************************************************************
+ *
+ * FUNCTION
+ *
+ * _close
+ *
+ * DESCRIPTION
+ *
+ * Close a file. Minimal implementation
+ *
+ *************************************************************************/
+int _close(int fd) {
+ int payload_size = sizeof(struct _sys_rpc);
+ int retval = -1;
+
+ rpc_data->rpc->id = CLOSE_SYSCALL_ID;
+ rpc_data->rpc->sys_call_args.int_field1 = fd;
+ rpc_data->rpc->sys_call_args.int_field2 = 0; /*not used*/
+ rpc_data->rpc->sys_call_args.data_len = 0; /*not used*/
+
+ env_lock_mutex(rpc_data->rpc_lock);
+ send_rpc((void*) rpc_data->rpc, payload_size);
+ env_unlock_mutex(rpc_data->rpc_lock);
+
+ env_acquire_sync_lock(rpc_data->sync_lock);
+
+ if (rpc_data->rpc_response->id == CLOSE_SYSCALL_ID) {
+ retval = rpc_data->rpc_response->sys_call_args.int_field1;
+ }
+
+ return retval;
+}
diff --git a/proxy/remote/rpmsg_retarget/rpmsg_retarget.h b/proxy/remote/rpmsg_retarget/rpmsg_retarget.h
--- /dev/null
@@ -0,0 +1,52 @@
+#include "open_amp.h"
+/* RPC response buffer size */
+#define RPC_BUFF_SIZE 512
+
+/* System call definitions */
+#define OPEN_SYSCALL_ID 1
+#define CLOSE_SYSCALL_ID 2
+#define WRITE_SYSCALL_ID 3
+#define READ_SYSCALL_ID 4
+#define ACK_STATUS_ID 5
+#define TERM_SYSCALL_ID 6
+
+
+#define FILE_NAME_LEN 50
+
+/* Proxy device endpoint ID */
+#define PROXY_ENDPOINT 127
+
+typedef void (*rpc_shutdown_cb)(struct rpmsg_channel *);
+
+struct _rpc_data
+{
+ struct rpmsg_channel* rpmsg_chnl;
+ struct rpmsg_endpoint* rp_ept;
+ void* rpc_lock;
+ void* sync_lock;
+ struct _sys_rpc* rpc;
+ struct _sys_rpc* rpc_response;
+ rpc_shutdown_cb shutdown_cb;
+};
+
+struct _sys_call_args
+{
+ int int_field1;
+ int int_field2;
+ unsigned long data_len;
+ char data[0];
+};
+
+/* System call rpc data structure */
+struct _sys_rpc
+{
+ unsigned long id;
+ struct _sys_call_args sys_call_args;
+};
+
+
+void debug_print(char* str, int len);
+
+/* API prototypes */
+int rpmsg_retarget_init(struct rpmsg_channel *rp_chnl, rpc_shutdown_cb cb);
+int rpmsg_retarget_deinit(struct rpmsg_channel *rp_chnl);
diff --git a/remoteproc/elf_loader.c b/remoteproc/elf_loader.c
--- /dev/null
+++ b/remoteproc/elf_loader.c
@@ -0,0 +1,643 @@
+/*\r
+ * Copyright (c) 2014, Mentor Graphics Corporation\r
+ * All rights reserved.\r
+ *\r
+ * Redistribution and use in source and binary forms, with or without\r
+ * modification, are permitted provided that the following conditions are met:\r
+ *\r
+ * 1. Redistributions of source code must retain the above copyright notice,\r
+ * this list of conditions and the following disclaimer.\r
+ * 2. Redistributions in binary form must reproduce the above copyright notice,\r
+ * this list of conditions and the following disclaimer in the documentation\r
+ * and/or other materials provided with the distribution.\r
+ * 3. Neither the name of Mentor Graphics Corporation nor the names of its\r
+ * contributors may be used to endorse or promote products derived from this\r
+ * software without specific prior written permission.\r
+ *\r
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"\r
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\r
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\r
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE\r
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\r
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\r
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\r
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\r
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\r
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\r
+ * POSSIBILITY OF SUCH DAMAGE.\r
+ */\r
+\r
+#include "elf_loader.h"\r
+\r
+/* Local functions. */\r
+\r
+static int elf_loader_get_needed_sections(struct elf_decode_info *elf_info);\r
+static int elf_loader_relocs_specific(struct elf_decode_info *elf_info,\r
+ Elf32_Shdr *section);\r
+static void *elf_loader_get_entry_point_address(\r
+ struct elf_decode_info *elf_info);\r
+static int elf_loader_relocate_link(struct elf_decode_info *elf_info);\r
+static int elf_loader_seek_and_read(void *firmware, void *destination,\r
+ Elf32_Off offset, Elf32_Word size);\r
+static int elf_loader_read_headers(void *firmware,\r
+ struct elf_decode_info *elf_info);\r
+static int elf_loader_load_sections(void *firmware,\r
+ struct elf_decode_info *elf_info);\r
+static int elf_loader_get_decode_info(void *firmware,\r
+ struct elf_decode_info *elf_info);\r
+static int elf_loader_reloc_entry(struct elf_decode_info *elf_info,\r
+ Elf32_Rel *rel_entry);\r
+static Elf32_Addr elf_loader_get_dynamic_symbol_addr(\r
+ struct elf_decode_info *elf_info, int index);\r
+\r
+/**\r
+ * elf_loader_init\r
+ *\r
+ * Initializes ELF loader.\r
+ *\r
+ * @param loader - pointer to remoteproc loader\r
+ *\r
+ * @return - 0 if success, error otherwise\r
+ */\r
+int elf_loader_init(struct remoteproc_loader *loader) {\r
+\r
+ /* Initialize loader function table */\r
+ loader->load_firmware = elf_loader_load_remote_firmware;\r
+ loader->retrieve_entry = elf_loader_retrieve_entry_point;\r
+ loader->retrieve_rsc = elf_loader_retrieve_resource_section;\r
+ loader->attach_firmware = elf_loader_attach_firmware;\r
+ loader->detach_firmware = elf_loader_detach_firmware;\r
+ loader->retrieve_load_addr = elf_get_load_address;\r
+\r
+ return RPROC_SUCCESS;\r
+}\r
+\r
+/**\r
+ * elf_loader_attach_firmware\r
+ *\r
+ * Attaches an ELF firmware to the loader\r
+ *\r
+ * @param loader - pointer to remoteproc loader\r
+ * @param firmware - pointer to the firmware start location\r
+ *\r
+ * @return - 0 if success, error otherwise\r
+ */\r
+int elf_loader_attach_firmware(struct remoteproc_loader *loader, void *firmware) {\r
+\r
+ struct elf_decode_info *elf_info;\r
+ int status;\r
+\r
+ /* Allocate memory for decode info structure. */\r
+ elf_info = env_allocate_memory(sizeof(struct elf_decode_info));\r
+\r
+ if (!elf_info) {\r
+ return RPROC_ERR_NO_MEM;\r
+ }\r
+\r
+ /* Clear the ELF decode struct. */\r
+ env_memset(elf_info, 0, sizeof(struct elf_decode_info));\r
+\r
+ /* Get the essential information to decode the ELF. */\r
+ status = elf_loader_get_decode_info(firmware, elf_info);\r
+\r
+ if (status) {\r
+ /* Free memory. */\r
+ env_free_memory(elf_info);\r
+ return status;\r
+ }\r
+\r
+ elf_info->firmware = firmware;\r
+ loader->fw_decode_info = elf_info;\r
+\r
+ return status;\r
+}\r
+\r
+/**\r
+ * elf_loader_detach_firmware\r
+ *\r
+ * Detaches ELF firmware from the loader\r
+ *\r
+ * @param loader - pointer to remoteproc loader\r
+ *\r
+ * @return - 0 if success, error otherwise\r
+ */\r
+int elf_loader_detach_firmware(struct remoteproc_loader *loader) {\r
+\r
+ struct elf_decode_info *elf_info =\r
+ (struct elf_decode_info *) loader->fw_decode_info;\r
+ if (elf_info) {\r
+ /* Free memory. */\r
+ env_free_memory(elf_info->shstrtab);\r
+ env_free_memory(elf_info->section_headers_start);\r
+ env_free_memory(elf_info);\r
+ }\r
+\r
+ return RPROC_SUCCESS;\r
+}\r
+\r
+/**\r
+ * elf_loader_retrieve_entry_point\r
+ *\r
+ * Retrieves the ELF entrypoint.\r
+ *\r
+ * @param loader - pointer to remoteproc loader\r
+ *\r
+ * @return - entrypoint\r
+ */\r
+void *elf_loader_retrieve_entry_point(struct remoteproc_loader *loader) {\r
+\r
+ return elf_loader_get_entry_point_address(\r
+ (struct elf_decode_info *)loader->fw_decode_info);\r
+}\r
+\r
+/**\r
+ * elf_loader_retrieve_resource_section\r
+ *\r
+ * Retrieves the resource section.\r
+ *\r
+ * @param loader - pointer to remoteproc loader\r
+ * @param size - pointer to contain the size of the section\r
+ *\r
+ * @return - pointer to resource section\r
+ */\r
+void *elf_loader_retrieve_resource_section(struct remoteproc_loader *loader,\r
+ unsigned int *size) {\r
+\r
+ Elf32_Shdr *rsc_header;\r
+ void* resource_section = NULL;\r
+ struct elf_decode_info *elf_info =\r
+ (struct elf_decode_info *) loader->fw_decode_info;\r
+\r
+ if (elf_info->rsc) {\r
+ /* Retrieve resource section header. */\r
+ rsc_header = elf_info->rsc;\r
+ /* Retrieve resource section size. */\r
+ *size = rsc_header->sh_size;\r
+\r
+ /* Locate the start of resource section. */\r
+ resource_section = (void *) ((unsigned int) elf_info->firmware\r
+ + rsc_header->sh_offset);\r
+ }\r
+\r
+ /* Return the address of resource section. */\r
+ return resource_section;\r
+}\r
+\r
+/**\r
+ * elf_loader_load_remote_firmware\r
+ *\r
+ * Loads the ELF firmware.\r
+ *\r
+ * @param loader - pointer to remoteproc loader\r
+ *\r
+ * @return - 0 if success, error otherwise\r
+ */\r
+int elf_loader_load_remote_firmware(struct remoteproc_loader *loader) {\r
+\r
+ struct elf_decode_info *elf_info =\r
+ (struct elf_decode_info *) loader->fw_decode_info;\r
+ int status;\r
+\r
+ /* Load ELF sections. */\r
+ status = elf_loader_load_sections(elf_info->firmware, elf_info);\r
+\r
+ if (!status) {\r
+\r
+ /* Perform dynamic relocations if needed. */\r
+ status = elf_loader_relocate_link(elf_info);\r
+ }\r
+\r
+ return status;\r
+}\r
+\r
+/**\r
+ * elf_get_load_address\r
+ *\r
+ * Provides firmware load address.\r
+ *\r
+ * @param loader - pointer to remoteproc loader\r
+ *\r
+ * @return - load address pointer\r
+ */\r
+void *elf_get_load_address(struct remoteproc_loader *loader) {\r
+\r
+ struct elf_decode_info *elf_info =\r
+ (struct elf_decode_info *) loader->fw_decode_info;\r
+ int status = 0;\r
+ Elf32_Shdr *current = (Elf32_Shdr *) (elf_info->section_headers_start);\r
+\r
+ /* Traverse all sections except the reserved null section. */\r
+ int section_count = elf_info->elf_header.e_shnum - 1;\r
+ while ((section_count > 0) && (status == 0)) {\r
+ /* Compute the pointer to section header. */\r
+ current = (Elf32_Shdr *) (((unsigned char *) current)\r
+ + elf_info->elf_header.e_shentsize);\r
+ /* Get the name of current section. */\r
+ char *current_name = elf_info->shstrtab + current->sh_name;\r
+ if(!env_strcmp(current_name , ".text")){\r
+ return ((void *) (current->sh_addr));\r
+ }\r
+ /* Move to the next section. */\r
+ section_count--;\r
+ }\r
+\r
+ return (RPROC_ERR_PTR);\r
+}\r
+/**\r
+ * elf_loader_get_needed_sections\r
+ *\r
+ * Retrieves the sections we need during the load and link from the\r
+ * section headers list.\r
+ *\r
+ * @param elf_info - ELF object decode info container.\r
+ *\r
+ * @return- Pointer to the ELF section header.\r
+ */\r
+\r
+static int elf_loader_get_needed_sections(struct elf_decode_info *elf_info) {\r
+ Elf32_Shdr *current = (Elf32_Shdr *) (elf_info->section_headers_start);\r
+\r
+ /* We are interested in the following sections:\r
+ .dynsym\r
+ .dynstr\r
+ .rel.plt\r
+ .rel.dyn\r
+ */\r
+ int sections_to_find = 5;\r
+\r
+ /* Search for sections but skip the reserved null section. */\r
+\r
+ int section_count = elf_info->elf_header.e_shnum - 1;\r
+ while ((section_count > 0) && (sections_to_find > 0)) {\r
+ /* Compute the section header pointer. */\r
+ current = (Elf32_Shdr *) (((unsigned char *) current)\r
+ + elf_info->elf_header.e_shentsize);\r
+\r
+ /* Get the name of current section. */\r
+ char *current_name = elf_info->shstrtab + current->sh_name;\r
+\r
+ /* Proceed if the section is allocatable and is not executable. */\r
+ if ((current->sh_flags & SHF_ALLOC)\r
+ && !(current->sh_flags & SHF_EXECINSTR)) {\r
+ /* Check for '.dynsym' or '.dynstr' or '.rel.plt' or '.rel.dyn'. */\r
+ if (*current_name == '.') {\r
+ current_name++;\r
+\r
+ /* Check for '.dynsym' or 'dynstr'. */\r
+ if (*current_name == 'd') {\r
+ current_name++;\r
+\r
+ /* Check for '.dynsym'. */\r
+ if (env_strncmp(current_name, "ynsym", 5) == 0) {\r
+ elf_info->dynsym = current;\r
+ sections_to_find--;\r
+ }\r
+\r
+ /* Check for '.dynstr'. */\r
+ else if (env_strncmp(current_name, "ynstr", 5) == 0) {\r
+ elf_info->dynstr = current;\r
+ sections_to_find--;\r
+ }\r
+ }\r
+\r
+ /* Check for '.rel.plt' or '.rel.dyn'. */\r
+ else if (*current_name == 'r') {\r
+ current_name++;\r
+\r
+ /* Check for '.rel.plt'. */\r
+ if (env_strncmp(current_name, "el.plt", 6) == 0) {\r
+ elf_info->rel_plt = current;\r
+ sections_to_find--;\r
+ }\r
+\r
+ /* Check for '.rel.dyn'. */\r
+ else if (env_strncmp(current_name, "el.dyn", 6) == 0) {\r
+ elf_info->rel_dyn = current;\r
+ sections_to_find--;\r
+ }\r
+\r
+ /* Check for '.resource_table'. */\r
+ else if (env_strncmp(current_name, "esource_table", 13)\r
+ == 0) {\r
+ elf_info->rsc = current;\r
+ sections_to_find--;\r
+ }\r
+ }\r
+ }\r
+ }\r
+\r
+ /* Move to the next section. */\r
+ section_count--;\r
+ }\r
+\r
+ /* Return remaining sections section. */\r
+ return (sections_to_find);\r
+}\r
+\r
+/**\r
+ * elf_loader_relocs_specific\r
+ *\r
+ * Processes the relocations contained in the specified section.\r
+ *\r
+ * @param elf_info - elf decoding information.\r
+ * @param section - header of the specified relocation section.\r
+ *\r
+ * @return - 0 if success, error otherwise\r
+ */\r
+static int elf_loader_relocs_specific(struct elf_decode_info *elf_info,\r
+ Elf32_Shdr *section) {\r
+\r
+ unsigned char *section_load_addr = (unsigned char*) section->sh_addr;\r
+ int status = 0;\r
+ int i;\r
+\r
+ /* Check the section type. */\r
+ if (section->sh_type == SHT_REL) {\r
+ /* Traverse the list of relocation entries contained in the section. */\r
+ for (i = 0; (i < section->sh_size) && (status == 0);\r
+ i += section->sh_entsize) {\r
+ /* Compute the relocation entry address. */\r
+ Elf32_Rel *rel_entry = (Elf32_Rel *) (section_load_addr + i);\r
+\r
+ /* Process the relocation entry. */\r
+ status = elf_loader_reloc_entry(elf_info, rel_entry);\r
+ }\r
+ }\r
+\r
+ /* Return status to caller. */\r
+ return (status);\r
+}\r
+\r
+/**\r
+ * elf_loader_get_entry_point_address\r
+ *\r
+ * Retrieves the entry point address from the specified ELF object.\r
+ *\r
+ * @param elf_info - elf object decode info container.\r
+ * @param runtime_buffer - buffer containing ELF sections which are\r
+ * part of runtime.\r
+ *\r
+ * @return - entry point address of the specified ELF object.\r
+ */\r
+static void *elf_loader_get_entry_point_address(\r
+ struct elf_decode_info *elf_info) {\r
+ return ((void *) elf_info->elf_header.e_entry);\r
+}\r
+\r
+/**\r
+ * elf_loader_relocate_link\r
+ *\r
+ * Relocates and links the given ELF object.\r
+ *\r
+ * @param elf_info - elf object decode info container.\r
+\r
+ *\r
+ * @return - 0 if success, error otherwise\r
+ */\r
+\r
+static int elf_loader_relocate_link(struct elf_decode_info *elf_info) {\r
+ int status = 0;\r
+\r
+ /* Check of .rel.dyn section exists in the ELF. */\r
+ if (elf_info->rel_dyn) {\r
+ /* Relocate and link .rel.dyn section. */\r
+ status = elf_loader_relocs_specific(elf_info, elf_info->rel_dyn);\r
+ }\r
+\r
+ /* Proceed to check if .rel.plt section exists, if no error encountered yet. */\r
+ if (status == 0 && elf_info->rel_plt) {\r
+ /* Relocate and link .rel.plt section. */\r
+ status = elf_loader_relocs_specific(elf_info, elf_info->rel_plt);\r
+ }\r
+\r
+ /* Return status to caller */\r
+ return (status);\r
+}\r
+\r
+/**\r
+ * elf_loader_seek_and_read\r
+ *\r
+ * Seeks to the specified offset in the given file and reads the data\r
+ * into the specified destination location.\r
+ *\r
+ * @param firmware - firmware to read from.\r
+ * @param destination - Location into which the data should be read.\r
+ * @param offset - Offset to seek in the file.\r
+ * @param size - Size of the data to read.\r
+\r
+ *\r
+ * @return - 0 if success, error otherwise\r
+ */\r
+\r
+static int elf_loader_seek_and_read(void *firmware, void *destination,\r
+ Elf32_Off offset, Elf32_Word size) {\r
+ char *src = (char *) firmware;\r
+\r
+ /* Seek to the specified offset. */\r
+ src = src + offset;\r
+\r
+ /* Read the data. */\r
+ env_memcpy((char *) destination, src, size);\r
+\r
+ /* Return status to caller. */\r
+ return (0);\r
+}\r
+\r
+/**\r
+ * elf_loader_read_headers\r
+ *\r
+ * Reads the ELF headers (ELF header, section headers and the section\r
+ * headers string table) essential to access further information from\r
+ * the file containing the ELF object.\r
+ *\r
+ * @param firmware - firmware to read from.\r
+ * @param elf_info - ELF object decode info container.\r
+ *\r
+ * @return - 0 if success, error otherwise\r
+ */\r
+static int elf_loader_read_headers(void *firmware,\r
+ struct elf_decode_info *elf_info) {\r
+ int status = 0;\r
+ unsigned int section_count;\r
+\r
+ /* Read the ELF header. */\r
+ status = elf_loader_seek_and_read(firmware, &(elf_info->elf_header), 0,\r
+ sizeof(Elf32_Ehdr));\r
+\r
+ /* Ensure the read was successful. */\r
+ if (!status) {\r
+ /* Get section count from the ELF header. */\r
+ section_count = elf_info->elf_header.e_shnum;\r
+\r
+ /* Allocate memory to read in the section headers. */\r
+ elf_info->section_headers_start = env_allocate_memory(\r
+ section_count * elf_info->elf_header.e_shentsize);\r
+\r
+ /* Check if the allocation was successful. */\r
+ if (elf_info->section_headers_start) {\r
+ /* Read the section headers list. */\r
+ status = elf_loader_seek_and_read(firmware,\r
+ elf_info->section_headers_start,\r
+ elf_info->elf_header.e_shoff,\r
+ section_count * elf_info->elf_header.e_shentsize);\r
+\r
+ /* Ensure the read was successful. */\r
+ if (!status) {\r
+ /* Compute the pointer to section header string table section. */\r
+ Elf32_Shdr *section_header_string_table =\r
+ (Elf32_Shdr *) (elf_info->section_headers_start\r
+ + elf_info->elf_header.e_shstrndx\r
+ * elf_info->elf_header.e_shentsize);\r
+\r
+ /* Allocate the memory for section header string table. */\r
+ elf_info->shstrtab = env_allocate_memory(\r
+ section_header_string_table->sh_size);\r
+\r
+ /* Ensure the allocation was successful. */\r
+ if (elf_info->shstrtab) {\r
+ /* Read the section headers string table. */\r
+ status = elf_loader_seek_and_read(firmware,\r
+ elf_info->shstrtab,\r
+ section_header_string_table->sh_offset,\r
+ section_header_string_table->sh_size);\r
+ }\r
+ }\r
+ }\r
+ }\r
+\r
+ /* Return status to caller. */\r
+ return (status);\r
+}\r
+\r
+/**\r
+ * elf_loader_file_read_sections\r
+ *\r
+ * Reads the ELF section contents from the specified file containing\r
+ * the ELF object.\r
+ *\r
+ * @param firmware - firmware to read from.\r
+ * @param elf_info - ELF object decode info container.\r
+ *\r
+ * @return - 0 if success, error otherwise\r
+ */\r
+static int elf_loader_load_sections(void *firmware,\r
+ struct elf_decode_info *elf_info) {\r
+ int status = 0;\r
+ Elf32_Shdr *current = (Elf32_Shdr *) (elf_info->section_headers_start);\r
+\r
+ /* Traverse all sections except the reserved null section. */\r
+ int section_count = elf_info->elf_header.e_shnum - 1;\r
+ while ((section_count > 0) && (status == 0)) {\r
+ /* Compute the pointer to section header. */\r
+ current = (Elf32_Shdr *) (((unsigned char *) current)\r
+ + elf_info->elf_header.e_shentsize);\r
+\r
+ /* Make sure the section can be allocated and is not empty. */\r
+ if ((current->sh_flags & SHF_ALLOC) && (current->sh_size)) {\r
+ char *destination = NULL;\r
+\r
+ /* Check if the section is part of runtime and is not section with\r
+ * no-load attributes such as BSS or heap. */\r
+ if ((current->sh_type & SHT_NOBITS) == 0) {\r
+ /* Compute the destination address where the section should\r
+ * be copied. */\r
+ destination = (char *) (current->sh_addr);\r
+ status = elf_loader_seek_and_read(firmware, destination,\r
+ current->sh_offset, current->sh_size);\r
+ }\r
+ }\r
+\r
+ /* Move to the next section. */\r
+ section_count--;\r
+ }\r
+\r
+ /* Return status to caller. */\r
+ return (status);\r
+}\r
+\r
+/**\r
+ * elf_loader_get_decode_info\r
+ *\r
+ * Retrieves the information necessary to decode the ELF object for\r
+ * loading, relocating and linking.\r
+ *\r
+ * @param firmware - firmware to read from.\r
+ * @param elf_info - ELF object decode info container.\r
+ *\r
+ * @return - 0 if success, error otherwise\r
+ */\r
+static int elf_loader_get_decode_info(void *firmware,\r
+ struct elf_decode_info *elf_info) {\r
+ int status;\r
+\r
+ /* Read the ELF headers (ELF header and section headers including\r
+ * the section header string table). */\r
+ status = elf_loader_read_headers(firmware, elf_info);\r
+\r
+ /* Ensure that ELF headers were read successfully. */\r
+ if (!status) {\r
+ /* Retrieve the sections required for load. */\r
+ elf_loader_get_needed_sections(elf_info);\r
+\r
+ }\r
+\r
+ /* Return status to caller. */\r
+ return (status);\r
+}\r
+\r
+/**\r
+ * elf_loader_get_dynamic_symbol_addr\r
+ *\r
+ * Retrieves the (relocatable) address of the symbol specified as\r
+ * index from the given ELF object.\r
+ *\r
+ * @param elf_info - ELF object decode info container.\r
+ * @param index - Index of the desired symbol in the dynamic symbol table.\r
+ *\r
+ * @return - Address of the specified symbol.\r
+ */\r
+static Elf32_Addr elf_loader_get_dynamic_symbol_addr(\r
+ struct elf_decode_info *elf_info, int index) {\r
+ Elf32_Sym *symbol_entry = (Elf32_Sym *) (elf_info->dynsym_addr\r
+ + index * elf_info->dynsym->sh_entsize);\r
+\r
+ /* Return the symbol address. */\r
+ return (symbol_entry->st_value);\r
+}\r
+\r
+/**\r
+ * elf_loader_reloc_entry\r
+ *\r
+ * Processes the specified relocation entry. It handles the relocation\r
+ * and linking both cases.\r
+ *\r
+ *\r
+ * @param elf_info - ELF object decode info container.\r
+ *\r
+ * @return - 0 if success, error otherwise\r
+ */\r
+static int elf_loader_reloc_entry(struct elf_decode_info *elf_info,\r
+ Elf32_Rel *rel_entry) {\r
+ unsigned char rel_type = ELF32_R_TYPE(rel_entry->r_info);\r
+ int status = 0;\r
+\r
+ switch (rel_type) {\r
+ case R_ARM_ABS32: /* 0x02 */\r
+ {\r
+ Elf32_Addr sym_addr = elf_loader_get_dynamic_symbol_addr(elf_info,\r
+ ELF32_R_SYM(rel_entry->r_info));\r
+\r
+ if (sym_addr) {\r
+ *((unsigned int *) (rel_entry->r_offset)) = (unsigned int) sym_addr;\r
+ break;\r
+ }\r
+ }\r
+\r
+ break;\r
+\r
+ default:\r
+ break;\r
+ }\r
+\r
+ return status;\r
+}\r
diff --git a/remoteproc/elf_loader.h b/remoteproc/elf_loader.h
--- /dev/null
+++ b/remoteproc/elf_loader.h
@@ -0,0 +1,234 @@
+/*\r
+ * Copyright (c) 2014, Mentor Graphics Corporation\r
+ * All rights reserved.\r
+ *\r
+ * Redistribution and use in source and binary forms, with or without\r
+ * modification, are permitted provided that the following conditions are met:\r
+ *\r
+ * 1. Redistributions of source code must retain the above copyright notice,\r
+ * this list of conditions and the following disclaimer.\r
+ * 2. Redistributions in binary form must reproduce the above copyright notice,\r
+ * this list of conditions and the following disclaimer in the documentation\r
+ * and/or other materials provided with the distribution.\r
+ * 3. Neither the name of Mentor Graphics Corporation nor the names of its\r
+ * contributors may be used to endorse or promote products derived from this\r
+ * software without specific prior written permission.\r
+ *\r
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"\r
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\r
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\r
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE\r
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\r
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\r
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\r
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\r
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\r
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\r
+ * POSSIBILITY OF SUCH DAMAGE.\r
+ */\r
+\r
+\r
+#ifndef ELF_LOADER_H_\r
+#define ELF_LOADER_H_\r
+\r
+#include "remoteproc_loader.h"\r
+\r
+/* ELF base types - 32-bit. */\r
+typedef unsigned int Elf32_Addr;\r
+typedef unsigned short Elf32_Half;\r
+typedef unsigned int Elf32_Off;\r
+typedef signed int Elf32_Sword;\r
+typedef unsigned int Elf32_Word;\r
+\r
+/* Size of ELF identifier field in the ELF file header. */\r
+#define EI_NIDENT 16\r
+\r
+/* ELF file header */\r
+typedef struct\r
+{\r
+ unsigned char e_ident[EI_NIDENT];\r
+ Elf32_Half e_type;\r
+ Elf32_Half e_machine;\r
+ Elf32_Word e_version;\r
+ Elf32_Addr e_entry;\r
+ Elf32_Off e_phoff;\r
+ Elf32_Off e_shoff;\r
+ Elf32_Word e_flags;\r
+ Elf32_Half e_ehsize;\r
+ Elf32_Half e_phentsize;\r
+ Elf32_Half e_phnum;\r
+ Elf32_Half e_shentsize;\r
+ Elf32_Half e_shnum;\r
+ Elf32_Half e_shstrndx;\r
+\r
+} Elf32_Ehdr;\r
+\r
+/* e_ident */\r
+#define ET_NONE 0\r
+#define ET_REL 1 /* Re-locatable file */\r
+#define ET_EXEC 2 /* Executable file */\r
+#define ET_DYN 3 /* Shared object file */\r
+#define ET_CORE 4 /* Core file */\r
+#define ET_LOOS 0xfe00 /* Operating system-specific */\r
+#define ET_HIOS 0xfeff /* Operating system-specific */\r
+#define ET_LOPROC 0xff00 /* remote_proc-specific */\r
+#define ET_HIPROC 0xffff /* remote_proc-specific */\r
+\r
+/* e_machine */\r
+#define EM_ARM 40 /* ARM/Thumb Architecture */\r
+\r
+/* e_version */\r
+#define EV_CURRENT 1 /* Current version */\r
+\r
+/* e_ident[] Identification Indexes */\r
+#define EI_MAG0 0 /* File identification */\r
+#define EI_MAG1 1 /* File identification */\r
+#define EI_MAG2 2 /* File identification */\r
+#define EI_MAG3 3 /* File identification */\r
+#define EI_CLASS 4 /* File class */\r
+#define EI_DATA 5 /* Data encoding */\r
+#define EI_VERSION 6 /* File version */\r
+#define EI_OSABI 7 /* Operating system/ABI identification */\r
+#define EI_ABIVERSION 8 /* ABI version */\r
+#define EI_PAD 9 /* Start of padding bytes */\r
+#define EI_NIDENT 16 /* Size of e_ident[] */\r
+\r
+/* EI_MAG0 to EI_MAG3 - A file's first 4 bytes hold amagic number, identifying the file as an ELF object file */\r
+#define ELFMAG0 0x7f /* e_ident[EI_MAG0] */\r
+#define ELFMAG1 'E' /* e_ident[EI_MAG1] */\r
+#define ELFMAG2 'L' /* e_ident[EI_MAG2] */\r
+#define ELFMAG3 'F' /* e_ident[EI_MAG3] */\r
+\r
+/* EI_CLASS - The next byte, e_ident[EI_CLASS], identifies the file's class, or capacity. */\r
+#define ELFCLASSNONE 0 /* Invalid class */\r
+#define ELFCLASS32 1 /* 32-bit objects */\r
+#define ELFCLASS64 2 /* 64-bit objects */\r
+\r
+/* EI_DATA - Byte e_ident[EI_DATA] specifies the data encoding of the remote_proc-specific data in the object\r
+file. The following encodings are currently defined. */\r
+#define ELFDATANONE 0 /* Invalid data encoding */\r
+#define ELFDATA2LSB 1 /* See Data encodings, below */\r
+#define ELFDATA2MSB 2 /* See Data encodings, below */\r
+\r
+/* EI_OSABI - We do not define a Nucleus specific OS ABI */\r
+#define ELFOSABI_NONE 0\r
+\r
+/* ELF section header. */\r
+typedef struct\r
+{\r
+ Elf32_Word sh_name;\r
+ Elf32_Word sh_type;\r
+ Elf32_Word sh_flags;\r
+ Elf32_Addr sh_addr;\r
+ Elf32_Off sh_offset;\r
+ Elf32_Word sh_size;\r
+ Elf32_Word sh_link;\r
+ Elf32_Word sh_info;\r
+ Elf32_Word sh_addralign;\r
+ Elf32_Word sh_entsize;\r
+\r
+} Elf32_Shdr;\r
+\r
+/* sh_type */\r
+#define SHT_NULL 0\r
+#define SHT_PROGBITS 1\r
+#define SHT_SYMTAB 2\r
+#define SHT_STRTAB 3\r
+#define SHT_RELA 4\r
+#define SHT_HASH 5\r
+#define SHT_DYNAMIC 6\r
+#define SHT_NOTE 7\r
+#define SHT_NOBITS 8\r
+#define SHT_REL 9\r
+#define SHT_SHLIB 10\r
+#define SHT_DYNSYM 11\r
+#define SHT_INIT_ARRAY 14\r
+#define SHT_FINI_ARRAY 15\r
+#define SHT_PREINIT_ARRAY 16\r
+#define SHT_GROUP 17\r
+#define SHT_SYMTAB_SHNDX 18\r
+#define SHT_LOOS 0x60000000\r
+#define SHT_HIOS 0x6fffffff\r
+#define SHT_LOPROC 0x70000000\r
+#define SHT_HIPROC 0x7fffffff\r
+#define SHT_LOUSER 0x80000000\r
+#define SHT_HIUSER 0xffffffff\r
+\r
+/* sh_flags */\r
+#define SHF_WRITE 0x1\r
+#define SHF_ALLOC 0x2\r
+#define SHF_EXECINSTR 0x4\r
+#define SHF_MASKPROC 0xf0000000\r
+\r
+/* Relocation entry (without addend) */\r
+typedef struct\r
+{\r
+ Elf32_Addr r_offset;\r
+ Elf32_Word r_info;\r
+\r
+} Elf32_Rel;\r
+\r
+/* Relocation entry with addend */\r
+typedef struct\r
+{\r
+ Elf32_Addr r_offset;\r
+ Elf32_Word r_info;\r
+ Elf32_Sword r_addend;\r
+\r
+} Elf32_Rela;\r
+\r
+/* Macros to extract information from 'r_info' field of relocation entries */\r
+#define ELF32_R_SYM(i) ((i)>>8)\r
+#define ELF32_R_TYPE(i) ((unsigned char)(i))\r
+\r
+/* Symbol table entry */\r
+typedef struct\r
+{\r
+ Elf32_Word st_name;\r
+ Elf32_Addr st_value;\r
+ Elf32_Word st_size;\r
+ unsigned char st_info;\r
+ unsigned char st_other;\r
+ Elf32_Half st_shndx;\r
+\r
+} Elf32_Sym;\r
+\r
+/* ARM specific dynamic relocation codes */\r
+#define R_ARM_GLOB_DAT 21 /* 0x15 */\r
+#define R_ARM_JUMP_SLOT 22 /* 0x16 */\r
+#define R_ARM_RELATIVE 23 /* 0x17 */\r
+#define R_ARM_ABS32 2 /* 0x02 */\r
+\r
+\r
+/* ELF decoding information */\r
+struct elf_decode_info\r
+{\r
+ Elf32_Ehdr elf_header;\r
+ unsigned char *section_headers_start;\r
+ char *shstrtab;\r
+\r
+ Elf32_Shdr *dynsym;\r
+ Elf32_Shdr *dynstr;\r
+ Elf32_Shdr *rel_plt;\r
+ Elf32_Shdr *rel_dyn;\r
+ Elf32_Shdr *rsc;\r
+\r
+ unsigned char *dynsym_addr;\r
+ unsigned char *dynstr_addr;\r
+\r
+ char *firmware;\r
+\r
+};\r
+\r
+\r
+\r
+/* ELF Loader functions. */\r
+int elf_loader_init(struct remoteproc_loader *loader);\r
+void *elf_loader_retrieve_entry_point(struct remoteproc_loader *loader);\r
+void *elf_loader_retrieve_resource_section(struct remoteproc_loader *loader, unsigned int *size);\r
+int elf_loader_load_remote_firmware(struct remoteproc_loader *loader);\r
+int elf_loader_attach_firmware(struct remoteproc_loader *loader, void *firmware);\r
+int elf_loader_detach_firmware(struct remoteproc_loader *loader);\r
+void *elf_get_load_address(struct remoteproc_loader *loader);\r
+\r
+#endif /* ELF_LOADER_H_ */\r
diff --git a/remoteproc/remoteproc.c b/remoteproc/remoteproc.c
--- /dev/null
+++ b/remoteproc/remoteproc.c
@@ -0,0 +1,351 @@
+/*\r
+ * Copyright (c) 2014, Mentor Graphics Corporation\r
+ * All rights reserved.\r
+ *\r
+ * Redistribution and use in source and binary forms, with or without\r
+ * modification, are permitted provided that the following conditions are met:\r
+ *\r
+ * 1. Redistributions of source code must retain the above copyright notice,\r
+ * this list of conditions and the following disclaimer.\r
+ * 2. Redistributions in binary form must reproduce the above copyright notice,\r
+ * this list of conditions and the following disclaimer in the documentation\r
+ * and/or other materials provided with the distribution.\r
+ * 3. Neither the name of Mentor Graphics Corporation nor the names of its\r
+ * contributors may be used to endorse or promote products derived from this\r
+ * software without specific prior written permission.\r
+ *\r
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"\r
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\r
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\r
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE\r
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\r
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\r
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\r
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\r
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\r
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\r
+ * POSSIBILITY OF SUCH DAMAGE.\r
+ */\r
+\r
+#include "remoteproc.h"\r
+#include "remoteproc_loader.h"\r
+#include "rsc_table_parser.h"\r
+#include "../porting/env/env.h"\r
+#include "../common/hil/hil.h"\r
+\r
+/**\r
+ * remoteproc_resource_init\r
+ *\r
+ * Initializes resources for remoteproc remote configuration. Only\r
+ * remoteproc remote applications are allowed to call this function.\r
+ *\r
+ * @param rsc_info - pointer to resource table info control\r
+ * block\r
+ * @param channel_created - callback function for channel creation\r
+ * @param channel_destroyed - callback function for channel deletion\r
+ * @param default_cb - default callback for channel I/O\r
+ * @param rproc_handle - pointer to new remoteproc instance\r
+ *\r
+ * @param returns - status of function execution\r
+ *\r
+ */\r
+int remoteproc_resource_init(struct rsc_table_info *rsc_info,\r
+ rpmsg_chnl_cb_t channel_created, rpmsg_chnl_cb_t channel_destroyed,\r
+ rpmsg_rx_cb_t default_cb, struct remote_proc** rproc_handle) {\r
+\r
+ struct remote_proc *rproc;\r
+ int status;\r
+\r
+ if(!rsc_info) {\r
+ return RPROC_ERR_PARAM;\r
+ }\r
+\r
+ /* Initialize environment component */\r
+ status = env_init();\r
+ if (status != RPROC_SUCCESS) {\r
+ return status;\r
+ }\r
+\r
+ rproc = env_allocate_memory(sizeof(struct remote_proc));\r
+ if (rproc) {\r
+ env_memset(rproc, 0x00, sizeof(struct remote_proc));\r
+ /* There can be only one master for remote configuration so use the\r
+ * rsvd cpu id for creating hil proc */\r
+ rproc->proc = hil_create_proc(HIL_RSVD_CPU_ID);\r
+ if (rproc->proc) {\r
+ /* Parse resource table */\r
+ status = handle_rsc_table(rproc, rsc_info->rsc_tab, rsc_info->size);\r
+ if (status == RPROC_SUCCESS) {\r
+ /* Initialize RPMSG "messaging" component */\r
+ status = rpmsg_init(rproc->proc->cpu_id, &rproc->rdev,\r
+ channel_created, channel_destroyed, default_cb,\r
+ RPMSG_MASTER);\r
+ } else {\r
+ status = RPROC_ERR_NO_RSC_TABLE;\r
+ }\r
+ } else {\r
+ status = RPROC_ERR_CPU_ID;\r
+ }\r
+ } else {\r
+ status = RPROC_ERR_NO_MEM;\r
+ }\r
+\r
+ /* Cleanup in case of error */\r
+ if (status != RPROC_SUCCESS) {\r
+ (void) remoteproc_resource_deinit(rproc);\r
+ return status;\r
+ }\r
+\r
+ *rproc_handle = rproc;\r
+\r
+ return status;\r
+}\r
+\r
+/**\r
+ * remoteproc_resource_deinit\r
+ *\r
+ * Uninitializes resources for remoteproc "remote" configuration.\r
+ *\r
+ * @param rproc - pointer to rproc instance\r
+ *\r
+ * @param returns - status of function execution\r
+ *\r
+ */\r
+\r
+int remoteproc_resource_deinit(struct remote_proc *rproc) {\r
+\r
+ if (rproc) {\r
+ if (rproc->rdev) {\r
+ rpmsg_deinit(rproc->rdev);\r
+ }\r
+ if (rproc->proc) {\r
+ hil_delete_proc(rproc->proc);\r
+ }\r
+\r
+ env_free_memory(rproc);\r
+ }\r
+\r
+ env_deinit();
+\r
+ /* Disable the caches - This is required if master boots firmwares\r
+ * multiple times without hard reset on same core. If caches are\r
+ * not invalidated at this point in time then subsequent firmware\r
+ * boots on the same core may experience cache inconsistencies.\r
+ *\r
+ */\r
+ env_disable_cache();
+\r
+ return RPROC_SUCCESS;\r
+}\r
+\r
+/**\r
+ * remoteproc_init\r
+ *\r
+ * Initializes resources for remoteproc master configuration. Only\r
+ * remoteproc master applications are allowed to call this function.\r
+ *\r
+ * @param fw_name - name of frimware\r
+ * @param channel_created - callback function for channel creation\r
+ * @param channel_destroyed - callback function for channel deletion\r
+ * @param default_cb - default callback for channel I/O\r
+ * @param rproc_handle - pointer to new remoteproc instance\r
+ * \r
+ * @param returns - status of function execution\r
+ *\r
+ */\r
+int remoteproc_init(char *fw_name, rpmsg_chnl_cb_t channel_created,\r
+ rpmsg_chnl_cb_t channel_destroyed, rpmsg_rx_cb_t default_cb,\r
+ struct remote_proc** rproc_handle) {\r
+\r
+ struct remote_proc *rproc;\r
+ struct resource_table *rsc_table;\r
+ unsigned int fw_addr, fw_size, rsc_size;\r
+ int status, cpu_id;\r
+\r
+ if (!fw_name) {\r
+ return RPROC_ERR_PARAM;\r
+ }\r
+\r
+ /* Initialize environment component */\r
+ status = env_init();\r
+ if (status != RPROC_SUCCESS) {\r
+ return status;\r
+ }\r
+\r
+ rproc = env_allocate_memory(sizeof(struct remote_proc));\r
+ if (rproc) {\r
+ env_memset((void *) rproc, 0x00, sizeof(struct remote_proc));\r
+ /* Get CPU ID for the given firmware name */\r
+ cpu_id = hil_get_cpuforfw(fw_name);\r
+ if (cpu_id >= 0) {\r
+ /* Create proc instance */\r
+ rproc->proc = hil_create_proc(cpu_id);\r
+ if (rproc->proc) {\r
+ /* Retrieve firmware attributes */\r
+ status = hil_get_firmware(fw_name, &fw_addr, &fw_size);\r
+ if (!status) {\r
+ /* Initialize ELF loader - currently only ELF format is supported */\r
+ rproc->loader = remoteproc_loader_init(ELF_LOADER);\r
+ if (rproc->loader) {\r
+ /* Attach the given firmware with the ELF parser/loader */\r
+ status = remoteproc_loader_attach_firmware(\r
+ rproc->loader, (void *) fw_addr);\r
+ } else {\r
+ status = RPROC_ERR_LOADER;\r
+ }\r
+ }\r
+ } else {\r
+ status = RPROC_ERR_NO_MEM;\r
+ }\r
+ } else {\r
+ status = RPROC_ERR_INVLD_FW;\r
+ }\r
+ } else {\r
+ status = RPROC_ERR_NO_MEM;\r
+ }\r
+\r
+ if (!status) {\r
+ rproc->role = RPROC_MASTER;\r
+ \r
+ /* Get resource table from firmware */\r
+ rsc_table = remoteproc_loader_retrieve_resource_section(rproc->loader,\r
+ &rsc_size);\r
+ if (rsc_table) {\r
+ /* Parse resource table */\r
+ status = handle_rsc_table(rproc, rsc_table, rsc_size);\r
+ } else {\r
+ status = RPROC_ERR_NO_RSC_TABLE;\r
+ }\r
+ }\r
+\r
+ /* Cleanup in case of error */\r
+ if (status != RPROC_SUCCESS) {\r
+ (void) remoteproc_deinit(rproc);\r
+ return status;\r
+ }\r
+\r
+ rproc->channel_created = channel_created;\r
+ rproc->channel_destroyed = channel_destroyed;\r
+ rproc->default_cb = default_cb;\r
+\r
+ *rproc_handle = rproc;\r
+\r
+ return status;\r
+}\r
+\r
+/**\r
+ * remoteproc_deinit\r
+ *\r
+ * Uninitializes resources for remoteproc "master" configuration.\r
+ *\r
+ * @param rproc - pointer to remote proc instance\r
+ *\r
+ * @param returns - status of function execution\r
+ *\r
+ */\r
+int remoteproc_deinit(struct remote_proc *rproc) {\r
+\r
+ if (rproc) {\r
+ if (rproc->loader) {\r
+ (void) remoteproc_loader_delete(rproc->loader);\r
+ rproc->loader = RPROC_NULL;\r
+ }\r
+ if (rproc->proc) {\r
+ hil_delete_proc(rproc->proc);\r
+ rproc->proc = RPROC_NULL;\r
+ }\r
+ env_free_memory(rproc);\r
+ }\r
+\r
+ env_deinit();\r
+\r
+ return RPROC_SUCCESS;\r
+}\r
+\r
+/**\r
+ * remoteproc_boot\r
+ *\r
+ * This function loads the image on the remote processor and starts\r
+ * its execution from image load address.\r
+ *\r
+ * @param rproc - pointer to remoteproc instance to boot\r
+ *\r
+ * @param returns - status of function execution\r
+ */\r
+int remoteproc_boot(struct remote_proc *rproc) {\r
+\r
+ void *load_addr;\r
+ int status;\r
+\r
+ if (!rproc) {\r
+ return RPROC_ERR_PARAM;\r
+ }\r
+\r
+ /* Stop the remote CPU */\r
+ hil_shutdown_cpu(rproc->proc);\r
+\r
+ /* Load the firmware */\r
+ status = remoteproc_loader_load_remote_firmware(rproc->loader);\r
+ if (status == RPROC_SUCCESS) {\r
+ load_addr = remoteproc_get_load_address(rproc->loader);\r
+ if (load_addr != RPROC_ERR_PTR) {\r
+ /* Start the remote cpu */\r
+ status = hil_boot_cpu(rproc->proc,\r
+ (unsigned int) load_addr);\r
+ if (status == RPROC_SUCCESS) {\r
+ /* Wait for remote side to come up. This delay is arbitrary and may\r
+ * need adjustment for different configuration of remote systems */\r
+ env_sleep_msec(RPROC_BOOT_DELAY);\r
+\r
+ /* Initialize RPMSG "messaging" component */\r
+\r
+ /* It is a work-around to work with remote Linux context. \r
+ Since the upstream Linux rpmsg implementation always \r
+ assumes itself to be an rpmsg master, we initialize\r
+ the remote device as an rpmsg master for remote Linux\r
+ configuration only. */\r
+#if defined (OPENAMP_REMOTE_LINUX_ENABLE)\r
+ status = rpmsg_init(rproc->proc->cpu_id, &rproc->rdev,\r
+ rproc->channel_created,\r
+ rproc->channel_destroyed, rproc->default_cb,\r
+ RPMSG_MASTER);\r
+#else\r
+ status = rpmsg_init(rproc->proc->cpu_id, &rproc->rdev,\r
+ rproc->channel_created,\r
+ rproc->channel_destroyed, rproc->default_cb,\r
+ RPMSG_REMOTE);\r
+#endif\r
+ }\r
+ } else {\r
+ status = RPROC_ERR_LOADER;\r
+ }\r
+ } else {\r
+ status = RPROC_ERR_LOADER;\r
+ }\r
+\r
+ return status;\r
+}\r
+\r
+/**\r
+ * remoteproc_shutdown\r
+ *\r
+ * This function shutdowns the remote execution context\r
+ *\r
+ * @param rproc - pointer to remote proc instance to shutdown\r
+ *\r
+ * @param returns - status of function execution\r
+ */\r
+int remoteproc_shutdown(struct remote_proc *rproc) {\r
+\r
+ if (rproc) {\r
+ if (rproc->rdev) {\r
+ rpmsg_deinit(rproc->rdev);\r
+ rproc->rdev = RPROC_NULL;\r
+ }\r
+ if (rproc->proc) {\r
+ hil_shutdown_cpu(rproc->proc);\r
+ }\r
+ }\r
+\r
+ return RPROC_SUCCESS;\r
+}\r
diff --git a/remoteproc/remoteproc.h b/remoteproc/remoteproc.h
--- /dev/null
+++ b/remoteproc/remoteproc.h
@@ -0,0 +1,466 @@
+/*
+ * Remote remote_proc Framework
+ *
+ * Copyright(c) 2011 Texas Instruments, Inc.
+ * Copyright(c) 2011 Google, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name Texas Instruments nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef REMOTEPROC_H
+#define REMOTEPROC_H
+
+#include "../rpmsg/rpmsg.h"
+#include "../porting/config/config.h"
+/**
+ * struct resource_table - firmware resource table header
+ * @ver: version number
+ * @num: number of resource entries
+ * @reserved: reserved (must be zero)
+ * @offset: array of offsets pointing at the various resource entries
+ *
+ * A resource table is essentially a list of system resources required
+ * by the remote remote_proc. It may also include configuration entries.
+ * If needed, the remote remote_proc firmware should contain this table
+ * as a dedicated ".resource_table" ELF section.
+ *
+ * Some resources entries are mere announcements, where the host is informed
+ * of specific remoteproc configuration. Other entries require the host to
+ * do something (e.g. allocate a system resource). Sometimes a negotiation
+ * is expected, where the firmware requests a resource, and once allocated,
+ * the host should provide back its details (e.g. address of an allocated
+ * memory region).
+ *
+ * The header of the resource table, as expressed by this structure,
+ * contains a version number (should we need to change this format in the
+ * future), the number of available resource entries, and their offsets
+ * in the table.
+ *
+ * Immediately following this header are the resource entries themselves,
+ * each of which begins with a resource entry header (as described below).
+ */
+struct resource_table {
+ unsigned int ver;
+ unsigned int num;
+ unsigned int reserved[2];
+ unsigned int offset[0];
+} __attribute__((__packed__));
+
+/**
+ * struct fw_rsc_hdr - firmware resource entry header
+ * @type: resource type
+ * @data: resource data
+ *
+ * Every resource entry begins with a 'struct fw_rsc_hdr' header providing
+ * its @type. The content of the entry itself will immediately follow
+ * this header, and it should be parsed according to the resource type.
+ */
+struct fw_rsc_hdr {
+ unsigned int type;
+ unsigned char data[0];
+} __attribute__((__packed__));
+
+/**
+ * enum fw_resource_type - types of resource entries
+ *
+ * @RSC_CARVEOUT: request for allocation of a physically contiguous
+ * memory region.
+ * @RSC_DEVMEM: request to iommu_map a memory-based peripheral.
+ * @RSC_TRACE: announces the availability of a trace buffer into which
+ * the remote remote_proc will be writing logs.
+ * @RSC_VDEV: declare support for a virtio device, and serve as its
+ * virtio header.
+ * @RSC_LAST: just keep this one at the end
+ *
+ * For more details regarding a specific resource type, please see its
+ * dedicated structure below.
+ *
+ * Please note that these values are used as indices to the rproc_handle_rsc
+ * lookup table, so please keep them sane. Moreover, @RSC_LAST is used to
+ * check the validity of an index before the lookup table is accessed, so
+ * please update it as needed.
+ */
+enum fw_resource_type {
+ RSC_CARVEOUT = 0,
+ RSC_DEVMEM = 1,
+ RSC_TRACE = 2,
+ RSC_VDEV = 3,
+ RSC_LAST = 4,
+};
+
+#define FW_RSC_ADDR_ANY (0xFFFFFFFFFFFFFFFF)
+
+/**
+ * struct fw_rsc_carveout - physically contiguous memory request
+ * @da: device address
+ * @pa: physical address
+ * @len: length (in bytes)
+ * @flags: iommu protection flags
+ * @reserved: reserved (must be zero)
+ * @name: human-readable name of the requested memory region
+ *
+ * This resource entry requests the host to allocate a physically contiguous
+ * memory region.
+ *
+ * These request entries should precede other firmware resource entries,
+ * as other entries might request placing other data objects inside
+ * these memory regions (e.g. data/code segments, trace resource entries, ...).
+ *
+ * Allocating memory this way helps utilizing the reserved physical memory
+ * (e.g. CMA) more efficiently, and also minimizes the number of TLB entries
+ * needed to map it (in case @rproc is using an IOMMU). Reducing the TLB
+ * pressure is important; it may have a substantial impact on performance.
+ *
+ * If the firmware is compiled with static addresses, then @da should specify
+ * the expected device address of this memory region. If @da is set to
+ * FW_RSC_ADDR_ANY, then the host will dynamically allocate it, and then
+ * overwrite @da with the dynamically allocated address.
+ *
+ * We will always use @da to negotiate the device addresses, even if it
+ * isn't using an iommu. In that case, though, it will obviously contain
+ * physical addresses.
+ *
+ * Some remote remote_procs needs to know the allocated physical address
+ * even if they do use an iommu. This is needed, e.g., if they control
+ * hardware accelerators which access the physical memory directly (this
+ * is the case with OMAP4 for instance). In that case, the host will
+ * overwrite @pa with the dynamically allocated physical address.
+ * Generally we don't want to expose physical addresses if we don't have to
+ * (remote remote_procs are generally _not_ trusted), so we might want to
+ * change this to happen _only_ when explicitly required by the hardware.
+ *
+ * @flags is used to provide IOMMU protection flags, and @name should
+ * (optionally) contain a human readable name of this carveout region
+ * (mainly for debugging purposes).
+ */
+struct fw_rsc_carveout {
+ unsigned int type;
+ unsigned int da;
+ unsigned int pa;
+ unsigned int len;
+ unsigned int flags;
+ unsigned int reserved;
+ unsigned char name[32];
+} __attribute__((__packed__));
+
+/**
+ * struct fw_rsc_devmem - iommu mapping request
+ * @da: device address
+ * @pa: physical address
+ * @len: length (in bytes)
+ * @flags: iommu protection flags
+ * @reserved: reserved (must be zero)
+ * @name: human-readable name of the requested region to be mapped
+ *
+ * This resource entry requests the host to iommu map a physically contiguous
+ * memory region. This is needed in case the remote remote_proc requires
+ * access to certain memory-based peripherals; _never_ use it to access
+ * regular memory.
+ *
+ * This is obviously only needed if the remote remote_proc is accessing memory
+ * via an iommu.
+ *
+ * @da should specify the required device address, @pa should specify
+ * the physical address we want to map, @len should specify the size of
+ * the mapping and @flags is the IOMMU protection flags. As always, @name may
+ * (optionally) contain a human readable name of this mapping (mainly for
+ * debugging purposes).
+ *
+ * Note: at this point we just "trust" those devmem entries to contain valid
+ * physical addresses, but this isn't safe and will be changed: eventually we
+ * want remoteproc implementations to provide us ranges of physical addresses
+ * the firmware is allowed to request, and not allow firmwares to request
+ * access to physical addresses that are outside those ranges.
+ */
+struct fw_rsc_devmem {
+ unsigned int type;
+ unsigned int da;
+ unsigned int pa;
+ unsigned int len;
+ unsigned int flags;
+ unsigned int reserved;
+ unsigned char name[32];
+} __attribute__((__packed__));
+
+/**
+ * struct fw_rsc_trace - trace buffer declaration
+ * @da: device address
+ * @len: length (in bytes)
+ * @reserved: reserved (must be zero)
+ * @name: human-readable name of the trace buffer
+ *
+ * This resource entry provides the host information about a trace buffer
+ * into which the remote remote_proc will write log messages.
+ *
+ * @da specifies the device address of the buffer, @len specifies
+ * its size, and @name may contain a human readable name of the trace buffer.
+ *
+ * After booting the remote remote_proc, the trace buffers are exposed to the
+ * user via debugfs entries (called trace0, trace1, etc..).
+ */
+struct fw_rsc_trace {
+ unsigned int type;
+ unsigned int da;
+ unsigned int len;
+ unsigned int reserved;
+ unsigned char name[32];
+} __attribute__((__packed__));
+
+/**
+ * struct fw_rsc_vdev_vring - vring descriptor entry
+ * @da: device address
+ * @align: the alignment between the consumer and producer parts of the vring
+ * @num: num of buffers supported by this vring (must be power of two)
+ * @notifyid is a unique rproc-wide notify index for this vring. This notify
+ * index is used when kicking a remote remote_proc, to let it know that this
+ * vring is triggered.
+ * @reserved: reserved (must be zero)
+ *
+ * This descriptor is not a resource entry by itself; it is part of the
+ * vdev resource type (see below).
+ *
+ * Note that @da should either contain the device address where
+ * the remote remote_proc is expecting the vring, or indicate that
+ * dynamically allocation of the vring's device address is supported.
+ */
+struct fw_rsc_vdev_vring {
+ unsigned int da;
+ unsigned int align;
+ unsigned int num;
+ unsigned int notifyid;
+ unsigned int reserved;
+} __attribute__((__packed__));
+
+/**
+ * struct fw_rsc_vdev - virtio device header
+ * @id: virtio device id (as in virtio_ids.h)
+ * @notifyid is a unique rproc-wide notify index for this vdev. This notify
+ * index is used when kicking a remote remote_proc, to let it know that the
+ * status/features of this vdev have changes.
+ * @dfeatures specifies the virtio device features supported by the firmware
+ * @gfeatures is a place holder used by the host to write back the
+ * negotiated features that are supported by both sides.
+ * @config_len is the size of the virtio config space of this vdev. The config
+ * space lies in the resource table immediate after this vdev header.
+ * @status is a place holder where the host will indicate its virtio progress.
+ * @num_of_vrings indicates how many vrings are described in this vdev header
+ * @reserved: reserved (must be zero)
+ * @vring is an array of @num_of_vrings entries of 'struct fw_rsc_vdev_vring'.
+ *
+ * This resource is a virtio device header: it provides information about
+ * the vdev, and is then used by the host and its peer remote remote_procs
+ * to negotiate and share certain virtio properties.
+ *
+ * By providing this resource entry, the firmware essentially asks remoteproc
+ * to statically allocate a vdev upon registration of the rproc (dynamic vdev
+ * allocation is not yet supported).
+ *
+ * Note: unlike virtualization systems, the term 'host' here means
+ * the Linux side which is running remoteproc to control the remote
+ * remote_procs. We use the name 'gfeatures' to comply with virtio's terms,
+ * though there isn't really any virtualized guest OS here: it's the host
+ * which is responsible for negotiating the final features.
+ * Yeah, it's a bit confusing.
+ *
+ * Note: immediately following this structure is the virtio config space for
+ * this vdev (which is specific to the vdev; for more info, read the virtio
+ * spec). the size of the config space is specified by @config_len.
+ */
+struct fw_rsc_vdev {
+ unsigned int type;
+ unsigned int id;
+ unsigned int notifyid;
+ unsigned int dfeatures;
+ unsigned int gfeatures;
+ unsigned int config_len;
+ unsigned char status;
+ unsigned char num_of_vrings;
+ unsigned char reserved[2];
+ struct fw_rsc_vdev_vring vring[0];
+} __attribute__((__packed__));
+
+/**
+ * struct remote_proc
+ *
+ * This structure is maintained by the remoteproc to represent the remote
+ * processor instance. This structure acts as a prime parameter to use
+ * the remoteproc APIs.
+ *
+ * @proc : hardware interface layer processor control
+ * @rdev : remote device , used by RPMSG "messaging" framework.
+ * @loader : pointer remoteproc loader
+ * @channel_created : create channel callback
+ * @channel_destroyed : delete channel callback
+ * @default_cb : default callback for channel
+ * @role : remote proc role , RPROC_MASTER/RPROC_REMOTE
+ *
+ */
+struct remote_proc {
+ struct hil_proc *proc;
+ struct remote_device *rdev;
+ struct remoteproc_loader *loader;
+ rpmsg_chnl_cb_t channel_created;
+ rpmsg_chnl_cb_t channel_destroyed;
+ rpmsg_rx_cb_t default_cb;
+ int role;
+};
+
+/**
+ * struct resc_table_info
+ *
+ * This structure is maintained by the remoteproc to allow applications
+ * to pass resource table info during remote initialization.
+ *
+ * @rsc_tab : pointer to resource table control block
+ * @size : size of resource table.
+ *
+ */
+struct rsc_table_info {
+ struct resource_table *rsc_tab;
+ int size;
+};
+
+/* Definitions for device types , null pointer, etc.*/
+#define RPROC_SUCCESS 0
+#define RPROC_NULL (void *)0
+#define RPROC_TRUE 1
+#define RPROC_FALSE 0
+#define RPROC_MASTER 1
+#define RPROC_REMOTE 0
+/* Number of msecs to wait for remote context to come up */
+#define RPROC_BOOT_DELAY 500
+
+/* Remoteproc error codes */
+#define RPROC_ERR_BASE -4000
+#define RPROC_ERR_CPU_ID (RPROC_ERR_BASE -1)
+#define RPROC_ERR_NO_RSC_TABLE (RPROC_ERR_BASE -2)
+#define RPROC_ERR_NO_MEM (RPROC_ERR_BASE -3)
+#define RPROC_ERR_RSC_TAB_TRUNC (RPROC_ERR_BASE -4)
+#define RPROC_ERR_RSC_TAB_VER (RPROC_ERR_BASE -5)
+#define RPROC_ERR_RSC_TAB_RSVD (RPROC_ERR_BASE -6)
+#define RPROC_ERR_RSC_TAB_VDEV_NRINGS (RPROC_ERR_BASE -7)
+#define RPROC_ERR_RSC_TAB_NP (RPROC_ERR_BASE -8)
+#define RPROC_ERR_RSC_TAB_NS (RPROC_ERR_BASE -9)
+#define RPROC_ERR_INVLD_FW (RPROC_ERR_BASE -10)
+#define RPROC_ERR_LOADER (RPROC_ERR_BASE -11)
+#define RPROC_ERR_PARAM (RPROC_ERR_BASE -12)
+#define RPROC_ERR_PTR (void*)0xDEADBEAF
+
+/**
+ * remoteproc_resource_init
+ *
+ * Initializes resources for remoteproc remote configuration.Only
+ * remoteproc remote applications are allowed to call this function.
+ *
+ * @param rsc_info - pointer to resource table info control
+ * block
+ * @param channel_created - callback function for channel creation
+ * @param channel_destroyed - callback function for channel deletion
+ * @param default_cb - default callback for channel I/O
+ * @param rproc_handle - pointer to new remoteproc instance
+ *
+ * @param returns - status of execution
+ *
+ */
+int remoteproc_resource_init(
+ struct rsc_table_info *rsc_info,
+ rpmsg_chnl_cb_t channel_created,
+ rpmsg_chnl_cb_t channel_destroyed,
+ rpmsg_rx_cb_t default_cb,
+ struct remote_proc** rproc_handle);
+
+
+/**
+ * remoteproc_resource_deinit
+ *
+ * Uninitializes resources for remoteproc remote configuration.
+ *
+ * @param rproc - pointer to remoteproc instance
+ *
+ * @param returns - status of execution
+ *
+ */
+
+int remoteproc_resource_deinit(struct remote_proc *rproc);
+
+/**
+ * remoteproc_init
+ *
+ * Initializes resources for remoteproc master configuration. Only
+ * remoteproc master applications are allowed to call this function.
+ *
+ * @param fw_name - name of firmware
+ * @param channel_created - callback function for channel creation
+ * @param channel_destroyed - callback function for channel deletion
+ * @param default_cb - default callback for channel I/O
+ * @param rproc_handle - pointer to new remoteproc instance
+ *
+ * @param returns - status of function execution
+ *
+ */
+int remoteproc_init(char *fw_name,
+ rpmsg_chnl_cb_t channel_created,
+ rpmsg_chnl_cb_t channel_destroyed,
+ rpmsg_rx_cb_t default_cb, struct remote_proc** rproc_handle);
+
+/**
+ * remoteproc_deinit
+ *
+ * Uninitializes resources for remoteproc "master" configuration.
+ *
+ * @param rproc - pointer to remoteproc instance
+ *
+ * @param returns - status of function execution
+ *
+ */
+int remoteproc_deinit(struct remote_proc *rproc);
+
+/**
+ * remoteproc_boot
+ *
+ * This function loads the image on the remote processor and starts
+ * its execution from image load address.
+ *
+ * @param rproc - pointer to remoteproc instance to boot
+ *
+ * @param returns - status of function execution
+ */
+int remoteproc_boot(struct remote_proc *rproc);
+
+/**
+ * remoteproc_shutdown
+ *
+ * This function shutdowns the remote execution context.
+ *
+ * @param rproc - pointer to remoteproc instance to shutdown
+ *
+ * @param returns - status of function execution
+ */
+int remoteproc_shutdown(struct remote_proc *rproc);
+
+#endif /* REMOTEPROC_H_ */
diff --git a/remoteproc/remoteproc_loader.c b/remoteproc/remoteproc_loader.c
--- /dev/null
@@ -0,0 +1,241 @@
+/*\r
+ * Copyright (c) 2014, Mentor Graphics Corporation\r
+ * All rights reserved.\r
+ *\r
+ * Redistribution and use in source and binary forms, with or without\r
+ * modification, are permitted provided that the following conditions are met:\r
+ *\r
+ * 1. Redistributions of source code must retain the above copyright notice,\r
+ * this list of conditions and the following disclaimer.\r
+ * 2. Redistributions in binary form must reproduce the above copyright notice,\r
+ * this list of conditions and the following disclaimer in the documentation\r
+ * and/or other materials provided with the distribution.\r
+ * 3. Neither the name of Mentor Graphics Corporation nor the names of its\r
+ * contributors may be used to endorse or promote products derived from this\r
+ * software without specific prior written permission.\r
+ *\r
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"\r
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\r
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\r
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE\r
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\r
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\r
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\r
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\r
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\r
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\r
+ * POSSIBILITY OF SUCH DAMAGE.\r
+ */\r
+\r
+#include "remoteproc_loader.h"\r
+\r
+/**\r
+ * remoteproc_loader_init\r
+ *\r
+ * Initializes the remoteproc loader.\r
+ *\r
+ * @param type - loader type\r
+ *\r
+ * @return - remoteproc_loader\r
+ */\r
+struct remoteproc_loader * remoteproc_loader_init(enum loader_type type) {\r
+\r
+ struct remoteproc_loader *loader;\r
+\r
+ /* Check for valid loader type. */\r
+ if (type >= LAST_LOADER) {\r
+ return RPROC_NULL ;\r
+ }\r
+\r
+ /* Allocate a loader handle. */\r
+ loader = env_allocate_memory(sizeof(struct remoteproc_loader));\r
+\r
+ if (!loader) {\r
+ return RPROC_NULL ;\r
+ }\r
+\r
+ /* Clear loader handle. */\r
+ env_memset(loader, 0, sizeof(struct remoteproc_loader));\r
+\r
+ /* Save loader type. */\r
+ loader->type = type;\r
+\r
+ switch (type) {\r
+\r
+ case ELF_LOADER:\r
+ elf_loader_init(loader);\r
+ break;\r
+\r
+ default:\r
+ /* Loader not supported. */\r
+ env_free_memory(loader);\r
+ loader = RPROC_NULL;\r
+ break;\r
+ }\r
+\r
+ return loader;\r
+}\r
+\r
+/**\r
+ * remoteproc_loader_delete\r
+ *\r
+ * Deletes the remoteproc loader.\r
+ *\r
+ * @param loader - pointer to remoteproc loader\r
+ *\r
+ * @return - 0 if success, error otherwise\r
+ */\r
+int remoteproc_loader_delete(struct remoteproc_loader *loader) {\r
+\r
+ int status;\r
+\r
+ if (!loader) {\r
+ return RPROC_ERR_PARAM;\r
+ }\r
+\r
+ /* Check if a firmware is attached. */\r
+ if (loader->remote_firmware) {\r
+\r
+ /* Detach firmware first. */\r
+ status = loader->detach_firmware(loader);\r
+ }\r
+\r
+ /* Recover the allocated memory. */\r
+ env_free_memory(loader);\r
+\r
+ return status;\r
+}\r
+\r
+/**\r
+ * remoteproc_loader_attach_firmware\r
+ *\r
+ * Attaches an ELF firmware to the loader\r
+ *\r
+ * @param loader - pointer to remoteproc loader\r
+ * @param firmware - pointer to the firmware start location\r
+ *\r
+ * @return - 0 if success, error otherwise\r
+ */\r
+int remoteproc_loader_attach_firmware(struct remoteproc_loader *loader,\r
+ void *firmware_image) {\r
+\r
+ int status = RPROC_SUCCESS;\r
+\r
+ if (!loader || !firmware_image) {\r
+ return RPROC_ERR_PARAM;\r
+ }\r
+\r
+ if (loader->attach_firmware) {\r
+\r
+ /* Check if a firmware is already attached. */\r
+ if (loader->remote_firmware) {\r
+\r
+ /* Detach firmware first. */\r
+ status = loader->detach_firmware(loader);\r
+ }\r
+\r
+ /* Attach firmware. */\r
+ if (!status) {\r
+ status = loader->attach_firmware(loader, firmware_image);\r
+\r
+ /* Save firmware address. */\r
+ if (!status) {\r
+ loader->remote_firmware = firmware_image;\r
+ }\r
+ }\r
+ }else{\r
+ status = RPROC_ERR_LOADER;\r
+ }\r
+\r
+ return status;\r
+}\r
+\r
+/**\r
+ * remoteproc_loader_retrieve_entry_point\r
+ *\r
+ * Provides entry point address.\r
+ *\r
+ * @param loader - pointer to remoteproc loader\r
+ *\r
+ * @return - entrypoint\r
+ */\r
+void *remoteproc_loader_retrieve_entry_point(struct remoteproc_loader *loader) {\r
+\r
+ if (!loader) {\r
+ return RPROC_NULL ;\r
+ }\r
+\r
+ if (loader->retrieve_entry) {\r
+ return loader->retrieve_entry(loader);\r
+ } else {\r
+ return RPROC_NULL ;\r
+ }\r
+}\r
+\r
+/**\r
+ * remoteproc_loader_retrieve_resource_section\r
+ *\r
+ * Provides resource section address.\r
+ *\r
+ * @param loader - pointer to remoteproc loader\r
+ * @param size - pointer to hold size of resource section\r
+ *\r
+ * @return - pointer to resource section\r
+ */\r
+void *remoteproc_loader_retrieve_resource_section(\r
+ struct remoteproc_loader *loader, unsigned int *size) {\r
+\r
+ if (!loader) {\r
+ return RPROC_NULL ;\r
+ }\r
+\r
+ if (loader->retrieve_rsc) {\r
+ return loader->retrieve_rsc(loader, size);\r
+ } else {\r
+ return RPROC_NULL ;\r
+ }\r
+}\r
+\r
+/**\r
+ * remoteproc_loader_load_remote_firmware\r
+ *\r
+ * Loads the firmware in memory\r
+ *\r
+ * @param loader - pointer to remoteproc loader\r
+ *\r
+ * @return - 0 if success, error otherwise\r
+ */\r
+int remoteproc_loader_load_remote_firmware(struct remoteproc_loader *loader) {\r
+\r
+ if (!loader) {\r
+ return RPROC_ERR_PARAM;\r
+ }\r
+\r
+ if (loader->load_firmware) {\r
+ return loader->load_firmware(loader);\r
+ } else {\r
+ return RPROC_ERR_LOADER;\r
+ }\r
+}\r
+\r
+/**\r
+ * remoteproc_get_load_address\r
+ *\r
+ * Provides firmware load address.\r
+ *\r
+ * @param loader - pointer to remoteproc loader\r
+ *\r
+ * @return - load address pointer\r
+ */\r
+void *remoteproc_get_load_address(struct remoteproc_loader *loader){\r
+\r
+ if (!loader) {\r
+ return RPROC_ERR_PTR;\r
+ }\r
+\r
+ if (loader->retrieve_load_addr) {\r
+ return loader->retrieve_load_addr(loader);\r
+ } else {\r
+ return RPROC_ERR_PTR;\r
+ }\r
+}\r
diff --git a/remoteproc/remoteproc_loader.h b/remoteproc/remoteproc_loader.h
--- /dev/null
@@ -0,0 +1,92 @@
+/*\r
+ * Copyright (c) 2014, Mentor Graphics Corporation\r
+ * All rights reserved.\r
+ *\r
+ * Redistribution and use in source and binary forms, with or without\r
+ * modification, are permitted provided that the following conditions are met:\r
+ *\r
+ * 1. Redistributions of source code must retain the above copyright notice,\r
+ * this list of conditions and the following disclaimer.\r
+ * 2. Redistributions in binary form must reproduce the above copyright notice,\r
+ * this list of conditions and the following disclaimer in the documentation\r
+ * and/or other materials provided with the distribution.\r
+ * 3. Neither the name of Mentor Graphics Corporation nor the names of its\r
+ * contributors may be used to endorse or promote products derived from this\r
+ * software without specific prior written permission.\r
+ *\r
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"\r
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\r
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\r
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE\r
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\r
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\r
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\r
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\r
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\r
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\r
+ * POSSIBILITY OF SUCH DAMAGE.\r
+ */\r
+\r
+/**************************************************************************\r
+ * FILE NAME\r
+ *\r
+ * remoteproc_loader.h\r
+ *\r
+ * COMPONENT\r
+ *\r
+ * OpenAMP stack.\r
+ *\r
+ * DESCRIPTION\r
+ *\r
+ * This file provides definitions for remoteproc loader\r
+ *\r
+ *\r
+ **************************************************************************/\r
+#ifndef REMOTEPROC_LOADER_H_\r
+#define REMOTEPROC_LOADER_H_\r
+\r
+#include "remoteproc.h"\r
+\r
+/**\r
+ * enum loader_type - dynamic name service announcement flags\r
+ *\r
+ * @ELF_LOADER: an ELF loader\r
+ * @FIT_LOADER: a loader for Flattened Image Trees\r
+ */\r
+enum loader_type {\r
+ ELF_LOADER = 0, FIT_LOADER = 1, LAST_LOADER = 2,\r
+};\r
+\r
+/* Loader structure definition. */\r
+\r
+struct remoteproc_loader {\r
+ enum loader_type type;\r
+ void *remote_firmware;\r
+ /* Pointer to firmware decoded info control block */\r
+ void *fw_decode_info;\r
+\r
+ /* Loader callbacks. */\r
+ void *(*retrieve_entry)(struct remoteproc_loader *loader);\r
+ void *(*retrieve_rsc)(struct remoteproc_loader *loader, unsigned int *size);\r
+ int (*load_firmware)(struct remoteproc_loader *loader);\r
+ int (*attach_firmware)(struct remoteproc_loader *loader, void *firmware);\r
+ int (*detach_firmware)(struct remoteproc_loader *loader);\r
+ void *(*retrieve_load_addr)(struct remoteproc_loader *loader);\r
+\r
+};\r
+\r
+/* RemoteProc Loader functions. */\r
+struct remoteproc_loader * remoteproc_loader_init(enum loader_type type);\r
+int remoteproc_loader_delete(struct remoteproc_loader *loader);\r
+int remoteproc_loader_attach_firmware(struct remoteproc_loader *loader,\r
+ void *firmware_image);\r
+void *remoteproc_loader_retrieve_entry_point(struct remoteproc_loader *loader);\r
+void *remoteproc_loader_retrieve_resource_section(\r
+ struct remoteproc_loader *loader, unsigned int* size);\r
+int remoteproc_loader_load_remote_firmware(struct remoteproc_loader *loader);\r
+void *remoteproc_get_load_address(struct remoteproc_loader *loader);\r
+\r
+/* Supported loaders */\r
+extern int elf_loader_init(struct remoteproc_loader *loader);\r
+\r
+#endif /* REMOTEPROC_LOADER_H_ */\r
diff --git a/remoteproc/rsc_table_parser.c b/remoteproc/rsc_table_parser.c
--- /dev/null
@@ -0,0 +1,234 @@
+/*
+ * Copyright (c) 2014, Mentor Graphics Corporation
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * 3. Neither the name of Mentor Graphics Corporation nor the names of its
+ * contributors may be used to endorse or promote products derived from this
+ * software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "rsc_table_parser.h"
+
+/* Resources handler */
+rsc_handler rsc_handler_table[] =
+{
+ handle_carve_out_rsc,
+ handle_trace_rsc,
+ handle_dev_mem_rsc,
+ handle_vdev_rsc,
+ handle_mmu_rsc
+};
+
+/**
+ * handle_rsc_table
+ *
+ * This function parses resource table.
+ *
+ * @param rproc - pointer to remote remote_proc
+ * @param rsc_table - resource table to parse
+ * @param size - size of rsc table
+ *
+ * @returns - execution status
+ *
+ */
+int handle_rsc_table(struct remote_proc *rproc, struct resource_table *rsc_table,
+ int size) {
+
+ unsigned char *rsc_start;
+ unsigned int *rsc_offset;
+ unsigned int rsc_type;
+ int idx, status;
+
+ /* Validate rsc table header fields*/
+
+ /* Minimum rsc table size */
+ if (sizeof(struct resource_table) > size) {
+ return (RPROC_ERR_RSC_TAB_TRUNC);
+ }
+
+ /* Supported version */
+ if (rsc_table->ver != RSC_TAB_SUPPORTED_VERSION) {
+ return (RPROC_ERR_RSC_TAB_VER);
+ }
+
+ /* Offset array */
+ if (sizeof(struct resource_table)
+ + rsc_table->num * sizeof(rsc_table->offset[0]) > size) {
+ return (RPROC_ERR_RSC_TAB_TRUNC);
+ }
+
+ /* Reserved fields - must be zero */
+ if ((rsc_table->reserved[0] != 0 || rsc_table->reserved[1]) != 0) {
+ return RPROC_ERR_RSC_TAB_RSVD;
+ }
+
+ rsc_start = (unsigned char *) rsc_table;
+
+ /* Loop through the offset array and parse each resource entry */
+ for (idx = 0; idx < rsc_table->num; idx++) {
+ rsc_offset = (unsigned int *) (rsc_start + rsc_table->offset[idx]);
+ rsc_type = *rsc_offset;
+ status = rsc_handler_table[rsc_type](rproc, (void *) rsc_offset);
+ if (status != RPROC_SUCCESS) {
+ break;
+ }
+ }
+
+ return status;
+}
+
+/**
+ * handle_carve_out_rsc
+ *
+ * Carveout resource handler.
+ *
+ * @param rproc - pointer to remote remote_proc
+ * @param rsc - pointer to carveout resource
+ *
+ * @returns - execution status
+ *
+ */
+int handle_carve_out_rsc(struct remote_proc *rproc, void *rsc) {
+ struct fw_rsc_carveout *carve_rsc = (struct fw_rsc_carveout *) rsc;
+
+ /* Validate resource fields */
+ if (!carve_rsc) {
+ return RPROC_ERR_RSC_TAB_NP;
+ }
+
+ if (carve_rsc->reserved) {
+ return RPROC_ERR_RSC_TAB_RSVD;
+ }
+
+ if (rproc->role == RPROC_MASTER) {
+ /* Map memory region for loading the image */
+ env_map_memory(carve_rsc->da, carve_rsc->da, carve_rsc->len,
+ (SHARED_MEM | UNCACHED));
+ }
+
+ return RPROC_SUCCESS;
+}
+
+/**
+ * handle_trace_rsc
+ *
+ * Trace resource handler.
+ *
+ * @param rproc - pointer to remote remote_proc
+ * @param rsc - pointer to trace resource
+ *
+ * @returns - execution status
+ *
+ */
+int handle_trace_rsc(struct remote_proc *rproc, void *rsc) {
+ return RPROC_ERR_RSC_TAB_NS;
+}
+
+/**
+ * handle_dev_mem_rsc
+ *
+ * Device memory resource handler.
+ *
+ * @param rproc - pointer to remote remote_proc
+ * @param rsc - pointer to device memory resource
+ *
+ * @returns - execution status
+ *
+ */
+int handle_dev_mem_rsc(struct remote_proc *rproc, void *rsc) {
+ return RPROC_ERR_RSC_TAB_NS;
+}
+
+/**
+ * handle_vdev_rsc
+ *
+ * Virtio device resource handler
+ *
+ * @param rproc - pointer to remote remote_proc
+ * @param rsc - pointer to virtio device resource
+ *
+ * @returns - execution status
+ *
+ */
+int handle_vdev_rsc(struct remote_proc *rproc, void *rsc) {
+
+ struct fw_rsc_vdev *vdev_rsc = (struct fw_rsc_vdev *) rsc;
+ struct fw_rsc_vdev_vring *vring;
+ struct proc_vdev *vdev;
+ struct proc_vring *vring_table;
+ int idx;
+
+ if (!vdev_rsc) {
+ return RPROC_ERR_RSC_TAB_NP;
+ }
+
+ /* Maximum supported vrings per Virtio device */
+ if (vdev_rsc->num_of_vrings > RSC_TAB_MAX_VRINGS) {
+ return RPROC_ERR_RSC_TAB_VDEV_NRINGS;
+ }
+
+ /* Reserved fields - must be zero */
+ if (vdev_rsc->reserved[0] || vdev_rsc->reserved[1]) {
+ return RPROC_ERR_RSC_TAB_RSVD;
+ }
+
+ /* Get the Virtio device from HIL proc */
+ vdev = hil_get_vdev_info(rproc->proc);
+
+ /* Initialize HIL Virtio device resources */
+ vdev->num_vrings = vdev_rsc->num_of_vrings;
+ vdev->dfeatures = vdev_rsc->dfeatures;
+ vdev->gfeatures = vdev_rsc->gfeatures;
+ vring_table = &vdev->vring_info[0];
+
+ for (idx = 0; idx < vdev_rsc->num_of_vrings; idx++) {
+ vring = &vdev_rsc->vring[idx];
+
+ /* Initialize HIL vring resources */
+ vring_table[idx].phy_addr = (void *) vring->da;
+ vring_table[idx].num_descs = vring->num;
+ vring_table[idx].align = vring->align;
+
+ /* Enable access to vring memory regions */
+ env_map_memory(vring->da, vring->da,
+ vring_size(vring->num, vring->align),
+ (SHARED_MEM | UNCACHED));
+ }
+
+ return RPROC_SUCCESS;
+}
+
+/**
+ * handle_mmu_rsc
+ *
+ * This function parses mmu resource , requested by the peripheral.
+ *
+ * @param rproc - pointer to remote remote_proc
+ * @param rsc - pointer to mmu resource
+ *
+ * @returns - execution status
+ *
+ */
+int handle_mmu_rsc(struct remote_proc *rproc, void *rsc) {
+ return RPROC_ERR_RSC_TAB_NS;
+}
diff --git a/remoteproc/rsc_table_parser.h b/remoteproc/rsc_table_parser.h
--- /dev/null
@@ -0,0 +1,53 @@
+/*\r
+ * Copyright (c) 2014, Mentor Graphics Corporation\r
+ * All rights reserved.\r
+ *\r
+ * Redistribution and use in source and binary forms, with or without\r
+ * modification, are permitted provided that the following conditions are met:\r
+ *\r
+ * 1. Redistributions of source code must retain the above copyright notice,\r
+ * this list of conditions and the following disclaimer.\r
+ * 2. Redistributions in binary form must reproduce the above copyright notice,\r
+ * this list of conditions and the following disclaimer in the documentation\r
+ * and/or other materials provided with the distribution.\r
+ * 3. Neither the name of Mentor Graphics Corporation nor the names of its\r
+ * contributors may be used to endorse or promote products derived from this\r
+ * software without specific prior written permission.\r
+ *\r
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"\r
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\r
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\r
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE\r
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\r
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\r
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\r
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\r
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\r
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\r
+ * POSSIBILITY OF SUCH DAMAGE.\r
+ */\r
+\r
+#ifndef RSC_TABLE_PARSER_H\r
+#define RSC_TABLE_PARSER_H\r
+\r
+#include "remoteproc.h"\r
+#include "../porting/env/env.h"\r
+#include "../common/hil/hil.h"\r
+\r
+#define RSC_TAB_SUPPORTED_VERSION 1\r
+#define RSC_TAB_HEADER_SIZE 12\r
+#define RSC_TAB_MAX_VRINGS 2\r
+\r
+/* Standard control request handling. */\r
+typedef int (*rsc_handler)(struct remote_proc *rproc, void * rsc);\r
+\r
+/* Function prototypes */\r
+int handle_rsc_table(struct remote_proc *rproc, struct resource_table *rsc_table,\r
+ int len);\r
+int handle_carve_out_rsc(struct remote_proc *rproc, void *rsc);\r
+int handle_trace_rsc(struct remote_proc *rproc, void *rsc);\r
+int handle_dev_mem_rsc(struct remote_proc *rproc, void *rsc);\r
+int handle_vdev_rsc(struct remote_proc *rproc, void *rsc);\r
+int handle_mmu_rsc(struct remote_proc *rproc, void *rsc);\r
+\r
+#endif /* RSC_TABLE_PARSER_H */\r
diff --git a/rpmsg/Makefile b/rpmsg/Makefile
--- /dev/null
+++ b/rpmsg/Makefile
@@ -0,0 +1,36 @@
+# Make file to create rpmsg library.\r
+\r
+# Include commons make file to get platform and tool chain specific variables.\r
+include ../Makefile.commons\r
+\r
+LIB := librpmsg.a\r
+\r
+# Include the header and source files required by the virtio lib.\r
+HEADERS += \\r
+$(wildcard *.h) \\r
+$(wildcard ../include/*.h) \\r
+$(wildcard ../hil/*.h) \\r
+$(wildcard ../env/*.h)\r
+\r
+SRCFILES += \\r
+$(wildcard *.c) \\r
+$(wildcard ../hil/*/*.c) \\r
+$(wildcard ../common/*.c) \\r
+$(wildcard ../env/*.c)\r
+\r
+OBJFILES := $(patsubst %.c, %.o, $(SRCFILES))\r
+\r
+all: $(LIB)\r
+\r
+$(LIB): $(OBJFILES)\r
+ @echo AR $@\r
+ @$(AR) -r $@ $(OBJFILES)\r
+\r
+%.o:%.c $(HEADERS)\r
+ @echo CC $(<:.c=.o)\r
+ @$(CC) $(CFLAGS) $(ARCH_CFLAGS) $(INCLUDE) -c $< -o $@\r
+\r
+clean:\r
+ -$(RM) $(LIB) $(OBJFILES)\r
+\r
+PHONY: all clean
\ No newline at end of file
diff --git a/rpmsg/remote_device.c b/rpmsg/remote_device.c
--- /dev/null
+++ b/rpmsg/remote_device.c
@@ -0,0 +1,520 @@
+/*\r
+ * Copyright (c) 2014, Mentor Graphics Corporation\r
+ * All rights reserved.\r
+ *\r
+ * Redistribution and use in source and binary forms, with or without\r
+ * modification, are permitted provided that the following conditions are met:\r
+ *\r
+ * 1. Redistributions of source code must retain the above copyright notice,\r
+ * this list of conditions and the following disclaimer.\r
+ * 2. Redistributions in binary form must reproduce the above copyright notice,\r
+ * this list of conditions and the following disclaimer in the documentation\r
+ * and/or other materials provided with the distribution.\r
+ * 3. Neither the name of Mentor Graphics Corporation nor the names of its\r
+ * contributors may be used to endorse or promote products derived from this\r
+ * software without specific prior written permission.\r
+ *\r
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"\r
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\r
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\r
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE\r
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\r
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\r
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\r
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\r
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\r
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\r
+ * POSSIBILITY OF SUCH DAMAGE.\r
+ */\r
+\r
+/**************************************************************************\r
+ * FILE NAME\r
+ *\r
+ * remote_device.c\r
+ *\r
+ * COMPONENT\r
+ *\r
+ * OpenAMP Stack\r
+ *\r
+ * DESCRIPTION\r
+ *\r
+ * This file provides services to manage the remote devices.It also implements\r
+ * the interface defined by the virtio and provides few other utility functions.\r
+ *\r
+ *\r
+ **************************************************************************/\r
+\r
+#include "rpmsg.h"\r
+\r
+/* Macro to initialize vring HW info */\r
+#define INIT_VRING_ALLOC_INFO(ring_info,vring_hw) \\r
+ (ring_info).phy_addr = (vring_hw).phy_addr; \\r
+ (ring_info).align = (vring_hw).align; \\r
+ (ring_info).num_descs = (vring_hw).num_descs\r
+\r
+/* Local functions */\r
+static int rpmsg_rdev_init_channels(struct remote_device *rdev);\r
+\r
+/* Ops table for virtio device */\r
+virtio_dispatch rpmsg_rdev_config_ops =\r
+{\r
+ rpmsg_rdev_create_virtqueues,\r
+ rpmsg_rdev_get_status,\r
+ rpmsg_rdev_set_status,\r
+ rpmsg_rdev_get_feature,\r
+ rpmsg_rdev_set_feature,\r
+ rpmsg_rdev_negotiate_feature,\r
+ rpmsg_rdev_read_config,\r
+ rpmsg_rdev_write_config,\r
+ rpmsg_rdev_reset\r
+};\r
+\r
+/**\r
+ * rpmsg_rdev_init\r
+ *\r
+ * This function creates and initializes the remote device. The remote device\r
+ * encapsulates virtio device.\r
+ *\r
+ * @param rdev - pointer to newly created remote device\r
+ * @param dev-id - ID of device to create , remote cpu id\r
+ * @param role - role of the other device, Master or Remote\r
+ * @param channel_created - callback function for channel creation\r
+ * @param channel_destroyed - callback function for channel deletion\r
+ * @param default_cb - default callback for channel\r
+ *\r
+ * @return - status of function execution\r
+ *\r
+ */\r
+int rpmsg_rdev_init(struct remote_device **rdev, int dev_id, int role,\r
+ rpmsg_chnl_cb_t channel_created,\r
+ rpmsg_chnl_cb_t channel_destroyed,\r
+ rpmsg_rx_cb_t default_cb) {\r
+\r
+ struct remote_device *rdev_loc;\r
+ struct virtio_device *virt_dev;\r
+ struct hil_proc *proc;\r
+ struct proc_shm *shm;\r
+ int status;\r
+\r
+ /* Initialize HIL data structures for given device */\r
+ proc = hil_create_proc(dev_id);\r
+\r
+ if (!proc) {\r
+ return RPMSG_ERR_DEV_ID;\r
+ }\r
+\r
+ /* Create software representation of remote processor. */\r
+ rdev_loc = (struct remote_device *) env_allocate_memory(\r
+ sizeof(struct remote_device));\r
+\r
+ if (!rdev_loc) {\r
+ return RPMSG_ERR_NO_MEM;\r
+ }\r
+\r
+ env_memset(rdev_loc, 0x00, sizeof(struct remote_device));\r
+ status = env_create_mutex(&rdev_loc->lock, 1);\r
+\r
+ if (status != RPMSG_SUCCESS) {\r
+\r
+ /* Cleanup required in case of error is performed by caller */\r
+ return status;\r
+ }\r
+\r
+ rdev_loc->proc = proc;\r
+ rdev_loc->role = role;\r
+ rdev_loc->channel_created = channel_created;\r
+ rdev_loc->channel_destroyed = channel_destroyed;\r
+ rdev_loc->default_cb = default_cb;\r
+\r
+ /* Initialize the virtio device */\r
+ virt_dev = &rdev_loc->virt_dev;\r
+ virt_dev->device = proc;\r
+ virt_dev->func = &rpmsg_rdev_config_ops;\r
+ if (virt_dev->func->set_features != RPMSG_NULL) {\r
+ virt_dev->func->set_features(virt_dev, proc->vdev.dfeatures);\r
+ }\r
+\r
+ if (rdev_loc->role == RPMSG_REMOTE) {\r
+ /*\r
+ * Since device is RPMSG Remote so we need to manage the\r
+ * shared buffers. Create shared memory pool to handle buffers.\r
+ */\r
+ shm = hil_get_shm_info(proc);\r
+ rdev_loc->mem_pool = sh_mem_create_pool(shm->start_addr, shm->size,\r
+ RPMSG_BUFFER_SIZE);\r
+\r
+ if (!rdev_loc->mem_pool) {\r
+ return RPMSG_ERR_NO_MEM;\r
+ }\r
+ }\r
+\r
+ /* Initialize channels for RPMSG Remote */\r
+ status = rpmsg_rdev_init_channels(rdev_loc);\r
+\r
+ if (status != RPMSG_SUCCESS) {\r
+ return status;\r
+ }\r
+\r
+ *rdev = rdev_loc;\r
+\r
+ return RPMSG_SUCCESS;\r
+}\r
+\r
+/**\r
+ * rpmsg_rdev_deinit\r
+ *\r
+ * This function un-initializes the remote device.\r
+ *\r
+ * @param rdev - pointer to remote device to deinit.\r
+ *\r
+ * @return - none\r
+ *\r
+ */\r
+void rpmsg_rdev_deinit(struct remote_device *rdev) {\r
+ struct llist *rp_chnl_head, *rp_chnl_temp, *node;\r
+ struct rpmsg_channel *rp_chnl;\r
+\r
+ rp_chnl_head = rdev->rp_channels;\r
+\r
+ while (rp_chnl_head != RPMSG_NULL ) {\r
+\r
+ rp_chnl_temp = rp_chnl_head->next;\r
+ rp_chnl = (struct rpmsg_channel *) rp_chnl_head->data;\r
+\r
+ if (rdev->channel_destroyed) {\r
+ rdev->channel_destroyed(rp_chnl);\r
+ }\r
+\r
+ if ((rdev->support_ns) && (rdev->role == RPMSG_MASTER)) {\r
+ rpmsg_send_ns_message(rdev, rp_chnl, RPMSG_NS_DESTROY);\r
+ }\r
+\r
+ /* Delete default endpoint for channel */\r
+ if (rp_chnl->rp_ept) {\r
+ rpmsg_destroy_ept(rp_chnl->rp_ept);\r
+ }\r
+\r
+ _rpmsg_delete_channel(rp_chnl);\r
+ rp_chnl_head = rp_chnl_temp;\r
+ }\r
+\r
+ /* Delete name service endpoint */\r
+ node = rpmsg_rdev_get_endpoint_from_addr(rdev,RPMSG_NS_EPT_ADDR);\r
+ if (node) {\r
+ _destroy_endpoint(rdev, (struct rpmsg_endpoint *) node->data);\r
+ }\r
+\r
+ if (rdev->rvq) {\r
+ virtqueue_free(rdev->rvq);\r
+ }\r
+ if (rdev->tvq) {\r
+ virtqueue_free(rdev->tvq);\r
+ }\r
+ if (rdev->mem_pool) {\r
+ sh_mem_delete_pool(rdev->mem_pool);\r
+ }\r
+ if (rdev->lock) {\r
+ env_delete_mutex(rdev->lock);\r
+ }\r
+\r
+ env_free_memory(rdev);\r
+}\r
+\r
+/**\r
+ * rpmsg_rdev_get_chnl_node_from_id\r
+ *\r
+ * This function returns channel node based on channel name.\r
+ *\r
+ * @param stack - pointer to remote device\r
+ * @param rp_chnl_id - rpmsg channel name\r
+ *\r
+ * @return - channel node\r
+ *\r
+ */\r
+struct llist *rpmsg_rdev_get_chnl_node_from_id(struct remote_device *rdev,\r
+ char *rp_chnl_id) {\r
+ struct rpmsg_channel *rp_chnl;\r
+ struct llist *rp_chnl_head;\r
+\r
+ rp_chnl_head = rdev->rp_channels;\r
+\r
+ env_lock_mutex(rdev->lock);\r
+ while (rp_chnl_head) {\r
+ rp_chnl = (struct rpmsg_channel *) rp_chnl_head->data;\r
+ if (env_strncmp(rp_chnl->name, rp_chnl_id, sizeof(rp_chnl->name))\r
+ == 0) {\r
+ env_unlock_mutex(rdev->lock);\r
+ return rp_chnl_head;\r
+ }\r
+ rp_chnl_head = rp_chnl_head->next;\r
+ }\r
+ env_unlock_mutex(rdev->lock);\r
+\r
+ return RPMSG_NULL ;\r
+}\r
+\r
+/**\r
+ * rpmsg_rdev_get_chnl_from_addr\r
+ *\r
+ * This function returns channel node based on src/dst address.\r
+ *\r
+ * @param rdev - pointer remote device control block\r
+ * @param addr - src/dst address\r
+ *\r
+ * @return - channel node\r
+ *\r
+ */\r
+struct llist *rpmsg_rdev_get_chnl_from_addr(struct remote_device *rdev,\r
+ unsigned long addr) {\r
+ struct rpmsg_channel *rp_chnl;\r
+ struct llist *rp_chnl_head;\r
+\r
+ rp_chnl_head = rdev->rp_channels;\r
+\r
+ env_lock_mutex(rdev->lock);\r
+ while (rp_chnl_head) {\r
+ rp_chnl = (struct rpmsg_channel *) rp_chnl_head->data;\r
+ if ((rp_chnl->src == addr) || (rp_chnl->dst == addr)) {\r
+ env_unlock_mutex(rdev->lock);\r
+ return rp_chnl_head;\r
+ }\r
+ rp_chnl_head = rp_chnl_head->next;\r
+ }\r
+ env_unlock_mutex(rdev->lock);\r
+\r
+ return RPMSG_NULL ;\r
+}\r
+\r
+/**\r
+ * rpmsg_rdev_get_endpoint_from_addr\r
+ *\r
+ * This function returns endpoint node based on src address.\r
+ *\r
+ * @param rdev - pointer remote device control block\r
+ * @param addr - src address\r
+ *\r
+ * @return - endpoint node\r
+ *\r
+ */\r
+struct llist *rpmsg_rdev_get_endpoint_from_addr(struct remote_device *rdev,\r
+ unsigned long addr) {\r
+ struct llist *rp_ept_lut_head;\r
+\r
+ rp_ept_lut_head = rdev->rp_endpoints;\r
+\r
+ env_lock_mutex(rdev->lock);\r
+ while (rp_ept_lut_head) {\r
+ struct rpmsg_endpoint *rp_ept =\r
+ (struct rpmsg_endpoint *) rp_ept_lut_head->data;\r
+ if (rp_ept->addr == addr) {\r
+ env_unlock_mutex(rdev->lock);\r
+ return rp_ept_lut_head;\r
+ }\r
+ rp_ept_lut_head = rp_ept_lut_head->next;\r
+ }\r
+ env_unlock_mutex(rdev->lock);\r
+\r
+ return RPMSG_NULL ;\r
+}\r
+/*\r
+ * rpmsg_rdev_notify\r
+ *\r
+ * This function checks whether remote device is up or not. If it is up then\r
+ * notification is sent based on device role to start IPC.\r
+ *\r
+ * @param rdev - pointer to remote device\r
+ *\r
+ * @return - status of function execution\r
+ *\r
+ */\r
+int rpmsg_rdev_notify(struct remote_device *rdev) {\r
+ int status = RPMSG_SUCCESS;\r
+\r
+ if (rdev->role == RPMSG_REMOTE) {\r
+ status = hil_get_status(rdev->proc);\r
+\r
+ /*\r
+ * Let the remote device know that Master is ready for\r
+ * communication.\r
+ */\r
+ if (!status)\r
+ virtqueue_kick(rdev->rvq);\r
+\r
+ } else {\r
+ status = hil_set_status(rdev->proc);\r
+ }\r
+\r
+ if (status == RPMSG_SUCCESS) {\r
+ rdev->state = RPMSG_DEV_STATE_ACTIVE;\r
+ }\r
+\r
+ return status;\r
+}\r
+/**\r
+ * rpmsg_rdev_init_channels\r
+ *\r
+ * This function is only applicable to RPMSG remote. It obtains channel IDs\r
+ * from the HIL and creates RPMSG channels corresponding to each ID.\r
+ *\r
+ * @param rdev - pointer to remote device\r
+ *\r
+ * @return - status of function execution\r
+ *\r
+ */\r
+int rpmsg_rdev_init_channels(struct remote_device *rdev) {\r
+ struct rpmsg_channel *rp_chnl;\r
+ struct proc_chnl *chnl_info;\r
+ int num_chnls, idx;\r
+\r
+ if (rdev->role == RPMSG_MASTER) {\r
+\r
+ chnl_info = hil_get_chnl_info(rdev->proc, &num_chnls);\r
+ for (idx = 0; idx < num_chnls; idx++) {\r
+\r
+ rp_chnl = _rpmsg_create_channel(rdev, chnl_info[idx].name, 0x00,\r
+ RPMSG_NS_EPT_ADDR);\r
+ if (!rp_chnl) {\r
+ return RPMSG_ERR_NO_MEM;\r
+ }\r
+\r
+ rp_chnl->rp_ept = rpmsg_create_ept(rp_chnl, rdev->default_cb, rdev,\r
+ RPMSG_ADDR_ANY);\r
+\r
+ if (!rp_chnl->rp_ept) {\r
+ return RPMSG_ERR_NO_MEM;\r
+ }\r
+\r
+ rp_chnl->src = rp_chnl->rp_ept->addr;\r
+ }\r
+ }\r
+\r
+ return RPMSG_SUCCESS;\r
+}\r
+\r
+/**\r
+ *------------------------------------------------------------------------\r
+ * The rest of the file implements the virtio device interface as defined\r
+ * by the virtio.h file.\r
+ *------------------------------------------------------------------------\r
+ */\r
+int rpmsg_rdev_create_virtqueues(struct virtio_device *dev, int flags, int nvqs,\r
+ const char *names[], vq_callback *callbacks[],\r
+ struct virtqueue *vqs_[]) {\r
+ struct remote_device *rdev;\r
+ struct vring_alloc_info ring_info;\r
+ struct virtqueue *vqs[RPMSG_MAX_VQ_PER_RDEV];\r
+ struct proc_vring *vring_table;\r
+ void *buffer;\r
+ struct llist node;\r
+ int idx, num_vrings, status;\r
+\r
+ rdev = (struct remote_device*) dev;\r
+\r
+ /* Get the vring HW info for the given virtio device */\r
+ vring_table = hil_get_vring_info(&rdev->proc->vdev,\r
+ &num_vrings);\r
+\r
+ if (num_vrings > nvqs) {\r
+ return RPMSG_ERR_MAX_VQ;\r
+ }\r
+\r
+ /* Create virtqueue for each vring. */\r
+ for (idx = 0; idx < num_vrings; idx++) {\r
+\r
+ INIT_VRING_ALLOC_INFO( ring_info, vring_table[idx]);\r
+\r
+ if (rdev->role == RPMSG_REMOTE) {\r
+ env_memset((void*) ring_info.phy_addr, 0x00,\r
+ vring_size(vring_table[idx].num_descs,\r
+ vring_table[idx].align));\r
+ }\r
+\r
+ status = virtqueue_create(dev, idx, (char *) names[idx], &ring_info,\r
+ callbacks[idx], hil_vring_notify,\r
+ &vqs[idx]);\r
+\r
+ if (status != RPMSG_SUCCESS) {\r
+ return status;\r
+ }\r
+\r
+ /* Initialize notifications for vring. */\r
+ status = hil_enable_vring_notifications(idx, vqs[idx]);\r
+\r
+ if (status != RPMSG_SUCCESS) {\r
+ return status;\r
+ }\r
+ }\r
+\r
+ //FIXME - a better way to handle this , tx for master is rx for remote and vice versa.\r
+ if (rdev->role == RPMSG_MASTER) {\r
+ rdev->tvq = vqs[0];\r
+ rdev->rvq = vqs[1];\r
+ } else {\r
+ rdev->tvq = vqs[1];\r
+ rdev->rvq = vqs[0];\r
+ }\r
+\r
+ if (rdev->role == RPMSG_REMOTE) {\r
+ for (idx = 0; ((idx < rdev->rvq->vq_nentries)\r
+ && (idx < rdev->mem_pool->total_buffs / 2));\r
+ idx++) {\r
+\r
+ /* Initialize TX virtqueue buffers for remote device */\r
+ buffer = sh_mem_get_buffer(rdev->mem_pool);\r
+\r
+ if (!buffer) {\r
+ return RPMSG_ERR_NO_BUFF;\r
+ }\r
+\r
+ node.data = buffer;\r
+ node.attr = RPMSG_BUFFER_SIZE;\r
+ node.next = RPMSG_NULL;\r
+\r
+ env_memset(buffer, 0x00, RPMSG_BUFFER_SIZE);\r
+ status = virtqueue_add_buffer(rdev->rvq, &node, 0, 1, buffer);\r
+\r
+ if (status != RPMSG_SUCCESS) {\r
+ return status;\r
+ }\r
+ }\r
+ }\r
+\r
+ return RPMSG_SUCCESS;\r
+}\r
+\r
+unsigned char rpmsg_rdev_get_status(struct virtio_device *dev) {\r
+ return 0;\r
+}\r
+\r
+void rpmsg_rdev_set_status(struct virtio_device *dev, unsigned char status) {\r
+\r
+}\r
+\r
+unsigned long rpmsg_rdev_get_feature(struct virtio_device *dev) {\r
+ return dev->features;\r
+}\r
+\r
+void rpmsg_rdev_set_feature(struct virtio_device *dev, unsigned long feature) {\r
+ dev->features |= feature;\r
+}\r
+\r
+unsigned long rpmsg_rdev_negotiate_feature(struct virtio_device *dev,\r
+ unsigned long features) {\r
+ return 0;\r
+}\r
+/*\r
+ * Read/write a variable amount from the device specific (ie, network)\r
+ * configuration region. This region is encoded in the same endian as\r
+ * the guest.\r
+ */\r
+void rpmsg_rdev_read_config(struct virtio_device *dev, unsigned long offset,\r
+ void *dst, int length) {\r
+ return;\r
+}\r
+void rpmsg_rdev_write_config(struct virtio_device *dev, unsigned long offset,\r
+ void *src, int length) {\r
+ return;\r
+}\r
+void rpmsg_rdev_reset(struct virtio_device *dev) {\r
+ return;\r
+}\r
diff --git a/rpmsg/rpmsg.c b/rpmsg/rpmsg.c
--- /dev/null
+++ b/rpmsg/rpmsg.c
@@ -0,0 +1,414 @@
+/*\r
+ * Copyright (c) 2014, Mentor Graphics Corporation\r
+ * All rights reserved.\r
+ *\r
+ * Redistribution and use in source and binary forms, with or without\r
+ * modification, are permitted provided that the following conditions are met:\r
+ *\r
+ * 1. Redistributions of source code must retain the above copyright notice,\r
+ * this list of conditions and the following disclaimer.\r
+ * 2. Redistributions in binary form must reproduce the above copyright notice,\r
+ * this list of conditions and the following disclaimer in the documentation\r
+ * and/or other materials provided with the distribution.\r
+ * 3. Neither the name of Mentor Graphics Corporation nor the names of its\r
+ * contributors may be used to endorse or promote products derived from this\r
+ * software without specific prior written permission.\r
+ *\r
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"\r
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\r
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\r
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE\r
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\r
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\r
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\r
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\r
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\r
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\r
+ * POSSIBILITY OF SUCH DAMAGE.\r
+ */\r
+\r
+/**************************************************************************\r
+ * FILE NAME\r
+ *\r
+ * rpmsg.c\r
+ *\r
+ * COMPONENT\r
+ *\r
+ * OpenAMP stack.\r
+ *\r
+ * DESCRIPTION\r
+ *\r
+ * Main file for the RPMSG driver. This file implements APIs as defined by\r
+ * RPMSG documentation(Linux docs) and also provides some utility functions.\r
+ *\r
+ * RPMSG driver represents each processor/core to which it communicates with\r
+ * remote_device control block.\r
+ * Each remote device(processor) defines its role in the communication i.e\r
+ * whether it is RPMSG Master or Remote. If the device(processor) to which\r
+ * driver is talking is RPMSG master then RPMSG driver implicitly behaves as\r
+ * Remote and vice versa.\r
+ * RPMSG Master is responsible for initiating communications with the Remote\r
+ * and shared buffers management. Terms remote device/core/proc are used\r
+ * interchangeably for the processor to which RPMSG driver is communicating\r
+ * irrespective of the fact whether it is RPMSG Remote or Master.\r
+ *\r
+ **************************************************************************/\r
+#include "rpmsg.h"\r
+\r
+/**\r
+ * rpmsg_init\r
+ *\r
+ * Thus function allocates and initializes the rpmsg driver resources for\r
+ * given device ID(cpu id). The successful return from this function leaves\r
+ * fully enabled IPC link.\r
+ *\r
+ * @param dev_id - remote device for which driver is to\r
+ * be initialized\r
+ * @param rdev - pointer to newly created remote device\r
+ * @param channel_created - callback function for channel creation\r
+ * @param channel_destroyed - callback function for channel deletion\r
+ * @param default_cb - default callback for channel I/O\r
+ * @param role - role of the other device, Master or Remote\r
+ *\r
+ * @return - status of function execution\r
+ *\r
+ */\r
+\r
+int rpmsg_init(int dev_id, struct remote_device **rdev,\r
+ rpmsg_chnl_cb_t channel_created,\r
+ rpmsg_chnl_cb_t channel_destroyed,\r
+ rpmsg_rx_cb_t default_cb, int role) {\r
+ int status;\r
+\r
+ /* Initialize IPC environment */\r
+ status = env_init();\r
+ if (status == RPMSG_SUCCESS) {\r
+ /* Initialize the remote device for given cpu id */\r
+ status = rpmsg_rdev_init(rdev, dev_id, role, channel_created,\r
+ channel_destroyed, default_cb);\r
+ if (status == RPMSG_SUCCESS) {\r
+ /* Kick off IPC with the remote device */\r
+ status = rpmsg_start_ipc(*rdev);\r
+ }\r
+ }\r
+\r
+ /* Deinit system in case of error */\r
+ if (status != RPMSG_SUCCESS) {\r
+ rpmsg_deinit(*rdev);\r
+ }\r
+\r
+ return status;\r
+}\r
+\r
+/**\r
+ * rpmsg_deinit\r
+ *\r
+ * Thus function frees rpmsg driver resources for given remote device.\r
+ *\r
+ * @param rdev - pointer to device to de-init\r
+ *\r
+ */\r
+\r
+void rpmsg_deinit(struct remote_device *rdev) {\r
+ if (rdev) {\r
+ rpmsg_rdev_deinit(rdev);\r
+ env_deinit();\r
+ }\r
+}\r
+\r
+/**\r
+ * This function sends rpmsg "message" to remote device.\r
+ *\r
+ * @param rp_chnl - pointer to rpmsg channel\r
+ * @param src - source address of channel\r
+ * @param dst - destination address of channel\r
+ * @param data - data to transmit\r
+ * @param size - size of data\r
+ * @param wait - boolean, wait or not for buffer to become\r
+ * available\r
+ *\r
+ * @return - status of function execution\r
+ *\r
+ */\r
+\r
+int rpmsg_send_offchannel_raw(struct rpmsg_channel *rp_chnl, unsigned long src,\r
+ unsigned long dst, char *data, int size, int wait) {\r
+ struct remote_device *rdev;\r
+ struct rpmsg_hdr *rp_hdr;\r
+ void *buffer;\r
+ int status = RPMSG_SUCCESS;\r
+ unsigned short idx;\r
+ int tick_count = 0;\r
+ int buff_len;\r
+\r
+ if (!rp_chnl) {\r
+ return RPMSG_ERR_PARAM;\r
+ }\r
+\r
+ /* Get the associated remote device for channel. */\r
+ rdev = rp_chnl->rdev;\r
+\r
+ /* Validate device state */\r
+ if (rp_chnl->state != RPMSG_CHNL_STATE_ACTIVE\r
+ || rdev->state != RPMSG_DEV_STATE_ACTIVE) {\r
+ return RPMSG_ERR_DEV_STATE;\r
+ }\r
+\r
+ /* Lock the device to enable exclusive access to virtqueues */\r
+ env_lock_mutex(rdev->lock);\r
+ /* Get rpmsg buffer for sending message. */\r
+ buffer = rpmsg_get_tx_buffer(rdev, &buff_len, &idx);\r
+ if (!buffer && !wait) {\r
+ status = RPMSG_ERR_NO_MEM;\r
+ }\r
+ env_unlock_mutex(rdev->lock);\r
+\r
+ if (status == RPMSG_SUCCESS) {\r
+\r
+ while (!buffer) {\r
+ /*\r
+ * Wait parameter is true - pool the buffer for\r
+ * 15 secs as defined by the APIs.\r
+ */\r
+ env_sleep_msec(RPMSG_TICKS_PER_INTERVAL);\r
+ env_lock_mutex(rdev->lock);\r
+ buffer = rpmsg_get_tx_buffer(rdev, &buff_len, &idx);\r
+ env_unlock_mutex(rdev->lock);\r
+ tick_count += RPMSG_TICKS_PER_INTERVAL;\r
+ if (tick_count >= (RPMSG_TICK_COUNT / RPMSG_TICKS_PER_INTERVAL)) {\r
+ status = RPMSG_ERR_NO_BUFF;\r
+ break;\r
+ }\r
+ }\r
+\r
+ if (status == RPMSG_SUCCESS) {\r
+ //FIXME : may be just copy the data size equal to buffer length and Tx it.\r
+ if (size > (buff_len - sizeof(struct rpmsg_hdr)))\r
+ status = RPMSG_ERR_BUFF_SIZE;\r
+\r
+ if (status == RPMSG_SUCCESS) {\r
+ rp_hdr = (struct rpmsg_hdr *) buffer;\r
+\r
+ /* Initialize RPMSG header. */\r
+ rp_hdr->dst = dst;\r
+ rp_hdr->src = src;\r
+ rp_hdr->len = size;\r
+\r
+ /* Copy data to rpmsg buffer. */\r
+ env_memcpy(rp_hdr->data, data, size);\r
+\r
+ env_lock_mutex(rdev->lock);\r
+ /* Enqueue buffer on virtqueue. */\r
+ status = rpmsg_enqueue_buffer(rdev, buffer, buff_len, idx);\r
+ if (status == RPMSG_SUCCESS) {\r
+ /* Let the other side know that there is a job to process. */\r
+ virtqueue_kick(rdev->tvq);\r
+ }\r
+ env_unlock_mutex(rdev->lock);\r
+ }\r
+\r
+ }\r
+ }\r
+\r
+ /* Do cleanup in case of error.*/\r
+ if (status != RPMSG_SUCCESS) {\r
+ rpmsg_free_buffer(rdev, buffer);\r
+ }\r
+\r
+ return status;\r
+}\r
+\r
+/**\r
+ * rpmsg_get_buffer_size\r
+ *\r
+ * Returns buffer size available for sending messages.\r
+ *\r
+ * @param channel - pointer to rpmsg channel\r
+ *\r
+ * @return - buffer size\r
+ *\r
+ */\r
+int rpmsg_get_buffer_size(struct rpmsg_channel *rp_chnl) {\r
+ struct remote_device *rdev;\r
+ int length;\r
+\r
+ if (!rp_chnl) {\r
+ return RPMSG_ERR_PARAM;\r
+ }\r
+\r
+ /* Get associated remote device for channel. */\r
+ rdev = rp_chnl->rdev;\r
+\r
+ /* Validate device state */\r
+ if (rp_chnl->state != RPMSG_CHNL_STATE_ACTIVE\r
+ || rdev->state != RPMSG_DEV_STATE_ACTIVE) {\r
+ return RPMSG_ERR_DEV_STATE;\r
+ }\r
+\r
+ env_lock_mutex(rdev->lock);\r
+\r
+ if (rdev->role == RPMSG_REMOTE) {\r
+ /*\r
+ * If device role is Remote then buffers are provided by us\r
+ * (RPMSG Master), so just provide the macro.\r
+ */\r
+ length = RPMSG_BUFFER_SIZE - sizeof(struct rpmsg_hdr);\r
+ } else {\r
+ /*\r
+ * If other core is Master then buffers are provided by it,\r
+ * so get the buffer size from the virtqueue.\r
+ */\r
+ length = (int) virtqueue_get_desc_size(rdev->tvq) - sizeof(struct rpmsg_hdr);\r
+ }\r
+\r
+ env_unlock_mutex(rdev->lock);\r
+\r
+ return length;\r
+}\r
+\r
+/**\r
+ * rpmsg_create_ept\r
+ *\r
+ * This function creates rpmsg endpoint for the rpmsg channel.\r
+ *\r
+ * @param channel - pointer to rpmsg channel\r
+ * @param cb - Rx completion call back\r
+ * @param priv - private data\r
+ * @param addr - endpoint src address\r
+ *\r
+ * @return - pointer to endpoint control block\r
+ *\r
+ */\r
+struct rpmsg_endpoint *rpmsg_create_ept(struct rpmsg_channel *rp_chnl,\r
+ rpmsg_rx_cb_t cb, void *priv, unsigned long addr) {\r
+\r
+ struct remote_device *rdev = RPMSG_NULL;\r
+ struct rpmsg_endpoint *rp_ept = RPMSG_NULL;\r
+\r
+ if (!rp_chnl || !cb) {\r
+ return RPMSG_NULL ;\r
+ }\r
+\r
+ rdev = rp_chnl->rdev;\r
+\r
+ rp_ept = _create_endpoint(rdev, cb, priv, addr);\r
+\r
+ if (rp_ept) {\r
+ rp_ept->rp_chnl = rp_chnl;\r
+ }\r
+\r
+ return rp_ept;\r
+}\r
+\r
+/**\r
+ * rpmsg_destroy_ept\r
+ *\r
+ * This function deletes rpmsg endpoint and performs cleanup.\r
+ *\r
+ * @param rp_ept - pointer to endpoint to destroy\r
+ *\r
+ */\r
+void rpmsg_destroy_ept(struct rpmsg_endpoint *rp_ept) {\r
+\r
+ struct remote_device *rdev;\r
+ struct rpmsg_channel *rp_chnl;\r
+\r
+ if (!rp_ept)\r
+ return;\r
+\r
+ rp_chnl = rp_ept->rp_chnl;\r
+ rdev = rp_chnl->rdev;\r
+\r
+ _destroy_endpoint(rdev, rp_ept);\r
+}\r
+\r
+/**\r
+ * rpmsg_create_channel\r
+ *\r
+ * This function provides facility to create channel dynamically. It sends\r
+ * Name Service announcement to remote device to let it know about the channel\r
+ * creation. There must be an active communication among the cores (or atleast\r
+ * one rpmsg channel must already exist) before using this API to create new\r
+ * channels.\r
+ *\r
+ * @param rdev - pointer to remote device\r
+ * @param name - channel name\r
+ *\r
+ * @return - pointer to new rpmsg channel\r
+ *\r
+ */\r
+struct rpmsg_channel *rpmsg_create_channel(struct remote_device *rdev,\r
+ char *name) {\r
+\r
+ struct rpmsg_channel *rp_chnl;\r
+ struct rpmsg_endpoint *rp_ept;\r
+\r
+ if (!rdev || !name) {\r
+ return RPMSG_NULL ;\r
+ }\r
+\r
+ /* Create channel instance */\r
+ rp_chnl = _rpmsg_create_channel(rdev, name, RPMSG_NS_EPT_ADDR,\r
+ RPMSG_NS_EPT_ADDR);\r
+ if (!rp_chnl) {\r
+ return RPMSG_NULL ;\r
+ }\r
+\r
+ /* Create default endpoint for the channel */\r
+ rp_ept = rpmsg_create_ept(rp_chnl , rdev->default_cb, rdev,\r
+ RPMSG_ADDR_ANY);\r
+\r
+ if (!rp_ept) {\r
+ _rpmsg_delete_channel(rp_chnl);\r
+ return RPMSG_NULL;\r
+ }\r
+
+ rp_chnl->rp_ept = rp_ept;\r
+ rp_chnl->src = rp_ept->addr;\r
+ rp_chnl->state = RPMSG_CHNL_STATE_NS;\r
+\r
+ /* Notify the application of channel creation event */\r
+ if (rdev->channel_created) {\r
+ rdev->channel_created(rp_chnl);\r
+ }\r
+\r
+ /* Send NS announcement to remote processor */\r
+ rpmsg_send_ns_message(rdev, rp_chnl, RPMSG_NS_CREATE);\r
+\r
+ return rp_chnl;\r
+}\r
+\r
+/**\r
+ * rpmsg_delete_channel\r
+ *\r
+ * Deletes the given RPMSG channel. The channel must first be created with the\r
+ * rpmsg_create_channel API.\r
+ *\r
+ * @param rp_chnl - pointer to rpmsg channel to delete\r
+ *\r
+ */\r
+void rpmsg_delete_channel(struct rpmsg_channel *rp_chnl) {\r
+\r
+ struct remote_device *rdev;\r
+\r
+ if (!rp_chnl) {\r
+ return;\r
+ }\r
+\r
+ rdev = rp_chnl->rdev;\r
+\r
+ if (rp_chnl->state > RPMSG_CHNL_STATE_IDLE) {\r
+ /* Notify the other processor that channel no longer exists */\r
+ rpmsg_send_ns_message(rdev, rp_chnl, RPMSG_NS_DESTROY);\r
+ }\r
+\r
+ /* Notify channel deletion to application */\r
+ if (rdev->channel_destroyed) {\r
+ rdev->channel_destroyed(rp_chnl);\r
+ }\r
+\r
+ rpmsg_destroy_ept(rp_chnl->rp_ept);\r
+ _rpmsg_delete_channel(rp_chnl);\r
+\r
+ return;\r
+}\r
diff --git a/rpmsg/rpmsg.h b/rpmsg/rpmsg.h
--- /dev/null
+++ b/rpmsg/rpmsg.h
@@ -0,0 +1,402 @@
+/*
+ * Remote processor messaging
+ *
+ * Copyright (C) 2011 Texas Instruments, Inc.
+ * Copyright (C) 2011 Google, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name Texas Instruments nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _RPMSG_H_
+#define _RPMSG_H_
+
+#include "../rpmsg/rpmsg_core.h"
+
+/* The feature bitmap for virtio rpmsg */
+#define VIRTIO_RPMSG_F_NS 0 /* RP supports name service notifications */
+#define RPMSG_NAME_SIZE 32
+
+/**
+ * struct rpmsg_hdr - common header for all rpmsg messages
+ * @src: source address
+ * @dst: destination address
+ * @reserved: reserved for future use
+ * @len: length of payload (in bytes)
+ * @flags: message flags
+ * @data: @len bytes of message payload data
+ *
+ * Every message sent(/received) on the rpmsg bus begins with this header.
+ */
+struct rpmsg_hdr {
+ unsigned long src;
+ unsigned long dst;
+ unsigned long reserved;
+ unsigned short len;
+ unsigned short flags;
+ unsigned char data[0];
+} __attribute__((packed));
+
+/**
+ * struct rpmsg_ns_msg - dynamic name service announcement message
+ * @name: name of remote service that is published
+ * @addr: address of remote service that is published
+ * @flags: indicates whether service is created or destroyed
+ *
+ * This message is sent across to publish a new service, or announce
+ * about its removal. When we receive these messages, an appropriate
+ * rpmsg channel (i.e device) is created/destroyed. In turn, the ->probe()
+ * or ->remove() handler of the appropriate rpmsg driver will be invoked
+ * (if/as-soon-as one is registered).
+ */
+struct rpmsg_ns_msg {
+ char name[RPMSG_NAME_SIZE];
+ unsigned long addr;
+ unsigned long flags;
+} __attribute__((packed));
+
+/**
+ * enum rpmsg_ns_flags - dynamic name service announcement flags
+ *
+ * @RPMSG_NS_CREATE: a new remote service was just created
+ * @RPMSG_NS_DESTROY: a known remote service was just destroyed
+ */
+enum rpmsg_ns_flags {
+ RPMSG_NS_CREATE = 0,
+ RPMSG_NS_DESTROY = 1,
+};
+
+#define RPMSG_ADDR_ANY 0xFFFFFFFF
+
+
+/**
+ * rpmsg_channel - devices that belong to the rpmsg bus are called channels
+ * @name: channel name
+ * @src: local address
+ * @dst: destination address
+ * rdev: rpmsg remote device
+ * @ept: the rpmsg endpoint of this channel
+ * @state: channel state
+ */
+struct rpmsg_channel {
+ char name[RPMSG_NAME_SIZE];
+ unsigned long src;
+ unsigned long dst;
+ struct remote_device *rdev;
+ struct rpmsg_endpoint *rp_ept;
+ unsigned int state;
+};
+
+/**
+ * channel_info - channel info
+ * @name: channel name
+ * @src: local address
+ * @dst: destination address
+ */
+
+struct channel_info {
+ char name[RPMSG_NAME_SIZE];
+ unsigned long src;
+ unsigned long dest;
+};
+
+/**
+ * struct rpmsg_endpoint - binds a local rpmsg address to its user
+ * @rp_chnl: rpmsg channel device
+ * @cb: rx callback handler
+ * @addr: local rpmsg address
+ * @priv: private data for the driver's use
+ *
+ * In essence, an rpmsg endpoint represents a listener on the rpmsg bus, as
+ * it binds an rpmsg address with an rx callback handler.
+ *
+ * Simple rpmsg drivers shouldn't use this struct directly, because
+ * things just work: every rpmsg driver provides an rx callback upon
+ * registering to the bus, and that callback is then bound to its rpmsg
+ * address when the driver is probed. When relevant inbound messages arrive
+ * (i.e. messages which their dst address equals to the src address of
+ * the rpmsg channel), the driver's handler is invoked to process it.
+ *
+ * More complicated drivers though, that do need to allocate additional rpmsg
+ * addresses, and bind them to different rx callbacks, must explicitly
+ * create additional endpoints by themselves (see rpmsg_create_ept()).
+ */
+struct rpmsg_endpoint {
+ struct rpmsg_channel *rp_chnl;
+ rpmsg_rx_cb_t cb;
+ unsigned long addr;
+ void *priv;
+};
+
+struct rpmsg_endpoint *rpmsg_create_ept(struct rpmsg_channel *rp_chnl,
+ rpmsg_rx_cb_t cb, void *priv, unsigned long addr);
+
+void rpmsg_destroy_ept(struct rpmsg_endpoint *rp_ept);
+
+int
+rpmsg_send_offchannel_raw(struct rpmsg_channel *, unsigned long, unsigned long, char *, int, int);
+
+/**
+ * rpmsg_sendto() - send a message across to the remote processor, specify dst
+ * @rpdev: the rpmsg channel
+ * @data: payload of message
+ * @len: length of payload
+ * @dst: destination address
+ *
+ * This function sends @data of length @len to the remote @dst address.
+ * The message will be sent to the remote processor which the @rpdev
+ * channel belongs to, using @rpdev's source address.
+ * In case there are no TX buffers available, the function will block until
+ * one becomes available, or a timeout of 15 seconds elapses. When the latter
+ * happens, -ERESTARTSYS is returned.
+ *
+ * Can only be called from process context (for now).
+ *
+ * Returns 0 on success and an appropriate error value on failure.
+ */
+static inline
+int rpmsg_sendto(struct rpmsg_channel *rpdev, void *data, int len, unsigned long dst)
+{
+ if (!rpdev || !data)
+ return RPMSG_ERR_PARAM;
+
+ return rpmsg_send_offchannel_raw(rpdev, rpdev->src, dst, (char *)data, len, RPMSG_TRUE);
+}
+
+/**
+ * rpmsg_send() - send a message across to the remote processor
+ * @rpdev: the rpmsg channel
+ * @data: payload of message
+ * @len: length of payload
+ *
+ * This function sends @data of length @len on the @rpdev channel.
+ * The message will be sent to the remote processor which the @rpdev
+ * channel belongs to, using @rpdev's source and destination addresses.
+ * In case there are no TX buffers available, the function will block until
+ * one becomes available, or a timeout of 15 seconds elapses. When the latter
+ * happens, -ERESTARTSYS is returned.
+ *
+ * Can only be called from process context (for now).
+ *
+ * Returns 0 on success and an appropriate error value on failure.
+ */
+static inline int rpmsg_send(struct rpmsg_channel *rpdev, void *data, int len)
+{
+ if (!rpdev || !data)
+ return RPMSG_ERR_PARAM;
+
+ return rpmsg_send_offchannel_raw(rpdev, rpdev->src, rpdev->dst, (char*)data, len, RPMSG_TRUE);
+}
+
+/**
+ * rpmsg_send_offchannel() - send a message using explicit src/dst addresses
+ * @rpdev: the rpmsg channel
+ * @src: source address
+ * @dst: destination address
+ * @data: payload of message
+ * @len: length of payload
+ *
+ * This function sends @data of length @len to the remote @dst address,
+ * and uses @src as the source address.
+ * The message will be sent to the remote processor which the @rpdev
+ * channel belongs to.
+ * In case there are no TX buffers available, the function will block until
+ * one becomes available, or a timeout of 15 seconds elapses. When the latter
+ * happens, -ERESTARTSYS is returned.
+ *
+ * Can only be called from process context (for now).
+ *
+ * Returns 0 on success and an appropriate error value on failure.
+ */
+static inline
+int rpmsg_send_offchannel(struct rpmsg_channel *rpdev, unsigned long src, unsigned long dst,
+ void *data, int len)
+{
+ if (!rpdev || !data)
+ return RPMSG_ERR_PARAM;
+
+ return rpmsg_send_offchannel_raw(rpdev, src, dst, (char *)data, len, RPMSG_TRUE);
+}
+
+/**
+ * rpmsg_trysend() - send a message across to the remote processor
+ * @rpdev: the rpmsg channel
+ * @data: payload of message
+ * @len: length of payload
+ *
+ * This function sends @data of length @len on the @rpdev channel.
+ * The message will be sent to the remote processor which the @rpdev
+ * channel belongs to, using @rpdev's source and destination addresses.
+ * In case there are no TX buffers available, the function will immediately
+ * return -ENOMEM without waiting until one becomes available.
+ *
+ * Can only be called from process context (for now).
+ *
+ * Returns 0 on success and an appropriate error value on failure.
+ */
+static inline
+int rpmsg_trysend(struct rpmsg_channel *rpdev, void *data, int len)
+{
+
+ if (!rpdev || !data)
+ return RPMSG_ERR_PARAM;
+
+ return rpmsg_send_offchannel_raw(rpdev, rpdev->src, rpdev->dst, (char *)data, len, RPMSG_FALSE);
+}
+
+/**
+ * rpmsg_trysendto() - send a message across to the remote processor, specify dst
+ * @rpdev: the rpmsg channel
+ * @data: payload of message
+ * @len: length of payload
+ * @dst: destination address
+ *
+ * This function sends @data of length @len to the remote @dst address.
+ * The message will be sent to the remote processor which the @rpdev
+ * channel belongs to, using @rpdev's source address.
+ * In case there are no TX buffers available, the function will immediately
+ * return -ENOMEM without waiting until one becomes available.
+ *
+ * Can only be called from process context (for now).
+ *
+ * Returns 0 on success and an appropriate error value on failure.
+ */
+static inline
+int rpmsg_trysendto(struct rpmsg_channel *rpdev, void *data, int len, unsigned long dst)
+{
+ unsigned long src;
+
+ if (!rpdev || !data)
+ return RPMSG_ERR_PARAM;
+
+ src = rpdev->src;
+
+ return rpmsg_send_offchannel_raw(rpdev, src, dst, (char *)data, len, RPMSG_FALSE);
+}
+
+/**
+ * rpmsg_trysend_offchannel() - send a message using explicit src/dst addresses
+ * @rpdev: the rpmsg channel
+ * @src: source address
+ * @dst: destination address
+ * @data: payload of message
+ * @len: length of payload
+ *
+ * This function sends @data of length @len to the remote @dst address,
+ * and uses @src as the source address.
+ * The message will be sent to the remote processor which the @rpdev
+ * channel belongs to.
+ * In case there are no TX buffers available, the function will immediately
+ * return -ENOMEM without waiting until one becomes available.
+ *
+ * Can only be called from process context (for now).
+ *
+ * Returns 0 on success and an appropriate error value on failure.
+ */
+static inline
+int rpmsg_trysend_offchannel(struct rpmsg_channel *rpdev, unsigned long src, unsigned long dst,
+ void *data, int len)
+{
+ if (!rpdev || !data)
+ return RPMSG_ERR_PARAM;
+
+ return rpmsg_send_offchannel_raw(rpdev, src, dst, (char *)data, len, RPMSG_FALSE);
+}
+
+/**
+ * rpmsg_init
+ *
+ * Thus function allocates and initializes the rpmsg driver resources for given
+ * device id (cpu id).The successful return from this function leaves
+ * fully enabled IPC link.
+ *
+ * @param dev_id - rpmsg remote device for which driver is to
+ * be initialized
+ * @param rdev - pointer to newly created remote device
+ * @param channel_created - callback function for channel creation
+ * @param channel_destroyed - callback function for channel deletion
+ * @default_cb - default callback for channel
+ * @param role - role of the other device, Master or Remote
+ * @return - status of function execution
+ *
+ */
+
+int rpmsg_init(int dev_id, struct remote_device **rdev,
+ rpmsg_chnl_cb_t channel_created,
+ rpmsg_chnl_cb_t channel_destroyed,
+ rpmsg_rx_cb_t default_cb, int role);
+
+/**
+ * rpmsg_deinit
+ *
+ * Thus function releases the rpmsg driver resources for given remote
+ * instance.
+ *
+ * @param rdev - pointer to device de-init
+ *
+ * @return - none
+ *
+ */
+void rpmsg_deinit(struct remote_device *rdev);
+
+/**
+ * rpmsg_get_buffer_size
+ *
+ * Returns buffer size available for sending messages.
+ *
+ * @param channel - pointer to rpmsg channel/device
+ *
+ * @return - buffer size
+ *
+ */
+int rpmsg_get_buffer_size(struct rpmsg_channel *rp_chnl);
+
+/**
+ * rpmsg_create_channel
+ *
+ * Creates RPMSG channel with the given name for remote device.
+ *
+ * @param rdev - pointer to rpmsg remote device
+ * @param name - channel name
+ *
+ * @return - pointer to new rpmsg channel
+ *
+ */
+struct rpmsg_channel *rpmsg_create_channel(struct remote_device *rdev, char *name);
+
+/**
+ * rpmsg_delete_channel
+ *
+ * Deletes the given RPMSG channel. The channel must first be created with the
+ * rpmsg_create_channel API.
+ *
+ * @param rp_chnl - pointer to rpmsg channel to delete
+ *
+ */
+void rpmsg_delete_channel(struct rpmsg_channel *rp_chnl);
+
+#endif /* _RPMSG_H_ */
diff --git a/rpmsg/rpmsg_core.c b/rpmsg/rpmsg_core.c
--- /dev/null
+++ b/rpmsg/rpmsg_core.c
@@ -0,0 +1,731 @@
+/*\r
+ * Copyright (c) 2014, Mentor Graphics Corporation\r
+ * All rights reserved.\r
+ *\r
+ * Redistribution and use in source and binary forms, with or without\r
+ * modification, are permitted provided that the following conditions are met:\r
+ *\r
+ * 1. Redistributions of source code must retain the above copyright notice,\r
+ * this list of conditions and the following disclaimer.\r
+ * 2. Redistributions in binary form must reproduce the above copyright notice,\r
+ * this list of conditions and the following disclaimer in the documentation\r
+ * and/or other materials provided with the distribution.\r
+ * 3. Neither the name of Mentor Graphics Corporation nor the names of its\r
+ * contributors may be used to endorse or promote products derived from this\r
+ * software without specific prior written permission.\r
+ *\r
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"\r
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\r
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\r
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE\r
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\r
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\r
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\r
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\r
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\r
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\r
+ * POSSIBILITY OF SUCH DAMAGE.\r
+ */\r
+\r
+/**************************************************************************\r
+ * FILE NAME\r
+ *\r
+ * rpmsg_core.c\r
+ *\r
+ * COMPONENT\r
+ *\r
+ * OpenAMP\r
+ *\r
+ * DESCRIPTION\r
+ *\r
+ * This file provides the core functionality of RPMSG messaging part like\r
+ * message parsing ,Rx/Tx callbacks handling , channel creation/deletion\r
+ * and address management.\r
+ *\r
+ *\r
+ **************************************************************************/\r
+#include "rpmsg.h"\r
+\r
+/* Internal functions */\r
+static void rpmsg_rx_callback(struct virtqueue *vq);\r
+static void rpmsg_tx_callback(struct virtqueue *vq);\r
+\r
+/**\r
+ * rpmsg_start_ipc\r
+ *\r
+ * This function creates communication links(virtqueues) for remote device\r
+ * and notifies it to start IPC.\r
+ *\r
+ * @param rdev - remote device handle\r
+ *\r
+ * @return - status of function execution\r
+ *\r
+ */\r
+int rpmsg_start_ipc(struct remote_device *rdev) {\r
+ struct virtio_device *virt_dev;\r
+ struct rpmsg_endpoint *ns_ept;\r
+ void (*callback[2])(struct virtqueue *vq);\r
+ const char *vq_names[2];\r
+ unsigned long dev_features;\r
+ int status;\r
+\r
+ virt_dev = &rdev->virt_dev;\r
+\r
+ /* Initialize names and callbacks based on the device role */\r
+ if (rdev->role == RPMSG_MASTER) {\r
+ vq_names[0] = "tx_vq";\r
+ vq_names[1] = "rx_vq";\r
+ callback[0] = rpmsg_tx_callback;\r
+ callback[1] = rpmsg_rx_callback;\r
+ } else {\r
+ vq_names[0] = "rx_vq";\r
+ vq_names[1] = "tx_vq";\r
+ callback[0] = rpmsg_rx_callback;\r
+ callback[1] = rpmsg_tx_callback;\r
+ }\r
+\r
+ /* Create virtqueues for remote device */\r
+ status = virt_dev->func->create_virtqueues(virt_dev, 0,\r
+ RPMSG_MAX_VQ_PER_RDEV, vq_names, callback, RPMSG_NULL);\r
+ if (status != RPMSG_SUCCESS) {\r
+ return status;\r
+ }\r
+\r
+ dev_features = virt_dev->func->get_features(virt_dev);\r
+\r
+ /*\r
+ * Create name service announcement endpoint if device supports name\r
+ * service announcement feature.\r
+ */\r
+ if ((dev_features & (1 << VIRTIO_RPMSG_F_NS))) {\r
+ rdev->support_ns = RPMSG_TRUE;\r
+ ns_ept = _create_endpoint(rdev, rpmsg_ns_callback, rdev,\r
+ RPMSG_NS_EPT_ADDR);\r
+ if (!ns_ept) {\r
+ return RPMSG_ERR_NO_MEM;\r
+ }\r
+ }\r
+\r
+ status = rpmsg_rdev_notify(rdev);\r
+\r
+ return status;\r
+}\r
+\r
+/**\r
+ * _rpmsg_create_channel\r
+ *\r
+ * Creates new rpmsg channel with the given parameters.\r
+ *\r
+ * @param rdev - pointer to remote device which contains the channel\r
+ * @param name - name of the device\r
+ * @param src - source address for the rpmsg channel\r
+ * @param dst - destination address for the rpmsg channel\r
+ *\r
+ * @return - pointer to new rpmsg channel\r
+ *\r
+ */\r
+struct rpmsg_channel *_rpmsg_create_channel(struct remote_device *rdev,\r
+ char *name, unsigned long src, unsigned long dst) {\r
+ struct rpmsg_channel *rp_chnl;\r
+ struct llist *node;\r
+\r
+ rp_chnl = env_allocate_memory(sizeof(struct rpmsg_channel));\r
+ if (rp_chnl) {\r
+ env_memset(rp_chnl, 0x00, sizeof(struct rpmsg_channel));\r
+ env_strncpy(rp_chnl->name, name, sizeof(rp_chnl->name));\r
+ rp_chnl->src = src;\r
+ rp_chnl->dst = dst;\r
+ rp_chnl->rdev = rdev;\r
+ /* Place channel on channels list */\r
+ node = env_allocate_memory(sizeof(struct llist));\r
+ if (!node) {\r
+ env_free_memory(rp_chnl);\r
+ return RPMSG_NULL ;\r
+ }\r
+ node->data = rp_chnl;\r
+ env_lock_mutex(rdev->lock);\r
+ add_to_list(&rdev->rp_channels , node);\r
+ env_unlock_mutex(rdev->lock);\r
+ }\r
+\r
+ return rp_chnl;\r
+}\r
+\r
+/**\r
+ * _rpmsg_delete_channel\r
+ *\r
+ * Deletes given rpmsg channel.\r
+ *\r
+ * @param rp_chnl - pointer to rpmsg channel to delete\r
+ *\r
+ * return - none\r
+ */\r
+void _rpmsg_delete_channel(struct rpmsg_channel * rp_chnl) {\r
+ struct llist *node;\r
+ if (rp_chnl) {\r
+ node = rpmsg_rdev_get_chnl_node_from_id(rp_chnl->rdev, rp_chnl->name);\r
+ if (node) {\r
+ env_lock_mutex(rp_chnl->rdev->lock);\r
+ remove_from_list(&rp_chnl->rdev->rp_channels, node);\r
+ env_unlock_mutex(rp_chnl->rdev->lock);\r
+ env_free_memory(node);\r
+ }\r
+ env_free_memory(rp_chnl);\r
+ }\r
+}\r
+\r
+/**\r
+ * _create_endpoint\r
+ *\r
+ * This function creates rpmsg endpoint.\r
+ *\r
+ * @param rdev - pointer to remote device\r
+ * @param cb - Rx completion call back\r
+ * @param priv - private data\r
+ * @param addr - endpoint src address\r
+ *\r
+ * @return - pointer to endpoint control block\r
+ *\r
+ */\r
+struct rpmsg_endpoint *_create_endpoint(struct remote_device *rdev,\r
+ rpmsg_rx_cb_t cb, void *priv, unsigned long addr) {\r
+\r
+ struct rpmsg_endpoint *rp_ept;\r
+ struct llist *node;\r
+ int status = RPMSG_SUCCESS;\r
+\r
+ rp_ept = env_allocate_memory(sizeof(struct rpmsg_endpoint));\r
+ if (!rp_ept) {\r
+ return RPMSG_NULL ;\r
+ }\r
+\r
+ node = env_allocate_memory(sizeof(struct llist));\r
+ if (!node) {\r
+ env_free_memory(rp_ept);\r
+ return RPMSG_NULL;\r
+ }\r
+\r
+ env_lock_mutex(rdev->lock);\r
+\r
+ if (addr != RPMSG_ADDR_ANY) {\r
+ /*\r
+ * Application has requested a particular src address for endpoint,\r
+ * first check if address is available.\r
+ */\r
+ if (!rpmsg_is_address_set(rdev->bitmap, RPMSG_ADDR_BMP_SIZE, addr)) {\r
+ /* Mark the address as used in the address bitmap. */\r
+ rpmsg_set_address(rdev->bitmap, RPMSG_ADDR_BMP_SIZE, addr);\r
+\r
+ } else {\r
+ status = RPMSG_ERR_DEV_ADDR;\r
+ }\r
+ } else {\r
+ addr = rpmsg_get_address(rdev->bitmap, RPMSG_ADDR_BMP_SIZE);\r
+ if (addr < 0) {\r
+ status = RPMSG_ERR_DEV_ADDR;\r
+ }\r
+ }\r
+\r
+ /* Do cleanup in case of error and return */\r
+ if (status) {\r
+ env_free_memory(node);\r
+ env_free_memory(rp_ept);\r
+ env_unlock_mutex(rdev->lock);\r
+ return RPMSG_NULL;\r
+ }\r
+\r
+ rp_ept->addr = addr;\r
+ rp_ept->cb = cb;\r
+ rp_ept->priv = priv;\r
+\r
+ node->data = rp_ept;\r
+ add_to_list(&rdev->rp_endpoints, node);\r
+\r
+ env_unlock_mutex(rdev->lock);\r
+\r
+ return rp_ept;\r
+}\r
+\r
+/**\r
+ * rpmsg_destroy_ept\r
+ *\r
+ * This function deletes rpmsg endpoint and performs cleanup.\r
+ *\r
+ * @param rdev - pointer to remote device\r
+ * @param rp_ept - pointer to endpoint to destroy\r
+ *\r
+ */\r
+void _destroy_endpoint(struct remote_device *rdev,\r
+ struct rpmsg_endpoint *rp_ept) {\r
+ struct llist *node;\r
+ node = rpmsg_rdev_get_endpoint_from_addr(rdev, rp_ept->addr);\r
+ if (node) {\r
+ env_lock_mutex(rdev->lock);\r
+ rpmsg_release_address(rdev->bitmap, RPMSG_ADDR_BMP_SIZE, rp_ept->addr);\r
+ remove_from_list(&rdev->rp_endpoints, node);\r
+ env_unlock_mutex(rdev->lock);\r
+ env_free_memory(node);\r
+ }\r
+ env_free_memory(rp_ept);\r
+}\r
+/**\r
+ * rpmsg_send_ns_message\r
+ *\r
+ * Sends name service announcement to remote device\r
+ *\r
+ * @param rdev - pointer to remote device\r
+ * @param rp_chnl - pointer to rpmsg channel\r
+ * @param flags - Channel creation/deletion flags\r
+ *\r
+ */\r
+void rpmsg_send_ns_message(struct remote_device *rdev,\r
+ struct rpmsg_channel *rp_chnl, unsigned long flags) {\r
+\r
+ struct rpmsg_hdr *rp_hdr;\r
+ struct rpmsg_ns_msg *ns_msg;\r
+ unsigned short idx;\r
+ int len;\r
+\r
+ env_lock_mutex(rdev->lock);\r
+\r
+ /* Get Tx buffer. */\r
+ rp_hdr = (struct rpmsg_hdr *) rpmsg_get_tx_buffer(rdev, &len, &idx);\r
+ if (!rp_hdr)\r
+ return;\r
+\r
+ /* Fill out name service data. */\r
+ rp_hdr->dst = RPMSG_NS_EPT_ADDR;\r
+ rp_hdr->len = sizeof(struct rpmsg_ns_msg);\r
+ ns_msg = (struct rpmsg_ns_msg *) rp_hdr->data;\r
+ env_strncpy(ns_msg->name, rp_chnl->name, sizeof(rp_chnl->name));\r
+ ns_msg->flags = flags;\r
+ ns_msg->addr = rp_chnl->src;\r
+\r
+ /* Place the buffer on virtqueue. */\r
+ rpmsg_enqueue_buffer(rdev, rp_hdr, len, idx);\r
+\r
+ /* Notify the other side that it has data to process. */\r
+ virtqueue_kick(rdev->tvq);\r
+\r
+ env_unlock_mutex(rdev->lock);\r
+}\r
+\r
+/**\r
+ * rpmsg_enqueue_buffers\r
+ *\r
+ * Places buffer on the virtqueue for consumption by the other side.\r
+ *\r
+ * @param rdev - pointer to remote core\r
+ * @param buffer - buffer pointer\r
+ * @param len - buffer length\r
+ * @idx - buffer index\r
+ *\r
+ * @return - status of function execution\r
+ *\r
+ */\r
+int rpmsg_enqueue_buffer(struct remote_device *rdev, void *buffer,\r
+ unsigned long len, unsigned short idx) {\r
+ struct llist node;\r
+ int status;\r
+\r
+ /* Initialize buffer node */\r
+ node.data = buffer;\r
+ node.attr = len;\r
+ node.next = RPMSG_NULL;\r
+ node.prev = RPMSG_NULL;\r
+\r
+ if (rdev->role == RPMSG_REMOTE) {\r
+ status = virtqueue_add_buffer(rdev->tvq, &node, 0, 1, buffer);\r
+ } else {\r
+ status = virtqueue_add_consumed_buffer(rdev->tvq, idx, len);\r
+ }\r
+\r
+ return status;\r
+}\r
+\r
+/**\r
+ * rpmsg_return_buffer\r
+ *\r
+ * Places the used buffer back on the virtqueue.\r
+ *\r
+ * @param rdev - pointer to remote core\r
+ * @param buffer - buffer pointer\r
+ * @param len - buffer length\r
+ * @param idx - buffer index\r
+ *\r
+ */\r
+void rpmsg_return_buffer(struct remote_device *rdev, void *buffer,\r
+ unsigned long len, unsigned short idx) {\r
+ struct llist node;\r
+\r
+ /* Initialize buffer node */\r
+ node.data = buffer;\r
+ node.attr = len;\r
+ node.next = RPMSG_NULL;\r
+ node.prev = RPMSG_NULL;\r
+\r
+ if (rdev->role == RPMSG_REMOTE) {\r
+ virtqueue_add_buffer(rdev->rvq, &node, 0, 1, buffer);\r
+ } else {\r
+ virtqueue_add_consumed_buffer(rdev->rvq, idx, len);\r
+ }\r
+}\r
+\r
+/**\r
+ * rpmsg_get_tx_buffer\r
+ *\r
+ * Provides buffer to transmit messages.\r
+ *\r
+ * @param rdev - pointer to remote device\r
+ * @param len - length of returned buffer\r
+ * @param idx - buffer index\r
+ *\r
+ * return - pointer to buffer.\r
+ */\r
+void *rpmsg_get_tx_buffer(struct remote_device *rdev, int *len,\r
+ unsigned short *idx) {\r
+ void *data;\r
+\r
+ if (rdev->role == RPMSG_REMOTE) {\r
+ data = virtqueue_get_buffer(rdev->tvq, (unsigned long *) len);\r
+ if (data == RPMSG_NULL) {\r
+ data = sh_mem_get_buffer(rdev->mem_pool);\r
+ *len = RPMSG_BUFFER_SIZE;\r
+ }\r
+ } else {\r
+ data = virtqueue_get_available_buffer(rdev->tvq, idx,\r
+ (unsigned long *) len);\r
+ }\r
+ return ((void*) env_map_vatopa(data));\r
+}\r
+\r
+/**\r
+ * rpmsg_get_rx_buffer\r
+ *\r
+ * Retrieves the received buffer from the virtqueue.\r
+ *\r
+ * @param rdev - pointer to remote device\r
+ * @param len - size of received buffer\r
+ * @param idx - index of buffer\r
+ *\r
+ * @return - pointer to received buffer\r
+ *\r
+ */\r
+void *rpmsg_get_rx_buffer(struct remote_device *rdev, unsigned long *len,\r
+ unsigned short *idx) {\r
+\r
+ void *data;\r
+ if (rdev->role == RPMSG_REMOTE) {\r
+ data = virtqueue_get_buffer(rdev->rvq, len);\r
+ } else {\r
+ data = virtqueue_get_available_buffer(rdev->rvq, idx, len);\r
+ }\r
+ return ((void *) env_map_vatopa(data));\r
+}\r
+\r
+/**\r
+ * rpmsg_free_buffer\r
+ *\r
+ * Frees the allocated buffers.\r
+ *\r
+ * @param rdev - pointer to remote device\r
+ * @param buffer - pointer to buffer to free\r
+ *\r
+ */\r
+void rpmsg_free_buffer(struct remote_device *rdev, void *buffer) {\r
+ if (rdev->role == RPMSG_REMOTE) {\r
+ sh_mem_free_buffer(rdev->mem_pool, buffer);\r
+ }\r
+}\r
+\r
+/**\r
+ * rpmsg_tx_callback\r
+ *\r
+ * Tx callback function.\r
+ *\r
+ * @param vq - pointer to virtqueue on which Tx is has been\r
+ * completed.\r
+ *\r
+ */\r
+static void rpmsg_tx_callback(struct virtqueue *vq) {\r
+ struct remote_device *rdev;\r
+ struct virtio_device *vdev;\r
+ struct rpmsg_channel *rp_chnl;\r
+ struct llist *chnl_hd;\r
+\r
+ vdev = (struct virtio_device *) vq->vq_dev;\r
+ rdev = (struct remote_device *) vdev;\r
+ chnl_hd = rdev->rp_channels;\r
+\r
+ /* Check if the remote device is master. */\r
+ if (rdev->role == RPMSG_MASTER) {\r
+\r
+ /* Notification is received from the master. Now the remote(us) can\r
+ * performs one of two operations;\r
+ *\r
+ * a. If name service announcement is supported then it will send NS message.\r
+ * else\r
+ * b. It will update the channel state to active so that further communication\r
+ * can take place.\r
+ */\r
+ while (chnl_hd != RPMSG_NULL) {\r
+ rp_chnl = (struct rpmsg_channel *) chnl_hd->data;\r
+\r
+ if (rp_chnl->state == RPMSG_CHNL_STATE_IDLE) {\r
+\r
+ if (rdev->support_ns) {\r
+ rp_chnl->state = RPMSG_CHNL_STATE_NS;\r
+ } else {\r
+ rp_chnl->state = RPMSG_CHNL_STATE_ACTIVE;\r
+ }\r
+\r
+ if (rp_chnl->state == RPMSG_CHNL_STATE_NS) {\r
+ rpmsg_send_ns_message(rdev, rp_chnl, RPMSG_NS_CREATE);\r
+ }\r
+ }\r
+\r
+ chnl_hd = chnl_hd->next;\r
+ }\r
+ }\r
+}\r
+\r
+/**\r
+ * rpmsg_rx_callback\r
+ *\r
+ * Rx callback function.\r
+ *\r
+ * @param vq - pointer to virtqueue on which messages is received\r
+ *\r
+ */\r
+void rpmsg_rx_callback(struct virtqueue *vq) {\r
+ struct remote_device *rdev;\r
+ struct virtio_device *vdev;\r
+ struct rpmsg_channel *rp_chnl;\r
+ struct rpmsg_endpoint *rp_ept;\r
+ struct rpmsg_hdr *rp_hdr;\r
+ struct llist *node;\r
+ unsigned long len;\r
+ unsigned short idx;\r
+\r
+ vdev = (struct virtio_device *) vq->vq_dev;\r
+ rdev = (struct remote_device *) vdev;\r
+\r
+ env_lock_mutex(rdev->lock);\r
+\r
+ /* Process the received data from remote node */\r
+ rp_hdr = (struct rpmsg_hdr *) rpmsg_get_rx_buffer(rdev, &len, &idx);\r
+\r
+ env_unlock_mutex(rdev->lock);\r
+\r
+ if (!rp_hdr)\r
+ return;\r
+\r
+ /* Get the channel node from the remote device channels list. */\r
+ node = rpmsg_rdev_get_endpoint_from_addr(rdev, rp_hdr->dst);\r
+\r
+ if (!node)\r
+ /* Fatal error no endpoint for the given dst addr. */\r
+ return;\r
+\r
+ rp_ept = (struct rpmsg_endpoint *) node->data;\r
+\r
+ rp_chnl = rp_ept->rp_chnl;\r
+ if ((rp_chnl) && (rp_chnl->state == RPMSG_CHNL_STATE_NS)) {\r
+\r
+ /* First message from RPMSG Master, update channel\r
+ * destination address and state */\r
+ rp_chnl->dst = rp_hdr->src;\r
+ rp_chnl->state = RPMSG_CHNL_STATE_ACTIVE;\r
+\r
+ /* Notify channel creation to application */\r
+ if (rdev->channel_created) {\r
+ rdev->channel_created(rp_chnl);\r
+ }\r
+ } else {\r
+\r
+ rp_ept->cb(rp_chnl, rp_hdr->data, rp_hdr->len, rp_ept->priv,\r
+ rp_hdr->src);\r
+ }\r
+\r
+ env_lock_mutex(rdev->lock);\r
+\r
+ /* Return used buffers. */\r
+ rpmsg_return_buffer(rdev, rp_hdr, len, idx);\r
+\r
+ env_unlock_mutex(rdev->lock);\r
+}\r
+\r
+/**\r
+ * rpmsg_ns_callback\r
+ *\r
+ * This callback handles name service announcement from the remote device\r
+ * and creates/deletes rpmsg channels.\r
+ *\r
+ * @param server_chnl - pointer to server channel control block.\r
+ * @param data - pointer to received messages\r
+ * @param len - length of received data\r
+ * @param priv - any private data\r
+ * @param src - source address\r
+ *\r
+ * @return - none\r
+ */\r
+void rpmsg_ns_callback(struct rpmsg_channel *server_chnl, void *data, int len,\r
+ void *priv, unsigned long src) {\r
+ struct remote_device *rdev;\r
+ struct rpmsg_channel *rp_chnl;\r
+ struct rpmsg_ns_msg *ns_msg;\r
+ struct llist *node;\r
+\r
+ rdev = (struct remote_device *) priv;\r
+\r
+ //FIXME: This assumes same name string size for channel name both on master\r
+ //and remote. If this is not the case then we will have to parse the\r
+ //message contents.\r
+\r
+ ns_msg = (struct rpmsg_ns_msg *) data;\r
+ ns_msg->name[len - 1] = '\0';\r
+\r
+ if (ns_msg->flags & RPMSG_NS_DESTROY) {\r
+ node = rpmsg_rdev_get_chnl_node_from_id(rdev, ns_msg->name);\r
+ if (node) {\r
+ rp_chnl = (struct rpmsg_channel *) node->data;\r
+ if (rdev->channel_destroyed) {\r
+ rdev->channel_destroyed(rp_chnl);\r
+ }\r
+ rpmsg_destroy_ept(rp_chnl->rp_ept);\r
+ _rpmsg_delete_channel(rp_chnl);\r
+ }\r
+ } else {\r
+ rp_chnl = _rpmsg_create_channel(rdev, ns_msg->name, 0x00, ns_msg->addr);\r
+ if (rp_chnl) {\r
+ rp_chnl->state = RPMSG_CHNL_STATE_ACTIVE;\r
+ /* Create default endpoint for channel */\r
+ rp_chnl->rp_ept = rpmsg_create_ept(rp_chnl, rdev->default_cb, rdev,\r
+ RPMSG_ADDR_ANY);\r
+ if (rp_chnl->rp_ept) {\r
+ rp_chnl->src = rp_chnl->rp_ept->addr;\r
+ /*\r
+ * Echo back the NS message to remote in order to\r
+ * complete the connection stage. Remote will know the endpoint\r
+ * address from this point onward which will enable it to send\r
+ * message without waiting for any application level message from\r
+ * master.
+ */\r
+ rpmsg_send(rp_chnl,data,len);\r
+ if (rdev->channel_created) {\r
+ rdev->channel_created(rp_chnl);\r
+ }\r
+ }\r
+ }\r
+ }\r
+}\r
+\r
+/**\r
+ * rpmsg_get_address\r
+ *\r
+ * This function provides unique 32 bit address.\r
+ *\r
+ * @param bitmap - bit map for addresses\r
+ * @param size - size of bitmap\r
+ *\r
+ * return - a unique address\r
+ */\r
+int rpmsg_get_address(unsigned long *bitmap, int size) {\r
+ int addr = -1;\r
+ int i, tmp32;\r
+\r
+ /* Find first available buffer */\r
+ for (i = 0; i < size; i++) {\r
+ tmp32 = get_first_zero_bit(bitmap[i]);\r
+\r
+ if (tmp32 < 32) {\r
+ addr = tmp32 + i + 1;\r
+ bitmap[i] |= (1 << tmp32);\r
+ break;\r
+ }\r
+ }\r
+\r
+ return addr;\r
+}\r
+\r
+/**\r
+ * rpmsg_release_address\r
+ *\r
+ * Frees the given address.\r
+ *\r
+ * @param bitmap - bit map for addresses\r
+ * @param size - size of bitmap\r
+ * @param addr - address to free\r
+ *\r
+ * return - none\r
+ */\r
+int rpmsg_release_address(unsigned long *bitmap, int size, int addr) {\r
+ unsigned int i, j;\r
+ unsigned long mask = 1;\r
+\r
+ if (addr >= size * 32)\r
+ return -1;\r
+\r
+ /* Mark the addr as available */\r
+ i = addr / 32;\r
+ j = addr % 32;\r
+\r
+ mask = mask << j;\r
+ bitmap[i] = bitmap[i] & (~mask);\r
+\r
+ return RPMSG_SUCCESS;\r
+}\r
+\r
+/**\r
+ * rpmsg_is_address_set\r
+ *\r
+ * Checks whether address is used or free.\r
+ *\r
+ * @param bitmap - bit map for addresses\r
+ * @param size - size of bitmap\r
+ * @param addr - address to free\r
+ *\r
+ * return - TRUE/FALSE\r
+ */\r
+int rpmsg_is_address_set(unsigned long *bitmap, int size,\r
+ int addr) {\r
+ int i, j;\r
+ unsigned long mask = 1;\r
+\r
+ if (addr >= size * 32)\r
+ return -1;\r
+\r
+ /* Mark the id as available */\r
+ i = addr / 32;\r
+ j = addr % 32;\r
+ mask = mask << j;\r
+\r
+ return (bitmap[i] & mask);\r
+}\r
+\r
+/**\r
+ * rpmsg_set_address\r
+ *\r
+ * Marks the address as consumed.\r
+ *\r
+ * @param bitmap - bit map for addresses\r
+ * @param size - size of bitmap\r
+ * @param addr - address to free\r
+ *\r
+ * return - none\r
+ */\r
+int rpmsg_set_address(unsigned long *bitmap, int size, int addr) {\r
+ int i, j;\r
+ unsigned long mask = 1;\r
+\r
+ if (addr >= size * 32)\r
+ return -1;\r
+\r
+ /* Mark the id as available */\r
+ i = addr / 32;\r
+ j = addr % 32;\r
+ mask = mask << j;\r
+ bitmap[i] |= mask;\r
+\r
+ return RPMSG_SUCCESS;\r
+}\r
diff --git a/rpmsg/rpmsg_core.h b/rpmsg/rpmsg_core.h
--- /dev/null
+++ b/rpmsg/rpmsg_core.h
@@ -0,0 +1,190 @@
+/*\r
+ * Copyright (c) 2014, Mentor Graphics Corporation\r
+ * All rights reserved.\r
+ *\r
+ * Redistribution and use in source and binary forms, with or without\r
+ * modification, are permitted provided that the following conditions are met:\r
+ *\r
+ * 1. Redistributions of source code must retain the above copyright notice,\r
+ * this list of conditions and the following disclaimer.\r
+ * 2. Redistributions in binary form must reproduce the above copyright notice,\r
+ * this list of conditions and the following disclaimer in the documentation\r
+ * and/or other materials provided with the distribution.\r
+ * 3. Neither the name of Mentor Graphics Corporation nor the names of its\r
+ * contributors may be used to endorse or promote products derived from this\r
+ * software without specific prior written permission.\r
+ *\r
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"\r
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\r
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\r
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE\r
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\r
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\r
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\r
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\r
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\r
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\r
+ * POSSIBILITY OF SUCH DAMAGE.\r
+ */\r
+\r
+\r
+#ifndef _RPMSG_CORE_H_\r
+#define _RPMSG_CORE_H_\r
+\r
+#include "../porting/env/env.h"\r
+#include "../virtio/virtio.h"\r
+#include "../common/hil/hil.h"\r
+#include "../common/shm/sh_mem.h"\r
+#include "../common/llist/llist.h"\r
+#include "rpmsg.h"\r
+\r
+/* Configurable parameters */\r
+#define RPMSG_BUFFER_SIZE 512\r
+#define RPMSG_MAX_VQ_PER_RDEV 2\r
+#define RPMSG_NS_EPT_ADDR 0x35\r
+#define RPMSG_ADDR_BMP_SIZE 4\r
+\r
+/* Definitions for device types , null pointer, etc.*/\r
+#define RPMSG_SUCCESS 0\r
+#define RPMSG_NULL (void *)0\r
+#define RPMSG_REMOTE 0\r
+#define RPMSG_MASTER 1\r
+#define RPMSG_TRUE 1\r
+#define RPMSG_FALSE 0\r
+\r
+/* RPMSG channel states. */\r
+#define RPMSG_CHNL_STATE_IDLE 0\r
+#define RPMSG_CHNL_STATE_NS 1\r
+#define RPMSG_CHNL_STATE_ACTIVE 2\r
+\r
+/* Remote processor/device states. */\r
+#define RPMSG_DEV_STATE_IDLE 0\r
+#define RPMSG_DEV_STATE_ACTIVE 1\r
+\r
+/* Total tick count for 15secs - 1msec tick. */\r
+#define RPMSG_TICK_COUNT 15000\r
+\r
+/* Time to wait - In multiple of 10 msecs. */\r
+#define RPMSG_TICKS_PER_INTERVAL 10\r
+\r
+/* Error macros. */\r
+#define RPMSG_ERRORS_BASE -3000\r
+#define RPMSG_ERR_NO_MEM (RPMSG_ERRORS_BASE - 1)\r
+#define RPMSG_ERR_NO_BUFF (RPMSG_ERRORS_BASE - 2)\r
+#define RPMSG_ERR_MAX_VQ (RPMSG_ERRORS_BASE - 3)\r
+#define RPMSG_ERR_PARAM (RPMSG_ERRORS_BASE - 4)\r
+#define RPMSG_ERR_DEV_STATE (RPMSG_ERRORS_BASE - 5)\r
+#define RPMSG_ERR_BUFF_SIZE (RPMSG_ERRORS_BASE - 6)\r
+#define RPMSG_ERR_DEV_ID (RPMSG_ERRORS_BASE - 7)\r
+#define RPMSG_ERR_DEV_ADDR (RPMSG_ERRORS_BASE - 8)\r
+\r
+struct rpmsg_channel;\r
+typedef void (*rpmsg_rx_cb_t)(struct rpmsg_channel *, void *, int, void *, unsigned long);\r
+typedef void (*rpmsg_chnl_cb_t)(struct rpmsg_channel *rp_chl);\r
+/**\r
+ * remote_device\r
+ *\r
+ * This structure is maintained by RPMSG driver to represent remote device/core.\r
+ *\r
+ * @virtd_dev - virtio device for remote core\r
+ * @rvq - Rx virtqueue for virtio device\r
+ * @tvq - Tx virtqueue for virtio device\r
+ * @proc - reference to remote processor\r
+ * @rp_channels - rpmsg channels list for the device\r
+ * @rp_endpoints - rpmsg endpoints list for the device\r
+ * @mem_pool - shared memory pool\r
+ * @bitmap - bitmap for channels addresses\r
+ * @channel_created - create channel callback\r
+ * @channel_destroyed - delete channel callback\r
+ * @default_cb - default callback handler for RX data on channel\r
+ * @lock - remote device mutex\r
+ * @role - role of the remote device, RPMSG_MASTER/RPMSG_REMOTE\r
+ * @state - remote device state, IDLE/ACTIVE\r
+ * @support_ns - if device supports name service announcement\r
+ *\r
+ */\r
+struct remote_device {\r
+ struct virtio_device virt_dev;\r
+ struct virtqueue *rvq;\r
+ struct virtqueue *tvq;\r
+ struct hil_proc *proc;\r
+ struct llist *rp_channels;\r
+ struct llist *rp_endpoints;\r
+ struct sh_mem_pool *mem_pool;\r
+ unsigned long bitmap[RPMSG_ADDR_BMP_SIZE];\r
+ rpmsg_chnl_cb_t channel_created;\r
+ rpmsg_chnl_cb_t channel_destroyed;\r
+ rpmsg_rx_cb_t default_cb;\r
+ LOCK *lock;\r
+ unsigned int role;\r
+ unsigned int state;\r
+ int support_ns;\r
+};\r
+\r
+/* Core functions */\r
+int rpmsg_start_ipc(struct remote_device *rdev);\r
+struct rpmsg_channel *_rpmsg_create_channel(struct remote_device *rdev,\r
+ char *name, unsigned long src, unsigned long dst);\r
+void _rpmsg_delete_channel(struct rpmsg_channel * rp_chnl);\r
+struct rpmsg_endpoint *_create_endpoint(struct remote_device *rdev,\r
+ rpmsg_rx_cb_t cb, void *priv, unsigned long addr);\r
+void _destroy_endpoint(struct remote_device *rdev,\r
+ struct rpmsg_endpoint *rp_ept);\r
+void rpmsg_send_ns_message(struct remote_device *rdev,\r
+ struct rpmsg_channel *rp_chnl, unsigned long flags);\r
+int rpmsg_enqueue_buffer(struct remote_device *rdev, void *buffer,\r
+ unsigned long len, unsigned short idx);\r
+void rpmsg_return_buffer(struct remote_device *rdev, void *buffer,\r
+ unsigned long len, unsigned short idx);\r
+void *rpmsg_get_tx_buffer(struct remote_device *rdev, int *len,\r
+ unsigned short *idx);\r
+void rpmsg_free_buffer(struct remote_device *rdev, void *buffer);\r
+void rpmsg_free_channel(struct rpmsg_channel* rp_chnl);\r
+void * rpmsg_get_rx_buffer(struct remote_device *rdev, unsigned long *len,\r
+ unsigned short *idx);\r
+int rpmsg_get_address(unsigned long *bitmap, int size);\r
+int rpmsg_release_address(unsigned long *bitmap, int size, int addr);\r
+int rpmsg_is_address_set(unsigned long *bitmap, int size,\r
+ int addr);\r
+int rpmsg_set_address(unsigned long *bitmap, int size, int addr);\r
+void rpmsg_ns_callback(struct rpmsg_channel *server_chnl,\r
+ void *data, int len, void *priv, unsigned long src);\r
+\r
+/* Remote device functions */\r
+int rpmsg_rdev_init(struct remote_device **rdev, int dev_id, int role,\r
+ rpmsg_chnl_cb_t channel_created,\r
+ rpmsg_chnl_cb_t channel_destroyed,\r
+ rpmsg_rx_cb_t default_cb);\r
+void rpmsg_rdev_deinit(struct remote_device *rdev);\r
+struct llist *rpmsg_rdev_get_chnl_node_from_id(struct remote_device *rdev,\r
+ char *rp_chnl_id);\r
+struct llist *rpmsg_rdev_get_chnl_from_addr(struct remote_device *rdev,\r
+ unsigned long addr);\r
+struct llist *rpmsg_rdev_get_endpoint_from_addr(struct remote_device *rdev,\r
+ unsigned long addr);\r
+int rpmsg_rdev_notify(struct remote_device *rdev);\r
+int rpmsg_rdev_create_virtqueues(struct virtio_device *dev, int flags, int nvqs,\r
+ const char *names[], vq_callback *callbacks[],\r
+ struct virtqueue *vqs[]);\r
+unsigned char rpmsg_rdev_get_status(struct virtio_device *dev);\r
+\r
+void rpmsg_rdev_set_status(struct virtio_device *dev, unsigned char status);\r
+\r
+unsigned long rpmsg_rdev_get_feature(struct virtio_device *dev);\r
+\r
+void rpmsg_rdev_set_feature(struct virtio_device *dev, unsigned long feature);\r
+\r
+unsigned long rpmsg_rdev_negotiate_feature(struct virtio_device *dev,\r
+ unsigned long features);\r
+/*\r
+ * Read/write a variable amount from the device specific (ie, network)\r
+ * configuration region. This region is encoded in the same endian as\r
+ * the guest.\r
+ */\r
+void rpmsg_rdev_read_config(struct virtio_device *dev, unsigned long offset,\r
+ void *dst, int length);\r
+void rpmsg_rdev_write_config(struct virtio_device *dev, unsigned long offset,\r
+ void *src, int length);\r
+void rpmsg_rdev_reset(struct virtio_device *dev);\r
+\r
+#endif /* _RPMSG_CORE_H_ */\r
diff --git a/virtio/Makefile b/virtio/Makefile
--- /dev/null
+++ b/virtio/Makefile
@@ -0,0 +1,34 @@
+# Make file to create virtio library.\r
+\r
+# Include commons make file to get platform and tool chain specific variables.\r
+include ../Makefile.commons\r
+\r
+LIB := libvirtio.a\r
+\r
+# Include the header and source files required by the virtio lib.\r
+HEADERS += \\r
+$(wildcard *.h) \\r
+$(wildcard ../hil/*.h) \\r
+$(wildcard ../env/*.h)\r
+\r
+SRCFILES += \\r
+$(wildcard *.c) \\r
+$(wildcard ../hil/*/*.c) \\r
+$(wildcard ../env/*.c)\r
+\r
+OBJFILES := $(patsubst %.c, %.o, $(SRCFILES))\r
+\r
+all: $(LIB)\r
+\r
+$(LIB): $(OBJFILES)\r
+ @echo AR $@\r
+ @$(AR) -r $@ $(OBJFILES)\r
+\r
+%.o:%.c $(HEADERS)\r
+ @echo CC $(<:.c=.o)\r
+ @$(CC) $(CFLAGS) $(ARCH_CFLAGS) $(INCLUDE) -c $< -o $@\r
+\r
+clean:\r
+ -$(RM) $(LIB) $(OBJFILES)\r
+\r
+PHONY: all clean
\ No newline at end of file
diff --git a/virtio/virtio.c b/virtio/virtio.c
--- /dev/null
+++ b/virtio/virtio.c
@@ -0,0 +1,96 @@
+/*-
+ * Copyright (c) 2011, Bryan Venteicher <bryanv@FreeBSD.org>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice unmodified, this list of conditions, and the following
+ * disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "virtio.h"
+
+static const char *virtio_feature_name(unsigned long feature, struct virtio_feature_desc *);
+
+//TODO : This structure may change depending on the types of devices we support.
+static struct virtio_ident {
+ unsigned short devid;
+ const char *name;
+} virtio_ident_table[] = {
+ { VIRTIO_ID_NETWORK, "Network" },
+ { VIRTIO_ID_BLOCK, "Block" },
+ { VIRTIO_ID_CONSOLE, "Console" },
+ { VIRTIO_ID_ENTROPY, "Entropy" },
+ { VIRTIO_ID_BALLOON, "Balloon" },
+ { VIRTIO_ID_IOMEMORY, "IOMemory" },
+ { VIRTIO_ID_SCSI, "SCSI" },
+ { VIRTIO_ID_9P, "9P Transport" },
+
+ { 0, NULL }
+};
+
+/* Device independent features. */
+static struct virtio_feature_desc virtio_common_feature_desc[] = {
+ { VIRTIO_F_NOTIFY_ON_EMPTY, "NotifyOnEmpty" },
+ { VIRTIO_RING_F_INDIRECT_DESC, "RingIndirect" },
+ { VIRTIO_RING_F_EVENT_IDX, "EventIdx" },
+ { VIRTIO_F_BAD_FEATURE, "BadFeature" },
+
+ { 0, NULL }
+};
+
+const char *
+virtio_dev_name(unsigned short devid)
+{
+ struct virtio_ident *ident;
+
+ for (ident = virtio_ident_table; ident->name != NULL; ident++) {
+ if (ident->devid == devid)
+ return (ident->name);
+ }
+
+ return (NULL);
+}
+
+static const char *
+virtio_feature_name(unsigned long val, struct virtio_feature_desc *desc)
+{
+ int i, j;
+ struct virtio_feature_desc *descs[2] = { desc,
+ virtio_common_feature_desc };
+
+ for (i = 0; i < 2; i++) {
+ if (descs[i] == NULL)
+ continue;
+
+ for (j = 0; descs[i][j].vfd_val != 0; j++) {
+ if (val == descs[i][j].vfd_val)
+ return (descs[i][j].vfd_str);
+ }
+ }
+
+ return (NULL);
+}
+
+void virtio_describe(struct virtio_device *dev, const char *msg,
+ uint32_t features, struct virtio_feature_desc *desc)
+{
+ // TODO: Not used currently - keeping it for future use
+ virtio_feature_name(0,desc);
+}
+
diff --git a/virtio/virtio.h b/virtio/virtio.h
--- /dev/null
+++ b/virtio/virtio.h
@@ -0,0 +1,151 @@
+/*-\r
+ * This header is BSD licensed so anyone can use the definitions to implement\r
+ * compatible drivers/servers.\r
+ *\r
+ * Redistribution and use in source and binary forms, with or without\r
+ * modification, are permitted provided that the following conditions\r
+ * are met:\r
+ * 1. Redistributions of source code must retain the above copyright\r
+ * notice, this list of conditions and the following disclaimer.\r
+ * 2. Redistributions in binary form must reproduce the above copyright\r
+ * notice, this list of conditions and the following disclaimer in the\r
+ * documentation and/or other materials provided with the distribution.\r
+ * 3. Neither the name of IBM nor the names of its contributors\r
+ * may be used to endorse or promote products derived from this software\r
+ * without specific prior written permission.\r
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\r
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED\r
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\r
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL IBM OR CONTRIBUTORS BE LIABLE\r
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\r
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\r
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\r
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\r
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\r
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\r
+ * SUCH DAMAGE.\r
+ *\r
+ * $FreeBSD$\r
+ */\r
+\r
+#ifndef _VIRTIO_H_\r
+#define _VIRTIO_H_\r
+\r
+#include "virtqueue.h"\r
+\r
+/* VirtIO device IDs. */\r
+#define VIRTIO_ID_NETWORK 0x01\r
+#define VIRTIO_ID_BLOCK 0x02\r
+#define VIRTIO_ID_CONSOLE 0x03\r
+#define VIRTIO_ID_ENTROPY 0x04\r
+#define VIRTIO_ID_BALLOON 0x05\r
+#define VIRTIO_ID_IOMEMORY 0x06\r
+#define VIRTIO_ID_RPMSG 0x07 /* virtio remote remote_proc messaging */\r
+#define VIRTIO_ID_SCSI 0x08\r
+#define VIRTIO_ID_9P 0x09\r
+\r
+/* Status byte for guest to report progress. */\r
+#define VIRTIO_CONFIG_STATUS_RESET 0x00\r
+#define VIRTIO_CONFIG_STATUS_ACK 0x01\r
+#define VIRTIO_CONFIG_STATUS_DRIVER 0x02\r
+#define VIRTIO_CONFIG_STATUS_DRIVER_OK 0x04\r
+#define VIRTIO_CONFIG_STATUS_FAILED 0x80\r
+\r
+/*\r
+ * Generate interrupt when the virtqueue ring is\r
+ * completely used, even if we've suppressed them.\r
+ */\r
+#define VIRTIO_F_NOTIFY_ON_EMPTY (1 << 24)\r
+\r
+/*\r
+ * The guest should never negotiate this feature; it\r
+ * is used to detect faulty drivers.\r
+ */\r
+#define VIRTIO_F_BAD_FEATURE (1 << 30)\r
+\r
+/*\r
+ * Some VirtIO feature bits (currently bits 28 through 31) are\r
+ * reserved for the transport being used (eg. virtio_ring), the\r
+ * rest are per-device feature bits.\r
+ */\r
+#define VIRTIO_TRANSPORT_F_START 28\r
+#define VIRTIO_TRANSPORT_F_END 32\r
+\r
+typedef struct _virtio_dispatch_ virtio_dispatch;\r
+\r
+struct virtio_feature_desc {\r
+ uint32_t vfd_val;\r
+ const char *vfd_str;\r
+};\r
+\r
+/*\r
+ * Structure definition for virtio devices for use by the\r
+ * applications/drivers\r
+ *\r
+ */\r
+\r
+struct virtio_device {\r
+ /*\r
+ * Since there is no generic device structure so\r
+ * keep its type as void. The driver layer will take\r
+ * care of it.\r
+ */\r
+ void *device;\r
+\r
+ /* Device name */\r
+ char *name;\r
+\r
+ /* List of virtqueues encapsulated by virtio device. */\r
+ //TODO : Need to implement a list service for ipc stack.\r
+ void *vq_list;\r
+\r
+ /* Virtio device specific features */\r
+ uint32_t features;\r
+\r
+ /* Virtio dispatch table */\r
+ virtio_dispatch *func;\r
+\r
+ /*\r
+ * Pointer to hold some private data, useful\r
+ * in callbacks.\r
+ */\r
+ void *data;\r
+};\r
+\r
+/* \r
+ * Helper functions.\r
+ */ \r
+const char *virtio_dev_name(uint16_t devid);\r
+void virtio_describe(struct virtio_device *dev, const char *msg,\r
+ uint32_t features, struct virtio_feature_desc *feature_desc);\r
+\r
+/*\r
+ * Functions for virtio device configuration as defined in Rusty Russell's paper.\r
+ * Drivers are expected to implement these functions in their respective codes.\r
+ * \r
+ */\r
+\r
+struct _virtio_dispatch_ {\r
+ int (*create_virtqueues)(struct virtio_device *dev, int flags, int nvqs,\r
+ const char *names[], vq_callback *callbacks[],\r
+ struct virtqueue *vqs[]);\r
+ uint8_t (*get_status)(struct virtio_device *dev);\r
+ void (*set_status)(struct virtio_device *dev, uint8_t status);\r
+ uint32_t (*get_features)(struct virtio_device *dev);\r
+ void (*set_features)(struct virtio_device *dev, uint32_t feature);\r
+ uint32_t (*negotiate_features)(struct virtio_device *dev, uint32_t features);\r
+\r
+ /*\r
+ * Read/write a variable amount from the device specific (ie, network)\r
+ * configuration region. This region is encoded in the same endian as\r
+ * the guest.\r
+ */\r
+ void (*read_config)(struct virtio_device *dev, uint32_t offset, void *dst,\r
+ int length);\r
+ void (*write_config)(struct virtio_device *dev, uint32_t offset, void *src,\r
+ int length);\r
+ void (*reset_device)(struct virtio_device *dev);\r
+\r
+};\r
+\r
+#endif /* _VIRTIO_H_ */\r
diff --git a/virtio/virtio_ring.h b/virtio/virtio_ring.h
--- /dev/null
+++ b/virtio/virtio_ring.h
@@ -0,0 +1,165 @@
+/*-\r
+ * Copyright Rusty Russell IBM Corporation 2007.\r
+ *\r
+ * This header is BSD licensed so anyone can use the definitions to implement\r
+ * compatible drivers/servers.\r
+ *\r
+ * Redistribution and use in source and binary forms, with or without\r
+ * modification, are permitted provided that the following conditions\r
+ * are met:\r
+ * 1. Redistributions of source code must retain the above copyright\r
+ * notice, this list of conditions and the following disclaimer.\r
+ * 2. Redistributions in binary form must reproduce the above copyright\r
+ * notice, this list of conditions and the following disclaimer in the\r
+ * documentation and/or other materials provided with the distribution.\r
+ * 3. Neither the name of IBM nor the names of its contributors\r
+ * may be used to endorse or promote products derived from this software\r
+ * without specific prior written permission.\r
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\r
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED\r
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\r
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL IBM OR CONTRIBUTORS BE LIABLE\r
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\r
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\r
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\r
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\r
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\r
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\r
+ * SUCH DAMAGE.\r
+ *\r
+ * $FreeBSD$\r
+ */\r
+\r
+#ifndef VIRTIO_RING_H\r
+#define VIRTIO_RING_H\r
+\r
+/* This marks a buffer as continuing via the next field. */\r
+#define VRING_DESC_F_NEXT 1\r
+/* This marks a buffer as write-only (otherwise read-only). */\r
+#define VRING_DESC_F_WRITE 2\r
+/* This means the buffer contains a list of buffer descriptors. */\r
+#define VRING_DESC_F_INDIRECT 4\r
+\r
+/* The Host uses this in used->flags to advise the Guest: don't kick me\r
+ * when you add a buffer. It's unreliable, so it's simply an\r
+ * optimization. Guest will still kick if it's out of buffers. */\r
+#define VRING_USED_F_NO_NOTIFY 1\r
+/* The Guest uses this in avail->flags to advise the Host: don't\r
+ * interrupt me when you consume a buffer. It's unreliable, so it's\r
+ * simply an optimization. */\r
+#define VRING_AVAIL_F_NO_INTERRUPT 1\r
+\r
+/* VirtIO ring descriptors: 16 bytes.\r
+ * These can chain together via "next". */\r
+struct vring_desc {\r
+ /* Address (guest-physical). */\r
+ uint64_t addr;\r
+ /* Length. */\r
+ uint32_t len;\r
+ /* The flags as indicated above. */\r
+ uint16_t flags;\r
+ /* We chain unused descriptors via this, too. */\r
+ uint16_t next;\r
+};\r
+\r
+struct vring_avail {\r
+ uint16_t flags;\r
+ uint16_t idx;\r
+ uint16_t ring[0];\r
+};\r
+\r
+/* uint32_t is used here for ids for padding reasons. */\r
+struct vring_used_elem {\r
+ /* Index of start of used descriptor chain. */\r
+ uint32_t id;\r
+ /* Total length of the descriptor chain which was written to. */\r
+ uint32_t len;\r
+};\r
+\r
+struct vring_used {\r
+ uint16_t flags;\r
+ uint16_t idx;\r
+ struct vring_used_elem ring[0];\r
+};\r
+\r
+struct vring {\r
+ unsigned int num;\r
+\r
+ struct vring_desc *desc;\r
+ struct vring_avail *avail;\r
+ struct vring_used *used;\r
+};\r
+\r
+/* The standard layout for the ring is a continuous chunk of memory which\r
+ * looks like this. We assume num is a power of 2.\r
+ *\r
+ * struct vring {\r
+ * // The actual descriptors (16 bytes each)\r
+ * struct vring_desc desc[num];\r
+ *\r
+ * // A ring of available descriptor heads with free-running index.\r
+ * __u16 avail_flags;\r
+ * __u16 avail_idx;\r
+ * __u16 available[num];\r
+ * __u16 used_event_idx;\r
+ *\r
+ * // Padding to the next align boundary.\r
+ * char pad[];\r
+ *\r
+ * // A ring of used descriptor heads with free-running index.\r
+ * __u16 used_flags;\r
+ * __u16 used_idx;\r
+ * struct vring_used_elem used[num];\r
+ * __u16 avail_event_idx;\r
+ * };\r
+ *\r
+ * NOTE: for VirtIO PCI, align is 4096.\r
+ */\r
+\r
+/*\r
+ * We publish the used event index at the end of the available ring, and vice\r
+ * versa. They are at the end for backwards compatibility.\r
+ */\r
+#define vring_used_event(vr) ((vr)->avail->ring[(vr)->num])\r
+#define vring_avail_event(vr) (*(uint16_t *)&(vr)->used->ring[(vr)->num])\r
+\r
+static inline int\r
+vring_size(unsigned int num, unsigned long align)\r
+{\r
+ int size;\r
+\r
+ size = num * sizeof(struct vring_desc);\r
+ size += sizeof(struct vring_avail) + (num * sizeof(uint16_t)) +\r
+ sizeof(uint16_t);\r
+ size = (size + align - 1) & ~(align - 1);\r
+ size += sizeof(struct vring_used) +\r
+ (num * sizeof(struct vring_used_elem)) + sizeof(uint16_t);\r
+ return (size);\r
+}\r
+\r
+static inline void\r
+vring_init(struct vring *vr, unsigned int num, uint8_t *p,\r
+ unsigned long align)\r
+{\r
+ vr->num = num;\r
+ vr->desc = (struct vring_desc *) p;\r
+ vr->avail = (struct vring_avail *) (p +\r
+ num * sizeof(struct vring_desc));\r
+ vr->used = (void *)\r
+ (((unsigned long) &vr->avail->ring[num] + align-1) & ~(align-1));\r
+}\r
+\r
+/*\r
+ * The following is used with VIRTIO_RING_F_EVENT_IDX.\r
+ *\r
+ * Assuming a given event_idx value from the other size, if we have\r
+ * just incremented index from old to new_idx, should we trigger an\r
+ * event?\r
+ */\r
+static inline int\r
+vring_need_event(uint16_t event_idx, uint16_t new_idx, uint16_t old)\r
+{\r
+\r
+ return (uint16_t)(new_idx - event_idx - 1) < (uint16_t)(new_idx - old);\r
+}\r
+#endif /* VIRTIO_RING_H */\r
diff --git a/virtio/virtqueue.c b/virtio/virtqueue.c
--- /dev/null
+++ b/virtio/virtqueue.c
@@ -0,0 +1,691 @@
+/*-\r
+ * Copyright (c) 2011, Bryan Venteicher <bryanv@FreeBSD.org>\r
+ * All rights reserved.\r
+ *\r
+ * Redistribution and use in source and binary forms, with or without\r
+ * modification, are permitted provided that the following conditions\r
+ * are met:\r
+ * 1. Redistributions of source code must retain the above copyright\r
+ * notice unmodified, this list of conditions, and the following\r
+ * disclaimer.\r
+ * 2. Redistributions in binary form must reproduce the above copyright\r
+ * notice, this list of conditions and the following disclaimer in the\r
+ * documentation and/or other materials provided with the distribution.\r
+ *\r
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR\r
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES\r
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.\r
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,\r
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\r
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\r
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\r
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\r
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF\r
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
+ */\r
+\r
+#include "virtqueue.h"\r
+\r
+/* Prototype for internal functions. */\r
+static void vq_ring_init(struct virtqueue *);\r
+static void vq_ring_update_avail(struct virtqueue *, uint16_t);\r
+static uint16_t vq_ring_add_buffer(struct virtqueue *, struct vring_desc *,\r
+ uint16_t, struct llist *, int, int);\r
+static int vq_ring_enable_interrupt(struct virtqueue *, uint16_t);\r
+static void vq_ring_free_chain(struct virtqueue *, uint16_t);\r
+static int vq_ring_must_notify_host(struct virtqueue *vq);\r
+static void vq_ring_notify_host(struct virtqueue *vq);\r
+static int virtqueue_nused(struct virtqueue *vq);\r
+\r
+/**\r
+ * virtqueue_create - Creates new VirtIO queue\r
+ *\r
+ * @param device - Pointer to VirtIO device\r
+ * @param id - VirtIO queue ID , must be unique\r
+ * @param name - Name of VirtIO queue\r
+ * @param ring - Pointer to vring_alloc_info control block\r
+ * @param callback - Pointer to callback function, invoked\r
+ * when message is available on VirtIO queue\r
+ * @param notify - Pointer to notify function, used to notify\r
+ * other side that there is job available for it\r
+ * @param v_queue - Created VirtIO queue.\r
+ *\r
+ * @return - Function status\r
+ */\r
+int virtqueue_create(struct virtio_device *virt_dev, unsigned short id, char *name,\r
+ struct vring_alloc_info *ring, void (*callback)(struct virtqueue *vq),\r
+ void (*notify)(struct virtqueue *vq),\r
+ struct virtqueue **v_queue) {\r
+\r
+ struct virtqueue *vq = VQ_NULL;\r
+ int status = VQUEUE_SUCCESS;\r
+ uint32_t vq_size = 0;\r
+\r
+ VQ_PARAM_CHK(ring == VQ_NULL, status, ERROR_VQUEUE_INVLD_PARAM);\r
+ VQ_PARAM_CHK(ring->num_descs == 0, status, ERROR_VQUEUE_INVLD_PARAM);\r
+ VQ_PARAM_CHK(ring->num_descs & (ring->num_descs - 1), status,\r
+ ERROR_VRING_ALIGN);\r
+\r
+ //TODO : Error check for indirect buffer addition\r
+\r
+ if (status == VQUEUE_SUCCESS) {\r
+\r
+ vq_size = sizeof(struct virtqueue)\r
+ + (ring->num_descs) * sizeof(struct vq_desc_extra);\r
+ vq = (struct virtqueue *) env_allocate_memory(vq_size);\r
+\r
+ if (vq == VQ_NULL) {\r
+ return (ERROR_NO_MEM);\r
+ }\r
+\r
+ env_memset(vq, 0x00, vq_size);\r
+\r
+ vq->vq_dev = virt_dev;\r
+ env_strncpy(vq->vq_name, name, VIRTQUEUE_MAX_NAME_SZ);\r
+ vq->vq_queue_index = id;\r
+ vq->vq_alignment = ring->align;\r
+ vq->vq_nentries = ring->num_descs;\r
+ vq->vq_free_cnt = vq->vq_nentries;\r
+ vq->callback = callback;\r
+ vq->notify = notify;\r
+\r
+ //TODO : Whether we want to support indirect addition or not.\r
+ vq->vq_ring_size = vring_size(ring->num_descs, ring->align);\r
+ vq->vq_ring_mem = (void *) ring->phy_addr;\r
+\r
+ /* Initialize vring control block in virtqueue. */\r
+ vq_ring_init(vq);\r
+\r
+ /* Disable callbacks - will be enabled by the application\r
+ * once initialization is completed.\r
+ */\r
+ virtqueue_disable_cb(vq);\r
+\r
+ *v_queue = vq;\r
+\r
+ //TODO : Need to add cleanup in case of error used with the indirect buffer addition\r
+ //TODO: do we need to save the new queue in db based on its id\r
+ }\r
+\r
+ return (status);\r
+}\r
+\r
+/**\r
+ * virtqueue_add_buffer() - Enqueues new buffer in vring for consumption\r
+ * by other side. Readable buffers are always\r
+ * inserted before writable buffers\r
+ *\r
+ * @param vq - Pointer to VirtIO queue control block.\r
+ * @param buffer - Pointer to buffer list\r
+ * @param readable - Number of readable buffers\r
+ * @param writable - Number of writable buffers\r
+ * @param cookie - Pointer to hold call back data\r
+ *\r
+ * @return - Function status\r
+ */\r
+int virtqueue_add_buffer(struct virtqueue *vq, struct llist *buffer,\r
+ int readable, int writable, void *cookie) {\r
+\r
+ struct vq_desc_extra *dxp = VQ_NULL;\r
+ int status = VQUEUE_SUCCESS;\r
+ uint16_t head_idx;\r
+ uint16_t idx;\r
+ int needed;\r
+\r
+ needed = readable + writable;\r
+\r
+ VQ_PARAM_CHK(vq == VQ_NULL, status, ERROR_VQUEUE_INVLD_PARAM);\r
+ VQ_PARAM_CHK(needed < 1, status, ERROR_VQUEUE_INVLD_PARAM);\r
+ VQ_PARAM_CHK(vq->vq_free_cnt == 0, status, ERROR_VRING_FULL);\r
+\r
+ //TODO: Add parameters validation for indirect buffer addition\r
+\r
+ VQUEUE_BUSY(vq);\r
+\r
+ if (status == VQUEUE_SUCCESS) {\r
+\r
+ //TODO : Indirect buffer addition support\r
+\r
+ VQASSERT(vq, cookie != VQ_NULL, "enqueuing with no cookie");\r
+\r
+ head_idx = vq->vq_desc_head_idx;\r
+ VQ_RING_ASSERT_VALID_IDX(vq, head_idx);\r
+ dxp = &vq->vq_descx[head_idx];\r
+\r
+ VQASSERT(vq, (dxp->cookie == VQ_NULL), "cookie already exists for index");\r
+\r
+ dxp->cookie = cookie;\r
+ dxp->ndescs = needed;\r
+\r
+ /* Enqueue buffer onto the ring. */\r
+ idx = vq_ring_add_buffer(vq, vq->vq_ring.desc, head_idx, buffer,\r
+ readable, writable);\r
+\r
+ vq->vq_desc_head_idx = idx;\r
+ vq->vq_free_cnt -= needed;\r
+\r
+ if (vq->vq_free_cnt == 0)\r
+ VQ_RING_ASSERT_CHAIN_TERM(vq);\r
+ else\r
+ VQ_RING_ASSERT_VALID_IDX(vq, idx);\r
+\r
+ /*\r
+ * Update vring_avail control block fields so that other\r
+ * side can get buffer using it.\r
+ */\r
+ vq_ring_update_avail(vq, head_idx);\r
+ }\r
+\r
+ VQUEUE_IDLE(vq);\r
+\r
+ return (status);\r
+}\r
+\r
+/**\r
+ * virtqueue_add_single_buffer - Enqueues single buffer in vring\r
+ *\r
+ * @param vq - Pointer to VirtIO queue control block\r
+ * @param cookie - Pointer to hold call back data\r
+ * @param buffer_addr - Address of buffer\r
+ * @param len - Length of buffer\r
+ * @param writable - If buffer writable\r
+ * @param has_next - If buffers for subsequent call are\r
+ * to be chained\r
+ *\r
+ * @return - Function status\r
+ */\r
+int virtqueue_add_single_buffer(struct virtqueue *vq, void *cookie,\r
+ void *buffer_addr, uint_t len, int writable, boolean has_next) {\r
+\r
+ struct vq_desc_extra *dxp;\r
+ struct vring_desc *dp;\r
+ uint16_t head_idx;\r
+ uint16_t idx;\r
+ int status = VQUEUE_SUCCESS;\r
+\r
+ VQ_PARAM_CHK(vq == VQ_NULL, status, ERROR_VQUEUE_INVLD_PARAM);\r
+ VQ_PARAM_CHK(vq->vq_free_cnt == 0, status, ERROR_VRING_FULL);\r
+\r
+ VQUEUE_BUSY(vq);\r
+\r
+ if (status == VQUEUE_SUCCESS) {\r
+\r
+ VQASSERT(vq, cookie != VQ_NULL, "enqueuing with no cookie");\r
+\r
+ head_idx = vq->vq_desc_head_idx;\r
+ dxp = &vq->vq_descx[head_idx];\r
+\r
+ dxp->cookie = cookie;\r
+ dxp->ndescs = 1;\r
+ idx = head_idx;\r
+\r
+ dp = &vq->vq_ring.desc[idx];\r
+ dp->addr = env_map_vatopa(buffer_addr);\r
+ dp->len = len;\r
+ dp->flags = 0;\r
+ idx = dp->next;\r
+\r
+ if (has_next)\r
+ dp->flags |= VRING_DESC_F_NEXT;\r
+ if (writable)\r
+ dp->flags |= VRING_DESC_F_WRITE;\r
+\r
+ vq->vq_desc_head_idx = idx;\r
+ vq->vq_free_cnt--;\r
+\r
+ if (vq->vq_free_cnt == 0)\r
+ VQ_RING_ASSERT_CHAIN_TERM(vq);\r
+ else\r
+ VQ_RING_ASSERT_VALID_IDX(vq, idx);\r
+\r
+ vq_ring_update_avail(vq, head_idx);\r
+ }\r
+\r
+ VQUEUE_IDLE(vq);\r
+\r
+ return (status);\r
+}\r
+\r
+/**\r
+ * virtqueue_get_buffer - Returns used buffers from VirtIO queue\r
+ *\r
+ * @param vq - Pointer to VirtIO queue control block\r
+ * @param len - Length of conumed buffer\r
+ *\r
+ * @return - Pointer to used buffer\r
+ */\r
+void *virtqueue_get_buffer(struct virtqueue *vq, uint32_t *len) {\r
+ struct vring_used_elem *uep;\r
+ void *cookie;\r
+ uint16_t used_idx, desc_idx;\r
+\r
+ if ((vq == VQ_NULL) || (vq->vq_used_cons_idx == vq->vq_ring.used->idx))\r
+ return (VQ_NULL);\r
+\r
+ VQUEUE_BUSY(vq);\r
+\r
+ used_idx = vq->vq_used_cons_idx++ & (vq->vq_nentries - 1);\r
+ uep = &vq->vq_ring.used->ring[used_idx];\r
+\r
+ env_rmb();\r
+\r
+ desc_idx = (uint16_t) uep->id;\r
+ if (len != VQ_NULL)\r
+ *len = uep->len;\r
+\r
+ vq_ring_free_chain(vq, desc_idx);\r
+\r
+ cookie = vq->vq_descx[desc_idx].cookie;\r
+ vq->vq_descx[desc_idx].cookie = VQ_NULL;\r
+\r
+ VQUEUE_IDLE(vq);\r
+\r
+ return (cookie);\r
+}\r
+\r
+/**\r
+ * virtqueue_free - Frees VirtIO queue resources\r
+ *\r
+ * @param vq - Pointer to VirtIO queue control block\r
+ *\r
+ */\r
+void virtqueue_free(struct virtqueue *vq) {\r
+\r
+ if (vq != VQ_NULL) {\r
+\r
+ if (vq->vq_free_cnt != vq->vq_nentries) {\r
+ env_print("\r\nWARNING %s: freeing non-empty virtqueue\r\n", vq->vq_name);\r
+ }\r
+\r
+ //TODO : Need to free indirect buffers here\r
+\r
+ if (vq->vq_ring_mem != VQ_NULL) {\r
+ vq->vq_ring_size = 0;\r
+ vq->vq_ring_mem = VQ_NULL;\r
+ }\r
+\r
+ env_free_memory(vq);\r
+ }\r
+}\r
+\r
+/**\r
+ * virtqueue_get_available_buffer - Returns buffer available for use in the\r
+ * VirtIO queue\r
+ *\r
+ * @param vq - Pointer to VirtIO queue control block\r
+ * @param avail_idx - Pointer to index used in vring desc table\r
+ * @param len - Length of buffer\r
+ *\r
+ * @return - Pointer to available buffer\r
+ */\r
+void *virtqueue_get_available_buffer(struct virtqueue *vq, uint16_t *avail_idx,\r
+ uint32_t *len) {\r
+\r
+ uint16_t head_idx = 0;\r
+ void *buffer;\r
+\r
+ if (vq->vq_available_idx == vq->vq_ring.avail->idx) {\r
+ return (VQ_NULL);\r
+ }\r
+\r
+ VQUEUE_BUSY(vq);\r
+\r
+ head_idx = vq->vq_available_idx++ & (vq->vq_nentries - 1);\r
+ *avail_idx = vq->vq_ring.avail->ring[head_idx];\r
+\r
+ env_rmb();\r
+\r
+ buffer = env_map_patova(vq->vq_ring.desc[*avail_idx].addr);\r
+ *len = vq->vq_ring.desc[*avail_idx].len;\r
+\r
+ VQUEUE_IDLE(vq);\r
+\r
+ return (buffer);\r
+}\r
+\r
+/**\r
+ * virtqueue_add_consumed_buffer - Returns consumed buffer back to VirtIO queue\r
+ *\r
+ * @param vq - Pointer to VirtIO queue control block\r
+ * @param head_idx - Index of vring desc containing used buffer\r
+ * @param len - Length of buffer\r
+ *\r
+ * @return - Function status\r
+ */\r
+int virtqueue_add_consumed_buffer(struct virtqueue *vq, uint16_t head_idx,\r
+ uint_t len) {\r
+\r
+ struct vring_used_elem *used_desc = VQ_NULL;\r
+ uint16_t used_idx;\r
+\r
+ if ((head_idx > vq->vq_nentries) || (head_idx < 0)) {\r
+ return (ERROR_VRING_NO_BUFF);\r
+ }\r
+\r
+ VQUEUE_BUSY(vq);\r
+\r
+ used_idx = vq->vq_ring.used->idx & (vq->vq_nentries - 1);\r
+ used_desc = &(vq->vq_ring.used->ring[used_idx]);\r
+ used_desc->id = head_idx;\r
+ used_desc->len = len;\r
+\r
+ env_wmb();\r
+\r
+ vq->vq_ring.used->idx++;\r
+\r
+ VQUEUE_IDLE(vq);\r
+\r
+ return (VQUEUE_SUCCESS);\r
+}\r
+\r
+/**\r
+ * virtqueue_enable_cb - Enables callback generation\r
+ *\r
+ * @param vq - Pointer to VirtIO queue control block\r
+ *\r
+ * @return - Function status\r
+ */\r
+int virtqueue_enable_cb(struct virtqueue *vq) {\r
+\r
+ return (vq_ring_enable_interrupt(vq, 0));\r
+}\r
+\r
+/**\r
+ * virtqueue_enable_cb - Disables callback generation\r
+ *\r
+ * @param vq - Pointer to VirtIO queue control block\r
+ *\r
+ */\r
+void virtqueue_disable_cb(struct virtqueue *vq) {\r
+\r
+ VQUEUE_BUSY(vq);\r
+\r
+ if (vq->vq_flags & VIRTQUEUE_FLAG_EVENT_IDX) {\r
+ vring_used_event(&vq->vq_ring)= vq->vq_used_cons_idx - vq->vq_nentries\r
+ - 1;\r
+ } else {\r
+ vq->vq_ring.avail->flags |= VRING_AVAIL_F_NO_INTERRUPT;\r
+ }\r
+\r
+ VQUEUE_IDLE(vq);\r
+}\r
+\r
+/**\r
+ * virtqueue_kick - Notifies other side that there is buffer available for it.\r
+ *\r
+ * @param vq - Pointer to VirtIO queue control block\r
+ */\r
+void virtqueue_kick(struct virtqueue *vq) {\r
+\r
+ VQUEUE_BUSY(vq);\r
+\r
+ /* Ensure updated avail->idx is visible to host. */\r
+ env_mb();\r
+\r
+ if (vq_ring_must_notify_host(vq))\r
+ vq_ring_notify_host(vq);\r
+\r
+ vq->vq_queued_cnt = 0;\r
+\r
+ VQUEUE_IDLE(vq);\r
+}\r
+\r
+/**\r
+ * virtqueue_dump Dumps important virtqueue fields , use for debugging purposes\r
+ *\r
+ * @param vq - Pointer to VirtIO queue control block\r
+ */\r
+void virtqueue_dump(struct virtqueue *vq) {\r
+\r
+ if (vq == VQ_NULL)\r
+ return;\r
+\r
+ env_print("VQ: %s - size=%d; free=%d; used=%d; queued=%d; "\r
+ "desc_head_idx=%d; avail.idx=%d; used_cons_idx=%d; "\r
+ "used.idx=%d; avail.flags=0x%x; used.flags=0x%x\r\n", vq->vq_name,\r
+ vq->vq_nentries, vq->vq_free_cnt, virtqueue_nused(vq),\r
+ vq->vq_queued_cnt, vq->vq_desc_head_idx, vq->vq_ring.avail->idx,\r
+ vq->vq_used_cons_idx, vq->vq_ring.used->idx,\r
+ vq->vq_ring.avail->flags, vq->vq_ring.used->flags);\r
+}\r
+\r
+/**\r
+ * virtqueue_get_desc_size - Returns vring descriptor size\r
+ *\r
+ * @param vq - Pointer to VirtIO queue control block\r
+ *\r
+ * @return - Descriptor length\r
+ */\r
+uint32_t virtqueue_get_desc_size(struct virtqueue *vq) {\r
+ uint16_t head_idx = 0;\r
+ uint16_t avail_idx = 0;\r
+ uint32_t len = 0;\r
+\r
+ if (vq->vq_available_idx == vq->vq_ring.avail->idx) {\r
+ return (VQ_NULL);\r
+ }\r
+\r
+ VQUEUE_BUSY(vq);\r
+\r
+ head_idx = vq->vq_available_idx & (vq->vq_nentries - 1);\r
+ avail_idx = vq->vq_ring.avail->ring[head_idx];\r
+ len = vq->vq_ring.desc[avail_idx].len;\r
+\r
+ VQUEUE_IDLE(vq);\r
+\r
+ return (len);\r
+}\r
+/**************************************************************************\r
+ * Helper Functions *\r
+ **************************************************************************/\r
+\r
+/**\r
+ *\r
+ * vq_ring_add_buffer\r
+ *\r
+ */\r
+static uint16_t vq_ring_add_buffer(struct virtqueue *vq,\r
+ struct vring_desc *desc, uint16_t head_idx, struct llist *buffer,\r
+ int readable, int writable) {\r
+\r
+ struct vring_desc *dp;\r
+ int i, needed;\r
+ uint16_t idx;\r
+\r
+ needed = readable + writable;\r
+\r
+ for (i = 0, idx = head_idx; (i < needed && buffer != VQ_NULL);\r
+ i++, idx = dp->next, buffer = buffer->next) {\r
+\r
+ VQASSERT(vq, idx != VQ_RING_DESC_CHAIN_END,\r
+ "premature end of free desc chain");\r
+\r
+ dp = &desc[idx];\r
+ dp->addr = env_map_vatopa(buffer->data);\r
+ dp->len = buffer->attr;\r
+ dp->flags = 0;\r
+\r
+ if (i < needed - 1)\r
+ dp->flags |= VRING_DESC_F_NEXT;\r
+\r
+ /* Readable buffers are inserted into vring before the writable buffers.*/\r
+ if (i >= readable)\r
+ dp->flags |= VRING_DESC_F_WRITE;\r
+ }\r
+\r
+ return (idx);\r
+}\r
+\r
+/**\r
+ *\r
+ * vq_ring_free_chain\r
+ *\r
+ */\r
+static void vq_ring_free_chain(struct virtqueue *vq, uint16_t desc_idx) {\r
+ struct vring_desc *dp;\r
+ struct vq_desc_extra *dxp;\r
+\r
+ VQ_RING_ASSERT_VALID_IDX(vq, desc_idx);\r
+ dp = &vq->vq_ring.desc[desc_idx];\r
+ dxp = &vq->vq_descx[desc_idx];\r
+\r
+ if (vq->vq_free_cnt == 0)\r
+ VQ_RING_ASSERT_CHAIN_TERM(vq);\r
+\r
+ vq->vq_free_cnt += dxp->ndescs;\r
+ dxp->ndescs--;\r
+\r
+ if ((dp->flags & VRING_DESC_F_INDIRECT) == 0) {\r
+ while (dp->flags & VRING_DESC_F_NEXT) {\r
+ VQ_RING_ASSERT_VALID_IDX(vq, dp->next);\r
+ dp = &vq->vq_ring.desc[dp->next];\r
+ dxp->ndescs--;\r
+ }\r
+ }\r
+\r
+ VQASSERT(vq, (dxp->ndescs == 0),\r
+ "failed to free entire desc chain, remaining");\r
+\r
+ /*\r
+ * We must append the existing free chain, if any, to the end of\r
+ * newly freed chain. If the virtqueue was completely used, then\r
+ * head would be VQ_RING_DESC_CHAIN_END (ASSERTed above).\r
+ */\r
+ dp->next = vq->vq_desc_head_idx;\r
+ vq->vq_desc_head_idx = desc_idx;\r
+}\r
+\r
+/**\r
+ *\r
+ * vq_ring_init\r
+ *\r
+ */\r
+static void vq_ring_init(struct virtqueue *vq) {\r
+ struct vring *vr;\r
+ unsigned char *ring_mem;\r
+ int i, size;\r
+\r
+ ring_mem = vq->vq_ring_mem;\r
+ size = vq->vq_nentries;\r
+ vr = &vq->vq_ring;\r
+\r
+ vring_init(vr, size, ring_mem, vq->vq_alignment);\r
+\r
+ for (i = 0; i < size - 1; i++)\r
+ vr->desc[i].next = i + 1;\r
+ vr->desc[i].next = VQ_RING_DESC_CHAIN_END;\r
+}\r
+\r
+/**\r
+ *\r
+ * vq_ring_update_avail\r
+ *\r
+ */\r
+static void vq_ring_update_avail(struct virtqueue *vq, uint16_t desc_idx) {\r
+ uint16_t avail_idx;\r
+\r
+ /*\r
+ * Place the head of the descriptor chain into the next slot and make\r
+ * it usable to the host. The chain is made available now rather than\r
+ * deferring to virtqueue_notify() in the hopes that if the host is\r
+ * currently running on another CPU, we can keep it processing the new\r
+ * descriptor.\r
+ */\r
+ avail_idx = vq->vq_ring.avail->idx & (vq->vq_nentries - 1);\r
+ vq->vq_ring.avail->ring[avail_idx] = desc_idx;\r
+\r
+ env_wmb();\r
+\r
+ vq->vq_ring.avail->idx++;\r
+\r
+ /* Keep pending count until virtqueue_notify(). */\r
+ vq->vq_queued_cnt++;\r
+}\r
+\r
+/**\r
+ *\r
+ * vq_ring_enable_interrupt\r
+ *\r
+ */\r
+static int vq_ring_enable_interrupt(struct virtqueue *vq, uint16_t ndesc) {\r
+\r
+ /*\r
+ * Enable interrupts, making sure we get the latest index of\r
+ * what's already been consumed.\r
+ */\r
+ if (vq->vq_flags & VIRTQUEUE_FLAG_EVENT_IDX) {\r
+ vring_used_event(&vq->vq_ring)= vq->vq_used_cons_idx + ndesc;\r
+ } else {\r
+ vq->vq_ring.avail->flags &= ~VRING_AVAIL_F_NO_INTERRUPT;\r
+ }\r
+\r
+ env_mb();\r
+\r
+ /*\r
+ * Enough items may have already been consumed to meet our threshold\r
+ * since we last checked. Let our caller know so it processes the new\r
+ * entries.\r
+ */\r
+ if (virtqueue_nused(vq) > ndesc) {\r
+ return (1);\r
+ }\r
+\r
+ return (0);\r
+}\r
+\r
+/**\r
+ *\r
+ * virtqueue_interrupt\r
+ *\r
+ */\r
+void virtqueue_notification(struct virtqueue *vq) {\r
+\r
+ if (vq->callback != VQ_NULL)\r
+ vq->callback(vq);\r
+}\r
+\r
+/**\r
+ *\r
+ * vq_ring_must_notify_host\r
+ *\r
+ */\r
+static int vq_ring_must_notify_host(struct virtqueue *vq) {\r
+ uint16_t new_idx, prev_idx, event_idx;\r
+\r
+ if (vq->vq_flags & VIRTQUEUE_FLAG_EVENT_IDX) {\r
+ new_idx = vq->vq_ring.avail->idx;\r
+ prev_idx = new_idx - vq->vq_queued_cnt;\r
+ event_idx = vring_avail_event(&vq->vq_ring);\r
+\r
+ return (vring_need_event(event_idx, new_idx, prev_idx) != 0);\r
+ }\r
+\r
+ return ((vq->vq_ring.used->flags & VRING_USED_F_NO_NOTIFY) == 0);\r
+}\r
+\r
+/**\r
+ *\r
+ * vq_ring_notify_host\r
+ *\r
+ */\r
+static void vq_ring_notify_host(struct virtqueue *vq) {\r
+\r
+ if (vq->notify != VQ_NULL)\r
+ vq->notify(vq);\r
+}\r
+\r
+/**\r
+ *\r
+ * virtqueue_nused\r
+ *\r
+ */\r
+static int virtqueue_nused(struct virtqueue *vq) {\r
+ uint16_t used_idx, nused;\r
+\r
+ used_idx = vq->vq_ring.used->idx;\r
+\r
+ nused = (uint16_t) (used_idx - vq->vq_used_cons_idx);\r
+ VQASSERT(vq, nused <= vq->vq_nentries, "used more than available");\r
+\r
+ return (nused);\r
+}\r
diff --git a/virtio/virtqueue.h b/virtio/virtqueue.h
--- /dev/null
+++ b/virtio/virtqueue.h
@@ -0,0 +1,233 @@
+#ifndef VIRTQUEUE_H_\r
+#define VIRTQUEUE_H_\r
+\r
+/*-\r
+ * Copyright (c) 2011, Bryan Venteicher <bryanv@FreeBSD.org>\r
+ * All rights reserved.\r
+ *\r
+ * Redistribution and use in source and binary forms, with or without\r
+ * modification, are permitted provided that the following conditions\r
+ * are met:\r
+ * 1. Redistributions of source code must retain the above copyright\r
+ * notice unmodified, this list of conditions, and the following\r
+ * disclaimer.\r
+ * 2. Redistributions in binary form must reproduce the above copyright\r
+ * notice, this list of conditions and the following disclaimer in the\r
+ * documentation and/or other materials provided with the distribution.\r
+ *\r
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR\r
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES\r
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.\r
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,\r
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\r
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\r
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\r
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\r
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF\r
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
+ *\r
+ * $FreeBSD$\r
+ */\r
+\r
+typedef unsigned int uint_t;\r
+typedef signed char int8_t;\r
+typedef unsigned char uint8_t;\r
+typedef uint8_t boolean;\r
+typedef signed short int16_t;\r
+typedef unsigned short uint16_t;\r
+typedef unsigned long uint32_t;\r
+typedef unsigned long long uint64_t;\r
+typedef signed long long int64_t;\r
+\r
+#include "virtio_ring.h"\r
+#include "../porting/env/env.h"\r
+#include "../common/llist/llist.h"\r
+\r
+/*Error Codes*/\r
+#define VQ_ERROR_BASE -3000\r
+#define ERROR_VRING_FULL (VQ_ERROR_BASE - 1)\r
+#define ERROR_INVLD_DESC_IDX (VQ_ERROR_BASE - 2)\r
+#define ERROR_EMPTY_RING (VQ_ERROR_BASE - 3)\r
+#define ERROR_NO_MEM (VQ_ERROR_BASE - 4)\r
+#define ERROR_VRING_MAX_DESC (VQ_ERROR_BASE - 5)\r
+#define ERROR_VRING_ALIGN (VQ_ERROR_BASE - 6)\r
+#define ERROR_VRING_NO_BUFF (VQ_ERROR_BASE - 7)\r
+#define ERROR_VQUEUE_INVLD_PARAM (VQ_ERROR_BASE - 8)\r
+\r
+#define true 1\r
+#define false 0\r
+#define VQUEUE_SUCCESS 0\r
+#define VQUEUE_DEBUG false\r
+\r
+//TODO:\r
+/* This is temporary macro to replace C NULL support.\r
+ * At the moment all the RTL specific functions are present in env.\r
+ * */\r
+#define VQ_NULL 0\r
+\r
+/* The maximum virtqueue size is 2^15. Use that value as the end of\r
+ * descriptor chain terminator since it will never be a valid index\r
+ * in the descriptor table. This is used to verify we are correctly\r
+ * handling vq_free_cnt.\r
+ */\r
+#define VQ_RING_DESC_CHAIN_END 32768\r
+#define VIRTQUEUE_FLAG_INDIRECT 0x0001\r
+#define VIRTQUEUE_FLAG_EVENT_IDX 0x0002\r
+#define VIRTQUEUE_MAX_NAME_SZ 32\r
+\r
+/* Support for indirect buffer descriptors. */\r
+#define VIRTIO_RING_F_INDIRECT_DESC (1 << 28)\r
+\r
+/* Support to suppress interrupt until specific index is reached. */\r
+#define VIRTIO_RING_F_EVENT_IDX (1 << 29)\r
+\r
+/*\r
+ * Hint on how long the next interrupt should be postponed. This is\r
+ * only used when the EVENT_IDX feature is negotiated.\r
+ */\r
+typedef enum {\r
+ VQ_POSTPONE_SHORT,\r
+ VQ_POSTPONE_LONG,\r
+ VQ_POSTPONE_EMPTIED /* Until all available desc are used. */\r
+} vq_postpone_t;\r
+\r
+struct virtqueue {\r
+ //TODO: Need to define proper structure for\r
+ // virtio device with RPmsg and paravirtualization.\r
+\r
+ struct virtio_device *vq_dev;\r
+ char vq_name[VIRTQUEUE_MAX_NAME_SZ];\r
+ uint16_t vq_queue_index;\r
+ uint16_t vq_nentries;\r
+ uint32_t vq_flags;\r
+ int vq_alignment;\r
+ int vq_ring_size;\r
+ boolean vq_inuse;\r
+ void *vq_ring_mem;\r
+ void (*callback)(struct virtqueue *vq);\r
+ void (*notify)(struct virtqueue *vq);\r
+ int vq_max_indirect_size;\r
+ int vq_indirect_mem_size;\r
+ struct vring vq_ring;\r
+ uint16_t vq_free_cnt;\r
+ uint16_t vq_queued_cnt;\r
+\r
+ /*\r
+ * Head of the free chain in the descriptor table. If\r
+ * there are no free descriptors, this will be set to\r
+ * VQ_RING_DESC_CHAIN_END.\r
+ */\r
+ uint16_t vq_desc_head_idx;\r
+\r
+ /*\r
+ * Last consumed descriptor in the used table,\r
+ * trails vq_ring.used->idx.\r
+ */\r
+ uint16_t vq_used_cons_idx;\r
+\r
+ /*\r
+ * Last consumed descriptor in the available table -\r
+ * used by the consumer side.\r
+ */\r
+ uint16_t vq_available_idx;\r
+\r
+ uint8_t padd;\r
+\r
+ /*\r
+ * Used by the host side during callback. Cookie\r
+ * holds the address of buffer received from other side.\r
+ * Other fields in this structure are not used currently.\r
+ */\r
+\r
+ struct vq_desc_extra {\r
+ void *cookie;\r
+ struct vring_desc *indirect;\r
+ uint32_t indirect_paddr;\r
+ uint16_t ndescs;\r
+ } vq_descx[0];\r
+};\r
+\r
+/* struct to hold vring specific information */\r
+struct vring_alloc_info {\r
+ void *phy_addr;\r
+ uint32_t align;\r
+ uint16_t num_descs;\r
+ uint16_t pad;\r
+};\r
+\r
+typedef void vq_callback(struct virtqueue *);\r
+typedef void vq_notify(struct virtqueue *);\r
+\r
+#if (VQUEUE_DEBUG == true)\r
+\r
+#define VQASSERT(_vq, _exp, _msg) do{ \\r
+ if (!(_exp)){ env_print("%s: %s - "_msg, __func__, (_vq)->vq_name); while(1);} \\r
+ } while(0)\r
+\r
+#define VQ_RING_ASSERT_VALID_IDX(_vq, _idx) \\r
+ VQASSERT((_vq), (_idx) < (_vq)->vq_nentries, \\r
+ "invalid ring index")\r
+\r
+#define VQ_RING_ASSERT_CHAIN_TERM(_vq) \\r
+ VQASSERT((_vq), (_vq)->vq_desc_head_idx == \\r
+ VQ_RING_DESC_CHAIN_END, "full ring terminated incorrectly: invalid head")\r
+\r
+#define VQ_PARAM_CHK(condition, status_var, status_err) \\r
+ if ((status_var == 0) && (condition)) \\r
+ { \\r
+ status_var = status_err; \\r
+ }\r
+\r
+#define VQUEUE_BUSY(vq) if ((vq)->vq_inuse == false) \\r
+ (vq)->vq_inuse = true; \\r
+ else \\r
+ VQASSERT(vq, (vq)->vq_inuse == false, \\r
+ "VirtQueue already in use")\r
+\r
+#define VQUEUE_IDLE(vq) ((vq)->vq_inuse = false)\r
+\r
+#else\r
+\r
+#define KASSERT(cond, str)\r
+#define VQASSERT(_vq, _exp, _msg)\r
+#define VQ_RING_ASSERT_VALID_IDX(_vq, _idx)\r
+#define VQ_RING_ASSERT_CHAIN_TERM(_vq)\r
+#define VQ_PARAM_CHK(condition, status_var, status_err)\r
+#define VQUEUE_BUSY(vq)\r
+#define VQUEUE_IDLE(vq)\r
+\r
+#endif\r
+\r
+int virtqueue_create(struct virtio_device *device, unsigned short id, char *name,\r
+ struct vring_alloc_info *ring, void (*callback)(struct virtqueue *vq),\r
+ void (*notify)(struct virtqueue *vq), struct virtqueue **v_queue);\r
+\r
+int virtqueue_add_buffer(struct virtqueue *vq, struct llist *buffer,\r
+ int readable, int writable, void *cookie);\r
+\r
+int virtqueue_add_single_buffer(struct virtqueue *vq, void *cookie,\r
+ void* buffer_addr, uint_t len, int writable, boolean has_next);\r
+\r
+void *virtqueue_get_buffer(struct virtqueue *vq, uint32_t *len);\r
+\r
+void *virtqueue_get_available_buffer(struct virtqueue *vq, uint16_t *avail_idx,\r
+ uint32_t *len);\r
+\r
+int virtqueue_add_consumed_buffer(struct virtqueue *vq, uint16_t head_idx,\r
+ uint_t len);\r
+\r
+void virtqueue_disable_cb(struct virtqueue *vq);\r
+\r
+int virtqueue_enable_cb(struct virtqueue *vq);\r
+\r
+void virtqueue_kick(struct virtqueue *vq);\r
+\r
+void virtqueue_free(struct virtqueue *vq);\r
+\r
+void virtqueue_dump(struct virtqueue *vq);\r
+\r
+void virtqueue_notification(struct virtqueue *vq);\r
+\r
+uint32_t virtqueue_get_desc_size(struct virtqueue *vq);\r
+\r
+#endif /* VIRTQUEUE_H_ */\r