Ada Runtime Library: Difference between revisions

m
Bot: Replace deprecated source tag with syntaxhighlight
[unchecked revision][unchecked revision]
m (Bot: Replace deprecated source tag with syntaxhighlight)
 
(One intermediate revision by the same user not shown)
Line 52:
For more information regarding GNAT project configuration refer to the AdaCore documentation: [https://docs.adacore.com/gprbuild-docs/html/gprbuild_ug/gnat_project_manager.html]
 
<sourcesyntaxhighlight lang="ada">
library project Runtime is
-- Tells Gprbuild to create any missing directories in the build process.
Line 123:
for Target use "i686-elf";
end Runtime;
</syntaxhighlight>
</source>
 
As noted in the source code comments above, in this setup the run-time sources are used as a run-time library during the build process. One method to implement this is to include a pre-requisite step in your makefile to copy the sources to the final build destination <tt>adainclude</tt> directory, then to specify this build directory as the run-time for the project. An example makefile for facilitating this can be seen below.
Line 129:
''Please note that this makefile may not be fit for all projects and purposes.''
 
<sourcesyntaxhighlight lang="make">
RUNTIME_BINARY := ${LIB_DIR}/libgnat.a
RUNTIME_PROJ := runtime
Line 176:
${LIB_DIR}:
mkdir -p ${LIB_DIR}
</syntaxhighlight>
</source>
 
 
Line 249:
Also, add the following line in the private part of the package:
 
<sourcesyntaxhighlight lang="ada">
private
Run_Time_Name : constant String := "Bare Bones Run Time";
</syntaxhighlight>
</source>
 
According to <tt>targparm.ads</tt>, this directive should be the first thing after the private keyword.
Line 266:
 
'''x86.ads'''
<sourcesyntaxhighlight lang="ada">
-------------------------------------------------------------------------------
-- X86
Line 276:
pragma Preelaborate (x86);
end x86;
</syntaxhighlight>
</source>
 
'''x86-port_io.ads'''
<sourcesyntaxhighlight lang="ada">
with Interfaces;
with System;
Line 321:
);
end x86.Port_IO;
</syntaxhighlight>
</source>
 
 
'''x86-port_io.adb'''
<sourcesyntaxhighlight lang="ada">
with System.Machine_Code;
 
Line 367:
end Outb;
end x86.Port_IO;
</syntaxhighlight>
</source>
 
Fundamentally, the role of the runtime library is to implement the features defined in the Ada language standard for the particular target platform. This requires the creation of target-specific packages to interface with platform features such as internal clocks, [[UART|UARTs]] and [[PIT|timers]], among other things. These packages can then be used by language-defined packages in the runtime library to expose this functionality to the linked application.
Line 380:
A practical usage of this would be to define a <tt>runtime.xml</tt> file, placed within the final <tt>adainclude</tt> directory of the run-time library. This is used to automatically use a linker script for the target platform when the kernel is linked against the library.
 
<sourcesyntaxhighlight lang="xml">
<?xml version="1.0" ?>
<gprconfig>
Line 395:
</configuration>
</gprconfig>
</syntaxhighlight>
</source>
 
Where <tt>${RUNTIME}</tt> is a predefined variable made available by Gprbuild.
Line 423:
 
'''s-imguns.ads'''
<sourcesyntaxhighlight lang="ada">
with System.Unsigned_Types;
 
Line 468:
 
end System.Img_Uns;
</syntaxhighlight>
</source>
 
'''s-imguns.adb'''
<sourcesyntaxhighlight lang="ada">
with System.Unsigned_Types; use System.Unsigned_Types;
 
Line 539:
 
end System.Img_Uns;
</syntaxhighlight>
</source>
 
User-defined images for a given type can be implemented by overriding the default implementation of the <tt>Put_Image</tt> attribute.