static void pl181_send_command(pl181_state *s)

{

    SDRequest request;

    uint8_t response[16];

    int rlen;



    request.cmd = s->cmd & PL181_CMD_INDEX;

    request.arg = s->cmdarg;

    DPRINTF("Command %d %08x\n", request.cmd, request.arg);

    rlen = sd_do_command(s->card, &request, response);

    if (rlen < 0)

        goto error;

    if (s->cmd & PL181_CMD_RESPONSE) {

#define RWORD(n) ((response[n] << 24) | (response[n + 1] << 16) \

                  | (response[n + 2] << 8) | response[n + 3])

        if (rlen == 0 || (rlen == 4 && (s->cmd & PL181_CMD_LONGRESP)))

            goto error;

        if (rlen != 4 && rlen != 16)

            goto error;

        s->response[0] = RWORD(0);

        if (rlen == 4) {

            s->response[1] = s->response[2] = s->response[3] = 0;

        } else {

            s->response[1] = RWORD(4);

            s->response[2] = RWORD(8);

            s->response[3] = RWORD(12) & ~1;

        }

        DPRINTF("Response received\n");

        s->status |= PL181_STATUS_CMDRESPEND;

#undef RWORD

    } else {

        DPRINTF("Command sent\n");

        s->status |= PL181_STATUS_CMDSENT;

    }

    return;



error:

    DPRINTF("Timeout\n");

    s->status |= PL181_STATUS_CMDTIMEOUT;

}

static void pl181_send_command(pl181_state *s)

{

    SDRequest request;

    uint8_t response[16];

    int rlen;



    request.cmd = s->cmd & PL181_CMD_INDEX;

    request.arg = s->cmdarg;

    DPRINTF("Command %d %08x\n", request.cmd, request.arg);

    rlen = sd_do_command(s->card, &request, response);

    if (rlen < 0)

        goto error;

    if (s->cmd & PL181_CMD_RESPONSE) {

#define RWORD(n) ((response[n] << 24) | (response[n + 1] << 16) \

                  | (response[n + 2] << 8) | response[n + 3])

        if (rlen == 0 || (rlen == 4 && (s->cmd & PL181_CMD_LONGRESP)))

            goto error;

        if (rlen != 4 && rlen != 16)

            goto error;

        s->response[0] = RWORD(0);

        if (rlen == 4) {

            s->response[1] = s->response[2] = s->response[3] = 0;

        } else {

            s->response[1] = RWORD(4);

            s->response[2] = RWORD(8);

            s->response[3] = RWORD(12) & ~1;

        }

        DPRINTF("Response received\n");

        s->status |= PL181_STATUS_CMDRESPEND;

#undef RWORD

    } else {

        DPRINTF("Command sent\n");

        s->status |= PL181_STATUS_CMDSENT;

    }

    return;



error:

    DPRINTF("Timeout\n");

    s->status |= PL181_STATUS_CMDTIMEOUT;

}

#define RWORD(n) ((response[n] << 24) | (response[n + 1] << 16) \
static void FUNC_0(pl181_state *VAR_0)

{

    SDRequest request;

    uint8_t response[16];

    int VAR_1;



    request.cmd = VAR_0->cmd & PL181_CMD_INDEX;

    request.arg = VAR_0->cmdarg;

    DPRINTF("Command %d %08x\n", request.cmd, request.arg);

    VAR_1 = sd_do_command(VAR_0->card, &request, response);

    if (VAR_1 < 0)

        goto error;

    if (VAR_0->cmd & PL181_CMD_RESPONSE) {

#define RWORD(n) ((response[n] << 24) | (response[n + 1] << 16) \

                  | (response[n + 2] << 8) | response[n + 3])

        if (VAR_1 == 0 || (VAR_1 == 4 && (VAR_0->cmd & PL181_CMD_LONGRESP)))

            goto error;

        if (VAR_1 != 4 && VAR_1 != 16)

            goto error;

        VAR_0->response[0] = RWORD(0);

        if (VAR_1 == 4) {

            VAR_0->response[1] = VAR_0->response[2] = VAR_0->response[3] = 0;

        } else {

            VAR_0->response[1] = RWORD(4);

            VAR_0->response[2] = RWORD(8);

            VAR_0->response[3] = RWORD(12) & ~1;

        }

        DPRINTF("Response received\n");

        VAR_0->status |= PL181_STATUS_CMDRESPEND;

#undef RWORD

    } else {

        DPRINTF("Command sent\n");

        VAR_0->status |= PL181_STATUS_CMDSENT;

    }

    return;



error:

    DPRINTF("Timeout\n");

    VAR_0->status |= PL181_STATUS_CMDTIMEOUT;

}

static void FUNC_0(pl181_state *VAR_0)
{ SDRequest request; uint8_t response[16]; int VAR_1; request.cmd = VAR_0->cmd & PL181_CMD_INDEX; request.arg = VAR_0->cmdarg; DPRINTF("Command %d %08x\n", request.cmd, request.arg); VAR_1 = sd_do_command(VAR_0->card, &request, response); if (VAR_1 < 0)
goto error; if (VAR_0->cmd & PL181_CMD_RESPONSE) { #define RWORD(n) ((response[n] << 24) | (response[n + 1] << 16) \
| (response[n + 2] << 8) | response[n + 3])
if (VAR_1 == 0 || (VAR_1 == 4 && (VAR_0->cmd & PL181_CMD_LONGRESP)))
goto error; if (VAR_1 != 4 && VAR_1 != 16)
goto error; VAR_0->response[0] = RWORD(0); if (VAR_1 == 4) { VAR_0->response[1] = VAR_0->response[2] = VAR_0->response[3] = 0; } else { VAR_0->response[1] = RWORD(4); VAR_0->response[2] = RWORD(8); VAR_0->response[3] = RWORD(12) & ~1; } DPRINTF("Response received\n"); VAR_0->status |= PL181_STATUS_CMDRESPEND; #undef RWORD
} else { DPRINTF("Command sent\n"); VAR_0->status |= PL181_STATUS_CMDSENT; } return; error:
DPRINTF("Timeout\n"); VAR_0->status |= PL181_STATUS_CMDTIMEOUT; }