Пример #1
0
static void
vox_close (struct sound_device *sd)
{
  if (sd->fd >= 0)
    {
      /* On GNU/Linux, it seems that the device driver doesn't like to
	 be interrupted by a signal.  Block the ones we know to cause
	 troubles.  */
#ifdef SIGIO
      sigblock (sigmask (SIGIO));
#endif
      turn_on_atimers (0);

      /* Flush sound data, and reset the device.  */
      ioctl (sd->fd, SNDCTL_DSP_SYNC, NULL);

      turn_on_atimers (1);
#ifdef SIGIO
      sigunblock (sigmask (SIGIO));
#endif

      /* Close the device.  */
      emacs_close (sd->fd);
      sd->fd = -1;
    }
}
Пример #2
0
static void
sound_perror (const char *msg)
{
  int saved_errno = errno;

  turn_on_atimers (1);
#ifdef SIGIO
  sigunblock (sigmask (SIGIO));
#endif
  if (saved_errno != 0)
    error ("%s: %s", msg, strerror (saved_errno));
  else
    error ("%s", msg);
}
Пример #3
0
void
systime_tick(void){

    /* keep track of real time */
    systime += PROC_TIME;

#ifdef USE_PROC
    struct Proc *p;

    wakeup( &systime );

    for(p=(struct Proc*)proclist; p; p=p->next){
        /* check timeouts */
        if( p->state & PRS_BLOCKED ){
            if( p->timeout && p->timeout <= systime ){
                p->timeout = 0;
                sigunblock(p);
                if( p->wchan != WCHAN_NEVER )
                    ksendmsg(p, MSG_TIMEOUT);
            }
        }

        /* handle alarm clocks */
        if( p->alarm && p->alarm <= get_time() ){
            p->alarm = 0;
            if( p->state & PRS_BLOCKED )
                sigunblock(p);
            ksendmsg(p, MSG_ALARM);
        }
    }

    if( currproc && (--timeremain <= 0) ){
        sched_yield();
    }
#endif

}
Пример #4
0
static void
vox_configure (struct sound_device *sd)
{
  int val;

  xassert (sd->fd >= 0);

  /* On GNU/Linux, it seems that the device driver doesn't like to be
     interrupted by a signal.  Block the ones we know to cause
     troubles.  */
  turn_on_atimers (0);
#ifdef SIGIO
  sigblock (sigmask (SIGIO));
#endif

  val = sd->format;
  if (ioctl (sd->fd, SNDCTL_DSP_SETFMT, &sd->format) < 0
      || val != sd->format)
    sound_perror ("Could not set sound format");

  val = sd->channels != 1;
  if (ioctl (sd->fd, SNDCTL_DSP_STEREO, &val) < 0
      || val != (sd->channels != 1))
    sound_perror ("Could not set stereo/mono");

  /* I think bps and sampling_rate are the same, but who knows.
     Check this. and use SND_DSP_SPEED for both.  */
  if (sd->sample_rate > 0)
    {
      val = sd->sample_rate;
      if (ioctl (sd->fd, SNDCTL_DSP_SPEED, &sd->sample_rate) < 0)
	sound_perror ("Could not set sound speed");
      else if (val != sd->sample_rate)
	sound_warning ("Could not set sample rate");
    }

  if (sd->volume > 0)
    {
      int volume = sd->volume & 0xff;
      volume |= volume << 8;
      /* This may fail if there is no mixer.  Ignore the failure.  */
      ioctl (sd->fd, SOUND_MIXER_WRITE_PCM, &volume);
    }

  turn_on_atimers (1);
#ifdef SIGIO
  sigunblock (sigmask (SIGIO));
#endif
}
Пример #5
0
static void
serial_irq(int unit){
    USART_TypeDef *addr = com[unit].addr;

    int sr = addr->ISR;

    //kprintf("s %d %x\n", unit, sr);

    if( sr & SR_TXE ){
        /* transmitter empty */
        //blink(1);
        addr->CR1 &= ~ 0xC0;	// disable TXE irq
        wakeup( addr );
    }

    if( sr & SR_RXNE ){
        /* got a char */
        int ch = addr->RDR;
        int i;

        /* special control char ? */
        for(i=0; i<sizeof(com[unit].file.cchars); i++){
            if(com[unit].file.cchars[i] && ch == com[unit].file.cchars[i]){
                sigunblock( com[unit].file.ccpid );
                ksendmsg( com[unit].file.ccpid, MSG_CCHAR_0 + i );
                return;
            }
        }

        if( com[unit].len < SERIAL_QUEUE_SIZE ){
            /* queue it up */
            com[unit].queue[ com[unit].head++ ] = ch;
            com[unit].head %= SERIAL_QUEUE_SIZE;
            com[unit].len ++;
            /* flow control */
#if 0
            if( com[unit].len > SERIAL_QUEUE_HIWATER ){
                /* almost full - drop RTS */
                /* com[unit].status |= COMSTAT_THROTTLED; */
            }
#endif
            wakeup( &com[unit].len );
        }
    }
}
Пример #6
0
Файл: pcterm.c Проект: jaw0/osj5
void
kbdirq(struct intrframe *fr){
    int c, i;
    const char *cs=0;
    struct Kbd *k = &term.kbd;	/* we only support one, for now */

    c = inb( k->port );

    /* make or break */
    if( c & 0x80 ){
        /* break */
        c &= 0x7f;

        switch( scan_codes[c].type ){
        case SCROLL:
            k->state &= ~SCROLL;
            break;
        case SHIFT:
            k->state &= ~SHIFT;
            break;
        case ALT:
            k->state &= ~ALT;
            break;
        case CTL:
            k->state &= ~CTL;
            break;
        }
    }else{
        /* make */
        switch( scan_codes[c].type ){

        case SHIFT:
            k->state |= SHIFT;
            break;
        case ALT:
            k->state |= ALT;
            break;
        case CTL:
            k->state |= CTL;
            break;
        case NUM:
            k->state ^= NUM;
            break;
        case CAPS:
            k->state ^= CAPS;
            break;
        case NONE:
            break;
        case ASCII:
        case FUNC:
            if( k->state & CTL )
                cs = scan_codes[c].ctl;
            else if( k->state & (SHIFT | CAPS) )
                cs = scan_codes[c].shift;
            else
                cs = scan_codes[c].unshift;
            break;

        case KP:
            if( c == 83 && k->state & CTL && k->state & ALT ){
                /* ctl-alt-del detected */
#ifdef USE_GDB
                if( bootflags & BOOT_USEGDB )
                    breakpoint();
                else
#endif
                {
                    E9PRINTF(("\n<C-A-Del>\nrebooting\n"));
                    kprintf("\nrebooting...");
                    reboot();
                }

            }
            if( k->state & CTL )
                cs = scan_codes[c].ctl;
            else if( k->state & (SHIFT | NUM) )
                cs = scan_codes[c].shift;
            else
                cs = scan_codes[c].unshift;
            break;


        }

        /* special control char ? */
        for(i=0; i<sizeof(term.file.cchars); i++){
            if(cs && term.file.cchars[i] && *cs == term.file.cchars[i]){
                sigunblock( term.file.ccpid );
                ksendmsg( term.file.ccpid, MSG_CCHAR_0 + i );
                return;
            }
        }

        /* enqueue chars */
        while( cs && *cs ){
            if( k->len < PCTERM_QUEUE_SIZE ){
                k->queue[ k->head++ ] = (k->state & ALT) ? (0x80 | *cs) : *cs;
                k->head %= PCTERM_QUEUE_SIZE;
                k->len ++;
            }
            /* else just drop it */

            cs++;
        }
        wakeup(k);
    }
}