<?xml version="1.0" encoding="UTF-8" ?>

<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
	<channel>
			<title>Archeia Feed</title>
			<link>http://www.archeia.com/rss_feed.html</link>
			<description></description>
			<language>en</language>
			<copyright>Copyright (C) 2008 Luke A. Guest</copyright>
			<ttl>120</ttl><item>  <title>Getting the Samsung YP-P2 working with Ubuntu Gutsy</title>  <link>http://www.archeia.com/getting-the-samsung-yp-p2-working-with-ubuntu-gutsy.html</link>  <description><![CDATA[ <h2>Getting the Samsung YP-P2 working with Ubuntu Gutsy</h2>

<p>I have no idea what happened yesterday when I charged it, it charged for only a few minutes then the led turned to green (meaning it's finished) yet there was virtually no charge on the battery indicator.</p>

<p>I charged it last night and it's now at full charge, so I'm happy at the moment.</p>

<p>Ubuntu Gutsy (7.10) provides the right packages to get MTP devices working, just not the right versions for the P2. To get it working somebody has put up a <a href="http://www.anythingbutipod.com/forum/showthread.php?p=213505" title="MTP mode in Ubuntu Gutsy Gibbon">repository of packages with the right versions</a> up, install these as per the instructions. These packages also add the /etc/udev/rules.d/libmtp7.rules file which has the correct line for the P2.</p>

<p>To mount the player in Gutsy, do the following:</p>

<ol>
  <li>Install mtpfs (as in the above link).</li>
  <li>Uncomment the <i>user_allow_other</i> line in the <i>/etc/fuse.conf</i> so that any user can mount the player.</li>
</ol>

<pre class="Bash">
<dfn>Bash code</dfn>
<code>$ mkdir ~/YP-P2
$ mtpfs -o allow_other ~/YP-P2/</code>
</pre>

<p>To unmount the player type:</p>

<pre class="Bash">
<dfn>Bash code</dfn>
<code>$ fusermount -u ~/YP-P2</code>
</pre>

<p>I've noticed that if RhythmBox has been started you can't use mtpfs at the same time.</p>

<h3>Upgrading the firmware</h3>

<p>Samsung have made this is a complete doddle to do, mount the P2, and copy over the 2 firmware files to the root of the device, unmount, remove the USB cable (I don't know if this is really necessary) and then reboot. On the first boot, it'll upgrade one of the files and shut down. Power it back up and it'll upgrade the next one and shut down again. Power on for the third time and all should be upgrded to the new firmware. Mine is now running the new <a href="http://www.advancedmp3players.co.uk/shop/newsdesk_info.php?newsdesk_id=100" title="Bluewave 2 firmware">Bluewave 2 firmware</a>. Or you can see <a href="http://www.yjzone.net/showthread.php?t=1938" title="Upgrading the Samsung YP-P2 firmware">screenshots of the upgrade</a>.</p>

<h3>Getting the cover art to work</h3>

<p>This took me about 2 hours to work out during which I tried all sorts of packages. Easytag doesn't work, it embeds it, but the P2 cannot read it. I couldn't work out Amarok, so that was out. Finally, I tried kid3 and it worked first time! Basically, you select all the files that you want to have the same image, add a new tag (APIC), set the encoding (UTF8), the mimetype (image/jpeg), picture type (front cover) and description (the filename in this case) and import the file into kid3. Select <b>OK</b> and then save all the files to disk. Easy as that!</p>

<h3>Playlists</h3>

<p>My success with these has been patchy really, most of the time I copy a playlist (in m3u format) to the P2 (using mtpfs, as this is supposed to convert to the native playlist format when the file is copied), I can't unmount the player (it says the device is busy). Killing mtpfs works, I can then unmount, but the playlist isn't copied across, the P2 states that it is empty. I've managed to copy a playlist over twice so far, but patchy it is.</p>

<div class="center article_banner">
<script type="text/javascript"><!--
google_ad_client = "pub-1197956670848234";
//468x60 - image full banner - articles
google_ad_slot = "3640510725";
google_ad_width = 468;
google_ad_height = 60;
//--></script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</div>


<a name="comments"></a>








 ]]></description>  <pubDate>Wed, 13 Feb 2008 06:47:54 -0500</pubDate>  <guid isPermaLink="false">http://www.archeia.com/getting-the-samsung-yp-p2-working-with-ubuntu-gutsy.html</guid>  <dc:creator>Archeia</dc:creator>   </item> 
<item>  <title>Deciding on a new MP3 player</title>  <link>http://www.archeia.com/deciding-on-a-new-mp3-player.html</link>  <description><![CDATA[ <h2>Deciding on a new MP3 player</h2>

<p>I've had an Xclef MT-500 for about 5 years now, but it has a number of problems:</p>

<ul>
  <li>The battery life is crap and I have to carry around a number of spares.</li>
  <li>internal memory can corrupt easily.</li>
  <li>There are no more firmware updates, and these can easily go wrong causing a broken player.</li>
</ul>

<p>The things it got right though were:</p>

<ul>
  <li>The provision of an SD card slot, although no-one seems to know what size limit it has.</li>
  <li>Has an FM radio.</li>
</ul>

<p>So, I started to look for a new MP3 player this week. Although the <a href="http://www.paidonresults.net/c/13721/FM39/39/0/shop/product_info.php?products_id=2597" onmouseover="window.status='http://www.advancedmp3players.co.uk/';return true;" title="Apple iPod nano 4GB MP3 Player" onmouseout="window.status=' ';return true;">Apple iPod nano 4GB MP3 Player's</a> are very sexy, they're still too much style over substance in my opinion. So, these have been ruled out.</p>

<p>I would prefer a player I can upgrade the memory of, but given that these things are such a commodity these days, it's very unlikely that I'd find one that was SD card (or similar) only. I did find the <a href="http://www.paidonresults.net/c/13721/FM39/39/0/shop/product_info.php?products_id=2281" title="COWON iAudio D2 Personal Media Player" onmouseover="window.status='http://www.advancedmp3players.co.uk/';return true;" onmouseout="window.status=' ';return true;">iAudio D2 2GB MP3 Player</a> and although it does have the SD card, for the price, I think it's a bit expensive.</p>

<p>I then found the <a href="http://www.paidonresults.net/c/13721/FM39/39/0/shop/product_info.php?products_id=2689" title="Samsung YP-P2 8GB Bluetooth Portable Media Player" onmouseover="window.status='http://www.advancedmp3players.co.uk/';return true;" onmouseout="window.status=' ';return true;">Samsung YP-P2 8GB Bluetooth Portable Media Player</a> which is slightly bigger than an iPOD Nano, but has a radio, plays films too (whether I'll use these features is unknown at this time though). But then, after a bit of searching on the net, I find that there is a 16GB version coming out, when? I've no idea. Also, a possibility of a dock with a mini-SD card slot in it (although a lot of people think it's a fake). So, if these 2 things pan out, I'm probably going to buy one of these.</p>

<p>I've found that this device can be <a href="http://jocohp.hu/?o=user_post&amp;id=58&amp;l=1" title="Using the Samsung YP-P2 on Linux">used on Linux</a>.</p>

<div class="center article_banner">
<script type="text/javascript"><!--
google_ad_client = "pub-1197956670848234";
//468x60 - image full banner - articles
google_ad_slot = "3640510725";
google_ad_width = 468;
google_ad_height = 60;
//--></script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</div>


<a name="comments"></a>








 ]]></description>  <pubDate>Sun, 10 Feb 2008 11:35:12 -0500</pubDate>  <guid isPermaLink="false">http://www.archeia.com/deciding-on-a-new-mp3-player.html</guid>  <dc:creator>Archeia</dc:creator>   </item> 
