iPXE
Functions | Variables
acpi_settings.c File Reference

ACPI settings. More...

#include <string.h>
#include <errno.h>
#include <ipxe/init.h>
#include <ipxe/settings.h>
#include <ipxe/acpi.h>

Go to the source code of this file.

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
static int acpi_settings_applies (struct settings *settings __unused, const struct setting *setting)
 Check applicability of ACPI setting.
static int acpi_settings_fetch (struct settings *settings, struct setting *setting, void *data, size_t len)
 Fetch value of ACPI setting.
static void acpi_settings_init (void)
 Initialise ACPI settings.
struct init_fn
acpi_settings_init_fn 
__init_fn (INIT_NORMAL)
 ACPI settings initialiser.

Variables

static struct settings_scope acpi_settings_scope
 ACPI settings scope.
static struct settings_operations acpi_settings_operations
 ACPI settings operations.
static struct settings acpi_settings
 ACPI settings.

Detailed Description

ACPI settings.

Definition in file acpi_settings.c.


Function Documentation

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )
static int acpi_settings_applies ( struct settings *settings  __unused,
const struct setting setting 
) [static]

Check applicability of ACPI setting.

Parameters:
settingsSettings block
settingSetting
Return values:
appliesSetting applies within this settings block

Definition at line 49 of file acpi_settings.c.

References acpi_settings_scope, and setting::scope.

                                                                   {

        return ( setting->scope == &acpi_settings_scope );
}
static int acpi_settings_fetch ( struct settings settings,
struct setting setting,
void *  data,
size_t  len 
) [static]

Fetch value of ACPI setting.

Parameters:
settingsSettings block
settingSetting to fetch
dataBuffer to fill with setting data
lenLength of buffer
Return values:
lenLength of setting data, or negative error

Definition at line 64 of file acpi_settings.c.

References acpi_find(), acpi_name(), bswap_32, copy_from_user(), DBGC, ENOENT, le32_to_cpu, acpi_header::length, max_len, setting_type::numerate, offset, setting::tag, and setting::type.

                                                          {
        struct acpi_header acpi;
        uint32_t tag_high;
        uint32_t tag_low;
        uint32_t tag_signature;
        unsigned int tag_index;
        size_t tag_offset;
        size_t tag_len;
        userptr_t table;
        size_t offset;
        size_t max_len;
        int delta;
        unsigned int i;

        /* Parse settings tag */
        tag_high = ( setting->tag >> 32 );
        tag_low = setting->tag;
        tag_signature = bswap_32 ( tag_high );
        tag_index = ( ( tag_low >> 24 ) & 0xff );
        tag_offset = ( ( tag_low >> 8 ) & 0xffff );
        tag_len = ( ( tag_low >> 0 ) & 0xff );
        DBGC ( settings, "ACPI %s.%d offset %#zx length %#zx\n",
               acpi_name ( tag_signature ), tag_index, tag_offset, tag_len );

        /* Locate ACPI table */
        table = acpi_find ( tag_signature, tag_index );
        if ( ! table )
                return -ENOENT;

        /* Read table header */
        copy_from_user ( &acpi, table, 0, sizeof ( acpi ) );

        /* Calculate starting offset and maximum available length */
        max_len = le32_to_cpu ( acpi.length );
        if ( tag_offset > max_len )
                return -ENOENT;
        offset = tag_offset;
        max_len -= offset;

        /* Restrict to requested length, if specified */
        if ( tag_len && ( tag_len < max_len ) )
                max_len = tag_len;

        /* Invert endianness for numeric settings */
        if ( setting->type && setting->type->numerate ) {
                offset += ( max_len - 1 );
                delta = -1;
        } else {
                delta = +1;
        }

        /* Read data */
        for ( i = 0 ; ( ( i < max_len ) && ( i < len ) ) ; i++ ) {
                copy_from_user ( data, table, offset, 1 );
                data++;
                offset += delta;
        }

        /* Set type if not already specified */
        if ( ! setting->type )
                setting->type = &setting_type_hexraw;

        return max_len;
}
static void acpi_settings_init ( void  ) [static]

Initialise ACPI settings.

Definition at line 147 of file acpi_settings.c.

References DBG, NULL, rc, register_settings(), and strerror().

                                        {
        int rc;

        if ( ( rc = register_settings ( &acpi_settings, NULL,
                                        "acpi" ) ) != 0 ) {
                DBG ( "ACPI could not register settings: %s\n",
                      strerror ( rc ) );
                return;
        }
}
struct init_fn acpi_settings_init_fn __init_fn ( INIT_NORMAL  ) [read]

ACPI settings initialiser.


Variable Documentation

ACPI settings scope.

Definition at line 40 of file acpi_settings.c.

Referenced by acpi_settings_applies().

Initial value:
 {
        .applies = acpi_settings_applies,
        .fetch = acpi_settings_fetch,
}

ACPI settings operations.

Definition at line 132 of file acpi_settings.c.

struct settings acpi_settings [static]
Initial value:
 {
        .refcnt = NULL,
        .siblings = LIST_HEAD_INIT ( acpi_settings.siblings ),
        .children = LIST_HEAD_INIT ( acpi_settings.children ),
        .op = &acpi_settings_operations,
        .default_scope = &acpi_settings_scope,
}

ACPI settings.

Definition at line 138 of file acpi_settings.c.