Commit Graph

77 Commits

Author SHA1 Message Date
Rob Bradford
d7decfd525 build: Fix beta clippy issue (unnecessary_to_owned)
warning: unnecessary use of `to_vec`
  --> acpi_tables/src/aml.rs:71:37
   |
71 |             bytes.extend_from_slice(&part.to_vec());
   |                                     ^^^^^^^^^^^^^^ help: use: `part.as_ref()`
   |
   = note: `#[warn(clippy::unnecessary_to_owned)]` on by default
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_to_owned

Signed-off-by: Rob Bradford <robert.bradford@intel.com>
2022-06-30 20:50:45 +01:00
Rob Bradford
f6333a39a5 acpi_tables: Fix clippy (unnecessary_to_owned) issues
warning: unnecessary use of `to_vec`
    --> acpi_tables/src/aml.rs:1395:38
     |
1395 |         assert_eq!(create_pkg_length(&[0u8; 62].to_vec(), true), vec![63]);
     |                                      ^^^^^^^^^^^^^^^^^^^ help: use: `[0u8; 62].as_ref()`
     |
     = note: `#[warn(clippy::unnecessary_to_owned)]` on by default
     = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_to_owned

warning: unnecessary use of `to_vec`
    --> acpi_tables/src/aml.rs:1397:31
     |
1397 |             create_pkg_length(&[0u8; 64].to_vec(), true),
     |                               ^^^^^^^^^^^^^^^^^^^ help: use: `[0u8; 64].as_ref()`
     |
     = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_to_owned

warning: unnecessary use of `to_vec`
    --> acpi_tables/src/aml.rs:1401:31
     |
1401 |             create_pkg_length(&[0u8; 4096].to_vec(), true),
     |                               ^^^^^^^^^^^^^^^^^^^^^ help: use: `[0u8; 4096].as_ref()`
     |
     = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_to_owned

Signed-off-by: Rob Bradford <robert.bradford@intel.com>
2022-01-07 08:16:26 -08:00
Wei Liu
243b5bad65 acpi_tables: add safety comment for impl ByteValued
Signed-off-by: Wei Liu <liuwe@microsoft.com>
2021-11-17 14:40:51 +00:00
Rob Bradford
eae4b315e4 acpi_tables: aml: Replace use of Vec::append with Vec::extend_from_slice
Avoid removing from the source vector by using Vec::extend_from_slice().
The primitive values (bytes) will be copied from the source in either
case.

Signed-off-by: Rob Bradford <robert.bradford@intel.com>
2021-11-08 16:46:30 +00:00
Rob Bradford
c1a3b63112 acpi_tables: aml: Use Aml::append_aml_bytes()
Signed-off-by: Rob Bradford <robert.bradford@intel.com>
2021-11-08 16:46:30 +00:00
Rob Bradford
def371e969 acpi_tables: aml: Implement Aml::append_aml_bytes() for CreateField
For now it still relies on Aml::to_aml_bytes() for the children as not
all structures have been ported.

Signed-off-by: Rob Bradford <robert.bradford@intel.com>
2021-11-08 16:46:30 +00:00
Rob Bradford
72d4d2c6f0 acpi_tables: aml: Implement Aml::append_aml_bytes() for Buffer
For now it still relies on Aml::to_aml_bytes() for the children as not
all structures have been ported.

Signed-off-by: Rob Bradford <robert.bradford@intel.com>
2021-11-08 16:46:30 +00:00
Rob Bradford
99467982aa acpi_tables: aml: Implement Aml::append_aml_bytes() for MethodCall
For now it still relies on Aml::to_aml_bytes() for the children as not
all structures have been ported.

Signed-off-by: Rob Bradford <robert.bradford@intel.com>
2021-11-08 16:46:30 +00:00
Rob Bradford
6172b6aac5 acpi_tables: aml: Implement Aml::append_aml_bytes() for !binary_op macro
For now it still relies on Aml::to_aml_bytes() for the children as not
all structures have been ported.

Signed-off-by: Rob Bradford <robert.bradford@intel.com>
2021-11-08 16:46:30 +00:00
Rob Bradford
9cddcc8766 acpi_tables: aml: Implement Aml::append_aml_bytes() for While
For now it still relies on Aml::to_aml_bytes() for the children as not
all structures have been ported.

