1/*
2 * Copyright (C) 1995 Advanced RISC Machines Limited. All rights reserved.
3 *
4 * This software may be freely used, copied, modified, and distributed
5 * provided that the above copyright notice is preserved in all copies of the
6 * software.
7 */
8
9/* -*-C-*-
10 *
11 * $Revision: 1.2 $
12 *     $Date: 1998/01/08 11:11:34 $
13 *
14 *
15 *   Project: ANGEL
16 *
17 *     Title: Public interface to buffer management
18 */
19
20#ifndef angel_buffers_h
21#define angel_buffers_h
22
23#include "chandefs.h"           /* CHAN_HEADER_SIZE */
24
25
26/* the handle to a buffer */
27typedef unsigned char *p_Buffer;
28
29
30/*
31 * Angel Packets are structured as a fixed size header, followed
32 * by the packet data
33 */
34#ifdef TARGET
35# define BUFFERDATA(b)  (b)     /* channels layer takes care of it */
36#else
37# define BUFFERDATA(b)  (&((b)[CHAN_HEADER_SIZE]))
38#endif
39
40
41/*
42 * The buffer management function prototypes are only applicable
43 * when compiling target code
44 */
45#ifdef TARGET
46
47/*
48 * Function: Angel_BufferQuerySizes
49 *  Purpose: Request infomation on the default and maximum buffer sizes
50 *           that can be allocated
51 *
52 *   Params:
53 *             In/Out: default_size, max_size: pointers to place the
54 *                     sizes in on return
55 */
56
57void Angel_BufferQuerySizes(unsigned int *default_size,
58                            unsigned int *max_size );
59
60/*
61 * Function: Angel_RxEnginBuffersLeft
62 *  Purpose: return the number of free buffers
63 *
64 *   Params:
65 *            Returns: number of free buffers
66 */
67unsigned int Angel_BuffersLeft( void );
68
69/*
70 * Function: Angel_BufferAlloc
71 *  Purpose: allocate a buffer that is at least req_size bytes long
72 *
73 *   Params:
74 *              Input: req_size     the required size of the buffer
75 *
76 *              Returns: pointer to the buffer NULL if unable to
77 *                       fulfil the request
78 */
79p_Buffer     Angel_BufferAlloc(unsigned int  req_size);
80
81/*
82 * Function: Angel_BufferRelease
83 *  Purpose: release a buffer back to the free pool
84 *
85 *   Params:
86 *              Input: pointer to the buffer to free
87 */
88void Angel_BufferRelease(p_Buffer buffer);
89
90
91/* return values for angel_InitBuffers */
92typedef enum buf_init_error{
93  INIT_BUF_OK,
94  INIT_BUF_FAIL
95} buf_init_error;
96
97/*
98 * Function: Angel_InitBuffers
99 *  Purpose: Initalised and malloc the buffer pool
100 *
101 *   Params:
102 *              Returns: see above
103 */
104
105buf_init_error  Angel_InitBuffers(void);
106
107#endif /* def TARGET */
108
109#endif /* ndef angel_buffers_h */
110
111/* EOF buffers.h */
112