1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19FILE_LICENCE ( GPL2_OR_LATER );
20
21#include <stdint.h>
22#include <string.h>
23#include <errno.h>
24#include <assert.h>
25#include <gpxe/uaccess.h>
26#include <gpxe/smbios.h>
27#include <realmode.h>
28#include <pnpbios.h>
29
30
31
32
33
34
35
36
37
38
39
40
41
42static int bios_find_smbios ( struct smbios *smbios ) {
43 union {
44 struct smbios_entry entry;
45 uint8_t bytes[256];
46 } u;
47 static unsigned int offset = 0;
48 size_t len;
49 unsigned int i;
50 uint8_t sum;
51
52
53 for ( ; offset < 0x10000 ; offset += 0x10 ) {
54
55
56 copy_from_real ( &u.entry, BIOS_SEG, offset,
57 sizeof ( u.entry ));
58 if ( u.entry.signature != SMBIOS_SIGNATURE )
59 continue;
60
61
62 len = u.entry.len;
63 copy_from_real ( &u.bytes, BIOS_SEG, offset, len );
64 for ( i = 0 , sum = 0 ; i < len ; i++ ) {
65 sum += u.bytes[i];
66 }
67 if ( sum != 0 ) {
68 DBG ( "SMBIOS at %04x:%04x has bad checksum %02x\n",
69 BIOS_SEG, offset, sum );
70 continue;
71 }
72
73
74 DBG ( "Found SMBIOS v%d.%d entry point at %04x:%04x\n",
75 u.entry.major, u.entry.minor, BIOS_SEG, offset );
76 smbios->address = phys_to_user ( u.entry.smbios_address );
77 smbios->len = u.entry.smbios_len;
78 smbios->count = u.entry.smbios_count;
79 return 0;
80 }
81
82 DBG ( "No SMBIOS found\n" );
83 return -ENODEV;
84}
85
86PROVIDE_SMBIOS ( pcbios, find_smbios, bios_find_smbios );
87