Download GNAT User's Guide

Transcript
Appendix C: Tornado 2.x / VxWorks 5.x Topics
/*
* This is an example on how to load and spawn an application from
* a C program using two different methods: via taskSpawn, or by
* using taskInit and taskActivate.
*
* With taskSpawn, the task will be initialized and run. A call
* to taskInit followed by a call to taskActivate gives a similar
* result.
*
* If taskInit is called alone, then the task is only initialized
* and not started. The advantage of this approach is that you can
* then attach a debugger to the task and start a debugging session.
* If the spawned application is a multitasking application written
* in Ada, then you can debug it in multitask mode.
*
* By default, taskSpawn is used. To use taskInit, you should define
* the symbol DEBUG.
*
* Note that VX_FP_TASK is set when spawning the main Ada program.
* This is required if the program uses any floating-point operations
* at all, to ensure proper saving and restoring of floating-point
* registers. The GNAT run-time takes care of setting VX_FP_TASK for
* tasks other than the environment task, but you need to set this
* flag explicitly for the environment task.
*/
#include
#include
#include
#include
#include
#include
#include
<vxWorks.h>
<loadLib.h>
<taskLib.h>
<symLib.h>
<sysSymTbl.h>
<ioLib.h>
<stdio.h>
#define STACK_SIZE
0x100000
int loader (void) {
int fd;
int STATUS;
char *module_name = "diners";
MODULE_ID mod_id;
FUNCPTR pValue;
SYM_TYPE pType;
char *tMonitorStack;
/* allocate memory for the task stack and task control block */
tMonitorStack =
49