blob: c0a7e3ddb444df6493961fabcc24ff1c6722cdb0 [file] [log] [blame]
Thomas Heijligen62268ee2023-11-27 15:10:41 +00001with Interfaces;
2
Nico Huber98417fc2023-11-30 16:46:25 +01003use Interfaces;
4
Thomas Heijligen5c43abc2023-12-11 15:24:36 +00005package FILO is
Thomas Heijligend1e04572023-11-27 14:28:55 +00006
Nico Huber481ff842023-12-12 13:19:49 +01007 type Partition_Length is range 0 .. Interfaces.Unsigned_64'Last;
8 subtype Partition_Offset is Partition_Length range 0 .. Partition_Length'Last - 1;
9
10 BLOCK_SIZE : constant := 512;
11 type Block_Offset is range 0 .. Partition_Offset'Last / BLOCK_SIZE;
12
Nico Huber98417fc2023-11-30 16:46:25 +010013 subtype Index_Type is Natural range 0 .. Natural'Last - 1;
14 subtype Index_Type16 is Index_Type range 0 .. Index_Type'Last - 1;
15 subtype Index_Type32 is Index_Type16 range 0 .. Index_Type16'Last - 2;
16
17 type Buffer_Type is array (Index_Type range <>) of Unsigned_8;
18
19 function Read_LE16 (Buf : Buffer_Type; Off : Index_Type16) return Unsigned_16
20 is
Nico Hubercd6b7ec2023-12-04 15:21:26 +010021 (Shift_Left (Unsigned_16 (Buf (Off + 1)), 8) or Unsigned_16 (Buf (Off)))
22 with
23 Pre => Buf'First <= Off and Off + 1 <= Buf'Last;
Nico Huber98417fc2023-11-30 16:46:25 +010024
25 function Read_LE32 (Buf : Buffer_Type; Off : Index_Type32) return Unsigned_32
26 is
27 (Shift_Left (Unsigned_32 (Buf (Off + 3)), 24) or
28 Shift_Left (Unsigned_32 (Buf (Off + 2)), 16) or
29 Shift_Left (Unsigned_32 (Buf (Off + 1)), 8) or
Nico Hubercd6b7ec2023-12-04 15:21:26 +010030 Unsigned_32 (Buf (Off)))
31 with
32 Pre => Buf'First <= Off and Off + 3 <= Buf'Last;
Thomas Heijligend1e04572023-11-27 14:28:55 +000033
Thomas Heijligen5c43abc2023-12-11 15:24:36 +000034end FILO;