<item>  <title>Burn out</title>  <link>http://www.archeia.com/burn-out.html</link>  <description><![CDATA[ <h2>Burn out</h2>

<p>I know I've been suffering from this for the past 3 years; basically, since I left my last programming job. I had actually been suffering during the time I was there, for at least 2 years really. I should've left a year after being there like I was going to. Ideally, I never should've taken the job in the first place, but it seemed like such a good job at the time. Hindsight's a wonderful thing!</p>

<p>Anyways, I keep trying to work on projects that I have always wanted to do and I keep failing because I just can't get motivated. The idea of working on something <i>cool</i> just doesn't seem to be enough. So, I thought I'd do a quick search and see what <a href="http://en.wikipedia.org/wiki/Burnout_(psychology)" title="Burn out" target="blank">burn out really is</a>. I've read through the article and quite surprised to find that I recognise all of those traits, oh well.</p>

<p>I honestly can't cope with this when I really want to be working on stuff again. How long does this last? Anybody else experience this? Maybe I just need to get out more?</p>

<div class="center article_banner">
<script type="text/javascript"><!--
google_ad_client = "pub-1197956670848234";
//468x60 - image full banner - articles
google_ad_slot = "3640510725";
google_ad_width = 468;
google_ad_height = 60;
//--></script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</div>


<a name="comments"></a>







 ]]></description>  <pubDate>Sat, 02 Feb 2008 09:22:27 -0500</pubDate>  <guid isPermaLink="false">http://www.archeia.com/burn-out.html</guid>  <dc:creator>Archeia</dc:creator>   </item> 
<item>  <title>The Ada Microkernel Project (or TAMP): The plan</title>  <link>http://www.archeia.com/the-ada-microkernel-project-or-tamp-the-plan.html</link>  <description><![CDATA[ <h2>The Ada Microkernel Project (or TAMP): The plan</h2>

<p>Following on from my <a href="an-ada95-hello-world-style-kernel.html" title="Hello world style kernel">hello world style kernel</a>, I've decided to post a plan for what I intend to accomplish in regards to an OS design.</p>

<p>I've been thinking about OS designs for over 10 years on and off and have wanted to develop one. Originally, I was going to do it in C but as I now use Ada more and more I want to use this language for the implementation (and assembly where necessary). The main thing that has been stopping me from developing an OS is the thought that I didn't really know how to. I pretty much know the basics of the underlying core of an OS, e.g. setting up interrupts, memory management, etc. so that is, at least, a starting point.</p>

<p>So, here's the plan; develop a microkernel based OS using Ada. This <i>OS</i> should provide a microkernel, some basic services and be able to run some applications. I'm not aiming to provide a full OS, just something to learn from. I'm also not going to be trying to implement POSIX, it'll be something else entirely.</p>

<h4>Targets</h4>

<p>I intend for the OS to be portable to other architectures and it should be capable of being compiled for big-endian <i>and</i> little-endian machines. I'll also be aiming to provide versions for both 32-bit and 64-bit architectures.</p>

<p>This might seem a bit excessive, but I believe that the OS designer should start thinking about making their OS cross platform from the outset. Here is a list of the tools I will use:</p>

<ul>
  <li>binutils-2.18</li>
  <li>GCC/GNAT-4.2.2</li>
  <li>NewLib (latest version from CVS)</li>
  <li>GNU Make (standard Ubuntu version is fine)</li>
  <li>QEMU (latest version from CVS)</li>
  <li>GRUB 2 (there's a problem with GRUB 1 segfaulting on my Ubuntu and the GRUB developers are only interesting in talking/helping with GRUB 2)</li>
</ul>

<p>These tools will be available on all Linux and Win32 platforms. I'm not too sure about MacOS X, I'm fairly sure that they have the GNU tools available, they definitely have GNAT. I'll be using Ubuntu Linux and compiling my own toolchain. I'll also be attempting to port a minimal Ada runtime so I can have full GNAT tool support (including ASIS) and I will be showing the build process of each relevant component.</p>

<p>The QEMU emulator provides a number of system targets:</p>

<ul>
  <li>ia32 (PC)
    <ul>
      <li>Little-endian</li>
      <li>32-bit</li>
      <li>Hardware TLB</li>
    </ul>
  </li>
  <li>amd64 (PC)
    <ul>
      <li>Little-endian</li>
      <li>64-bit</li>
      <li>Hardware TLB</li>
    </ul>
  </li>
  <li>MIPS (Malta board)
    <ul>
      <li>Endian switchable by running different emulators. On real hardware this is done when executing the kernel.</li>
      <li>32/64-bit</li>
      <li>Software TLB</li>
    </ul>
  </li>
</ul>

<p>QEMU provides these targets and this should keep me going for a while anyway. Also, by showing how to do memory managment using a software MMU I'll get more experience as will the reader.</p>

<p>I also forgot to mention, that apart from being different hardware, they'll also provide interesting challenges regarding the booting environment.</p>

<div class="center article_banner">
<script type="text/javascript"><!--
google_ad_client = "pub-1197956670848234";
//468x60 - image full banner - articles
google_ad_slot = "3640510725";
google_ad_width = 468;
google_ad_height = 60;
//--></script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</div>


<a name="comments"></a>








 ]]></description>  <pubDate>Sun, 13 Jan 2008 05:10:08 -0500</pubDate>  <guid isPermaLink="false">http://www.archeia.com/the-ada-microkernel-project-or-tamp-the-plan.html</guid>  <dc:creator>Archeia</dc:creator>   </item> 
<item>  <title>Site template enhancements</title>  <link>http://www.archeia.com/site-template-enhancements.html</link>  <description><![CDATA[ <h2>Site template enhancements</h2>

<p>After playing with Google AdSense and Amazon Affiliate code, I found that the size of the template was just wrong, so I've gone through and made it slightly wider. This allows for full size banners and more text in the width of the page, which I think is a bit nicer.</p>

<p>I also found that there were a few problems with IE6 (as per usual) so these have been fixed as far as I can possibly fix them.</p>

<p>Also, you'll note the styling on the tag cloud to the left, this is much nicer design-wise and also the line-height has been increased as IE6 (again) decided to render the text too close together.</p>

<p>Finally, I've added the Amazon e-store. This is a real pain as Amazon in their infinite wisdom only provide:</p>

<ol>
  <li>a direct link to the store on their site, or</li>
  <li>a frameset to embed the store into your own site, or</li>
  <li>an iframe (which is what I've used) to embed the store into you own site.</li>
</ol>

<p>Now because of this, you have to either set the iframe to scroll if it gets too big or make the frame tall enough to handle lots of data. Why can't they provide an API so we can do what we want with it and not use a frame?</p>

<p>Finally, I fixed that damned date problem I was having way back <a href="why-is-modx-showing-the-wrong-date.html" title="MODx date display problem">when</a>.</p>

<div class="center article_banner">
<script type="text/javascript"><!--
google_ad_client = "pub-1197956670848234";
//468x60 - image full banner - articles
google_ad_slot = "3640510725";
google_ad_width = 468;
google_ad_height = 60;
//--></script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</div>


<a name="comments"></a>







 ]]></description>  <pubDate>Sat, 12 Jan 2008 10:58:46 -0500</pubDate>  <guid isPermaLink="false">http://www.archeia.com/site-template-enhancements.html</guid>  <dc:creator>Archeia</dc:creator>   </item> 
