iPXE
acpi_test.c File Reference

ACPI tests. More...

#include <string.h>
#include <ipxe/acpi.h>
#include <ipxe/acpimac.h>
#include <ipxe/if_ether.h>
#include <ipxe/test.h>

Go to the source code of this file.

Data Structures

union  acpi_test_signature
 An ACPI test table signature. More...
struct  acpi_test_table
 An ACPI test table. More...
struct  acpi_test_tables
 An ACPI test table set. More...
struct  acpi_mac_test
 An ACPI MAC extraction test. More...

Macros

#define DATA(...)
 Define inline data.
#define ACPI_TABLE(name, SIGNATURE, DATA)
 Define an ACPI test table.
#define ACPI_TABLES(name, ...)
 Define an ACPI test table set.
#define ACPI_MAC(name, TABLES, EXPECTED)
 Define an ACPI MAC extraction test.
#define acpi_mac_ok(test)

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
 ACPI_TABLE (amac_ssdt, "SSDT", DATA(0x53, 0x53, 0x44, 0x54, 0x5d, 0x00, 0x00, 0x00, 0x02, 0x89, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x49, 0x4e, 0x54, 0x4c, 0x04, 0x06, 0x21, 0x20, 0x10, 0x38, 0x5c, 0x5f, 0x53, 0x42, 0x5f, 0x14, 0x08, 0x48, 0x57, 0x30, 0x30, 0x08, 0xa4, 0x00, 0x14, 0x1e, 0x41, 0x4d, 0x41, 0x43, 0x08, 0x0d, 0x5f, 0x41, 0x55, 0x58, 0x4d, 0x41, 0x43, 0x5f, 0x23, 0x35, 0x32, 0x35, 0x34, 0x30, 0x30, 0x61, 0x61, 0x62, 0x62, 0x63, 0x63, 0x23, 0x00, 0x14, 0x09, 0x48, 0x57, 0x34, 0x32, 0x08, 0xa4, 0x0a, 0x2a))
 "AMAC" SSDT
 ACPI_TABLES (amac_tables, &amac_ssdt)
 "AMAC" test tables
 ACPI_MAC (amac, &amac_tables, DATA(0x52, 0x54, 0x00, 0xaa, 0xbb, 0xcc))
 "AMAC" test
 ACPI_TABLE (maca_ssdt1, "SSDT", DATA(0x53, 0x53, 0x44, 0x54, 0x3e, 0x00, 0x00, 0x00, 0x02, 0x5f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x49, 0x4e, 0x54, 0x4c, 0x04, 0x06, 0x21, 0x20, 0x10, 0x19, 0x5c, 0x5f, 0x53, 0x42, 0x5f, 0x14, 0x08, 0x48, 0x57, 0x30, 0x30, 0x08, 0xa4, 0x00, 0x14, 0x09, 0x48, 0x57, 0x34, 0x32, 0x08, 0xa4, 0x0a, 0x2a))
 "MACA" SSDT1 (does not contain AUXMAC)
 ACPI_TABLE (maca_ssdt2, "SSDT", DATA(0x53, 0x53, 0x44, 0x54, 0x54, 0x00, 0x00, 0x00, 0x02, 0x3d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x49, 0x4e, 0x54, 0x4c, 0x04, 0x06, 0x21, 0x20, 0x10, 0x2f, 0x5c, 0x5f, 0x53, 0x42, 0x5f, 0x14, 0x1e, 0x4d, 0x41, 0x43, 0x41, 0x08, 0x0d, 0x5f, 0x41, 0x55, 0x58, 0x4d, 0x41, 0x43, 0x5f, 0x23, 0x35, 0x32, 0x35, 0x34, 0x30, 0x30, 0x31, 0x31, 0x32, 0x32, 0x33, 0x33, 0x23, 0x00, 0x14, 0x09, 0x48, 0x57, 0x39, 0x39, 0x08, 0xa4, 0x0a, 0x63))
 "MACA" SSDT2 (contains AUXMAC)
 ACPI_TABLES (maca_tables, &maca_ssdt1, &maca_ssdt2)
 "MACA" test tables
 ACPI_MAC (maca, &maca_tables, DATA(0x52, 0x54, 0x00, 0x11, 0x22, 0x33))
 "MACA" test
 ACPI_TABLE (rtma_ssdt, "SSDT", DATA(0x53, 0x53, 0x44, 0x54, 0x44, 0x00, 0x00, 0x00, 0x02, 0x6d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x49, 0x4e, 0x54, 0x4c, 0x04, 0x06, 0x21, 0x20, 0x10, 0x1f, 0x5c, 0x5f, 0x53, 0x42, 0x5f, 0x14, 0x18, 0x52, 0x54, 0x4d, 0x41, 0x08, 0x0d, 0x5f, 0x52, 0x54, 0x58, 0x4d, 0x41, 0x43, 0x5f, 0x23, 0x52, 0x54, 0x30, 0x30, 0x30, 0x31, 0x23, 0x00))
 "RTMA" SSDT
 ACPI_TABLES (rtma_tables, &rtma_ssdt)
 "RTMA" test tables
 ACPI_MAC (rtma, &rtma_tables, DATA(0x52, 0x54, 0x30, 0x30, 0x30, 0x31))
 "RTMA" test
