From nobody Fri Aug 22 03:48:55 2025 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4c7R4m2R4Tz64wc1; Fri, 22 Aug 2025 03:48:56 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R12" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4c7R4m0bNZz3bwl; Fri, 22 Aug 2025 03:48:56 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1755834536; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=8G4ph7UOUNHVTD359n87NuAdEoUvzYroAGl4mokCr5Q=; b=Y/fWu7AlqcO02fETZxkthlH5OTPch2GgvpzEvn5rTrh7b0E+auIAyipYN9cg41s8W2B5xQ BcChTpYzG4AOLpMQOovjzuua5Bw2YG0JTlwoSQp0VwRm1rclG0Z2q+6cbI0uLYiqHMMT3m DhHYxNCjP7XVtU1feWAIS7CAhdzX4BUizteIRF//gYa4ZqAFCgZoEkU3EeKmgohC/n73ia perMlBlBj0QX1rLW7lKF2cXXioJ8IpQ37GuikRK9upHvguTY2WJViSbN9utibNAA1z4y6n RtHTKh0LVb7+Z7Vpso8+YNN+u2s44vfhP1HFU4Me1+gFqoBAHJuKF4r3TBKpvw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1755834536; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=8G4ph7UOUNHVTD359n87NuAdEoUvzYroAGl4mokCr5Q=; b=ZE+TFyqbhkgNlFnnPFL0MmgNJfoFdoZ6y6MLxrm2nv9PRAFO1vH9IzfA/UepkgbBD0WPaM 7oh1nQaz3rUxJtpomvja9Cz+hY+PJ3RNJyv2JKnDIR8/1nD4dUVbkR+vSMZ8JyFemSdlLl C/VjkFa5HoYwapt5s0JBPILFxAPKdqA6m5E0pxec9kXMhpjZD9x7wvnBQASoYBZg7vUWhA gbPL8neG/AfNDp3266yYsjmvsbsLMfxwnmMHNAmnydHsPHPBw1QDj+SQSeCmC4QjWU25S5 bVfPzU8zQjmNAWc9fow70qzAQVVikOBm1sDzkmsSJPTqU41PvhIdjf4zHUpOzw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1755834536; a=rsa-sha256; cv=none; b=Lq/ufBBKzSTqDHoQDV4n3aL2DS+FKBAnUXirvPkUpJ+RjLwhoXgyWpH1cSvne7EVnL+S3L x5p9hv1ZQ02uq1CYF0xGs0/BnV2WI5kUvNzI5vC4KEppGO40qyIfhgsG1mtiNL7bxmxzqW A2ixMmizIcPE6Mncq3LBRjrHC4vHBdOQ2d5KRImZgPVUewvjGr10+/cKDWemfyY7nr4Tjq W0/d63DqHqqKIHxFzi01Dp8zlK+hJg++z3zubXcQi/86uNRN/oQsu3KQtq+fuByvKUZziT RYQZ5rVn49Uq359nDkYCbgF2wR1d6cjBrQwpnyqRdcfokH6a6YGjsoi2V/HoWg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4c7R4m0BdCzDJ2; Fri, 22 Aug 2025 03:48:56 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 57M3mt6E001027; Fri, 22 Aug 2025 03:48:55 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 57M3mtev001024; Fri, 22 Aug 2025 03:48:55 GMT (envelope-from git) Date: Fri, 22 Aug 2025 03:48:55 GMT Message-Id: <202508220348.57M3mtev001024@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Kyle Evans Subject: git: c43de099d013 - main - stand: use a common function in gfx_fb for setting up teken colors List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kevans X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: c43de099d0138b369b705b3af2c3254d3f3afc6e Auto-Submitted: auto-generated The branch main has been updated by kevans: URL: https://cgit.FreeBSD.org/src/commit/?id=c43de099d0138b369b705b3af2c3254d3f3afc6e commit c43de099d0138b369b705b3af2c3254d3f3afc6e Author: Kyle Evans AuthorDate: 2025-08-22 03:48:14 +0000 Commit: Kyle Evans CommitDate: 2025-08-22 03:48:28 +0000 stand: use a common function in gfx_fb for setting up teken colors These are basically identical, with exception to the hook installed which is specific to the loader we're building by necessity. Pull these out into common/gfx_fb.c and just parameterize the hooks to make it easier to change the logic. Reviewed by: imp Differential Revision: https://reviews.freebsd.org/D50886 --- stand/common/gfx_fb.c | 31 +++++++++++++++++++++++++++++++ stand/common/gfx_fb.h | 1 + stand/efi/libefi/efi_console.c | 23 +---------------------- stand/i386/libi386/vidconsole.c | 21 +-------------------- 4 files changed, 34 insertions(+), 42 deletions(-) diff --git a/stand/common/gfx_fb.c b/stand/common/gfx_fb.c index af72ab1a4c99..1d2f22649955 100644 --- a/stand/common/gfx_fb.c +++ b/stand/common/gfx_fb.c @@ -232,6 +232,37 @@ gfx_parse_mode_str(char *str, int *x, int *y, int *depth) return (true); } +void +gfx_fb_setcolors(teken_attr_t *attr, ev_sethook_t sethook, + ev_unsethook_t unsethook) +{ + const char *ptr; + char env[10]; + + /* + * 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. + */ + ptr = getenv("teken.fg_color"); + if (ptr != NULL) { + attr->ta_fgcolor = strtol(ptr, NULL, 10); + ptr = getenv("teken.bg_color"); + attr->ta_bgcolor = strtol(ptr, NULL, 10); + + teken_set_defattr(&gfx_state.tg_teken, attr); + } else { + snprintf(env, sizeof(env), "%d", + attr->ta_fgcolor); + env_setenv("teken.fg_color", EV_VOLATILE, env, + sethook, unsethook); + snprintf(env, sizeof(env), "%d", + attr->ta_bgcolor); + env_setenv("teken.bg_color", EV_VOLATILE, env, + sethook, unsethook); + } +} + 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/efi/libefi/efi_console.c b/stand/efi/libefi/efi_console.c index cbb4dd01d1fb..46a3c957f151 100644 --- a/stand/efi/libefi/efi_console.c +++ b/stand/efi/libefi/efi_console.c @@ -1041,28 +1041,7 @@ cons_update_mode(bool use_gfx_mode) a = teken_get_defattr(&gfx_state.tg_teken); attr = *a; - /* - * On first run, we set up the efi_set_colors() - * callback. If the env is already set, we - * pick up fg and bg color values from the environment. - */ - ptr = getenv("teken.fg_color"); - if (ptr != NULL) { - attr.ta_fgcolor = strtol(ptr, NULL, 10); - ptr = getenv("teken.bg_color"); - attr.ta_bgcolor = strtol(ptr, NULL, 10); - - teken_set_defattr(&gfx_state.tg_teken, &attr); - } else { - snprintf(env, sizeof(env), "%d", - attr.ta_fgcolor); - env_setenv("teken.fg_color", EV_VOLATILE, env, - efi_set_colors, env_nounset); - snprintf(env, sizeof(env), "%d", - attr.ta_bgcolor); - env_setenv("teken.bg_color", EV_VOLATILE, env, - efi_set_colors, env_nounset); - } + gfx_fb_setcolors(&attr, efi_set_colors, env_nounset); } } diff --git a/stand/i386/libi386/vidconsole.c b/stand/i386/libi386/vidconsole.c index 414803e9af3d..3938bd7822ea 100644 --- a/stand/i386/libi386/vidconsole.c +++ b/stand/i386/libi386/vidconsole.c @@ -956,26 +956,7 @@ cons_update_mode(bool use_gfx_mode) a = teken_get_defattr(&gfx_state.tg_teken); attr = *a; - /* - * On first run, we set up the vidc_set_colors() - * callback. If the env is already set, we - * pick up fg and bg color values from the environment. - */ - ptr = getenv("teken.fg_color"); - if (ptr != NULL) { - attr.ta_fgcolor = strtol(ptr, NULL, 10); - ptr = getenv("teken.bg_color"); - attr.ta_bgcolor = strtol(ptr, NULL, 10); - - teken_set_defattr(&gfx_state.tg_teken, &attr); - } else { - snprintf(env, sizeof(env), "%d", attr.ta_fgcolor); - env_setenv("teken.fg_color", EV_VOLATILE, env, - vidc_set_colors, env_nounset); - snprintf(env, sizeof(env), "%d", attr.ta_bgcolor); - env_setenv("teken.bg_color", EV_VOLATILE, env, - vidc_set_colors, env_nounset); - } + gfx_fb_setcolors(&attr, vidc_set_colors, env_nounset); /* Improve visibility */ if (attr.ta_bgcolor == TC_WHITE)