⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pic.c

📁 test file nucleus source
💻 C
📖 第 1 页 / 共 5 页
字号:
/*************************************************************************//*                                                                       *//*               Copyright Mentor Graphics Corporation 2002              *//*                         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       *//*                                                                       *//*      pic.c                                          Nucleus PLUS 1.14 *//*                                                                       *//* COMPONENT                                                             *//*                                                                       *//*      PI - Pipe Management                                             *//*                                                                       *//* DESCRIPTION                                                           *//*                                                                       *//*      This file contains the core routines for the pipe management     *//*      component.                                                       *//*                                                                       *//* DATA STRUCTURES                                                       *//*                                                                       *//*      None                                                             *//*                                                                       *//* FUNCTIONS                                                             *//*                                                                       *//*      PIC_Create_Pipe                     Create a message pipe        *//*      PIC_Delete_Pipe                     Delete a message pipe        *//*      PIC_Send_To_Pipe                    Send message to a pipe       *//*      PIC_Receive_From_Pipe               Receive a message from pipe  *//*      PIC_Cleanup                         Cleanup on timeout or a      *//*                                            terminate condition        *//*                                                                       *//* DEPENDENCIES                                                          *//*                                                                       *//*      cs_extr.h                           Common Service functions     *//*      tc_extr.h                           Thread Control functions     *//*      pi_extr.h                           Pipe functions               *//*      hi_extr.h                           History functions            *//*                                                                       *//* HISTORY                                                               *//*                                                                       *//*          DATE                    REMARKS                              *//*                                                                       *//*      03-01-1993      Created initial version 1.0                      *//*      04-19-1993      Verified version 1.0                             *//*      08-09-1993      Corrected pointer retrieval                      *//*                      loop, resulting in version 1.0a                  *//*      08-09-1993      Verified version 1.0a                            *//*      03-01-1994      Moved non-core functions into                    *//*                      supplemental files, changed                      *//*                      function interfaces to match                     *//*                      those in prototype, added                        *//*                      register options, changed                        *//*                      protection logic to reduce                       *//*                      overhead, corrected bug in                       *//*                      pipe reset, optimized item                       *//*                      copy loops, resulting in                         *//*                      version 1.1                                      *//*                                                                       *//*      03-18-1994      Verified version 1.1                             *//*      04-17-1996      updated to version 1.2                           *//*      03-24-1998      Released version 1.3                             *//*      03-26-1999      Released 1.11m (new release                      *//*                        numbering scheme)                              *//*      04-17-2002      Released version 1.13m                           *//*      11-07-2002      Released version 1.14                            *//*************************************************************************/#define         NU_SOURCE_FILE#include        "cs_extr.h"                 /* Common service functions  */#include        "tc_extr.h"                 /* Thread control functions  */#include        "pi_extr.h"                 /* Pipe functions            */#include        "hi_extr.h"                 /* History functions         */#include        "profiler.h"                /* ProView interface         *//* Define external inner-component global data references.  */extern CS_NODE         *PID_Created_Pipes_List;extern UNSIGNED         PID_Total_Pipes;extern TC_PROTECT       PID_List_Protect;/* Define internal component function prototypes.  */VOID    PIC_Cleanup(VOID *information);/*************************************************************************//*                                                                       *//* FUNCTION                                                              *//*                                                                       *//*      PIC_Create_Pipe                                                  *//*                                                                       *//* DESCRIPTION                                                           *//*                                                                       *//*      This function creates a pipe and then places it on the list      *//*      of created pipes.                                                *//*                                                                       *//* CALLED BY                                                             *//*                                                                       *//*      Application                                                      *//*      PICE_Create_Pipe                    Error checking shell         *//*                                                                       *//* CALLS                                                                 *//*                                                                       *//*      CSC_Place_On_List                   Add to node to linked-list   *//*      [HIC_Make_History_Entry]            Make entry in history log    *//*      [TCT_Check_Stack]                   Stack checking function      *//*      TCT_Protect                         Data structure protect       *//*      TCT_Unprotect                       Un-protect data structure    *//*                                                                       *//* INPUTS                                                                *//*                                                                       *//*      pipe_ptr                            Pipe control block pointer   *//*      name                                Pipe name                    *//*      start_address                       Starting address of actual   *//*                                            pipe area                  *//*      pipe_size                           Total size of pipe in bytes  *//*      message_type                        Type of message supported by *//*                                            the pipe (fixed/variable)  *//*      message_size                        Size of message.  Variable   *//*                                            message-length pipes, this *//*                                            represents the maximum size*//*      suspend_type                        Suspension type              *//*                                                                       *//* OUTPUTS                                                               *//*                                                                       *//*      NU_SUCCESS                                                       *//*                                                                       *//* HISTORY                                                               *//*                                                                       *//*         DATE                    REMARKS                               *//*                                                                       *//*      03-01-1993      Created initial version 1.0                      *//*      04-19-1993      Verified version 1.0                             *//*      03-01-1994      Changed function interfaces to                   *//*                      match those in prototype,                        *//*                      added register options,                          *//*                      resulting in version 1.1                         *//*                                                                       *//*      03-18-1994      Verified version 1.1                             *//*                                                                       *//*************************************************************************/STATUS  PIC_Create_Pipe(NU_PIPE *pipe_ptr, CHAR *name,                      VOID *start_address, UNSIGNED pipe_size,                      OPTION message_type, UNSIGNED message_size,                      OPTION suspend_type){R1 PI_PCB      *pipe;                       /* Pipe control block ptr    */INT             i;                          /* Working index variable    */NU_SUPERV_USER_VARIABLES    /* Switch to supervisor mode */    NU_SUPERVISOR_MODE();    /* Move input pipe pointer into internal pointer.  */    pipe =  (PI_PCB *) pipe_ptr;#ifdef  NU_ENABLE_STACK_CHECK    /* Call stack checking function to check for an overflow condition.  */    TCT_Check_Stack();#endif#ifdef  NU_ENABLE_HISTORY    /* Make an entry that corresponds to this function in the system history       log.  */    HIC_Make_History_Entry(NU_CREATE_PIPE_ID, (UNSIGNED) pipe,                                (UNSIGNED) name, (UNSIGNED) start_address);#endif    /* First, clear the pipe ID just in case it is an old pipe       Control Block.  */    pipe -> pi_id =             0;    /* Fill in the pipe name.  */    for (i = 0; i < NU_MAX_NAME; i++)        pipe -> pi_name[i] =  name[i];    /* Setup the pipe suspension type.  */    if (suspend_type == NU_FIFO)        /* FIFO suspension is selected, setup the flag accordingly.  */        pipe -> pi_fifo_suspend =  NU_TRUE;    else        /* Priority suspension is selected.  */        pipe -> pi_fifo_suspend =  NU_FALSE;    /* Setup the pipe message type.  */    if (message_type == NU_FIXED_SIZE)        /* Fixed-size messages are required.  */        pipe -> pi_fixed_size =  NU_TRUE;    else        /* Variable-size messages are required.  */        pipe -> pi_fixed_size =  NU_FALSE;    /* Setup the message size.  */    pipe -> pi_message_size =  message_size;    /* Clear the messages counter.   */    pipe -> pi_messages =  0;    /* Setup the actual pipe pointers.  */    pipe -> pi_pipe_size =     pipe_size;    /* Determine if the pipe's size needs to be adjusted.  */    if (pipe -> pi_fixed_size)        /* The size of a fixed-size message pipe must be an even multiple of           the actual message size.  */        pipe_size =  (pipe_size/message_size) * message_size;    else        /* Insure that the size is in terms of UNSIGNED data elements.  This           insures that the UNSIGNED word is never written past the end of           the pipe.  */        pipe_size =  (pipe_size/sizeof(UNSIGNED)) * sizeof(UNSIGNED);    pipe -> pi_available =     pipe_size;    pipe -> pi_start =         (BYTE_PTR) start_address;    pipe -> pi_end =           pipe -> pi_start + pipe_size;    pipe -> pi_read =          (BYTE_PTR) start_address;    pipe -> pi_write =         (BYTE_PTR) start_address;    /* Clear the suspension list pointer.  */    pipe -> pi_suspension_list =  NU_NULL;    /* Clear the number of tasks waiting on the pipe counter.  */    pipe -> pi_tasks_waiting =  0;    /* Clear the urgent message list pointer.  */    pipe -> pi_urgent_list =  NU_NULL;    /* Initialize link pointers.  */    pipe -> pi_created.cs_previous =    NU_NULL;    pipe -> pi_created.cs_next =        NU_NULL;    /* Protect against access to the list of created pipes.  */    TCT_Protect(&PID_List_Protect);    /* At this point the pipe is completely built.  The ID can now be       set and it can be linked into the created pipe list.  */    pipe -> pi_id =                     PI_PIPE_ID;    /* Link the pipe into the list of created pipes and increment the       total number of pipes in the system.  */    CSC_Place_On_List(&PID_Created_Pipes_List, &(pipe -> pi_created));    PID_Total_Pipes++;#ifdef INCLUDE_PROVIEW    _RTProf_DumpPipe(RT_PROF_CREATE_PIPE,pipe,RT_PROF_OK);#endif /* INCLUDE_PROVIEW */    /* Release protection against access to the list of created pipes.  */    TCT_Unprotect();    /* Return to user mode */    NU_USER_MODE();    /* Return successful completion.  */    return(NU_SUCCESS);}/*************************************************************************//*                                                                       *//* FUNCTION                                                              *//*                                                                       *//*      PIC_Delete_Pipe                                                  *//*                                                                       *//* DESCRIPTION                                                           *//*                                                                       *//*      This function deletes a pipe and removes it from the list of     *//*      created pipes.  All tasks suspended on the pipe are              *//*      resumed.  Note that this function does not free the memory       *//*      associated with the pipe.                                        *//*                                                                       */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -