# Vault 7: Projects

This publication series is about specific projects related to the Vault 7 main publication.

### Protego

# MLA -- USB Library

20 December, 2013

- 1
- 2
…
- 93
- 94
- 95
- 96
- 97
…
- 311
- 312

bool (* MediaDetect)(void * config); Function pointer to the MediaDetect() function of the physical
media being used.
uint8_t (* SectorRead)(void * config, uint32_t sector_addr,
uint8_t* buffer);
Function pointer to the SectorRead() function of the physical
media being used.
uint8_t (* WriteProtectState)(void * config); Function pointer to the WriteProtectState() function of the
physical media being used.
uint8_t (* SectorWrite)(void * config, uint32_t sector_addr,
uint8_t* buffer, uint8_t allowWriteToZero);
Function pointer to the SectorWrite() function of the physical
media being used.
void * mediaParameters; Pointer to a media-specific parameter structure
Description
LUN_FUNCTIONS is a structure of function pointers that tells the stack where to find each of the physical layer functions it is
looking for. This structure needs to be defined for any project for PIC24F or PIC32.
Typical Usage:
LUN_FUNCTIONS LUN[MAX_LUN + 1] =
{
{
&MDD_SDSPI_MediaInitialize,
&MDD_SDSPI_ReadCapacity,
&MDD_SDSPI_ReadSectorSize,
&MDD_SDSPI_MediaDetect,
&MDD_SDSPI_SectorRead,
&MDD_SDSPI_WriteProtectState,
&MDD_SDSPI_SectorWrite
}
};
In the above code we are passing the address of the SDSPI functions to the corresponding member of the
LUN_FUNCTIONS structure. In the above case we have created an array of LUN_FUNCTIONS structures so that it is
possible to have multiple physical layers by merely increasing the MAX_LUN variable and by adding one more set of entries
in the array. Please take caution to insure that each function is in the the correct location in the structure. Incorrect alignment
will cause the USB stack to call the incorrect function for a given command.
See the MDD File System Library for additional information about the available physical media, their requirements, and how
to use their associated functions.
1.4.1.5.3 usb_device_msd.h
Functions
Name Description
MSDTasks This is function MSDTasks.
USBCheckMSDRequest
USBMSDInit This is function USBMSDInit.
Module
MSD Function Driver
Structures
Name Description
LUN_FUNCTIONS LUN_FUNCTIONS is a structure of function pointers that tells the stack
where to find each of the physical layer functions it is looking for. This
structure needs to be defined for any project for PIC24F or PIC32.
Description
This is file usb_device_msd.h.
1.4 Library Interface MLA - USB Library Help Device/Peripheral
95

- 1
- 2
…
- 93
- 94
- 95
- 96
- 97
…
- 311
- 312