|
ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
|
FAT16 read-only volume image synthesizer for the MSC MRAM demo. More...
Go to the source code of this file.
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". | |
FAT16 read-only volume image synthesizer for the MSC MRAM demo.
Holds the on-the-fly FAT16 volume builder used by main.c's storage media-read callback: the little-endian packing primitives (demo_put16 / demo_put32), the per-region sector synthesizers (boot sector, FAT chain, root directory), and the LBA dispatcher demo_fat_fill_sector that ties them together and copies data sectors straight out of the chip's 1 MiB MRAM window at 0x02000000. Geometry, boot-field, and offset constants are shared with main.c through usb_msc_mram_steps.h; the FAT name / label / OEM byte strings are private to this translation unit.
Definition in file usb_msc_mram_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 100 of file usb_msc_mram_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 144 of file usb_msc_mram_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 183 of file usb_msc_mram_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 199 of file usb_msc_mram_steps.c.
|
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 61 of file usb_msc_mram_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 81 of file usb_msc_mram_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 45 of file usb_msc_mram_steps.c.
|
static |
Filesystem-type tag, 8 bytes space padded.
Definition at line 42 of file usb_msc_mram_steps.c.
|
static |
Boot-sector OEM name (8 bytes, space padded).
Definition at line 36 of file usb_msc_mram_steps.c.
|
static |
Volume label, 11 bytes space padded (also the root entry).
Definition at line 39 of file usb_msc_mram_steps.c.