int eCosBoard_erase(ecosflash_flash_bank_t *info, u32 address, u32 len) { int retval; int timeout = (len / 20480 + 1) * 1000; /*asume 20 KB/s*/ retval=loadDriver(info); if (retval!=ERROR_OK) return retval; u32 flashErr; retval=runCode(info, info->start_address+OFFSET_ERASE, info->start_address+OFFSET_ERASE+OFFSET_ERASE_SIZE, address, len, 0, &flashErr, timeout ); if (retval!=ERROR_OK) return retval; if (flashErr != 0x0) { LOG_ERROR("Flash erase failed with %d (%s)\n", flashErr, flash_errmsg(flashErr)); return ERROR_FAIL; } return ERROR_OK; }
const ScreenDriver * loadScreenDriver (const char *code, void **driverObject, const char *driverDirectory) { return loadDriver(code, driverObject, driverDirectory, driverTable, "screen", 'x', "scr", &noScreen, &noScreen.definition); }
bool AsioDrivers::loadDriver(char *name) { char dname[64]; char curName[64]; for(long i = 0; i < asioGetNumDev(); i++) { if(!asioGetDriverName(i, dname, 32) && !strcmp(name, dname)) { curName[0] = 0; getCurrentDriverName(curName); // in case we fail... removeCurrentDriver(); if(!asioOpenDriver(i, (void **)&theAsioDriver)) { curIndex = i; return true; } else { theAsioDriver = 0; if(curName[0] && strcmp(dname, curName)) loadDriver(curName); // try restore } break; } } return false; }
const SpeechDriver * loadSpeechDriver (const char *code, void **driverObject, const char *driverDirectory) { return loadDriver(code, driverObject, driverDirectory, driverTable, "speech", 's', "spk", &noSpeech, &noSpeech.definition); }
int eCosBoard_flash(ecosflash_flash_bank_t *info, void *data, u32 address, u32 len) { target_t *target=info->target; const int chunk=8192; int retval=ERROR_OK; int timeout = (chunk / 20480 + 1) * 1000; /*asume 20 KB/s + 1 second*/ retval=loadDriver(info); if (retval!=ERROR_OK) return retval; u32 buffer; retval=runCode(info, info->start_address+OFFSET_GET_WORKAREA, info->start_address+OFFSET_GET_WORKAREA+OFFSET_GET_WORKAREA_SIZE, 0, 0, 0, &buffer, 1000); if (retval!=ERROR_OK) return retval; int i; for (i=0; i<len; i+=chunk) { int t=len-i; if (t>chunk) { t=chunk; } int retval; retval=target_write_buffer(target, buffer, t, ((u8 *)data)+i); if (retval != ERROR_OK) return retval; u32 flashErr; retval=runCode(info, info->start_address+OFFSET_FLASH, info->start_address+OFFSET_FLASH+OFFSET_FLASH_SIZE, buffer, address+i, t, &flashErr, timeout); if (retval != ERROR_OK) return retval; if (flashErr != 0x0) { LOG_ERROR("Flash prog failed with %d (%s)\n", flashErr, flash_errmsg(flashErr)); return ERROR_FAIL; } } return ERROR_OK; }
TCPServer::TCPServer(QObject *parent) : QTcpServer(parent) { int port = 8888; if(!this->listen(QHostAddress::Any, port)) { qDebug() << "Could not start server"; } else { qDebug() << "Server listening on port: " << this->serverPort(); loadDriver(); } }
int loadOtherConfigs( int useDefault ) { char *val, *table; int count; char *string; int fd, ret; if (getValueForKey( "Boot Drivers", &val, &count)) { while (string = newStringFromList(&val, &count)) { ret = loadConfigDir(string, useDefault, &table, 0); if (ret >= 0) { if ((fd = openDriverReloc(string)) >= 0) { localPrintf("Loading binary for %s\n",string); if (loadDriver(string, fd) < 0) error("Error loading driver %s\n",string); close(fd); } driverWasLoaded(string, table); free(string); } else { driverIsMissing(string); } if (ret == 1) useDefault = 1; // use defaults from now on } } else { error("Warning: No active drivers specified in system config\n"); } bootArgs->first_addr0 = (int)bootArgs->configEnd + 1024; return 0; }
K runtest(K opv, K ecxv, K eaxv, K edxv, K testCount) { struct MsrInOut s_pmc_reset[9]; struct MsrInOut s_pmc_read[9]; unsigned long long s_ffc_fixed[FFC_COUNT]; unsigned long long s_pmc_fixed[PMC_COUNT]; struct MsrInOut *ptr; int i; long long count; void *handle; char *error; K result; void (*execute_test)(void (s1)(void), void(s2)(void)); // dynamically load the test library handle = dlopen("libtest.so", RTLD_NOW); //handle = dlopen("libtest.so", RTLD_LAZY); if (!handle) { krr(dlerror()); // signal exception to kdb+ return (K)0; } execute_test = dlsym(handle, "execute_test"); if ((error = dlerror()) != NULL) { krr("While locating symbof 'execute_test'"); return (K)0; } // zero the fixed-cost accumulators for (i = 0 ; i < PMC_COUNT ; i++) s_pmc_fixed[i] = 0; for (i = 0 ; i < FFC_COUNT ; i++) s_ffc_fixed[i] = 0; // set the global (static) pointers ffc_fixed = s_ffc_fixed; pmc_fixed = s_pmc_fixed; pmc_reset = s_pmc_reset; pmc_read = s_pmc_read; ptr = pmc_cfg = (struct MsrInOut*)malloc((opv->n + 1) * sizeof(struct MsrInOut)); if (pmc_cfg == NULL) { orr("malloc"); return (K)0; } record_reset(); record_read(); // record the PMC instructions to memory count = opv->n; for (i = 0 ; i < count ; i++) { wr_msrio(ptr++, kI(opv)[i], kI(ecxv)[i], kI(eaxv)[i], kI(edxv)[i]); } msr_wr_stop(ptr++); loadDriver(); if (fd == -1) { return (K)0; } result = run_test(execute_test, testCount->i); // disable and zero the PMC MSRs ioctl(fd, IOCTL_MSR_CMDS, (long long)s_pmc_reset); // return the dynamically allocated memory free(pmc_cfg); // close the dyn-lib function handle dlclose(handle); // close the MSR driver closeDriver(fd); return result; }
/** * Initializes p11 library and loads PKCS #11 driver. * * @param driver full path to the PKCS #11 driver (e.g. /usr/lib/opensc-pkcs11.so) * @throws SignException exception is thrown if the provided PKCS #11 driver * loading failed. */ digidoc::PKCS11Signer::PKCS11Signer(const std::string& driver) throw(SignException) : d(new PKCS11SignerPrivate(driver)) { DEBUG("PKCS11Signer(driver = '%s'", d->driver.c_str()); loadDriver(d->driver); }
/** * Initializes p11 library and loads PKCS #11 driver. Get driver path * from configuration. * * @throws SignException exception is thrown if the provided PKCS #11 driver * loading failed. */ digidoc::PKCS11Signer::PKCS11Signer() throw(SignException) : d(new PKCS11SignerPrivate()) { loadDriver(); DEBUG("PKCS11Signer(driver = '%s'", d->driver.c_str()); }
void digidoc::PKCS11Signer::loadDriver() throw(SignException) { if(Conf::getInstance()) d->driver = Conf::getInstance()->getPKCS11DriverPath(); loadDriver(d->driver); }