<item>  <title>Amazon affiliate scheme</title>  <link>http://www.archeia.com/amazon-affiliate-scheme.html</link>  <description><![CDATA[ <h2>Amazon affiliate scheme</h2>

<p>As you can probably tell, I've been playing with the Amazon Affiliation links and have found that:</p>

<ul>
  <li>Most of them just don't fit on this site because their size.</li>
  <li>They're not customisable in regards to their size like I thought they might be.</li>
  <li>The optimised links don't seem to provide a close enough match to the content of the pages, oh well.</li>
  <li>Ths shop is too bloody wide for this site!</li>
  <li>It'd also be nice to customise the e-store links to a particular category or product as well.</li>
</ul>

<p>So, all in all, I'm not that pleased with it so far, I expected so much more. Looks like I'm going to have to go back into the templates and modify them, which I hate doing.</p>

<p>I'll continue to look into it and see what I can find, maybe I can find some scripting API for it, that might be better.</p>

<div class="center article_banner">
<script type="text/javascript"><!--
google_ad_client = "pub-1197956670848234";
//468x60 - image full banner - articles
google_ad_slot = "3640510725";
google_ad_width = 468;
google_ad_height = 60;
//--></script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</div>


<a name="comments"></a>








 ]]></description>  <pubDate>Fri, 11 Jan 2008 09:23:55 -0500</pubDate>  <guid isPermaLink="false">http://www.archeia.com/amazon-affiliate-scheme.html</guid>  <dc:creator>Archeia</dc:creator>   </item> 
<item>  <title>Samurai programming?</title>  <link>http://www.archeia.com/samurai-programming.html</link>  <description><![CDATA[ <h2>Samurai programming?</h2>

<p>I've just been reading an Ada blog and found a link to <a name="split"></a> <a href="http://www.wilshipley.com/blog/2005/02/free-programming-tips-are-worth-every.html" title="Tips every programmer should know">a number of programming tips</a> which really should be adhered to by all programmers and managers should read it so they don't get on programmer's backs causing more stress.</p>

<div class="center article_banner">
<script type="text/javascript"><!--
google_ad_client = "pub-1197956670848234";
//468x60 - image full banner - articles
google_ad_slot = "3640510725";
google_ad_width = 468;
google_ad_height = 60;
//--></script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</div>


<a name="comments"></a>








 ]]></description>  <pubDate>Thu, 10 Jan 2008 11:36:30 -0500</pubDate>  <guid isPermaLink="false">http://www.archeia.com/samurai-programming.html</guid>  <dc:creator>Archeia</dc:creator>   </item> 
<item>  <title>Professors Slam Java As &quot;Damaging&quot; To Students</title>  <link>http://www.archeia.com/professors-slam-java-as-damaging-to-students.html</link>  <description><![CDATA[ <h2>Professors Slam Java As "Damaging" To Students</h2>

<p>Just posted on SlashDot.com is an article outlining the problems with <a name="split"></a>  <a href="http://developers.slashdot.org/article.pl?sid=08/01/08/0348239&amp;from=rss" title="Teaching Java as a first programming language is damaging the future software engineer">teaching Java as a first language</a> for CS students. I can relate to this as my uni decided to change from Ada95 to Java during the second year, this was interesting at the time, but Java had only just come out and I didn't know anything about the language at the time. I can now see it's problems. In retrospect I think my uni was just jumping on the Java bandwagon. In a way there was some foresight in this as there are now a lot of jobs in industry for Java programmers, mostly banking but even some real-time (I have no idea how well this works).</p>

<p>Let's face it:</p>

<ol>
  <li>You really should have programmed before doing a CS degree anyway, but these courses do actually go through the A-level CS stuff in the first year anyway.</li>
  <li>Teaching Java is a bad idea as a first language as it doesn't touch on pointers and this is necessary for understanding the hardware (later courses will go into this).</li>
  <li>Teaching C or C++ isn't a good idea either considering it teaches really bad programming habits that are hard to get out of later on. Yes, I was a C/C++ programmer before Ada.</li>
  <li>If anyone is thinking about it, don't teach VB as a first language either, cos it's crap, half the time it works, type in the same program and it might just work the second time. This has been my experience!</li>
</ol>

<p>In my CS course they tried to teach Haskell (a functional language) and PROLOG (logic) and they failed miserably. The guy <i>teaching</i> functional programming wasn't a lecturer, didn't like lecturing and lets face it was crap at it. He took a tape recorder into the lecture as back up just in case anyone complained about the course; which they did. The guy taking the PROLOG course was actually the head of department and was Italian, not the best English speaker in the world and didn't like teaching undergraduates. PROLOG isn't the easiest language to get to grips with, but if the lecturer can't speak English that well, he's got no chance.</p>

<p>Also that article mentions formal methods, they taught us discrete maths and Z, I got to the point where I could read Z (ish), but couldn't write a spec in it to save my life. Also, the formal methods used later were an extension of this but without the Z notation (just set theory really) and relating this to actual programming practice is difficult. Let's just say, I didn't really find it easy and subsequently never used it. In industry, it's unlikely students will ever use it either.</p>

<p>Now, unfortunately, having been out of programming for a few years after total burn out I can't say my maths is the best and I've no idea if I'll ever get back to where I was when I was at uni, so I can't say if I'll ever touch a functional language again or even formal methods. Oh well.</p>

<div class="center article_banner">
<script type="text/javascript"><!--
google_ad_client = "pub-1197956670848234";
//468x60 - image full banner - articles
google_ad_slot = "3640510725";
google_ad_width = 468;
google_ad_height = 60;
//--></script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</div>


<a name="comments"></a>








 ]]></description>  <pubDate>Wed, 09 Jan 2008 11:34:04 -0500</pubDate>  <guid isPermaLink="false">http://www.archeia.com/professors-slam-java-as-damaging-to-students.html</guid>  <dc:creator>Archeia</dc:creator>   </item> 
<item>  <title>An Ada95 &quot;hello world&quot; style kernel</title>  <link>http://www.archeia.com/an-ada95-hello-world-style-kernel.html</link>  <description><![CDATA[ <h2>An Ada95 "hello world" style kernel</h2>

<p>Conversations on #Ada keep coming back to operating systems and their kernels so I decided to dig out some code I wrote in 2000 and get it working again. I intended this code to be the basis of <a href="an-operating-system-design.html" title="a microkernel written in Ada">a microkernel written in Ada</a>. The code presented here is a second attempt at using the latest version of GNAT (4.2.2) and binutils (2.18) as the first time I just couldn't get it working properly.</p>

<p>Unlike other OSes that have been written in Ada like MarteOS, RTEMS, AdaExpOS (a more full featured test kernel), I wanted to get it working using no Ada runtime, which is quite tricky. These other compilers seem to have a full runtime as they use the host's native port of the compiler and just add the <i>-nostdlib</i> flag when compiling. This isn't exactly the best way forward as you won't actually have this when targeting bare hardware.</p>

<p>Also, I didn't want to go the route of porting the Ada runtime to bare hardware - this is what other Ada OS developers do, which makes sense for specific targets, i.e. a robot in a manufacturing plant or a guided missile, but not for a general purpose OS.</p>

<p>It is possible to build GNAT so that there is no runtime installed. This is called the "Zero Foot Print" runtime which has to be configured from the <b>system.ads</b> package which needs to be modified. The configuration options that are in the private part of the system.ads package are documented in the <b>targparm.ads</b> package in the GNAT distribution.</p>

<p>Further to modifying the system package, we need to provide restrictions in the <b>gnat.adc</b> file. These restrictions are supplied using the Ada 2005 <i>pragma Restrictions</i> directive. There used to be <i>pragma No_Run_Time</i> but this is deprecated now, although I've heard it still works. So, even though the source provided is Ada95 it should be possible to compile it using an Ada95 compiler and using a different <b>gnat.adc</b> file.</p>

<p>The following commands will configure a basic compiler and other tools required.</p>

<pre class="Bash">
<dfn>Bash code</dfn>
<code>$ cd &lt;to somewhere on disk&gt;
$ mkdir -p build-binutils-2.18 build-gcc-4.2.2
$ tar -xjvpf binutils-2.18.bz2
$ tar -xjvpf gcc-core-4.2.2.bz2
$ tar -xjvpf gcc-ada-4.2.2.bz2
$ cd build-binutils-2.18
$ ../binutils-2.18/configure --prefix=$HOME/opt/cross-gcc \
    --target=i386-elf --host=x86_64-pc-linux \
    --build=x86_64-pc-linux --disable-nls \
    2>&amp;1|tee config.log
$ make
$ make install
$ export PATH=$HOME/opt/cross-gcc/bin:$PATH
$ cd ../build-gcc-4.2.2
$ ../gcc-4.2.2/configure --prefix=$HOME/opt/cross-gcc \
    --target=i386-elf --host=x86_64-pc-linux \
    --build=x86_64-pc-linux --disable-nls \
    --enable-languages=c,ada --without-headers \
    2>&amp;1|tee config.log
$ make all-gcc
$ make install-gcc</code>
</pre>

<p>You may need to change your <i>--host</i> and <i>--build</i> options to reflect what your host machine is, you may not even need them. I've added them as Ubuntu doesn't define the platform properly.</p>

<p>Now you have the compiler and tools installed you can build my test kernel by downloading it from below and extracting it somewhere, just type the following:</p>

<pre class="Bash">
<dfn>Bash code</dfn>
<code>$ tar -xzvpf multiboot.tgz
$ cd multiboot
$ make qemu</code>
</pre>

<p>As long as you have qemu installed somewhere, this will build a boot floppy and boot into GRUB. For some reason, it doesn't pick up the menu, so when booted type the following to get the menu:</p>

<pre class="Bash">
<dfn>GRUB commands</dfn>
<code>$ configfile /boot/grub/menu.lst</code>
</pre>

<p>As it stands, I'm not sure that restricting the runtime to zero footprint is the right approach. I think that providing a very limited runtime is the best way forward. This way, the kernel developer has access to aggregates, 'Image attribute (useful for debugging) and other features. Obviously it makes no sense to allow tasking or even exceptions (as far as I can see).</p>

<p><a href="assets/files/os/tutorials/multiboot.tgz" title="Download the source to my simple kernel">Download multiboot.tgz</a></p>

<div class="center article_banner">
<script type="text/javascript"><!--
google_ad_client = "pub-1197956670848234";
//468x60 - image full banner - articles
google_ad_slot = "3640510725";
google_ad_width = 468;
google_ad_height = 60;
//--></script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</div>


<a name="comments"></a>








 ]]></description>  <pubDate>Fri, 04 Jan 2008 06:07:39 -0500</pubDate>  <guid isPermaLink="false">http://www.archeia.com/an-ada95-hello-world-style-kernel.html</guid>  <dc:creator>Archeia</dc:creator>   </item> 
<item>  <title>Persistence makes you capable</title>  <link>http://www.archeia.com/persistence-makes-you-capable.html</link>  <description><![CDATA[ <h2>Persistence makes you capable</h2>

<p>During my research of operating systems kernels, I got side tracked towards security mechanisms in operating systems and their kernels. Obviously, I'd heard of the usual 2:</p>

<ol>
  <li>Access Control Lists (ACL's), and</li>
  <li>Capabilities.</li>
</ol>

<p>ACL's are used in most OSes due to being easy to implement, and I had no idea how to implement capabilities, so I thought I'd try and research them. Seems they're incredibly hard to understand unless you're one of these research type people who spend their days writing in bizarre mathematical notation and dream in <a href="http://en.wikipedia.org/wiki/Z_notation" title="A formal mathematical language for defining software">Z</a>!</p>

<p>Whilst on IRC, I did go into the <a href="http://www.freenode.net" title="An IRC network">#erights channel on Freenode</a> and talk to the guys there who did essentially say that an object-oriented OS is basically a capability OS. They were saying that by holding onto a capability, a process has the right to access whatever that capability points to.</p>

<p>Now, from what I understand, the kernels like <a href="http://www.eros-os.org" title="An Object-Oriented persistent microkernel">EROS</a> and <a href="http://www.coyotos.org" title="Another Object-Oriented persistent microkernel written by the same guys behind EROS">Coyotos</a> define a set of objects (like a class in OOP) that are defined in the kernel. Each of these objects have a bunch of capabilities associated with them, these capabilities are like the method calls of an OOP language so that other programs can call them. So, these capabilities are essentially syscalls into the kernel via Inter-Process Communication (IPC) mechanisms.</p>

<p>Another part of my research into other security mechanisms lead me to <a href="http://www.scs.stanford.edu/histar/" title="A research operating system with an alternative to capabilities">HiStar</a>, which is a kernel based on <a href="http://en.wikipedia.org/wiki/Pi-calculus" title="A formal notation in a similar vein to Z">&Pi;-Calculus</a>, no me neither! This stuff is even harder to understand than the capability papers, maybe I should try reading them for longer rather than skimming?</p>

<h4>Persistence</h4>

<p>Another area of capability based OSes is that they tend to use persistence. This it seems, is due to:</p>

<ol>
  <li>The capabilities being managed by the kernel, and</li>
  <li>Not knowing what configuration capabilities should be in when the machine is rebooted.</li>
</ol>

<p>So, how was the <a href="http://www.gnu.org/software/hurd/hurd-l4.html" title="The GNU Foundation's long running attempt to reimplement a free UNIX operating system">HURD</a> going to do it using user-space capabilities?</p>

<p>Now, the idea of orthogonal persistence is a fine one:</p>

<ul>
  <li>You don't have to worry about saving any documents, images, etc. whilst using the OS as the checkpointing mechanism will save your data at regular intervals, i.e. at, say every 5 mins, the system will take a snapshot of the current state of the OS and save this to disk.</li>
  <li>If somebody pulls out the mains cable by accident (or to turn on a hoover), you won't have lost everything you've been working on (you might have lost something between checkpoints though), so when you restart the machine, everything (mostly) will still be present in your session.</li>
</ul>

<p>Persistence basically maps RAM onto disk. RAM is managed in page sized chunks (usually 4KB), so each page in RAM has a page on disk. When a program opens a file from disk, the OS will just memory map (mmap) the page from disk into RAM, now if the file is small (say, less than a page in size) and you also have quite a few small files open at any one time, you are essentially not utilising RAM efficiently.</p>

<h4>Conclusion</h4>

<ol>
  <li>Nobody knows how an OS based on capabilities is to present itself to the user as it's never really been done. Most capability based OSes are research projects and tend to get shelved when the research has completed and it hardly ever gets released to the public.</li>
  <li>Most of it is research and can be found in (sometimes) hard to read papers.</li>
  <li>Placing capabilities in the kernel seems to tie the <b>filesystem</b> to the kernel as well, this goes against the concept of a <i>&mu;-kernel</i>.</li>
  <li>With persistence, small files (less than the page size) can cause memory to just be eaten up really quickly.</li>
</ol>

<p>I've already set myself quite a task in using Ada as the implementation language for an OS kernel, so I think that rather than try to cram in all these extra features, I should concentrate on just getting a portable  &mu;-kernel developed</p>

<div class="center article_banner">
<script type="text/javascript"><!--
google_ad_client = "pub-1197956670848234";
//468x60 - image full banner - articles
google_ad_slot = "3640510725";
google_ad_width = 468;
google_ad_height = 60;
//--></script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</div>


<a name="comments"></a>








 ]]></description>  <pubDate>Sun, 02 Dec 2007 08:06:28 -0500</pubDate>  <guid isPermaLink="false">http://www.archeia.com/persistence-makes-you-capable.html</guid>  <dc:creator>Archeia</dc:creator>   </item> 
