~vcs-imports/qemu/git

« back to all changes in this revision

Viewing changes to hw/arm_sysctl.c

  • Committer: Blue Swirl
  • Date: 2009-08-31 15:14:40 UTC
  • Revision ID: git-v1:528e93a9787ccfc59582a44035f5f342caf5b84f
Fix breakage due to __thread

Thread-local storage is not supported on all hosts.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>

Show diffs side-by-side

added added

removed removed

Lines of Context:
7
7
 * This code is licenced under the GPL.
8
8
 */
9
9
 
10
 
#include "hw.h"
 
10
#include "sysbus.h"
11
11
#include "primecell.h"
12
12
#include "sysemu.h"
13
13
 
14
14
#define LOCK_VALUE 0xa05f
15
15
 
16
16
typedef struct {
17
 
    uint32_t base;
 
17
    SysBusDevice busdev;
18
18
    uint32_t sys_id;
19
19
    uint32_t leds;
20
20
    uint16_t lockval;
29
29
{
30
30
    arm_sysctl_state *s = (arm_sysctl_state *)opaque;
31
31
 
32
 
    offset -= s->base;
33
32
    switch (offset) {
34
33
    case 0x00: /* ID */
35
34
        return s->sys_id;
108
107
                          uint32_t val)
109
108
{
110
109
    arm_sysctl_state *s = (arm_sysctl_state *)opaque;
111
 
    offset -= s->base;
112
110
 
113
111
    switch (offset) {
114
112
    case 0x08: /* LED */
179
177
    }
180
178
}
181
179
 
182
 
static CPUReadMemoryFunc *arm_sysctl_readfn[] = {
 
180
static CPUReadMemoryFunc * const arm_sysctl_readfn[] = {
183
181
   arm_sysctl_read,
184
182
   arm_sysctl_read,
185
183
   arm_sysctl_read
186
184
};
187
185
 
188
 
static CPUWriteMemoryFunc *arm_sysctl_writefn[] = {
 
186
static CPUWriteMemoryFunc * const arm_sysctl_writefn[] = {
189
187
   arm_sysctl_write,
190
188
   arm_sysctl_write,
191
189
   arm_sysctl_write
192
190
};
193
191
 
194
 
void arm_sysctl_init(uint32_t base, uint32_t sys_id)
 
192
static int arm_sysctl_init1(SysBusDevice *dev)
195
193
{
196
 
    arm_sysctl_state *s;
 
194
    arm_sysctl_state *s = FROM_SYSBUS(arm_sysctl_state, dev);
197
195
    int iomemtype;
198
196
 
199
 
    s = (arm_sysctl_state *)qemu_mallocz(sizeof(arm_sysctl_state));
200
 
    if (!s)
201
 
        return;
202
 
    s->base = base;
203
 
    s->sys_id = sys_id;
204
197
    /* The MPcore bootloader uses these flags to start secondary CPUs.
205
198
       We don't use a bootloader, so do this here.  */
206
199
    s->flags = 3;
207
 
    iomemtype = cpu_register_io_memory(0, arm_sysctl_readfn,
 
200
    iomemtype = cpu_register_io_memory(arm_sysctl_readfn,
208
201
                                       arm_sysctl_writefn, s);
209
 
    cpu_register_physical_memory(base, 0x00001000, iomemtype);
 
202
    sysbus_init_mmio(dev, 0x1000, iomemtype);
210
203
    /* ??? Save/restore.  */
211
 
}
212
 
 
 
204
    return 0;
 
205
}
 
206
 
 
207
/* Legacy helper function.  */
 
208
void arm_sysctl_init(uint32_t base, uint32_t sys_id)
 
209
{
 
210
    DeviceState *dev;
 
211
 
 
212
    dev = qdev_create(NULL, "realview_sysctl");
 
213
    qdev_prop_set_uint32(dev, "sys_id", sys_id);
 
214
    qdev_init(dev);
 
215
    sysbus_mmio_map(sysbus_from_qdev(dev), 0, base);
 
216
}
 
217
 
 
218
static SysBusDeviceInfo arm_sysctl_info = {
 
219
    .init = arm_sysctl_init1,
 
220
    .qdev.name  = "realview_sysctl",
 
221
    .qdev.size  = sizeof(arm_sysctl_state),
 
222
    .qdev.props = (Property[]) {
 
223
        DEFINE_PROP_UINT32("sys_id", arm_sysctl_state, sys_id, 0),
 
224
        DEFINE_PROP_END_OF_LIST(),
 
225
    }
 
226
};
 
227
 
 
228
static void arm_sysctl_register_devices(void)
 
229
{
 
230
    sysbus_register_withprop(&arm_sysctl_info);
 
231
}
 
232
 
 
233
device_init(arm_sysctl_register_devices)