iPXE
Data Structures | Macros | Functions | Variables
acpi.h File Reference

ACPI data structures. More...

#include <stdint.h>
#include <byteswap.h>
#include <ipxe/refcnt.h>
#include <ipxe/list.h>
#include <ipxe/interface.h>
#include <ipxe/uaccess.h>
#include <ipxe/tables.h>
#include <ipxe/api.h>
#include <config/general.h>
#include <ipxe/null_acpi.h>
#include <ipxe/efi/efi_acpi.h>
#include <ipxe/linux/linux_acpi.h>
#include <bits/acpi.h>

Go to the source code of this file.

Data Structures

struct  acpi_small_resource
 An ACPI small resource descriptor header. More...
 
struct  acpi_end_resource
 An ACPI end resource descriptor. More...
 
struct  acpi_large_resource
 An ACPI large resource descriptor header. More...
 
struct  acpi_qword_address_space_resource
 An ACPI QWORD address space resource descriptor. More...
 
union  acpi_resource
 An ACPI resource descriptor. More...
 
struct  acpi_header
 An ACPI description header. More...
 
struct  acpi_rsdp
 Root System Description Pointer. More...
 
struct  acpi_rsdt
 ACPI Root System Description Table (RSDT) More...
 
struct  acpi_fadt
 Fixed ACPI Description Table (FADT) More...
 
struct  acpi_descriptor
 An ACPI descriptor (used to construct ACPI tables) More...
 
struct  acpi_model
 An ACPI table model. More...
 

Macros

#define ACPI_SMALL_LEN_MASK   0x03
 ACPI small resource length mask. More...
 
#define ACPI_END_RESOURCE   0x78
 An ACPI end resource descriptor. More...
 
#define ACPI_LARGE   0x80
 ACPI large resource flag. More...
 
#define ACPI_QWORD_ADDRESS_SPACE_RESOURCE   0x8a
 An ACPI QWORD address space resource descriptor. More...
 
#define ACPI_ADDRESS_TYPE_MEM   0x00
 A memory address space type. More...
 
#define ACPI_ADDRESS_TYPE_BUS   0x02
 A bus number address space type. More...
 
#define ACPI_SIGNATURE(a, b, c, d)   ( ( (a) << 0 ) | ( (b) << 8 ) | ( (c) << 16 ) | ( (d) << 24 ) )
 Build ACPI signature. More...
 
#define RSDP_SIGNATURE   { 'R', 'S', 'D', ' ', 'P', 'T', 'R', ' ' }
 Root System Description Pointer signature. More...
 
#define RSDT_SIGNATURE   ACPI_SIGNATURE ( 'R', 'S', 'D', 'T' )
 Root System Description Table (RSDT) signature. More...
 
#define FADT_SIGNATURE   ACPI_SIGNATURE ( 'F', 'A', 'C', 'P' )
 Fixed ACPI Description Table (FADT) signature. More...
 
#define ACPI_PM1_CNT   0
 ACPI PM1 Control Register (within PM1a_CNT_BLK or PM1A_CNT_BLK) More...
 
#define ACPI_PM1_CNT_SLP_TYP(x)   ( (x) << 10 )
 Sleep type. More...
 
#define ACPI_PM1_CNT_SLP_EN   ( 1 << 13 )
 Sleep enable. More...
 
#define ACPI_PM_TMR   0
 ACPI PM Timer Register (within PM_TMR_BLK) More...
 
#define DSDT_SIGNATURE   ACPI_SIGNATURE ( 'D', 'S', 'D', 'T' )
 Differentiated System Description Table (DSDT) signature. More...
 
#define SSDT_SIGNATURE   ACPI_SIGNATURE ( 'S', 'S', 'D', 'T' )
 Secondary System Description Table (SSDT) signature. More...
 
#define ACPI_MODELS   __table ( struct acpi_model, "acpi_models" )
 ACPI models. More...
 
#define __acpi_model   __table_entry ( ACPI_MODELS, 01 )
 Declare an ACPI model. More...
 
#define ACPI_INLINE(_subsys, _api_func)   SINGLE_API_INLINE ( ACPI_PREFIX_ ## _subsys, _api_func )
 Calculate static inline ACPI API function name. More...
 
#define PROVIDE_ACPI(_subsys, _api_func, _func)   PROVIDE_SINGLE_API ( ACPI_PREFIX_ ## _subsys, _api_func, _func )
 Provide an ACPI API implementation. More...
 
