std::string IDSEXT::Challenge(const std::string& provider, int challengeType, int challengeFlags) { ids_request_id_t *challengeRequestId = NULL; ids_provider_mapping *requestProvider = getProvider(provider); ids_result_t challengeResult; challengeResult = ids_challenge((requestProvider ? requestProvider->provider : NULL), challengeType, challengeFlags, challengeSuccessCB, failureCB, this, challengeRequestId); if ( challengeResult != IDS_SUCCESS ) { failureCB((ids_request_id_t)0, IDS_FAILURE, strerror(errno), this); } return ""; }
std::string IDSEXT::ListData(const std::string& provider, int dataType, int dataFlags) { ids_request_id_t *listDataRequestId = NULL; ids_provider_mapping *requestProvider = getProvider(provider); ids_result_t listDataResult; listDataResult = ids_list_data((requestProvider ? requestProvider->provider : NULL), dataType, dataFlags, listDataSuccessCB, failureCB, this, listDataRequestId); if ( listDataResult != IDS_SUCCESS ) { failureCB((ids_request_id_t)0, IDS_FAILURE, strerror(errno), this); } return ""; }
std::string IDSEXT::ClearToken(const std::string& provider, const std::string& tokenType, const std::string& appliesTo) { ids_request_id_t *clearTokenRequestId = NULL; ids_provider_mapping *requestProvider = getProvider(provider); ids_result_t clearTokenResult; clearTokenResult = ids_clear_token((requestProvider ? requestProvider->provider : NULL), tokenType.c_str(), appliesTo.c_str(), clearTokenSuccessCB, failureCB, this, clearTokenRequestId); if ( clearTokenResult != IDS_SUCCESS ) { failureCB((ids_request_id_t)0, IDS_FAILURE, strerror(errno), this); } return ""; }
std::string IDSEXT::DeleteData(const std::string& provider, int dataType, int dataFlags, const std::string& dataName) { ids_request_id_t *deleteDataRequestId = NULL; ids_provider_mapping *requestProvider = getProvider(provider); ids_result_t deleteDataResult; deleteDataResult = ids_delete_data((requestProvider ? requestProvider->provider : NULL), dataType, dataFlags, dataName.c_str(), deleteDataSuccessCB, failureCB, this, deleteDataRequestId); if ( deleteDataResult != IDS_SUCCESS ) { failureCB((ids_request_id_t)0, IDS_FAILURE, strerror(errno), this); } return ""; }
void AppleGPIO::enableWithParent(void) { DLOG("AppleGPIO::enableWithParent 0x%lx enabling notification\n", fGPIOID); // don't enable twice if (amEnabled()) { DLOG("AppleGPIO::enableWithParent already enabled!!\n"); return; } // enable notification from parent if ((!setAmEnabled(true)) || (fParent->callPlatformFunction(kSymGPIOParentEvtEnable, false, (void *)fGPIOID, (void *)getProvider(), (void *)&sGPIOEventOccured, (void *)this) != kIOReturnSuccess)) { DLOG("AppleGPIO::enableWithParent enable attempt failed\n"); } }
void IOPartitionScheme::write(IOService * client, UInt64 byteStart, IOMemoryDescriptor * buffer, IOStorageAttributes * attributes, IOStorageCompletion * completion) { // // Write data into the storage object at the specified byte offset from the // specified buffer, asynchronously. When the write completes, the caller // will be notified via the specified completion action. // // The buffer will be retained for the duration of the write. // // For simple partition schemes, the default behavior is to simply pass the // write through to the provider media. More complex partition schemes such // as RAID will need to do extra processing here. // #ifndef __LP64__ if ( IOStorage::_expansionData ) { if ( attributes == &gIOStorageAttributesUnsupported ) { attributes = NULL; } else { IOStorage::write( client, byteStart, buffer, attributes, completion ); return; } } #endif /* !__LP64__ */ getProvider( )->write( this, byteStart, buffer, attributes, completion ); }
IOReturn IOInterruptController::registerInterrupt(IOService *nub, int source, void *target, IOInterruptHandler handler, void *refCon) { IOInterruptSource *interruptSources; IOInterruptVectorNumber vectorNumber; IOInterruptVector *vector; int wasDisabledSoft; IOReturn error; OSData *vectorData; IOOptionBits options; bool canBeShared, shouldBeShared, wasAlreadyRegisterd; IOService *originalNub = NULL; // Protected by wasAlreadyRegisterd int originalSource = 0; // Protected by wasAlreadyRegisterd interruptSources = nub->_interruptSources; vectorData = interruptSources[source].vectorData; vectorNumber = *(IOInterruptVectorNumber *)vectorData->getBytesNoCopy(); vector = &vectors[vectorNumber]; // Get the lock for this vector. IOLockLock(vector->interruptLock); // Check if the interrupt source can/should be shared. canBeShared = vectorCanBeShared(vectorNumber, vector); IODTGetInterruptOptions(nub, source, &options); #if defined(__i386__) || defined(__x86_64__) int interruptType; if (OSDynamicCast(IOPlatformDevice, getProvider()) && (getInterruptType(nub, source, &interruptType) == kIOReturnSuccess) && (kIOInterruptTypeLevel & interruptType)) { options |= kIODTInterruptShared; } #endif shouldBeShared = canBeShared && (options & kIODTInterruptShared); wasAlreadyRegisterd = vector->interruptRegistered; // If the vector is registered and can not be shared return error. if (wasAlreadyRegisterd && !canBeShared) { IOLockUnlock(vector->interruptLock); return kIOReturnNoResources; } // If this vector is already in use, and can be shared (implied), // or it is not registered and should be shared, // register as a shared interrupt. if (wasAlreadyRegisterd || shouldBeShared) { // If this vector is not already shared, break it out. if (vector->sharedController == 0) { // Make the IOShareInterruptController instance vector->sharedController = new IOSharedInterruptController; if (vector->sharedController == 0) { IOLockUnlock(vector->interruptLock); return kIOReturnNoMemory; } if (wasAlreadyRegisterd) { // Save the nub and source for the original consumer. originalNub = vector->nub; originalSource = vector->source; // Physically disable the interrupt, but mark it as being enabled in the hardware. // The interruptDisabledSoft now indicates the driver's request for enablement. disableVectorHard(vectorNumber, vector); vector->interruptDisabledHard = 0; } // Initialize the new shared interrupt controller. error = vector->sharedController->initInterruptController(this, vectorData); // If the IOSharedInterruptController could not be initalized, // if needed, put the original consumer's interrupt back to normal and // get rid of whats left of the shared controller. if (error != kIOReturnSuccess) { if (wasAlreadyRegisterd) enableInterrupt(originalNub, originalSource); vector->sharedController->release(); vector->sharedController = 0; IOLockUnlock(vector->interruptLock); return error; } // If there was an original consumer try to register it on the shared controller. if (wasAlreadyRegisterd) { error = vector->sharedController->registerInterrupt(originalNub, originalSource, vector->target, vector->handler, vector->refCon); // If the original consumer could not be moved to the shared controller, // put the original consumor's interrupt back to normal and // get rid of whats left of the shared controller. if (error != kIOReturnSuccess) { // Save the driver's interrupt enablement state. wasDisabledSoft = vector->interruptDisabledSoft; // Make the interrupt really hard disabled. vector->interruptDisabledSoft = 1; vector->interruptDisabledHard = 1; // Enable the original consumer's interrupt if needed. if (!wasDisabledSoft) originalNub->enableInterrupt(originalSource); enableInterrupt(originalNub, originalSource); vector->sharedController->release(); vector->sharedController = 0; IOLockUnlock(vector->interruptLock); return error; } } // Fill in vector with the shared controller's info. vector->handler = (IOInterruptHandler)vector->sharedController->getInterruptHandlerAddress(); vector->nub = vector->sharedController; vector->source = 0; vector->target = vector->sharedController; vector->refCon = 0; // If the interrupt was already registered, // save the driver's interrupt enablement state. if (wasAlreadyRegisterd) wasDisabledSoft = vector->interruptDisabledSoft; else wasDisabledSoft = true; // Do any specific initalization for this vector if it has not yet been used. if (!wasAlreadyRegisterd) initVector(vectorNumber, vector); // Make the interrupt really hard disabled. vector->interruptDisabledSoft = 1; vector->interruptDisabledHard = 1; vector->interruptRegistered = 1; // Enable the original consumer's interrupt if needed. // originalNub is protected by wasAlreadyRegisterd here (see line 184). if (!wasDisabledSoft) originalNub->enableInterrupt(originalSource); } error = vector->sharedController->registerInterrupt(nub, source, target, handler, refCon); IOLockUnlock(vector->interruptLock); return error; } // Fill in vector with the client's info. vector->handler = handler; vector->nub = nub; vector->source = source; vector->target = target; vector->refCon = refCon; // Do any specific initalization for this vector. initVector(vectorNumber, vector); // Get the vector ready. It starts hard disabled. vector->interruptDisabledHard = 1; vector->interruptDisabledSoft = 1; vector->interruptRegistered = 1; IOLockUnlock(vector->interruptLock); return kIOReturnSuccess; }
IOReturn AppleKiwiATA::message (UInt32 type, IOService* provider, void* argument) { switch( type ) { case kATARemovedEvent: DLOG( "AppleKiwiATA got remove event.\n"); // mark the bus as dead. if(isBusOnline == true) { isBusOnline = false; // lock the queue, don't dispatch immediates or anything else. _queueState = IOATAController::kQueueLocked; // disable the interrupt source(s) and timers _devIntSrc->disable(); stopTimer(); _workLoop->removeEventSource(_devIntSrc); _workLoop->removeEventSource(_timer); getLock(true); stopDMA(); // disable the controller pins *globalControlReg |= 0x00000800; // LE format OSSynchronizeIO(); // flush any commands in the queue handleQueueFlush(); // if there's a command active then call through the command gate // and clean it up from inside the workloop. // if( _currentCommand != 0) { DLOG( "AppleKiwiATA Calling cleanup bus.\n"); _cmdGate->runAction( (IOCommandGate::Action) &AppleKiwiATA::cleanUpAction, 0, // arg 0 0, // arg 1 0, 0); // arg2 arg 3 } _workLoop->removeEventSource(_cmdGate); getLock(false); DLOG( "AppleKiwiATA notify the clients.\n"); terminate( ); getProvider()->message( 'ofln', 0 ); } break; default: DLOG( "AppleKiwiATA got some other event = %d\n", (int) type); return super::message(type, provider, argument); break; } return kATANoErr; }
bool AppleKiwiATA::start(IOService *provider) { DLOG("AppleKiwiATA::start() begin\n"); if( ! provider->open(this) ) { DLOG("AppleKiwiATA provider did not open\n"); getProvider()->message( 'fail', 0 ); return false; } chipRoot = (AppleKiwiRoot*) getProvider()->getProvider(); ATADeviceNub* newNub=0L; // GET a lock before calling the start on the superclass: getLock(true); // call start on the superclass if (!super::start( provider)) { DLOG("AppleKiwiATA: super::start() failed\n"); goto failurePath; } // Find the interrupt source and attach it to the command gate if( ! createDeviceInterrupt() ) { DLOG("AppleKiwiATA: createDeviceInterrupts failed\n"); goto failurePath; } DLOG("AppleKiwiATA::start() done\n"); getLock( false ); // the nubs will call in on handleCommand and take a lock seperately for each identifyDevice command that they issue. for( UInt32 i = 0; i < 2; i++) { if( _devInfo[i].type != kUnknownATADeviceType ) { DLOG("AppleKiwiATA creating nub\n"); newNub = ATADeviceNub::ataDeviceNub( (IOATAController*)this, (ataUnitID) i, _devInfo[i].type ); if( newNub ) { DLOG("AppleKiwiATA attach nub\n"); newNub->attach(this); _nub[i] = (IOATADevice*) newNub; DLOG("AppleKiwiATA register nub\n"); newNub->registerService(); newNub = 0L; } } } getProvider()->message( 'onli', 0 ); return true; failurePath: getProvider()->message( 'fail', 0 ); getLock( false ); return false; }
IOReturn IODVDBlockStorageDriver::sendKey(IOMemoryDescriptor *buffer,const DVDKeyClass keyClass, const UInt8 agid,const DVDKeyFormat keyFormat) { return(getProvider()->sendKey(buffer,keyClass,agid,keyFormat)); }
IOWorkLoop *net_habitue_device_SC101::getWorkLoop() { return ((net_habitue_driver_SC101 *)getProvider())->getWorkLoop(); }
IOReturn VNodeDiskDeviceClass::doEjectMedia(void) { VNodeDiskControllerClass * provider = (VNodeDiskControllerClass *) getProvider(); provider->deleteVNodeWithFilePath(m_filePath->getCStringNoCopy()); return kIOReturnSuccess; }
int main(int argc, char *argv[], char *envp[]) { register char *pl, *pr, *p, x; #ifdef AK auto FILE *f = fopen("/www/log/isdn.log", "r"); #else auto FILE *f = fopen("/var/log/isdn.log", "r"); #endif auto char s[BUFSIZ], sx[BUFSIZ]; auto int i, l, col, day, lday = UNKNOWN, month, lmonth = UNKNOWN; auto double dur; auto char *version; auto char *myname = basename(argv[0]); auto int opt, go, s0, indent; auto time_t now; auto struct tm *tm; if (f != (FILE *)NULL) { while ((opt = getopt(argc, argv, options)) != EOF) switch (opt) { case 'n' : onlynumbers++; break; case 'v' : verbose = atoi(optarg); break; case 'V' : print_version(myname); exit(0); case 'i' : showincoming++; break; case 'o' : showoutgoing++; break; case 'e' : showerrors++; break; case 'a' : showincoming = showoutgoing = showerrors = 1; break; case 'N' : strcpy(onlythis, optarg); break; case 'm' : netto++; break; case 'f' : force++; break; case 't' : onlytoday++; break; case 'I' : onlyInternal++; break; case 'E' : onlyExternal++; break; case '?' : printf(usage, argv[0], argv[0], options); return(1); } /* switch */ if (!showincoming && !showoutgoing && !showerrors) { printf("This makes no sense! You must specify -i, -o or -e\n"); printf("\t-a -> alle Verbindungen anzeigen i.e. \"-ioe\"\n"); printf("\t -> show all connections\n"); printf("\t-e -> nichtzustandegekommene Verbindungen anzeigen\n"); printf("\t -> show incomplete calls\n"); printf("\t-f -> Verbindungsentgeld _immer_ neu berechnen\n"); printf("\t -> recalculate costs _always_\n"); printf("\t-i -> reinkommende Verbindungen anzeigen\n"); printf("\t -> show incoming calls\n"); printf("\t-m -> ohne MwSt anzeigen\n"); printf("\t -> prices without VAT\n"); printf("\t-n -> _nicht_ anstelle Rufnummern Alias-Bezeichnungen anzeigen\n"); printf("\t -> do _not_ replace numbers with aliases\n"); printf("\t-o -> rausgehende Verbindungen anzeigen\n"); printf("\t -> show outgoing calls\n"); printf("\t-t -> nur die heutigen Verbindungen anzeigen\n"); printf("\t -> show only current connections\n"); printf("\t-vn -> Verbose Level\n"); printf("\t-Nnnn -> nur Verbindungen mit _dieser_ Rufnummer anzeigen\n"); printf("\t -> show only calls with the specified number\n"); printf("\t-I -> nur Verbindungen am Internen S0-Bus anzeigen\n"); printf("\t -> show only calls on the internal S0 bus\n"); printf("\t-E -> nur Verbindungen am Externen S0-Bus anzeigen\n"); printf("\t -> show only calls on the external S0 bus\n"); printf("\t-V -> Version anzeigen\n"); printf("\t -> show version\n"); return(1); } /* if */ *home = 0; interns0 = 3; set_print_fct_for_tools(print_in_modules); if (!readconfig(myname)) { initHoliday(holifile, &version); if (verbose) fprintf(stderr, "%s\n", version); initDest(destfile, &version); if (verbose) fprintf(stderr, "%s\n", version); initRate(rateconf, ratefile, zonefile, &version); if (verbose) fprintf(stderr, "%s\n", version); memset(&msnsum, 0, sizeof(msnsum)); memset(&provsum, 0, sizeof(provsum)); memset(&zonesum, 0, sizeof(zonesum)); partner[0] = (PARTNER *)calloc(knowns, sizeof(PARTNER)); partner[1] = (PARTNER *)calloc(knowns, sizeof(PARTNER)); time(&now); tm = localtime(&now); tm->tm_sec = tm->tm_min = tm->tm_hour = 0; now = mktime(tm); while (fgets(s, BUFSIZ, f)) { pl = s; col = 0; memset(&c, 0, sizeof(c)); while ((pr = strchr(pl, '|'))) { memcpy(sx, pl, (l = (pr - pl))); sx[l] = 0; pl = pr + 1; switch (col++) { case 0 : break; case 1 : deb(sx); strcpy(c.num[CALLING], sx); break; case 2 : deb(sx); strcpy(c.num[CALLED], sx); break; case 3 : dur = atoi(sx); break; case 4 : c.duration = atol(sx) / 100; break; case 5 : c.connect = atol(sx); break; case 6 : c.units = atoi(sx); break; case 7 : c.dialout = *sx == 'O'; break; case 8 : c.cause = atoi(sx); break; case 9 : c.ibytes = atoi(sx); break; case 10 : c.obytes = atoi(sx); break; case 11 : strcpy(c.version, sx); break; case 12 : c.si1 = atoi(sx); break; case 13 : c.si2 = atoi(sx); break; case 14 : c.currency_factor = atof(sx); break; case 15 : strcpy(c.currency, sx); break; case 16 : c.pay = atof(sx); break; case 17 : c.provider = atoi(sx); break; case 18 : break; } /* switch */ } /* while */ /* Repair wrong entries from older (or current?) isdnlog-versions ... */ if (abs((int)dur - (int)c.duration) > 1) { if (verbose) fprintf(stderr, "REPAIR: Duration %f -> %f\n", c.duration, dur); c.duration = dur; } /* if */ if (!memcmp(c.num[CALLED], "+4910", 5)) { p = c.num[CALLED] + 7; x = *p; *p = 0; c.provider = atoi(c.num[CALLED] + 5); *p = x; if (strlen(c.num[CALLED]) > 7) memmove(c.num[CALLED] + 3, c.num[CALLED] + 8, strlen(c.num[CALLED]) - 7); if (verbose) fprintf(stderr, "REPAIR: Provider=%d\n", c.provider); } /* if */ if (!c.provider || (c.provider == UNKNOWN)) { if (verbose) fprintf(stderr, "REPAIR: Provider %d -> %d\n", c.provider, preselect); c.provider = preselect; } /* if */ if (c.dialout && (strlen(c.num[CALLED]) > 3) && !getSpecial(c.num[CALLED])) { sprintf(s, "0%s", c.num[CALLED] + 3); if (getSpecial(s)) { if (verbose) fprintf(stderr, "REPAIR: Callee %s -> %s\n", c.num[CALLED], s); strcpy(c.num[CALLED], s); } /* if */ } /* if */ if (!c.dialout && (strlen(c.num[CALLING]) > 3) && !getSpecial(c.num[CALLING])) { sprintf(s, "0%s", c.num[CALLING] + 3); if (getSpecial(s)) { if (verbose) fprintf(stderr, "REPAIR: Caller %s -> %s\n", c.num[CALLING], s); strcpy(c.num[CALLING], s); } /* if */ } /* if */ go = 0; if (showoutgoing && c.dialout && c.duration) go++; if (showincoming && !c.dialout && c.duration) go++; if (showerrors && !c.duration) go++; if (*onlythis && strstr(c.num[CALLING], onlythis) == NULL && strstr(c.num[CALLED], onlythis) == NULL) go = 0; if (onlytoday && c.connect < now) go = 0; s0 = 0; /* Externer S0 */ if (c.dialout && (strlen(c.num[CALLING]) < interns0)) s0 = 1; /* Interner S0-Bus */ if (!c.dialout && (strlen(c.num[CALLED]) < interns0)) s0 = 1; /* Interner S0-Bus */ if (onlyInternal && !s0) go = 0; if (onlyExternal && s0) go = 0; if (go) { when(s, &day, &month); if (lmonth == UNKNOWN) lmonth = month; else if (month != lmonth) { total(SUBTOTAL); lmonth = month; } /* if */ if (lday == UNKNOWN) lday = day; else if (day != lday) { printf("\n"); lday = day; } /* else */ printf("%s%s ", s, timestr(c.duration)); if (*c.num[CALLING]) normalizeNumber(c.num[CALLING], &number[CALLING], TN_ALL); else { memset(&number[CALLING], 0, sizeof(TELNUM)); strcpy(number[CALLING].msn, "UNKNOWN"); } /* else */ if (*c.num[CALLED]) normalizeNumber(c.num[CALLED], &number[CALLED], TN_ALL); else { memset(&number[CALLED], 0, sizeof(TELNUM)); strcpy(number[CALLED].msn, "UNKNOWN"); } /* else */ findme(); indent = 11 + strlen(c.currency); if (c.dialout) { findrate(); msnsum[SUBTOTAL][c.si1][c.ihome].ncalls++; justify(number[CALLING].msn, c.num[CALLED], number[CALLED]); provsum[SUBTOTAL][c.provider].ncalls++; strcpy(s, getProvider(pnum2prefix(c.provider, c.connect))); s[PROVLEN] = 0; if (c.provider < 100) sprintf(c.sprovider, " 010%02d:%-*s", c.provider, PROVLEN, s); else if (c.provider < 200) sprintf(c.sprovider, "0100%03d:%-*s", c.provider - 100, PROVLEN, s); else sprintf(c.sprovider, "01900%02d:%-*s", c.provider - 200, PROVLEN, s); if (c.duration) { #if 0 // Berechnung, um wieviel es mit AktivPlus der DTAG billiger waere -- stimmt irgendwie eh nicht mehr ... if ((preselect == DTAG) && ((c.zone == 1) || (c.zone == 2))) { auto struct tm *tm = localtime(&c.connect); auto int takte; auto double price; takte = (c.duration + 59) / 60; if ((tm->tm_wday > 0) && (tm->tm_wday < 5)) { /* Wochentag */ if ((tm->tm_hour > 8) && (tm->tm_hour < 18)) /* Hauptzeit */ price = 0.06; else price = 0.03; } else /* Wochenende */ price = 0.03; c.aktiv = takte * price; msnsum[SUBTOTAL][c.si1][c.ihome].aktiv += c.aktiv; provsum[SUBTOTAL][c.provider].aktiv += c.aktiv; zonesum[SUBTOTAL][c.zone].aktiv += c.aktiv; } /* if */ #endif if (c.pay < 0.0) { /* impossible! */ c.pay = c.compute; c.computed++; } /* if */ if (force || fabs(c.pay - c.compute) > 1.00) { c.pay = c.compute; c.computed++; } /* if */ if (netto) c.pay = c.pay * 100.0 / 116.0; if (c.pay) printf("%12s%s ", printRate(c.pay), c.computed ? "*" : " "); else printf("%*s", indent, ""); printf("%s%s%s", c.country, c.sprovider, c.error); #if 0 if (c.aktiv) printf(" AktivPlus - %13s", printRate(c.pay - c.aktiv)); #endif msnsum[SUBTOTAL][c.si1][c.ihome].pay += c.pay; msnsum[SUBTOTAL][c.si1][c.ihome].duration += c.duration; msnsum[SUBTOTAL][c.si1][c.ihome].compute += c.compute; msnsum[SUBTOTAL][c.si1][c.ihome].ibytes += c.ibytes; msnsum[SUBTOTAL][c.si1][c.ihome].obytes += c.obytes; provsum[SUBTOTAL][c.provider].pay += c.pay; provsum[SUBTOTAL][c.provider].duration += c.duration; provsum[SUBTOTAL][c.provider].compute += c.compute; provsum[SUBTOTAL][c.provider].ibytes += c.ibytes; provsum[SUBTOTAL][c.provider].obytes += c.obytes; zonesum[SUBTOTAL][c.zone].pay += c.pay; zonesum[SUBTOTAL][c.zone].duration += c.duration; zonesum[SUBTOTAL][c.zone].compute += c.compute; zonesum[SUBTOTAL][c.zone].ibytes += c.ibytes; zonesum[SUBTOTAL][c.zone].obytes += c.obytes; } else { printf("%*s%s%s", indent, "", c.country, c.sprovider); if ((c.cause != 0x1f) && /* Normal, unspecified */ (c.cause != 0x10)) /* Normal call clearing */ printf(" %s", qmsg(TYPE_CAUSE, VERSION_EDSS1, c.cause)); if ((c.cause == 0x22) || /* No circuit/channel available */ (c.cause == 0x2a) || /* Switching equipment congestion */ (c.cause == 0x2f)) /* Resource unavailable, unspecified */ provsum[SUBTOTAL][c.provider].failed++; } /* else */ } else { /* Dialin: */ justify(number[CALLED].msn, c.num[CALLING], number[CALLING]); printf("%*s%s%s", indent, "", c.country, c.sprovider); } /* else */ if (c.known[OTHER] == UNKNOWN) { l = UNKNOWN; for (i = 0; i < nunknown[c.dialout]; i++) { if (!strcmp(unknown[c.dialout][i].num, c.num[OTHER])) { l = i; break; } /* if */ } /* for */ if (l == UNKNOWN) { l = nunknown[c.dialout]; nunknown[c.dialout]++; if (!l) unknown[c.dialout] = (PARTNER *)malloc(sizeof(PARTNER)); else unknown[c.dialout] = (PARTNER *)realloc(unknown[c.dialout], sizeof(PARTNER) * nunknown[c.dialout]); memset(&unknown[c.dialout][l], 0, sizeof(PARTNER)); } /* if */ strcpy(unknown[c.dialout][l].num, c.num[OTHER]); unknown[c.dialout][l].ihome = c.ihome; unknown[c.dialout][l].ncalls++; unknown[c.dialout][l].pay += c.pay; unknown[c.dialout][l].duration += c.duration; unknown[c.dialout][l].compute += c.compute; unknown[c.dialout][l].ibytes += c.ibytes; unknown[c.dialout][l].obytes += c.obytes; } else { strcpy(partner[c.dialout][c.known[OTHER]].num, c.num[OTHER]); partner[c.dialout][c.known[OTHER]].ncalls++; partner[c.dialout][c.known[OTHER]].pay += c.pay; partner[c.dialout][c.known[OTHER]].duration += c.duration; partner[c.dialout][c.known[OTHER]].compute += c.compute; partner[c.dialout][c.known[OTHER]].ibytes += c.ibytes; partner[c.dialout][c.known[OTHER]].obytes += c.obytes; } /* else */ printf("\n"); } /* if */ } /* while */ fclose(f); total(SUBTOTAL); if (!onlytoday) total(TOTAL); showpartner(); } else fprintf(stderr, "%s: Can't read configuration file(s)\n", myname); } else fprintf(stderr, "%s: Can't open \"isdn.log\" file\n", myname); return(0); } /* isdnbill */
static void total(int w) { register int i, j, firsttime = 1; auto int ncalls = 0, failed = 0; auto double duration = 0.0, pay = 0.0, compute = 0.0, aktiv = 0.0; firsttime = 1; for (i = 0; i < nhome; i++) { for (j = 0; j < MAXSI; j++) { if (msnsum[w][j][i].ncalls) { if (firsttime) { firsttime = 0; printf("\n\nMSN calls Duration Charge Computed\n"); strich('-', 67); } printf("%6s,%d %-12s %5d %s %13s", msnsum[w][j][i].msn, j, msnsum[w][j][i].alias ? msnsum[w][j][i].alias : "", msnsum[w][j][i].ncalls, timestr(msnsum[w][j][i].duration), printRate(msnsum[w][j][i].pay)); if (msnsum[w][j][i].pay == msnsum[w][j][i].compute) printf("\n"); else printf(" %13s\n", printRate(msnsum[w][j][i].compute)); ncalls += msnsum[w][j][i].ncalls; duration += msnsum[w][j][i].duration; pay += msnsum[w][j][i].pay; compute += msnsum[w][j][i].compute; } /* if */ if (w == SUBTOTAL) { strcpy(msnsum[TOTAL][j][i].msn, msnsum[SUBTOTAL][j][i].msn); msnsum[TOTAL][j][i].alias = msnsum[SUBTOTAL][j][i].alias; msnsum[TOTAL][j][i].ncalls += msnsum[SUBTOTAL][j][i].ncalls; msnsum[TOTAL][j][i].duration += msnsum[SUBTOTAL][j][i].duration; msnsum[TOTAL][j][i].pay += msnsum[SUBTOTAL][j][i].pay; msnsum[TOTAL][j][i].compute += msnsum[SUBTOTAL][j][i].compute; msnsum[SUBTOTAL][j][i].ncalls = 0; msnsum[SUBTOTAL][j][i].duration = 0; msnsum[SUBTOTAL][j][i].pay = 0; msnsum[SUBTOTAL][j][i].compute = 0; } /* if */ } /* for */ } /* for */ if (!firsttime) { strich('=', 67); printf(" %5d %s %13s", ncalls, timestr(duration), printRate(pay)); if (pay == compute) printf("\n"); else printf(" %13s\n", printRate(compute)); } /* if */ ncalls = 0; failed = 0; duration = 0.0; pay = 0.0; compute = 0.0; firsttime = 1; for (i = 0; i < MAXPROVIDER; i++) { if (provsum[w][i].ncalls) { if (firsttime) { firsttime = 0; printf("\n\nProvider calls Duration Charge Computed failures avail\n"); strich('-', 93); } /* if */ if (i < 100) printf(" 010%02d", i); else if (i < 200) printf("0100%03d", i - 100); else printf("01900%02d", i - 200); printf(":%-24s", getProvider(pnum2prefix(i, c.connect))); printf("%5d %s %13s %13s %8d %5.1f%%\n", provsum[w][i].ncalls, timestr(provsum[w][i].duration), printRate(provsum[w][i].pay), printRate(provsum[w][i].compute), provsum[w][i].failed, 100.0 * (provsum[w][i].ncalls - provsum[w][i].failed) / provsum[w][i].ncalls); ncalls += provsum[w][i].ncalls; duration += provsum[w][i].duration; pay += provsum[w][i].pay; compute += provsum[w][i].compute; failed += provsum[w][i].failed; if (w == SUBTOTAL) { provsum[TOTAL][i].ncalls += provsum[SUBTOTAL][i].ncalls; provsum[TOTAL][i].duration += provsum[SUBTOTAL][i].duration; provsum[TOTAL][i].pay += provsum[SUBTOTAL][i].pay; provsum[TOTAL][i].failed += provsum[SUBTOTAL][i].failed; provsum[TOTAL][i].compute += provsum[SUBTOTAL][i].compute; provsum[SUBTOTAL][i].ncalls = 0; provsum[SUBTOTAL][i].duration = 0; provsum[SUBTOTAL][i].pay = 0; provsum[SUBTOTAL][i].failed = 0; provsum[SUBTOTAL][i].compute = 0; } /* if */ } /* if */ } /* for */ if (!firsttime) { strich('=', 93); printf("%*s%5d %s %13s %13s %8d %5.1f%%\n", 32, "", ncalls, timestr(duration), printRate(pay), printRate(compute), failed, 100.0 * (ncalls - failed) / ncalls); } /* if */ ncalls = 0; duration = 0.0; pay = 0.0; compute = 0.0; aktiv = 0; firsttime = 1; for (i = 0; i < MAXZONE; i++) { if (zonesum[w][i].ncalls) { if (firsttime) { firsttime = 0; printf("\n\nZone calls Duration Charge Computed"); if (0 /* preselect == DTAG */) { printf(" AktivPlus\n"); strich('-', 73); } else { printf("\n"); strich('-', 61); } /* else */ } /* if */ switch (i) { case 0 : printf("FreeCall "); break; case 1 : printf("Ortszone "); break; case 2 : printf("CityCall (R20) "); break; case 3 : printf("RegioCall (R50) "); break; case 4 : printf("GermanCall "); break; case 5 : printf("Sonderrufnummern"); break; case 6 : printf("Ausland "); break; case 7 : printf("elsewhere "); break; } /* switch */ printf("%5d %s %13s %13s", zonesum[w][i].ncalls, timestr(zonesum[w][i].duration), printRate(zonesum[w][i].pay), printRate(zonesum[w][i].compute)); if (0 /* preselect == DTAG */) printf(" %13s\n", printRate(zonesum[w][i].aktiv)); else printf("\n"); ncalls += zonesum[w][i].ncalls; duration += zonesum[w][i].duration; pay += zonesum[w][i].pay; compute += zonesum[w][i].compute; aktiv += zonesum[w][i].aktiv; } /* if */ if (w == SUBTOTAL) { zonesum[TOTAL][i].ncalls += zonesum[SUBTOTAL][i].ncalls; zonesum[TOTAL][i].duration += zonesum[SUBTOTAL][i].duration; zonesum[TOTAL][i].pay += zonesum[SUBTOTAL][i].pay; zonesum[TOTAL][i].compute += zonesum[SUBTOTAL][i].compute; zonesum[TOTAL][i].aktiv += zonesum[SUBTOTAL][i].aktiv; zonesum[SUBTOTAL][i].ncalls = 0; zonesum[SUBTOTAL][i].duration = 0; zonesum[SUBTOTAL][i].pay = 0; zonesum[SUBTOTAL][i].compute = 0; zonesum[SUBTOTAL][i].aktiv = 0; } /* if */ } /* for */ if (!firsttime) { strich('=', (0 /* preselect == DTAG */) ? 73 : 61); printf("%*s%5d %s %13s %13s", 16, "", ncalls, timestr(duration), printRate(pay), printRate(compute)); if (0 /* preselect == DTAG */) printf(" %13s\n", printRate(aktiv)); else printf("\n"); printf("\n\n"); } /* if */ } /* total */
virtual Ramp* clone() const override { return new Ramp(m_min, m_max, std::unique_ptr<ValueProvider>(getProvider()->clone())); }
OSSet * IOGUIDPartitionScheme::scan(SInt32 * score) { // // Scan the provider media for a GUID partition map. Returns the set // of media objects representing each of the partitions (the retain for // the set is passed to the caller), or null should no partition map be // found. The default probe score can be adjusted up or down, based on // the confidence of the scan. // IOBufferMemoryDescriptor * buffer = 0; IOByteCount bufferSize = 0; UInt32 fdiskID = 0; disk_blk0 * fdiskMap = 0; UInt64 gptBlock = 0; UInt32 gptCheck = 0; UInt32 gptCount = 0; UInt32 gptID = 0; gpt_ent * gptMap = 0; UInt32 gptSize = 0; UInt32 headerCheck = 0; gpt_hdr * headerMap = 0; UInt32 headerSize = 0; IOMedia * media = getProvider(); UInt64 mediaBlockSize = media->getPreferredBlockSize(); bool mediaIsOpen = false; OSSet * partitions = 0; IOReturn status = kIOReturnError; // Determine whether this media is formatted. if ( media->isFormatted() == false ) goto scanErr; // Determine whether this media has an appropriate block size. if ( (mediaBlockSize % sizeof(disk_blk0)) ) goto scanErr; // Allocate a buffer large enough to hold one map, rounded to a media block. bufferSize = IORound(sizeof(disk_blk0), mediaBlockSize); buffer = IOBufferMemoryDescriptor::withCapacity( /* capacity */ bufferSize, /* withDirection */ kIODirectionIn ); if ( buffer == 0 ) goto scanErr; // Allocate a set to hold the set of media objects representing partitions. partitions = OSSet::withCapacity(8); if ( partitions == 0 ) goto scanErr; // Open the media with read access. mediaIsOpen = open(this, 0, kIOStorageAccessReader); if ( mediaIsOpen == false ) goto scanErr; // Read the protective map into our buffer. status = media->read(this, 0, buffer); if ( status != kIOReturnSuccess ) goto scanErr; fdiskMap = (disk_blk0 *) buffer->getBytesNoCopy(); // Determine whether the protective map signature is present. if ( OSSwapLittleToHostInt16(fdiskMap->signature) != DISK_SIGNATURE ) { goto scanErr; } // Scan for valid partition entries in the protective map. for ( unsigned index = 0; index < DISK_NPART; index++ ) { if ( fdiskMap->parts[index].systid ) { if ( fdiskMap->parts[index].systid == 0xEE ) { if ( fdiskID ) goto scanErr; fdiskID = index + 1; } } } if ( fdiskID == 0 ) goto scanErr; // Read the partition header into our buffer. status = media->read(this, mediaBlockSize, buffer); if ( status != kIOReturnSuccess ) goto scanErr; headerMap = (gpt_hdr *) buffer->getBytesNoCopy(); // Determine whether the partition header signature is present. if ( memcmp(headerMap->hdr_sig, GPT_HDR_SIG, strlen(GPT_HDR_SIG)) ) { goto scanErr; } // Determine whether the partition header size is valid. headerCheck = OSSwapLittleToHostInt32(headerMap->hdr_crc_self); headerSize = OSSwapLittleToHostInt32(headerMap->hdr_size); if ( headerSize < offsetof(gpt_hdr, padding) ) { goto scanErr; } if ( headerSize > mediaBlockSize ) { goto scanErr; } // Determine whether the partition header checksum is valid. headerMap->hdr_crc_self = 0; if ( crc32(0, headerMap, headerSize) != headerCheck ) { goto scanErr; } // Determine whether the partition entry size is valid. gptCheck = OSSwapLittleToHostInt32(headerMap->hdr_crc_table); gptSize = OSSwapLittleToHostInt32(headerMap->hdr_entsz); if ( gptSize < sizeof(gpt_ent) ) { goto scanErr; } if ( gptSize > UINT16_MAX ) { goto scanErr; } // Determine whether the partition entry count is valid. gptBlock = OSSwapLittleToHostInt64(headerMap->hdr_lba_table); gptCount = OSSwapLittleToHostInt32(headerMap->hdr_entries); if ( gptCount > UINT16_MAX ) { goto scanErr; } // Allocate a buffer large enough to hold one map, rounded to a media block. buffer->release(); bufferSize = IORound(gptCount * gptSize, mediaBlockSize); buffer = IOBufferMemoryDescriptor::withCapacity( /* capacity */ bufferSize, /* withDirection */ kIODirectionIn ); if ( buffer == 0 ) goto scanErr; // Read the partition header into our buffer. status = media->read(this, gptBlock * mediaBlockSize, buffer); if ( status != kIOReturnSuccess ) goto scanErr; gptMap = (gpt_ent *) buffer->getBytesNoCopy(); // Determine whether the partition entry checksum is valid. if ( crc32(0, gptMap, gptCount * gptSize) != gptCheck ) { goto scanErr; } // Scan for valid partition entries in the partition map. for ( gptID = 1; gptID <= gptCount; gptID++ ) { gptMap = (gpt_ent *) ( ((UInt8 *) buffer->getBytesNoCopy()) + (gptID * gptSize) - gptSize ); uuid_unswap( gptMap->ent_type ); uuid_unswap( gptMap->ent_uuid ); if ( isPartitionUsed( gptMap ) ) { // Determine whether the partition is corrupt (fatal). if ( isPartitionCorrupt( gptMap, gptID ) ) { goto scanErr; } // Determine whether the partition is invalid (skipped). if ( isPartitionInvalid( gptMap, gptID ) ) { continue; } // Create a media object to represent this partition. IOMedia * newMedia = instantiateMediaObject( gptMap, gptID ); if ( newMedia ) { partitions->setObject(newMedia); newMedia->release(); } } } // Release our resources. close(this); buffer->release(); return partitions; scanErr: // Release our resources. if ( mediaIsOpen ) close(this); if ( partitions ) partitions->release(); if ( buffer ) buffer->release(); return 0; }
IOMedia * IOGUIDPartitionScheme::instantiateMediaObject( gpt_ent * partition, UInt32 partitionID ) { // // Instantiate a new media object to represent the given partition. // IOMedia * media = getProvider(); UInt64 mediaBlockSize = media->getPreferredBlockSize(); UInt64 partitionBase = 0; uuid_string_t partitionHint; char partitionName[36 * 3 + 1]; UInt64 partitionSize = 0; ucs2_to_utf8( partition->ent_name, sizeof(partition->ent_name), partitionName, sizeof(partitionName), UCS_LITTLE_ENDIAN ); uuid_unparse( partition->ent_type, partitionHint ); // Compute the relative byte position and size of the new partition. partitionBase = OSSwapLittleToHostInt64(partition->ent_lba_start); partitionSize = OSSwapLittleToHostInt64(partition->ent_lba_end); partitionBase *= mediaBlockSize; partitionSize *= mediaBlockSize; partitionSize -= partitionBase - mediaBlockSize; // Create the new media object. IOMedia * newMedia = instantiateDesiredMediaObject( /* partition */ partition, /* partitionID */ partitionID ); if ( newMedia ) { if ( newMedia->init( /* base */ partitionBase, /* size */ partitionSize, /* preferredBlockSize */ mediaBlockSize, /* attributes */ media->getAttributes(), /* isWhole */ false, /* isWritable */ media->isWritable(), /* contentHint */ partitionHint ) ) { // Set a name for this partition. char name[24]; snprintf(name, sizeof(name), "Untitled %d", (int) partitionID); newMedia->setName(partitionName[0] ? partitionName : name); // Set a location value (the partition number) for this partition. char location[12]; snprintf(location, sizeof(location), "%d", (int) partitionID); newMedia->setLocation(location); // Set the "Base" key for this partition. newMedia->setProperty(kIOMediaBaseKey, partitionBase, 64); // Set the "Partition ID" key for this partition. newMedia->setProperty(kIOMediaPartitionIDKey, partitionID, 32); // Set the "Universal Unique ID" key for this partition. uuid_string_t uuid; uuid_unparse(partition->ent_uuid, uuid); newMedia->setProperty(kIOMediaUUIDKey, uuid); } else { newMedia->release(); newMedia = 0; } } return newMedia; }
Clamp(std::vector<std::unique_ptr<ValueProvider>>&& provider) : MultiProvider(std::move(provider)) { if(getProvider().size() != 3) throw std::runtime_error(utility::replace(utility::translateKey("ThreeChilds"), "Clamp")); }
IOReturn IOHIDevice::setParamProperties( OSDictionary * dict ) { IOHIDEventService * eventService = NULL; if ( dict->getObject(kIOHIDEventServicePropertiesKey) == NULL ) { IOService * service = getProvider(); if ( service ) eventService = OSDynamicCast(IOHIDEventService, service); } if ( dict->getObject(kIOHIDDeviceParametersKey) == kOSBooleanTrue ) { OSDictionary * deviceParameters = OSDynamicCast(OSDictionary, copyProperty(kIOHIDParametersKey)); if ( !deviceParameters ) { deviceParameters = OSDictionary::withCapacity(4); } else { if (deviceParameters->setOptions(0, 0) & OSDictionary::kImmutable) { OSDictionary * temp = deviceParameters; deviceParameters = OSDynamicCast(OSDictionary, temp->copyCollection()); temp->release(); } else { // do nothing } } if ( deviceParameters ) { // RY: Because K&M Prefs and Admin still expect device props to be // top level, let's continue to set them via setProperty. When we get // Max to migrate over, we can remove the interator code and use: // deviceParameters->merge(dict); // deviceParameters->removeObject(kIOHIDResetKeyboardKey); // deviceParameters->removeObject(kIOHIDResetPointerKey); // setProperty(kIOHIDParametersKey, deviceParameters); // deviceParameters->release(); OSCollectionIterator * iterator = OSCollectionIterator::withCollection(dict); if ( iterator ) { OSSymbol * key; while ( ( key = (OSSymbol *)iterator->getNextObject() ) ) if ( !key->isEqualTo(kIOHIDResetKeyboardKey) && !key->isEqualTo(kIOHIDResetPointerKey) && !key->isEqualTo(kIOHIDScrollResetKey) && !key->isEqualTo(kIOHIDDeviceParametersKey) && !key->isEqualTo(kIOHIDResetLEDsKey) && !key->isEqualTo(kIOUserClientClassKey) && !key->isEqualTo(kIOClassKey) && !key->isEqualTo(kIOProviderClassKey) && !key->isEqualTo(kIOKitDebugKey)) { OSObject * value = dict->getObject(key); deviceParameters->setObject(key, value); setProperty(key, value); } iterator->release(); } setProperty(kIOHIDParametersKey, deviceParameters); deviceParameters->release(); // RY: Propogate up to IOHIDEventService level if ( eventService ) eventService->setSystemProperties(dict); } else { return kIOReturnNoMemory; } } return( kIOReturnSuccess ); }
bool IOPlatformDevice::compareName( OSString * name, OSString ** matched ) const { return( ((IOPlatformExpert *)getProvider())-> compareNubName( this, name, matched )); }
void net_habitue_device_SC101::doSubmitIO(outstanding_io *io) { bool isWrite = (io->buffer->getDirection() == kIODirectionOut); UInt32 ioLen = (io->nblks * SECTOR_SIZE); mbuf_t m; retryResolve(); if (isWrite) { KDEBUG("%p write %d %d (%d)", io, io->block, io->nblks, _outstandingCount); psan_put_t req; bzero(&req, sizeof(req)); req.ctrl.cmd = PSAN_PUT; req.ctrl.seq = ((net_habitue_driver_SC101 *)getProvider())->getSequenceNumber(); req.ctrl.len_power = POWER_OF_2(ioLen); req.sector = htonl(io->block); if (mbuf_allocpacket(MBUF_WAITOK, sizeof(req) + ioLen, NULL, &m) != 0) KINFO("mbuf_allocpacket failed!"); // TODO(iwade) handle if (mbuf_copyback(m, 0, sizeof(req), &req, MBUF_WAITOK) != 0) KINFO("mbuf_copyback failed!"); // TODO(iwade) handle if (!mbuf_buffer(io->buffer, 0, m, sizeof(req), ioLen)) KINFO("mbuf_buffer failed"); // TODO(iwade) handle io->outstanding.seq = ntohs(req.ctrl.seq); io->outstanding.len = sizeof(psan_put_response_t); io->outstanding.cmd = PSAN_PUT_RESPONSE; } else { KDEBUG("%p read %d %d (%d)", io, io->block, io->nblks, _outstandingCount); psan_get_t req; bzero(&req, sizeof(req)); req.ctrl.cmd = PSAN_GET; req.ctrl.seq = ((net_habitue_driver_SC101 *)getProvider())->getSequenceNumber(); req.ctrl.len_power = POWER_OF_2(ioLen); req.sector = htonl(io->block); if (mbuf_allocpacket(MBUF_WAITOK, sizeof(req), NULL, &m) != 0) KINFO("mbuf_allocpacket failed!"); // TODO(iwade) handle if (mbuf_copyback(m, 0, sizeof(req), &req, MBUF_WAITOK) != 0) KINFO("mbuf_copyback failed!"); // TODO(iwade) handle io->outstanding.seq = ntohs(req.ctrl.seq); io->outstanding.len = sizeof(psan_get_response_t) + ioLen; io->outstanding.cmd = PSAN_GET_RESPONSE; } io->outstanding.packetHandler = OSMemberFunctionCast(PacketHandler, this, &net_habitue_device_SC101::handleAsyncIOPacket); io->outstanding.timeoutHandler = OSMemberFunctionCast(TimeoutHandler, this, &net_habitue_device_SC101::handleAsyncIOTimeout); io->outstanding.target = this; io->outstanding.ctx = io; io->outstanding.timeout_ms = io->timeout_ms; ((net_habitue_driver_SC101 *)getProvider())->sendPacket((sockaddr_in *)io->addr->getBytesNoCopy(), m, &io->outstanding); }
IOReturn IOPlatformDevice::getResources( void ) { return( ((IOPlatformExpert *)getProvider())->getNubResources( this )); }
IOReturn IODVDBlockStorageDriver::readStructure(IOMemoryDescriptor *buffer,const DVDStructureFormat format, const UInt32 address,const UInt8 layer,const UInt8 agid) { return(getProvider()->readDVDStructure(buffer,format,address,layer,agid)); }
OSSet * IOFDiskPartitionScheme::scan(SInt32 * score) { // // Scan the provider media for an FDisk partition map. Returns the set // of media objects representing each of the partitions (the retain for // the set is passed to the caller), or null should no partition map be // found. The default probe score can be adjusted up or down, based on // the confidence of the scan. // IOBufferMemoryDescriptor * buffer = 0; UInt32 bufferSize = 0; UInt32 fdiskBlock = 0; UInt32 fdiskBlockExtn = 0; UInt32 fdiskBlockNext = 0; UInt32 fdiskID = 0; disk_blk0 * fdiskMap = 0; IOMedia * media = getProvider(); UInt64 mediaBlockSize = media->getPreferredBlockSize(); bool mediaIsOpen = false; OSSet * partitions = 0; IOReturn status = kIOReturnError; // Determine whether this media is formatted. if ( media->isFormatted() == false ) goto scanErr; // Determine whether this media has an appropriate block size. if ( (mediaBlockSize % sizeof(disk_blk0)) ) goto scanErr; // Allocate a buffer large enough to hold one map, rounded to a media block. bufferSize = IORound(sizeof(disk_blk0), mediaBlockSize); buffer = IOBufferMemoryDescriptor::withCapacity( /* capacity */ bufferSize, /* withDirection */ kIODirectionIn ); if ( buffer == 0 ) goto scanErr; // Allocate a set to hold the set of media objects representing partitions. partitions = OSSet::withCapacity(4); if ( partitions == 0 ) goto scanErr; // Open the media with read access. mediaIsOpen = open(this, 0, kIOStorageAccessReader); if ( mediaIsOpen == false ) goto scanErr; // Scan the media for FDisk partition map(s). do { // Read the next FDisk map into our buffer. status = media->read(this, fdiskBlock * mediaBlockSize, buffer); if ( status != kIOReturnSuccess ) goto scanErr; fdiskMap = (disk_blk0 *) buffer->getBytesNoCopy(); // Determine whether the partition map signature is present. if ( OSSwapLittleToHostInt16(fdiskMap->signature) != DISK_SIGNATURE ) { goto scanErr; } // Scan for valid partition entries in the partition map. fdiskBlockNext = 0; for ( unsigned index = 0; index < DISK_NPART; index++ ) { // Determine whether this is an extended (vs. data) partition. if ( isPartitionExtended(fdiskMap->parts + index) ) // (extended) { // If peer extended partitions exist, we accept only the first. if ( fdiskBlockNext == 0 ) // (no peer extended partition) { fdiskBlockNext = fdiskBlockExtn + OSSwapLittleToHostInt32( /* data */ fdiskMap->parts[index].relsect ); if ( fdiskBlockNext * mediaBlockSize >= media->getSize() ) { fdiskBlockNext = 0; // (exceeds confines of media) } } } else if ( isPartitionUsed(fdiskMap->parts + index) ) // (data) { // Prepare this partition's ID. fdiskID = ( fdiskBlock == 0 ) ? (index + 1) : (fdiskID + 1); // Determine whether the partition is corrupt (fatal). if ( isPartitionCorrupt( /* partition */ fdiskMap->parts + index, /* partitionID */ fdiskID, /* fdiskBlock */ fdiskBlock ) ) { goto scanErr; } // Determine whether the partition is invalid (skipped). if ( isPartitionInvalid( /* partition */ fdiskMap->parts + index, /* partitionID */ fdiskID, /* fdiskBlock */ fdiskBlock ) ) { continue; } // Create a media object to represent this partition. IOMedia * newMedia = instantiateMediaObject( /* partition */ fdiskMap->parts + index, /* partitionID */ fdiskID, /* fdiskBlock */ fdiskBlock ); if ( newMedia ) { partitions->setObject(newMedia); newMedia->release(); } } } // Prepare for first extended partition, if any. if ( fdiskBlock == 0 ) { fdiskID = DISK_NPART; fdiskBlockExtn = fdiskBlockNext; } } while ( (fdiskBlock = fdiskBlockNext) ); // Release our resources. close(this); buffer->release(); return partitions; scanErr: // Release our resources. if ( mediaIsOpen ) close(this); if ( partitions ) partitions->release(); if ( buffer ) buffer->release(); return 0; }
/*--------------------------------------------------------------------------- * * Intercept the setup for the control register pointers so we can set the * timing register in the cell to some safe value prior to scanning for devices * start. * * ---------------------------------------------------------------------------*/ bool AppleKiwiATA::configureTFPointers(void) { DLOG("AppleKiwiATA config TF Pointers \n"); OSString* locationCompare = OSString::withCString( "1" ); if( locationCompare->isEqualTo( getProvider()->getLocation() )) { busChildNumber = 1; } locationCompare->release(); locationCompare = NULL; DLOG("AppleKiwiATA busChildNumber = %d, string = %1s \n", busChildNumber, getProvider()->getLocation()); ioBaseAddrMap[0] = getProvider()->mapDeviceMemoryWithIndex( busChildNumber == 0 ? 0 : 2 ); if ( ioBaseAddrMap[0] == NULL ) { return false; } volatile UInt8* baseAddress = (volatile UInt8*)ioBaseAddrMap[0]->getVirtualAddress(); _tfDataReg = (volatile UInt16*) (baseAddress + 0x00); _tfFeatureReg = baseAddress + 0x01; _tfSCountReg = baseAddress + 0x02; _tfSectorNReg = baseAddress + 0x03; _tfCylLoReg = baseAddress + 0x04; _tfCylHiReg = baseAddress + 0x05; _tfSDHReg = baseAddress + 0x06; _tfStatusCmdReg = baseAddress + 0x07; DLOG("AppleKiwiATA base address 0 = %lX \n", baseAddress); // get the address of the alt-status register from the second base address. ioBaseAddrMap[1] = getProvider()->mapDeviceMemoryWithIndex( busChildNumber == 0 ? 1 : 3 ); if ( ioBaseAddrMap[1] == NULL ) { return false; } baseAddress = (volatile UInt8 *)ioBaseAddrMap[1]->getVirtualAddress(); _tfAltSDevCReg = baseAddress + 2; DLOG("AppleKiwiATA base address 1 = %lX altStatus at %lx \n", baseAddress, _tfAltSDevCReg); // get the address of the BusMaster/DMA control registers from last base address. ioBaseAddrMap[2] = getProvider()->mapDeviceMemoryWithIndex( 4 ); if ( ioBaseAddrMap[2] == NULL ) { return false; } volatile UInt8* bmAddress = (volatile UInt8*)ioBaseAddrMap[2]->getVirtualAddress(); if( busChildNumber == 1) { bmAddress += 0x08; // secondary bus } DLOG("AppleKiwiATA base address 2 = %lX \n", bmAddress); _bmCommandReg = bmAddress; _bmStatusReg = bmAddress + 2; _bmPRDAddresReg = (volatile UInt32*) (bmAddress + 4); // get the address of the mmio control registers from base address 5. ioBaseAddrMap[3] = getProvider()->mapDeviceMemoryWithIndex( 5 ); if ( ioBaseAddrMap[3] == NULL ) { return false; } volatile UInt8* bar5Address = (volatile UInt8*)ioBaseAddrMap[3]->getVirtualAddress(); DLOG("AppleKiwiATA base address 5 = %lx \n", bar5Address); if( busChildNumber == 1) { globalControlReg = (volatile UInt32*) (bar5Address + 0x1208); // secondary bus timingAReg0 =(volatile UInt32*) (bar5Address + 0x120c); timingBReg0 =(volatile UInt32*) (bar5Address + 0x1210); timingAReg1 =(volatile UInt32*) (bar5Address + 0x1214); timingBReg1 =(volatile UInt32*) (bar5Address + 0x1218); } else { globalControlReg =(volatile UInt32*) (bar5Address + 0x1108); // primary bus timingAReg0 =(volatile UInt32*) (bar5Address + 0x110c); timingBReg0 =(volatile UInt32*) (bar5Address + 0x1110); timingAReg1 =(volatile UInt32*) (bar5Address + 0x1114); timingBReg1 =(volatile UInt32*) (bar5Address + 0x1118); } // enable the controller pins *globalControlReg &= (~ 0x00000800); // already LE OSSynchronizeIO(); busTimings[0].ataUltraDMASpeedMode = 32; busTimings[1].ataUltraDMASpeedMode = 32; DLOG("AppleKiwiATA GCR = %lx \n", *globalControlReg); IOSleep(50); DLOG("AppleKiwiATA configTFPointers done\n"); return true; }
IOMedia * IOFDiskPartitionScheme::instantiateMediaObject( fdisk_part * partition, UInt32 partitionID, UInt32 fdiskBlock ) { // // Instantiate a new media object to represent the given partition. // IOMedia * media = getProvider(); UInt64 mediaBlockSize = media->getPreferredBlockSize(); UInt64 partitionBase = 0; char * partitionHint = 0; UInt64 partitionSize = 0; // Compute the relative byte position and size of the new partition. partitionBase = OSSwapLittleToHostInt32(partition->relsect) + fdiskBlock; partitionSize = OSSwapLittleToHostInt32(partition->numsect); partitionBase *= mediaBlockSize; partitionSize *= mediaBlockSize; // Clip the size of the new partition if it extends past the end-of-media. if ( partitionBase + partitionSize > media->getSize() ) { partitionSize = media->getSize() - partitionBase; } // Look up a type for the new partition. char hintIndex[5]; snprintf(hintIndex, sizeof(hintIndex), "0x%02X", partition->systid & 0xFF); partitionHint = hintIndex; OSDictionary * hintTable = OSDynamicCast( /* type */ OSDictionary, /* instance */ getProperty(kIOFDiskPartitionSchemeContentTable) ); if ( hintTable ) { OSString * hintValue; hintValue = OSDynamicCast(OSString, hintTable->getObject(hintIndex)); if ( hintValue ) partitionHint = (char *) hintValue->getCStringNoCopy(); } // Create the new media object. IOMedia * newMedia = instantiateDesiredMediaObject( /* partition */ partition, /* partitionID */ partitionID, /* fdiskBlock */ fdiskBlock ); if ( newMedia ) { if ( newMedia->init( /* base */ partitionBase, /* size */ partitionSize, /* preferredBlockSize */ mediaBlockSize, /* attributes */ media->getAttributes(), /* isWhole */ false, /* isWritable */ media->isWritable(), /* contentHint */ partitionHint ) ) { // Set a name for this partition. char name[24]; snprintf(name, sizeof(name), "Untitled %d", (int) partitionID); newMedia->setName(name); // Set a location value (the partition number) for this partition. char location[12]; snprintf(location, sizeof(location), "%d", (int) partitionID); newMedia->setLocation(location); // Set the "Partition ID" key for this partition. newMedia->setProperty(kIOMediaPartitionIDKey, partitionID, 32); } else { newMedia->release(); newMedia = 0; } } return newMedia; }
Multiplier(std::vector<std::unique_ptr<ValueProvider>>&& provider) : MultiProvider(std::move(provider)) { if(getProvider().size() < 1) throw std::runtime_error(utility::replace(utility::translateKey("TwoChildsMin"), "Multiply")); }
virtual float getValue() override { float value = getProvider()->getValue(); return -1 * value; }
IOFireWireSBP2Target * IOFireWireSBP2LUN::getTarget( void ) { return (IOFireWireSBP2Target*)getProvider(); }
virtual Negate* clone() const override { return new Negate(std::unique_ptr<ValueProvider>(getProvider()->clone())); }