Main Page | Data Structures | File List | Data Fields | Globals
Long Term Loans Big Lines of Credit Equipment Financing Working Capital best business loans Short Term Loads Small Business Loans SBA Loans Merchant Cash Advancesbusiness loans

opale.h File Reference

This graph shows which files directly or indirectly include this file:

Included by dependency graph

Go to the source code of this file.

Data Structures

struct  t_MAILBOX
struct  t_op_BUFFER
struct  t_QUEUE
struct  t_SEMAPHORE
struct  t_TASK
struct  t_TASK_BLOCK

Defines

#define _N_   3
#define _X_   (1<<_N_)
#define _Y_   8
#define IDLE_TASK_STACK_SIZE   70
#define LOWEST_PRIORITY   (NUM_TASKS-1)
#define NUM_TASKS   (_X_*_Y_)
#define op_EnterCriticalSection()   asm(" trap #7")
#define op_ExitCriticalSection()   asm(" trap #8")
#define Opale_version   "00.03.000"
#define TO_LOWEST_SETTED_BIT_TABLE_SIZE   ((_X_>_Y_)?(1<<_X_):(1<<_Y_))

Typedefs

typedef t_MAILBOX t_MAILBOX
typedef t_op_BUFFER t_op_BUFFER
typedef t_SEMAPHORE t_SEMAPHORE
typedef t_TASK t_TASK
typedef t_TASK_BLOCK t_TASK_BLOCK

Functions

void op_KernelInit (register t_op_BUFFER *buffer asm(" "), register unsigned char rotationMask asm("Ð"))
void op_KernelStart (void)
void op_KernelStop (void) __attribute__((noreturn))
void op_MailBoxInit (register t_MAILBOX *mailbox asm(" "), register void *initMessage asm("Ð"))
void * op_MailBoxPend (register t_MAILBOX *mailBox asm(" "))
unsigned short op_MailBoxPost (register t_MAILBOX *mailBox asm(" "), register void *message asm("Ð"))
void op_QueueInit (register t_QUEUE *queue asm(" "), register void *buffer asm("Ð"), register unsigned short size asm("Ñ"))
void * op_QueuePend (register t_QUEUE *queue asm(" "))
unsigned short op_QueuePost (register t_QUEUE *queue asm(" "), register void *message asm("Ð"))
unsigned short op_QueuePostFront (register t_QUEUE *queue asm(" "), register void *message asm("Ð"))
void op_SemaphoreInit (register t_SEMAPHORE *semaphore asm(" "), register unsigned long initValue asm("Ð"))
void op_SemaphorePend (register t_SEMAPHORE *semaphore asm(" "))
void op_SemaphorePost (register t_SEMAPHORE *semaphore asm(" "))
short op_TaskStart (register t_TASK *task asm("£"), register void(*taskEntryFunction)(register void *asm(" ")) asm("¢"), register char *stackPointer asm("¡"), register unsigned char ident asm("Ð"), register void *taskFunctionArgs asm(" "))
void op_TaskStop (void)
void op_TaskWaitForTicks (register unsigned short ticks asm("Ð"))

Variables

unsigned long op_idleCounter


Define Documentation

#define _N_   3
 

First primary constant to fix the highest number of tasks the kernel will handle. This is an internal constant, so you don't have to change it if you're not rebuilding the kernel itself. If you are, fix N so that X will be 2^N. Because of the size of some tables, N can't be more than 3. Definition at line 14 of file opale.h.

#define _X_   (1<<_N_)
 

X is the number of rows for all tasks tables Definition at line 23 of file opale.h.

Referenced by rotate().

#define _Y_   8
 

Second constant to fix the highest number of tasks the kernel will handle. This is an internal constant, so you don't have to change it if you're not rebuilding the kernel itself. It is the number of lines for all tasks tables. Y can take any value from 2 to 8. Definition at line 20 of file opale.h.

Referenced by EventInit(), and op_KernelInit().

#define IDLE_TASK_STACK_SIZE   70
 

Size of the stack needed by the idle task (lowest priority task allocated by the kernel itself). This is the stack size needed to handle a single context switch. Definition at line 43 of file opale.h.

Referenced by op_KernelInit().

#define LOWEST_PRIORITY   (NUM_TASKS-1)
 

Lowest priority. Used by the idle task. Definition at line 46 of file opale.h.

#define NUM_TASKS   (_X_*_Y_)
 

