Issue
I'm currently diagnosing an issue where my guest is attempting to poll the LSR for the THRE to clear so that it can output to a UART device. However, the LSR is never updated and therefore it polls indefinitely. I'm using serial_mm_init() on my lightly-customized mipssim board.
I'm trying to trace through the source to find where the LSR is supposed to be updated, but all I see pertaining to that register is uint8_t lsr in the SerialState struct; I can't find anything that maps that variable to guest memory.
Could someone explain how SerialState's values are mapped to guest memory?
Solution
Well after a lot of hard work I got the UART working. The answer to the question lies within the serial_ioport_read() and serial_ioport_write() functions. These two methods are assigned as the callbacks QEMU invokes when data is read or written to the MemoryRegion for the serial device (which is initialized in serial_init() or serial_mm_init()). These functions do a bit of masking on the address (passed into the functions as addr) to determine which register is being referenced, then return the value from the SerialState struct corresponding to that register. It's surprisingly simple, but I guess everything seems simple once you've figured it out. The big turning point was the realization that QEMU effectively implements the serial device as a MemoryRegion with special functionality that is triggered on a memory operation.
Anyway, hope this helps someone in the future avoid the nightmare I went through. Cheers!
Answered By - SwarthyMantooth
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.