2 #include "serial_port.h"
3 #include "interrupts.h"
7 delegate
<void, const char> serialport_handler
;
9 extern "C" void serialport_irq(void);
10 void arch::serialport_init(delegate
<void, const char> sp_hndl
) {
12 serialport_handler
= sp_hndl
;
14 /* Get access to the clock registers */
15 outb(0x3fb,inb(0x3fb)|(1<<7));
17 /* Set transmission speed (the highest possible) */
21 /* Restore default registers access */
22 outb(0x3fb,inb(0x3fb)& ~(1<<7));
24 /* Set 8bit data format */
27 /* Call interrupt at every received byte */
31 set_irq(0x24, serialport_irq
);
34 void arch::serialport_send(const char sign
) {
38 extern "C" void arch::serialport_received() {
40 serialport_handler(inb(0x3f8));
43 __asm__
__volatile__("serialport_irq:\n\tcall serialport_received\n\tiret");