summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErwan Velu <erwan.velu@free.fr>2009-02-25 21:53:01 +0100
committerH. Peter Anvin <hpa@linux.intel.com>2009-02-26 13:25:25 -0800
commitc73ffb0c9d7b42046a895df80b2443c21d41fef7 (patch)
tree6b2daeae7adf332086d7d657be47936c96b1ec1a
parentdb3d9fd124f8971e38fb8b44b83f9d739b10ef7e (diff)
downloadsyslinux-c73ffb0c9d7b42046a895df80b2443c21d41fef7.tar.gz
hdt: More kernel stuff
-rw-r--r--com32/hdt/hdt-cli-kernel.c63
-rw-r--r--com32/hdt/hdt-cli.c8
-rw-r--r--com32/hdt/hdt-cli.h2
-rw-r--r--com32/hdt/hdt-common.c5
4 files changed, 73 insertions, 5 deletions
diff --git a/com32/hdt/hdt-cli-kernel.c b/com32/hdt/hdt-cli-kernel.c
index 6ca75e1e..0485ca00 100644
--- a/com32/hdt/hdt-cli-kernel.c
+++ b/com32/hdt/hdt-cli-kernel.c
@@ -63,7 +63,7 @@ void main_show_kernel(struct s_hardware *hardware,struct s_cli_mode *cli_mode) {
strncat(kernel_modules, pci_device->dev_info->linux_kernel_module[kmod],LINUX_KERNEL_MODULE_SIZE-1);
}
- if (pci_device->dev_info->linux_kernel_module_count>0) {
+ if ((pci_device->dev_info->linux_kernel_module_count>0) && (!strstr(buffer,kernel_modules))) {
found=true;
if (pci_device->dev_info->linux_kernel_module_count>1) strncat(buffer,"(",1);
strncat(buffer, kernel_modules, sizeof(kernel_modules));
@@ -77,3 +77,64 @@ void main_show_kernel(struct s_hardware *hardware,struct s_cli_mode *cli_mode) {
more_printf(buffer);
}
}
+
+void show_kernel_modules(struct s_hardware *hardware) {
+ int i=1;
+ struct pci_device *pci_device;
+ char kernel_modules [LINUX_KERNEL_MODULE_SIZE*MAX_KERNEL_MODULES_PER_PCI_DEVICE];
+ bool nopciids=false;
+ bool nomodulespcimap=false;
+ char first_line[81];
+ char second_line[81];
+ char modules[MAX_PCI_CLASSES][256];
+ char category_name[MAX_PCI_CLASSES][256];
+
+ clear_screen();
+ memset(&modules,0,sizeof(modules));
+
+ if (hardware->pci_ids_return_code == -ENOPCIIDS) {
+ nopciids=true;
+ }
+
+ if (hardware->modules_pcimap_return_code == -ENOMODULESPCIMAP) {
+ nomodulespcimap=true;
+ }
+
+ if ((nomodulespcimap==false) && (nopciids==false)) {
+ for_each_pci_func(pci_device, hardware->pci_domain) {
+ memset(kernel_modules,0,sizeof kernel_modules);
+
+ for (int kmod=0; kmod<pci_device->dev_info->linux_kernel_module_count;kmod++) {
+ strncat(kernel_modules, pci_device->dev_info->linux_kernel_module[kmod],LINUX_KERNEL_MODULE_SIZE-1);
+ strncat(kernel_modules," ",1);
+ }
+
+ if ((pci_device->dev_info->linux_kernel_module_count>0) && (!strstr(modules[pci_device->class[2]],kernel_modules))) {
+ strncat(modules[pci_device->class[2]], kernel_modules, sizeof(kernel_modules));
+ snprintf(category_name[pci_device->class[2]], sizeof(category_name[pci_device->class[2]]),"%s",pci_device->dev_info->category_name);
+ }
+ }
+ /* print the found items */
+ for (int i=0; i<MAX_PCI_CLASSES;i++) {
+ if (strlen(category_name[i])>1) {
+ more_printf("%s : %s\n",category_name[i], modules[i]);
+ }
+ }
+ }
+
+}
+
+void kernel_show(char *item, struct s_hardware *hardware) {
+ if ( !strncmp(item, CLI_SHOW_LIST, sizeof(CLI_SHOW_LIST) - 1) ) {
+ show_kernel_modules(hardware);
+ return;
+ }
+}
+
+void handle_kernel_commands(char *cli_line, struct s_cli_mode *cli_mode, struct s_hardware *hardware) {
+ if ( !strncmp(cli_line, CLI_SHOW, sizeof(CLI_SHOW) - 1) ) {
+ kernel_show(strstr(cli_line,"show")+ sizeof(CLI_SHOW), hardware);
+ return;
+ }
+}
+
diff --git a/com32/hdt/hdt-cli.c b/com32/hdt/hdt-cli.c
index 5589c898..25658808 100644
--- a/com32/hdt/hdt-cli.c
+++ b/com32/hdt/hdt-cli.c
@@ -49,8 +49,10 @@ void set_mode(struct s_cli_mode *cli_mode, cli_mode_t mode, struct s_hardware *h
break;
case KERNEL_MODE:
+ detect_pci(hardware);
cli_mode->mode=mode;
snprintf(cli_mode->prompt, sizeof(cli_mode->prompt), "%s> ", CLI_KERNEL);
+ break;
case PCI_MODE:
cli_mode->mode=mode;
@@ -69,7 +71,6 @@ void set_mode(struct s_cli_mode *cli_mode, cli_mode_t mode, struct s_hardware *h
break;
case DMI_MODE:
- if (!hardware->dmi_detection)
detect_dmi(hardware);
if (!hardware->is_dmi_valid) {
printf("No valid DMI table found, exiting.\n");
@@ -135,6 +136,10 @@ void start_cli_mode(struct s_hardware *hardware, int argc, char *argv[]) {
set_mode(&cli_mode,DMI_MODE,hardware);
continue;
}
+ if ( !strncmp(cli_line, CLI_KERNEL, sizeof(CLI_KERNEL) - 1) ) {
+ set_mode(&cli_mode,KERNEL_MODE,hardware);
+ continue;
+ }
/* All commands before that line are common for all cli modes
* the following will be specific for every mode */
switch(cli_mode.mode) {
@@ -142,6 +147,7 @@ void start_cli_mode(struct s_hardware *hardware, int argc, char *argv[]) {
case PCI_MODE: handle_pci_commands(cli_line,&cli_mode, hardware); break;
case HDT_MODE: handle_hdt_commands(cli_line,&cli_mode, hardware); break;
case CPU_MODE: handle_cpu_commands(cli_line,&cli_mode, hardware); break;
+ case KERNEL_MODE: handle_kernel_commands(cli_line,&cli_mode, hardware); break;
case EXIT_MODE: break; /* should not happend */
}
}
diff --git a/com32/hdt/hdt-cli.h b/com32/hdt/hdt-cli.h
index 80780b20..31a5c0d4 100644
--- a/com32/hdt/hdt-cli.h
+++ b/com32/hdt/hdt-cli.h
@@ -105,5 +105,5 @@ void main_show_pxe(struct s_hardware *hardware,struct s_cli_mode *cli_mode);
//KERNEL STUFF
void main_show_kernel(struct s_hardware *hardware,struct s_cli_mode *cli_mode);
-
+void handle_kernel_commands(char *cli_line, struct s_cli_mode *cli_mode, struct s_hardware *hardware);
#endif
diff --git a/com32/hdt/hdt-common.c b/com32/hdt/hdt-common.c
index 46fde400..231c35fc 100644
--- a/com32/hdt/hdt-common.c
+++ b/com32/hdt/hdt-common.c
@@ -100,7 +100,7 @@ int detect_pxe(struct s_hardware *hardware) {
// printf("PXE: PXElinux detected\n");
if (!pxe_get_cached_info(PXENV_PACKET_TYPE_DHCP_ACK, &dhcpdata, &dhcplen)) {
pxe_bootp_t *dhcp=&hardware->pxe.dhcpdata;
- memcpy(&hardware->pxe.dhcpdata,dhcpdata,dhcplen);
+ memcpy(&hardware->pxe.dhcpdata,dhcpdata,sizeof(hardware->pxe.dhcpdata));
snprintf(hardware->pxe.mac_addr, sizeof(hardware->pxe.mac_addr), "%02x:%02x:%02x:%02x:%02x:%02x",
dhcp->CAddr[0],dhcp->CAddr[1],dhcp->CAddr[2],dhcp->CAddr[3],dhcp->CAddr[4],dhcp->CAddr[5]);
@@ -170,16 +170,17 @@ int detect_pxe(struct s_hardware *hardware) {
void detect_pci(struct s_hardware *hardware) {
if (hardware->pci_detection == true) return;
hardware->pci_detection=true;
- printf("PCI: Detecting Devices\n");
/* Scanning to detect pci buses and devices */
hardware->pci_domain = pci_scan();
+ hardware->nb_pci_devices=0;
struct pci_device *pci_device;
for_each_pci_func(pci_device, hardware->pci_domain) {
hardware->nb_pci_devices++;
}
+ printf("PCI: %d devices detected\n",hardware->nb_pci_devices);
printf("PCI: Resolving names\n");
/* Assigning product & vendor name for each device*/
hardware->pci_ids_return_code=get_name_from_pci_ids(hardware->pci_domain);