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
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 * -----------------------------------------------------------------------
31 /* Main Kernel menu */
32 void compute_kernel(struct s_my_menu *menu, struct s_hardware *hardware)
34 char buffer[SUBMENULEN + 1];
35 char infobar[STATLEN + 1];
36 char kernel_modules[LINUX_KERNEL_MODULE_SIZE *
37 MAX_KERNEL_MODULES_PER_PCI_DEVICE];
38 struct pci_device *pci_device;
40 menu->menu = add_menu(" Kernel Modules ", -1);
41 menu->items_count = 0;
42 set_menu_pos(SUBMENU_Y, SUBMENU_X);
44 if (hardware->modules_pcimap_return_code == -ENOMODULESPCIMAP) {
45 add_item("The modules.pcimap file is missing",
46 "Missing modules.pcimap file", OPT_INACTIVE, NULL, 0);
47 add_item("Kernel modules can't be computed.",
48 "Missing modules.pcimap file", OPT_INACTIVE, NULL, 0);
49 add_item("Please put one in same dir as hdt",
50 "Missing modules.pcimap file", OPT_INACTIVE, NULL, 0);
51 add_item("", "", OPT_SEP, "", 0);
54 * For every detected pci device, grab its kernel module to
55 * compute this submenu
57 for_each_pci_func(pci_device, hardware->pci_domain) {
58 memset(kernel_modules, 0, sizeof kernel_modules);
61 pci_device->dev_info->linux_kernel_module_count;
64 strncat(kernel_modules, " | ", 3);
66 strncat(kernel_modules,
67 pci_device->dev_info->
68 linux_kernel_module[i],
69 LINUX_KERNEL_MODULE_SIZE - 1);
71 /* No need to add unknown kernel modules */
72 if (strlen(kernel_modules) > 0) {
73 snprintf(buffer, sizeof buffer, "%s (%s)",
75 pci_device->dev_info->class_name);
76 snprintf(infobar, sizeof infobar,
77 "%04x:%04x %s : %s\n",
80 pci_device->dev_info->vendor_name,
81 pci_device->dev_info->product_name);
83 add_item(buffer, infobar, OPT_INACTIVE, NULL,
90 printf("MENU: Kernel menu done (%d items)\n", menu->items_count);