Skip to content
Snippets Groups Projects
Commit c9b541a9 authored by Armin Luntzer's avatar Armin Luntzer
Browse files

add demonstrator for Xentium processing network

parent 32e008fe
No related branches found
No related tags found
No related merge requests found
/**
* @file include/modules-image.h
*/
#ifndef _MODULES_IMAGE_H_
#define _MODULES_IMAGE_H_
void module_image_load_embedded(void);
void *module_lookup_embedded(char *mod_name);
void *module_lookup_symbol_embedded(char *sym_name);
void *module_read_embedded(char *mod_name);
void module_load_xen_kernels(void);
#endif /* _MODULES_IMAGE_H_ */
obj-y += main.o
obj-y += xentium_demo.o
obj-$(CONFIG_EMBED_MODULES_IMAGE) += modules-image.o
......@@ -7,111 +7,52 @@
#include <kernel/init.h>
#include <kernel/module.h> /* module_load */
#include <kernel/ksym.h> /* lookup_symbol */
#include <kernel/kernel.h>
#include <kernel/printk.h>
#include <kernel/kmem.h>
#include <kernel/sbrk.h>
#include <kernel/sysctl.h>
#include <asm/processor.h>
#define MSG "MAIN: "
void module_image_load_embedded(void);
void *module_lookup_embedded(char *mod_name);
void *module_lookup_symbol_embedded(char *sym_name);
void *module_read_embedded(char *mod_name);
void module_load_xen_kernels(void);
static void kernel_init(void)
{
/* Initcalls are executed by the libgloss boot code at this time,
* so we define our them below.
* No need to do anything here at the moment.
*/
}
arch_initcall(setup_arch);
#ifdef CONFIG_SYSCTL
subsys_initcall(sysctl_init);
#endif
#include <modules-image.h>
#include <data_proc_net.h>
#include <kernel/xentium.h>
int xen_op_output(unsigned long op_code, struct proc_task *t)
{
ssize_t i;
ssize_t n;
#include "xentium_demo.h"
unsigned int *p = NULL;
n = pt_get_nmemb(t);
if (!n)
goto exit;
printk("XEN OUT: op code %d, %d items t: %p\n", op_code, n, t);
#define MSG "MAIN: "
p = (unsigned int *) pt_get_data(t);
if (!p)
goto exit;
#if defined(GCC_VERSION) && (GCC_VERSION == 30404)
#ifdef __OPTIMIZE__
#warning "Optimisation flags appear to occasionally produce"
#warning "incorrect code for this compiler version. If something doesn't "
#warning "work when it logically should, select different compiler options"
#warning "in make menuconfig. You have been warned."
#endif /* __OPTIMIZE__ */
#endif /* GCC_VERSION */
for (i = 0; i < n; i++) {
printk("XEN_OUT: \t%d\n", p[i]);
}
exit:
kfree(p); /* clean up our data buffer */
#ifdef CONFIG_TARGET_COMPILER_BOOT_CODE
pt_destroy(t);
return PN_TASK_SUCCESS;
}
/**
* @brief kernel initialisation routines
*/
void xen_new_input_task(size_t n)
static int kernel_init(void)
{
struct proc_task *t;
static int seq;
int i;
unsigned int *data;
data = kzalloc(sizeof(unsigned int) * n);
for (i = 0; i < n; i++)
data[i] = i;
t = pt_create(data, n, 4, 0, seq++);
printk("\nT: %p\n", t);
BUG_ON(!t);
/* registered initcalls are executed by the libgloss boot code at this
* time no need to do anything here at the moment.
*/
BUG_ON(pt_add_step(t, 0xdeadbeef, NULL));
BUG_ON(pt_add_step(t, 0xb19b00b5, NULL));
// BUG_ON(pt_add_step(t, 0xdeadbeef, NULL));
// BUG_ON(pt_add_step(t, 0xb19b00b5, NULL));
setup_arch();
xentium_input_task(t);
return 0;
}
arch_initcall(kernel_init);
#ifdef CONFIG_TARGET_COMPILER_BOOT_CODE
/**
* @brief kernel main function
*/
int main(void)
{
......@@ -119,74 +60,40 @@ int main(void)
struct elf_module m;
kernel_init();
printk(MSG "Loading module image\n");
/* load the embedded AR image */
module_image_load_embedded();
#if 0
/* look up a kernel symbol */
printk("%s at %p\n", "printk", lookup_symbol("printk"));
printk(MSG "Looked up symbol %s at %p\n",
"printk", lookup_symbol("printk"));
/* look up a file in the embedded image */
printk("%s at %p\n", "noc_dma.ko",
printk(MSG "Looked up file %s at %p\n", "noc_dma.ko",
module_lookup_embedded("noc_dma.ko"));
#endif
/* to load an arbitrary image, you may upload it via grmon, e.g.
* load -binary kernel/test.ko 0xA0000000
* then load it:
* module_load(&m, (char *) 0xA0000000);
#if 0
/* If you have kernel modules embedded in your modules.images, this
* is how you can access them
*/
/* lookup the module containing <symbol> */
/* addr = module_lookup_symbol_embedded("somefunction"); */
addr = module_lookup_symbol_embedded("somefunction");
/* XXX the image is not necessary aligned properly, so we can't access
* it directly, until we have a MNA trap */
#if 0
addr = module_read_embedded("noc_dma.ko");
pr_debug(MSG "noc_dma module address is %p\n", addr);
if (addr)
module_load(&m, addr);
#endif
#if 0
modules_list_loaded();
#endif
#if 1
/* load all available Xentium kernels from the embedded modules image */
module_load_xen_kernels();
xentium_config_output_node(xen_op_output);
xen_new_input_task(3);
xen_new_input_task(10);
#if 0
xen_new_input_task(20);
xen_new_input_task(30);
#endif
while (1) {
xentium_schedule_next();
xentium_output_tasks();
cpu_relax();
}
#endif
xen_demo();
return 0;
}
......
/**
* linker references to embedded modules.image
* @file init/modules-image.c
*
* load files and modules in embedded modules.image
*/
#include <kernel/printk.h>
#include <kernel/ar.h>
#include <kernel/kmem.h>
......
/**
* @file init/xentium_demo.c
*
* @brief demonstrates how a Xentium processing network is used
*/
#include <kernel/kmem.h>
#include <kernel/kernel.h>
#include <kernel/printk.h>
#include <asm-generic/io.h>
#include <modules-image.h>
#include <data_proc_net.h>
#include <kernel/xentium.h>
/**
* @brief the output function of the xentium processing network
*/
static int xen_op_output(unsigned long op_code, struct proc_task *t)
{
ssize_t i;
ssize_t n;
unsigned int *p = NULL;
n = pt_get_nmemb(t);
if (!n)
goto exit;
p = (unsigned int *) pt_get_data(t);
if (!p)
goto exit;
printk("XEN_OUT: \t%d\n", ioread32be(&p[n-1]));
exit:
/* clean up our data buffer, its (de-)allocation is outside the
* responsibility of proc_task
*/
kfree(p);
pt_destroy(t);
return PN_TASK_SUCCESS;
}
/**
* @brief create a task and add it to the Xentium processing network
*/
static void xen_new_input_task(size_t n)
{
struct proc_task *t;
static int seq;
static int cnt;
int i;
unsigned int *data;
data = kzalloc(sizeof(unsigned int) * n);
if (!data)
return;
for (i = 0; i < n; i++)
data[i] = cnt++;
t = pt_create(data, n, 6, 0, seq++);
BUG_ON(!t);
BUG_ON(pt_add_step(t, 0xdeadbeef, NULL));
BUG_ON(pt_add_step(t, 0xb19b00b5, NULL));
BUG_ON(pt_add_step(t, 0xdeadbeef, NULL));
BUG_ON(pt_add_step(t, 0xb19b00b5, NULL));
BUG_ON(pt_add_step(t, 0xb19b00b5, NULL));
while (xentium_input_task(t) < 0)
printk("Xenitium input busy!\n");
}
/**
* @brief configure and run a xentium processing network demo
*/
void xen_demo(void)
{
/* load all available Xentium kernels from the embedded modules image */
module_load_xen_kernels();
xentium_config_output_node(xen_op_output);
while (1) {
static int seq = 100;
if (seq < 120)
xen_new_input_task(seq++);
xentium_output_tasks();
}
}
/**
* @file init/xentium_demo.h
*/
#ifndef _XENTIUM_DEMO_H_
#define _XENTIUM_DEMO_H_
void xen_demo(void);
#endif /* _XENTIUM_DEMO_H_ */
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment