rusEFI
The most advanced open source ECU
Loading...
Searching...
No Matches
Functions | Variables
mass_storage_init.cpp File Reference

Functions

void attachMsdSdCard (BaseBlockDevice *blkdev, uint8_t *blkbuf, size_t blkbufsize)
 
void deattachMsdSdCard (void)
 
static BaseBlockDevice * getRamdiskDevice ()
 
void initUsbMsd ()
 

Variables

static CompressedBlockDevice cbd
 
static RamDisk ramdisk
 
USBDriver * usb_driver = &USBD1
 
static NO_CACHE uint8_t blkbuf0 [MMCSD_BLOCK_SIZE]
 
static MassStorageController msd (usb_driver)
 
static const scsi_inquiry_response_t iniDriveInquiry
 
static const scsi_inquiry_response_t sdCardInquiry
 

Function Documentation

◆ attachMsdSdCard()

void attachMsdSdCard ( BaseBlockDevice *  blkdev,
uint8_t *  blkbuf,
size_t  blkbufsize 
)

Definition at line 77 of file mass_storage_init.cpp.

77 {
78 if ((blkbuf == NULL) || (blkbufsize == 0)) {
79 // if no specific buffer was provided use default
81 blkbufsize = sizeof(blkbuf0);
82 }
83 msd.attachLun(1, blkdev, blkbuf, blkbufsize, &sdCardInquiry, nullptr);
84
85#if EFI_TUNER_STUDIO
86 // SD MSD attached, enable indicator in TS
88#endif
89}
TunerStudioOutputChannels outputChannels
Definition engine.h:109
void attachLun(uint8_t lunIndex, BaseBlockDevice *blkdev, uint8_t *blkbuf, size_t blkbufsize, const scsi_inquiry_response_t *inquiry, const scsi_unit_serial_number_inquiry_response_t *serialInquiry)
static EngineAccessor engine
Definition engine.h:413
static NO_CACHE uint8_t blkbuf0[MMCSD_BLOCK_SIZE]
static MassStorageController msd(usb_driver)
static const scsi_inquiry_response_t sdCardInquiry
uint8_t blkbuf[4 *MMCSD_BLOCK_SIZE]
Definition mmc_card.cpp:292

Referenced by sdModeSwitcher().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ deattachMsdSdCard()

void deattachMsdSdCard ( void  )

Definition at line 91 of file mass_storage_init.cpp.

91 {
92 // this is safe to use same read/write buffer couse all luns are handled from one thread
93 msd.attachLun(1, (BaseBlockDevice*)&ND1, blkbuf0, sizeof(blkbuf0), &sdCardInquiry, nullptr);
94
95#if EFI_TUNER_STUDIO
96 // SD MSD attached, enable indicator in TS
98#endif
99}
NullDevice ND1

Referenced by sdModeSwitchToIdle().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getRamdiskDevice()

static BaseBlockDevice * getRamdiskDevice ( )
static

Definition at line 101 of file mass_storage_init.cpp.

101 {
102#if EFI_EMBED_INI_MSD
103#if EFI_USE_COMPRESSED_INI_MSD
104 uzlib_init();
106 compressedBlockDeviceStart(&cbd, ramdisk_image_gz, sizeof(ramdisk_image_gz));
107
108 return (BaseBlockDevice*)&cbd;
109#else // not EFI_USE_COMPRESSED_INI_MSD
110 ramdiskObjectInit(&ramdisk);
111
112 constexpr size_t ramdiskSize = sizeof(ramdisk_image);
113 constexpr size_t blockSize = 512;
114 constexpr size_t blockCount = ramdiskSize / blockSize;
115
116 // Ramdisk should be a round number of blocks
117 static_assert(ramdiskSize % blockSize == 0);
118
119 ramdiskStart(&ramdisk, const_cast<uint8_t*>(ramdisk_image), blockSize, blockCount, /*readonly =*/ true);
120
121 return (BaseBlockDevice*)&ramdisk;
122#endif // EFI_USE_COMPRESSED_INI_MSD
123#else // not EFI_EMBED_INI_MSD
124 // No embedded ini file, just mount the null device instead
125 return (BaseBlockDevice*)&ND1;
126#endif
127}
void compressedBlockDeviceObjectInit(CompressedBlockDevice *cbd)
void compressedBlockDeviceStart(CompressedBlockDevice *cbd, const uint8_t *source, size_t sourceSize)
static CompressedBlockDevice cbd
static RamDisk ramdisk

