Commit 9e61ec315374120c92cc7a20e1e078b89b217e69
1 parent
2a1d1880
PL050 status register fixes.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@2759 c046a42c-6fe2-441c-8c8c-71466251a162
Showing
1 changed file
with
25 additions
and
6 deletions
hw/pl050.c
| 1 | 1 | /* |
| 2 | 2 | * Arm PrimeCell PL050 Keyboard / Mouse Interface |
| 3 | 3 | * |
| 4 | - * Copyright (c) 2006 CodeSourcery. | |
| 4 | + * Copyright (c) 2006-2007 CodeSourcery. | |
| 5 | 5 | * Written by Paul Brook |
| 6 | 6 | * |
| 7 | 7 | * This code is licenced under the GPL. |
| ... | ... | @@ -20,6 +20,14 @@ typedef struct { |
| 20 | 20 | int is_mouse; |
| 21 | 21 | } pl050_state; |
| 22 | 22 | |
| 23 | +#define PL050_TXEMPTY (1 << 6) | |
| 24 | +#define PL050_TXBUSY (1 << 5) | |
| 25 | +#define PL050_RXFULL (1 << 4) | |
| 26 | +#define PL050_RXBUSY (1 << 3) | |
| 27 | +#define PL050_RXPARITY (1 << 2) | |
| 28 | +#define PL050_KMIC (1 << 1) | |
| 29 | +#define PL050_KMID (1 << 0) | |
| 30 | + | |
| 23 | 31 | static const unsigned char pl050_id[] = |
| 24 | 32 | { 0x50, 0x10, 0x04, 0x00, 0x0d, 0xf0, 0x05, 0xb1 }; |
| 25 | 33 | |
| ... | ... | @@ -45,11 +53,22 @@ static uint32_t pl050_read(void *opaque, target_phys_addr_t offset) |
| 45 | 53 | case 0: /* KMICR */ |
| 46 | 54 | return s->cr; |
| 47 | 55 | case 1: /* KMISTAT */ |
| 48 | - /* KMIC and KMID bits not implemented. */ | |
| 49 | - if (s->pending) { | |
| 50 | - return 0x10; | |
| 51 | - } else { | |
| 52 | - return 0; | |
| 56 | + { | |
| 57 | + uint8_t val; | |
| 58 | + uint32_t stat; | |
| 59 | + | |
| 60 | + val = s->last; | |
| 61 | + val = val ^ (val >> 4); | |
| 62 | + val = val ^ (val >> 2); | |
| 63 | + val = (val ^ (val >> 1)) & 1; | |
| 64 | + | |
| 65 | + stat = PL050_TXEMPTY; | |
| 66 | + if (val) | |
| 67 | + stat |= PL050_RXPARITY; | |
| 68 | + if (s->pending) | |
| 69 | + stat |= PL050_RXFULL; | |
| 70 | + | |
| 71 | + return stat; | |
| 53 | 72 | } |
| 54 | 73 | case 2: /* KMIDATA */ |
| 55 | 74 | if (s->pending) | ... | ... |