summaryrefslogtreecommitdiffstats
path: root/src/acpi/acpigen.c
Commit message (Collapse)AuthorAgeFilesLines
* acpi/acpigen: add acpigen_write_SEG for segment group number methodFelix Held2024-01-131-0/+11
| | | | | | | | | | | Introduce acpigen_write_SEG to generate the ACPI method object that returns the PCI segment group number for a PCI(e) host bridge. Signed-off-by: Felix Held <felix-coreboot@felixheld.de> Change-Id: I94837fdbe140ee1ff904ffd20bdab3e86f850774 Reviewed-on: https://review.coreboot.org/c/coreboot/+/79923 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Patrick Rudolph <patrick.rudolph@9elements.com>
* acpi: Reduce wait interval in delay loop for sleepSukumar Ghorai2023-12-201-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | The optimization of sleep time in acpi code includes reducing the sleep duration and increasing the polling frequency within the acpi _ON/_OFF method. StorageD3Enable is activated in Google/Rex, and this optimization results in a saving of approximately 25ms in D3cold resume time, reducing it from around 160ms to 135ms. BUG=b:296206467 BRANCH=firmware-rex-15709.B TEST=boot test verified on google/rex verified _ON/_OFF Method in SSDT. verifid kernel log in s0ix test - 0000:00:06.0: PM: pci_pm_resume_noirq Change-Id: I7ba960cb78b42ff0108a48f00206b6df0c78ce7a Signed-off-by: Sukumar Ghorai <sukumar.ghorai@intel.com> Reviewed-on: https://review.coreboot.org/c/coreboot/+/79414 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Jakub Czapiga <czapiga@google.com> Reviewed-by: Subrata Banik <subratabanik@google.com> Reviewed-by: Jérémy Compostella <jeremy.compostella@intel.com>
* acpigen.c: Add resource consumer functions for mmioArthur Heymans2023-11-231-25/+37
| | | | | | | | | Signed-off-by: Arthur Heymans <arthur@aheymans.xyz> Change-Id: Id9e4adcd976e1f56ef7f502d9df16dbefce95c3e Reviewed-on: https://review.coreboot.org/c/coreboot/+/79217 Reviewed-by: Nico Huber <nico.h@gmx.de> Reviewed-by: Tim Wawrzynczak <inforichland@gmail.com> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
* acpi/acpigen: drop len assert in acpigen_pop_lenFelix Held2023-11-151-2/+0
| | | | | | | | | | | | This is already handled as a separate case in the code below, so there's no need for this assert any more. Signed-off-by: Felix Held <felix-coreboot@felixheld.de> Change-Id: I7511ec5683a924dc289faa2b9fabd0e8714d291e Reviewed-on: https://review.coreboot.org/c/coreboot/+/79047 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Matt DeVillier <matt.devillier@gmail.com> Reviewed-by: Nico Huber <nico.h@gmx.de>
* acpi/acpigen: introduce and use ACPIGEN_RSVD_PKGLEN_BYTESFelix Held2023-11-151-14/+12
| | | | | | | | | | | Use a define instead of magic numbers. Signed-off-by: Felix Held <felix-coreboot@felixheld.de> Change-Id: I2c6d17bd78a0e207f9130102b43ba78aa55ce377 Reviewed-on: https://review.coreboot.org/c/coreboot/+/79046 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Matt DeVillier <matt.devillier@gmail.com> Reviewed-by: Nico Huber <nico.h@gmx.de>
* acpi/acpigen: rework acpigen_pop_len for different size PkgLengthFelix Held2023-11-151-6/+47
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously acpigen_pop_len always wrote a 3 byte PkgLength to the 3 bytes reserved by acpigen_write_len_f. After this patch acpigen_pop_len encodes PkgLength in 1-3 bytes depending on the PkgLength. When less than the 3 bytes that were previously reserved in the corresponding acpigen_write_len_f call are needed for PkgLength, the payload data will be moved back by the number of reserved bytes that aren't needed for the PkgLength. This fixes the problem that the Windows AML parser doesn't like a 3 byte PkgLength being used for the size of the buffer containing UTF-16 strings when the length could be encoded in a single PkgLength byte. In that case, Windows previously ignored the whole SSDT containing this larger than necessary PkgLength encoding. It should however be noted that the ACPI 6.4 spec doesn't specify if it's required to always use the most compact possible encoding of the PkgLength or not. Since iasl generates the shortest possible PkgLength encoding, it's also a good idea to make coreboot's acpigen do the same although it's not required by the specification. With this patch applied, Windows still boots on Mandolin and the time it takes to write the tables doesn't change. To measure the times, the log level in bs_sample_time was increased to BIOS_CRIT and the console log level was increased to BIOS_CRIT too to only get those times as output. BS: BS_WRITE_TABLES run times (exec / console): 8 / 0 ms Signed-off-by: Felix Held <felix-coreboot@felixheld.de> Change-Id: Ib897b08a05a7cdc52902d51364246c260ea1f206 Reviewed-on: https://review.coreboot.org/c/coreboot/+/79002 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Matt DeVillier <matt.devillier@gmail.com> Reviewed-by: Nico Huber <nico.h@gmx.de> Reviewed-by: Jérémy Compostella <jeremy.compostella@intel.com>
* acpi/acpigen: point out what acpigen_write_len_f doesFelix Held2023-11-131-0/+2
| | | | | | | | | Signed-off-by: Felix Held <felix-coreboot@felixheld.de> Change-Id: Ibaf2f54f2f428f4438ef22b7f9d205db10e144db Reviewed-on: https://review.coreboot.org/c/coreboot/+/79001 Reviewed-by: Nico Huber <nico.h@gmx.de> Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Matt DeVillier <matt.devillier@gmail.com>
* acpi/acpigen: Fix buffer length in acpigen_write_name_unicode()Matt DeVillier2023-11-111-1/+1
| | | | | | | | | | | | | | | | | The buffer length is in bytes, and since we are converting from ASCII to UTF-16, the value written needs to be 2x the string length + null terminator. TEST=build/boot google skyrim (frostflow), dump acpi and check bytecode for correct buffer length preceding unicode strings. Change-Id: Id322e3ff457ca1c92c55125224ca6cfab8762a84 Signed-off-by: Matt DeVillier <matt.devillier@gmail.com> Reviewed-on: https://review.coreboot.org/c/coreboot/+/78977 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Nico Huber <nico.h@gmx.de> Reviewed-by: Paul Menzel <paulepanter@mailbox.org> Reviewed-by: Felix Held <felix-coreboot@felixheld.de>
* acpi/acpigen: Allow general namestring in write mutex functionsPaweł Anikiel2023-10-161-6/+3
| | | | | | | | | | | | BUG=b:301150499 TEST=Compiled and tested on google/redrix - PERST# goes low when wwan modem goes into runtime suspend. Change-Id: Ib09d5a6091cedfce24da49390cf980414f97a2c9 Signed-off-by: Paweł Anikiel <panikiel@google.com> Reviewed-on: https://review.coreboot.org/c/coreboot/+/78349 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Tim Wawrzynczak <inforichland@gmail.com>
* acpi/acpigen.c: Ignore compiler warning about stack overflowingArthur Heymans2023-07-211-0/+4
| | | | | | | | | | | | | | | With arm64 -Wstack-usage= is enabled which is triggered on any use of alloca(). Since this function basically works on x86 without wrecking things and causing massive stack consumption it's unlikely to cause problems on arm64. Signed-off-by: Arthur Heymans <arthur@aheymans.xyz> Change-Id: I5d445d151db5e6cc7b6e13bf74ce81007d819f1d Reviewed-on: https://review.coreboot.org/c/coreboot/+/76007 Reviewed-by: Nico Huber <nico.h@gmx.de> Reviewed-by: Tim Wawrzynczak <inforichland@gmail.com> Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Lean Sheng Tan <sheng.tan@9elements.com>
* acpi/acpigen.c: Be explicit about char signArthur Heymans2023-06-261-1/+1
| | | | | | | | | | | | | The sign of 'char' is not standardized and with GCC is architecture dependent. This fixes warnings when compiling this file on arm64. Signed-off-by: Arthur Heymans <arthur@aheymans.xyz> Change-Id: I53b99835b2ffec5d752fc531fd59e4715f61aced Reviewed-on: https://review.coreboot.org/c/coreboot/+/76006 Reviewed-by: Felix Singer <service+coreboot-gerrit@felixsinger.de> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
* acpi/acpigen: generate DWord IO resource in acpigen_resource_producer_ioFelix Held2023-06-071-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | When an IO resource producer is generated that covers the whole IO space from 0 to 0xffff, the length field in the word resource ACPI type would overflow and be truncated which results in Linux not finding any usable IO space to use for the PCI IO BARs. Instead generate a double word IO resource producer to have all cases supported. Beware that covering all IO ports with the IO resource producer while covering the PCI config IO ports with a resource consumer in the same PCI root device will make Linux a bit unhappy and it will complain due to the overlap, but still end up doing the right thing: acpi PNP0A08:00: host bridge window expanded to [io 0x0000-0xffff]; [io 0x0000-0xffff window] ignored The SoC code should make sure to carve out the PCI config IO ports from the IO resource producer. TEST=Both Ubuntu 2022.04.1 LTS and Windows 10 are ok with the IO DWord resource producer. Signed-off-by: Felix Held <felix-coreboot@felixheld.de> Change-Id: I8a59cdfcfa30a8fdd13f8db3dc1447994c266c8b Reviewed-on: https://review.coreboot.org/c/coreboot/+/75613 Reviewed-by: Arthur Heymans <arthur@aheymans.xyz> Reviewed-by: Raul Rangel <rrangel@chromium.org> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
* acpi/acpigen: rename and clarify bus/IO/MMIO resource producer functionsFelix Held2023-05-301-11/+15
| | | | | | | | | | | | | | | The acpigen_resource_[bus_number,io,mmio*] functions didn't make it very clear that they are generating resource producer ranges and not resource consumer ranges. To clarify this, change the function names to acpigen_resource_producer_[bus_number,io,mmio*] and explicitly add the ADDR_SPACE_GENERAL_FLAG_PRODUCER flag which evaluates to 0, so this doesn't change the functionality. Signed-off-by: Felix Held <felix-coreboot@felixheld.de> Change-Id: I334f38aa8ab418d5577f92b980ff750504e2bb4e Reviewed-on: https://review.coreboot.org/c/coreboot/+/75486 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Tim Wawrzynczak <inforichland@gmail.com>
* acpi/acpigen: add acpigen_resource_mmio to generate MMIO resourceFelix Held2023-05-261-0/+36
| | | | | | | | | | | | Add the acpigen_resource_mmio helper function to generate an MMIO range resource. Signed-off-by: Felix Held <felix-coreboot@felixheld.de> Signed-off-by: Arthur Heymans <arthur@aheymans.xyz> Change-Id: I38d55dfcc2892bcb5d253a3aef6ed993cfdba0a5 Reviewed-on: https://review.coreboot.org/c/coreboot/+/75045 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Kyösti Mälkki <kyosti.malkki@gmail.com>
* acpi: Warn on timeout in write_delay_until()Cliff Huang2023-05-171-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Make ACPI code print a debug warning message when a timeout is detected in a loop waiting for a condition. This timeout message won't be displayed when this function is used as delay loop (ie. without checking variable condition). The following is required to get this log in kernel log buffer: echo 1 > /sys/module/acpi/parameters/aml_debug_output Here is an example of generated code when waiting for variable L23E to be 0. Local7 = 0x08 While ((Local7 > Zero)) { If ((L23E == Zero)) { Break } Sleep (0x10) Local7-- If ((Local7 == Zero)) { Debug = "WARN: Wait loop timeout for variable L23E" } } BRANCH=firmware-brya-14505.B TEST=Boot to OS and check that the Debug print is added to the function. Change-Id: I3843e51988527e99822017d1b5f653ff2eaa7958 Signed-off-by: Cliff Huang <cliff.huang@intel.com> Signed-off-by: Jeremy Compostella <jeremy.compostella@intel.com> Reviewed-on: https://review.coreboot.org/c/coreboot/+/73348 Reviewed-by: Nico Huber <nico.h@gmx.de> Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Lean Sheng Tan <sheng.tan@9elements.com>
* acpigen: Add printf-like function for debug stringCliff Huang2023-05-161-33/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Generate formatted string and ACPI code to print debug string. For example (with pcie_rp = 1): acpigen_write_debug_sprintf("calling _ON for RP: %u", pcie_rp); generates the following ACPI code: Debug = "calling _ON for RP: 1" With this new function, the following functions are not needed anymore and therefore are removed by this patch. - acpigen_concatenate_string_string() - acpigen_concatenate_string_int() - acpigen_write_debug_concatenate_string_string() - acpigen_write_debug_concatenate_string_int() BRANCH=firmware-brya-14505.B TEST=Add above functions in the acpigen code and check the generated SSDT table after OS boot. Check the debug messages is in the kernel log when /sys/modules/acpi/parameters/aml_debug_output is set to '1'. Change-Id: Id4a42e5854516a22b7bc4559c2ed08680722c5ba Signed-off-by: Cliff Huang <cliff.huang@intel.com> Signed-off-by: Jeremy Compostella <jeremy.compostella@intel.com> Reviewed-on: https://review.coreboot.org/c/coreboot/+/73113 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Bora Guvendik <bora.guvendik@intel.com> Reviewed-by: Nico Huber <nico.h@gmx.de> Reviewed-by: Zhixing Ma <zhixing.ma@intel.com> Reviewed-by: Musse Abdullahi <musse.abdullahi@intel.corp-partner.google.com> Reviewed-by: Angel Pons <th3fanbus@gmail.com> Reviewed-by: Lean Sheng Tan <sheng.tan@9elements.com>
* acpi/acpigen: add comment about byte 0 in acpigen_resource_*wordFelix Held2023-05-141-0/+3
| | | | | | | | | | | | | | | | | | | | | Since it's not obvious, add comments to acpigen_resource_word, acpigen_resource_dword and acpigen_resource_qword to clarify out what the magic number in byte 0 means. The most significant bit of byte 0 indicates if it is a small or large resource data type. In the case of the MSB being 0, it's a small resource data type (aka type 0), and the other bits encode bit the type and size of the item; if the MSB is 1, it's a large resource data type (aka type 1), and the other bits just encode the type and there are two separate bytes to encode the size. Beware that the large resource's data type values in the ACPI specification don't include the MSB that's set, but only the 7 lower bits. Signed-off-by: Felix Held <felix-coreboot@felixheld.de> Change-Id: Ia6a6c9fb1bcde232122bb5899b9a0983ef48e12b Reviewed-on: https://review.coreboot.org/c/coreboot/+/75158 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Tim Wawrzynczak <inforichland@gmail.com> Reviewed-by: Kyösti Mälkki <kyosti.malkki@gmail.com>
* acpi/Kconfig: move \_SB scope out of ACPI_CPU_STRINGFelix Held2023-05-131-2/+3
| | | | | | | | | | | | | | | | | | | | | | In ACPI 1.0 the processor objects were inside the \_PR scope, but since ACPI 2.0 the \_SB scope can be used for that. Outside of coreboot some firmwares still used the \_PR scope for a while for legacy ACPI 1.0 OS compatibility, but apart from that the \_PR scope is deprecated. coreboot already uses the \_SB scope for the processor devices everywhere, so move the \_SB scope out of the ACPI_CPU_STRING to the format string inside the 3 snprintf statements that use the ACPI_CPU_STRING. Signed-off-by: Felix Held <felix-coreboot@felixheld.de> Suggested-by: Kyösti Mälkki <kyosti.malkki@gmail.com> Change-Id: I76f18594a3a623b437a163c270547d3e9618c31a Reviewed-on: https://review.coreboot.org/c/coreboot/+/75167 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Nico Huber <nico.h@gmx.de> Reviewed-by: Tim Wawrzynczak <inforichland@gmail.com> Reviewed-by: Matt DeVillier <matt.devillier@amd.corp-partner.google.com> Reviewed-by: Fred Reitberger <reitbergerfred@gmail.com> Reviewed-by: Kyösti Mälkki <kyosti.malkki@gmail.com>
* acpi/acpigen: add acpigen_resource_io to generate I/O resourceFelix Held2023-05-111-0/+14
| | | | | | | | | | | | Add the acpigen_resource_io helper function to generate an I/O range resource. Signed-off-by: Felix Held <felix-coreboot@felixheld.de> Signed-off-by: Arthur Heymans <arthur@aheymans.xyz> Change-Id: I177f59b52d4dbbff0a3ceeef5fc8c7455cef9ff8 Reviewed-on: https://review.coreboot.org/c/coreboot/+/75044 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Tim Wawrzynczak <inforichland@gmail.com>
* acpi/acpigen: add acpigen_resource_bus_number to generate bus numberFelix Held2023-05-111-0/+14
| | | | | | | | | | | | Add the acpigen_resource_bus_number helper function to generate a bus number range resource. Signed-off-by: Felix Held <felix-coreboot@felixheld.de> Signed-off-by: Arthur Heymans <arthur@aheymans.xyz> Change-Id: Ib1f1da3dbe823c6bc4fc30c0622653410cfbf301 Reviewed-on: https://review.coreboot.org/c/coreboot/+/75043 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Tim Wawrzynczak <inforichland@gmail.com>
* acpi/acpigen: add acpigen_write_BBN to generate base bus number methodFelix Held2023-05-081-0/+11
| | | | | | | | | | | | | Introduce acpigen_write_BBN to generate the ACPI method object that returns the base bus number for a PCI(e) host bridge. When called, the base_bus_number argument must be the first PCI bus number that got assigned to the corresponding host bridge. Signed-off-by: Felix Held <felix-coreboot@felixheld.de> Change-Id: Ib67bf42b9c77c262d8a02d8f28ac5cb8482136b9 Reviewed-on: https://review.coreboot.org/c/coreboot/+/74991 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Tim Wawrzynczak <inforichland@gmail.com>
* acpigen: Add a runtime method to override exposed _Sx sleep statesArthur Heymans2023-05-011-0/+14
| | | | | | | | | | | | | | | This allows mainboards to override available sleep states at runtime. This is done by adding a IntObj in SSDT that DSDT consumes to override the available _Sx states. Signed-off-by: Arthur Heymans <arthur@aheymans.xyz> Change-Id: Ic21830c1ef9c183b1e3005cc1f8b7daf7e9ea998 Reviewed-on: https://review.coreboot.org/c/coreboot/+/74762 Reviewed-by: Nico Huber <nico.h@gmx.de> Reviewed-by: Jakub Czapiga <jacz@semihalf.com> Reviewed-by: Jan Samek <jan.samek@siemens.com> Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Lean Sheng Tan <sheng.tan@9elements.com>
* ACPI: Add acpigen_write_PTC()Kyösti Mälkki2023-04-261-11/+20
| | | | | | | | Change-Id: Ibaf2d7105e7a5da8a50ef32b682978ff55fe31e0 Signed-off-by: Kyösti Mälkki <kyosti.malkki@gmail.com> Reviewed-on: https://review.coreboot.org/c/coreboot/+/74473 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Arthur Heymans <arthur@aheymans.xyz>
* acpi/acpigen: use acpigen_write_store_* in acpigen_write_romFelix Held2023-02-101-18/+6
| | | | | | | | | | | Use existing functions instead of open-coding the same functionality. Signed-off-by: Felix Held <felix-coreboot@felixheld.de> Change-Id: Ie35c7e0fd3caa25b0d3d02443609e54dd2fdcb7c Reviewed-on: https://review.coreboot.org/c/coreboot/+/72937 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Tim Wawrzynczak <inforichland@gmail.com> Reviewed-by: Elyes Haouas <ehaouas@noos.fr>
* acpi/acpigen: add acpigen_write_store_namestr_to_namestrFelix Held2023-02-101-0/+8
| | | | | | | | | | | | acpigen_write_rom open-codes this functionality, so add a function for this. Signed-off-by: Felix Held <felix-coreboot@felixheld.de> Change-Id: Ief25dd854d1639a295c021e9d02c05b4cc61109c Reviewed-on: https://review.coreboot.org/c/coreboot/+/72936 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Tim Wawrzynczak <inforichland@gmail.com> Reviewed-by: Elyes Haouas <ehaouas@noos.fr>
* acpi/acpigen: use acpigen_write_if_lgreater_* in acpigen_write_romFelix Held2023-02-101-16/+4
| | | | | | | | | | | Use existing functions instead of open-coding the same functionality. Signed-off-by: Felix Held <felix-coreboot@felixheld.de> Change-Id: I660bd5d357eb86c19a5a7847925f6176c3fb4425 Reviewed-on: https://review.coreboot.org/c/coreboot/+/72935 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Tim Wawrzynczak <inforichland@gmail.com> Reviewed-by: Elyes Haouas <ehaouas@noos.fr>
* src/acpi: add function gen: if_lgreater_ and namestr assignmentCliff Huang2023-02-091-0/+50
| | | | | | | | | | | | | | | | | | | | | | | | 1. add functions to generate if greater than conditions: acpigen_write_if_lgreater_op_op: if (op1 > op2) acpigen_write_if_lgreater_op_int: if (op > val) acpigen_write_if_lgreater_namestr_int: if (namestr > val) 2. add function to assignal value to a namestr acpigen_write_store_namestr_to_op: namestr = val TEST=Use above functions and check the generated SSDT table after OS boot. Signed-off-by: Cliff Huang <cliff.huang@intel.com> Change-Id: Iffe1b23362a7ab58bdc2aa8daf45cd6f086ee818 Reviewed-on: https://review.coreboot.org/c/coreboot/+/72825 Reviewed-by: Eric Lai <eric_lai@quanta.corp-partner.google.com> Reviewed-by: Jérémy Compostella <jeremy.compostella@intel.com> Reviewed-by: Anil Kumar K <anil.kumar.k@intel.corp-partner.google.com> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
* acpi/acpigen.c: Add a comment to deprecate acpigen_write_processor()Elyes Haouas2023-02-071-0/+1
| | | | | | | | | | | ACPI Revision 6.0 deprecates Processor keyword, so use acpigen_write_processor_device() instead. Change-Id: I31626f4e323dd9053a63c0f5e89d1685103e4bd4 Signed-off-by: Elyes Haouas <ehaouas@noos.fr> Reviewed-on: https://review.coreboot.org/c/coreboot/+/72487 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Felix Held <felix-coreboot@felixheld.de>
* acpi/acpigen: introduce acpigen_write_processor_deviceFelix Held2023-01-311-0/+9
| | | | | | | | | | | | | | | | The ACPI PROCESSOR_OP has been deprecated in ACPI 6.0 and dropped in ACPI 6.4 and is now permanently reserved. As a replacement, DEVICE_OP with the special HID ACPI0007 should be used instead. This special HID was introduced in version 3 of the ACPI spec. To have a function to generate this, acpigen_write_processor_device is introduced. The CPU index is used as UID which can be assumed to be unique. Signed-off-by: Felix Held <felix-coreboot@felixheld.de> Change-Id: Ifb0da903a972be134bb3b9071f81b441f60917d1 Reviewed-on: https://review.coreboot.org/c/coreboot/+/72469 Reviewed-by: Elyes Haouas <ehaouas@noos.fr> Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Kyösti Mälkki <kyosti.malkki@gmail.com>
* acpi/acpigen: factor out acpigen_write_processor_namestringFelix Held2023-01-281-13/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | This functionality is used in multiple places, so factor it out into a function. Compared to acpigen_write_processor_cnot, the buffer size is decreased from 40 to 16 bytes, but the format string specified by CONFIG_ACPI_CPU_STRING results in 9 chars and a NULL byte which will fit into the buffer without any issue. I've seen the CPU devices being put into another scope within \_SB, but even in that case that would be 14 chars and a NULL byte whist still fits into the 16 byte buffer. For acpigen_write_processor and acpigen_write_processor_package this doesn't change any edge case behavior. In the unrealistic case of the format string resulting in a longer CPU device string, this would have been a problem before this patch too. Also drop the curly braces of the for loop in acpigen_write_processor_package. This makes the code a bit harder to read and isn't a very good idea, but with the curly braces in place, the linter breaks the build :( Signed-off-by: Felix Held <felix-coreboot@felixheld.de> Change-Id: I5d8291a2aaae2011cb185d72c7f7864b6e2220ec Reviewed-on: https://review.coreboot.org/c/coreboot/+/72452 Reviewed-by: Fred Reitberger <reitbergerfred@gmail.com> Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Matt DeVillier <matt.devillier@amd.corp-partner.google.com> Reviewed-by: Elyes Haouas <ehaouas@noos.fr>
* src/acpi: add debug message with concatenated stringCliff Huang2023-01-271-0/+54
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | add functions for concatenate OP add debug message containing concatenated string with string, value, or OPs Ex1: to print string with another string provided from C side: acpigen_write_debug_concatenate_string_string("Wait loop Timeout! var=", name, LOCAL6_OP); will generate: Concatenate ("Wait loop Timeout! var=", "L23E", Local6) Debug = Local6 Ex2: to print string with a value: acpigen_write_debug_concatenate_string_int("ModPHY enabling for RP:", pcie_rp, LOCAL0_OP); will generate: Concatenate ("ModPHY enabling for RP:", 0x05, Local0) Debug = Local0 Ex3: to print string with an ACPI OP: acpigen_write_debug_concatenate_string_op("while Loop count: ", LOCAL7_OP, LOCAL6_OP) will generate: Concatenate ("while Loop count: ", Local7, Local6) Debug = Local6 TEST=Add above functions in the acpigen code and check the generated SSDT table after OS boot Signed-off-by: Cliff Huang <cliff.huang@intel.com> Change-Id: I370745efe3d6b513ec2c5376248362a3eb4b3d21 Reviewed-on: https://review.coreboot.org/c/coreboot/+/72126 Reviewed-by: Jérémy Compostella <jeremy.compostella@intel.com> Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Bora Guvendik <bora.guvendik@intel.com>
* src/acpi: Remove unnecessary space after castsElyes Haouas2022-11-221-2/+2
| | | | | | | | Change-Id: I3c077dee1c14e4aa45f837361daf799f02d32a29 Signed-off-by: Elyes Haouas <ehaouas@noos.fr> Reviewed-on: https://review.coreboot.org/c/coreboot/+/69818 Reviewed-by: Eric Lai <eric_lai@quanta.corp-partner.google.com> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
* acpigen: export acpigen_write_field_nameMichael Niewöhner2022-11-021-1/+1
| | | | | | | | | | It will be used in a follow-up change. Change-Id: If89f9569c33949995d3b45a5f871ff2cb84a6610 Signed-off-by: Michael Niewöhner <foss@mniewoehner.de> Reviewed-on: https://review.coreboot.org/c/coreboot/+/68787 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Angel Pons <th3fanbus@gmail.com>
* src/acpi/acpigen.c: Reformat codeElyes Haouas2022-02-211-40/+27
| | | | | | | | Change-Id: I58851c8a26cad61975f8ba2910eedef3029aab6f Signed-off-by: Elyes Haouas <ehaouas@noos.fr> Reviewed-on: https://review.coreboot.org/c/coreboot/+/62131 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Lance Zhao
* treewide: Remove "ERROR: "/"WARN: " prefixes from log messagesJulius Werner2022-02-071-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | Now that the console system itself will clearly differentiate loglevels, it is no longer necessary to explicitly add "ERROR: " in front of every BIOS_ERR message to help it stand out more (and allow automated tooling to grep for it). Removing all these extra .rodata characters should save us a nice little amount of binary size. This patch was created by running find src/ -type f -exec perl -0777 -pi -e 's/printk\(\s*BIOS_ERR,\s*"ERROR: /printk\(BIOS_ERR, "/gi' '{}' ';' and doing some cursory review/cleanup on the result. Then doing the same thing for BIOS_WARN with 's/printk\(\s*BIOS_WARNING,\s*"WARN(ING)?: /printk\(BIOS_WARNING, "/gi' Signed-off-by: Julius Werner <jwerner@chromium.org> Change-Id: I3d0573acb23d2df53db6813cb1a5fc31b5357db8 Reviewed-on: https://review.coreboot.org/c/coreboot/+/61309 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: HAOUAS Elyes <ehaouas@noos.fr> Reviewed-by: Lance Zhao Reviewed-by: Jason Glenesk <jason.glenesk@gmail.com>
* src/include/acpi: Move CPPC_PACKAGE_NAME macro definitionSridhar Siricilla2022-01-181-2/+0
| | | | | | | | | | | | | | | The patch moves the CPPC_PACKAGE_NAME macro definition from file acpi/acpigen.c to include/acpi/acpigen.h file since the CPPC_PACKAGE_NAME method will get called from cpu/intel/common in a later patch. TEST=Built the code for Brya Signed-off-by: Sridhar Siricilla <sridhar.siricilla@intel.com> Change-Id: Ic547445cdbe2b1a3efe44390bd127f577386e7fc Reviewed-on: https://review.coreboot.org/c/coreboot/+/59358 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Tim Wawrzynczak <twawrzynczak@chromium.org>
* acpi/acpigen.c: Remove weak gpio definitionArthur Heymans2021-10-291-29/+0
| | | | | | | | | | | Compiletime errors > runtime errors. Change-Id: I1db0a8f01eaecf012e5444c03f8d4e2bb6e42a77 Signed-off-by: Arthur Heymans <arthur@aheymans.xyz> Reviewed-on: https://review.coreboot.org/c/coreboot/+/58649 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Tim Wawrzynczak <twawrzynczak@chromium.org> Reviewed-by: Felix Held <felix-coreboot@felixheld.de>
* acpigen,soc/amd,cpu/intel: rework static DWORD for CPPC tableMichael Niewöhner2021-10-211-7/+5
| | | | | | | | | | | | | | Some elements in the ACPI CPPC table allow static DWORDs. Instead of using a fake register resource, use a tagged union with the two types "register" and "DWORD" and respective macros for CPPC table entries. Test: dumped SSDT before and after do not differ. Change-Id: Ib853261b5c0ea87ae2424fed188f2d1872be9a06 Signed-off-by: Michael Niewöhner <foss@mniewoehner.de> Reviewed-on: https://review.coreboot.org/c/coreboot/+/57886 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Felix Held <felix-coreboot@felixheld.de>
* acpi/acpigen: Constify CST functions' pointersAngel Pons2021-10-191-2/+2
| | | | | | | | | | | | | | The `acpigen_write_CST_package` and `acpigen_write_CST_package_entry` functions don't modify the provided C-state information. So, make the pointer parameters read-only to enforce this. Also constify arguments where possible. Change-Id: I9e18d82ee6c16e4435b8fad6d467e58c33194cf4 Signed-off-by: Angel Pons <th3fanbus@gmail.com> Reviewed-on: https://review.coreboot.org/c/coreboot/+/58391 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Raul Rangel <rrangel@chromium.org> Reviewed-by: Felix Held <felix-coreboot@felixheld.de>
* acpigen: Add ability to auto-generate _DSM Function 0Tim Wawrzynczak2021-09-101-3/+46
| | | | | | | | | | | | | Since the value returned by _DSM function 0 for a given UUID is trivial to calculate, add the ability to do so to the acpigen_write_dsm() functions. Change-Id: Id9be050442485b42202cf91649aa94e56f35032a Signed-off-by: Tim Wawrzynczak <twawrzynczak@chromium.org> Reviewed-on: https://review.coreboot.org/c/coreboot/+/56459 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Angel Pons <th3fanbus@gmail.com> Reviewed-by: Furquan Shaikh <furquan@google.com>
* acpi: Add function to simplify If (CondRefOf (..)) sequencesTim Wawrzynczak2021-07-121-0/+15
| | | | | | | | | | | The new function is called acpigen_write_if_cond_refof(), and it must be paired with a following acpigen_write_if_end() call. Change-Id: I6e192a569f550ecb77ad264275d52f219eacaca1 Signed-off-by: Tim Wawrzynczak <twawrzynczak@chromium.org> Reviewed-on: https://review.coreboot.org/c/coreboot/+/56003 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Patrick Georgi <pgeorgi@google.com>
* acpi: Add acpigen_write_thermal_zoneRaul E Rangel2021-05-141-0/+7
| | | | | | | | | | | | BUG=b:186166365 TEST=Compiles Signed-off-by: Raul E Rangel <rrangel@chromium.org> Change-Id: Icf88477143049119036c00276f9a01985dc0b4d3 Reviewed-on: https://review.coreboot.org/c/coreboot/+/54131 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Lance Zhao Reviewed-by: Tim Wawrzynczak <twawrzynczak@chromium.org>
* acpi: Add acpigen_write_LPI_packageRaul E Rangel2021-04-211-0/+72
| | | | | | | | | | | | | | | | | | Low Power Idle States defines additional information not present in the _CST. See ACPI Specification, Version 6.3 Section 8.4.4.3 _LPI. BUG=b:178728116, b:185787242 TEST=Boot guybrush and dump ACPI tables Signed-off-by: Raul E Rangel <rrangel@chromium.org> Signed-off-by: Jason Glenesk <jason.glenesk@amd.corp-partner.google.com> Change-Id: I4f5301b95ff8245facaf48e2fbd51cc82df2d8cc Reviewed-on: https://review.coreboot.org/c/coreboot/+/52529 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Furquan Shaikh <furquan@google.com> Reviewed-by: Marshall Dawson <marshalldawson3rd@gmail.com>
* acpi/acpigen.h: Add more intuitive AML package closing functionsJakub Czapiga2021-03-221-0/+2
| | | | | | | | | | | | | | | | Until now every AML package had to be closed using acpigen_pop_len(). This commit introduces set of package closing functions corresponding with their opening function names. For example acpigen_write_if() opens if-statement package, acpigen_write_if_end() closes it. Now acpigen_write_else() closes previously opened acpigen_write_if(), so acpigen_pop_len() is not required before it. Signed-off-by: Jakub Czapiga <jacz@semihalf.com> Change-Id: Icfdc3804cd93bde049cd11dec98758b3a639eafd Reviewed-on: https://review.coreboot.org/c/coreboot/+/50910 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Lance Zhao Reviewed-by: Angel Pons <th3fanbus@gmail.com>
* acpi: Move PCI functions to separate fileTim Wawrzynczak2021-03-011-19/+0
| | | | | | | | | Signed-off-by: Tim Wawrzynczak <twawrzynczak@chromium.org> Change-Id: Idc96b99da9f9037267c0bec2c839014b13ceb8cc Reviewed-on: https://review.coreboot.org/c/coreboot/+/51106 Reviewed-by: Furquan Shaikh <furquan@google.com> Reviewed-by: Lance Zhao Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
* src/acpi: Add missing <types.h>Elyes HAOUAS2021-02-161-0/+1
| | | | | | | | | Change-Id: Iec78183b43ea26d9de14e0ce28eef6fc0361cc95 Signed-off-by: Elyes HAOUAS <ehaouas@noos.fr> Reviewed-on: https://review.coreboot.org/c/coreboot/+/50555 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Lance Zhao Reviewed-by: Kyösti Mälkki <kyosti.malkki@gmail.com>
* acpi/acpigen.c: Remove unused and incorrect functionsJakub Czapiga2021-01-281-12/+0
| | | | | | | | | | | | | | acpigen_write_name_zero() and acpigen_write_name_one() are not implemented correctly, and are not used anywhere. Drop them in favor of the more flexible acpigen_write_name_integer() function. Signed-off-by: Jakub Czapiga <jacz@semihalf.com> Change-Id: I116fd41624a8e8b536d18d747f21d3131b734dfc Reviewed-on: https://review.coreboot.org/c/coreboot/+/49834 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Duncan Laurie <dlaurie@chromium.org> Reviewed-by: Lance Zhao Reviewed-by: Angel Pons <th3fanbus@gmail.com>
* src/acpi/acpigen: Add NULL pointer checkRonak Kanabar2020-12-021-0/+4
| | | | | | | | | | | | Add NULL pointer check in acpigen_emit_namestring to avoid segmentation fault. Change-Id: I3d01d28e74f202278b5a5a96d2edd45c66f10883 Signed-off-by: Ronak Kanabar <ronak.kanabar@intel.com> Reviewed-on: https://review.coreboot.org/c/coreboot/+/48148 Reviewed-by: Subrata Banik <subrata.banik@intel.com> Reviewed-by: Maulik V Vaghela <maulik.v.vaghela@intel.com> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
* acpigen: Add more useful helper functionsDuncan Laurie2020-11-091-1/+93
| | | | | | | | | | | | | | | | | | | | | | | | acpigen_write_debug_namestr() - Debug = NAME acpigen_write_return_namestr() - Return (NAME) acpigen_set_package_op_element_int() - Set package pointer element DeRefOf (PKG[ELEM]) = INT acpigen_get_package_element() - Get package (not pointer) element dest_op = PKG[ELEM] acpigen_set_package_element_int() - Set package element to integer PKG[ELEM] = INT acpigen_set_package_element_namestr() - Set package element to namestr PKG[ELEM] = NAME acpigen_write_delay_until_namestr_int() - Delay while waiting for register to equal expected value. BUG=b:160996445 Signed-off-by: Duncan Laurie <dlaurie@google.com> Change-Id: I9b20a23872b7d4a50f03761032426ffbb722b9ee Reviewed-on: https://review.coreboot.org/c/coreboot/+/47196 Reviewed-by: Furquan Shaikh <furquan@google.com> Reviewed-by: Tim Wawrzynczak <twawrzynczak@chromium.org> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
* soc/intel/skl,acpi/acpigen: convert global CPPC package to local oneMichael Niewöhner2020-11-041-3/+6
| | | | | | | | | | | | | | Move the global CPPC package \GCPC to the first logical core CP00 and adapt the reference in the other cores. This is cleaner and avoids confusion. Test: dumped SSDT on Supermicro X11SSM-F and verified decompiled version Change-Id: I40b9fd644622196da434128895eb6fb96fdf254d Signed-off-by: Michael Niewöhner <foss@mniewoehner.de> Reviewed-on: https://review.coreboot.org/c/coreboot/+/46465 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Tim Wawrzynczak <twawrzynczak@chromium.org>