iPXE
Data Structures | Macros | 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...
 

Macros

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

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. More...
 
int find_pnp_bios (void)
 Locate Plug-and-Play BIOS. More...
 

Variables

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

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.

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )

◆ __attribute__()

struct pnp_bios __attribute__ ( (packed)  )

◆ is_pnp_bios()

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.

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 }
PnP BIOS structure.
Definition: pnpbios.c:39
#define EINVAL
Invalid argument.
Definition: errno.h:428
static userptr_t size_t offset
Offset of the first segment within the content.
Definition: deflate.h:259
unsigned char uint8_t
Definition: stdint.h:10
#define copy_from_real
Definition: libkir.h:79
uint32_t len
Length.
Definition: ena.h:14
#define PNP_BIOS_SIGNATURE
Signature for a PnP BIOS structure.
Definition: pnpbios.c:56
union @16 u
#define DBG(...)
Print a debugging message.
Definition: compiler.h:498
uint8_t bytes[64]
Definition: ib_mad.h:16
#define BIOS_SEG
Definition: pnpbios.h:13

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

◆ version

uint8_t version

Version as BCD (e.g.

1.0 is 0x10)

Definition at line 31 of file pnpbios.c.

◆ length

uint8_t length

Length of this structure.

Definition at line 33 of file pnpbios.c.

◆ control

uint16_t control

System capabilities.

Definition at line 35 of file pnpbios.c.

◆ checksum

uint8_t checksum