| Nico Huber | 312433c | 2019-09-28 03:15:48 +0200 | [diff] [blame] | 1 | -- |
| 2 | -- Copyright (C) 2016, 2019 secunet Security Networks AG |
| 3 | -- |
| 4 | -- This program is free software; you can redistribute it and/or modify |
| 5 | -- it under the terms of the GNU General Public License as published by |
| 6 | -- the Free Software Foundation; either version 2 of the License, or |
| 7 | -- (at your option) any later version. |
| 8 | -- |
| 9 | -- This program is distributed in the hope that it will be useful, |
| 10 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | -- GNU General Public License for more details. |
| 13 | -- |
| 14 | |
| 15 | with HW.GFX.GMA.Registers; |
| 16 | |
| 17 | private package HW.GFX.GMA.PCode is |
| 18 | |
| 19 | -- We have to ensure that previous usage of the mailbox finished |
| 20 | -- (Wait_Ready) or know that we already did so (Mailbox_Ready). |
| 21 | -- |
| 22 | -- If we wait for the other side to acknowledge (Wait_Ack), we |
| 23 | -- know that it's ready (=> Mailbox_Ready). |
| 24 | |
| 25 | -- XXX: Supposed to be a `Ghost` variable, but GNAT seems too broken? |
| 26 | Mailbox_Ready : Boolean with Part_Of => HW.GFX.GMA.State; |
| 27 | |
| 28 | -- Just send a command, discard the reply. |
| 29 | procedure Mailbox_Write |
| 30 | (MBox : in Word32; |
| 31 | Command : in Word64; |
| 32 | Wait_Ready : in Boolean := False; |
| 33 | Wait_Ack : in Boolean := True; |
| 34 | Success : out Boolean) |
| 35 | with |
| 36 | Pre => Mailbox_Ready or Wait_Ready, |
| 37 | Post => (if Wait_Ack and Success then Mailbox_Ready); |
| 38 | |
| 39 | -- Repeatedly send a request command the expected reply is received. |
| 40 | procedure Mailbox_Request |
| 41 | (MBox : in Word32; |
| 42 | Command : in Word64; |
| 43 | Reply_Mask : in Word64; |
| 44 | Reply : in Word64 := 16#ffff_ffff_ffff_ffff#; |
| 45 | TOut_MS : in Natural := Registers.Default_Timeout_MS; |
| 46 | Wait_Ready : in Boolean := False; |
| 47 | Success : out Boolean) |
| 48 | with |
| 49 | Pre => Mailbox_Ready or Wait_Ready, |
| 50 | Post => (if Success then Mailbox_Ready); |
| 51 | |
| 52 | -- For final mailbox commands that don't have to wait. |
| 53 | procedure Mailbox_Write |
| 54 | (MBox : Word32; |
| 55 | Command : Word64; |
| 56 | Wait_Ready : Boolean := False) |
| 57 | with |
| 58 | Pre => Mailbox_Ready or Wait_Ready; |
| 59 | |
| Tim Wawrzynczak | 79a5379 | 2022-09-09 10:24:35 -0600 | [diff] [blame^] | 60 | -- For reading data from PCode |
| 61 | procedure Mailbox_Read |
| 62 | (MBox : in Word32; |
| 63 | Command : in Word64 := 0; |
| 64 | Wait_Ready : in Boolean := False; |
| 65 | Reply : out Word64; |
| 66 | Success : out Boolean) |
| 67 | with |
| 68 | Pre => Mailbox_Ready or Wait_Ready, |
| 69 | Post => (if Success then Mailbox_Ready); |
| 70 | |
| Nico Huber | 312433c | 2019-09-28 03:15:48 +0200 | [diff] [blame] | 71 | end HW.GFX.GMA.PCode; |