#define PROVIDE_ACPI_INLINE(_subsys, _api_func)   PROVIDE_SINGLE_API_INLINE ( ACPI_PREFIX_ ## _subsys, _api_func )
 Provide a static inline ACPI API implementation. More...
 
#define acpi_describe_TYPE(object_type)   typeof ( struct acpi_descriptor * ( object_type ) )
 

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
 
static unsigned int acpi_resource_tag (union acpi_resource *res)
 Get ACPI resource tag. More...
 
static size_t acpi_small_len (struct acpi_small_resource *res)
 Get length of ACPI small resource descriptor. More...
 
static size_t acpi_large_len (struct acpi_large_resource *res)
 Get length of ACPI large resource descriptor. More...
 
static size_t acpi_resource_len (union acpi_resource *res)
 Get length of ACPI resource descriptor. More...
 
static union acpi_resourceacpi_resource_next (union acpi_resource *res)
 Get next ACPI resource descriptor. More...
 
static const char * acpi_name (uint32_t signature)
 Transcribe ACPI table signature (for debugging) More...
 
static void acpi_init (struct acpi_descriptor *desc, struct acpi_model *model, struct refcnt *refcnt)
 Initialise ACPI descriptor. More...
 
userptr_t acpi_find_via_rsdt (uint32_t signature, unsigned int index)
 Locate ACPI table via RSDT. More...
 
userptr_t acpi_find_rsdt (void)
 Locate ACPI root system description table. More...
 
userptr_t acpi_find (uint32_t signature, unsigned int index)
 Locate ACPI table. More...
 
struct acpi_descriptoracpi_describe (struct interface *interface)
 Get object's ACPI descriptor. More...
 
void acpi_fix_checksum (struct acpi_header *acpi)
 Fix up ACPI table checksum. More...
 
userptr_t acpi_table (uint32_t signature, unsigned int index)
 Locate ACPI table. More...
 
int acpi_extract (uint32_t signature, void *data, int(*extract)(userptr_t zsdt, size_t len, size_t offset, void *data))
 Extract value from DSDT/SSDT. More...
 
void acpi_add (struct acpi_descriptor *desc)
 Add ACPI descriptor. More...
 
void acpi_del (struct acpi_descriptor *desc)
 Remove ACPI descriptor. More...
 
int acpi_install (int(*install)(struct acpi_header *acpi))
 Install ACPI tables. More...
 

Variables

userptr_t(* acpi_finder )(uint32_t signature, unsigned int index)
 

Detailed Description

ACPI data structures.

Definition in file acpi.h.

Macro Definition Documentation

◆ ACPI_SMALL_LEN_MASK

#define ACPI_SMALL_LEN_MASK   0x03

ACPI small resource length mask.

Definition at line 29 of file acpi.h.

◆ ACPI_END_RESOURCE

#define ACPI_END_RESOURCE   0x78

An ACPI end resource descriptor.

Definition at line 32 of file acpi.h.

◆ ACPI_LARGE

#define ACPI_LARGE   0x80

ACPI large resource flag.

Definition at line 51 of file acpi.h.

◆ ACPI_QWORD_ADDRESS_SPACE_RESOURCE

#define ACPI_QWORD_ADDRESS_SPACE_RESOURCE   0x8a

An ACPI QWORD address space resource descriptor.

Definition at line 54 of file acpi.h.

◆ ACPI_ADDRESS_TYPE_MEM

#define ACPI_ADDRESS_TYPE_MEM   0x00

A memory address space type.

Definition at line 79 of file acpi.h.

◆ ACPI_ADDRESS_TYPE_BUS

#define ACPI_ADDRESS_TYPE_BUS   0x02

A bus number address space type.

Definition at line 82 of file acpi.h.

◆ ACPI_SIGNATURE

#define ACPI_SIGNATURE (   a,
  b,
  c,
  d 
)    ( ( (a) << 0 ) | ( (b) << 8 ) | ( (c) << 16 ) | ( (d) << 24 ) )

Build ACPI signature.

Parameters
aFirst character of ACPI signature
bSecond character of ACPI signature
cThird character of ACPI signature
dFourth character of ACPI signature
Return values
signatureACPI signature

Definition at line 209 of file acpi.h.

◆ RSDP_SIGNATURE

#define RSDP_SIGNATURE   { 'R', 'S', 'D', ' ', 'P', 'T', 'R', ' ' }

