mirror of
https://github.com/genodelabs/genode.git
synced 2025-04-07 19:34:56 +00:00
Support GNAT.IO in Ada programs
This commit is contained in:
parent
119a12cba5
commit
14cd115c82
16
repos/app-file.ads
Normal file
16
repos/app-file.ads
Normal file
@ -0,0 +1,16 @@
|
||||
pragma Ada_2012;
|
||||
|
||||
package App.File with Spark_Mode is
|
||||
|
||||
type Chunk_Number_Type is new Integer;
|
||||
type Chunk_Type is array (Positive range 1..4096) of Byte;
|
||||
|
||||
procedure Read(Offset : in Offset_Type;
|
||||
Destination : in out Chunk_Type;
|
||||
Size : in Size_Type)
|
||||
with
|
||||
import,
|
||||
convention => c,
|
||||
external_name => "c_genode_file_read";
|
||||
|
||||
end App.File;
|
40
repos/app-file_cache.adb
Normal file
40
repos/app-file_cache.adb
Normal file
@ -0,0 +1,40 @@
|
||||
pragma Ada_2012;
|
||||
|
||||
with App.File;
|
||||
|
||||
use type App.File.Chunk_Number_Type;
|
||||
|
||||
package body App.File_Cache with Spark_Mode is
|
||||
|
||||
procedure Read_Chunk(Object_Private : in out Object_Private_Type;
|
||||
Object_Public : in out Object_Public_Type;
|
||||
Chunk_Number : in File.Chunk_Number_Type;
|
||||
Chunk_In_Slot : out Boolean;
|
||||
Slot_Index : out Slot_Array_Index_Type)
|
||||
is
|
||||
-- Object_Public.Slot_Array(1)'Address
|
||||
begin
|
||||
|
||||
Object_Private.Slot_Array_Last_Index := 1;
|
||||
Object_Public.Slot_Array(1)(1) := 0;
|
||||
Chunk_In_Slot := False;
|
||||
Slot_Index := 1;
|
||||
|
||||
Slot_Array_Loop : for Index in Object_Private.Slot_Array'Range loop
|
||||
if Object_Private.Slot_Array(Index).Chunk_Number = Chunk_Number then
|
||||
Chunk_In_Slot := True;
|
||||
Slot_Index := Index;
|
||||
exit Slot_Array_Loop;
|
||||
end if;
|
||||
end loop Slot_Array_Loop;
|
||||
|
||||
if not Chunk_In_Slot then
|
||||
Log("Chunk in Slot");
|
||||
-- File.Read(0, , Chunk_Type'Size / Byte'Size);
|
||||
else
|
||||
Log("Chunk not in Slot");
|
||||
end if;
|
||||
|
||||
end Read_Chunk;
|
||||
|
||||
end App.File_Cache;
|
35
repos/app-file_cache.ads
Normal file
35
repos/app-file_cache.ads
Normal file
@ -0,0 +1,35 @@
|
||||
pragma Ada_2012;
|
||||
|
||||
with App.File;
|
||||
|
||||
|
||||
package App.File_Cache with Spark_Mode is
|
||||
|
||||
type Slot_Array_Index_Type is new Positive range 1..128;
|
||||
type Slot_Array_Public_Type is array (Slot_Array_Index_Type) of File.Chunk_Type;
|
||||
|
||||
type Object_Private_Type is private;
|
||||
type Object_Public_Type is record
|
||||
Slot_Array : Slot_Array_Public_Type;
|
||||
end record;
|
||||
|
||||
procedure Read_Chunk(Object_Private : in out Object_Private_Type;
|
||||
Object_Public : in out Object_Public_Type;
|
||||
Chunk_Number : in File.Chunk_Number_Type;
|
||||
Chunk_In_Slot : out Boolean;
|
||||
Slot_Index : out Slot_Array_Index_Type);
|
||||
|
||||
private
|
||||
|
||||
type Slot_Type is record
|
||||
Used : Boolean := False;
|
||||
Chunk_Number : File.Chunk_Number_Type := 0;
|
||||
end record;
|
||||
|
||||
type Slot_Array_Private_Type is array (Slot_Array_Index_Type) of Slot_Type;
|
||||
type Object_Private_Type is record
|
||||
Slot_Array_Last_Index : Slot_Array_Index_Type;
|
||||
Slot_Array : Slot_Array_Private_Type;
|
||||
end record;
|
||||
|
||||
end App.File_Cache;
|
@ -595,6 +595,7 @@ set default_test_pkgs {
|
||||
test-fs_rom_update
|
||||
test-fs_rom_update_fs
|
||||
test-fs_rom_update_ram
|
||||
test-gnatio
|
||||
test-init
|
||||
test-init_loop
|
||||
test-ldso
|
||||
|
@ -15,7 +15,10 @@ SRC_ADS += system.ads \
|
||||
s-stoele.ads \
|
||||
s-secsta.ads \
|
||||
interfac.ads \
|
||||
a-except.ads
|
||||
a-except.ads \
|
||||
gnat.ads
|
||||
|
||||
SRC_ADB += g-io.adb
|
||||
|
||||
CUSTOM_ADA_MAKE = $(CC)
|
||||
CUSTOM_ADA_FLAGS = -c -gnatg -gnatp -gnatpg -gnatn2
|
||||
@ -39,12 +42,15 @@ vpath s-secsta.ads $(ADA_RUNTIME_DIR)
|
||||
vpath s-imgint.ads $(ADA_RTS_SOURCE)
|
||||
vpath a-except.ads $(ADA_RUNTIME_DIR)
|
||||
vpath interfac.ads $(ADA_RTS_SOURCE)
|
||||
vpath gnat.ads $(ADA_RTS_SOURCE)
|
||||
vpath g-io.ads $(ADA_RTS_SOURCE)
|
||||
|
||||
vpath s-stoele.adb $(ADA_RTS_SOURCE)
|
||||
vpath s-secsta.adb $(ADA_RUNTIME_DIR)
|
||||
vpath s-soflin.adb $(ADA_RUNTIME_DIR)
|
||||
vpath s-imgint.adb $(ADA_RTS_SOURCE)
|
||||
vpath a-except.adb $(ADA_RUNTIME_DIR)
|
||||
vpath g-io.adb $(ADA_RTS_SOURCE)
|
||||
|
||||
vpath platform.% $(ADA_RUNTIME_LIB_DIR)
|
||||
vpath string_utils.% $(ADA_RUNTIME_LIB_DIR)
|
||||
|
@ -20,6 +20,19 @@ ada__exceptions__warn_not_implemented T
|
||||
allocate_secondary_stack T
|
||||
constraint_error T
|
||||
get_thread T
|
||||
gnat__io__new_line__2 T
|
||||
gnat__io__new_line T
|
||||
gnat__io__put__2 T
|
||||
gnat__io__put__3 T
|
||||
gnat__io__put__4 T
|
||||
gnat__io__put__5 T
|
||||
gnat__io__put__6 T
|
||||
gnat__io__put_line__2 T
|
||||
gnat__io__put_line T
|
||||
gnat__io__put T
|
||||
gnat__io__set_output T
|
||||
gnat__io__standard_error T
|
||||
gnat__io__standard_output T
|
||||
memcmp T
|
||||
raise_ada_exception T
|
||||
ss_utils_E D 2
|
||||
|
@ -1 +1 @@
|
||||
1898150e6e4544954634733a2384674b0193d4fd
|
||||
eea97604807f7cbb9b9c1aea9d4f0da6256d75b9
|
||||
|
@ -3,5 +3,5 @@ VERSION := 0
|
||||
DOWNLOADS := ada-runtime.git
|
||||
|
||||
URL(ada-runtime) := https://github.com/Componolit/ada-runtime.git
|
||||
REV(ada-runtime) := 82e4df4ed4ae73b9e391dc250d25a524d69a7598
|
||||
REV(ada-runtime) := 6ebc27d7954eff4d027b3834f10a0934523c569b
|
||||
DIR(ada-runtime) := ada-runtime
|
||||
|
@ -6,6 +6,8 @@ MIRROR_FROM_ADA_RT_DIR := \
|
||||
system.ads \
|
||||
s-stoele.ads \
|
||||
a-unccon.ads \
|
||||
gnat.ads \
|
||||
g-io.ads \
|
||||
)\
|
||||
$(addprefix ada-runtime/src/,\
|
||||
s-stalib.ads \
|
||||
|
@ -1 +1 @@
|
||||
2018-11-27 3862934b204ecb8a4f0944b511ba3f4b4598d299
|
||||
2019-01-03 f064c0ffc41ac5571bdaaf66dbad6b35c79db390
|
||||
|
1
repos/libports/recipes/pkg/test-gnatio/README
Normal file
1
repos/libports/recipes/pkg/test-gnatio/README
Normal file
@ -0,0 +1 @@
|
||||
Test for the GNAT.IO support of the Ada runtime.
|
4
repos/libports/recipes/pkg/test-gnatio/archives
Normal file
4
repos/libports/recipes/pkg/test-gnatio/archives
Normal file
@ -0,0 +1,4 @@
|
||||
_/src/init
|
||||
_/src/test-gnatio
|
||||
_/src/ada
|
||||
_/src/log_terminal
|
1
repos/libports/recipes/pkg/test-gnatio/hash
Normal file
1
repos/libports/recipes/pkg/test-gnatio/hash
Normal file
@ -0,0 +1 @@
|
||||
2019-01-04-a f712e9b8ab863b024127b0f29beecca4dea1d487
|
41
repos/libports/recipes/pkg/test-gnatio/runtime
Normal file
41
repos/libports/recipes/pkg/test-gnatio/runtime
Normal file
@ -0,0 +1,41 @@
|
||||
<runtime ram="32M" caps="1000" binary="init">
|
||||
|
||||
<events>
|
||||
<timeout meaning="failed" sec="20" />
|
||||
<log meaning="succeeded">GNAT.IO test program started successfully.</log>
|
||||
</events>
|
||||
|
||||
<content>
|
||||
<rom label="ld.lib.so"/>
|
||||
<rom label="ada.lib.so"/>
|
||||
<rom label="test-gnatio"/>
|
||||
<rom label="log_terminal"/>
|
||||
</content>
|
||||
|
||||
<config>
|
||||
<parent-provides>
|
||||
<service name="LOG"/>
|
||||
<service name="PD"/>
|
||||
<service name="CPU"/>
|
||||
<service name="ROM"/>
|
||||
</parent-provides>
|
||||
<default-route>
|
||||
<any-service> <parent/> </any-service>
|
||||
</default-route>
|
||||
<default caps="100"/>
|
||||
|
||||
<start name="terminal">
|
||||
<binary name="log_terminal"/>
|
||||
<resource name="RAM" quantum="2M"/>
|
||||
<provides><service name="Terminal"/></provides>
|
||||
</start>
|
||||
|
||||
<start name="test-gnatio">
|
||||
<resource name="RAM" quantum="2M"/>
|
||||
<route>
|
||||
<service name="Terminal"> <child name="terminal"/> </service>
|
||||
<any-service> <parent/> <any-child/> </any-service>
|
||||
</route>
|
||||
</start>
|
||||
</config>
|
||||
</runtime>
|
@ -11,6 +11,9 @@ MIRROR_FROM_ADA_RT_DIR := \
|
||||
s-imgint.ads \
|
||||
s-imgint.adb \
|
||||
a-unccon.ads \
|
||||
gnat.ads \
|
||||
g-io.ads \
|
||||
g-io.adb \
|
||||
) \
|
||||
ada-runtime/src \
|
||||
ada-runtime/platform/genode.cc
|
||||
|
@ -1 +1 @@
|
||||
2019-01-02 3b7f984823ebb680568cdf546a8f0edce7f12b6e
|
||||
2019-01-04-a 0a6e927cfa8fc2b28674aa4f9b766568babd3b53
|
||||
|
@ -1,2 +1,3 @@
|
||||
base
|
||||
so
|
||||
os
|
||||
terminal_session
|
||||
|
3
repos/libports/recipes/src/test-gnatio/content.mk
Normal file
3
repos/libports/recipes/src/test-gnatio/content.mk
Normal file
@ -0,0 +1,3 @@
|
||||
SRC_DIR = src/test/gnatio
|
||||
|
||||
include $(GENODE_DIR)/repos/base/recipes/src/content.inc
|
1
repos/libports/recipes/src/test-gnatio/hash
Normal file
1
repos/libports/recipes/src/test-gnatio/hash
Normal file
@ -0,0 +1 @@
|
||||
2019-01-04 da199ed59c5327be8c6cf04ccfab93a0c5214d22
|
3
repos/libports/recipes/src/test-gnatio/used_apis
Normal file
3
repos/libports/recipes/src/test-gnatio/used_apis
Normal file
@ -0,0 +1,3 @@
|
||||
base
|
||||
ada
|
||||
terminal_session
|
36
repos/libports/src/test/gnatio/main.adb
Normal file
36
repos/libports/src/test/gnatio/main.adb
Normal file
@ -0,0 +1,36 @@
|
||||
--
|
||||
-- \brief GNAT.IO test program
|
||||
-- \author Alexander Senier
|
||||
-- \date 2019-01-03
|
||||
--
|
||||
|
||||
with GNAT.IO;
|
||||
|
||||
procedure Main is
|
||||
use GNAT.IO;
|
||||
begin
|
||||
Put (Standard_Output, "Hell");
|
||||
Put (Standard_Output, 'o');
|
||||
Put_Line (Standard_Output, " World!");
|
||||
New_Line (Standard_Output);
|
||||
Put (Standard_Output, 98765432);
|
||||
New_Line;
|
||||
|
||||
Put ("Integer: ");
|
||||
Put (123456);
|
||||
New_Line;
|
||||
|
||||
Put_Line ("Character: ");
|
||||
Put ('X');
|
||||
Put ('Y');
|
||||
Put ('Z');
|
||||
New_Line;
|
||||
|
||||
Put ("New_Line with spacing:");
|
||||
New_Line (Spacing => 5);
|
||||
|
||||
Set_Output (Standard_Error);
|
||||
Put (11223344);
|
||||
New_Line;
|
||||
Put_Line ("GNAT.IO test program started successfully.");
|
||||
end Main;
|
23
repos/libports/src/test/gnatio/startup.cc
Normal file
23
repos/libports/src/test/gnatio/startup.cc
Normal file
@ -0,0 +1,23 @@
|
||||
/*
|
||||
* \brief Wrapper for Ada main program using Terminal session
|
||||
* \author Alexander Senier
|
||||
* \date 2019-01-03
|
||||
*/
|
||||
|
||||
/* Genode includes */
|
||||
#include <base/component.h>
|
||||
#include <terminal_session/connection.h>
|
||||
|
||||
extern "C" void _ada_main(void);
|
||||
|
||||
/* Required in runtime */
|
||||
Terminal::Connection *__genode_terminal;
|
||||
|
||||
void Component::construct(Genode::Env &env)
|
||||
{
|
||||
Terminal::Connection _terminal (env, "Ada");
|
||||
__genode_terminal = &_terminal;
|
||||
|
||||
_ada_main();
|
||||
env.parent().exit(0);
|
||||
}
|
4
repos/libports/src/test/gnatio/target.mk
Normal file
4
repos/libports/src/test/gnatio/target.mk
Normal file
@ -0,0 +1,4 @@
|
||||
TARGET = test-gnatio
|
||||
SRC_ADB = main.adb
|
||||
SRC_CC = startup.cc
|
||||
LIBS = base ada
|
Loading…
x
Reference in New Issue
Block a user