void cm_TRC_traceLoadMap( t_nmfTraceComponentCommandDescription command, const t_component_instance* component) { if(cm_trace_enabled) { struct t_nmfTraceComponent trace; /* * Generate instantiate trace */ trace.header.v = HEADER(TRACE_TYPE_COMPONENT, sizeof(trace)); trace.command = (t_uint16)command; trace.domainId = (t_uint16)component->Template->dspId + 1; trace.componentContext = (t_uint32)component->thisAddress; trace.componentUserContext = (t_uint32)component; cm_StringCopy((char*)trace.componentLocalName, component->pathname, MAX_COMPONENT_NAME_LENGTH); cm_StringCopy((char*)trace.componentTemplateName, component->Template->name, MAX_TEMPLATE_NAME_LENGTH); writeN((struct t_nmfTraceChannelHeader*)&trace); if(command == TRACE_COMPONENT_COMMAND_ADD) { struct t_nmfTraceMethod tracemethod; int i, j, k; /* * Generate method trace */ tracemethod.header.v = HEADER(TRACE_TYPE_METHOD, sizeof(tracemethod)); tracemethod.domainId = (t_uint16)component->Template->dspId + 1; tracemethod.componentContext = (t_uint32)component->thisAddress; for(i = 0; i < component->Template->provideNumber; i++) { t_interface_provide* provide = &component->Template->provides[i]; t_interface_provide_loaded* provideLoaded = &component->Template->providesLoaded[i]; for(j = 0; j < provide->collectionSize; j++) { for(k = 0; k < provide->interface->methodNumber; k++) { tracemethod.methodId = provideLoaded->indexesLoaded[j][k].methodAddresses; cm_StringCopy((char*)tracemethod.methodName, provide->interface->methodNames[k], MAX_INTERFACE_METHOD_NAME_LENGTH); writeN((struct t_nmfTraceChannelHeader*)&tracemethod); } } } } } }
void cm_TRC_traceBinding( t_nmfTraceBindCommandDescription command, const t_component_instance* clientComponent, const t_component_instance* serverComponent, const char *requiredItfName, const char *providedItfName) { if(cm_trace_enabled) { struct t_nmfTraceBind trace; trace.header.v = HEADER(TRACE_TYPE_BIND, sizeof(trace)); trace.command = (t_uint16)command; if(clientComponent == ARM_TRACE_COMPONENT) // ARM { trace.clientDomainId = 0x1; trace.clientComponentContext = 0x0; } else { trace.clientDomainId = (t_uint16)clientComponent->Template->dspId + 1; trace.clientComponentContext = (t_uint32)clientComponent->thisAddress; } if(requiredItfName != NULL) cm_StringCopy((char*)trace.requiredItfName, requiredItfName, MAX_INTERFACE_NAME_LENGTH); else trace.requiredItfName[0] = 0; if(serverComponent == NULL) { // Unbind or VOID trace.serverDomainId = 0; trace.serverComponentContext = 0x0; } else if(serverComponent == ARM_TRACE_COMPONENT) { // ARM trace.serverDomainId = 0x1; trace.serverComponentContext = 0x0; } else { trace.serverDomainId = (t_uint16)serverComponent->Template->dspId + 1; trace.serverComponentContext = (t_uint32)serverComponent->thisAddress; } if(providedItfName != NULL) cm_StringCopy((char*)trace.providedItfName, providedItfName, MAX_INTERFACE_NAME_LENGTH); else trace.providedItfName[0] = 0; writeN((struct t_nmfTraceChannelHeader*)&trace); } }
void cm_TRC_traceReset(void) { if(cm_trace_enabled) { struct t_nmfTraceReset trace; trace.header.v = HEADER(TRACE_TYPE_RESET, sizeof(trace)); trace.minorVersion = TRACE_MINOR_VERSION; trace.majorVersion = TRACE_MAJOR_VERSION; writeN((struct t_nmfTraceChannelHeader*)&trace); } }
void cm_TRC_traceMem(t_nmfTraceAllocCommandDescription command, t_uint8 allocId, t_uint32 startAddress, t_uint32 memorySize) { if(cm_trace_enabled) { struct t_nmfTraceAlloc trace; trace.header.v = HEADER(TRACE_TYPE_ALLOC, sizeof(trace)); trace.command = (t_uint16)command; trace.allocId = (t_uint16)allocId; trace.offset = startAddress; trace.size = memorySize; writeN((struct t_nmfTraceChannelHeader*)&trace); } }
void cm_TRC_traceMemAlloc(t_nmfTraceAllocatorCommandDescription command, t_uint8 allocId, t_uint32 memorySize, const char *allocname) { if(cm_trace_enabled) { struct t_nmfTraceAllocator trace; trace.header.v = HEADER(TRACE_TYPE_ALLOCATOR, sizeof(trace)); trace.command = (t_uint16)command; trace.allocId = (t_uint16)allocId; trace.size = memorySize; cm_StringCopy((char*)trace.name, allocname, sizeof(trace.name)); writeN((struct t_nmfTraceChannelHeader*)&trace); } }
void cm_TRC_traceCommunication( t_nmfTraceCommunicationCommandDescription command, t_nmf_core_id coreId, t_nmf_core_id remoteCoreId) { if(cm_trace_enabled) { struct t_nmfTraceCommunication trace; trace.header.v = HEADER(TRACE_TYPE_COMMUNICATION, sizeof(trace)); trace.command = (t_uint16)command; trace.domainId = (t_uint16)coreId + 1; trace.remoteDomainId = (t_uint16)remoteCoreId + 1; writeN((struct t_nmfTraceChannelHeader*)&trace); } }
void daemon_pipe::try_error_write(const std::string &input) { // keep signals blocked even inside our catch, so we can't // get SIGPIPE from the fwrite SignalBlocker signals; try { CHECK(m_specs.size() == 1, "specs must have 1 element"); const daemon_proc_spec_ptr &procSpec = m_specs[0]; { ProcHarvester harvester(&signals.m_sigset); file_spec_ptr pipe_spec(new file_spec); File file(pipe_spec); file.open(); file.m_writeSide->setNonBlock(); Proc &proc(harvester.addProc(procSpec)); proc.m_stdin = &file; proc.m_blockedSignals = &signals; proc.m_newPGID = 0; proc.safe_fork_exec(); file.m_readSide->reset(); int ret = ::write(file.m_writeSide->get(), input.c_str(), input.length()); CHECK(ret >= 0, "write failed: %m"); file.m_writeSide->reset(); } if(!(procSpec->finished() && WIFEXITED(procSpec->getStatus()) && WEXITSTATUS(procSpec->getStatus()) == 0)) throw failure("proc failed"); } catch(failure &f) { writeN(STDERR_FILENO, input.c_str(), input.length()); } }
void daemon_pipe::LockFile::open(const std::string &file) { m_fd.reset(::open(file.c_str(), O_CREAT|O_RDWR, 0666)); CHECK(m_fd.isOk(), "unable to open pidfile %s for writing: %m", file.c_str()); m_fd.setCloseOnExec(); int ret = ::flock(m_fd.get(), LOCK_EX | LOCK_NB); if(ret != 0) { m_fd.reset(); // close the FD so we don't truncate in destructor if(errno == EWOULDBLOCK) throw failure("process is already running (pidfile %s is locked)", file.c_str()); throw failure("unable to lock pidfile %s", file.c_str()); } CHECK(ftruncate(m_fd.get(), 0) == 0, "unable to truncate lockfile %s: %m", file.c_str()); char buf[256]; buf[sizeof(buf)-1] = '\0'; int n = snprintf(buf, sizeof(buf)-1, "%d\n", getpid()); CHECK(writeN(m_fd.get(), buf, n) == 0, "unable to write to lockfile %s: %m", file.c_str()); }
assert(this->fd == fd); SYSLOG_DEBUG("connection fd=%d flow=%d onError", fd, flow); int retval = destroy(); return retval; } int Connection::sendMessage(Message *msg) { BPROF_TRACE(BPT_CONN_SENDMESSAGE) if (outMsg == NULL && outQueue->empty()) { /* send out directly as can as possible */ gettimeofday(&msg->ts_byte_first, NULL); size_t rest = msg->getWptr() - msg->getRptr(); ssize_t wlen = writeN(msg, rest); if ((size_t)wlen == rest) { SYSLOG_DEBUG("connection fd=%d flow=%d sendMessage %ld bytes done", fd, flow, (long)rest); gettimeofday(&msg->ts_process_end, NULL); proc->onSent(msg, SS_OK); return 0; } else if ((size_t)wlen < rest) { /* send later */ SYSLOG_ERROR("connection fd=%d flow=%d sendMessage %ld bytes, done=%ld ", fd, flow, (long)rest, (long)wlen); outMsg = msg; emgr->modifyConnection(this, EVENT_OUT, 0); // watch out-able return 0;
static VOID _BlockWrite( IN PADAPTER Adapter, IN PVOID buffer, IN u32 size ) { #if 1 #ifdef SUPPORTED_BLOCK_IO u32 blockSize = MAX_REG_BOLCK_SIZE; // Use 196-byte write to download FW u32 blockSize2 = MIN_REG_BOLCK_SIZE; #else u32 blockSize = sizeof(u32); // Use 4-byte write to download FW u32* pu4BytePtr = (u32*)buffer; u32 blockSize2 = sizeof(u8); #endif u8* bufferPtr = (u8*)buffer; u32 i, offset, offset2, blockCount, remainSize, remainSize2; blockCount = size / blockSize; remainSize = size % blockSize; for(i = 0 ; i < blockCount ; i++){ offset = i * blockSize; #ifdef SUPPORTED_BLOCK_IO writeN(Adapter, (FW_8192C_START_ADDRESS + offset), blockSize, (bufferPtr + offset)); #else rtw_write32(Adapter, (FW_8192C_START_ADDRESS + offset), le32_to_cpu(*(pu4BytePtr + i))); #endif } if(remainSize){ offset2 = blockCount * blockSize; blockCount = remainSize / blockSize2; remainSize2 = remainSize % blockSize2; for(i = 0 ; i < blockCount ; i++){ offset = offset2 + i * blockSize2; #ifdef SUPPORTED_BLOCK_IO writeN(Adapter, (FW_8192C_START_ADDRESS + offset), blockSize2, (bufferPtr + offset)); #else rtw_write8(Adapter, (FW_8192C_START_ADDRESS + offset ), *(bufferPtr + offset)); #endif } if(remainSize2) { offset += blockSize2; bufferPtr += offset; for(i = 0 ; i < remainSize2 ; i++){ rtw_write8(Adapter, (FW_8192C_START_ADDRESS + offset + i), *(bufferPtr + i)); } } } #else u32 blockSize = sizeof(u32); // Use 4-byte write to download FW u8* bufferPtr = (u8*)buffer; u32* pu4BytePtr = (u32*)buffer; u32 i, offset, blockCount, remainSize; blockCount = size / blockSize; remainSize = size % blockSize; for(i = 0 ; i < blockCount ; i++){ offset = i * blockSize; rtw_write32(Adapter, (FW_8192C_START_ADDRESS + offset), le32_to_cpu(*(pu4BytePtr + i))); } if(remainSize){ offset = blockCount * blockSize; bufferPtr += offset; for(i = 0 ; i < remainSize ; i++){ rtw_write8(Adapter, (FW_8192C_START_ADDRESS + offset + i), *(bufferPtr + i)); } } #endif }