Total number of tasks the kernel will be able to handle. Because of the size of some table, it could be wise to take some standardize values for Y and N (such as 8/3 for 64 tasks, 4/2 for 16 tasks and not try bigger than 8/3 (64 tasks). Definition at line 36 of file opale.h.

Referenced by op_KernelInit().

 
#define op_EnterCriticalSection  )     asm(" trap #7")
 

That macro enables to enter a critical section. While in a critical section, a task can't be interrupted by any other task or an interrupt since SR is set to 0x2700. It uses a custom trap 7. Never use this macro if you are already in a critical section ! Definition at line 51 of file opale.h.

Referenced by op_MailBoxPend(), op_MailBoxPost(), op_QueuePend(), op_QueuePost(), op_QueuePostFront(), op_SemaphorePend(), op_SemaphorePost(), op_TaskStart(), op_TaskStop(), and op_TaskWaitForTicks().

 
#define op_ExitCriticalSection  )     asm(" trap #8")
 

Exits a critical section, and restores SR to the value it has before the call to op_EnterCriticalSection(). Uses a custom trap 8. Definition at line 55 of file opale.h.

Referenced by op_MailBoxPend(), op_MailBoxPost(), op_QueuePend(), op_QueuePost(), op_QueuePostFront(), op_SemaphorePend(), op_SemaphorePost(), op_TaskStart(), op_TaskStop(), and op_TaskWaitForTicks().

#define Opale_version   "00.03.000"
 

Current version Definition at line 8 of file opale.h.

#define TO_LOWEST_SETTED_BIT_TABLE_SIZE   ((_X_>_Y_)?(1<<_X_):(1<<_Y_))
 

Size of a table used to get the highest priority task in any task table. Definition at line 39 of file opale.h.


Typedef Documentation

typedef struct t_MAILBOX t_MAILBOX
 

Structure to describe a mailBox event handler. Mailboxes are objects that helps synchronyzation and data sharing between tasks

typedef struct t_op_BUFFER t_op_BUFFER
 

Structure that will contain some tables used by the kernel. Once again, it doesn't need to be initialized/modified by the user.

typedef struct t_SEMAPHORE t_SEMAPHORE
 

Structure describing a semaphore event handler. Semaphores are objects that helps synchronyzation between tasks

typedef struct t_TASK t_TASK
 

Structure describing a task. It is not useful to know exactly what's in since you don't have to initialize or read/modify the fields yourself if you are making a program using the kernel.

typedef struct t_TASK_BLOCK t_TASK_BLOCK
 

Structure to handle waiting tasks (on an event, a tick, etc)


Function Documentation

void op_KernelInit register t_op_BUFFER *buffer   asm(" "),
register unsigned char rotationMask   asm("Ð")
 

Inits the kernel. It is the first function you have to call before using any other function of Opale.

Parameters:
buffer (a0.l) Pointer to a buffer of sizeof(t_op_BUFFER) bytes. Can be allocated in any writable memory (Heap or stack). When NUM_TASKS is big, be carefull to stack overflow.
rotationEnableMask (d0.b) MAsk enabling priority rotation for groups while scheduling. There are _Y_ groups of _X_ tasks each, when the correponding bit of rotationEnableMask is setted, all the tasks of the group have the same priority, and are run sequencially.
Definition at line 63 of file opale_core.c.

References _Y_, IDLE_TASK_IDENT, IDLE_TASK_STACK_SIZE, idleTask, IdleTaskFunction(), idleTaskStack, indexToLowestSettedBit, InitIntVectors(), kernelStarted, NUM_TASKS, numberOfNestedISRs, numberOfNestedShedulerHalts, op_TaskStart(), readyTasks, roundRobin, t_TASK_BLOCK::rowIndex, runningTasks, and t_TASK_BLOCK::tasksTable.

Here is the call graph for this function:

void op_KernelStart void   ) 
 

Starts the kernel by launching the highest priority task ready to run. If there's been no call to op_TaskStart before entering op_KernelStart, the idle task will be made ready to run and the system will be freezed waiting for an interrupt or anything. So don't forget to create at least one task before calling op_KernelStart.
op_KernelStart never returns except if op_KernelStop is called.