Signed-off-by: Rob Bradford <robert.bradford@intel.com>
2021-11-08 16:46:30 +00:00
Rob Bradford
d2319124f5 acpi_tables: aml: Implement Aml::append_aml_bytes() for Notify
For now it still relies on Aml::to_aml_bytes() for the children as not
all structures have been ported.

Signed-off-by: Rob Bradford <robert.bradford@intel.com>
2021-11-08 16:46:30 +00:00
Rob Bradford
24fd54401d acpi_tables: aml: Implement Aml::append_aml_bytes() for Release
Signed-off-by: Rob Bradford <robert.bradford@intel.com>
2021-11-08 16:46:30 +00:00
Rob Bradford
9256c41173 acpi_tables: aml: Implement Aml::append_aml_bytes() for Acquire
Signed-off-by: Rob Bradford <robert.bradford@intel.com>
2021-11-08 16:46:30 +00:00
Rob Bradford
b1d4bcf952 acpi_tables: aml: Implement Aml::append_aml_bytes() for Mutex
Signed-off-by: Rob Bradford <robert.bradford@intel.com>
2021-11-08 16:46:30 +00:00
Rob Bradford
8b7bfca9b0 acpi_tables: aml: Implement Aml::append_aml_bytes() for Store
For now it still relies on Aml::to_aml_bytes() for the children as not
all structures have been ported.

Signed-off-by: Rob Bradford <robert.bradford@intel.com>
2021-11-08 16:46:30 +00:00
Rob Bradford
7da69b59f7 acpi_tables: aml: Implement Aml::append_aml_bytes() for Local
Signed-off-by: Rob Bradford <robert.bradford@intel.com>
2021-11-08 16:46:30 +00:00
Rob Bradford
50b6ee3947 acpi_tables: aml: Implement Aml::append_aml_bytes() for Arg
Signed-off-by: Rob Bradford <robert.bradford@intel.com>
2021-11-08 16:46:30 +00:00
Rob Bradford
c0ca6b5377 acpi_tables: aml: Implement Aml::append_aml_bytes() for LessThan
For now it still relies on Aml::to_aml_bytes() for the predicates as not
all structures have been ported.

Signed-off-by: Rob Bradford <robert.bradford@intel.com>
2021-11-08 16:46:30 +00:00
Rob Bradford
8c9f0e407f acpi_tables: aml: Implement Aml::append_aml_bytes() for Equal
For now it still relies on Aml::to_aml_bytes() for the predicates as not
all structures have been ported.

Signed-off-by: Rob Bradford <robert.bradford@intel.com>
2021-11-08 16:46:30 +00:00
Rob Bradford
29f46ee470 acpi_tables: aml: Implement Aml::append_aml_bytes() for If
For now it still relies on Aml::to_aml_bytes() for the children as not
all structures have been ported.

Signed-off-by: Rob Bradford <robert.bradford@intel.com>
2021-11-08 16:46:30 +00:00
Rob Bradford
f3e86bdf26 acpi_tables: aml: Implement Aml::append_aml_bytes() for OpRegion
As it relies on primitive types that have already been ported
Aml::append_aml_bytes can be used for the child values.

Signed-off-by: Rob Bradford <robert.bradford@intel.com>
2021-11-08 16:46:30 +00:00
Rob Bradford
311dd7be50 acpi_tables: aml: Implement Aml::append_aml_bytes() for Field
Signed-off-by: Rob Bradford <robert.bradford@intel.com>
2021-11-08 16:46:30 +00:00
Rob Bradford
bfd3deac7c acpi_tables: aml: Implement Aml::append_aml_bytes() for Return
For now it still relies on Aml::to_aml_bytes() for the child as not all
structures have been ported.

Signed-off-by: Rob Bradford <robert.bradford@intel.com>
2021-11-08 16:46:30 +00:00
Rob Bradford
1a35d5a017 acpi_tables: aml: Implement Aml::append_aml_bytes() for Method
For now it still relies on Aml::to_aml_bytes() for the children as not
all structures have been ported.

Signed-off-by: Rob Bradford <robert.bradford@intel.com>
2021-11-08 16:46:30 +00:00
Rob Bradford
95e63d5f44 acpi_tables: aml: Implement Aml::append_aml_bytes() for Scope
For now it still relies on Aml::to_aml_bytes() for the children as not
all structures have been ported.

