<dev/protocols/mmcdrv.h>¶
Block-device protocol shared by every SD/MMC driver ("/dev/mmc0").
One client at a time. Every request gets exactly one reply, sent once the transfer has finished. Requests and replies travel in the message buffer; block data goes through the buffer page from SD_CMD_GET_BUF.
#include <dev/protocols/mmcdrv.h>
Constants¶
| Name | Value | Description |
|---|---|---|
SD_CMD_GET_BUF |
1 |
Get the transfer buffer. SdRequest {cmd}; replies SdReply and grants the driver-owned buffer page (PERM_MAP | PERM_WRITE | PERM_TXFR). Asking again grants the same buffer. |
SD_CMD_READ |
2 |
Read blocks. SdRequest {cmd, lba, count}; the data lands at buffer offset 0. |
SD_CMD_WRITE |
3 |
Write blocks. SdRequest {cmd, lba, count}; the data is taken from buffer offset 0. |
SD_ERR_IO |
ERR_IO |
A block transfer failed: CRC error, timeout, or FIFO overrun or underrun. |
SD_BLOCK_SIZE |
512u |
Bytes per block. |
SD_BUF_SIZE |
4096u |
Size of the transfer buffer: one page, so at most 8 blocks per request. |
Structures¶
SdRequest¶
A request, in the message buffer.
| Field | Type | Description |
|---|---|---|
cmd |
uint32_t |
An SD_CMD_* value. |
lba |
uint32_t |
First block. |
count |
uint32_t |
Number of blocks. |
SdReply¶
A reply, in the message buffer; READ and WRITE fill in only status.
| Field | Type | Description |
|---|---|---|
status |
Err |
ZUZU_OK, or an error code. |
buf_size |
uint32_t |
GET_BUF: size of the transfer buffer. |
block_size |
uint32_t |
GET_BUF: bytes per block. |
block_count |
uint32_t |
GET_BUF: blocks on the card, or 0 if unknown. |