diff options
| author | macallan <macallan@NetBSD.org> | 2018-11-29 23:44:50 +0000 |
|---|---|---|
| committer | macallan <macallan@NetBSD.org> | 2018-11-29 23:44:50 +0000 |
| commit | 77c069febdc2d6e256e21bb25067f89554eb0358 (patch) | |
| tree | 6fb684f0618ac6e25fd30ce070b831a07c851806 /sys/dev/rasops | |
| parent | 8e5c69818317d2a15e81b711ba3793d685cda83c (diff) | |
rasops_do_cursor():
- simplify & sanitize the unaligned case
- use only 32bit accesses
... no longer crash with odd sized fonts in 8bit
Diffstat (limited to 'sys/dev/rasops')
| -rw-r--r-- | sys/dev/rasops/rasops.c | 55 |
1 files changed, 20 insertions, 35 deletions
diff --git a/sys/dev/rasops/rasops.c b/sys/dev/rasops/rasops.c index 7dbd0236358..2b9153227c5 100644 --- a/sys/dev/rasops/rasops.c +++ b/sys/dev/rasops/rasops.c @@ -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 @@ static void 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 @@ rasops_do_cursor(struct rasops_info *ri) } } } 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 (ri->ri_hwbits) { - *hp++ = tmp; - } - } - - if (slop1 & 2) { - tmp16 = *(int16_t *)dp ^ ~0; - *(uint16_t *)dp = tmp16; - dp += 2; + if (msk1 != 0) { + tmp32 = *(int32_t *)dp ^ msk1; + *(uint32_t *)dp = tmp32; + dp += 4; if (ri->ri_hwbits) { - *(int16_t *)hp = tmp16; - hp += 2; + *(int32_t *)hp = tmp32; + hp += 4; } } @@ -1095,19 +1088,11 @@ rasops_do_cursor(struct rasops_info *ri) } } - if (slop2 & 1) { - tmp = *dp ^ ~0; - *dp = tmp; - dp++; - if (ri->ri_hwbits) - *hp++ = tmp; - } - - if (slop2 & 2) { - tmp16 = *(int16_t *)dp ^ ~0; - *(uint16_t *)dp = tmp16; + if (msk2 != 0) { + tmp32 = *(int32_t *)dp ^ msk2; + *(uint32_t *)dp = tmp32; if (ri->ri_hwbits) - *(int16_t *)hp = tmp16; + *(int32_t *)hp = tmp32; } } } |
