[Cbe-oss-dev] [PATCH 16/23]MARS/task: workload module elf loader compatibility

Yuji Mano yuji.mano at am.sony.com
Sat Mar 14 12:18:54 EST 2009


This patch updates the task library for compatibility with the base workload
module elf loader patch. The task context is now 256 bytes and task module elf
loading is handled internally by the workload queue API in base library.

Signed-off-by: Yuji Mano <yuji.mano at am.sony.com>
---
 task/src/common/task_internal_types.h |   12 +++++---
 task/src/host/lib/task.c              |   51 +++++++++-------------------------
 task/src/mpu/module/Makefile.am       |    1 
 3 files changed, 22 insertions(+), 42 deletions(-)

--- a/task/src/common/task_internal_types.h
+++ b/task/src/common/task_internal_types.h
@@ -42,12 +42,16 @@
 
 #include "mars/workload_types.h"
 
-#define MARS_TASK_CONTEXT_SIZE				128
-#define MARS_TASK_CONTEXT_ALIGN				16
-#define MARS_TASK_CONTEXT_SAVE_ALIGN			128
+#define MARS_TASK_MODULE_NAME			"MARS TASK"
+
+#define MARS_TASK_CONTEXT_SIZE			MARS_WORKLOAD_CONTEXT_SIZE
+#define MARS_TASK_CONTEXT_ALIGN			MARS_WORKLOAD_CONTEXT_ALIGN
+#define MARS_TASK_CONTEXT_SAVE_ALIGN		128
 
 struct mars_task_context {
-	struct mars_workload_module module;	/* workload module */
+	uint8_t workload_module[MARS_WORKLOAD_MODULE_SIZE];
+	uint8_t pad[MARS_TASK_CONTEXT_SIZE - MARS_WORKLOAD_MODULE_SIZE - 108];
+
 	int32_t exit_code;			/* exit code */
 	uint64_t exec_ea;			/* ea of exec */
 	uint32_t exec_size;			/* text/data size of exec */
--- a/task/src/host/lib/task.c
+++ b/task/src/host/lib/task.c
@@ -63,10 +63,8 @@ int mars_task_create(struct mars_context
 		     uint32_t context_save_size)
 {
 	int ret;
-
-	Elf32_Ehdr *ehdr_module, *ehdr_task;
-	Elf32_Phdr *phdr_module, *phdr_task;
-
+	Elf32_Ehdr *ehdr;
+	Elf32_Phdr *phdr;
 	uint16_t workload_id;
 	uint64_t workload_ea;
 	struct mars_task_context *task;
@@ -84,21 +82,16 @@ int mars_task_create(struct mars_context
 		return MARS_ERROR_PARAMS;
 
 	/* process elf header information */
-	ehdr_module = (Elf32_Ehdr *)mars_task_module_entry;
-	phdr_module = (Elf32_Phdr *)
-		((void *)ehdr_module + ehdr_module->e_phoff);
-
-	ehdr_task = (Elf32_Ehdr *)elf_image;
-	phdr_task = (Elf32_Phdr *)
-		((void *)ehdr_task + ehdr_task->e_phoff);
-
-	if (phdr_module->p_type != PT_LOAD || phdr_task->p_type != PT_LOAD ||
-	    phdr_module->p_vaddr != MARS_WORKLOAD_MODULE_BASE_ADDR ||
-	    phdr_task->p_vaddr != MARS_TASK_BASE_ADDR)
+	ehdr = (Elf32_Ehdr *)elf_image;
+	phdr = (Elf32_Phdr *)((void *)ehdr + ehdr->e_phoff);
+
+	if (phdr->p_type != PT_LOAD || phdr->p_vaddr != MARS_TASK_BASE_ADDR)
 		return MARS_ERROR_FORMAT;
 
 	/* begin process to add the task to the workload queue */
-	ret = mars_workload_queue_add_begin(mars, &workload_id, &workload_ea);
+	ret = mars_workload_queue_add_begin(mars, &workload_id, &workload_ea,
+					    mars_task_module_entry,
+					    MARS_TASK_MODULE_NAME);
 	if (ret != MARS_SUCCESS)
 		return ret;
 
@@ -107,29 +100,16 @@ int mars_task_create(struct mars_context
 				     MARS_TASK_CONTEXT_ALIGN,
 				     MARS_TASK_CONTEXT_SIZE);
 
-	/* initialize the module elf parameters */
-	task->module.exec_size = phdr_module->p_filesz;
-	task->module.exec_ea =
-		mars_ea_map((void *)ehdr_module + phdr_module->p_offset,
-			    task->module.exec_size);
-	if (!task->module.exec_ea) {
-		ret = MARS_ERROR_MEMORY;
-		goto error_map_module;
-	}
-	task->module.bss_size = phdr_module->p_memsz - phdr_module->p_filesz;
-	task->module.entry = ehdr_module->e_entry;
-
 	/* initialize the task elf parameters */
-	task->exec_size = phdr_task->p_filesz;
-	task->exec_ea =
-		mars_ea_map((void *)ehdr_task + phdr_task->p_offset,
-			    task->exec_size);
+	task->exec_size = phdr->p_filesz;
+	task->exec_ea = mars_ea_map((void *)ehdr + phdr->p_offset,
+				    task->exec_size);
 	if (!task->exec_ea) {
 		ret = MARS_ERROR_MEMORY;
 		goto error_map_exec;
 	}
-	task->bss_size = phdr_task->p_memsz - phdr_task->p_filesz;
-	task->entry = ehdr_task->e_entry;
+	task->bss_size = phdr->p_memsz - phdr->p_filesz;
+	task->entry = ehdr->e_entry;
 
 	/* initialize task id */
 	task->id.mars_context_ea = mars_ptr_to_ea(mars);
@@ -177,8 +157,6 @@ error_workload_queue_add_end:
 error_malloc_context_save_area:
 	mars_ea_unmap(task->exec_ea, task->exec_size);
 error_map_exec:
-	mars_ea_unmap(task->module.exec_ea, task->module.exec_size);
-error_map_module:
 	mars_workload_queue_add_cancel(mars, workload_id);
 
 	return ret;
@@ -219,7 +197,6 @@ int mars_task_destroy(struct mars_task_i
 		mars_ea_free(task->context_save_area_ea);
 
 	/* unmap ELFs */
-	mars_ea_unmap(task->module.exec_ea, task->module.exec_size);
 	mars_ea_unmap(task->exec_ea, task->exec_size);
 
 	/* end process to remove the task from the workload queue */
--- a/task/src/mpu/module/Makefile.am
+++ b/task/src/mpu/module/Makefile.am
@@ -94,7 +94,6 @@ AM_LDFLAGS = \
 	-Wl,-gc-sections \
 	-Wl,--sort-common \
 	-Wl,--sort-section -Wl,alignment \
-	-Wl,-N \
 	-Wl,-s
 
 noinst_PROGRAMS = mars_task_module






More information about the cbe-oss-dev mailing list