iPXE
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...

Macros

#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.

Macro Definition Documentation

◆ PNP_BIOS_SIGNATURE

#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.

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

Referenced by is_pnp_bios().

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )

◆ is_pnp_bios()

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.

65 {
66 union {
67 struct pnp_bios pnp_bios;
68 uint8_t bytes[256]; /* 256 is maximum length possible */
69 } u;
70 size_t len;
71 unsigned int i;
72 uint8_t sum = 0;
73
74 /* Read start of header and verify signature */
75 copy_from_real ( &u.pnp_bios, BIOS_SEG, offset, sizeof ( u.pnp_bios ));
76 if ( u.pnp_bios.signature != PNP_BIOS_SIGNATURE )
77 return -EINVAL;
78
79 /* Read whole header and verify checksum */
80 len = u.pnp_bios.length;
81 copy_from_real ( &u.bytes, BIOS_SEG, offset, len );
82 for ( i = 0 ; i < len ; i++ ) {
83 sum += u.bytes[i];
84 }
85 if ( sum != 0 )
86 return -EINVAL;
87
88 DBG ( "Found PnP BIOS at %04x:%04x\n", BIOS_SEG, offset );
89
90 return 0;
91}
unsigned char uint8_t
Definition stdint.h:10
uint16_t offset
Offset to command line.
Definition bzimage.h:3
union @104331263140136355135267063077374276003064103115 u
ring len
Length.
Definition dwmac.h:226
#define DBG(...)
Print a debugging message.
Definition compiler.h:498
#define EINVAL
Invalid argument.
Definition errno.h:429
uint8_t bytes[64]
Definition ib_mad.h:5
#define copy_from_real
Definition libkir.h:79
#define PNP_BIOS_SIGNATURE
Signature for a PnP BIOS structure.
Definition pnpbios.c:56
#define BIOS_SEG
Definition pnpbios.h:13
PnP BIOS structure.
Definition pnpbios.c:39

References BIOS_SEG, bytes, copy_from_real, DBG, EINVAL, len, offset, PNP_BIOS_SIGNATURE, and u.

Referenced by find_pnp_bios().

◆ find_pnp_bios()

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.

101 {
102 static int pnp_offset = 0;
103
104 if ( pnp_offset )
105 return pnp_offset;
106
107 for ( pnp_offset = 0 ; pnp_offset < 0x10000 ; pnp_offset += 0x10 ) {
108 if ( is_pnp_bios ( pnp_offset ) == 0 )
109 return pnp_offset;
110 }
111
112 pnp_offset = -1;
113 return pnp_offset;
114}
static int is_pnp_bios(unsigned int offset)
Test address for PnP BIOS structure.
Definition pnpbios.c:65

References is_pnp_bios().

Referenced by undi_load(), and undinet_probe().

Variable Documentation

◆ signature

uint32_t signature

Signature.

Must be equal to PNP_BIOS_SIGNATURE

Definition at line 4 of file pnpbios.c.

◆ version

uint8_t version

Version as BCD (e.g.

1.0 is 0x10)

Definition at line 6 of file pnpbios.c.

◆ length

uint8_t length

Length of this structure.

Definition at line 8 of file pnpbios.c.

◆ control

uint16_t control

System capabilities.

Definition at line 10 of file pnpbios.c.

◆ checksum