PatchworkOS
Loading...
Searching...
No Matches
ps2.c File Reference
#include <kernel/drivers/hpet.h>
#include <kernel/drivers/ps2/ps2.h>
#include <kernel/drivers/ps2/ps2_kbd.h>
#include <kernel/drivers/ps2/ps2_mouse.h>
#include <kernel/acpi/tables.h>
#include <kernel/log/log.h>
#include <kernel/log/panic.h>
#include <kernel/sched/timer.h>
#include <errno.h>
#include <string.h>

Go to the source code of this file.

Macros

#define PS2_KNOWN_DEVICE_AMOUNT   (sizeof(knownDevices) / sizeof(knownDevices[0]))
 

Functions

static const char * ps2_device_test_response_to_string (ps2_device_test_response_t response)
 
static const char * ps2_self_test_response_to_string (ps2_self_test_response_t response)
 
static const char * ps2_device_to_string (ps2_device_t device)
 
static const char * ps2_device_type_to_string (ps2_device_type_t type)
 
static uint64_t ps2_set_initial_config (ps2_config_bits_t *cfg)
 
static uint64_t ps2_self_test (void)
 
static uint64_t ps2_check_if_dual_channel (void)
 
static uint64_t ps2_devices_test (void)
 
static uint64_t ps2_device_init (ps2_device_t device)
 
void ps2_init (void)
 Initialize the PS/2 controller.
 
void ps2_drain (void)
 Drain the PS/2 output buffer.
 
uint64_t ps2_wait_until_set (ps2_status_bits_t status)
 Wait until status bit(s) is set.
 
uint64_t ps2_wait_until_clear (ps2_status_bits_t status)
 Wait until status bit(s) is clear.
 
uint64_t ps2_send_cmd (ps2_cmd_t command)
 Send a command to the PS/2 controller.
 
uint64_t ps2_send_device_cmd (ps2_device_t device, ps2_device_cmd_t command)
 Send a command to a PS/2 device.
 

Variables

static bool isDualChannel = false
 
static ps2_device_info_t devices [PS2_DEV_COUNT] = {0}
 
static const ps2_device_info_t knownDevices []
 

Macro Definition Documentation

◆ PS2_KNOWN_DEVICE_AMOUNT

#define PS2_KNOWN_DEVICE_AMOUNT   (sizeof(knownDevices) / sizeof(knownDevices[0]))

Definition at line 28 of file ps2.c.

Function Documentation

◆ ps2_check_if_dual_channel()

static uint64_t ps2_check_if_dual_channel ( void  )
static

◆ ps2_device_init()

◆ ps2_device_test_response_to_string()

static const char * ps2_device_test_response_to_string ( ps2_device_test_response_t  response)
static

◆ ps2_device_to_string()

static const char * ps2_device_to_string ( ps2_device_t  device)
static

Definition at line 62 of file ps2.c.

References PS2_DEV_FIRST, and PS2_DEV_SECOND.

Referenced by ps2_device_init(), and ps2_send_device_cmd().

◆ ps2_device_type_to_string()

static const char * ps2_device_type_to_string ( ps2_device_type_t  type)
static

◆ ps2_devices_test()

◆ ps2_self_test()

static uint64_t ps2_self_test ( void  )
static

◆ ps2_self_test_response_to_string()

static const char * ps2_self_test_response_to_string ( ps2_self_test_response_t  response)
static

Definition at line 49 of file ps2.c.

References PS2_SELF_TEST_FAIL, and PS2_SELF_TEST_PASS.

Referenced by ps2_self_test().

◆ ps2_set_initial_config()

Variable Documentation

◆ devices

ps2_device_info_t devices[PS2_DEV_COUNT] = {0}
static

Definition at line 15 of file ps2.c.

Referenced by ps2_device_init(), ps2_devices_test(), and ps2_init().

◆ isDualChannel

bool isDualChannel = false
static

Definition at line 14 of file ps2.c.

Referenced by ps2_check_if_dual_channel(), and ps2_devices_test().

◆ knownDevices

const ps2_device_info_t knownDevices[]
static
Initial value:
= {
{.type = PS2_DEV_TYPE_MOUSE_STANDARD, .name = "Standard PS/2 mouse", .firstIdByte = 0x00},
{.type = PS2_DEV_TYPE_MOUSE_SCROLL, .name = "Mouse with scroll wheel", .firstIdByte = 0x03},
{.type = PS2_DEV_TYPE_MOUSE_5BUTTON, .name = "5-button mouse", .firstIdByte = 0x04},
{.type = PS2_DEV_TYPE_KEYBOARD, .name = "Standard PS/2 keyboard", .firstIdByte = 0xAB},
{.type = PS2_DEV_TYPE_KEYBOARD, .name = "NCD Sun keyboard", .firstIdByte = 0xAC},
{.type = PS2_DEV_TYPE_KEYBOARD, .name = "Trust keyboard", .firstIdByte = 0x5D},
{.type = PS2_DEV_TYPE_KEYBOARD, .name = "NMB SGI keyboard", .firstIdByte = 0x47},
}
@ PS2_DEV_TYPE_MOUSE_5BUTTON
Definition ps2.h:142
@ PS2_DEV_TYPE_KEYBOARD
Definition ps2.h:139
@ PS2_DEV_TYPE_MOUSE_STANDARD
Definition ps2.h:140
@ PS2_DEV_TYPE_MOUSE_SCROLL
Definition ps2.h:141

Definition at line 18 of file ps2.c.

Referenced by ps2_device_init().