Thomas Heijligen | 5c43abc | 2023-12-11 15:24:36 +0000 | [diff] [blame] | 1 | package body FILO.Blockdev is |
Thomas Heijligen | d1e0457 | 2023-11-27 14:28:55 +0000 | [diff] [blame] | 2 | |
| 3 | procedure Read |
Thomas Heijligen | 62268ee | 2023-11-27 15:10:41 +0000 | [diff] [blame] | 4 | (Buffer : in out Buffer_Type; |
Nico Huber | 9c04187 | 2023-12-12 13:24:55 +0100 | [diff] [blame^] | 5 | Offset : in Blockdev_Offset; |
Thomas Heijligen | 62268ee | 2023-11-27 15:10:41 +0000 | [diff] [blame] | 6 | Success : out Boolean) |
Thomas Heijligen | d1e0457 | 2023-11-27 14:28:55 +0000 | [diff] [blame] | 7 | is |
Thomas Heijligen | a968f6f | 2023-12-11 09:40:06 +0000 | [diff] [blame] | 8 | 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 Heijligen | d1e0457 | 2023-11-27 14:28:55 +0000 | [diff] [blame] | 19 | begin |
Thomas Heijligen | a968f6f | 2023-12-11 09:40:06 +0000 | [diff] [blame] | 20 | Success := To_Success (C_devread (Sector, Byte_Offset, Byte_Len, Buf)); |
Thomas Heijligen | d1e0457 | 2023-11-27 14:28:55 +0000 | [diff] [blame] | 21 | end Read; |
| 22 | |
Thomas Heijligen | 5c43abc | 2023-12-11 15:24:36 +0000 | [diff] [blame] | 23 | end FILO.Blockdev; |