iPXE
Data Structures | Defines | Functions | Variables
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_OR_UBDL)
struct pnp_bios __attribute__ ((packed))
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

uint32_t signature
 Signature.
uint8_t version
 Version as BCD (e.g.
uint8_t length
 Length of this structure.
uint16_t control
 System capabilities.
uint8_t checksum
 Checksum.

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 56 of file pnpbios.c.


Function Documentation

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )
struct pnp_bios __attribute__ ( (packed)  )
static int is_pnp_bios ( unsigned int  offset) [static]

Test address for PnP BIOS structure.

Parameters:
offsetOffset within BIOS segment to test
Return values:
rcReturn status code

Definition at line 65 of file pnpbios.c.

Referenced by find_pnp_bios().

                                               {
        union {
                struct pnp_bios pnp_bios;
                uint8_t bytes[256]; /* 256 is maximum length possible */
        } u;
        size_t len;
        unsigned int i;
        uint8_t sum = 0;

        /* Read start of header and verify signature */
        copy_from_real ( &u.pnp_bios, BIOS_SEG, offset, sizeof ( u.pnp_bios ));
        if ( u.pnp_bios.signature != PNP_BIOS_SIGNATURE )
                return -EINVAL;

        /* Read whole header and verify checksum */
        len = u.pnp_bios.length;
        copy_from_real ( &u.bytes, BIOS_SEG, offset, len );
        for ( i = 0 ; i < len ; i++ ) {
                sum += u.bytes[i];
        }
        if ( sum != 0 )
                return -EINVAL;

        DBG ( "Found PnP BIOS at %04x:%04x\n", BIOS_SEG, offset );

        return 0;
}
int find_pnp_bios ( void  )

Locate Plug-and-Play BIOS.

Return values:
pnp_offsetOffset 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 101 of file pnpbios.c.

References is_pnp_bios().

Referenced by undi_load(), and undinet_probe().

                           {
        static int pnp_offset = 0;

        if ( pnp_offset )
                return pnp_offset;

        for ( pnp_offset = 0 ; pnp_offset < 0x10000 ; pnp_offset += 0x10 ) {
                if ( is_pnp_bios ( pnp_offset ) == 0 )
                        return pnp_offset;
        }

        pnp_offset = -1;
        return pnp_offset;
}

Variable Documentation

Signature.

Must be equal to PNP_BIOS_SIGNATURE

Definition at line 58 of file pnpbios.c.

Version as BCD (e.g.

1.0 is 0x10)

Definition at line 60 of file pnpbios.c.

Length of this structure.

Definition at line 62 of file pnpbios.c.

System capabilities.

Definition at line 64 of file pnpbios.c.