<item>  <title>An operating system design</title>  <link>http://www.archeia.com/an-operating-system-design.html</link>  <description><![CDATA[ <h2>An operating system design</h2>

<p>Conversations in #Ada on IRC yesterday turned back to developing an OS in Ada, this has actually been a goal of mine for some time. I had written a demo <b>hello world</b> style kernel in Ada a few years ago, so I thought I'd try to recompile it using the newest version of FSF GNAT; this failed to build.</p>

<p>After looking through the manuals and finding <b>pragma Restrictions</b>, I stripped out all the other pragmas I had in there to reduce the runtime and tried it out using these <b>pragma restrictions</b>; all compiled ok and it even booted on QEMU!</p>

<p>So, I decided to try and put together a <a href="assets/files/os/highlevel.pdf" title="Download my operating system high level design document">high level design document</a> based on thoughts that I've had over the last 10 years or so, which outlines what I want in an OS. I may even get started on this thing!</p>

<div class="center article_banner">
<script type="text/javascript"><!--
google_ad_client = "pub-1197956670848234";
//468x60 - image full banner - articles
google_ad_slot = "3640510725";
google_ad_width = 468;
google_ad_height = 60;
//--></script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</div>


<a name="comments"></a>








 ]]></description>  <pubDate>Sun, 25 Nov 2007 09:42:59 -0500</pubDate>  <guid isPermaLink="false">http://www.archeia.com/an-operating-system-design.html</guid>  <dc:creator>Archeia</dc:creator>   </item> 
<item>  <title>New hosting</title>  <link>http://www.archeia.com/new-web-host.html</link>  <description><![CDATA[ <h2>New hosting</h2>

<p>Well, there were problems with my last web host, so I closed down that site and shifted everything over to a new host in the US. Hopefully, all will be fine here.</p>

<p>I changed the name as <i>archangel-interactive.com</i> was a bit unwieldy and hard to type and <i>archangeli.co.uk</i> was difficult to type as well. I wanted something shorter, after spending about a week looking for a word that hasn't been taken (the entire dictionary seems to have been registered by a bunch of morons expecting people to pay stupid amounts of cash!!), I found <a href="http://en.wikipedia.org/wiki/Archeia" title="An explanation of where the term Archeia comes from, even if it is made up">the term <i>Archeia</i> on Wikipedia</a> which I found was a female Archangel, so fitted quite nicely with what I had already. Thing is, it seems that Archeia is a made up word and has never been used before some woman decided to make it up and use it, oh well.</p>

<div class="center article_banner">
<script type="text/javascript"><!--
google_ad_client = "pub-1197956670848234";
//468x60 - image full banner - articles
google_ad_slot = "3640510725";
google_ad_width = 468;
google_ad_height = 60;
//--></script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</div>


<a name="comments"></a>








 ]]></description>  <pubDate>Sun, 25 Nov 2007 09:39:05 -0500</pubDate>  <guid isPermaLink="false">http://www.archeia.com/new-web-host.html</guid>  <dc:creator>Archeia</dc:creator>   </item> 
<item>  <title>Restarting work on ANTLR's Ada95 Target</title>  <link>http://www.archeia.com/restarting-work-on-the-antlr-ada95-target.html</link>  <description><![CDATA[ <h2>Restarting work on ANTLR's Ada95 Target</h2>

<p>Well, I've begun to look at the ANTLR source and the source I started writing for the Ada95 language target and I'm getting to the point where I'm seeing problems with the Java implementation again. This is just the basic stuff like the token definitions and the generation of the tokens in the string template group (STG) for the language. Ideally, I'd like the token types to be an enumeration so that we can have Ada coverage testing but other classes in the runtime use Token.EOF which in turn is actually the same thing as CharStream.EOF.</p>

<p>Also, the STG dumps out a constant called "Tokens" which is basically a count of all the tokens defined. When using this for Ada it's not quite right. This can be massaged to give the correct value, but in Ada it's unnecessary, as you can use 'Last attribute for any correctly defined type. I'm not sure if I can get rid of this for the target yet.</p>

<p>The channel numbers also seems odd, the default channel is given a number of 0 and the hidden channel is 99, why not 0 and 1? You'd think that channel 99 is the upper bound allowed, but no, any positive integer will do, this just seems like it's been plucked out of thin air without thinking about it. For example, say you have a whole bunch of channels and want to use a counter to step through them, you'd have to keep checking for 99 before you can skip over it, why not just set it to 1 or 0, at least then there is no checking needed!</p>

<div class="center article_banner">
<script type="text/javascript"><!--
google_ad_client = "pub-1197956670848234";
//468x60 - image full banner - articles
google_ad_slot = "3640510725";
google_ad_width = 468;
google_ad_height = 60;
//--></script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</div>


<a name="comments"></a>








 ]]></description>  <pubDate>Wed, 05 Sep 2007 08:05:30 -0400</pubDate>  <guid isPermaLink="false">http://www.archeia.com/restarting-work-on-the-antlr-ada95-target.html</guid>  <dc:creator>Archeia</dc:creator>   </item> 
<item>  <title>Interfacing to C from Ada95</title>  <link>http://www.archeia.com/interfacing-ada-95-and-c-tutorial.html</link>  <description><![CDATA[ <h2>Interfacing to C from Ada95</h2>

<p>In this tutorial I will take you through the steps of interfacing to C variables and functions. When creating bindings to libraries written in C from Ada a programmer really needs to know how to use the information contained within Appendix B of the Ada Reference Manual (ARM).</p>

<h4>Binding variables</h4>

<p>Firstly, I will show how to import a simple integer variable from C. Given the global variable declaration:</p>

<pre class="CPP">
<dfn>C code</dfn>
<code>/* A variable to import.
 */
int MyGlobal = 10;</code>
</pre>

<p>The following Ada95 code can be used to bring it into the Ada program:</p>

