bios_smbios.c
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 FILE_LICENCE ( GPL2_OR_LATER );
00020
00021 #include <stdint.h>
00022 #include <string.h>
00023 #include <errno.h>
00024 #include <assert.h>
00025 #include <gpxe/uaccess.h>
00026 #include <gpxe/smbios.h>
00027 #include <realmode.h>
00028 #include <pnpbios.h>
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042 static int bios_find_smbios ( struct smbios *smbios ) {
00043 union {
00044 struct smbios_entry entry;
00045 uint8_t bytes[256];
00046 } u;
00047 static unsigned int offset = 0;
00048 size_t len;
00049 unsigned int i;
00050 uint8_t sum;
00051
00052
00053 for ( ; offset < 0x10000 ; offset += 0x10 ) {
00054
00055
00056 copy_from_real ( &u.entry, BIOS_SEG, offset,
00057 sizeof ( u.entry ));
00058 if ( u.entry.signature != SMBIOS_SIGNATURE )
00059 continue;
00060
00061
00062 len = u.entry.len;
00063 copy_from_real ( &u.bytes, BIOS_SEG, offset, len );
00064 for ( i = 0 , sum = 0 ; i < len ; i++ ) {
00065 sum += u.bytes[i];
00066 }
00067 if ( sum != 0 ) {
00068 DBG ( "SMBIOS at %04x:%04x has bad checksum %02x\n",
00069 BIOS_SEG, offset, sum );
00070 continue;
00071 }
00072
00073
00074 DBG ( "Found SMBIOS v%d.%d entry point at %04x:%04x\n",
00075 u.entry.major, u.entry.minor, BIOS_SEG, offset );
00076 smbios->address = phys_to_user ( u.entry.smbios_address );
00077 smbios->len = u.entry.smbios_len;
00078 smbios->count = u.entry.smbios_count;
00079 return 0;
00080 }
00081
00082 DBG ( "No SMBIOS found\n" );
00083 return -ENODEV;
00084 }
00085
00086 PROVIDE_SMBIOS ( pcbios, find_smbios, bios_find_smbios );