qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH 3/7] tcx: port to test_and_clear instead of test/res


From: Juan Quintela
Subject: [Qemu-devel] [PATCH 3/7] tcx: port to test_and_clear instead of test/reset
Date: Fri, 11 Oct 2013 16:20:46 +0200

From: Juan Quintela <address@hidden>

Now page_min/max are not needed anymore.

Signed-off-by: Juan Quintela <address@hidden>
---
 hw/display/tcx.c | 72 ++++++++++++++------------------------------------------
 1 file changed, 18 insertions(+), 54 deletions(-)

diff --git a/hw/display/tcx.c b/hw/display/tcx.c
index 24876d3..d863a55 100644
--- a/hw/display/tcx.c
+++ b/hw/display/tcx.c
@@ -178,45 +178,31 @@ static inline void tcx24_draw_line32(TCXState *s1, 
uint8_t *d,
     }
 }

-static inline int check_dirty(TCXState *s, ram_addr_t page, ram_addr_t page24,
-                              ram_addr_t cpage)
+static inline int test_and_clear_dirty(TCXState *s, ram_addr_t page,
+                                       ram_addr_t page24,
+                                       ram_addr_t cpage)
 {
     int ret;

-    ret = memory_region_get_dirty(&s->vram_mem, page, TARGET_PAGE_SIZE,
-                                  DIRTY_MEMORY_VGA);
-    ret |= memory_region_get_dirty(&s->vram_mem, page24, TARGET_PAGE_SIZE * 4,
-                                   DIRTY_MEMORY_VGA);
-    ret |= memory_region_get_dirty(&s->vram_mem, cpage, TARGET_PAGE_SIZE * 4,
-                                   DIRTY_MEMORY_VGA);
+    ret = memory_region_test_and_clear_dirty(&s->vram_mem, page,
+                                             TARGET_PAGE_SIZE,
+                                             DIRTY_MEMORY_VGA);
+    ret |= memory_region_test_and_clear_dirty(&s->vram_mem, page24,
+                                              TARGET_PAGE_SIZE * 4,
+                                              DIRTY_MEMORY_VGA);
+    ret |= memory_region_test_and_clear_dirty(&s->vram_mem, cpage,
+                                              TARGET_PAGE_SIZE * 4,
+                                              DIRTY_MEMORY_VGA);
     return ret;
 }

-static inline void reset_dirty(TCXState *ts, ram_addr_t page_min,
-                               ram_addr_t page_max, ram_addr_t page24,
-                              ram_addr_t cpage)
-{
-    memory_region_reset_dirty(&ts->vram_mem,
-                              page_min,
-                              (page_max - page_min) + TARGET_PAGE_SIZE,
-                              DIRTY_MEMORY_VGA);
-    memory_region_reset_dirty(&ts->vram_mem,
-                              page24 + page_min * 4,
-                              (page_max - page_min) * 4 + TARGET_PAGE_SIZE,
-                              DIRTY_MEMORY_VGA);
-    memory_region_reset_dirty(&ts->vram_mem,
-                              cpage + page_min * 4,
-                              (page_max - page_min) * 4 + TARGET_PAGE_SIZE,
-                              DIRTY_MEMORY_VGA);
-}
-
 /* Fixed line length 1024 allows us to do nice tricks not possible on
    VGA... */
 static void tcx_update_display(void *opaque)
 {
     TCXState *ts = opaque;
     DisplaySurface *surface = qemu_console_surface(ts->con);
-    ram_addr_t page, page_min, page_max;
+    ram_addr_t page;
     int y, y_start, dd, ds;
     uint8_t *d, *s;
     void (*f)(TCXState *s1, uint8_t *dst, const uint8_t *src, int width);
@@ -227,8 +213,6 @@ static void tcx_update_display(void *opaque)

     page = 0;
     y_start = -1;
-    page_min = -1;
-    page_max = 0;
     d = surface_data(surface);
     s = ts->vram;
     dd = surface_stride(surface);
@@ -251,14 +235,11 @@ static void tcx_update_display(void *opaque)
     }

     for(y = 0; y < ts->height; y += 4, page += TARGET_PAGE_SIZE) {
-        if (memory_region_get_dirty(&ts->vram_mem, page, TARGET_PAGE_SIZE,
-                                    DIRTY_MEMORY_VGA)) {
+        if (memory_region_test_and_clear_dirty(&ts->vram_mem, page,
+                                               TARGET_PAGE_SIZE,
+                                               DIRTY_MEMORY_VGA)) {
             if (y_start < 0)
                 y_start = y;
-            if (page < page_min)
-                page_min = page;
-            if (page > page_max)
-                page_max = page;
             f(ts, d, s, ts->width);
             d += dd;
             s += ds;
@@ -287,20 +268,13 @@ static void tcx_update_display(void *opaque)
         dpy_gfx_update(ts->con, 0, y_start,
                        ts->width, y - y_start);
     }
-    /* reset modified pages */
-    if (page_max >= page_min) {
-        memory_region_reset_dirty(&ts->vram_mem,
-                                  page_min,
-                                  (page_max - page_min) + TARGET_PAGE_SIZE,
-                                  DIRTY_MEMORY_VGA);
-    }
 }

 static void tcx24_update_display(void *opaque)
 {
     TCXState *ts = opaque;
     DisplaySurface *surface = qemu_console_surface(ts->con);
-    ram_addr_t page, page_min, page_max, cpage, page24;
+    ram_addr_t page, cpage, page24;
     int y, y_start, dd, ds;
     uint8_t *d, *s;
     uint32_t *cptr, *s24;
@@ -313,8 +287,6 @@ static void tcx24_update_display(void *opaque)
     page24 = ts->vram24_offset;
     cpage = ts->cplane_offset;
     y_start = -1;
-    page_min = -1;
-    page_max = 0;
     d = surface_data(surface);
     s = ts->vram;
     s24 = ts->vram24;
@@ -324,13 +296,9 @@ static void tcx24_update_display(void *opaque)

     for(y = 0; y < ts->height; y += 4, page += TARGET_PAGE_SIZE,
             page24 += TARGET_PAGE_SIZE, cpage += TARGET_PAGE_SIZE) {
-        if (check_dirty(ts, page, page24, cpage)) {
+        if (test_and_clear_dirty(ts, page, page24, cpage)) {
             if (y_start < 0)
                 y_start = y;
-            if (page < page_min)
-                page_min = page;
-            if (page > page_max)
-                page_max = page;
             tcx24_draw_line32(ts, d, s, ts->width, cptr, s24);
             d += dd;
             s += ds;
@@ -369,10 +337,6 @@ static void tcx24_update_display(void *opaque)
         dpy_gfx_update(ts->con, 0, y_start,
                        ts->width, y - y_start);
     }
-    /* reset modified pages */
-    if (page_max >= page_min) {
-        reset_dirty(ts, page_min, page_max, page24, cpage);
-    }
 }

 static void tcx_invalidate_display(void *opaque)
-- 
1.8.3.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]