ada binding

This commit is contained in:
Guillaume Cluzel
2020-04-06 09:47:15 +02:00
parent ade629ecdc
commit 7285dcbf99
7 changed files with 122 additions and 176 deletions

15
http_cyclone.gpr Normal file
View File

@@ -0,0 +1,15 @@
with "Ada_Drivers_Library/boards/stm32f769_discovery/stm32f769_discovery_sfp.gpr";
project HTTP_Cyclone extends "Ada_Drivers_Library/examples/shared/common/common.gpr" is
for Runtime ("Ada") use STM32F769_Discovery_sfp'Runtime("Ada");
for Target use "arm-eabi";
for Object_Dir use "obj";
for Create_Missing_Dirs use "True";
for Source_Dirs use ("src/**");
package Compiler renames STM32F769_Discovery_SFP.Compiler;
end HTTP_Cyclone;

View File

@@ -1,165 +0,0 @@
with Interfaces.C; use Interfaces.C;
with Net; use Net;
with Compiler_Port; use Compiler_Port;
with Tcp; use Tcp;
with Error_H; use Error_H;
with Systeme;
package Socket_Binding is
MAX_BYTES : constant := 128
type Sock_Descriptor is new unsigned;
type Sock_Type is new unsigned;
type Sock_Protocol is new unsigned;
type Sock_Port is new unsigned_short;
type SackBlockArray is array (0 .. 3) of Tcp_Sack_Block;
type uint8 is mod 2 ** 8;
subtype Index is unsigned range 0 .. MAX_BYTES;
type Block8 is array (Index range <>) of uint8;
type OsEvent is
record
handle: access TcpQueueItem;
end record
with Convention => C;
-- type Socket is
-- record
-- S_Descriptor: Sock_Descriptor;
-- S_Type: Sock_Type;
-- S_Protocol: Sock_Protocol;
-- S_NetInterface: access Net_Interface;
-- S_localIpAddr: IpAddr;
-- S_Local_Port: Sock_Port;
-- S_remoteIpAddr: IpAddr;
-- S_Remote_Port: Sock_Port;
-- S_Timeout: Compiler_Port.Systime;
-- S_TTL: unsigned_char;
-- S_Multicast_TTL: unsigned_char;
-- S_errnoCode: int;
-- S_event: OsEvent;
-- S_Event_Mask: unsigned;
-- S_Event_Flags: unsigned;
-- userEvent: access OsEvent;
-- -- TCP specific variables
-- State: Tcp_State;
-- owned_Flag: Bool;
-- closed_Flag: Bool;
-- reset_Flag: Bool;
-- smss: unsigned_short;
-- rmss: unsigned_short;
-- iss: unsigned_long;
-- irs: unsigned_long;
-- sndUna: unsigned_long;
-- sndNxt: unsigned_long;
-- sndUser: unsigned_short;
-- sndWnd: unsigned_short;
-- maxSndWnd: unsigned_short;
-- sndWl1: unsigned_long;
-- sndWl2: unsigned_long;
-- rcvNxt: unsigned_long;
-- rcvUser: unsigned_short;
-- rcvWnd: unsigned_short;
-- rttBusy: Bool;
-- rttSeqNum: unsigned_long;
-- rettStartTime: Systime;
-- srtt: Systime;
-- rttvar: Systime;
-- rto: Systime;
-- congestState: TCP_Congest_State;
-- cwnd: unsigned_short;
-- ssthresh: unsigned_short;
-- dupAckCount: unsigned;
-- n: unsigned;
-- recover: unsigned_long;
-- txBuffer: Tcp_Tx_Buffer;
-- txBufferSize: unsigned_long;
-- rxBuffer: Tcp_Rx_Buffer;
-- rxBufferSize: unsigned_long;
-- retransmitQueue: access TcpQueueItem;
-- retransmitTimer: Tcp_Timer;
-- retransmitCount: unsigned;
-- -- TODO: Not good type. Just used to denote a pointer
-- synQueue: access TcpQueueItem;
-- synQueueSize: unsigned;
-- wndProbeCount: unsigned;
-- wndProbeInterval: Systime;
-- persistTimer: Tcp_Timer;
-- overrideTimer: Tcp_Timer;
-- finWait2Timer: Tcp_Timer;
-- timeWaitTimer: Tcp_Timer;
-- sackPermitted: Bool;
-- sackBlock: SackBlockArray;
-- sackBlockCount: unsigned;
-- -- TODO: should be socketQueueItem here
-- receiveQueue: access TcpQueueItem;
-- end record
-- with Convention => C;
type Socket is new Systeme.Address;
type IpAddr is new Systeme.Address;
function socketOpen (S_Type: Sock_Type; protocol: Sock_Protocol) return Socket
with
Import => True,
Convention => C,
External_Name => "socketOpen";
function socketSetTimeout (sock: Socket; timeout: Systime) return Error_T
with
Import => True,
Convention => C,
External_Name => "socketSetTimeout";
function socketConnect (sock: Socket; remoteIpAddr: IpAddr; remotePort: Sock_Port)
return Error_T
with
Import => True,
Convention => C,
External_Name => "socketConnect";
function socketSend (sock: Socket; data: Block8; length: unsigned; written: out unsigned; flags: unsigned)
return Error_T
with
Import => True,
Convention => C,
External_Name => "socketSend";
function socketReceive(sock: Socket; data: out Block8; size: unsigned; received: out unsigned; flags: unsigned)
return Error_T
with
Import => True,
Convention => C,
External_Name => "socketReceive";
function socketShutdown (sock: Socket; how: unsigned)
return Error_T
with
Import => True,
Convention => C,
External_Name => "socketShutdown";
procedure socketClose (sock: Socket)
with
Import => True,
Convention => C,
External_Name => "socketClose";
end Socket_Binding;

