static void KEYBOARD_SetPort60(Bit16u val) { keyb.auxchanged=(val&AUX)>0; keyb.p60changed=true; keyb.p60data=val; if (keyb.auxchanged) { if (keyb.cb_irq12) { PIC_ActivateIRQ(12); } } else { if (keyb.cb_irq1) { if (machine == MCH_PCJR) CPU_Raise_NMI(); /* NTS: PCjr apparently hooked the keyboard to NMI */ else PIC_ActivateIRQ(1); } } }
void Mouse_AddEvent(Bit8u type) { if (mouse.events < QUEUE_SIZE) { if (mouse.events > 0) { if (type == MOUSE_HAS_MOVED) // Skip duplicate events return; /* Always put the newest element in the front as that the events are * handled backwards (prevents doubleclicks while moving) */ for (Bitu i = mouse.events; i; i--) mouse.event_queue[i] = mouse.event_queue[i-1]; } mouse.event_queue[0].type = type; mouse.event_queue[0].buttons = mouse.buttons; mouse.events++; } if (!mouse.timer_in_progress) { mouse.timer_in_progress = true; PIC_AddEvent(MOUSE_Limit_Events, MOUSE_DELAY); PIC_ActivateIRQ(MOUSE_IRQ); } }
static void cmos_timerevent(Bitu val) { PIC_ActivateIRQ(8); if (cmos.timer.enabled) { PIC_AddEvent(cmos_timerevent,cmos.timer.delay); cmos.regs[0xc] = 0xC0;//Contraption Zack (music) } }
void MOUSE_Limit_Events(Bitu /*val*/) { mouse.timer_in_progress = false; if (mouse.events) { mouse.timer_in_progress = true; PIC_AddEvent(MOUSE_Limit_Events,MOUSE_DELAY); PIC_ActivateIRQ(MOUSE_IRQ); } }
INLINE void Mouse_AddEvent(Bit16u type) { if (mouse.events<QUEUE_SIZE) { /* Always put the newest element in the front as that the events are * handled backwards (prevents doubleclicks while moving) */ for(Bitu i = mouse.events ; i ; i--) mouse.event_queue[i] = mouse.event_queue[i-1]; mouse.event_queue[0].type=type; mouse.event_queue[0].buttons=mouse.buttons; mouse.events++; } PIC_ActivateIRQ(MOUSE_IRQ); }
static Bitu INT74_Handler(void) { if (mouse.events>0) { mouse.events--; /* Check for an active Interrupt Handler that will get called */ if (mouse.sub_mask & mouse.event_queue[mouse.events].type) { /* Save lot's of registers */ Bit32u oldeax,oldebx,oldecx,oldedx,oldesi,oldedi,oldebp,oldesp; Bit16u oldds,oldes,oldss; oldeax=reg_eax;oldebx=reg_ebx;oldecx=reg_ecx;oldedx=reg_edx; oldesi=reg_esi;oldedi=reg_edi;oldebp=reg_ebp;oldesp=reg_esp; oldds=SegValue(ds); oldes=SegValue(es); oldss=SegValue(ss); // Save segments reg_ax=mouse.event_queue[mouse.events].type; reg_bx=mouse.event_queue[mouse.events].buttons; reg_cx=POS_X; reg_dx=POS_Y; reg_si=(Bit16s)(mouse.mickey_x*mouse.mickeysPerPixel_x); reg_di=(Bit16s)(mouse.mickey_y*mouse.mickeysPerPixel_y); // Hmm... this look ok, but moonbase wont work with it /*if (mouse.event_queue[mouse.events].type==MOUSE_MOVED) { mouse.mickey_x=0; mouse.mickey_y=0; }*/ CALLBACK_RunRealFar(mouse.sub_seg,mouse.sub_ofs); reg_eax=oldeax;reg_ebx=oldebx;reg_ecx=oldecx;reg_edx=oldedx; reg_esi=oldesi;reg_edi=oldedi;reg_ebp=oldebp;reg_esp=oldesp; SegSet16(ds,oldds); SegSet16(es,oldes); SegSet16(ss,oldss); // Save segments } DoPS2Callback(mouse.event_queue[mouse.events].buttons, POS_X, POS_Y); } IO_Write(0xa0,0x20); IO_Write(0x20,0x20); /* Check for more Events if so reactivate IRQ */ if (mouse.events) { PIC_ActivateIRQ(MOUSE_IRQ); } return CBRET_NONE; }
static void KEYBOARD_SetPort60(Bit8u val) { keyb.p60changed=true; keyb.p60data=val; if (machine==MCH_PCJR) PIC_ActivateIRQ(6); else PIC_ActivateIRQ(1); }
void bx_ne2k_c::write_cr(Bit32u value) { BX_DEBUG ("wrote 0x%02x to CR", value); // Validate remote-DMA if ((value & 0x38) == 0x00) { BX_DEBUG("CR write - invalid rDMA value 0"); value |= 0x20; /* dma_cmd == 4 is a safe default */ //value = 0x22; /* dma_cmd == 4 is a safe default */ } // Check for s/w reset if (value & 0x01) { BX_NE2K_THIS s.ISR.reset = 1; BX_NE2K_THIS s.CR.stop = 1; } else { BX_NE2K_THIS s.CR.stop = 0; } BX_NE2K_THIS s.CR.rdma_cmd = (value & 0x38) >> 3; // If start command issued, the RST bit in the ISR // must be cleared if ((value & 0x02) && !BX_NE2K_THIS s.CR.start) { BX_NE2K_THIS s.ISR.reset = 0; } BX_NE2K_THIS s.CR.start = ((value & 0x02) == 0x02); BX_NE2K_THIS s.CR.pgsel = (value & 0xc0) >> 6; // Check for send-packet command if (BX_NE2K_THIS s.CR.rdma_cmd == 3) { // Set up DMA read from receive ring BX_NE2K_THIS s.remote_start = BX_NE2K_THIS s.remote_dma = BX_NE2K_THIS s.bound_ptr * 256; BX_NE2K_THIS s.remote_bytes = *((Bit16u*) & BX_NE2K_THIS s.mem[BX_NE2K_THIS s.bound_ptr * 256 + 2 - BX_NE2K_MEMSTART]); BX_INFO("Sending buffer #x%x length %d", BX_NE2K_THIS s.remote_start, BX_NE2K_THIS s.remote_bytes); } // Check for start-tx if ((value & 0x04) && BX_NE2K_THIS s.TCR.loop_cntl) { // loopback mode if (BX_NE2K_THIS s.TCR.loop_cntl != 1) { BX_INFO("Loop mode %d not supported.", BX_NE2K_THIS s.TCR.loop_cntl); } else { rx_frame (& BX_NE2K_THIS s.mem[BX_NE2K_THIS s.tx_page_start*256 - BX_NE2K_MEMSTART], BX_NE2K_THIS s.tx_bytes); // do a TX interrupt // Generate an interrupt if not masked and not one in progress if (BX_NE2K_THIS s.IMR.tx_inte && !BX_NE2K_THIS s.ISR.pkt_tx) { //LOG_MSG("tx complete interrupt"); PIC_ActivateIRQ(s.base_irq); } BX_NE2K_THIS s.ISR.pkt_tx = 1; } } else if (value & 0x04) { // start-tx and no loopback if (BX_NE2K_THIS s.CR.stop || !BX_NE2K_THIS s.CR.start) BX_PANIC(("CR write - tx start, dev in reset")); if (BX_NE2K_THIS s.tx_bytes == 0) BX_PANIC(("CR write - tx start, tx bytes == 0")); #ifdef notdef // XXX debug stuff printf("packet tx (%d bytes):\t", BX_NE2K_THIS s.tx_bytes); for (int i = 0; i < BX_NE2K_THIS s.tx_bytes; i++) { printf("%02x ", BX_NE2K_THIS s.mem[BX_NE2K_THIS s.tx_page_start*256 - BX_NE2K_MEMSTART + i]); if (i && (((i+1) % 16) == 0)) printf("\t"); } printf(""); #endif // Send the packet to the system driver /* TODO: Transmit packet */ //BX_NE2K_THIS ethdev->sendpkt(& BX_NE2K_THIS s.mem[BX_NE2K_THIS s.tx_page_start*256 - BX_NE2K_MEMSTART], BX_NE2K_THIS s.tx_bytes); NE2000_PrivelegeEscalate(); pcap_sendpacket(adhandle,&s.mem[s.tx_page_start*256 - BX_NE2K_MEMSTART], s.tx_bytes); NE2000_PrivelegeDrop(); // some more debug if (BX_NE2K_THIS s.tx_timer_active) { BX_PANIC(("CR write, tx timer still active")); PIC_RemoveEvents(NE2000_TX_Event); } //LOG_MSG("send packet command"); //s.tx_timer_index = (64 + 96 + 4*8 + BX_NE2K_THIS s.tx_bytes*8)/10; s.tx_timer_active = 1; PIC_AddEvent(NE2000_TX_Event,(float)((64 + 96 + 4*8 + BX_NE2K_THIS s.tx_bytes*8)/10000.0),0); // Schedule a timer to trigger a tx-complete interrupt // The number of microseconds is the bit-time / 10. // The bit-time is the preamble+sfd (64 bits), the // inter-frame gap (96 bits), the CRC (4 bytes), and the // the number of bits in the frame (s.tx_bytes * 8). // /* TODO: Code transmit timer */ /* bx_pc_system.activate_timer(BX_NE2K_THIS s.tx_timer_index, (64 + 96 + 4*8 + BX_NE2K_THIS s.tx_bytes*8)/10, 0); // not continuous */ } // end transmit-start branch // Linux probes for an interrupt by setting up a remote-DMA read // of 0 bytes with remote-DMA completion interrupts enabled. // Detect this here if (BX_NE2K_THIS s.CR.rdma_cmd == 0x01 && BX_NE2K_THIS s.CR.start && BX_NE2K_THIS s.remote_bytes == 0) { BX_NE2K_THIS s.ISR.rdma_done = 1; if (BX_NE2K_THIS s.IMR.rdma_inte) { PIC_ActivateIRQ(s.base_irq); //DEV_pic_raise_irq(BX_NE2K_THIS s.base_irq); } } }
static void TandyDAC_DMA_CallBack(DmaChannel * /*chan*/, DMAEvent event) { if (event == DMA_REACHED_TC) { tandy.dac.dma.transfer_done=true; PIC_ActivateIRQ(tandy.dac.hw.irq); } }