iPXE
Data Structures | Macros | Functions | Variables
acpi_test.c File Reference

ACPI tests. More...

#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(...)   { __VA_ARGS__ }
 Define inline data. More...
 
#define ACPI_TABLE(name, SIGNATURE, DATA)
 Define an ACPI test table. More...
 
#define ACPI_TABLES(name, ...)
 Define an ACPI test table set. More...
 
#define ACPI_MAC(name, TABLES, EXPECTED)
 Define an ACPI MAC extraction test. More...
 
#define acpi_mac_ok(test)   acpi_mac_okx ( test, __FILE__, __LINE__ )
 

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 More...
 
 ACPI_TABLES (amac_tables, &amac_ssdt)
 "AMAC" test tables More...
 
 ACPI_MAC (amac, &amac_tables, DATA(0x52, 0x54, 0x00, 0xaa, 0xbb, 0xcc))
 "AMAC" test More...
 
 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) More...
 
 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) More...
 
 ACPI_TABLES (maca_tables, &maca_ssdt1, &maca_ssdt2)
 "MACA" test tables More...
 
 ACPI_MAC (maca, &maca_tables, DATA(0x52, 0x54, 0x00, 0x11, 0x22, 0x33))
 "MACA" test More...
 
 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 More...
 
 ACPI_TABLES (rtma_tables, &rtma_ssdt)
 "RTMA" test tables More...
 
 ACPI_MAC (rtma, &rtma_tables, DATA(0x52, 0x54, 0x30, 0x30, 0x30, 0x31))
 "RTMA" test More...
 
static userptr_t acpi_test_find (uint32_t signature, unsigned int index)
 Locate ACPI test table. More...
 
 typeof (acpi_find)
 Override ACPI table finder. More...
 
static void acpi_test_exec (void)
 Perform ACPI self-test. More...
 

Variables

static struct acpi_test_tablesacpi_test_tables
 Current ACPI test table set. More...
 
struct self_test acpi_test __self_test
 ACPI self-test. More...
 

Detailed Description

ACPI tests.

Definition in file acpi_test.c.

Macro Definition Documentation

◆ DATA

#define DATA (   ...)    { __VA_ARGS__ }

Define inline data.

Definition at line 73 of file acpi_test.c.

◆ 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, \
}
const char * name
Definition: ath9k_hw.c:1984
unsigned char uint8_t
Definition: stdint.h:10
#define SIGNATURE(name, DATA)
Define a test signature.
Definition: cms_test.c:80
An ACPI test table.
Definition: acpi_test.c:49
#define DATA(...)
Define inline data.
Definition: acpi_test.c:73

Define an ACPI test table.

Definition at line 76 of file acpi_test.c.

◆ 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] ) ), \
}
const char * name
Definition: ath9k_hw.c:1984
An ACPI test table set.
Definition: acpi_test.c:57
An ACPI test table.
Definition: acpi_test.c:49

Define an ACPI test table set.

Definition at line 86 of file acpi_test.c.

◆ ACPI_MAC

#define ACPI_MAC (   name,
  TABLES,
  EXPECTED 
)
Value:
static struct acpi_mac_test name = { \
.tables = TABLES, \
.expected = EXPECTED, \
}
#define EXPECTED(...)
Define inline expected HMAC.
Definition: hmac_test.c:49
const char * name
Definition: ath9k_hw.c:1984
An ACPI MAC extraction test.
Definition: acpi_test.c:65

Define an ACPI MAC extraction test.

Definition at line 96 of file acpi_test.c.

◆ acpi_mac_ok

#define acpi_mac_ok (   test)    acpi_mac_okx ( test, __FILE__, __LINE__ )

Definition at line 238 of file acpi_test.c.

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) } } }

◆ 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

◆ 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)

◆ 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)

◆ 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

◆ 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

◆ 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

◆ acpi_test_find()

static userptr_t 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 UNULL if not found

Definition at line 190 of file acpi_test.c.

190  {
191  struct acpi_test_table *table;
192  unsigned int i;
193 
194  /* Fail if no test tables are installed */
195  if ( ! acpi_test_tables )
196  return UNULL;
197 
198  /* Scan through test tables */
199  for ( i = 0 ; i < acpi_test_tables->count ; i++ ) {
200  table = acpi_test_tables->table[i];
201  if ( ( signature == le32_to_cpu ( table->signature.raw ) ) &&
202  ( index-- == 0 ) ) {
203  return virt_to_user ( table->data );
204  }
205  }
206 
207  return UNULL;
208 }
#define le32_to_cpu(value)
Definition: byteswap.h:113
struct acpi_test_table ** table
Tables.
Definition: acpi_test.c:59
An ACPI test table set.
Definition: acpi_test.c:57
uint32_t raw
Raw value.
Definition: acpi_test.c:45
unsigned int count
Number of tables.
Definition: acpi_test.c:61
union acpi_test_signature signature
Signature.
Definition: acpi_test.c:51
#define UNULL
Equivalent of NULL for user pointers.
Definition: uaccess.h:36
userptr_t virt_to_user(volatile const void *addr)
Convert virtual address to user pointer.
An ACPI test table.
Definition: acpi_test.c:49
uint64_t index
Index of the first segment within the content.
Definition: pccrc.h:21
u8 signature
Signature.
Definition: CIB_PRM.h:35
const void * data
Table content.
Definition: acpi_test.c:53

References acpi_test_tables::count, acpi_test_table::data, index, le32_to_cpu, acpi_test_signature::raw, signature, acpi_test_table::signature, acpi_test_tables::table, UNULL, and virt_to_user().

◆ typeof()

typeof ( acpi_find  )

Override ACPI table finder.

Definition at line 211 of file acpi_test.c.

221  {
223  int rc;
224 
225  /* Set test table set */
226  acpi_test_tables = test->tables;
227 
228  /* Extract MAC address */
229  rc = acpi_mac ( mac );
230  okx ( rc == 0, file, line );
231 
232  /* Check extracted MAC address */
233  okx ( memcmp ( mac, test->expected, ETH_ALEN ) == 0, file, line );
234 
235  /* Clear test table set */
237 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
uint8_t mac[ETH_ALEN]
MAC address.
Definition: ena.h:24
An ACPI test table set.
Definition: acpi_test.c:57
int acpi_mac(uint8_t *hw_addr)
Extract MAC address from DSDT/SSDT.
Definition: acpimac.c:233
#define okx(success, file, line)
Report test result.
Definition: test.h:44
unsigned char uint8_t
Definition: stdint.h:10
#define ETH_ALEN
Definition: if_ether.h:8
int memcmp(const void *first, const void *second, size_t len)
Compare memory regions.
Definition: string.c:114
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321
static int test
Definition: epic100.c:73

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

◆ acpi_test_exec()

static void acpi_test_exec ( void  )
static

Perform ACPI self-test.

Definition at line 245 of file acpi_test.c.

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

References acpi_mac_ok.

Variable Documentation

◆ acpi_test_tables

Current ACPI test table set.

Definition at line 181 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:245

ACPI self-test.

Definition at line 254 of file acpi_test.c.