Unleashed v1.4
[unleashed.git] / usr / src / boot / sys / sys / font.h
blob4ff7160b52e8e7f0427ad1240f68fc10a9c44d2b
1 /*
2 * CDDL HEADER START
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
19 * CDDL HEADER END
23 * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 #ifndef _SYS_FONT_H
28 #define _SYS_FONT_H
30 #include <sys/queue.h>
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
36 enum vfnt_map {
37 VFNT_MAP_NORMAL = 0, /* Normal font. */
38 VFNT_MAP_NORMAL_RH, /* Normal font right hand. */
39 VFNT_MAP_BOLD, /* Bold font. */
40 VFNT_MAP_BOLD_RH, /* Bold font right hand. */
41 VFNT_MAPS /* Number of maps. */
45 * If the custom console font was loaded, pass it for kernel as an module.
46 * We do not just load the font file, as the font file needs to be processed,
47 * and the early boot has very little resources. So we just set up the
48 * needed structures and make an copy of the byte arrays.
50 * Note we can not copy the structures one to one due to the pointer size,
51 * so we record the data by using fixed size structure.
53 struct font_info {
54 int32_t fi_checksum;
55 uint32_t fi_width;
56 uint32_t fi_height;
57 uint32_t fi_bitmap_size;
58 uint32_t fi_map_count[VFNT_MAPS];
61 struct font_map {
62 uint32_t font_src; /* Source glyph. */
63 uint16_t font_dst; /* Target glyph. */
64 uint16_t font_len; /* The number of glyphs in sequence. */
67 /* Any unknown glyph is mapped as first (offset 0) glyph in bitmap. */
68 struct font {
69 struct font_map *vf_map[VFNT_MAPS]; /* Mapping tables. */
70 uint8_t *vf_bytes; /* Font bitmap data. */
71 uint32_t vf_width; /* Glyph width. */
72 uint32_t vf_height; /* Glyph height. */
73 uint32_t vf_map_count[VFNT_MAPS]; /* Entries in map */
76 typedef struct bitmap_data {
77 uint32_t width;
78 uint32_t height;
79 uint32_t compressed_size;
80 uint32_t uncompressed_size;
81 uint8_t *compressed_data;
82 struct font *font;
83 } bitmap_data_t;
85 typedef enum {
86 FONT_AUTO,
87 FONT_MANUAL,
88 FONT_BOOT
89 } FONT_FLAGS;
91 struct fontlist {
92 char *font_name;
93 FONT_FLAGS font_flags;
94 bitmap_data_t *font_data;
95 bitmap_data_t *(*font_load)(char *);
96 STAILQ_ENTRY(fontlist) font_next;
99 #define FONT_HEADER_MAGIC "VFNT0002"
100 struct font_header {
101 uint8_t fh_magic[8];
102 uint8_t fh_width;
103 uint8_t fh_height;
104 uint16_t fh_pad;
105 uint32_t fh_glyph_count;
106 uint32_t fh_map_count[4];
107 } __attribute__((__packed__));
109 typedef STAILQ_HEAD(font_list, fontlist) font_list_t;
110 extern font_list_t fonts;
113 * Built in fonts. We are using Gallant as default on sparc to keep
114 * smooth transition from prom and 8x16 on x86, for vga text mode.
116 #ifdef sparc
117 #define DEFAULT_FONT_DATA font_data_12x22
118 extern bitmap_data_t font_data_12x22;
119 #else
120 #define DEFAULT_FONT_DATA font_data_8x16
121 extern bitmap_data_t font_data_8x16;
122 #endif
123 #define BORDER_PIXELS 10 /* space from screen border */
125 bitmap_data_t *set_font(short *, short *, short, short);
126 const uint8_t *font_lookup(const struct font *, uint32_t);
127 void font_bit_to_pix4(struct font *, uint8_t *, uint32_t, uint8_t, uint8_t);
128 void font_bit_to_pix8(struct font *, uint8_t *, uint32_t, uint8_t, uint8_t);
129 void font_bit_to_pix16(struct font *, uint16_t *, uint32_t, uint16_t, uint16_t);
130 void font_bit_to_pix24(struct font *, uint8_t *, uint32_t, uint32_t, uint32_t);
131 void font_bit_to_pix32(struct font *, uint32_t *, uint32_t, uint32_t, uint32_t);
133 #ifdef __cplusplus
135 #endif
137 #endif /* !_SYS_FONT_H */