ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
Loading...
Searching...
No Matches
ra8_usb_pmsc.h
Go to the documentation of this file.
1
47
48#pragma once
49
50#ifdef __cplusplus
51extern "C" {
52#endif
53
54#include <stdint.h>
55
56#include "ra8_err.h"
57#include "ra8_usb.h"
58
59/* =============================================================================
60 * Constants
61 * =============================================================================
62 */
63
79
92
101
116
128
136typedef enum : uint8_t {
139
153
172
190
205
206/* =============================================================================
207 * Storage backend interface (Dependency Inversion)
208 * =============================================================================
209 */
210
226 uint32_t lba,
227 uint32_t block_count,
228 uint8_t* buf);
229
243 uint32_t lba,
244 uint32_t block_count,
245 const uint8_t* buf);
246
259 uint32_t* block_count,
260 uint32_t* block_size);
261
280 uint8_t* vendor8,
281 uint8_t* product16,
282 uint8_t* revision4);
283
317
318/* =============================================================================
319 * Lifecycle
320 * =============================================================================
321 */
322
353[[nodiscard]] ra8_err_t ra8_usb_pmsc_init(ra8_usb_speed_t speed);
354
370[[nodiscard]] ra8_err_t ra8_usb_pmsc_close(void);
371
372/* =============================================================================
373 * Storage backend
374 * =============================================================================
375 */
376
403
404/* =============================================================================
405 * BOT state machine
406 * =============================================================================
407 */
408
444[[nodiscard]] ra8_err_t ra8_usb_pmsc_step(void);
445
446/* =============================================================================
447 * Test / introspection helpers
448 * =============================================================================
449 */
450
480[[nodiscard]] ra8_err_t ra8_usb_pmsc_feed_cbw(const uint8_t* cbw);
481
517[[nodiscard]] ra8_err_t ra8_usb_pmsc_dispatch_command(uint8_t* data_buf,
518 uint32_t data_buf_capacity,
519 uint32_t* data_len,
520 ra8_usb_pmsc_csw_status_t* csw_status);
521
554[[nodiscard]] ra8_err_t
555ra8_usb_pmsc_build_csw(ra8_usb_pmsc_csw_status_t csw_status, uint32_t residue, uint8_t* out_csw);
556
557#ifdef __cplusplus
558}
559#endif
Error Code Definitions for ra8-firmware.
ra8_err_codes_t ra8_err_t
Canonical error-return type used by every ra8-firmware API.
Definition ra8_err.h:546
Native USB controller driver public API (device + host modes).
ra8_usb_speed_t
Selects which controller instance the call targets.
ra8_usb_pmsc_class_t
Class / subclass / protocol triplet advertised in the device's interface descriptor.
@ k_ra8_pmsc_protocol_bbb
Bulk-Only Transport.
@ k_ra8_pmsc_class_msc
MSC interface class.
@ k_ra8_pmsc_subclass_scsi
Transparent SCSI subclass.
ra8_err_t ra8_usb_pmsc_close(void)
Tear down the device-MSC driver and release the controller.
ra8_usb_pmsc_inquiry_field_t
Sizes of the three INQUIRY ASCII strings the storage backend returns.
@ k_ra8_pmsc_inq_revision_len
Revision byte count.
@ k_ra8_pmsc_inq_vendor_len
Vendor ID byte count.
@ k_ra8_pmsc_inq_product_len
Product ID byte count.
ra8_err_t(* ra8_usb_pmsc_read_block_fn_t)(void *ctx, uint32_t lba, uint32_t block_count, uint8_t *buf)
Storage-backend read hook.
ra8_usb_pmsc_pipe_t
PIPE numbers used by the device-MSC driver for the local bulk endpoints.
@ k_ra8_pmsc_pipe_bulk_out
PIPE4 -> local EP bulk OUT.
@ k_ra8_pmsc_pipe_bulk_in
PIPE3 -> local EP bulk IN.
ra8_err_t ra8_usb_pmsc_dispatch_command(uint8_t *data_buf, uint32_t data_buf_capacity, uint32_t *data_len, ra8_usb_pmsc_csw_status_t *csw_status)
Run the SCSI command currently parked in the BOT state.
ra8_usb_pmsc_max_lun_t
Number of logical units the starter exposes.
@ k_ra8_pmsc_max_lun
Highest valid LUN index.
ra8_err_t(* ra8_usb_pmsc_write_block_fn_t)(void *ctx, uint32_t lba, uint32_t block_count, const uint8_t *buf)
Storage-backend write hook.
ra8_usb_pmsc_resp_size_t
Standard SCSI response payload sizes.
@ k_ra8_pmsc_read_capacity_resp_len
READ_CAPACITY(10).
@ k_ra8_pmsc_request_sense_resp_len
REQUEST SENSE response.
@ k_ra8_pmsc_inquiry_resp_len
INQUIRY response len.
@ k_ra8_pmsc_block_size_default
SCSI default block.
@ k_ra8_pmsc_mode_sense_resp_len
MODE SENSE(6) response.
ra8_err_t ra8_usb_pmsc_init(ra8_usb_speed_t speed)
Bring up the device-MSC driver on a chosen USB controller.
ra8_usb_pmsc_endpoint_t
USB endpoint numbers advertised in the configuration descriptor.
@ k_ra8_pmsc_ep_bulk_in
Bulk-IN endpoint number.
@ k_ra8_pmsc_ep_bulk_out
Bulk-OUT endpoint number.
ra8_usb_pmsc_packet_t
Packet sizing for the local bulk endpoints.
@ k_ra8_pmsc_bulk_max_packet_fs
Bulk size at full speed.
@ k_ra8_pmsc_bulk_max_packet_hs
Bulk size at high speed.
ra8_usb_pmsc_request_t
MSC class-specific request codes the host issues to the device.
@ k_ra8_pmsc_req_mass_storage_reset
0-byte payload.
@ k_ra8_pmsc_req_get_max_lun
1-byte response.
ra8_err_t ra8_usb_pmsc_build_csw(ra8_usb_pmsc_csw_status_t csw_status, uint32_t residue, uint8_t *out_csw)
Build the 13-byte CSW for the in-flight command.
ra8_err_t(* ra8_usb_pmsc_get_capacity_fn_t)(void *ctx, uint32_t *block_count, uint32_t *block_size)
Storage-backend capacity hook – answers SCSI READ CAPACITY(10).
ra8_usb_pmsc_csw_status_t
CSW status field values the device returns after a CBW.
@ k_ra8_pmsc_csw_status_passed
Command succeeded.
@ k_ra8_pmsc_csw_status_phase_error
BBB phase error – the host must run reset recovery.
@ k_ra8_pmsc_csw_status_failed
Command failed.
ra8_usb_pmsc_scsi_t
SCSI opcodes the device-MSC class answers over BBB.
@ k_ra8_pmsc_scsi_write_10
WRITE(10).
@ k_ra8_pmsc_scsi_read_capacity_10
READ CAPACITY(10).
@ k_ra8_pmsc_scsi_read_10
READ(10).
@ k_ra8_pmsc_scsi_test_unit_ready
TEST UNIT READY.
@ k_ra8_pmsc_scsi_inquiry
INQUIRY.
@ k_ra8_pmsc_scsi_request_sense
REQUEST SENSE.
@ k_ra8_pmsc_scsi_mode_sense_6
MODE SENSE(6).
ra8_err_t ra8_usb_pmsc_step(void)
Drive the BOT (Bulk-Only Transport) state machine forward by one step.
ra8_err_t(* ra8_usb_pmsc_get_inquiry_fn_t)(void *ctx, uint8_t *vendor8, uint8_t *product16, uint8_t *revision4)
Storage-backend INQUIRY hook – answers SCSI INQUIRY.
ra8_err_t ra8_usb_pmsc_feed_cbw(const uint8_t *cbw)
Inject a CBW directly into the BOT state machine.
ra8_err_t ra8_usb_pmsc_attach_storage(const ra8_usb_pmsc_storage_t *storage)
Bind a caller-owned storage backend to the device-MSC class.
Caller-owned storage backend bound to the device-MSC class.
void * ctx
Opaque context.
ra8_usb_pmsc_get_inquiry_fn_t get_inquiry
INQUIRY hook.
ra8_usb_pmsc_read_block_fn_t read_block
Block read hook.
ra8_usb_pmsc_get_capacity_fn_t get_capacity
Capacity hook.
ra8_usb_pmsc_write_block_fn_t write_block
Block write hook.