views:

513

answers:

6

Next term, I'll need to write a basic operating system for Motorola 68K processor as part of a course lab material.

Is there a Linux emulator of a basic hardware setup with that processor? So my partners and I can debug quicker on our computers instead of physically restarting the board and stuff.

Is it possible to apply test-driven development technique to OS development? Code will be mostly assembly and C. What will be the main difficulties with trying to test-drive this? Any advice on how to do it?

+3  A: 

I would suggest QEMU for m68k emulation.

(The system emulator you want in QEMU is "Coldfire" - that's what Freescale calls the successor to the m68k architecture).

caf
Looking at the QMEU site, I don't see support for M68K; for PowerPC (a descendant of M68K), it suggests PearPC, which doesn't seem to be active (last update appears to be September 2005).
Jonathan Leffler
Having said that, I found an external site about M68K testing that mentions QEMU: http://gwenole.beauchesne.info/en/blog/2007/07/08/m68k_emulator_testsuite
Jonathan Leffler
Jonathan: It's called "Coldfire", which is the successor to m68k, see here: http://www.qemu.org/qemu-doc.html#SEC66
caf
A: 

The uClinux project started on a m68k board. They may have the tools you need...

dmckee
A: 

Maybe the AROS project at Sourceforge has what you need. It says it is an M68K Emulator.

You might also find some leads at this site.

Jonathan Leffler
+1  A: 

You certainly can tdd this project. First off decouple all accesses to the hardware with simple routine calls, e.g. getch() and printf, then you can provide simple mocks that provide test input and check output. You can then write well over 90% of the project on a PC using gcc, msdev or xcode. Once you have got some confidence in the decoupling routines you will need very little access to the hardware, and only then to occasionally check that your mocks are acting as you expect.

Keep to C until you find a particular bottle neck, and only then resort to assembler.

David Sykes
I disagree with the last sentence. If you're writing an OS there's lots of necessary things you can't do in C. Keeping asm to a minimum is good, and it's good to do most of the needed asm as inline assembly from C code. But you will still probably need some files which are nothing but assembly. Take a look at entry.S on Linux for an example -- that kind of stuff makes no sense as inline asm, it has to stand on its own.
asveikau
+2  A: 

I would recommend developing an operating system for the classic Amiga computers, which had different versions of the 68000 processor. Since the Amiga computer is a complete computer and is extremely well documented, I thought this would be a good exercise.

There is an emulator for it called UAE (and Win-UAE) which is very exact and can be configured with different kinds of processors (68000 - 68060) and other capabilities. Normally, you would also need to acquire the copyrighted ROMS to it, but since you are developing an operating system yourselves, this is not necessary.

Tools you will need is either Cygwin (for developing under Windows) or a Linux computer. Then you will need cross compilers. This includes both a C compiler and an assembler. A template for creating a simple ROM which changes screen color and flicks the power LED can be found at the hyperlink below. It will create a file 'kick.rom' which UAE then searches for in the current directory.

Reference on the 68000 instruction set can be found at the link below. Be aware that different assembler programs may use slightly different syntax and instruction set.

If you need to demo the operating system on real hardware, actual Amigas are still extremely cheap and abundant on Ebay.

I would post links too, but stackoverflow will not let me, I have too low reputation so here are the references with links.

Amigable Clark Kant
A: 

There are a few new projects that use hardware simulated 68000 cpus, the C-One project, the Minimig (Mini Amiga) project and the Natami (Native Amiga) project - they are new 68k compatible Amiga systems. http://www.vesalia.de/e_commodoreone.htm?slc=uk

amigakit.leamancomputing.com/catalog/product_info.php?products_id=777

natami.net/hardware.htm (in development, prototypes done).

angelheart