示例#1
0
文件: xlib.c 项目: jacereda/glcv
intptr_t osEvent(ev * e) {
        intptr_t ret = 1;
        static int fullscreen = 0;
        switch (evType(e)) {
        case CVE_QUIT: g_done = 1; break;               
        case CVE_SETCURSOR: 
                setcursor((uint8_t*)evArg0(e), 
                        evArg1(e) >> 16, evArg1(e) & 0xffff); 
                break;
        case CVE_DEFAULTCURSOR: defaultcursor(); break;
        case CVE_WINDOWED:
                if (fullscreen) {
                        closewin();
                        openwin(g_nx, g_ny, g_nw, g_nh, 1);
                        map();
                        fullscreen = 0;
                }
                break;
        case CVE_FULLSCREEN: 
                if (!fullscreen) {
                        savegeom();
                        closewin();
                        openwin(0, 0, 
                                DisplayWidth(g_dpy, scr()), 
                                DisplayHeight(g_dpy, scr()), 0);
                        map();
                        fullscreen = 1;
                }
                break;
        default: ret = 0;
        }
        return ret;
}
示例#2
0
文件: hd6457x.c 项目: wxlong/Test
static inline void sca_rx(card_t *card, port_t *port, pkt_desc *desc, u16 rxin)
{
	struct net_device *dev = port_to_dev(port);
	struct net_device_stats *stats = hdlc_stats(dev);
	struct sk_buff *skb;
	u16 len;
	u32 buff;
#ifndef ALL_PAGES_ALWAYS_MAPPED
	u32 maxlen;
	u8 page;
#endif

	len = readw(&desc->len);
	skb = dev_alloc_skb(len);
	if (!skb) {
		stats->rx_dropped++;
		return;
	}

	buff = buffer_offset(port, rxin, 0);
#ifndef ALL_PAGES_ALWAYS_MAPPED
	page = buff / winsize(card);
	buff = buff % winsize(card);
	maxlen = winsize(card) - buff;

	openwin(card, page);

	if (len > maxlen) {
		memcpy_fromio(skb->data, winbase(card) + buff, maxlen);
		openwin(card, page + 1);
		memcpy_fromio(skb->data + maxlen, winbase(card), len - maxlen);
	} else
#endif
	memcpy_fromio(skb->data, winbase(card) + buff, len);

#if !defined(PAGE0_ALWAYS_MAPPED) && !defined(ALL_PAGES_ALWAYS_MAPPED)
	/* select pkt_desc table page back */
	openwin(card, 0);
#endif
	skb_put(skb, len);
#ifdef DEBUG_PKT
	printk(KERN_DEBUG "%s RX(%i):", dev->name, skb->len);
	debug_frame(skb);
#endif
	stats->rx_packets++;
	stats->rx_bytes += skb->len;
	skb->mac.raw = skb->data;
	skb->dev = dev;
	skb->dev->last_rx = jiffies;
	skb->protocol = hdlc_type_trans(skb, dev);
	netif_rx(skb);
}
示例#3
0
文件: hd64570.c 项目: 020gzh/linux
static irqreturn_t sca_intr(int irq, void* dev_id)
{
	card_t *card = dev_id;
	int i;
	u8 stat;
	int handled = 0;
	u8 page = sca_get_page(card);

	while((stat = sca_intr_status(card)) != 0) {
		handled = 1;
		for (i = 0; i < 2; i++) {
			port_t *port = get_port(card, i);
			if (port) {
				if (stat & SCA_INTR_MSCI(i))
					sca_msci_intr(port);

				if (stat & SCA_INTR_DMAC_RX(i))
					sca_rx_intr(port);

				if (stat & SCA_INTR_DMAC_TX(i))
					sca_tx_intr(port);
			}
		}
	}

	openwin(card, page);		/* Restore original page */
	return IRQ_RETVAL(handled);
}
示例#4
0
static irqreturn_t sca_intr(int irq, void* dev_id, struct pt_regs *regs)
{
	card_t *card = dev_id;
	int i;
	u8 stat;
	int handled = 0;

#ifndef ALL_PAGES_ALWAYS_MAPPED
	u8 page = sca_get_page(card);
#endif

	while((stat = sca_intr_status(card)) != 0) {
		handled = 1;
		for (i = 0; i < 2; i++) {
			port_t *port = get_port(card, i);
			if (port) {
				if (stat & SCA_INTR_MSCI(i))
					sca_msci_intr(port);

				if (stat & SCA_INTR_DMAC_RX(i))
					sca_rx_intr(port);

				if (stat & SCA_INTR_DMAC_TX(i))
					sca_tx_intr(port);
			}
		}
	}

#ifndef ALL_PAGES_ALWAYS_MAPPED
	openwin(card, page);		/* Restore original page */
#endif
	return IRQ_RETVAL(handled);
}
static inline void sca_rx(card_t *card, port_t *port, pkt_desc __iomem *desc,
                          u16 rxin)
{
    struct net_device *dev = port_to_dev(port);
    struct sk_buff *skb;
    u16 len;
    u32 buff;
    u32 maxlen;
    u8 page;

    len = readw(&desc->len);
    skb = dev_alloc_skb(len);
    if (!skb) {
        dev->stats.rx_dropped++;
        return;
    }

    buff = buffer_offset(port, rxin, 0);
    page = buff / winsize(card);
    buff = buff % winsize(card);
    maxlen = winsize(card) - buff;

    openwin(card, page);

    if (len > maxlen) {
        memcpy_fromio(skb->data, winbase(card) + buff, maxlen);
        openwin(card, page + 1);
        memcpy_fromio(skb->data + maxlen, winbase(card), len - maxlen);
    } else
        memcpy_fromio(skb->data, winbase(card) + buff, len);

#ifndef PAGE0_ALWAYS_MAPPED
    openwin(card, 0);
#endif
    skb_put(skb, len);
#ifdef DEBUG_PKT
    printk(KERN_DEBUG "%s RX(%i):", dev->name, skb->len);
    debug_frame(skb);
#endif
    dev->stats.rx_packets++;
    dev->stats.rx_bytes += skb->len;
    skb->protocol = hdlc_type_trans(skb, dev);
    netif_rx(skb);
}
示例#6
0
void Seg::trim(Sequen *seq, int *leftend, int *rightend)
{
    Sequen *win;
    double prob, minprob;
    int shift, len, i;
    int lend, rend;
    int minlen;

    /* fprintf(stderr, "%d %d\n", *leftend, *rightend);  */

    lend = 0;
    rend = seq->length - 1;
    minlen = 1;
    if ((seq->length-maxtrim)>minlen) minlen = seq->length-maxtrim;

    minprob = 1.;
    for (len=seq->length; len>minlen; len--)
    {
        win = openwin(seq, 0, len);
        i = 0;

        shift = TRUE;
        while (shift)
        {
            prob = getprob(win->state, len);
            if (prob<minprob)
            {
                minprob = prob;
                lend = i;
                rend = len + i - 1;
            }
            shift = shiftwin1(win);
            i++;
        }
        closewin(win);
    }

    /* fprintf(stderr, "%d-%d ", *leftend, *rightend);  */

    *leftend = *leftend + lend;
    *rightend = *rightend - (seq->length - rend - 1);

    /* fprintf(stderr, "%d-%d\n", *leftend, *rightend);  */

    closewin(seq);
    return;
}
示例#7
0
double* Seg::seqent(Sequen *seq)
{
    Sequen *win;
    double *H;
    int i, first, last;

    if (window>seq->length)
    {
        return((double *) NULL);
    }

    H = (double *) malloc(seq->length*sizeof(double));

    for (i=0; i<seq->length; i++)
    {
        H[i] = -1.;
    }

    win = openwin(seq, 0, window);
    enton(win);

    first = downset;
    last = seq->length - upset;

    for (i=first; i<=last; i++)
    {
        if (seq->punctuation && hasdash(win))
        {
            H[i] = -1;
            shiftwin1(win);
            continue;
        }
        H[i] = win->entropy;
        shiftwin1(win);
    }

    closewin(win);
    return(H);
}
示例#8
0
文件: xlib.c 项目: jacereda/glcv
int cvrun(int argc, char ** argv) {
        int attr[] = {
                GLX_RGBA,
                GLX_DOUBLEBUFFER,
                GLX_RED_SIZE, 1,
                GLX_GREEN_SIZE, 1,
                GLX_BLUE_SIZE, 1,
                GLX_DEPTH_SIZE, 1,
                None};
        XVisualInfo * vi;
        g_dpy = XOpenDisplay(0);
        g_xim = XOpenIM(g_dpy, 0, 0, 0);
        cvInject(CVE_INIT, 0, 0);
        openwin(cvInject(CVQ_XPOS, 0, 0),
                cvInject(CVQ_YPOS, 0, 0),
                cvInject(CVQ_WIDTH, 0, 0),
                cvInject(CVQ_HEIGHT, 0, 0), 1);
        vi = glXChooseVisual(g_dpy, scr(), attr);
        g_ctx = glXCreateContext(g_dpy, vi, 0, True);
        XFree(vi);

        map();
        ((int(*)(int))glXGetProcAddress((GLubyte*)"glXSwapIntervalSGI"))(1);
        cvInject(CVE_GLINIT, 0, 0);
        while (!g_done) {
                XEvent e;
                if (XCheckWindowEvent(g_dpy, g_win, EVMASK, &e)
                    || XCheckTypedWindowEvent(g_dpy, g_win, ClientMessage, &e))
                        handle(g_dpy, g_win, g_xic, &e);
                glXSwapBuffers(g_dpy, g_win);
                cvInject(CVE_UPDATE, 0, 0);
        }
        cvInject(CVE_GLTERM, 0, 0);
                closewin();
                glXDestroyContext(g_dpy, g_ctx);
        XCloseIM(g_xim);
        XCloseDisplay(g_dpy);
        return cvInject(CVE_TERM, 0, 0);
}
示例#9
0
void Seg::segseq(Sequen *seq, Segment **segs, int offset)
{
    Segment *seg, *leftsegs;
    Sequen *leftseq;
    int first, last, lowlim;
    int loi, hii, i;
    int leftend, rightend, lend, rend;
    double *H;
    H = seqent(seq);
    if (H==NULL) return;

    first = downset;
    last = seq->length - upset;
    lowlim = first;

    for (i=first; i<=last; i++)
    {
        if (H[i]<=locut && H[i]!=-1)
        {
            loi = findlo(i, lowlim, H);
            hii = findhi(i, last, H);

            leftend = loi - downset;
            rightend = hii + upset - 1;
            //rightend = hii + upset;

            trim(openwin(seq, leftend, rightend-leftend+1), &leftend, &rightend);

            if (i+upset-1<leftend)     /* check for trigger window in left trim */
            {
                lend = loi - downset;
                rend = leftend - 1;

                leftseq = openwin(seq, lend, rend-lend+1);
                leftsegs = (Segment *) NULL;
                segseq(leftseq, &leftsegs, offset+lend);
                if (leftsegs!=NULL)
                {
                    if (*segs==NULL) *segs = leftsegs;
                    else appendseg(*segs, leftsegs);
                }
                closewin(leftseq);

            }

            seg = (Segment *) malloc(sizeof(Segment));
            seg->begin = leftend + offset;
            seg->end = rightend + offset;
            seg->next = (Segment *) NULL;

            if (*segs==NULL) *segs = seg;
            else appendseg(*segs, seg);

            i = min(hii, rightend+downset);
            lowlim = i + 1;
        }
    }

    free(H);
    return;
}
示例#10
0
文件: hd64570.c 项目: 020gzh/linux
static void sca_init_port(port_t *port)
{
	card_t *card = port_to_card(port);
	int transmit, i;

	port->rxin = 0;
	port->txin = 0;
	port->txlast = 0;

#ifndef PAGE0_ALWAYS_MAPPED
	openwin(card, 0);
#endif

	for (transmit = 0; transmit < 2; transmit++) {
		u16 dmac = transmit ? get_dmac_tx(port) : get_dmac_rx(port);
		u16 buffs = transmit ? card->tx_ring_buffers
			: card->rx_ring_buffers;

		for (i = 0; i < buffs; i++) {
			pkt_desc __iomem *desc = desc_address(port, i, transmit);
			u16 chain_off = desc_offset(port, i + 1, transmit);
			u32 buff_off = buffer_offset(port, i, transmit);

			writew(chain_off, &desc->cp);
			writel(buff_off, &desc->bp);
			writew(0, &desc->len);
			writeb(0, &desc->stat);
		}

		/* DMA disable - to halt state */
		sca_out(0, transmit ? DSR_TX(phy_node(port)) :
			DSR_RX(phy_node(port)), card);
		/* software ABORT - to initial state */
		sca_out(DCR_ABORT, transmit ? DCR_TX(phy_node(port)) :
			DCR_RX(phy_node(port)), card);

		/* current desc addr */
		sca_out(0, dmac + CPB, card); /* pointer base */
		sca_outw(desc_offset(port, 0, transmit), dmac + CDAL, card);
		if (!transmit)
			sca_outw(desc_offset(port, buffs - 1, transmit),
				 dmac + EDAL, card);
		else
			sca_outw(desc_offset(port, 0, transmit), dmac + EDAL,
				 card);

		/* clear frame end interrupt counter */
		sca_out(DCR_CLEAR_EOF, transmit ? DCR_TX(phy_node(port)) :
			DCR_RX(phy_node(port)), card);

		if (!transmit) { /* Receive */
			/* set buffer length */
			sca_outw(HDLC_MAX_MRU, dmac + BFLL, card);
			/* Chain mode, Multi-frame */
			sca_out(0x14, DMR_RX(phy_node(port)), card);
			sca_out(DIR_EOME | DIR_BOFE, DIR_RX(phy_node(port)),
				card);
			/* DMA enable */
			sca_out(DSR_DE, DSR_RX(phy_node(port)), card);
		} else {	/* Transmit */
			/* Chain mode, Multi-frame */
			sca_out(0x14, DMR_TX(phy_node(port)), card);
			/* enable underflow interrupts */
			sca_out(DIR_BOFE, DIR_TX(phy_node(port)), card);
		}
	}
	sca_set_carrier(port);
}
示例#11
0
int checkformacs(){
	short mcto=0;
	char temps[2048];

	if(kreturn==11779){
	if(wn[cwin].chan>-1)closchan(wn[cwin].chan);
	return 1;
	}
	
	if(kreturn==19200){
	if(wn[cwin].cx>0){wn[cwin].cx--;return 1;}
	else{
	if(wn[cwin].cvof==0)return 1;
	if(wn[cwin].cvof!=0){wn[cwin].cvof--;wn[cwin].cx=wn[cwin].ihc[wn[cwin].cvof];ipbredraw(cwin);return 1;}
	}
	return 1;
	}
	if(kreturn==19712){
	if(wn[cwin].cx<wn[cwin].ihc[wn[cwin].cvof]){wn[cwin].cx++;return 1;}
	else{
	if(wn[cwin].cx==wn[cwin].ihc[wn[cwin].cvof]){
	if(wn[cwin].ihc[wn[cwin].cvof+1]){wn[cwin].cvof++;wn[cwin].cx=0;ipbredraw(cwin);return 1;}
	else{
	return 1;
	}
	}
	}
	return 1;
	}
	
	if(kreturn==283){
	clearipb(cwin);
	return 1;
	}
	if(kreturn==3849){
	clearipb(cwin);
	strcpy(temps,"/msg ");
	if(lastnt){
	mcto=0;
	lastnc++;
	while(!strlen(lastn[lastnc]) && mcto!=50){
	lastnc++;
	if(lastnc==20)lastnc=0;
	mcto++;
	if(mcto==21)mcto=50;
	}
	}
	if(strlen(lastn[lastnc])){strcat(temps,lastn[lastnc]);strcat(temps," ");wtib(temps,1);}
	lastnt=20;
	return 1;
	}
	
	if(kreturn==15104){doms(0);return 1;}
	if(kreturn==15360){doms(1);return 1;}
	if(kreturn==15616){doms(2);return 1;}
	if(kreturn==15872){doms(3);return 1;}
	if(kreturn==16128){doms(4);return 1;}
	if(kreturn==16384){doms(5);return 1;}
	if(kreturn==16640){doms(6);return 1;}
	if(kreturn==16896){doms(7);return 1;}
	if(kreturn==17152){doms(8);return 1;}
	if(kreturn==17408){doms(9);return 1;}
	
	if(kreturn==30720 && wn[0].hand>-1){topwindow(0);return 1;}
	if(kreturn==30976 && wn[1].hand>-1){topwindow(1);return 1;}
	if(kreturn==31232 && wn[2].hand>-1){topwindow(2);return 1;}
	if(kreturn==31488 && wn[3].hand>-1){topwindow(3);return 1;}
	if(kreturn==31744 && wn[4].hand>-1){topwindow(4);return 1;}
	if(kreturn==32000 && wn[5].hand>-1){topwindow(5);return 1;}
	if(kreturn==3103){
	wtib("",0);
	return 1;
	}
	if(kreturn==3357){
	wtib("",0);
	return 1;
	}
	if(kreturn==10496){
	wtib("",0);
	return 1;
	}
	if(kreturn==2832){
	wtib("",0);
	return 1;
	}
	
	if(kreturn==4096){
	mcto=0;
	while(mcto<NOFWIN)
	{
	if(cn[mcto].cn>-1){
	if(form_alert(2,"[1][Still connected!|Are you sure?][No!][Yes!]")==1)return 1;
	mcto=NOFWIN;
	}
	mcto++;
	}
	mcto=0;
	while(mcto<10)
	{
	if(dcc[mcto].stat){
	if(form_alert(2,"[1][DCC transfer open!|Are you sure?][No!][Yes!]")==1)return 1;
	mcto=10;
	}
	mcto++;
	}
	qt();
	}
	if(kreturn==19252){
	cycchan(BACKWARDS);
	return 1;
	}
	if(kreturn==19766){
	cycchan(FORWARDS);
	return 1;
	}
	if(kreturn==29440){
	cycwin(BACKWARDS);
	return 1;
	}
	if(kreturn==29696){
	cycwin(FORWARDS);
	return 1;
	}
	if(kreturn==4375){
	openwin(0,0,0,0,2);
	return 1;
	}
	if(kreturn==5653){
	dodccsend();
	return 1;
	}
	if(kreturn==4113){
	disnnect(wn[cwin].cnn);
	return 1;
	}
	if(kreturn==12813 && cwin>-1){
	closewin(cwin);
	return 1;
	}
	if(kreturn==6159){
	sortconnection();
	return 1;
	}
	return 0;
	}
