Changeset View
Changeset View
Standalone View
Standalone View
sys/dev/altera/sdcard/altera_sdcard_io.c
Show First 20 Lines • Show All 287 Lines • ▼ Show 20 Lines | recheck: | ||||
} | } | ||||
} while (differences != 0); | } while (differences != 0); | ||||
if (retry_counter) | if (retry_counter) | ||||
device_printf(sc->as_dev, "%s: succeeded after %u retries\n", | device_printf(sc->as_dev, "%s: succeeded after %u retries\n", | ||||
__func__, retry_counter); | __func__, retry_counter); | ||||
} | } | ||||
static void | static void | ||||
altera_sdcard_io_start_internal(struct altera_sdcard_softc *sc, struct bio **bp) | altera_sdcard_io_start_internal(struct altera_sdcard_softc *sc, struct bio **bpp) | ||||
{ | { | ||||
switch (*bp->bio_cmd) { | switch ((*bpp)->bio_cmd) { | ||||
case BIO_READ: | case BIO_READ: | ||||
altera_sdcard_write_cmd_arg(sc, *bp->bio_pblkno * | altera_sdcard_write_cmd_arg(sc, (*bpp)->bio_pblkno * | ||||
ALTERA_SDCARD_SECTORSIZE); | ALTERA_SDCARD_SECTORSIZE); | ||||
altera_sdcard_write_cmd(sc, ALTERA_SDCARD_CMD_READ_BLOCK); | altera_sdcard_write_cmd(sc, ALTERA_SDCARD_CMD_READ_BLOCK); | ||||
break; | break; | ||||
case BIO_WRITE: | case BIO_WRITE: | ||||
altera_sdcard_write_rxtx_buffer(sc, *bp->bio_data, | altera_sdcard_write_rxtx_buffer(sc, (*bpp)->bio_data, | ||||
*bp->bio_bcount); | (*bpp)->bio_bcount); | ||||
altera_sdcard_write_cmd_arg(sc, *bp->bio_pblkno * | altera_sdcard_write_cmd_arg(sc, (*bpp)->bio_pblkno * | ||||
ALTERA_SDCARD_SECTORSIZE); | ALTERA_SDCARD_SECTORSIZE); | ||||
altera_sdcard_write_cmd(sc, ALTERA_SDCARD_CMD_WRITE_BLOCK); | altera_sdcard_write_cmd(sc, ALTERA_SDCARD_CMD_WRITE_BLOCK); | ||||
break; | break; | ||||
default: | default: | ||||
biofinish(*bp, NULL, EOPNOTSUPP); | biofinish(*bpp, NULL, EOPNOTSUPP); | ||||
*bp = NULL; | *bpp = NULL; | ||||
} | } | ||||
} | } | ||||
void | void | ||||
altera_sdcard_io_start(struct altera_sdcard_softc *sc, struct bio *bp) | altera_sdcard_io_start(struct altera_sdcard_softc *sc, struct bio *bp) | ||||
{ | { | ||||
ALTERA_SDCARD_LOCK_ASSERT(sc); | ALTERA_SDCARD_LOCK_ASSERT(sc); | ||||
KASSERT(sc->as_currentbio == NULL, | KASSERT(sc->as_currentbio == NULL, | ||||
("%s: bio already started", __func__)); | ("%s: bio already started", __func__)); | ||||
/* | /* | ||||
* We advertise a block size and maximum I/O size up the stack of the | * We advertise a block size and maximum I/O size up the stack of the | ||||
* SD Card IP Core sector size. Catch any attempts to not follow the | * SD Card IP Core sector size. Catch any attempts to not follow the | ||||
* rules. | * rules. | ||||
*/ | */ | ||||
KASSERT(bp->bio_bcount == ALTERA_SDCARD_SECTORSIZE, | KASSERT(bp->bio_bcount == ALTERA_SDCARD_SECTORSIZE, | ||||
("%s: I/O size not %d", __func__, ALTERA_SDCARD_SECTORSIZE)); | ("%s: I/O size not %d", __func__, ALTERA_SDCARD_SECTORSIZE)); | ||||
altera_sdcard_io_start_internal(sc, &bp); | altera_sdcard_io_start_internal(sc, &bp); | ||||
sc->as_currentbio = *bp; | sc->as_currentbio = bp; | ||||
sc->as_retriesleft = ALTERA_SDCARD_RETRY_LIMIT; | sc->as_retriesleft = ALTERA_SDCARD_RETRY_LIMIT; | ||||
} | } | ||||
/* | /* | ||||
* Handle completed I/O. ASR is passed in to avoid reading it more than once. | * Handle completed I/O. ASR is passed in to avoid reading it more than once. | ||||
* Return 1 if the I/O is actually complete (success, or retry limit | * Return 1 if the I/O is actually complete (success, or retry limit | ||||
* exceeded), or 0 if not. | * exceeded), or 0 if not. | ||||
*/ | */ | ||||
▲ Show 20 Lines • Show All 101 Lines • Show Last 20 Lines |