/* * Function: soc_i2c_probe * Purpose: Probe I2C devices on bus, report devices found. * This routine will walk through our internal I2C device driver * tables, attempt to find the device on the I2C bus, and if * successful, register a device driver for that device. * * This allows for the device to be used in an API context as * when the devices are found, the device driver table is filled * with the correct entries for that device (r/w function, etc). * * Parameters: * unit - StrataSwitch device number or I2C bus number * * Return: * count of found devices or SOC_E_*** */ int soc_i2c_probe(int unit) { _soc_i2c_probe_info_t i2c_probe_info; int devid; int rv; int mux_devid; uint8 mux_data; /* Make sure that we're already attached, or go get attached */ if (!soc_i2c_is_attached(unit)) { return soc_i2c_attach(unit, 0, 0); } /* Check for supported I2c devices */ if (NUM_I2C_DEVICES > MAX_I2C_DEVICES) { LOG_INFO(BSL_LS_SOC_I2C, (BSL_META_U(unit, "ERROR: %d exceeds supported I2C devices\n"), NUM_I2C_DEVICES )); return SOC_E_INTERNAL; } i2c_probe_info.i2cbus = I2CBUS(unit); LOG_INFO(BSL_LS_SOC_I2C, (BSL_META_U(unit, "unit %d i2c: probing %d I2C devices.\n"), unit, NUM_I2C_DEVICES)); /* Attempt to contact known slave devices, hookup driver and * run device init function if the device exists, otherwise * simply acknowledge the device can be found. */ i2c_probe_info.i2c_nvram_skip = soc_property_get(unit, spn_I2C_NVRAM_SKIP, 0); i2c_probe_info.i2c_hclk_skip = soc_property_get(unit, spn_I2C_HCLK_SKIP, 0); i2c_probe_info.i2c_poe_power = soc_property_get(unit, spn_I2C_POE_POWER, 0); i2c_probe_info.devid_found = 0; /* Installed I2C device types */ i2c_probe_info.devices_found = 0; /* Number of installed I2C devices */ /* Initialize device table with none found. */ for (devid = 0; devid < NUM_I2C_DEVICES; devid++) { /* I2C device not present */ i2c_probe_info.i2cbus->devs[devid] = NULL; i2c_probe_info.i2c_muxed_devid_count[devid] = 0; i2c_probe_info.i2c_mux_stack[devid] = -1; } i2c_probe_info.i2c_mux_stack_depth = 0; /* First, disable all visible MUX's. */ for (mux_devid = 0; mux_devid < NUM_I2C_DEVICES; mux_devid++) { if (i2c_devices[mux_devid].driver != &_soc_i2c_pca9548_driver) { /* Only the MUX's are interesting here. */ continue; } i2c_probe_info.devid = mux_devid; rv = _soc_i2c_probe_device(unit, FALSE, &i2c_probe_info); if (SOC_E_EXISTS == rv) { mux_data = 0; /* Shut down ALL channels */ if ((rv = i2c_devices[mux_devid].driver->write(unit, mux_devid, 0, &mux_data, 1)) < 0) { LOG_INFO(BSL_LS_SOC_I2C, (BSL_META_U(unit, "unit %d i2c: Could not disable channels on %s\n"), unit, i2c_devices[mux_devid].devname)); return rv; } else { /* MUX disabled */ rv = SOC_E_NONE; } } else if ((SOC_E_NOT_FOUND == rv) || (SOC_E_INIT == rv)) { /* No error */ rv = SOC_E_NONE; } else if (SOC_FAILURE(rv)) { /* Access error */ return rv; } } /* Reset after MUX ops */ i2c_probe_info.devid_found = 0; i2c_probe_info.devices_found = 0; /* Probe the currently configured (i.e. MUX'd) I2C bus. */ for (devid = 0; devid < NUM_I2C_DEVICES; devid++) { /* Detect device type */ i2c_probe_info.devid = devid; rv = _soc_i2c_probe_device(unit, FALSE, &i2c_probe_info); if ((SOC_E_EXISTS == rv) || (SOC_E_NOT_FOUND == rv) || (SOC_E_INIT == rv)) { /* No problem */ rv = SOC_E_NONE; } else if (SOC_FAILURE(rv)) { /* Access error */ return rv; } } /* Now we know all of the devices that aren't behind a MUX. * Anything new we find now must be behind a MUX. * Recursively scan down the MUX tree. */ if ((rv = _soc_i2c_probe_mux(unit, -1, &i2c_probe_info)) < 0) { LOG_INFO(BSL_LS_SOC_I2C, (BSL_META_U(unit, "unit %d i2c: Could not probe MUX's\n"), unit)); return rv; } return i2c_probe_info.devid_found; }
void UpdaterPrivate::LaunchUI() { LOG_INFO(Frontend, "Launching update UI..."); LaunchWithArguments(run_arguments); }
View::View(node_id_t node_id, std::string cf) : node_id_(node_id), master_id_(0), period_(500) { LOG_INFO("loading config file %s ...", cf.c_str()); YAML::Node config; if (cf.empty()) { // default only one node config = YAML::LoadFile("config/localhost-1.yaml"); node_id_ = 0; } else { config = YAML::LoadFile(cf); } if (config == NULL) { printf("cannot open config file: %s.", cf.c_str()); } YAML::Node nodes = config["host"]; YAML::Node lease = config["lease"]; for (std::size_t i = 0; i < nodes.size(); i++) { YAML::Node node = nodes[i]; std::string name = node["name"].as<std::string>(); std::string addr = node["addr"].as<std::string>(); uint32_t port = node["port"].as<int>(); // set a node in view host_info_t host_info = host_info_t(name, addr, port); host_nodes_.push_back(host_info); } size_ = host_nodes_.size(); if (lease) { master_id_ = lease["master_id"].as<int>(); period_ = lease["period"].as<int>(); } else { LOG_INFO("No lease Node Found, using default master_id/0 period/500"); } #if MODE_TYPE == 1 YAML::Node rs = config["rs"]; if (rs) { rs_x_ = rs["x"].as<int>(); rs_n_ = rs["n"].as<int>(); rs_qr_ = rs["qr"].as<int>(); rs_qw_ = rs["qw"].as<int>(); rs_f_ = rs["f"].as<int>(); } else { LOG_INFO("No RS Node Found!!, using Default function to compute"); rs_n_ = size_; if (rs_n_ == 1) { rs_x_ = 1; } else { if (rs_n_ % 2 == 0) { rs_x_ = 2; } else { rs_x_ = 3; } } rs_qr_ = (rs_n_ + rs_x_) / 2; rs_qw_ = rs_qr_; rs_f_ = rs_n_ - rs_qr_; } #endif if (node_id_ >= size_) { std::cout << "Node_Id " << node_id_ << " > host_nodes_.size " << size_ << "Invalid!" << std::endl; std::cout << "Set Node_Id = 0" << std::endl; node_id_ = 0; } LOG_INFO("config file loaded"); }
void ReplicatedMergeTreePartCheckThread::checkPart(const String & part_name) { LOG_WARNING(log, "Checking part " << part_name); ProfileEvents::increment(ProfileEvents::ReplicatedPartChecks); /// If the part is still in the PreCommitted -> Committed transition, it is not lost /// and there is no need to go searching for it on other replicas. To definitely find the needed part /// if it exists (or a part containing it) we first search among the PreCommitted parts. auto part = storage.data.getPartIfExists(part_name, {MergeTreeDataPartState::PreCommitted}); if (!part) part = storage.data.getActiveContainingPart(part_name); /// We do not have this or a covering part. if (!part) { searchForMissingPart(part_name); } /// We have this part, and it's active. We will check whether we need this part and whether it has the right data. else if (part->name == part_name) { auto zookeeper = storage.getZooKeeper(); auto table_lock = storage.lockStructure(false, __PRETTY_FUNCTION__); /// If the part is in ZooKeeper, check its data with its checksums, and them with ZooKeeper. if (zookeeper->exists(storage.replica_path + "/parts/" + part_name)) { LOG_WARNING(log, "Checking data of part " << part_name << "."); try { auto zk_checksums = MinimalisticDataPartChecksums::deserializeFrom( zookeeper->get(storage.replica_path + "/parts/" + part_name + "/checksums")); zk_checksums.checkEqual(part->checksums, true); auto zk_columns = NamesAndTypesList::parse( zookeeper->get(storage.replica_path + "/parts/" + part_name + "/columns")); if (part->columns != zk_columns) throw Exception("Columns of local part " + part_name + " are different from ZooKeeper"); checkDataPart( storage.data.getFullPath() + part_name, storage.data.index_granularity, true, storage.data.primary_key_data_types, [this] { return need_stop.load(); }); if (need_stop) { LOG_INFO(log, "Checking part was cancelled."); return; } LOG_INFO(log, "Part " << part_name << " looks good."); } catch (const Exception & e) { /// TODO Better to check error code. tryLogCurrentException(log, __PRETTY_FUNCTION__); LOG_ERROR(log, "Part " << part_name << " looks broken. Removing it and queueing a fetch."); ProfileEvents::increment(ProfileEvents::ReplicatedPartChecksFailed); storage.removePartAndEnqueueFetch(part_name); /// Delete part locally. storage.data.forgetPartAndMoveToDetached(part, "broken_"); } } else if (part->modification_time + MAX_AGE_OF_LOCAL_PART_THAT_WASNT_ADDED_TO_ZOOKEEPER < time(nullptr)) { /// If the part is not in ZooKeeper, delete it locally. /// Probably, someone just wrote down the part, and has not yet added to ZK. /// Therefore, delete only if the part is old (not very reliable). ProfileEvents::increment(ProfileEvents::ReplicatedPartChecksFailed); LOG_ERROR(log, "Unexpected part " << part_name << " in filesystem. Removing."); storage.data.forgetPartAndMoveToDetached(part, "unexpected_"); } else { /// TODO You need to make sure that the part is still checked after a while. /// Otherwise, it's possible that the part was not added to ZK, /// but remained in the filesystem and in a number of active parts. /// And then for a long time (before restarting), the data on the replicas will be different. LOG_TRACE(log, "Young part " << part_name << " with age " << (time(nullptr) - part->modification_time) << " seconds hasn't been added to ZooKeeper yet. It's ok."); } } else { /// If we have a covering part, ignore all the problems with this part. /// In the worst case, errors will still appear `old_parts_lifetime` seconds in error log until the part is removed as the old one. LOG_WARNING(log, "We have part " << part->name << " covering part " << part_name); } }
bool WaveformObjImporter::convertToPropellerModel(String filename, ModelStream &stream) { struct Float3 { float v[3]; }; struct FaceData { FaceData() {} FaceData(unsigned vertexIndex, unsigned texCoordIndex, unsigned normalIndex) : vertexIndex(vertexIndex) , texCoordIndex(texCoordIndex) , normalIndex(normalIndex) { } unsigned vertexIndex; unsigned texCoordIndex; unsigned normalIndex; }; struct Face { FaceData v[3]; }; LOG_INFO("importing file from .obj!"); std::ifstream file(filename); //HACK: Editor is windows only, not using wrappers if (!file.is_open()) return false; std::vector<Float3> objVertices; std::vector<Float3> objTexCoords; std::vector<Float3> objNormals; std::vector<Face> objFaces; String line; while (std::getline(file, line)) { if (line.substr(0, 1) == "#") continue; // comment if (line.substr(0, 2) == "v ") { std::vector<String> parts; engine::util::explode(&parts, line, ' '); Float3 f3; f3.v[0] = boost::lexical_cast<float>(parts[1]); f3.v[1] = boost::lexical_cast<float>(parts[2]); f3.v[2] = boost::lexical_cast<float>(parts[3]); objVertices.push_back(f3); continue; } if (line.substr(0, 3) == "vn ") { std::vector<String> parts; engine::util::explode(&parts, line, ' '); Float3 f3; f3.v[0] = boost::lexical_cast<float>(parts[1]); f3.v[1] = boost::lexical_cast<float>(parts[2]); f3.v[2] = boost::lexical_cast<float>(parts[3]); objNormals.push_back(f3); continue; } if (line.substr(0, 3) == "vt ") { std::vector<String> parts; engine::util::explode(&parts, line, ' '); Float3 f3; f3.v[0] = boost::lexical_cast<float>(parts[1]); f3.v[1] = boost::lexical_cast<float>(parts[2]); f3.v[2] = boost::lexical_cast<float>(parts[3]); objTexCoords.push_back(f3); continue; } if (line.substr(0, 2) == "f ") { std::vector<String> parts; engine::util::explode(&parts, line, ' '); String faceStrings[3]; faceStrings[0] = parts[1]; faceStrings[1] = parts[2]; faceStrings[2] = parts[3]; Face face; for (unsigned i = 0; i < 3; ++i) { std::vector <String> parts; engine::util::explode(&parts, faceStrings[i], '/'); face.v[i] = FaceData(boost::lexical_cast<unsigned>(parts[0]), boost::lexical_cast<unsigned>(parts[1]), boost::lexical_cast<unsigned>(parts[2])); } objFaces.push_back(face); continue; } DEBUG_PRINT("Line ignored: " << line); } LOG_INFO("Reading data from .obj file done."); // .PropellerModel header stream.write(PROPELLER_MODEL_IDENTIFIER, PROPELLER_MODEL_IDENTIFIER_SIZE); stream.write(unsigned(2)); //This is version 1 writer // face is one vertex, vertex has 3 floats, 3 normal and 3 texCoords floats(4bit). // 3 * 9 -> 27 stream.write(unsigned(objFaces.size() * 27)); for (unsigned i = 0; i < objFaces.size(); ++i) { // vertex 3 + normal + 3 (float) //DEBUG_PRINT("write > face: " << i << "vertexIndex:" << objFaces[i].v[0].vertexIndex); stream.write(objVertices[objFaces[i].v[0].vertexIndex - 1].v[0]); stream.write(objVertices[objFaces[i].v[0].vertexIndex - 1].v[1]); stream.write(objVertices[objFaces[i].v[0].vertexIndex - 1].v[2]); //DEBUG_PRINT("write > texCoord: " << i << "texCoordIndex:" << objFaces[i].v[0].texCoordIndex); stream.write(objTexCoords[objFaces[i].v[0].texCoordIndex - 1].v[0]); stream.write(objTexCoords[objFaces[i].v[0].texCoordIndex - 1].v[1]); stream.write(objTexCoords[objFaces[i].v[0].texCoordIndex - 1].v[2]); //DEBUG_PRINT("write > normal: " << i << "normalIndex:" << objFaces[i].v[0].normalIndex); stream.write(objNormals[objFaces[i].v[0].normalIndex - 1].v[0]); stream.write(objNormals[objFaces[i].v[0].normalIndex - 1].v[1]); stream.write(objNormals[objFaces[i].v[0].normalIndex - 1].v[2]); //# //DEBUG_PRINT("write > face: " << i << "vertexIndex:" << objFaces[i].v[1].vertexIndex); stream.write(objVertices[objFaces[i].v[1].vertexIndex - 1].v[0]); stream.write(objVertices[objFaces[i].v[1].vertexIndex - 1].v[1]); stream.write(objVertices[objFaces[i].v[1].vertexIndex - 1].v[2]); //DEBUG_PRINT("write > texCoord: " << i << "texCoordIndex:" << objFaces[i].v[1].texCoordIndex); stream.write(objTexCoords[objFaces[i].v[1].texCoordIndex - 1].v[0]); stream.write(objTexCoords[objFaces[i].v[1].texCoordIndex - 1].v[1]); stream.write(objTexCoords[objFaces[i].v[1].texCoordIndex - 1].v[2]); //DEBUG_PRINT("write > normal: " << i << "normalIndex:" << objFaces[i].v[1].normalIndex); stream.write(objNormals[objFaces[i].v[1].normalIndex - 1].v[0]); stream.write(objNormals[objFaces[i].v[1].normalIndex - 1].v[1]); stream.write(objNormals[objFaces[i].v[1].normalIndex - 1].v[2]); //# //DEBUG_PRINT("write > face: " << i << "vertexIndex:" << objFaces[i].v[2].vertexIndex); stream.write(objVertices[objFaces[i].v[2].vertexIndex - 1].v[0]); stream.write(objVertices[objFaces[i].v[2].vertexIndex - 1].v[1]); stream.write(objVertices[objFaces[i].v[2].vertexIndex - 1].v[2]); //DEBUG_PRINT("write > texCoord: " << i << "texCoordIndex:" << objFaces[i].v[2].texCoordIndex); stream.write(objTexCoords[objFaces[i].v[2].texCoordIndex - 1].v[0]); stream.write(objTexCoords[objFaces[i].v[2].texCoordIndex - 1].v[1]); stream.write(objTexCoords[objFaces[i].v[2].texCoordIndex - 1].v[2]); //DEBUG_PRINT("write > normal: " << i << "normalIndex:" << objFaces[i].v[2].normalIndex); stream.write(objNormals[objFaces[i].v[2].normalIndex - 1].v[0]); stream.write(objNormals[objFaces[i].v[2].normalIndex - 1].v[1]); stream.write(objNormals[objFaces[i].v[2].normalIndex - 1].v[2]); } // INDICES ARE JUST LIST FROM 0 TO FACECOUNT // CONSIDER DROPPING/OPTIMIZING THESE stream.write(unsigned(objFaces.size() * 3)); for (unsigned i = 0; i < (objFaces.size() * 3); ++i) stream.write(uint16_t(i)); return true; }
int CCB::deactivate(const char *msisdn) { fprintf(stdout, "Deactivate... svc_url: %s, msisdn: %s\n", _svc_url.c_str(), msisdn); LOG_INFO("CCB::deactivate: svc_url: %s, msisdn: %s", _svc_url.c_str(), msisdn); return 0; }
int CCB::getIMSI(const char *msisdn, char *imsi, int imsi_size) { fprintf(stdout, "Get IMSI... svc_url: %s, msisdn: %s\n", _svc_url.c_str(), msisdn); LOG_INFO("CCB::getIMSI: svc_url: %s, msisdn: %s", _svc_url.c_str(), msisdn); return -2; }
bcm_rx_t socend_receive(int unit, bcm_pkt_t *pkt, void *cookie) { #define OK_REASON ((uint32)(-1)) /* * Was: * (DMAS1_OP_IPSW | DMAS1_OP_IPINF | DMAS1_OP_IPMC | \ * DMAS1_OP_TTL | BCM_PMUX_PR_DEFIP | BCM_PMUX_PR_COSMK | \ * DMAS1_OP_BCA) */ int pkt_rv = BCM_RX_NOT_HANDLED; int rv; int enqueue = TRUE; if (pkt->rx_reason & ~OK_REASON) { return BCM_RX_NOT_HANDLED; } /* Check VLAN for match; Check dest MAC for match; check for bcast */ if (snoop_ip_rx != NULL) { pkt_rv = snoop_ip_rx(unit, pkt, &enqueue); } if (pkt_rv == BCM_RX_NOT_HANDLED && enqueue) { if (SOC_IS_ESW(unit)) { rv = netJobAdd((FUNCPTR)socend_receive_netjob, (int)cookie, (int)pkt->pkt_data[0].data, (int)pkt->pkt_len, 4, 5); pkt_rv = ((rv == OK) ? BCM_RX_HANDLED_OWNED : BCM_RX_NOT_HANDLED); } else { char *packet; socend_packet_alloc(unit, SOC_END_PK_SZ, 0, (void *)&packet); if (NULL == packet){ LOG_INFO(BSL_LS_SYS_END, (BSL_META_U(unit, "failed to allocate buffer with socend_packet_alloc\n"))); return BCM_RX_NOT_HANDLED; } sal_memset(packet, 0x0, SOC_END_PK_SZ); sal_memcpy(packet, (unsigned char *)pkt->pkt_data[0].data, pkt->pkt_len); rv = netJobAdd((FUNCPTR)socend_receive_netjob, (int)cookie, (int)packet, (int)pkt->pkt_len, 4, 5); LOG_INFO(BSL_LS_SYS_END, (BSL_META_U(unit, "netJobAdd rv=0x%x OK=%x\n"), rv, OK)); pkt_rv = BCM_RX_HANDLED; } } return pkt_rv; }
static STATUS socend_mempool_alloc(socend_t *se, int pksize, int clblks, int cl, int mblks) /* * Function: socend_mempool_alloc * Purpose: Initialize END memory pools for the specified SOC. * Parameters: u - unit number to initialize. * pksize - Packet size to use, MUST BE MTU size or greater. * clblks - number of cluster block headers this unit * cl - number of actual cluster buffers this unit. * mblks - number of mblks this unit. * * Returns: OK or error if failed. * Notes: If already initialized, nothing is done. */ { seu_t *seu = &socend_seu[se->se_unit]; LOG_INFO(BSL_LS_SYS_END, (BSL_META("socend_mempool_alloc: Unit %d %sinitialized\n"), se->se_unit, seu->seu_init ? "" : "not ")); /* * If already done, skip the allocation and just assign the required * values. */ if (!seu->seu_init) { seu->seu_init = TRUE; seu->seu_netpool_id = (NET_POOL_ID)sal_alloc(sizeof(NET_POOL), "net_pool"); /* First Initialize the CL configuration */ seu->seu_blks.mBlkNum = mblks; seu->seu_blks.clBlkNum= clblks; seu->seu_blks.memSize = (mblks * (M_BLK_SZ + sizeof(long))) + (clblks * (CL_BLK_SZ + sizeof(long))); seu->seu_blks.memArea = sal_alloc(seu->seu_blks.memSize, "socend cl"); /* Now initialize the actual cluster buffers that contain packets */ seu->seu_cluster.clNum = cl; seu->seu_cluster.clSize = pksize; seu->seu_cluster.memSize = cl*(pksize + sizeof(long)) + sizeof(long); if (SOC_IS_ESW(se->se_unit)) { seu->seu_cluster.memArea = sal_dma_alloc(seu->seu_cluster.memSize, "socend_mempool"); } else { seu->seu_cluster.memArea = memalign(4096, seu->seu_cluster.memSize); } /* Now set up the pool and GO! */ if (!seu->seu_blks.memArea || !seu->seu_cluster.memArea || !seu->seu_netpool_id || (OK != netPoolInit(seu->seu_netpool_id, &seu->seu_blks, &seu->seu_cluster, 1, NULL))){ LOG_CLI((BSL_META("socend_mempool_init: Failed for unit %d\n"), se->se_unit)); if (seu->seu_blks.memArea) { sal_free(seu->seu_blks.memArea); } if (seu->seu_cluster.memArea) { sal_dma_free(seu->seu_cluster.memArea); } if (seu->seu_netpool_id) { free(seu->seu_netpool_id); } bzero((void *)seu, sizeof(*seu)); return(ERROR); } seu->seu_clpool_id = netClPoolIdGet(seu->seu_netpool_id, pksize, FALSE); } se->se_eo.pNetPool = seu->seu_netpool_id; return(OK); }
uint8_t *session_get_outgoing(session_t *session, size_t *length, size_t max_length) { packet_t *packet = NULL; uint8_t *result = NULL; uint8_t *data = NULL; size_t data_length = -1; /* Suck in any data we can from the driver. */ poll_for_data(session); /* Don't transmit too quickly without receiving anything. */ if(!can_i_transmit_yet(session)) return NULL; /* It's pretty ugly, but I don't see any other way, since ping requires * special packets we have to handle it separately. */ if(session->is_ping) { /* Read data without consuming it (ie, leave it in the buffer till it's ACKed) */ data = buffer_read_remaining_bytes(session->outgoing_buffer, &data_length, max_length - packet_get_ping_size(), FALSE); packet = packet_create_ping(session->id, (char*)data); safe_free(data); LOG_INFO("In PING, sending a PING packet (%zd bytes of data...)", data_length); } else { switch(session->state) { case SESSION_STATE_NEW: LOG_INFO("In SESSION_STATE_NEW, sending a SYN packet (SEQ = 0x%04x)...", session->my_seq); packet = packet_create_syn(session->id, session->my_seq, (options_t)0); if(session->is_command) packet_syn_set_is_command(packet); if(session->name) packet_syn_set_name(packet, session->name); break; case SESSION_STATE_ESTABLISHED: /* Read data without consuming it (ie, leave it in the buffer till it's ACKed) */ data = buffer_read_remaining_bytes(session->outgoing_buffer, &data_length, max_length - packet_get_msg_size(session->options), FALSE); LOG_INFO("In SESSION_STATE_ESTABLISHED, sending a MSG packet (SEQ = 0x%04x, ACK = 0x%04x, %zd bytes of data...)", session->my_seq, session->their_seq, data_length); if(data_length == 0 && session->is_shutdown) packet = packet_create_fin(session->id, "Stream closed"); else packet = packet_create_msg_normal(session->id, session->my_seq, session->their_seq, data, data_length); safe_free(data); break; default: LOG_FATAL("Wound up in an unknown state: 0x%x", session->state); exit(1); } } if(packet) { /* Print packet data if we're supposed to. */ if(packet_trace) { printf("OUTGOING: "); packet_print(packet, session->options); } update_counter(session); result = packet_to_bytes(packet, length, session->options); packet_destroy(packet); } return result; }
STATUS socend_mcast_add(_END_OBJ_PAR *p, char *a) /* * Function: socend_mcast_add * Purpose: SENS interface to add a multicast address for the interface. * Parameters: p - pointer to VxWorks end_obj structure for device * a - pointer to address to add * Returns: OK/ERROR */ { struct end_object *eo = (struct end_object *)p; socend_t *se = (socend_t *)eo->devObject.pDevice; int ret; pbmp_t pbmp, ubmp; bcm_mcast_addr_t mcaddr; char mac_str[MACADDR_STR_LEN]; int unit = se->se_unit; if (LOG_CHECK(BSL_LS_SYS_END | BSL_INFO)) { format_macaddr(mac_str, (uint8 *)a); LOG_INFO(BSL_LS_SYS_END, (BSL_META_U(unit, "socend_mcast_add: %s%d %s\n"), eo->devObject.name, eo->devObject.unit, mac_str)); } /*soc_ioctl(ADD_MULTICAST)*/ if (ENETRESET == etherMultiAdd(&eo->multiList, a)) { BCM_PBMP_CLEAR(pbmp); BCM_PBMP_PORT_ADD(pbmp, CMIC_PORT(unit)); #if 0 BCM_PBMP_PORT_ADD(pbmp, eo->devObject.unit); #endif BCM_PBMP_ASSIGN(ubmp, pbmp); bcm_mcast_addr_t_init(&mcaddr, (uint8 *)a, se->se_vlan); mcaddr.cos_dst = 0; BCM_PBMP_ASSIGN(mcaddr.pbmp, pbmp); BCM_PBMP_ASSIGN(mcaddr.ubmp, ubmp); ret = bcm_mcast_addr_add(se->se_unit, &mcaddr); if (ret >= BCM_E_NONE) { #if 0 ret = bcm_amux_register(se->se_unit, a, se->se_vlan, socend_receive, (void *)se); #endif if (ret < 0) { LOG_CLI((BSL_META_U(unit, "socend_mcast_add: %s%d bcm_amux_register failed: %s\n"), eo->devObject.name, eo->devObject.unit, bcm_errmsg(ret))); bcm_mcast_addr_remove(se->se_unit, (uint8 *)a, se->se_vlan); } return (OK); } else { LOG_CLI((BSL_META_U(unit, "bcm_mcast_addr_add failed ERROR : %s\n"), bcm_errmsg(ret))); LOG_INFO(BSL_LS_SYS_END, (BSL_META_U(unit, "socend_mcast_add: Unit %d Device %s%d " "Software RESET\n"), se->se_unit, eo->devObject.name, eo->devObject.unit)); return (ERROR); } } return(ERROR); }
NBBOOL session_data_incoming(session_t *session, uint8_t *data, size_t length) { /* Parse the packet to get the session id */ packet_t *packet = packet_parse(data, length, session->options); /* Set to TRUE if data was properly ACKed and we should send more right away. */ NBBOOL send_right_away = FALSE; /* Suck in any data we can from the driver. */ poll_for_data(session); /* Print packet data if we're supposed to. */ if(packet_trace) { printf("INCOMING: "); packet_print(packet, session->options); } if(session->is_ping) { /* This only returns if the receive is bad. */ driver_data_received(session->driver, (uint8_t*)packet->body.ping.data, strlen(packet->body.ping.data)); } else { switch(session->state) { case SESSION_STATE_NEW: if(packet->packet_type == PACKET_TYPE_SYN) { LOG_INFO("In SESSION_STATE_NEW, received SYN (ISN = 0x%04x)", packet->body.syn.seq); session->their_seq = packet->body.syn.seq; session->options = (options_t) packet->body.syn.options; session->state = SESSION_STATE_ESTABLISHED; /* Since we established a valid session, we can send stuff right away. */ session->last_transmit = 0; session->missed_transmissions = 0; send_right_away = TRUE; } else if(packet->packet_type == PACKET_TYPE_MSG) { LOG_WARNING("In SESSION_STATE_NEW, received unexpected MSG (ignoring)"); } else if(packet->packet_type == PACKET_TYPE_FIN) { /* TODO: I shouldn't exit here. */ LOG_FATAL("In SESSION_STATE_NEW, received FIN: %s", packet->body.fin.reason); exit(0); } else { /* TODO: I shouldn't exit here. */ LOG_FATAL("Unknown packet type: 0x%02x", packet->packet_type); exit(1); } break; case SESSION_STATE_ESTABLISHED: if(packet->packet_type == PACKET_TYPE_SYN) { LOG_WARNING("In SESSION_STATE_ESTABLISHED, recieved SYN (ignoring)"); } else if(packet->packet_type == PACKET_TYPE_MSG) { LOG_INFO("In SESSION_STATE_ESTABLISHED, received a MSG"); /* Validate the SEQ */ if(packet->body.msg.options.normal.seq == session->their_seq) { /* Verify the ACK is sane */ uint16_t bytes_acked = packet->body.msg.options.normal.ack - session->my_seq; /* If there's still bytes waiting in the buffer.. */ if(bytes_acked <= buffer_get_remaining_bytes(session->outgoing_buffer)) { /* Since we got a valid response back, the connection isn't dying. */ session->missed_transmissions = 0; /* Reset the retransmit counter since we got some valid data. */ if(bytes_acked > 0) { /* Only reset the counter if we want to re-transmit * right away. */ if(transmit_instantly_on_data) { session->last_transmit = 0; session->missed_transmissions = 0; send_right_away = TRUE; } } /* Increment their sequence number */ session->their_seq = (session->their_seq + packet->body.msg.data_length) & 0xFFFF; /* Remove the acknowledged data from the buffer */ buffer_consume(session->outgoing_buffer, bytes_acked); /* Increment my sequence number */ if(bytes_acked != 0) { session->my_seq = (session->my_seq + bytes_acked) & 0xFFFF; } /* Print the data, if we received any, and then immediately receive more. */ if(packet->body.msg.data_length > 0) { driver_data_received(session->driver, packet->body.msg.data, packet->body.msg.data_length); } } else { LOG_WARNING("Bad ACK received (%d bytes acked; %d bytes in the buffer)", bytes_acked, buffer_get_remaining_bytes(session->outgoing_buffer)); } } else { LOG_WARNING("Bad SEQ received (Expected %d, received %d)", session->their_seq, packet->body.msg.options.normal.seq); } } else if(packet->packet_type == PACKET_TYPE_FIN) { LOG_FATAL("In SESSION_STATE_ESTABLISHED, received FIN: %s - closing session", packet->body.fin.reason); session->last_transmit = 0; session->missed_transmissions = 0; session_kill(session); } else { LOG_FATAL("Unknown packet type: 0x%02x - closing session", packet->packet_type); session_kill(session); } break; default: LOG_FATAL("Wound up in an unknown state: 0x%x", session->state); packet_destroy(packet); session_kill(session); exit(1); } } packet_destroy(packet); return send_right_away; }
bool CCPU::init() { FeatureDetector::cpu_x86 cpuFeature; cpuFeature.detect_host(); m_feature.vendor = cpuFeature.Vendor_Intel ? CPUVendor::Intel : cpuFeature.Vendor_AMD ? CPUVendor::AMD : CPUVendor::Unknown; m_feature.vendorName = CharacterSet::FromUTF8(cpuFeature.get_vendor_string()); { int32 cpui[4] = {}; cpuFeature.cpuid(cpui, 0x80000000); const int32 nExIDs = cpui[0]; Array<int32> extData; for (int32 i = 0x80000000; i <= nExIDs; ++i) { cpuFeature.cpuid(cpui, i); extData.insert(extData.end(), std::begin(cpui), std::end(cpui)); } char brand[0x40] = {}; if (static_cast<uint32>(nExIDs) >= 0x80000004) { ::memcpy(brand, &extData[8], sizeof(cpui)); ::memcpy(brand + 16, &extData[12], sizeof(cpui)); ::memcpy(brand + 32, &extData[16], sizeof(cpui)); } m_feature.name = CharacterSet::FromUTF8(brand); } LOG_INFO(L"ℹ️ CPU vendor: {0}"_fmt(m_feature.vendorName)); LOG_INFO(L"ℹ️ CPU name: {0}"_fmt(m_feature.name)); m_feature.SSE = cpuFeature.HW_SSE; m_feature.SSE2 = cpuFeature.HW_SSE2; m_feature.SSE3 = cpuFeature.HW_SSE3; m_feature.SSSE3 = cpuFeature.HW_SSSE3; m_feature.SSE41 = cpuFeature.HW_SSE41; m_feature.SSE42 = cpuFeature.HW_SSE42; m_feature.SSE4a = cpuFeature.HW_SSE4a; m_feature.AES = cpuFeature.HW_AES; m_feature.SHA = cpuFeature.HW_SHA; m_feature.AVX = cpuFeature.HW_AVX && cpuFeature.OS_AVX; m_feature.XOP = cpuFeature.HW_XOP; m_feature.FMA4 = cpuFeature.HW_FMA4; m_feature.FMA3 = cpuFeature.HW_FMA3; m_feature.AVX2 = cpuFeature.HW_AVX2 && cpuFeature.OS_AVX; m_feature.AVX512_F = cpuFeature.HW_AVX512_F && cpuFeature.OS_AVX512; Array<String> features; if (m_feature.SSE) { features.emplace_back(L"SSE"); } if (m_feature.SSE2) { features.emplace_back(L"SSE2"); } if (m_feature.SSE3) { features.emplace_back(L"SSE3"); } if (m_feature.SSSE3) { features.emplace_back(L"SSSE3"); } if (m_feature.SSE41) { features.emplace_back(L"SSE4.1"); } if (m_feature.SSE42) { features.emplace_back(L"SSE4.2"); } if (m_feature.SSE4a) { features.emplace_back(L"SSE4a"); } if (m_feature.AES) { features.emplace_back(L"AES-NI"); } if (m_feature.SHA) { features.emplace_back(L"SHA"); } if (m_feature.AVX) { features.emplace_back(L"AVX"); } if (m_feature.XOP) { features.emplace_back(L"XOP"); } if (m_feature.FMA4) { features.emplace_back(L"FMA4"); } if (m_feature.FMA3) { features.emplace_back(L"FMA3"); } if (m_feature.AVX2) { features.emplace_back(L"AVX2"); } if (m_feature.AVX512_F) { features.emplace_back(L"AVX-512 F"); } LOG_INFO(L"ℹ️ Instruction set extensions: {0}"_fmt(features.join(L", ", L"", L""))); return true; }
static int xtensa_poll(struct target *target) { struct xtensa_common *xtensa = target_to_xtensa(target); struct reg *reg; uint32_t dosr; int res; /* OCD guide 2.9.2 points out no reliable way to detect core reset. So, even though this ENABLE_OCD is nearly always a No-Op, we send it on every poll just in case the target has reset and gone back to Running state (in which case this moves it to OCD Run State. */ res = xtensa_tap_queue(target, TAP_INS_ENABLE_OCD, NULL, NULL); if(res != ERROR_OK) { LOG_ERROR("Failed to queue EnableOCD instruction."); return ERROR_FAIL; } res = xtensa_tap_exec(target, TAP_INS_READ_DOSR, 0, &dosr); if(res != ERROR_OK) { LOG_ERROR("Failed to read DOSR. Not Xtensa OCD?"); return ERROR_FAIL; } if(dosr & (DOSR_IN_OCD_MODE)) { if (target->state != TARGET_HALTED) { if (target->state != TARGET_UNKNOWN && (dosr & DOSR_EXCEPTION) == 0) { LOG_WARNING("%s: DOSR has set InOCDMode without the Exception flag. Unexpected. DOSR=0x%02x", __func__, dosr); } int state = target->state; xtensa->state = XT_OCD_HALT; target->state = TARGET_HALTED; register_cache_invalidate(xtensa->core_cache); xtensa_save_context(target); if (state == TARGET_DEBUG_RUNNING) { target_call_event_callbacks(target, TARGET_EVENT_DEBUG_HALTED); } else { //target->debug_reason is checked in gdb_last_signal() that is invoked as a result of calling target_call_event_callbacks() below. //Unless we specify it, GDB will get confused and report the stop to the user on its internal breakpoints. uint32_t dbgcause = buf_get_u32(xtensa->core_cache->reg_list[XT_REG_IDX_DEBUGCAUSE].value, 0, 32); if (dbgcause & 0x20) //Debug interrupt target->debug_reason = DBG_REASON_DBGRQ; else if (dbgcause & 0x01) //ICOUNT match target->debug_reason = DBG_REASON_SINGLESTEP; else target->debug_reason = DBG_REASON_BREAKPOINT; target_call_event_callbacks(target, TARGET_EVENT_HALTED); } LOG_DEBUG("target->state: %s", target_state_name(target)); reg = &xtensa->core_cache->reg_list[XT_REG_IDX_PC]; LOG_INFO("halted: PC: 0x%" PRIx32, buf_get_u32(reg->value, 0, 32)); reg = &xtensa->core_cache->reg_list[XT_REG_IDX_DEBUGCAUSE]; LOG_INFO("debug cause: 0x%" PRIx32, buf_get_u32(reg->value, 0, 32)); } else { if (s_FeedWatchdogDuringStops) xtensa_feed_esp8266_watchdog(target); } } else if(target->state != TARGET_RUNNING && target->state != TARGET_DEBUG_RUNNING){ xtensa->state = XT_OCD_RUN; target->state = TARGET_RUNNING; } return ERROR_OK; }
/*============================================================================== LOCAL FUNCTIONS ==============================================================================*/ static int8_t _fradio_init(void) { uint32_t env_s_ip; uint32_t env_s_port; uint32_t env_c_ip; uint32_t env_c_port; linkaddr_t un_addr; env_s_ip = inet_addr(FRADIO_S_IP); env_c_ip = inet_addr(FRADIO_C_IP); if (!env_s_ip || !env_c_ip) { LOG_ERR("%s\n\r","FRADIO_S_IP or FRADIO_C_IP not found"); exit(1); } LOG_INFO("serv ip is: %s\n", FRADIO_S_IP); LOG_INFO("cli ip is: %s\n", FRADIO_C_IP); #if CLIENT & !SERVER env_s_port = atoi(FRADIO_OUTPORT_CLIENT); env_c_port = atoi(FRADIO_INPORT_CLIENT); #elif SERVER & !CLIENT env_s_port = atoi(FRADIO_OUTPORT_SERVER); env_c_port = atoi(FRADIO_INPORT_SERVER); #endif if (!env_s_port || !env_c_port) { LOG_ERR("%s\n\r","OUTPORT or INPORT not found"); exit(1); } LOG_INFO("serv port is: %d\n", env_s_port); LOG_INFO("cli port is: %d\n", env_c_port); // LOG_INFO("initial ll addr = %02X:%02X:%02X:%02X:%02X:%02X\n",uip_lladdr.addr[0],uip_lladdr.addr[1],uip_lladdr.addr[2],uip_lladdr.addr[3],uip_lladdr.addr[4],uip_lladdr.addr[5]); sockfd=socket(AF_INET,SOCK_DGRAM,0); memset(&servaddr,0,sizeof(servaddr)); servaddr.sin_family = AF_INET; servaddr.sin_addr.s_addr=env_s_ip; servaddr.sin_port=htons(env_s_port); if (bind(sockfd,(struct sockaddr *)&servaddr,sizeof(servaddr)) < 0) { LOG_ERR("fail to create a socket: error %d\n",errno); exit(1); } memset(&cliaddr,0,sizeof(cliaddr)); cliaddr.sin_family = AF_INET; cliaddr.sin_addr.s_addr=env_c_ip; cliaddr.sin_port=htons(env_c_port); int flags = fcntl(sockfd, F_GETFL, 0); if (flags < 0) { LOG_ERR("%s\n\r","fcntl error"); exit(1); } flags = (flags|O_NONBLOCK); fcntl(sockfd, F_SETFL, flags); LOG_INFO("%s\n\r","fake_radio driver was initialized"); memcpy((void *)&un_addr.u8, &mac_address, 8); memcpy(&uip_lladdr.addr, &un_addr.u8, 8); linkaddr_set_node_addr(&un_addr); LOG_INFO("MAC address %x:%x:%x:%x:%x:%x:%x:%x\n", \ un_addr.u8[0],un_addr.u8[1],\ un_addr.u8[2],un_addr.u8[3],\ un_addr.u8[4],un_addr.u8[5],\ un_addr.u8[6],un_addr.u8[7]); /* Start the packet receive process */ etimer_set(&tmr, 10, _fradio_handler); printf("set %p for %p callback\n\r",&tmr, &_fradio_handler); return 0; } /* _fradio_init() */
struct end_object * socend_load(char *is, void* ap) /* * Function: socend_load * Purpose: Provides SENS load routine for SOC device. * Parameters: is - initialization string. * Returns: Pointer to VxWorks end_obj structure or NULL */ { struct end_object *eo; socend_t *se; /* Sock End Structure */ seu_t *seu; char dev_name[sizeof(eo->devObject.name)]; char mac[6]; /* MAC address parsing */ int net_unit; char mac_str[MACADDR_STR_LEN]; int i, column_count, rt; if (NULL == is) { LOG_CLI((BSL_META("socend_load: unexpected NULL pointer for device name\n"))); return(NULL); } else if ('\0' == *is) { /* Copy in our device name */ strcpy(is, "sc"); return(NULL); } LOG_INFO(BSL_LS_SYS_END, (BSL_META("socend_load: %s\n"), is)); /* * Setup END structure * * NOTE NOTE NOTE: This call MUST use calloc or malloc, since the object * is freed by VxWorks using free(); */ if (NULL == (se = malloc(sizeof(*se)))) { LOG_CLI((BSL_META("socend_load: failed to allocate memory for %s\n"), is)); return(NULL); } bzero((void *)se, sizeof(*se)); eo = &se->se_eo; net_unit = atoi(is); is = index(is, ':') + 1; /* Parse init string, format is "net_unit:bcm_unit:MAC_ADDR:vlan" */ se->se_unit = atoi(is); seu = &socend_seu[se->se_unit]; is = index(is, ':') + 1; /* Onto net unit # */ if ((se->se_unit >= BCM_MAX_NUM_UNITS) || !*is) { LOG_CLI((BSL_META("socend_load: Invalid soc device: %d\n"), se->se_unit)); free(se); return(NULL); } /* Check if optional VLAN/MAC address */ se->se_vlan = VLAN_ID_INVALID; if (is) { column_count = 0; i = 0; while (*is && i < MACADDR_STR_LEN - 1 && column_count <= 5) { mac_str[i++] = *is; if (*is++ == ':') { column_count++; } } mac_str[i] = '\0'; if (column_count == 6) { mac_str[i-1] = '\0'; } if (5 <= column_count) { rt = parse_macaddr(mac_str, se->se_mac); } else { rt = -1; } if (rt) { LOG_CLI((BSL_META("socend_load: Invalid MAC address specified: %s\n"), mac_str)); free(se); return(NULL); } if (column_count == 6) { se->se_vlan = atoi(is); } } else { ENET_COPY_MACADDR(mac_zero, se->se_mac); } if (se->se_vlan == VLAN_ID_INVALID) { bcm_vlan_t vid; bcm_vlan_default_get(se->se_unit, &vid); se->se_vlan = vid; } if (ERROR == END_OBJ_INIT(eo, (DEV_OBJ *)se, "sc", net_unit, &socend_netfuncs, SOC_END_STRING)) { LOG_CLI((BSL_META("socend_load: END_OBJ_INIT failed for %s\n"), dev_name)); } if (ERROR == END_MIB_INIT(eo, M2_ifType_ethernet_csmacd, (UCHAR *)mac, sizeof(mac), ETHERMTU, SOC_END_SPEED)) { LOG_CLI((BSL_META("socend_load: END_MIB_INIT failed for %s\n"), dev_name)); } socend_mempool_alloc(se, SOC_END_PK_SZ, SOC_END_CLBLKS, SOC_END_CLBUFS, SOC_END_MBLKS); /* Set Ready */ END_OBJ_READY (eo, IFF_NOTRAILERS | IFF_MULTICAST | IFF_BROADCAST); /* Queue off of seu structure */ se->se_next = seu->seu_devices; seu->seu_devices = se; #if defined(__mips__) if(SOC_IS_ESW(se->se_unit)) { socend_packet_alloc(se->se_unit, SOC_END_PK_SZ, 0, &seu->pkt_align_buf); } #endif /* __mips__ */ return(eo); }
int CCB::deinitialize() { fprintf(stdout, "Deinitialize...\n"); LOG_INFO("CCB::deinitialize: url: %s", _svc_url.c_str()); return 0; }
STATUS socend_ioctl(_END_OBJ_PAR *p, int cmd, caddr_t data) /* * Function: socend_ioctl * Purpose: SENS IOCTL function for SOC devices. * Parameters: p - pointer to VxWorks end_obj structure for device * cmd - command to execute * data - data or address of data for CMD. * Returns: Status */ { struct end_object *eo = (struct end_object *)p; socend_t *se = (socend_t *)eo->devObject.pDevice; STATUS error = OK; int unit = se->se_unit; LOG_INFO(BSL_LS_SYS_END, (BSL_META_U(unit, "socend_ioctl: unit %d\n"), se->se_unit)); switch((unsigned int)cmd) { case EIOCSFLAGS: LOG_INFO(BSL_LS_SYS_END, (BSL_META_U(unit, "socend_ioctl: %s%d: EIOCSFLAGS(0x%x)\n"), eo->devObject.name, eo->devObject.unit, (unsigned int)data)); if ((long)data < 0) { /* Clearing flags? */ END_FLAGS_CLR(eo, -(long)data); } else { END_FLAGS_SET(eo, (long)data); } break; case EIOCGFLAGS: LOG_INFO(BSL_LS_SYS_END, (BSL_META_U(unit, "socend_ioctl: %s%d: EIOCGFLAGS\n"), eo->devObject.name, eo->devObject.unit)); if (NULL == data) { error = EINVAL; } else { *(int *)data = eo->flags; } break; case EIOCSADDR: /* Set interface address */ LOG_INFO(BSL_LS_SYS_END, (BSL_META_U(unit, "socend_ioctl: %s%d: EIOCSADDR\n"), eo->devObject.name, eo->devObject.unit)); if (NULL == data) { error = EINVAL; } else { bcm_l2_addr_t l2addr; int my_modid; if (ENET_CMP_MACADDR(se->se_mac, mac_zero)) { LOG_INFO(BSL_LS_SYS_END, (BSL_META_U(unit, "socend_ioctl: Deleting old mac address\n"))); (void)bcm_l2_addr_delete(se->se_unit, se->se_mac, se->se_vlan); } ENET_COPY_MACADDR(data, se->se_mac); LOG_INFO(BSL_LS_SYS_END, (BSL_META_U(unit, "socend_ioctl: Setting new mac address\n"))); bcm_l2_addr_t_init(&l2addr, se->se_mac, se->se_vlan); l2addr.port = CMIC_PORT(unit); l2addr.flags = BCM_L2_STATIC; bcm_stk_my_modid_get(se->se_unit, &my_modid); l2addr.modid = my_modid; if (0 > bcm_l2_addr_add(se->se_unit, &l2addr)) { LOG_CLI((BSL_META_U(unit, "socend_ioctl: mac_configure_address failed: " "Network Device %s%d\n"), eo->devObject.name, eo->devObject.unit)); ENET_COPY_MACADDR(mac_zero, se->se_mac); error = EIO; break; } END_MIB_INIT(eo, M2_ifType_ethernet_csmacd, (uint8 *)data, 6, ETHERMTU, SOC_END_SPEED); } break; case EIOCGADDR: /* Get Interface address */ LOG_INFO(BSL_LS_SYS_END, (BSL_META_U(unit, "socend_ioctl: %s%d: EIOCGADDR\n"), eo->devObject.name, eo->devObject.unit)); if (NULL == data) { error = EINVAL; } else { bcopy((char *)eo->mib2Tbl.ifPhysAddress.phyAddress, (char *)data, eo->mib2Tbl.ifPhysAddress.addrLength); } break; case EIOCGFBUF: /* Get min 1st buf for chain */ LOG_INFO(BSL_LS_SYS_END, (BSL_META_U(unit, "socend_ioctl: %s%d: EIOCGFBUF\n"), eo->devObject.name, eo->devObject.unit)); if (data == NULL) { error = EINVAL; } else { *(int *)data = 32; } break; case EIOCGMWIDTH: /* Get device memory witdh */ LOG_INFO(BSL_LS_SYS_END, (BSL_META_U(unit, "socend_ioctl: %s%d: EIOCGMWIDTH\n"), eo->devObject.name, eo->devObject.unit)); if (NULL == data) { error = EINVAL; } else { *(int *)data = 32; } break; case EIOCMULTIADD: case EIOCMULTIDEL: case EIOCMULTIGET: case EIOCPOLLSTART: case EIOCPOLLSTOP: LOG_INFO(BSL_LS_SYS_END, (BSL_META_U(unit, "socend_ioctl: %s%d: MULTI/POLL\n"), eo->devObject.name, eo->devObject.unit)); error = ENOSYS; break; case EIOCGMIB2: /* Get MIB2 Table */ LOG_INFO(BSL_LS_SYS_END, (BSL_META_U(unit, "socend_ioctl: %s%d: EIOCGMIB2\n"), eo->devObject.name, eo->devObject.unit)); if (data == NULL) { error = EINVAL; } else { bcopy ((char *)&eo->mib2Tbl, (char *)data, sizeof(eo->mib2Tbl)); } break; case EIOCGNAME: /* Get device Name */ LOG_INFO(BSL_LS_SYS_END, (BSL_META_U(unit, "socend_ioctl: %s%d: EIOCGNAME\n"), eo->devObject.name, eo->devObject.unit)); if (NULL == data) { error = EINVAL; } else { bcopy(eo->devObject.name, (char *)data, sizeof(eo->devObject.name)); } break; case EIOCGHDRLEN: if (NULL == data) { error = EINVAL; } else { *(int *)data = ENET_TAGGED_HDR_LEN; } break; #if VX_VERSION == 62 || VX_VERSION == 64 || VX_VERSION == 66 || VX_VERSION == 68 case EIOCGRCVJOBQ: LOG_INFO(BSL_LS_SYS_END, (BSL_META_U(unit, "socend_ioctl: %s%d: EIOCGRCVJOBQ\n"), eo->devObject.name, eo->devObject.unit)); if (NULL == data) { error = EINVAL; } else { END_RCVJOBQ_INFO *qinfo = (END_RCVJOBQ_INFO *)data; LOG_INFO(BSL_LS_SYS_END, (BSL_META_U(unit, "socend_ioctl: %s%d: numRcvJobQs input#: %d\n"), eo->devObject.name, eo->devObject.unit, qinfo->numRcvJobQs)); if (qinfo->numRcvJobQs < 1) { error = ENOSPC; } else { qinfo->qIds[0] = netJobQueueId; } qinfo->numRcvJobQs = 1; } break; #endif /* VX_VERSION */ default: LOG_INFO(BSL_LS_SYS_END, (BSL_META_U(unit, "socend_ioctl: %s%d: Unknown IOCTL\n"), eo->devObject.name, eo->devObject.unit)); error = EINVAL; break; } LOG_INFO(BSL_LS_SYS_END, (BSL_META_U(unit, "socend_ioctl: %s%d: cmd=0x%x Return(%d)\n"), eo->devObject.name, eo->devObject.unit, cmd, error)); return(error); }
int CCB::getBalance(const char *msisdn) { fprintf(stdout, "Get balance... svc_url: %s, msisdn: %s\n", _svc_url.c_str(), msisdn); LOG_INFO("CCB::getBalance: svc_url: %s, msisdn: %s", _svc_url.c_str(), msisdn); return -2; }
STATUS socend_start(_END_OBJ_PAR *p) /* * Function: socend_start * Purpose: SENS interface to activate a SOC interface. * Parameters: p - pointer to VxWorks end_obj structure for device * Returns: OK/ERROR * * Notes: */ { int rv; struct end_object *eo = (struct end_object *)p; socend_t *se = (socend_t *)eo->devObject.pDevice; bcm_l2_addr_t l2addr; int i; int my_modid; LOG_INFO(BSL_LS_SYS_END, (BSL_META("socend_start: Device(%s), unit %d\n"), eo->devObject.name, se->se_unit)); if (!ENET_CMP_MACADDR(se->se_mac, mac_zero)) { LOG_CLI((BSL_META("socend_start: No valid mac address assigned: " "Network Device %s%d\n"), eo->devObject.name, eo->devObject.unit)); } bcopy((char *)se->se_mac, (char *)eo->mib2Tbl.ifPhysAddress.phyAddress, eo->mib2Tbl.ifPhysAddress.addrLength); LOG_INFO(BSL_LS_SYS_END, (BSL_META("socend_start: Starting bcm_rx\n"))); if (!bcm_rx_active(se->se_unit)) { bcm_rx_cfg_t rx_cfg; bcm_rx_cfg_get(se->se_unit, &rx_cfg); rx_cfg.pkt_size = SOC_END_PK_SZ; rx_cfg.rx_alloc = socend_packet_alloc; rx_cfg.rx_free = socend_packet_free; if ((rv= bcm_rx_start(se->se_unit, &rx_cfg)) < 0) { LOG_CLI((BSL_META("rxmon: Error: Cannot start RX: %s.\n"), bcm_errmsg(rv))); return(ERROR); } }else { LOG_CLI((BSL_META("RX Thread is already running\n"))); } LOG_INFO(BSL_LS_SYS_END, (BSL_META("socend_start: adding l2 addr\n"))); bcm_l2_addr_t_init(&l2addr, se->se_mac, se->se_vlan); l2addr.port = CMIC_PORT(se->se_unit); l2addr.flags = BCM_L2_STATIC; bcm_stk_my_modid_get(se->se_unit, &my_modid); l2addr.modid = my_modid; rv = bcm_l2_addr_add(se->se_unit, &l2addr); if (rv < 0) { LOG_CLI((BSL_META("socend_start: %s%d bcm_l2_addr_add failed: %s\n"), eo->devObject.name, eo->devObject.unit, bcm_errmsg(rv))); return(ERROR); } LOG_INFO(BSL_LS_SYS_END, (BSL_META("socend_start: registering with bcm_rx\n"))); for (i = 0; i < SOC_END_HANDLER_PRIO_COUNT; i++) { if (socend_prio_map[i].valid != TRUE){ socend_prio_map[i].valid = TRUE; socend_prio_map[i].socend = se; break; } } if(i == SOC_END_HANDLER_PRIO_COUNT){ LOG_CLI((BSL_META("socend_start: socend count is larger %d\n"), SOC_END_HANDLER_PRIO_COUNT)); return(ERROR); } /* Register call back */ if (SOC_IS_ESW(se->se_unit)) { rv = bcm_rx_register(se->se_unit, "SOCEND", socend_receive, (i + SOC_END_HANDLER_PRIO_BASE), (void *)se, BCM_RCO_F_ALL_COS); } else { rv = bcm_rx_register(se->se_unit, "SOCEND", socend_receive, (i + SOC_END_HANDLER_PRIO_BASE), (void *)se, BCM_RCO_F_ALL_COS | BCM_RCO_F_INTR); } if (rv < 0) { LOG_CLI((BSL_META("Warning: Could not register socend_receive from RX\n"))); return(ERROR); } END_FLAGS_SET(eo, IFF_UP | IFF_RUNNING | IFF_BROADCAST); LOG_INFO(BSL_LS_SYS_END, (BSL_META("socend_start: Started Network Interface: %s%d\n"), eo->devObject.name, eo->devObject.unit)); return(OK); }
int Switch_Manager::DeleteAllWsitch(char* strUrl,char* outPutUrl,char* strSessionID) { LOG_DEBUG("DEBUG - [SWM]: - DeleteAllWsitch fun \n"); printf("---DeleteAllWsitch fun \n"); bool bIsReplyflag = false; //遍历切流器 时间过长,不加锁 pthread_mutex_lock(&m_mutexServerList); MapSwitchSeverInfo::iterator iterLook = m_mapSwitchServerInfo.begin(); while(iterLook != m_mapSwitchServerInfo.end()) { // SwitchSeverInfo *pFindSeverInfo = iterLook->second; if(pFindSeverInfo && pFindSeverInfo->iRunStatus == 0) //在线的切流器 { //连接server //报文转发 Stream ptmpRequest; int iret = ptmpRequest.ConnectServer(pFindSeverInfo->strServerIPAddr,pFindSeverInfo->iListenPort); if(iret != 0) { //连接失败 continue; } iret = ptmpRequest.Send_str(strUrl); if(iret != 0) { continue; } char Rcv_buf[1024]={0}; int iLen = sizeof(Rcv_buf); iret = ptmpRequest.Recv_str(Rcv_buf,&iLen); if(iret !=0) continue; memcpy(outPutUrl,Rcv_buf,iLen); bIsReplyflag = true; outPutUrl[iLen] ='\0'; cJSON *pcmd = NULL; //解析报文数据 replace(Rcv_buf, "XXEE", ""); cJSON* pRoot = cJSON_Parse(Rcv_buf); int iRet = -1; if (pRoot) { pcmd = cJSON_GetObjectItem(pRoot, "cmd"); if (pcmd) { //判断请求类型 if(strcmp(pcmd->valuestring, "reset_device") == 0) { iRet = 0; } } } if(iRet == 0) { LOG_INFO_FORMAT("INFO - [SWM]:切流器[%s] 重置流成功 \n",pFindSeverInfo->strServerIPAddr); pFindSeverInfo->iStreamStatus = 0; pFindSeverInfo->iCurrentSwitchNumber = 0; } else { LOG_INFO_FORMAT("INFO - [SWM]:切流器[%s] 重置流失败 \n",pFindSeverInfo->strServerIPAddr); pFindSeverInfo->iStreamStatus = 1; //流状态异常 } } else printf("---切流器 不在线 %s \n",pFindSeverInfo->strServerIPAddr); ++iterLook; } pthread_mutex_unlock(&ManagerFactory::instance()->m_mutexServerList); if(!bIsReplyflag) { ReplyException(strUrl,outPutUrl,Error_ReSet_Device); LOG_INFO("INFO - [SWM]: Delete ALL stream exception \n"); } return 0; }
int CONFLoad(const char* fileName) { int i; int rv = CONF_OK; char* line = NULL; int length = 0; char* buffer = NULL; void* vbuffer = NULL; char* savePtr = NULL; LOG_DEBUG("CONFLoad %s", fileName); if (fileName == NULL) { LOG_ERROR("fileName = NULL"); rv = CONF_ERROR_PARAMETER; goto out; } if (__confInit == 0) { LOG_ERROR("libconf not initialized"); rv = CONF_ERROR_INIT; goto out; } LOG_INFO("Reading configuration from %s", fileName); length = Util_ReadFile(fileName, &vbuffer, 1); if (length < 0) { if (length == VPL_ERR_NOENT) { LOG_INFO("%s does not exist; skipping", fileName); } else { LOG_ERROR("Util_ReadFile(%s) failed: %d", fileName, length); } rv = length; goto out; } buffer = vbuffer; // Add a null-terminator so strtok doesn't read past the end of the buffer. buffer[length] = '\0'; line = safe_strtok(buffer, "\n", &savePtr); while (line != NULL) { CONFVariable var; size_t lineLen = strlen(line); if (lineLen < 2 || (line[0] == '/' && line[1] == '/')) { goto skip; } memset(&var, 0, sizeof(var)); sscanf(line, "%"VPL_STRING(CONF_MAX_STR_LENGTH)"s = %"VPL_STRING(CONF_MAX_STR_LENGTH)"s\n", var.name, var.value); LOG_DEBUG("name,value = '%s','%s'", var.name, var.value); // Check if the length of name and value are less than buffer size. // 3 is the length of ' = ' in configuration format. // Still regard as success but put an error in log. // Add 3 (instead of subtracting 3) to avoid wrapping around if lineLen == strlen(var.name), // which can happen if there is no ' = ' in the line. if ( (lineLen - strlen(var.name) > CONF_MAX_STR_LENGTH + 3) || (lineLen - strlen(var.value) > CONF_MAX_STR_LENGTH + 3) ) { LOG_ERROR("Configuration exceeds buffer size: '%s'", line); } for (i = 0; i < CONF_MAX_LENGTH; i++) { var.name[i] = tolower(var.name[i]); } // overwrite duplicate entries if (CONFOverWriteDuplicate(&var) == CONF_ERROR_NOT_FOUND) { memcpy(&__confVars[__confFilled], &var, sizeof(var)); __confFilled++; } // grow array if (__confFilled >= __confSize) { CONFVariable* tempVars; __confSize *= 2; tempVars = __confVars; __confVars = (CONFVariable*)malloc(__confSize * sizeof(CONFVariable)); memset(__confVars, 0, __confSize * sizeof(CONFVariable)); memcpy(__confVars, tempVars, __confFilled * sizeof(CONFVariable)); free(tempVars); } skip: line = safe_strtok(NULL, "\n", &savePtr); } qsort(__confVars, __confFilled, sizeof(CONFVariable), CONFCompare); out: free(buffer); return rv; }
int main(int argc, const char **argv) { VCOS_THREAD_ATTR_T attrs; int i; vcos_init(); signal(SIGINT, test_signal_handler); /* coverity[tainted_data] Ignore unnecessary warning about an attacker * being able to pass an arbitrarily long "-vvvvv..." argument */ if (test_parse_cmdline(argc, argv)) return -1; if (verbosity--) { static char value[512]; const char *levels[] = {"warn", "info", "trace"}; char *env = getenv("VC_LOGLEVEL"); if (verbosity >= MMAL_COUNTOF(levels)) verbosity = MMAL_COUNTOF(levels) - 1; snprintf(value, sizeof(value)-1, "mmalplay:%s,mmal:%s,%s", levels[verbosity], levels[verbosity], env ? env : ""); #ifdef WIN32 _putenv("VC_LOGLEVEL", value, 1); #else setenv("VC_LOGLEVEL", value, 1); #endif } vcos_log_register("mmalplay", VCOS_LOG_CATEGORY); LOG_INFO("MMAL Video Playback Test App"); vcos_thread_attr_init(&attrs); for (i = 0; i < play_info_count; i++) { const char *uri = play_info[i].uri; memcpy(play_info[i].name, THREAD_PREFIX, sizeof(THREAD_PREFIX)); if (strlen(uri) >= URI_FOR_THREAD_NAME_MAX) uri += strlen(uri) - URI_FOR_THREAD_NAME_MAX; strncat(play_info[i].name, uri, URI_FOR_THREAD_NAME_MAX); vcos_mutex_create(&play_info[i].lock, "mmalplay"); play_info[i].options.render_layer = i; if (vcos_thread_create(&play_info[i].thread, play_info[i].name, &attrs, mmal_playback, &play_info[i]) != VCOS_SUCCESS) { LOG_ERROR("Thread creation failure for URI %s", play_info[i].uri); return -2; } } if (sleepy_time != 0) { #ifdef WIN32 Sleep(sleepy_time); #else sleep(sleepy_time); #endif for (i = 0; i < play_info_count; i++) { vcos_mutex_lock(&play_info[i].lock); if (play_info[i].ctx) mmalplay_stop(play_info[i].ctx); vcos_mutex_unlock(&play_info[i].lock); } } LOG_TRACE("Waiting for threads to terminate"); for (i = 0; i < play_info_count; i++) { vcos_thread_join(&play_info[i].thread, NULL); LOG_TRACE("Joined thread %d (%i)", i, play_info[i].status); } LOG_TRACE("Completed"); /* Check for errors */ for (i = 0; i < play_info_count; i++) { if (!play_info[i].status) continue; LOG_ERROR("Playback of %s failed (%i, %s)", play_info[i].uri, play_info[i].status, mmal_status_to_string(play_info[i].status)); fprintf(stderr, "playback of %s failed (%i, %s)\n", play_info[i].uri, play_info[i].status, mmal_status_to_string(play_info[i].status)); return play_info[i].status; } return 0; }
void _check_header(void) { u8_t *ptr = streambuf->readp; unsigned bytes = min(_buf_used(streambuf), _buf_cont_read(streambuf)); header_format format = UNKNOWN; // simple parsing of wav and aiff headers and get to samples if (bytes > 12) { if (!memcmp(ptr, "RIFF", 4) && !memcmp(ptr+8, "WAVE", 4)) { LOG_INFO("WAVE"); format = WAVE; } else if (!memcmp(ptr, "FORM", 4) && (!memcmp(ptr+8, "AIFF", 4) || !memcmp(ptr+8, "AIFC", 4))) { LOG_INFO("AIFF"); format = AIFF; } } if (format != UNKNOWN) { ptr += 12; bytes -= 12; while (bytes >= 8) { char id[5]; unsigned len; memcpy(id, ptr, 4); id[4] = '\0'; if (format == WAVE) { len = *(ptr+4) | *(ptr+5) << 8 | *(ptr+6) << 16| *(ptr+7) << 24; } else { len = *(ptr+4) << 24 | *(ptr+5) << 16 | *(ptr+6) << 8 | *(ptr+7); } LOG_INFO("header: %s len: %d", id, len); if (format == WAVE && !memcmp(ptr, "data", 4)) { ptr += 8; _buf_inc_readp(streambuf, ptr - streambuf->readp); return; } if (format == AIFF && !memcmp(ptr, "SSND", 4) && bytes >= 16) { unsigned offset = *(ptr+8) << 24 | *(ptr+9) << 16 | *(ptr+10) << 8 | *(ptr+11); // following 4 bytes is blocksize - ignored ptr += 8 + 8; _buf_inc_readp(streambuf, ptr + offset - streambuf->readp); return; } if (format == WAVE && !memcmp(ptr, "fmt ", 4) && bytes >= 24) { // override the server parsed values with our own channels = *(ptr+10) | *(ptr+11) << 8; sample_rate = *(ptr+12) | *(ptr+13) << 8 | *(ptr+14) << 16 | *(ptr+15) << 24; sample_size = (*(ptr+22) | *(ptr+23) << 8) / 8; bigendian = 0; LOG_INFO("pcm size: %u rate: %u chan: %u bigendian: %u", sample_size, sample_rate, channels, bigendian); } if (format == AIFF && !memcmp(ptr, "COMM", 4) && bytes >= 26) { int exponent; // override the server parsed values with our own channels = *(ptr+8) << 8 | *(ptr+9); sample_size = (*(ptr+14) << 8 | *(ptr+15)) / 8; bigendian = 1; // sample rate is encoded as IEEE 80 bit extended format // make some assumptions to simplify processing - only use first 32 bits of mantissa exponent = ((*(ptr+16) & 0x7f) << 8 | *(ptr+17)) - 16383 - 31; sample_rate = *(ptr+18) << 24 | *(ptr+19) << 16 | *(ptr+20) << 8 | *(ptr+21); while (exponent < 0) { sample_rate >>= 1; ++exponent; } while (exponent > 0) { sample_rate <<= 1; --exponent; } LOG_INFO("pcm size: %u rate: %u chan: %u bigendian: %u", sample_size, sample_rate, channels, bigendian); } if (bytes >= len + 8) { ptr += len + 8; bytes -= (len + 8); } else { LOG_WARN("run out of data"); return; } }
void StatusManager::reload() { XML::Document doc(statusReferenceFile); xmlNodePtr rootNode = doc.rootNode(); if (!rootNode || !xmlStrEqual(rootNode->name, BAD_CAST "status-effects")) { LOG_ERROR("Status Manager: Error while parsing status database (" << statusReferenceFile << ")!"); return; } LOG_INFO("Loading status reference: " << statusReferenceFile); for_each_xml_child_node(node, rootNode) { if (!xmlStrEqual(node->name, BAD_CAST "status-effect")) continue; const int id = XML::getProperty(node, "id", 0); if (id < 1) { LOG_WARN("Status Manager: The status ID: " << id << " in " << statusReferenceFile << " is invalid and will be ignored."); continue; } StatusEffect *statusEffect = new StatusEffect(id); const std::string name = XML::getProperty(node, "name", std::string()); if (!name.empty()) { if (statusEffectsByName.contains(name)) { LOG_WARN("StatusManager: name not unique for status effect " << id); } else { statusEffectsByName.insert(name, statusEffect); } } //TODO: Get these modifiers /* modifiers.setAttributeValue(BASE_ATTR_PHY_ATK_MIN, XML::getProperty(node, "attack-min", 0)); modifiers.setAttributeValue(BASE_ATTR_PHY_ATK_DELTA, XML::getProperty(node, "attack-delta", 0)); modifiers.setAttributeValue(BASE_ATTR_HP, XML::getProperty(node, "hp", 0)); modifiers.setAttributeValue(BASE_ATTR_PHY_RES, XML::getProperty(node, "defense", 0)); modifiers.setAttributeValue(CHAR_ATTR_STRENGTH, XML::getProperty(node, "strength", 0)); modifiers.setAttributeValue(CHAR_ATTR_AGILITY, XML::getProperty(node, "agility", 0)); modifiers.setAttributeValue(CHAR_ATTR_DEXTERITY, XML::getProperty(node, "dexterity", 0)); modifiers.setAttributeValue(CHAR_ATTR_VITALITY, XML::getProperty(node, "vitality", 0)); modifiers.setAttributeValue(CHAR_ATTR_INTELLIGENCE, XML::getProperty(node, "intelligence", 0)); modifiers.setAttributeValue(CHAR_ATTR_WILLPOWER, XML::getProperty(node, "willpower", 0)); */ statusEffects[id] = statusEffect; } }
oob_intf* oob_intf_create(const char *name, const uint8_t mac[6]) { int rc; int flags; struct ifreq ifr; oob_intf *intf = NULL; #define _CHECK_RC(fmt, ...) do { \ if (rc < 0) { \ rc = errno; \ LOG_ERR(rc, fmt, ##__VA_ARGS__); \ goto err_out; \ } \ } while(0) intf = malloc(sizeof(*intf)); if (!intf) { rc = ENOMEM; LOG_ERR(rc, "Failed to allocate memory for interface"); goto err_out; } memset(intf, 0, sizeof(*intf)); strncpy(intf->oi_name, name, sizeof(intf->oi_name)); intf->oi_name[sizeof(intf->oi_name) - 1] = '\0'; intf->oi_fd = -1; rc = rtnl_open(&intf->oi_rth, 0); _CHECK_RC("Failed to open rth_handler"); rc = open(TUN_DEVICE, O_RDWR); _CHECK_RC("Failed to open %s", TUN_DEVICE); intf->oi_fd = rc; memset(&ifr, 0, sizeof(ifr)); /* * IFF_TAP: TAP interface * IFF_NO_PI: Do not provide pracket information */ ifr.ifr_flags = IFF_TAP|IFF_NO_PI; strncpy(ifr.ifr_name, name, sizeof(ifr.ifr_name)); ifr.ifr_name[sizeof(ifr.ifr_name) - 1] = '\0'; rc = ioctl(intf->oi_fd, TUNSETIFF, (void *) &ifr); _CHECK_RC("Failed to create tap interface %s", ifr.ifr_name); /* make fd non-blocking */ rc = fcntl(intf->oi_fd, F_GETFL); _CHECK_RC("Failed to get flags from fd ", intf->oi_fd); flags = rc | O_NONBLOCK; rc = fcntl(intf->oi_fd, F_SETFL, rc); _CHECK_RC("Failed to set non-blocking flags ", flags, " to fd ", intf->oi_fd); /* set CLOEXEC */ rc = fcntl(intf->oi_fd, F_GETFD); _CHECK_RC("Failed to get flags from fd ", intf->oi_fd); flags = rc | FD_CLOEXEC; rc = fcntl(intf->oi_fd, F_SETFD, flags); _CHECK_RC("Failed to set close-on-exec flags ", flags, " to fd ", intf->oi_fd); // TODO: if needed, we can adjust send buffer size, TUNSETSNDBUF intf->oi_ifidx = ll_name_to_index(intf->oi_name); /* now set the mac address */ oob_intf_set_mac(intf, mac); #if 0 /* make it persistent */ rc = ioctl(intf->oi_fd, TUNSETPERSIST, 0); _CHECK_RC("Failed to make the tap interface %s persistent", intf->oi_name); #endif LOG_INFO("Create/attach to tap interface %s @ fd %d, index %d", intf->oi_name, intf->oi_fd, intf->oi_ifidx); //oob_intf_bring_up(intf); return intf; err_out: if (intf) { rtnl_close(&intf->oi_rth); if (intf->oi_fd != -1) { close(intf->oi_fd); } free(intf); } return NULL; }
void UpdaterPrivate::SilentlyUpdate() { LOG_INFO(Frontend, "Launching silent update..."); LaunchWithArguments(silent_arguments); }
ArchiveFactory_SDMCWriteOnly::ArchiveFactory_SDMCWriteOnly(const std::string& mount_point) : sdmc_directory(mount_point) { LOG_INFO(Service_FS, "Directory %s set as SDMCWriteOnly.", sdmc_directory.c_str()); }
int start_rendering() { static int done = 0; static void * network_thread_data[2] = { NULL, NULL }; static Uint32 last_frame_and_command_update = 0; SDL_Thread *network_thread; queue_t *message_queue; #ifndef WINDOWS SDL_EventState(SDL_SYSWMEVENT,SDL_ENABLE); #endif queue_initialise(&message_queue); network_thread_data[0] = message_queue; network_thread_data[1] = &done; network_thread = SDL_CreateThread(get_message_from_server, network_thread_data); /* Loop until done. */ while( !done ) { SDL_Event event; // handle SDL events in_main_event_loop = 1; while( SDL_PollEvent( &event ) ) { done = HandleEvent(&event); } in_main_event_loop = 0; //advance the clock cur_time = SDL_GetTicks(); //check for network data if(!queue_isempty(message_queue)) { message_t *message; while((message = queue_pop(message_queue)) != NULL) { #ifdef OTHER_LIFE handle_extended_protocol_message(message->data, message->length); #else process_message_from_server(message->data, message->length); #endif free(message->data); free(message); } } #ifdef OLC olc_process(); #endif //OLC my_tcp_flush(my_socket); // make sure the tcp output buffer is set if (have_a_map && cur_time > last_frame_and_command_update + 60) { LOCK_ACTORS_LISTS(); next_command(); UNLOCK_ACTORS_LISTS(); move_to_next_frame(); last_frame_and_command_update = cur_time; } while (cur_time > next_second_time && real_game_second < 59) { real_game_second += 1; new_second(); next_second_time += 1000; } #ifdef NEW_SOUND weather_sound_control(); #endif //NEW_SOUND if(!limit_fps || (cur_time-last_time && 1000/(cur_time-last_time) <= limit_fps)) { weather_update(); animate_actors(); //draw everything draw_scene(); last_time=cur_time; } else { SDL_Delay(1);//give up timeslice for anyone else } #ifdef TIMER_CHECK //Check the timers to make sure that they are all still alive... check_timers(); #endif //cache handling if(cache_system)cache_system_maint(); //see if we need to exit if(exit_now) { done = 1; break; } } if(!done) { done = 1; } LOG_INFO("Client closed"); SDL_WaitThread(network_thread,&done); queue_destroy(message_queue); if(pm_log.ppl)free_pm_log(); //save all local data save_local_data(NULL, 0); #ifdef PAWN cleanup_pawn (); #endif #ifdef NEW_SOUND destroy_sound(); // Cleans up physical elements of the sound system and the streams thread clear_sound_data(); // Cleans up the config data #endif // NEW_SOUND ec_destroy_all_effects(); if (have_a_map) { destroy_map(); free_buffers(); } unload_questlog(); save_item_lists(); free_emotes(); free_actor_defs(); free_books(); free_vars(); cleanup_rules(); save_exploration_map(); cleanup_counters(); cleanup_chan_names(); cleanup_hud(); destroy_all_root_windows(); SDL_RemoveTimer(draw_scene_timer); SDL_RemoveTimer(misc_timer); end_particles (); free_bbox_tree(main_bbox_tree); main_bbox_tree = NULL; free_astro_buffer(); free_translations(); free_skybox(); /* Destroy our GL context, etc. */ SDL_QuitSubSystem(SDL_INIT_AUDIO); SDL_QuitSubSystem(SDL_INIT_TIMER); /*#ifdef WINDOWS // attempt to restart if requested if(restart_required > 0){ LOG_INFO("Restarting %s", win_command_line); SDL_CreateThread(system, win_command_line); } #endif //WINDOWS */ #ifdef NEW_SOUND final_sound_exit(); #endif #ifdef CUSTOM_UPDATE stopp_custom_update(); #endif /* CUSTOM_UPDATE */ clear_zip_archives(); clean_update(); cleanup_tcp(); if (use_frame_buffer) free_reflection_framebuffer(); cursors_cleanup(); printf("doing SDL_Quit\n"); fflush(stderr); SDL_Quit( ); printf("done SDL_Quit\n"); fflush(stderr); cleanup_mem(); xmlCleanupParser(); FreeXML(); exit_logging(); return(0); }
/* * Function: _soc_i2c_probe_mux * Purpose: Internal probing of a given I2C MUX. * * Parameters: * unit - StrataSwitch device number or I2C bus number * mux_devid_range - I2C device ID for MUX to scan, -1 for all * i2c_probe_info - data structre of I2C probe parameters * * Return: * SOC_E_*** */ int _soc_i2c_probe_mux(int unit, int mux_devid_range, _soc_i2c_probe_info_t *i2c_probe_info) { int devid, mux_devid; int mux_channel; int rv = SOC_E_NONE; uint8 mux_data; int mux_devid_min, mux_devid_max; if (mux_devid_range < 0) { mux_devid_min = 0; mux_devid_max = NUM_I2C_DEVICES - 1; } else { mux_devid_min = mux_devid_range; mux_devid_max = mux_devid_range; } /* Now scan down the MUX tree */ for (mux_devid = mux_devid_min; mux_devid <= mux_devid_max; mux_devid++) { if (i2c_devices[mux_devid].driver != &_soc_i2c_pca9548_driver) { /* Only the MUX's are interesting here. */ continue; } if (NULL == i2c_probe_info->i2cbus->devs[mux_devid]) { /* We didn't find a MUX of this type */ continue; } if ((0 == i2c_probe_info->i2c_mux_stack_depth) && /* Top level */ (0 != i2c_probe_info->i2c_muxed_devid_count[mux_devid])) { /* We found this MUX type at a lower level of the tree */ continue; } LOG_INFO(BSL_LS_SOC_I2C, (BSL_META_U(unit, "unit %d i2c: Detected MUX 0x%02x - %s\n"), unit, mux_devid, i2c_devices[mux_devid].devname)); for (mux_channel = 0; mux_channel < PCA9548_CHANNEL_NUM; mux_channel++) { /* Set the channel so we can probe beyond it */ mux_data = (1 << mux_channel); if ((rv = i2c_devices[mux_devid].driver->write(unit, mux_devid, 0, &mux_data, 1)) < 0) { LOG_INFO(BSL_LS_SOC_I2C, (BSL_META_U(unit, "unit %d i2c: Could not assign channel %d to %s\n"), unit, mux_channel, i2c_devices[mux_devid].devname)); return rv; } LOG_INFO(BSL_LS_SOC_I2C, (BSL_META_U(unit, "unit %d i2c: Set channel %d of MUX 0x%02x - %s\n"), unit, mux_channel, mux_devid, i2c_devices[mux_devid].devname)); for (devid = 0; devid < NUM_I2C_DEVICES; devid++) { i2c_probe_info->devid = devid; rv = _soc_i2c_probe_device(unit, TRUE, i2c_probe_info); if (SOC_E_EXISTS == rv) { /* Is it a MUX? Recurse! */ if (i2c_devices[devid].driver == &_soc_i2c_pca9548_driver) { /* Record MUX stack to get here */ i2c_probe_info->i2c_mux_stack[i2c_probe_info->i2c_mux_stack_depth] = devid; i2c_probe_info->i2c_mux_stack_depth++; rv = _soc_i2c_probe_mux(unit, devid, i2c_probe_info); if (SOC_FAILURE(rv)) { /* Access error */ return rv; } } rv = SOC_E_NONE; } else if ((SOC_E_NOT_FOUND == rv) || (SOC_E_INIT == rv)) { /* No problem */ rv = SOC_E_NONE; } else if (SOC_FAILURE(rv)) { /* Access error */ return rv; } } } /* Restore default channel 0 on the MUX now that * the probe is complete */ mux_channel = 0; mux_data = (1 << mux_channel); if ((rv = i2c_devices[mux_devid].driver->write(unit, mux_devid, 0, &mux_data, 1)) < 0) { LOG_INFO(BSL_LS_SOC_I2C, (BSL_META_U(unit, "unit %d i2c: Could not assign channel %d to %s\n"), unit, mux_channel, i2c_devices[mux_devid].devname)); return rv; } } i2c_probe_info->i2c_mux_stack_depth--; i2c_probe_info->i2c_mux_stack[i2c_probe_info->i2c_mux_stack_depth] = -1; return rv; }