static void cmd_start_stop_unit(IDEState *s, uint8_t* buf)

{

    int sense;

    bool start = buf[4] & 1;

    bool loej = buf[4] & 2;     /* load on start, eject on !start */

    int pwrcnd = buf[4] & 0xf0;



    if (pwrcnd) {

        /* eject/load only happens for power condition == 0 */

        return;

    }



    if (loej) {

        if (!start && !s->tray_open && s->tray_locked) {

            sense = bdrv_is_inserted(s->bs)

                ? NOT_READY : ILLEGAL_REQUEST;

            ide_atapi_cmd_error(s, sense, ASC_MEDIA_REMOVAL_PREVENTED);

            return;

        }



        if (s->tray_open != !start) {

            bdrv_eject(s->bs, !start);

            s->tray_open = !start;

        }

    }



    ide_atapi_cmd_ok(s);

}

static void cmd_start_stop_unit(IDEState *s, uint8_t* buf)

{

    int sense;

    bool start = buf[4] & 1;

    bool loej = buf[4] & 2;     

    int pwrcnd = buf[4] & 0xf0;



    if (pwrcnd) {

        

        return;

    }



    if (loej) {

        if (!start && !s->tray_open && s->tray_locked) {

            sense = bdrv_is_inserted(s->bs)

                ? NOT_READY : ILLEGAL_REQUEST;

            ide_atapi_cmd_error(s, sense, ASC_MEDIA_REMOVAL_PREVENTED);

            return;

        }



        if (s->tray_open != !start) {

            bdrv_eject(s->bs, !start);

            s->tray_open = !start;

        }

    }



    ide_atapi_cmd_ok(s);

}

static void FUNC_0(IDEState *VAR_0, uint8_t* VAR_1)

{

    int VAR_2;

    bool start = VAR_1[4] & 1;

    bool loej = VAR_1[4] & 2;     

    int VAR_3 = VAR_1[4] & 0xf0;



    if (VAR_3) {

        

        return;

    }



    if (loej) {

        if (!start && !VAR_0->tray_open && VAR_0->tray_locked) {

            VAR_2 = bdrv_is_inserted(VAR_0->bs)

                ? NOT_READY : ILLEGAL_REQUEST;

            ide_atapi_cmd_error(VAR_0, VAR_2, ASC_MEDIA_REMOVAL_PREVENTED);

            return;

        }



        if (VAR_0->tray_open != !start) {

            bdrv_eject(VAR_0->bs, !start);

            VAR_0->tray_open = !start;

        }

    }



    ide_atapi_cmd_ok(VAR_0);

}

static void FUNC_0(IDEState *VAR_0, uint8_t* VAR_1)
{ int VAR_2; bool start = VAR_1[4] & 1; bool loej = VAR_1[4] & 2; int VAR_3 = VAR_1[4] & 0xf0; if (VAR_3) { return; } if (loej) { if (!start && !VAR_0->tray_open && VAR_0->tray_locked) { VAR_2 = bdrv_is_inserted(VAR_0->bs)
? NOT_READY : ILLEGAL_REQUEST; ide_atapi_cmd_error(VAR_0, VAR_2, ASC_MEDIA_REMOVAL_PREVENTED); return; } if (VAR_0->tray_open != !start) { bdrv_eject(VAR_0->bs, !start); VAR_0->tray_open = !start; } } ide_atapi_cmd_ok(VAR_0); }