raw
cryostat_genesis.kv     1 ------------------------------------------------------------------------------
cryostat_genesis.kv 2 ------------------------------------------------------------------------------
cryostat_genesis.kv 3 -- This file is part of 'Cryostat', an Ada library for persistent storage. --
cryostat_genesis.kv 4 -- --
cryostat_genesis.kv 5 -- (C) 2020 Stanislav Datskovskiy ( www.loper-os.org ) --
cryostat_genesis.kv 6 -- http://wot.deedbot.org/17215D118B7239507FAFED98B98228A001ABFFC7.html --
cryostat_genesis.kv 7 -- --
cryostat_genesis.kv 8 -- You do not have, nor can you ever acquire the right to use, copy or --
cryostat_genesis.kv 9 -- distribute this software ; Should you use this software for any purpose, --
cryostat_genesis.kv 10 -- or copy and distribute it to anyone or in any manner, you are breaking --
cryostat_genesis.kv 11 -- the laws of whatever soi-disant jurisdiction, and you promise to --
cryostat_genesis.kv 12 -- continue doing so for the indefinite future. In any case, please --
cryostat_genesis.kv 13 -- always : read and understand any software ; verify any PGP signatures --
cryostat_genesis.kv 14 -- that you use - for any purpose. --
cryostat_genesis.kv 15 ------------------------------------------------------------------------------
cryostat_genesis.kv 16 ------------------------------------------------------------------------------
cryostat_genesis.kv 17
cryostat_genesis.kv 18 with System;
cryostat_genesis.kv 19 with Ada.Finalization;
cryostat_genesis.kv 20 with Unix; use Unix;
cryostat_genesis.kv 21
cryostat_genesis.kv 22
cryostat_genesis.kv 23 package PMaps is
cryostat_genesis.kv 24
cryostat_genesis.kv 25 pragma Preelaborate;
cryostat_genesis.kv 26
cryostat_genesis.kv 27 -- Open file for map
cryostat_genesis.kv 28 function OpenMapFile(Path : in String;
cryostat_genesis.kv 29 Writable : in Boolean := False;
cryostat_genesis.kv 30 Create : in Boolean := False)
cryostat_genesis.kv 31 return FD
cryostat_genesis.kv 32 with Pre => not ((not Writable) and Create);
cryostat_genesis.kv 33
cryostat_genesis.kv 34 -- The address in memory where the map resides
cryostat_genesis.kv 35 subtype MapAddress is System.Address;
cryostat_genesis.kv 36
cryostat_genesis.kv 37 -- Internal representation of the map
cryostat_genesis.kv 38 type PMap(Handle : FD; -- Unix FD handle of the open file
cryostat_genesis.kv 39 Length : Word; -- The length (bytes) of the map
cryostat_genesis.kv 40 Offset : Word; -- Offset into the file (normally zero)
cryostat_genesis.kv 41 Create : Boolean; -- Whether to create the file if not exists
cryostat_genesis.kv 42 Writable : Boolean) -- Whether the map is writeable
cryostat_genesis.kv 43 is new Ada.Finalization.Limited_Controlled with private;
cryostat_genesis.kv 44
cryostat_genesis.kv 45 -- Test if map is usable
cryostat_genesis.kv 46 function IsReady(Map : in PMap) return Boolean;
cryostat_genesis.kv 47
cryostat_genesis.kv 48 -- Zero the entire map space
cryostat_genesis.kv 49 procedure Zap(Map : in out PMap);
cryostat_genesis.kv 50
cryostat_genesis.kv 51 -- Sync map to disk immediately
cryostat_genesis.kv 52 procedure Sync(Map : in out PMap);
cryostat_genesis.kv 53
cryostat_genesis.kv 54 -- Close map and mark it unusable
cryostat_genesis.kv 55 procedure Stop(Map : in out PMap);
cryostat_genesis.kv 56
cryostat_genesis.kv 57 -- Retrieve the address at which map resides
cryostat_genesis.kv 58 function GetAddress(Map : in PMap) return MapAddress;
cryostat_genesis.kv 59
cryostat_genesis.kv 60 -- Eggogs
cryostat_genesis.kv 61 PMapFailedOpen : exception; -- Could not open the given file
cryostat_genesis.kv 62 PMapFailedMMap : exception; -- Eggog when performed MMap()
cryostat_genesis.kv 63 PMapFailedAddr : exception; -- MMap() returned an unusable address
cryostat_genesis.kv 64 PMapFailedSync : exception; -- Sync failed
cryostat_genesis.kv 65 PMapFailedUnmap : exception; -- Unmap failed
cryostat_genesis.kv 66 PMapFailedClose : exception; -- Closing backing file failed
cryostat_genesis.kv 67 PMapNotRunning : exception; -- Tried to use an inactive map
cryostat_genesis.kv 68 PMapNotWritable : exception; -- Tried to zap a read-only map
cryostat_genesis.kv 69
cryostat_genesis.kv 70 private
cryostat_genesis.kv 71
cryostat_genesis.kv 72 -- Current state of the map
cryostat_genesis.kv 73 type State is (Stop, Run, Eggog);
cryostat_genesis.kv 74
cryostat_genesis.kv 75 type PMap(Handle : FD;
cryostat_genesis.kv 76 Length : Word;
cryostat_genesis.kv 77 Offset : Word;
cryostat_genesis.kv 78 Create : Boolean;
cryostat_genesis.kv 79 Writable : Boolean) is
cryostat_genesis.kv 80 new Ada.Finalization.Limited_Controlled with
cryostat_genesis.kv 81 record
cryostat_genesis.kv 82 -- Unix FD handle of the open file
cryostat_genesis.kv 83 FileFD : FD := Handle;
cryostat_genesis.kv 84
cryostat_genesis.kv 85 -- Whether to create the file if not exists
cryostat_genesis.kv 86 MapCreate : Boolean := Create;
cryostat_genesis.kv 87
cryostat_genesis.kv 88 -- Whether the map is writeable
cryostat_genesis.kv 89 MapWritable : Boolean := Writable;
cryostat_genesis.kv 90
cryostat_genesis.kv 91 -- The length (bytes) of the map
cryostat_genesis.kv 92 MapLength : Word := Length;
cryostat_genesis.kv 93
cryostat_genesis.kv 94 -- Offset into the file (normally zero)
cryostat_genesis.kv 95 MapOffset : Word := Offset;
cryostat_genesis.kv 96
cryostat_genesis.kv 97 -- The address in memory where the map resides
cryostat_genesis.kv 98 Address : MapAddress := NullPtr;
cryostat_genesis.kv 99
cryostat_genesis.kv 100 -- Current condition of this map
cryostat_genesis.kv 101 Status : State := Stop;
cryostat_genesis.kv 102 end record;
cryostat_genesis.kv 103
cryostat_genesis.kv 104 -- Initialization
cryostat_genesis.kv 105 overriding procedure Initialize(Map : in out PMap);
cryostat_genesis.kv 106
cryostat_genesis.kv 107 -- Automatic sync and close of the map when leaving scope
cryostat_genesis.kv 108 overriding procedure Finalize(Map : in out PMap);
cryostat_genesis.kv 109
cryostat_genesis.kv 110 end PMaps;