rewrite comments into one, unified style
This commit is contained in:
1 parent
6260de0085
commit
467a58c9c6
163 files changed
+3560
-2556
No files matched your search
@@ -1,10 +1,13 @@
|
||||
// ps2_i8042.c - 8042 controller and device command helpers.
|
||||
// i8042 controller driver. This file owns PS/2 controller commands, IRQ handling, and packet decoding.
|
||||
|
||||
#include "ps2.h"
|
||||
|
||||
// Implements the ps2 Pause operation.
|
||||
void Ps2Pause(void) {
|
||||
_mm_pause();
|
||||
}
|
||||
|
||||
// Implements the ps2 Wait Input operation.
|
||||
void Ps2WaitInput(void) {
|
||||
int timeout = 100000;
|
||||
while ((__inbyte(PS2_STAT) & PS2_STAT_IN_FULL) && --timeout) {
|
||||
@@ -12,6 +15,7 @@ void Ps2WaitInput(void) {
|
||||
}
|
||||
}
|
||||
|
||||
// Implements the ps2 Wait Output operation.
|
||||
bool Ps2WaitOutput(void) {
|
||||
int timeout = 5000000;
|
||||
while (!(__inbyte(PS2_STAT) & PS2_STAT_OUT_FULL) && --timeout) {
|
||||
@@ -20,6 +24,7 @@ bool Ps2WaitOutput(void) {
|
||||
return timeout != 0;
|
||||
}
|
||||
|
||||
// Implements the ps2 Flush Output operation.
|
||||
void Ps2FlushOutput(void) {
|
||||
int timeout = 100000;
|
||||
while ((__inbyte(PS2_STAT) & PS2_STAT_OUT_FULL) && --timeout) {
|
||||
@@ -27,36 +32,43 @@ void Ps2FlushOutput(void) {
|
||||
}
|
||||
}
|
||||
|
||||
// Implements the ps2 Read Data operation.
|
||||
uint8_t Ps2ReadData(void) {
|
||||
if (!Ps2WaitOutput()) return 0xFFu;
|
||||
return __inbyte(PS2_DATA);
|
||||
}
|
||||
|
||||
// Implements the ps2 Write Command operation.
|
||||
void Ps2WriteCommand(uint8_t command) {
|
||||
Ps2WaitInput();
|
||||
__outbyte(PS2_CMD, command);
|
||||
}
|
||||
|
||||
// Implements the ps2 Write Data operation.
|
||||
void Ps2WriteData(uint8_t data) {
|
||||
Ps2WaitInput();
|
||||
__outbyte(PS2_DATA, data);
|
||||
}
|
||||
|
||||
// Implements the ps2 Read Command Byte operation.
|
||||
uint8_t Ps2ReadCommandByte(void) {
|
||||
Ps2WriteCommand(0x20u);
|
||||
return Ps2ReadData();
|
||||
}
|
||||
|
||||
// Implements the ps2 Write Command Byte operation.
|
||||
void Ps2WriteCommandByte(uint8_t commandByte) {
|
||||
Ps2WriteCommand(0x60u);
|
||||
Ps2WriteData(commandByte);
|
||||
}
|
||||
|
||||
// Implements the ps2 Send Keyboard operation.
|
||||
bool Ps2SendKeyboard(uint8_t byte) {
|
||||
Ps2WriteData(byte);
|
||||
return Ps2ReadData() == 0xFAu;
|
||||
}
|
||||
|
||||
// Implements the ps2 Send Mouse operation.
|
||||
bool Ps2SendMouse(uint8_t byte) {
|
||||
Ps2WriteCommand(0xD4u);
|
||||
Ps2WriteData(byte);
|
||||
|
||||
Reference in new issue
Block a user