Changeset f049983 in rtems for c/src/libchip


Ignore:
Timestamp:
Oct 10, 2008, 3:52:41 PM (11 years ago)
Author:
Thomas Doerfler <Thomas.Doerfler@…>
Branches:
4.10, 4.11, master
Children:
06c3530
Parents:
da6142f
Message:

Update for status-checks.h changes.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • c/src/libchip/i2c/spi-sd-card.c

    rda6142f rf049983  
    309309                /* Query busy tokens */
    310310                rv = sd_card_query( e, e->response, n);
    311                 CHECK_RV( rv, "Busy");
     311                RTEMS_CHECK_RV( rv, "Busy");
    312312
    313313                /* Search for non busy tokens */
     
    342342        /* Wait until card is not busy */
    343343        rv = sd_card_wait( e);
    344         CHECK_RV( rv, "Wait");
     344        RTEMS_CHECK_RV( rv, "Wait");
    345345
    346346        /* Write command and read response */
     
    348348        SD_CARD_COMMAND_SET_ARGUMENT( e->command, argument);
    349349        rv = rtems_libi2c_ioctl( e->minor, RTEMS_LIBI2C_IOCTL_READ_WRITE, &rw);
    350         CHECK_RV( rv, "Write command and read response");
     350        RTEMS_CHECK_RV( rv, "Write command and read response");
    351351
    352352        /* Check respose */
    353353        for (r = SD_CARD_COMMAND_RESPONSE_START; r < SD_CARD_COMMAND_SIZE; ++r) {
    354                 DEBUG_PRINT( "Token [%02u]: 0x%02x\n", r, e->response [r]);
     354                RTEMS_DEBUG_PRINT( "Token [%02u]: 0x%02x\n", r, e->response [r]);
    355355                e->response_index = r;
    356356                if (SD_CARD_IS_RESPONSE( e->response [r])) {
     
    358358                                return 0;
    359359                        } else {
    360                                 SYSLOG_ERROR( "Command error [%02i]: 0x%02" PRIx8 "\n", r, e->response [r]);
     360                                RTEMS_SYSLOG_ERROR( "Command error [%02i]: 0x%02" PRIx8 "\n", r, e->response [r]);
    361361                                goto sd_card_send_command_error;
    362362                        }
    363363                } else if (e->response [r] != SD_CARD_IDLE_TOKEN) {
    364                         SYSLOG_ERROR( "Unexpected token [%02i]: 0x%02" PRIx8 "\n", r, e->response [r]);
     364                        RTEMS_SYSLOG_ERROR( "Unexpected token [%02i]: 0x%02" PRIx8 "\n", r, e->response [r]);
    365365                        goto sd_card_send_command_error;
    366366                }
    367367        }
    368368
    369         SYSLOG_ERROR( "Timeout\n");
     369        RTEMS_SYSLOG_ERROR( "Timeout\n");
    370370
    371371sd_card_send_command_error:
    372372
    373         SYSLOG_ERROR( "Response:");
     373        RTEMS_SYSLOG_ERROR( "Response:");
    374374        for (r = 0; r < SD_CARD_COMMAND_SIZE; ++r) {
    375375                if (e->response_index == r) {
    376                         SYSLOG_PRINT( " %02" PRIx8 ":[%02" PRIx8 "]", e->command [r], e->response [r]);
     376                        RTEMS_SYSLOG_PRINT( " %02" PRIx8 ":[%02" PRIx8 "]", e->command [r], e->response [r]);
    377377                } else {
    378                         SYSLOG_PRINT( " %02" PRIx8 ":%02" PRIx8 "", e->command [r], e->response [r]);
     378                        RTEMS_SYSLOG_PRINT( " %02" PRIx8 ":%02" PRIx8 "", e->command [r], e->response [r]);
    379379                }
    380380        }
    381         SYSLOG_PRINT( "\n");
     381        RTEMS_SYSLOG_PRINT( "\n");
    382382
    383383        return -RTEMS_IO_ERROR;
     
    390390        SD_CARD_COMMAND_SET_COMMAND( e->command, SD_CARD_CMD_STOP_TRANSMISSION);
    391391        rv = rtems_libi2c_write_bytes( e->minor, e->command, SD_CARD_COMMAND_SIZE);
    392         CHECK_RV( rv, "Write stop transfer token");
     392        RTEMS_CHECK_RV( rv, "Write stop transfer token");
    393393
    394394        return 0;
     
    402402        /* Wait until card is not busy */
    403403        rv = sd_card_wait( e);
    404         CHECK_RV( rv, "Wait");
     404        RTEMS_CHECK_RV( rv, "Wait");
    405405
    406406        /* Send stop token */
    407407        rv = rtems_libi2c_write_bytes( e->minor, stop_transfer, 3);
    408         CHECK_RV( rv, "Write stop transfer token");
     408        RTEMS_CHECK_RV( rv, "Write stop transfer token");
    409409
    410410        /* Card is now busy */
     
    436436
    437437        while (1) {
    438                 DEBUG_PRINT( "Search from %u to %u\n", r, response_size - 1);
     438                RTEMS_DEBUG_PRINT( "Search from %u to %u\n", r, response_size - 1);
    439439
    440440                /* Search the data start token in in current response buffer */
    441441                while (r < response_size) {
    442                         DEBUG_PRINT( "Token [%02u]: 0x%02x\n", r, e->response [r]);
     442                        RTEMS_DEBUG_PRINT( "Token [%02u]: 0x%02x\n", r, e->response [r]);
    443443                        if (n_ac > e->n_ac_max) {
    444                                 SYSLOG_ERROR( "Timeout\n");
     444                                RTEMS_SYSLOG_ERROR( "Timeout\n");
    445445                                return -RTEMS_IO_ERROR;
    446446                        } else if (e->response [r] == start_token) {
     
    449449                                goto sd_card_read_start;
    450450                        } else if (SD_CARD_IS_DATA_ERROR( e->response [r])) {
    451                                 SYSLOG_ERROR( "Data error token [%02i]: 0x%02" PRIx8 "\n", r, e->response [r]);
     451                                RTEMS_SYSLOG_ERROR( "Data error token [%02i]: 0x%02" PRIx8 "\n", r, e->response [r]);
    452452                                return -RTEMS_IO_ERROR;
    453453                        } else if (e->response [r] != SD_CARD_IDLE_TOKEN) {
    454                                 SYSLOG_ERROR( "Unexpected token [%02i]: 0x%02" PRIx8 "\n", r, e->response [r]);
     454                                RTEMS_SYSLOG_ERROR( "Unexpected token [%02i]: 0x%02" PRIx8 "\n", r, e->response [r]);
    455455                                return -RTEMS_IO_ERROR;
    456456                        }
     
    461461                /* Query more */
    462462                rv = sd_card_query( e, e->response, next_response_size);
    463                 CHECK_RV( rv, "Query data start token");
     463                RTEMS_CHECK_RV( rv, "Query data start token");
    464464
    465465                /* Set standard query size */
     
    481481        if (i < n) {
    482482                rv = sd_card_query( e, &in [i], n - i);
    483                 CHECK_RV( rv, "Read data");
     483                RTEMS_CHECK_RV( rv, "Read data");
    484484                i += rv;
    485485        }
     
    487487        /* Read CRC 16 and N_RC */
    488488        rv = sd_card_query( e, e->response, 3);
    489         CHECK_RV( rv, "Read CRC 16");
     489        RTEMS_CHECK_RV( rv, "Read CRC 16");
    490490
    491491        return i;
     
    502502        /* Wait until card is not busy */
    503503        rv = sd_card_wait( e);
    504         CHECK_RV( rv, "Wait");
     504        RTEMS_CHECK_RV( rv, "Wait");
    505505
    506506        /* Write data start token */
    507507        rv = rtems_libi2c_write_bytes( e->minor, &start_token, 1);
    508         CHECK_RV( rv, "Write data start token");
     508        RTEMS_CHECK_RV( rv, "Write data start token");
    509509
    510510        /* Write data */
    511511        o = rtems_libi2c_write_bytes( e->minor, out, n);
    512         CHECK_RV( o, "Write data");
     512        RTEMS_CHECK_RV( o, "Write data");
    513513
    514514        /* Write CRC 16 */
    515515        rv = rtems_libi2c_write_bytes( e->minor, crc16, 2);
    516         CHECK_RV( rv, "Write CRC 16");
     516        RTEMS_CHECK_RV( rv, "Write CRC 16");
    517517
    518518        /* Read data response */
    519519        rv = sd_card_query( e, e->response, 2);
    520         CHECK_RV( rv, "Read data response");
     520        RTEMS_CHECK_RV( rv, "Read data response");
    521521        if (SD_CARD_IS_DATA_REJECTED( e->response [0])) {
    522                 SYSLOG_ERROR( "Data rejected: 0x%02" PRIx8 "\n", e->response [0]);
     522                RTEMS_SYSLOG_ERROR( "Data rejected: 0x%02" PRIx8 "\n", e->response [0]);
    523523                return -RTEMS_IO_ERROR;
    524524        }
     
    536536
    537537        sc = rtems_libi2c_send_start( e->minor);
    538         CHECK_SC( sc, "Send start");
     538        RTEMS_CHECK_SC( sc, "Send start");
    539539
    540540        rv = rtems_libi2c_ioctl( e->minor, RTEMS_LIBI2C_IOCTL_SET_TFRMODE, &e->transfer_mode);
    541         CHECK_RVSC( rv, "Set transfer mode");
     541        RTEMS_CHECK_RV_SC( rv, "Set transfer mode");
    542542
    543543        sc = rtems_libi2c_send_addr( e->minor, 1);
    544         CHECK_SC( sc, "Send address");
     544        RTEMS_CHECK_SC( sc, "Send address");
    545545
    546546        return RTEMS_SUCCESSFUL;
     
    552552
    553553        sc = rtems_libi2c_send_stop( e->minor);
    554         CHECK_SC( sc, "Send stop");
     554        RTEMS_CHECK_SC( sc, "Send stop");
    555555
    556556        return RTEMS_SUCCESSFUL;
     
    570570        uint32_t i = 0;
    571571
    572         DEBUG_PRINT( "start = %u, bufnum = %u\n", r->start, r->bufnum);
     572        RTEMS_DEBUG_PRINT( "start = %u, bufnum = %u\n", r->start, r->bufnum);
    573573
    574574#ifdef DEBUG
    575575        /* Check request */
    576576  if (r->bufs[0].block >= e->block_number) {
    577                 SYSLOG_ERROR( "Start block number out of range");
     577                RTEMS_SYSLOG_ERROR( "Start block number out of range");
    578578                return -RTEMS_INTERNAL_ERROR;
    579579        } else if (r->bufnum > e->block_number - RTEMS_BLKDEV_START_BLOCK (r)) {
    580                 SYSLOG_ERROR( "Block count out of range");
     580                RTEMS_SYSLOG_ERROR( "Block count out of range");
    581581                return -RTEMS_INTERNAL_ERROR;
    582582        }
     
    585585        /* Start */
    586586        sc = sd_card_start( e);
    587         CLEANUP_SCRV( sc, rv, sd_card_disk_block_read_cleanup, "Start");
     587        RTEMS_CLEANUP_SC_RV( sc, rv, sd_card_disk_block_read_cleanup, "Start");
    588588
    589589        if (r->bufnum == 1) {
     
    591591                /* Check buffer */
    592592                if (r->bufs [0].length != e->block_size) {
    593                         DO_CLEANUP_RV( -RTEMS_INTERNAL_ERROR, rv, sd_card_disk_block_read_cleanup, "Buffer and disk block size are not equal");
     593                        RTEMS_DO_CLEANUP_RV( -RTEMS_INTERNAL_ERROR, rv, sd_card_disk_block_read_cleanup, "Buffer and disk block size are not equal");
    594594                }
    595                 DEBUG_PRINT( "[%02u]: buffer = 0x%08x, size = %u\n", 0, r->bufs [0].buffer, r->bufs [0].length);
     595                RTEMS_DEBUG_PRINT( "[%02u]: buffer = 0x%08x, size = %u\n", 0, r->bufs [0].buffer, r->bufs [0].length);
    596596#endif /* DEBUG */
    597597
    598598                /* Single block read */
    599599                rv = sd_card_send_command( e, SD_CARD_CMD_READ_SINGLE_BLOCK, start_address);
    600                 CLEANUP_RV( rv, sd_card_disk_block_read_cleanup, "Send: SD_CARD_CMD_READ_SINGLE_BLOCK");
     600                RTEMS_CLEANUP_RV( rv, sd_card_disk_block_read_cleanup, "Send: SD_CARD_CMD_READ_SINGLE_BLOCK");
    601601                rv = sd_card_read( e, SD_CARD_START_BLOCK_SINGLE_BLOCK_READ, (uint8_t *) r->bufs [0].buffer, (int) e->block_size);
    602                 CLEANUP_RV( rv, sd_card_disk_block_read_cleanup, "Read: SD_CARD_CMD_READ_SINGLE_BLOCK");
     602                RTEMS_CLEANUP_RV( rv, sd_card_disk_block_read_cleanup, "Read: SD_CARD_CMD_READ_SINGLE_BLOCK");
    603603        } else {
    604604                /* Start multiple block read */
    605605                rv = sd_card_send_command( e, SD_CARD_CMD_READ_MULTIPLE_BLOCK, start_address);
    606                 CLEANUP_RV( rv, sd_card_disk_block_read_stop_cleanup, "Send: SD_CARD_CMD_READ_MULTIPLE_BLOCK");
     606                RTEMS_CLEANUP_RV( rv, sd_card_disk_block_read_stop_cleanup, "Send: SD_CARD_CMD_READ_MULTIPLE_BLOCK");
    607607
    608608                /* Multiple block read */
     
    611611                        /* Check buffer */
    612612                        if (r->bufs [i].length != e->block_size) {
    613                                 DO_CLEANUP_RV( -RTEMS_INTERNAL_ERROR, rv, sd_card_disk_block_read_stop_cleanup, "Buffer and disk block size are not equal");
     613                                RTEMS_DO_CLEANUP_RV( -RTEMS_INTERNAL_ERROR, rv, sd_card_disk_block_read_stop_cleanup, "Buffer and disk block size are not equal");
    614614                        }
    615                         DEBUG_PRINT( "[%02u]: buffer = 0x%08x, size = %u\n", i, r->bufs [i].buffer, r->bufs [i].length);
     615                        RTEMS_DEBUG_PRINT( "[%02u]: buffer = 0x%08x, size = %u\n", i, r->bufs [i].buffer, r->bufs [i].length);
    616616#endif /* DEBUG */
    617617
    618618                        rv = sd_card_read( e, SD_CARD_START_BLOCK_MULTIPLE_BLOCK_READ, (uint8_t *) r->bufs [i].buffer, (int) e->block_size);
    619                         CLEANUP_RV( rv, sd_card_disk_block_read_stop_cleanup, "Read block");
     619                        RTEMS_CLEANUP_RV( rv, sd_card_disk_block_read_stop_cleanup, "Read block");
    620620                }
    621621
    622622                /* Stop multiple block read */
    623623                rv = sd_card_stop_multiple_block_read( e);
    624                 CLEANUP_RV( rv, sd_card_disk_block_read_cleanup, "Stop multiple block read");
     624                RTEMS_CLEANUP_RV( rv, sd_card_disk_block_read_cleanup, "Stop multiple block read");
    625625        }
    626626
    627627        /* Stop */
    628628        sc = sd_card_stop( e);
    629         CHECK_SCRV( sc, "Stop");
     629        RTEMS_CHECK_SC_RV( sc, "Stop");
    630630
    631631        /* Done */
     
    657657        uint32_t i = 0;
    658658
    659         DEBUG_PRINT( "start = %u, count = %u, bufnum = %u\n", r->start, r->count, r->bufnum);
     659        RTEMS_DEBUG_PRINT( "start = %u, count = %u, bufnum = %u\n", r->start, r->count, r->bufnum);
    660660
    661661#ifdef DEBUG
    662662        /* Check request */
    663663  if (r->bufs[0].block >= e->block_number) {
    664                 SYSLOG_ERROR( "Start block number out of range");
     664                RTEMS_SYSLOG_ERROR( "Start block number out of range");
    665665                return -RTEMS_INTERNAL_ERROR;
    666666        } else if (r->bufnum > e->block_number - RTEMS_BLKDEV_START_BLOCK (r)) {
    667                 SYSLOG_ERROR( "Block count out of range");
     667                RTEMS_SYSLOG_ERROR( "Block count out of range");
    668668                return -RTEMS_INTERNAL_ERROR;
    669669        }
     
    672672        /* Start */
    673673        sc = sd_card_start( e);
    674         CLEANUP_SCRV( sc, rv, sd_card_disk_block_write_cleanup, "Start");
     674        RTEMS_CLEANUP_SC_RV( sc, rv, sd_card_disk_block_write_cleanup, "Start");
    675675
    676676        if (r->bufnum == 1) {
     
    678678                /* Check buffer */
    679679                if (r->bufs [0].length != e->block_size) {
    680                         DO_CLEANUP_RV( -RTEMS_INTERNAL_ERROR, rv, sd_card_disk_block_write_cleanup, "Buffer and disk block size are not equal");
     680                        RTEMS_DO_CLEANUP_RV( -RTEMS_INTERNAL_ERROR, rv, sd_card_disk_block_write_cleanup, "Buffer and disk block size are not equal");
    681681                }
    682                 DEBUG_PRINT( "[%02u]: buffer = 0x%08x, size = %u\n", 0, r->bufs [0].buffer, r->bufs [0].length);
     682                RTEMS_DEBUG_PRINT( "[%02u]: buffer = 0x%08x, size = %u\n", 0, r->bufs [0].buffer, r->bufs [0].length);
    683683#endif /* DEBUG */
    684684
    685685                /* Single block write */
    686686                rv = sd_card_send_command( e, SD_CARD_CMD_WRITE_BLOCK, start_address);
    687                 CLEANUP_RV( rv, sd_card_disk_block_write_cleanup, "Send: SD_CARD_CMD_WRITE_BLOCK");
     687                RTEMS_CLEANUP_RV( rv, sd_card_disk_block_write_cleanup, "Send: SD_CARD_CMD_WRITE_BLOCK");
    688688                rv = sd_card_write( e, SD_CARD_START_BLOCK_SINGLE_BLOCK_WRITE, (uint8_t *) r->bufs [0].buffer, (int) e->block_size);
    689                 CLEANUP_RV( rv, sd_card_disk_block_write_cleanup, "Write: SD_CARD_CMD_WRITE_BLOCK");
     689                RTEMS_CLEANUP_RV( rv, sd_card_disk_block_write_cleanup, "Write: SD_CARD_CMD_WRITE_BLOCK");
    690690        } else {
    691691                /* Start multiple block write */
    692692                rv = sd_card_send_command( e, SD_CARD_CMD_WRITE_MULTIPLE_BLOCK, start_address);
    693                 CLEANUP_RV( rv, sd_card_disk_block_write_stop_cleanup, "Send: SD_CARD_CMD_WRITE_MULTIPLE_BLOCK");
     693                RTEMS_CLEANUP_RV( rv, sd_card_disk_block_write_stop_cleanup, "Send: SD_CARD_CMD_WRITE_MULTIPLE_BLOCK");
    694694
    695695                /* Multiple block write */
     
    698698                        /* Check buffer */
    699699                        if (r->bufs [i].length != e->block_size) {
    700                                 DO_CLEANUP_RV( -RTEMS_INTERNAL_ERROR, rv, sd_card_disk_block_write_stop_cleanup, "Buffer and disk block size are not equal");
     700                                RTEMS_DO_CLEANUP_RV( -RTEMS_INTERNAL_ERROR, rv, sd_card_disk_block_write_stop_cleanup, "Buffer and disk block size are not equal");
    701701                        }
    702                         DEBUG_PRINT( "[%02u]: buffer = 0x%08x, size = %u\n", i, r->bufs [i].buffer, r->bufs [i].length);
     702                        RTEMS_DEBUG_PRINT( "[%02u]: buffer = 0x%08x, size = %u\n", i, r->bufs [i].buffer, r->bufs [i].length);
    703703#endif /* DEBUG */
    704704
    705705                        rv = sd_card_write( e, SD_CARD_START_BLOCK_MULTIPLE_BLOCK_WRITE, (uint8_t *) r->bufs [i].buffer, (int) e->block_size);
    706                         CLEANUP_RV( rv, sd_card_disk_block_write_stop_cleanup, "Write block");
     706                        RTEMS_CLEANUP_RV( rv, sd_card_disk_block_write_stop_cleanup, "Write block");
    707707                }
    708708
    709709                /* Stop multiple block write */
    710710                rv = sd_card_stop_multiple_block_write( e);
    711                 CLEANUP_RV( rv, sd_card_disk_block_write_cleanup, "Stop multiple block write");
     711                RTEMS_CLEANUP_RV( rv, sd_card_disk_block_write_cleanup, "Stop multiple block write");
    712712        }
    713713
    714714        /* Get card status */
    715715        rv = sd_card_send_command( e, SD_CARD_CMD_SEND_STATUS, 0);
    716         CHECK_RV( rv, "Send: SD_CARD_CMD_SEND_STATUS");
     716        RTEMS_CHECK_RV( rv, "Send: SD_CARD_CMD_SEND_STATUS");
    717717
    718718        /* Stop */
    719719        sc = sd_card_stop( e);
    720         CHECK_SCRV( sc, "Stop");
     720        RTEMS_CHECK_SC_RV( sc, "Stop");
    721721
    722722        /* Done */
     
    734734        /* Get card status */
    735735        rv = sd_card_send_command( e, SD_CARD_CMD_SEND_STATUS, 0);
    736         CHECK_RV( rv, "Send: SD_CARD_CMD_SEND_STATUS");
     736        RTEMS_CHECK_RV( rv, "Send: SD_CARD_CMD_SEND_STATUS");
    737737
    738738        /* Stop */
     
    747747static int sd_card_disk_ioctl( dev_t dev, uint32_t req, void *arg)
    748748{
    749         DEBUG_PRINT( "dev = %u, req = %u, arg = 0x08%x\n", dev, req, arg);
     749        RTEMS_DEBUG_PRINT( "dev = %u, req = %u, arg = 0x08%x\n", dev, req, arg);
    750750        if (req == RTEMS_BLKIO_REQUEST) {
    751751                rtems_device_minor_number minor = rtems_filesystem_dev_minor_t( dev);
     
    815815        /* Get driver entry */
    816816        rv = sd_card_driver_get_entry( minor, &e);
    817         CHECK_RVSC( rv, "Get driver entry");
     817        RTEMS_CHECK_RV_SC( rv, "Get driver entry");
    818818
    819819        /* Start */
    820820        sc = sd_card_start( e);
    821         CLEANUP_SC( sc, sd_card_driver_init_cleanup, "Start");
     821        RTEMS_CLEANUP_SC( sc, sd_card_driver_init_cleanup, "Start");
    822822
    823823        /* Save minor number for disk operations */
     
    828828                sd_card_driver_first = 0;
    829829                sc = rtems_io_register_driver( 0, &sd_card_disk_ops, &sd_card_disk_major);
    830                 CLEANUP_SC( sc, sd_card_driver_init_cleanup, "Register disk IO driver");
     830                RTEMS_CLEANUP_SC( sc, sd_card_driver_init_cleanup, "Register disk IO driver");
    831831        }
    832832
    833833        /* Wait until card is not busy */
    834834        rv = sd_card_wait( e);
    835         CLEANUP_RVSC( rv, sc, sd_card_driver_init_cleanup, "Wait");
     835        RTEMS_CLEANUP_RV_SC( rv, sc, sd_card_driver_init_cleanup, "Wait");
    836836
    837837        /* Send idle tokens for at least 74 clock cycles with active chip select */
    838838        memset( block, SD_CARD_IDLE_TOKEN, SD_CARD_BLOCK_SIZE_DEFAULT);
    839839        rv = rtems_libi2c_write_bytes( e->minor, block, SD_CARD_BLOCK_SIZE_DEFAULT);
    840         CLEANUP_RVSC( rv, sc, sd_card_driver_init_cleanup, "Active chip select delay");
     840        RTEMS_CLEANUP_RV_SC( rv, sc, sd_card_driver_init_cleanup, "Active chip select delay");
    841841
    842842        /* Stop */
    843843        sc = sd_card_stop( e);
    844         CHECK_SC( sc, "Stop");
     844        RTEMS_CHECK_SC( sc, "Stop");
    845845
    846846        /* Start with inactive chip select */
    847847        sc = rtems_libi2c_send_start( e->minor);
    848         CHECK_SC( sc, "Send start");
     848        RTEMS_CHECK_SC( sc, "Send start");
    849849
    850850        /* Set transfer mode */
    851851        rv = rtems_libi2c_ioctl( e->minor, RTEMS_LIBI2C_IOCTL_SET_TFRMODE, &e->transfer_mode);
    852         CLEANUP_RVSC( rv, sc, sd_card_driver_init_cleanup, "Set transfer mode");
     852        RTEMS_CLEANUP_RV_SC( rv, sc, sd_card_driver_init_cleanup, "Set transfer mode");
    853853
    854854        /* Send idle tokens with inactive chip select */
    855855        rv = sd_card_query( e, e->response, SD_CARD_COMMAND_SIZE);
    856         CLEANUP_RVSC( rv, sc, sd_card_driver_init_cleanup, "Inactive chip select delay");
     856        RTEMS_CLEANUP_RV_SC( rv, sc, sd_card_driver_init_cleanup, "Inactive chip select delay");
    857857
    858858        /* Activate chip select */
    859859        sc = rtems_libi2c_send_addr( e->minor, 1);
    860         CLEANUP_SC( sc, sd_card_driver_init_cleanup, "Send address");
     860        RTEMS_CLEANUP_SC( sc, sd_card_driver_init_cleanup, "Send address");
    861861
    862862        /* Stop multiple block write */
     
    871871        /* Switch to SPI mode */
    872872        rv = sd_card_send_command( e, SD_CARD_CMD_GO_IDLE_STATE, 0);
    873         CLEANUP_RVSC( rv, sc, sd_card_driver_init_cleanup, "Send: SD_CARD_CMD_GO_IDLE_STATE");
     873        RTEMS_CLEANUP_RV_SC( rv, sc, sd_card_driver_init_cleanup, "Send: SD_CARD_CMD_GO_IDLE_STATE");
    874874
    875875        /* Initialize card */
    876876        while (1) {
    877877                rv = sd_card_send_command( e, SD_CARD_CMD_APP_CMD, 0);
    878                 CLEANUP_RVSC( rv, sc, sd_card_driver_init_cleanup, "Send: SD_CARD_CMD_APP_CMD");
     878                RTEMS_CLEANUP_RV_SC( rv, sc, sd_card_driver_init_cleanup, "Send: SD_CARD_CMD_APP_CMD");
    879879                rv = sd_card_send_command( e, SD_CARD_ACMD_SD_SEND_OP_COND, 0);
    880                 CLEANUP_RVSC( rv, sc, sd_card_driver_init_cleanup, "Send: SD_CARD_ACMD_SD_SEND_OP_COND");
     880                RTEMS_CLEANUP_RV_SC( rv, sc, sd_card_driver_init_cleanup, "Send: SD_CARD_ACMD_SD_SEND_OP_COND");
    881881       
    882882                /* Not idle? */
     
    892892        if (e->verbose) {
    893893                rv = sd_card_send_command( e, SD_CARD_CMD_SEND_CID, 0);
    894                 CLEANUP_RVSC( rv, sc, sd_card_driver_init_cleanup, "Send: SD_CARD_CMD_SEND_CID");
     894                RTEMS_CLEANUP_RV_SC( rv, sc, sd_card_driver_init_cleanup, "Send: SD_CARD_CMD_SEND_CID");
    895895                rv = sd_card_read( e, SD_CARD_START_BLOCK_SINGLE_BLOCK_READ, block, SD_CARD_CID_SIZE);
    896                 CLEANUP_RVSC( rv, sc, sd_card_driver_init_cleanup, "Read: SD_CARD_CMD_SEND_CID");
    897                 SYSLOG( "*** Card Identification ***\n");
    898                 SYSLOG( "Manufacturer ID          : %" PRIu8 "\n", SD_CARD_CID_GET_MID( block));
    899                 SYSLOG( "OEM/Application ID       : %" PRIu16 "\n", SD_CARD_CID_GET_OID( block));
    900                 SYSLOG(
     896                RTEMS_CLEANUP_RV_SC( rv, sc, sd_card_driver_init_cleanup, "Read: SD_CARD_CMD_SEND_CID");
     897                RTEMS_SYSLOG( "*** Card Identification ***\n");
     898                RTEMS_SYSLOG( "Manufacturer ID          : %" PRIu8 "\n", SD_CARD_CID_GET_MID( block));
     899                RTEMS_SYSLOG( "OEM/Application ID       : %" PRIu16 "\n", SD_CARD_CID_GET_OID( block));
     900                RTEMS_SYSLOG(
    901901                        "Product name             : %c%c%c%c%c%c\n",
    902902                        SD_CARD_CID_GET_PNM( block, 0),
     
    907907                        SD_CARD_CID_GET_PNM( block, 5)
    908908                );
    909                 SYSLOG( "Product revision         : %" PRIu8 "\n", SD_CARD_CID_GET_PRV( block));
    910                 SYSLOG( "Product serial number    : %" PRIu32 "\n", SD_CARD_CID_GET_PSN( block));
    911                 SYSLOG( "Manufacturing date       : %" PRIu8 "\n", SD_CARD_CID_GET_MDT( block));
    912                 SYSLOG( "7-bit CRC checksum       : %" PRIu8 "\n",  SD_CARD_CID_GET_CRC7( block));
     909                RTEMS_SYSLOG( "Product revision         : %" PRIu8 "\n", SD_CARD_CID_GET_PRV( block));
     910                RTEMS_SYSLOG( "Product serial number    : %" PRIu32 "\n", SD_CARD_CID_GET_PSN( block));
     911                RTEMS_SYSLOG( "Manufacturing date       : %" PRIu8 "\n", SD_CARD_CID_GET_MDT( block));
     912                RTEMS_SYSLOG( "7-bit CRC checksum       : %" PRIu8 "\n",  SD_CARD_CID_GET_CRC7( block));
    913913        }
    914914
    915915        /* Card Specific Data */
    916916        rv = sd_card_send_command( e, SD_CARD_CMD_SEND_CSD, 0);
    917         CLEANUP_RVSC( rv, sc, sd_card_driver_init_cleanup, "Send: SD_CARD_CMD_SEND_CSD");
     917        RTEMS_CLEANUP_RV_SC( rv, sc, sd_card_driver_init_cleanup, "Send: SD_CARD_CMD_SEND_CSD");
    918918        rv = sd_card_read( e, SD_CARD_START_BLOCK_SINGLE_BLOCK_READ, block, SD_CARD_CSD_SIZE);
    919         CLEANUP_RVSC( rv, sc, sd_card_driver_init_cleanup, "Read: SD_CARD_CMD_SEND_CSD");
     919        RTEMS_CLEANUP_RV_SC( rv, sc, sd_card_driver_init_cleanup, "Read: SD_CARD_CMD_SEND_CSD");
    920920        transfer_speed = sd_card_transfer_speed( block);
    921921        e->transfer_mode.baudrate = transfer_speed;
     
    925925        write_block_size = 1U << e->block_size_shift;
    926926        if (read_block_size < write_block_size) {
    927                 SYSLOG_ERROR( "Read block size smaller than write block size\n");
     927                RTEMS_SYSLOG_ERROR( "Read block size smaller than write block size\n");
    928928                return -RTEMS_IO_ERROR;
    929929        }
     
    931931        e->block_number = sd_card_block_number( block);
    932932        if (e->verbose) {
    933                 SYSLOG( "*** Card Specific Data ***\n");
    934                 SYSLOG( "CSD structure            : %" PRIu8 "\n", SD_CARD_CSD_GET_CSD_STRUCTURE( block));
    935                 SYSLOG( "Spec version             : %" PRIu8 "\n", SD_CARD_CSD_GET_SPEC_VERS( block));
    936                 SYSLOG( "Access time [ns]         : %" PRIu32 "\n", sd_card_access_time( block));
    937                 SYSLOG( "Max access time [N]      : %" PRIu32 "\n", e->n_ac_max);
    938                 SYSLOG( "Max read block size [B]  : %" PRIu32 "\n", read_block_size);
    939                 SYSLOG( "Max write block size [B] : %" PRIu32 "\n", write_block_size);
    940                 SYSLOG( "Block size [B]           : %" PRIu32 "\n", e->block_size);
    941                 SYSLOG( "Block number             : %" PRIu32 "\n", e->block_number);
    942                 SYSLOG( "Capacity [B]             : %" PRIu32 "\n", sd_card_capacity( block));
    943                 SYSLOG( "Max transfer speed [b/s] : %" PRIu32 "\n", transfer_speed);
     933                RTEMS_SYSLOG( "*** Card Specific Data ***\n");
     934                RTEMS_SYSLOG( "CSD structure            : %" PRIu8 "\n", SD_CARD_CSD_GET_CSD_STRUCTURE( block));
     935                RTEMS_SYSLOG( "Spec version             : %" PRIu8 "\n", SD_CARD_CSD_GET_SPEC_VERS( block));
     936                RTEMS_SYSLOG( "Access time [ns]         : %" PRIu32 "\n", sd_card_access_time( block));
     937                RTEMS_SYSLOG( "Max access time [N]      : %" PRIu32 "\n", e->n_ac_max);
     938                RTEMS_SYSLOG( "Max read block size [B]  : %" PRIu32 "\n", read_block_size);
     939                RTEMS_SYSLOG( "Max write block size [B] : %" PRIu32 "\n", write_block_size);
     940                RTEMS_SYSLOG( "Block size [B]           : %" PRIu32 "\n", e->block_size);
     941                RTEMS_SYSLOG( "Block number             : %" PRIu32 "\n", e->block_number);
     942                RTEMS_SYSLOG( "Capacity [B]             : %" PRIu32 "\n", sd_card_capacity( block));
     943                RTEMS_SYSLOG( "Max transfer speed [b/s] : %" PRIu32 "\n", transfer_speed);
    944944        }
    945945
    946946        /* Set read block size */
    947947        rv = sd_card_send_command( e, SD_CARD_CMD_SET_BLOCKLEN, e->block_size);
    948         CLEANUP_RVSC( rv, sc, sd_card_driver_init_cleanup, "Send: SD_CARD_CMD_SET_BLOCKLEN");
     948        RTEMS_CLEANUP_RV_SC( rv, sc, sd_card_driver_init_cleanup, "Send: SD_CARD_CMD_SET_BLOCKLEN");
    949949
    950950        /* Create disk device */
    951951        dev = rtems_filesystem_make_dev_t( sd_card_disk_major, (rtems_device_minor_number) e->table_index);
    952952        sc = rtems_disk_io_initialize();
    953         CLEANUP_SC( sc, sd_card_driver_init_cleanup, "Initialize RTEMS disk IO");
     953        RTEMS_CLEANUP_SC( sc, sd_card_driver_init_cleanup, "Initialize RTEMS disk IO");
    954954        sc = rtems_disk_create_phys( dev, (int) e->block_size, (int) e->block_number, sd_card_disk_ioctl, e->disk_device_name);
    955         CLEANUP_SC( sc, sd_card_driver_init_cleanup, "Create disk device");
     955        RTEMS_CLEANUP_SC( sc, sd_card_driver_init_cleanup, "Create disk device");
    956956
    957957        /* Stop */
    958958        sc = sd_card_stop( e);
    959         CHECK_SC( sc, "Stop");
     959        RTEMS_CHECK_SC( sc, "Stop");
    960960
    961961        return RTEMS_SUCCESSFUL;
     
    985985        /* Get driver entry */
    986986        rv = sd_card_driver_get_entry( minor, &e);
    987         CHECK_RVSC( rv, "Get driver entry");
     987        RTEMS_CHECK_RV_SC( rv, "Get driver entry");
    988988
    989989        /* Start */
    990990        sc = sd_card_start( e);
    991         CLEANUP_SC( sc, sd_card_driver_read_cleanup, "Start");
     991        RTEMS_CLEANUP_SC( sc, sd_card_driver_read_cleanup, "Start");
    992992
    993993        /* Check arguments */
     
    996996        start_block = (uint32_t) rw->offset >> e->block_size_shift;
    997997        if (rw->offset & block_size_mask) {
    998                 DO_CLEANUP_SC( RTEMS_INVALID_ADDRESS, sc, sd_card_driver_read_cleanup, "Invalid offset");
     998                RTEMS_DO_CLEANUP_SC( RTEMS_INVALID_ADDRESS, sc, sd_card_driver_read_cleanup, "Invalid offset");
    999999        } else if ((rw->count & block_size_mask) || (start_block >= e->block_number) || (block_count > e->block_number - start_block)) {
    1000                 DO_CLEANUP_SC( RTEMS_INVALID_NUMBER, sc, sd_card_driver_read_cleanup, "Invalid count or out of range");
     1000                RTEMS_DO_CLEANUP_SC( RTEMS_INVALID_NUMBER, sc, sd_card_driver_read_cleanup, "Invalid count or out of range");
    10011001        }
    10021002
     
    10061006                /* Single block read */
    10071007                rv = sd_card_send_command( e, SD_CARD_CMD_READ_SINGLE_BLOCK, (uint32_t) rw->offset);
    1008                 CLEANUP_RVSC( rv, sc, sd_card_driver_read_cleanup, "Send: SD_CARD_CMD_READ_SINGLE_BLOCK");
     1008                RTEMS_CLEANUP_RV_SC( rv, sc, sd_card_driver_read_cleanup, "Send: SD_CARD_CMD_READ_SINGLE_BLOCK");
    10091009                rv = sd_card_read( e, SD_CARD_START_BLOCK_SINGLE_BLOCK_READ, (uint8_t *) rw->buffer, (int) e->block_size);
    1010                 CLEANUP_RVSC( rv, sc, sd_card_driver_read_cleanup, "Read: SD_CARD_CMD_READ_SINGLE_BLOCK");
     1010                RTEMS_CLEANUP_RV_SC( rv, sc, sd_card_driver_read_cleanup, "Read: SD_CARD_CMD_READ_SINGLE_BLOCK");
    10111011
    10121012                /* Set moved bytes counter */
     
    10151015                /* Start multiple block read */
    10161016                rv = sd_card_send_command( e, SD_CARD_CMD_READ_MULTIPLE_BLOCK, (uint32_t) rw->offset);
    1017                 CLEANUP_RVSC( rv, sc, sd_card_driver_read_stop_cleanup, "Send: SD_CARD_CMD_READ_MULTIPLE_BLOCK");
     1017                RTEMS_CLEANUP_RV_SC( rv, sc, sd_card_driver_read_stop_cleanup, "Send: SD_CARD_CMD_READ_MULTIPLE_BLOCK");
    10181018
    10191019                /* Multiple block read */
    10201020                for (i = 0; i < block_count; ++i) {
    10211021                        rv = sd_card_read( e, SD_CARD_START_BLOCK_MULTIPLE_BLOCK_READ, (uint8_t *) rw->buffer + (i << e->block_size_shift), (int) e->block_size);
    1022                         CLEANUP_RVSC( rv, sc, sd_card_driver_read_stop_cleanup, "Read block");
     1022                        RTEMS_CLEANUP_RV_SC( rv, sc, sd_card_driver_read_stop_cleanup, "Read block");
    10231023
    10241024                        /* Update moved bytes counter */
     
    10281028                /* Stop multiple block read */
    10291029                rv = sd_card_stop_multiple_block_read( e);
    1030                 CLEANUP_RVSC( rv, sc, sd_card_driver_read_cleanup, "Stop multiple block read");
     1030                RTEMS_CLEANUP_RV_SC( rv, sc, sd_card_driver_read_cleanup, "Stop multiple block read");
    10311031        }
    10321032
    10331033        /* Stop */
    10341034        sc = sd_card_stop( e);
    1035         CHECK_SC( sc, "Stop");
     1035        RTEMS_CHECK_SC( sc, "Stop");
    10361036
    10371037        return RTEMS_SUCCESSFUL;
     
    10661066        /* Get driver entry */
    10671067        rv = sd_card_driver_get_entry( minor, &e);
    1068         CHECK_RVSC( rv, "Get driver entry");
     1068        RTEMS_CHECK_RV_SC( rv, "Get driver entry");
    10691069
    10701070        /* Start */
    10711071        sc = sd_card_start( e);
    1072         CLEANUP_SC( sc, sd_card_driver_write_cleanup, "Start");
     1072        RTEMS_CLEANUP_SC( sc, sd_card_driver_write_cleanup, "Start");
    10731073
    10741074        /* Check arguments */
     
    10771077        start_block = (uint32_t) rw->offset >> e->block_size_shift;
    10781078        if (rw->offset & block_size_mask) {
    1079                 DO_CLEANUP_SC( RTEMS_INVALID_ADDRESS, sc, sd_card_driver_write_cleanup, "Invalid offset");
     1079                RTEMS_DO_CLEANUP_SC( RTEMS_INVALID_ADDRESS, sc, sd_card_driver_write_cleanup, "Invalid offset");
    10801080        } else if ((rw->count & block_size_mask) || (start_block >= e->block_number) || (block_count > e->block_number - start_block)) {
    1081                 DO_CLEANUP_SC( RTEMS_INVALID_NUMBER, sc, sd_card_driver_write_cleanup, "Invalid count or out of range");
     1081                RTEMS_DO_CLEANUP_SC( RTEMS_INVALID_NUMBER, sc, sd_card_driver_write_cleanup, "Invalid count or out of range");
    10821082        }
    10831083
     
    10871087                /* Single block write */
    10881088                rv = sd_card_send_command( e, SD_CARD_CMD_WRITE_BLOCK, (uint32_t) rw->offset);
    1089                 CLEANUP_RVSC( rv, sc, sd_card_driver_write_cleanup, "Send: SD_CARD_CMD_WRITE_BLOCK");
     1089                RTEMS_CLEANUP_RV_SC( rv, sc, sd_card_driver_write_cleanup, "Send: SD_CARD_CMD_WRITE_BLOCK");
    10901090                rv = sd_card_write( e, SD_CARD_START_BLOCK_SINGLE_BLOCK_WRITE, (uint8_t *) rw->buffer, (int) e->block_size);
    1091                 CLEANUP_RVSC( rv, sc, sd_card_driver_write_cleanup, "Write: SD_CARD_CMD_WRITE_BLOCK");
     1091                RTEMS_CLEANUP_RV_SC( rv, sc, sd_card_driver_write_cleanup, "Write: SD_CARD_CMD_WRITE_BLOCK");
    10921092
    10931093                /* Set moved bytes counter */
     
    10961096                /* Start multiple block write */
    10971097                rv = sd_card_send_command( e, SD_CARD_CMD_WRITE_MULTIPLE_BLOCK, (uint32_t) rw->offset);
    1098                 CLEANUP_RVSC( rv, sc, sd_card_driver_write_stop_cleanup, "Send: SD_CARD_CMD_WRITE_MULTIPLE_BLOCK");
     1098                RTEMS_CLEANUP_RV_SC( rv, sc, sd_card_driver_write_stop_cleanup, "Send: SD_CARD_CMD_WRITE_MULTIPLE_BLOCK");
    10991099
    11001100                /* Multiple block write */
    11011101                for (i = 0; i < block_count; ++i) {
    11021102                        rv = sd_card_write( e, SD_CARD_START_BLOCK_MULTIPLE_BLOCK_WRITE, (uint8_t *) rw->buffer + (i << e->block_size_shift), (int) e->block_size);
    1103                         CLEANUP_RVSC( rv, sc, sd_card_driver_write_stop_cleanup, "Write: SD_CARD_CMD_WRITE_MULTIPLE_BLOCK");
     1103                        RTEMS_CLEANUP_RV_SC( rv, sc, sd_card_driver_write_stop_cleanup, "Write: SD_CARD_CMD_WRITE_MULTIPLE_BLOCK");
    11041104
    11051105                        /* Update moved bytes counter */
     
    11091109                /* Stop multiple block write */
    11101110                rv = sd_card_stop_multiple_block_write( e);
    1111                 CLEANUP_RVSC( rv, sc, sd_card_driver_write_cleanup, "Stop multiple block write");
     1111                RTEMS_CLEANUP_RV_SC( rv, sc, sd_card_driver_write_cleanup, "Stop multiple block write");
    11121112        }
    11131113
    11141114        /* Get card status */
    11151115        rv = sd_card_send_command( e, SD_CARD_CMD_SEND_STATUS, 0);
    1116         CHECK_RV( rv, "Send: SD_CARD_CMD_SEND_STATUS");
     1116        RTEMS_CHECK_RV( rv, "Send: SD_CARD_CMD_SEND_STATUS");
    11171117
    11181118        /* Stop */
    11191119        sc = sd_card_stop( e);
    1120         CHECK_SC( sc, "Stop");
     1120        RTEMS_CHECK_SC( sc, "Stop");
    11211121
    11221122        return RTEMS_SUCCESSFUL;
     
    11311131        /* Get card status */
    11321132        rv = sd_card_send_command( e, SD_CARD_CMD_SEND_STATUS, 0);
    1133         CHECK_RV( rv, "Send: SD_CARD_CMD_SEND_STATUS");
     1133        RTEMS_CHECK_RV( rv, "Send: SD_CARD_CMD_SEND_STATUS");
    11341134
    11351135        /* Stop */
Note: See TracChangeset for help on using the changeset viewer.