posix file: Add an `Offset` parameter and make `Len` optional
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>
diff --git a/common/hw-file.ads b/common/hw-file.ads
index 57cf429..9dbfcf7 100644
--- a/common/hw-file.ads
+++ b/common/hw-file.ads
@@ -17,17 +17,20 @@
--
-- Map a file's content into our address space
--
- -- If `Map_Copy` is `False`, `Len` bytes from the start of the file
- -- given by `Path` shall be mapped into the application's address
- -- space using mmap().
+ -- If `Map_Copy` is `False`, `Len` bytes at `Offset` from the start
+ -- of the file given by `Path` should be mapped into the application's
+ -- address space using mmap().
--
-- If `Map_Copy` is `True`, anonymous memory should be mapped instead
-- and be filled with a copy of the file's content using read().
--
+ -- If `Len` is zero, the whole file should be mapped.
+ --
procedure Map
(Addr : out Word64;
Path : in String;
- Len : in Natural;
+ Len : in Natural := 0;
+ Offset : in Natural := 0;
Readable : in Boolean := False;
Writable : in Boolean := False;
Map_Copy : in Boolean := False;