int archive_dump(std::string file, std::string application, std::string version, std::string date, std::string target) { try { if (!boost::filesystem::exists(target)) { if (!boost::filesystem::create_directories(target)) { std::cout << "Failed to create directory: " << target << std::endl; return -1; } std::cout << "Created folder: " << target << std::endl; } if (!boost::filesystem::is_directory(target)) { std::cout << L"Target is not a folder: " << target << std::endl; return -1; } std::string fname = file.substr(file.find_last_of("/\\")); boost::filesystem::copy_file(file, target + fname); std::string descfile = target + fname + ".txt"; if (!write_desc(utf8::cvt<std::string>(descfile), utf8::cvt<std::string>(application), utf8::cvt<std::string>(version), utf8::cvt<std::string>(date))) { std::cout << L"Failed to write description: " << target << fname << L".txt" << std::endl; return -1; } return 0; } catch (const std::exception &e) { std::cout << e.what() << std::endl; return -1; } }
/* Setup SG Desriptors for a DMA transfer * */ int setupSGDesc(pd_umem_t *umem, void *bar_ptr, unsigned int base_loc, unsigned int *tail_desc, int istx) { unsigned int next_desc, buff_addr, buff_len; int i,last = 0; if(base_loc < BRAM_BASE || base_loc > BRAM_BASE + 0x1000){ PRINT("Error: Base location for descriptor ring must be within the BRAM Adress Space\n"); return -1; } if(base_loc % 0x40 != 0){ PRINT("Error: Base location must be 16-word aligned\n"); return -1; } PRINT("Number of SG entries: %d\n", umem->nents ); // Create descriptors and write them to the BRAM memory next_desc = (unsigned int)base_loc; for(i=0;i<umem->nents;i++) { PRINT("Descriptor %d: %08x - %08x\n", i, (umem->sg[i]).addr, (umem->sg[i]).size); buff_addr = (umem->sg[i]).addr; buff_len = (umem->sg[i]).size; if(buff_len >= 0x800000){ PRINT("Error: Buffer is larger than 23 bits. Aborting\n"); return -1; } // Save the location of the tail descriptor if(i == (umem->nents - 1)){ *tail_desc = next_desc; last = 1; } write_desc(bar_ptr, next_desc, (i==0), last, buff_addr, buff_len, istx); next_desc += + 0x40; // Next descriptor is placed 16 words after current one } return 0; }
int archive_dump(std::wstring file, std::wstring application, std::wstring version, std::wstring date, std::wstring target) { if (!file_helpers::checks::exists(target)) { if (_wmkdir(target.c_str()) != 0) { std::wcout << _T("Failed to create directory: ") << target << std::endl; return -1; } std::wcout << _T("Created folder: ") << target << std::endl; } if (!file_helpers::checks::is_directory(target)) { std::wcout << _T("Target is not a folder: ") << target << std::endl; return -1; } std::wstring fname = file.substr(file.find_last_of(_T("/\\"))); if (!CopyFile(file.c_str(), (target + fname).c_str(), TRUE)) { std::wcout << _T("Failed to copy file to: ") << target << std::endl; return -1; } if (!write_desc(target + fname + _T(".txt"), strEx::wstring_to_string(application), strEx::wstring_to_string(version), strEx::wstring_to_string(date))) { std::wcout << _T("Failed to write description: ") << target << fname << _T(".txt") << std::endl; return -1; } return 0; }