hdt.elf: hdt.o hdt-ata.o hdt-menu.o hdt-menu-pci.o hdt-menu-kernel.o \
hdt-menu-disk.o hdt-menu-dmi.o hdt-menu-processor.o hdt-menu-syslinux.o hdt-menu-about.o \
- hdt-cli.o hdt-common.o hdt-cli-pci.o hdt-cli-dmi.o hdt-cli-cpu.o\
+ hdt-cli.o hdt-common.o hdt-cli-pci.o hdt-cli-dmi.o hdt-cli-cpu.o hdt-cli-net.o\
$(com32)/modules/cpuid.o $(com32)/modules/dmi.o $(topdir)/menu/libmenu/libmenu.a $(LIB) $(C_LIBS)
$(LD) $(LDFLAGS) -o $@ $^
--- /dev/null
+/* ----------------------------------------------------------------------- *
+ *
+ * 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-cli.h"
+#include "hdt-common.h"
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <syslinux/pxe.h>
+
+void main_show_net(struct s_hardware *hardware,struct s_cli_mode *cli_mode) {
+ char buffer[1024];
+ memset(buffer,0,sizeof(buffer));
+
+ if (hardware->pxe_detection==false) detect_pxe(hardware);
+ if (hardware->is_pxe_valid==false) {
+ more_printf("No valid PXE rom found\n");
+ return;
+ }
+ t_PXENV_UNDI_GET_NIC_TYPE *g = &hardware->gnt;
+ switch(hardware->gnt.NicType) {
+ case PCI_NIC: more_printf("PCI NIC: %04x:%04x[%04x:%04X] rev(%02x) Bus(%02x:%02x.%02x) %02x.%02x %02x %02x\n",
+ g->info.pci.Vendor_ID, g->info.pci.Dev_ID, g->info.pci.SubVendor_ID, g->info.pci.SubDevice_ID,
+ g->info.pci.Rev, (g->info.pci.BusDevFunc >> 8) & 0xff, (g->info.pci.BusDevFunc >> 3) & 0x7,
+ g->info.pci.BusDevFunc & 0x03,
+ g->info.pci.Base_Class,
+ g->info.pci.Sub_Class, g->info.pci.Prog_Intf);break;
+ case PnP_NIC: break;
+ case CardBus_NIC:break;
+ }
+}
+
+
int do_exit(struct s_cli_mode *cli_mode) {
switch (cli_mode->mode) {
case HDT_MODE: return EXIT_MODE;
+ case NET_MODE:
case PCI_MODE:
case DMI_MODE:
case CPU_MODE: return HDT_MODE;
case HDT_MODE:
printf("Available commands are : %s %s %s %s %s %s\n",CLI_CLEAR, CLI_EXIT,CLI_HELP,CLI_SHOW, CLI_PCI, CLI_DMI);
break;
+ case NET_MODE:
case CPU_MODE:
case PCI_MODE:
case DMI_MODE:
if (!strncmp(item,CLI_PCI, sizeof (CLI_PCI))) main_show_pci(hardware);
if (!strncmp(item,CLI_DMI, sizeof (CLI_DMI))) main_show_dmi(hardware,cli_mode);
if (!strncmp(item,CLI_CPU, sizeof (CLI_CPU))) main_show_cpu(hardware,cli_mode);
+ if (!strncmp(item,CLI_NET, sizeof (CLI_NET))) main_show_net(hardware,cli_mode);
}
#define CLI_SHOW "show"
#define CLI_HDT "hdt"
#define CLI_PCI "pci"
+#define CLI_NET "net"
#define CLI_COMMANDS "commands"
#define CLI_DMI "dmi"
#define CLI_CPU "cpu"
PCI_MODE,
DMI_MODE,
CPU_MODE,
+ NET_MODE,
} cli_mode_t;
struct s_cli_mode {
void main_show_cpu(struct s_hardware *hardware,struct s_cli_mode *cli_mode);
void handle_cpu_commands(char *cli_line, struct s_cli_mode *cli_mode, struct s_hardware *hardware);
void cpu_show(char *item, struct s_hardware *hardware);
+
+//NET STUFF
+void main_show_net(struct s_hardware *hardware,struct s_cli_mode *cli_mode);
#endif
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
+#include "syslinux/config.h"
void init_hardware(struct s_hardware *hardware) {
hardware->pci_ids_return_code=0;
hardware->pci_detection=false;
hardware->disk_detection=false;
hardware->dmi_detection=false;
+ hardware->pxe_detection=false;
hardware->nb_pci_devices=0;
hardware->is_dmi_valid=false;
+ hardware->is_pxe_valid=false;
hardware->pci_domain=NULL;
/* Cleaning structures */
memset(hardware->disk_info,0,sizeof(hardware->disk_info));
- memset(&hardware->dmi,0,sizeof(hardware->dmi));
- memset(&hardware->cpu,0,sizeof(hardware->cpu));
+ memset(&hardware->dmi,0,sizeof(s_dmi));
+ memset(&hardware->cpu,0,sizeof(s_cpu));
+ memset(&hardware->gnt,0,sizeof(t_PXENV_UNDI_GET_NIC_TYPE));
}
/* Detecting if a DMI table exist
}
}
+int detect_pxe(struct s_hardware *hardware) {
+ void *dhcpdata;
+ size_t dhcplen;
+ const struct syslinux_version *sv;
+
+ hardware->pxe_detection=true;
+ memset(&hardware->gnt,0, sizeof(t_PXENV_UNDI_GET_NIC_TYPE));
+
+ sv = syslinux_version();
+ /* This code can only work if pxelinux is loaded*/
+ if (sv->filesystem != SYSLINUX_FS_PXELINUX) {
+ printf("No valid PXE Rom found\n");
+ return -1;
+ }
+ printf("PXE: PXElinux detected, Detecting parameters\n");
+
+ if (!pxe_get_cached_info(PXENV_PACKET_TYPE_DHCP_ACK, &dhcpdata, &dhcplen)) {
+ if (!pxe_get_nic_type(&hardware->gnt)) {
+ hardware->is_pxe_valid=true;
+ }
+ }
+ return 0;
+}
+
void detect_pci(struct s_hardware *hardware) {
hardware->pci_detection=true;
printf("PCI: Detecting Devices\n");
#include "sys/pci.h"
#include "cpuid.h"
#include "dmi/dmi.h"
+#include <syslinux/pxe.h>
#include "hdt-ata.h"
/* This two values are used for switching for the menu to the CLI mode*/
s_cpu cpu; /* CPU information */
struct pci_domain *pci_domain; /* PCI Devices */
struct diskinfo disk_info[256]; /* Disk Information*/
+ t_PXENV_UNDI_GET_NIC_TYPE gnt;
+
int pci_ids_return_code;
int modules_pcimap_return_code;
int nb_pci_devices;
bool is_dmi_valid;
+ bool is_pxe_valid;
+
bool dmi_detection; /* Does the dmi stuff have been already detected */
bool pci_detection; /* Does the pci stuff have been already detected */
bool cpu_detection; /* Does the cpu stuff have been already detected */
bool disk_detection; /* Does the disk stuff have been already detected */
+ bool pxe_detection; /* Does the pxe stuff have been already detected*/
};
char *find_argument(const char **argv, const char *argument);
void detect_disks(struct s_hardware *hardware);
void detect_pci(struct s_hardware *hardware);
void cpu_detect(struct s_hardware *hardware);
+int detect_pxe(struct s_hardware *hardware);
void init_hardware(struct s_hardware *hardware);
void clear_screen(void);
#endif