PatchworkOS  3984a1d
A non-POSIX operating system.
Loading...
Searching...
No Matches
ps2.c
Go to the documentation of this file.
1#include "ps2.h"
2#include "ps2_kbd.h"
3#include "ps2_mouse.h"
4
5#include <kernel/cpu/irq.h>
6#include <kernel/log/log.h>
7#include <kernel/log/panic.h>
10#include <kernel/sched/timer.h>
11#include <kernel/sync/lock.h>
15#include <modules/acpi/tables.h>
16
17#include <errno.h>
18#include <string.h>
19#include <time.h>
20
21static port_t dataPort = 0;
22static port_t statusPort = 0;
24
26
27static bool isDualChannel = false;
28static bool controllerInitialized = false;
29
31 {"PNP0300", "IBM PC/XT keyboard controller (83-key)"},
32 {"PNP0301", "IBM PC/AT keyboard controller (86-key)"},
33 {"PNP0302", "IBM PC/XT keyboard controller (84-key)"},
34 {"PNP0303", "IBM Enhanced (101/102-key, PS/2 mouse support)"},
35 {"PNP0304", "Olivetti Keyboard (83-key)"},
36 {"PNP0305", "Olivetti Keyboard (102-key)"},
37 {"PNP0306", "Olivetti Keyboard (86-key)"},
38 {"PNP0307", "Microsoft Windows(R) Keyboard"},
39 {"PNP0308", "General Input Device Emulation Interface (GIDEI) legacy"},
40 {"PNP0309", "Olivetti Keyboard (A101/102 key)"},
41 {"PNP030A", "AT&T 302 keyboard"},
42 {"PNP030B", "Reserved by Microsoft"},
43 {"PNP0320", "Japanese 101-key keyboard"},
44 {"PNP0321", "Japanese AX keyboard"},
45 {"PNP0322", "Japanese 106-key keyboard A01"},
46 {"PNP0323", "Japanese 106-key keyboard 002/003"},
47 {"PNP0324", "Japanese 106-key keyboard 001"},
48 {"PNP0325", "Japanese Toshiba Desktop keyboard"},
49 {"PNP0326", "Japanese Toshiba Laptop keyboard"},
50 {"PNP0327", "Japanese Toshiba Notebook keyboard"},
51 {"PNP0340", "Korean 84-key keyboard"},
52 {"PNP0341", "Korean 86-key keyboard"},
53 {"PNP0342", "Korean Enhanced keyboard"},
54 {"PNP0343", "Korean Enhanced keyboard 101(b/c)"},
55 {"PNP0344", "Korean Enhanced keyboard 103"},
56};
57
59 {"PNP0F00", "Microsoft Bus Mouse"},
60 {"PNP0F01", "Microsoft Serial Mouse"},
61 {"PNP0F02", "Microsoft InPort Mouse"},
62 {"PNP0F03", "Microsoft PS/2-style Mouse"},
63 {"PNP0F04", "Mouse Systems Mouse"},
64 {"PNP0F05", "Mouse Systems 3-Button Mouse (COM2)"},
65 {"PNP0F06", "Genius Mouse (COM1)"},
66 {"PNP0F07", "Genius Mouse (COM2)"},
67 {"PNP0F08", "Logitech Serial Mouse"},
68 {"PNP0F09", "Microsoft BallPoint Serial Mouse"},
69 {"PNP0F0A", "Microsoft Plug and Play Mouse"},
70 {"PNP0F0B", "Microsoft Plug and Play BallPoint Mouse"},
71 {"PNP0F0C", "Microsoft-compatible Serial Mouse"},
72 {"PNP0F0D", "Microsoft-compatible InPort-compatible Mouse"},
73 {"PNP0F0E", "Microsoft-compatible PS/2-style Mouse"},
74 {"PNP0F0F", "Microsoft-compatible Serial BallPoint-compatible Mouse"},
75 {"PNP0F10", "Texas Instruments QuickPort Mouse"},
76 {"PNP0F11", "Microsoft-compatible Bus Mouse"},
77 {"PNP0F12", "Logitech PS/2-style Mouse"},
78 {"PNP0F13", "PS/2 Port for PS/2-style Mice"},
79 {"PNP0F14", "Microsoft Kids Mouse"},
80 {"PNP0F15", "Logitech bus mouse"},
81 {"PNP0F16", "Logitech SWIFT device"},
82 {"PNP0F17", "Logitech-compatible serial mouse"},
83 {"PNP0F18", "Logitech-compatible bus mouse"},
84 {"PNP0F19", "Logitech-compatible PS/2-style Mouse"},
85 {"PNP0F1A", "Logitech-compatible SWIFT Device"},
86 {"PNP0F1B", "HP Omnibook Mouse"},
87 {"PNP0F1C", "Compaq LTE Trackball PS/2-style Mouse"},
88 {"PNP0F1D", "Compaq LTE Trackball Serial Mouse"},
89 {"PNP0F1E", "Microsoft Kids Trackball Mouse"},
90 {"PNP0F1F", "Reserved by Microsoft Input Device Group"},
91 {"PNP0F20", "Reserved by Microsoft Input Device Group"},
92 {"PNP0F21", "Reserved by Microsoft Input Device Group"},
93 {"PNP0F22", "Reserved by Microsoft Input Device Group"},
94 {"PNP0F23", "Reserved by Microsoft Input Device Group"},
95 {"PNP0FFC", "Reserved (temporarily) by Microsoft Kernel team"},
96 {"PNP0FFF", "Reserved by Microsoft Systems (SDA Standard Compliant SD Host Controller Vendor)"},
97};
98
100 [0] = {.device = PS2_DEV_FIRST},
101 [1] = {.device = PS2_DEV_SECOND},
102};
104
106{
107 switch (response)
108 {
110 return "pass";
112 return "fail";
113 default:
114 return "invalid response";
115 }
116}
117
119{
120 switch (response)
121 {
123 return "pass";
125 return "clock stuck low";
127 return "clock stuck high";
129 return "data stuck low";
131 return "data stuck high";
132 default:
133 return "invalid response";
134 }
135}
136
137static const char* ps2_device_to_string(ps2_device_t device)
138{
139 switch (device)
140 {
141 case PS2_DEV_FIRST:
142 return "first";
143 case PS2_DEV_SECOND:
144 return "second";
145 default:
146 return "invalid device";
147 }
148}
149
151{
153 {
154 return 0;
155 }
157
159 {
160 LOG_ERR("ps2 first device disable failed during controller init\n");
161 return ERR;
162 }
164 {
165 LOG_ERR("ps2 second device disable failed during controller init\n");
166 return ERR;
167 }
168 ps2_drain();
169
171 if (currentConfig == ERR)
172 {
173 LOG_ERR("ps2 failed to read initial config\n");
174 return ERR;
175 }
176
177 LOG_DEBUG("ps2 initial config byte: 0x%02x\n", currentConfig);
180 LOG_DEBUG("ps2 setting config byte to: 0x%02x\n", currentConfig);
181
183 {
184 LOG_ERR("ps2 failed to write initial config\n");
185 return ERR;
186 }
187
188 return 0;
189}
190
191static void ps2_controller_deinit(void)
192{
194 {
195 return;
196 }
197 controllerInitialized = false;
198
200 {
202 }
203
205 {
207 }
208
210 {
211 LOG_WARN("ps2 first device disable failed during deinit\n");
212 }
213
215 {
216 LOG_WARN("ps2 second device disable failed during deinit\n");
217 }
218}
219
221{
223 if (cfg == ERR)
224 {
225 LOG_ERR("ps2 failed to read config byte.\n");
226 return ERR;
227 }
228
230 if (response == ERR)
231 {
232 LOG_ERR("ps2 failed to send self test command\n");
233 return ERR;
234 }
235
237 {
238 LOG_ERR("ps2 self test failed %s", ps2_self_test_response_to_string(response));
239 return ERR;
240 }
241
243 {
244 LOG_ERR("ps2 failed to write config byte.\n");
245 return ERR;
246 }
247
248 return 0;
249}
250
252{
254 if (cfg == ERR)
255 {
256 LOG_ERR("ps2 failed to read config for dual channel check\n");
257 return ERR;
258 }
259
261 {
263 {
264 LOG_ERR("ps2 failed to send second port enable command\n");
265 return ERR;
266 }
267
269 if (cfg == ERR)
270 {
271 LOG_ERR("ps2 failed to read config after second port enable\n");
272 return ERR;
273 }
274
275 if (!(cfg & PS2_CFG_SECOND_CLOCK_DISABLE))
276 {
277 isDualChannel = true;
278 LOG_INFO("dual channel PS/2 controller detected\n");
279
281 {
282 LOG_ERR("ps2 failed to disable second port after detection\n");
283 return ERR;
284 }
285 }
286 else
287 {
288 isDualChannel = false;
289 LOG_INFO("single channel PS/2 controller detected\n");
290 }
291 }
292 else
293 {
294 isDualChannel = false;
295 LOG_INFO("single channel PS/2 controller detected (second port clock not disabled)\n");
296 }
297
298 return 0;
299}
300
302{
305 {
306 LOG_ERR("first port test failed with response %s.\n", ps2_device_test_response_to_string(response));
307 return ERR;
308 }
309
310 if (!isDualChannel)
311 {
312 return 0;
313 }
314
317 {
318 LOG_ERR("second port test failed with response %s.\n", ps2_device_test_response_to_string(response));
319 return ERR;
320 }
321
322 return 0;
323}
324
325void ps2_drain(void)
326{
329 {
332 }
333}
334
336{
338 while ((io_in8(statusPort) & status) == 0)
339 {
341 {
343 return ERR;
344 }
345 asm volatile("pause");
346 }
347 return 0;
348}
349
351{
353 while ((io_in8(statusPort) & status) != 0)
354 {
356 {
358 return ERR;
359 }
360 asm volatile("pause");
361 }
362 return 0;
363}
364
366{
368 {
370 return ERR;
371 }
372 return io_in8(dataPort);
373}
374
376{
378 {
379 errno = EAGAIN;
380 return ERR;
381 }
382
383 return io_in8(dataPort);
384}
385
387{
389 {
391 return ERR;
392 }
394 return 0;
395}
396
398{
400 {
402 return ERR;
403 }
404 io_out8(commandPort, command);
405 return 0;
406}
407
409{
410 if (ps2_cmd(command) == ERR)
411 {
412 return ERR;
413 }
414 return ps2_read();
415}
416
418{
419 if (ps2_cmd(command) == ERR)
420 {
421 return ERR;
422 }
423 return ps2_write(data);
424}
425
427{
428 ps2_device_info_t* info = &devices[device];
429
430 if (ps2_device_cmd(device, PS2_DEV_CMD_RESET) == ERR)
431 {
432 LOG_ERR("%s port reset failed\n", ps2_device_to_string(device));
433 return ERR;
434 }
436
438 if (response == ERR)
439 {
440 LOG_ERR("ps2 %s device reset failed to read response\n", ps2_device_to_string(device));
441 return ERR;
442 }
443
445 {
446 LOG_ERR("ps2 %s device reset failed, invalid response 0x%02x\n", ps2_device_to_string(device), response);
447 return ERR;
448 }
449
450 // The device might send its id bytes here, but we don't care about them.
451 ps2_drain();
452
454 {
455 LOG_ERR("ps2 %s device disable scanning failed\n", ps2_device_to_string(device));
456 return ERR;
457 }
458
459 if (device == PS2_DEV_FIRST)
460 {
461 LOG_INFO("found PS/2 keyboard '%s' on IRQ %u\n", info->name, info->irq);
462 if (ps2_kbd_init(info) == ERR)
463 {
464 LOG_ERR("ps2 %s device keyboard initialization failed\n", ps2_device_to_string(device));
465 return ERR;
466 }
467 }
468 else
469 {
470 LOG_INFO("found PS/2 mouse '%s' on IRQ %u\n", info->name, info->irq);
471 if (ps2_mouse_init(info) == ERR)
472 {
473 LOG_ERR("ps2 %s device mouse initialization failed\n", ps2_device_to_string(device));
474 return ERR;
475 }
476 }
477
479 {
480 LOG_ERR("ps2 %s device enable scanning failed\n", ps2_device_to_string(device));
481 return ERR;
482 }
483
484 info->initialized = true;
485 return 0;
486}
487
489{
490 for (uint8_t i = 0; i < PS2_COMMAND_RETRIES; i++)
491 {
492 if (device == PS2_DEV_SECOND)
493 {
495 {
496 return ERR;
497 }
498 }
499 if (ps2_write(command) == ERR)
500 {
501 return ERR;
502 }
503
505 if (response == ERR)
506 {
507 continue;
508 }
509
511 {
512 return 0;
513 }
514
516 {
517 continue;
518 }
519
520 LOG_WARN("%s device cmd 0x%02x got unexpected response 0x%02x\n", ps2_device_to_string(device), command,
521 response);
522 return ERR;
523 }
524
525 LOG_ERR("%s device cmd 0x%02x failed after %d retries\n", ps2_device_to_string(device), command,
527 return ERR;
528}
529
531{
532 if (ps2_device_cmd(device, command) == ERR)
533 {
534 return ERR;
535 }
536 return ps2_read();
537}
538
540{
541 if (ps2_device_cmd(device, command) == ERR)
542 {
543 return ERR;
544 }
545 return ps2_device_cmd(device, subCommand);
546}
547
548static uint64_t ps2_attach_device(const char* type, const char* name)
549{
551
553 if (acpiCfg == NULL)
554 {
555 LOG_ERR("ps2 failed to get ACPI device config for '%s'\n", name);
556 return ERR;
557 }
558
559 // We dont know if the controllers resources will be specified on the first device or the second device,
560 // so we might need to delay initialization of the first device until the second device is attached.
561 if (acpiCfg->ioCount != 0)
562 {
564 {
565 LOG_ERR("ps2 device '%s' cannot initialize controller (already initialized)\n", name);
566 return ERR;
567 }
569
572 {
573 LOG_ERR("ps2 device '%s' has invalid status port resource\n", name);
574 return ERR;
575 }
576 commandPort = statusPort; // Command port is the same as status port
577
578 if (ps2_controller_init() == ERR)
579 {
580 LOG_ERR("ps2 controller initialization failed\n");
581 return ERR;
582 }
583 if (ps2_self_test() == ERR)
584 {
585 LOG_ERR("ps2 controller self test failed\n");
586 return ERR;
587 }
589 {
590 LOG_ERR("ps2 controller dual channel check failed\n");
591 return ERR;
592 }
593 if (ps2_devices_test() == ERR)
594 {
595 LOG_ERR("ps2 controller devices test failed\n");
596 return ERR;
597 }
598 }
599
600 if (acpiCfg->irqCount != 1)
601 {
602 LOG_ERR("ps2 device '%s' has invalid IRQ resource count %d\n", name, acpiCfg->irqCount);
603 return ERR;
604 }
605
608 {
610 }
612 {
614 }
615 else
616 {
617 LOG_ERR("ps2 device '%s' has unknown type '%s'\n", name, type);
618 return ERR;
619 }
620
621 if (devices[targetDevice].attached)
622 {
623 LOG_ERR("ps2 device '%s' cannot be attached to %s port (port already attached)\n", name,
625 return ERR;
626 }
627
629 {
630 LOG_ERR("ps2 device '%s' cannot be attached to %s port (port already in use by %s)\n", name,
632 return ERR;
633 }
634
635 devices[targetDevice].pnpId = type;
636
639 {
640 for (size_t i = 0; i < ARRAY_SIZE(knownKeyboards); i++)
641 {
642 if (strcmp(type, knownKeyboards[i].pnpId) == 0)
643 {
645 break;
646 }
647 }
648 }
649 else
650 {
651 for (size_t i = 0; i < ARRAY_SIZE(knownMice); i++)
652 {
653 if (strcmp(type, knownMice[i].pnpId) == 0)
654 {
656 break;
657 }
658 }
659 }
660
661 if (devices[targetDevice].name == NULL)
662 {
663 devices[targetDevice].name = "Unknown PS/2 Device";
664 LOG_WARN("ps2 device '%s' has unknown PNP ID '%s'\n", name, type);
665 }
666
667 devices[targetDevice].irq = acpiCfg->irqs[0].virt;
669
671 {
672 LOG_INFO("delaying ps2 device '%s' initialization (controller not initialized)\n", name);
673 return 0;
674 }
675
678 {
679 LOG_INFO("delaying ps2 device '%s' initialization (waiting for other device)\n", name);
680 return 0;
681 }
682
683 for (ps2_device_t dev = 0; dev < PS2_DEV_COUNT; dev++)
684 {
685 if (devices[dev].attached && !devices[dev].initialized)
686 {
687 if (ps2_device_init(dev) == ERR)
688 {
689 LOG_ERR("ps2 failed to initialize device '%s' on %s port\n", name, ps2_device_to_string(dev));
690 return ERR;
691 }
692 devices[dev].initialized = true;
693 }
694 }
695
697
699 {
701 {
702 LOG_ERR("ps2 failed to register IRQ for keyboard device\n");
703 return ERR;
704 }
705
707 }
708 else
709 {
711 }
712
714 {
716 {
717 LOG_ERR("ps2 failed to register IRQ for mouse device\n");
718 return ERR;
719 }
721 }
722 else
723 {
725 }
726
728 {
729 LOG_ERR("ps2 failed to write final config byte\n");
730 return ERR;
731 }
732
734 {
736 {
737 LOG_ERR("ps2 failed to enable first port\n");
738 return ERR;
739 }
740 }
741
743 {
745 {
746 LOG_ERR("ps2 failed to enable second port\n");
747 return ERR;
748 }
749 }
750
751 return 0;
752}
753
755{
756 switch (event->type)
757 {
760 {
762 return ERR;
763 }
764 break;
767 break;
768 default:
769 break;
770 }
771
772 return 0;
773}
774
775MODULE_INFO("PS2 Driver", "Kai Norberg", "A PS/2 keyboard and mouse driver", OS_VERSION, "MIT",
int64_t y
Definition main.c:153
static fd_t data
Definition dwm.c:21
static void io_out8(port_t port, uint8_t val)
Write an 8-bit value to an I/O port.
Definition io.h:71
static uint8_t io_in8(port_t port)
Read an 8-bit value from an I/O port.
Definition io.h:82
uint16_t port_t
I/O port type.
Definition io.h:27
#define LOG_ERR(format,...)
Definition log.h:93
#define LOG_WARN(format,...)
Definition log.h:92
#define LOG_INFO(format,...)
Definition log.h:91
#define LOG_DEBUG(format,...)
Definition log.h:85
bool module_device_types_contains(const char *deviceTypes, const char *type)
Check if a list of device types contains a specific device type.
Definition module.c:1184
#define MODULE_INFO(_name, _author, _description, _version, _licence, _deviceTypes)
Macro to define module information.
Definition module.h:200
@ MODULE_EVENT_DEVICE_ATTACH
Definition module.h:251
@ MODULE_EVENT_UNLOAD
Definition module.h:245
void clock_wait(clock_t nanoseconds)
Wait for a specified number of nanoseconds.
Definition clock.c:130
clock_t clock_uptime(void)
Retrieve the time in nanoseconds since boot.
Definition clock.c:99
#define LOCK_CREATE()
Create a lock initializer.
Definition lock.h:69
#define LOCK_SCOPE(lock)
Acquires a lock for the reminder of the current scope.
Definition lock.h:58
#define ETIMEDOUT
Connection timed out.
Definition errno.h:577
#define errno
Error number variable.
Definition errno.h:27
#define EAGAIN
Try again.
Definition errno.h:87
#define ARRAY_SIZE(x)
Get the number of elements in a static array.
Definition defs.h:108
#define NULL
Pointer error value.
Definition NULL.h:23
#define ERR
Integer error value.
Definition ERR.h:17
uint64_t ps2_kbd_init(ps2_device_info_t *info)
Initialize a PS/2 keyboard device.
Definition ps2_kbd.c:51
void ps2_kbd_deinit(ps2_device_info_t *info)
Deinitialize a PS/2 keyboard device.
Definition ps2_kbd.c:97
uint64_t ps2_kbd_irq_register(ps2_device_info_t *info)
Register the IRQ handler for a PS/2 keyboard device.
Definition ps2_kbd.c:78
void ps2_mouse_deinit(ps2_device_info_t *info)
Deinitialize a PS/2 mouse device.
Definition ps2_mouse.c:160
uint64_t ps2_mouse_irq_register(ps2_device_info_t *info)
Register the IRQ handler for a PS/2 mouse device.
Definition ps2_mouse.c:141
uint64_t ps2_mouse_init(ps2_device_info_t *info)
Initialize a PS/2 mouse device.
Definition ps2_mouse.c:110
acpi_device_cfg_t * acpi_device_cfg_lookup(const char *name)
Retrieves the ACPI device configuration for a device by its name.
Definition devices.c:567
uint64_t acpi_device_cfg_get_port(acpi_device_cfg_t *cfg, uint64_t index, port_t *out)
Retrieves an the nth IO port assigned to an ACPI device.
Definition devices.c:603
uint64_t ps2_cmd(ps2_cmd_t command)
Send a command to the PS/2 controller without reading response.
Definition ps2.c:397
ps2_device_t
PS/2 device identifiers.
Definition ps2.h:131
uint64_t ps2_read(void)
Read from the PS/2 controllers data port.
Definition ps2.c:365
ps2_status_bits_t
PS/2 controller status register bits.
Definition ps2.h:82
#define PS2_COMMAND_RETRIES
Number of retries for commands.
Definition ps2.h:37
ps2_device_test_response_t
PS/2 device test responses.
Definition ps2.h:166
ps2_cmd_t
PS/2 controller commands.
Definition ps2.h:63
#define PS2_WAIT_TIMEOUT
Wait timeout for PS/2 controller.
Definition ps2.h:22
uint64_t ps2_wait_until_set(ps2_status_bits_t status)
Wait until status bit(s) are set.
Definition ps2.c:335
uint64_t ps2_write(uint8_t data)
Write to the PS/2 controllers data port.
Definition ps2.c:386
#define PS2_LARGE_DELAY
Large delay for various operations.
Definition ps2.h:32
uint64_t ps2_device_cmd_and_read(ps2_device_t device, ps2_device_cmd_t command)
Send a command to a PS/2 device and read response.
Definition ps2.c:530
ps2_self_test_response_t
PS/2 controller self-test responses.
Definition ps2.h:156
uint64_t ps2_cmd_and_read(ps2_cmd_t command)
Send a command to the PS/2 controller and read response.
Definition ps2.c:408
void ps2_drain(void)
Drain the PS/2 output buffer.
Definition ps2.c:325
uint64_t ps2_read_no_wait(void)
Read from the PS/2 controllers data port without waiting.
Definition ps2.c:375
#define PS2_MOUSE_PNP_IDS
All known PS/2 mouse PNP IDs.
Definition ps2.h:53
#define PS2_SMALL_DELAY
Small delay for various operations.
Definition ps2.h:27
uint64_t ps2_wait_until_clear(ps2_status_bits_t status)
Wait until status bit(s) are clear.
Definition ps2.c:350
ps2_device_cmd_t
PS/2 device commands.
Definition ps2.h:113
#define PS2_KEYBOARD_PNP_IDS
All known PS/2 keyboard PNP IDs.
Definition ps2.h:44
uint64_t ps2_device_cmd(ps2_device_t device, ps2_device_cmd_t command)
Send a command to a PS/2 device without reading response.
Definition ps2.c:488
uint64_t ps2_cmd_and_write(ps2_cmd_t command, uint8_t data)
Send a command to the PS/2 controller and write data.
Definition ps2.c:417
uint64_t ps2_device_sub_cmd(ps2_device_t device, ps2_device_cmd_t command, uint8_t subCommand)
Send a command and a subcommand to a PS/2 device.
Definition ps2.c:539
@ PS2_DEV_COUNT
Definition ps2.h:135
@ PS2_DEV_SECOND
Definition ps2.h:134
@ PS2_DEV_FIRST
Definition ps2.h:133
@ PS2_STATUS_IN_FULL
Input buffer status (0 = empty, 1 = full)
Definition ps2.h:84
@ PS2_STATUS_OUT_FULL
Output buffer status (0 = empty, 1 = full)
Definition ps2.h:83
@ PS2_DEV_TEST_DATA_STUCK_LOW
Definition ps2.h:170
@ PS2_DEV_TEST_PASS
Definition ps2.h:167
@ PS2_DEV_TEST_DATA_STUCK_HIGH
Definition ps2.h:171
@ PS2_DEV_TEST_CLOCK_STUCK_HIGH
Definition ps2.h:169
@ PS2_DEV_TEST_CLOCK_STUCK_LOW
Definition ps2.h:168
@ PS2_CMD_SECOND_TEST
Definition ps2.h:70
@ PS2_CMD_SECOND_WRITE
Definition ps2.h:74
@ PS2_CMD_SELF_TEST
Definition ps2.h:71
@ PS2_CMD_FIRST_ENABLE
Definition ps2.h:69
@ PS2_CMD_FIRST_DISABLE
Definition ps2.h:68
@ PS2_CMD_CFG_READ
Definition ps2.h:64
@ PS2_CMD_SECOND_ENABLE
Definition ps2.h:67
@ PS2_CMD_SECOND_DISABLE
Definition ps2.h:66
@ PS2_CMD_FIRST_TEST
Definition ps2.h:72
@ PS2_CMD_CFG_WRITE
Definition ps2.h:65
@ PS2_CFG_SECOND_IRQ
Second PS/2 port interrupt enable.
Definition ps2.h:99
@ PS2_CFG_FIRST_IRQ
First PS/2 port interrupt enable.
Definition ps2.h:98
@ PS2_CFG_SECOND_CLOCK_DISABLE
Second PS/2 port clock disable.
Definition ps2.h:103
@ PS2_CFG_FIRST_CLOCK_DISABLE
First PS/2 port clock disable.
Definition ps2.h:102
@ PS2_CFG_FIRST_TRANSLATION
First PS/2 port translation enable.
Definition ps2.h:104
@ PS2_SELF_TEST_FAIL
Definition ps2.h:158
@ PS2_SELF_TEST_PASS
Definition ps2.h:157
@ PS2_DEV_CMD_RESET
Definition ps2.h:123
@ PS2_DEV_CMD_DISABLE_SCANNING
Definition ps2.h:120
@ PS2_DEV_CMD_ENABLE_SCANNING
Definition ps2.h:119
@ PS2_DEV_RESPONSE_RESEND
Definition ps2.h:181
@ PS2_DEV_RESPONSE_ACK
Definition ps2.h:180
@ PS2_DEV_RESPONSE_BAT_OK
Definition ps2.h:182
static clock_t startTime
Definition clock.c:5
static void ps2_controller_deinit(void)
Definition ps2.c:191
static port_t statusPort
Definition ps2.c:22
static bool isDualChannel
Definition ps2.c:27
static ps2_known_device_t knownKeyboards[]
Definition ps2.c:30
static port_t dataPort
Definition ps2.c:21
static bool controllerInitialized
Definition ps2.c:28
static lock_t attachLock
Definition ps2.c:103
static uint64_t ps2_device_init(ps2_device_t device)
Definition ps2.c:426
static ps2_known_device_t knownMice[]
Definition ps2.c:58
uint64_t _module_procedure(const module_event_t *event)
Definition ps2.c:754
static port_t commandPort
Definition ps2.c:23
static uint64_t ps2_controller_init(void)
Definition ps2.c:150
static uint64_t currentConfig
Definition ps2.c:25
static uint64_t ps2_self_test(void)
Definition ps2.c:220
static const char * ps2_self_test_response_to_string(ps2_self_test_response_t response)
Definition ps2.c:105
static uint64_t ps2_check_if_dual_channel(void)
Definition ps2.c:251
static uint64_t ps2_devices_test(void)
Definition ps2.c:301
static const char * ps2_device_test_response_to_string(ps2_device_test_response_t response)
Definition ps2.c:118
static uint64_t ps2_attach_device(const char *type, const char *name)
Definition ps2.c:548
static const char * ps2_device_to_string(ps2_device_t device)
Definition ps2.c:137
static ps2_device_info_t devices[PS2_DEV_COUNT]
Definition ps2.c:99
__UINT64_TYPE__ uint64_t
Definition stdint.h:17
__UINT8_TYPE__ uint8_t
Definition stdint.h:11
_PUBLIC int strcmp(const char *s1, const char *s2)
Definition strcmp.c:3
ACPI device configuration structure.
Definition devices.h:112
A simple ticket lock implementation.
Definition lock.h:44
struct module_event_t::@4::@6 deviceAttach
module_event_type_t type
Definition module.h:268
char * name
Definition module.h:273
PS/2 device information structure.
Definition ps2.h:202
bool attached
The device has been attached from ACPI.
Definition ps2.h:207
irq_virt_t irq
IRQ assigned to the device by ACPI.
Definition ps2.h:206
ps2_device_t device
Device port.
Definition ps2.h:203
bool initialized
The device has been initialized.
Definition ps2.h:208
const char * name
Human-readable name of the device.
Definition ps2.h:205
const char * pnpId
PNP ID of the device.
Definition ps2.h:204
Known PS/2 device structure.
Definition ps2.h:192
const char * name
Definition ps2.h:194
static bool initialized
Definition tmpfs.c:28