blob: e8adfc29b7e037ca75b1b89a6de3f7699855aafc [file] [log] [blame]
Nico Huber5e9b1b52016-10-08 22:09:33 +02001--
2-- Copyright (C) 2015 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; version 2 of the License.
7--
8-- This program is distributed in the hope that it will be useful,
9-- but WITHOUT ANY WARRANTY; without even the implied warranty of
10-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11-- GNU General Public License for more details.
12--
13
14with System;
15with System.Machine_Code;
16
17package body HW.Port_IO
18with
19 Refined_State => (State => null),
20 SPARK_Mode => Off
21is
22
23 generic
24 type Word is private;
25 procedure Port_In (Value : out Word; Port : Port_Type);
26
27 procedure Port_In (Value : out Word; Port : Port_Type) is
28 begin
29 System.Machine_Code.Asm
30 ("in %1, %0",
31 Inputs => (Port_Type'Asm_Input ("Nd", Port)),
32 Outputs => (Word'Asm_Output ("=a", Value)),
33 Volatile => True);
34 end Port_In;
35
36 procedure InB_Body is new Port_In (Word => Word8);
37 procedure InB (Value : out Word8; Port : Port_Type) renames InB_Body;
38
39 procedure InW_Body is new Port_In (Word => Word16);
40 procedure InW (Value : out Word16; Port : Port_Type) renames InW_Body;
41
42 procedure InL_Body is new Port_In (Word => Word32);
43 procedure InL (Value : out Word32; Port : Port_Type) renames InL_Body;
44
45 ----------------------------------------------------------------------------
46
47 generic
48 type Word is private;
49 procedure Port_Out (Port : Port_Type; Value : Word);
50
51 procedure Port_Out (Port : Port_Type; Value : Word) is
52 begin
53 System.Machine_Code.Asm
54 ("out %1, %0",
55 Inputs => (Port_Type'Asm_Input ("Nd", Port),
56 Word'Asm_Input ("a", Value)),
57 Volatile => True);
58 end Port_Out;
59
60 procedure OutB_Body is new Port_Out (Word => Word8);
61 procedure OutB (Port : Port_Type; Value : Word8) renames OutB_Body;
62
63 procedure OutW_Body is new Port_Out (Word => Word16);
64 procedure OutW (Port : Port_Type; Value : Word16) renames OutW_Body;
65
66 procedure OutL_Body is new Port_Out (Word => Word32);
67 procedure OutL (Port : Port_Type; Value : Word32) renames OutL_Body;
68
69end HW.Port_IO;
70
71-- vim: set ts=8 sts=3 sw=3 et: