1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
|
/*
* This file is part of SIS.
*
* SIS, SPARC instruction simulator. Copyright (C) 2014 Jiri Gaisler
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free
* Software Foundation; either version 3 of the License, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, see <http://www.gnu.org/licenses/>.
*
*/
#include "sis.h"
#include "grlib.h"
/* APB PNP */
static uint32 apbppmem[32 * 2]; /* 32-entry APB PP AREA */
static int apbppindex;
int
grlib_apbpp_add (uint32 id, uint32 addr)
{
apbppmem[apbppindex++] = id;
apbppmem[apbppindex++] = addr;
if (apbppindex >= (32 * 2))
apbppindex = 0; /* prevent overflow of area */
return apbppindex;
}
uint32
grlib_apbpnp_read (uint32 addr)
{
uint32 read_data;
addr &= 0xff;
read_data = apbppmem[addr >> 2];
return read_data;
}
/* AHB PNP */
static uint32 ahbppmem[128 * 8]; /* 128-entry AHB PP AREA */
static int ahbmppindex;
static int ahbsppindex = 64 * 8;
int
grlib_ahbmpp_add (uint32 id)
{
ahbppmem[ahbmppindex] = id;
ahbmppindex += 8;
if (ahbmppindex >= (64 * 8))
ahbmppindex = 0; /* prevent overflow of area */
return ahbmppindex;
}
int
grlib_ahbspp_add (uint32 id, uint32 addr1, uint32 addr2,
uint32 addr3, uint32 addr4)
{
ahbppmem[ahbsppindex] = id;
ahbsppindex += 4;
ahbppmem[ahbsppindex++] = addr1;
ahbppmem[ahbsppindex++] = addr2;
ahbppmem[ahbsppindex++] = addr3;
ahbppmem[ahbsppindex++] = addr4;
if (ahbsppindex >= (128 * 8))
ahbsppindex = 64 * 8; /* prevent overflow of area */
return ahbsppindex;
}
uint32
grlib_ahbpnp_read (uint32 addr)
{
uint32 read_data;
addr &= 0xfff;
read_data = ahbppmem[addr >> 2];
return read_data;
}
void
grlib_init ()
{
/* Add PP records for Leon3, APB bridge and interrupt controller
as this is not done elsewhere */
grlib_ahbmpp_add (GRLIB_PP_ID (VENDOR_GAISLER, GAISLER_LEON3, 0, 0));
grlib_ahbspp_add (GRLIB_PP_ID (VENDOR_GAISLER, GAISLER_APBMST, 0, 0),
GRLIB_PP_AHBADDR (0x80000000, 0xFFF, 0, 0, 2), 0, 0, 0);
grlib_apbpp_add (GRLIB_PP_ID (VENDOR_GAISLER, GAISLER_IRQMP, 2, 0),
GRLIB_PP_APBADDR (0x80000200, 0xFFF));
}
|