|
pipe.h |
|
|---|---|
|
|
/*
* pipe.h
*
* ------------------------------------------------------------
* A Kla2 Module
* Copyright (c) 2003, David Clifton
* All Rights Reserved
* http://www.codelode.com
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or
* sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice, website reference, this permission
* notice, and the disclaimer of warranty below shall be included
* in all copies, derivatives, or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
* -------------------------------------------------------------
*
* Header file for pipe object
*
*/
#ifndef PIPE_H
#define PIPE_H
/*
* type definition for PIPE
*/
typedef struct {
s16 ipcode; // a code which identifies this as an
// initialized pipe
s16 bnum; // number of buffers
s16 bsiz; // size of buffers
u8 *bptr; // pointer to first byte of buffer space
s16 freeList; // bufnodeTable index of first free buffer
s16 allocdList; // bufnodeTable index of first alloc'd buffer
s16 filledListFirst; // bufnodeTable index of first filled buffer
s16 filledListLast; // bufnodeTable index of last filled buffer
s16 recvdList; // bufnodeTable index of first recv'd buffer
// (received but not freed)
s16 recvPfcn; // pfcnTable index of registered pfcn
// (prioritized function) to post
// when buffer written
} PIPE;
/*
* Public method definitions
*/
void Pipe_init(void);
PIPE *Pipe_new(s16 bufnum,s16 bufsiz,void*bufptr,s16 rcvpfcn);
void *Pipe_bufalloc(PIPE *pipeptr);
void Pipe_putbuf(PIPE *pipeptr,void *bufptr);
void *Pipe_getbuf(PIPE *pipeptr);
void Pipe_freebuf(PIPE *pipeptr,void *bufptr);
bool Pipe_dataAvailable(PIPE *pipeptr);
#endif
|