tcce.c
来自「nucleus 2006 source code」· C语言 代码 · 共 942 行 · 第 1/4 页
C
942 行
/*************************************************************************/
/* */
/* Copyright Mentor Graphics Corporation 2004 */
/* 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 VERSION */
/* */
/* tcce.c Nucleus PLUS 1.15 */
/* */
/* COMPONENT */
/* */
/* TC - Thread Control */
/* */
/* DESCRIPTION */
/* */
/* This file contains error checking routines for the functions in */
/* the Thread Control component. This permits easy removal of */
/* error checking logic when it is not needed. */
/* */
/* DATA STRUCTURES */
/* */
/* None */
/* */
/* FUNCTIONS */
/* */
/* TCCE_Create_Task Create a task */
/* TCCE_Create_HISR Create HISR */
/* TCCE_Delete_HISR Delete HISR */
/* TCCE_Delete_Task Delete a task */
/* TCCE_Reset_Task Reset a task */
/* TCCE_Terminate_Task Terminate a task */
/* TCCE_Resume_Service Resume a task service call */
/* TCCE_Suspend_Service Suspend a task service call */
/* TCCE_Relinquish Relinquish task execution */
/* TCCE_Task_Sleep Task sleep request */
/* TCCE_Suspend_Error Check for suspend req error */
/* TCCE_Activate_HISR Activate an HISR */
/* TCCE_Validate_Resume Validates resume requests */
/* */
/* DEPENDENCIES */
/* */
/* tc_extr.h Thread Control functions */
/* */
/*************************************************************************/
#define NU_SOURCE_FILE
#include "plus/inc/tc_extr.h" /* Thread control functions */
/* Define external inner-component global data references. */
extern TC_TCB *TCD_Execute_Task;
extern VOID *TCD_Current_Thread;
/*************************************************************************/
/* */
/* FUNCTION */
/* */
/* TCCE_Create_Task */
/* */
/* DESCRIPTION */
/* */
/* This function performs error checking on the parameters supplied */
/* to the create task function. */
/* */
/* CALLED BY */
/* */
/* Application */
/* */
/* CALLS */
/* */
/* TCC_Create_Task Actual create task function */
/* */
/* INPUTS */
/* */
/* task_ptr Task control block pointer */
/* name Task name */
/* task_entry Entry function of the task */
/* argc Optional task parameter */
/* argv Optional task parameter */
/* stack_address Pointer to start of stack */
/* stack_size Size of task stack in bytes */
/* priority Task priority */
/* time_slice Task time slice */
/* preempt Task preemptability flag */
/* auto_start Automatic task start */
/* */
/* OUTPUTS */
/* */
/* NU_SUCCESS Successful request */
/* NU_INVALID_TASK Task control block pointer */
/* is NULL */
/* NU_INVALID_ENTRY Task entry function is NULL */
/* NU_INVALID_MEMORY Stack pointer is NULL */
/* NU_INVALID_SIZE Stack size is too small */
/* NU_INVALID_PRIORITY Invalid task priority */
/* NU_INVALID_PREEMPT Invalid preemption selection */
/* NU_INVALID_START Invalid start selection */
/* */
/*************************************************************************/
STATUS TCCE_Create_Task(NU_TASK *task_ptr, CHAR *name,
VOID (*task_entry)(UNSIGNED, VOID *), UNSIGNED argc, VOID *argv,
VOID *stack_address, UNSIGNED stack_size,
OPTION priority, UNSIGNED time_slice,
OPTION preempt, OPTION auto_start)
{
TC_TCB *task; /* Task control block ptr */
STATUS status; /* Completion status */
/* Move input task control block pointer into internal pointer. */
task = (TC_TCB *) task_ptr;
/* Check each parameter. */
if ((task == NU_NULL) || (task -> tc_id == TC_TASK_ID))
/* Invalid task control block pointer. */
status = NU_INVALID_TASK;
else if (task_entry == NU_NULL)
/* Invalid task entry function pointer. */
status = NU_INVALID_ENTRY;
else if (stack_address == NU_NULL)
/* Invalid stack starting address. */
status = NU_INVALID_MEMORY;
else if (stack_size < NU_MIN_STACK_SIZE)
/* Invalid stack size. */
status = NU_INVALID_SIZE;
else if ((preempt != NU_PREEMPT) && (preempt != NU_NO_PREEMPT))
/* Invalid preemption. */
status = NU_INVALID_PREEMPT;
else if ((auto_start != NU_START) && (auto_start != NU_NO_START))
/* Invalid start selection. */
status = NU_INVALID_START;
else
/* Call the actual function to create a task. All the parameters
appear to be correct. */
status = TCC_Create_Task(task_ptr, name, task_entry, argc, argv,
stack_address, stack_size, priority, time_slice, preempt, auto_start);
/* Return completion status. */
return(status);
}
/*************************************************************************/
/* */
/* FUNCTION */
/* */
/* TCCE_Create_HISR */
/* */
/* DESCRIPTION */
/* */
/* This function performs error checking on the parameters supplied */
/* to the create HISR function. */
/* */
/* CALLED BY */
/* */
/* Application */
/* */
/* CALLS */
/* */
/* TCC_Create_HISR Actual create HISR function */
/* */
/* INPUTS */
/* */
/* hisr_ptr HISR control block pointer */
/* name HISR name */
/* hisr_entry Entry function of the HISR */
/* priority Task priority */
/* stack_address Pointer to start of stack */
/* stack_size Size of HISR stack in bytes */
/* */
/* OUTPUTS */
/* */
/* NU_INVALID_HISR Invalid HISR pointer */
/* NU_INVALID_ENTRY Invalid HISR entry point */
/* NU_INVALID_PRIORITY Invalid HISR priority */
/* NU_INVALID_MEMORY Indicates stack pointer NULL */
/* NU_INVALID_SIZE Indicates stack size is too */
/* small */
/* */
/*************************************************************************/
STATUS TCCE_Create_HISR(NU_HISR *hisr_ptr, CHAR *name,
VOID (*hisr_entry)(VOID), OPTION priority,
VOID *stack_address, UNSIGNED stack_size)
{
TC_HCB *hisr; /* HISR control block ptr */
STATUS status; /* Completion status */
/* Move input HISR pointer into internal pointer. */
hisr = (TC_HCB *) hisr_ptr;
/* Check each parameter. */
if ((hisr == NU_NULL) || (hisr -> tc_id == TC_HISR_ID))
/* Invalid HISR control block pointer. */
status = NU_INVALID_HISR;
else if (hisr_entry == NU_NULL)
/* Invalid HISR entry function pointer. */
status = NU_INVALID_ENTRY;
else if (stack_address == NU_NULL)
/* Invalid stack starting address. */
status = NU_INVALID_MEMORY;
else if (stack_size < NU_MIN_STACK_SIZE)
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?