comp.lang.ada
 help / color / mirror / Atom feed
From: anon@anon.org (anon)
Subject: Re: How do I go about creating a minimal GNAT runtime?
Date: Mon, 26 Jan 2009 06:52:52 GMT
Date: 2009-01-26T06:52:52+00:00	[thread overview]
Message-ID: <85dfl.153987$_Y1.127262@bgtnsc05-news.ops.worldnet.att.net> (raw)
In-Reply-To: eb511600-6446-4bad-b859-0d7444416a4c@d36g2000prf.googlegroups.com

Will deal with exception later.

I wrote this last time when you ask about building a Stand-Alone Ada 
Hello program. In this example all code files are written using GNAT 
Ada 95 and was tested using GNAT GPL Ada 2005, Adacore 2007
version. And Yes, I do have all source files.

##############################################################################
# Linux: script file                                                         #
#                                                                            #
#  Both GNATBIND and GNATLINK can be used but the binder output file         #
#  must be edited to move function 'main' to first routine of the            #
#  package, before linking. Required for GNAT Ada binary type of             #
#  kernels.                                                                  #
#                                                                            #
#  In this example I use an Ada partition call 'edit_bind' to preform        #
#  the move. But file can be be edited manually.                             #
#                                                                            #
##############################################################################


##############################################################################
#                                                                            #
#  'video_io' package basically a "protective-mode" video device driver      #
#  that access video memory and handles a few  simple control characters,    #
#  such as CR/LF.                                                            #
#                                                                            #
#  'test_io' package is a edited copy of GNAT.IO which defines the major     #
#  put/put_line/new_line routines.  Deleted 'Get'(s) routines.               #
#                                                                            #
##############################################################################
gnat compile video_io -gnatl >1
gnat compile text_io.adb -gnatl -a >>1

##############################################################################
#                                                                            #
#  Hello is a simple 32-bit protective-mode kernel                           #
#                                                                            #
##############################################################################
gnat make -c hello.adb -gnatl >>1
gnat bind hello.ali 

##############################################################################
#                                                                            #
# edit_bind: Moved function 'main' to top of package '_ada_main'.            #
#            So, function 'main' is first routine                            #
#                                                                            #
##############################################################################
./edit_bind b~hello.adb

##############################################################################
#                                                                            #
#  link Kernel routines into a single Stand-Alone file                       #
#                                                                            #
##############################################################################
gnat link hello.ali -e _ada_hello -T hello.lds -nostdlib
#
objdump -d hello >3
#
objcopy -R .comment -R .dynamic -R .note -S -O binary hello hello.bin
#
rm video_io.ali video_io.o text_io.ali text_io.o hello.ali hello hello.o

##############################################################################
#                                                                            #
#  compile and build the MBR boot program. calls setup routine               #
#  Then pad boot.bin to MBR size and insert boot sig.                        #
#                                                                            #
##############################################################################
gnat compile boot.adb >4
ld -o boot.exe -Ttext 0 -e _ada_boot boot.o
objcopy -R .comment -R .dynamic -R .note -S -O binary boot.exe boot.bin
#
./fix_mbr boot.bin
rm boot.ali boot.exe boot.o

##############################################################################
#                                                                            #
# compile and build the 'proctive-mode' initiator. Which calls an            #
# Ada program at a specific offset.                                          #
#                                                                            #
##############################################################################
gnat compile setup.adb >>4
ld -o setup.exe -T setup.lds --oformat binary -s -e _ada_setup setup.o 
./fix_mbr setup.exe
rm setup.ali setup.o

##############################################################################
#                                                                            #
# catenate a list of binary file into one, building a loadable kernal.       #
#   Kernel := ipl.img                                                        #
#                                                                            #
##############################################################################
./catenate ipl.img boot.bin setup.exe hello.bin
rm boot.bin setup.exe hello.bin



In <eb511600-6446-4bad-b859-0d7444416a4c@d36g2000prf.googlegroups.com>, Lucretia <lucretia9@lycos.co.uk> writes:
>Hi (again),
>
>It's been a while, but I'm coming back to my Ada kernel again. I've
>been messing with my helo_world_kernel which I built using no runtime
>(see http://www.archeia.com for more info).
>
>Having just spoken to Ludovic on #Ada, he pointed out that the gnat
>tools can use a basic cross tool set, like the ones I have built
>myself (again, see the above link). My toolset comprises of a gnat1
>compiler and a gnatbind for my targets. I found that it does work
>using the --GCC and --GNATBIND flags, and I need to make sure the
>cross tools and the host tools are of the same GCC version otherwise
>GNAT throws up ALI format errors.
>
>The thing is, I've been trying to enable exceptions, but keep coming
>across big problems in that the runtime requires features that are
>being restricted, such as returning aggregates and assigning
>composites, returning unconstrained objects which requires the
>secondary stack. So, what I really need to know is, how do I create a
>runtime which is restricted in this way for bare hw access?
>
>Thanks,
>Luke.




  parent reply	other threads:[~2009-01-26  6:52 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-01-24 20:47 How do I go about creating a minimal GNAT runtime? Lucretia
2009-01-25 11:13 ` Ludovic Brenta
2009-01-25 11:18   ` Ludovic Brenta
2009-01-25 14:00     ` Lucretia
2009-01-25 14:00   ` Lucretia
2009-01-25 19:43     ` Ludovic Brenta
2009-01-25 20:30 ` xavier grave
2009-01-26  6:52 ` anon [this message]
2009-01-26 21:36 ` anon
2009-02-10  2:34 ` Exceptions (was Re: How do I go about creating a minimal GNAT runtime?) anon
2009-02-16  1:41 ` How do I go about creating a minimal GNAT runtime? Hibou57 (Yannick Duchêne)
2009-02-21  9:11 ` Dimonax
2009-02-21 16:41   ` anon
2009-02-21 21:14     ` Dimonax
2009-02-22  1:36       ` anon
2009-02-27 23:42   ` Randy Brukardt
2009-03-01  1:12     ` Dimonax
2009-03-01 19:13       ` anon
2009-03-02 22:07         ` Randy Brukardt
2009-03-03  2:00           ` anon
2009-03-03 22:23             ` lucretia
2009-03-04  0:03               ` anon
2009-03-11 12:54   ` gautier_niouzes
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox