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/ada/posix/hw-file.adb b/ada/posix/hw-file.adb
index d9b15ba..e2384be 100644
--- a/ada/posix/hw-file.adb
+++ b/ada/posix/hw-file.adb
@@ -29,6 +29,7 @@
(addr : out Word64;
path : chars_ptr;
len : Word32;
+ off : Word32;
mode : Word32;
copy : int)
return int;
@@ -37,7 +38,8 @@
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;
@@ -50,6 +52,7 @@
(addr => Addr,
path => cpath,
len => Word32 (Len),
+ off => Word32 (Offset),
mode => (if Readable then READ else 0) or
(if Writable then WRITE else 0),
copy => (if Map_Copy then 1 else 0));