iPXE
rsdp.c File Reference

ACPI Root System Description Pointer. More...

#include <stdint.h>
#include <string.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.
#define RSDP_BIOS_START   0xe0000
 Fixed BIOS area RSDP start address.
#define RSDP_BIOS_LEN   0x20000
 Fixed BIOS area RSDP length.
#define RSDP_STRIDE   16
 Stride at which to search for RSDP.

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
static const struct acpi_rsdtrsdp_find_rsdt_range (const void *start, size_t len)
 Locate ACPI root system description table within a memory range.
static const struct acpi_rsdtrsdp_find_rsdt (void)
 Locate ACPI root system description table.
 PROVIDE_ACPI (rsdp, acpi_find_rsdt, rsdp_find_rsdt)
 PROVIDE_ACPI_INLINE (rsdp, acpi_find)

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 41 of file rsdp.c.

Referenced by rsdp_find_rsdt().

◆ RSDP_BIOS_START

#define RSDP_BIOS_START   0xe0000

Fixed BIOS area RSDP start address.

Definition at line 44 of file rsdp.c.

Referenced by rsdp_find_rsdt().

◆ RSDP_BIOS_LEN

#define RSDP_BIOS_LEN   0x20000

Fixed BIOS area RSDP length.

Definition at line 47 of file rsdp.c.

Referenced by rsdp_find_rsdt().

◆ RSDP_STRIDE

#define RSDP_STRIDE   16

Stride at which to search for RSDP.

Definition at line 50 of file rsdp.c.

Referenced by rsdp_find_rsdt_range().

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )

◆ rsdp_find_rsdt_range()

const struct acpi_rsdt * rsdp_find_rsdt_range ( const void * 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 NULL

Definition at line 59 of file rsdp.c.

60 {
61 static const char signature[8] = RSDP_SIGNATURE;
62 const struct acpi_rsdp *rsdp;
63 const struct acpi_rsdt *rsdt;
64 size_t offset;
65 uint8_t sum;
66 unsigned int i;
67
68 /* Search for RSDP */
69 for ( offset = 0 ; ( ( offset + sizeof ( *rsdp ) ) < len ) ;
70 offset += RSDP_STRIDE ) {
71
72 /* Check signature and checksum */
73 rsdp = ( start + offset );
74 if ( memcmp ( rsdp->signature, signature,
75 sizeof ( signature ) ) != 0 )
76 continue;
77 for ( sum = 0, i = 0 ; i < sizeof ( *rsdp ) ; i++ )
78 sum += *( ( ( uint8_t * ) rsdp ) + i );
79 if ( sum != 0 )
80 continue;
81
82 /* Extract RSDT */
83 rsdt = phys_to_virt ( le32_to_cpu ( rsdp->rsdt ) );
84 DBGC ( rsdt, "RSDT %#08lx found via RSDP %#08lx\n",
85 virt_to_phys ( rsdt ),
86 ( virt_to_phys ( start ) + offset ) );
87 return rsdt;
88 }
89
90 return NULL;
91}
#define NULL
NULL pointer (VOID *)
Definition Base.h:322
u8 signature
CPU signature.
Definition CIB_PRM.h:7
unsigned char uint8_t
Definition stdint.h:10
uint16_t offset
Offset to command line.
Definition bzimage.h:3
ring len
Length.
Definition dwmac.h:226
static EFI_ACPI_1_0_ROOT_SYSTEM_DESCRIPTION_POINTER * rsdp
ACPI configuration table.
Definition efi_acpi.c:41
#define DBGC(...)
Definition compiler.h:505
uint32_t start
Starting offset.
Definition netvsc.h:1
#define le32_to_cpu(value)
Definition byteswap.h:114
#define RSDP_SIGNATURE
Root System Description Pointer signature.
Definition acpi.h:230
#define RSDP_STRIDE
Stride at which to search for RSDP.
Definition rsdp.c:50
int memcmp(const void *first, const void *second, size_t len)
Compare memory regions.
Definition string.c:115
Root System Description Pointer.
Definition acpi.h:233
ACPI Root System Description Table (RSDT)
Definition acpi.h:250

References DBGC, le32_to_cpu, len, memcmp(), NULL, offset, rsdp, RSDP_SIGNATURE, RSDP_STRIDE, signature, and start.

Referenced by rsdp_find_rsdt().

◆ rsdp_find_rsdt()

const struct acpi_rsdt * rsdp_find_rsdt ( void )
static

Locate ACPI root system description table.

Return values
rsdtACPI root system description table, or NULL

Definition at line 98 of file rsdp.c.

98 {
99 static const struct acpi_rsdt *rsdt;
100 const void *ebda;
101 uint16_t ebda_seg;
102 size_t ebda_len;
103
104 /* Return existing RSDT if already found */
105 if ( rsdt )
106 return rsdt;
107
108 /* Search EBDA */
109 get_real ( ebda_seg, BDA_SEG, BDA_EBDA );
110 if ( ebda_seg < RSDP_EBDA_END_SEG ) {
111 ebda = real_to_virt ( ebda_seg, 0 );
112 ebda_len = ( ( RSDP_EBDA_END_SEG - ebda_seg ) * 16 );
113 rsdt = rsdp_find_rsdt_range ( ebda, ebda_len );
114 if ( rsdt )
115 return rsdt;
116 }
117
118 /* Search fixed BIOS area */
119 rsdt = rsdp_find_rsdt_range ( phys_to_virt ( RSDP_BIOS_START ),
121 if ( rsdt )
122 return rsdt;
123
124 return NULL;
125}
unsigned short uint16_t
Definition stdint.h:11
#define BDA_SEG
Definition bios.h:6
#define BDA_EBDA
Definition bios.h:7
#define get_real
Definition libkir.h:151
static __always_inline void * real_to_virt(unsigned int segment, unsigned int offset)
Convert segment:offset address to virtual address.
Definition realmode.h:77
#define RSDP_EBDA_END_SEG
EBDA RSDP maximum segment.
Definition rsdp.c:41
static const struct acpi_rsdt * rsdp_find_rsdt_range(const void *start, size_t len)
Locate ACPI root system description table within a memory range.
Definition rsdp.c:59
#define RSDP_BIOS_LEN
Fixed BIOS area RSDP length.
Definition rsdp.c:47
#define RSDP_BIOS_START
Fixed BIOS area RSDP start address.
Definition rsdp.c:44

References BDA_EBDA, BDA_SEG, get_real, NULL, real_to_virt(), RSDP_BIOS_LEN, RSDP_BIOS_START, RSDP_EBDA_END_SEG, and rsdp_find_rsdt_range().

Referenced by PROVIDE_ACPI().

◆ PROVIDE_ACPI()

PROVIDE_ACPI ( rsdp ,
acpi_find_rsdt ,
rsdp_find_rsdt  )

◆ PROVIDE_ACPI_INLINE()

PROVIDE_ACPI_INLINE ( rsdp ,
acpi_find  )

References acpi_find(), and rsdp.