void micropolis_device::device_reset() { for (auto & elem : m_floppy_drive_tags) { if (elem) { legacy_floppy_image_device *img = siblingdevice<legacy_floppy_image_device>(elem); if (img) { img->floppy_drive_set_controller(this); //img->floppy_drive_set_index_pulse_callback(wd17xx_index_pulse_callback); img->floppy_drive_set_rpm(300.); } } } set_drive(0); m_drive_num = 0; m_sector = 0; m_track = 0; m_sector_length = 270; m_status = STAT_TRACK0; }
static int rf_encoder_changed(void *data) { int pos=*(int*)data; if(pos!=0) { if(function || tune) { // tune drive double d=getTuneDrive(); d+=(double)pos; if(d<0.0) { d=0.0; } else if(d>100.0) { d=100.0; } set_tune(d); } else { // drive double d=getDrive(); d+=(double)pos; if(d<0.0) { d=0.0; } else if(d>100.0) { d=100.0; } set_drive(d); } } free(data); return 0; }
IDE::IDE(hw::PCI_Device& pcidev, selector_t sel) : _pcidev {pcidev}, _drive {(uint8_t)sel}, _iobase {0U}, _nb_blk {0U} { INFO("IDE","VENDOR_ID : 0x%x, PRODUCT_ID : 0x%x", _pcidev.vendor_id(), _pcidev.product_id()); INFO("IDE","Attaching to PCI addr 0x%x",_pcidev.pci_addr()); /** PCI device checking */ if (_pcidev.vendor_id() not_eq IDE_VENDOR_ID) { panic("This is not an Intel device"); } CHECK(true, "Vendor ID is INTEL"); if (_pcidev.product_id() not_eq IDE_PRODUCT_ID) { panic("This is not an IDE Controller"); } CHECK(true, "Product ID is IDE Controller"); /** Probe PCI resources and fetch I/O-base for device */ _pcidev.probe_resources(); _iobase = _pcidev.iobase(); CHECK(_iobase, "Unit has valid I/O base (0x%x)", _iobase); /** IRQ initialization */ CHECK(IDE_IRQN, "Unit has IRQ %i", IDE_IRQN); enable_irq_handler(); INFO("IDE", "Enabling IRQ handler"); /** IDE device initialization */ set_irq_mode(false); set_drive(0xA0 | _drive); set_nbsectors(0U); set_blocknum(0U); set_command(IDE_CMD_IDENTIFY); if (not inb(IDE_STATUS)) { panic("Device not found"); } CHECK(true, "IDE device found"); wait_status_flags(IDE_DRDY, false); uint16_t buffer[256]; for (int i {0}; i < 256; ++i) { buffer[i] = inw(IDE_DATA); } _nb_blk = (buffer[61] << 16) | buffer[60]; INFO("IDE", "Initialization complete"); }
bool file_specification::make_relative(const file_specification& rootspec) { if (relative()) return true; DEBUG_ASSERT(rootspec.absolute()); // now compare elements of the root with elements of this to find the common path // if the drives are different, no conversion can take place, else clear the drive if (!path_compare(drive(), rootspec.drive())) return true; set_drive(""); // first remove leading elements that are identical to the corresponding element in root unsigned i = 0; while(subpath_size() > 0 && i < rootspec.subpath_size() && path_compare(subpath_element(0), rootspec.subpath_element(i))) { subpath_erase(0); i++; } // now add a .. prefix for every element in root that is different from this while (i < rootspec.subpath_size()) { m_path.insert(m_path.begin(), ".."); i++; } set_relative(); return true; }
static void ScanConflicts(char *path, unsigned inx, int argc, char **argv) { DIR *dp; struct dirent *de; struct stat sb; int j; unsigned k; #if SYS_MSDOS || SYS_OS2 || SYS_WIN32 || SYS_OS2_EMX char save_wd[MAXPATHLEN]; #endif /* * When scanning a directory, we first chdir to it, mostly to make * the scan+stat work faster, but also because some systems don't * scan properly otherwise. * * MSDOS and OS/2 are a little more complicated, because each drive * has its own current directory. */ #if SYS_MSDOS || SYS_OS2 || SYS_WIN32 || SYS_OS2_EMX (void) strcpy(save_wd, dot); if (!strcmp(".", path)) { path = dot; } else if (!same_drive(dot, path)) { if (!set_drive(path)) return; getwd(save_wd); } #endif if (v_opt > 2) printf("ScanConflicts \"%s\"\n", path); if (set_directory(path) && (dp = opendir(path)) != NULL) { while ((de = readdir(dp)) != NULL) { register type_t ok = 0; int found = FALSE; char buffer[MAXPATHLEN]; char *the_name; char *the_NAME; if (do_blips) blip('.'); (void) sprintf(buffer, "%.*s", (int) NAMLEN(de), de->d_name); the_name = MakeString(DOS_upper(buffer)); the_NAME = ToCompare(the_name); /* If arguments are given, restrict search to them */ if (argc > optind) { for (j = optind; j < argc; j++) { if (SameName(argv[j], the_name)) { found = TRUE; break; } } if (!found) continue; } /* Verify that the name is a file, and executable */ if (stat(the_name, &sb) < 0) continue; if ((sb.st_mode & S_IFMT) != S_IFREG) continue; #if SYS_UNIX || SYS_OS2 || SYS_OS2_EMX if (access(the_name, acc_mask) < 0) continue; ok = 1; #endif if (FileTypes != 0) { if ((ok = LookupType(the_name)) == 0) continue; } /* Find the name in our array of all names */ found = FALSE; for (k = 0; k < total; k++) { if (SameName(inpath[k].ip_NAME, the_NAME)) { FoundNode(&inpath[k], inx); found = TRUE; break; } } /* If not there, add it */ if (found) { if (the_NAME != the_name) { FreeString(the_NAME); } } else { if (!(total & CHUNK)) { size_t need = (((total * 3) / 2) | CHUNK) + 1; if (inpath != 0) inpath = TypeRealloc(INPATH, inpath, need); else inpath = TypeAlloc(INPATH, need); } j = (int) total++; inpath[j].ip_name = the_name; inpath[j].ip_NAME = the_NAME; inpath[j].node = TypeAlloc(NODE, path_len); FoundNode(&inpath[j], inx); } if (v_opt > 2) { (void) printf("%c %s%c%s\n", found ? '+' : '*', path, PATHNAME_SEP, buffer); } } (void) closedir(dp); } #if SYS_MSDOS || SYS_OS2 || SYS_WIN32 || SYS_OS2_EMX if (strcmp(dot, save_wd)) { chdir(save_wd); } #endif (void) set_directory(dot); }