📄 pice.c
字号:
/*************************************************************************//* *//* 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 *//* *//* pice.c Nucleus PLUS 1.14 *//* *//* COMPONENT *//* *//* PI - Pipe Management *//* *//* DESCRIPTION *//* *//* This file contains error checking routines for core functions *//* of the Pipe component. This permits easy removal of error *//* checking logic when it is not needed. *//* *//* DATA STRUCTURES *//* *//* None *//* *//* FUNCTIONS *//* *//* PICE_Create_Pipe Create a pipe *//* PICE_Delete_Pipe Delete a pipe *//* PICE_Send_To_Pipe Send a pipe message *//* PICE_Receive_From_Pipe Receive a pipe message *//* *//* DEPENDENCIES *//* *//* cs_extr.h Common Service functions *//* tc_extr.h Thread Control functions *//* pi_extr.h Pipe functions *//* *//* HISTORY *//* *//* DATE REMARKS *//* *//* 03-01-1993 Created initial version 1.0 *//* 04-19-1993 Verified version 1.0 *//* 03-01-1994 Split original error checking *//* file and changed function *//* interfaces, resulting in *//* version 1.1 *//* *//* 03-18-1994 Verified version 1.1 *//* 12-19-1995 Modified PICE_Receive_From_Pipe, *//* resulting in version 1.1+ *//* (spr065) *//* 04-17-1996 updated to version 1.2 *//* 03-24-1998 Released version 1.3 *//* 06-04-1998 Modified PICE_Send_To_Pipe to *//* check for a size of 0, created *//* version 1.3a. (SPR493) *//* 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 *//*************************************************************************//* *//* FUNCTION *//* *//* PICE_Create_Pipe *//* *//* DESCRIPTION *//* *//* This function performs error checking on the parameters supplied *//* to the pipe create function. *//* *//* CALLED BY *//* *//* Application *//* *//* CALLS *//* *//* PIC_Create_Pipe Actual create pipe function *//* *//* INPUTS *//* *//* pipe_ptr Pipe control block pointer *//* name Pipe name *//* start_address Starting address of actual *//* pipe area *//* pipe_size Total size of pipe *//* message_type Type of message supported by *//* the pipe (fixed/variable) *//* message_size Size of message. Variable *//* message-length queues, this*//* represents the maximum size*//* suspend_type Suspension type *//* *//* OUTPUTS *//* *//* NU_INVALID_PIPE Invalid pipe pointer *//* NU_INVALID_MEMORY Invalid pipe starting addr *//* NU_INVALID_SIZE Invalid pipe size and/or *//* size of message *//* NU_INVALID_MESSAGE Invalid message type *//* NU_INVALID_SUSPEND Invalid suspend type *//* *//* HISTORY *//* *//* DATE REMARKS *//* *//* 03-01-1993 Created initial version 1.0 *//* 04-19-1993 Verified version 1.0 *//* 03-01-1994 Modified function interface, *//* resulting in version 1.1 *//* *//* 03-18-1994 Verified version 1.1 *//* *//*************************************************************************/STATUS PICE_Create_Pipe(NU_PIPE *pipe_ptr, CHAR *name, VOID *start_address, UNSIGNED pipe_size, OPTION message_type, UNSIGNED message_size, OPTION suspend_type){PI_PCB *pipe;STATUS status;UNSIGNED overhead; /* Move input pipe pointer into internal pointer. */ pipe = (PI_PCB *) pipe_ptr; /* Determine if pipe supports variable length messages. If so, additional bytes of overhead are required. */ if (message_type == NU_VARIABLE_SIZE) /* Calculate the number of overhead bytes necessary for the additional word of overhead and the pad-bytes required to keep the pipe write pointer on an UNSIGNED data element alignment. */ overhead = sizeof(UNSIGNED) + (((message_size + sizeof(UNSIGNED) - 1)/sizeof(UNSIGNED)) * sizeof(UNSIGNED)) - message_size; else /* Fixed-size message queues require no additional overhead. */ overhead = 0; /* Determine if there is an error with the pipe pointer. */ if ((pipe == NU_NULL) || (pipe -> pi_id == PI_PIPE_ID)) /* Indicate that the pipe pointer is invalid. */ status = NU_INVALID_PIPE; else if (start_address == NU_NULL) /* Indicate that the starting address of the pipe is invalid. */ status = NU_INVALID_MEMORY; else if ((pipe_size == 0) || (message_size == 0) || ((message_size + overhead) > pipe_size)) /* Indicate that one or both of the size parameters are invalid. */ status = NU_INVALID_SIZE; else if ((message_type != NU_FIXED_SIZE) && (message_type != NU_VARIABLE_SIZE)) /* Indicate that the message type is invalid. */ status = NU_INVALID_MESSAGE; else if ((suspend_type != NU_FIFO) && (suspend_type != NU_PRIORITY)) /* Indicate that the suspend type is invalid. */ status = NU_INVALID_SUSPEND; else /* All the parameters are okay, call the actual function to create a pipe. */ status = PIC_Create_Pipe(pipe_ptr, name, start_address, pipe_size, message_type, message_size, suspend_type); /* Return completion status. */ return(status);}/*************************************************************************//* *//* FUNCTION *//* *//* PICE_Delete_Pipe *//* *//* DESCRIPTION *//* *//* This function performs error checking on the parameter supplied *//* to the pipe delete function. *//* *//* CALLED BY *//* *//* Application *//* *//* CALLS *//* *//* PIC_Delete_Pipe Actual delete pipe function *//* *//* INPUTS *//* *//* pipe_ptr Pipe control block pointer *//* *//* OUTPUTS *//* *//* NU_INVALID_PIPE Invalid pipe pointer *//* *//* HISTORY *//* *//* DATE REMARKS *//* *//* 03-01-1993 Created initial version 1.0 *//* 04-19-1993 Verified version 1.0 *//* 03-01-1994 Modified function interface, *//* resulting in version 1.1 *//* *//* 03-18-1994 Verified version 1.1 *//* *//*************************************************************************/STATUS PICE_Delete_Pipe(NU_PIPE *pipe_ptr){PI_PCB *pipe;STATUS status; /* Move input pipe pointer into internal pointer. */ pipe = (PI_PCB *) pipe_ptr;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -