MCPcopy Create free account
hub / github.com/ading2210/linuxpdf / ide_drive_init

Function ide_drive_init

tinyemu/ide.c:755–797  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

753}
754
755static IDEState *ide_drive_init(IDEIFState *ide_if, BlockDevice *bs)
756{
757 IDEState *s;
758 uint32_t cylinders;
759 uint64_t nb_sectors;
760
761 s = malloc(sizeof(*s));
762 memset(s, 0, sizeof(*s));
763
764 s->ide_if = ide_if;
765 s->bs = bs;
766
767 nb_sectors = s->bs->get_sector_count(s->bs);
768 cylinders = nb_sectors / (16 * 63);
769 if (cylinders > 16383)
770 cylinders = 16383;
771 else if (cylinders < 2)
772 cylinders = 2;
773 s->cylinders = cylinders;
774 s->heads = 16;
775 s->sectors = 63;
776 s->nb_sectors = nb_sectors;
777
778 s->mult_sectors = MAX_MULT_SECTORS;
779 /* ide regs */
780 s->feature = 0;
781 s->error = 0;
782 s->nsector = 0;
783 s->sector = 0;
784 s->lcyl = 0;
785 s->hcyl = 0;
786 s->select = 0xa0;
787 s->status = READY_STAT | SEEK_STAT;
788
789 /* init I/O buffer */
790 s->data_index = 0;
791 s->data_end = 0;
792 s->end_transfer_func = ide_transfer_stop;
793
794 s->req_nb_sectors = 0; /* temp for read/write */
795 s->io_nb_sectors = 0; /* temp for read/write */
796 return s;
797}
798
799IDEIFState *ide_init(PhysMemoryMap *port_map, uint32_t addr, uint32_t addr2,
800 IRQSignal *irq, BlockDevice **tab_bs)

Callers 1

ide_initFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected