vmstate: port cirrus_vga device
[qemu] / hw / jazz_led.c
index c8ac263..18780e9 100644 (file)
@@ -34,20 +34,17 @@ typedef enum {
 } screen_state_t;
 
 typedef struct LedState {
-    target_phys_addr_t base;
     uint8_t segments;
     DisplayState *ds;
-    QEMUConsole *console;
     screen_state_t state;
 } LedState;
 
 static uint32_t led_readb(void *opaque, target_phys_addr_t addr)
 {
     LedState *s = opaque;
-    int relative_addr = addr - s->base;
     uint32_t val;
 
-    switch (relative_addr) {
+    switch (addr) {
         case 0:
             val = s->segments;
             break;
@@ -94,9 +91,8 @@ static uint32_t led_readl(void *opaque, target_phys_addr_t addr)
 static void led_writeb(void *opaque, target_phys_addr_t addr, uint32_t val)
 {
     LedState *s = opaque;
-    int relative_addr = addr - s->base;
 
-    switch (relative_addr) {
+    switch (addr) {
         case 0:
             s->segments = val;
             s->state |= REDRAW_SEGMENTS;
@@ -135,13 +131,13 @@ static void led_writel(void *opaque, target_phys_addr_t addr, uint32_t val)
 #endif
 }
 
-static CPUReadMemoryFunc *led_read[3] = {
+static CPUReadMemoryFunc * const led_read[3] = {
     led_readb,
     led_readw,
     led_readl,
 };
 
-static CPUWriteMemoryFunc *led_write[3] = {
+static CPUWriteMemoryFunc * const led_write[3] = {
     led_writeb,
     led_writew,
     led_writel,
@@ -292,7 +288,7 @@ static void jazz_led_text_update(void *opaque, console_ch_t *chardata)
     char buf[2];
 
     dpy_cursor(s->ds, -1, -1);
-    qemu_console_resize(s->console, 2, 1);
+    qemu_console_resize(s->ds, 2, 1);
 
     /* TODO: draw the segments */
     snprintf(buf, 2, "%02hhx\n", s->segments);
@@ -302,25 +298,21 @@ static void jazz_led_text_update(void *opaque, console_ch_t *chardata)
     dpy_update(s->ds, 0, 0, 2, 1);
 }
 
-void jazz_led_init(DisplayState *ds, target_phys_addr_t base)
+void jazz_led_init(target_phys_addr_t base)
 {
     LedState *s;
     int io;
 
     s = qemu_mallocz(sizeof(LedState));
-    if (!s)
-        return;
 
-    s->base = base;
-    s->ds = ds;
     s->state = REDRAW_SEGMENTS | REDRAW_BACKGROUND;
 
-    io = cpu_register_io_memory(0, led_read, led_write, s);
-    cpu_register_physical_memory(s->base, 1, io);
+    io = cpu_register_io_memory(led_read, led_write, s);
+    cpu_register_physical_memory(base, 1, io);
 
-    s->console = graphic_console_init(ds, jazz_led_update_display,
-                                     jazz_led_invalidate_display,
-                                     jazz_led_screen_dump,
-                                     jazz_led_text_update, s);
-    qemu_console_resize(s->console, 60, 80);
+    s->ds = graphic_console_init(jazz_led_update_display,
+                                 jazz_led_invalidate_display,
+                                 jazz_led_screen_dump,
+                                 jazz_led_text_update, s);
+    qemu_console_resize(s->ds, 60, 80);
 }