Referenced by initUsbMsd().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ initUsbMsd()

void initUsbMsd ( )

Definition at line 129 of file mass_storage_init.cpp.

129 {
130 // Attach the ini ramdisk
131 msd.attachLun(0, getRamdiskDevice(), blkbuf0, sizeof(blkbuf0), &iniDriveInquiry, nullptr);
132
133 // attach a null device in place of the SD card for now - the SD thread may replace it later
134 // this is safe to use same read/write buffer couse all luns are handled from one thread
135 msd.attachLun(1, (BaseBlockDevice*)&ND1, blkbuf0, sizeof(blkbuf0), &sdCardInquiry, nullptr);
136
137 // start the mass storage thread
138 msd.start();
139}
void start()
Start the thread.
static BaseBlockDevice * getRamdiskDevice()
static const scsi_inquiry_response_t iniDriveInquiry

Referenced by runRusEfi().

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ blkbuf0

NO_CACHE uint8_t blkbuf0[MMCSD_BLOCK_SIZE]
static

Definition at line 45 of file mass_storage_init.cpp.

Referenced by attachMsdSdCard(), deattachMsdSdCard(), and initUsbMsd().

◆ cbd

◆ iniDriveInquiry

const scsi_inquiry_response_t iniDriveInquiry
static
Initial value:
= {
0x00,
0x80,
0x04,
0x02,
sizeof(scsi_inquiry_response_t) - 5,
0x00,
0x00,
0x00,
"rusEFI",
"INI Drive",
{'v',CH_KERNEL_MAJOR+'0','.',CH_KERNEL_MINOR+'0'}
}

Definition at line 49 of file mass_storage_init.cpp.

49 {
50 0x00, /* direct access block device */
51 0x80, /* removable */
52 0x04, /* SPC-2 */
53 0x02, /* response data format */
54 sizeof(scsi_inquiry_response_t) - 5, // size of this struct, minus bytes up to and including this one
55 0x00,
56 0x00,
57 0x00,
58 "rusEFI",
59 "INI Drive",
60 {'v',CH_KERNEL_MAJOR+'0','.',CH_KERNEL_MINOR+'0'}
61};

Referenced by initUsbMsd().

◆ msd

◆ ramdisk

RamDisk ramdisk
static

Definition at line 32 of file mass_storage_init.cpp.

Referenced by getRamdiskDevice().

◆ sdCardInquiry

const scsi_inquiry_response_t sdCardInquiry
static
Initial value:
= {
0x00,
0x80,
0x04,
0x02,
sizeof(scsi_inquiry_response_t) - 5,
0x00,
0x00,
0x00,
"rusEFI",
"SD Card",
{'v',CH_KERNEL_MAJOR+'0','.',CH_KERNEL_MINOR+'0'}
}

Definition at line 63 of file mass_storage_init.cpp.

63 {
64 0x00, /* direct access block device */
65 0x80, /* removable */
66 0x04, /* SPC-2 */
67 0x02, /* response data format */
68 sizeof(scsi_inquiry_response_t) - 5, // size of this struct, minus bytes up to and including this one
69 0x00,
70 0x00,
71 0x00,
72 "rusEFI",
73 "SD Card",
74 {'v',CH_KERNEL_MAJOR+'0','.',CH_KERNEL_MINOR+'0'}
75};

Referenced by attachMsdSdCard(), deattachMsdSdCard(), and initUsbMsd().

◆ usb_driver

USBDriver * usb_driver = &USBD1

Definition at line 37 of file mass_storage_init.cpp.

Go to the source code of this file.