Lines Matching refs:syndbg

51 static void set_pending_state(HvSynDbg *syndbg, bool has_pending)  in set_pending_state()  argument
56 syndbg->has_data_pending = has_pending; in set_pending_state()
58 if (!syndbg->pending_page_gpa) { in set_pending_state()
63 out_data = cpu_physical_memory_map(syndbg->pending_page_gpa, &out_len, 1); in set_pending_state()
99 static uint16_t handle_send_msg(HvSynDbg *syndbg, uint64_t ingpa, in handle_send_msg() argument
119 &syndbg->target_ip)) { in handle_send_msg()
125 sent_count = sendto(syndbg->socket, pkt_data, count - udp_data_ofs, in handle_send_msg()
146 static bool create_udp_pkt(HvSynDbg *syndbg, void *pkt, uint32_t pkt_len, in create_udp_pkt() argument
168 PKT_GET_IP_HDR(pkt)->ip_src = syndbg->servaddr.sin_addr.s_addr; in create_udp_pkt()
169 PKT_GET_IP_HDR(pkt)->ip_dst = syndbg->target_ip; in create_udp_pkt()
178 udp_part->uh_sport = syndbg->servaddr.sin_port; in create_udp_pkt()
179 udp_part->uh_dport = syndbg->servaddr.sin_port; in create_udp_pkt()
186 static uint16_t handle_recv_msg(HvSynDbg *syndbg, uint64_t outgpa, in handle_recv_msg() argument
200 if (!syndbg->has_data_pending) { in handle_recv_msg()
203 recv_byte_count = recv(syndbg->socket, data_buf, in handle_recv_msg()
215 set_pending_state(syndbg, false); in handle_recv_msg()
227 !create_udp_pkt(syndbg, out_data, in handle_recv_msg()
249 HvSynDbg *syndbg = context; in hv_syndbg_handler() local
255 ntohl(syndbg->servaddr.sin_addr.s_addr); in hv_syndbg_handler()
257 ntohs(syndbg->servaddr.sin_port); in hv_syndbg_handler()
261 ret = handle_send_msg(syndbg, msg->u.send.buf_gpa, msg->u.send.count, in hv_syndbg_handler()
265 ret = handle_recv_msg(syndbg, msg->u.recv.buf_gpa, msg->u.recv.count, in hv_syndbg_handler()
271 syndbg->pending_page_gpa = msg->u.pending_page.buf_gpa; in hv_syndbg_handler()
276 if (syndbg->use_hcalls) { in hv_syndbg_handler()
290 HvSynDbg *syndbg = opaque; in hv_syndbg_recv_event() local
297 FD_SET(syndbg->socket, &rfds); in hv_syndbg_recv_event()
298 if (select(syndbg->socket + 1, &rfds, NULL, NULL, &tv) > 0) { in hv_syndbg_recv_event()
299 set_pending_state(syndbg, true); in hv_syndbg_recv_event()
305 HvSynDbg *syndbg = HVSYNDBG(dev); in hv_syndbg_realize() local
319 if (qemu_isdigit(syndbg->host_ip[0])) { in hv_syndbg_realize()
320 syndbg->servaddr.sin_addr.s_addr = inet_addr(syndbg->host_ip); in hv_syndbg_realize()
322 struct hostent *he = gethostbyname(syndbg->host_ip); in hv_syndbg_realize()
325 TYPE_HV_SYNDBG, syndbg->host_ip); in hv_syndbg_realize()
328 syndbg->servaddr.sin_addr = *(struct in_addr *)he->h_addr; in hv_syndbg_realize()
331 syndbg->socket = socket(AF_INET, SOCK_DGRAM, 0); in hv_syndbg_realize()
332 if (syndbg->socket < 0) { in hv_syndbg_realize()
337 qemu_socket_set_nonblock(syndbg->socket); in hv_syndbg_realize()
339 syndbg->servaddr.sin_port = htons(syndbg->host_port); in hv_syndbg_realize()
340 syndbg->servaddr.sin_family = AF_INET; in hv_syndbg_realize()
341 if (connect(syndbg->socket, (struct sockaddr *)&syndbg->servaddr, in hv_syndbg_realize()
342 sizeof(syndbg->servaddr)) < 0) { in hv_syndbg_realize()
343 close(syndbg->socket); in hv_syndbg_realize()
348 syndbg->pending_page_gpa = 0; in hv_syndbg_realize()
349 syndbg->has_data_pending = false; in hv_syndbg_realize()
350 hyperv_set_syndbg_handler(hv_syndbg_handler, syndbg); in hv_syndbg_realize()
351 qemu_set_fd_handler(syndbg->socket, hv_syndbg_recv_event, NULL, syndbg); in hv_syndbg_realize()
356 HvSynDbg *syndbg = HVSYNDBG(dev); in hv_syndbg_unrealize() local
358 if (syndbg->socket > 0) { in hv_syndbg_unrealize()
359 qemu_set_fd_handler(syndbg->socket, NULL, NULL, NULL); in hv_syndbg_unrealize()
360 close(syndbg->socket); in hv_syndbg_unrealize()