Root System Description Pointer signature.

Definition at line 213 of file acpi.h.

◆ RSDT_SIGNATURE

#define RSDT_SIGNATURE   ACPI_SIGNATURE ( 'R', 'S', 'D', 'T' )

Root System Description Table (RSDT) signature.

Definition at line 230 of file acpi.h.

◆ FADT_SIGNATURE

#define FADT_SIGNATURE   ACPI_SIGNATURE ( 'F', 'A', 'C', 'P' )

Fixed ACPI Description Table (FADT) signature.

Definition at line 241 of file acpi.h.

◆ ACPI_PM1_CNT

#define ACPI_PM1_CNT   0

ACPI PM1 Control Register (within PM1a_CNT_BLK or PM1A_CNT_BLK)

Definition at line 264 of file acpi.h.

◆ ACPI_PM1_CNT_SLP_TYP

#define ACPI_PM1_CNT_SLP_TYP (   x)    ( (x) << 10 )

Sleep type.

Definition at line 265 of file acpi.h.

◆ ACPI_PM1_CNT_SLP_EN

#define ACPI_PM1_CNT_SLP_EN   ( 1 << 13 )

Sleep enable.

Definition at line 266 of file acpi.h.

◆ ACPI_PM_TMR

#define ACPI_PM_TMR   0

ACPI PM Timer Register (within PM_TMR_BLK)

Definition at line 269 of file acpi.h.

◆ DSDT_SIGNATURE

#define DSDT_SIGNATURE   ACPI_SIGNATURE ( 'D', 'S', 'D', 'T' )

Differentiated System Description Table (DSDT) signature.

Definition at line 272 of file acpi.h.

◆ SSDT_SIGNATURE

#define SSDT_SIGNATURE   ACPI_SIGNATURE ( 'S', 'S', 'D', 'T' )

Secondary System Description Table (SSDT) signature.

Definition at line 275 of file acpi.h.

◆ ACPI_MODELS

#define ACPI_MODELS   __table ( struct acpi_model, "acpi_models" )

ACPI models.

Definition at line 324 of file acpi.h.

◆ __acpi_model

struct acpi_model ib_sbft_model __acpi_model   __table_entry ( ACPI_MODELS, 01 )

Declare an ACPI model.

IB sBFT model.

aBFT model

Definition at line 327 of file acpi.h.

◆ ACPI_INLINE

#define ACPI_INLINE (   _subsys,
  _api_func 
)    SINGLE_API_INLINE ( ACPI_PREFIX_ ## _subsys, _api_func )

Calculate static inline ACPI API function name.

Parameters
_prefixSubsystem prefix
_api_funcAPI function
Return values
_subsys_funcSubsystem API function

Definition at line 336 of file acpi.h.

◆ PROVIDE_ACPI

#define PROVIDE_ACPI (   _subsys,
  _api_func,
  _func 
)    PROVIDE_SINGLE_API ( ACPI_PREFIX_ ## _subsys, _api_func, _func )

Provide an ACPI API implementation.

Parameters
_prefixSubsystem prefix
_api_funcAPI function
_funcImplementing function

Definition at line 346 of file acpi.h.

◆ PROVIDE_ACPI_INLINE

#define PROVIDE_ACPI_INLINE (   _subsys,
  _api_func 
)    PROVIDE_SINGLE_API_INLINE ( ACPI_PREFIX_ ## _subsys, _api_func )

Provide a static inline ACPI API implementation.

Parameters
_prefixSubsystem prefix
_api_funcAPI function

Definition at line 355 of file acpi.h.

◆ acpi_describe_TYPE

#define acpi_describe_TYPE (   object_type)    typeof ( struct acpi_descriptor * ( object_type ) )

Definition at line 386 of file acpi.h.

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )

◆ acpi_resource_tag()

static unsigned int acpi_resource_tag ( union acpi_resource res)
inlinestatic

Get ACPI resource tag.

Parameters
resACPI resource descriptor
Return values
tagResource tag

Definition at line 104 of file acpi.h.

104  {
105 
106  return ( ( res->tag & ACPI_LARGE ) ?
107  res->tag : ( res->tag & ~ACPI_SMALL_LEN_MASK ) );
108 }
uint8_t tag
Tag byte.
Definition: acpi.h:87
#define ACPI_SMALL_LEN_MASK
ACPI small resource length mask.
Definition: acpi.h:29
#define ACPI_LARGE
ACPI large resource flag.
Definition: acpi.h:51

