v8086 mostely successful now i need to debug without a scree

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
proxy

v8086 mostely successful now i need to debug without a scree

Post 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
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:v8086 mostely successful now i need to debug without a sc

Post 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 ;)
proxy

Re:v8086 mostely successful now i need to debug without a sc

Post 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
mystran

Re:v8086 mostely successful now i need to debug without a sc

Post 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.
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:v8086 mostely successful now i need to debug without a sc

Post 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 ?
zyp

Re:v8086 mostely successful now i need to debug without a sc

Post by zyp »

Use minicom or cutecom.
distantvoices
Member
Member
Posts: 1600
Joined: Wed Oct 18, 2006 11:59 am
Location: Vienna/Austria
Contact:

Re:v8086 mostely successful now i need to debug without a sc

Post by distantvoices »

As for this function:

Code: Select all

serial_recieved()
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.
... the osdever formerly known as beyond infinity ...
BlueillusionOS iso image
mystran

Re:v8086 mostely successful now i need to debug without a sc

Post 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.
proxy

Re:v8086 mostely successful now i need to debug without a sc

Post 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
Post Reply