ATA (IDE) driver for Windows CE 2.11

So I was thinking about the idea of an embedded version of SIMH to run on small machines (old cellphones) and maybe a PC or something, else weird… Sure Linux & BSD would work, and be so easy, but where is the fun in that?

Years ago I’d picked up a copy of the “Windows CE Platform builder 2.11”, but I never really did anything with it. So I thought this would be a great little project for the thing, starting with the CEPC, an x86 version of Windows CE that runs on any normal PC.

After I gave up fighting the installer, I just decided it’d be best to run this on Windows NT 4.0, and the install went smooth, I just selected the x86 platform for now, as I don’t have any physical SH3/MIPS/PowerPC gear I’d want to play with, and at any rate I think adapting Windows CE must be a major chore, as nobody has done it, even to Qemu….

So within a few minutes I was well on my way to building my own MAXALL version of Windows CE 2.11, when I found out that there are a few snags with this old version.

First is that there is no shell. That’s kind of lame. Then there is no built in apps, like Pocket Internet explorer, hell even NOTEPAD. That’s pretty lame as well. Finally the only included NDIS driver I can quickly run is the NE2000, under Qemu (I assume I haven’t even tackled the networking yet), and on Qemu I’m stuck at 320×200…..

Then the final straw was that the “ROM” can’t access IDE hard disks.

Yes, that’s right, Windows CE cannot access IDE disks.

So something like SIMH with data files of several hundred megabytes would be out.

That is until I somehow came across this link:

Which is dead….

But thanks to the internet archive… it lives on here:

The paper is titled “Designing a Hard Disk Driver for Windows CE 2.12”, by Stephen Hague & Chris Wood which certainly is a step in the right direction! The best part, is that the archive also snagged the source code!!!!

So I followed the instructions as best as I could, compiled the driver & the loader, inserted them into the ROM, built the CEPC, and booted up and… nothing happened!

What I also didn’t get is that the dll was only 4kb. And that’s pretty damned small for some 90kb of C code.. Something was wrong. After some poking around, I then remembered the great “dumpbin” utility. And it confirmed what I had suspected, there was no exported symbols.

I couldn’t figure out how to feed a ‘.def’ file into the Platform Builder system, so I kind of was at an impas. Then I remembered a while ago I had posted about creating DLL’s and how Visual C++ could call GCC’s dlls and vice versa (C only, I never said C++!!!) so looking back, I then went to the needed procedures, and set them up as “__declspec(dllexport)”. Now when I re-compiled my dll was larger, and dumpbin verified that there were exports.

So with that I was all happy, and rebuilt everything then found the next few limitations… The driver doesn’t use the disks geometry, it just makes it up. The driver only uses 5MB. The driver also doesn’t flag the disk as MBR so it’ll WIPE YOUR DISK. And the real deal breaker is that the FATFS driver will pass 4kb chunks to be written out to disk in a sequential manner, but the driver only writes the first 512b.

So a few hours later, and LOTS of printf’s and googling around I’ve improved the driver to go around all of these issues. I still think there is some things to go around, but so far it’s looking good. The only ‘issue’ I don’t understand is that files seem to copy from the ROM to the disk fine, my text files look just fine, but copying an EXE from ROM to the disk, then into the ramdisk produces an exe that won’t run. however the same exe once on the hard disk, I’ve been able to diff the two, and they are ok….

I don’t know how much of that is a show stopper, and how much is it me not knowing CE all that well.

So with all that fun, I partitioned a 500MB disk on Qemu with MS-DOS 5.0, and copied in a file…


Then I booted up CE:

ce211 harddisk

And my file is there, and even copying things around, booting back to MS-DOS didn’t result in a corrupted disk…

So now I’m back to trying to port SIMH to Windows.. which is difficult as CE has no real console that I can figure out how to program, so I’m hacking up “tty.c” an example dumbterm, with really mixed results so far… It’ll really be interesting if it works.

For anyone that cares, my ata driver for CE 2.11 is here.

I have no idea if it’ll work on CE 3.0, 4.0, 5.0 or 6.0 … Maybe the newer ones include ATAPI/ATA (IDE) drivers? Hell they could support NTFS for all I know, but again I’m working with what I have on hand…. Also the ‘maxall’ rom for 2.11 is 4Mb. !!

This entry was posted in device drivers, Windows CE by neozeed. Bookmark the permalink.

About neozeed

What is there to tell? I've loved UNIX like things since I was first exposed to QNX in highschool (we had the Unisys ICONS!), and spent the better time of my teenage years trying to get my own UNIX... I should have bought Coherent in retrospect.. Anyways latched onto Linux in 1992, and then got some old BSD admin books and have been hooked on the VAX BSD & other big/ancient things since...!

Leave a Reply

Your email address will not be published.

Notify me of followup comments via e-mail. You can also subscribe without commenting.