[Solved] IRQ Firing Bug

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.
User avatar
SpyderTL
Member
Member
Posts: 1074
Joined: Sun Sep 19, 2010 10:05 pm

Re: IRQ Firing Bug

Post 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".
Project: OZone
Source: GitHub
Current Task: LIB/OBJ file support
"The more they overthink the plumbing, the easier it is to stop up the drain." - Montgomery Scott
User avatar
Ch4ozz
Member
Member
Posts: 170
Joined: Mon Jul 18, 2016 2:46 pm
Libera.chat IRC: esi

Re: IRQ Firing Bug

Post 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);
		}
	}
}
User avatar
SpyderTL
Member
Member
Posts: 1074
Joined: Sun Sep 19, 2010 10:05 pm

Re: IRQ Firing Bug

Post 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)
Project: OZone
Source: GitHub
Current Task: LIB/OBJ file support
"The more they overthink the plumbing, the easier it is to stop up the drain." - Montgomery Scott
Post Reply