tcp_protocol.aadl 4.08 KB
Newer Older
1
2
3
4
5
6
7
package TCP_IP_Protocol

-- This package models a TCP/IP based protocol layer for the
-- PolyORB-HI/Ada AADL runtime. It defines the subprograms and threads
-- to be integrated with the runtime low level interface.
--
-- To configure this interface, you should use the
8
-- Deployment::Configuration property with the following format:
9
10
11
12
13
14
15
16
17
--     "ip <ipv4_addresse> <ipv4_port>"
--
-- e.g.
--
--     netif : device TCP_IP_Protocol::TCP_IP_Device
--            {Deployment::Configuration => "ip 192.168.0.10 45678";}:

public

18
   with Generic_Bus;
jhugues's avatar
jhugues committed
19
   with Deployment;
20
21
22
23
24
25
26
27
28
29
30

   ------------
   -- DEVICE --
   ------------

   -- The main entrypoint for this package is this device, it relies
   -- on the 'Implement_As' feature that defines its full
   -- specification.

   device TCP_IP_Device
   features
31
32
      Ethernet_Wire : requires bus access Generic_Bus::Generic_Bus.impl;
      -- Connection to the remote node
33
34
35
36
37

   end TCP_IP_Device;

   device implementation TCP_IP_Device.impl
   properties
38
      Implemented_As =>
39
40
41
42
43
44
45
46
47
48
49
50
         classifier (TCP_IP_Protocol::Driver_TCP_IP_Protocol.impl);
      Initialize_Entrypoint => classifier (TCP_IP_Protocol::Initialize);
   end TCP_IP_Device.impl;

   ------------
   -- DRIVER --
   ------------

   -- In AADLv2, we can model the actual implementation of a driver
   -- using an abstract component.

   abstract Driver_TCP_IP_Protocol
51
52
53
54
   properties
      Deployment::Configuration_Type => classifier (ocarina_drivers::configuration_type_ip);
      Deployment::Version  => "0.1beta";
      Deployment::Help     => "Write your ASN.1 configuration here";
55
56
57
58
59
   end Driver_TCP_IP_Protocol;

   abstract implementation Driver_TCP_IP_Protocol.impl
   subcomponents
      receiver : thread Driver_TCP_IP_Protocol_thread_receiver.impl;
60
      sender : subprogram Send;
61
62
63
64
65
66
67
68
69
70
71
   end Driver_TCP_IP_Protocol.impl;

   -------------
   -- THREADS --
   -------------

   -- This thread handles the execution logic of the protocol
   -- stack. It relies on the previous subprograms to receive
   -- messages.

   thread Driver_TCP_IP_Protocol_thread_receiver
72

73
74
75
76
77
      -- This thread is dispatched when an event is detected on the
      -- real hardware. It then calls receive to handle the incoming
      -- event.

   properties
78
      -- Initialize_Entrypoint
79
80
81
82
83
      --    => classifier (TCP_IP_Protocol::Initialize_Receiver);
      Dispatch_Protocol => Background;
   end Driver_TCP_IP_Protocol_thread_receiver;

   thread implementation Driver_TCP_IP_Protocol_thread_receiver.impl
84
   calls
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
      call1 : { pspg : subprogram receive; };
   end Driver_TCP_IP_Protocol_thread_receiver.impl;

   -----------------
   -- SUBPROGRAMS --
   -----------------

   -- These subprograms model the high-level view of the TCP/IP
   -- protocol stack. They define an API used by the stack to send and
   -- receive data, and perform node's initialisation.

   subprogram Initialize

     -- Initialize the different internal resources for managing
     -- connections on a node. This subprogram has no formal visible
     -- parameters, but relies on well-known data structures and
     -- variables to configure the stack.

   properties
      Source_Name => "POlyORB_HI_Drivers_Native_TCP_IP.Initialize";
105
      Source_Language => (Ada);
106
107
108
109
110
111
112
113
114
115
   end Initialize;

   -------------

   subprogram Initialize_Receiver

     -- Initialize the receiver thread

   properties
      Source_Name => "POlyORB_HI_Drivers_Native_TCP_IP.Initialize_Receiver";
116
      Source_Language => (Ada);
117
118
119
120
121
122
123
124
125
126
127
128
   end Initialize_Receiver;

   -------------

   subprogram Receive

      -- Receive data and dispatch them to the receiving entity. This
      -- program and its sibling (send) share a common protocol, not
      -- defined in the AADL model.

   properties
      Source_Name => "POlyORB_HI_Drivers_Native_TCP_IP.Receive";
129
      Source_Language => (Ada);
130
131
132
133
134
135
136
137
138
139
140
141
   end Receive;

   -------------

   subprogram Send

      -- Send data to a remote node. This program and its sibling
      -- (receive) share a common protocol, not defined in the AADL
      -- model.

   properties
      Source_Name => "POlyORB_HI_Drivers_Native_TCP_IP.Send";
142
      Source_Language => (Ada);
143
144
145
   end Send;

end TCP_IP_Protocol;