Initial commit of OpenSPARC T2 design and verification files.
[OpenSPARC-T2-DV] / verif / model / systemc / niu / sharedmem.h
CommitLineData
86530b38
AT
1/*
2* ========== Copyright Header Begin ==========================================
3*
4* OpenSPARC T2 Processor File: sharedmem.h
5* Copyright (C) 1995-2007 Sun Microsystems, Inc. All Rights Reserved
6* 4150 Network Circle, Santa Clara, California 95054, U.S.A.
7*
8* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
9*
10* This program is free software; you can redistribute it and/or modify
11* it under the terms of the GNU General Public License as published by
12* the Free Software Foundation; version 2 of the License.
13*
14* This program is distributed in the hope that it will be useful,
15* but WITHOUT ANY WARRANTY; without even the implied warranty of
16* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17* GNU General Public License for more details.
18*
19* You should have received a copy of the GNU General Public License
20* along with this program; if not, write to the Free Software
21* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22*
23* For the avoidance of doubt, and except that if any non-GPL license
24* choice is available it will apply instead, Sun elects to use only
25* the General Public License version 2 (GPLv2) at this time for any
26* software where a choice of GPL license versions is made
27* available with the language indicating that GPLv2 or any later version
28* may be used, or where a choice of which version of the GPL is applied is
29* otherwise unspecified.
30*
31* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
32* CA 95054 USA or visit www.sun.com if you need additional information or
33* have any questions.
34*
35*
36* ========== Copyright Header End ============================================
37*/
38/*
39* ========== Copyright Header Begin ==========================================
40*
41* OpenSPARC T2 Processor File: sharedmem.h
42* Copyright (C) 1995-2007 Sun Microsystems, Inc. All Rights Reserved
43* 4150 Network Circle, Santa Clara, California 95054, U.S.A.
44*
45* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
46*
47* This program is free software; you can redistribute it and/or modify
48* it under the terms of the GNU General Public License as published by
49* the Free Software Foundation; version 2 of the License.
50*
51* This program is distributed in the hope that it will be useful,
52* but WITHOUT ANY WARRANTY; without even the implied warranty of
53* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
54* GNU General Public License for more details.
55*
56* You should have received a copy of the GNU General Public License
57* along with this program; if not, write to the Free Software
58* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
59*
60* For the avoidance of doubt, and except that if any non-GPL license
61* choice is available it will apply instead, Sun elects to use only
62* the General Public License version 2 (GPLv2) at this time for any
63* software where a choice of GPL license versions is made
64* available with the language indicating that GPLv2 or any later version
65* may be used, or where a choice of which version of the GPL is applied is
66* otherwise unspecified.
67*
68* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
69* CA 95054 USA or visit www.sun.com if you need additional information or
70* have any questions.
71*
72*
73* ========== Copyright Header End ============================================
74*/
75#include <sys/types.h>
76#include <sys/ipc.h>
77#include <sys/shm.h>
78#include <unistd.h>
79#include <thread.h>
80#include <synch.h>
81
82extern void ncu_interface(unsigned int mem[4]);
83
84
85
86class sharedmem {
87char *shm;
88sema_t *sp_niu_pio_request;
89sema_t *sp_niu_pio_response;
90sema_t *sp_sii_rd_available;
91sema_t *sp_sii_wr_available;
92sema_t *sp_sii_rd_req;
93sema_t *sp_sii_rd_res;
94sema_t *sp_xaui0_available;
95sema_t *sp_xaui0_req;
96sema_t *sp_xaui1_available;
97sema_t *sp_xaui1_req;
98sema_t *sp_rx0_available;
99sema_t *sp_rx1_available;
100sema_t *sp_sii_wr_req;
101sema_t *sp_sii_wr_res;
102
103void *data;
104int *typ;
105
106void *sii_wr_data;
107int *sii_wr_size;
108unsigned long long int *sii_wr_addr;
109
110int *niu_read;
111int *niu_write;
112int *read_size;
113unsigned long long int *pa_read;
114void *sio_data;
115
116void *xaui0_data;
117int *xaui0_size;
118
119void *xaui1_data;
120int *xaui1_size;
121
122unsigned char *xaui_rx_data[2];
123
124int *xaui_rx_pointer[2];
125int *xaui_rx_head[2];
126int *xaui_rx_tail[2];
127
128unsigned int *interrupt;
129
130
131void add_rx_packet(int port, void *data, int size);
132void remove_rx_packet(int port, void *data, int &size);
133void display_rx_packet_queue(int port);
134
135
136public:
137
138typedef enum {NCU, SIU, ESR, EXIT} TYPE;
139sharedmem(key_t key, int create);
140void deliver_ncu_req(void *buf, int size);
141void receive_ncu_req(void *buf, int size);
142void deliver_niu_res(void *buf, int size);
143void receive_niu_res(void *buf, int size);
144void signalExit();
145
146void tx0_send_packet(int size, uint8_t * data);
147int tx0_wait_packet(int &size, uint8_t * data);
148void tx0_packet_sent();
149
150void tx1_send_packet(int size, uint8_t * data);
151int tx1_wait_packet(int &size, uint8_t * data);
152void tx1_packet_sent();
153
154void setType(int t);
155int getType();
156
157void rx0_wait_packet(int &size, uint8_t * data);
158void rx1_wait_packet(int &size, uint8_t * data);
159void rx0_packet_rec(int size, uint8_t * data);
160void rx1_packet_rec(int size, uint8_t * data);
161
162void sii_write_req(uint64_t paddr, uint8_t * data, uint64_t size);
163int sii_receive_write_req(uint64_t &paddr, uint8_t * data, uint64_t &size);
164void sii_write_res();
165
166void sii_read_req(uint64_t paddr, uint8_t * data, uint64_t size);
167int sii_receive_read_req(uint64_t &paddr, uint64_t &size);
168void sii_read_res(uint8_t * data, uint64_t size);
169
170
171void deliverInterrupt(unsigned int data);
172void receiveInterrupt(unsigned int &data);
173
174
175
176};
177