Subversion Repositories HelenOS

Rev

Rev 4153 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 4153 Rev 4263
Line 39... Line 39...
39
#include <arch/drivers/pic.h>
39
#include <arch/drivers/pic.h>
40
#include <sysinfo/sysinfo.h>
40
#include <sysinfo/sysinfo.h>
41
#include <interrupt.h>
41
#include <interrupt.h>
42
#include <stdarg.h>
42
#include <stdarg.h>
43
#include <ddi/device.h>
43
#include <ddi/device.h>
-
 
44
#include <string.h>
44
 
45
 
45
#define CUDA_IRQ 10
46
#define CUDA_IRQ 10
46
#define SPECIAL     '?'
-
 
47
 
47
 
48
#define PACKET_ADB  0x00
48
#define PACKET_ADB   0x00
49
#define PACKET_CUDA 0x01
49
#define PACKET_CUDA  0x01
50
 
50
 
51
#define CUDA_POWERDOWN  0x0a
51
#define CUDA_POWERDOWN  0x0a
52
#define CUDA_RESET      0x11
52
#define CUDA_RESET      0x11
53
 
53
 
54
#define RS 0x200
54
#define RS   0x200
55
#define B (0 * RS)
55
#define B    (0 * RS)
56
#define A (1 * RS)
56
#define A    (1 * RS)
57
#define SR (10 * RS)
57
#define SR   (10 * RS)
58
#define ACR (11 * RS)
58
#define ACR  (11 * RS)
59
 
59
 
60
#define SR_OUT 0x10
60
#define SR_OUT  0x10
61
#define TACK 0x10
61
#define TACK    0x10
62
#define TIP 0x20
62
#define TIP     0x20
63
 
63
 
-
 
64
#define SCANCODES  128
64
 
65
 
65
static volatile uint8_t *cuda = NULL;
66
static volatile uint8_t *cuda = NULL;
66
static irq_t cuda_irq;      /**< Cuda's IRQ. */
67
static irq_t cuda_irq;                 /**< Cuda's IRQ. */
67
 
68
 
192
};
150
};
193
 
151
 
194
 
-
 
195
static void receive_packet(uint8_t *kind, index_t count, uint8_t data[])
152
static void receive_packet(uint8_t *kind, index_t count, uint8_t data[])
196
{
153
{
197
    cuda[B] = cuda[B] & ~TIP;
154
    cuda[B] = cuda[B] & ~TIP;
198
    *kind = cuda[SR];
155
    *kind = cuda[SR];
199
   
156
   
Line 202... Line 159...
202
        data[i] = cuda[SR];
159
        data[i] = cuda[SR];
203
   
160
   
204
    cuda[B] = cuda[B] | TIP;
161
    cuda[B] = cuda[B] | TIP;
205
}
162
}
206
 
163
 
207
 
-
 
208
static indev_t kbrd;
164
static indev_t kbrd;
209
static indev_operations_t ops = {
165
static indev_operations_t ops = {
210
    .poll = NULL
166
    .poll = NULL
211
};
167
};
212
 
168
 
213
 
-
 
214
int cuda_get_scancode(void)
169
int cuda_get_scancode(void)
215
{
170
{
216
    if (cuda) {
171
    if (cuda) {
217
        uint8_t kind;
172
        uint8_t kind;
218
        uint8_t data[4];
173
        uint8_t data[4];
Line 261... Line 216...
261
    sysinfo_set_item_val("kbd", NULL, true);
216
    sysinfo_set_item_val("kbd", NULL, true);
262
    sysinfo_set_item_val("kbd.inr", NULL, CUDA_IRQ);
217
    sysinfo_set_item_val("kbd.inr", NULL, CUDA_IRQ);
263
    sysinfo_set_item_val("kbd.address.virtual", NULL, base);
218
    sysinfo_set_item_val("kbd.address.virtual", NULL, base);
264
}
219
}
265
 
220
 
266
 
-
 
267
static void send_packet(const uint8_t kind, count_t count, ...)
221
static void send_packet(const uint8_t kind, count_t count, ...)
268
{
222
{
269
    index_t i;
223
    index_t i;
270
    va_list va;
224
    va_list va;
271
   
225
   
Line 285... Line 239...
285
    va_end(va);
239
    va_end(va);
286
   
240
   
287
    cuda[B] = cuda[B] | TIP;
241
    cuda[B] = cuda[B] | TIP;
288
}
242
}
289
 
243
 
290
 
-
 
291
void cpu_halt(void) {
244
void cpu_halt(void) {
292
    asm volatile (
245
    asm volatile (
293
        "b 0\n"
246
        "b 0\n"
294
    );
247
    );
295
}
248
}