<pre class="Ada">
<dfn>Ada95 code</dfn>
<code>  -- We want to link to the C MyGlobal variable here.
  My_Global : Interfaces.C.int;
  pragma Import(
    Convention    => C,
    Entity        => My_Global,
    External_Name => "MyGlobal");</code>
</pre>

<p>I have used the named parameter passing mechanism so it's easier to see what's happening. We state that the <i>linkage convention</i> is <b>C</b> and the name we will give the integer in the Ada source is <b>My_Global</b>, we then provide the C name <b>MyGlobal</b> and the pragma <strong>binds</strong> the C name to the Ada name. We can then use the Ada name like this:</p>

<pre class="Ada">
<dfn>Ada95 code</dfn>
<code>  My_Global := 25;</code>
</pre>

<h4>Binding functions</h4>

<p>Now following from this, we can extend this knowledge to importing a simple function from C:</p>

<pre class="CPP">
<dfn>C code</dfn>
<code>/* A function to import.
 */
int MyAdd(int a, int b)
    {
    return a + b;
    }</code>
</pre>

<p>Again, using the same <strong>import pragma</strong> we can bring this function into the Ada program and make use of it:</p>

<pre class="Ada">
<dfn>Ada95 code</dfn>
<code>  -- We now want to import a function.
  function My_Add(A, B : Interfaces.C.int)
    return Interfaces.C.int;
  pragma Import(
    Convention    => C,
    Entity        => My_Add,
    External_Name => "MyAdd");</code>
</pre>

<p>See how the C and Ada names differ? The pragma binds the 2 together so that they can be used in a program:</p>

<pre class="Ada">
<dfn>Ada95 code</dfn>
<code>  My_Global := My_Add(My_Global, 7);</code>
</pre>

<h4>Binding C strings</h4>

<p>Strings in C are annoying as they can be viewed in a number of different ways. This also means that binding to them can be tricky. One way is to bind to a pointer to an array. So, for example say we have a function which returns a message string:</p>

<pre class="CPP">
<dfn>C code</dfn>
<code>/* A message to return to Ada.
 */
const char *Message = "This is a test string";

const char *MyString(void)
    {
    return Message;
    }</code>
</pre>

<p>We want to import the MyString function into the Ada program. Ada provides access to pointers to char from the  Interfaces.C.Strings package:</p>

<pre class="Ada">
<dfn>Ada95 code</dfn>
<code>  -- We have a function that returns a message in a string.
  function My_String return Interfaces.C.Strings.chars_ptr;
  pragma Import(
    Convention    => C,
    Entity        => My_String,
    External_Name => "MyString");

  -- This converts the char * array into an Ada String type.  
  Message : String := Interfaces.C.Strings.Value(My_String);</code>
</pre>

<p>In the preceding code, we import as usual, but we use the <strong>chars_ptr</strong> type rather than the <strong>char_array</strong> type as we are passing a pointer and not a string from the stack. We can then transform this into an Ada String type by using the Value function.</p>

<h4>Source code</h4>

<p>I have placed a full example into an archive which can be built with GNAT using the following commands:</p>

<pre class="Bash">
<dfn>Bash code</dfn>
<code>$ tar -xzvpf importing_c.tgz
$ cd importing_c
$ make</code>
</pre>

<p>Other Ada95 compilers will differ.</p>

<p><a href="assets/files/tutorials/importing_c.tgz" title="Download the source">Download importing_c.tgz</a></p>

<div class="center article_banner">
<script type="text/javascript"><!--
google_ad_client = "pub-1197956670848234";
//468x60 - image full banner - articles
google_ad_slot = "3640510725";
google_ad_width = 468;
google_ad_height = 60;
//--></script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</div>


<a name="comments"></a>








 ]]></description>  <pubDate>Mon, 13 Aug 2007 15:05:05 -0400</pubDate>  <guid isPermaLink="false">http://www.archeia.com/interfacing-ada-95-and-c-tutorial.html</guid>  <dc:creator>Archeia</dc:creator>   </item> 
<item>  <title>Dot notation for tagged types</title>  <link>http://www.archeia.com/ada-2005-dot-notation-tutorial.html</link>  <description><![CDATA[ <h2>Dot notation for tagged types</h2>

<p>Using the code from the <a href="ada-2005-interface-types-tutorial.html" title="A tutorial on interface types">interface types tutorial</a>, we can now use the dot notation provided by Ada 2005. This allows the programmer to use the dot for tagged types which will be familiar from other programming languages like C++.</p>

<pre class="CPP">
<dfn>C++ code</dfn>
<code>class Dragster : public Vehicle, public Parachute {
    bool GearUp();
    // etc.
};

Dragster D;
bool     Result = D.GearUp();</code>
</pre>

<p>The usual way of referencing a primitive for a tagged type is to either <i>use</i> the package that contains it or to reference it including the package's name:</p>

<pre class="Ada">
<dfn>Ada95 code</dfn>
<code>with Dragster;

procedure Test is

  D      : Dragster.Dragster_Type;
  Result : Boolean;

begin

  Result := Dragster.Gear_Up(D);
  
end Test;</code>
</pre>

<p>So, we can transform our code to use the new notation and we still don't have to <i>use</i> the package!</p>

<pre class="Ada">
<dfn>Ada 2005 code</dfn>
<code>with Dragster;

procedure Test is

  D      : Dragster.Dragster_Type;
  Result : Boolean;

begin

  -- D is passed as the "Self" parameter to Gear_Up.
  Result := D.Gear_Up;
  
end Test;</code>
</pre>

<p>I have placed a full example into a compressed text file which can be built with GNAT using the following commands:</p>

<pre class="Bash">
<dfn>Bash code</dfn>
<code>$ gunzip dot_notation.ada.gz
$ gnatchop -cw -gnat05 dot_notation.ada
$ gnatmake -gnat05 test.adb</code>
</pre>

<p>Other Ada 2005 compilers will differ.</p>

<p><a href="assets/files/tutorials/dot_notation.ada.gz" title="Download the source">Download dot_notation.ada.gz</a></p>

<div class="center article_banner">
<script type="text/javascript"><!--
google_ad_client = "pub-1197956670848234";
//468x60 - image full banner - articles
google_ad_slot = "3640510725";
google_ad_width = 468;
google_ad_height = 60;
//--></script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</div>


<a name="comments"></a>








 ]]></description>  <pubDate>Tue, 07 Aug 2007 11:06:16 -0400</pubDate>  <guid isPermaLink="false">http://www.archeia.com/ada-2005-dot-notation-tutorial.html</guid>  <dc:creator>Archeia</dc:creator>   </item> 
<item>  <title>Interface types</title>  <link>http://www.archeia.com/ada-2005-interface-types-tutorial.html</link>  <description><![CDATA[ <h2>Interface types</h2>

<p>Carrying on from the <a href="ada95-abstract-types-tutorial.html" title="An tutorial on abstract types">abstract types tutorial</a>, the natural progression is to add multiple inheritance. In Ada95 this cannot be done as the language doesn't supply any features for this - it is possible, however, but requires the use of generics.</p>

<p>In C++ this is easy enough as we can just add another interface (or class) to the list of classes to derive from:</p>

<pre class="CPP">
<dfn>C++ code</dfn>
<code>class Dragster : public Vehicle, public Parachute {
    bool GearUp();
    bool GearDown();
    void Accelerate();
    void Brake();
    void Deploy(); -- This has been added!
};</code>
</pre>

