summaryrefslogtreecommitdiffstats
path: root/src/core/acpi.c
diff options
context:
space:
mode:
authorMichael Brown2017-03-27 17:20:34 +0200
committerMichael Brown2017-03-28 18:12:48 +0200
commit7cfdd769aac76d605aa31146c69ba518b194bea7 (patch)
tree7c09e144792833f81297e6dacf0823733a2a399a /src/core/acpi.c
parent[block] Ignore redundant xfer_window_changed() messages (diff)
downloadipxe-7cfdd769aac76d605aa31146c69ba518b194bea7.tar.gz
ipxe-7cfdd769aac76d605aa31146c69ba518b194bea7.tar.xz
ipxe-7cfdd769aac76d605aa31146c69ba518b194bea7.zip
[block] Describe all SAN devices via ACPI tables
Describe all SAN devices via ACPI tables such as the iBFT. For tables that can describe only a single device (i.e. the aBFT and sBFT), one table is installed per device. For multi-device tables (i.e. the iBFT), all devices are described in a single table. An underlying SAN device connection may be closed at the time that we need to construct an ACPI table. We therefore introduce the concept of an "ACPI descriptor" which enables the SAN boot code to maintain an opaque pointer to the underlying object, and an "ACPI model" which can build tables from a list of such descriptors. This separates the lifecycles of ACPI descriptions from the lifecycles of the block device interfaces, and allows for construction of the ACPI tables even if the block device interface has been closed. For a multipath SAN device, iPXE will wait until sufficient information is available to describe all devices but will not wait for all paths to connect successfully. For example: with a multipath iSCSI boot iPXE will wait until at least one path has become available and name resolution has completed on all other paths. We do this since the iBFT has to include IP addresses rather than DNS names. We will commence booting without waiting for the inactive paths to either become available or close; this avoids unnecessary boot delays. Note that the Linux kernel will refuse to accept an iBFT with more than two NIC or target structures. We therefore describe only the NICs that are actually required in order to reach the described targets. Any iBFT with at most two targets is therefore guaranteed to describe at most two NICs. Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/core/acpi.c')
-rw-r--r--src/core/acpi.c85
1 files changed, 54 insertions, 31 deletions
diff --git a/src/core/acpi.c b/src/core/acpi.c
index 955637e0..8ebe4b19 100644
--- a/src/core/acpi.c
+++ b/src/core/acpi.c
@@ -43,27 +43,11 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
*/
/**
- * Transcribe ACPI table signature (for debugging)
- *
- * @v signature ACPI table signature
- * @ret name ACPI table signature name
- */
-static const char * acpi_name ( uint32_t signature ) {
- static union {
- uint32_t signature;
- char name[5];
- } u;
-
- u.signature = cpu_to_le32 ( signature );
- return u.name;
-}
-
-/**
* Fix up ACPI table checksum
*
* @v acpi ACPI table header
*/
-void acpi_fix_checksum ( struct acpi_description_header *acpi ) {
+void acpi_fix_checksum ( struct acpi_header *acpi ) {
unsigned int i = 0;
uint8_t sum = 0;
@@ -147,7 +131,7 @@ userptr_t acpi_find_rsdt ( userptr_t ebda ) {
* @ret table Table, or UNULL if not found
*/
userptr_t acpi_find ( userptr_t rsdt, uint32_t signature, unsigned int index ) {
- struct acpi_description_header acpi;
+ struct acpi_header acpi;
struct acpi_rsdt *rsdtab;
typeof ( rsdtab->entry[0] ) entry;
userptr_t table;
@@ -227,7 +211,7 @@ userptr_t acpi_find ( userptr_t rsdt, uint32_t signature, unsigned int index ) {
* the ACPI specification itself.
*/
static int acpi_sx_zsdt ( userptr_t zsdt, uint32_t signature ) {
- struct acpi_description_header acpi;
+ struct acpi_header acpi;
union {
uint32_t dword;
uint8_t byte[4];
@@ -331,34 +315,73 @@ int acpi_sx ( userptr_t rsdt, uint32_t signature ) {
/******************************************************************************
*
- * Interface methods
+ * Descriptors
*
******************************************************************************
*/
/**
- * Describe object in an ACPI table
+ * Add ACPI descriptor
+ *
+ * @v desc ACPI descriptor
+ */
+void acpi_add ( struct acpi_descriptor *desc ) {
+
+ /* Add to list of descriptors */
+ ref_get ( desc->refcnt );
+ list_add_tail ( &desc->list, &desc->model->descs );
+}
+
+/**
+ * Remove ACPI descriptor
+ *
+ * @v desc ACPI descriptor
+ */
+void acpi_del ( struct acpi_descriptor *desc ) {
+
+ /* Remove from list of descriptors */
+ list_check_contains_entry ( desc, &desc->model->descs, list );
+ list_del ( &desc->list );
+ ref_put ( desc->refcnt );
+}
+
+/**
+ * Get object's ACPI descriptor
*
* @v intf Interface
- * @v acpi ACPI table
- * @v len Length of ACPI table
- * @ret rc Return status code
+ * @ret desc ACPI descriptor, or NULL
*/
-int acpi_describe ( struct interface *intf,
- struct acpi_description_header *acpi, size_t len ) {
+struct acpi_descriptor * acpi_describe ( struct interface *intf ) {
struct interface *dest;
acpi_describe_TYPE ( void * ) *op =
intf_get_dest_op ( intf, acpi_describe, &dest );
void *object = intf_object ( dest );
- int rc;
+ struct acpi_descriptor *desc;
if ( op ) {
- rc = op ( object, acpi, len );
+ desc = op ( object );
} else {
- /* Default is to fail to describe */
- rc = -EOPNOTSUPP;
+ desc = NULL;
}
intf_put ( dest );
- return rc;
+ return desc;
+}
+
+/**
+ * Install ACPI tables
+ *
+ * @v install Table installation method
+ * @ret rc Return status code
+ */
+int acpi_install ( int ( * install ) ( struct acpi_header *acpi ) ){
+ struct acpi_model *model;
+ int rc;
+
+ for_each_table_entry ( model, ACPI_MODELS ) {
+ if ( ( rc = model->install ( install ) ) != 0 )
+ return rc;
+ }
+
+ return 0;
}