ReactOS 0.4.15-dev-8393-g61b7fb9
hwkmi.c
Go to the documentation of this file.
1/*
2 * PROJECT: ReactOS Boot Loader
3 * LICENSE: BSD - See COPYING.ARM in the top level directory
4 * FILE: boot/armllb/hw/versatile/hwkmi.c
5 * PURPOSE: LLB KMI Support for Versatile
6 * PROGRAMMERS: ReactOS Portable Systems Group
7 */
8
9#include "precomp.h"
10
11//
12// Control Register Bits
13//
14#define KMICR_TYPE (1 << 5)
15#define KMICR_RXINTREN (1 << 4)
16#define KMICR_TXINTREN (1 << 3)
17#define KMICR_EN (1 << 2)
18#define KMICR_FD (1 << 1)
19#define KMICR_FC (1 << 0)
20
21//
22// Status Register Bits
23//
24#define KMISTAT_TXEMPTY (1 << 6)
25#define KMISTAT_TXBUSY (1 << 5)
26#define KMISTAT_RXFULL (1 << 4)
27#define KMISTAT_RXBUSY (1 << 3)
28#define KMISTAT_RXPARITY (1 << 2)
29#define KMISTAT_IC (1 << 1)
30#define KMISTAT_ID (1 << 0)
31
32//
33// KMI Registers
34//
35#define PL050_KMICR (LlbHwVersaKmiBase + 0x00)
36#define PL050_KMISTAT (LlbHwVersaKmiBase + 0x04)
37#define PL050_KMIDATA (LlbHwVersaKmiBase + 0x08)
38#define PL050_KMICLKDIV (LlbHwVersaKmiBase + 0x0c)
39static const ULONG LlbHwVersaKmiBase = 0x10006000;
40
41//
42// PS/2 Commands/Requests
43//
44#define PS2_O_RESET 0xff
45#define PS2_O_RESEND 0xfe
46#define PS2_O_DISABLE 0xf5
47#define PS2_O_ENABLE 0xf4
48#define PS2_O_ECHO 0xee
49#define PS2_O_SET_DEFAULT 0xf6
50#define PS2_O_SET_RATE_DELAY 0xf3
51#define PS2_O_SET_SCANSET 0xf0
52#define PS2_O_INDICATORS 0xed
53#define PS2_I_RESEND 0xfe
54#define PS2_I_DIAGFAIL 0xfd
55#define PS2_I_ACK 0xfa
56#define PS2_I_BREAK 0xf0
57#define PS2_I_ECHO 0xee
58#define PS2_I_BAT_OK 0xaa
59
60/* FUNCTIONS ******************************************************************/
61
62VOID
65{
66 volatile int i = 1000;
67
68 /* Send the value */
70
71 /* Wait a bit */
72 while (--i);
73
74 /* Now make sure we received an ACK */
75 if (LlbHwKbdRead() != PS2_I_ACK) DbgPrint("PS/2 FAILURE!\n");
76}
77
78VOID
81{
83
84 /* Setup divisor and enable KMI */
85 Divisor = (LlbHwGetPClk() / 8000000) - 1;
88
89 /* Reset PS/2 controller */
91 if (LlbHwKbdRead() != PS2_I_BAT_OK) DbgPrint("PS/2 RESET FAILURE!\n");
92
93 /* Send PS/2 Initialization Stream */
99}
100
101VOID
102NTAPI
104{
106
107 /* Wait for ready signal */
108 do
109 {
110 /* Read TX buffer state */
112 } while (!(Status & KMISTAT_TXEMPTY));
113
114 /* Send value */
116}
117
119NTAPI
121{
123}
124
125INT
126NTAPI
128{
129 /* Read current data on keyboard */
131}
132
133/* EOF */
unsigned char BOOLEAN
Status
Definition: gdiplustypes.h:25
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define DbgPrint
Definition: hal.h:12
#define PS2_O_ENABLE
Definition: hwkmi.c:47
#define PS2_O_SET_SCANSET
Definition: hwkmi.c:51
BOOLEAN NTAPI LlbHwKbdReady(VOID)
Definition: hwkmi.c:120
#define PL050_KMICLKDIV
Definition: hwkmi.c:38
#define PS2_O_SET_DEFAULT
Definition: hwkmi.c:49
#define PS2_O_DISABLE
Definition: hwkmi.c:46
#define PL050_KMICR
Definition: hwkmi.c:35
#define PS2_O_RESET
Definition: hwkmi.c:44
#define KMISTAT_TXEMPTY
Definition: hwkmi.c:24
#define PL050_KMISTAT
Definition: hwkmi.c:36
VOID NTAPI LlbHwVersaKmiInitialize(VOID)
Definition: hwkmi.c:80
INT NTAPI LlbHwKbdRead(VOID)
Definition: hwkmi.c:127
#define PS2_I_ACK
Definition: hwkmi.c:55
#define PS2_I_BAT_OK
Definition: hwkmi.c:58
#define KMISTAT_RXFULL
Definition: hwkmi.c:26
#define PL050_KMIDATA
Definition: hwkmi.c:37
VOID NTAPI LlbHwVersaKmiSendAndWait(IN ULONG Value)
Definition: hwkmi.c:64
#define KMICR_EN
Definition: hwkmi.c:17
VOID NTAPI LlbHwKbdSend(IN ULONG Value)
Definition: hwkmi.c:103
static const ULONG LlbHwVersaKmiBase
Definition: hwkmi.c:39
ULONG NTAPI LlbHwGetPClk(VOID)
Definition: hwinfo.c:20
#define NTAPI
Definition: typedefs.h:36
int32_t INT
Definition: typedefs.h:58
#define IN
Definition: typedefs.h:39
uint32_t ULONG
Definition: typedefs.h:59
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _Out_opt_ PUSHORT _Inout_opt_ PUNICODE_STRING Value
Definition: wdfregistry.h:413
NTKERNELAPI VOID NTAPI WRITE_REGISTER_UCHAR(IN PUCHAR Register, IN UCHAR Value)
NTKERNELAPI UCHAR NTAPI READ_REGISTER_UCHAR(IN PUCHAR Register)
_In_ LARGE_INTEGER Divisor
Definition: rtlfuncs.h:3044
unsigned char UCHAR
Definition: xmlstorage.h:181