From nobody Fri Feb 2 21:04:55 2024 X-Original-To: dev-commits-src-all@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 4TRSvr221Wz58GDP; Fri, 2 Feb 2024 21:04: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 "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4TRSvq72cmz548v; Fri, 2 Feb 2024 21:04:55 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1706907896; 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=YIE9/kyOq8gXjth3lb+G429KGajY+YrDi0UkbjgqlJU=; b=gLucwhPObJYfm5BemNR3fFA6hMJW1izLY87dLn2jVrQWcSMjLo7T4dzlPRGJzj9J6MW5+S UmvCCf3ECyAmp3+ZISbvXX+5iby1aTgIAbx+yjNLbEK/B6fXKcb+P+rsbn27NE5LmnoLvJ M+G8gjJjDD33MwnOA1oUPSNaU8Vzxb6lWBUc4sKpBzOAeHnCHAcq71lM5VdgoOk80a6vVV YfEqZFyeeQA7u17SNnkvoOOCpQZiPzeKbdhX2BB6kIITes4Paz5ZA8NJZYxuGSBMR+GuIR trzgDm6vDu8s0gBsGoBLvBA8lZinyxQHcRR/JwdjdWBfSSIaUxr3nAvUorsS3Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1706907896; 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=YIE9/kyOq8gXjth3lb+G429KGajY+YrDi0UkbjgqlJU=; b=AeUfebr89XYihPLksBu+gskhHVUpUCAdRQEMaGgMHiJfphGohrrjIy1dha1/5PyzXO0cyq S2Bw0Vpt+tKhP4VYAXyKJ7qLHQjCIwsGDDSBFUc09H3fDnWEGomWpudGqMSC6Dh8Y/81dN qUNCy2SpPNfUgP0bBEct3TnM7h+sS/aDYUMSPQbkc/0k713lp0zQSFUdX2+5uXjg51quCd emzTtiRylC6Yd/haHoKB/lJgy5Hc6gt9z/0dg/Dd54vG6EgSrisIXat0DXawC8AMDYWfZq lm2NxxBb87AY4rRfUzbNT0oweYFWOtJtLJfwn4R8W0JAgANE566a4MhyJjsfHQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1706907896; a=rsa-sha256; cv=none; b=D3yzQMw7sEqfqbkmMgPrfepDfBvZjJQ7nanpDSbgdjdGDfwoKldXPvO1a9bSw0F3cBkTVC kUlqUpBIi3ATreylKb6PF4PER7KTdNoFxmdGZ7gLRfiQvn3lgw4IyJ4uGgYlGAjI7MBRrM +yUXnIiPCTIkEtnSAn2cVNXqRpkh3xAHgcizosIoGNv2qCIQHX8vXklv8MsHtC49Vx892l h/Mm+gHHI2XoMR4FfiAS6CJ5C/KgLHluViBH6tjMW/steg63basw3j7H0IOnE22OJF9Tnh eKxb8gyMSRGzHsqiAfmBUjV1xI/PWJhXedr+ezytpa0iePooob/t7Go8OvJI+A== 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 4TRSvq5m8szlsg; Fri, 2 Feb 2024 21:04:55 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 412L4t3Y056400; Fri, 2 Feb 2024 21:04:55 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 412L4thx056397; Fri, 2 Feb 2024 21:04:55 GMT (envelope-from git) Date: Fri, 2 Feb 2024 21:04:55 GMT Message-Id: <202402022104.412L4thx056397@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Warner Losh Subject: git: 18968b8274b5 - main - loader: Move build_font_module to gfx_fb.c List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: imp X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 18968b8274b56d8b60ab4e0d606e7f53f3a02014 Auto-Submitted: auto-generated The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=18968b8274b56d8b60ab4e0d606e7f53f3a02014 commit 18968b8274b56d8b60ab4e0d606e7f53f3a02014 Author: Warner Losh AuthorDate: 2024-02-02 01:38:18 +0000 Commit: Warner Losh CommitDate: 2024-02-02 21:01:04 +0000 loader: Move build_font_module to gfx_fb.c The font module is part and parsel of the gfx_fb support. Move it to gfx_fb.c where it can access the data it needs. Sponsored by: Netflix --- stand/common/gfx_fb.c | 89 +++++++++++++++++++++++++++++++++++++++++++++++++++ stand/common/module.c | 87 ------------------------------------------------- 2 files changed, 89 insertions(+), 87 deletions(-) diff --git a/stand/common/gfx_fb.c b/stand/common/gfx_fb.c index c10d227a5fc8..b61591bf3d45 100644 --- a/stand/common/gfx_fb.c +++ b/stand/common/gfx_fb.c @@ -87,6 +87,8 @@ #include #include #include +#include +#include #include #include #include @@ -2917,3 +2919,90 @@ gfx_get_edid_resolution(struct vesa_edid_info *edid, edid_res_list_t *res) } return (!TAILQ_EMPTY(res)); } + +vm_offset_t +build_font_module(vm_offset_t addr) +{ + vt_font_bitmap_data_t *bd; + struct vt_font *fd; + struct preloaded_file *fp; + size_t size; + uint32_t checksum; + int i; + struct font_info fi; + struct fontlist *fl; + uint64_t fontp; + + if (STAILQ_EMPTY(&fonts)) + return (addr); + + /* We can't load first */ + if ((file_findfile(NULL, NULL)) == NULL) { + printf("Can not load font module: %s\n", + "the kernel is not loaded"); + return (addr); + } + + /* helper pointers */ + bd = NULL; + STAILQ_FOREACH(fl, &fonts, font_next) { + if (gfx_state.tg_font.vf_width == fl->font_data->vfbd_width && + gfx_state.tg_font.vf_height == fl->font_data->vfbd_height) { + /* + * Kernel does have better built in font. + */ + if (fl->font_flags == FONT_BUILTIN) + return (addr); + + bd = fl->font_data; + break; + } + } + if (bd == NULL) + return (addr); + fd = bd->vfbd_font; + + fi.fi_width = fd->vf_width; + checksum = fi.fi_width; + fi.fi_height = fd->vf_height; + checksum += fi.fi_height; + fi.fi_bitmap_size = bd->vfbd_uncompressed_size; + checksum += fi.fi_bitmap_size; + + size = roundup2(sizeof (struct font_info), 8); + for (i = 0; i < VFNT_MAPS; i++) { + fi.fi_map_count[i] = fd->vf_map_count[i]; + checksum += fi.fi_map_count[i]; + size += fd->vf_map_count[i] * sizeof (struct vfnt_map); + size += roundup2(size, 8); + } + size += bd->vfbd_uncompressed_size; + + fi.fi_checksum = -checksum; + + fp = file_findfile(NULL, "elf kernel"); + if (fp == NULL) + fp = file_findfile(NULL, "elf64 kernel"); + if (fp == NULL) + panic("can't find kernel file"); + + fontp = addr; + addr += archsw.arch_copyin(&fi, addr, sizeof (struct font_info)); + addr = roundup2(addr, 8); + + /* Copy maps. */ + for (i = 0; i < VFNT_MAPS; i++) { + if (fd->vf_map_count[i] != 0) { + addr += archsw.arch_copyin(fd->vf_map[i], addr, + fd->vf_map_count[i] * sizeof (struct vfnt_map)); + addr = roundup2(addr, 8); + } + } + + /* Copy the bitmap. */ + addr += archsw.arch_copyin(fd->vf_bytes, addr, fi.fi_bitmap_size); + + /* Looks OK so far; populate control structure */ + file_addmetadata(fp, MODINFOMD_FONT, sizeof(fontp), &fontp); + return (addr); +} diff --git a/stand/common/module.c b/stand/common/module.c index 289d174733da..ac0ad466484a 100644 --- a/stand/common/module.c +++ b/stand/common/module.c @@ -640,93 +640,6 @@ file_load_dependencies(struct preloaded_file *base_file) return (error); } -vm_offset_t -build_font_module(vm_offset_t addr) -{ - vt_font_bitmap_data_t *bd; - struct vt_font *fd; - struct preloaded_file *fp; - size_t size; - uint32_t checksum; - int i; - struct font_info fi; - struct fontlist *fl; - uint64_t fontp; - - if (STAILQ_EMPTY(&fonts)) - return (addr); - - /* We can't load first */ - if ((file_findfile(NULL, NULL)) == NULL) { - printf("Can not load font module: %s\n", - "the kernel is not loaded"); - return (addr); - } - - /* helper pointers */ - bd = NULL; - STAILQ_FOREACH(fl, &fonts, font_next) { - if (gfx_state.tg_font.vf_width == fl->font_data->vfbd_width && - gfx_state.tg_font.vf_height == fl->font_data->vfbd_height) { - /* - * Kernel does have better built in font. - */ - if (fl->font_flags == FONT_BUILTIN) - return (addr); - - bd = fl->font_data; - break; - } - } - if (bd == NULL) - return (addr); - fd = bd->vfbd_font; - - fi.fi_width = fd->vf_width; - checksum = fi.fi_width; - fi.fi_height = fd->vf_height; - checksum += fi.fi_height; - fi.fi_bitmap_size = bd->vfbd_uncompressed_size; - checksum += fi.fi_bitmap_size; - - size = roundup2(sizeof (struct font_info), 8); - for (i = 0; i < VFNT_MAPS; i++) { - fi.fi_map_count[i] = fd->vf_map_count[i]; - checksum += fi.fi_map_count[i]; - size += fd->vf_map_count[i] * sizeof (struct vfnt_map); - size += roundup2(size, 8); - } - size += bd->vfbd_uncompressed_size; - - fi.fi_checksum = -checksum; - - fp = file_findfile(NULL, "elf kernel"); - if (fp == NULL) - fp = file_findfile(NULL, "elf64 kernel"); - if (fp == NULL) - panic("can't find kernel file"); - - fontp = addr; - addr += archsw.arch_copyin(&fi, addr, sizeof (struct font_info)); - addr = roundup2(addr, 8); - - /* Copy maps. */ - for (i = 0; i < VFNT_MAPS; i++) { - if (fd->vf_map_count[i] != 0) { - addr += archsw.arch_copyin(fd->vf_map[i], addr, - fd->vf_map_count[i] * sizeof (struct vfnt_map)); - addr = roundup2(addr, 8); - } - } - - /* Copy the bitmap. */ - addr += archsw.arch_copyin(fd->vf_bytes, addr, fi.fi_bitmap_size); - - /* Looks OK so far; populate control structure */ - file_addmetadata(fp, MODINFOMD_FONT, sizeof(fontp), &fontp); - return (addr); -} - #ifdef LOADER_VERIEXEC_VECTX #define VECTX_HANDLE(fd) vctx #else