static const struct acpi_headeracpi_test_find (uint32_t signature, unsigned int index)
 Locate ACPI test table.
 typeof (acpi_find)
 Override ACPI table finder.
static void acpi_test_exec (void)
 Perform ACPI self-test.

Variables

static struct acpi_test_tables * acpi_test_tables
 Current ACPI test table set.
struct self_test acpi_test __self_test
 ACPI self-test.

Detailed Description

ACPI tests.

Definition in file acpi_test.c.

Macro Definition Documentation

◆ DATA

#define DATA ( ...)
Value:
{ __VA_ARGS__ }

Define inline data.

Definition at line 74 of file acpi_test.c.

Referenced by ACPI_MAC(), ACPI_MAC(), ACPI_MAC(), ACPI_TABLE(), ACPI_TABLE(), ACPI_TABLE(), ACPI_TABLE(), ASN1(), ASN1(), ASN1(), AUTHENTICATE_TEST(), BASE16(), BASE16(), BASE64(), BASE64(), CERTIFICATE(), CERTIFICATE(), CERTIFICATE(), CERTIFICATE(), CERTIFICATE(), CERTIFICATE(), CERTIFICATE(), CERTIFICATE(), CERTIFICATE(), CERTIFICATE(), CERTIFICATE(), CERTIFICATE(), CERTIFICATE(), CERTIFICATE(), CERTIFICATE(), CERTIFICATE(), CERTIFICATE(), CRC32_TEST(), CRC32_TEST(), CRC32_TEST(), CRC32_TEST(), DEFLATE(), DEFLATE(), DEFLATE(), DEFLATE(), DEFLATE(), DEFLATE(), DEFLATE(), DEFLATE(), DNS_COMPARE(), DNS_COMPARE(), DNS_COMPARE(), DNS_COMPARE(), DNS_COMPARE(), DNS_COPY(), DNS_COPY(), DNS_COPY(), DNS_COPY(), DNS_DECODE(), DNS_DECODE(), DNS_DECODE(), DNS_DECODE(), DNS_DECODE(), DNS_DECODE(), DNS_DECODE(), DNS_DECODE(), DNS_DECODE(), DNS_ENCODE(), DNS_ENCODE(), DNS_ENCODE(), DNS_ENCODE(), DNS_ENCODE(), DNS_LIST(), GZIP(), GZIP(), GZIP(), HMAC_TEST(), HMAC_TEST(), HMAC_TEST(), HMAC_TEST(), HMAC_TEST(), IMAGE(), IMAGE(), IMAGE(), IMAGE_RW(), IMAGE_RW(), KEY_TEST(), KEYPAIR(), MESSAGE(), MESSAGE(), MESSAGE(), MESSAGE(), MESSAGE(), MESSAGE(), MSCHAPV2_TEST(), OCSP(), OCSP(), OCSP(), OCSP(), OCSP(), PEERDIST_INFO_BLOCK_TEST(), PEERDIST_INFO_BLOCK_TEST(), PEERDIST_INFO_BLOCK_TEST(), PEERDIST_INFO_BLOCK_TEST(), PEERDIST_INFO_SEGMENT_TEST(), PEERDIST_INFO_SEGMENT_TEST(), PEERDIST_INFO_SEGMENT_TEST(), PEERDIST_INFO_TEST(), PEERDIST_INFO_TEST(), PIX(), PIX(), PIX(), PIX(), PIX(), PIX(), PIX(), PIX(), PIX(), PIX(), PIX(), PIX(), PIX(), PIX(), PIX(), PIX(), PIX(), PIX(), PIX(), PIX(), PIX(), PIX(), PIX(), PIX(), PIX(), PIX(), PIX(), PIX(), PIX(), PIX(), PIX(), PIX(), PIX(), PIX(), PIX(), PIX(), PIX(), PIX(), PIX(), PROFILE_TEST(), PROFILE_TEST(), PROFILE_TEST(), PROFILE_TEST(), PROFILE_TEST(), PROFILE_TEST(), SERVER_PASSPHRASE(), TCPIP_TEST(), TCPIP_TEST(), TCPIP_TEST(), TCPIP_TEST(), TCPIP_TEST(), TCPIP_TEST(), TCPIP_TEST(), UTF8_ACCUMULATE(), UTF8_ACCUMULATE(), UTF8_ACCUMULATE(), UTF8_ACCUMULATE(), UTF8_ACCUMULATE(), UTF8_ACCUMULATE(), UTF8_ACCUMULATE(), UTF8_ACCUMULATE(), and ZLIB().

