Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/rasops rasops_do_cursor():
details: https://anonhg.NetBSD.org/src/rev/7f2abb47e519
branches: trunk
changeset: 446298:7f2abb47e519
user: macallan <macallan%NetBSD.org@localhost>
date: Thu Nov 29 23:44:50 2018 +0000
description:
rasops_do_cursor():
- simplify & sanitize the unaligned case
- use only 32bit accesses
... no longer crash with odd sized fonts in 8bit
diffstat:
sys/dev/rasops/rasops.c | 55 +++++++++++++++++-------------------------------
1 files changed, 20 insertions(+), 35 deletions(-)
diffs (98 lines):
diff -r b8690ecb8280 -r 7f2abb47e519 sys/dev/rasops/rasops.c
--- a/sys/dev/rasops/rasops.c Thu Nov 29 23:18:40 2018 +0000
+++ b/sys/dev/rasops/rasops.c Thu Nov 29 23:44:50 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: rasops.c,v 1.77 2017/06/01 02:45:11 chs Exp $ */
+/* $NetBSD: rasops.c,v 1.78 2018/11/29 23:44:50 macallan Exp $ */
/*-
* Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rasops.c,v 1.77 2017/06/01 02:45:11 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rasops.c,v 1.78 2018/11/29 23:44:50 macallan Exp $");
#include "opt_rasops.h"
#include "rasops_glue.h"
@@ -995,7 +995,7 @@
rasops_do_cursor(struct rasops_info *ri)
{
int full1, height, cnt, slop1, slop2, row, col;
- u_char *dp, *rp, *hrp, *hp, tmp = 0;
+ u_char *dp, *rp, *hrp, *hp;
hrp = hp = NULL;
@@ -1055,33 +1055,26 @@
}
}
} else {
- uint16_t tmp16;
- uint32_t tmp32;
- /* XXX this is stupid.. use masks instead */
+ uint32_t tmp32, msk1, msk2;
+
+ msk1 = be32toh(0xffffffff >> (32 - (8 * slop1)));
+ msk2 = be32toh(0xffffffff << (32 - (8 * slop2)));
+
while (height--) {
- dp = rp;
+ dp = (u_char *)((uintptr_t)rp & ~3);
rp += ri->ri_stride;
if (ri->ri_hwbits) {
- hp = hrp;
+ hp = (u_char *)((uintptr_t)hrp & ~3);
hrp += ri->ri_stride;
}
- if (slop1 & 1) {
- tmp = *dp ^ ~0;
- *dp = tmp;
- dp++;
+ if (msk1 != 0) {
+ tmp32 = *(int32_t *)dp ^ msk1;
+ *(uint32_t *)dp = tmp32;
+ dp += 4;
if (ri->ri_hwbits) {
- *hp++ = tmp;
- }
- }
-
- if (slop1 & 2) {
- tmp16 = *(int16_t *)dp ^ ~0;
- *(uint16_t *)dp = tmp16;
- dp += 2;
- if (ri->ri_hwbits) {
- *(int16_t *)hp = tmp16;
- hp += 2;
+ *(int32_t *)hp = tmp32;
+ hp += 4;
}
}
@@ -1095,19 +1088,11 @@
}
}
- if (slop2 & 1) {
- tmp = *dp ^ ~0;
- *dp = tmp;
- dp++;
+ if (msk2 != 0) {
+ tmp32 = *(int32_t *)dp ^ msk2;
+ *(uint32_t *)dp = tmp32;
if (ri->ri_hwbits)
- *hp++ = tmp;
- }
-
- if (slop2 & 2) {
- tmp16 = *(int16_t *)dp ^ ~0;
- *(uint16_t *)dp = tmp16;
- if (ri->ri_hwbits)
- *(int16_t *)hp = tmp16;
+ *(int32_t *)hp = tmp32;
}
}
}
Home |
Main Index |
Thread Index |
Old Index