View File

@@ -0,0 +1,61 @@
------------------------------------------------------------------------------
-- --
-- Copyright (C) 2015-2016, AdaCore --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions are --
-- met: --
-- 1. Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- 2. Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in --
-- the documentation and/or other materials provided with the --
-- distribution. --
-- 3. Neither the name of the copyright holder nor the names of its --
-- contributors may be used to endorse or promote products derived --
-- from this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT --
-- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, --
-- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY --
-- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT --
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE --
-- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
package body Last_Chance_Handler is
-------------------------
-- Last_Chance_Handler --
-------------------------
procedure Last_Chance_Handler (Msg : System.Address; Line : Integer) is
pragma Unreferenced (Msg, Line);
procedure Busy_loop;
---------------
-- Busy_loop --
---------------
procedure Busy_loop is
begin
for Cnt in 1 .. 10_000_000 loop
null;
end loop;
end Busy_loop;
begin
-- No-return procedure...
loop
null;
end loop;
end Last_Chance_Handler;
end Last_Chance_Handler;

View File

@@ -0,0 +1,42 @@
------------------------------------------------------------------------------
-- --
-- Copyright (C) 2015-2016, AdaCore --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions are --
-- met: --
-- 1. Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- 2. Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in --
-- the documentation and/or other materials provided with the --
-- distribution. --
-- 3. Neither the name of the copyright holder nor the names of its --
-- contributors may be used to endorse or promote products derived --
-- from this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT --
-- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, --
-- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY --
-- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT --
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE --
-- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- This version is for use with the ravenscar-sfp runtime.
with System;
package Last_Chance_Handler is
procedure Last_Chance_Handler (Msg : System.Address; Line : Integer);
pragma Export (C, Last_Chance_Handler, "__gnat_last_chance_handler");
pragma No_Return (Last_Chance_Handler);
end Last_Chance_Handler;

View File

@@ -1,7 +0,0 @@
with Interfaces.C; use Interfaces.C;
package os_Port_Freertos is
end os_Port_Freertos

View File

@@ -153,9 +153,7 @@ is
function Socket_Receive (
Sock: Socket_Struct;
Buf : out char_array)
return Integer
with
Pre => Buf'Length > 0;
return Integer;
procedure Socket_Shutdown (
Sock: Socket_Struct);

View File

@@ -81,6 +81,8 @@ SlaacSettings slaacSettings;
SlaacContext slaacContext;
FtpClientContext ftpClientContext;
extern void http_client_test(void);
/**
* @brief Set cursor location
@@ -360,7 +362,7 @@ void userTask(void *param)
//User button pressed?
if(BSP_PB_GetState(BUTTON_WAKEUP))
{
HttpClientTest("httpbin.org", "/anything");
http_client_test(); //"httpbin.org", "/anything");
//Wait for the user button to be released
while(BSP_PB_GetState(BUTTON_WAKEUP));