OpenCores
URL https://opencores.org/ocsvn/funbase_ip_library/funbase_ip_library/trunk

Subversion Repositories funbase_ip_library

[/] [funbase_ip_library/] [trunk/] [TUT/] [ip.swp.api/] [openmcapi/] [1.0/] [libmcapi/] [shm/] [shm.h] - Blame information for rev 145

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 145 lanttu
/*
2
 * Copyright (c) 2010, Mentor Graphics Corporation
3
 * All rights reserved.
4
 *
5
 * Redistribution and use in source and binary forms, with or without
6
 * modification, are permitted provided that the following conditions are met:
7
 *
8
 * 1. Redistributions of source code must retain the above copyright notice,
9
 *    this list of conditions and the following disclaimer.
10
 * 2. Redistributions in binary form must reproduce the above copyright notice,
11
 *    this list of conditions and the following disclaimer in the documentation
12
 *    and/or other materials provided with the distribution.
13
 * 3. Neither the name of the <ORGANIZATION> nor the names of its contributors
14
 *    may be used to endorse or promote products derived from this software
15
 *    without specific prior written permission.
16
 *
17
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20
 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
21
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27
 * POSSIBILITY OF SUCH DAMAGE.
28
 */
29
 
30
 
31
#ifndef MCAPI_SM_DRV_H
32
#define MCAPI_SM_DRV_H
33
 
34
#include <openmcapi.h>
35
#include <atomic.h>
36
 
37
/* Configure buffering system */
38
 
39
/* Define the number of shared memory buffers that will be present
40
 * in the system */
41
#define SHM_BUFF_COUNT           128
42
 
43
/* Define the depth of the SM packet descriptor ring queue. */
44
#define SHM_BUFF_DESC_Q_SHIFT    4
45
#define SHM_BUFF_DESC_Q_SIZE     (1<<SHM_BUFF_DESC_Q_SHIFT)
46
 
47
#define SHM_INVALID_NODE         0xFF
48
#define SHM_INVALID_SCH_UNIT     0xFF
49
 
50
#define SHM_4K_ALIGN_SIZE        4*1024
51
#define SHM_INIT_COMPLETE_KEY    0xEF56A55A
52
 
53
/* Definition for SM buffer management structure */
54
#define SHM_NUM_PRIORITIES       2
55
#define SHM_PRIO_0               0
56
#define SHM_PRIO_1               1
57
#define SHM_LOW_PRI_BUF_CONT     (SHM_BUFF_COUNT - (SHM_BUFF_COUNT/4))
58
#define BITMASK_WORD_COUNT       (SHM_BUFF_COUNT/BITMASK_WORD_SIZE)
59
#define BITMASK_WORD_SIZE        32
60
 
61
/* SM buffer */
62
 
63
struct _shm_buff_
64
{
65
    mcapi_uint32_t idx;
66
    MCAPI_BUFFER   mcapi_buff;
67
};
68
 
69
typedef struct _shm_buff_ SHM_BUFFER;
70
 
71
/* SM buffer array */
72
 
73
struct _shm_buff_array_
74
{
75
    SHM_BUFFER shm_buff_array[SHM_BUFF_COUNT];
76
};
77
 
78
typedef struct _shm_buff_array_ SHM_BUFF_ARRAY;
79
 
80
/* SM buffer descriptor */
81
 
82
struct _shm_buff_desc_
83
{
84
    mcapi_uint32_t value;
85
    mcapi_uint16_t type;
86
    mcapi_uint16_t priority;
87
};
88
 
89
typedef struct _shm_buff_desc_ SHM_BUFF_DESC;
90
 
91
/* SM buffer descriptor queue */
92
 
93
struct _shm_buff_desc_q_
94
{
95
    SHM_BUFF_DESC  pkt_desc_q[SHM_BUFF_DESC_Q_SIZE];
96
    shm_lock       lock;
97
    mcapi_uint32_t put_idx;
98
    mcapi_uint32_t count;
99
    mcapi_uint32_t get_idx;
100
};
101
 
102
/* Routes */
103
 
104
struct _shm_route_
105
{
106
    mcapi_uint32_t node_id;
107
    mcapi_uint32_t unit_id;
108
};
109
 
110
typedef struct _shm_buff_desc_q_ SHM_BUFF_DESC_Q;
111
 
112
/* SM buffer management block */
113
 
114
struct _shm_buff_mgmt_blk_
115
{
116
    shm_lock       lock;
117
    mcapi_uint32_t buff_bit_mask[BITMASK_WORD_COUNT];
118
    mcapi_uint32_t shm_buff_count;
119
    mcapi_uint32_t shm_buff_base_offset;
120
};
121
 
122
typedef struct _shm_buff_mgmt_blk_ SHM_BUFF_MGMT_BLK;
123
 
124
/* SM driver mamagement block */
125
 
126
struct _shm_drv_mgmt_struct_
127
{
128
    shm_lock                    shm_init_lock;
129
    mcapi_uint32_t              shm_init_field;
130
    struct _shm_route_          shm_routes[CONFIG_SHM_NR_NODES];
131
    struct _shm_buff_desc_q_    shm_queues[CONFIG_SHM_NR_NODES];
132
    struct _shm_buff_mgmt_blk_  shm_buff_mgmt_blk;
133
};
134
 
135
typedef struct _shm_drv_mgmt_struct_ SHM_MGMT_BLOCK;
136
 
137
/* Macros for address to offset conversion */
138
 
139
#define OFFSET_TO_ADDRESS(offset)  (void*)((mcapi_uint32_t)SHM_Mgmt_Blk + offset);
140
 
141
#define ADDRESS_TO_OFFSET(address) (mcapi_uint32_t)((char*)address - (char *)SHM_Mgmt_Blk);
142
 
143
 
144
void shm_poll(void);
145
 
146
#endif /* MCAPI_SM_DRV_H */

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.