PIT/Serial irq refactoring
Serial IRQ still wip
This commit is contained in:
parent
e4200782ac
commit
00d7004815
@ -9,3 +9,4 @@ void print_handler(struct interrupt_frame *frame, ulong error_code);
|
||||
//IRQ
|
||||
void keyboard_handler(struct interrupt_frame *frame);
|
||||
void timer_handler(struct interrupt_frame *frame);
|
||||
void serial_handler(struct interrupt_frame *frame);
|
||||
|
@ -25,5 +25,5 @@ __attribute__((interrupt)) void timer_handler(struct interrupt_frame *frame)
|
||||
__attribute__((interrupt)) void serial_handler(struct interrupt_frame *frame)
|
||||
{
|
||||
EOIIrq(IRQ_COM1);
|
||||
serial_do_irq((int)frame);
|
||||
serial_do_irq(frame);
|
||||
}
|
||||
|
@ -57,7 +57,6 @@ void kmain(unsigned long magic, unsigned long addr)
|
||||
|
||||
printf("Setting up IRQ handlers\n");
|
||||
irqSetRoutine(IRQ_KEYBOARD, keyboard_handler);
|
||||
irqSetRoutine(IRQ_TIMER, timer_handler);
|
||||
printf("Enabling HW interrupts\n");
|
||||
exceptionSetRoutine(EXCEPTION_DOUBLE_FAULT, print_handler);
|
||||
// Enabling the HW interrupts
|
||||
|
@ -1,5 +1,6 @@
|
||||
#include "pit.h"
|
||||
#include "io.h"
|
||||
#include "irq.h"
|
||||
|
||||
int initPit(unsigned int freq)
|
||||
{
|
||||
@ -10,5 +11,6 @@ int initPit(unsigned int freq)
|
||||
outb(PIT_CHAN_0, divisor & 0xFF);
|
||||
outb(PIT_CHAN_0, divisor >> 8u);
|
||||
|
||||
irqSetRoutine(IRQ_TIMER, timer_handler);
|
||||
return 0;
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
#include "serial.h"
|
||||
#include "io.h"
|
||||
#include "irq.h"
|
||||
#include "vga.h"
|
||||
|
||||
#define PORT 0x3f8 /* COM1 */
|
||||
#define SERIAL_MAX_SPEED 115200
|
||||
@ -31,11 +32,12 @@ void initSerial(int speed)
|
||||
UART_NO_PARITY | UART_8BITS_WORD | UART_1_STOP_BIT); // 8 bits, no parity, one stop bit
|
||||
outb(PORT + 2, 0xC7); // Enable FIFO, clear them, with 14-byte threshold
|
||||
outb(PORT + 4, 0x0B); // IRQs enabled, RTS/DSR set
|
||||
irqSetRoutine(IRQ_COM1, serial_handler);
|
||||
}
|
||||
|
||||
int isTransmitEmpty()
|
||||
{
|
||||
return inb(PORT + 5) & 0x20;
|
||||
return (inb(PORT + 5) & 0x20);
|
||||
}
|
||||
|
||||
void writeSerial(char a)
|
||||
@ -46,10 +48,9 @@ void writeSerial(char a)
|
||||
outb(PORT, a);
|
||||
}
|
||||
|
||||
void serial_do_irq(int level){
|
||||
if(level == IRQ_COM1){
|
||||
char c = inb(PORT + 5) & 1;
|
||||
writeSerial(c);
|
||||
}
|
||||
return;
|
||||
void serial_do_irq(struct interrupt_frame *level)
|
||||
{
|
||||
(void)level;
|
||||
char c = inb(PORT);
|
||||
writeSerial(c);
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "irq.h"
|
||||
|
||||
void initSerial(int speed);
|
||||
void writeSerial(char a);
|
||||
void serial_do_irq(int level);
|
||||
void serial_do_irq(struct interrupt_frame *frame);
|
||||
|
Loading…
Reference in New Issue
Block a user