Changeset View
Changeset View
Standalone View
Standalone View
usr.sbin/vidcontrol/vidcontrol.c
Show First 20 Lines • Show All 77 Lines • ▼ Show 20 Lines | |||||
static struct { | static struct { | ||||
int active_vty; | int active_vty; | ||||
vid_info_t console_info; | vid_info_t console_info; | ||||
unsigned char screen_map[256]; | unsigned char screen_map[256]; | ||||
int video_mode_number; | int video_mode_number; | ||||
struct video_info video_mode_info; | struct video_info video_mode_info; | ||||
} cur_info; | } cur_info; | ||||
struct vt4font_header { | |||||
uint8_t magic[8]; | |||||
uint8_t width; | |||||
uint8_t height; | |||||
uint16_t pad; | |||||
uint32_t glyph_count; | |||||
uint32_t map_count[4]; | |||||
} __packed; | |||||
static int hex = 0; | static int hex = 0; | ||||
static int vesa_cols; | static int vesa_cols; | ||||
static int vesa_rows; | static int vesa_rows; | ||||
static int font_height; | static int font_height; | ||||
static int vt4_mode = 0; | static int vt4_mode = 0; | ||||
static int video_mode_changed; | static int video_mode_changed; | ||||
static struct video_info new_mode_info; | static struct video_info new_mode_info; | ||||
▲ Show 20 Lines • Show All 296 Lines • ▼ Show 20 Lines | load_vt4mappingtable(unsigned int nmappings, FILE *f) | ||||
if (fread(t, sizeof *t * nmappings, 1, f) != 1) { | if (fread(t, sizeof *t * nmappings, 1, f) != 1) { | ||||
warn("read mappings"); | warn("read mappings"); | ||||
free(t); | free(t); | ||||
return (NULL); | return (NULL); | ||||
} | } | ||||
for (i = 0; i < nmappings; i++) { | for (i = 0; i < nmappings; i++) { | ||||
t[i].src = be32toh(t[i].src); | t[i].vfm_src = be32toh(t[i].vfm_src); | ||||
t[i].dst = be16toh(t[i].dst); | t[i].vfm_dst = be16toh(t[i].vfm_dst); | ||||
t[i].len = be16toh(t[i].len); | t[i].vfm_len = be16toh(t[i].vfm_len); | ||||
} | } | ||||
return (t); | return (t); | ||||
} | } | ||||
/* | /* | ||||
* Set the default vt font. | * Set the default vt font. | ||||
*/ | */ | ||||
static void | static void | ||||
load_default_vt4font(void) | load_default_vt4font(void) | ||||
{ | { | ||||
if (ioctl(0, PIO_VFONT_DEFAULT) == -1) { | if (ioctl(0, PIO_VFONT_DEFAULT) == -1) { | ||||
revert(); | revert(); | ||||
err(1, "loading default vt font"); | err(1, "loading default vt font"); | ||||
} | } | ||||
} | } | ||||
static void | static void | ||||
load_vt4font(FILE *f) | load_vt4font(FILE *f) | ||||
{ | { | ||||
struct vt4font_header fh; | struct font_header fh; | ||||
static vfnt_t vfnt; | static vfnt_t vfnt; | ||||
size_t glyphsize; | size_t glyphsize; | ||||
unsigned int i; | unsigned int i; | ||||
if (fread(&fh, sizeof fh, 1, f) != 1) { | if (fread(&fh, sizeof fh, 1, f) != 1) { | ||||
warn("read file_header"); | warn("read file_header"); | ||||
return; | return; | ||||
} | } | ||||
if (memcmp(fh.magic, "VFNT0002", 8) != 0) { | if (memcmp(fh.fh_magic, "VFNT0002", 8) != 0) { | ||||
warnx("bad magic in font file\n"); | warnx("bad magic in font file\n"); | ||||
return; | return; | ||||
} | } | ||||
for (i = 0; i < VFNT_MAPS; i++) | for (i = 0; i < VFNT_MAPS; i++) | ||||
vfnt.map_count[i] = be32toh(fh.map_count[i]); | vfnt.map_count[i] = be32toh(fh.fh_map_count[i]); | ||||
vfnt.glyph_count = be32toh(fh.glyph_count); | vfnt.glyph_count = be32toh(fh.fh_glyph_count); | ||||
vfnt.width = fh.width; | vfnt.width = fh.fh_width; | ||||
vfnt.height = fh.height; | vfnt.height = fh.fh_height; | ||||
glyphsize = howmany(vfnt.width, 8) * vfnt.height * vfnt.glyph_count; | glyphsize = howmany(vfnt.width, 8) * vfnt.height * vfnt.glyph_count; | ||||
if ((vfnt.glyphs = malloc(glyphsize)) == NULL) { | if ((vfnt.glyphs = malloc(glyphsize)) == NULL) { | ||||
warn("malloc"); | warn("malloc"); | ||||
return; | return; | ||||
} | } | ||||
if (fread(vfnt.glyphs, glyphsize, 1, f) != 1) { | if (fread(vfnt.glyphs, glyphsize, 1, f) != 1) { | ||||
▲ Show 20 Lines • Show All 1,123 Lines • Show Last 20 Lines |