Sfoglia il codice sorgente

Added definition of a UUID and uuid_ntoa() (for debugging), and

implemented smbios_get_uuid().
tags/v0.9.3
Michael Brown 17 anni fa
parent
commit
899f5b8ab2

+ 8
- 19
src/arch/i386/firmware/pcbios/smbios.c Vedi File

@@ -21,6 +21,7 @@
21 21
 #include <stdio.h>
22 22
 #include <errno.h>
23 23
 #include <gpxe/uaccess.h>
24
+#include <gpxe/uuid.h>
24 25
 #include <realmode.h>
25 26
 #include <pnpbios.h>
26 27
 #include <smbios.h>
@@ -301,34 +302,22 @@ int find_smbios_string ( struct smbios_strings *strings, unsigned int index,
301 302
 }
302 303
 
303 304
 /**
304
- * Find SMBIOS serial number
305
+ * Get UUID from SMBIOS
305 306
  *
307
+ * @v uuid		UUID to fill in
308
+ * @ret rc		Return status code
306 309
  */
307
-int dump_smbios_info ( void ) {
310
+int smbios_get_uuid ( union uuid *uuid ) {
308 311
 	struct smbios_system_information sysinfo;
309
-	struct smbios_strings strings;
310
-	char buf[64];
311 312
 	int rc;
312 313
 
313 314
 	if ( ( rc = find_smbios_structure ( SMBIOS_TYPE_SYSTEM_INFORMATION,
314 315
 					    &sysinfo, sizeof ( sysinfo ),
315
-					    &strings ) ) != 0 )
316
-		return rc;
317
-
318
-	DBG_HD ( &sysinfo, sizeof ( sysinfo ) );
319
-
320
-	if ( ( rc = find_smbios_string ( &strings, sysinfo.manufacturer,
321
-					 buf, sizeof ( buf ) ) ) != 0 )
322
-		return rc;
323
-	DBG ( "Manufacturer: \"%s\"\n", buf );
324
-
325
-	if ( ( rc = find_smbios_string ( &strings, sysinfo.product,
326
-					 buf, sizeof ( buf ) ) ) != 0 )
316
+					    NULL ) ) != 0 )
327 317
 		return rc;
328
-	DBG ( "Product: \"%s\"\n", buf );
329 318
 
330
-	DBG ( "UUID:\n" );
331
-	DBG_HD ( &sysinfo.uuid, sizeof ( sysinfo.uuid ) );
319
+	memcpy ( uuid, sysinfo.uuid, sizeof ( *uuid ) );
320
+	DBG ( "SMBIOS found UUID %s\n", uuid_ntoa ( uuid ) );
332 321
 
333 322
 	return 0;
334 323
 }

+ 2
- 0
src/arch/i386/include/smbios.h Vedi File

@@ -32,6 +32,8 @@ struct smbios_system_information {
32 32
 	uint8_t serial;
33 33
 	/** UUID */
34 34
 	uint8_t uuid[16];
35
+	/** Wake-up type */
36
+	uint8_t wakeup;
35 37
 } __attribute__ (( packed ));
36 38
 
37 39
 /** SMBIOS system information structure type */

+ 48
- 0
src/core/uuid.c Vedi File

@@ -0,0 +1,48 @@
1
+/*
2
+ * Copyright (C) 2007 Michael Brown <mbrown@fensystems.co.uk>.
3
+ *
4
+ * This program is free software; you can redistribute it and/or
5
+ * modify it under the terms of the GNU General Public License as
6
+ * published by the Free Software Foundation; either version 2 of the
7
+ * License, or any later version.
8
+ *
9
+ * This program is distributed in the hope that it will be useful, but
10
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12
+ * General Public License for more details.
13
+ *
14
+ * You should have received a copy of the GNU General Public License
15
+ * along with this program; if not, write to the Free Software
16
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17
+ */
18
+
19
+#include <stdint.h>
20
+#include <stdio.h>
21
+#include <byteswap.h>
22
+#include <gpxe/uuid.h>
23
+
24
+/** @file
25
+ *
26
+ * Universally unique IDs
27
+ *
28
+ */
29
+
30
+/**
31
+ * Convert UUID to printable string
32
+ *
33
+ * @v uuid		UUID
34
+ * @ret string		UUID in canonical form
35
+ */
36
+char * uuid_ntoa ( union uuid *uuid ) {
37
+	static char buf[37]; /* "00000000-0000-0000-0000-000000000000" */
38
+
39
+	sprintf ( buf, "%08lx-%04x-%04x-%04x-%02x%02x%02x%02x%02x%02x",
40
+		  le32_to_cpu ( uuid->canonical.a ),
41
+		  le16_to_cpu ( uuid->canonical.b ),
42
+		  le16_to_cpu ( uuid->canonical.c ),
43
+		  be16_to_cpu ( uuid->canonical.d ),
44
+		  uuid->canonical.e[0], uuid->canonical.e[1],
45
+		  uuid->canonical.e[2], uuid->canonical.e[3],
46
+		  uuid->canonical.e[4], uuid->canonical.e[5] );
47
+	return buf;
48
+}

+ 31
- 0
src/include/gpxe/uuid.h Vedi File

@@ -0,0 +1,31 @@
1
+#ifndef _GPXE_UUID_H
2
+#define _GPXE_UUID_H
3
+
4
+/** @file
5
+ *
6
+ * Universally unique IDs
7
+ */
8
+
9
+#include <stdint.h>
10
+
11
+/** A universally unique ID */
12
+union uuid {
13
+	/** Canonical form (00000000-0000-0000-0000-000000000000) */
14
+	struct {
15
+		/** 8 hex digits, little-endian */
16
+		uint32_t a;
17
+		/** 2 hex digits, little-endian */
18
+		uint16_t b;
19
+		/** 2 hex digits, little-endian */
20
+		uint16_t c;
21
+		/** 2 hex digits, big-endian */
22
+		uint16_t d;
23
+		/** 12 hex digits, big-endian */
24
+		uint8_t e[6];
25
+	} canonical;
26
+	uint8_t raw[16];
27
+};
28
+
29
+extern char * uuid_ntoa ( union uuid *uuid );
30
+
31
+#endif /* _GPXE_UUID_H */

Loading…
Annulla
Salva