uint32 IDEDriver::doDeviceDetection() { const char* name = "idea"; MMCDriver* drv = new MMCDriver(); BDVirtualDevice *bdv = new BDVirtualDevice(drv, 0, drv->getNumSectors(), drv->getSectorSize(), name, true); BDManager::getInstance()->addVirtualDevice(bdv); debug(IDE_DRIVER, "doDetection: initialized with MMCDriver!\n "); processMBR(drv, 0, drv->SPT, name); return 1; }
int32 IDEDriver::processMBR ( ATADriver * drv, uint32 sector, uint32 SPT, char *name ) { uint32 offset = 0, numsec = 0; uint16 buff[256]; // read buffer debug(IDE_DRIVER, "processMBR:reading MBR\n"); static uint32 part_num = 0; // char part_num_str[2]; // char part_name[10]; uint32 read_res = drv->rawReadSector( sector, 1, (void *)buff ); if( read_res != 0 ) { debug(IDE_DRIVER, "processMBR: drv returned BD_ERROR\n" ); return -1; } MBR *mbr = (MBR *) buff; if( mbr->signature == 0xAA55 ) { debug(IDE_DRIVER, "processMBR: | Valid PC MBR | \n"); FP * fp = (FP *) mbr->parts; uint32 i; for(i = 0; i < 4; i++, fp++) { switch( fp->systid ) { case 0x00: // do nothing break; case 0x05: // DOS extended partition case 0x0F: // Windows extended partition case 0x85: // linux extended partition debug(IDE_DRIVER, "ext. part. at: %d \n", fp->relsect ); if ( processMBR( drv, sector + fp->relsect, SPT, name) == -1 ) processMBR( drv, sector + fp->relsect - SPT, SPT, name ); break; default: // offset = fp->relsect - SPT; offset = fp->relsect; numsec = fp->numsect; char part_name[6]; strncpy( part_name, name, 4 ); part_name[4] = part_num + '0'; part_name[5] = 0; part_num++; BDVirtualDevice *bdv = new BDVirtualDevice( drv, offset, numsec, drv->getSectorSize(), part_name, true); // set Partition Type (FileSystem identifier) bdv->setPartitionType(fp->systid); BDManager::getInstance()->addVirtualDevice( bdv ); break; } } } else { debug(IDE_DRIVER, "processMBR: | Invalid PC MBR %d | \n", mbr->signature); return -1; } debug(IDE_DRIVER, "processMBR:, done with partitions \n"); return 0; }
uint32 IDEDriver::doDeviceDetection() { uint32 jiffies = 0; uint16 base_port = 0x1F0; uint16 base_regport = 0x3F6; uint8 cs = 0; uint8 sc; uint8 sn; uint8 devCtrl; uint8 ata_irqs[4] = { 14, 15, 11, 9 }; // setup register values devCtrl = 0x00; // please use interrupts // assume there are no devices debug(IDE_DRIVER, "doDetection:%d\n", cs); for( cs = 0; cs < 4; cs ++) { char name[5]; name[0] = 'i'; name[1] = 'd'; name[2] = 'e'; name[3] = cs + 'a'; name[4] = '\0'; debug(IDE_DRIVER, "doDetection:Detecting IDE DEV: %s\n", name); if( cs > 1 ) { base_port = 0x170; base_regport = 0x376; } outbp( base_regport, devCtrl ); // init the device with interupts uint8 value = (cs % 2 == 0 ? 0xA0 : 0xB0 ); uint16 bpp6 = base_port + 6; uint16 bpp2 = base_port + 2; uint16 bpp3 = base_port + 3; outportb( bpp6, value ); outportb( 0x80, 0x00 ); outportb( bpp2, 0x55 ); outportb( 0x80, 0x00 ); outportb( bpp3, 0xAA ); outportb( 0x80, 0x00 ); outportb( bpp2, 0xAA ); outportb( 0x80, 0x00 ); outportb( bpp3, 0x55 ); outportb( 0x80, 0x00 ); outportb( bpp2, 0x55 ); outportb( 0x80, 0x00 ); outportb( bpp3, 0xAA ); outportb( 0x80, 0x00 ); sc = inportb( bpp2 ); outportb( 0x80, 0x00 ); sn = inportb( bpp3 ); outportb( 0x80, 0x00 ); if ( ( sc == 0x55 ) && ( sn == 0xAA ) ) { outbp( base_regport , devCtrl | 0x04 ); // RESET outbp( base_regport , devCtrl ); jiffies = 0; while (!(inbp( base_port + 7 ) & 0x58) && jiffies++ < IO_TIMEOUT) ArchInterrupts::yieldIfIFSet(); if( jiffies >= IO_TIMEOUT ) debug(IDE_DRIVER, "doDetection: Still busy after reset!\n "); else { outbp( base_port + 6, (cs % 2 == 0 ? 0xA0 : 0xB0 ) ); uint8 c1 = inbp( base_port + 2 ); uint8 c2 = inbp( base_port + 3 ); if( c1 != 0x01 && c2 != 0x01 ) debug(IDE_DRIVER, "doDetection: Not found after reset ! \n"); else { uint8 c3 = inbp( base_port + 7 ); uint8 c4 = inbp( base_port + 4 ); uint8 c5 = inbp( base_port + 5 ); if(((c4 == 0x14) && (c5 == 0xEB)) || ((c4 == 0x69) && (c5 == 0x96))) { debug(IDE_DRIVER, "doDetection: Found ATAPI ! \n"); debug(IDE_DRIVER, "doDetection: port: %4X, drive: %d \n", base_port, cs%2); debug(IDE_DRIVER, "doDetection: CDROM not supported \n"); // CDROM hook goes here // // char *name = "ATAX0"; // name[3] = cs + '0'; // drv = new CROMDriver ( base_port, cs % 2 ); // BDVirtualDevice *bdv = new // BDVirtualDevice( drv, 0, drv->getNumSectors(), // drv->getSectorSize(), name, true); // BDManager::getInstance()->addDevice( bdv ); } else { if( c3 != 0 ) { if( ( c4 == 0x00 ) && ( c5 == 0x00 ) ) { debug(IDE_DRIVER, "doDetection: Found PATA ! \n"); debug(IDE_DRIVER, "doDetection: port: %4X, drive: %d \n", base_port, cs%2); ATADriver *drv = new ATADriver( base_port, cs % 2, ata_irqs[cs] ); BDVirtualDevice *bdv = new BDVirtualDevice( drv, 0, drv->getNumSectors(), drv->getSectorSize(), name, true); BDManager::getInstance()->addVirtualDevice( bdv ); processMBR( drv, 0, drv->SPT, name ); } else if( ( c4 == 0x3C ) && ( c5 == 0xC3 ) ) { debug(IDE_DRIVER, "doDetection: Found SATA device! \n"); debug(IDE_DRIVER, "doDetection: port: %4X, drive: %d \n", base_port, cs%2); // SATA hook // drv = new SATADriver ( base_port, cs % 2 ); debug(IDE_DRIVER, "doDetection: Running SATA device as PATA in compatibility mode! \n"); ATADriver *drv = new ATADriver( base_port, cs % 2, ata_irqs[cs] ); BDVirtualDevice *bdv = new BDVirtualDevice( drv, 0, drv->getNumSectors(), drv->getSectorSize(), name, true); BDManager::getInstance()->addVirtualDevice( bdv ); processMBR( drv, 0, drv->SPT, name ); } } else { debug(IDE_DRIVER, "doDetection: Unknown harddisk!\n"); } } } } } else { debug(IDE_DRIVER, "doDetection: Not found!\n "); } } // TODO : verify if the device is ATA and not ATAPI or SATA return 0; }
Static void musicParagraph(void) { struct LOC_musicParagraph V; voice_index0 j, nvoice; Char lyrassign[256]; Char STR1[256]; Char STR2[256]; Char STR3[256], STR4[256], STR5[256]; voice_index0 FORLIM; short FORLIM1; paragraphSetup(&nvoice); if (nvoice == 0) { nonMusic(); return; } if (nvoice > nvoices) { if (nvoice == 0) error("No voices! Did you remember to to supply a Style?", !print); sprintf(STR4, "Paragraph has %s voices but Style allows only %s", toString(STR1, nvoice), toString(STR2, nvoices)); error(STR4, !print); return; } if (first_paragraph) includeStartString(); if (pmx_preamble_done && (!final_paragraph || nvoice > 0)) { sprintf(STR5, "%c Paragraph %s line %s bar %s", comment, toString(STR1, paragraph_no), toString(STR2, orig_line_no[0]), toString(STR3, bar_no)); putLine(STR5); } testParagraph(); rememberDurations(); if (beVerbose()) describeParagraph(); /* ---- Knowing the score, we can start setting music ---------------- */ if (!pmx_preamble_done) { doPMXpreamble(); sprintf(STR3, "%c Paragraph %s line %s bar ", comment, toString(STR1, paragraph_no), toString(STR2, orig_line_no[0])); put(STR3, putspace); if (pickup > 0) putLine("0"); else putLine("1"); } putPMXlines(&V); if (must_restyle) restyle(); if (some_vocal && (nvoice > 0 || !final_paragraph)) { FORLIM = ninstr; for (j = 1; j <= FORLIM; j++) { assignLyrics(j, lyrassign); if (*lyrassign != '\0') { sprintf(STR2, "\\\\%s\\", lyrassign); putLine(STR2); } } } if (must_respace) respace(); if (meternum == 0) putMeter(meterChange(STR2, beatsPerLine(), meterdenom, true), &V); if (nleft > 0) nbars++; if (nbars == 0 && *multi_bar_rest != '\0') processMBR(&V); else { FORLIM1 = nbars; for (bar_of_line = 1; bar_of_line <= FORLIM1; bar_of_line++) processOneBar(&V); } restoreDurations(); }