iPXE
Macros | Functions
rsdp.c File Reference

ACPI Root System Description Pointer. More...

#include <stdint.h>
#include <realmode.h>
#include <bios.h>
#include <ipxe/acpi.h>
#include <ipxe/rsdp.h>

Go to the source code of this file.

Macros

#define RSDP_EBDA_END_SEG   0xa000
 EBDA RSDP maximum segment. More...
 
#define RSDP_BIOS_START   0xe0000
 Fixed BIOS area RSDP start address. More...
 
#define RSDP_BIOS_LEN   0x20000
 Fixed BIOS area RSDP length. More...
 
#define RSDP_STRIDE   16
 Stride at which to search for RSDP. More...
 

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
 
static userptr_t rsdp_find_rsdt_range (userptr_t start, size_t len)
 Locate ACPI root system description table within a memory range. More...
 
static userptr_t rsdp_find_rsdt (void)
 Locate ACPI root system description table. More...
 
 PROVIDE_ACPI (rsdp, acpi_find_rsdt, rsdp_find_rsdt)
 

Detailed Description

ACPI Root System Description Pointer.

Definition in file rsdp.c.

Macro Definition Documentation

◆ RSDP_EBDA_END_SEG

#define RSDP_EBDA_END_SEG   0xa000

EBDA RSDP maximum segment.

Definition at line 40 of file rsdp.c.

◆ RSDP_BIOS_START

#define RSDP_BIOS_START   0xe0000

Fixed BIOS area RSDP start address.

Definition at line 43 of file rsdp.c.

◆ RSDP_BIOS_LEN

#define RSDP_BIOS_LEN   0x20000

Fixed BIOS area RSDP length.

Definition at line 46 of file rsdp.c.

◆ RSDP_STRIDE

#define RSDP_STRIDE   16

Stride at which to search for RSDP.

Definition at line 49 of file rsdp.c.

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )

◆ rsdp_find_rsdt_range()

static userptr_t rsdp_find_rsdt_range ( userptr_t  start,
size_t  len 
)
static

Locate ACPI root system description table within a memory range.

Parameters
startStart address to search
lenLength to search
Return values
rsdtACPI root system description table, or UNULL

Definition at line 58 of file rsdp.c.

58  {
59  static const char signature[8] = RSDP_SIGNATURE;
60  struct acpi_rsdp rsdp;
62  size_t offset;
63  uint8_t sum;
64  unsigned int i;
65 
66  /* Search for RSDP */
67  for ( offset = 0 ; ( ( offset + sizeof ( rsdp ) ) < len ) ;
68  offset += RSDP_STRIDE ) {
69 
70  /* Check signature and checksum */
71  copy_from_user ( &rsdp, start, offset, sizeof ( rsdp ) );
72  if ( memcmp ( rsdp.signature, signature,
73  sizeof ( signature ) ) != 0 )
74  continue;
75  for ( sum = 0, i = 0 ; i < sizeof ( rsdp ) ; i++ )
76  sum += *( ( ( uint8_t * ) &rsdp ) + i );
77  if ( sum != 0 )
78  continue;
79 
80  /* Extract RSDT */
81  rsdt = phys_to_user ( le32_to_cpu ( rsdp.rsdt ) );
82  DBGC ( rsdt, "RSDT %#08lx found via RSDP %#08lx\n",
83  user_to_phys ( rsdt, 0 ),
84  user_to_phys ( start, offset ) );
85  return rsdt;
86  }
87 
88  return UNULL;
89 }
#define le32_to_cpu(value)
Definition: byteswap.h:113
static __always_inline void copy_from_user(void *dest, userptr_t src, off_t src_off, size_t len)
Copy data from user buffer.
Definition: uaccess.h:337
unsigned long user_to_phys(userptr_t userptr, off_t offset)
Convert user pointer to physical address.
#define DBGC(...)
Definition: compiler.h:505
#define RSDP_STRIDE
Stride at which to search for RSDP.
Definition: rsdp.c:49
userptr_t phys_to_user(unsigned long phys_addr)
Convert physical address to user pointer.
uint32_t start
Starting offset.
Definition: netvsc.h:12
u8 signature
Definition: CIB_PRM.h:35
static userptr_t size_t offset
Offset of the first segment within the content.
Definition: deflate.h:259
static EFI_ACPI_1_0_ROOT_SYSTEM_DESCRIPTION_POINTER * rsdp
ACPI configuration table.
Definition: efi_acpi.c:39
unsigned char uint8_t
Definition: stdint.h:10
#define RSDP_SIGNATURE
Root System Description Pointer signature.
Definition: acpi.h:78
#define UNULL
Equivalent of NULL for user pointers.
Definition: uaccess.h:36
uint32_t len
Length.
Definition: ena.h:14
uint32_t rsdt
Physical address of RSDT.
Definition: acpi.h:91
Root System Description Pointer.
Definition: acpi.h:81
int memcmp(const void *first, const void *second, size_t len)
Compare memory regions.
Definition: string.c:98
unsigned long userptr_t
A pointer to a user buffer.
Definition: uaccess.h:33

