-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpodule_regs.h
142 lines (128 loc) · 4.7 KB
/
podule_regs.h
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
/* podule_regs
*
* Various definitions describing the layout of the memory/register space
* shared between the podule_interface code and the services provided by the MCU.
*
* MIT License
*
* Copyright (c) 2021 Matt Evans
*
* 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 and this permission notice shall be included in all
* copies 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.
*/
#ifndef PODULE_REGS_H
#define PODULE_REGS_H
/* From the view of the host: */
#define PR_BASE 0x2000
#define PR_ROM_PAGE_BASE 0x1000
/* From the view of us, the podule: */
#define PR_OFFSET (PR_BASE/4)
#define PR_ROM_PAGE_OFFSET (PR_ROM_PAGE_BASE/4)
/* Page regs: max 15 bits of 1KB page, i.e. 32M max ROM area. */
#define PR_PAGE_L 0
#define PR_PAGE_H 1 // Host sets bit 7 to load; podule clears
/* Reset: incremented by loader/OS */
#define PR_RESET 2
/* Packet descriptors: Arc sees these byte-wide, but we can access as words: */
#define PR_TX_DESCR(pb, desc_n) ( ((volatile uint32_t *)(&(pb)[PR_TX0_0]))[desc_n] )
#define PR_RX_DESCR(pb, desc_n) ( ((volatile uint32_t *)(&(pb)[PR_RX0_0]))[desc_n] )
#define PR_DESCR_READY 0x80000000
#define PR_DESCR_ADDR_MASK 0x000001ff
#define PR_DESCR_ADDR_SHIFT 0
#define PR_DESCR_SIZE_MASK 0x001ff000
#define PR_DESCR_SIZE_SHIFT 12
#define PR_DESCR_CID_MASK 0x7f000000
#define PR_DESCR_CID_SHIFT 24
#define PR_DESCR_IS_READY(x) ( !!((x) & PR_DESCR_READY) )
#define PR_DESCR_ADDR(x) ( ((x) & PR_DESCR_ADDR_MASK) >> PR_DESCR_ADDR_SHIFT )
#define PR_DESCR_SIZE(x) ( (((x) & PR_DESCR_SIZE_MASK) >> PR_DESCR_SIZE_SHIFT) + 1 )
#define PR_DESCR_CID(x) ( ((x) & PR_DESCR_CID_MASK) >> PR_DESCR_CID_SHIFT )
#define PR_NUM_DESCRS 2 // Po2
#define PR_DESCRS_MASK (PR_NUM_DESCRS-1)
#define PR_TX_TAIL 0x40
#define PR_RX_HEAD 0x41
#define PR_TX0_0 0x80
#define PR_TX0_1 0x81
#define PR_TX0_2 0x82
#define PR_TX0_3 0x83
#define PR_TX1_0 0x84
#define PR_TX1_1 0x85
#define PR_TX1_2 0x86
#define PR_TX1_3 0x87
// Unused, but reserved:
#define PR_TX2_0 0x88
#define PR_TX2_1 0x89
#define PR_TX2_2 0x8a
#define PR_TX2_3 0x8b
#define PR_TX3_0 0x8c
#define PR_TX3_1 0x8d
#define PR_TX3_2 0x8e
#define PR_TX3_3 0x8f
#define PR_TX4_0 0x90
#define PR_TX4_1 0x91
#define PR_TX4_2 0x92
#define PR_TX4_3 0x93
#define PR_TX5_0 0x94
#define PR_TX5_1 0x95
#define PR_TX5_2 0x96
#define PR_TX5_3 0x97
#define PR_TX6_0 0x98
#define PR_TX6_1 0x99
#define PR_TX6_2 0x9a
#define PR_TX6_3 0x9b
#define PR_TX7_0 0x9c
#define PR_TX7_1 0x9d
#define PR_TX7_2 0x9e
#define PR_TX7_3 0x9f
#define PR_RX0_0 0xa0
#define PR_RX0_1 0xa1
#define PR_RX0_2 0xa2
#define PR_RX0_3 0xa3
#define PR_RX1_0 0xa4
#define PR_RX1_1 0xa5
#define PR_RX1_2 0xa6
#define PR_RX1_3 0xa7
// Unused, but reserved:
#define PR_RX2_0 0xa8
#define PR_RX2_1 0xa9
#define PR_RX2_2 0xaa
#define PR_RX2_3 0xab
#define PR_RX3_0 0xac
#define PR_RX3_1 0xad
#define PR_RX3_2 0xae
#define PR_RX3_3 0xaf
#define PR_RX4_0 0xb0
#define PR_RX4_1 0xb1
#define PR_RX4_2 0xb2
#define PR_RX4_3 0xb3
#define PR_RX5_0 0xb4
#define PR_RX5_1 0xb5
#define PR_RX5_2 0xb6
#define PR_RX5_3 0xb7
#define PR_RX6_0 0xb8
#define PR_RX6_1 0xb9
#define PR_RX6_2 0xba
#define PR_RX6_3 0xbb
#define PR_RX7_0 0xbc
#define PR_RX7_1 0xbd
#define PR_RX7_2 0xbe
#define PR_RX7_3 0xbf
#define PR_RX_TX_BUFSZ 512
#define PR_TX_BUFFERS 0x400
#define PR_RX_BUFFERS 0x600
#endif