Date: Mon, 21 Aug 2006 22:09:59 GMT From: Warner Losh <imp@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 104734 for review Message-ID: <200608212209.k7LM9xG7055676@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=104734 Change 104734 by imp@imp_lighthouse on 2006/08/21 22:09:57 Fix block length calculations to be consistant. implement %d == %u for printf. lame but useful. nits we're now to 'not ufs'! progress Affected files ... .. //depot/projects/arm/src/sys/boot/arm/at91/boot2/boot2.c#7 edit .. //depot/projects/arm/src/sys/boot/arm/at91/libat91/mci_device.c#7 edit .. //depot/projects/arm/src/sys/boot/arm/at91/libat91/mci_device.h#5 edit .. //depot/projects/arm/src/sys/boot/arm/at91/libat91/printf.c#4 edit .. //depot/projects/arm/src/sys/boot/arm/at91/libat91/sd-card.c#5 edit Differences ... ==== //depot/projects/arm/src/sys/boot/arm/at91/boot2/boot2.c#7 (text+ko) ==== @@ -160,7 +160,7 @@ s = cmd; for (;;) { - switch (c = getc(0)) { + switch (c = getc(10000)) { case 0: break; case '\177': @@ -188,6 +188,9 @@ int autoboot; ino_t ino; + if (kname[0]) + printf("bss not zero\r\n"); + EMAC_Init(); sdcard_init(); EMAC_SetMACAddress(mac); @@ -218,10 +221,8 @@ "boot: ", kname); if (!autoboot || getc(5) == -1) getstr(); - else if (!autoboot || !OPT_CHECK(RBX_QUIET)) { - xputchar('\r'); + else if (!autoboot || !OPT_CHECK(RBX_QUIET)) xputchar('\n'); - } autoboot = 0; if (parse()) xputchar('\a'); ==== //depot/projects/arm/src/sys/boot/arm/at91/libat91/mci_device.c#7 (text+ko) ==== @@ -162,6 +162,9 @@ unsigned int *dataBuffer, int sizeToRead) { + unsigned log2sl = pMCI_Device->pMCI_DeviceFeatures->READ_BL_LEN; + unsigned sectorLength = 1 << log2sl; + /////////////////////////////////////////////////////////////////////// if (pMCI_Device->pMCI_DeviceDesc->state != AT91C_MCI_IDLE) { #if IMP_DEBUG @@ -188,7 +191,7 @@ } // If source does not fit a begin of a block - if ((src & ((1 << pMCI_Device->pMCI_DeviceFeatures->READ_BL_LEN) - 1)) != 0) { + if ((src & (sectorLength - 1)) != 0) { #if IMP_DEBUG printf("4\r\n"); #endif @@ -197,7 +200,7 @@ // Test if the MMC supports Partial Read Block // ALWAYS SUPPORTED IN SD Memory Card - if( (sizeToRead < pMCI_Device->pMCI_DeviceFeatures->Max_Read_DataBlock_Length) + if( (sizeToRead < sectorLength) && (pMCI_Device->pMCI_DeviceFeatures->Read_Partial == 0x00) ) { #if IMP_DEBUG printf("5\r\n"); @@ -205,7 +208,7 @@ return AT91C_READ_ERROR; } - if( sizeToRead > pMCI_Device->pMCI_DeviceFeatures->Max_Read_DataBlock_Length) { + if( sizeToRead > sectorLength) { #if IMP_DEBUG printf("6\r\n"); #endif @@ -214,7 +217,7 @@ /////////////////////////////////////////////////////////////////////// // Init Mode Register - AT91C_BASE_MCI->MCI_MR |= ((pMCI_Device->pMCI_DeviceFeatures->Max_Read_DataBlock_Length << 16) | AT91C_MCI_PDCMODE); + AT91C_BASE_MCI->MCI_MR |= ((sectorLength << 16) | AT91C_MCI_PDCMODE); if (sizeToRead %4) sizeToRead = (sizeToRead /4)+1; @@ -251,6 +254,9 @@ unsigned int *dataBuffer, int sizeToWrite ) { + unsigned log2sl = MCI_Device.pMCI_DeviceFeatures->WRITE_BL_LEN; + unsigned sectorLength = 1 << log2sl; + /////////////////////////////////////////////////////////////////////// if( pMCI_Device->pMCI_DeviceDesc->state != AT91C_MCI_IDLE) return AT91C_WRITE_ERROR; @@ -262,15 +268,15 @@ return AT91C_WRITE_ERROR; // If source does not fit a begin of a block - if ( (dest % pMCI_Device->pMCI_DeviceFeatures->Max_Read_DataBlock_Length) != 0 ) + if ( dest % sectorLength != 0 ) 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 < sectorLength) + && (pMCI_Device->pMCI_DeviceFeatures->Write_Partial == 0x00)) return AT91C_WRITE_ERROR; - if( sizeToWrite > pMCI_Device->pMCI_DeviceFeatures->Max_Write_DataBlock_Length ) + if (sizeToWrite > sectorLength) return AT91C_WRITE_ERROR; /////////////////////////////////////////////////////////////////////// @@ -449,27 +455,27 @@ f->Relative_Card_Address = 0; continue; } - f->READ_BL_LEN = ((tab_response[1] >> AT91C_CSD_RD_B_LEN_S) & AT91C_CSD_RD_B_LEN_M); - f->WRITE_BL_LEN = ((tab_response[3] >> AT91C_CSD_WBLEN_S) & AT91C_CSD_WBLEN_M ); - f->Max_Read_DataBlock_Length = 1 << f->READ_BL_LEN; - f->Max_Write_DataBlock_Length = 1 << f->WRITE_BL_LEN; - f->Sector_Size = 1 + ((tab_response[2] >> AT91C_CSD_v22_SECT_SIZE_S) & AT91C_CSD_v22_SECT_SIZE_M ); - f->Read_Partial = (tab_response[1] >> AT91C_CSD_RD_B_PAR_S) & AT91C_CSD_RD_B_PAR_M; - f->Write_Partial = (tab_response[3] >> AT91C_CSD_WBLOCK_P_S) & AT91C_CSD_WBLOCK_P_M; + printf("Response is %x %x %x %x\r\n", tab_response[0], + tab_response[1], tab_response[2], tab_response[3]) + f->READ_BL_LEN = ((tab_response[2] >> CSD__RD_B_LEN_S) & CSD__RD_B_LEN_M); + f->WRITE_BL_LEN = ((tab_response[3] >> CSD__WBLEN_S) & CSD__WBLEN_M ); + f->Sector_Size = 1 + ((tab_response[2] >> CSD__v22_SECT_SIZE_S) & CSD__v22_SECT_SIZE_M ); + f->Read_Partial = (tab_response[2] >> CSD__RD_B_PAR_S) & CSD__RD_B_PAR_M; + f->Write_Partial = (tab_response[3] >> CSD__WBLOCK_P_S) & CSD__WBLOCK_P_M; // None in MMC specification version 2.2 f->Erase_Block_Enable = 0; - f->Read_Block_Misalignment = (tab_response[1] >> AT91C_CSD_RD_B_MIS_S) & AT91C_CSD_RD_B_MIS_M; - f->Write_Block_Misalignment = (tab_response[1] >> AT91C_CSD_WR_B_MIS_S) & AT91C_CSD_WR_B_MIS_M; + f->Read_Block_Misalignment = (tab_response[2] >> CSD__RD_B_MIS_S) & CSD__RD_B_MIS_M; + f->Write_Block_Misalignment = (tab_response[2] >> CSD__WR_B_MIS_S) & CSD__WR_B_MIS_M; //// Compute Memory Capacity // compute MULT - mult = 1 << ( ((tab_response[2] >> AT91C_CSD_C_SIZE_M_S) & AT91C_CSD_C_SIZE_M_M) + 2 ); + mult = 1 << ( ((tab_response[2] >> CSD__C_SIZE_M_S) & CSD__C_SIZE_M_M) + 2 ); // compute MSB of C_SIZE - blocknr = ((tab_response[1] >> AT91C_CSD_CSIZE_H_S) & AT91C_CSD_CSIZE_H_M) << 2; + blocknr = ((tab_response[1] >> CSD__CSIZE_H_S) & CSD__CSIZE_H_M) << 2; // compute MULT * (LSB of C-SIZE + MSB already computed + 1) = BLOCKNR - blocknr = mult * ( ( blocknr + ( (tab_response[2] >> AT91C_CSD_CSIZE_L_S) & AT91C_CSD_CSIZE_L_M) ) + 1 ); - f->Memory_Capacity = f->Max_Read_DataBlock_Length * blocknr; + blocknr = mult * ( ( blocknr + ( (tab_response[2] >> CSD__CSIZE_L_S) & CSD__CSIZE_L_M) ) + 1 ); + f->Memory_Capacity = (1 << f->READ_BL_LEN) * blocknr; //// End of Compute Memory Capacity } // XXX warner hacked this @@ -577,40 +583,41 @@ if (AT91F_MCI_GetCSD(f->Relative_Card_Address,tab_response) != AT91C_CMD_SEND_OK) return AT91C_INIT_ERROR; - f->READ_BL_LEN = 1 << ((tab_response[1] >> AT91C_CSD_RD_B_LEN_S) & - AT91C_CSD_RD_B_LEN_M); - f->WRITE_BL_LEN = 1 << ((tab_response[3] >> AT91C_CSD_WBLEN_S) & - AT91C_CSD_WBLEN_M); - f->Max_Read_DataBlock_Length = 1 << f->READ_BL_LEN; - f->Max_Write_DataBlock_Length = 1 << f->WRITE_BL_LEN; - f->Sector_Size = 1 + ((tab_response[2] >> AT91C_CSD_v21_SECT_SIZE_S) & - AT91C_CSD_v21_SECT_SIZE_M); - f->Read_Partial = (tab_response[1] >> AT91C_CSD_RD_B_PAR_S) & - AT91C_CSD_RD_B_PAR_M; - f->Write_Partial = (tab_response[3] >> AT91C_CSD_WBLOCK_P_S) & - AT91C_CSD_WBLOCK_P_M; - f->Erase_Block_Enable = (tab_response[3] >> AT91C_CSD_v21_ER_BLEN_EN_S) & - AT91C_CSD_v21_ER_BLEN_EN_M; - f->Read_Block_Misalignment = (tab_response[1] >> AT91C_CSD_RD_B_MIS_S) & - AT91C_CSD_RD_B_MIS_M; - f->Write_Block_Misalignment = (tab_response[1] >> AT91C_CSD_WR_B_MIS_S) & - AT91C_CSD_WR_B_MIS_M; + printf("Response is %x %x %x %x\r\n", tab_response[0], + tab_response[1], tab_response[2], tab_response[3]); + f->READ_BL_LEN = (tab_response[1] >> CSD_1_RD_B_LEN_S) & + CSD_1_RD_B_LEN_M; + f->WRITE_BL_LEN = (tab_response[3] >> CSD_3_WBLEN_S) & + CSD_3_WBLEN_M; + f->Sector_Size = 1 + ((tab_response[2] >> CSD_2_v21_SECT_SIZE_S) & + CSD_2_v21_SECT_SIZE_M); + f->Read_Partial = (tab_response[1] >> CSD_1_RD_B_PAR_S) & + CSD_1_RD_B_PAR_M; + f->Write_Partial = (tab_response[3] >> CSD_3_WBLOCK_P_S) & + CSD_3_WBLOCK_P_M; + f->Erase_Block_Enable = (tab_response[2] >> CSD_2_v21_ER_BLEN_EN_S) & + CSD_2_v21_ER_BLEN_EN_M; + f->Read_Block_Misalignment = (tab_response[1] >> CSD_1_RD_B_MIS_S) & + CSD_1_RD_B_MIS_M; + f->Write_Block_Misalignment = (tab_response[1] >> CSD_1_WR_B_MIS_S) & + CSD_1_WR_B_MIS_M; //// Compute Memory Capacity // compute MULT - mult = 1 << ( ((tab_response[2] >> AT91C_CSD_C_SIZE_M_S) & - AT91C_CSD_C_SIZE_M_M) + 2 ); + mult = 1 << ( ((tab_response[2] >> CSD_2_C_SIZE_M_S) & + CSD_2_C_SIZE_M_M) + 2 ); // compute MSB of C_SIZE - blocknr = ((tab_response[1] >> AT91C_CSD_CSIZE_H_S) & - AT91C_CSD_CSIZE_H_M) << 2; + blocknr = ((tab_response[1] >> CSD_1_CSIZE_H_S) & + CSD_1_CSIZE_H_M) << 2; // compute MULT * (LSB of C-SIZE + MSB already computed + 1) = BLOCKNR - blocknr = mult * ((blocknr + ((tab_response[2] >> AT91C_CSD_CSIZE_L_S) & - AT91C_CSD_CSIZE_L_M)) + 1); - f->Memory_Capacity = f->Max_Read_DataBlock_Length * blocknr; + blocknr = mult * ((blocknr + ((tab_response[2] >> CSD_2_CSIZE_L_S) & + CSD_2_CSIZE_L_M)) + 1); + f->Memory_Capacity = (1 << f->READ_BL_LEN) * blocknr; //// End of Compute Memory Capacity if (AT91F_MCI_SDCard_SetBusWidth(pMCI_Device) != AT91C_CMD_SEND_OK) return AT91C_INIT_ERROR; - if (AT91F_MCI_SetBlocklength(f->Max_Read_DataBlock_Length) != - AT91C_CMD_SEND_OK) + if (AT91F_MCI_SetBlocklength(1 << f->READ_BL_LEN) != AT91C_CMD_SEND_OK) return AT91C_INIT_ERROR; + printf("Found SD card %u bytes in size %u %u\r\n", f->Memory_Capacity, + blocknr, mult); return AT91C_INIT_OK; } ==== //depot/projects/arm/src/sys/boot/arm/at91/libat91/mci_device.h#5 (text+ko) ==== @@ -99,8 +99,6 @@ unsigned int Relative_Card_Address; // RCA unsigned int READ_BL_LEN; unsigned int WRITE_BL_LEN; - unsigned int Max_Read_DataBlock_Length; // 2^(READ_BL_LEN) in CSD - unsigned int Max_Write_DataBlock_Length; // 2^(WRITE_BL_LEN) in CSD unsigned char Read_Partial; // READ_BL_PARTIAL unsigned char Write_Partial; // WRITE_BL_PARTIAL unsigned char Erase_Block_Enable; // ERASE_BLK_EN @@ -308,99 +306,99 @@ ///////////////////////////////////////////////////////////////////////////////////////////////////// // MMC CSD register header File -// AT91C_CSD_xxx_S for shift value -// AT91C_CSD_xxx_M for mask value +// CSD_x_xxx_S for shift value for word x +// CSD_x_xxx_M for mask value for word x ///////////////////////////////////////////////////////////////////////////////////////////////////// // First Response INT <=> CSD[3] : bits 0 to 31 -#define AT91C_CSD_BIT0_S 0 // [0:0] -#define AT91C_CSD_BIT0_M 0x01 -#define AT91C_CSD_CRC_S 1 // [7:1] -#define AT91C_CSD_CRC_M 0x7F -#define AT91C_CSD_MMC_ECC_S 8 // [9:8] reserved for MMC compatibility -#define AT91C_CSD_MMC_ECC_M 0x03 -#define AT91C_CSD_FILE_FMT_S 10 // [11:10] -#define AT91C_CSD_FILE_FMT_M 0x03 -#define AT91C_CSD_TMP_WP_S 12 // [12:12] -#define AT91C_CSD_TMP_WP_M 0x01 -#define AT91C_CSD_PERM_WP_S 13 // [13:13] -#define AT91C_CSD_PERM_WP_M 0x01 -#define AT91C_CSD_COPY_S 14 // [14:14] -#define AT91C_CSD_COPY_M 0x01 -#define AT91C_CSD_FILE_FMT_GRP_S 15 // [15:15] -#define AT91C_CSD_FILE_FMT_GRP_M 0x01 +#define CSD_3_BIT0_S 0 // [0:0] +#define CSD_3_BIT0_M 0x01 +#define CSD_3_CRC_S 1 // [7:1] +#define CSD_3_CRC_M 0x7F +#define CSD_3_MMC_ECC_S 8 // [9:8] reserved for MMC compatibility +#define CSD_3_MMC_ECC_M 0x03 +#define CSD_3_FILE_FMT_S 10 // [11:10] +#define CSD_3_FILE_FMT_M 0x03 +#define CSD_3_TMP_WP_S 12 // [12:12] +#define CSD_3_TMP_WP_M 0x01 +#define CSD_3_PERM_WP_S 13 // [13:13] +#define CSD_3_PERM_WP_M 0x01 +#define CSD_3_COPY_S 14 // [14:14] +#define CSD_3_COPY_M 0x01 +#define CSD_3_FILE_FMT_GRP_S 15 // [15:15] +#define CSD_3_FILE_FMT_GRP_M 0x01 // reserved 16 // [20:16] // reserved 0x1F -#define AT91C_CSD_WBLOCK_P_S 21 // [21:21] -#define AT91C_CSD_WBLOCK_P_M 0x01 -#define AT91C_CSD_WBLEN_S 22 // [25:22] -#define AT91C_CSD_WBLEN_M 0x0F -#define AT91C_CSD_R2W_F_S 26 // [28:26] -#define AT91C_CSD_R2W_F_M 0x07 -#define AT91C_CSD_MMC_DEF_ECC_S 29 // [30:29] reserved for MMC compatibility -#define AT91C_CSD_MMC_DEF_ECC_M 0x03 -#define AT91C_CSD_WP_GRP_EN_S 31 // [31:31] -#define AT91C_CSD_WP_GRP_EN_M 0x01 +#define CSD_3_WBLOCK_P_S 21 // [21:21] +#define CSD_3_WBLOCK_P_M 0x01 +#define CSD_3_WBLEN_S 22 // [25:22] +#define CSD_3_WBLEN_M 0x0F +#define CSD_3_R2W_F_S 26 // [28:26] +#define CSD_3_R2W_F_M 0x07 +#define CSD_3_MMC_DEF_ECC_S 29 // [30:29] reserved for MMC compatibility +#define CSD_3_MMC_DEF_ECC_M 0x03 +#define CSD_3_WP_GRP_EN_S 31 // [31:31] +#define CSD_3_WP_GRP_EN_M 0x01 // Seconde Response INT <=> CSD[2] : bits 32 to 63 -#define AT91C_CSD_v21_WP_GRP_SIZE_S 0 // [38:32] -#define AT91C_CSD_v21_WP_GRP_SIZE_M 0x7F -#define AT91C_CSD_v21_SECT_SIZE_S 7 // [45:39] -#define AT91C_CSD_v21_SECT_SIZE_M 0x7F -#define AT91C_CSD_v21_ER_BLEN_EN_S 14 // [46:46] -#define AT91C_CSD_v21_ER_BLEN_EN_M 0x01 +#define CSD_2_v21_WP_GRP_SIZE_S 0 // [38:32] +#define CSD_2_v21_WP_GRP_SIZE_M 0x7F +#define CSD_2_v21_SECT_SIZE_S 7 // [45:39] +#define CSD_2_v21_SECT_SIZE_M 0x7F +#define CSD_2_v21_ER_BLEN_EN_S 14 // [46:46] +#define CSD_2_v21_ER_BLEN_EN_M 0x01 -#define AT91C_CSD_v22_WP_GRP_SIZE_S 0 // [36:32] -#define AT91C_CSD_v22_WP_GRP_SIZE_M 0x1F -#define AT91C_CSD_v22_ER_GRP_SIZE_S 5 // [41:37] -#define AT91C_CSD_v22_ER_GRP_SIZE_M 0x1F -#define AT91C_CSD_v22_SECT_SIZE_S 10 // [46:42] -#define AT91C_CSD_v22_SECT_SIZE_M 0x1F +#define CSD_2_v22_WP_GRP_SIZE_S 0 // [36:32] +#define CSD_2_v22_WP_GRP_SIZE_M 0x1F +#define CSD_2_v22_ER_GRP_SIZE_S 5 // [41:37] +#define CSD_2_v22_ER_GRP_SIZE_M 0x1F +#define CSD_2_v22_SECT_SIZE_S 10 // [46:42] +#define CSD_2_v22_SECT_SIZE_M 0x1F -#define AT91C_CSD_C_SIZE_M_S 15 // [49:47] -#define AT91C_CSD_C_SIZE_M_M 0x07 -#define AT91C_CSD_VDD_WMAX_S 18 // [52:50] -#define AT91C_CSD_VDD_WMAX_M 0x07 -#define AT91C_CSD_VDD_WMIN_S 21 // [55:53] -#define AT91C_CSD_VDD_WMIN_M 0x07 -#define AT91C_CSD_RCUR_MAX_S 24 // [58:56] -#define AT91C_CSD_RCUR_MAX_M 0x07 -#define AT91C_CSD_RCUR_MIN_S 27 // [61:59] -#define AT91C_CSD_RCUR_MIN_M 0x07 -#define AT91C_CSD_CSIZE_L_S 30 // [63:62] <=> 2 LSB of CSIZE -#define AT91C_CSD_CSIZE_L_M 0x03 +#define CSD_2_C_SIZE_M_S 15 // [49:47] +#define CSD_2_C_SIZE_M_M 0x07 +#define CSD_2_VDD_WMAX_S 18 // [52:50] +#define CSD_2_VDD_WMAX_M 0x07 +#define CSD_2_VDD_WMIN_S 21 // [55:53] +#define CSD_2_VDD_WMIN_M 0x07 +#define CSD_2_RCUR_MAX_S 24 // [58:56] +#define CSD_2_RCUR_MAX_M 0x07 +#define CSD_2_RCUR_MIN_S 27 // [61:59] +#define CSD_2_RCUR_MIN_M 0x07 +#define CSD_2_CSIZE_L_S 30 // [63:62] <=> 2 LSB of CSIZE +#define CSD_2_CSIZE_L_M 0x03 // Third Response INT <=> CSD[1] : bits 64 to 95 -#define AT91C_CSD_CSIZE_H_S 0 // [73:64] <=> 10 MSB of CSIZE -#define AT91C_CSD_CSIZE_H_M 0x03FF +#define CSD_1_CSIZE_H_S 0 // [73:64] <=> 10 MSB of CSIZE +#define CSD_1_CSIZE_H_M 0x03FF // reserved 10 // [75:74] // reserved 0x03 -#define AT91C_CSD_DSR_I_S 12 // [76:76] -#define AT91C_CSD_DSR_I_M 0x01 -#define AT91C_CSD_RD_B_MIS_S 13 // [77:77] -#define AT91C_CSD_RD_B_MIS_M 0x01 -#define AT91C_CSD_WR_B_MIS_S 14 // [78:78] -#define AT91C_CSD_WR_B_MIS_M 0x01 -#define AT91C_CSD_RD_B_PAR_S 15 // [79:79] -#define AT91C_CSD_RD_B_PAR_M 0x01 -#define AT91C_CSD_RD_B_LEN_S 16 // [83:80] -#define AT91C_CSD_RD_B_LEN_M 0x0F -#define AT91C_CSD_CCC_S 20 // [95:84] -#define AT91C_CSD_CCC_M 0x0FFF +#define CSD_1_DSR_I_S 12 // [76:76] +#define CSD_1_DSR_I_M 0x01 +#define CSD_1_RD_B_MIS_S 13 // [77:77] +#define CSD_1_RD_B_MIS_M 0x01 +#define CSD_1_WR_B_MIS_S 14 // [78:78] +#define CSD_1_WR_B_MIS_M 0x01 +#define CSD_1_RD_B_PAR_S 15 // [79:79] +#define CSD_1_RD_B_PAR_M 0x01 +#define CSD_1_RD_B_LEN_S 16 // [83:80] +#define CSD_1_RD_B_LEN_M 0x0F +#define CSD_1_CCC_S 20 // [95:84] +#define CSD_1_CCC_M 0x0FFF // Fourth Response INT <=> CSD[0] : bits 96 to 127 -#define AT91C_CSD_TRANS_SPEED_S 0 // [103:96] -#define AT91C_CSD_TRANS_SPEED_M 0xFF -#define AT91C_CSD_NSAC_S 8 // [111:104] -#define AT91C_CSD_NSAC_M 0xFF -#define AT91C_CSD_TAAC_S 16 // [119:112] -#define AT91C_CSD_TAAC_M 0xFF +#define CSD_0_TRANS_SPEED_S 0 // [103:96] +#define CSD_0_TRANS_SPEED_M 0xFF +#define CSD_0_NSAC_S 8 // [111:104] +#define CSD_0_NSAC_M 0xFF +#define CSD_0_TAAC_S 16 // [119:112] +#define CSD_0_TAAC_M 0xFF // reserved 24 // [121:120] // reserved 0x03 -#define AT91C_CSD_MMC_SPEC_VERS_S 26 // [125:122] reserved for MMC compatibility -#define AT91C_CSD_MMC_SPEC_VERS_M 0x0F -#define AT91C_CSD_STRUCT_S 30 // [127:126] -#define AT91C_CSD_STRUCT_M 0x03 +#define CSD_0_MMC_SPEC_VERS_S 26 // [125:122] reserved for MMC compatibility +#define CSD_0_MMC_SPEC_VERS_M 0x0F +#define CSD_0_STRUCT_S 30 // [127:126] +#define CSD_0_STRUCT_M 0x03 ///////////////////////////////////////////////////////////////////////////////////////////////////// ==== //depot/projects/arm/src/sys/boot/arm/at91/libat91/printf.c#4 (text+ko) ==== @@ -42,6 +42,7 @@ for (s = va_arg(ap, char *); *s; s++) putchar(*s); continue; + case 'd': /* A lie, always prints unsigned */ case 'u': u = va_arg(ap, unsigned); s = buf; ==== //depot/projects/arm/src/sys/boot/arm/at91/libat91/sd-card.c#5 (text+ko) ==== @@ -47,6 +47,8 @@ #include "lib.h" #include "sd-card.h" +#define IMP_DEBUG 1 + #define AT91C_MCI_TIMEOUT 1000000 /* For AT91F_MCIDeviceWaitReady */ #define BUFFER_SIZE_MCI_DEVICE 512 #define MASTER_CLOCK 60000000 @@ -96,7 +98,7 @@ int MCI_write (unsigned dest, char* source, unsigned length) { - unsigned sectorLength = MCI_Device.pMCI_DeviceFeatures->Max_Read_DataBlock_Lenfgth; + unsigned sectorLength = 1 << MCI_Device.pMCI_DeviceFeatures->WRITE_BL_LEN; unsigned offset = dest % sectorLength; AT91S_MCIDeviceStatus status; int sizeToWrite; @@ -169,15 +171,16 @@ int MCI_read(char* dest, unsigned source, unsigned length) { - unsigned sectorLength = MCI_Device.pMCI_DeviceFeatures->Max_Read_DataBlock_Length; unsigned log2sl = MCI_Device.pMCI_DeviceFeatures->READ_BL_LEN; - unsigned slmask = ((1 << log2sl) - 1); + unsigned sectorLength = 1 << log2sl; + unsigned slmask = sectorLength - 1; // unsigned sector = (unsigned)source >> log2sl; unsigned offset = (unsigned)source & slmask; AT91S_MCIDeviceStatus status; int sizeToRead; unsigned int *walker; + printf("sector length is %d\r\n", sectorLength); #if IMP_DEBUG printf("Reading 0x%x bytes into ARM Addr 0x%x from card offset 0x%x\r\n", length, dest, source); @@ -279,8 +282,8 @@ MCI_Device_Features.Relative_Card_Address = 0; MCI_Device_Features.Card_Inserted = AT91C_SD_CARD_INSERTED; - MCI_Device_Features.Max_Read_DataBlock_Length = 0; - MCI_Device_Features.Max_Write_DataBlock_Length = 0; + MCI_Device_Features.READ_BL_LEN = 0; + MCI_Device_Features.WRITE_BL_LEN = 0; MCI_Device_Features.Read_Partial = 0; MCI_Device_Features.Write_Partial = 0; MCI_Device_Features.Erase_Block_Enable = 0;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200608212209.k7LM9xG7055676>