?? pice.c
字號:
/*************************************************************************/
/* */
/* Copyright (c) 1993-1996 Accelerated Technology, Inc. */
/* */
/* PROPRIETARY RIGHTS of Accelerated Technology are involved in the */
/* subject matter of this material. All manufacturing, reproduction, */
/* use, and sales rights pertaining to this subject matter are governed */
/* by the license agreement. The recipient of this software implicitly */
/* accepts the terms of the license. */
/* */
/*************************************************************************/
/*************************************************************************/
/* */
/* FILE NAME VERSION */
/* */
/* pice.c PLUS 1.2 */
/* */
/* 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. */
/* */
/* AUTHOR */
/* */
/* William E. Lamie, Accelerated Technology, Inc. */
/* */
/* 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 */
/* */
/* NAME DATE REMARKS */
/* */
/* W. Lamie 03-01-1993 Created initial version 1.0 */
/* D. Lamie 04-19-1993 Verified version 1.0 */
/* W. Lamie 03-01-1994 Split original error checking */
/* file and changed function */
/* interfaces, resulting in */
/* version 1.1 */
/* R. Pfaff - */
/* D. Lamie 03-18-1994 Verified version 1.1 */
/* M. Trippi 12-19-1995 Modified PICE_Receive_From_Pipe, */
/* resulting in version 1.1+ */
/* (spr065) */
/* M.Q. Qian 04-17-1996 updated to version 1.2 */
/* */
/*************************************************************************/
#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. */
/* */
/* AUTHOR */
/* */
/* William E. Lamie, Accelerated Technology, Inc. */
/* */
/* 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 */
/* */
/* NAME DATE REMARKS */
/* */
/* W. Lamie 03-01-1993 Created initial version 1.0 */
/* D. Lamie 04-19-1993 Verified version 1.0 */
/* W. Lamie 03-01-1994 Modified function interface, */
/* resulting in version 1.1 */
/* R. Pfaff - */
/* D. Lamie 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. */
/* */
/* AUTHOR */
/* */
/* William E. Lamie, Accelerated Technology, Inc. */
/* */
/* 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 */
/* */
/* NAME DATE REMARKS */
/* */
/* W. Lamie 03-01-1993 Created initial version 1.0 */
/* D. Lamie 04-19-1993 Verified version 1.0 */
/* W. Lamie 03-01-1994 Modified function interface, */
/* resulting in version 1.1 */
/* R. Pfaff - */
/* D. Lamie 03-18-1994 Verified version 1.1 */
/* */
/*************************************************************************/
STATUS PICE_Delete_Pipe(NU_PIPE *pipe_ptr)
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -