#
d26193a0 |
| 01-Sep-2020 |
Roman Bolshakov <r.bolshakov@yadro.com> |
lib: x86: Use portable format macros for uint32_t
Compilation of the files fails on ARCH=i386 with i686-elf gcc because they use "%x" or "%d" format specifier that does not match the actual size of
lib: x86: Use portable format macros for uint32_t
Compilation of the files fails on ARCH=i386 with i686-elf gcc because they use "%x" or "%d" format specifier that does not match the actual size of uint32_t:
x86/s3.c: In function ‘main’: x86/s3.c:53:35: error: format ‘%x’ expects argument of type ‘unsigned int’, but argument 2 has type ‘u32’ {aka ‘long unsigned int’} [-Werror=format=] 53 | printf("PM1a event registers at %x\n", fadt->pm1a_evt_blk); | ~^ ~~~~~~~~~~~~~~~~~~ | | | | | u32 {aka long unsigned int} | unsigned int | %lx
Use PRIx32 instead of "x" and PRId32 instead of "d" to take into account u32_long case.
Cc: Alex Bennée <alex.bennee@linaro.org> Cc: Andrew Jones <drjones@redhat.com> Cc: Cameron Esfahani <dirty@apple.com> Signed-off-by: Roman Bolshakov <r.bolshakov@yadro.com> Message-Id: <20200901085056.33391-6-r.bolshakov@yadro.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
show more ...
|
#
fd6aada0 |
| 17-May-2017 |
Radim Krčmář <rkrcmar@redhat.com> |
use %# instead of 0x% in all format strings
It's one character shorter, properly prefixed, and also provides error detection: %#d triggers a warning.
Done with `sed -i 's/0x%/%#/g' **/*.[ch]` to mo
use %# instead of 0x% in all format strings
It's one character shorter, properly prefixed, and also provides error detection: %#d triggers a warning.
Done with `sed -i 's/0x%/%#/g' **/*.[ch]` to motivate the use of %#, existing padding was raised by 2 to account for the counted "0x" (output should be the same).
Signed-off-by: Radim Krčmář <rkrcmar@redhat.com>
show more ...
|
#
68cf12d2 |
| 27-Mar-2017 |
Alexander Gordeev <agordeev@redhat.com> |
pci: Add BAR sanity checks
Cc: Thomas Huth <thuth@redhat.com> Cc: Andrew Jones <drjones@redhat.com> Cc: Peter Xu <peterx@redhat.com> Reviewed-by: Thomas Huth <thuth@redhat.com> Reviewed-by: Andrew J
pci: Add BAR sanity checks
Cc: Thomas Huth <thuth@redhat.com> Cc: Andrew Jones <drjones@redhat.com> Cc: Peter Xu <peterx@redhat.com> Reviewed-by: Thomas Huth <thuth@redhat.com> Reviewed-by: Andrew Jones <drjones@redhat.com> Signed-off-by: Alexander Gordeev <agordeev@redhat.com> Signed-off-by: Radim Krčmář <rkrcmar@redhat.com>
show more ...
|
#
cb026028 |
| 28-Feb-2017 |
Alexander Gordeev <agordeev@redhat.com> |
pci: Make PCI API consistent wrt using struct pci_dev
Complete conversion of PCI API so all functions that imply the underlying device does exist would use struct pci_dev as a handle, not pcidevaddr
pci: Make PCI API consistent wrt using struct pci_dev
Complete conversion of PCI API so all functions that imply the underlying device does exist would use struct pci_dev as a handle, not pcidevaddr_t.
Cc: Thomas Huth <thuth@redhat.com> Cc: Andrew Jones <drjones@redhat.com> Cc: Peter Xu <peterx@redhat.com> Reviewed-by: Andrew Jones <drjones@redhat.com> Signed-off-by: Alexander Gordeev <agordeev@redhat.com> Signed-off-by: Radim Krčmář <rkrcmar@redhat.com>
show more ...
|
#
9e292d10 |
| 28-Feb-2017 |
Alexander Gordeev <agordeev@redhat.com> |
pci: Rework pci_bar_is_valid()
Cc: Thomas Huth <thuth@redhat.com> Cc: Andrew Jones <drjones@redhat.com> Cc: Peter Xu <peterx@redhat.com> Reviewed-by: Andrew Jones <drjones@redhat.com> Signed-off-by:
pci: Rework pci_bar_is_valid()
Cc: Thomas Huth <thuth@redhat.com> Cc: Andrew Jones <drjones@redhat.com> Cc: Peter Xu <peterx@redhat.com> Reviewed-by: Andrew Jones <drjones@redhat.com> Signed-off-by: Alexander Gordeev <agordeev@redhat.com> Signed-off-by: Radim Krčmář <rkrcmar@redhat.com>
show more ...
|
#
78609f0e |
| 28-Feb-2017 |
Alexander Gordeev <agordeev@redhat.com> |
pci: Turn struct pci_dev into device handle for PCI functions
Currently struct pci_dev is used for caching PCI device info used by some functions. This update turns the struct into device handle tha
pci: Turn struct pci_dev into device handle for PCI functions
Currently struct pci_dev is used for caching PCI device info used by some functions. This update turns the struct into device handle that will be used by nearly all existing and future APIs.
As result of this change a pci_dev should be initialized with pci_dev_init() and pci_scan_bars() becomes redundant.
Cc: Thomas Huth <thuth@redhat.com> Cc: Andrew Jones <drjones@redhat.com> Cc: Peter Xu <peterx@redhat.com> Reviewed-by: Andrew Jones <drjones@redhat.com> Signed-off-by: Alexander Gordeev <agordeev@redhat.com> Signed-off-by: Radim Krčmář <rkrcmar@redhat.com>
show more ...
|
#
48543201 |
| 28-Feb-2017 |
Alexander Gordeev <agordeev@redhat.com> |
pci: Accomodate 64 bit BARs in pci_dev::resource[]
Array pci_dev::resource[] is ambiguous wrt what is actually stored in its elements and how to interpret the index into the array.
It is simple in
pci: Accomodate 64 bit BARs in pci_dev::resource[]
Array pci_dev::resource[] is ambiguous wrt what is actually stored in its elements and how to interpret the index into the array.
It is simple in case a device has only 32-bit BARs - an element pci_dev::resource[bar_num] contains the decoded address of BAR # bar_num.
But what if a device has 64-bit BAR starting at bar_num?
Curretnly pci_dev::resource[bar_num] contains the decoded address of the BAR, while pci_dev::resource[bar_num + 1] contains 0. That makes meaning of (bar_num + 1) index difficult to understand.
On the one hand a testcase should not address a 64-bit BAR using high part BAR number. Particularly, when it tries to obtan BAR size or address. On the other hand a testcase should be able to access a low and high parts separately if it needs to for whatever reason. The rest of the API allows that as well.
pci_dev::resource[] contains decoded 32/64-bit BAR addresses, not low/high parts of underlying 32-bit device BARs. Yet, indexes into this array correspond to raw 32-bit BARs in the PCI device configuration space. Thus, a question arises - what should be stored in array elements that correspond to high-parts of 64-bit BARs? Zero is particularly bad choice, because: - it is a valid address in PIO address space, so it can not stand for "no value" or NULL or whatever marker could be used to indicate a high part; - the high part of underlying 64-bit address is (could be) non-zero. So there is inconsistency also;
By placing the same 64-bit address in both bar_num and (bar_num + 1) elements the ambiguity is less striking, since: - the meaning of bar_num kept consistent with the rest of the functions (where it refers 32-bit BAR in terms of the device configuration address space); - pci_dev::resource[bar_num + 1] contains a valid address rather than vague value of 0. - both bar_num and (bar_num + 1) indexes refer to the same 64-bit BAR and therefore return the same address; The notion of low and high parts of a 64-bit address is ignored, but that is fine, since pci_dev::resource[] contain only full addresses;
Cc: Thomas Huth <thuth@redhat.com> Cc: Andrew Jones <drjones@redhat.com> Cc: Peter Xu <peterx@redhat.com> Reviewed-by: Andrew Jones <drjones@redhat.com> Signed-off-by: Alexander Gordeev <agordeev@redhat.com> Signed-off-by: Radim Krčmář <rkrcmar@redhat.com>
show more ...
|
#
82f2f21a |
| 16-Jan-2017 |
Andrew Jones <drjones@redhat.com> |
lib/pci: reduce library noise
Avoid printfs in library code unless in a printing function, e.g. pci_dev_print. Particularly we can avoid printing anything the caller can easily print themselves, if
lib/pci: reduce library noise
Avoid printfs in library code unless in a printing function, e.g. pci_dev_print. Particularly we can avoid printing anything the caller can easily print themselves, if so desired.
Signed-off-by: Andrew Jones <drjones@redhat.com> Reviewed-by: Peter Xu <peterx@redhat.com> Signed-off-by: Radim Krčmář <rkrcmar@redhat.com>
show more ...
|
#
c4b7d52a |
| 16-Jan-2017 |
Andrew Jones <drjones@redhat.com> |
lib/pci: expose pci_dev_print
Signed-off-by: Andrew Jones <drjones@redhat.com> Reviewed-by: Peter Xu <peterx@redhat.com> Signed-off-by: Radim Krčmář <rkrcmar@redhat.com>
|
#
cdccea7c |
| 16-Jan-2017 |
Andrew Jones <drjones@redhat.com> |
lib/pci: generalize pci_cap_walk
Increase the utility of pci_cap_walk by allowing the caller to supply the table of cap handlers via a single handler, which implements all the cases of interest.
Si
lib/pci: generalize pci_cap_walk
Increase the utility of pci_cap_walk by allowing the caller to supply the table of cap handlers via a single handler, which implements all the cases of interest.
Signed-off-by: Andrew Jones <drjones@redhat.com> Reviewed-by: Peter Xu <peterx@redhat.com> Signed-off-by: Radim Krčmář <rkrcmar@redhat.com>
show more ...
|
#
7c305137 |
| 11-Jan-2017 |
Alex Bennée <alex.bennee@linaro.org> |
lib/pci: fix BAR format strings
Using %lx as a format string is not portable across 32/64 bit builds. Use explicit PRIx64 format strings.
Signed-off-by: Alex Bennée <alex.bennee@linaro.org> Signed-
lib/pci: fix BAR format strings
Using %lx as a format string is not portable across 32/64 bit builds. Use explicit PRIx64 format strings.
Signed-off-by: Alex Bennée <alex.bennee@linaro.org> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
show more ...
|
#
19daf1c5 |
| 30-Dec-2016 |
Peter Xu <peterx@redhat.com> |
pci: introduce pci_msi_set_enable()
Generalize this function out of pci_setup_msi(), then it can be further used to enable INTx (or, disable MSI).
Signed-off-by: Peter Xu <peterx@redhat.com> Signed
pci: introduce pci_msi_set_enable()
Generalize this function out of pci_setup_msi(), then it can be further used to enable INTx (or, disable MSI).
Signed-off-by: Peter Xu <peterx@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
show more ...
|
#
352096c7 |
| 30-Dec-2016 |
Peter Xu <peterx@redhat.com> |
pci: introduce pci_intx_line()
To fetch INTx irq line number.
Signed-off-by: Peter Xu <peterx@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
|
#
903b0516 |
| 12-Dec-2016 |
Peter Xu <peterx@redhat.com> |
pci: add msi support for 32/64bit address
pci_cap_walk() is provided to allow walk through all the capability bits for a specific PCI device. If a cap handler is provided, it'll be triggered if the
pci: add msi support for 32/64bit address
pci_cap_walk() is provided to allow walk through all the capability bits for a specific PCI device. If a cap handler is provided, it'll be triggered if the cap is detected along the cap walk.
MSI cap handler is the first one supported. We can add more cap handler in the future.
Meanwhile, pci_setup_msi() API is provided to support basic 32/64 bit address MSI setup.
Reviewed-by: Andrew Jones <drjones@redhat.com> Signed-off-by: Peter Xu <peterx@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
show more ...
|
#
66082ed6 |
| 12-Dec-2016 |
Peter Xu <peterx@redhat.com> |
pci: provide pci_enable_defaults()
One helper function to set/clear specific bit in PCI_COMMAND register is introduced. Then, provide a function to do most of the common PCI init work.
Suggested-by
pci: provide pci_enable_defaults()
One helper function to set/clear specific bit in PCI_COMMAND register is introduced. Then, provide a function to do most of the common PCI init work.
Suggested-by: Andrew Jones <drjones@redhat.com> Reviewed-by: Andrew Jones <drjones@redhat.com> Signed-off-by: Peter Xu <peterx@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
show more ...
|
#
e954ce23 |
| 12-Dec-2016 |
Peter Xu <peterx@redhat.com> |
pci: provide pci_scan_bars()
Let's provide a more general way to scan PCI bars, rather than read the config registers every time.
Then let x86/vmexit.c leverage pci_scan_bars()
Reviewed-by: Andrew
pci: provide pci_scan_bars()
Let's provide a more general way to scan PCI bars, rather than read the config registers every time.
Then let x86/vmexit.c leverage pci_scan_bars()
Reviewed-by: Andrew Jones <drjones@redhat.com> Signed-off-by: Peter Xu <peterx@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
show more ...
|
#
4d6cefa9 |
| 12-Dec-2016 |
Peter Xu <peterx@redhat.com> |
pci: introduce struct pci_dev
To extend current PCI framework, we need a per-device struct to store device specific information. Time to have a pci_dev struct. Most of the current PCI APIs are conve
pci: introduce struct pci_dev
To extend current PCI framework, we need a per-device struct to store device specific information. Time to have a pci_dev struct. Most of the current PCI APIs are converted to use this pci_dev object as the first argument. Currently it only contains one field "bdf", which is the bdf of current device.
For a few APIs like pci_config_*() ops or pci_find_dev(), I kept the old interface (use PCI BDF value rather than "struct pci_dev") since they can be used in a open context that without any specific PCI device.
Reviewed-by: Andrew Jones <drjones@redhat.com> Signed-off-by: Peter Xu <peterx@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
show more ...
|
#
647d2ab7 |
| 29-Nov-2016 |
Alexander Gordeev <agordeev@redhat.com> |
pci: Assert when PCI bus address can not be translated
Failing to translate the PCI address obtained from the bar means something isn't right with the PCI setup. As this should never happen, assert
pci: Assert when PCI bus address can not be translated
Failing to translate the PCI address obtained from the bar means something isn't right with the PCI setup. As this should never happen, assert when it does.
Cc: Thomas Huth <thuth@redhat.com> Cc: Andrew Jones <drjones@redhat.com> Signed-off-by: Alexander Gordeev <agordeev@redhat.com> [Added commit message] Signed-off-by: Andrew Jones <drjones@redhat.com>
show more ...
|
#
33d78b07 |
| 07-Nov-2016 |
Alexander Gordeev <agordeev@redhat.com> |
pci: Add generic ECAM host support
Unlike x86, other architectures using generic ECAM PCI host do not have a luxury of PCI bus initialized by a BIOS and ready to use at start. Thus, we need allocate
pci: Add generic ECAM host support
Unlike x86, other architectures using generic ECAM PCI host do not have a luxury of PCI bus initialized by a BIOS and ready to use at start. Thus, we need allocate and assign resources to all devices, much like an architecture's firmware would do.
There is no any sort of resource management for memory and io spaces, since only ones-per-BAR allocations are expected and no deallocations at all.
Cc: Thomas Huth <thuth@redhat.com> Cc: Andrew Jones <drjones@redhat.com> Cc: Peter Xu <peterx@redhat.com> Suggested-by: Andrew Jones <drjones@redhat.com> Signed-off-by: Alexander Gordeev <agordeev@redhat.com> Message-Id: <6488b060e4cbbead5a5ec525a53d65773ceb5f87.1478512824.git.agordeev@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
show more ...
|
#
e4611520 |
| 07-Nov-2016 |
Alexander Gordeev <agordeev@redhat.com> |
pci: Add pci_print()
Cc: Thomas Huth <thuth@redhat.com> Cc: Andrew Jones <drjones@redhat.com> Cc: Peter Xu <peterx@redhat.com> Suggested-by: Andrew Jones <drjones@redhat.com> Reviewed-by: Andrew Jon
pci: Add pci_print()
Cc: Thomas Huth <thuth@redhat.com> Cc: Andrew Jones <drjones@redhat.com> Cc: Peter Xu <peterx@redhat.com> Suggested-by: Andrew Jones <drjones@redhat.com> Reviewed-by: Andrew Jones <drjones@redhat.com> Signed-off-by: Alexander Gordeev <agordeev@redhat.com> Message-Id: <b261e0c3fbfafaa4c38793d4ae632a667f46fb16.1478512824.git.agordeev@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
show more ...
|
#
e1cad5c8 |
| 07-Nov-2016 |
Alexander Gordeev <agordeev@redhat.com> |
pci: Add pci_dev_exists()
Cc: Thomas Huth <thuth@redhat.com> Cc: Andrew Jones <drjones@redhat.com> Cc: Peter Xu <peterx@redhat.com> Reviewed-by: Andrew Jones <drjones@redhat.com> Signed-off-by: Alex
pci: Add pci_dev_exists()
Cc: Thomas Huth <thuth@redhat.com> Cc: Andrew Jones <drjones@redhat.com> Cc: Peter Xu <peterx@redhat.com> Reviewed-by: Andrew Jones <drjones@redhat.com> Signed-off-by: Alexander Gordeev <agordeev@redhat.com> Message-Id: <bbe2afcf1701fa8905d910e141c922e2b058073f.1478512824.git.agordeev@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
show more ...
|
#
647f92c7 |
| 07-Nov-2016 |
Alexander Gordeev <agordeev@redhat.com> |
pci: Add pci_bar_set_addr()
Because the counterpart to pci_bar_set_addr() setter is pci_bar_addr() getter, these names become inconsistent. Rename pci_bar_addr() to pci_bar_get_addr() also to make t
pci: Add pci_bar_set_addr()
Because the counterpart to pci_bar_set_addr() setter is pci_bar_addr() getter, these names become inconsistent. Rename pci_bar_addr() to pci_bar_get_addr() also to make the resulting names conform to each other.
Cc: Thomas Huth <thuth@redhat.com> Cc: Andrew Jones <drjones@redhat.com> Cc: Peter Xu <peterx@redhat.com> Reviewed-by: Andrew Jones <drjones@redhat.com> Signed-off-by: Alexander Gordeev <agordeev@redhat.com> Message-Id: <ce732680ee4989d1b2b26361a2c02d24b8bef37b.1478512824.git.agordeev@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
show more ...
|
#
2455ef20 |
| 07-Nov-2016 |
Alexander Gordeev <agordeev@redhat.com> |
pci: Rework pci_bar_addr()
This update makes pci_bar_addr() interface 64 bit BARs aware and introduces a concept of PCI address translation.
An architecutre should implement pci_translate_addr() in
pci: Rework pci_bar_addr()
This update makes pci_bar_addr() interface 64 bit BARs aware and introduces a concept of PCI address translation.
An architecutre should implement pci_translate_addr() interface in order to provide mapping between PCI bus address and CPU physical address.
Cc: Thomas Huth <thuth@redhat.com> Cc: Andrew Jones <drjones@redhat.com> Cc: Peter Xu <peterx@redhat.com> Reviewed-by: Andrew Jones <drjones@redhat.com> Reviewed-by: Thomas Huth <thuth@redhat.com> Signed-off-by: Alexander Gordeev <agordeev@redhat.com> Message-Id: <11145b9c19a61b4f585b3fabf5b2c64299aa89ff.1478512824.git.agordeev@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
show more ...
|
#
7aa83307 |
| 07-Nov-2016 |
Alexander Gordeev <agordeev@redhat.com> |
pci: Factor out pci_bar_get()
Cc: Thomas Huth <thuth@redhat.com> Cc: Andrew Jones <drjones@redhat.com> Cc: Peter Xu <peterx@redhat.com> Reviewed-by: Andrew Jones <drjones@redhat.com> Reviewed-by: Th
pci: Factor out pci_bar_get()
Cc: Thomas Huth <thuth@redhat.com> Cc: Andrew Jones <drjones@redhat.com> Cc: Peter Xu <peterx@redhat.com> Reviewed-by: Andrew Jones <drjones@redhat.com> Reviewed-by: Thomas Huth <thuth@redhat.com> Signed-off-by: Alexander Gordeev <agordeev@redhat.com> Message-Id: <1173859894ae623b5324ad04fc6417a4591ad450.1478512824.git.agordeev@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
show more ...
|
#
d8369c77 |
| 07-Nov-2016 |
Alexander Gordeev <agordeev@redhat.com> |
pci: x86: Add remaining PCI configuration space accessors
Cc: Thomas Huth <thuth@redhat.com> Cc: Andrew Jones <drjones@redhat.com> Cc: Peter Xu <peterx@redhat.com> Reviewed-by: Andrew Jones <drjones
pci: x86: Add remaining PCI configuration space accessors
Cc: Thomas Huth <thuth@redhat.com> Cc: Andrew Jones <drjones@redhat.com> Cc: Peter Xu <peterx@redhat.com> Reviewed-by: Andrew Jones <drjones@redhat.com> Reviewed-by: Thomas Huth <thuth@redhat.com> Signed-off-by: Alexander Gordeev <agordeev@redhat.com> Message-Id: <df1dee9ef0ff2740835e0690f84b849315ee7885.1478512824.git.agordeev@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
show more ...
|