Skip to content

Commit 1a7eb2f

Browse files
committed
Export four specific decoding functions, make them suitable for external
call.
1 parent c6a3d62 commit 1a7eb2f

File tree

3 files changed

+45
-17
lines changed

3 files changed

+45
-17
lines changed

Makefile

+2-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ vpddecode : vpddecode.o util.o
5656
# Objects
5757
#
5858

59-
dmidecode.o : dmidecode.c version.h types.h util.h config.h dmiopt.h
59+
dmidecode.o : dmidecode.c version.h types.h util.h config.h dmidecode.h \
60+
dmiopt.h
6061
$(CC) $(CFLAGS) -c $< -o $@
6162

6263
dmiopt.o : dmiopt.c config.h types.h dmiopt.h

dmidecode.c

+19-16
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
#include "config.h"
6161
#include "types.h"
6262
#include "util.h"
63+
#include "dmidecode.h"
6364
#include "dmiopt.h"
6465

6566
static const char *out_of_spec = "<OUT OF SPEC>";
@@ -314,7 +315,7 @@ static void dmi_bios_characteristics_x2(u8 code, const char *prefix)
314315
* 3.3.2 System Information (Type 1)
315316
*/
316317

317-
static void dmi_system_uuid(u8 *p)
318+
void dmi_system_uuid(u8 *p)
318319
{
319320
int only0xFF=1, only0x00=1;
320321
int i;
@@ -327,16 +328,16 @@ static void dmi_system_uuid(u8 *p)
327328

328329
if(only0xFF)
329330
{
330-
printf(" Not Present");
331+
printf("Not Present");
331332
return;
332333
}
333334
if(only0x00)
334335
{
335-
printf(" Not Settable");
336+
printf("Not Settable");
336337
return;
337338
}
338339

339-
printf(" %02X%02X%02X%02X-%02X%02X-%02X%02X-%02X%02X-%02X%02X%02X%02X%02X%02X",
340+
printf("%02X%02X%02X%02X-%02X%02X-%02X%02X-%02X%02X-%02X%02X%02X%02X%02X%02X",
340341
p[0], p[1], p[2], p[3], p[4], p[5], p[6], p[7],
341342
p[8], p[9], p[10], p[11], p[12], p[13], p[14], p[15]);
342343
}
@@ -429,7 +430,7 @@ static void dmi_base_board_handles(u8 count, u8 *p, const char *prefix)
429430
* 3.3.4 Chassis Information (Type 3)
430431
*/
431432

432-
static const char *dmi_chassis_type(u8 code)
433+
const char *dmi_chassis_type(u8 code)
433434
{
434435
/* 3.3.4.1 */
435436
static const char *type[]={
@@ -568,7 +569,7 @@ static const char *dmi_processor_type(u8 code)
568569
return out_of_spec;
569570
}
570571

571-
static const char *dmi_processor_family(u8 code)
572+
const char *dmi_processor_family(u8 code)
572573
{
573574
/* 3.3.5.2 */
574575
static const char *family[256]={
@@ -1002,12 +1003,14 @@ static void dmi_processor_voltage(u8 code)
10021003
}
10031004
}
10041005

1005-
static void dmi_processor_frequency(u16 code)
1006+
void dmi_processor_frequency(u8 *p)
10061007
{
1008+
u16 code = WORD(p);
1009+
10071010
if(code)
1008-
printf(" %u MHz", code);
1011+
printf("%u MHz", code);
10091012
else
1010-
printf(" Unknown");
1013+
printf("Unknown");
10111014
}
10121015

10131016
static const char *dmi_processor_status(u8 code)
@@ -2878,7 +2881,7 @@ static void dmi_decode(u8 *data, u16 ver)
28782881
printf("\tSerial Number: %s\n",
28792882
dmi_string(h, data[0x07]));
28802883
if(h->length<0x19) break;
2881-
printf("\tUUID:");
2884+
printf("\tUUID: ");
28822885
dmi_system_uuid(data+0x08);
28832886
printf("\n");
28842887
printf("\tWake-up Type: %s\n",
@@ -2973,14 +2976,14 @@ static void dmi_decode(u8 *data, u16 ver)
29732976
printf("\tVoltage:");
29742977
dmi_processor_voltage(data[0x11]);
29752978
printf("\n");
2976-
printf("\tExternal Clock:");
2977-
dmi_processor_frequency(WORD(data+0x12));
2979+
printf("\tExternal Clock: ");
2980+
dmi_processor_frequency(data+0x12);
29782981
printf("\n");
2979-
printf("\tMax Speed:");
2980-
dmi_processor_frequency(WORD(data+0x14));
2982+
printf("\tMax Speed: ");
2983+
dmi_processor_frequency(data+0x14);
29812984
printf("\n");
2982-
printf("\tCurrent Speed:");
2983-
dmi_processor_frequency(WORD(data+0x16));
2985+
printf("\tCurrent Speed: ");
2986+
dmi_processor_frequency(data+0x16);
29842987
printf("\n");
29852988
if(data[0x18]&(1<<6))
29862989
printf("\tStatus: Populated, %s\n",

dmidecode.h

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/*
2+
* This file is part of the dmidecode project.
3+
*
4+
* (C) 2005 Jean Delvare <[email protected]>
5+
*
6+
* This program is free software; you can redistribute it and/or modify
7+
* it under the terms of the GNU General Public License as published by
8+
* the Free Software Foundation; either version 2 of the License, or
9+
* (at your option) any later version.
10+
*
11+
* This program is distributed in the hope that it will be useful,
12+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
* GNU General Public License for more details.
15+
*
16+
* You should have received a copy of the GNU General Public License
17+
* along with this program; if not, write to the Free Software
18+
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19+
*/
20+
21+
void dmi_system_uuid(u8 *p);
22+
const char *dmi_chassis_type(u8 code);
23+
const char *dmi_processor_family(u8 code);
24+
void dmi_processor_frequency(u8 *p);

0 commit comments

Comments
 (0)