PKP
VS1000 P
ROGRAMMER
’
S
G
UIDE
VSMPG
20.4.1
Augmenting the ROM functionality
Changing only the descriptors is easy since the descriptors are accessed via a descrip-
tor pointer table in RAM that consists of 6 pointers to X memory:
USB.descriptorTable entries
Index
Function
[0]
String Descriptor 0 (Language Index)
[1]
String Descriptor 1 (Manufacturer: “VLSI”)
[2]
String Descriptor 2 (Model: “VS1000”)
[3]
String Descriptor 3 (Serial Number: “100010001003”)
[4]
Device Descriptor
[5]
Configuration Descriptors
Because the configuration descriptor is actually a set of descriptors, its size is stored
in USB.configurationDescriptorSize. For other descriptors, the size is taken from the
descriptor itself.
Note: A good storage driver should overwrite the serial number string descriptor with a
unique one. For a NAND flash, this could be done easily in the first sector’s optional boot
code. Since the USB.descriptorTable default values are loaded at each USB init (attacj),
the most straightforward way to do this would be to hook the DecodeSetupPacket()
function to load USB.descriptorTable[3] and call the RealDecodeSetupPacket() in ROM.
USB-related software hooks are:
•
void USBHandler() - USB task handler
•
void DecodeSetupPacket() - handles SETUP packets to EP0OUT
•
void MSCPacketFromPC() - handles mass storage class command packets
•
void ScsiTaskHandler() - handles (pending) disk operations
Hooking means replacing a ROM function with a RAM function by setting the hook vector
address. This is normally used to augment or replace functionality of the ROM code. In
most cases, the original ROM function can be called after handling some special case
in the RAM function. The ROM functions are called by using a function name with prefix
“Real”.
Rev. 0.20
2011-10-04
Page