File : s-ioport-prep.adb
1 ------------------------------------------------------------------------------
2 -- --
3 -- GNAT RUN-TIME COMPONENTS --
4 -- --
5 -- S Y S T E M . I O P O R T S --
6 -- --
7 -- S p e c --
8 -- --
9 -- Copyright (C) 2010-2013, AdaCore --
10 -- --
11 -- GNAT is free software; you can redistribute it and/or modify it under --
12 -- terms of the GNU General Public License as published by the Free Soft- --
13 -- ware Foundation; either version 3, or (at your option) any later ver- --
14 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
15 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
16 -- or FITNESS FOR A PARTICULAR PURPOSE. --
17 -- --
18 -- --
19 -- --
20 -- --
21 -- --
22 -- You should have received a copy of the GNU General Public License and --
23 -- a copy of the GCC Runtime Library Exception along with this program; --
24 -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
25 -- <http://www.gnu.org/licenses/>. --
26 -- --
27 -- GNAT was originally developed by the GNAT team at New York University. --
28 -- Extensive contributions were provided by Ada Core Technologies Inc. --
29 -- --
30 ------------------------------------------------------------------------------
31
32 with Interfaces; use Interfaces;
33
34 package body System.IOPorts is
35
36 function Get_Port_Address (P : Port_Id) return Address;
37 pragma Inline (Get_Port_Address);
38 -- Get the address corresponding to a port id
39
40 ----------------------
41 -- Get_Port_Address --
42 ----------------------
43
44 function Get_Port_Address (P : Port_Id) return Address is
45 begin
46 return 16#8000_0000# + Port_Id'Pos (P);
47 end Get_Port_Address;
48
49 ---------
50 -- Inb --
51 ---------
52
53 function Inb (P : Port_Id) return Interfaces.Unsigned_8 is
54 Port_Byte : Unsigned_8;
55 pragma Atomic (Port_Byte);
56 for Port_Byte'Address use Get_Port_Address (P);
57 begin
58 return Port_Byte;
59 end Inb;
60
61 ----------
62 -- Outb --
63 ----------
64
65 procedure Outb (P : Port_Id; B : Unsigned_8) is
66 Port_Byte : Unsigned_8;
67 pragma Volatile (Port_Byte);
68 for Port_Byte'Address use Get_Port_Address (P);
69 begin
70 Port_Byte := B;
71 end Outb;
72
73 end System.IOPorts;