Signed-off-by: Rob Bradford <robert.bradford@intel.com>
2021-11-08 16:46:30 +00:00
Rob Bradford
f31d218479 acpi_tables: aml: Implement Aml::append_aml_bytes() for Device
For now it still relies on Aml::to_aml_bytes() for the children as not
all structures have been ported.

Signed-off-by: Rob Bradford <robert.bradford@intel.com>
2021-11-08 16:46:30 +00:00
Rob Bradford
ef216c37df acpi_tables: aml: Avoid allocating temporary vector in Interrupt
Use extend_from_slice() vs creating a temporary vector.

Signed-off-by: Rob Bradford <robert.bradford@intel.com>
2021-11-08 16:46:30 +00:00
Rob Bradford
242a7f7ab4 acpi_tables: aml: Implement Aml::append_aml_bytes() for Interrupt
Signed-off-by: Rob Bradford <robert.bradford@intel.com>
2021-11-08 16:46:30 +00:00
Rob Bradford
eec7634cd7 acpi_tables: aml: Avoid allocating temporary vector in Io
Use extend_from_slice() vs creating a temporary vector.

Signed-off-by: Rob Bradford <robert.bradford@intel.com>
2021-11-08 16:46:30 +00:00
Rob Bradford
7ad83f1daa acpi_tables: aml: Implement Aml::append_aml_bytes() for Io
Signed-off-by: Rob Bradford <robert.bradford@intel.com>
2021-11-08 16:46:30 +00:00
Rob Bradford
6c181061df acpi_tables: aml: Avoid allocating temporary vector in AddressSpace
Use extend_from_slice() vs creating a temporary vector.

Signed-off-by: Rob Bradford <robert.bradford@intel.com>
2021-11-08 16:46:30 +00:00
Rob Bradford
99d4f77197 acpi_tables: aml: Avoid allocating temporary vector in Memory32Fixed
Use extend_from_slice() vs creating a temporary vector.

Signed-off-by: Rob Bradford <robert.bradford@intel.com>
2021-11-08 16:46:30 +00:00
Rob Bradford
3c00a696b5 acpi_tables: aml: Implement Aml::append_aml_bytes() for Memory32Fixed
Signed-off-by: Rob Bradford <robert.bradford@intel.com>
2021-11-08 16:46:30 +00:00
Rob Bradford
4f496e39a1 acpi_tables: aml: Implement Aml::append_aml_bytes() for ResourceTemplate
For now it still relies on Aml::to_aml_bytes() for the children as not
all structures have been ported.

Signed-off-by: Rob Bradford <robert.bradford@intel.com>
2021-11-08 16:46:30 +00:00
Rob Bradford
d92489e0a4 acpi_tables: aml: Implement Aml::append_aml_bytes() for AmlStr and AmlString
Signed-off-by: Rob Bradford <robert.bradford@intel.com>
2021-11-08 16:46:30 +00:00
Rob Bradford
93647f0313 acpi_tables: aml: Implement Aml::append_aml_bytes() for Usize
Since we know all the numerical types now have implementations of
Aml::append_aml_bytes() we can use that directly.

Signed-off-by: Rob Bradford <robert.bradford@intel.com>
2021-11-08 16:46:30 +00:00
Rob Bradford
1877c723cd acpi_tables: aml: Implement Aml::append_aml_bytes() for EisaName
As this is a DWord and we know that DWord::append_aml_bytes() is
implemented we may call it directly.

Signed-off-by: Rob Bradford <robert.bradford@intel.com>
2021-11-08 16:46:30 +00:00
Rob Bradford
f51bad20bf acpi_tables: aml: Avoid extra vector allocation in number types
Using extend_from_slice() on the number types removes an extra vector
allocation.

Signed-off-by: Rob Bradford <robert.bradford@intel.com>
2021-11-08 16:46:30 +00:00
Rob Bradford
f7da35857f acpi_tables: aml: Implement Aml::append_aml_bytes() for Package
Signed-off-by: Rob Bradford <robert.bradford@intel.com>
2021-11-08 16:46:30 +00:00
Rob Bradford
5902ceb955 acpi_tables: aml: Implement Aml::append_aml_bytes() for Name
This is a naive implementation and there is scope to improve this
without extra copies but that requires addressing the users to ensure
there are no lifetime issues.

