Page 5 of 5

Re: IRQ Firing Bug

Posted: Mon Aug 01, 2016 7:12 am
by SpyderTL
Both read and write flags are set when the buffer is full, so waiting on the read buffer should be "wait until buffer is full". But the write buffer should be "wait until it is not full".

Re: IRQ Firing Bug

Posted: Mon Aug 01, 2016 7:56 am
by Ch4ozz
Shouldnt it look rather like this?
I took the infos from the wiki:

Code: Select all

inline void ps2_wait(unsigned char type)
{
	unsigned int _time_out = 10;
	
	if(type)
	{
		while(_time_out--) //Wait for write
		{
			if((inb(0x64) & 2) == 0)
				break;
			
			Sleep(1);
		}
	}
	else
	{
		while(_time_out--) //Wait for read
		{
			if((inb(0x64) & 1) == 1)
				break;
			
			Sleep(1);
		}
	}
}

Re: IRQ Firing Bug

Posted: Mon Aug 01, 2016 9:09 am
by SpyderTL
Yes.

From the ["8042" PS/2 Controller] wiki page:

Status Register

The Status Register contains various flags that indicate the state of the PS/2 controller. The meanings for each bit are:

Bit Meaning

0 Output buffer status (0 = empty, 1 = full)
(must be set before attempting to read data from IO port 0x60)

1 Input buffer status (0 = empty, 1 = full)
(must be clear before attempting to write data to IO port 0x60 or IO port 0x64)