* Help writing ada booting kernel
@ 2007-07-15 13:55 Xianzheng Zhou
2007-07-15 14:44 ` Wiktor Moskwa
2007-07-16 3:02 ` anon
0 siblings, 2 replies; 11+ messages in thread
From: Xianzheng Zhou @ 2007-07-15 13:55 UTC (permalink / raw)
Hello all,
I'm a new to Ada and very interested in learning this language.
Currently, I'm trying to write a small program in ada compiled by gnat,
to boot an ordinary PC, something like grub. I'm wonderring whether
ada can do this low-level task and how may I use the gnat progma to
achieve this. Please advise if you know how to do this.
Many thanks.
Joe
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Help writing ada booting kernel
2007-07-15 13:55 Help writing ada booting kernel Xianzheng Zhou
@ 2007-07-15 14:44 ` Wiktor Moskwa
2007-07-16 1:59 ` Xianzheng Zhou
2007-07-16 3:02 ` anon
1 sibling, 1 reply; 11+ messages in thread
From: Wiktor Moskwa @ 2007-07-15 14:44 UTC (permalink / raw)
On 15.07.2007, Xianzheng Zhou <joe@lgsolutions.com.au> wrote:
> I'm a new to Ada and very interested in learning this language.
> Currently, I'm trying to write a small program in ada compiled by gnat,
> to boot an ordinary PC, something like grub. I'm wonderring whether
> ada can do this low-level task and how may I use the gnat progma to
> achieve this. Please advise if you know how to do this.
Hi,
First of all if you want to experiment with writing a native program
don't write your own bootloader, please :-)
GRUB multiboot specification is a good place to start if you don't
want to waste a lot of time fighting with weird x86 architecture.
By learning Ada this way you will miss many features that Ada run-time
provides (tasking, secondary stack, exceptions, standard library, etc.).
If you still want to try, I can provide a piece of code to start with.
Some time ago I wanted to experiment with native programs, you can
download the results - it's a small native program that starts in
protected mode, loads GDTR, enables memory paging and prints few
things directly to VGA memory.
It compiles with GNAT GPL and can be tested with bochs or qemu.
Feel free to ask if something is not clear in the code or build script.
http://hoborg.zapto.org/AdaExpOs.tgz
For something serious you can check out Marte OS: http://marte.unican.es/
--
Wiktor Moskwa
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Help writing ada booting kernel
2007-07-15 14:44 ` Wiktor Moskwa
@ 2007-07-16 1:59 ` Xianzheng Zhou
2007-07-16 6:07 ` Wiktor Moskwa
0 siblings, 1 reply; 11+ messages in thread
From: Xianzheng Zhou @ 2007-07-16 1:59 UTC (permalink / raw)
Hi Wiktor,
Thanks for your reply. That really helps. This is exactly the example I
need. :)
In the example, int.S and boot.S are in assembly code. Is there a way to
write this part in Ada?
Wiktor Moskwa wrote:
> On 15.07.2007, Xianzheng Zhou <joe@lgsolutions.com.au> wrote:
>> I'm a new to Ada and very interested in learning this language.
>> Currently, I'm trying to write a small program in ada compiled by gnat,
>> to boot an ordinary PC, something like grub. I'm wonderring whether
>> ada can do this low-level task and how may I use the gnat progma to
>> achieve this. Please advise if you know how to do this.
>
> Hi,
>
> First of all if you want to experiment with writing a native program
> don't write your own bootloader, please :-)
> GRUB multiboot specification is a good place to start if you don't
> want to waste a lot of time fighting with weird x86 architecture.
>
> By learning Ada this way you will miss many features that Ada run-time
> provides (tasking, secondary stack, exceptions, standard library, etc.).
>
> If you still want to try, I can provide a piece of code to start with.
> Some time ago I wanted to experiment with native programs, you can
> download the results - it's a small native program that starts in
> protected mode, loads GDTR, enables memory paging and prints few
> things directly to VGA memory.
> It compiles with GNAT GPL and can be tested with bochs or qemu.
> Feel free to ask if something is not clear in the code or build script.
>
> http://hoborg.zapto.org/AdaExpOs.tgz
>
> For something serious you can check out Marte OS: http://marte.unican.es/
>
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Help writing ada booting kernel
2007-07-15 13:55 Help writing ada booting kernel Xianzheng Zhou
2007-07-15 14:44 ` Wiktor Moskwa
@ 2007-07-16 3:02 ` anon
2007-07-16 11:16 ` Xianzheng Zhou
1 sibling, 1 reply; 11+ messages in thread
From: anon @ 2007-07-16 3:02 UTC (permalink / raw)
But Ada was never meant to be use as a Stand-Alone program without
some kind of interface code from the BOOT ROM to the main procedure.
So unless you purchase an Ada compile, which can produce Stand-Alone
code you must write a bootloader for your Ada program. This bootloader
is normally written in either C or Assembly., This is because the Free
GNAT Ada Compiler/Binder/Linker does not include a way of creating
Stand-Alone code.
As for low-level code, you have two options. The first is to use the
pragma Import/Export statement. While the second is to use the
Ada ASM instruction and build your assembly routines.
The Best thing is go to your local book store and see if they have any
books on Ada. The other is to check out http://www.adapower.com
In <f7d8vk$4tt$1@aioe.org>, Xianzheng Zhou <joe@lgsolutions.com.au> writes:
>Hello all,
>I'm a new to Ada and very interested in learning this language.
>Currently, I'm trying to write a small program in ada compiled by gnat,
> to boot an ordinary PC, something like grub. I'm wonderring whether
>ada can do this low-level task and how may I use the gnat progma to
>achieve this. Please advise if you know how to do this.
>
>Many thanks.
>
>Joe
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Help writing ada booting kernel
2007-07-16 1:59 ` Xianzheng Zhou
@ 2007-07-16 6:07 ` Wiktor Moskwa
2007-07-16 11:01 ` Xianzheng Zhou
2007-07-16 11:18 ` Xianzheng Zhou
0 siblings, 2 replies; 11+ messages in thread
From: Wiktor Moskwa @ 2007-07-16 6:07 UTC (permalink / raw)
On 16.07.2007, Xianzheng Zhou <joe@lgsolutions.com.au> wrote:
> In the example, int.S and boot.S are in assembly code. Is there a way to
> write this part in Ada?
>
In boot.S you need a way to pass values of two registers (EAX and EBX)
to the main procedure through stack - that's where Ada expects parameters.
The code in int.S can't be put in procedures because interrupt handlers
don't behave like procedures (stack frame has different format).
If a compiler supported "bare x86" target it wouldn't probably be
a problem. For example if you compile something for AVR microcontroler
using AVR-GCC, interrupt handlers are ordinary blocks of code wrapped
in special macros - all necessary assembly code is generated by the
compiler.
--
Wiktor Moskwa
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Help writing ada booting kernel
2007-07-16 6:07 ` Wiktor Moskwa
@ 2007-07-16 11:01 ` Xianzheng Zhou
2007-07-16 11:18 ` Xianzheng Zhou
1 sibling, 0 replies; 11+ messages in thread
From: Xianzheng Zhou @ 2007-07-16 11:01 UTC (permalink / raw)
hi Wiktor,
Thanks for your explanation:)
I was actually trying to write a kernel like this(not grub, I used grub
as an example since I need to figure out how to do standalone booting
program). This is a good example exactly what I was looking for.
Joe
Wiktor Moskwa wrote:
> On 16.07.2007, Xianzheng Zhou <joe@lgsolutions.com.au> wrote:
>> In the example, int.S and boot.S are in assembly code. Is there a way to
>> write this part in Ada?
>>
>
> In boot.S you need a way to pass values of two registers (EAX and EBX)
> to the main procedure through stack - that's where Ada expects parameters.
> The code in int.S can't be put in procedures because interrupt handlers
> don't behave like procedures (stack frame has different format).
>
> If a compiler supported "bare x86" target it wouldn't probably be
> a problem. For example if you compile something for AVR microcontroler
> using AVR-GCC, interrupt handlers are ordinary blocks of code wrapped
> in special macros - all necessary assembly code is generated by the
> compiler.
>
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Help writing ada booting kernel
2007-07-16 3:02 ` anon
@ 2007-07-16 11:16 ` Xianzheng Zhou
0 siblings, 0 replies; 11+ messages in thread
From: Xianzheng Zhou @ 2007-07-16 11:16 UTC (permalink / raw)
Hi Anon,
Thanks for your reply.
I'll try to figure out how to use Import/Export pragma or Ada asm.
I learned Ada when I was still in Uni, one of the course used it, which
is called concurrent and distributed system. I can use Ada's high level
features, but I never used its low level power and it's hard to find
examples on web resources.
Joe
anon wrote:
> But Ada was never meant to be use as a Stand-Alone program without
> some kind of interface code from the BOOT ROM to the main procedure.
>
> So unless you purchase an Ada compile, which can produce Stand-Alone
> code you must write a bootloader for your Ada program. This bootloader
> is normally written in either C or Assembly., This is because the Free
> GNAT Ada Compiler/Binder/Linker does not include a way of creating
> Stand-Alone code.
>
> As for low-level code, you have two options. The first is to use the
> pragma Import/Export statement. While the second is to use the
> Ada ASM instruction and build your assembly routines.
>
> The Best thing is go to your local book store and see if they have any
> books on Ada. The other is to check out http://www.adapower.com
>
>
>
>
> In <f7d8vk$4tt$1@aioe.org>, Xianzheng Zhou <joe@lgsolutions.com.au> writes:
>> Hello all,
>> I'm a new to Ada and very interested in learning this language.
>> Currently, I'm trying to write a small program in ada compiled by gnat,
>> to boot an ordinary PC, something like grub. I'm wonderring whether
>> ada can do this low-level task and how may I use the gnat progma to
>> achieve this. Please advise if you know how to do this.
>>
>> Many thanks.
>>
>> Joe
>
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Help writing ada booting kernel
2007-07-16 6:07 ` Wiktor Moskwa
2007-07-16 11:01 ` Xianzheng Zhou
@ 2007-07-16 11:18 ` Xianzheng Zhou
2007-07-16 12:21 ` Wiktor Moskwa
2007-07-16 21:02 ` anon
1 sibling, 2 replies; 11+ messages in thread
From: Xianzheng Zhou @ 2007-07-16 11:18 UTC (permalink / raw)
Just wonderring, is it possible to replace int.S and boot.S using ada
asm inline assembly instruction?
Joe
Wiktor Moskwa wrote:
> On 16.07.2007, Xianzheng Zhou <joe@lgsolutions.com.au> wrote:
>> In the example, int.S and boot.S are in assembly code. Is there a way to
>> write this part in Ada?
>>
>
> In boot.S you need a way to pass values of two registers (EAX and EBX)
> to the main procedure through stack - that's where Ada expects parameters.
> The code in int.S can't be put in procedures because interrupt handlers
> don't behave like procedures (stack frame has different format).
>
> If a compiler supported "bare x86" target it wouldn't probably be
> a problem. For example if you compile something for AVR microcontroler
> using AVR-GCC, interrupt handlers are ordinary blocks of code wrapped
> in special macros - all necessary assembly code is generated by the
> compiler.
>
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Help writing ada booting kernel
2007-07-16 11:18 ` Xianzheng Zhou
@ 2007-07-16 12:21 ` Wiktor Moskwa
2007-07-16 21:02 ` anon
1 sibling, 0 replies; 11+ messages in thread
From: Wiktor Moskwa @ 2007-07-16 12:21 UTC (permalink / raw)
On 16.07.2007, Xianzheng Zhou <joe@lgsolutions.com.au> wrote:
> Just wonderring, is it possible to replace int.S and boot.S using ada
> asm inline assembly instruction?
>
I don't think so but if you succeed let me know.
--
Wiktor Moskwa
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Help writing ada booting kernel
2007-07-16 11:18 ` Xianzheng Zhou
2007-07-16 12:21 ` Wiktor Moskwa
@ 2007-07-16 21:02 ` anon
2007-07-17 9:15 ` Xianzheng Zhou
1 sibling, 1 reply; 11+ messages in thread
From: anon @ 2007-07-16 21:02 UTC (permalink / raw)
It is possible but you have to know the linker that you are using.
Then you must:
Rewrite the bootloader aka the asm packages in ada.
Secondly define a procedure to handle Ada elaborate schemes
Must define a file system for your program if you need to load
any data files.
Then create a linker build file aka the linker script file
which defines the programs external variable and procedures.
(For GNAT Ada it has a lot of variable and routines, that
must be defined)
Afterward use either boch or qemu to test and debug.
As for another kernel type of sample type the Toy_Lovelace packages
1..6. Package 2 builds on package 1, and so go. But he still uses a
couple of assembly routines. Also it is based on the SimpleOS (SOS)
version written in C/Assembly so if you know C you can learn from
looking a both set of packages and programs. The only problem is no
documentation for the Toy_Lovelace version and and most variable are
in french. The SOS's documentation is in PDF format written in
French. The SOS was a set of articles that were published in a Linux
Mag, French version 2004-2006. Do a google search on "Simple OS"
(SOS) to find the packages. The SOS web page as links for the Ada
Toy_Lovelace kernels.
For what you are trying to do. You should allocate 8 hrs a day for the
next 2 months. just to get a simple program to work. More complex try
1 year. The reason is there are no documention or sample code you can
build from. And C does not follow Ada elaboration, etc. schemes.
As for the Time table well I know because I am wriiting a True Pure
Ada-OS. And this code will not be a redesigned of a Posix or Linux
based kernel. It will only run only Pure Ada-83/95 recompled code
(at the moment Ada-83/95 only).
In <f7fk6i$agf$2@aioe.org>, Xianzheng Zhou <joe@lgsolutions.com.au> writes:
>Just wonderring, is it possible to replace int.S and boot.S using ada
>asm inline assembly instruction?
>
>Joe
>
>Wiktor Moskwa wrote:
>> On 16.07.2007, Xianzheng Zhou <joe@lgsolutions.com.au> wrote:
>>> In the example, int.S and boot.S are in assembly code. Is there a way to
>>> write this part in Ada?
>>>
>>
>> In boot.S you need a way to pass values of two registers (EAX and EBX)
>> to the main procedure through stack - that's where Ada expects parameters.
>> The code in int.S can't be put in procedures because interrupt handlers
>> don't behave like procedures (stack frame has different format).
>>
>> If a compiler supported "bare x86" target it wouldn't probably be
>> a problem. For example if you compile something for AVR microcontroler
>> using AVR-GCC, interrupt handlers are ordinary blocks of code wrapped
>> in special macros - all necessary assembly code is generated by the
>> compiler.
>>
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Help writing ada booting kernel
2007-07-16 21:02 ` anon
@ 2007-07-17 9:15 ` Xianzheng Zhou
0 siblings, 0 replies; 11+ messages in thread
From: Xianzheng Zhou @ 2007-07-17 9:15 UTC (permalink / raw)
That was quite a time-consuming approach, I guess I'll leave it in
assembly code for the time being until it's getting necessary to change
it:) Thanks for your detailed suggestion anyway.
anon wrote:
> It is possible but you have to know the linker that you are using.
> Then you must:
>
> Rewrite the bootloader aka the asm packages in ada.
> Secondly define a procedure to handle Ada elaborate schemes
> Must define a file system for your program if you need to load
> any data files.
>
> Then create a linker build file aka the linker script file
> which defines the programs external variable and procedures.
> (For GNAT Ada it has a lot of variable and routines, that
> must be defined)
>
> Afterward use either boch or qemu to test and debug.
>
> As for another kernel type of sample type the Toy_Lovelace packages
> 1..6. Package 2 builds on package 1, and so go. But he still uses a
> couple of assembly routines. Also it is based on the SimpleOS (SOS)
> version written in C/Assembly so if you know C you can learn from
> looking a both set of packages and programs. The only problem is no
> documentation for the Toy_Lovelace version and and most variable are
> in french. The SOS's documentation is in PDF format written in
> French. The SOS was a set of articles that were published in a Linux
> Mag, French version 2004-2006. Do a google search on "Simple OS"
> (SOS) to find the packages. The SOS web page as links for the Ada
> Toy_Lovelace kernels.
>
> For what you are trying to do. You should allocate 8 hrs a day for the
> next 2 months. just to get a simple program to work. More complex try
> 1 year. The reason is there are no documention or sample code you can
> build from. And C does not follow Ada elaboration, etc. schemes.
>
> As for the Time table well I know because I am wriiting a True Pure
> Ada-OS. And this code will not be a redesigned of a Posix or Linux
> based kernel. It will only run only Pure Ada-83/95 recompled code
> (at the moment Ada-83/95 only).
>
> In <f7fk6i$agf$2@aioe.org>, Xianzheng Zhou <joe@lgsolutions.com.au> writes:
>> Just wonderring, is it possible to replace int.S and boot.S using ada
>> asm inline assembly instruction?
>>
>> Joe
>>
>> Wiktor Moskwa wrote:
>>> On 16.07.2007, Xianzheng Zhou <joe@lgsolutions.com.au> wrote:
>>>> In the example, int.S and boot.S are in assembly code. Is there a way to
>>>> write this part in Ada?
>>>>
>>> In boot.S you need a way to pass values of two registers (EAX and EBX)
>>> to the main procedure through stack - that's where Ada expects parameters.
>>> The code in int.S can't be put in procedures because interrupt handlers
>>> don't behave like procedures (stack frame has different format).
>>>
>>> If a compiler supported "bare x86" target it wouldn't probably be
>>> a problem. For example if you compile something for AVR microcontroler
>>> using AVR-GCC, interrupt handlers are ordinary blocks of code wrapped
>>> in special macros - all necessary assembly code is generated by the
>>> compiler.
>>>
>
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2007-07-17 9:15 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-07-15 13:55 Help writing ada booting kernel Xianzheng Zhou
2007-07-15 14:44 ` Wiktor Moskwa
2007-07-16 1:59 ` Xianzheng Zhou
2007-07-16 6:07 ` Wiktor Moskwa
2007-07-16 11:01 ` Xianzheng Zhou
2007-07-16 11:18 ` Xianzheng Zhou
2007-07-16 12:21 ` Wiktor Moskwa
2007-07-16 21:02 ` anon
2007-07-17 9:15 ` Xianzheng Zhou
2007-07-16 3:02 ` anon
2007-07-16 11:16 ` Xianzheng Zhou
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox