aboutsummaryrefslogtreecommitdiffstats
path: root/com32/hdt/hdt-common.h
blob: 5cf806031b6327020f9b6a616866ead33838e838 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
/* ----------------------------------------------------------------------- *
 *
 *   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.
 *
 * -----------------------------------------------------------------------
*/

#ifndef DEFINE_HDT_COMMON_H
#define DEFINE_HDT_COMMON_H
#include <stdio.h>
#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*/
#define HDT_SWITCH_TO_CLI "hdt_switch_to_cli"
#define HDT_RETURN_TO_CLI 100

extern int display_line_nb;

#define more_printf(...) do {\
 if (display_line_nb == 23) {\
   char tempbuf[10];\
   printf("Press enter to continue\n");\
   display_line_nb=0;\
   fgets(tempbuf, sizeof(tempbuf), stdin);\
 }\
 printf ( __VA_ARGS__);\
 display_line_nb++; \
} while (0);


struct s_pxe {
 uint16_t vendor_id;
 uint16_t product_id;
 uint16_t subvendor_id;
 uint16_t subproduct_id;
 uint8_t rev;
 uint8_t pci_bus;
 uint8_t pci_dev;
 uint8_t pci_func;
 uint8_t base_class;
 uint8_t sub_class;
 uint8_t prog_intf;
 uint8_t nictype;
 char mac_addr[18]; /* The current mac address */
 uint8_t ip_addr[4];

 pxe_bootp_t dhcpdata; /* The dhcp answer */
 struct pci_device *pci_device; /* The matching pci device */
 uint8_t pci_device_pos; /* It position in our pci sorted list*/

};

struct s_hardware {
  s_dmi dmi; /* DMI table */
  s_cpu cpu; /* CPU information */
  struct pci_domain *pci_domain; /* PCI Devices */
  struct diskinfo disk_info[256];     /* Disk Information*/
  struct s_pxe pxe;

  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 syslinux_fs[22];
 struct syslinux_version *sv;
};

char *find_argument(const char **argv, const char *argument);
int detect_dmi(struct s_hardware *hardware);
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);
void detect_syslinux(struct s_hardware *hardware);
#endif