Changeset 3c743901 in rtems


Ignore:
Timestamp:
Oct 13, 2014, 6:20:35 PM (5 years ago)
Author:
Joel Sherrill <joel.sherrill@…>
Branches:
4.11, master
Children:
6da91abb
Parents:
57e8a0d
git-author:
Joel Sherrill <joel.sherrill@…> (10/13/14 18:20:35)
git-committer:
Joel Sherrill <joel.sherrill@…> (10/16/14 13:58:45)
Message:

arm/gp32/smc/smc.c: Remove unused sm_ECCEncode() and sm_status()

File:
1 edited

Legend:

Unmodified
Added
Removed
  • c/src/lib/libbsp/arm/gp32/smc/smc.c

    r57e8a0d r3c743901  
    103103  return data;
    104104}
    105 
    106 
    107 /* assumes chip enabled
    108    bit 7: write protected = 0, write enabled = 1
    109    bit 6: busy = 0, ready = 1
    110    bit 0: success = 0, failed = 1
    111 
    112    returns 1 on success, 0 on fail
    113 */
    114 #if UNUSED
    115 static static uint8_t sm_status()
    116 {
    117   uint8_t status;
    118 
    119   sm_cle_en();
    120   sm_write_en();
    121   sm_write(READ_STATUS_CMD);
    122   sm_write_dis();
    123   sm_cle_dis();
    124 
    125   sm_read_en();
    126   status = sm_read();
    127   sm_read_dis();
    128 
    129   if (status == 0xC0)
    130     return 1;
    131   else
    132     return 0;
    133 }
    134 #endif
    135105
    136106static void smc_read_id( uint8_t* buf, uint32_t length)
     
    335305}
    336306
    337 /**********
    338  * Function: sm_ECCEncode (completely ripped, unaltered, from the samsung routines)
    339  * Remark:
    340  *  - adopted from "ECC Algorithm for SmartMedia V3.0"
    341  *    by Memory Product & Technology, Samsung Electronics Co. (ecc30.pdf)
    342  **********/
    343 int sm_ECCEncode(const uint8_t * p_buf, uint8_t * p_ecc)
    344 {
    345   uint32_t i, j;
    346   uint8_t paritr[256], tmp = 0, tmp2 = 0;
    347   uint8_t data_table0[16] = { 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0 };
    348   uint8_t data_table1[16] = { 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1 };
    349   uint8_t sum = 0, paritc = 0;
    350   uint8_t parit0c = 0, parit1c = 0, parit2c = 0, parit3c = 0;
    351   uint8_t parit4c = 0, parit5c = 0, parit6c = 0, parit7c = 0;
    352   uint8_t parit1_1, parit1_2, parit2_1, parit2_2, parit4_1, parit4_2;
    353   uint8_t parit8_1 = 0, parit8_2 = 0, parit16_1 = 0, parit16_2 = 0, parit32_1 = 0, parit32_2 = 0;
    354   uint8_t parit64_1 = 0, parit64_2 = 0, parit128_1 = 0, parit128_2 = 0, parit256_1 = 0, parit256_2 = 0;
    355   uint8_t parit512_1 = 0, parit512_2 = 0, parit1024_1 = 0, parit1024_2 = 0;
    356   uint8_t* paritr_ptr;
    357 
    358   paritr_ptr = paritr;
    359   for (i = 0; i < 256; ++i, ++paritr_ptr, ++p_buf) {
    360     paritc ^= *p_buf;
    361     tmp = (*p_buf & 0xf0) >> 4;
    362     tmp2 = *p_buf & 0x0f;
    363 
    364     switch (tmp) {
    365       case 0:
    366       case 3:
    367       case 5:
    368       case 6:
    369       case 9:
    370       case 10:
    371       case 12:
    372       case 15:
    373         *paritr_ptr = *(data_table0 + tmp2);
    374         break;
    375 
    376       case 1:
    377       case 2:
    378       case 4:
    379       case 7:
    380       case 8:
    381       case 11:
    382       case 13:
    383       case 14:
    384         *paritr_ptr = *(data_table1 + tmp2);
    385         break;
    386     }
    387   }
    388 
    389   parit0c = (paritc & 0x01) ? 1 : 0;
    390   parit1c = (paritc & 0x02) ? 1 : 0;
    391   parit2c = (paritc & 0x04) ? 1 : 0;
    392   parit3c = (paritc & 0x08) ? 1 : 0;
    393   parit4c = (paritc & 0x10) ? 1 : 0;
    394   parit5c = (paritc & 0x20) ? 1 : 0;
    395   parit6c = (paritc & 0x40) ? 1 : 0;
    396   parit7c = (paritc & 0x80) ? 1 : 0;
    397   parit1_2 = parit6c ^ parit4c ^ parit2c ^ parit0c;
    398   parit1_1 = parit7c ^ parit5c ^ parit3c ^ parit1c;
    399   parit2_2 = parit5c ^ parit4c ^ parit1c ^ parit0c;
    400   parit2_1 = parit7c ^ parit6c ^ parit3c ^ parit2c;
    401   parit4_2 = parit3c ^ parit2c ^ parit1c ^ parit0c;
    402   parit4_1 = parit7c ^ parit6c ^ parit5c ^ parit4c;
    403 
    404   paritr_ptr = paritr;
    405   for (i = 0; i < 256; ++i, ++paritr_ptr) {
    406     sum ^= *paritr_ptr;
    407   }
    408 
    409   paritr_ptr = paritr;
    410   for (i = 0; i < 256; i += 2, paritr_ptr += 2) {
    411     parit8_2 ^= *paritr_ptr;
    412   }
    413 
    414   paritr_ptr = paritr;
    415   for (i = 0; i < 256; i += 4, paritr_ptr += 4) {
    416     parit16_2 ^= *paritr_ptr;
    417     parit16_2 ^= *(paritr_ptr + 1);
    418   }
    419 
    420   paritr_ptr = paritr;
    421   for (i = 0; i < 256; i += 8, paritr_ptr += 8) {
    422     for (j = 0; j <= 3; ++j) {
    423       parit32_2 ^= *(paritr_ptr + j);
    424     }
    425   }
    426 
    427   paritr_ptr = paritr;
    428   for (i = 0; i < 256; i += 16, paritr_ptr += 16) {
    429     for (j = 0; j <= 7; ++j) {
    430       parit64_2 ^= *(paritr_ptr + j);
    431     }
    432   }
    433 
    434   paritr_ptr = paritr;
    435   for (i = 0; i < 256; i += 32, paritr_ptr += 32) {
    436     for (j = 0; j <= 15; ++j) {
    437       parit128_2 ^= *(paritr_ptr + j);
    438     }
    439   }
    440 
    441   paritr_ptr = paritr;
    442   for (i = 0; i < 256; i += 64, paritr_ptr += 64) {
    443     for (j = 0; j <= 31; ++j) {
    444       parit256_2 ^= *(paritr_ptr + j);
    445     }
    446   }
    447 
    448   paritr_ptr = paritr;
    449   for (i = 0; i < 256; i += 128, paritr_ptr += 128) {
    450     for (j = 0; j <= 63; ++j) {
    451       parit512_2 ^= *(paritr_ptr + j);
    452     }
    453   }
    454 
    455   paritr_ptr = paritr;
    456   for (i = 0; i < 256; i += 256, paritr_ptr += 256) {
    457     for (j = 0; j <= 127; ++j) {
    458       parit1024_2 ^= *(paritr_ptr + j);
    459     }
    460   }
    461 
    462   if (sum==0) {
    463     parit1024_1 = parit1024_2;
    464     parit512_1 = parit512_2;
    465     parit256_1 = parit256_2;
    466     parit128_1 = parit128_2;
    467     parit64_1 = parit64_2;
    468     parit32_1 = parit32_2;
    469     parit16_1 = parit16_2;
    470     parit8_1 = parit8_2;
    471   } else {
    472     parit1024_1 = parit1024_2 ? 0 : 1;
    473     parit512_1 = parit512_2 ? 0 : 1;
    474     parit256_1 = parit256_2 ? 0 : 1;
    475     parit128_1 = parit128_2 ? 0 : 1;
    476     parit64_1 = parit64_2 ? 0 : 1;
    477     parit32_1 = parit32_2 ? 0 : 1;
    478     parit16_1 = parit16_2 ? 0 : 1;
    479     parit8_1 = parit8_2 ? 0 : 1;
    480   }
    481 
    482   parit1_2 <<= 2;
    483   parit1_1 <<= 3;
    484   parit2_2 <<= 4;
    485   parit2_1 <<= 5;
    486   parit4_2 <<= 6;
    487   parit4_1 <<= 7;
    488   parit128_1 <<= 1;
    489   parit256_2 <<= 2;
    490   parit256_1 <<= 3;
    491   parit512_2 <<= 4;
    492   parit512_1 <<= 5;
    493   parit1024_2 <<= 6;
    494   parit1024_1 <<= 7;
    495   parit8_1 <<= 1;
    496   parit16_2 <<= 2;
    497   parit16_1 <<= 3;
    498   parit32_2 <<= 4;
    499   parit32_1 <<= 5;
    500   parit64_2 <<= 6;
    501   parit64_1 <<= 7;
    502 
    503   p_ecc[0] = ~(parit64_1 | parit64_2 | parit32_1 | parit32_2 | parit16_1 | parit16_2 | parit8_1 | parit8_2);
    504   p_ecc[1] = ~(parit1024_1 |parit1024_2 | parit512_1 | parit512_2 | parit256_1 | parit256_2 | parit128_1 | parit128_2);
    505   p_ecc[2] = ~(parit4_1 | parit4_2 | parit2_1 | parit2_2 | parit1_1 | parit1_2);
    506 
    507   return 0;
    508 }
    509 
    510307/* smc_write --
    511308 * write stub
    512 */
     309 */
    513310static int smc_write(rtems_blkdev_request *req)
    514311{
Note: See TracChangeset for help on using the changeset viewer.