|
ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
|
Synthesized FAT16 volume helpers for the USB-HS MRAM MSC demo. More...
Go to the source code of this file.
Enumerations | |
| enum | demo_mram_t : uint32_t { k_mram_base_addr = 0x02000000U , k_mram_bytes = 0x00100000U } |
| The MRAM window this volume exposes (RA8D2 HUM memory map). More... | |
| enum | demo_fat_boot_t : uint32_t { k_boot_jmp0 = 0xEBU , k_boot_jmp1 = 0x3CU , k_boot_jmp2 = 0x90U , k_boot_media = 0xF8U , k_boot_sec_per_trk = 32U , k_boot_num_heads = 16U , k_boot_drive_num = 0x80U , k_boot_ext_sig = 0x29U , k_boot_volume_id = 0x52A8D200U , k_boot_sig_lo = 0x55U , k_boot_sig_hi = 0xAAU , k_boot_sig_lo_off = 510U , k_boot_sig_hi_off = 511U } |
| Boot-sector field values (MS FAT spec 1.03 sec 3.1). More... | |
| enum | demo_fat_off_t : uint8_t { k_bpb_off_jmp = 0U , k_bpb_off_oem = 3U , k_bpb_off_bps = 11U , k_bpb_off_spc = 13U , k_bpb_off_rsvd = 14U , k_bpb_off_nfats = 16U , k_bpb_off_rootent = 17U , k_bpb_off_totsec16 = 19U , k_bpb_off_media = 21U , k_bpb_off_fatsz16 = 22U , k_bpb_off_spt = 24U , k_bpb_off_heads = 26U , k_bpb_off_drvnum = 36U , k_bpb_off_bootsig = 38U , k_bpb_off_volid = 39U , k_bpb_off_label = 43U , k_bpb_off_fstype = 54U , k_dir_entry_bytes = 32U , k_dir_off_attr = 11U , k_dir_off_cluster_lo = 26U , k_dir_off_size = 28U , k_dir_attr_volume = 0x08U , k_dir_attr_read_only = 0x01U , k_dir_name_bytes = 11U , k_byte_shift = 8U , k_byte_mask = 0xFFU } |
| Byte offsets inside the boot sector and directory entries. More... | |
| enum | demo_word_pack_t : uint32_t { k_word_shift = 16U , k_word_mask = 0xFFFFU } |
| 32-bit little-endian split constants. More... | |
Functions | |
| static void | demo_put16 (UCHAR *dst, uint16_t value) |
| Write a 16-bit value little-endian into a byte buffer. | |
| static void | demo_put32 (UCHAR *dst, uint32_t value) |
| Write a 32-bit value little-endian into a byte buffer. | |
| static void | demo_fat_fill_boot (UCHAR *out) |
| Synthesize the FAT16 boot sector (MS FAT spec 1.03 sec 3.1). | |
| static void | demo_fat_fill_fat (uint32_t fat_sector, UCHAR *out) |
| Synthesize one FAT16 sector of the cluster chain. | |
| static void | demo_fat_fill_root (uint32_t root_sector, UCHAR *out) |
| Synthesize one root-directory sector. | |
| void | demo_fat_fill_sector (uint32_t lba, UCHAR *out) |
| Synthesize one 512-byte sector of the read-only volume. | |
Variables | |
| static const UCHAR | s_fat_oem_name [8] = {'R', 'A', '8', 'D', '2', 'F', 'W', ' '} |
| Boot-sector OEM name (8 bytes, space padded). | |
| static const UCHAR | s_fat_volume_label [11] = {'R', 'A', '8', 'D', '2', ' ', 'M', 'R', 'A', 'M', ' '} |
| Volume label, 11 bytes space padded (also the root entry). | |
| static const UCHAR | s_fat_fs_type [8] = {'F', 'A', 'T', '1', '6', ' ', ' ', ' '} |
| Filesystem-type tag, 8 bytes space padded. | |
| static const UCHAR | s_fat_file_name [11] = {'M', 'R', 'A', 'M', ' ', ' ', ' ', ' ', 'B', 'I', 'N'} |
| 8.3 directory name of the exposed file: "MRAM.BIN". | |
Synthesized FAT16 volume helpers for the USB-HS MRAM MSC demo.
Implements the read-only FAT16 sector-synthesis routines split out of main.c so every translation unit stays under the source-size cap. The boot sector, FAT, and root directory are generated on the fly, and the data clusters map 1:1 onto the chip's 1 MiB MRAM window at 0x02000000, exposed as a single root file MRAM.BIN. Only demo_fat_fill_sector() is exported (called from the MSC media-read callback in main.c); the boot/FAT/root fillers and the little-endian packers stay private to this sibling, alongside the file-static FAT identifier strings and the FAT-specific layout enums.
Definition in file usb_msc_mram_hs_steps.c.
| enum demo_fat_boot_t : uint32_t |
Boot-sector field values (MS FAT spec 1.03 sec 3.1).
Definition at line 46 of file usb_msc_mram_hs_steps.c.
| enum demo_fat_off_t : uint8_t |
Byte offsets inside the boot sector and directory entries.
Definition at line 66 of file usb_msc_mram_hs_steps.c.
| enum demo_mram_t : uint32_t |
The MRAM window this volume exposes (RA8D2 HUM memory map).
| Enumerator | |
|---|---|
| k_mram_base_addr | MRAM code window base address. |
| k_mram_bytes | 1 MiB window size. |
Definition at line 37 of file usb_msc_mram_hs_steps.c.
| enum demo_word_pack_t : uint32_t |
32-bit little-endian split constants.
| Enumerator | |
|---|---|
| k_word_shift | Bits per half-word. |
| k_word_mask | Low half-word mask. |
Definition at line 99 of file usb_msc_mram_hs_steps.c.
|
static |
Synthesize the FAT16 boot sector (MS FAT spec 1.03 sec 3.1).
| [out] | out | Zeroed 512-byte sector buffer. |
out is zeroed. out holds the BPB + 0x55AA signature. Definition at line 169 of file usb_msc_mram_hs_steps.c.
References demo_put16(), demo_put32(), k_boot_drive_num, k_boot_ext_sig, k_boot_jmp0, k_boot_jmp1, k_boot_jmp2, k_boot_media, k_boot_num_heads, k_boot_sec_per_trk, k_boot_sig_hi, k_boot_sig_hi_off, k_boot_sig_lo, k_boot_sig_lo_off, k_boot_volume_id, k_bpb_off_bootsig, k_bpb_off_bps, k_bpb_off_drvnum, k_bpb_off_fatsz16, k_bpb_off_fstype, k_bpb_off_heads, k_bpb_off_jmp, k_bpb_off_label, k_bpb_off_media, k_bpb_off_nfats, k_bpb_off_oem, k_bpb_off_rootent, k_bpb_off_rsvd, k_bpb_off_spc, k_bpb_off_spt, k_bpb_off_totsec16, k_bpb_off_volid, k_demo_block_size, k_fat_fat_sectors, k_fat_num_fats, k_fat_reserved_sectors, k_fat_root_entries, k_fat_total_sectors, memcpy(), s_fat_fs_type, s_fat_oem_name, and s_fat_volume_label.
Referenced by demo_fat_fill_sector().
|
static |
Synthesize one FAT16 sector of the cluster chain.
MRAM.BIN occupies clusters 2..2049 as one sequential chain (entry c -> c + 1, last entry -> end-of-chain). Entries 0/1 carry the media descriptor per the FAT spec; everything past the chain reads as free (0x0000).
| [in] | fat_sector | Index of the FAT sector (0-based). |
| [out] | out | Zeroed 512-byte sector buffer. |
out is zeroed. fat_sector is below k_fat_fat_sectors. out holds 256 little-endian FAT16 entries. Definition at line 213 of file usb_msc_mram_hs_steps.c.
References demo_put16(), k_fat_entries_per_sec, k_fat_entry0, k_fat_eoc, and k_fat_last_mram_clus.
Referenced by demo_fat_fill_sector().
|
static |
Synthesize one root-directory sector.
Sector 0 of the root carries two entries: the volume label and the read-only MRAM.BIN file (start cluster 2, size 1 MiB). Every other root sector is empty.
| [in] | root_sector | Index of the root sector (0-based). |
| [out] | out | Zeroed 512-byte sector buffer. |
out is zeroed. root_sector is below k_fat_root_sectors. out holds the directory entries for that sector. Definition at line 252 of file usb_msc_mram_hs_steps.c.
References demo_put16(), demo_put32(), k_dir_attr_read_only, k_dir_attr_volume, k_dir_entry_bytes, k_dir_name_bytes, k_dir_off_attr, k_dir_off_cluster_lo, k_dir_off_size, k_fat_first_cluster, k_mram_bytes, memcpy(), s_fat_file_name, and s_fat_volume_label.
Referenced by demo_fat_fill_sector().
| void demo_fat_fill_sector | ( | uint32_t | lba, |
| UCHAR * | out ) |
Synthesize one 512-byte sector of the read-only volume.
Dispatches on the LBA: boot sector, FAT, root directory, or data region. Data sectors inside the MRAM.BIN chain are copied straight out of the 1 MiB MRAM window; padding clusters past the chain read as zeros.
| [in] | lba | Logical block address inside the volume. |
| [out] | out | 512-byte destination buffer. |
lba is below k_fat_total_sectors (caller-checked). out has 512 writable bytes. out holds the synthesized sector content. Definition at line 268 of file usb_msc_mram_hs_steps.c.
References demo_fat_fill_boot(), demo_fat_fill_boot(), demo_fat_fill_fat(), demo_fat_fill_fat(), demo_fat_fill_root(), demo_fat_fill_root(), k_demo_block_size, k_fat_data_lba, k_fat_fat_lba, k_fat_first_cluster, k_fat_last_mram_clus, k_fat_root_lba, k_mram_base_addr, memcpy(), and memset().
Referenced by demo_msc_read().
|
static |
Write a 16-bit value little-endian into a byte buffer.
| [out] | dst | Destination (2 bytes). |
| [in] | value | Value to store. |
dst has 2 writable bytes. Definition at line 130 of file usb_msc_mram_hs_steps.c.
References k_byte_mask, and k_byte_shift.
Referenced by demo_fat_fill_boot(), demo_fat_fill_fat(), demo_fat_fill_root(), and demo_put32().
|
static |
Write a 32-bit value little-endian into a byte buffer.
| [out] | dst | Destination (4 bytes). |
| [in] | value | Value to store. |
dst has 4 writable bytes. dst holds the four little-endian bytes of value. Definition at line 150 of file usb_msc_mram_hs_steps.c.
References demo_put16(), k_word_mask, and k_word_shift.
Referenced by demo_fat_fill_boot(), and demo_fat_fill_root().
|
static |
8.3 directory name of the exposed file: "MRAM.BIN".
Definition at line 114 of file usb_msc_mram_hs_steps.c.
|
static |
Filesystem-type tag, 8 bytes space padded.
Definition at line 111 of file usb_msc_mram_hs_steps.c.
|
static |
Boot-sector OEM name (8 bytes, space padded).
Definition at line 105 of file usb_msc_mram_hs_steps.c.
|
static |
Volume label, 11 bytes space padded (also the root entry).
Definition at line 108 of file usb_msc_mram_hs_steps.c.