1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
|
/* ----------------------------------------------------------------------- *
*
* Copyright 2009 Erwan Velu - All Rights Reserved
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or
* sell copies of the Software, and to permit persons to whom
* the Software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall
* be included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
* -----------------------------------------------------------------------
*/
#include "hdt-menu.h"
/* Submenu for the vesa card */
static void compute_vesa_card(struct s_my_menu *menu,
struct s_hardware *hardware)
{
char buffer[SUBMENULEN + 1];
char statbuffer[STATLEN + 1];
menu->menu = add_menu(" VESA Bios ", -1);
menu->items_count = 0;
set_menu_pos(SUBMENU_Y, SUBMENU_X);
snprintf(buffer, sizeof buffer, "VESA Version: %d.%d",
hardware->vesa.major_version, hardware->vesa.minor_version);
snprintf(statbuffer, sizeof statbuffer, "Version: %d.%d",
hardware->vesa.major_version, hardware->vesa.minor_version);
add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
menu->items_count++;
snprintf(buffer, sizeof buffer, "Vendor : %s", hardware->vesa.vendor);
snprintf(statbuffer, sizeof statbuffer, "Vendor Name: %s",
hardware->vesa.vendor);
add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
menu->items_count++;
snprintf(buffer, sizeof buffer, "Product : %s", hardware->vesa.product);
snprintf(statbuffer, sizeof statbuffer, "Product Name: %s",
hardware->vesa.product);
add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
menu->items_count++;
snprintf(buffer, sizeof buffer, "Product Rev.: %s",
hardware->vesa.product_revision);
snprintf(statbuffer, sizeof statbuffer, "Produt Revision: %s",
hardware->vesa.product_revision);
add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
menu->items_count++;
snprintf(buffer, sizeof buffer, "Software Rev: %d",
hardware->vesa.software_rev);
snprintf(statbuffer, sizeof statbuffer, "Software Revision: %d",
hardware->vesa.software_rev);
add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
menu->items_count++;
snprintf(buffer, sizeof buffer, "Memory (KB) : %d",
hardware->vesa.total_memory * 64);
snprintf(statbuffer, sizeof statbuffer, "Memory (KB): %d",
hardware->vesa.total_memory * 64);
add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
menu->items_count++;
}
/* Submenu for the vesa card */
void compute_vesa_modes(struct s_my_menu *menu, struct s_hardware *hardware)
{
char buffer[56];
char statbuffer[STATLEN];
menu->menu = add_menu(" VESA Modes ", -1);
menu->items_count = 0;
set_menu_pos(SUBMENU_Y, SUBMENU_X);
for (int i = 0; i < hardware->vesa.vmi_count; i++) {
struct vesa_mode_info *mi = &hardware->vesa.vmi[i].mi;
/* Sometimes, vesa bios reports 0x0 modes
* We don't need to display that ones */
if ((mi->h_res == 0) || (mi->v_res == 0))
continue;
snprintf(buffer, sizeof buffer, "%4u x %4u x %2ubits vga=%3d",
mi->h_res, mi->v_res, mi->bpp,
hardware->vesa.vmi[i].mode + 0x200);
snprintf(statbuffer, sizeof statbuffer, "%4ux%4ux%2ubits vga=%3d",
mi->h_res, mi->v_res, mi->bpp,
hardware->vesa.vmi[i].mode + 0x200);
add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
menu->items_count++;
}
}
/* Main VESA Menu*/
int compute_VESA(struct s_hdt_menu *hdt_menu, struct s_hardware *hardware)
{
char buffer[15];
compute_vesa_card(&hdt_menu->vesa_card_menu, hardware);
compute_vesa_modes(&hdt_menu->vesa_modes_menu, hardware);
hdt_menu->vesa_menu.menu = add_menu(" VESA ", -1);
hdt_menu->vesa_menu.items_count = 0;
add_item("VESA Bios", "VESA Bios", OPT_SUBMENU, NULL,
hdt_menu->vesa_card_menu.menu);
hdt_menu->vesa_menu.items_count++;
snprintf(buffer, sizeof buffer, "%s (%d)", "Modes",
hardware->vesa.vmi_count);
add_item(buffer, "VESA Modes", OPT_SUBMENU, NULL,
hdt_menu->vesa_modes_menu.menu);
hdt_menu->vesa_menu.items_count++;
printf("MENU: VESA menu done (%d items)\n",
hdt_menu->vesa_menu.items_count);
return 0;
}
|