pnpbios.c File Reference

PnP BIOS. More...

#include <stdint.h>
#include <string.h>
#include <errno.h>
#include <realmode.h>
#include <pnpbios.h>

Go to the source code of this file.

Data Structures

struct  pnp_bios
 PnP BIOS structure. More...

Defines

#define PNP_BIOS_SIGNATURE   ( ( '$' << 0 ) + ( 'P' << 8 ) + ( 'n' << 16 ) + ( 'P' << 24 ) )
 Signature for a PnP BIOS structure.

Functions

 FILE_LICENCE (GPL2_OR_LATER)
static int is_pnp_bios (unsigned int offset)
 Test address for PnP BIOS structure.
int find_pnp_bios (void)
 Locate Plug-and-Play BIOS.

Variables

struct pnp_bios packed
 PnP BIOS structure.


Detailed Description

PnP BIOS.

Definition in file pnpbios.c.


Define Documentation

#define PNP_BIOS_SIGNATURE   ( ( '$' << 0 ) + ( 'P' << 8 ) + ( 'n' << 16 ) + ( 'P' << 24 ) )

Signature for a PnP BIOS structure.

Definition at line 51 of file pnpbios.c.

Referenced by is_pnp_bios().


Function Documentation

FILE_LICENCE ( GPL2_OR_LATER   ) 

static int is_pnp_bios ( unsigned int  offset  )  [static]

Test address for PnP BIOS structure.

Parameters:
offset Offset within BIOS segment to test
Return values:
rc Return status code

Definition at line 60 of file pnpbios.c.

References BIOS_SEG, copy_from_real, DBG, EINVAL, and PNP_BIOS_SIGNATURE.

Referenced by find_pnp_bios().

00060                                                {
00061         union {
00062                 struct pnp_bios pnp_bios;
00063                 uint8_t bytes[256]; /* 256 is maximum length possible */
00064         } u;
00065         size_t len;
00066         unsigned int i;
00067         uint8_t sum = 0;
00068 
00069         /* Read start of header and verify signature */
00070         copy_from_real ( &u.pnp_bios, BIOS_SEG, offset, sizeof ( u.pnp_bios ));
00071         if ( u.pnp_bios.signature != PNP_BIOS_SIGNATURE )
00072                 return -EINVAL;
00073 
00074         /* Read whole header and verify checksum */
00075         len = u.pnp_bios.length;
00076         copy_from_real ( &u.bytes, BIOS_SEG, offset, len );
00077         for ( i = 0 ; i < len ; i++ ) {
00078                 sum += u.bytes[i];
00079         }
00080         if ( sum != 0 )
00081                 return -EINVAL;
00082 
00083         DBG ( "Found PnP BIOS at %04x:%04x\n", BIOS_SEG, offset );
00084 
00085         return 0;
00086 }

int find_pnp_bios ( void   ) 

Locate Plug-and-Play BIOS.

Return values:
pnp_offset Offset of PnP BIOS structure within BIOS segment
The PnP BIOS structure will be at BIOS_SEG:pnp_offset. If no PnP BIOS is found, -1 is returned.

Definition at line 96 of file pnpbios.c.

References is_pnp_bios().

Referenced by undi_load(), and undinet_probe().

00096                            {
00097         static int pnp_offset = 0;
00098 
00099         if ( pnp_offset )
00100                 return pnp_offset;
00101 
00102         for ( pnp_offset = 0 ; pnp_offset < 0x10000 ; pnp_offset += 0x10 ) {
00103                 if ( is_pnp_bios ( pnp_offset ) == 0 )
00104                         return pnp_offset;
00105         }
00106 
00107         pnp_offset = -1;
00108         return pnp_offset;
00109 }


Variable Documentation

struct pnp_bios packed

PnP BIOS structure.


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