Adding upstream version 6.02~pre8+dfsg.
[syslinux-debian/hramrach.git] / com32 / hdt / hdt-cli-vesa.c
blobca44987afb77952532c587bf8cd698f0325970b8
1 /* ----------------------------------------------------------------------- *
3 * Copyright 2009 Erwan Velu - All Rights Reserved
5 * Permission is hereby granted, free of charge, to any person
6 * obtaining a copy of this software and associated documentation
7 * files (the "Software"), to deal in the Software without
8 * restriction, including without limitation the rights to use,
9 * copy, modify, merge, publish, distribute, sublicense, and/or
10 * sell copies of the Software, and to permit persons to whom
11 * the Software is furnished to do so, subject to the following
12 * conditions:
14 * The above copyright notice and this permission notice shall
15 * be included in all copies or substantial portions of the Software.
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
19 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
21 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
22 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
24 * OTHER DEALINGS IN THE SOFTWARE.
26 * -----------------------------------------------------------------------
29 #include "hdt-cli.h"
30 #include "hdt-common.h"
31 #include <stdio.h>
32 #include <string.h>
33 #include <stdlib.h>
34 #include <errno.h>
36 void main_show_vesa(int argc __unused, char **argv __unused,
37 struct s_hardware *hardware)
39 reset_more_printf();
40 if (hardware->is_vesa_valid == false) {
41 more_printf("No VESA BIOS detected\n");
42 return;
44 more_printf("VESA\n");
45 more_printf(" Vesa version : %d.%d\n", hardware->vesa.major_version,
46 hardware->vesa.minor_version);
47 more_printf(" Vendor : %s\n", hardware->vesa.vendor);
48 more_printf(" Product : %s\n", hardware->vesa.product);
49 more_printf(" Product rev. : %s\n", hardware->vesa.product_revision);
50 more_printf(" Software rev.: %d\n", hardware->vesa.software_rev);
51 more_printf(" Memory (KB) : %d\n", hardware->vesa.total_memory * 64);
52 more_printf(" Modes : %d\n", hardware->vesa.vmi_count);
55 static void show_vesa_modes(int argc __unused, char **argv __unused,
56 struct s_hardware *hardware)
58 reset_more_printf();
59 if (hardware->is_vesa_valid == false) {
60 more_printf("No VESA BIOS detected\n");
61 return;
63 more_printf(" ResH. x ResV x Bits : vga= : Vesa Mode\n");
64 more_printf("----------------------------------------\n");
66 for (int i = 0; i < hardware->vesa.vmi_count; i++) {
67 struct vesa_mode_info *mi = &hardware->vesa.vmi[i].mi;
69 * Sometimes, vesa bios reports 0x0 modes.
70 * We don't need to display that ones.
72 if ((mi->h_res == 0) || (mi->v_res == 0))
73 continue;
74 more_printf("%5u %5u %3u %3d 0x%04x\n",
75 mi->h_res, mi->v_res, mi->bpp,
76 hardware->vesa.vmi[i].mode + 0x200,
77 hardware->vesa.vmi[i].mode);
81 static void enable_vesa(int argc __unused, char **argv __unused,
82 struct s_hardware *hardware)
84 vesamode = true;
85 max_console_lines = MAX_VESA_CLI_LINES;
86 init_console(hardware);
89 static void disable_vesa(int argc __unused, char **argv __unused,
90 struct s_hardware *hardware)
92 vesamode = false;
93 max_console_lines = MAX_CLI_LINES;
94 init_console(hardware);
97 struct cli_callback_descr list_vesa_show_modules[] = {
99 .name = CLI_MODES,
100 .exec = show_vesa_modes,
101 .nomodule=false,
104 .name = NULL,
105 .exec = NULL,
106 .nomodule=false,
110 struct cli_callback_descr list_vesa_commands[] = {
112 .name = CLI_ENABLE,
113 .exec = enable_vesa,
114 .nomodule=false,
117 .name = CLI_DISABLE,
118 .exec = disable_vesa,
119 .nomodule=false,
123 .name = NULL,
124 .exec = NULL,
125 .nomodule=false,
129 struct cli_module_descr vesa_show_modules = {
130 .modules = list_vesa_show_modules,
131 .default_callback = main_show_vesa,
134 struct cli_module_descr vesa_commands = {
135 .modules = list_vesa_commands,
136 .default_callback = enable_vesa,
139 struct cli_mode_descr vesa_mode = {
140 .mode = VESA_MODE,
141 .name = CLI_VESA,
142 .default_modules = &vesa_commands,
143 .show_modules = &vesa_show_modules,
144 .set_modules = NULL,