void pm_setup(void) { cr0_set(cr0_get() | CR0_PM); cs_set(KERNEL_CS); ds_set(KERNEL_DS); es_set(KERNEL_DS); fs_set(KERNEL_DS); gs_set(KERNEL_DS); ss_set(KERNEL_DS); console_message(T_OK, "Kernel now running in protected-mode"); }
void ZmqServer::start() { // init estate if(this->peers.size() < 1) es_init(this->estate_node_address.c_str(), this->estate_node_port); else es_init_with_peers(this->estate_node_address.c_str(), this->estate_node_port, this->peers.c_str()); cout << "ZMQ API server listening to port: " << this->local_api_port << endl; while (true) { // prepare messages zmqpp::message response_msg; zmqpp::message request_msg; // receive requests this->recv_socket->receive(request_msg); // work on request if(request_msg.parts() > 1) { //cout << "received: " << request_msg.get(0) << " " << request_msg.get(1) << endl; if(request_msg.get(0) == "SET") { //--- SET command es_set(request_msg.get(1).c_str(), request_msg.get(2).c_str()); response_msg.push_back("OK"); } else if(request_msg.get(0) == "GET") { //--- GET command const char* data = es_get(request_msg.get(1).c_str()); response_msg.push_back("OK"); response_msg.push_back(data); } else if(request_msg.get(0) == "DEL") { //--- DEL command es_del(request_msg.get(1).c_str()); response_msg.push_back("OK"); } else if(request_msg.get(0) == "GET_GLOBAL") { //--- GET_GLOBAL command if(request_msg.get(2) == "LATEST") { const char* data = es_get_global(request_msg.get(1).c_str(), reduce_latest); response_msg.push_back("OK"); response_msg.push_back(data); } else if(request_msg.get(2) == "SUM") { const char* data = es_get_global(request_msg.get(1).c_str(), reduce_sum); response_msg.push_back("OK"); response_msg.push_back(data); } else if(request_msg.get(2) == "AVG") { const char* data = es_get_global(request_msg.get(1).c_str(), reduce_avg); response_msg.push_back("OK"); response_msg.push_back(data); } else { response_msg.push_back("ERROR"); response_msg.push_back("reduce function not implemented"); } } else { response_msg.push_back("ERROR"); response_msg.push_back("unknown command"); } } else { response_msg.push_back("ERROR"); response_msg.push_back("missing message parts"); } // send reply //cout << "sending: " << response_msg.get(0) << endl; this->recv_socket->send(response_msg); } }