diff options
Diffstat (limited to 'stand/common/gfx_fb.c')
-rw-r--r-- | stand/common/gfx_fb.c | 95 |
1 files changed, 91 insertions, 4 deletions
diff --git a/stand/common/gfx_fb.c b/stand/common/gfx_fb.c index b80e9c565944..0a88a166089b 100644 --- a/stand/common/gfx_fb.c +++ b/stand/common/gfx_fb.c @@ -25,8 +25,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * $FreeBSD$ */ /* @@ -84,12 +82,13 @@ * from VGA colors to console colors, while we are reading RGB data. */ -#include <sys/cdefs.h> #include <sys/param.h> #include <stand.h> #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> @@ -182,6 +181,7 @@ gfx_framework_init(void) * Setup font list to have builtin font. */ (void) insert_font(NULL, FONT_BUILTIN); + gfx_interp_ref(); /* Draw in the gfx interpreter for this thing */ } static uint8_t * @@ -1190,7 +1190,7 @@ gfx_fb_copy_line(teken_gfx_t *state, int ncol, teken_pos_t *s, teken_pos_t *d) screen_buffer[doffset + x] = screen_buffer[soffset + x]; if (mark) { /* update end point */ - sr.tr_end.tp_col = s->tp_col + x;; + sr.tr_end.tp_col = s->tp_col + x; } else { /* set up new rectangle */ mark = true; @@ -2920,3 +2920,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); +} |