]> Joshua Wise's Git repositories - netwatch.git/commitdiff
add checksumrect utilities
authorJacob Potter <jdpotter@andrew.cmu.edu>
Sat, 13 Dec 2008 22:10:02 +0000 (17:10 -0500)
committerJacob Potter <jdpotter@andrew.cmu.edu>
Sat, 13 Dec 2008 22:10:02 +0000 (17:10 -0500)
aseg-paging/Makefile
include/fb.h
video/checksumrect.c [new file with mode: 0644]
video/checksumrect.h [new file with mode: 0644]
video/tnt2.c

index ae63244f5f8f120f61cc8fa7e5dfe54e2b79bd05..73d7feb4d432e90f4f3d781a01b42bc012dc71b2 100644 (file)
@@ -46,6 +46,7 @@ OBJS =        ../ich2/smi.o \
        ../net/rfb.o \
        ../video/tnt2.o \
        ../video/fb.o \
+       ../video/checksumrect.o \
        drivers.o \
        ../lib/minilib.o \
        ../lib/doprnt.o \
index 9ade9e70b3bec1d441385694260edb8072408140..19dae0bb65ee481814483f7e048d8ab38287c98a 100644 (file)
@@ -1,6 +1,8 @@
 #ifndef __FB_H
 #define __FB_H
 
+#include <stdint.h>
+
 struct fbdevice;
 struct vmode;
 
@@ -9,6 +11,7 @@ typedef enum {
 } format_t;
 
 typedef void (*getvmode_t)(void *);
+typedef uint32_t (*checksum_rect_t)(int x, int y, int width, int height);
 
 struct vmode {
        int text:1;
@@ -20,6 +23,7 @@ struct fbdevice {
        unsigned char *fbaddr;
        void *priv;
        getvmode_t getvmode;
+       checksum_rect_t checksum_rect;
        struct vmode curmode;
 };
 
diff --git a/video/checksumrect.c b/video/checksumrect.c
new file mode 100644 (file)
index 0000000..f96c033
--- /dev/null
@@ -0,0 +1,26 @@
+#include <stdint.h>
+#include <fb.h>
+
+uint32_t checksum_rect_generic32(int x, int y, int width, int height) {
+
+       /* Generic checksum_rect function for video modes with 32-bit pixels
+        * (i.e. fb->curmode.bytestride = 4).
+        */
+
+        int scanline = fb->curmode.xres * 4;
+        uint32_t * lineaddr;
+        int i, j;
+
+        uint32_t sum = 0;
+
+        for (i = 0; i < height; i++) {
+                lineaddr = (uint32_t *)(fb->fbaddr + (i + y) * scanline);
+
+                for (j = 0; j < width; j++) {
+                        sum += lineaddr[j + x];
+                }
+        }
+
+        return sum;
+}
+
diff --git a/video/checksumrect.h b/video/checksumrect.h
new file mode 100644 (file)
index 0000000..8dd2a6d
--- /dev/null
@@ -0,0 +1,6 @@
+#ifndef _CHECKSUM_RECT_C
+#define _CHECKSUM_RECT_H
+
+uint32_t checksum_rect_generic32(int x, int y, int width, int height);
+
+#endif
index 32e646a407989ecd17ed35739de95d5f0502d0d4..c04b067d06bc4466a95d470de70f3ed0bbbd57e3 100644 (file)
@@ -5,6 +5,8 @@
 #include <fb.h>
 #include <paging.h>
 
+#include "checksumrect.h"
+
 static void tnt2_getvmode(void *priv);
 
 static struct fbdevice tnt2_fb = {
@@ -27,6 +29,7 @@ static void tnt2_getvmode(void *priv)
                tnt2_fb.curmode.format = FB_RGB888;
                tnt2_fb.curmode.bytestride = 4;
                tnt2_fb.curmode.text = 0;
+               tnt2_fb.checksum_rect = checksum_rect_generic32;
                break;
        case 0:
                tnt2_fb.curmode.text = 1;
This page took 0.035077 seconds and 4 git commands to generate.