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

Defines

#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 userptr_t rsdp_find_rsdt_range (userptr_t start, size_t len)
 Locate ACPI root system description table within a memory range.
static userptr_t rsdp_find_rsdt (void)
 Locate ACPI root system description table.
 PROVIDE_ACPI (rsdp, acpi_find_rsdt, rsdp_find_rsdt)

Detailed Description

ACPI Root System Description Pointer.

Definition in file rsdp.c.


Define Documentation

#define RSDP_EBDA_END_SEG   0xa000

EBDA RSDP maximum segment.

Definition at line 40 of file rsdp.c.

Referenced by rsdp_find_rsdt().

#define RSDP_BIOS_START   0xe0000

Fixed BIOS area RSDP start address.

Definition at line 43 of file rsdp.c.

Referenced by rsdp_find_rsdt().

#define RSDP_BIOS_LEN   0x20000

Fixed BIOS area RSDP length.

Definition at line 46 of file rsdp.c.

Referenced by rsdp_find_rsdt().

#define RSDP_STRIDE   16

Stride at which to search for RSDP.

Definition at line 49 of file rsdp.c.

Referenced by rsdp_find_rsdt_range().


Function Documentation

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )
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.

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

Referenced by rsdp_find_rsdt().

                                                                      {
        static const char signature[8] = RSDP_SIGNATURE;
        struct acpi_rsdp rsdp;
        userptr_t rsdt;
        size_t offset;
        uint8_t sum;
        unsigned int i;

        /* Search for RSDP */
        for ( offset = 0 ; ( ( offset + sizeof ( rsdp ) ) < len ) ;
              offset += RSDP_STRIDE ) {

                /* Check signature and checksum */
                copy_from_user ( &rsdp, start, offset, sizeof ( rsdp ) );
                if ( memcmp ( rsdp.signature, signature,
                              sizeof ( signature ) ) != 0 )
                        continue;
                for ( sum = 0, i = 0 ; i < sizeof ( rsdp ) ; i++ )
                        sum += *( ( ( uint8_t * ) &rsdp ) + i );
                if ( sum != 0 )
                        continue;

                /* Extract RSDT */
                rsdt = phys_to_user ( le32_to_cpu ( rsdp.rsdt ) );
                DBGC ( rsdt, "RSDT %#08lx found via RSDP %#08lx\n",
                       user_to_phys ( rsdt, 0 ),
                       user_to_phys ( start, offset ) );
                return rsdt;
        }

        return UNULL;
}
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.

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.

                                         {
        static userptr_t rsdt;
        uint16_t ebda_seg;
        userptr_t ebda;
        size_t ebda_len;

        /* Return existing RSDT if already found */
        if ( rsdt )
                return rsdt;

        /* Search EBDA */
        get_real ( ebda_seg, BDA_SEG, BDA_EBDA );
        if ( ebda_seg < RSDP_EBDA_END_SEG ) {
             ebda = real_to_user ( ebda_seg, 0 );
             ebda_len = ( ( RSDP_EBDA_END_SEG - ebda_seg ) * 16 );
             rsdt = rsdp_find_rsdt_range ( ebda, ebda_len );
             if ( rsdt )
                     return rsdt;
        }

        /* Search fixed BIOS area */
        rsdt = rsdp_find_rsdt_range ( phys_to_user ( RSDP_BIOS_START ),
                                      RSDP_BIOS_LEN );
        if ( rsdt )
                return rsdt;

        return UNULL;
}