Reading serial port from bochs

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
Kunalnitin
Posts: 7
Joined: Thu Jul 28, 2011 6:10 am

Reading serial port from bochs

Post by Kunalnitin »

I have light OS kernel that runs on bochs. I want to setup communication b/w the guest OS and the host OS using serial port. For this I thought to use an unused virtual console of the host system (found tty9). So I added following line to the bochsrc.txt file ...

com1: enabled=1, mode=term, dev=/dev/tty9

Then I implemented simple getchar() and putchar() functions to read and write to serial port respectively. The putchar() code is working fine as I can see the characters on the console 9 of my host system. But the getchar() function is not working as expected. The 'available' bit of status register is never set and hence it can not read character from the screen.

I am wondering what may be the potential problem....
1. Is there a problem in my serial port configuration?
2. Am I checking wrong 'available' bit?


Serial port setup code (taken from OSdev serial port wiki page)
-----------------------------------------------------------------------------------------------
Portout8 ( PORT1 + 1, 0x00 ); /* Disable all interrupts */
Portout8 ( PORT1 + 3, 0x80 ); /* Enable DLAB (set baud rate divisor) */
Portout8 ( PORT1 + 0, 0x0c ); /* Set Baud rate -9600 BPS Divisor Latch Low Byte */
Portout8 ( PORT1 + 1, 0x00 ); /* hi byte */
Portout8 ( PORT1 + 3, 0x03 ) ; /* 8 Bits, No Parity, 1 Stop Bit */
Portout8 ( PORT1 + 2, 0xC7 ); /* Enable FIFO, clear them, with 14-byte threshold */
Portout8 ( PORT1 + 4, 0x0B ); /* IRQs enabled, RTS/DSR set*/
Post Reply