Пример #1
0
void davicom_interrupt(int minor_no)
{
dword status;
PDAVICOM_SOFTC softc;
PDESCRIPTOR pdesc;
DCU msg;
int pkt_len;

    softc = off_to_davicom_softc(minor_no);
    if (!softc)
        return;

     status = READ_CR(DC_STATUS_ISR_CR5);
     WRITE_CR(DC_STATUS_ISR_CR5, status);

     status &= DC_STATUS_MASK;  /* keep only bits we are interested in */

     if (status & DC_ISR_RX_DONE)
         while (1)
         {
            pdesc = softc->rx_desc + softc->this_rx;
            if (pdesc->buffer == 0)
               break;
            if (pdesc->status & OWN_BIT)
               break;
            if ((pdesc->status & (ES_BIT|PLE_BIT|AE_BIT)) == 0) /* no error */
            {
                pkt_len = (pdesc->status >> 16) & 2047;
                msg = softc->rx_dcus[softc->this_rx];

                /* set up length of packet; MUST be set to actual size      */
                /* not including crc etc even if allocated a larger         */
                /* packet above                                             */
                DCUTOPACKET(msg)->length = pkt_len;

                softc->stats.packets_in++;
                softc->stats.bytes_in += pkt_len;

                /* signal IP layer that a packet is on its exchange'      */
                /* send packet from ring buffer                           */
                ks_invoke_input(softc->iface, msg);

                /* replace current DCU from ring buffer just passed to      */
                /* IP task with a new DCU                                   */
                softc->rx_dcus[softc->this_rx] = msg = os_alloc_packet_input(CFG_MAX_PACKETSIZE+4, DRIVER_ALLOC);
                if (msg)
                   pdesc->buffer = (dword) DCUTODATA(msg);
                else
                {
                   pdesc->buffer = 0; /* out of buffers */
                   DEBUG_ERROR("davicom_interrupt: out of DCUs", NOVAR, 0, 0);
                }
            }
            else /* error receive, discard */
            {
Пример #2
0
uint8_t mc6821_read(struct MC6821 *pia, uint16_t A) {
	switch (A & 3) {
		default:
		case 0:
			if (DDR_SELECTED(pia->a))
				return pia->a.direction_register;
			READ_DR(pia->a);
			return pia->a.out_sink & pia->a.in_sink;
		case 1:
			READ_CR(pia->a);
			return (pia->a.control_register | (pia->a.interrupt_received ? 0x80 : 0));
		case 2:
			if (DDR_SELECTED(pia->b))
				return pia->b.direction_register;
			READ_DR(pia->b);
			return (pia->b.output_register & pia->b.direction_register) | ((pia->b.out_source | pia->b.in_source) & pia->b.out_sink & pia->b.in_sink & ~pia->b.direction_register);
		case 3:
			READ_CR(pia->b);
			return (pia->b.control_register | (pia->b.interrupt_received ? 0x80 : 0));
	}
}