void bx_tap_pktmover_c::rx_timer() { int nbytes; Bit8u buf[BX_PACKET_BUFSIZE]; Bit8u *rxbuf; if (fd<0) return; #if defined(__sun__) struct strbuf sbuf; int f = 0; sbuf.maxlen = sizeof(buf); sbuf.buf = (char *)buf; nbytes = getmsg(fd, NULL, &sbuf, &f) >=0 ? sbuf.len : -1; #else nbytes = read (fd, buf, sizeof(buf)); #endif // hack: discard first two bytes #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__APPLE__) || defined(__sun__) // Should be fixed for other *BSD rxbuf = buf; #else rxbuf = buf+2; nbytes-=2; #endif #if defined(__linux__) // hack: TAP device likes to create an ethernet header which has // the same source and destination address FE:FD:00:00:00:00. // Change the dest address to FE:FD:00:00:00:01. if (!memcmp(&rxbuf[0], &rxbuf[6], 6)) { rxbuf[5] = guest_macaddr[5]; } #endif if (nbytes>0) BX_DEBUG(("tap read returned %d bytes", nbytes)); if (nbytes<0) { if (errno != EAGAIN) BX_ERROR(("tap read error: %s", strerror(errno))); return; } #if BX_ETH_TAP_LOGGING if (nbytes > 0) { BX_DEBUG(("receive packet length %u", nbytes)); // dump raw bytes to a file, eventually dump in pcap format so that // tcpdump -r FILE can interpret them for us. int n = fwrite(rxbuf, nbytes, 1, rxlog); if (n != 1) BX_ERROR(("fwrite to rxlog failed, nbytes = %d", nbytes)); // dump packet in hex into an ascii log file write_pktlog_txt(rxlog_txt, rxbuf, nbytes, 1); // flush log so that we see the packets as they arrive w/o buffering fflush(rxlog); } #endif BX_DEBUG(("eth_tap: got packet: %d bytes, dst=%x:%x:%x:%x:%x:%x, src=%x:%x:%x:%x:%x:%x\n", nbytes, rxbuf[0], rxbuf[1], rxbuf[2], rxbuf[3], rxbuf[4], rxbuf[5], rxbuf[6], rxbuf[7], rxbuf[8], rxbuf[9], rxbuf[10], rxbuf[11])); if (nbytes < 60) { BX_INFO(("packet too short (%d), padding to 60", nbytes)); nbytes = 60; } (*rxh)(netdev, rxbuf, nbytes); }
BX_CPU_C::load_cs(bx_selector_t *selector, bx_descriptor_t *descriptor, Bit8u cpl) { BX_CPU_THIS_PTR sregs[BX_SEG_REG_CS].selector = *selector; BX_CPU_THIS_PTR sregs[BX_SEG_REG_CS].cache = *descriptor; /* caller may request different CPL then in selector */ BX_CPU_THIS_PTR sregs[BX_SEG_REG_CS].selector.rpl = cpl; BX_CPU_THIS_PTR sregs[BX_SEG_REG_CS].cache.valid = 1; // Added cpl to the selector value. BX_CPU_THIS_PTR sregs[BX_SEG_REG_CS].selector.value = (0xfffc & BX_CPU_THIS_PTR sregs[BX_SEG_REG_CS].selector.value) | cpl; #if BX_SUPPORT_X86_64 if (BX_CPU_THIS_PTR efer.lma) { if (descriptor->u.segment.l) { BX_CPU_THIS_PTR cpu_mode = BX_MODE_LONG_64; BX_DEBUG(("Long Mode Activated")); loadSRegLMNominal(BX_SEG_REG_CS, selector->value, cpl); } else { BX_DEBUG(("Compatibility Mode Activated")); BX_CPU_THIS_PTR cpu_mode = BX_MODE_LONG_COMPAT; } } #endif #if BX_SUPPORT_ICACHE BX_CPU_THIS_PTR updateFetchModeMask(); #endif // Loading CS will invalidate the EIP fetch window. invalidate_prefetch_q(); }
int serial_raw::receive() { #ifdef WIN32 int data; #endif if (present) { #ifdef WIN32 if (DCBchanged) { setup_port(); } data = rxdata_buffer[0]; if (rxdata_count > 0) { memcpy(&rxdata_buffer[0], &rxdata_buffer[1], sizeof(Bit16s)*(RX_BUFSIZE-1)); rxdata_count--; } if (data < 0) { switch (data) { case RAW_EVENT_CTS_ON: MSR_value |= 0x10; break; case RAW_EVENT_CTS_OFF: MSR_value &= ~0x10; break; case RAW_EVENT_DSR_ON: MSR_value |= 0x20; break; case RAW_EVENT_DSR_OFF: MSR_value &= ~0x20; break; case RAW_EVENT_RING_ON: MSR_value |= 0x40; break; case RAW_EVENT_RING_OFF: MSR_value &= ~0x40; break; case RAW_EVENT_RLSD_ON: MSR_value |= 0x80; break; case RAW_EVENT_RLSD_OFF: MSR_value &= ~0x80; break; } } return data; #else BX_DEBUG (("receive returning 'A'")); return (int)'A'; #endif } else { BX_DEBUG (("receive returning 'A'")); return (int)'A'; } }
void bx_tap_pktmover_c::sendpkt(void *buf, unsigned io_len) { Bit8u txbuf[BX_PACKET_BUFSIZE]; txbuf[0] = 0; txbuf[1] = 0; unsigned int size; #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || \ defined(__APPLE__) || defined(__OpenBSD__) || defined(__sun__) // Should be fixed for other *BSD memcpy(txbuf, buf, io_len); /* PD - for Sun variant the retry cycle from qemu - mainly to be sure packet is really out */ #if defined(__sun__) int ret; for(;;) { ret=write(fd, txbuf, io_len); if (ret < 0 && (errno == EINTR || errno == EAGAIN)) { } else { size=ret; break; } } #else /* not defined __sun__ */ size = write(fd, txbuf, io_len); #endif /* whole condition about defined __sun__ */ if (size != io_len) { #else /* not bsd/apple/sun style */ memcpy(txbuf+2, buf, io_len); size = write(fd, txbuf, io_len+2); if (size != io_len+2) { #endif BX_PANIC(("write on tap device: %s", strerror(errno))); } else { BX_DEBUG(("wrote %d bytes + ev. 2 byte pad on tap", io_len)); } #if BX_ETH_TAP_LOGGING BX_DEBUG(("sendpkt length %u", io_len)); // dump raw bytes to a file, eventually dump in pcap format so that // tcpdump -r FILE can interpret them for us. int n = fwrite(buf, io_len, 1, txlog); if (n != 1) BX_ERROR(("fwrite to txlog failed, io_len = %u", io_len)); // dump packet in hex into an ascii log file write_pktlog_txt(txlog_txt, (const Bit8u *)buf, io_len, 0); // flush log so that we see the packets as they arrive w/o buffering fflush(txlog); #endif } void bx_tap_pktmover_c::rx_timer_handler(void *this_ptr) { bx_tap_pktmover_c *class_ptr = (bx_tap_pktmover_c *) this_ptr; class_ptr->rx_timer(); }
BXKeyEntry *bx_keymap_c::findHostKey(Bit32u key) { // We look through the keymap table to find the searched key for (Bit16u i=0; i<keymapCount; i++) { if (keymapTable[i].hostKey == key) { BX_DEBUG (("key 0x%02x matches hostKey for entry #%d", key, i)); return &keymapTable[i]; } } BX_DEBUG(("key %02x matches no entries", key)); // Return default return NULL; }
void bx_pit_c::handle_timer() { Bit64u my_time_usec = bx_virt_timer.time_usec(); Bit64u time_passed = my_time_usec-BX_PIT_THIS s.last_usec; Bit32u time_passed32 = (Bit32u)time_passed; BX_DEBUG(("entering timer handler")); if(time_passed32) { periodic(time_passed32); } BX_PIT_THIS s.last_usec = BX_PIT_THIS s.last_usec + time_passed; if (time_passed || (BX_PIT_THIS s.last_next_event_time != BX_PIT_THIS s.timer.get_next_event_time())) { BX_DEBUG(("RESETting timer")); bx_virt_timer.deactivate_timer(BX_PIT_THIS s.timer_handle[0]); BX_DEBUG(("deactivated timer")); if(BX_PIT_THIS s.timer.get_next_event_time()) { bx_virt_timer.activate_timer(BX_PIT_THIS s.timer_handle[0], (Bit32u)BX_MAX(1,TICKS_TO_USEC(BX_PIT_THIS s.timer.get_next_event_time())), 0); BX_DEBUG(("activated timer")); } BX_PIT_THIS s.last_next_event_time = BX_PIT_THIS s.timer.get_next_event_time(); } BX_DEBUG(("s.last_usec="FMT_LL"d", BX_PIT_THIS s.last_usec)); BX_DEBUG(("s.timer_id=%d", BX_PIT_THIS s.timer_handle[0])); BX_DEBUG(("s.timer.get_next_event_time=%x", BX_PIT_THIS s.timer.get_next_event_time())); BX_DEBUG(("s.last_next_event_time=%d", BX_PIT_THIS s.last_next_event_time)); }
off_t vmware3_image_t::perform_seek() { if(requested_offset < current->min_offset || requested_offset >= current->max_offset) { if(!sync()) { BX_DEBUG(("could not sync before switching vmware3 COW files")); return INVALID_OFFSET; } while(requested_offset < current->min_offset) current = &images[current->header.chain_id - 1]; while(requested_offset >= current->max_offset) current = &images[current->header.chain_id + 1]; } if(current->offset != INVALID_OFFSET && requested_offset >= current->offset && requested_offset < current->offset + tlb_size) return (requested_offset - current->offset); if(!sync()) { BX_DEBUG(("could not sync before seeking vmware3 COW file")); return INVALID_OFFSET; } unsigned relative_offset = (unsigned)(requested_offset - current->min_offset); unsigned i = relative_offset >> FL_SHIFT; unsigned j = (relative_offset & ~FL_MASK) / tlb_size; if(current->slb[i][j]) { if(::lseek(current->fd, current->slb[i][j] * 512, SEEK_SET) < 0) { BX_DEBUG(("could not seek vmware3 COW to sector slb[%d][%d]", i, j)); return INVALID_OFFSET; } if(::read(current->fd, current->tlb, tlb_size) < 0) { BX_DEBUG(("could not read %d bytes from vmware3 COW image", tlb_size)); return INVALID_OFFSET; } } else memset(current->tlb, 0, tlb_size); current->offset = (requested_offset / tlb_size) * tlb_size; return (requested_offset - current->offset); }
BXKeyEntry *bx_keymap_c::findAsciiChar(Bit8u ch) { BX_DEBUG (("findAsciiChar (0x%02x)", ch)); // We look through the keymap table to find the searched key for (Bit16u i=0; i<keymapCount; i++) { if (keymapTable[i].ascii == ch) { BX_DEBUG (("key %02x matches ascii for entry #%d", ch, i)); return &keymapTable[i]; } } BX_DEBUG (("key 0x%02x matches no entries", ch)); // Return default return NULL; }
void serial_raw::set_parity_mode(int mode) { BX_DEBUG (("set parity mode %d", mode)); #ifdef WIN32 switch (mode) { case 0: dcb.fParity = FALSE; dcb.Parity = NOPARITY; break; case 1: dcb.fParity = TRUE; dcb.Parity = ODDPARITY; break; case 2: dcb.fParity = TRUE; dcb.Parity = EVENPARITY; break; case 3: dcb.fParity = TRUE; dcb.Parity = MARKPARITY; break; case 4: dcb.fParity = TRUE; dcb.Parity = SPACEPARITY; break; } DCBchanged = TRUE; #endif }
void serial_raw::transmit(Bit8u byte) { #ifdef WIN32 DWORD DErr, Len2; OVERLAPPED tx_ovl; #endif BX_DEBUG (("transmit %d", byte)); if (present) { #ifdef WIN32 if (DCBchanged) { setup_port(); } else { ClearCommError(hCOM, &DErr, NULL); } memset(&tx_ovl, 0, sizeof(OVERLAPPED)); tx_ovl.hEvent = CreateEvent(NULL,TRUE,TRUE,"transmit"); if (!WriteFile(hCOM, &byte, 1, &Len2, &tx_ovl)) { if (GetLastError() == ERROR_IO_PENDING) { if (WaitForSingleObject(tx_ovl.hEvent, 100) == WAIT_OBJECT_0) { GetOverlappedResult(hCOM, &tx_ovl, &Len2, FALSE); } } } if (Len2 != 1) BX_ERROR(("transmit failed: len = %d", Len2)); ClearCommError(hCOM, &DErr, NULL); CloseHandle(tx_ovl.hEvent); #endif } }
void BX_CPU_C::iret32_stack_return_from_v86(bxInstruction_c *i) { if (BX_CPU_THIS_PTR get_IOPL() < 3) { // trap to virtual 8086 monitor BX_DEBUG(("IRET in vm86 with IOPL != 3, VME = 0")); exception(BX_GP_EXCEPTION, 0); } Bit32u eip, cs_raw, flags32; // Build a mask of the following bits: // ID,VIP,VIF,AC,VM,RF,x,NT,IOPL,OF,DF,IF,TF,SF,ZF,x,AF,x,PF,x,CF Bit32u change_mask = EFlagsOSZAPCMask | EFlagsTFMask | EFlagsIFMask | EFlagsDFMask | EFlagsNTMask | EFlagsRFMask; #if BX_CPU_LEVEL >= 4 change_mask |= (EFlagsIDMask | EFlagsACMask); // ID/AC #endif eip = pop_32(); cs_raw = pop_32(); flags32 = pop_32(); load_seg_reg(&BX_CPU_THIS_PTR sregs[BX_SEG_REG_CS], (Bit16u) cs_raw); EIP = eip; // VIF, VIP, VM, IOPL unchanged writeEFlags(flags32, change_mask); }
ssize_t vmware3_image_t::write(const void * buf, size_t count) { ssize_t total = 0; while(count > 0) { off_t offset = perform_seek(); if(offset == INVALID_OFFSET) return -1; unsigned bytes_remaining = (unsigned)(tlb_size - offset); unsigned amount = 0; current->synced = false; if(bytes_remaining > count) { memcpy(current->tlb + offset, buf, count); amount = count; } else { memcpy(current->tlb + offset, buf, bytes_remaining); if(!sync()) { BX_DEBUG(("failed to sync when writing %u bytes", (unsigned)count)); return -1; } amount = bytes_remaining; } requested_offset += amount; total += amount; count -= amount; } return total; }
void BochsView::MouseUp(BPoint point) { UNUSED(point); // currently a place holder function BX_DEBUG(("mouseup()")); BView::MouseUp(point); }
void bx_cpu_c::RETnear32_Iw(BxInstruction_t *i) { Bit16u imm16; Bit32u temp_ESP; Bit32u return_EIP; #if BX_DEBUGGER bx_cpu. show_flag |= Flag_ret; #endif if (bx_cpu. sregs[BX_SEG_REG_SS].cache.u.segment.d_b) /* 32bit stack */ temp_ESP = ESP; else temp_ESP = SP; imm16 = i->Iw; invalidate_prefetch_q(); if (protected_mode()) { if ( !can_pop(4) ) { BX_PANIC(("retnear_iw: can't pop EIP")); /* ??? #SS(0) -or #GP(0) */ } access_linear(bx_cpu. sregs[BX_SEG_REG_SS].cache.u.segment.base + temp_ESP + 0, 4, CPL==3, BX_READ, &return_EIP); if (protected_mode() && (return_EIP > bx_cpu. sregs[BX_SEG_REG_CS].cache.u.segment.limit_scaled) ) { BX_DEBUG(("retnear_iw: EIP > limit")); exception(BX_GP_EXCEPTION, 0, 0); } /* Pentium book says imm16 is number of words ??? */ if ( !can_pop(4 + imm16) ) { BX_PANIC(("retnear_iw: can't release bytes from stack")); /* #GP(0) -or #SS(0) ??? */ } bx_cpu. eip = return_EIP; if (bx_cpu. sregs[BX_SEG_REG_SS].cache.u.segment.d_b) /* 32bit stack */ ESP += 4 + imm16; /* ??? should it be 2*imm16 ? */ else SP += 4 + imm16; } else { pop_32(&return_EIP); bx_cpu. eip = return_EIP; if (bx_cpu. sregs[BX_SEG_REG_SS].cache.u.segment.d_b) /* 32bit stack */ ESP += imm16; /* ??? should it be 2*imm16 ? */ else SP += imm16; } BX_INSTR_UCNEAR_BRANCH(BX_INSTR_IS_RET, bx_cpu. eip); }
// Dumps the contents of a buffer to the log file void usb_device_c::usb_dump_packet(Bit8u *data, unsigned size) { char the_packet[256], str[16]; strcpy(the_packet, "Packet contents (in hex):"); unsigned offset = 0; for (unsigned p=0; p<size; p++) { if (!(p & 0x0F)) { BX_DEBUG(("%s", the_packet)); sprintf(the_packet, " 0x%04X ", offset); offset += 16; } sprintf(str, " %02X", data[p]); strcat(the_packet, str); } if (strlen(the_packet)) BX_DEBUG(("%s", the_packet)); }
void serial_raw::set_data_bits(int val) { BX_DEBUG (("set data bits (%d)", val)); #ifdef WIN32 dcb.ByteSize = val; DCBchanged = TRUE; #endif }
void BochsView::MouseMoved(BPoint point, uint32 transit, const BMessage *message) { UNUSED(point); UNUSED(transit); UNUSED(message); BX_DEBUG(("mousemoved()")); }
void serial_raw::set_modem_control(int ctrl) { BX_DEBUG (("set modem control 0x%02x", ctrl)); #ifdef WIN32 EscapeCommFunction(hCOM, (ctrl & 0x01)?SETDTR:CLRDTR); EscapeCommFunction(hCOM, (ctrl & 0x02)?SETRTS:CLRRTS); #endif }
void bx_pit_c::init(void) { DEV_register_irq(0, "8254 PIT"); DEV_register_ioread_handler(this, read_handler, 0x0040, "8254 PIT", 1); DEV_register_ioread_handler(this, read_handler, 0x0041, "8254 PIT", 1); DEV_register_ioread_handler(this, read_handler, 0x0042, "8254 PIT", 1); DEV_register_ioread_handler(this, read_handler, 0x0043, "8254 PIT", 1); DEV_register_ioread_handler(this, read_handler, 0x0061, "8254 PIT", 1); DEV_register_iowrite_handler(this, write_handler, 0x0040, "8254 PIT", 1); DEV_register_iowrite_handler(this, write_handler, 0x0041, "8254 PIT", 1); DEV_register_iowrite_handler(this, write_handler, 0x0042, "8254 PIT", 1); DEV_register_iowrite_handler(this, write_handler, 0x0043, "8254 PIT", 1); DEV_register_iowrite_handler(this, write_handler, 0x0061, "8254 PIT", 1); BX_DEBUG(("starting init")); BX_PIT_THIS s.speaker_data_on = 0; BX_PIT_THIS s.refresh_clock_div2 = 0; BX_PIT_THIS s.timer.init(); BX_PIT_THIS s.timer.set_OUT_handler(0, irq_handler); Bit64u my_time_usec = bx_virt_timer.time_usec(); if (BX_PIT_THIS s.timer_handle[0] == BX_NULL_TIMER_HANDLE) { BX_PIT_THIS s.timer_handle[0] = bx_virt_timer.register_timer(this, timer_handler, (unsigned) 100 , 1, 1, "pit_wrap"); } BX_DEBUG(("RESETting timer.")); bx_virt_timer.deactivate_timer(BX_PIT_THIS s.timer_handle[0]); BX_DEBUG(("deactivated timer.")); if (BX_PIT_THIS s.timer.get_next_event_time()) { bx_virt_timer.activate_timer(BX_PIT_THIS s.timer_handle[0], (Bit32u)BX_MAX(1,TICKS_TO_USEC(BX_PIT_THIS s.timer.get_next_event_time())), 0); BX_DEBUG(("activated timer.")); } BX_PIT_THIS s.last_next_event_time = BX_PIT_THIS s.timer.get_next_event_time(); BX_PIT_THIS s.last_usec = my_time_usec; BX_PIT_THIS s.total_ticks = 0; BX_PIT_THIS s.total_usec = 0; BX_DEBUG(("finished init")); BX_DEBUG(("s.last_usec="FMT_LL"d",BX_PIT_THIS s.last_usec)); BX_DEBUG(("s.timer_id=%d",BX_PIT_THIS s.timer_handle[0])); BX_DEBUG(("s.timer.get_next_event_time=%d", BX_PIT_THIS s.timer.get_next_event_time())); BX_DEBUG(("s.last_next_event_time=%d", BX_PIT_THIS s.last_next_event_time)); }
void bx_tap_pktmover_c::sendpkt(void *buf, unsigned io_len) { Bit8u txbuf[BX_PACKET_BUFSIZE]; txbuf[0] = 0; txbuf[1] = 0; #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || \ defined(__APPLE__) || defined(__OpenBSD__) // Should be fixed for other *BSD memcpy(txbuf, buf, io_len); unsigned int size = write(fd, txbuf, io_len); if (size != io_len) { #else memcpy(txbuf+2, buf, io_len); unsigned int size = write(fd, txbuf, io_len+2); if (size != io_len+2) { #endif BX_PANIC(("write on tap device: %s", strerror(errno))); } else { BX_DEBUG(("wrote %d bytes + 2 byte pad on tap", io_len)); } #if BX_ETH_TAP_LOGGING BX_DEBUG(("sendpkt length %u", io_len)); // dump raw bytes to a file, eventually dump in pcap format so that // tcpdump -r FILE can interpret them for us. int n = fwrite(buf, io_len, 1, txlog); if (n != 1) BX_ERROR(("fwrite to txlog failed, io_len = %u", io_len)); // dump packet in hex into an ascii log file fprintf(txlog_txt, "NE2K transmitting a packet, length %u\n", io_len); Bit8u *charbuf = (Bit8u *)buf; for (n=0; n<(int)io_len; n++) { if (((n % 16) == 0) && n>0) fprintf(txlog_txt, "\n"); fprintf(txlog_txt, "%02x ", charbuf[n]); } fprintf(txlog_txt, "\n--\n"); // flush log so that we see the packets as they arrive w/o buffering fflush(txlog); fflush(txlog_txt); #endif } void bx_tap_pktmover_c::rx_timer_handler(void *this_ptr) { bx_tap_pktmover_c *class_ptr = (bx_tap_pktmover_c *) this_ptr; class_ptr->rx_timer(); }
void BochsView::MouseDown(BPoint point) { UNUSED(point); if (point.y < BX_HEADER_BAR_Y) { headerbar_click(int(point.x), int(point.y)); return; } BX_DEBUG(("mousedown()")); }
void bx_arpback_pktmover_c::rx_timer_handler (void * this_ptr) { #if BX_ETH_NULL_LOGGING BX_DEBUG (("rx_timer_handler")); #endif bx_arpback_pktmover_c *class_ptr = ((bx_arpback_pktmover_c *)this_ptr); class_ptr->rx_timer(); }
int serial_raw::get_modem_status() { int status = 0; #ifdef WIN32 status = MSR_value; #endif BX_DEBUG (("get modem status returns 0x%02x", status)); return status; }
void BX_CPU_C::iret16_stack_return_from_v86(bxInstruction_c *i) { if ((BX_CPU_THIS_PTR get_IOPL() < 3) && (BX_CR4_VME_ENABLED == 0)) { // trap to virtual 8086 monitor BX_DEBUG(("IRET in vm86 with IOPL != 3, VME = 0")); exception(BX_GP_EXCEPTION, 0); } Bit16u ip, cs_raw, flags16; ip = pop_16(); cs_raw = pop_16(); flags16 = pop_16(); #if BX_CPU_LEVEL >= 5 if (BX_CPU_THIS_PTR cr4.get_VME() && BX_CPU_THIS_PTR get_IOPL() < 3) { if (((flags16 & EFlagsIFMask) && BX_CPU_THIS_PTR get_VIP()) || (flags16 & EFlagsTFMask)) { BX_DEBUG(("iret16_stack_return_from_v86(): #GP(0) in VME mode")); exception(BX_GP_EXCEPTION, 0); } load_seg_reg(&BX_CPU_THIS_PTR sregs[BX_SEG_REG_CS], cs_raw); EIP = (Bit32u) ip; // IF, IOPL unchanged, EFLAGS.VIF = TMP_FLAGS.IF Bit32u changeMask = EFlagsOSZAPCMask | EFlagsTFMask | EFlagsDFMask | EFlagsNTMask | EFlagsVIFMask; Bit32u flags32 = (Bit32u) flags16; if (flags16 & EFlagsIFMask) flags32 |= EFlagsVIFMask; writeEFlags(flags32, changeMask); return; } #endif load_seg_reg(&BX_CPU_THIS_PTR sregs[BX_SEG_REG_CS], cs_raw); EIP = (Bit32u) ip; write_flags(flags16, /*IOPL*/ 0, /*IF*/ 1); }
BX_CPU_C::read_virtual_dqword_aligned(unsigned s, bx_address offset, Bit8u *data) { // If double quadword access is unaligned, #GP(0). bx_address laddr = BX_CPU_THIS_PTR get_laddr(s, offset); if (laddr & 0xf) { BX_DEBUG(("read_virtual_dqword_aligned(): access not aligned to 16-byte")); exception(BX_GP_EXCEPTION, 0, 0); } read_virtual_dqword(s, offset, data); }
BX_CPU_C::write_virtual_dqword_aligned(unsigned s, bx_address offset, Bit8u *data) { // If double quadword access is unaligned, #GP(0). bx_address laddr = BX_CPU_THIS_PTR get_segment_base(s) + offset; if (laddr & 0xf) { BX_DEBUG(("write_virtual_dqword_aligned: access not aligned to 16-byte")); exception(BX_GP_EXCEPTION, 0, 0); } write_virtual_dqword(s, offset, data); }
bx_bool serial_raw::ready_receive() { #ifdef WIN32_RECEIVE_RAW if ((rxdata_count == 0) && (thread_rxdata_count > 0)) { SetEvent(thread_ovl.hEvent); SetEvent(rx_ovl.hEvent); } #endif BX_DEBUG (("ready_receive returning %d", (rxdata_count > 0))); return (rxdata_count > 0); }
void serial_raw::set_break(int mode) { BX_DEBUG (("set break %s", mode?"on":"off")); #ifdef WIN32 if (mode) { SetCommBreak(hCOM); } else { ClearCommBreak(hCOM); } #endif }
// // read_cr/write_cr - utility routines for handling reads/writes to // the Command Register // Bit32u bx_ne2k_c::read_cr(void) { Bit32u val = (((BX_NE2K_THIS s.CR.pgsel & 0x03) << 6) | ((BX_NE2K_THIS s.CR.rdma_cmd & 0x07) << 3) | (BX_NE2K_THIS s.CR.tx_packet << 2) | (BX_NE2K_THIS s.CR.start << 1) | (BX_NE2K_THIS s.CR.stop)); BX_DEBUG("read CR returns 0x%08x", val); return val; }
void BX_CPU_C::get_SS_ESP_from_TSS(unsigned pl, Bit16u *ss, Bit32u *esp) { if (BX_CPU_THIS_PTR tr.cache.valid==0) BX_PANIC(("get_SS_ESP_from_TSS: TR.cache invalid")); if (BX_CPU_THIS_PTR tr.cache.type==BX_SYS_SEGMENT_AVAIL_386_TSS || BX_CPU_THIS_PTR tr.cache.type==BX_SYS_SEGMENT_BUSY_386_TSS) { // 32-bit TSS Bit32u TSSstackaddr = 8*pl + 4; if ((TSSstackaddr+7) > BX_CPU_THIS_PTR tr.cache.u.system.limit_scaled) { BX_DEBUG(("get_SS_ESP_from_TSS(386): TSSstackaddr > TSS.LIMIT")); exception(BX_TS_EXCEPTION, BX_CPU_THIS_PTR tr.selector.value & 0xfffc, 0); } access_read_linear(BX_CPU_THIS_PTR tr.cache.u.system.base + TSSstackaddr+4, 2, 0, BX_READ, ss); access_read_linear(BX_CPU_THIS_PTR tr.cache.u.system.base + TSSstackaddr, 4, 0, BX_READ, esp); } else if (BX_CPU_THIS_PTR tr.cache.type==BX_SYS_SEGMENT_AVAIL_286_TSS || BX_CPU_THIS_PTR tr.cache.type==BX_SYS_SEGMENT_BUSY_286_TSS) { // 16-bit TSS Bit16u temp16; Bit32u TSSstackaddr = 4*pl + 2; if ((TSSstackaddr+4) > BX_CPU_THIS_PTR tr.cache.u.system.limit_scaled) { BX_DEBUG(("get_SS_ESP_from_TSS(286): TSSstackaddr > TSS.LIMIT")); exception(BX_TS_EXCEPTION, BX_CPU_THIS_PTR tr.selector.value & 0xfffc, 0); } access_read_linear(BX_CPU_THIS_PTR tr.cache.u.system.base + TSSstackaddr+2, 2, 0, BX_READ, ss); access_read_linear(BX_CPU_THIS_PTR tr.cache.u.system.base + TSSstackaddr, 2, 0, BX_READ, &temp16); *esp = temp16; // truncate } else { BX_PANIC(("get_SS_ESP_from_TSS: TR is bogus type (%u)", (unsigned) BX_CPU_THIS_PTR tr.cache.type)); } }