bios_smbios.c File Reference

System Management BIOS. More...

#include <stdint.h>
#include <string.h>
#include <errno.h>
#include <assert.h>
#include <gpxe/uaccess.h>
#include <gpxe/smbios.h>
#include <realmode.h>
#include <pnpbios.h>

Go to the source code of this file.

Functions

 FILE_LICENCE (GPL2_OR_LATER)
static int bios_find_smbios (struct smbios *smbios)
 Find SMBIOS.
 PROVIDE_SMBIOS (pcbios, find_smbios, bios_find_smbios)


Detailed Description

System Management BIOS.

Definition in file bios_smbios.c.


Function Documentation

FILE_LICENCE ( GPL2_OR_LATER   ) 

static int bios_find_smbios ( struct smbios smbios  )  [static]

Find SMBIOS.

Parameters:
smbios SMBIOS entry point descriptor structure to fill in
Return values:
rc Return status code

Definition at line 42 of file bios_smbios.c.

References smbios::address, BIOS_SEG, copy_from_real, smbios::count, DBG, ENODEV, smbios::len, smbios_entry::len, offset, phys_to_user(), and SMBIOS_SIGNATURE.

00042                                                       {
00043         union {
00044                 struct smbios_entry entry;
00045                 uint8_t bytes[256]; /* 256 is maximum length possible */
00046         } u;
00047         static unsigned int offset = 0;
00048         size_t len;
00049         unsigned int i;
00050         uint8_t sum;
00051 
00052         /* Try to find SMBIOS */
00053         for ( ; offset < 0x10000 ; offset += 0x10 ) {
00054 
00055                 /* Read start of header and verify signature */
00056                 copy_from_real ( &u.entry, BIOS_SEG, offset,
00057                                  sizeof ( u.entry ));
00058                 if ( u.entry.signature != SMBIOS_SIGNATURE )
00059                         continue;
00060 
00061                 /* Read whole header and verify checksum */
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                 /* Fill result structure */
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 }

PROVIDE_SMBIOS ( pcbios  ,
find_smbios  ,
bios_find_smbios   
)


Generated on Tue Apr 6 20:01:13 2010 for gPXE by  doxygen 1.5.7.1