~jderose/ubuntu/raring/qemu/vde-again

« back to all changes in this revision

Viewing changes to hw/pl050.c

Tags: upstream-0.9.0+20070816
ImportĀ upstreamĀ versionĀ 0.9.0+20070816

Show diffs side-by-side

added added

removed removed

Lines of Context:
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.
15
15
    uint32_t cr;
16
16
    uint32_t clk;
17
17
    uint32_t last;
18
 
    void *pic;
19
18
    int pending;
20
 
    int irq;
 
19
    qemu_irq irq;
21
20
    int is_mouse;
22
21
} pl050_state;
23
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
 
24
31
static const unsigned char pl050_id[] =
25
32
{ 0x50, 0x10, 0x04, 0x00, 0x0d, 0xf0, 0x05, 0xb1 };
26
33
 
32
39
    s->pending = level;
33
40
    raise = (s->pending && (s->cr & 0x10) != 0)
34
41
            || (s->cr & 0x08) != 0;
35
 
    pic_set_irq_new(s->pic, s->irq, raise);
 
42
    qemu_set_irq(s->irq, raise);
36
43
}
37
44
 
38
45
static uint32_t pl050_read(void *opaque, target_phys_addr_t offset)
46
53
    case 0: /* KMICR */
47
54
        return s->cr;
48
55
    case 1: /* KMISTAT */
49
 
        /* KMIC and KMID bits not implemented.  */
50
 
        if (s->pending) {
51
 
            return 0x10;
52
 
        } else {
53
 
            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;
54
72
        }
55
73
    case 2: /* KMIDATA */
56
74
        if (s->pending)
105
123
   pl050_write
106
124
};
107
125
 
108
 
void pl050_init(uint32_t base, void *pic, int irq, int is_mouse)
 
126
void pl050_init(uint32_t base, qemu_irq irq, int is_mouse)
109
127
{
110
128
    int iomemtype;
111
129
    pl050_state *s;
113
131
    s = (pl050_state *)qemu_mallocz(sizeof(pl050_state));
114
132
    iomemtype = cpu_register_io_memory(0, pl050_readfn,
115
133
                                       pl050_writefn, s);
116
 
    cpu_register_physical_memory(base, 0x00000fff, iomemtype);
 
134
    cpu_register_physical_memory(base, 0x00001000, iomemtype);
117
135
    s->base = base;
118
 
    s->pic = pic;
119
136
    s->irq = irq;
120
137
    s->is_mouse = is_mouse;
121
138
    if (is_mouse)