-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmmc.system
429 lines (425 loc) · 17.3 KB
/
mmc.system
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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
<?xml version="1.0" encoding="UTF-8"?>
<system>
<!-- This is a 4KB, page-aligned memory region at the physical address of
0x3f200000, which is where the GPIO registers are mapped to. -->
<memory_region
name="gpio"
size="0x1_000"
phys_addr="0x3f200000"/>
<!-- This is a 4KB, page-aligned memory region at the physical address of
0x3f_003_000, which is where the Timer registers are mapped to. -->
<memory_region
name="timer"
size="0x1_000"
phys_addr="0x3f_003_000"/>
<!-- This is a 4KB, page-aligned memory region at the physical address of
0x3f_300_000, which is where the EMMC registers are mapped to. -->
<memory_region
name="emmc"
size="0x1_000"
phys_addr="0x3f_300_000"/>
<!-- This is a 4KB, page-aligned memory region at the physical address of
0x3f215000, which is where the UART device registers are mapped to. Note, we
are mapping in the Rpi3B's "Mini" UART device registers and NOT its "PL011"
UART device registers. An important aspect to note that the base of the Mini
UART device registers are actually mapped to 0x3f215040 in physical memory.
Unfortunately, 0x3f215040 is not a 4K page-aligned address, so we can't map
a page at that physical address. As such in our `serial_driver.c` code, we
must remember to obtain the real base address of the Mini UART device by
adding 0x40 to 0x3f215000. -->
<memory_region
name="uart"
size="0x1_000"
phys_addr="0x3f215000"/>
<!-- In the SDDF's design-documentation, `shared_dma` is referred to as the
"Data Region". `shared_dma` is an array of I/O buffers that will be used to
pass/transport data from `serial_client` to `serial_driver` and vice-versa.
The `shared_dma` memory region MUST be mapped at the exact same virtual
memory address in all the PDs that use the `shared_dma`. If they aren't
mapped to the same address, the SDDF's ring buffer mechanism of transporting
data across PDs will NOT work. This is because the SDDF's ring buffer
mechanism passes the virtual address of a `shared_dma` buffer from PD to PD,
which enables the SDDF's transport mechanism to be zero-copy. Theoretically,
the requirement to map the `shared_dma` to the same virtual address in
various PDs could be alleviated if there existed a mechanism to translate
virtual addresses across PDs (VSpaces); however, such a mechanism does NOT
currently exist. -->
<memory_region
name="shared_dma"
size="0x200_000"
page_size="0x200_000"/>
<!-- This is a 2MB memory region with a 2MB page size. An explanation of the
purpose of this memory region is provided in `serial_client.c`. The SDDF
does not require this memory region to be mapped to a specific virtual
address. -->
<memory_region
name="tx_avail_ring_buf"
size="0x200_000"
page_size="0x200_000"/>
<!-- This is a 2MB memory region with a 2MB page size. An explanation of the
purpose of this memory region is provided in `serial_client.c`. The SDDF
does not require this memory region to be mapped to a specific virtual
address. -->
<memory_region
name="tx_used_ring_buf"
size="0x200_000"
page_size="0x200_000"/>
<!-- This is a 2MB memory region with a 2MB page size. An explanation of the
purpose of this memory region is provided in `serial_client.c`. The SDDF
does not require this memory region to be mapped to a specific virtual
address. -->
<memory_region
name="rx_avail_ring_buf"
size="0x200_000"
page_size="0x200_000"/>
<!-- This is a 2MB memory region with a 2MB page size. An explanation of the
purpose of this memory region is provided in `serial_client.c`. The SDDF
does not require this memory region to be mapped to a specific virtual
address. -->
<memory_region
name="rx_used_ring_buf"
size="0x200_000"
page_size="0x200_000"/>
<!-- A shared buffer to pass chars from `mmc_driver.c` to `serial_client.c`. -->
<memory_region
name="mmc_to_serial_client_putchar_buf"
size="0x1_000"
page_size="0x1_000"/>
<!-- A shared buffer to pass chars from `fatfs.c` to `serial_client.c`. -->
<memory_region
name="fatfs_to_serial_client_putchar_buf"
size="0x1_000"
page_size="0x1_000"/>
<!-- A 2MB shared data region for passing data between `mmc_driver` and
`fatfs`. -->
<memory_region
name="mmc_driver_shared_data"
size="0x200_000"
page_size="0x200_000"/>
<!-- A 2MB shared data region for sending requests from `fatfs` to
`mmc_driver`. -->
<memory_region
name="mmc_driver_request_queue"
size="0x200_000"
page_size="0x200_000"/>
<!-- A 2MB shared data region for sending responses from `mmc_driver` to
`fatfs`. -->
<memory_region
name="mmc_driver_response_queue"
size="0x200_000"
page_size="0x200_000"/>
<!-- The `serial_driver` PD must have a higher priority than the
`serial_client` PD so that it doesn't get preempted by `serial_client` when
it is busy writing to the UART device. -->
<protection_domain
name="serial_driver"
priority="101"
pp="true">
<program_image path="serial_driver.elf"/>
<!-- We map our physical memory to the virtual address at 0x5_000_000 -->
<map
mr="uart"
vaddr="0x5_000_000"
perms="rw"
cached="false"
setvar_vaddr="uart_base_vaddr"/>
<!--
BCM2835/2837 TRM
Section 7.5
The mini-UART from the AUX peripheral triggers IRQ 29 ("Aux int")
on the VideoCore, which then signals pending GPU interrupts
to the ARM core.
The PL011 triggers IRQ 57 ("uart_int").
The seL4 kernel's interrupt controller driver creates a linear mapping
of all interrupts in the system (see
include/drivers/bcm2836-armctrl-ic.h) with 32 ARM PPIs, 32 basic
interrupts and 64 GPU interrupts.
Thus, the actual interrupts to be used in userland are: 93 (=32+32+29).
mini-UART 32+32+29 = 93
PL011 UART 32+32+57 = 121
-->
<irq irq="93" id="2" />
<!-- As per our earlier comment on `shared_dma`, `shared_dma` is always
mapped to the same virtual address of 0x2_400_000 for ALL PDs (which is
a requirement and assumption of the SDDF's transport mechanism). -->
<map
mr="shared_dma"
vaddr="0x2_400_000"
perms="rw"
cached="true"
setvar_vaddr="shared_dma" />
<!-- Unlike `shared_dma`, there is no limitation to where this memory
region is mapped to in this PD's virtual address space. -->
<map
mr="tx_avail_ring_buf"
vaddr="0x7_000_000"
perms="rw"
cached="true"
setvar_vaddr="tx_avail_ring_buf"/>
<!-- Unlike `shared_dma`, there is no limitation to where this memory
region is mapped to in this PD's virtual address space. -->
<map
mr="tx_used_ring_buf"
vaddr="0x7_200_000"
perms="rw"
cached="true"
setvar_vaddr="tx_used_ring_buf"/>
<!-- Unlike `shared_dma`, there is no limitation to where this memory
region is mapped to in this PD's virtual address space. -->
<map
mr="rx_avail_ring_buf"
vaddr="0x7_400_000"
perms="rw"
cached="true"
setvar_vaddr="rx_avail_ring_buf"/>
<!-- Unlike `shared_dma`, there is no limitation to where this memory
region is mapped to in this PD's virtual address space. -->
<map
mr="rx_used_ring_buf"
vaddr="0x7_600_000"
perms="rw"
cached="true"
setvar_vaddr="rx_used_ring_buf"/>
</protection_domain>
<!-- The `serial_client` PD must have a lower priority than the
`serial_driver` PD so that it doesn't preempt `serial_client` when it is
busy writing to the UART device. -->
<protection_domain
name="serial_client"
priority="100"
pp="true">
<program_image path="serial_client.elf"/>
<!-- As per our earlier comment on `shared_dma`, `shared_dma` is always
mapped to the same virtual address of 0x2_400_000 for ALL PDs (which is
a requirement and assumption of the SDDF's transport mechanism). -->
<map
mr="shared_dma"
vaddr="0x2_400_000"
perms="rw"
cached="true"
setvar_vaddr="shared_dma" />
<!-- Unlike `shared_dma`, there is no limitation to where this memory
region is mapped to in this PD's virtual address space. -->
<map
mr="tx_avail_ring_buf"
vaddr="0x6_000_000"
perms="rw"
cached="true"
setvar_vaddr="tx_avail_ring_buf"/>
<!-- Unlike `shared_dma`, there is no limitation to where this memory
region is mapped to in this PD's virtual address space. -->
<map
mr="tx_used_ring_buf"
vaddr="0x6_200_000"
perms="rw"
cached="true"
setvar_vaddr="tx_used_ring_buf"/>
<!-- Unlike `shared_dma`, there is no limitation to where this memory
region is mapped to in this PD's virtual address space. -->
<map
mr="rx_avail_ring_buf"
vaddr="0x6_400_000"
perms="rw"
cached="true"
setvar_vaddr="rx_avail_ring_buf"/>
<!-- Unlike `shared_dma`, there is no limitation to where this memory
region is mapped to in this PD's virtual address space. -->
<map
mr="rx_used_ring_buf"
vaddr="0x6_600_000"
perms="rw"
cached="true"
setvar_vaddr="rx_used_ring_buf"/>
<map
mr="mmc_to_serial_client_putchar_buf"
vaddr="0x6_800_000"
perms="rw"
cached="true"
setvar_vaddr="mmc_to_serial_client_putchar_buf"/>
<map
mr="timer_driver_to_serial_client_putchar_buf"
vaddr="0x7_000_000"
perms="rw"
cached="true"
setvar_vaddr="timer_driver_to_serial_client_putchar_buf"/>
<map
mr="fatfs_to_serial_client_putchar_buf"
vaddr="0x7_200_000"
perms="rw"
cached="true"
setvar_vaddr="fatfs_to_serial_client_putchar_buf"/>
</protection_domain>
<!-- Channel between `serial_client` and `serial_driver` for printf() calls
by `serial_client`. -->
<channel>
<end pd="serial_client" id="3" />
<end pd="serial_driver" id="4" />
</channel>
<!-- Channel between `serial_client` and `serial_driver` for getchar() calls
by `serial_client`. -->
<channel>
<end pd="serial_client" id="5" />
<end pd="serial_driver" id="6" />
</channel>
<!-- A shared buffer for `mmc_driver.c` to obtain num ticks from
`timer_driver.c`. -->
<memory_region
name="timer_driver_to_mmc_driver_numticks_buf"
size="0x1_000"
page_size="0x1_000"/>
<!-- A shared buffer to pass chars from `timer_driver.c` to `serial_client.c`. -->
<memory_region
name="timer_driver_to_serial_client_putchar_buf"
size="0x1_000"
page_size="0x1_000"/>
<!-- Protection Domain for Timer driver. -->
<protection_domain
name="timer_driver"
priority="99"
pp="true">
<program_image path="timer_driver.elf"/>
<!-- Memory region mapped to Timer registers. -->
<map
mr="timer"
vaddr="0x2_200_000"
perms="rw"
cached="false"
setvar_vaddr="timer_base_vaddr"/>
<!-- Shared memory region for `timer_driver` PD to pass num ticks to
`mmc` PD.-->
<map
mr="timer_driver_to_mmc_driver_numticks_buf"
vaddr="0x2_600_000"
perms="rw"
cached="true"
setvar_vaddr="timer_driver_to_mmc_driver_numticks_buf"/>
</protection_domain>
<!-- Channel between `timer_driver` and `serial_client` for printf()
calls by `timer_driver`. -->
<channel>
<end pd="timer_driver" id="9" />
<end pd="serial_client" id="10" />
</channel>
<!-- Protection Domain for MultiMediaCard driver. -->
<protection_domain
name="mmc_driver"
priority="98"
pp="true">
<program_image path="mmc_driver.elf"/>
<!-- Shared memory region for `timer_driver` PD to pass num ticks to
`mmc` PD.-->
<map
mr="timer_driver_to_mmc_driver_numticks_buf"
vaddr="0x2_600_000"
perms="rw"
cached="true"
setvar_vaddr="timer_driver_to_mmc_driver_numticks_buf"/>
<!-- Shared memory region for `mmc_driver` PD to pass characters to
`serial_client` to print. -->
<map
mr="mmc_to_serial_client_putchar_buf"
vaddr="0x3_000_000"
perms="rw"
cached="true"
setvar_vaddr="mmc_to_serial_client_putchar_buf"/>
<!-- Memory region mapped to GPIO registers. Since this region of memory
is memory-mapped, we turn caching off. -->
<map
mr="gpio"
vaddr="0x3_002_000"
perms="rw"
cached="false"
setvar_vaddr="gpio_base_vaddr"/>
<!-- Memory region mapped to EMMC registers. Since this region of memory
is memory-mapped, we turn caching off. -->
<map
mr="emmc"
vaddr="0x3_004_000"
perms="rw"
cached="false"
setvar_vaddr="emmc_base_vaddr"/>
<!-- A shared memory region for passing requests from `fatfs` to
`mmc_driver`. -->
<map
mr="mmc_driver_request_queue"
vaddr="0x3_200_000"
perms="rw"
cached="true"
setvar_vaddr="mmc_driver_request_queue" />
<!-- A shared memory region for passing responses from `mmc_driver` to
`fatfs`. -->
<map
mr="mmc_driver_response_queue"
vaddr="0x3_400_000"
perms="rw"
cached="true"
setvar_vaddr="mmc_driver_response_queue" />
<!-- A shared memory region for passing data between `mmc_driver` and
`fatfs`. -->
<map
mr="mmc_driver_shared_data"
vaddr="0x4_000_000"
perms="rw"
cached="true"
setvar_vaddr="mmc_driver_shared_data" />
</protection_domain>
<!-- Channel between `mmc_driver` and `serial_client` for printf()
calls by `mmc_driver`. -->
<channel>
<end pd="mmc_driver" id="7" />
<end pd="serial_client" id="8" />
</channel>
<!-- Channel between `mmc_driver` and `timer_driver` for get_num_ticks()
calls by `mmc_driver`. -->
<channel>
<end pd="mmc_driver" id="11"/>
<end pd="timer_driver" id="12"/>
</channel>
<!-- Protection Domain for FAT File System. -->
<protection_domain
name="fatfs"
priority="97"
pp="true">
<program_image path="fatfs.elf"/>
<!-- Shared memory region for `fatfs` PD to pass characters to
`serial_client` to print. -->
<map
mr="fatfs_to_serial_client_putchar_buf"
vaddr="0x2_600_000"
perms="rw"
cached="true"
setvar_vaddr="fatfs_to_serial_client_putchar_buf"/>
<!-- A shared memory region for passing requests from `fatfs` to
`mmc_driver`. -->
<map
mr="mmc_driver_request_queue"
vaddr="0x2_800_000"
perms="rw"
cached="true"
setvar_vaddr="mmc_driver_request_queue" />
<!-- A shared memory region for passing responses from `mmc_driver` to
`fatfs`. -->
<map
mr="mmc_driver_response_queue"
vaddr="0x3_000_000"
perms="rw"
cached="true"
setvar_vaddr="mmc_driver_response_queue" />
<!-- A shared memory region for passing data between `mmc_driver` and
`fatfs`. -->
<map
mr="mmc_driver_shared_data"
vaddr="0x4_000_000"
perms="rw"
cached="true"
setvar_vaddr="mmc_driver_shared_data" />
</protection_domain>
<channel>
<end pd="fatfs" id="13"/>
<end pd="serial_client" id="14"/>
</channel>
<channel>
<end pd="fatfs" id="15"/>
<end pd="mmc_driver" id="16"/>
</channel>
</system>