section op_KernelStart
op_KernelStart:

        movem.l d0-a6,-(a7)
        
        lea.l   idleTask(pc),a0
        move.l  a0,currentTask                  ;currentTask = &idleTask;

        move.l  a7,exitSP                       ; saves SP

        move.l  (a0),a7
        
        addq.l  #6,a7

        movem.l (a7) ,d0-a6
        
        lea.l   op_idleCounter(pc),a0
        
        clr.l   (a0)
        move.l  (a0),op_tickCounter
        move.l  (a0),numberOfNestedShedulerHalts        ; numberOfNestedShedulerHalts = 0;
        
        trap    #6                              ; calls scheduler
                
IdleTaskFunction:
        addq.l  #1,op_idleCounter
Definition at line 24 of file opale_fake.c.

void op_KernelStop void   ) 
 

Stops all running tasks, and exits the kernel multithreading. The effect is just that op_KernelStart seemes to return, and so the code after the call to op_KernelStart will be executed.
Remember that it won't free ressources allocated by the tasks.

section op_KernelStop
op_KernelStop:

        trap #7                 ;op_EnterCriticalSection();

        move.l  exitSP(pc),a7   ; restores sp
        movem.l (a7) ,d0-a6     ; restores regs
        
        bra     RestoreIntVectors(pc)

;       never returns
Definition at line 64 of file opale_fake.c.

void op_MailBoxInit register t_MAILBOX *mailbox   asm(" "),
register void *initMessage   asm("Ð")
 

Inits a MailBox with an initial message. It is done so you just don't have to fill manually the fields of the

mailBox (a0.l) MailBox to post to.
message (d0.l) Message to post.

Returns:
FALSE if a message is already in the mailbox (can't post), or TRUE on success.
Definition at line 165 of file opale_event.c.

References MakeTaskReady(), op_EnterCriticalSection, and op_ExitCriticalSection.

Here is the call graph for this function:

void op_QueueInit register t_QUEUE *queue   asm(" "),
register void *buffer   asm("Ð"),
register unsigned short size   asm("Ñ")
 

Inits a message queue with an initial message. It is done so you just don't have to fill manually the fields of the t_MAILBOX object.

Parameters:
mailbox (a0.l) Pointer to the t_MAILBOX object to initialyze.
initMessage (d0.l) Pointer to initialyze the mailbox with.
Definition at line 49 of file opale_event.c.

References EventInit().

Here is the call graph for this function:

void* op_QueuePend register t_QUEUE *queue   asm(" ")  ) 
 

Wait for a message to be posted in the message queue. If one or more message already is in the queue when the function is called, it will just return the one on the front of the queue. If there's no message, the task will be removed from the ready list and make ready again only when a message has been posted and the task is the highest priority one waiting for it.

Parameters:
queue (a0.l) Queue to pend on.
Returns:
Message posted on the message queue.
Definition at line 261 of file opale_event.c.

References op_EnterCriticalSection, op_ExitCriticalSection, and WaitForEvent().

Here is the call graph for this function:

unsigned short op_QueuePost register t_QUEUE *queue   asm(" "),
register void *message   asm("Ð")
 

Post a message on the back of the message queue. It will add the message to the back of the queue if the queue isn't already full. If so, the function will return an error. If tasks were waiting on the message queue, the highest priority one is made ready to run and the scheduler is called.

