hdt: fix conflict
[profile/ivi/syslinux.git] / com32 / hdt / hdt-menu-kernel.c
1 /* ----------------------------------------------------------------------- *
2  *
3  *   Copyright 2009 Erwan Velu - All Rights Reserved
4  *
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:
13  *
14  *   The above copyright notice and this permission notice shall
15  *   be included in all copies or substantial portions of the Software.
16  *
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.
25  *
26  * -----------------------------------------------------------------------
27  */
28
29 #include "hdt-menu.h"
30
31 /* Main Kernel menu */
32 void compute_kernel(struct s_my_menu *menu, struct s_hardware *hardware)
33 {
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;
39
40   menu->menu = add_menu(" Kernel Modules ", -1);
41   menu->items_count = 0;
42   set_menu_pos(SUBMENU_Y, SUBMENU_X);
43
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);
52   } else {
53     /*
54      * For every detected pci device, grab its kernel module to
55      * compute this submenu
56      */
57     for_each_pci_func(pci_device, hardware->pci_domain) {
58       memset(kernel_modules, 0, sizeof kernel_modules);
59       for (int i = 0;
60            i <
61            pci_device->dev_info->linux_kernel_module_count;
62            i++) {
63         if (i > 0) {
64           strncat(kernel_modules, " | ", 3);
65         }
66         strncat(kernel_modules,
67           pci_device->dev_info->
68           linux_kernel_module[i],
69           LINUX_KERNEL_MODULE_SIZE - 1);
70       }
71       /* No need to add unknown kernel modules */
72       if (strlen(kernel_modules) > 0) {
73         snprintf(buffer, sizeof buffer, "%s (%s)",
74            kernel_modules,
75            pci_device->dev_info->class_name);
76         snprintf(infobar, sizeof infobar,
77            "%04x:%04x %s : %s\n",
78            pci_device->vendor,
79            pci_device->product,
80            pci_device->dev_info->vendor_name,
81            pci_device->dev_info->product_name);
82
83         add_item(buffer, infobar, OPT_INACTIVE, NULL,
84            0);
85         menu->items_count++;
86       }
87     }
88   }
89
90   printf("MENU: Kernel menu done (%d items)\n", menu->items_count);
91 }