diff options
| author | macallan <macallan@NetBSD.org> | 2010-05-06 04:30:18 +0000 |
|---|---|---|
| committer | macallan <macallan@NetBSD.org> | 2010-05-06 04:30:18 +0000 |
| commit | 21bc7f3caadc91d50e14cbf20cbc6c35abe1a8b4 (patch) | |
| tree | 65d6ad01c8386da46697014645d1245b3e9571e0 /sys/dev/rasops | |
| parent | e35956774de3fb2910ba0b3c0bc6a603b823c988 (diff) | |
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 (limited to 'sys/dev/rasops')
| -rw-r--r-- | sys/dev/rasops/rasops.c | 22 | ||||
| -rw-r--r-- | sys/dev/rasops/rasops.h | 12 |
2 files changed, 24 insertions, 10 deletions
diff --git a/sys/dev/rasops/rasops.c b/sys/dev/rasops/rasops.c index 480d38c2674..8d00e2e1297 100644 --- a/sys/dev/rasops/rasops.c +++ b/sys/dev/rasops/rasops.c @@ -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_8(struct rasops_info *); 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 @@ rasops_reconfig(struct rasops_info *ri, int wantrows, int wantcols) } /* 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_optfont.data = kmem_zalloc(len, KM_SLEEP)) != NULL) { + ri->ri_optfont.numchars; + + if (((ri->ri_flg & RI_NO_AUTO) == 0) && + ((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_reconfig(struct rasops_info *ri, int wantrows, int wantcols) 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 --git a/sys/dev/rasops/rasops.h b/sys/dev/rasops/rasops.h index 2c78af47bcd..7bb97e69419 100644 --- a/sys/dev/rasops/rasops.h +++ b/sys/dev/rasops/rasops.h @@ -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 @@ struct rasops_info { ((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 /* |
