Beispiel #1
0
void InitSerial(void)
{
  /* Disable interrupts during initialization */
  disable() ;
  
  /* 9600 baud */
  outportb(SER_LCR, SER_LCR_DLAB) ;
  outportb(SER_DLO, 12) ;
  outportb(SER_DHI, 0) ;
  
  /* 8 data bits, even parity, 1 stop bit */
  outportb(SER_LCR, 0x1B) ;
  
  /* Enable only receiver data ready interrupts */
  outportb(SER_IER, 0x01) ;
  
  /* Request to send, data terminal ready, enable interrupts */
  outportb(SER_MCR, SER_MCR_RTS|SER_MCR_DTR|SER_MCR_OUT2) ;

  /* Store address of ISR in IDT */
  SetISR(IRQ2INT(SER_IRQ), SerialISR) ;
  
  /* Unmask the UART's IRQ line */
  outportb(0x21, inportb(0x21) & ~SER_MSK) ;
  
  /* Re-enable interrupts */
  enable() ;
}
Beispiel #2
0
PRIVATE void KeyboardInit(void)
{
  static void *q[20] ;
  
  kybd_queue = OSQCreate(q, ENTRIES(q)) ;
  SetISR(IRQ2INT(IRQ_KYBD), OSKeyboardISR) ;
  outportb(0x21, inportb(0x21) & ~0x02) ;
}
Beispiel #3
0
int irq_set_redirect(pid_t pid, irqid_t irq) {

	irq_holder[irq] = pid;
	int_set_handler(IRQ2INT(irq), irq_redirect);
	irq_allow(irq);

	return 0;
}
Beispiel #4
0
void keyboard_init()
{
  INODE tmp[2];
  new_pipe(1024, tmp);
  keyboard_pipe = tmp[1];
  /* vfs_mount("/dev/kbd", tmp[0]); */
  vfs_open(keyboard_pipe, O_WRONLY);

  // Make keyboard stdin (first entry in file descriptor table)
  process_t *p = current->proc;
  p->fd[0] = calloc(1, sizeof(file_desc_t));
  fd_get(p->fd[0]);
  p->fd[0]->ino = tmp[0];
  p->fd[0]->flags = O_RDONLY;
  vfs_open(tmp[0], O_RDONLY);

  new_pipe(1024, tmp);
  keyboard_raw = tmp[1];
  vfs_mount("/dev/kbdraw", tmp[0]);
  vfs_open(keyboard_raw, O_WRONLY);

  register_int_handler(IRQ2INT(IRQ_KBD), keyboard_handler);
}