示例#1
0
文件: elsa.c 项目: nhanh0/hah
static void
reset_elsa(struct IsdnCardState *cs)
{
	long flags;

	if (cs->hw.elsa.timer) {
		/* Wait 1 Timer */
		byteout(cs->hw.elsa.timer, 0);
		while (TimerRun(cs));
		cs->hw.elsa.ctrl_reg |= 0x50;
		cs->hw.elsa.ctrl_reg &= ~ELSA_ISDN_RESET;	/* Reset On */
		byteout(cs->hw.elsa.ctrl, cs->hw.elsa.ctrl_reg);
		/* Wait 1 Timer */
		byteout(cs->hw.elsa.timer, 0);
		while (TimerRun(cs));
		cs->hw.elsa.ctrl_reg |= ELSA_ISDN_RESET;	/* Reset Off */
		byteout(cs->hw.elsa.ctrl, cs->hw.elsa.ctrl_reg);
		/* Wait 1 Timer */
		byteout(cs->hw.elsa.timer, 0);
		while (TimerRun(cs));
		if (cs->hw.elsa.trig)
			byteout(cs->hw.elsa.trig, 0xff);
	}
	if ((cs->subtyp == ELSA_QS1000PCI) || (cs->subtyp == ELSA_QS3000PCI) || (cs->subtyp == ELSA_PCMCIA_IPAC)) {
		save_flags(flags);
		sti();
		writereg(cs->hw.elsa.ale, cs->hw.elsa.isac, IPAC_POTA2, 0x20);
		set_current_state(TASK_UNINTERRUPTIBLE);
		schedule_timeout((10*HZ)/1000); /* Timeout 10ms */
		writereg(cs->hw.elsa.ale, cs->hw.elsa.isac, IPAC_POTA2, 0x00);
		set_current_state(TASK_UNINTERRUPTIBLE);
		writereg(cs->hw.elsa.ale, cs->hw.elsa.isac, IPAC_MASK, 0xc0);
		schedule_timeout((10*HZ)/1000); /* Timeout 10ms */
		restore_flags(flags);
		if (cs->subtyp != ELSA_PCMCIA_IPAC) {
			writereg(cs->hw.elsa.ale, cs->hw.elsa.isac, IPAC_ACFG, 0x0);
			writereg(cs->hw.elsa.ale, cs->hw.elsa.isac, IPAC_AOE, 0x3c);
		} else {
			writereg(cs->hw.elsa.ale, cs->hw.elsa.isac, IPAC_PCFG, 0x10);
			writereg(cs->hw.elsa.ale, cs->hw.elsa.isac, IPAC_ACFG, 0x4);
			writereg(cs->hw.elsa.ale, cs->hw.elsa.isac, IPAC_AOE, 0xf8);
		}
		writereg(cs->hw.elsa.ale, cs->hw.elsa.isac, IPAC_ATX, 0xff);
		if (cs->subtyp == ELSA_QS1000PCI)
			byteout(cs->hw.elsa.cfg + 0x4c, 0x41); /* enable ELSA PCI IRQ */
		else if (cs->subtyp == ELSA_QS3000PCI)
			byteout(cs->hw.elsa.cfg + 0x4c, 0x43); /* enable ELSA PCI IRQ */
	}
}
示例#2
0
static void
reset_elsa(struct IsdnCardState *cs)
{
	if (cs->hw.elsa.timer) {
		/* Wait 1 Timer */
		byteout(cs->hw.elsa.timer, 0);
		while (TimerRun(cs));
		cs->hw.elsa.ctrl_reg |= 0x50;
		cs->hw.elsa.ctrl_reg &= ~ELSA_ISDN_RESET;	/* Reset On */
		byteout(cs->hw.elsa.ctrl, cs->hw.elsa.ctrl_reg);
		/* Wait 1 Timer */
		byteout(cs->hw.elsa.timer, 0);
		while (TimerRun(cs));
		cs->hw.elsa.ctrl_reg |= ELSA_ISDN_RESET;	/* Reset Off */
		byteout(cs->hw.elsa.ctrl, cs->hw.elsa.ctrl_reg);
		/* Wait 1 Timer */
		byteout(cs->hw.elsa.timer, 0);
		while (TimerRun(cs));
		if (cs->hw.elsa.trig)
			byteout(cs->hw.elsa.trig, 0xff);
	}
	if ((cs->subtyp == ELSA_QS1000PCI) || (cs->subtyp == ELSA_QS3000PCI) || (cs->subtyp == ELSA_PCMCIA_IPAC)) {
		writereg(cs->hw.elsa.ale, cs->hw.elsa.isac, IPAC_POTA2, 0x20);
		mdelay(10);
		writereg(cs->hw.elsa.ale, cs->hw.elsa.isac, IPAC_POTA2, 0x00);
		writereg(cs->hw.elsa.ale, cs->hw.elsa.isac, IPAC_MASK, 0xc0);
		mdelay(10);
		if (cs->subtyp != ELSA_PCMCIA_IPAC) {
			writereg(cs->hw.elsa.ale, cs->hw.elsa.isac, IPAC_ACFG, 0x0);
			writereg(cs->hw.elsa.ale, cs->hw.elsa.isac, IPAC_AOE, 0x3c);
		} else {
			writereg(cs->hw.elsa.ale, cs->hw.elsa.isac, IPAC_PCFG, 0x10);
			writereg(cs->hw.elsa.ale, cs->hw.elsa.isac, IPAC_ACFG, 0x4);
			writereg(cs->hw.elsa.ale, cs->hw.elsa.isac, IPAC_AOE, 0xf8);
		}
		writereg(cs->hw.elsa.ale, cs->hw.elsa.isac, IPAC_ATX, 0xff);
		if (cs->subtyp == ELSA_QS1000PCI)
			byteout(cs->hw.elsa.cfg + 0x4c, 0x41); /* enable ELSA PCI IRQ */
		else if (cs->subtyp == ELSA_QS3000PCI)
			byteout(cs->hw.elsa.cfg + 0x4c, 0x43); /* enable ELSA PCI IRQ */
	}
}
示例#3
0
void CST_setState(T_ST_State state,byte num_cntrl){
  if(state==ST_STATE_RUNNING){
    St_Step[num_cntrl]=0;
    St_Counter[num_cntrl]=0,
    TimerRun(100,NULL,CONTINUO_SET,On_StCountInc);
    Cntr_SetearOnOff(CNTR_ONOFF,num_cntrl); //seteo salida en ON-OFF
    set_MainText("St 0");
    ST_State[num_cntrl]=state;
  }else if(state==ST_STATE_OFF){
    set_MainText("");
    Cntr_SetearOnOff(get_TipoControl(num_cntrl),num_cntrl); //seteo salida en ON-OFF
  }
}
示例#4
0
文件: elsa.c 项目: sarnobat/knoppix
static int __init
elsa_timer_test(struct IsdnCardState *cs)
{
	/* test timer */
	byteout(cs->hw.elsa.trig, 0xff);
	byteout(cs->hw.elsa.timer, 0);
	if (!TimerRun(cs)) {
		byteout(cs->hw.elsa.timer, 0);	/* second attempt */
		if (!TimerRun(cs)) {
			printk(KERN_WARNING "Elsa: timer does not start\n");
			goto err;
		}
	}
	HZDELAY(10 * HZ / 1000); /* wait >=10 ms */
	if (TimerRun(cs)) {
		printk(KERN_WARNING "Elsa: timer does not run\n");
		goto err;
	}
	printk(KERN_INFO "Elsa: timer OK; resetting card\n");
	return 0;
 err:
	return -EBUSY;
}
示例#5
0
文件: elsa.c 项目: sarnobat/knoppix
static irqreturn_t
elsa_interrupt(int intno, void *dev_id, struct pt_regs *regs)
{
	struct IsdnCardState *cs = dev_id;
	u8 val;

	if ((cs->typ == ISDN_CTYPE_ELSA_PCMCIA) && (*cs->busy_flag == 1)) {
	/* The card tends to generate interrupts while being removed
	   causing us to just crash the kernel. bad. */
		printk(KERN_WARNING "Elsa: card not available!\n");
		return IRQ_NONE;
	}
#if ARCOFI_USE
	if (cs->hw.elsa.MFlag) {
		val = serial_inp(cs, UART_IIR);
		if (!(val & UART_IIR_NO_INT)) {
			debugl1(cs,"IIR %02x", val);
			spin_lock(&cs->lock);
			rs_interrupt_elsa(intno, cs);
			spin_unlock(&cs->lock);
		}
	}
#endif
	hscxisac_irq(intno, dev_id, regs);

	if (cs->hw.elsa.status & ELSA_TIMER_AKTIV) {
		if (!TimerRun(cs)) {
			/* Timer Restart */
			byteout(cs->hw.elsa.timer, 0);
			cs->hw.elsa.counter++;
		}
	}
#if ARCOFI_USE
	if (cs->hw.elsa.MFlag) {
		val = serial_inp(cs, UART_MCR);
		val ^= 0x8;
		serial_outp(cs, UART_MCR, val);
		val = serial_inp(cs, UART_MCR);
		val ^= 0x8;
		serial_outp(cs, UART_MCR, val);
	}
#endif
	if (cs->hw.elsa.trig)
		byteout(cs->hw.elsa.trig, 0x00);
	return IRQ_HANDLED;
}
示例#6
0
static irqreturn_t
elsa_interrupt(int intno, void *dev_id, struct pt_regs *regs)
{
	struct IsdnCardState *cs = dev_id;
	u_long flags;
	u_char val;
	int icnt=5;

	if ((cs->typ == ISDN_CTYPE_ELSA_PCMCIA) && (*cs->busy_flag == 1)) {
	/* The card tends to generate interrupts while being removed
	   causing us to just crash the kernel. bad. */
		printk(KERN_WARNING "Elsa: card not available!\n");
		return IRQ_NONE;
	}
	spin_lock_irqsave(&cs->lock, flags);
#if ARCOFI_USE
	if (cs->hw.elsa.MFlag) {
		val = serial_inp(cs, UART_IIR);
		if (!(val & UART_IIR_NO_INT)) {
			debugl1(cs,"IIR %02x", val);
			rs_interrupt_elsa(intno, cs);
		}
	}
#endif
	val = readreg(cs->hw.elsa.ale, cs->hw.elsa.hscx, HSCX_ISTA + 0x40);
      Start_HSCX:
	if (val) {
		hscx_int_main(cs, val);
	}
	val = readreg(cs->hw.elsa.ale, cs->hw.elsa.isac, ISAC_ISTA);
      Start_ISAC:
	if (val) {
		isac_interrupt(cs, val);
	}
	val = readreg(cs->hw.elsa.ale, cs->hw.elsa.hscx, HSCX_ISTA + 0x40);
	if (val && icnt) {
		if (cs->debug & L1_DEB_HSCX)
			debugl1(cs, "HSCX IntStat after IntRoutine");
		icnt--;
		goto Start_HSCX;
	}
	val = readreg(cs->hw.elsa.ale, cs->hw.elsa.isac, ISAC_ISTA);
	if (val && icnt) {
		if (cs->debug & L1_DEB_ISAC)
			debugl1(cs, "ISAC IntStat after IntRoutine");
		icnt--;
		goto Start_ISAC;
	}
	if (!icnt)
		printk(KERN_WARNING"ELSA IRQ LOOP\n");
	writereg(cs->hw.elsa.ale, cs->hw.elsa.hscx, HSCX_MASK, 0xFF);
	writereg(cs->hw.elsa.ale, cs->hw.elsa.hscx, HSCX_MASK + 0x40, 0xFF);
	writereg(cs->hw.elsa.ale, cs->hw.elsa.isac, ISAC_MASK, 0xFF);
	if (cs->hw.elsa.status & ELSA_TIMER_AKTIV) {
		if (!TimerRun(cs)) {
			/* Timer Restart */
			byteout(cs->hw.elsa.timer, 0);
			cs->hw.elsa.counter++;
		}
	}
#if ARCOFI_USE
	if (cs->hw.elsa.MFlag) {
		val = serial_inp(cs, UART_MCR);
		val ^= 0x8;
		serial_outp(cs, UART_MCR, val);
		val = serial_inp(cs, UART_MCR);
		val ^= 0x8;
		serial_outp(cs, UART_MCR, val);
	}
#endif
	if (cs->hw.elsa.trig)
		byteout(cs->hw.elsa.trig, 0x00);
	writereg(cs->hw.elsa.ale, cs->hw.elsa.hscx, HSCX_MASK, 0x0);
	writereg(cs->hw.elsa.ale, cs->hw.elsa.hscx, HSCX_MASK + 0x40, 0x0);
	writereg(cs->hw.elsa.ale, cs->hw.elsa.isac, ISAC_MASK, 0x0);
	spin_unlock_irqrestore(&cs->lock, flags);
	return IRQ_HANDLED;
}
示例#7
0
文件: main.cpp 项目: Nebual/terracer
int main(int argc, char *argv[]) {
    static SDL_Window *window;
    if(initWindow(&window, &renderer, argc, argv)) return 1;
    initVariables(WIDTH, HEIGHT);
    initTextures();
    initFonts();
    initInput();
    //initHUD();

    generateLevel(FIRSTLEVEL);

    hud = new Hud();

    /*==============*/
    /*  Test Stuff  */
    /*==============*/

    /*PhysicsEntity *goomba = new PhysicsEntity(getTexture("goomba"), 500, 50);
    goomba->patrolling = 1;

    Interactable *healthUp = new Interactable(getTexture("concrete"), 800, 500);
    healthUp->target = ply;
    healthUp->action = HEALTH_UP;

    Interactable *scrapUp = new Interactable(getTexture("sand"), 850, 500);
    scrapUp->target = ply;
    scrapUp->action = SCRAP_UP;*/

    /*=================*/
    /*End of Test Stuff*/
    /*=================*/

    int lastFrame = curtime_u() - 1;
    double dt;
    while(!quit) {
        if(DEBUG) fpsCounter();

        // Calculate dt
        int curFrame = curtime_u();
        if(lastFrame > curFrame) {
            dt = ((1000000 - lastFrame) + curFrame) / 1000000.0;
        }
        else {
            dt = (curFrame - lastFrame) / 1000000.0;
        }
        if(dt > 0.05) {
            dt = 0.05;   // Clamp dt so objects don't have collision issues
        }
        lastFrame = curFrame;

        // ===================
        // Update
        if(nextlevel != "") {
            printf("Switching to level %s\n", nextlevel.c_str());
            generateLevel(nextlevel);
            nextlevel = "";
        }
        TimerRun();
        for(int enti=0; enti<entsC; enti++) {
            if(ents[enti] == NULL) continue;
            ents[enti]->Update(dt);
            if(ents[enti]->isKilled) delete ents[enti];
        }

        // ====================
        // Drawing
        for(int rli=0; rli<RL_MAX; rli++) {
            if(rli == RL_BACKGROUND) {
                drawBackground(renderer, dt);
                continue; // Done in drawBackground
            }
            Drawable** layer = renderLayers[rli];
            for(int enti=0; enti<renderLayersC[rli]; enti++) {
                if(layer[enti] == NULL) continue;
                layer[enti]->Draw(dt);
            }
        }

        // Flip render buffer
        SDL_RenderPresent(renderer);

        // Frame limiting, not needed if we're using vsync
        //SDL_Delay((1000 / 66) - (curtime_u() - lastFrame)/1000);
    }
    printf("\nShutting down...\n");

    cleanLevel();
    // Destroy old textures
    for(std::map<std::string, TextureData>::iterator it = blockTDs.begin(); it != blockTDs.end(); ++it) {
        SDL_DestroyTexture(it->second.texture);
    }
    blockTDs.clear();

    SDL_DestroyRenderer(renderer);
    SDL_DestroyWindow(window);

    Mix_CloseAudio();
    Mix_Quit();

    IMG_Quit();
    SDL_Quit();
    return 0;
}