diff options
Diffstat (limited to 'stand/common')
-rw-r--r-- | stand/common/gfx_fb.c | 62 | ||||
-rw-r--r-- | stand/common/gfx_fb.h | 1 | ||||
-rw-r--r-- | stand/common/misc.c | 13 | ||||
-rw-r--r-- | stand/common/modinfo.c | 2 |
4 files changed, 78 insertions, 0 deletions
diff --git a/stand/common/gfx_fb.c b/stand/common/gfx_fb.c index af72ab1a4c99..3de0a8b631ee 100644 --- a/stand/common/gfx_fb.c +++ b/stand/common/gfx_fb.c @@ -232,6 +232,68 @@ gfx_parse_mode_str(char *str, int *x, int *y, int *depth) return (true); } +/* + * Returns true if we set the color from pre-existing environment, false if + * just used existing defaults. + */ +static bool +gfx_fb_evalcolor(const char *envname, teken_color_t *cattr, + ev_sethook_t sethook, ev_unsethook_t unsethook) +{ + const char *ptr; + char env[10]; + int eflags = EV_VOLATILE | EV_NOKENV; + bool from_env = false; + + ptr = getenv(envname); + if (ptr != NULL) { + *cattr = strtol(ptr, NULL, 10); + + /* + * If we can't unset the value, then it's probably hooked + * properly and we can just carry on. Otherwise, we want to + * reinitialize it so that we can hook it for the console that + * we're resetting defaults for. + */ + if (unsetenv(envname) != 0) + return (true); + from_env = true; + + /* + * If we're carrying over an existing value, we *do* want that + * to propagate to the kenv. + */ + eflags &= ~EV_NOKENV; + } + + snprintf(env, sizeof(env), "%d", *cattr); + env_setenv(envname, eflags, env, sethook, unsethook); + + return (from_env); +} + +void +gfx_fb_setcolors(teken_attr_t *attr, ev_sethook_t sethook, + ev_unsethook_t unsethook) +{ + bool need_setattr = false; + + /* + * On first run, we setup an environment hook to process any color + * changes. If the env is already set, we pick up fg and bg color + * values from the environment. + */ + if (gfx_fb_evalcolor("teken.fg_color", &attr->ta_fgcolor, + sethook, unsethook)) + need_setattr = true; + if (gfx_fb_evalcolor("teken.bg_color", &attr->ta_bgcolor, + sethook, unsethook)) + need_setattr = true; + + if (need_setattr) + teken_set_defattr(&gfx_state.tg_teken, attr); +} + static uint32_t rgb_color_map(uint8_t index, uint32_t rmax, int roffset, uint32_t gmax, int goffset, uint32_t bmax, int boffset) diff --git a/stand/common/gfx_fb.h b/stand/common/gfx_fb.h index 17e419d8ffd3..d12bcd76b7fa 100644 --- a/stand/common/gfx_fb.h +++ b/stand/common/gfx_fb.h @@ -277,6 +277,7 @@ void gfx_fb_bezier(uint32_t, uint32_t, uint32_t, uint32_t, uint32_t, uint32_t, int gfx_fb_putimage(png_t *, uint32_t, uint32_t, uint32_t, uint32_t, uint32_t); bool gfx_parse_mode_str(char *, int *, int *, int *); +void gfx_fb_setcolors(teken_attr_t *, ev_sethook_t, ev_unsethook_t); void term_image_display(teken_gfx_t *, const teken_rect_t *); void reset_font_flags(void); diff --git a/stand/common/misc.c b/stand/common/misc.c index 402213100951..a7c46ad2e74c 100644 --- a/stand/common/misc.c +++ b/stand/common/misc.c @@ -220,3 +220,16 @@ set_currdev(const char *devname) env_setenv("loaddev", EV_VOLATILE | EV_NOHOOK, devname, env_noset, env_nounset); } + +#ifndef LOADER_NET_SUPPORT +/* + * This api is normally provided by dev_net.c + * This stub keeps libsa happy when LOADER_NET_SUPPORT + * is not enabled. + */ +bool +is_tftp(void) +{ + return false; +} +#endif diff --git a/stand/common/modinfo.c b/stand/common/modinfo.c index 313469d32f35..1e39bd858cc2 100644 --- a/stand/common/modinfo.c +++ b/stand/common/modinfo.c @@ -172,6 +172,8 @@ md_copyenv(vm_offset_t start) /* Traverse the environment. */ for (ep = environ; ep != NULL; ep = ep->ev_next) { + if ((ep->ev_flags & EV_NOKENV) != 0) + continue; len = strlen(ep->ev_name); if ((size_t)archsw.arch_copyin(ep->ev_name, addr, len) != len) break; |