Revision 90d37239
b/Makefile | ||
---|---|---|
101 | 101 |
OBJS+=buffered_file.o migration.o migration-tcp.o net.o qemu-sockets.o |
102 | 102 |
OBJS+=qemu-char.o aio.o net-checksum.o savevm.o cache-utils.o |
103 | 103 |
OBJS+=msmouse.o ps2.o |
104 |
OBJS+=qdev.o |
|
104 |
OBJS+=qdev.o ssi.o
|
|
105 | 105 |
|
106 | 106 |
ifdef CONFIG_BRLAPI |
107 | 107 |
OBJS+= baum.o |
b/hw/ssi.c | ||
---|---|---|
1 |
/* |
|
2 |
* QEMU Synchronous Serial Interface support |
|
3 |
* |
|
4 |
* Copyright (c) 2009 CodeSourcery. |
|
5 |
* Written by Paul Brook |
|
6 |
* |
|
7 |
* This code is licenced under the GNU GPL v2. |
|
8 |
*/ |
|
9 |
|
|
10 |
#include "ssi.h" |
|
11 |
|
|
12 |
struct SSIBus { |
|
13 |
SSISlave *slave; |
|
14 |
}; |
|
15 |
|
|
16 |
static void ssi_slave_init(DeviceState *dev, void *opaque) |
|
17 |
{ |
|
18 |
SSISlaveInfo *info = opaque; |
|
19 |
SSISlave *s = SSI_SLAVE_FROM_QDEV(dev); |
|
20 |
SSIBus *bus = qdev_get_bus(dev); |
|
21 |
|
|
22 |
bus->slave = s; |
|
23 |
s->info = info; |
|
24 |
info->init(s); |
|
25 |
} |
|
26 |
|
|
27 |
void ssi_register_slave(const char *name, int size, SSISlaveInfo *info) |
|
28 |
{ |
|
29 |
assert(size >= sizeof(SSISlave)); |
|
30 |
qdev_register(name, size, ssi_slave_init, info); |
|
31 |
} |
|
32 |
|
|
33 |
DeviceState *ssi_create_slave(SSIBus *bus, const char *name) |
|
34 |
{ |
|
35 |
DeviceState *dev; |
|
36 |
dev = qdev_create(bus, name); |
|
37 |
qdev_init(dev); |
|
38 |
return dev; |
|
39 |
} |
|
40 |
|
|
41 |
SSIBus *ssi_create_bus(void) |
|
42 |
{ |
|
43 |
return qemu_mallocz(sizeof(SSIBus)); |
|
44 |
} |
|
45 |
|
|
46 |
uint32_t ssi_transfer(SSIBus *bus, uint32_t val) |
|
47 |
{ |
|
48 |
if (!bus->slave) { |
|
49 |
return 0; |
|
50 |
} |
|
51 |
return bus->slave->info->transfer(bus->slave, val); |
|
52 |
} |
b/hw/ssi.h | ||
---|---|---|
1 |
/* QEMU Synchronous Serial Interface support. */ |
|
2 |
|
|
3 |
/* In principle SSI is a point-point interface. As such the qemu |
|
4 |
implementation has a single slave device on a "bus". |
|
5 |
However it is fairly common for boards to have multiple slaves |
|
6 |
connected to a single master, and select devices with an external |
|
7 |
chip select. This is implemented in qemu by having an explicit mux device. |
|
8 |
It is assumed that master and slave are both using the same transfer width. |
|
9 |
*/ |
|
10 |
|
|
11 |
#ifndef QEMU_SSI_H |
|
12 |
#define QEMU_SSI_H |
|
13 |
|
|
14 |
#include "qdev.h" |
|
15 |
|
|
16 |
typedef struct SSISlave SSISlave; |
|
17 |
|
|
18 |
/* Slave devices. */ |
|
19 |
typedef struct { |
|
20 |
void (*init)(SSISlave *dev); |
|
21 |
uint32_t (*transfer)(SSISlave *dev, uint32_t val); |
|
22 |
} SSISlaveInfo; |
|
23 |
|
|
24 |
struct SSISlave { |
|
25 |
DeviceState qdev; |
|
26 |
SSISlaveInfo *info; |
|
27 |
}; |
|
28 |
|
|
29 |
#define SSI_SLAVE_FROM_QDEV(dev) DO_UPCAST(SSISlave, qdev, dev) |
|
30 |
#define FROM_SSI_SLAVE(type, dev) DO_UPCAST(type, ssidev, dev) |
|
31 |
|
|
32 |
void ssi_register_slave(const char *name, int size, SSISlaveInfo *info); |
|
33 |
|
|
34 |
DeviceState *ssi_create_slave(SSIBus *bus, const char *name); |
|
35 |
|
|
36 |
/* Master interface. */ |
|
37 |
SSIBus *ssi_create_bus(void); |
|
38 |
|
|
39 |
uint32_t ssi_transfer(SSIBus *bus, uint32_t val); |
|
40 |
|
|
41 |
#endif |
b/qemu-common.h | ||
---|---|---|
183 | 183 |
typedef struct uWireSlave uWireSlave; |
184 | 184 |
typedef struct I2SCodec I2SCodec; |
185 | 185 |
typedef struct DeviceState DeviceState; |
186 |
typedef struct SSIBus SSIBus; |
|
186 | 187 |
|
187 | 188 |
/* CPU save/load. */ |
188 | 189 |
void cpu_save(QEMUFile *f, void *opaque); |
Also available in: Unified diff