ReactOS  0.4.15-dev-1039-gb9754fa
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)
39 static 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 
62 VOID
63 NTAPI
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 
78 VOID
79 NTAPI
81 {
82  UCHAR Divisor;
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 
101 VOID
102 NTAPI
104 {
105  ULONG Status;
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 
118 BOOLEAN
119 NTAPI
121 {
123 }
124 
125 INT
126 NTAPI
128 {
129  /* Read current data on keyboard */
131 }
132 
133 /* EOF */
#define PL050_KMICLKDIV
Definition: hwkmi.c:38
#define IN
Definition: typedefs.h:39
#define DbgPrint
Definition: loader.c:25
static const ULONG LlbHwVersaKmiBase
Definition: hwkmi.c:39
#define PL050_KMICR
Definition: hwkmi.c:35
int32_t INT
Definition: typedefs.h:58
IN UCHAR Value
Definition: halp.h:394
#define KMICR_EN
Definition: hwkmi.c:17
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
NTSTATUS(* NTAPI)(IN PFILE_FULL_EA_INFORMATION EaBuffer, IN ULONG EaLength, OUT PULONG ErrorOffset)
Definition: IoEaTest.cpp:117
#define PS2_O_RESET
Definition: hwkmi.c:44
unsigned char BOOLEAN
#define PL050_KMIDATA
Definition: hwkmi.c:37
BOOLEAN NTAPI LlbHwKbdReady(VOID)
Definition: hwkmi.c:120
#define PS2_O_ENABLE
Definition: hwkmi.c:47
#define PS2_I_ACK
Definition: hwkmi.c:55
ULONG NTAPI LlbHwGetPClk(VOID)
Definition: hwinfo.c:20
VOID NTAPI LlbHwKbdSend(IN ULONG Value)
Definition: hwkmi.c:103
#define KMISTAT_TXEMPTY
Definition: hwkmi.c:24
#define PS2_O_SET_DEFAULT
Definition: hwkmi.c:49
unsigned char UCHAR
Definition: xmlstorage.h:181
Status
Definition: gdiplustypes.h:24
NTKERNELAPI UCHAR NTAPI READ_REGISTER_UCHAR(IN PUCHAR Register)
INT NTAPI LlbHwKbdRead(VOID)
Definition: hwkmi.c:127
#define PS2_O_SET_SCANSET
Definition: hwkmi.c:51
#define PL050_KMISTAT
Definition: hwkmi.c:36
VOID NTAPI LlbHwVersaKmiSendAndWait(IN ULONG Value)
Definition: hwkmi.c:64
_In_ LARGE_INTEGER Divisor
Definition: rtlfuncs.h:3046
VOID NTAPI LlbHwVersaKmiInitialize(VOID)
Definition: hwkmi.c:80
unsigned int ULONG
Definition: retypes.h:1
#define PS2_I_BAT_OK
Definition: hwkmi.c:58
#define KMISTAT_RXFULL
Definition: hwkmi.c:26
NTKERNELAPI VOID NTAPI WRITE_REGISTER_UCHAR(IN PUCHAR Register, IN UCHAR Value)
#define PS2_O_DISABLE
Definition: hwkmi.c:46