Page 1 of 1

PS/2 I/O

Posted: Fri May 02, 2014 11:30 am
by Roman
I am currently implementing PS/2 support for my OS. What is wrong with this code? getCurrentScanCodeSet() always returns ACKs (0xFA). sendByteToPort() and receiveByteFromPort() doesn't cause the problem. PS2DataPort = 0x60.

Code: Select all

uint8_t getCurrentScanCodeSet()
{
        sendByteToPort(PS2DataPort, 0xF0);
        sendByteToPort(PS2DataPort, 0x00);

        uint8_t receivedByteFromPS2DataPort = receiveByteFromPort(PS2DataPort);

        printf("Received 0x%x from 0x60.\n", receivedByteFromPS2DataPort);
        if(receivedByteFromPS2DataPort == 0xFE)
        {
                printf("RESEND: aborting...\n");
                return 4;
        }

        receivedByteFromPS2DataPort = receiveByteFromPort(PS2DataPort);

        printf("Received 0x%x from 0x60.\n", receivedByteFromPS2DataPort);

        return receivedByteFromPS2DataPort;
}
PS2Test() returns true. (seems like it works correctly)

Code: Select all

bool PS2Test()
{
        sendByteToPort(PS2DataPort, 0xEE);

        uint8_t receivedByteFromPS2DataPort = receiveByteFromPort(PS2DataPort);

        if(receivedByteFromPS2DataPort == 0xEE) return true;
        else return false;
}
Where should I send PS/2 commands and receive answers?

Re: PS/2 I/O

Posted: Fri May 02, 2014 12:57 pm
by Nable
I think that you should read this article: http://wiki.osdev.org/%228042%22_PS/2_Controller , it's about the whole 8042 controller. After you know how to work with controller, then you can add code for specific devices that can be connected to it.

Shorter answer: bytes sent to 0x60 port don't go directly to PS/2 keyboard, they go to 8042 controller, he interprets them and if you give him right commands, then he'll send right bytes to keyboard/mouse.