References ACPI_LARGE, ACPI_SMALL_LEN_MASK, and acpi_resource::tag.

Referenced by efipci_ioremap(), and efipci_root_match().

◆ acpi_small_len()

static size_t acpi_small_len ( struct acpi_small_resource res)
inlinestatic

Get length of ACPI small resource descriptor.

Parameters
resSmall resource descriptor
Return values
lenLength of descriptor

Definition at line 116 of file acpi.h.

116  {
117 
118  return ( sizeof ( *res ) + ( res->tag & ACPI_SMALL_LEN_MASK ) );
119 }
#define ACPI_SMALL_LEN_MASK
ACPI small resource length mask.
Definition: acpi.h:29
uint8_t tag
Tag byte.
Definition: acpi.h:25

References ACPI_SMALL_LEN_MASK, and acpi_small_resource::tag.

Referenced by acpi_resource_len().

◆ acpi_large_len()

static size_t acpi_large_len ( struct acpi_large_resource res)
inlinestatic

Get length of ACPI large resource descriptor.

Parameters
resLarge resource descriptor
Return values
lenLength of descriptor

Definition at line 127 of file acpi.h.

127  {
128 
129  return ( sizeof ( *res ) + le16_to_cpu ( res->len ) );
130 }
uint16_t len
Length of data items.
Definition: acpi.h:47
#define le16_to_cpu(value)
Definition: byteswap.h:112

References le16_to_cpu, and acpi_large_resource::len.

Referenced by acpi_resource_len().

◆ acpi_resource_len()

static size_t acpi_resource_len ( union acpi_resource res)
inlinestatic

Get length of ACPI resource descriptor.

Parameters
resACPI resource descriptor
Return values
lenLength of descriptor

Definition at line 138 of file acpi.h.

138  {
139 
140  return ( ( res->tag & ACPI_LARGE ) ?
141  acpi_large_len ( &res->large ) :
142  acpi_small_len ( &res->small ) );
143 }
struct acpi_small_resource small
Small resource descriptor.
Definition: acpi.h:89
struct acpi_large_resource large
Large resource descriptor.
Definition: acpi.h:93
uint8_t tag
Tag byte.
Definition: acpi.h:87
static size_t acpi_small_len(struct acpi_small_resource *res)
Get length of ACPI small resource descriptor.
Definition: acpi.h:116
static size_t acpi_large_len(struct acpi_large_resource *res)
Get length of ACPI large resource descriptor.
Definition: acpi.h:127
#define ACPI_LARGE
ACPI large resource flag.
Definition: acpi.h:51

References ACPI_LARGE, acpi_large_len(), acpi_small_len(), acpi_resource::large, acpi_resource::small, and acpi_resource::tag.

Referenced by acpi_resource_next().

◆ acpi_resource_next()

static union acpi_resource* acpi_resource_next ( union acpi_resource res)
static

Get next ACPI resource descriptor.

Parameters
resACPI resource descriptor
Return values
nextNext ACPI resource descriptor

Definition at line 152 of file acpi.h.

152  {
153 
154  return ( ( ( void * ) res ) + acpi_resource_len ( res ) );
155 }
static size_t acpi_resource_len(union acpi_resource *res)
Get length of ACPI resource descriptor.
Definition: acpi.h:138

References acpi_resource_len().

Referenced by efipci_ioremap(), and efipci_root_match().

◆ acpi_name()

static const char* acpi_name ( uint32_t  signature)
inlinestatic

Transcribe ACPI table signature (for debugging)

Parameters
signatureACPI table signature
Return values
nameACPI table signature name

Definition at line 190 of file acpi.h.

190  {
191  static union {
193  char name[5];
194  } u;
195 
196  u.signature = cpu_to_le32 ( signature );
197  return u.name;
198 }
#define cpu_to_le32(value)
Definition: byteswap.h:107
unsigned int uint32_t
Definition: stdint.h:12
char name[NETDEV_NAME_LEN]
Name of this network device.
Definition: netdevice.h:362
union @17 u
u8 signature
Signature.
Definition: CIB_PRM.h:35

References cpu_to_le32, name, signature, and u.

Referenced by acpi_extract(), acpi_find_via_rsdt(), acpi_settings_fetch(), acpi_zsdt(), dummy_install(), efi_block_install(), and int13_install().

◆ acpi_init()

