We added this as a GCC 10 quirk, but of course by now there are many
more versions with this flag. Stable GCC 10.1 was released almost 4
years ago and libhwbase is mostly used with coreboot's toolchain and
newer ones. So we don't have to keep compatibility with older GCC
releases.
Change-Id: I1131ebbdde71cd6223a9ea650512eec601401cc3
Signed-off-by: Nico Huber <nico.h@gmx.de>
Reviewed-on: https://review.coreboot.org/c/libhwbase/+/82052
Reviewed-by: Angel Pons <th3fanbus@gmail.com>
It places the Middle_Of_Line and Register_Write_Delay_Nanoseconds
variables in the .bss section. As a result they are set at runtime to
their desired default value which is respectively False and 0.
It helps to integrate the libhwbase library debug package in
environments where global initialized variables are not
supported such as coreboot romstage.
This change does not impact GNATprove as this package has SPARK_Mode
disabled.
BUG=b:252792591
BRANCH=firmware-brya-14505.B
TEST=Working as expected on skolas
Signed-off-by: Jeremy Compostella <jeremy.compostella@intel.com>
Change-Id: Ib23699f3f3446219c34c60ccd9987346e17769f2
Reviewed-on: https://review.coreboot.org/c/libhwbase/+/69854
Tested-by: Angel Pons <th3fanbus@gmail.com>
Reviewed-by: Angel Pons <th3fanbus@gmail.com>
GCC 11 complains about an incompatible access type, e.g.
hw-pci-dev.adb:28:04: instantiation error at hw-mmio_range.adb:32
hw-pci-dev.adb:28:04: instantiation error at hw-pci-mmconf.adb:36
hw-pci-dev.adb:28:04: designated type and access type are not compatible with respect to volatility due to Async_Readers, Async_Writers, Effective_Reads, Effective_Writes
Declaring the access type volatile works around the issue, but we
have to also treat `Range_A` as external state now. Declaring it
as `Base_Address` state was an odd hack anyway.
To avoid further hassle, we also disable `SPARK_Mode`. Treating
this as SPARK code was never intended, and we use a shadow imple-
mentation (`proof/hw-mmio_range.adb`) for proofs anyway.
TEST=Doesn't affect coreboot binaries.
Change-Id: I9ddc8d1dafdcb41810e4c8bf29164ef7130def3f
Signed-off-by: Nico Huber <nico.huber@secunet.com>
Reviewed-on: https://review.coreboot.org/c/libhwbase/+/55390
Reviewed-by: Jacob Garber <jgarber1@ualberta.ca>
Reviewed-by: Angel Pons <th3fanbus@gmail.com>
Reviewed-by: Patrick Georgi <pgeorgi@google.com>
Tested-by: Patrick Georgi <pgeorgi@google.com>
Looks like there's a new warning option that complains when the order of
component declarations, component clauses, and bit-level layout do not
all agree. However, we also enable `warnings are errors`. Plus, we use
mismatched component representation clauses on purpose in libgfxinit's
epilepsy-inducing gfxtest program to have RGB ordering on hardware that
works with BGR ordering. Hardware is cursed, so silence this warning.
Change-Id: I1565e3e834cd47b7f53fd2202b38fdf01a0b7619
Signed-off-by: Angel Pons <th3fanbus@gmail.com>
Reviewed-on: https://review.coreboot.org/c/libhwbase/+/43556
Tested-by: Nico Huber <nico.h@gmx.de>
Reviewed-by: Nico Huber <nico.h@gmx.de>
This allows users of this library to extend `ADAFLAGS` from within their
Makefile. The added flexibility makes this a very well spent dollar :-)
Change-Id: I873d3eea48549e6945c4229b50c2318a3711bc4d
Signed-off-by: Angel Pons <th3fanbus@gmail.com>
Reviewed-on: https://review.coreboot.org/c/libhwbase/+/43557
Tested-by: Nico Huber <nico.h@gmx.de>
Reviewed-by: Nico Huber <nico.h@gmx.de>
GNU Make 4.3 is more picky about the $(space) definition. It seems that
the variable ends up being empty.
Change-Id: If07db29fc63e8a45e9b0869df894ce3420fa9b95
Signed-off-by: Angel Pons <th3fanbus@gmail.com>
Reviewed-on: https://review.coreboot.org/c/libhwbase/+/39163
Tested-by: Patrick Georgi <pgeorgi@google.com>
Reviewed-by: Patrick Georgi <pgeorgi@google.com>
Reviewed-by: HAOUAS Elyes <ehaouas@noos.fr>
Reviewed-by: Nico Huber <nico.h@gmx.de>
The constant can be used to initialize variables of type HW.Time.T.
Change-Id: I65246d6776d464bfa8648075b48e7de61cd82902
Signed-off-by: Adrian-Ken Rueegsegger <ken@codelabs.ch>
Reviewed-on: https://review.coreboot.org/c/libhwbase/+/38983
Tested-by: Nico Huber <nico.h@gmx.de>
Reviewed-by: Nico Huber <nico.h@gmx.de>
The subject info data structure is static and is not changed during
runtime. Make Sinfo an imported constant and adjust refinement of
abstract timer state and global contract of Hz function accordingly.
They are no longer volatile.
Change-Id: I5729bc7f2d77c5c51a6cab2edc7953e95c9e4d29
Signed-off-by: Adrian-Ken Rueegsegger <ken@codelabs.ch>
Reviewed-on: https://review.coreboot.org/c/libhwbase/+/38982
Tested-by: Nico Huber <nico.h@gmx.de>
Reviewed-by: Nico Huber <nico.h@gmx.de>
Handle generated source files more independently from normal source
files. This allows mixing of generated specs with existing source
bodies.
As with the source file list, we filter the list of generated sources,
`$(name)-gens`: All spec (.ads) files that have a respective body file
(.adb), are moved into `$(name)-extra-gens`. This way, we can still
add these files as dependencies to all pre-existing source files.
Change-Id: I5479c436f39088ae9d0ebddf9a97446be0f191f3
Signed-off-by: Nico Huber <nico.h@gmx.de>
Reviewed-on: https://review.coreboot.org/c/libhwbase/+/27139
Reviewed-by: Angel Pons <th3fanbus@gmail.com>
Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
Reviewed-by: Patrick Georgi <pgeorgi@google.com>
Make abstract state `State` of HW.Time.Timer, that's used to derive the
Hz value for instance, External. This helps to fix flow issues in the
mutime implementation and also matches real hardware better: The clock
rate may be derived from the hardware state.
HW.Time.Timer.Hz had to be made a volatile function, therefore.
Change-Id: I35af2d0db1acbf9652ea00763aa288545746bb79
Signed-off-by: Nico Huber <nico.huber@secunet.com>
Reviewed-on: https://review.coreboot.org/c/libhwbase/+/26838
Tested-by: Nico Huber <nico.h@gmx.de>
Reviewed-by: Reto Buerki <reet@codelabs.ch>
Since we have z3, it was never of much use.
Change-Id: Ib0458bfe53fd999c60f8d1b7cf8709e6195d0a42
Signed-off-by: Nico Huber <nico.huber@secunet.com>
Reviewed-on: https://review.coreboot.org/c/libhwbase/+/26837
Tested-by: Nico Huber <nico.h@gmx.de>
Reviewed-by: Reto Buerki <reet@codelabs.ch>
GCC 8 wants us to tie the hidden, private state of HW.PCI.MMConf to a
surrounding state. Though, as it's impossible to do that before the
package instantiation, we can only comply by making it public.
Change-Id: I41c3d1324a7d9acde5be2c246011f976361e8f2b
Signed-off-by: Nico Huber <nico.h@gmx.de>
Reviewed-on: https://review.coreboot.org/26304
Tested-by: Patrick Georgi <pgeorgi@google.com>
Reviewed-by: Patrick Georgi <pgeorgi@google.com>
Other implementations may update the PCI_State in Resource_Size() and
Map(). To share the contract with those implementations, we have to
simulate such accesses.
Change-Id: If994db22d91eb3707e555871d854c3a25a13678b
Signed-off-by: Nico Huber <nico.h@gmx.de>
Reviewed-on: https://review.coreboot.org/21206
Reviewed-by: Adrian-Ken Rueegsegger <ken@codelabs.ch>
Reviewed-by: Arthur Heymans <arthur@aheymans.xyz>
Prefer Z3 over CVC4, the latter seems to not do anything for the current
code and just wastes CPU cycles.
Change-Id: Ia5e1341e881c5f887452486a318e8e72513f28fb
Signed-off-by: Nico Huber <nico.h@gmx.de>
Reviewed-on: https://review.coreboot.org/20627
Reviewed-by: Paul Menzel <paulepanter@users.sourceforge.net>
Reviewed-by: Adrian-Ken Rueegsegger <ken@codelabs.ch>
Let Initialize() always initialize the Address_State. This is not only
the expected behaviour but also necessary to share the contract with
other implementations.
Change-Id: I0454dfd6c36f7d4298edeec5b84d929e3160eb7b
Signed-off-by: Nico Huber <nico.h@gmx.de>
Reviewed-on: https://review.coreboot.org/21205
Reviewed-by: Adrian-Ken Rueegsegger <ken@codelabs.ch>
In Linux' sysfs, each PCI device has a directory like:
/sys/devices/pci0000:00/0000:00:02.0/
Therein, the file `config` represents the PCI device's configuration
space. Alas, it's not mappable so we work on a read only copy. Should
we ever need dynamic read/write access, we'd have to implement it
using read()/write().
IO and MMIO resources are represented by mappable files, `resource[0-5]`
for uncacheable accesses and `resource[0-5]_wc` for write-combining
access.
Change-Id: I1358e9336edaf75e8eff50808a8169b997817d7e
Signed-off-by: Nico Huber <nico.h@gmx.de>
Reviewed-on: https://review.coreboot.org/20554
Reviewed-by: Arthur Heymans <arthur@aheymans.xyz>
Add a HW.PCI.Dev implementation that assumes direct hardware access,
i.e. its Map() implementations just returns the physical address of
a resource.
Change-Id: I055a05a17e207e8b43aa02d1b39023b027f94f6c
Signed-off-by: Nico Huber <nico.h@gmx.de>
Reviewed-on: https://review.coreboot.org/20551
Reviewed-by: Arthur Heymans <arthur@aheymans.xyz>
The GNAT configuration file `debug.adc` has Assertion_Policy Debug
enabled to compile `pragma Debug` code. If `DEBUG` is set to `1`
during build, `debug.adc` is used instead of the default `gnat.adc`.
Change-Id: If5b52f5251cae7deed7aca2765f9b5db1c148fb7
Signed-off-by: Nico Huber <nico.h@gmx.de>
Reviewed-on: https://review.coreboot.org/20558
Reviewed-by: Arthur Heymans <arthur@aheymans.xyz>
Give Map() an `Offset` parameter that will be passed to mmap(). Make the
`Len` parameter of Map() optional. If it's left at the default, `0`, map
until the end of the file (up to SIZE_MAX bytes).
Change-Id: I7b062ce1e9cddab87a66a2aedc8b64e4e8524d9f
Signed-off-by: Nico Huber <nico.h@gmx.de>
Reviewed-on: https://review.coreboot.org/20553
Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
Reverse the direction of the `Addr` parameter of Map(). We let mmap()
decide which address to use and return that. Given that we can set the
address for `MMIO_Range` instances during runtime, we shouldn't ever
have to force static addresses.
Change-Id: I35bfd65e7b471daae4f43a9233ce613c7f45891e
Signed-off-by: Nico Huber <nico.h@gmx.de>
Reviewed-on: https://review.coreboot.org/20552
Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
Add generic PCI packages:
o HW.PCI containing basic definitions for PCI devices and
configuration space headers,
o HW.PCI.MMConf that provides access to memory mapped confi-
guration space of a PCI device, and
o HW.PCI.Dev adding a method to map resources of a PCI device.
Change-Id: I266ea35e273ff49fdb3176d617bb0b4ab1f13f93
Signed-off-by: Nico Huber <nico.h@gmx.de>
Reviewed-on: https://review.coreboot.org/20258
Reviewed-by: Arthur Heymans <arthur@aheymans.xyz>
This was only set to get more obvious error messages (i.e. restriction
violations instead of missing packages in the runtime environment).
However, it doesn't play well with the standard interfaces for console
applications. So remove the restriction to allow usage of the secondary
stack where possible.
Change-Id: Iceb64fe2b6f304e2e88b18cf3435fdbfda57440d
Signed-off-by: Nico Huber <nico.h@gmx.de>
Reviewed-on: https://review.coreboot.org/18784
Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
The code generated by the binder (gnatbind) isn't always compilable
with the restrictions in our gnat configuration file `gnat.adc`. This
is in accordance with how `gnatlink` would do the job.
Change-Id: I59ea4a68749cabfb6cccdda1db4c23c6c0d5be60
Signed-off-by: Nico Huber <nico.h@gmx.de>
Reviewed-on: https://review.coreboot.org/18782
Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
Since Ada supports different names for the Main() procedure, we have to
specify the main source file explicitly. Also, the binder (gnatbind)
insists on searching the required object files himself, so we only spe-
cify the object file of the main procedure.
Change-Id: I7227b845e38963e5434a4db0068d373fc4b7ee99
Signed-off-by: Nico Huber <nico.h@gmx.de>
Reviewed-on: https://review.coreboot.org/18781
Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
The `-gnatg` flag (internal GNAT implementation mode) was accidentally
copied over from the flags we use to build libgnat.
Change-Id: I2e9c6d1d5b68168d1608187aad2eae5aead759f9
Signed-off-by: Nico Huber <nico.h@gmx.de>
Reviewed-on: https://review.coreboot.org/18780
Reviewed-by: Patrick Georgi <pgeorgi@google.com>
Add a package HW.File with a single procedure Map():
procedure Map
(Path : in String;
Addr : in Word64;
Len : in Natural;
Readable : in Boolean := False;
Writable : in Boolean := False;
Map_Copy : in Boolean := False;
Success : out Boolean)
with
Pre => (Readable or Writable) and
(if Map_Copy then Readable and not Writable);
If `Map_Copy` is `False`, it should map `Len` bytes from the start of
the file given by `Path` into the application's address space at `Addr`
using mmap(). If `Map_Copy` is `True`, anonymous memory should be map-
ped instead and be filled with a copy of the file's content using
read().
The current implementation is backed by C code to reduce dependencies
to external libraries (e.g. Florist is not packaged by a famous Linux
distro).
While we are at it, also add a configuration file for common POSIX
environments (configs/posix).
Change-Id: Ic10c35b35d3216dab6a5b2baba7ba619c885b346
Signed-off-by: Nico Huber <nico.h@gmx.de>
Reviewed-on: https://review.coreboot.org/18779
Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
We only use C as an interface (e.g. to POSIX). Thus, we keep the rules
simple and don't do any dependency tracking.
Change-Id: I62b4b4e4d3ae83d5e1f1811f783b559b225746e6
Signed-off-by: Nico Huber <nico.h@gmx.de>
Reviewed-on: https://review.coreboot.org/18778
Reviewed-by: Philippe Mathieu-Daudé <philippe.mathieu.daude@gmail.com>
Reviewed-by: Patrick Georgi <pgeorgi@google.com>
The access variable `Range_A` was accidentally declared `Volatile` which
led to the following complaint by GCC 7.1:
volatile object cannot appear in this context (SPARK RM 7.1.3(11))
This happened probably to make `Range_A` compatible with our state
abstraction, but we can just use the correct abstraction instead.
TEST=Compiled a coreboot target with libgfxinit and checked the
emitted assembly: Only minor reordering regarding the pointer
but not the dereference.
Booted ThinkPad T420 with libgfxinit enabled.
Change-Id: I56a3fcadce59713fb03a089d192d2022bfb1d378
Signed-off-by: Nico Huber <nico.huber@secunet.com>
Reviewed-on: https://review.coreboot.org/19624
Tested-by: Nico Huber <nico.h@gmx.de>
Reviewed-by: Patrick Georgi <pgeorgi@google.com>
Reviewed-by: Philippe Mathieu-Daudé <philippe.mathieu.daude@gmail.com>
This is a very low precision clock. We just take the start of the cur-
rent scheduling minor frame as the minimum, yet elapsed moment and the
end of the frame as the maximum, yet reached moment in time. As a
result, every timer based delay will wait at least for the next minor
frame.
For the build, `musinfo.ads` and `muschedinfo.ads` from the Muen
project are required. One should point the `muen-common-path` variable
to the `common` subdir of the Muen source distribution.
Change-Id: Ib139749214bf8d2ca293e31327b156de5198b65d
Signed-off-by: Nico Huber <nico.huber@secunet.com>
Reviewed-on: https://review.coreboot.org/18357
Tested-by: Nico Huber <nico.h@gmx.de>
Reviewed-by: Adrian-Ken Rueegsegger <ken@codelabs.ch>
Change-Id: I465416dd8e4f92f9700253fc031a3933bba93f38
Signed-off-by: Nico Huber <nico.huber@secunet.com>
Reviewed-on: https://review.coreboot.org/16962
Reviewed-by: Paul Menzel <paulepanter@users.sourceforge.net>
Reviewed-by: Patrick Georgi <pgeorgi@google.com>
Tested-by: Patrick Georgi <pgeorgi@google.com>