+kdp_remove_all_breakpoints(void)
+{
+ int i;
+ boolean_t breakpoint_found = FALSE;
+
+ if (breakpoints_initialized) {
+ for (i = 0; i < MAX_BREAKPOINTS; i++) {
+ if (breakpoint_list[i].address) {
+ kdp_machine_vm_write((caddr_t)&(breakpoint_list[i].oldbytes), (mach_vm_address_t)breakpoint_list[i].address, (mach_vm_size_t)breakpoint_list[i].bytesused);
+ breakpoint_found = TRUE;
+ breakpoint_list[i].address = 0;
+ }
+ }
+
+ if (breakpoint_found) {
+ printf("kdp_remove_all_breakpoints: found extant breakpoints, removing them.\n");
+ }
+ }
+ return breakpoint_found;
+}
+
+boolean_t
+kdp_reboot(
+ __unused kdp_pkt_t *pkt,
+ __unused int *len,
+ __unused unsigned short *reply_port
+ )
+{
+ dprintf(("kdp_reboot\n"));
+
+ kdp_machine_reboot();
+
+ return TRUE; // no, not really, we won't return
+}
+
+static boolean_t
+kdp_readioport(
+ kdp_pkt_t *pkt,
+ int *len,
+ unsigned short *reply_port
+ )
+{
+ kdp_readioport_req_t *rq = &pkt->readioport_req;
+ kdp_readioport_reply_t *rp = &pkt->readioport_reply;
+ size_t plen = *len;
+
+ if (plen < sizeof(*rq)) {
+ return FALSE;
+ }
+
+ rp->hdr.is_reply = 1;
+ rp->hdr.len = sizeof(*rp);
+
+ if (rq->nbytes > MAX_KDP_DATA_SIZE) {
+ rp->error = KDPERR_BAD_NBYTES;
+ } else {
+#if KDP_TEST_HARNESS
+ uint16_t addr = rq->address;
+#endif
+ uint16_t size = rq->nbytes;
+ dprintf(("kdp_readioport addr %x size %d\n", addr, size));
+
+ rp->error = kdp_machine_ioport_read(rq, rp->data, rq->lcpu);
+ if (rp->error == KDPERR_NO_ERROR) {
+ rp->hdr.len += size;
+ }
+ }
+
+ *reply_port = kdp.reply_port;
+ *len = rp->hdr.len;
+
+ return TRUE;
+}
+
+static boolean_t
+kdp_writeioport(
+ kdp_pkt_t *pkt,
+ int *len,
+ unsigned short *reply_port
+ )
+{
+ kdp_writeioport_req_t *rq = &pkt->writeioport_req;
+ kdp_writeioport_reply_t *rp = &pkt->writeioport_reply;
+ size_t plen = *len;
+
+ if (plen < sizeof(*rq)) {
+ return FALSE;
+ }
+
+ if (rq->nbytes > MAX_KDP_DATA_SIZE) {
+ rp->error = KDPERR_BAD_NBYTES;
+ } else {
+ dprintf(("kdp_writeioport addr %x size %d\n", rq->address,
+ rq->nbytes));
+
+ rp->error = kdp_machine_ioport_write(rq, rq->data, rq->lcpu);
+ }
+
+ rp->hdr.is_reply = 1;
+ rp->hdr.len = sizeof(*rp);
+
+ *reply_port = kdp.reply_port;
+ *len = rp->hdr.len;
+
+ return TRUE;
+}
+
+static boolean_t
+kdp_readmsr64(
+ kdp_pkt_t *pkt,
+ int *len,
+ unsigned short *reply_port
+ )
+{
+ kdp_readmsr64_req_t *rq = &pkt->readmsr64_req;
+ kdp_readmsr64_reply_t *rp = &pkt->readmsr64_reply;
+ size_t plen = *len;
+
+ if (plen < sizeof(*rq)) {
+ return FALSE;
+ }
+
+ rp->hdr.is_reply = 1;
+ rp->hdr.len = sizeof(*rp);
+
+ dprintf(("kdp_readmsr64 lcpu %x addr %x\n", rq->lcpu, rq->address));
+ rp->error = kdp_machine_msr64_read(rq, rp->data, rq->lcpu);
+ if (rp->error == KDPERR_NO_ERROR) {
+ rp->hdr.len += sizeof(uint64_t);
+ }
+
+ *reply_port = kdp.reply_port;
+ *len = rp->hdr.len;
+
+ return TRUE;
+}
+
+static boolean_t
+kdp_writemsr64(
+ kdp_pkt_t *pkt,
+ int *len,
+ unsigned short *reply_port
+ )
+{
+ kdp_writemsr64_req_t *rq = &pkt->writemsr64_req;
+ kdp_writemsr64_reply_t *rp = &pkt->writemsr64_reply;
+ size_t plen = *len;
+
+ if (plen < sizeof(*rq)) {
+ return FALSE;
+ }
+
+ dprintf(("kdp_writemsr64 lcpu %x addr %x\n", rq->lcpu, rq->address));
+ rp->error = kdp_machine_msr64_write(rq, rq->data, rq->lcpu);
+
+ rp->hdr.is_reply = 1;
+ rp->hdr.len = sizeof(*rp);
+
+ *reply_port = kdp.reply_port;
+ *len = rp->hdr.len;
+
+ return TRUE;
+}
+
+static boolean_t
+kdp_dumpinfo(
+ kdp_pkt_t *pkt,
+ int *len,
+ unsigned short *reply_port
+ )
+{
+ kdp_dumpinfo_req_t *rq = &pkt->dumpinfo_req;
+ kdp_dumpinfo_reply_t *rp = &pkt->dumpinfo_reply;
+ size_t plen = *len;
+
+ if (plen < sizeof(*rq)) {
+ return FALSE;
+ }
+
+ dprintf(("kdp_dumpinfo file=%s destip=%s routerip=%s\n", rq->name, rq->destip, rq->routerip));
+ rp->hdr.is_reply = 1;
+ rp->hdr.len = sizeof(*rp);
+
+ if ((rq->type & KDP_DUMPINFO_MASK) != KDP_DUMPINFO_GETINFO) {
+ kdp_set_dump_info(rq->type, rq->name, rq->destip, rq->routerip,
+ rq->port);
+ }
+
+ /* gather some stats for reply */
+ kdp_get_dump_info(rp);
+
+ *reply_port = kdp.reply_port;
+ *len = rp->hdr.len;
+
+ return TRUE;