Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/rasops Introduce a new flag for rasops_info to keep ...
details: https://anonhg.NetBSD.org/src/rev/cfe321e34981
branches: trunk
changeset: 754609:cfe321e34981
user: macallan <macallan%NetBSD.org@localhost>
date: Thu May 06 04:30:18 2010 +0000
description:
Introduce a new flag for rasops_info to keep rasops_reconfig() from trying
to allocate memory. Use this when calling rasops_reconfig() before it is safe
to call kmem_alloc().
diffstat:
sys/dev/rasops/rasops.c | 22 ++++++++++++++--------
sys/dev/rasops/rasops.h | 12 ++++++++++--
2 files changed, 24 insertions(+), 10 deletions(-)
diffs (94 lines):
diff -r 4b0f0dd9bc3a -r cfe321e34981 sys/dev/rasops/rasops.c
--- a/sys/dev/rasops/rasops.c Wed May 05 22:11:19 2010 +0000
+++ b/sys/dev/rasops/rasops.c Thu May 06 04:30:18 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: rasops.c,v 1.63 2010/05/04 04:57:34 macallan Exp $ */
+/* $NetBSD: rasops.c,v 1.64 2010/05/06 04:30:18 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.63 2010/05/04 04:57:34 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rasops.c,v 1.64 2010/05/06 04:30:18 macallan Exp $");
#include "opt_rasops.h"
#include "rasops_glue.h"
@@ -163,6 +163,8 @@
void rasops_make_box_chars_16(struct rasops_info *);
void rasops_make_box_chars_32(struct rasops_info *);
+extern int cold;
+
/*
* Initialize a 'rasops_info' descriptor.
*/
@@ -250,15 +252,18 @@
}
/* autogenerate box drawing characters */
+ ri->ri_optfont.firstchar = WSFONT_FLAG_OPT;
+ ri->ri_optfont.numchars = 16;
ri->ri_optfont.fontwidth = ri->ri_font->fontwidth;
ri->ri_optfont.fontheight = ri->ri_font->fontheight;
ri->ri_optfont.stride = ri->ri_font->stride;
- ri->ri_optfont.firstchar = WSFONT_FLAG_OPT;
- ri->ri_optfont.numchars = 16;
+ len = ri->ri_optfont.fontheight * ri->ri_optfont.stride *
+ ri->ri_optfont.numchars;
+
+ if (((ri->ri_flg & RI_NO_AUTO) == 0) &&
+ ((ri->ri_optfont.data = kmem_zalloc(len, KM_SLEEP)) != NULL)) {
+
- len = ri->ri_optfont.fontheight * ri->ri_optfont.stride *
- ri->ri_optfont.numchars;
- if ((ri->ri_optfont.data = kmem_zalloc(len, KM_SLEEP)) != NULL) {
switch (ri->ri_optfont.stride) {
case 1:
rasops_make_box_chars_8(ri);
@@ -270,7 +275,8 @@
rasops_make_box_chars_32(ri);
break;
}
- }
+ } else
+ memset(&ri->ri_optfont, 0, sizeof(ri->ri_optfont));
if (ri->ri_font->fontwidth > 32 || ri->ri_font->fontwidth < 4)
panic("rasops_init: fontwidth assumptions botched!");
diff -r 4b0f0dd9bc3a -r cfe321e34981 sys/dev/rasops/rasops.h
--- a/sys/dev/rasops/rasops.h Wed May 05 22:11:19 2010 +0000
+++ b/sys/dev/rasops/rasops.h Thu May 06 04:30:18 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: rasops.h,v 1.25 2010/05/04 04:57:34 macallan Exp $ */
+/* $NetBSD: rasops.h,v 1.26 2010/05/06 04:30:18 macallan Exp $ */
/*-
* Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -48,6 +48,13 @@
#define RI_ROTATE_CCW 0x200 /* display is rotated, quarter counter-clockwise */
#define RI_ROTATE_UD 0x400 /* display is rotated, upside-down */
#define RI_ROTATE_MASK 0x700
+/*
+ * if you call rasops_init() or rasops_reconfig() in a context where it is not
+ * safe to call kmem_alloc(), like early on during kernel startup, you MUST set
+ * RI_NO_AUTO to keep rasops from trying to allocate memory for autogenerated
+ * box drawing characters
+ */
+#define RI_NO_AUTO 0x800 /* do not generate box drawing characters */
struct rasops_info {
/* These must be filled in by the caller */
@@ -124,7 +131,8 @@
((c) >= (font)->firstchar && \
((c) - (font)->firstchar) < (font)->numchars)
-#define PICK_FONT(ri, c) ((c & WSFONT_FLAGS_MASK) == WSFONT_FLAG_OPT) ? \
+#define PICK_FONT(ri, c) (((c & WSFONT_FLAGS_MASK) == WSFONT_FLAG_OPT) && \
+ (ri->ri_optfont.data != NULL)) ? \
&ri->ri_optfont : ri->ri_font
/*
Home |
Main Index |
Thread Index |
Old Index