Parameters:
queue (a0.l) Queue to post to.
message (d0.l) Message to post.
Returns:
FALSE if the queue is full (can't post), or TRUE on success.
Definition at line 213 of file opale_event.c.

References MakeTaskReady(), op_EnterCriticalSection, and op_ExitCriticalSection.

Here is the call graph for this function:

unsigned short op_QueuePostFront register t_QUEUE *queue   asm(" "),
register void *message   asm("Ð")
 

Post a message on the front of the message queue. It will add the message to the front of the queue if the queue isn't already full. If so, the function will return an error. This is different from QueuePost since the messages are taken from the front of the queue on a QueuePend. So a message posted with QueuePostFronT will be read before one posted with QueuePost. If tasks were waiting on the message queue, the highest priority one is made ready to run and the scheduler is called.

Parameters:
queue (a0.l) Queue to post to.
message (d0.l) Message to post.
Returns:
FALSE if the queue is full (can't post), or TRUE on success.
Definition at line 237 of file opale_event.c.

References MakeTaskReady(), op_EnterCriticalSection, and op_ExitCriticalSection.

Here is the call graph for this function:

void op_SemaphoreInit register t_SEMAPHORE *semaphore   asm(" "),
register unsigned long initValue   asm("Ð")
 

Inits a Semaphore with an initial count. It is done so you just don't have to fill manually the fields of the t_SEMAPHORE object.

Parameters:
semaphore (a0.l) Pointer to the t_SEMAPHORE object to initialyze.
initValue (d0.l) Value to initialyze the semaphore with. Remember semaphore are counter and blocking when 0.
Definition at line 31 of file opale_event.c.

References EventInit().

Here is the call graph for this function:

void op_SemaphorePend register t_SEMAPHORE *semaphore   asm(" ")  ) 
 

Pend on a semaphore. If the count is not 0, the function will just return. If the semaphore has already been taken (its count isn't 0), the task will be removed from the ready list and wait until some other task post to the semaphore, and no other task of higher priority is pending on it.

Parameters:
semaphore (a0.l) Semaphore to pend on.
Definition at line 146 of file opale_event.c.

References op_EnterCriticalSection, op_ExitCriticalSection, and WaitForEvent().

Here is the call graph for this function:

void op_SemaphorePost register t_SEMAPHORE *semaphore   asm(" ")  ) 
 

Post to the semaphore. It will increment the semaphore's count, and made ready to run the highest priority task pending on it. The scheduler is then called.

Parameters:
semaphore (a0.l) Semaphore to post to.
Definition at line 129 of file opale_event.c.

References MakeTaskReady(), op_EnterCriticalSection, and op_ExitCriticalSection.

Here is the call graph for this function:

short op_TaskStart register t_TASK *task   asm("£"),
register   void(*)(register void *asm(" ")) asm taskEntryFunction("¢"),
register char *stackPointer   asm("¡"),
register unsigned char ident   asm("Ð"),
register void *taskFunctionArgs   asm(" ")
 

Loads a task in the kernel. After the call to op_TaskStart, if the scheduler is activated, the highest priority task will be made ready to run.

Parameters:
task (a3.l) Pointer to a unique t_TASK structure.
taskEntryFunction (a2.l) Pointer to the function of the task. That function should never return, and gets a pointer to its parameters via the a0 register. Prototype of the functin : void taskEntryFunction( register void* args asm(" ")
stackPointer (a1.l) Pointer to a buffer allocated to be the stack of the task's function. Be careful to give a buffer of a suffivier size.
ident (d0.b) Identity of the function. It is also its priority. Remember 0 is the highest priority, and LOWEST_PRIORITY is reserved to the idle task. If a task of the same ident/priority has already been created, the current call to op_TaskStart will fail.
taskFunctionArgs (a0.l) Pointer to a structure that will be given as a parameter to the function of the task.
Returns:
FALSE if the requested identity already exists, TRUE in any other case.
Definition at line 17 of file opale_task.c.

References addTaskToTable(), InitStack(), op_EnterCriticalSection, op_ExitCriticalSection, op_Scheduler, readyTasks, and runningTasks.

Referenced by op_KernelInit().

Here is the call graph for this function:

void op_TaskStop void   ) 
 

Stops the current task. Use it at the end of a task function when you want to end it. Remember task functions shall not return, so if you want to quit one of those, use op_TaskStopDefinition at line 46 of file opale_task.c.

References currentTask, t_TASK::ident, op_EnterCriticalSection, op_ExitCriticalSection, op_Scheduler, readyTasks, removeTaskFromTable(), and runningTasks.

Here is the call graph for this function:

void op_TaskWaitForTicks register unsigned short ticks   asm("Ð")  ) 
 

Make a task wait for a number of ticks. A tick occurs each time the int 5 is called. The task will be made ready to run when the given time has expired and it is the highest priority task ready to run.

Parameters:
ticks (d0.w) Number of ticks to wait for.
Definition at line 64 of file opale_task.c.

References currentTask, t_TASK::ident, idleTask, t_TASK::nextSleeping, op_EnterCriticalSection, op_ExitCriticalSection, op_Scheduler, t_TASK::prevSleeping, readyTasks, removeTaskFromTable(), and t_TASK::tickDelay.

Here is the call graph for this function:


Variable Documentation

unsigned long op_idleCounter
 

counter incremented by the idle task. Useful to compute CPU load.

section op_idleCounter:
op_idleCounter:
        ds.l    1
Definition at line 16 of file opale_fake.c.


Generated on Sun May 14 22:31:06 2006 for Opale by doxygen 1.3.8