[syslinux:master] hdt: Unique hardware detection path
syslinux-bot for Erwan Velu
erwan.velu at free.fr
Sun Feb 6 14:07:08 PST 2011
Commit-ID: a148c8cf7d6a6eaa586c67c99b5c1982bd3c6cfa
Gitweb: http://syslinux.zytor.com/commit/a148c8cf7d6a6eaa586c67c99b5c1982bd3c6cfa
Author: Erwan Velu <erwan.velu at free.fr>
AuthorDate: Mon, 7 Dec 2009 11:12:06 +0100
Committer: Erwan Velu <erwan.velu at free.fr>
CommitDate: Mon, 7 Dec 2009 11:12:06 +0100
hdt: Unique hardware detection path
Impact: Hardware detection path is simplified
Hardware is detected once, at boot time
---
com32/hdt/hdt-cli-acpi.c | 4 +--
com32/hdt/hdt-cli-cpu.c | 2 -
com32/hdt/hdt-cli-disk.c | 3 --
com32/hdt/hdt-cli-dmi.c | 8 ------
com32/hdt/hdt-cli-hdt.c | 4 ---
com32/hdt/hdt-cli-kernel.c | 3 --
com32/hdt/hdt-cli-pci.c | 27 ----------------------
com32/hdt/hdt-cli-pxe.c | 1 -
com32/hdt/hdt-cli-vesa.c | 2 -
com32/hdt/hdt-cli-vpd.c | 1 -
com32/hdt/hdt-cli.c | 10 --------
com32/hdt/hdt-cli.h | 1 -
com32/hdt/hdt-common.c | 52 +++++++++++++++++++++++++++++++++++++++---
com32/hdt/hdt-common.h | 1 +
com32/hdt/hdt-menu.c | 53 +++----------------------------------------
com32/hdt/hdt-menu.h | 1 -
com32/hdt/hdt.c | 3 ++
com32/hdt/hdt.h | 1 -
18 files changed, 57 insertions(+), 120 deletions(-)
diff --git a/com32/hdt/hdt-cli-acpi.c b/com32/hdt/hdt-cli-acpi.c
index 1241927..1e5b31a 100644
--- a/com32/hdt/hdt-cli-acpi.c
+++ b/com32/hdt/hdt-cli-acpi.c
@@ -65,7 +65,7 @@ void main_show_acpi(int argc __unused, char **argv __unused,
struct s_hardware *hardware)
{
reset_more_printf();
- detect_acpi(hardware);
+
if (hardware->is_acpi_valid == false) {
more_printf("No ACPI Tables detected\n");
return;
@@ -209,8 +209,6 @@ static void show_interrupt_source_override(s_madt * madt)
static void show_acpi_madt(int argc __unused, char **argv __unused,
struct s_hardware *hardware)
{
- detect_acpi(hardware);
-
if (hardware->is_acpi_valid == false) {
more_printf("No ACPI Tables detected\n");
return;
diff --git a/com32/hdt/hdt-cli-cpu.c b/com32/hdt/hdt-cli-cpu.c
index aa7ec8f..359669e 100644
--- a/com32/hdt/hdt-cli-cpu.c
+++ b/com32/hdt/hdt-cli-cpu.c
@@ -38,8 +38,6 @@ void main_show_cpu(int argc __unused, char **argv __unused,
struct s_hardware *hardware)
{
char features[81];
- cpu_detect(hardware);
- detect_dmi(hardware);
more_printf("CPU\n");
more_printf(" Manufacturer : %s \n", hardware->cpu.vendor);
more_printf(" Product : %s \n", hardware->cpu.model);
diff --git a/com32/hdt/hdt-cli-disk.c b/com32/hdt/hdt-cli-disk.c
index c43b7ca..24fce67 100644
--- a/com32/hdt/hdt-cli-disk.c
+++ b/com32/hdt/hdt-cli-disk.c
@@ -111,7 +111,6 @@ void main_show_disk(int argc, char **argv, struct s_hardware *hardware)
char disk_size[11];
char mbr_name[50];
- detect_disks(hardware);
reset_more_printf();
if (!hardware->disk_info[i].cbios) {
@@ -161,7 +160,6 @@ void main_show_disks(int argc __unused, char **argv __unused,
{
bool found = false;
reset_more_printf();
- detect_disks(hardware);
int first_one = 0;
for (int drive = 0x80; drive < 0xff; drive++) {
@@ -189,7 +187,6 @@ void disks_summary(int argc __unused, char **argv __unused,
int i = -1;
bool found = false;
- detect_disks(hardware);
reset_more_printf();
for (int drive = 0x80; drive < 0xff; drive++) {
diff --git a/com32/hdt/hdt-cli-dmi.c b/com32/hdt/hdt-cli-dmi.c
index 968308b..70033ba 100644
--- a/com32/hdt/hdt-cli-dmi.c
+++ b/com32/hdt/hdt-cli-dmi.c
@@ -493,8 +493,6 @@ void main_show_dmi(int argc __unused, char **argv __unused,
struct s_hardware *hardware)
{
- detect_dmi(hardware);
-
if (hardware->is_dmi_valid == false) {
more_printf("No valid DMI table found, exiting.\n");
return;
@@ -513,12 +511,6 @@ void show_dmi_memory_modules(int argc __unused, char **argv __unused,
/* Do we have so display unpopulated banks ? */
int show_free_banks = 1;
- /* Needed, if called by the memory mode */
- detect_dmi(hardware);
-
- /* Detecting installed memory */
- detect_memory(hardware);
-
more_printf("Memory Size : %lu MB (%lu KB)\n",
(hardware->detected_memory_size + (1 << 9)) >> 10,
hardware->detected_memory_size);
diff --git a/com32/hdt/hdt-cli-hdt.c b/com32/hdt/hdt-cli-hdt.c
index 51d31c3..47cef66 100644
--- a/com32/hdt/hdt-cli-hdt.c
+++ b/com32/hdt/hdt-cli-hdt.c
@@ -196,10 +196,6 @@ static void goto_menu(int argc __unused, char **argv __unused,
void main_show_summary(int argc __unused, char **argv __unused,
struct s_hardware *hardware)
{
- detect_pci(hardware); /* pxe is detected in the pci */
- detect_dmi(hardware);
- cpu_detect(hardware);
- detect_memory(hardware);
reset_more_printf();
clear_screen();
main_show_cpu(argc, argv, hardware);
diff --git a/com32/hdt/hdt-cli-kernel.c b/com32/hdt/hdt-cli-kernel.c
index d4946f3..aaa177e 100644
--- a/com32/hdt/hdt-cli-kernel.c
+++ b/com32/hdt/hdt-cli-kernel.c
@@ -43,7 +43,6 @@ void main_show_kernel(int argc __unused, char **argv __unused,
char kernel_modules[LINUX_KERNEL_MODULE_SIZE *
MAX_KERNEL_MODULES_PER_PCI_DEVICE];
- detect_pci(hardware);
reset_more_printf();
more_printf("Kernel modules\n");
@@ -98,8 +97,6 @@ static void show_kernel_modules(int argc __unused, char **argv __unused,
char modules[MAX_PCI_CLASSES][256] = {{0}};
char category_name[MAX_PCI_CLASSES][256] = {{0}};
- detect_pci(hardware);
-
if (hardware->pci_ids_return_code == -ENOPCIIDS) {
nopciids = true;
more_printf(" Missing pci.ids, we can't compute the list\n");
diff --git a/com32/hdt/hdt-cli-pci.c b/com32/hdt/hdt-cli-pci.c
index c86a792..42571cf 100644
--- a/com32/hdt/hdt-cli-pci.c
+++ b/com32/hdt/hdt-cli-pci.c
@@ -36,7 +36,6 @@
void main_show_pci(int argc __unused, char **argv __unused,
struct s_hardware *hardware)
{
- cli_detect_pci(hardware);
reset_more_printf();
more_printf("PCI\n");
more_printf(" NB Devices : %d\n", hardware->nb_pci_devices);
@@ -290,29 +289,3 @@ struct cli_mode_descr pci_mode = {
.show_modules = &pci_show_modules,
.set_modules = NULL,
};
-
-void cli_detect_pci(struct s_hardware *hardware)
-{
- bool error = false;
- if (hardware->pci_detection == false) {
- detect_pci(hardware);
- if (hardware->pci_ids_return_code == -ENOPCIIDS) {
- more_printf
- ("The pci.ids file is missing, device names can't be computed.\n");
- more_printf("Please put one in same dir as hdt\n");
- error = true;
- }
- if ((hardware->modules_pcimap_return_code == -ENOMODULESPCIMAP) &&
- (hardware->modules_alias_return_code == -ENOMODULESALIAS)) {
- more_printf
- ("The modules.pcimap or modules.alias files are missing, device names can't be computed.\n");
- more_printf("Please put one of them in same dir as hdt\n");
- error = true;
- }
- if (error == true) {
- char tempbuf[10];
- more_printf("Press enter to continue\n");
- fgets(tempbuf, sizeof(tempbuf), stdin);
- }
- }
-}
diff --git a/com32/hdt/hdt-cli-pxe.c b/com32/hdt/hdt-cli-pxe.c
index 3a61bc0..faba043 100644
--- a/com32/hdt/hdt-cli-pxe.c
+++ b/com32/hdt/hdt-cli-pxe.c
@@ -48,7 +48,6 @@ void main_show_pxe(int argc __unused, char **argv __unused,
return;
}
- detect_pxe(hardware);
more_printf("PXE\n");
if (hardware->is_pxe_valid == false) {
more_printf(" No valid PXE ROM found\n");
diff --git a/com32/hdt/hdt-cli-vesa.c b/com32/hdt/hdt-cli-vesa.c
index a4a80fa..702f8bd 100644
--- a/com32/hdt/hdt-cli-vesa.c
+++ b/com32/hdt/hdt-cli-vesa.c
@@ -37,7 +37,6 @@ void main_show_vesa(int argc __unused, char **argv __unused,
struct s_hardware *hardware)
{
reset_more_printf();
- detect_vesa(hardware);
if (hardware->is_vesa_valid == false) {
more_printf("No VESA BIOS detected\n");
return;
@@ -56,7 +55,6 @@ void main_show_vesa(int argc __unused, char **argv __unused,
static void show_vesa_modes(int argc __unused, char **argv __unused,
struct s_hardware *hardware)
{
- detect_vesa(hardware);
reset_more_printf();
if (hardware->is_vesa_valid == false) {
more_printf("No VESA BIOS detected\n");
diff --git a/com32/hdt/hdt-cli-vpd.c b/com32/hdt/hdt-cli-vpd.c
index 4974720..81436cf 100644
--- a/com32/hdt/hdt-cli-vpd.c
+++ b/com32/hdt/hdt-cli-vpd.c
@@ -36,7 +36,6 @@ void main_show_vpd(int argc __unused, char **argv __unused,
struct s_hardware *hardware)
{
reset_more_printf();
- detect_vpd(hardware);
if (!hardware->is_vpd_valid) {
more_printf("No VPD structure detected.\n");
diff --git a/com32/hdt/hdt-cli.c b/com32/hdt/hdt-cli.c
index 7a4e24d..eb89a34 100644
--- a/com32/hdt/hdt-cli.c
+++ b/com32/hdt/hdt-cli.c
@@ -139,7 +139,6 @@ void set_mode(cli_mode_t mode, struct s_hardware *hardware)
snprintf(hdt_cli.prompt, sizeof(hdt_cli.prompt), "%s> ", CLI_PXE);
break;
case KERNEL_MODE:
- detect_pci(hardware);
hdt_cli.mode = mode;
snprintf(hdt_cli.prompt, sizeof(hdt_cli.prompt), "%s> ", CLI_KERNEL);
break;
@@ -154,19 +153,12 @@ void set_mode(cli_mode_t mode, struct s_hardware *hardware)
case PCI_MODE:
hdt_cli.mode = mode;
snprintf(hdt_cli.prompt, sizeof(hdt_cli.prompt), "%s> ", CLI_PCI);
- if (!hardware->pci_detection)
- cli_detect_pci(hardware);
break;
case CPU_MODE:
hdt_cli.mode = mode;
snprintf(hdt_cli.prompt, sizeof(hdt_cli.prompt), "%s> ", CLI_CPU);
- if (!hardware->dmi_detection)
- detect_dmi(hardware);
- if (!hardware->cpu_detection)
- cpu_detect(hardware);
break;
case DMI_MODE:
- detect_dmi(hardware);
if (!hardware->is_dmi_valid) {
printf("No valid DMI table found, exiting.\n");
break;
@@ -175,12 +167,10 @@ void set_mode(cli_mode_t mode, struct s_hardware *hardware)
snprintf(hdt_cli.prompt, sizeof(hdt_cli.prompt), "%s> ", CLI_DMI);
break;
case DISK_MODE:
- detect_disks(hardware);
hdt_cli.mode = mode;
snprintf(hdt_cli.prompt, sizeof(hdt_cli.prompt), "%s> ", CLI_DISK);
break;
case VPD_MODE:
- detect_vpd(hardware);
if (!hardware->is_vpd_valid) {
printf("No valid VPD table found, exiting.\n");
break;
diff --git a/com32/hdt/hdt-cli.h b/com32/hdt/hdt-cli.h
index 523f13c..bf9ca52 100644
--- a/com32/hdt/hdt-cli.h
+++ b/com32/hdt/hdt-cli.h
@@ -187,7 +187,6 @@ void show_dmi_memory_bank(int argc, char **argv, struct s_hardware *hardware);
// PCI STUFF
#define CLI_PCI_DEVICE "device"
void main_show_pci(int argc, char **argv, struct s_hardware *hardware);
-void cli_detect_pci(struct s_hardware *hardware);
// CPU STUFF
void main_show_cpu(int argc, char **argv, struct s_hardware *hardware);
diff --git a/com32/hdt/hdt-common.c b/com32/hdt/hdt-common.c
index aaf46bc..b8464f3 100644
--- a/com32/hdt/hdt-common.c
+++ b/com32/hdt/hdt-common.c
@@ -440,8 +440,6 @@ int detect_pxe(struct s_hardware *hardware)
return -1;
break;
}
- /* Let's try to find the associated pci device */
- detect_pci(hardware);
/* The firt pass try to find the exact pci device */
hardware->pxe.pci_device = NULL;
@@ -543,8 +541,6 @@ void detect_pci(struct s_hardware *hardware)
get_module_name_from_alias(hardware->pci_domain,
hardware->modules_alias_path);
- /* We try to detect the pxe stuff to populate the PXE: field of pci devices */
- detect_pxe(hardware);
}
void cpu_detect(struct s_hardware *hardware)
@@ -692,3 +688,51 @@ void init_console(struct s_hardware *hardware)
} else
console_ansi_raw();
}
+
+void detect_hardware(struct s_hardware *hardware)
+{
+ if (!quiet)
+ more_printf("ACPI: Detecting\n");
+ detect_acpi(hardware);
+
+ if (!quiet)
+ more_printf("MEMORY: Detecting\n");
+ detect_memory(hardware);
+
+ if (!quiet)
+ more_printf("DMI: Detecting Table\n");
+ if (detect_dmi(hardware) == -ENODMITABLE) {
+ printf("DMI: ERROR ! Table not found ! \n");
+ printf("DMI: Many hardware components will not be detected ! \n");
+ } else {
+ if (!quiet)
+ more_printf("DMI: Table found ! (version %u.%u)\n",
+ hardware->dmi.dmitable.major_version,
+ hardware->dmi.dmitable.minor_version);
+ }
+
+ if (!quiet)
+ more_printf("CPU: Detecting\n");
+ cpu_detect(hardware);
+
+ if (!quiet)
+ more_printf("DISKS: Detecting\n");
+ detect_disks(hardware);
+
+ if (!quiet)
+ more_printf("VPD: Detecting\n");
+ detect_vpd(hardware);
+
+ detect_pci(hardware);
+ if (!quiet)
+ more_printf("PCI: %d Devices Found\n", hardware->nb_pci_devices);
+
+ if (!quiet)
+ more_printf("PXE: Detecting\n");
+ detect_pxe(hardware);
+
+ if (!quiet)
+ more_printf("VESA: Detecting\n");
+ detect_vesa(hardware);
+}
+
diff --git a/com32/hdt/hdt-common.h b/com32/hdt/hdt-common.h
index 6d50b7b..31e88d6 100644
--- a/com32/hdt/hdt-common.h
+++ b/com32/hdt/hdt-common.h
@@ -226,4 +226,5 @@ void detect_parameters(const int argc, const char *argv[],
int detect_vesa(struct s_hardware *hardware);
void detect_memory(struct s_hardware *hardware);
void init_console(struct s_hardware *hardware);
+void detect_hardware(struct s_hardware *hardware);
#endif
diff --git a/com32/hdt/hdt-menu.c b/com32/hdt/hdt-menu.c
index 1aa0906..5701858 100644
--- a/com32/hdt/hdt-menu.c
+++ b/com32/hdt/hdt-menu.c
@@ -36,9 +36,6 @@ int start_menu_mode(struct s_hardware *hardware, char *version_string)
memset(&hdt_menu, 0, sizeof(hdt_menu));
- /* Detect every kind of hardware */
- detect_hardware(hardware);
-
/* Setup the menu system */
setup_menu(version_string);
@@ -159,11 +156,10 @@ void compute_submenus(struct s_hdt_menu *hdt_menu, struct s_hardware *hardware)
compute_vpd(&(hdt_menu->vpd_menu), hardware);
compute_disks(hdt_menu, hardware);
-#ifdef WITH_PCI
compute_PCI(hdt_menu, hardware);
compute_PXE(&(hdt_menu->pxe_menu), hardware);
compute_kernel(&(hdt_menu->kernel_menu), hardware);
-#endif
+
compute_summarymenu(&(hdt_menu->summary_menu), hardware);
compute_syslinuxmenu(&(hdt_menu->syslinux_menu), hardware);
compute_VESA(hdt_menu, hardware);
@@ -180,14 +176,13 @@ void compute_main_menu(struct s_hdt_menu *hdt_menu, struct s_hardware *hardware)
hdt_menu->main_menu.menu = add_menu(" Main Menu ", -1);
set_item_options(-1, 24);
-#ifdef WITH_PCI
snprintf(menu_item, sizeof(menu_item), "PC<I> Devices(%2d)\n",
hardware->nb_pci_devices);
add_item(menu_item, "PCI Devices Menu", OPT_SUBMENU, NULL,
hdt_menu->pci_menu.menu);
hdt_menu->main_menu.items_count++;
hdt_menu->total_menu_count += hdt_menu->pci_menu.items_count;
-#endif
+
if (hdt_menu->disk_menu.items_count > 0) {
snprintf(menu_item, sizeof(menu_item), "<D>isks (%2d)\n",
hdt_menu->disk_menu.items_count);
@@ -263,14 +258,14 @@ void compute_main_menu(struct s_hdt_menu *hdt_menu, struct s_hardware *hardware)
}
add_item("", "", OPT_SEP, "", 0);
-#ifdef WITH_PCI
+
if ((hardware->modules_pcimap_return_code != -ENOMODULESPCIMAP) ||
(hardware->modules_alias_return_code != -ENOMODULESALIAS)) {
add_item("<K>ernel Modules", "Kernel Modules Menu", OPT_SUBMENU,
NULL, hdt_menu->kernel_menu.menu);
hdt_menu->main_menu.items_count++;
}
-#endif
+
add_item("S<y>slinux", "Syslinux Information Menu", OPT_SUBMENU, NULL,
hdt_menu->syslinux_menu.menu);
hdt_menu->main_menu.items_count++;
@@ -290,43 +285,3 @@ void compute_main_menu(struct s_hdt_menu *hdt_menu, struct s_hardware *hardware)
hdt_menu->total_menu_count += hdt_menu->main_menu.items_count;
}
-
-void detect_hardware(struct s_hardware *hardware)
-{
- if (!quiet)
- more_printf("MEMORY: Detecting\n");
- detect_memory(hardware);
-
- if (!quiet)
- more_printf("DMI: Detecting Table\n");
- if (detect_dmi(hardware) == -ENODMITABLE) {
- printf("DMI: ERROR ! Table not found ! \n");
- printf("DMI: Many hardware components will not be detected ! \n");
- } else {
- if (!quiet)
- more_printf("DMI: Table found ! (version %u.%u)\n",
- hardware->dmi.dmitable.major_version,
- hardware->dmi.dmitable.minor_version);
- }
-
- if (!quiet)
- more_printf("CPU: Detecting\n");
- cpu_detect(hardware);
-
- if (!quiet)
- more_printf("DISKS: Detecting\n");
- detect_disks(hardware);
-
- if (!quiet)
- more_printf("VPD: Detecting\n");
- detect_vpd(hardware);
-
-#ifdef WITH_PCI
- detect_pci(hardware);
- if (!quiet)
- more_printf("PCI: %d Devices Found\n", hardware->nb_pci_devices);
-#endif
- if (!quiet)
- more_printf("VESA: Detecting\n");
- detect_vesa(hardware);
-}
diff --git a/com32/hdt/hdt-menu.h b/com32/hdt/hdt-menu.h
index f10e529..993452f 100644
--- a/com32/hdt/hdt-menu.h
+++ b/com32/hdt/hdt-menu.h
@@ -131,5 +131,4 @@ void setup_menu(char *version);
void compute_main_menu(struct s_hdt_menu *hdt_menu,
struct s_hardware *hardware);
void compute_submenus(struct s_hdt_menu *hdt_menu, struct s_hardware *hardware);
-void detect_hardware(struct s_hardware *hardware);
#endif
diff --git a/com32/hdt/hdt.c b/com32/hdt/hdt.c
index 1a438a3..229af54 100644
--- a/com32/hdt/hdt.c
+++ b/com32/hdt/hdt.c
@@ -66,6 +66,9 @@ int main(const int argc, const char *argv[])
/* Opening the Syslinux console */
init_console(&hardware);
+ /* Detect hardware */
+ detect_hardware(&hardware);
+
/* Clear the screen and reset position of the cursor */
clear_screen();
printf("\033[1;1H");
diff --git a/com32/hdt/hdt.h b/com32/hdt/hdt.h
index 2396e96..9cd74cb 100644
--- a/com32/hdt/hdt.h
+++ b/com32/hdt/hdt.h
@@ -41,7 +41,6 @@
#define ATTR_PACKED __attribute__((packed))
-#define WITH_PCI 1
#define WITH_MENU_DISPLAY 1
#endif
More information about the Syslinux-commits
mailing list