[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 2 14/39] windbg: send data and control packets
From: |
Mikhail Abakumov |
Subject: |
[Qemu-devel] [PATCH 2 14/39] windbg: send data and control packets |
Date: |
Wed, 05 Dec 2018 15:53:22 +0300 |
User-agent: |
StGit/0.17.1-dirty |
Signed-off-by: Mikhail Abakumov <address@hidden>
Signed-off-by: Pavel Dovgalyuk <address@hidden>
---
windbgstub.c | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 59 insertions(+)
diff --git a/windbgstub.c b/windbgstub.c
index 2869d94389..c45faec43f 100644
--- a/windbgstub.c
+++ b/windbgstub.c
@@ -71,6 +71,65 @@ static void windbg_state_clean(WindbgState *state)
state->ctx.result = RESULT_NONE;
}
+static uint32_t compute_checksum(uint8_t *data, uint16_t len)
+{
+ uint32_t checksum = 0;
+ while (len) {
+ --len;
+ checksum += *data++;
+ }
+ return checksum;
+}
+
+static void windbg_store_packet(KD_PACKET *packet)
+{
+ stw_p(&packet->PacketLeader, packet->PacketLeader);
+ stw_p(&packet->PacketType, packet->PacketType);
+ stw_p(&packet->ByteCount, packet->ByteCount);
+ stl_p(&packet->PacketId, packet->PacketId);
+ stl_p(&packet->Checksum, packet->Checksum);
+}
+
+__attribute__ ((unused)) /* unused yet */
+static void windbg_send_data_packet(WindbgState *state, uint8_t *data,
+ uint16_t byte_count, uint16_t type)
+{
+ const uint8_t trailing_byte = PACKET_TRAILING_BYTE;
+
+ KD_PACKET packet = {
+ .PacketLeader = PACKET_LEADER,
+ .PacketType = type,
+ .ByteCount = byte_count,
+ .PacketId = state->curr_packet_id,
+ .Checksum = compute_checksum(data, byte_count),
+ };
+
+ windbg_store_packet(&packet);
+
+ qemu_chr_fe_write(&state->chr, PTR(packet), sizeof(packet));
+ qemu_chr_fe_write(&state->chr, data, byte_count);
+ qemu_chr_fe_write(&state->chr, &trailing_byte, sizeof(trailing_byte));
+
+ state->wait_packet_type = PACKET_TYPE_KD_ACKNOWLEDGE;
+}
+
+__attribute__ ((unused)) /* unused yet */
+static void windbg_send_control_packet(WindbgState *state, uint16_t type,
+ uint32_t id)
+{
+ KD_PACKET packet = {
+ .PacketLeader = CONTROL_PACKET_LEADER,
+ .PacketType = type,
+ .ByteCount = 0,
+ .PacketId = id,
+ .Checksum = 0,
+ };
+
+ windbg_store_packet(&packet);
+
+ qemu_chr_fe_write(&state->chr, PTR(packet), sizeof(packet));
+}
+
static void windbg_ctx_handler(WindbgState *state)
{
}
- [Qemu-devel] [PATCH 2 04/39] windbg: add helper features, (continued)
- [Qemu-devel] [PATCH 2 04/39] windbg: add helper features, Mikhail Abakumov, 2018/12/05
- [Qemu-devel] [PATCH 2 05/39] windbg: add WindbgState, Mikhail Abakumov, 2018/12/05
- [Qemu-devel] [PATCH 2 06/39] windbg: add chardev, Mikhail Abakumov, 2018/12/05
- [Qemu-devel] [PATCH 2 08/39] windbg: implement windbg_on_load, Mikhail Abakumov, 2018/12/05
- [Qemu-devel] [PATCH 2 07/39] windbg: hook to wrmsr operation, Mikhail Abakumov, 2018/12/05
- [Qemu-devel] [PATCH 2 09/39] windbg: implement find_KPCR, Mikhail Abakumov, 2018/12/05
- [Qemu-devel] [PATCH 2 10/39] windbg: implement find_kdVersion, Mikhail Abakumov, 2018/12/05
- [Qemu-devel] [PATCH 2 11/39] windbg: add windbg_search_vmaddr, Mikhail Abakumov, 2018/12/05
- [Qemu-devel] [PATCH 2 12/39] windbg: implement find_kdDebuggerDataBlock, Mikhail Abakumov, 2018/12/05
- [Qemu-devel] [PATCH 2 13/39] windbg: parsing data stream, Mikhail Abakumov, 2018/12/05
- [Qemu-devel] [PATCH 2 14/39] windbg: send data and control packets,
Mikhail Abakumov <=
- [Qemu-devel] [PATCH 2 15/39] windbg: handler of parsing context, Mikhail Abakumov, 2018/12/05
- [Qemu-devel] [PATCH 2 16/39] windbg: init DBGKD_ANY_WAIT_STATE_CHANGE, Mikhail Abakumov, 2018/12/05
- [Qemu-devel] [PATCH 2 17/39] windbg: generate ExceptionStateChange and LoadSymbolsStateChange, Mikhail Abakumov, 2018/12/05
- [Qemu-devel] [PATCH 2 18/39] windbg: implement windbg_process_control_packet, Mikhail Abakumov, 2018/12/05
- [Qemu-devel] [PATCH 2 19/39] windbg: implement windbg_process_data_packet, Mikhail Abakumov, 2018/12/05
- [Qemu-devel] [PATCH 2 21/39] windbg: implement kd_api_read_virtual_memory and kd_api_write_virtual_memory, Mikhail Abakumov, 2018/12/05
- [Qemu-devel] [PATCH 2 20/39] windbg: implement windbg_process_manipulate_packet, Mikhail Abakumov, 2018/12/05
- [Qemu-devel] [PATCH 2 22/39] windbg: some kernel structures, Mikhail Abakumov, 2018/12/05
- [Qemu-devel] [PATCH 2 23/39] windbg: add helper functions, Mikhail Abakumov, 2018/12/05
- [Qemu-devel] [PATCH 2 24/39] windbg: [de]serialization cpu context, Mikhail Abakumov, 2018/12/05