◆ ACPI_TABLE

#define ACPI_TABLE ( name,
SIGNATURE,
DATA )
Value:
static const uint8_t name ## _data[] = DATA; \
static struct acpi_test_table name = { \
.signature = { \
.str = SIGNATURE, \
}, \
.data = name ## _data, \
}
#define DATA(...)
Define inline data.
Definition acpi_test.c:74
unsigned char uint8_t
Definition stdint.h:10
const char * name
Definition ath9k_hw.c:1986
#define SIGNATURE(...)
Define inline signature data.
Definition pubkey_test.h:60
An ACPI test table.
Definition acpi_test.c:50

Define an ACPI test table.

Definition at line 77 of file acpi_test.c.

77#define ACPI_TABLE( name, SIGNATURE, DATA ) \
78 static const uint8_t name ## _data[] = DATA; \
79 static struct acpi_test_table name = { \
80 .signature = { \
81 .str = SIGNATURE, \
82 }, \
83 .data = name ## _data, \
84 }

◆ ACPI_TABLES

#define ACPI_TABLES ( name,
... )
Value:
static struct acpi_test_table * name ## _table[] = \
{ __VA_ARGS__ }; \
static struct acpi_test_tables name = { \
.table = name ## _table, \
.count = ( sizeof ( name ## _table ) / \
sizeof ( name ## _table[0] ) ), \
}
An ACPI test table set.
Definition acpi_test.c:58

Define an ACPI test table set.

Definition at line 87 of file acpi_test.c.

87#define ACPI_TABLES( name, ... ) \
88 static struct acpi_test_table * name ## _table[] = \
89 { __VA_ARGS__ }; \
90 static struct acpi_test_tables name = { \
91 .table = name ## _table, \
92 .count = ( sizeof ( name ## _table ) / \
93 sizeof ( name ## _table[0] ) ), \
94 }

◆ ACPI_MAC

#define ACPI_MAC ( name,
TABLES,
EXPECTED )
Value:
static struct acpi_mac_test name = { \
.tables = TABLES, \
.expected = EXPECTED, \
}
#define EXPECTED(...)
Define inline expected result point.
An ACPI MAC extraction test.
Definition acpi_test.c:66

Define an ACPI MAC extraction test.

Definition at line 97 of file acpi_test.c.

97#define ACPI_MAC( name, TABLES, EXPECTED ) \
98 static struct acpi_mac_test name = { \
99 .tables = TABLES, \
100 .expected = EXPECTED, \
101 }

◆ acpi_mac_ok

#define acpi_mac_ok ( test)
Value:
acpi_mac_okx ( test, __FILE__, __LINE__ )
static int test
Definition epic100.c:73

Definition at line 240 of file acpi_test.c.

240#define acpi_mac_ok( test ) \
241 acpi_mac_okx ( test, __FILE__, __LINE__ )

Referenced by acpi_test_exec().

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )

◆ ACPI_TABLE() [1/4]

ACPI_TABLE ( amac_ssdt ,
"SSDT" ,
DATA(0x53, 0x53, 0x44, 0x54, 0x5d, 0x00, 0x00, 0x00, 0x02, 0x89, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x49, 0x4e, 0x54, 0x4c, 0x04, 0x06, 0x21, 0x20, 0x10, 0x38, 0x5c, 0x5f, 0x53, 0x42, 0x5f, 0x14, 0x08, 0x48, 0x57, 0x30, 0x30, 0x08, 0xa4, 0x00, 0x14, 0x1e, 0x41, 0x4d, 0x41, 0x43, 0x08, 0x0d, 0x5f, 0x41, 0x55, 0x58, 0x4d, 0x41, 0x43, 0x5f, 0x23, 0x35, 0x32, 0x35, 0x34, 0x30, 0x30, 0x61, 0x61, 0x62, 0x62, 0x63, 0x63, 0x23, 0x00, 0x14, 0x09, 0x48, 0x57, 0x34, 0x32, 0x08, 0xa4, 0x0a, 0x2a)  )

"AMAC" SSDT

DefinitionBlock ("", "SSDT", 2, "", "", 0x0) { Scope (_SB) { Method (HW00, 0, Serialized) { Return(0) } Method (AMAC, 0, Serialized) { ToString("_AUXMAC_#525400aabbcc#") } Method (HW42, 0, Serialized) { Return(42) } } }

References DATA.

◆ ACPI_TABLES() [1/3]

ACPI_TABLES ( amac_tables ,
& amac_ssdt )

"AMAC" test tables

◆ ACPI_MAC() [1/3]

ACPI_MAC ( amac ,
& amac_tables,
DATA(0x52, 0x54, 0x00, 0xaa, 0xbb, 0xcc)  )

"AMAC" test

References DATA.

◆ ACPI_TABLE() [2/4]

ACPI_TABLE ( maca_ssdt1 ,
"SSDT" ,
DATA(0x53, 0x53, 0x44, 0x54, 0x3e, 0x00, 0x00, 0x00, 0x02, 0x5f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x49, 0x4e, 0x54, 0x4c, 0x04, 0x06, 0x21, 0x20, 0x10, 0x19, 0x5c, 0x5f, 0x53, 0x42, 0x5f, 0x14, 0x08, 0x48, 0x57, 0x30, 0x30, 0x08, 0xa4, 0x00, 0x14, 0x09, 0x48, 0x57, 0x34, 0x32, 0x08, 0xa4, 0x0a, 0x2a)  )

"MACA" SSDT1 (does not contain AUXMAC)

References DATA.

◆ ACPI_TABLE() [3/4]

ACPI_TABLE ( maca_ssdt2 ,
"SSDT" ,
DATA(0x53, 0x53, 0x44, 0x54, 0x54, 0x00, 0x00, 0x00, 0x02, 0x3d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x49, 0x4e, 0x54, 0x4c, 0x04, 0x06, 0x21, 0x20, 0x10, 0x2f, 0x5c, 0x5f, 0x53, 0x42, 0x5f, 0x14, 0x1e, 0x4d, 0x41, 0x43, 0x41, 0x08, 0x0d, 0x5f, 0x41, 0x55, 0x58, 0x4d, 0x41, 0x43, 0x5f, 0x23, 0x35, 0x32, 0x35, 0x34, 0x30, 0x30, 0x31, 0x31, 0x32, 0x32, 0x33, 0x33, 0x23, 0x00, 0x14, 0x09, 0x48, 0x57, 0x39, 0x39, 0x08, 0xa4, 0x0a, 0x63)  )

"MACA" SSDT2 (contains AUXMAC)

References DATA.

◆ ACPI_TABLES() [2/3]

ACPI_TABLES ( maca_tables ,
& maca_ssdt1,
& maca_ssdt2 )

"MACA" test tables

◆ ACPI_MAC() [2/3]

ACPI_MAC ( maca ,
& maca_tables,
DATA(0x52, 0x54, 0x00, 0x11, 0x22, 0x33)  )

"MACA" test

References DATA.

◆ ACPI_TABLE() [4/4]

ACPI_TABLE ( rtma_ssdt ,
"SSDT" ,
DATA(0x53, 0x53, 0x44, 0x54, 0x44, 0x00, 0x00, 0x00, 0x02, 0x6d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x49, 0x4e, 0x54, 0x4c, 0x04, 0x06, 0x21, 0x20, 0x10, 0x1f, 0x5c, 0x5f, 0x53, 0x42, 0x5f, 0x14, 0x18, 0x52, 0x54, 0x4d, 0x41, 0x08, 0x0d, 0x5f, 0x52, 0x54, 0x58, 0x4d, 0x41, 0x43, 0x5f, 0x23, 0x52, 0x54, 0x30, 0x30, 0x30, 0x31, 0x23, 0x00)  )

"RTMA" SSDT

References DATA.

◆ ACPI_TABLES() [3/3]

ACPI_TABLES ( rtma_tables ,
& rtma_ssdt )

"RTMA" test tables

◆ ACPI_MAC() [3/3]

ACPI_MAC ( rtma ,
& rtma_tables,
DATA(0x52, 0x54, 0x30, 0x30, 0x30, 0x31)  )

"RTMA" test

References DATA.

◆ acpi_test_find()

const struct acpi_header * acpi_test_find ( uint32_t signature,
unsigned int index )
static

Locate ACPI test table.

Parameters
signatureRequested table signature
indexRequested index of table with this signature
Return values
tableTable, or NULL if not found

Definition at line 191 of file acpi_test.c.

192 {
193 struct acpi_test_table *table;
194 unsigned int i;
195
196 /* Fail if no test tables are installed */
197 if ( ! acpi_test_tables )
198 return NULL;
199
200 /* Scan through test tables */
201 for ( i = 0 ; i < acpi_test_tables->count ; i++ ) {
202 table = acpi_test_tables->table[i];
203 if ( ( signature == le32_to_cpu ( table->signature.raw ) ) &&
204 ( index-- == 0 ) ) {
205 return table->data;
206 }
207 }
208
209 return NULL;
210}
#define NULL
NULL pointer (VOID *)
Definition Base.h:322
u8 signature
CPU signature.
Definition CIB_PRM.h:7
long index
Definition bigint.h:65
#define le32_to_cpu(value)
Definition byteswap.h:114
const void * data
Table content.
Definition acpi_test.c:54
union acpi_test_signature signature
Signature.
Definition acpi_test.c:52
struct acpi_test_table ** table
Tables.
Definition acpi_test.c:60
unsigned int count
Number of tables.
Definition acpi_test.c:62
uint32_t raw
Raw value.
Definition acpi_test.c:46

References acpi_test_tables::count, acpi_test_table::data, index, le32_to_cpu, NULL, acpi_test_signature::raw, acpi_test_table::signature, signature, and acpi_test_tables::table.

Referenced by typeof().

◆ typeof()

typeof ( acpi_find )

Override ACPI table finder.

Definition at line 213 of file acpi_test.c.

223 {
225 int rc;
226
227 /* Set test table set */
228 acpi_test_tables = test->tables;
229
230 /* Extract MAC address */
231 rc = acpi_mac ( mac );
232 okx ( rc == 0, file, line );
233
234 /* Check extracted MAC address */
235 okx ( memcmp ( mac, test->expected, ETH_ALEN ) == 0, file, line );
236
237 /* Clear test table set */
239}
int acpi_mac(uint8_t *hw_addr)
Extract MAC address from DSDT/SSDT.
Definition acpimac.c:235
struct arbelprm_rc_send_wqe rc
Definition arbel.h:3
uint8_t mac[ETH_ALEN]
MAC address.
Definition ena.h:13
#define ETH_ALEN
Definition if_ether.h:9
int memcmp(const void *first, const void *second, size_t len)
Compare memory regions.
Definition string.c:115
#define okx(success, file, line)
Report test result.
Definition test.h:44

References acpi_find(), acpi_finder, acpi_mac(), acpi_test_find(), ETH_ALEN, mac, memcmp(), NULL, okx, rc, and test.

◆ acpi_test_exec()

void acpi_test_exec ( void )
static

Perform ACPI self-test.

Definition at line 247 of file acpi_test.c.

247 {
248
249 /* MAC extraction tests */
250 acpi_mac_ok ( &amac );
251 acpi_mac_ok ( &maca );
252 acpi_mac_ok ( &rtma );
253}
#define acpi_mac_ok(test)
Definition acpi_test.c:240

References acpi_mac_ok.

Variable Documentation

◆ acpi_test_tables

struct acpi_test_tables* acpi_test_tables
static

Current ACPI test table set.

Definition at line 182 of file acpi_test.c.

◆ __self_test

struct self_test acpi_test __self_test
Initial value:
= {
.name = "acpi",
.exec = acpi_test_exec,
}
static void acpi_test_exec(void)
Perform ACPI self-test.
Definition acpi_test.c:247

ACPI self-test.

Definition at line 256 of file acpi_test.c.

256 {
257 .name = "acpi",
258 .exec = acpi_test_exec,
259};