Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[xsrc/trunk]: xsrc/external/mit/xf86-video-wsfb/dist/src Correctly support th...
details: https://anonhg.NetBSD.org/xsrc/rev/cd77004fe056
branches: trunk
changeset: 10368:cd77004fe056
user: rin <rin%NetBSD.org@localhost>
date: Tue Jul 23 12:01:53 2019 +0000
description:
Correctly support the case of fbi->fbi_fboffset != 0, which means base
address of framebuffer is not page-aligned:
- When mmap framebuffer, fbi->fbi_fboffset is added to the length of
framebuffer. Otherwise, the last page of framebuffer is not mapped
properly if (size of framebuffer) <= (page boundary) < (size of
framebuffer + fbi->fbi_fboffset), since length of mapped area is
counted from page-truncated address. This results in memory
corruption in the upper adjacent page, or SEGV.
- Use fPtr->fbstart (real base address of framebuffer) instead of
fPtr->fbmem (return value of mmap, i.e., page-aligned base address)
where appropriate.
Tested on genfb(4) on Cubietruck, where fbi->fbi_fboffset = 4096.
No functional changes for majority of framebuffer drivers, whose base
address is page-aligned.
diffstat:
external/mit/xf86-video-wsfb/dist/src/wsfb_driver.c | 36 ++++++++++----------
1 files changed, 18 insertions(+), 18 deletions(-)
diffs (82 lines):
diff -r 47ab00024b70 -r cd77004fe056 external/mit/xf86-video-wsfb/dist/src/wsfb_driver.c
--- a/external/mit/xf86-video-wsfb/dist/src/wsfb_driver.c Tue Jul 23 11:40:29 2019 +0000
+++ b/external/mit/xf86-video-wsfb/dist/src/wsfb_driver.c Tue Jul 23 12:01:53 2019 +0000
@@ -505,10 +505,21 @@
}
fbi->fbi_flags = 0;
fbi->fbi_fbsize = lb * info.height;
- fbi->fbi_fboffset = 0;
-
+#ifdef WSDISPLAY_TYPE_LUNA
+ if (wstype == WSDISPLAY_TYPE_LUNA) {
+ /*
+ * XXX
+ * LUNA's FB seems to have 64 dot (8 byte) offset.
+ * This might be able to be changed in kernel
+ * lunafb driver, but current setting was pulled
+ * from 4.4BSD-Lite2/luna68k.
+ */
+ fbi->fbi_fboffset = 8;
+ } else
+#endif
+ fbi->fbi_fboffset = 0;
}
- xf86Msg(X_INFO, "fboffset %x\n", fPtr->fbi.fbi_fboffset);
+ xf86Msg(X_INFO, "fboffset %x\n", (int)fPtr->fbi.fbi_fboffset);
/*
* Allocate room for saving the colormap.
*/
@@ -927,7 +938,7 @@
return FALSE;
}
len = max(len, fPtr->fbi.fbi_fbsize);
- fPtr->fbmem = wsfb_mmap(len, 0, fPtr->fd);
+ fPtr->fbmem = wsfb_mmap(len + fPtr->fbi.fbi_fboffset, 0, fPtr->fd);
if (fPtr->fbmem == NULL) {
xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
@@ -966,17 +977,6 @@
}
fPtr->fbstart = fPtr->fbmem + fPtr->fbi.fbi_fboffset;
-#ifdef WSDISPLAY_TYPE_LUNA
- if (wstype == WSDISPLAY_TYPE_LUNA) {
- /*
- * XXX
- * LUNA's FB seems to have 64 dot (8 byte) offset.
- * This might be able to be changed in kernel lunafb driver,
- * but current setting was pulled from 4.4BSD-Lite2/luna68k.
- */
- fPtr->fbstart += 8;
- }
-#endif
if (fPtr->shadowFB) {
fPtr->shadow = calloc(1, fPtr->fbi.fbi_stride * pScrn->virtualY);
@@ -1163,7 +1163,7 @@
if (pScrn->vtSema) {
WsfbRestore(pScrn);
- if (munmap(fPtr->fbmem, fPtr->fbmem_len) == -1) {
+ if (munmap(fPtr->fbmem, fPtr->fbmem_len + fPtr->fbi.fbi_fboffset) == -1) {
xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
"munmap: %s\n", strerror(errno));
}
@@ -1203,7 +1203,7 @@
return NULL;
fPtr->fbi.fbi_stride = *size;
}
- return ((CARD8 *)fPtr->fbmem + row * fPtr->fbi.fbi_stride + offset);
+ return ((CARD8 *)fPtr->fbstart + row * fPtr->fbi.fbi_stride + offset);
}
static void
@@ -1448,7 +1448,7 @@
}
/* Clear the screen. */
- memset(fPtr->fbmem, 0, fPtr->fbmem_len);
+ memset(fPtr->fbstart, 0, fPtr->fbmem_len);
/* Restore the text mode. */
mode = WSDISPLAYIO_MODE_EMUL;
Home |
Main Index |
Thread Index |
Old Index