Currently mouse starts first, then keyboard.
My code:
Code: Select all
void InitMouse()
{
MouseStruct.mouse_data[0] = 0;
MouseStruct.mouse_data[1] = 0;
MouseStruct.mouse_data[2] = 0;
MouseStruct.mouse_X = 0;
MouseStruct.mouse_Y = 0;
MouseStruct.mouse_data_itterator = 1;
WaitFor0x60_0x64Write();
MS_CP = 0xA8;
writePort(PORT_MODE_8, HEX_PORT_NUMBER_KBMS_CP, (void*)&MS_CP);
WaitFor0x60_0x64Write();
MS_CP = 0x20;
writePort(PORT_MODE_8, HEX_PORT_NUMBER_KBMS_CP, (void*)&MS_CP);
WaitFor0x60Read();
readPort(PORT_MODE_8, HEX_PORT_NUMBER_KBMS_DP, (void*)&MouseStruct.status);
MouseStruct.status |=2;
WaitFor0x60_0x64Write();
MS_CP = 0x60;
writePort(PORT_MODE_8, HEX_PORT_NUMBER_KBMS_CP, (void*)&MS_CP);
WaitFor0x60_0x64Write();
writePort(PORT_MODE_8, HEX_PORT_NUMBER_KBMS_DP, (void*)&MouseStruct.status);
WaitFor0x60_0x64Write();
MS_CP = 0xD4;
writePort(PORT_MODE_8, HEX_PORT_NUMBER_KBMS_CP, (void*)&MS_CP);
WaitFor0x60_0x64Write();
MS_DP = 0xF6;
writePort(PORT_MODE_8, HEX_PORT_NUMBER_KBMS_DP, (void*)&MS_DP);
WaitFor0x60_0x64Write();
MS_CP = 0xD4;
writePort(PORT_MODE_8, HEX_PORT_NUMBER_KBMS_CP, (void*)&MS_CP);
WaitFor0x60_0x64Write();
MS_DP = 0xF4;
writePort(PORT_MODE_8, HEX_PORT_NUMBER_KBMS_DP, (void*)&MS_DP);
WaitFor0x60Read();
printf("Mouse ready\n");
}
Code: Select all
void InitKeyboard()
{
readPort(PORT_MODE_8_SLOW, HEX_PORT_NUMBER_KBMS_CP, (void*)&KeyboardStruct.status);
WaitFor0x60_0x64Write();
KB_CP = 0xAE;
writePort(PORT_MODE_8_SLOW, HEX_PORT_NUMBER_KBMS_CP, (void*)&KB_CP);
WaitFor0x60_0x64Write();
KB_CP = 0x20;
writePort(PORT_MODE_8_SLOW, HEX_PORT_NUMBER_KBMS_CP, (void*)&KB_CP);
WaitFor0x60Read();
readPort(PORT_MODE_8_SLOW, HEX_PORT_NUMBER_KBMS_DP, (void*)&KeyboardStruct.status);
KeyboardStruct.status = (KeyboardStruct.status | 1) & ~0x10;
WaitFor0x60_0x64Write();
KB_CP = 0x60;
writePort(PORT_MODE_8_SLOW, HEX_PORT_NUMBER_KBMS_CP, (void*)&KB_CP);
WaitFor0x60_0x64Write();
writePort(PORT_MODE_8_SLOW, HEX_PORT_NUMBER_KBMS_DP, (void*)&KeyboardStruct.status);
WaitFor0x60_0x64Write();
KB_DP = 0xF4;
writePort(PORT_MODE_8_SLOW, HEX_PORT_NUMBER_KBMS_DP, (void*)&KB_DP);
printf("Keyboard ready.\n");
}