Date: Fri, 2 Feb 2024 21:04:55 GMT From: Warner Losh <imp@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Subject: git: 18968b8274b5 - main - loader: Move build_font_module to gfx_fb.c Message-ID: <202402022104.412L4thx056397@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=18968b8274b56d8b60ab4e0d606e7f53f3a02014 commit 18968b8274b56d8b60ab4e0d606e7f53f3a02014 Author: Warner Losh <imp@FreeBSD.org> AuthorDate: 2024-02-02 01:38:18 +0000 Commit: Warner Losh <imp@FreeBSD.org> 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 <teken.h> #include <gfx_fb.h> #include <sys/font.h> +#include <sys/linker.h> +#include <sys/module.h> #include <sys/stdint.h> #include <sys/endian.h> #include <pnglite.h> @@ -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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202402022104.412L4thx056397>