blob: ba7bc6d484078e3eaff7fd5d4a76f980dd8d9577 [file] [log] [blame]
Thomas Heijligen5c43abc2023-12-11 15:24:36 +00001package body FILO.Blockdev is
Thomas Heijligend1e04572023-11-27 14:28:55 +00002
3 procedure Read
Thomas Heijligen62268ee2023-11-27 15:10:41 +00004 (Buffer : in out Buffer_Type;
Nico Huber9c041872023-12-12 13:24:55 +01005 Offset : in Blockdev_Offset;
Thomas Heijligen62268ee2023-11-27 15:10:41 +00006 Success : out Boolean)
Thomas Heijligend1e04572023-11-27 14:28:55 +00007 is
Thomas Heijligena968f6f2023-12-11 09:40:06 +00008 use Interfaces.C;
9
10 Sector : constant unsigned_long := unsigned_long (Offset) / 512;
11 Byte_Offset : constant unsigned_long := unsigned_long (Offset) rem 512;
12 Byte_Len : constant unsigned_long := unsigned_long (Buffer'Length);
13 Buf : constant System.Address := Buffer'Address;
14
15 -- NOTE: C_devread returns 1 on success
16 function To_Success (Item : Interfaces.C.int) return Boolean is
17 (if Item = 1 then True else False);
18
Thomas Heijligend1e04572023-11-27 14:28:55 +000019 begin
Thomas Heijligena968f6f2023-12-11 09:40:06 +000020 Success := To_Success (C_devread (Sector, Byte_Offset, Byte_Len, Buf));
Thomas Heijligend1e04572023-11-27 14:28:55 +000021 end Read;
22
Thomas Heijligen5c43abc2023-12-11 15:24:36 +000023end FILO.Blockdev;