Commit 4b816985b8622473afbe3e1bbe066a961661a5da

Authored by Edgar E. Iglesias
1 parent 73cfd29f

ETRAX-SER: qdevify.

Signed-off-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
hw/axis_dev88.c
... ... @@ -21,15 +21,12 @@
21 21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 22 * THE SOFTWARE.
23 23 */
24   -#include <time.h>
25   -#include <sys/time.h>
26   -#include "hw.h"
  24 +
  25 +#include "sysbus.h"
27 26 #include "net.h"
28 27 #include "flash.h"
29   -#include "sysemu.h"
30   -#include "devices.h"
31 28 #include "boards.h"
32   -
  29 +#include "sysemu.h"
33 30 #include "etraxfs.h"
34 31  
35 32 #define D(x)
... ... @@ -323,10 +320,8 @@ void axisdev88_init (ram_addr_t ram_size,
323 320 etraxfs_timer_init(env, irq + 0x1b, nmi + 1, 0x3005e000);
324 321  
325 322 for (i = 0; i < 4; i++) {
326   - if (serial_hds[i]) {
327   - etraxfs_ser_init(env, irq + 0x14 + i,
328   - serial_hds[i], 0x30026000 + i * 0x2000);
329   - }
  323 + sysbus_create_simple("etraxfs,serial", 0x30026000 + i * 0x2000,
  324 + irq[0x14 + i]);
330 325 }
331 326  
332 327 if (kernel_filename) {
... ...
hw/etraxfs.c
... ... @@ -21,15 +21,11 @@
21 21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 22 * THE SOFTWARE.
23 23 */
24   -#include <time.h>
25   -#include <sys/time.h>
26   -#include "hw.h"
27   -#include "net.h"
28   -#include "flash.h"
29   -#include "sysemu.h"
30   -#include "devices.h"
31   -#include "boards.h"
32 24  
  25 +#include "sysbus.h"
  26 +#include "boards.h"
  27 +#include "sysemu.h"
  28 +#include "net.h"
33 29 #include "etraxfs.h"
34 30  
35 31 #define FLASH_SIZE 0x2000000
... ... @@ -114,10 +110,8 @@ void bareetraxfs_init (ram_addr_t ram_size,
114 110 etraxfs_timer_init(env, irq + 0x1b, nmi + 1, 0x3005e000);
115 111  
116 112 for (i = 0; i < 4; i++) {
117   - if (serial_hds[i]) {
118   - etraxfs_ser_init(env, irq + 0x14 + i,
119   - serial_hds[i], 0x30026000 + i * 0x2000);
120   - }
  113 + sysbus_create_simple("etraxfs,serial", 0x30026000 + i * 0x2000,
  114 + irq[0x14 + i]);
121 115 }
122 116  
123 117 if (kernel_filename) {
... ...
hw/etraxfs.h
... ... @@ -29,5 +29,5 @@ void etraxfs_timer_init(CPUState *env, qemu_irq *irqs, qemu_irq *nmi,
29 29 target_phys_addr_t base);
30 30 void *etraxfs_eth_init(NICInfo *nd, CPUState *env,
31 31 qemu_irq *irq, target_phys_addr_t base, int phyaddr);
32   -void etraxfs_ser_init(CPUState *env, qemu_irq *irq, CharDriverState *chr,
33   - target_phys_addr_t base);
  32 +//void etraxfs_ser_init(CPUState *env, qemu_irq *irq, CharDriverState *chr,
  33 +// target_phys_addr_t base);
... ...
hw/etraxfs_ser.c
... ... @@ -22,11 +22,8 @@
22 22 * THE SOFTWARE.
23 23 */
24 24  
25   -#include <stdio.h>
26   -#include <ctype.h>
27   -#include "hw.h"
  25 +#include "sysbus.h"
28 26 #include "qemu-char.h"
29   -#include "etraxfs.h"
30 27  
31 28 #define D(x)
32 29  
... ... @@ -48,9 +45,9 @@
48 45  
49 46 struct etrax_serial
50 47 {
51   - CPUState *env;
  48 + SysBusDevice busdev;
52 49 CharDriverState *chr;
53   - qemu_irq *irq;
  50 + qemu_irq irq;
54 51  
55 52 /* This pending thing is a hack. */
56 53 int pending_tx;
... ... @@ -64,7 +61,7 @@ static void ser_update_irq(struct etrax_serial *s)
64 61 s->regs[R_INTR] &= ~(s->regs[RW_ACK_INTR]);
65 62 s->regs[R_MASKED_INTR] = s->regs[R_INTR] & s->regs[RW_INTR_MASK];
66 63  
67   - qemu_set_irq(s->irq[0], !!s->regs[R_MASKED_INTR]);
  64 + qemu_set_irq(s->irq, !!s->regs[R_MASKED_INTR]);
68 65 s->regs[RW_ACK_INTR] = 0;
69 66 }
70 67  
... ... @@ -164,25 +161,29 @@ static void serial_event(void *opaque, int event)
164 161  
165 162 }
166 163  
167   -void etraxfs_ser_init(CPUState *env, qemu_irq *irq, CharDriverState *chr,
168   - target_phys_addr_t base)
  164 +static void etraxfs_ser_init(SysBusDevice *dev)
169 165 {
170   - struct etrax_serial *s;
  166 + struct etrax_serial *s = FROM_SYSBUS(typeof (*s), dev);
171 167 int ser_regs;
172 168  
173   - s = qemu_mallocz(sizeof *s);
174   -
175   - s->env = env;
176   - s->irq = irq;
177   - s->chr = chr;
178   -
179 169 /* transmitter begins ready and idle. */
180 170 s->regs[RS_STAT_DIN] |= (1 << STAT_TR_RDY);
181 171 s->regs[RS_STAT_DIN] |= (1 << STAT_TR_IDLE);
182 172  
183   - qemu_chr_add_handlers(chr, serial_can_receive, serial_receive,
184   - serial_event, s);
185   -
  173 + sysbus_init_irq(dev, &s->irq);
186 174 ser_regs = cpu_register_io_memory(0, ser_read, ser_write, s);
187   - cpu_register_physical_memory (base, R_MAX * 4, ser_regs);
  175 + sysbus_init_mmio(dev, R_MAX * 4, ser_regs);
  176 + s->chr = qdev_init_chardev(&dev->qdev);
  177 + if (s->chr)
  178 + qemu_chr_add_handlers(s->chr,
  179 + serial_can_receive, serial_receive,
  180 + serial_event, s);
188 181 }
  182 +
  183 +static void etraxfs_serial_register(void)
  184 +{
  185 + sysbus_register_dev("etraxfs,serial", sizeof (struct etrax_serial),
  186 + etraxfs_ser_init);
  187 +}
  188 +
  189 +device_init(etraxfs_serial_register)
... ...