<p>For this tutorial we must use the Ada 2005 language as this provides interface types similar to those provided in Java. The interface type is like the abstract type seen in the previous tutorial except that the use of multiple inheritance is allowed. So, in Ada 2005 we would define the Parachute type as:</p>

<pre class="Ada">
<dfn>Ada 2005 code</dfn>
<code>package Parachute is

  type Parachute_Type is interface;
  
  procedure Deploy(Self : in Parachute_Type) is abstract;
  
end Parachute;</code>
</pre>

<p>Notice the use of the <strong>interface</strong> keyword, this is new as of Ada 2005. This package provides the specification of the Deploy operation and again, this is abstract. Interfaces can only have abstract primitives or null primitives (i.e. primitives that do not have to be implemented). We can then create a new Dragster type:</p>

<pre class="Ada">
<dfn>Ada 2005 code</dfn>
<code>with Vehicle;
with Parachute;

package Dragster is

  type Dragster_Type is new Vehicle.Vehicle_Type and
    Parachute.Parachute_Type with private;

  function Gear_Up(Self : Dragster_Type) return Boolean;
  function Gear_Down(Self : Dragster_Type) return Boolean;
  procedure Accelerate(Self : Dragster_Type);
  procedure Brake(Self : Dragster_Type);
  procedure Deploy(Self : in Dragster_Type);

private

  type Dragster_Type is new Vehicle.Vehicle_Type and
    Parachute.Parachute_Type with null record;
    
end Dragster;</code>
</pre>

<p>Again, notice the difference in the way we define the type, the <strong>and</strong> keyword means that we are also deriving this type from the vehicle type <i>and</i> the parachute interface type. The Dragster type has to implement the Deploy primitive, which can then be used:</p>

<pre class="Ada">
<dfn>Ada 2005 code</dfn>
<code>
procedure Test is

  -- Make sure we can accept pointers to all vehicles
  -- in this class.
  type Vehicle_Access is access all
    Vehicle.Vehicle_Type'Class;
  type Parachute_Access is access all
    Parachute.Parachute_Type'Class;

  A      : Vehicle_Access;
  -- Removed some code.
  D      : aliased Dragster.Dragster_Type;
  P      : Parachute_Access;
  Result : Boolean;

begin

  -- Removed some code.

  A      := Vehicle.Vehicle_Type(D)'Access;
  -- Call's Dragster.Gear_Up
  Result := Vehicle.Gear_Up(A.all);
  
  -- Use polymorphism on the Parachute type.
  P      := D'Access;

  Parachute.Deploy(P.all);
  
end Test;
</code>
</pre>

<p>I have placed a full example into a compressed text file which can be built with GNAT using the following commands:</p>

<pre class="Bash">
<dfn>Bash code</dfn>
<code>$ gunzip interface_types.ada.gz
$ gnatchop -cw -gnat05 interface_types.ada
$ gnatmake -gnat05 test.adb</code>
</pre>

<p>Other Ada 2005 compilers will differ.</p>

<p><a href="assets/files/tutorials/interface_types.ada.gz" title="Download the source">Download interface_types.ada.gz</a></p>

<div class="center article_banner">
<script type="text/javascript"><!--
google_ad_client = "pub-1197956670848234";
//468x60 - image full banner - articles
google_ad_slot = "3640510725";
google_ad_width = 468;
google_ad_height = 60;
//--></script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</div>


<a name="comments"></a>








 ]]></description>  <pubDate>Sun, 05 Aug 2007 13:46:22 -0400</pubDate>  <guid isPermaLink="false">http://www.archeia.com/ada-2005-interface-types-tutorial.html</guid>  <dc:creator>Archeia</dc:creator>   </item> 
<item>  <title>Abstract types</title>  <link>http://www.archeia.com/ada95-abstract-types-tutorial.html</link>  <description><![CDATA[ <h2>Abstract types</h2>

<p>This tutorial will show you what an abstract type is in Ada. I will also provide information on how the Ada type equates to the  C++ class.</p>

<p>An abstract type provides the &quot;specification&quot; for a family of a user defined types. When this type is derived from, the programmer must specify the operations that are defined as abstract.</p>

<p>Say we have a simple vehicle which can change gears, accelerate and brake. We're not interested in knowing what speed we're going, just the basics. In C++ a <i>Vehicle</i> pure virtual class could be defined:</p>

<pre class="CPP">
<dfn>C++ code</dfn>
<code>class Vehicle {
    virtual bool GearUp() = 0;
    virtual bool GearDown() = 0;
    virtual void Accelerate() = 0;
    virtual void Brake() = 0;
};</code>
</pre>

<p>This can then be derived from to create a number of concrete vehicles:</p>

<pre class="CPP">
<dfn>C++ code</dfn>
<code>class Car : public Vehicle {
    bool GearUp();
    bool GearDown();
    void Accelerate();
    void Brake();
};

bool Car::GearUp() {
    // Change the car's gears.
}

// etc.

class Van : public Vehicle {
    bool GearUp();
    bool GearDown();
    void Accelerate();
    void Brake();
};

bool Van::GearUp() {
    // Change the van's gears.
}

// etc.

class Scooter : public Vehicle {
    bool GearUp();
    bool GearDown();
    void Accelerate();
    void Brake();
};

bool Scooter::GearUp() {
    // Change the scooter's gears.
}

// etc.
</code>
</pre>

<p>Now, in Ada95 we use an <strong>abstract tagged type</strong> to implement the Vehicle type:</p>

<pre class="Ada">
<dfn>Ada95 code</dfn>
<code>package Vehicle is
  
  type Vehicle_Type is abstract tagged private;

  function Gear_Up(
    Self : Vehicle_Type) return Boolean is abstract;
  function Gear_Down(
    Self : Vehicle_Type) return Boolean is abstract;
  procedure Accelerate(Self : Vehicle_Type) is abstract;
  procedure Brake(Self : Vehicle_Type) is abstract;

private

  type Vehicle_Type is abstract tagged null record;

end Vehicle;</code>
</pre>

<p>Notice how the package has no body, it is a specification only and all operations are abstract, which means that any types which derive from this one must provide implementations of all the primitive operations.</p>

<p>Again, this can then be derived from to create a number of concrete vehicles:</p>

<pre class="Ada">
<dfn>Ada95 code</dfn>
<code>with Vehicle;

package Car is
  
  type Car_Type is new Vehicle.Vehicle_Type with private;

  function Gear_Up(Self : Car_Type) return Boolean;
  function Gear_Down(Self : Car_Type) return Boolean;
  procedure Accelerate(Self : Car_Type);
  procedure Brake(Self : Car_Type);

private

  type Car_Type is new Vehicle.Vehicle_Type with
    null record;

end Car;

package body Car is
  
  function Gear_Up(Self : Car_Type) return Boolean is

  begin

    -- Change the car's gears.

  end Gear_Up;

  -- Etc.

end Car;

with Vehicle;

package Van is
  
  type Van_Type is new Vehicle.Vehicle_Type with private;

  function Gear_Up(Self : Van_Type) return Boolean;
  function Gear_Down(Self : Van_Type) return Boolean;
  procedure Accelerate(Self : Van_Type);
  procedure Brake(Self : Van_Type);