static void acpi_init ( struct acpi_descriptor desc,
struct acpi_model model,
struct refcnt refcnt 
)
inlinestatic

Initialise ACPI descriptor.

Parameters
descACPI descriptor
modelTable model
refcntReference count

Definition at line 295 of file acpi.h.

296  {
297 
298  desc->refcnt = refcnt;
299  desc->model = model;
300  INIT_LIST_HEAD ( &desc->list );
301 }
static void(*) struct refcnt refcnt)
Definition: pool.h:62
struct acpi_model * model
Table model.
Definition: acpi.h:282
struct list_head list
List of ACPI descriptors for this model.
Definition: acpi.h:284
#define INIT_LIST_HEAD(list)
Initialise a list head.
Definition: list.h:45
struct refcnt * refcnt
Reference count of containing object.
Definition: acpi.h:280

References INIT_LIST_HEAD, acpi_descriptor::list, acpi_descriptor::model, refcnt, and acpi_descriptor::refcnt.

Referenced by aoedev_open(), ib_srp_open(), and iscsi_open().

◆ acpi_find_via_rsdt()

userptr_t acpi_find_via_rsdt ( uint32_t  signature,
unsigned int  index 
)

Locate ACPI table via RSDT.

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

Definition at line 110 of file acpi.c.

110  {
111  struct acpi_header acpi;
112  struct acpi_rsdt *rsdtab;
113  typeof ( rsdtab->entry[0] ) entry;
114  userptr_t rsdt;
115  userptr_t table;
116  size_t len;
117  unsigned int count;
118  unsigned int i;
119 
120  /* Locate RSDT */
121  rsdt = acpi_find_rsdt();
122  if ( ! rsdt ) {
123  DBG ( "RSDT not found\n" );
124  return UNULL;
125  }
126 
127  /* Read RSDT header */
128  copy_from_user ( &acpi, rsdt, 0, sizeof ( acpi ) );
129  if ( acpi.signature != cpu_to_le32 ( RSDT_SIGNATURE ) ) {
130  DBGC ( colour, "RSDT %#08lx has invalid signature:\n",
131  user_to_phys ( rsdt, 0 ) );
132  DBGC_HDA ( colour, user_to_phys ( rsdt, 0 ), &acpi,
133  sizeof ( acpi ) );
134  return UNULL;
135  }
136  len = le32_to_cpu ( acpi.length );
137  if ( len < sizeof ( rsdtab->acpi ) ) {
138  DBGC ( colour, "RSDT %#08lx has invalid length:\n",
139  user_to_phys ( rsdt, 0 ) );
140  DBGC_HDA ( colour, user_to_phys ( rsdt, 0 ), &acpi,
141  sizeof ( acpi ) );
142  return UNULL;
143  }
144 
145  /* Calculate number of entries */
146  count = ( ( len - sizeof ( rsdtab->acpi ) ) / sizeof ( entry ) );
147 
148  /* Search through entries */
149  for ( i = 0 ; i < count ; i++ ) {
150 
151  /* Get table address */
152  copy_from_user ( &entry, rsdt,
153  offsetof ( typeof ( *rsdtab ), entry[i] ),
154  sizeof ( entry ) );
155 
156  /* Read table header */
157  table = phys_to_user ( entry );
158  copy_from_user ( &acpi.signature, table, 0,
159  sizeof ( acpi.signature ) );
160 
161  /* Check table signature */
162  if ( acpi.signature != cpu_to_le32 ( signature ) )
163  continue;
164 
165  /* Check index */
166  if ( index-- )
167  continue;
168 
169  /* Check table integrity */
170  if ( acpi_checksum ( table ) != 0 ) {
171  DBGC ( colour, "RSDT %#08lx found %s with bad "
172  "checksum at %08lx\n", user_to_phys ( rsdt, 0 ),
173  acpi_name ( signature ),
174  user_to_phys ( table, 0 ) );
175  break;
176  }
177 
178  DBGC ( colour, "RSDT %#08lx found %s at %08lx\n",
179  user_to_phys ( rsdt, 0 ), acpi_name ( signature ),
180  user_to_phys ( table, 0 ) );
181  return table;
182  }
183 
184  DBGC ( colour, "RSDT %#08lx could not find %s\n",
185  user_to_phys ( rsdt, 0 ), acpi_name ( signature ) );
186  return UNULL;
187 }
#define RSDT_SIGNATURE
Root System Description Table (RSDT) signature.
Definition: acpi.h:230
#define le32_to_cpu(value)
Definition: byteswap.h:113
static __always_inline void copy_from_user(void *dest, userptr_t src, off_t src_off, size_t len)
Copy data from user buffer.
Definition: uaccess.h:337
unsigned long user_to_phys(userptr_t userptr, off_t offset)
Convert user pointer to physical address.
#define DBGC(...)
Definition: compiler.h:505
userptr_t phys_to_user(unsigned long phys_addr)
Convert physical address to user pointer.
#define offsetof(type, field)
Get offset of a field within a structure.
Definition: stddef.h:24
ACPI Root System Description Table (RSDT)
Definition: acpi.h:233
#define colour
Colour for debug messages.
Definition: acpi.c:39
#define DBGC_HDA(...)
Definition: compiler.h:506
static EFI_ACPI_TABLE_PROTOCOL * acpi
ACPI table protocol protocol.
Definition: efi_block.c:62
uint32_t entry[0]
ACPI table entries.
Definition: acpi.h:237
#define cpu_to_le32(value)
Definition: byteswap.h:107
union aes_table_entry entry[256]
Table entries, indexed by S(N)
Definition: aes.c:26
userptr_t acpi_find_rsdt(void)
Locate ACPI root system description table.
An ACPI description header.
Definition: acpi.h:163
struct acpi_header acpi
ACPI header.
Definition: acpi.h:235
#define UNULL
Equivalent of NULL for user pointers.
Definition: uaccess.h:36
uint32_t len
Length.
Definition: ena.h:14
uint16_t count
Number of entries.
Definition: ena.h:22
static const char * acpi_name(uint32_t signature)
Transcribe ACPI table signature (for debugging)
Definition: acpi.h:190
typeof(acpi_finder=acpi_find)
ACPI table finder.
Definition: acpi.c:45
uint64_t index
Index of the first segment within the content.
Definition: pccrc.h:21
#define DBG(...)
Print a debugging message.
Definition: compiler.h:498
u8 signature
Signature.
Definition: CIB_PRM.h:35
unsigned long userptr_t
A pointer to a user buffer.
Definition: uaccess.h:33
if(natsemi->flags &NATSEMI_64BIT) return 1

