Skip to content

Commit 25050c9

Browse files
committed
cp fifo
1 parent 171f92b commit 25050c9

File tree

2 files changed

+56
-2
lines changed

2 files changed

+56
-2
lines changed

src/command-processor.md

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,42 @@ a FIFO.
55

66
## CP FIFO
77

8-
The command processor has a FIFO of commands in main RAM, controlled by a bunch of registers.
8+
The command processor has a FIFO mechanism that builds and consumes ring buffers of commands in RAM,
9+
controlled by a bunch of registers:
910

10-
TODO: Document the registers and how the FIFO works
11+
> [!WARNING]
12+
> The registers are _middle endian_. Yep, you read that right. They are 4 byte long, but divided into
13+
> two 2 byte parts _low_ and _high_, and these parts themselves are big endian. This means the byte
14+
> significance order is `[1, 0, 3, 2]` instead of the big endian `[3, 2, 1, 0]`.
15+
16+
| Address | Name | Description |
17+
| ----------- | ---------------------- | ---------------------------------------------------------------------- |
18+
| 0x0C00_0020 | CP FIFO Start | Ring buffer's start address |
19+
| 0x0C00_0024 | CP FIFO End | Ring buffer's end address (exclusive) |
20+
| 0x0C00_0028 | CP FIFO High Watermark | Ring buffer's high watermark |
21+
| 0x0C00_002C | CP FIFO Low Watermark | Ring buffer's low watermark |
22+
| 0x0C00_0030 | CP FIFO Count | Ring buffer's current count (distance between read and write pointers) |
23+
| 0x0C00_0034 | CP FIFO Write Pointer | Ring buffer's write pointer |
24+
| 0x0C00_0038 | CP FIFO Read Pointer | Ring buffer's read pointer |
25+
26+
The mechanism has two modes of operations: linked and multi-buffer. The mode is controlled by bit
27+
4 of the CP Enable register.
28+
29+
### Linked Mode
30+
31+
In this mode, the CP FIFO is linked to the PI FIFO. Whenever a value is written to the PI ring buffer,
32+
the value is also written to the ring buffer pointed to by the CP write pointer.
33+
34+
This mode also contains "watermark" logic (whatever that means). If the CP count is smaller than the
35+
low watermark, then a CP FIFO underflow interrupt is generated. If the CP count is greater than the
36+
high watermark, then a a CP FIFO overflow interrupt is generated. Whenever one of these interrupts
37+
is active the CP stops processing new commands.
38+
39+
Watermark essentially allows the CP to signal to the system whether it's close to filling up or
40+
close to running out of commands.
41+
42+
### Multi-buffer Mode
43+
44+
TODO: Rewrite and expand - this is copy pasted from Dolwin docs
45+
46+
In multi-buffer mode, the CP processes FIFO until the FIFO size (FIFO_COUNT) is greater than 0. FIFO_COUNT is the distance between CP Wrptr and CP Rdptr.

theme/custom.css

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,22 @@ tbody {
2727
margin-top: 15px;
2828
text-align: center;
2929
font-size: 0.85em;
30+
}
31+
32+
.frame {
33+
margin-block-start: 1.5em;
34+
margin-block-end: 1.5em;
35+
36+
padding: 15px;
37+
38+
backdrop-filter: brightness(85%);
39+
border-radius: 10px;
40+
}
41+
42+
.frame *:first-child {
43+
margin-block-start: 0px;
44+
}
45+
46+
.frame *:last-child {
47+
margin-block-end: 0px;
3048
}

0 commit comments

Comments
 (0)