void transfer(std::shared_ptr<WalletInfo> walletInfo) { std::cout << InformationMsg("Note: You can type cancel at any time to " "cancel the transaction") << std::endl << std::endl; uint64_t balance = walletInfo->wallet.getActualBalance(); auto maybeAddress = getDestinationAddress(); if (!maybeAddress.isJust) { std::cout << WarningMsg("Cancelling transaction.") << std::endl; return; } std::string address = maybeAddress.x; auto maybeAmount = getTransferAmount(); if (!maybeAmount.isJust) { std::cout << WarningMsg("Cancelling transaction.") << std::endl; return; } uint64_t amount = maybeAmount.x; if (balance < amount) { std::cout << WarningMsg("You don't have enough funds to cover this " "transaction!") << std::endl << InformationMsg("Funds needed: " + formatAmount(amount)) << std::endl << SuccessMsg("Funds available: " + formatAmount(balance)) << std::endl; return; } auto maybeFee = getFee(); if (!maybeFee.isJust) { std::cout << WarningMsg("Cancelling transaction.") << std::endl; return; } uint64_t fee = maybeFee.x; if (balance < amount + fee) { std::cout << WarningMsg("You don't have enough funds to cover this " "transaction!") << std::endl << InformationMsg("Funds needed: " + formatAmount(amount + fee)) << std::endl << SuccessMsg("Funds available: " + formatAmount(balance)) << std::endl; return; } auto maybeMixin = getMixin(); if (!maybeMixin.isJust) { std::cout << WarningMsg("Cancelling transaction.") << std::endl; return; } uint16_t mixin = maybeMixin.x; auto maybeExtra = getPaymentID(); if (!maybeExtra.isJust) { std::cout << WarningMsg("Cancelling transaction.") << std::endl; return; } std::string extra = maybeExtra.x; doTransfer(mixin, address, amount, fee, extra, walletInfo); }
//HAL functions (for debugging only, direct ocp read/write, little endian data uint Vocpfifo::read(uint adr) { Vrequest<sp6adr> r(adr,0,1); initTransfer(0,r); doTransfer(); return (*(getInbuf()->posPtr())); }
int main(int argc, char **argv) { if (argc < 3) { // ###### Note: please consider adding new tests to karchivetest (so that they can be automated) // rather than here (interactive) printf("\n" " Usage :\n" " ./kziptest list /path/to/existing_file.zip tests listing an existing zip\n" " ./kziptest print-all file.zip prints contents of all files.\n" " ./kziptest print file.zip filename prints contents of one file.\n" " ./kziptest update file.zip filename update filename in file.zip.\n" " ./kziptest save file.zip save file.\n" " ./kziptest load file.zip load file.\n" " ./kziptest write file.bz2 write compressed file.\n" " ./kziptest read file.bz2 read uncompressed file.\n" ); return 1; } QCoreApplication app(argc, argv); QString command = argv[1]; if (command == QLatin1String("list")) { return doList(QFile::decodeName(argv[2])); } else if (command == QLatin1String("print-all")) { return doPrintAll(QFile::decodeName(argv[2])); } else if (command == QLatin1String("print")) { if (argc != 4) { printf("usage: kziptest print archivename filename"); return 1; } return doPrint(QFile::decodeName(argv[2]), argv[3]); } else if (command == QLatin1String("save")) { return doSave(QFile::decodeName(argv[2])); } else if (command == QLatin1String("load")) { return doLoad(QFile::decodeName(argv[2])); } else if (command == QLatin1String("write")) { return doCompress(QFile::decodeName(argv[2])); } else if (command == QLatin1String("read")) { return doUncompress(QFile::decodeName(argv[2])); } else if (command == QLatin1String("update")) { if (argc != 4) { printf("usage: kziptest update archivename filename"); return 1; } return doUpdate(QFile::decodeName(argv[2]), QFile::decodeName(argv[3])); } else if (command == QLatin1String("transfer")) { if (argc != 4) { printf("usage: kziptest transfer sourcefile destfile"); return 1; } return doTransfer(QFile::decodeName(argv[2]), QFile::decodeName(argv[3])); } else { printf("Unknown command\n"); } }
/* * ======= ACPY3_waitLinked ======== * Blocking wait for an individual transfer in a Linked transfer to finish. * Requires the individual transfer indicated by the 'waitId' * to be configured as synchronous, otherwise returns immediately. */ Void ACPY3_waitLinked(IDMA3_Handle handle, unsigned short waitId) { GT_2trace(CURTRACE, GT_ENTER, "ACPY3_waitLinked> Enter " "(handle=0x%x, waitId=%d)\n", handle, waitId); GT_assert(CURTRACE, (handle != NULL) && (waitId < handle->numTccs)); ACPY3_INSTR_CALLHOOKFXN(((ACPY3_MoreEnv *)(handle->env))->extendedHooks, handle, ACPY3_INSTR_WAITLINKED_ENTER); /* * Wait for a channel only once. Set the 'pending' flag whenever new * transfer is submitted, then clear it when ACPY3_wait* is issued. */ if (handle->transferPending == FALSE) { ACPY3_INSTR_CALLHOOKFXN(((ACPY3_MoreEnv *)(handle->env))->extendedHooks, handle, ACPY3_INSTR_WAITLINKED_EXIT); GT_0trace(CURTRACE, GT_4CLASS, "ACPY3_waitLinked> " "No transfer pending \n"); GT_0trace(CURTRACE, GT_ENTER, "ACPY3_waitLinked> Exit\n"); return; /* already waited since last start. */ } if (waitId == (handle->numTccs - 1)) { GT_0trace(CURTRACE, GT_4CLASS, "ACPY3_waitLinked> " "Waiting on the last transfer\n"); ACPY3_wait(handle); } else { doTransfer(handle); } /* * Mark channel handle state to indicate pending transfer has completed * and 'wait' done */ handle->transferPending = FALSE; ACPY3_INSTR_CALLHOOKFXN(((ACPY3_MoreEnv *)(handle->env))->extendedHooks, handle, ACPY3_INSTR_WAITLINKED_EXIT); GT_0trace(CURTRACE, GT_ENTER, "ACPY3_waitLinked> Exit\n"); }
/* * ======= ACPY3_waitLinked ======== * Blocking wait for an individual transfer in a Linked transfer to finish. * Requires the individual transfer indicated by the 'waitId' * to be configured as synchronous, otherwise returns immediately. */ Void ACPY3_waitLinked(IDMA3_Handle handle, unsigned short waitId) { Log_print2(Diags_ENTRY, "[+E] ACPY3_waitLinked> Enter " "(handle=0x%x, waitId=%d)", (IArg)handle, (IArg)waitId); Assert_isTrue((handle != NULL) && (waitId < handle->numTccs), (Assert_Id)NULL); ACPY3_INSTR_CALLHOOKFXN(((ACPY3_MoreEnv *)(handle->env))->extendedHooks, handle, ACPY3_INSTR_WAITLINKED_ENTER); /* * Wait for a channel only once. Set the 'pending' flag whenever new * transfer is submitted, then clear it when ACPY3_wait* is issued. */ if (handle->transferPending == FALSE) { ACPY3_INSTR_CALLHOOKFXN(((ACPY3_MoreEnv *)(handle->env))->extendedHooks, handle, ACPY3_INSTR_WAITLINKED_EXIT); Log_print0(Diags_USER4, "[+4] ACPY3_waitLinked> No transfer pending"); Log_print0(Diags_EXIT, "[+X] ACPY3_waitLinked> Exit"); return; /* already waited since last start. */ } if (waitId == (handle->numTccs - 1)) { Log_print0(Diags_USER4, "[+4] ACPY3_waitLinked> " "Waiting on the last transfer"); ACPY3_wait(handle); } else { doTransfer(handle); } /* * Mark channel handle state to indicate pending transfer has completed * and 'wait' done */ handle->transferPending = FALSE; ACPY3_INSTR_CALLHOOKFXN(((ACPY3_MoreEnv *)(handle->env))->extendedHooks, handle, ACPY3_INSTR_WAITLINKED_EXIT); Log_print0(Diags_EXIT, "[+X] ACPY3_waitLinked> Exit"); }
/* * ======== ACPY3_wait ======== * Wait for all submitted DMA transfer on this logical channel to complete. */ Void ACPY3_wait(IDMA3_Handle handle) { GT_1trace(CURTRACE, GT_ENTER, "ACPY3_wait> Enter " "(handle=0x%x)\n",handle); GT_assert(CURTRACE, handle != NULL); ACPY3_INSTR_CALLHOOKFXN(((ACPY3_MoreEnv *)(handle->env))->hooks,handle,\ ACPY3_INSTR_WAIT_ENTER); /* * Wait for a channel only once. Set the 'pending' flag whenever new * transfer is submitted, then clear it when ACPY3_wait* is issued. */ if (!handle->transferPending) { ACPY3_INSTR_CALLHOOKFXN(((ACPY3_MoreEnv *)(handle->env))->hooks,handle, ACPY3_INSTR_WAIT_EXIT); GT_0trace(CURTRACE, GT_4CLASS, "_ACPY3_start> No transfer" " pending\n"); GT_0trace(CURTRACE, GT_ENTER, "_ACPY3_start> Exit\n"); return; /* already waited since last start. */ } doTransfer(handle); /* * Mark channel handle state to indicate pending transfer has completed * and 'wait' done */ handle->transferPending = FALSE; ACPY3_INSTR_CALLHOOKFXN(((ACPY3_MoreEnv *)(handle->env))->hooks,handle,\ ACPY3_INSTR_WAIT_EXIT); GT_assert(CURTRACE, handle->transferPending == FALSE); GT_0trace(CURTRACE, GT_ENTER, "ACPY3_wait> Exit\n"); }
/* * ======== ACPY3_wait ======== * Wait for all submitted DMA transfer on this logical channel to complete. */ Void ACPY3_wait(IDMA3_Handle handle) { Log_print1(Diags_ENTRY, "[+E] ACPY3_wait> Enter (handle=0x%x)", (IArg)handle); Assert_isTrue(handle != NULL, (Assert_Id)NULL); ACPY3_INSTR_CALLHOOKFXN(((ACPY3_MoreEnv *)(handle->env))->hooks,handle,\ ACPY3_INSTR_WAIT_ENTER); /* * Wait for a channel only once. Set the 'pending' flag whenever new * transfer is submitted, then clear it when ACPY3_wait* is issued. */ if (!handle->transferPending) { ACPY3_INSTR_CALLHOOKFXN(((ACPY3_MoreEnv *)(handle->env))->hooks,handle, ACPY3_INSTR_WAIT_EXIT); Log_print0(Diags_USER4, "[+4] _ACPY3_start> No transfer pending"); Log_print0(Diags_EXIT, "[+X] _ACPY3_start> Exit"); return; /* already waited since last start. */ } doTransfer(handle); /* * Mark channel handle state to indicate pending transfer has completed * and 'wait' done */ handle->transferPending = FALSE; ACPY3_INSTR_CALLHOOKFXN(((ACPY3_MoreEnv *)(handle->env))->hooks,handle,\ ACPY3_INSTR_WAIT_EXIT); Assert_isTrue(handle->transferPending == FALSE, (Assert_Id)NULL); Log_print0(Diags_EXIT, "[+X] ACPY3_wait> Exit"); }
static void DMA_Thread(void *user) { for (;;) { if (diagnosticLevel >= 2) bhmMessage("I", "KinetisDMA", "DMA_Thread waiting..."); bhmWaitEvent(chState.start); if (diagnosticLevel >= 2) bhmMessage("I", "KinetisDMA", "DMA_Thread triggered..."); // A channel has requested service. Uns32 chNum = 0; dma_tcdT xferTcd; Uns32 numBytes; while (! isEmptyQue()) { // Check to see if we have recieved transfer cancel request. if (chState.cancel > 0) { initRequestQue(); // ECX transfer with error flags. if (chState.cancel == 1) { chReg->ES.bits.ERRCHN = chNum; chReg->ES.bits.ECX = 1; chReg->ES.bits.VLD = 1; } chState.cancel = 0; continue; } if (popRequest(&chNum) != 0) { bhmMessage("W", periphName, "Error: No DMA Channel available on request queue"); break; } if (diagnosticLevel >= 3) bhmMessage("I", periphName, "Servicing channel: %d", chNum); // Verify Channel TCD Data. if (! verifyChannel(chNum)) { if (diagnosticLevel >= 2) bhmMessage("W", periphName, "Channel configuration error: ES=0x%x", chReg->ES.value); sendErrorInterrupt(chNum); setBits(&(chReg->ERR.value), chNum, 1, "INT"); tcdReg[chNum].TCD_CSR.bits.ACTIVE = 0; tcdReg[chNum].TCD_CSR.bits.DONE = 1; continue; } // Set the apprioriate csr Bits. tcdReg[chNum].TCD_CSR.bits.DONE = 0; tcdReg[chNum].TCD_CSR.bits.START = 0; tcdReg[chNum].TCD_CSR.bits.ACTIVE = 1; numBytes = getNumBytes(chNum); memcpy(&xferTcd, &(tcdReg[chNum]), sizeof(dma_tcdT)); switch (tcdReg[chNum].TCD_ATTR.bits.SSIZE) { case 0x0: // 8 - bit src. doTransfer(chNum, &xferTcd, 1, numBytes); break; case 0x1: // 16 - bit src. case 0x4: // 16 - bit burst: doTransfer(chNum, &xferTcd, 2, numBytes); break; case 0x2: // 32 - bit src. doTransfer(chNum, &xferTcd, 4, numBytes); break; default: break; // should be caught in verify sections. } // Set the next address value. tcdReg[chNum].TCD_SADDR.value = xferTcd.TCD_SADDR.value + xferTcd.TCD_SLAST.value; tcdReg[chNum].TCD_DADDR.value = xferTcd.TCD_DADDR.value + xferTcd.TCD_DLASTSGA.value; // TODO: Update CITER/BITER. tcdReg[chNum].TCD_CSR.bits.ACTIVE = 0; tcdReg[chNum].TCD_CSR.bits.DONE = 1; sendDMADoneInterrupt(chNum); } } }
void transfer(std::shared_ptr<WalletInfo> walletInfo, std::vector<std::string> args) { uint16_t mixin; std::string address; uint64_t amount; uint64_t fee = CryptoNote::parameters::MINIMUM_FEE; std::string extra; /* Check we have enough args for the default required parameters */ if (args.size() >= 3) { if (parseMixin(args[0]) && parseAddress(args[1]) && parseAmount(args[2])) { mixin = std::stoi(args[0]); address = args[1]; parseAmount(args[2], amount); } else { return; } } else { std::cout << WarningMsg("Not enough arguments given!") << std::endl << "Try running just " << SuggestionMsg("transfer") << " for a walk through guide to transferring." << std::endl; return; } for (size_t i = 0; i < args.size(); i++) { if (args[i] == "-f") { if (i+1 < args.size()) { if (parseFee(args[i+1])) { parseAmount(args[i+1], fee); } else { return; } } else { std::cout << WarningMsg("Fee flag given but no fee follows!") << std::endl; return; } } else if (args[i] == "-p") { if (i+1 < args.size()) { std::vector<uint8_t> extraVec; std::string extraString; /* Convert the payment ID into an "extra" */ if (!CryptoNote::createTxExtraWithPaymentId(args[i+1], extraVec)) { std::cout << WarningMsg("Failed to parse payment ID! " "Payment ID's are 64 character " "hexadecimal strings.") << std::endl; return; } else { /* Then convert the "extra" back into a string so we can pass the argument that walletgreen expects. Note this string is not the same as the original paymentID string! */ for (auto i : extraVec) { extraString += static_cast<char>(i); } } extra = extraString; } else { std::cout << WarningMsg("Payment ID flag given but no payment " "ID follows!") << std::endl; return; } } } doTransfer(mixin, address, amount, fee, extra, walletInfo); }
void Vocpfifo::doWB() { doTransfer(); }