References acpi, acpi_rsdt::acpi, acpi_find_rsdt(), acpi_name(), colour, copy_from_user(), count, cpu_to_le32, DBG, DBGC, DBGC_HDA, entry, acpi_rsdt::entry, index, le32_to_cpu, len, offsetof, phys_to_user(), RSDT_SIGNATURE, signature, typeof(), UNULL, and user_to_phys().

Referenced by acpi_find().

◆ acpi_find_rsdt()

userptr_t acpi_find_rsdt ( void  )

Locate ACPI root system description table.

Return values
rsdtACPI root system description table, or UNULL

Referenced by acpi_find_via_rsdt().

◆ acpi_find()

userptr_t acpi_find ( uint32_t  signature,
unsigned int  index 
)

Locate ACPI table.

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

Definition at line 26 of file efi_acpi.h.

26  {
27 
29 }
userptr_t acpi_find_via_rsdt(uint32_t signature, unsigned int index)
Locate ACPI table via RSDT.
Definition: acpi.c:110
uint64_t index
Index of the first segment within the content.
Definition: pccrc.h:21
u8 signature
Signature.
Definition: CIB_PRM.h:35

References acpi_find_via_rsdt(), index, signature, and UNULL.

◆ acpi_describe()

struct acpi_descriptor* acpi_describe ( struct interface intf)

Get object's ACPI descriptor.

Parameters
intfInterface
Return values
descACPI descriptor, or NULL

Definition at line 313 of file acpi.c.

313  {
314  struct interface *dest;
315  acpi_describe_TYPE ( void * ) *op =
316  intf_get_dest_op ( intf, acpi_describe, &dest );
317  void *object = intf_object ( dest );
318  struct acpi_descriptor *desc;
319 
320  if ( op ) {
321  desc = op ( object );
322  } else {
323  desc = NULL;
324  }
325 
326  intf_put ( dest );
327  return desc;
328 }
void * intf_object(struct interface *intf)
Get pointer to object containing object interface.
Definition: interface.c:159
An object interface.
Definition: interface.h:124
static void * dest
Definition: strings.h:176
struct acpi_descriptor * acpi_describe(struct interface *intf)
Get object's ACPI descriptor.
Definition: acpi.c:313
#define acpi_describe_TYPE(object_type)
Definition: acpi.h:386
static uint16_t struct vmbus_xfer_pages_operations * op
Definition: netvsc.h:327
An ACPI descriptor (used to construct ACPI tables)
Definition: acpi.h:278
void intf_put(struct interface *intf)
Decrement reference count on an object interface.
Definition: interface.c:149
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362
#define intf_get_dest_op(intf, type, dest)
Get object interface destination and operation method.
Definition: interface.h:231

