aboutsummaryrefslogtreecommitdiffstats
path: root/LUFA/Drivers/USB/Core/UC3/Device_UC3.h
diff options
context:
space:
mode:
authorDean Camera <dean@fourwalledcubicle.com>2011-05-14 02:17:58 +0000
committerDean Camera <dean@fourwalledcubicle.com>2011-05-14 02:17:58 +0000
commit049e9309637cd057689cf273b2023afb0d6876ae (patch)
tree184919dd3e728aad41bc3bb1567b6f95f18564aa /LUFA/Drivers/USB/Core/UC3/Device_UC3.h
parent78e58b6d1c645c3ba1afaa536e2ba5bdab2b235b (diff)
downloadlufa-049e9309637cd057689cf273b2023afb0d6876ae.tar.gz
lufa-049e9309637cd057689cf273b2023afb0d6876ae.tar.bz2
lufa-049e9309637cd057689cf273b2023afb0d6876ae.zip
Fixed possible invalid program execution when in host mode if corrupt descriptor lengths are supplied by the attached device.
Minor code cleanups to add const and reformat where missing, as well as abstract out the internal device signature start address into a macro, so that it can be altered to suit particular devices within a single architecture if needed. Add missing documentation to the USB_Device_States_t enum.
Diffstat (limited to 'LUFA/Drivers/USB/Core/UC3/Device_UC3.h')
-rw-r--r--LUFA/Drivers/USB/Core/UC3/Device_UC3.h23
1 files changed, 16 insertions, 7 deletions
diff --git a/LUFA/Drivers/USB/Core/UC3/Device_UC3.h b/LUFA/Drivers/USB/Core/UC3/Device_UC3.h
index ed7409856..8bc8188d2 100644
--- a/LUFA/Drivers/USB/Core/UC3/Device_UC3.h
+++ b/LUFA/Drivers/USB/Core/UC3/Device_UC3.h
@@ -89,18 +89,24 @@
* On unsupported devices, this will evaluate to \ref NO_DESCRIPTOR and so will force the host to create a pseudo-serial
* number for the device.
*/
- #define USE_INTERNAL_SERIAL 0xDC
+ #define USE_INTERNAL_SERIAL 0xDC
/** Length of the device's unique internal serial number, in bits, if present on the selected microcontroller
* model.
*/
- #define INTERNAL_SERIAL_LENGTH_BITS 120
+ #define INTERNAL_SERIAL_LENGTH_BITS 120
+
+ /** Start address of the internal serial number, in the appropriate address space, if present on the selected microcontroller
+ * model.
+ */
+ #define INTERNAL_SERIAL_START_ADDRESS 0x80800204
#else
- #define USE_INTERNAL_SERIAL NO_DESCRIPTOR
+ #define USE_INTERNAL_SERIAL NO_DESCRIPTOR
- #define INTERNAL_SERIAL_LENGTH_BITS 0
+ #define INTERNAL_SERIAL_LENGTH_BITS 0
+ #define INTERNAL_SERIAL_START_ADDRESS 0
#endif
-
+
/* Function Prototypes: */
/** Sends a Remote Wakeup request to the host. This signals to the host that the device should
* be taken out of suspended mode, and communications should resume.
@@ -186,12 +192,13 @@
return AVR32_USBB.UDCON.adden;
}
- static inline void USB_Device_GetSerialString(uint16_t* UnicodeString)
+ #if (USE_INTERNAL_SERIAL != NO_DESCRIPTOR)
+ static inline void USB_Device_GetSerialString(uint16_t* const UnicodeString)
{
uint_reg_t CurrentGlobalInt = GetGlobalInterruptMask();
GlobalInterruptDisable();
- uint8_t* SigReadAddress = (uint8_t*)0x80800204;
+ uint8_t* SigReadAddress = (uint8_t*)INTERNAL_SERIAL_START_ADDRESS;
for (uint8_t SerialCharNum = 0; SerialCharNum < (INTERNAL_SERIAL_LENGTH_BITS / 4); SerialCharNum++)
{
@@ -211,6 +218,8 @@
SetGlobalInterruptMask(CurrentGlobalInt);
}
+ #endif
+
#endif
#endif