On Wed, Dec 29, 2010 at 5:28 AM, Stefan Hajnoczi <stefa...@gmail.com> wrote: > On Tue, Dec 28, 2010 at 9:45 PM, Peter Lieven <p...@dlh.net> wrote: >> What happens if I set the A20 Gate via the keyboard controller and then read >> its status via ioport 0x92? This doesn't work, or does it? >> What was wrong reading the A20 via >> >> int ioport_get_a20(void) >> { >> return ((first_cpu->a20_mask >> 20) & 1); >> } >> >> every time ioport 0x92 or the keyobard outport is read? > > I wonder the same thing.
The manuals are very vague on this. The keyboard A20 signal is different from port 92 signal and the combined signal seen by the CPU is another one. What can be read back from either keyboard port or port 92 is probably highly implementation dependent. For example, if these are combined with an external logic (AND, NAND etc) gate, both ports could see different levels. With wired-OR logic it's possible to get the same signal as seen by CPU to both ports.But also the ports may not be fully bidirectional (so that instead of output signal, true signal level would be sampled) but the data from output buffer may be simply returned on reads. Only if the logic was implemented with something transparent like wired-OR and the output ports were bidirectional, then the read back values would match what the CPU sees. I doubt this, so I'd keep this version unless somebody can show that a real machine works this way. The problem with the original function was that CPUState was used inside a device, which is not OK. > Also, stashing the uint8_t output value away is not migration-friendly > at the moment? Will fix, also reset handling is missing.