PERFORCE change 103622 for review
Warner Losh
imp at FreeBSD.org
Fri Aug 11 00:20:08 UTC 2006
http://perforce.freebsd.org/chv.cgi?CH=103622
Change 103622 by imp at imp_lighthouse on 2006/08/11 00:19:38
don't compile in so many debug writes. Saves another 400 bytes, more
or less.
Affected files ...
.. //depot/projects/arm/src/sys/boot/arm/at91/libat91/mci_device.c#3 edit
.. //depot/projects/arm/src/sys/boot/arm/at91/libat91/sd-card.c#3 edit
Differences ...
==== //depot/projects/arm/src/sys/boot/arm/at91/libat91/mci_device.c#3 (text+ko) ====
@@ -134,9 +134,11 @@
unsigned int *dataBuffer,
int sizeToRead)
{
- ////////////////////////////////////////////////////////////////////////////////////////////
+ ///////////////////////////////////////////////////////////////////////
if (pMCI_Device->pMCI_DeviceDesc->state != AT91C_MCI_IDLE) {
+#if IMP_DEBUG
printf("1 state is 0x%x\r\n", pMCI_Device->pMCI_DeviceDesc->state);
+#endif
return AT91C_READ_ERROR;
}
@@ -144,18 +146,24 @@
if ((AT91F_MCI_GetStatus(pMCI_Device,
pMCI_Device->pMCI_DeviceFeatures->Relative_Card_Address) & AT91C_SR_READY_FOR_DATA) !=
AT91C_SR_READY_FOR_DATA) {
+#if IMP_DEBUG
printf("2\r\n");
+#endif
return AT91C_READ_ERROR;
}
if ( (src + sizeToRead) > pMCI_Device->pMCI_DeviceFeatures->Memory_Capacity ) {
+#if IMP_DEBUG
printf("3\r\n");
+#endif
return AT91C_READ_ERROR;
}
// If source does not fit a begin of a block
if ((src & ((1 << pMCI_Device->pMCI_DeviceFeatures->READ_BL_LEN) - 1)) != 0) {
+#if IMP_DEBUG
printf("4\r\n");
+#endif
return AT91C_READ_ERROR;
}
@@ -163,15 +171,19 @@
// ALWAYS SUPPORTED IN SD Memory Card
if( (sizeToRead < pMCI_Device->pMCI_DeviceFeatures->Max_Read_DataBlock_Length)
&& (pMCI_Device->pMCI_DeviceFeatures->Read_Partial == 0x00) ) {
+#if IMP_DEBUG
printf("5\r\n");
+#endif
return AT91C_READ_ERROR;
}
if( sizeToRead > pMCI_Device->pMCI_DeviceFeatures->Max_Read_DataBlock_Length) {
+#if IMP_DEBUG
printf("6\r\n");
+#endif
return AT91C_READ_ERROR;
}
- ////////////////////////////////////////////////////////////////////////////////////////////
+ ///////////////////////////////////////////////////////////////////////
// Init Mode Register
AT91C_BASE_MCI->MCI_MR |= ((pMCI_Device->pMCI_DeviceFeatures->Max_Read_DataBlock_Length << 16) | AT91C_MCI_PDCMODE);
@@ -211,14 +223,14 @@
unsigned int *dataBuffer,
int sizeToWrite )
{
- ////////////////////////////////////////////////////////////////////////////////////////////
+ ///////////////////////////////////////////////////////////////////////
if( pMCI_Device->pMCI_DeviceDesc->state != AT91C_MCI_IDLE)
- return AT91C_WRITE_ERROR;
+ return AT91C_WRITE_ERROR;
- if( (AT91F_MCI_GetStatus(pMCI_Device,pMCI_Device->pMCI_DeviceFeatures->Relative_Card_Address) & AT91C_SR_READY_FOR_DATA) != AT91C_SR_READY_FOR_DATA)
- return AT91C_WRITE_ERROR;
+ if( (AT91F_MCI_GetStatus(pMCI_Device,pMCI_Device->pMCI_DeviceFeatures->Relative_Card_Address) & AT91C_SR_READY_FOR_DATA) != AT91C_SR_READY_FOR_DATA)
+ return AT91C_WRITE_ERROR;
- if ( (dest + sizeToWrite) > pMCI_Device->pMCI_DeviceFeatures->Memory_Capacity )
+ if ((dest + sizeToWrite) > pMCI_Device->pMCI_DeviceFeatures->Memory_Capacity)
return AT91C_WRITE_ERROR;
// If source does not fit a begin of a block
@@ -226,15 +238,15 @@
return AT91C_WRITE_ERROR;
// Test if the MMC supports Partial Write Block
- if( (sizeToWrite < pMCI_Device->pMCI_DeviceFeatures->Max_Write_DataBlock_Length)
- && (pMCI_Device->pMCI_DeviceFeatures->Write_Partial == 0x00) )
+ if( (sizeToWrite < pMCI_Device->pMCI_DeviceFeatures->Max_Write_DataBlock_Length)
+ && (pMCI_Device->pMCI_DeviceFeatures->Write_Partial == 0x00) )
return AT91C_WRITE_ERROR;
if( sizeToWrite > pMCI_Device->pMCI_DeviceFeatures->Max_Write_DataBlock_Length )
return AT91C_WRITE_ERROR;
- ////////////////////////////////////////////////////////////////////////////////////////////
+ ///////////////////////////////////////////////////////////////////////
- // Init Mode Register
+ // Init Mode Register
AT91C_BASE_MCI->MCI_MR |= ((pMCI_Device->pMCI_DeviceFeatures->Max_Write_DataBlock_Length << 16) | AT91C_MCI_PDCMODE);
if (sizeToWrite %4)
@@ -243,30 +255,30 @@
sizeToWrite = sizeToWrite/4;
// Init PDC for write sequence
- AT91C_BASE_PDC_MCI->PDC_PTCR = (AT91C_PDC_TXTDIS | AT91C_PDC_RXTDIS);
- AT91C_BASE_PDC_MCI->PDC_TPR = (unsigned int) dataBuffer;
- AT91C_BASE_PDC_MCI->PDC_TCR = sizeToWrite;
+ AT91C_BASE_PDC_MCI->PDC_PTCR = (AT91C_PDC_TXTDIS | AT91C_PDC_RXTDIS);
+ AT91C_BASE_PDC_MCI->PDC_TPR = (unsigned int) dataBuffer;
+ AT91C_BASE_PDC_MCI->PDC_TCR = sizeToWrite;
// Send the write single block command
- if ( AT91F_MCI_SendCommand(pMCI_Device, AT91C_WRITE_BLOCK_CMD, dest) != AT91C_CMD_SEND_OK)
- return AT91C_WRITE_ERROR;
+ if ( AT91F_MCI_SendCommand(pMCI_Device, AT91C_WRITE_BLOCK_CMD, dest) != AT91C_CMD_SEND_OK)
+ return AT91C_WRITE_ERROR;
pMCI_Device->pMCI_DeviceDesc->state = AT91C_MCI_TX_SINGLE_BLOCK;
// Enable AT91C_MCI_TXBUFE Interrupt
- AT91C_BASE_MCI->MCI_IER = AT91C_MCI_TXBUFE;
+ AT91C_BASE_MCI->MCI_IER = AT91C_MCI_TXBUFE;
// Enables TX for PDC transfert requests
- AT91C_BASE_PDC_MCI->PDC_PTCR = AT91C_PDC_TXTEN;
+ AT91C_BASE_PDC_MCI->PDC_PTCR = AT91C_PDC_TXTEN;
return AT91C_WRITE_OK;
}
#endif
-//*------------------------------------------------------------------------------------------------------------
+//*----------------------------------------------------------------------------
//* \fn AT91F_MCI_MMC_SelectCard
//* \brief Toggles a card between the Stand_by and Transfer states or between Programming and Disconnect states
-//*------------------------------------------------------------------------------------------------------------
+//*----------------------------------------------------------------------------
AT91S_MCIDeviceStatus
AT91F_MCI_MMC_SelectCard(AT91PS_MciDevice pMCI_Device, unsigned int relative_card_address)
{
==== //depot/projects/arm/src/sys/boot/arm/at91/libat91/sd-card.c#3 (text+ko) ====
@@ -54,8 +54,10 @@
}
while( !(status & AT91C_MCI_NOTBUSY) && (timeout>0) );
+#if IMP_DEBUG
if (timeout == 0)
printf("Timeout, status is 0x%x\r\n", status);
+#endif
//TODO: Make interrupts work!
AT91F_MCI_Handler();
@@ -70,7 +72,9 @@
AT91S_MCIDeviceStatus status;
int sizeToWrite;
+#if IMP_DEBUG
printf("\r\n");
+#endif
//See if we are requested to write partial sectors, and have the capability to do so
if ((length % sectorLength) && !(MCI_Device_Features.Write_Partial))
@@ -145,8 +149,10 @@
int sizeToRead;
unsigned int *walker;
+#if IMP_DEBUG
printf("Reading 0x%x bytes into ARM Addr 0x%x from card offset 0x%x\r\n",
length, dest, source);
+#endif
//See if we are requested to read partial sectors, and have the capability to do so
@@ -171,7 +177,9 @@
status = AT91F_MCI_ReadBlock(&MCI_Device, source, (unsigned int*)dest, sizeToRead);
//TODO:Status checking
if (status != AT91C_READ_OK) {
+#if IMP_DEBUG
printf("STATUS is 0x%x\r\n", status);
+#endif
return -1;
}
@@ -201,12 +209,16 @@
AT91F_MCIDeviceWaitReady(AT91C_MCI_TIMEOUT);
//Do the writing
status = AT91F_MCI_ReadBlock(&MCI_Device, source, (unsigned int*)dest, sizeToRead);
+#if IMP_DEBUG
printf("Reading 0x%x Addr 0x%x card 0x%x\r\n",
sizeToRead, dest, source);
+#endif
//TODO:Status checking
if (status != AT91C_READ_OK) {
+#if IMP_DEBUG
printf("STATUS is 0x%x\r\n", status);
+#endif
return -1;
}
More information about the p4-projects
mailing list