References acpi_describe(), acpi_describe_TYPE, dest, intf_get_dest_op, intf_object(), intf_put(), NULL, and op.

Referenced by acpi_describe(), and sanpath_open().

◆ acpi_fix_checksum()

void acpi_fix_checksum ( struct acpi_header acpi)

Fix up ACPI table checksum.

Parameters
acpiACPI table header

Definition at line 85 of file acpi.c.

85  {
86 
87  /* Update checksum */
88  acpi->checksum -= acpi_checksum ( virt_to_user ( acpi ) );
89 }
static EFI_ACPI_TABLE_PROTOCOL * acpi
ACPI table protocol protocol.
Definition: efi_block.c:62
userptr_t virt_to_user(volatile const void *addr)
Convert virtual address to user pointer.

References acpi, and virt_to_user().

Referenced by efi_block_install(), and int13_install().

◆ acpi_table()

userptr_t acpi_table ( uint32_t  signature,
unsigned int  index 
)

Locate ACPI table.

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

Definition at line 98 of file acpi.c.

98  {
99 
100  return ( *acpi_finder ) ( signature, index );
101 }
uint64_t index
Index of the first segment within the content.
Definition: pccrc.h:21
u8 signature
Signature.
Definition: CIB_PRM.h:35
userptr_t(* acpi_finder)(uint32_t signature, unsigned int index)

References acpi_finder, index, and signature.

Referenced by acpi_extract(), acpi_poweroff(), acpi_settings_fetch(), acpi_timer_probe(), and ecam_find().

◆ acpi_extract()

