summaryrefslogtreecommitdiff
path: root/com32/modules/dmitest.c
blob: 1958eb3e484bb94a2f7b1212163ccf782f50584f (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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
/* ----------------------------------------------------------------------- *
 *
 *   Copyright 2006 Erwan Velu - All Rights Reserved
 *
 *   This program is free software; you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation, Inc., 53 Temple Place Ste 330,
 *   Boston MA 02111-1307, USA; either version 2 of the License, or
 *   (at your option) any later version; incorporated herein by reference.
 *
 * ----------------------------------------------------------------------- */

/*
 * dmitest.c
 *
 * DMI demo program using libcom32
 */

#include <string.h>
#include <stdio.h>
#include <console.h>
#include "dmi/dmi.h"

char display_line;

void display_bios(s_dmi *dmi) {
 moreprintf("BIOS\n");
 moreprintf("\tVendor:   %s\n",dmi->bios.vendor);
 moreprintf("\tVersion:  %s\n",dmi->bios.version);
 moreprintf("\tRelease:  %s\n",dmi->bios.release_date);
 moreprintf("\tBios Revision     %s\n",dmi->bios.bios_revision);
 moreprintf("\tFirmware Revision %s\n",dmi->bios.firmware_revision);
 moreprintf("\tAddress:  0x%04X0\n",dmi->bios.address);
 moreprintf("\tRuntime address: %u %s\n",dmi->bios.runtime_size,dmi->bios.runtime_size_unit);
 moreprintf("\tRom size: %u %s\n",dmi->bios.rom_size,dmi->bios.rom_size_unit);
 display_bios_characteristics(dmi);
}

void display_system(s_dmi *dmi) {
 moreprintf("\nSystem\n");
 moreprintf("\tManufacturer %s\n",dmi->system.manufacturer);
 moreprintf("\tProduct Name %s\n",dmi->system.product_name);
 moreprintf("\tVersion      %s\n",dmi->system.version);
 moreprintf("\tSerial       %s\n",dmi->system.serial);
 moreprintf("\tUUID         %s\n",dmi->system.uuid);
 moreprintf("\tWakeup Type  %s\n",dmi->system.wakeup_type);
 moreprintf("\tSKU Number   %s\n",dmi->system.sku_number);
 moreprintf("\tFamily       %s\n",dmi->system.family);
}

void display_base_board(s_dmi *dmi) {
 moreprintf("Base board\n");
 moreprintf("\tManufacturer %s\n",dmi->base_board.manufacturer);
 moreprintf("\tProduct Name %s\n",dmi->base_board.product_name);
 moreprintf("\tVersion      %s\n",dmi->base_board.version);
 moreprintf("\tSerial       %s\n",dmi->base_board.serial);
 moreprintf("\tAsset Tag    %s\n",dmi->base_board.asset_tag);
 moreprintf("\tLocation     %s\n",dmi->base_board.location);
 moreprintf("\tType         %s\n",dmi->base_board.type);
 display_base_board_features(dmi);
}

void display_chassis(s_dmi *dmi) {
 moreprintf("\nChassis\n");
 moreprintf("\tManufacturer %s\n",dmi->chassis.manufacturer);
 moreprintf("\tType	   %s\n",dmi->chassis.type);
 moreprintf("\tLock	   %s\n",dmi->chassis.lock);
 moreprintf("\tVersion      %s\n",dmi->chassis.version);
 moreprintf("\tSerial       %s\n",dmi->chassis.serial);
 moreprintf("\tAsset Tag    %s\n",dmi->chassis.asset_tag);
 moreprintf("\tBoot up state %s\n",dmi->chassis.boot_up_state);
 moreprintf("\tPower supply state %s\n",dmi->chassis.power_supply_state);
 moreprintf("\tThermal state %s\n",dmi->chassis.thermal_state);
 moreprintf("\tSecurity Status    %s\n",dmi->chassis.security_status);
 moreprintf("\tOEM Information    %s\n",dmi->chassis.oem_information);
 moreprintf("\tHeight       %u\n",dmi->chassis.height);
 moreprintf("\tNB Power Cords     %u\n",dmi->chassis.nb_power_cords);
}

void display_cpu(s_dmi *dmi) {
 moreprintf("\nCPU\n");
 moreprintf("\tSocket Designation %s\n",dmi->processor.socket_designation);
 moreprintf("\tType         %s\n",dmi->processor.type);
 moreprintf("\tFamily       %s\n",dmi->processor.family);
 moreprintf("\tManufacturer %s\n",dmi->processor.manufacturer);
 moreprintf("\tVersion      %s\n",dmi->processor.version);
 moreprintf("\tExternal Clock    %u\n",dmi->processor.external_clock);
 moreprintf("\tMax Speed         %u\n",dmi->processor.max_speed);
 moreprintf("\tCurrent Speed     %u\n",dmi->processor.current_speed);
 moreprintf("\tCpu Type     %u\n",dmi->processor.signature.type);
 moreprintf("\tCpu Family   %u\n",dmi->processor.signature.family);
 moreprintf("\tCpu Model    %u\n",dmi->processor.signature.model);
 moreprintf("\tCpu Stepping %u\n",dmi->processor.signature.stepping);
 moreprintf("\tCpu Minor Stepping %u\n",dmi->processor.signature.minor_stepping);
 moreprintf("\tVoltage      %f\n",dmi->processor.voltage);
 moreprintf("\tStatus       %s\n",dmi->processor.status);
 moreprintf("\tUpgrade      %s\n",dmi->processor.upgrade);
 moreprintf("\tCache L1 Handle %s\n",dmi->processor.cache1);
 moreprintf("\tCache L2 Handle %s\n",dmi->processor.cache2);
 moreprintf("\tCache L3 Handle %s\n",dmi->processor.cache3);
 moreprintf("\tSerial       %s\n",dmi->processor.serial);
 moreprintf("\tPart Number  %s\n",dmi->processor.part_number);
 moreprintf("\tID           %s\n",dmi->processor.id);
 display_processor_flags(dmi);
}

int main(void)
{
  char buffer[1024];
  s_dmi dmi;
  openconsole(&dev_stdcon_r, &dev_stdcon_w);

  if ( ! dmi_interate() ) {
	  printf("No DMI Structure found\n");
	  return -1;
  }

  parse_dmitable(&dmi);

  for (;;) {
    printf("Available commands are system, chassis, base_board, cpu, bios, all, exit\n");
    printf("dmi: ");
    fgets(buffer, sizeof buffer, stdin);
    if ( !strncmp(buffer, "exit", 4) )
      break;
    if ( !strncmp(buffer, "system", 6) )
	    display_system(&dmi);
    if ( !strncmp(buffer, "chassis", 6) )
	    display_chassis(&dmi);
    if ( !strncmp(buffer, "base_board", 10) )
	    display_base_board(&dmi);
    if ( !strncmp(buffer, "cpu", 3) )
	    display_cpu(&dmi);
    if ( !strncmp(buffer, "bios", 4) )
	    display_bios(&dmi);
    if ( !strncmp(buffer, "all", 3) ) {
	    display_bios(&dmi);
	    display_system(&dmi);
	    display_chassis(&dmi);
	    display_base_board(&dmi);
	    display_cpu(&dmi);
    }
  }

  return 0;
}