uint8_t WizFi250SpiDrv::wizspi_byte(uint8_t byte, uint8_t issue_cs, uint16_t delay1, uint16_t delay2, uint8_t print) { uint8_t spi_data; if ( issue_cs != 0 ) digitalWrite(m_WizFi250_CS, LOW); if ( delay1 > 0 ) delayMicroseconds(delay1 * 10); spi_data = SPI.transfer(byte); if ( delay2 > 0 ) delayMicroseconds(delay2 * 10); if ( issue_cs != 0 ) digitalWrite(m_WizFi250_CS, HIGH); if ( print == 1 ) { DBG("{0x"); DBG_TYPE(spi_data, HEX); DBG("}"); } else if ( print == 2 ) { if ( isprint(spi_data) || spi_data == 0x0d || spi_data == 0x0a ) DBG((char)spi_data); else { DBG("{0x"); DBG_TYPE(spi_data, HEX); DBG("}"); } } else if ( print == 3 ) { if ( spi_data != SPI_NULL ) { if ( isprint(spi_data) || spi_data == 0x0d || spi_data == 0x0a ) DBG((char)spi_data); } } return spi_data; }
unsigned int mhp_debug(enum dosdebug_event code, unsigned int parm1, unsigned int parm2) { int rtncd = 0; #if 0 return rtncd; #endif mhpdbgc.currcode = code; mhp_bpclr(); switch (DBG_TYPE(mhpdbgc.currcode)) { case DBG_INIT: mhp_init(); break; case DBG_BOOT: mhp_boot(); break; case DBG_INTx: if (!mhpdbg.active) break; if (test_bit(DBG_ARG(mhpdbgc.currcode), mhpdbg.intxxtab)) { if ((mhpdbgc.bpload==1) && (DBG_ARG(mhpdbgc.currcode) == 0x21) && (LWORD(eax) == 0x4b00) ) { /* mhpdbgc.bpload_bp=((long)SREG(cs) << 4) +LWORD(eip); */ mhpdbgc.bpload_bp = SEGOFF2LINEAR(SREG(cs), LWORD(eip)); if (mhp_setbp(mhpdbgc.bpload_bp)) { mhp_printf("bpload: intercepting EXEC\n", SREG(cs), REG(eip)); /* mhp_cmd("r"); mhp_cmd("d ss:sp 30h"); */ mhpdbgc.bpload++; mhpdbgc.bpload_par=MK_FP32(BIOSSEG,(long)DBGload_parblock-(long)bios_f000); MEMCPY_2UNIX(mhpdbgc.bpload_par, SEGOFF2LINEAR(SREG(es), LWORD(ebx)), 14); MEMCPY_2UNIX(mhpdbgc.bpload_cmdline, PAR4b_addr(commandline_ptr), 128); MEMCPY_2UNIX(mhpdbgc.bpload_cmd, SEGOFF2LINEAR(SREG(ds), LWORD(edx)), 128); SREG(es)=BIOSSEG; LWORD(ebx)=(void *)mhpdbgc.bpload_par - MK_FP32(BIOSSEG, 0); LWORD(eax)=0x4b01; /* load, but don't execute */ } else { mhp_printf("bpload: ??? #1\n"); mhp_cmd("r"); mhpdbgc.bpload_bp=0; mhpdbgc.bpload=0; } if (!--mhpdbgc.int21_count) { volatile register int i=0x21; /* beware, set_bit-macro has wrong constraints */ clear_bit(i, mhpdbg.intxxtab); if (test_bit(i, mhpdbgc.intxxalt)) { clear_bit(i, mhpdbgc.intxxalt); reset_revectored(i, &vm86s.int_revectored); } } } else { if ((DBG_ARG(mhpdbgc.currcode) != 0x21) || !mhpdbgc.bpload ) { mhpdbgc.stopped = 1; if (parm1) LWORD(eip) -= 2; mhpdbgc.int_handled = 0; mhp_poll(); if (mhpdbgc.int_handled) rtncd = 1; else if (parm1) LWORD(eip) += 2; } } } break; case DBG_INTxDPMI: if (!mhpdbg.active) break; mhpdbgc.stopped = 1; #if WITH_DPMI dpmi_mhp_intxxtab[DBG_ARG(mhpdbgc.currcode) & 0xff] &= ~2; #endif break; case DBG_TRAP: if (!mhpdbg.active) break; if (DBG_ARG(mhpdbgc.currcode) == 1) { /* single step */ switch (mhpdbgc.trapcmd) { case 2: /* t command -- step until IP changes */ if (mhpdbgc.trapip == mhp_getcsip_value()) break; /* no break */ case 1: /* ti command */ mhpdbgc.trapcmd = 0; rtncd = 1; mhpdbgc.stopped = 1; break; } if (traceloop && mhp_bpchk(mhp_getcsip_value())) { traceloop = 0; loopbuf[0] = '\0'; } } if (DBG_ARG(mhpdbgc.currcode) == 3) { /* int3 (0xCC) */ int ok=0; unsigned int csip=mhp_getcsip_value() - 1; if (mhpdbgc.bpload_bp == csip ) { /* mhp_cmd("r"); */ mhp_clearbp(mhpdbgc.bpload_bp); mhp_modify_eip(-1); if (mhpdbgc.bpload == 2) { mhp_printf("bpload: INT3 caught\n"); SREG(cs)=BIOSSEG; LWORD(eip)=(long)DBGload-(long)bios_f000; mhpdbgc.trapcmd = 1; mhpdbgc.bpload = 0; } } else { if ((ok=mhp_bpchk( csip))) { mhp_modify_eip(-1); } else { if ((ok=test_bit(3, mhpdbg.intxxtab))) { /* software programmed INT3 */ mhp_modify_eip(-1); mhp_cmd("r"); mhp_modify_eip(+1); } } } if (ok) { mhpdbgc.trapcmd = 0; rtncd = 1; mhpdbgc.stopped = 1; } } break; case DBG_PRE_VM86: mhp_pre_vm86(); break; case DBG_POLL: mhp_poll(); break; case DBG_GPF: if (!mhpdbg.active) break; mhpdbgc.stopped = 1; mhp_poll(); break; default: break; } if (mhpdbg.active) mhp_bpset(); return rtncd; }