diff --git a/freebsd/sys/dev/mmc/mmc.c b/freebsd/sys/dev/mmc/mmc.c index c19fae7a..023091eb 100644 --- a/freebsd/sys/dev/mmc/mmc.c +++ b/freebsd/sys/dev/mmc/mmc.c @@ -394,6 +394,7 @@ mmc_highest_voltage(uint32_t ocr) static void mmc_wakeup(struct mmc_request *req) { +#ifndef __rtems__ struct mmc_softc *sc; sc = (struct mmc_softc *)req->done_data; @@ -401,12 +402,18 @@ mmc_wakeup(struct mmc_request *req) req->flags |= MMC_REQ_DONE; MMC_UNLOCK(sc); wakeup(req); +#else /* __rtems__ */ + rtems_binary_semaphore_post(&req->req_done); +#endif /* __rtems__ */ } static int mmc_wait_for_req(struct mmc_softc *sc, struct mmc_request *req) { +#ifdef __rtems__ + rtems_binary_semaphore_init(&req->req_done, "mmc_req_done"); +#endif /* __rtems__ */ req->done = mmc_wakeup; req->done_data = sc; if (mmc_debug > 1) { @@ -418,10 +425,15 @@ mmc_wait_for_req(struct mmc_softc *sc, struct mmc_request *req) printf("\n"); } MMCBR_REQUEST(device_get_parent(sc->dev), sc->dev, req); +#ifndef __rtems__ MMC_LOCK(sc); while ((req->flags & MMC_REQ_DONE) == 0) msleep(req, &sc->sc_mtx, 0, "mmcreq", 0); MMC_UNLOCK(sc); +#else /* __rtems__ */ + rtems_binary_semaphore_wait(&req->req_done); + rtems_binary_semaphore_destroy(&req->req_done); +#endif /* __rtems__ */ if (mmc_debug > 2 || (mmc_debug > 0 && req->cmd->error != MMC_ERR_NONE)) device_printf(sc->dev, "CMD%d RESULT: %d\n", req->cmd->opcode, req->cmd->error); diff --git a/freebsd/sys/dev/mmc/mmcreg.h b/freebsd/sys/dev/mmc/mmcreg.h index 359f31d5..39680ad6 100644 --- a/freebsd/sys/dev/mmc/mmcreg.h +++ b/freebsd/sys/dev/mmc/mmcreg.h @@ -54,6 +54,9 @@ #ifndef DEV_MMC_MMCREG_H #define DEV_MMC_MMCREG_H +#ifdef __rtems__ +#include +#endif /* __rtems__ */ /* * This file contains the register definitions for the mmc and sd buses. @@ -173,8 +176,12 @@ struct mmc_request { struct mmc_command *stop; void (*done)(struct mmc_request *); /* Completion function */ void *done_data; /* requestor set data */ +#ifndef __rtems__ uint32_t flags; #define MMC_REQ_DONE 1 +#else /* __rtems__ */ + rtems_binary_semaphore req_done; +#endif /* __rtems__ */ }; /* Command definitions */