static void ide_sector_write(IDEState *s)

{

    int64_t sector_num;

    int ret, n, n1;



    s->status = READY_STAT | SEEK_STAT;

    sector_num = ide_get_sector(s);

#if defined(DEBUG_IDE)

    printf("write sector=%Ld\n", sector_num);

#endif

    n = s->nsector;

    if (n > s->req_nb_sectors)

        n = s->req_nb_sectors;

    ret = bdrv_write(s->bs, sector_num, s->io_buffer, n);

    s->nsector -= n;

    if (s->nsector == 0) {

        /* no more sector to write */

        ide_transfer_stop(s);

    } else {

        n1 = s->nsector;

        if (n1 > s->req_nb_sectors)

            n1 = s->req_nb_sectors;

        ide_transfer_start(s, s->io_buffer, 512 * n1, ide_sector_write);

    }

    ide_set_sector(s, sector_num + n);

    

#ifdef TARGET_I386

    if (win2k_install_hack) {

        /* It seems there is a bug in the Windows 2000 installer HDD

           IDE driver which fills the disk with empty logs when the

           IDE write IRQ comes too early. This hack tries to correct

           that at the expense of slower write performances. Use this

           option _only_ to install Windows 2000. You must disable it

           for normal use. */

        qemu_mod_timer(s->sector_write_timer, 

                       qemu_get_clock(vm_clock) + (ticks_per_sec / 1000));

    } else 

#endif

    {

        ide_set_irq(s);

    }

}

static void ide_sector_write(IDEState *s)

{

    int64_t sector_num;

    int ret, n, n1;



    s->status = READY_STAT | SEEK_STAT;

    sector_num = ide_get_sector(s);

#if defined(DEBUG_IDE)

    printf("write sector=%Ld\n", sector_num);

#endif

    n = s->nsector;

    if (n > s->req_nb_sectors)

        n = s->req_nb_sectors;

    ret = bdrv_write(s->bs, sector_num, s->io_buffer, n);

    s->nsector -= n;

    if (s->nsector == 0) {

        

        ide_transfer_stop(s);

    } else {

        n1 = s->nsector;

        if (n1 > s->req_nb_sectors)

            n1 = s->req_nb_sectors;

        ide_transfer_start(s, s->io_buffer, 512 * n1, ide_sector_write);

    }

    ide_set_sector(s, sector_num + n);

    

#ifdef TARGET_I386

    if (win2k_install_hack) {

        











        qemu_mod_timer(s->sector_write_timer, 

                       qemu_get_clock(vm_clock) + (ticks_per_sec / 1000));

    } else 

#endif

    {

        ide_set_irq(s);

    }

}

static void FUNC_0(IDEState *VAR_0)

{

    int64_t sector_num;

    int VAR_1, VAR_2, VAR_3;



    VAR_0->status = READY_STAT | SEEK_STAT;

    sector_num = ide_get_sector(VAR_0);

#if defined(DEBUG_IDE)

    printf("write sector=%Ld\VAR_2", sector_num);

#endif

    VAR_2 = VAR_0->nsector;

    if (VAR_2 > VAR_0->req_nb_sectors)

        VAR_2 = VAR_0->req_nb_sectors;

    VAR_1 = bdrv_write(VAR_0->bs, sector_num, VAR_0->io_buffer, VAR_2);

    VAR_0->nsector -= VAR_2;

    if (VAR_0->nsector == 0) {

        

        ide_transfer_stop(VAR_0);

    } else {

        VAR_3 = VAR_0->nsector;

        if (VAR_3 > VAR_0->req_nb_sectors)

            VAR_3 = VAR_0->req_nb_sectors;

        ide_transfer_start(VAR_0, VAR_0->io_buffer, 512 * VAR_3, FUNC_0);

    }

    ide_set_sector(VAR_0, sector_num + VAR_2);

    

#ifdef TARGET_I386

    if (win2k_install_hack) {

        











        qemu_mod_timer(VAR_0->sector_write_timer, 

                       qemu_get_clock(vm_clock) + (ticks_per_sec / 1000));

    } else 

#endif

    {

        ide_set_irq(VAR_0);

    }

}

static void FUNC_0(IDEState *VAR_0)
{ int64_t sector_num; int VAR_1, VAR_2, VAR_3; VAR_0->status = READY_STAT | SEEK_STAT; sector_num = ide_get_sector(VAR_0); #if defined(DEBUG_IDE)
printf("write sector=%Ld\VAR_2", sector_num); #endif
VAR_2 = VAR_0->nsector; if (VAR_2 > VAR_0->req_nb_sectors)
VAR_2 = VAR_0->req_nb_sectors; VAR_1 = bdrv_write(VAR_0->bs, sector_num, VAR_0->io_buffer, VAR_2); VAR_0->nsector -= VAR_2; if (VAR_0->nsector == 0) { ide_transfer_stop(VAR_0); } else { VAR_3 = VAR_0->nsector; if (VAR_3 > VAR_0->req_nb_sectors)
VAR_3 = VAR_0->req_nb_sectors; ide_transfer_start(VAR_0, VAR_0->io_buffer, 512 * VAR_3, FUNC_0); } ide_set_sector(VAR_0, sector_num + VAR_2); #ifdef TARGET_I386
if (win2k_install_hack) { qemu_mod_timer(VAR_0->sector_write_timer,
qemu_get_clock(vm_clock) + (ticks_per_sec / 1000)); } else #endif
{ ide_set_irq(VAR_0); } }