private

  type Van_Type is new Vehicle.Vehicle_Type with
    null record;

end Van;

package body Van is
  
  function Gear_Up(Self : Van_Type) return Boolean is

  begin

    -- Change the van's gears.

  end Gear_Up;

  -- Etc.

end Van;

with Vehicle;

package Scooter is
  
  type Scooter_Type is new Vehicle.Vehicle_Type with
    private;

  function Gear_Up(Self : Scooter_Type) return Boolean;
  function Gear_Down(Self : Scooter_Type) return Boolean;
  procedure Accelerate(Self : Scooter_Type);
  procedure Brake(Self : Scooter_Type);

private

  type Scooter_Type is new Vehicle.Vehicle_Type with
    null record;

end Scooter;

package body Scooter is
  
  function Gear_Up(Self : Scooter_Type) return Boolean is

  begin

    -- Change the scooter's gears.

  end Gear_Up;

  -- Etc.

end Scooter;</code>
</pre>

<p>So, where ever a pointer to a Vehicle type is used it is possible to assign either Car, Van or Scooter instance to that variable:</p>

<pre class="Ada">
<dfn>Ada95 code</dfn>
<code>with Vehicle;
with Car;
with Scooter;
with Van;

procedure Test is

  -- Make sure we can accept pointers to all vehicles
  -- in this class.
  type Vehicle_Access is access all
    Vehicle.Vehicle_Type'Class;

  A      : Vehicle_Access;
  C      : aliased Car.Car_Type;
  S      : aliased Scooter.Scooter_Type;
  V      : aliased Van.Van_Type;
  Result : Boolean;

begin

  -- Call's Car.Gear_Up
  A      := C'Access;
  Result := Vehicle.Gear_Up(A.all);

  -- Call's Scooter.Gear_Up
  A      := S'Access;
  Result := Vehicle.Gear_Up(A.all);

  -- Call's Van.Gear_Up
  A      := V'Access;
  Result := Vehicle.Gear_Up(A.all);

end Test;</code>
</pre>

<p>I have placed a full example into a compressed text file which can be built with GNAT using the following commands:</p>

<pre class="Bash">
<dfn>Bash code</dfn>
<code>$ gunzip abstract_types.ada.gz
$ gnatchop -cw abstract_types.ada
$ gnatmake test.adb</code>
</pre>

<p>Other Ada95 compilers will differ.</p>

<p><a href="assets/files/tutorials/abstract_types.ada.gz" title="Download the source">Download abstract_types.ada.gz</a></p>

<div class="center article_banner">
<script type="text/javascript"><!--
google_ad_client = "pub-1197956670848234";
//468x60 - image full banner - articles
google_ad_slot = "3640510725";
google_ad_width = 468;
google_ad_height = 60;
//--></script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</div>


<a name="comments"></a>







 ]]></description>  <pubDate>Sun, 05 Aug 2007 10:24:03 -0400</pubDate>  <guid isPermaLink="false">http://www.archeia.com/ada95-abstract-types-tutorial.html</guid>  <dc:creator>Archeia</dc:creator>   </item> 
<item>  <title>wxAda: an Ada95 binding to wxWidgets</title>  <link>http://www.archeia.com/wxada-an-ada95-binding-to-wxwidgets.html</link>  <description><![CDATA[ <h2>wxAda: an Ada95 binding to wxWidgets</h2>

<p><a href="http://www.wxwidgets.org" title="The home of the wxWidgets library">wxWidets</a> was a piece of software I was using at work, I liked it so much that it made it's way into my home projects.</p>

<p>As I was using wxWidgets a lot, I was getting rather annoyed with C++. I wanted to go back to developing more in Ada but there wasn't any decent GUI toolkits. So, I decided to try and create an Ada95 binding to wxWidgets.</p>

<p>This didn't exactly work out as the strong typing that Ada enforces was causing problems with the class hierarchy I was trying to replicate from C++ into Ada. This caused me to stall, which in turn caused the demise of the project.</p>

<p>I then started to look at a native Ada95 GUI toolkit using design patterns but the cyclic dependency problem in Ada bit me, so this has also ceased for now. I haven't decided what I'll do about this project just yet.</p>

<p>I placed the wxAda source code in it's entirety into <a href="http://wxada.tigris.org/" title="A source repository for open source software projects, much like Source Forge">a Tigris repository</a> so that anybody with an interest in carrying on the project can do so.</p>

<div class="center article_banner">
<script type="text/javascript"><!--
google_ad_client = "pub-1197956670848234";
//468x60 - image full banner - articles
google_ad_slot = "3640510725";
google_ad_width = 468;
google_ad_height = 60;
//--></script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</div>


<a name="comments"></a>







 ]]></description>  <pubDate>Sat, 04 Aug 2007 13:22:07 -0400</pubDate>  <guid isPermaLink="false">http://www.archeia.com/wxada-an-ada95-binding-to-wxwidgets.html</guid>  <dc:creator>Archeia</dc:creator>   </item> 
<item>  <title>Dreamcast</title>  <link>http://www.archeia.com/sega-dreamcast-development.html</link>  <description><![CDATA[ <h2>Dreamcast</h2>

<p>Whilst working for a games company I ported one of their games to the Dreamcast without the use of an official development kit (which was called Dolphin/Katana), I used the freely available tools.</p>

<p>The game was very slow due to the fact that it was all done in 2D, there was no 3D interface for the game and it would've been particularly difficult to bolt something like that into an existing game. I then dabbled with the free tools in my own time, but not much came of that.</p>

<p>I put up <a href="http://uk.geocities.com/munkeechuff/" title="My old Sega Dreamcast documentation">documentation detailing the Sega Dreamcast</a> onto GeoCities.</p>

<div class="center article_banner">
<script type="text/javascript"><!--
google_ad_client = "pub-1197956670848234";
//468x60 - image full banner - articles
google_ad_slot = "3640510725";
google_ad_width = 468;
google_ad_height = 60;
//--></script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</div>


<a name="comments"></a>







 ]]></description>  <pubDate>Thu, 02 Aug 2007 14:46:05 -0400</pubDate>  <guid isPermaLink="false">http://www.archeia.com/sega-dreamcast-development.html</guid>  <dc:creator>Archeia</dc:creator>   </item> 
<item>  <title>AROS</title>  <link>http://www.archeia.com/aros-research-operating-system.html</link>  <description><![CDATA[ <h2>AROS</h2>

<p>Back in 1995, <a href="http://www.aros.org" title="Home of the AROS Research Operating System">AROS</a> was just starting out and needed programmers to work for them. I joined the development mail list and ended up reverse engineering a few command line tools. I actually wrote more than I submitted but due to time constraints they didn't all get submitted and the source has since been lost (since I no longer have any Amiga's). AROS is still going and is a very active project.</p>

<div class="center article_banner">
<script type="text/javascript"><!--
google_ad_client = "pub-1197956670848234";
//468x60 - image full banner - articles
google_ad_slot = "3640510725";
google_ad_width = 468;
google_ad_height = 60;
//--></script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</div>


<a name="comments"></a>







 ]]></description>  <pubDate>Thu, 02 Aug 2007 14:45:54 -0400</pubDate>  <guid isPermaLink="false">http://www.archeia.com/aros-research-operating-system.html</guid>  <dc:creator>Archeia</dc:creator>   </item> 
	</channel>
</rss>