References copy_from_user(), DBGC, le32_to_cpu, len, memcmp(), offset, phys_to_user(), rsdp, RSDP_SIGNATURE, RSDP_STRIDE, acpi_rsdp::rsdt, signature, start, UNULL, and user_to_phys().

Referenced by rsdp_find_rsdt().

◆ rsdp_find_rsdt()

static userptr_t rsdp_find_rsdt ( void  )
static

Locate ACPI root system description table.

Return values
rsdtACPI root system description table, or UNULL

Definition at line 96 of file rsdp.c.

96  {
97  static userptr_t rsdt;
98  uint16_t ebda_seg;
99  userptr_t ebda;
100  size_t ebda_len;
101 
102  /* Return existing RSDT if already found */
103  if ( rsdt )
104  return rsdt;
105 
106  /* Search EBDA */
107  get_real ( ebda_seg, BDA_SEG, BDA_EBDA );
108  if ( ebda_seg < RSDP_EBDA_END_SEG ) {
109  ebda = real_to_user ( ebda_seg, 0 );
110  ebda_len = ( ( RSDP_EBDA_END_SEG - ebda_seg ) * 16 );
111  rsdt = rsdp_find_rsdt_range ( ebda, ebda_len );
112  if ( rsdt )
113  return rsdt;
114  }
115 
116  /* Search fixed BIOS area */
118  RSDP_BIOS_LEN );
119  if ( rsdt )
120  return rsdt;
121 
122  return UNULL;
123 }
unsigned short uint16_t
Definition: stdint.h:11
#define get_real
Definition: libkir.h:151
userptr_t phys_to_user(unsigned long phys_addr)
Convert physical address to user pointer.
#define RSDP_EBDA_END_SEG
EBDA RSDP maximum segment.
Definition: rsdp.c:40
#define RSDP_BIOS_START
Fixed BIOS area RSDP start address.
Definition: rsdp.c:43
#define RSDP_BIOS_LEN
Fixed BIOS area RSDP length.
Definition: rsdp.c:46
static userptr_t rsdp_find_rsdt_range(userptr_t start, size_t len)
Locate ACPI root system description table within a memory range.
Definition: rsdp.c:58
#define BDA_SEG
Definition: bios.h:6
#define BDA_EBDA
Definition: bios.h:7
#define UNULL
Equivalent of NULL for user pointers.
Definition: uaccess.h:36
uint32_t rsdt
Physical address of RSDT.
Definition: acpi.h:91
static __always_inline userptr_t real_to_user(unsigned int segment, unsigned int offset)
Convert segment:offset address to user buffer.
Definition: realmode.h:75
unsigned long userptr_t
A pointer to a user buffer.
Definition: uaccess.h:33

References BDA_EBDA, BDA_SEG, get_real, phys_to_user(), real_to_user(), RSDP_BIOS_LEN, RSDP_BIOS_START, RSDP_EBDA_END_SEG, rsdp_find_rsdt_range(), acpi_rsdp::rsdt, and UNULL.

◆ PROVIDE_ACPI()

PROVIDE_ACPI ( rsdp  ,
acpi_find_rsdt  ,
rsdp_find_rsdt   
)