Signed-off-by: Rob Bradford <robert.bradford@intel.com>
2021-11-08 16:46:30 +00:00
Rob Bradford
395929f1d4 acpi_tables: aml: Implement Aml::append_aml_bytes() for number types
Including Byte, Word, DWord and QWord.

Signed-off-by: Rob Bradford <robert.bradford@intel.com>
2021-11-08 16:46:30 +00:00
Rob Bradford
4bd0ac6623 acpi_tables: aml: Implement Aml::append_aml_bytes() for Path
Signed-off-by: Rob Bradford <robert.bradford@intel.com>
2021-11-08 16:46:30 +00:00
Rob Bradford
f917198f27 acpi_tables: aml: Implement Aml::append_aml_bytes() for constants
Signed-off-by: Rob Bradford <robert.bradford@intel.com>
2021-11-08 16:46:30 +00:00
Rob Bradford
211ee1521d acpi_tables: aml: Add Aml trait implementation for vector appending
As an optimisation to avoid allocating byte vectors add a trait method
that will append to an existing vector. Further to support the
transition add a default implementation of Aml::to_aml_bytes() that uses
the newly added Aml::append_aml_bytes()

Signed-off-by: Rob Bradford <robert.bradford@intel.com>
2021-11-08 16:46:30 +00:00
Bo Chen
5825ab2dd4 clippy: Address the issue 'needless-borrow'
Issue from beta verion of clippy:

Error:    --> vm-virtio/src/queue.rs:700:59
    |
700 |             if let Some(used_event) = self.get_used_event(&mem) {
    |                                                           ^^^^ help: change this to: `mem`
    |
    = note: `-D clippy::needless-borrow` implied by `-D warnings`
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow

Signed-off-by: Bo Chen <chen.bo@intel.com>
2021-06-24 08:55:43 +02:00
Henry Wang
213da7d862 acpi: Implement SPCR on AArch64
This commit implements an AArch64-required ACPI table: Serial
Port Console Redirection Table (SPCR). The table provides
information about the configuration and use of the serial port
or non-legacy UART interface.

Signed-off-by: Henry Wang <Henry.Wang@arm.com>
2021-05-25 10:20:37 +02:00
Gaelan Steele
d8e1898b46 aml: make constructor field order consistent
On nightly, clippy expects the structs to be constructed with fields in
the same order they're declared in. Seems sensible enough, so let's do
that.

Signed-off-by: Gaelan Steele <gbs@canishe.com>
2021-03-29 09:55:29 +02:00
Rob Bradford
261c039831 acpi_tables: Address Rust 1.51.0 clippy issue (vec_init_then_push)
error: calls to `push` immediately after creation
    --> acpi_tables/src/aml.rs:1194:9
     |
1194 | /         let mut bytes = Vec::new();
1195 | |         bytes.push(0x8a); /* CreateDWordFieldOp */
     | |_________________________^ help: consider using the `vec![]` macro: `let mut bytes = vec![..];`
     |
     |
     = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#vec_init_then_push

Signed-off-by: Rob Bradford <robert.bradford@intel.com>
2021-03-26 11:32:09 +00:00
Rob Bradford
db6516931d acpi_tables: Address Rust 1.51.0 clippy issue (upper_case_acronyms)
error: name `SDT` contains a capitalized acronym
  --> acpi_tables/src/sdt.rs:27:12
   |
27 | pub struct SDT {
   |            ^^^ help: consider making the acronym lowercase, except the initial letter: `Sdt`
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#upper_case_acronyms

Signed-off-by: Rob Bradford <robert.bradford@intel.com>
2021-03-26 11:32:09 +00:00
Rob Bradford
9ae44aeada vmm: acpi_tables: Fix PM timer I/O port width
Ensure that the width of the I/O port is correctly set to 32-bits in the
generic address used for the X_PM_TMR_BLK. Do this by type
parameterising GenericAddress::io_port_address() fuction.

TEST=Boot with clocksource=acpi_pm and observe no errors in the dmesg.

Fixes: #1496

Signed-off-by: Rob Bradford <robert.bradford@intel.com>
2020-07-23 17:48:22 +02:00