comp.lang.ada
 help / color / mirror / Atom feed
* FreeDOS, Janus/Ada and GNAT
@ 2019-07-04  9:04 joakimds
  2019-07-04 13:09 ` joakimds
  2019-07-05 20:09 ` Randy Brukardt
  0 siblings, 2 replies; 5+ messages in thread
From: joakimds @ 2019-07-04  9:04 UTC (permalink / raw)


FreeDOS is an open source implementation of MS-DOS and in June 2019 celebrated 25 years in existence. In it there is an application called DIMPLES that is the package manager for FreeDOS. DIMPLES is like pip for Python, apt (aptitude) for Debian systems, and so on. To compile Ada applications in FreeDOS one can use the DJGPP compiler which is a port of gcc (GNAT) to FreeDOS (and one can use DIMPLES to install it if it is not already installed). It works well except that it cannot create an executable from Ada code that uses tasks. So if one wants to make Ada applications for FreeDOS there can be no tasking. This has to do with how tasking in GNAT is implemented. On Windows, Mac OS X and Linux the tasks are
mapped in a one-to-one correspondance to OS-threads (at least my understanding).
FreeDOS does not support or provide threads and is a single thread/task operating system. It has therefore not been a trivial exercise to port the standard GNAT-Runtime support for tasks to FreeDOS.

There is another Ada compiler called Janus/Ada where tasks are not mapped by the Ada-Runtime to OS-threads and an Ada application built with Janus/Ada is effectively a single thread application no matter how many tasks are used in the Ada code. Considering the task implementation by Janus/Ada, it sounds like a perfect fit for FreeDOS. Of course Janus/Ada produces win32 applications and not DOS application but there is a DOS Extender called HX DOS which can execute many win32 applicatins on FreeDOS. Trying it out reveals that there are three win32 calls which HX DOS could not emulate:

import not found: InitializeSListHead
import not found: GetModuleHandleExW
import not found: FindFirstFileExW

If HX DOS could be extended to emulate these calls then Janus/Ada can *probably* be used to build multi-task executables for FreeDOS. Jim Hall (creator of the FreeDOS project) wrote in April 2009 on the subject of multi-tasking in DOS:
"People sometimes ask me what I'd love to see in a future version of DOS.
I would like to see some level of running multiple applications at once.
...
True multitasking would be ideal, but I'd be happy if we supported
the simpler "task switching" - this would be a huge leap forward for FreeDOS.
..."

One area where FreeDOS can be used today is in embedded systems (and it has been used there). The implementation of FreeDOS requires the CPU to be x86 and many embedded systems are nowadays ARM based (which rules out FreeDOS). Any known hard-ware vendors where it is known one can run FreeDOS?

To summarize: It is possible today to use the DJGPP (GNAT) compiler to develop single task applications on FreeDOS. It is *almost* possible to run multi-task Ada applications on FreeDOS using the Janus/Ada compiler. AdaCore may have an Ada-Runtime that can support tasking on FreeDOS, but outside the scope of what I know.

Best regards,
Joakim


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: FreeDOS, Janus/Ada and GNAT
  2019-07-04  9:04 FreeDOS, Janus/Ada and GNAT joakimds
@ 2019-07-04 13:09 ` joakimds
  2019-07-05 20:09 ` Randy Brukardt
  1 sibling, 0 replies; 5+ messages in thread
From: joakimds @ 2019-07-04 13:09 UTC (permalink / raw)


> One area where FreeDOS can be used today is in embedded systems (and it has been used there). The implementation of FreeDOS requires the CPU to be x86 and many embedded systems are nowadays ARM based (which rules out FreeDOS). Any known hard-ware vendors where it is known one can run FreeDOS?
>

