bootloader: fix missing prototypes and shadowed vars

This commit is contained in:
Philippe Teuwen 2020-05-10 14:05:15 +02:00
commit f9463d183a
2 changed files with 20 additions and 16 deletions

View file

@ -10,6 +10,7 @@
#include "usb_cdc.h" #include "usb_cdc.h"
#include "proxmark3_arm.h" #include "proxmark3_arm.h"
#define DEBUG 0
struct common_area common_area __attribute__((section(".commonarea"))); struct common_area common_area __attribute__((section(".commonarea")));
unsigned int start_addr, end_addr, bootrom_unlocked; unsigned int start_addr, end_addr, bootrom_unlocked;
@ -45,13 +46,15 @@ static int reply_old(uint64_t cmd, uint64_t arg0, uint64_t arg1, uint64_t arg2,
return result; return result;
} }
void DbpString(char *str) { #if DEBUG
static void DbpString(char *str) {
uint8_t len = 0; uint8_t len = 0;
while (str[len] != 0x00) while (str[len] != 0x00)
len++; len++;
reply_old(CMD_DEBUG_PRINT_STRING, len, 0, 0, (uint8_t *)str, len); reply_old(CMD_DEBUG_PRINT_STRING, len, 0, 0, (uint8_t *)str, len);
} }
#endif
static void ConfigClocks(void) { static void ConfigClocks(void) {
// we are using a 16 MHz crystal as the basis for everything // we are using a 16 MHz crystal as the basis for everything
@ -76,7 +79,7 @@ static void Fatal(void) {
for (;;) {}; for (;;) {};
} }
void UsbPacketReceived(uint8_t *packet, int len) { static void UsbPacketReceived(uint8_t *packet, int len) {
int i, dont_ack = 0; int i, dont_ack = 0;
PacketCommandOLD *c = (PacketCommandOLD *)packet; PacketCommandOLD *c = (PacketCommandOLD *)packet;
@ -235,6 +238,7 @@ static void flash_mode(void) {
} }
} }
void BootROM(void);
void BootROM(void) { void BootROM(void) {
//------------ //------------
// First set up all the I/O pins; GPIOs configured directly, other ones // First set up all the I/O pins; GPIOs configured directly, other ones

View file

@ -394,7 +394,7 @@ static const char StrMS_OSDescriptor[] = {
'M', 0, 'S', 0, 'F', 0, 'T', 0, '1', 0, '0', 0, '0', 0, MS_VENDOR_CODE, 0 'M', 0, 'S', 0, 'F', 0, 'T', 0, '1', 0, '0', 0, '0', 0, MS_VENDOR_CODE, 0
}; };
const char *getStringDescriptor(uint8_t idx) { static const char *getStringDescriptor(uint8_t idx) {
switch (idx) { switch (idx) {
case 0: case 0:
return StrLanguageCodes; return StrLanguageCodes;
@ -793,7 +793,7 @@ int usb_write(const uint8_t *data, const size_t len) {
* \brief Send Data through the control endpoint * \brief Send Data through the control endpoint
*---------------------------------------------------------------------------- *----------------------------------------------------------------------------
*/ */
void AT91F_USB_SendData(AT91PS_UDP pUdp, const char *pData, uint32_t length) { void AT91F_USB_SendData(AT91PS_UDP pudp, const char *pData, uint32_t length) {
AT91_REG csr; AT91_REG csr;
do { do {
@ -801,17 +801,17 @@ void AT91F_USB_SendData(AT91PS_UDP pUdp, const char *pData, uint32_t length) {
length -= cpt; length -= cpt;
while (cpt--) while (cpt--)
pUdp->UDP_FDR[AT91C_EP_CONTROL] = *pData++; pudp->UDP_FDR[AT91C_EP_CONTROL] = *pData++;
if (pUdp->UDP_CSR[AT91C_EP_CONTROL] & AT91C_UDP_TXCOMP) { if (pudp->UDP_CSR[AT91C_EP_CONTROL] & AT91C_UDP_TXCOMP) {
UDP_CLEAR_EP_FLAGS(AT91C_EP_CONTROL, AT91C_UDP_TXCOMP); UDP_CLEAR_EP_FLAGS(AT91C_EP_CONTROL, AT91C_UDP_TXCOMP);
while (pUdp->UDP_CSR[AT91C_EP_CONTROL] & AT91C_UDP_TXCOMP); while (pudp->UDP_CSR[AT91C_EP_CONTROL] & AT91C_UDP_TXCOMP);
} }
UDP_SET_EP_FLAGS(AT91C_EP_CONTROL, AT91C_UDP_TXPKTRDY); UDP_SET_EP_FLAGS(AT91C_EP_CONTROL, AT91C_UDP_TXPKTRDY);
do { do {
csr = pUdp->UDP_CSR[AT91C_EP_CONTROL]; csr = pudp->UDP_CSR[AT91C_EP_CONTROL];
// Data IN stage has been stopped by a status OUT // Data IN stage has been stopped by a status OUT
if (csr & AT91C_UDP_RX_DATA_BK0) { if (csr & AT91C_UDP_RX_DATA_BK0) {
@ -822,9 +822,9 @@ void AT91F_USB_SendData(AT91PS_UDP pUdp, const char *pData, uint32_t length) {
} while (length); } while (length);
if (pUdp->UDP_CSR[AT91C_EP_CONTROL] & AT91C_UDP_TXCOMP) { if (pudp->UDP_CSR[AT91C_EP_CONTROL] & AT91C_UDP_TXCOMP) {
UDP_CLEAR_EP_FLAGS(AT91C_EP_CONTROL, AT91C_UDP_TXCOMP); UDP_CLEAR_EP_FLAGS(AT91C_EP_CONTROL, AT91C_UDP_TXCOMP);
while (pUdp->UDP_CSR[AT91C_EP_CONTROL] & AT91C_UDP_TXCOMP); while (pudp->UDP_CSR[AT91C_EP_CONTROL] & AT91C_UDP_TXCOMP);
} }
} }
@ -833,22 +833,22 @@ void AT91F_USB_SendData(AT91PS_UDP pUdp, const char *pData, uint32_t length) {
//* \fn AT91F_USB_SendZlp //* \fn AT91F_USB_SendZlp
//* \brief Send zero length packet through the control endpoint //* \brief Send zero length packet through the control endpoint
//*---------------------------------------------------------------------------- //*----------------------------------------------------------------------------
void AT91F_USB_SendZlp(AT91PS_UDP pUdp) { void AT91F_USB_SendZlp(AT91PS_UDP pudp) {
UDP_SET_EP_FLAGS(AT91C_EP_CONTROL, AT91C_UDP_TXPKTRDY); UDP_SET_EP_FLAGS(AT91C_EP_CONTROL, AT91C_UDP_TXPKTRDY);
while (!(pUdp->UDP_CSR[AT91C_EP_CONTROL] & AT91C_UDP_TXCOMP)) {}; while (!(pudp->UDP_CSR[AT91C_EP_CONTROL] & AT91C_UDP_TXCOMP)) {};
UDP_CLEAR_EP_FLAGS(AT91C_EP_CONTROL, AT91C_UDP_TXCOMP); UDP_CLEAR_EP_FLAGS(AT91C_EP_CONTROL, AT91C_UDP_TXCOMP);
while (pUdp->UDP_CSR[AT91C_EP_CONTROL] & AT91C_UDP_TXCOMP) {}; while (pudp->UDP_CSR[AT91C_EP_CONTROL] & AT91C_UDP_TXCOMP) {};
} }
//*---------------------------------------------------------------------------- //*----------------------------------------------------------------------------
//* \fn AT91F_USB_SendStall //* \fn AT91F_USB_SendStall
//* \brief Stall the control endpoint //* \brief Stall the control endpoint
//*---------------------------------------------------------------------------- //*----------------------------------------------------------------------------
void AT91F_USB_SendStall(AT91PS_UDP pUdp) { void AT91F_USB_SendStall(AT91PS_UDP pudp) {
UDP_SET_EP_FLAGS(AT91C_EP_CONTROL, AT91C_UDP_FORCESTALL); UDP_SET_EP_FLAGS(AT91C_EP_CONTROL, AT91C_UDP_FORCESTALL);
while (!(pUdp->UDP_CSR[AT91C_EP_CONTROL] & AT91C_UDP_ISOERROR)) {}; while (!(pudp->UDP_CSR[AT91C_EP_CONTROL] & AT91C_UDP_ISOERROR)) {};
UDP_CLEAR_EP_FLAGS(AT91C_EP_CONTROL, (AT91C_UDP_FORCESTALL | AT91C_UDP_ISOERROR)); UDP_CLEAR_EP_FLAGS(AT91C_EP_CONTROL, (AT91C_UDP_FORCESTALL | AT91C_UDP_ISOERROR));
while (pUdp->UDP_CSR[AT91C_EP_CONTROL] & (AT91C_UDP_FORCESTALL | AT91C_UDP_ISOERROR)) {}; while (pudp->UDP_CSR[AT91C_EP_CONTROL] & (AT91C_UDP_FORCESTALL | AT91C_UDP_ISOERROR)) {};
} }
//*---------------------------------------------------------------------------- //*----------------------------------------------------------------------------