static void sca_init_port(port_t *port)
{
    card_t *card = port_to_card(port);
    int transmit, i;

    port->rxin = 0;
    port->txin = 0;
    port->txlast = 0;

#ifndef PAGE0_ALWAYS_MAPPED
    openwin(card, 0);
#endif

    for (transmit = 0; transmit < 2; transmit++) {
        u16 dmac = transmit ? get_dmac_tx(port) : get_dmac_rx(port);
        u16 buffs = transmit ? card->tx_ring_buffers
                    : card->rx_ring_buffers;

        for (i = 0; i < buffs; i++) {
            pkt_desc __iomem *desc = desc_address(port, i, transmit);
            u16 chain_off = desc_offset(port, i + 1, transmit);
            u32 buff_off = buffer_offset(port, i, transmit);

            writew(chain_off, &desc->cp);
            writel(buff_off, &desc->bp);
            writew(0, &desc->len);
            writeb(0, &desc->stat);
        }


        sca_out(0, transmit ? DSR_TX(phy_node(port)) :
                DSR_RX(phy_node(port)), card);

        sca_out(DCR_ABORT, transmit ? DCR_TX(phy_node(port)) :
                DCR_RX(phy_node(port)), card);


        sca_out(0, dmac + CPB, card);
        sca_outw(desc_offset(port, 0, transmit), dmac + CDAL, card);
        if (!transmit)
            sca_outw(desc_offset(port, buffs - 1, transmit),
                     dmac + EDAL, card);
        else
            sca_outw(desc_offset(port, 0, transmit), dmac + EDAL,
                     card);


        sca_out(DCR_CLEAR_EOF, transmit ? DCR_TX(phy_node(port)) :
                DCR_RX(phy_node(port)), card);

        if (!transmit) {

            sca_outw(HDLC_MAX_MRU, dmac + BFLL, card);

            sca_out(0x14, DMR_RX(phy_node(port)), card);
            sca_out(DIR_EOME | DIR_BOFE, DIR_RX(phy_node(port)),
                    card);

            sca_out(DSR_DE, DSR_RX(phy_node(port)), card);
        } else {

            sca_out(0x14, DMR_TX(phy_node(port)), card);

            sca_out(DIR_BOFE, DIR_TX(phy_node(port)), card);
        }
    }
    sca_set_carrier(port);
}
示例#13
0
c_window()
{
    int col, row, xcol, xrow;
    int id;

    if ((id = findid()) < 0)
        return;
    if (!terse)
        wwputs("New window (upper left corner): ", cmdwin);
    col = 0;
    row = 1;
    wwadd(boxwin, framewin->ww_back);
    for (;;) {
        wwbox(boxwin, row - 1, col - 1, 3, 3);
        wwsetcursor(row, col);
        while (wwpeekc() < 0)
            wwiomux();
        switch (getpos(&row, &col, row > 1, 0,
                       wwnrow - 1, wwncol - 1)) {
        case 3:
            wwunbox(boxwin);
            wwdelete(boxwin);
            return;
        case 2:
            wwunbox(boxwin);
            break;
        case 1:
            wwunbox(boxwin);
        case 0:
            continue;
        }
        break;
    }
    if (!terse)
        wwputs("\nNew window (lower right corner): ", cmdwin);
    xcol = col;
    xrow = row;
    for (;;) {
        wwbox(boxwin, row - 1, col - 1,
              xrow - row + 3, xcol - col + 3);
        wwsetcursor(xrow, xcol);
        wwflush();
        while (wwpeekc() < 0)
            wwiomux();
        switch (getpos(&xrow, &xcol, row, col, wwnrow - 1, wwncol - 1))
        {
        case 3:
            wwunbox(boxwin);
            wwdelete(boxwin);
            return;
        case 2:
            wwunbox(boxwin);
            break;
        case 1:
            wwunbox(boxwin);
        case 0:
            continue;
        }
        break;
    }
    wwdelete(boxwin);
    if (!terse)
        wwputc('\n', cmdwin);
    wwcurtowin(cmdwin);
    (void) openwin(id, row, col, xrow-row+1, xcol-col+1, nbufline,
                   (char *) 0, 1, 1, shellfile, shell);
}