Here is a board with a single core x86 CPU that according to the hardware vendor supports DOS, Windows and Linux:
https://www.cnx-software.com/2013/11/27/39-86duino-zero-is-an-x86-arduino-compatible-board-that-supports-dos-windows-and-linux/


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: FreeDOS, Janus/Ada and GNAT
  2019-07-04  9:04 FreeDOS, Janus/Ada and GNAT joakimds
  2019-07-04 13:09 ` joakimds
@ 2019-07-05 20:09 ` Randy Brukardt
  2019-07-08 12:47   ` joakimds
  1 sibling, 1 reply; 5+ messages in thread
From: Randy Brukardt @ 2019-07-05 20:09 UTC (permalink / raw)


<joakimds@kth.se> wrote in message 
news:1ddb4817-8bb0-4cc4-9653-de12f8a746d6@googlegroups.com...
>FreeDOS is an open source implementation of MS-DOS and in June 2019 
>celebrated 25 years in existence.

...
>There is another Ada compiler called Janus/Ada where tasks are not mapped 
>by the
>Ada-Runtime to OS-threads and an Ada application built with Janus/Ada is 
>effectively
>a single thread application no matter how many tasks are used in the Ada 
>code.
>Considering the task implementation by Janus/Ada, it sounds like a perfect 
>fit for
>FreeDOS.

>Of course Janus/Ada produces win32 applications and not DOS application ...

The MS-DOS version of Janus/Ada 83 is still available (mainly because we 
mass-produced those and there are a number of cartons of them still here). 
Of course, using that would either require reading floppies or me spending 
some time to copy the floppies onto a CD. (The serialization scheme used for 
those expects to be able to modify the installation media, so one cannot 
make a master CD for everyone without replacing the instaaller -- which 
seems like too much work for this obsolete product.)

We also had a version for DOS extenders available until the mid-2000s. With 
sufficient interest, that could be ported to FreeDOS or possibly the last 
version (3.1.1d) could be used (with similar issues with the installer). 
Dunno what the 32-bit API for FreeDOS looks like; we supported the Pharlap 
DOS Extender along with another one that we used to distribute with the 
compiler.

.. > but there is a DOS Extender called HX DOS which can execute many win32
>applicatins on FreeDOS. Trying it out reveals that there are three win32 
>calls
>which HX DOS could not emulate:
>
>import not found: InitializeSListHead
>import not found: GetModuleHandleExW
>import not found: FindFirstFileExW

I can't find any evidence that any of these are used in the Janus/Ada 
runtime or by the Janus/Ada compiler.

We use FindFirstFileA; it's possible that is implemented in terms of 
FindFirstFileExW, but it seems odd that's not available. Similarly, we use 
GetModuleHandleA; again, it's possibly implemented in terms of 
GetModuleHandleExW, but it seems necessary to some version of 
GetModuleHandle to exist.

The first one I have no idea what it is. The Microsoft document doesn't help 
much on that, saying it is "for system use only".

It's conceivable I guess that something in the Microsoft SDK uses these 
things (I have no idea what that would be or why it is getting added).

>If HX DOS could be extended to emulate these calls then Janus/Ada can 
>*probably*
>be used to build multi-task executables for FreeDOS.

Certainly the MS-DOS version of Janus/Ada supported that, and I would be 
rather surprised if it didn't work on more recent compilers. The Win32 
version does a few odd things vis-a-vis memory management to get around 
Windows limitations on the use of the stack, but otherwise it should pretty 
vanilla.

                                                          Randy.



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: FreeDOS, Janus/Ada and GNAT
  2019-07-05 20:09 ` Randy Brukardt
@ 2019-07-08 12:47   ` joakimds
  2021-01-01 21:41     ` Joakim Strandberg
  0 siblings, 1 reply; 5+ messages in thread
From: joakimds @ 2019-07-08 12:47 UTC (permalink / raw)


Thanks for taking a look Randy and provide feedback.

I have used Ghidra (https://ghidra-sre.org/) to disassemble the win32 executable and come to the conclusion that InitializeSListHead, GetModuleHandleExW and FindFIrstFileExW are indeed not only referenced in the executable but they are called some time during the life-time of the application.

Ghidra not only gives an assembly code version of the source code but also a C programming language version. One can see for example how GetModuleHandleExW is used:
...
BOOL BVar1;
HMODULE local_8;

local_8 = (HMODULE) 0x0;
BVar1 = GetModuleHandleExW(0,L"mscoree.dll",&local_8);
...

I haven't been able to determine the origin of the code but this is as far as I have investigated. Will write in this thread when I know more on the subject of FreeDOS and possibilites of embedded systems on it.

Best regards,
Joakim

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: FreeDOS, Janus/Ada and GNAT
  2019-07-08 12:47   ` joakimds
@ 2021-01-01 21:41     ` Joakim Strandberg
  0 siblings, 0 replies; 5+ messages in thread
From: Joakim Strandberg @ 2021-01-01 21:41 UTC (permalink / raw)



To reopen this issue. The imports missing

import not found: InitializeSListHead
import not found: GetModuleHandleExW
import not found: FindFirstFileExW 

has been added to the HX DOS Extender and can be found in the prerelease 2.19 pre5 (28:th of December 2020):
https://github.com/Baron-von-Riedesel/HX/releases

With the missing imports added it is not only possible to run C applications built with Visual Studio 2015, 2017 and 2019 on Freedos using the HX Dos Extender but also possible to run Ada applications built with the Janus/Ada compiler 3.2.1. One alternative to run Ada applications in DOS would be to use an older version of Janus/Ada that only supports Ada83, but with the latest version of the HX DOS Extender (at the time of this writing) it is possible to use the latest version of Janus/Ada to make multi-task DOS applications.

I have successfully executed an Ada application on Freedos that had four tasks in the source code. This is the result of my R&D work during the Christmas of 2020.

Best regards,
Joakim

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-01-01 21:41 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-04  9:04 FreeDOS, Janus/Ada and GNAT joakimds
2019-07-04 13:09 ` joakimds
2019-07-05 20:09 ` Randy Brukardt
2019-07-08 12:47   ` joakimds
2021-01-01 21:41     ` Joakim Strandberg

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