int acpi_extract ( uint32_t  signature,
void *  data,
int(*)(userptr_t zsdt, size_t len, size_t offset, void *data extract 
)

Extract value from DSDT/SSDT.

Parameters
signatureSignature (e.g. "_S5_")
dataData buffer
extractExtraction method
Return values
rcReturn status code

Definition at line 240 of file acpi.c.

242  {
243  struct acpi_fadt fadtab;
244  userptr_t fadt;
245  userptr_t dsdt;
246  userptr_t ssdt;
247  unsigned int i;
248  int rc;
249 
250  /* Try DSDT first */
251  fadt = acpi_table ( FADT_SIGNATURE, 0 );
252  if ( fadt ) {
253  copy_from_user ( &fadtab, fadt, 0, sizeof ( fadtab ) );
254  dsdt = phys_to_user ( fadtab.dsdt );
255  if ( ( rc = acpi_zsdt ( dsdt, signature, data,
256  extract ) ) == 0 )
257  return 0;
258  }
259 
260  /* Try all SSDTs */
261  for ( i = 0 ; ; i++ ) {
262  ssdt = acpi_table ( SSDT_SIGNATURE, i );
263  if ( ! ssdt )
264  break;
265  if ( ( rc = acpi_zsdt ( ssdt, signature, data,
266  extract ) ) == 0 )
267  return 0;
268  }
269 
270  DBGC ( colour, "ACPI could not find \"%s\"\n",
271  acpi_name ( signature ) );
272  return -ENOENT;
273 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
static __always_inline void copy_from_user(void *dest, userptr_t src, off_t src_off, size_t len)
Copy data from user buffer.
Definition: uaccess.h:337
#define DBGC(...)
Definition: compiler.h:505
#define SSDT_SIGNATURE
Secondary System Description Table (SSDT) signature.
Definition: acpi.h:275
userptr_t acpi_table(uint32_t signature, unsigned int index)
Locate ACPI table.
Definition: acpi.c:98
#define ENOENT
No such file or directory.
Definition: errno.h:514
userptr_t phys_to_user(unsigned long phys_addr)
Convert physical address to user pointer.
#define colour
Colour for debug messages.
Definition: acpi.c:39
Fixed ACPI Description Table (FADT)
Definition: acpi.h:244
#define FADT_SIGNATURE
Fixed ACPI Description Table (FADT) signature.
Definition: acpi.h:241
uint32_t dsdt
Physical address of DSDT.
Definition: acpi.h:250
static const char * acpi_name(uint32_t signature)
Transcribe ACPI table signature (for debugging)
Definition: acpi.h:190
static int acpi_zsdt(userptr_t zsdt, uint32_t signature, void *data, int(*extract)(userptr_t zsdt, size_t len, size_t offset, void *data))
Extract value from DSDT/SSDT.
Definition: acpi.c:198
struct arbelprm_port_state_change_st data
Message.
Definition: arbel.h:12
u8 signature
Signature.
Definition: CIB_PRM.h:35
unsigned long userptr_t
A pointer to a user buffer.
Definition: uaccess.h:33

References acpi_name(), acpi_table(), acpi_zsdt(), colour, copy_from_user(), data, DBGC, acpi_fadt::dsdt, ENOENT, FADT_SIGNATURE, phys_to_user(), rc, signature, and SSDT_SIGNATURE.

Referenced by acpi_mac(), and acpi_poweroff().

◆ acpi_add()

void acpi_add ( struct acpi_descriptor desc)

Add ACPI descriptor.

Parameters
descACPI descriptor

Definition at line 287 of file acpi.c.

287  {
288 
289  /* Add to list of descriptors */
290  ref_get ( desc->refcnt );
291  list_add_tail ( &desc->list, &desc->model->descs );
292 }
struct list_head descs
List of descriptors.
Definition: acpi.h:306
struct acpi_model * model
Table model.
Definition: acpi.h:282
#define list_add_tail(new, head)
Add a new entry to the tail of a list.
Definition: list.h:93
struct list_head list
List of ACPI descriptors for this model.
Definition: acpi.h:284
#define ref_get(refcnt)
Get additional reference to object.
Definition: refcnt.h:92
struct refcnt * refcnt
Reference count of containing object.
Definition: acpi.h:280

References acpi_model::descs, acpi_descriptor::list, list_add_tail, acpi_descriptor::model, ref_get, and acpi_descriptor::refcnt.

Referenced by sanpath_open().

◆ acpi_del()

void acpi_del ( struct acpi_descriptor desc)

Remove ACPI descriptor.

Parameters
descACPI descriptor

Definition at line 299 of file acpi.c.

299  {
300 
301  /* Remove from list of descriptors */
302  list_check_contains_entry ( desc, &desc->model->descs, list );
303  list_del ( &desc->list );
304  ref_put ( desc->refcnt );
305 }
struct list_head descs
List of descriptors.
Definition: acpi.h:306
struct acpi_model * model
Table model.
Definition: acpi.h:282
#define list_del(list)
Delete an entry from a list.
Definition: list.h:119
struct list_head list
List of ACPI descriptors for this model.
Definition: acpi.h:284
struct refcnt * refcnt
Reference count of containing object.
Definition: acpi.h:280
#define list_check_contains_entry(entry, head, member)
Check list contains a specified entry.
Definition: list.h:522
#define ref_put(refcnt)
Drop reference to object.
Definition: refcnt.h:106

References acpi_model::descs, acpi_descriptor::list, list_check_contains_entry, list_del, acpi_descriptor::model, ref_put, and acpi_descriptor::refcnt.

Referenced by sandev_undescribe(), and sanpath_open().

◆ acpi_install()

int acpi_install ( int(*)(struct acpi_header *acpi install)

Install ACPI tables.

Parameters
installTable installation method
Return values
rcReturn status code

Definition at line 336 of file acpi.c.

336  {
337  struct acpi_model *model;
338  int rc;
339 
340  for_each_table_entry ( model, ACPI_MODELS ) {
341  if ( ( rc = model->install ( install ) ) != 0 )
342  return rc;
343  }
344 
345  return 0;
346 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
int(* install)(int(*install)(struct acpi_header *acpi))
Install ACPI tables.
Definition: acpi.h:320
An ACPI table model.
Definition: acpi.h:304
#define for_each_table_entry(pointer, table)
Iterate through all entries within a linker table.
Definition: tables.h:385
#define ACPI_MODELS
ACPI models.
Definition: acpi.h:324

References ACPI_MODELS, for_each_table_entry, acpi_model::install, and rc.

Referenced by dummy_san_describe(), efi_block_describe(), and int13_describe().

Variable Documentation

◆ acpi_finder

userptr_t( * acpi_finder) (uint32_t signature, unsigned int index)

Referenced by acpi_table().