|
5 | 5 |
|
6 | 6 | ## CP FIFO |
7 | 7 |
|
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: |
9 | 10 |
|
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. |
0 commit comments