Ada Kalinda

From OSDev Wiki
Jump to: navigation, search

Contents

The Ada Kalinda OS

Brief history and initial objectives

This project dates back from the early 1990s.

A few years earlier computer science had seen two marked evolutions : the Macintosh and the Ada language. Both were, each in its own domain, new worlds.

Strangely, those two worlds were quickly disappearing in their initial form: - The purity of black and white Macintosh was rapidly superseded by more powerful various machines, color screens, new os versions. - Ada 83 stayed confined to some specialized area of high reliability software and twelve years later was "augmented" with Ada 95. This brought rare useful additions and a bunch of new possibilities which were more prone to degenerate the initial idea and the occasion of an added compiler complexity.

Being a Pascalist with a strong allergy to C, Ada 83 was a real wonder and a compiler performance at the time. The inside Macintosh four volumes documentation were a thorough description of the Mac Plus system. I then decided to see if rewriting a Mac Plus OS with Ada 83 was possible and brought some clarity and ease of software maintenance.

But at the time, Ada cross compiler were rare and costly, so that a rewriting of the OS began in fact in CodeWarrior Pascal. Several machines were used, as the dual PPC/i86 power pc, but development mainly progressed on a Mac LCIII with CodeWarriow Windows MetroNub to target an x86 pc. The project advanced up to a functional graphical interface and a start of usable file system. But the Pascal code was becoming very heavy to maintain for a single person and an interruption of the development showed that reinsertion in the project was rather difficult and the Pascal code not so easy to comprehend or read after some years.

Time passing, CodeWarrior tools and machines changing, cross development became more difficult and tentative of rewriting with gcc C was done which was quickly abandoned being an horror story in maintenance and reinsertion in source code.

Then Gnat appeared, and being a new Linux user I saw that version 3.15 built on GCC 2.81 could be used with its pragma "No_Run_Time" as a sort of "half cross-compiler" x86 Linux hosted and generating x86 binary executable on a bare x86 pc.

A few trials were positive but development was not using a gdb stub and disquettes transfer for execution tests were cumbersome. The boot code was written in this configuration with much pain and beeps and all sort of debugging tricks, those who tried know. Later I decided to use the Bochs emulator to test the binary, a vast improvement indeed.

The Gnat 3.15 being an Ada 95 compiler, and the appeal of novelty aiding, I took the old Code Warrior Pascal source an decided to rewrite with new objects programming possibilities. Rather than an improvement, it resembled a catastrophe, it proved that the new Ada was much more prone to spaghetti code than the Ada 83 and that the best option was to adhere as much as possible to Ada 83 programming which imposed more constraints but resulted in better structured and simpler code, so that return and reinsertion in source code was easier.

Finally, after many years of instructive trials, I converted the initial Pascal code in something as close as possible to Ada 83, with only the "regrettable forced use" of child packages. I would have been very glad to be an Ada 83 purist, but child packages really simplify the Macintosh like OS structure of Kalinda. Only with child packages is it possible to write a complete interface to system services and complete this universal application interface layer with a sub layer which uses the same partially hidden data structures and implements the system itself. Pure Ada 83 would force to duplicate source code for data structures introducing potential compatibility problems and complicating the maintenance of the software.


Present state of the affair : Kalinda 2018

It seems relatively few people are interested in using Ada 83 or (Ada 95 83 styled) in present developments, and OS development in Ada is rather rare. Ada Bare Bones project is one of the rare ones. Kalinda experiment could be of some use for Ada OSers as it has a peculiar ancient development path.

Kalinda 2018 uses the following development system :

- A recent gcc toolchain with gnat Ada compiler built on Ubuntu for host Linux X86-64 and targeted to i486-unknown-elf (gcc 7.3.0 with binutils 2.30).

- The NASM assembler used for historical reasons for assembling the boot block and the "amorce" which prepares flat memory, sets protected mode and jumps to Ada code.

- Two versions of the Bochs emulator, one compiled with internal debugger the other with gdb stub, executing for cpu: model=pentium.

- Geany editor/project file for launching compile/bind/link/make/run scripts.

The gcc/gnat compiler is configured with --enable-languages=ada --disable-libquadmath --disable-libada --disable-libssp and subsequently stripped to the strict minimum : the gcc / gnat_1, as, ld, gnatbind, gdb. All useless libraries/includes have been removed. All compilations are done without standard adalib/adainclude but with a very small set of custom RTS files. The aim is to have the minimal gcc toolchain : 7 files ; 196 Mb (not so bad).

The principle of the whole thing is relatively simple :

Every Ada module is compiled in an object .o with suitable restrictions in a gnat.adc pragma configuration file so that Gnat RTS is not used and some rare compiler calls caught by the small custom "RTS".

The project is bound (elabs sequencing and program launch) in an ada_main with -nostdlib -nostdinc --RTS=... and compiled in .o.

The linker takes all .o planned in .ld script, with the boot_block.bin placed in head position, and produces a binary file the size of a 1.44 disquette which can be directly booted as a hard disk by Bochs. This process take the place of a ROM filling.

The boot block has the simple task of copying 9 64Kb segments (576Kb) from the binary file/hard_disg_img in the low pc memory space between 0x10000 and the 0xA0000 video buffer. This memory space contains system services which were in Macintosh ROM. This means that Kalinda system "ROM" code is limited to 576 Kb (very happy with it, Mac plus ROM was 128 Kb).

The system then uses RAM memory after the 1Mb pc low memory (Mac like memory manager "zoning" begins at 0x10_0000).


Git'ed source code

For curious OSers, Kalinda was CVS hosted since 2002 on SourceForge and Kalinda 2018 code has been Git'ed there The pieces of the development system are available in the "Files" section of the project (except Bochs run system)

To avoid unpleasant experience, note that the source code uses 20 spaces tabulations, so tell your favorite editor to set tabs every 20 spaces (in Geany config section "indentation" : indent_width=20).

After experimenting various text formatting, I settled on "horizontal" layout so that modules routines are all visible at first glance (as much as possible). In such a layout, tabs are nearly compulsory. I do not like gnat formatting which is too vertical and lengthy.

Printing with enscript / Oxygen font forge derived 5 points bold font gives 160 columns of small but legible characters ans most interfaces modules specs take 2 pages only (private part on verso). Also enscript section 2 separates the comments which are after column 160.

(In march 2018, the Macintosh desk and menu bar are drawn, and menus unroll, but file system is not operative because of floppy driver rewriting, so double click on the trash crash ! )

Personal tools
Namespaces
Variants
Actions
Navigation
About
Toolbox