root/kernel/chr_drv/serial.c

/* [previous][next][first][last][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. init
  2. rs_init
  3. rs_write

   1 /*
   2  *  linux/kernel/serial.c
   3  *
   4  *  (C) 1991  Linus Torvalds
   5  */
   6 
   7 /*
   8  *      serial.c
   9  *
  10  * This module implements the rs232 io functions
  11  *      void rs_write(struct tty_struct * queue);
  12  *      void rs_init(void);
  13  * and all interrupts pertaining to serial IO.
  14  */
  15 
  16 #include <linux/tty.h>
  17 #include <linux/sched.h>
  18 #include <asm/system.h>
  19 #include <asm/io.h>
  20 
  21 #define WAKEUP_CHARS (TTY_BUF_SIZE/4)
  22 
  23 extern void rs1_interrupt(void);
  24 extern void rs2_interrupt(void);
  25 
  26 static void init(int port)
     /* [previous][next][first][last][top][bottom][index][help] */
  27 {
  28         outb_p(0x80,port+3);    /* set DLAB of line control reg */
  29         outb_p(0x30,port);      /* LS of divisor (48 -> 2400 bps */
  30         outb_p(0x00,port+1);    /* MS of divisor */
  31         outb_p(0x03,port+3);    /* reset DLAB */
  32         outb_p(0x0b,port+4);    /* set DTR,RTS, OUT_2 */
  33         outb_p(0x0d,port+1);    /* enable all intrs but writes */
  34         (void)inb(port);        /* read data port to reset things (?) */
  35 }
  36 
  37 void rs_init(void)
     /* [previous][next][first][last][top][bottom][index][help] */
  38 {
  39         set_intr_gate(0x24,rs1_interrupt);
  40         set_intr_gate(0x23,rs2_interrupt);
  41         init(tty_table[1].read_q.data);
  42         init(tty_table[2].read_q.data);
  43         outb(inb_p(0x21)&0xE7,0x21);
  44 }
  45 
  46 /*
  47  * This routine gets called when tty_write has put something into
  48  * the write_queue. It must check wheter the queue is empty, and
  49  * set the interrupt register accordingly
  50  *
  51  *      void _rs_write(struct tty_struct * tty);
  52  */
  53 void rs_write(struct tty_struct * tty)
     /* [previous][next][first][last][top][bottom][index][help] */
  54 {
  55         cli();
  56         if (!EMPTY(tty->write_q))
  57                 outb(inb_p(tty->write_q.data+1)|0x02,tty->write_q.data+1);
  58         sti();
  59 }

/* [previous][next][first][last][top][bottom][index][help] */