Page 1 of 1
v8086 mostely successful now i need to debug without a scree
Posted: Thu Jun 16, 2005 1:07 pm
by proxy
ok so i got v8086 mode to work almost perfectly (switches modes corerctly in bochs, vmware still has a hang in there somewhere).
Anyway, in vmware ,my kernel crashes just after it starts to switch modes...so no video output to work with (meaning no visible exception handler or anything like that

)
So i think i wanna make my console driver mirror it's output to the serial port (which vmware can redirect to a file for me to tail

)
anyone have any code to do this? any clue of how this works? is it as simple as writing to a specific port?
proxy
Re:v8086 mostely successful now i need to debug without a sc
Posted: Sat Jun 18, 2005 8:16 am
by Pype.Clicker
you should find plenty of documentation about serial ports on OSRC (see QuickLinkz / FAQ)
I fear it will not be as easy as writing to an I/O port, but it shouldn't be as complicated as writing to a Floppy disk

Re:v8086 mostely successful now i need to debug without a sc
Posted: Sat Jun 18, 2005 1:00 pm
by proxy
i actually got it working (there was some broken code somewher in the wiki that i fixed and got to work). Here's my version of it:
Code: Select all
#define PORT 0x3f8 /* COM1 */
void init_serial() {
out<uint8_t>(PORT + 1, 0x00);
out<uint8_t>(PORT + 3, 0x80);
out<uint8_t>(PORT + 0, 0x03);
out<uint8_t>(PORT + 1, 0x00);
out<uint8_t>(PORT + 3, 0x03);
out<uint8_t>(PORT + 2, 0xC7);
out<uint8_t>(PORT + 4, 0x0B);
}
int serial_recieved() {
return in<uint8_t>(PORT + 5) & 1;
}
int is_transmit_empty() {
return in<uint8_t>(PORT + 5) & 0x20;
}
char read_serial() {
while (serial_recieved() == 0) {
continue;
}
return in<uint8_t>(PORT);
}
void write_serial(char a) {
while (is_transmit_empty() == 0) {
continue;
}
out<uint8_t>(PORT,a);
}
So now in my console object i have it mirror all characters written to video ram to the serial port. The i setup vmware to write the serial output to a file. SO when debugging video code i can do "tail -f serial.txt" in another term and see what's going on even when my video is broken
proxy
Re:v8086 mostely successful now i need to debug without a sc
Posted: Sat Jun 18, 2005 3:02 pm
by mystran
I have a similar setup for serial... Bochs writes to file, and running on real machine, I can catch it with another box using a null-modem cable.
Re:v8086 mostely successful now i need to debug without a sc
Posted: Mon Jun 20, 2005 1:52 am
by Pype.Clicker
mystran wrote:
I have a similar setup for serial... Bochs writes to file, and running on real machine, I can catch it with another box using a null-modem cable.
How easy is that to do ? i mean, do i just have to "tail -f /dev/com01" under linux ? is there something like baudrate to be set up ?
(just for the sake of filling
the Faq with infos).
btw, proxy, can i safely assume your code is free for pasting in the FAQ ?
Re:v8086 mostely successful now i need to debug without a sc
Posted: Mon Jun 20, 2005 1:55 am
by zyp
Use minicom or cutecom.
Re:v8086 mostely successful now i need to debug without a sc
Posted: Mon Jun 20, 2005 1:58 am
by distantvoices
As for this function:
Aren't the com ports able to trigger interrupts upon receipt of data?
I'd give it an interrupt handler then for fetching input from the com port.

Just a proposal. I'd use the mentioned function for polling the com port for data as long as no irq handler is installed.
Re:v8086 mostely successful now i need to debug without a sc
Posted: Mon Jun 20, 2005 5:52 am
by mystran
Pype: Yeah, I usually use simply "cat /dev/ttyS0 > debug.log". See setserial(8) for setting the parameters, or use a programs like Minicom to do the dirty work for you.
Re:v8086 mostely successful now i need to debug without a sc
Posted: Mon Jun 20, 2005 10:29 am
by proxy
of course you can paste it into the FAQ. This was one of those things I wish was there so i didn't have to spend an hour locating information on how to do it
proxy