THE STEAM ENGINE by WJ97 1. FIRST A TERRIBLE DISCLAIMER The author of The Steam Engine or related code, Walter de Jong aka WJ97, cannot be held responsible for any damage caused by using this software. USE AT YOUR OWN RISK. 2. CONTENTS 1. Disclaimer 2. Contents 3. Copyright 4. What is this? 4.1 Why the name 'The Steam Engine'? 4.2 Is it a real OS? 5. Installing 5.1 Using the Coal shell 5.2 Exit doesn't work 6. Reactions & Explanations 6.1 What's this crap junk bullshit? 6.2 Nice work! 7. Coders, programmers, hackers, and wannabe's 7.1 How does it work? 7.2 Can I wrote programs for The Steam Engine? 7.3 System Calls 7.4 Can I use all memory (> 640K)? 7.5 Device drivers 7.6 File systems 7.7 Multi-tasking 7.8 Multi-threading 7.9 Virtual machine kernel 8. The future 3. COPYRIGHT The author claims full copyright of this software. You may freely use and distribute this software (and I hope you will) as long as you do not charge anything for it. This software may not be redistrubuted in a modified form under the title of 'The Steam Engine'. Modified distributions should clearly state they are modified versions of 'The Steam Engine' by WJ97 or Walter de Jong. I know this is lame, but I might want to do something useful with this code in the future, and I think it'd be more lame if someone else stole and ran away with it. 4. WHAT IS THE STEAM ENGINE? It is a system that loads from floppy disk. It does not run on DOS or any other operating system, The Steam Engine uses your PC. In a way, The Steam Engine is an operating system -- although I do not wish to call it that because it just isn't worth to be called Operating System yet. 4.1 WHY THE NAME 'THE STEAM ENGINE'? Heheh, it's called The Steam Engine for a number of reasons. 1. It is a worthless piece of junk 2. You can feed it data cards (floppies) like those early 'computers'. By my knowledge none of them were driven by steam (perhaps some were (the Babbage machine?), I don't know... but anyway, the name is loosely inspired on the title of the book 'The Difference Engine' by William Gibson and Bruce Sterling, in which huge steam computers were invented in the year 1870 or so. 3. The steam engine was the beginning of the industrial revolution! By writing this code, I have come to a new period of bloom in my life! ;) 4.2 IS IT A REAL OS? Erhhmmm yes and no. It is software that can boot and load other software, and e.g. the kernel provides system calls for user programs. So in that way, it is an OS. However, it has no memory management, no file system, nothing. The 'shell' as it is called, can't do much for you either. 5. INSTALLING Insert a blank formatted floppy into drive A:. If you do not have a floppy drive A:, then you can delete all this stuff because it won't work from another drive. DOS/Windows users: run 'rawrite' Rawrite is a program I made that dumps the file 'steam.raw' onto your floppy disk. Linux/SCO Unix/NetBSD/FreeBSD/etc users: cat steam.raw >/dev/fd0 I have not tested this yet (shame on me..!) but it should work. Reboot the system, and make sure it boots from floppy. You may have to alter a BIOS Setup setting in order to have it boot from floppy drive. 5.1 USING THE COAL SHELL After The Steam Engine has booted, it runs the Coal shell. The Coal shell is currently version 0.0.1, and it also requests The Steam Engine version and displays it. You cannot do much with the Coal shell yet; it knows only 4 commands: help Gimme help ver Display version info exit Exit the shell reboot Reboot system 5.2 EXIT IN COAL DOESN'T WORK Yes, it does work, but it returns control to the kernel, which loads and executes the shell. In order to get out, issue the 'reboot' command. (But I guess you figured that out already.) Note that you can write your own program for The Steam Engine, place it on a disk, take the bootdisk out, insert the new program disk, and enter 'exit' to load your very own program under The Steam Engine. Also see the section for 'CODERS'. 6. YOUR POSSIBLE REACTION & MY POSSIBLE EXPLANATION 6.1 HEY, I CAN DO NOTHING WITH THIS CRAP CODE. WHY DID YOU PUBLISH IT LIKE THIS??! To show off, of course :) You are probably no assembly programmer either. You must understand that this small step is also a giant step for me. No programmer I know personally has even gotten close to writing something even resembling an operating system, whether it was a junk pile or not. I _always_ have said I could write MS-DOS, and that I could do it better if I had written it. I also _always_ have said that one day, I'd be writing my own OS, perferrably mostly in assembly. This small step is the step that just might be accelerating into a giant leap some day. This step is my dreams of life coming true. 6.2 HEY, NICE. DID IT TAKE YOU LONG TO WRITE IT? I wrote The Steam Engine in only 8 hours or so in a weekend. I didn't even have to think much, the code just came out. I also didn't sit down with the thought 'Let's write an OS!', no, I wrote a small command line interpreter routine (the shell) and added a loader to it. Then I glued some bootcode to it and implemented real system calls. The monday after this weekend, I found out that it didn't boot the shell correctly on the computers at work (grmbl! Even PC's are not PC's!) so I fixed it on the spot, which took about an hour and a half. 7. CODERS, PROGRAMMERS, HACKERS, AND WANNABE's 7.1 HOW DOES IT WORK? The bootcode places the stack at the end of low memory, 640K. The bootcode loads sector #2 at 0100:0000 from floppy (note that sector #1 is the bootsector (not sector #0!!)), which contains the kernel. In this premature version, the kernel is only 512 bytes big, so it fits in 1 sector. The kernel installs the vector to the system call table (see next section 'SYSTEM CALLS') and loads the shell from sector #3. The shell is only one sector in size too, because this is a premature version. Next, the shell is executed. If the shell cleanly exits, the kernel will load and execute the shell again. 7.2 CAN I WRITE MY OWN PROGRAMS FOR THE STEAM ENGINE? Yes :) I told you it was a real OS :) However, this premature version is very braindead. Your programs must fit in 1 disk sector (512 bytes) and must be placed on sector #3 of your disks. Also note that The Steam Engine hasn't got any file system yet, nor can it load a disk block other than the third. This is hardcoded in the kernel, I think I'll improving that soon. For more info on writing programs for The Steam Engine, read on: 7.3 SYSTEM CALLS The kernel installs a vector at 0000:0084h -- the address were the INT 21h vector is located. BEFORE you stop reading and decide to call INT 21h, read on: You are not supposed to call INT 21h. I needed a special place to store an address, and I chose this spot because we don't use INT 21h anyway. What is this stored address then? It is a pointer to the system call table. The system call table is a table of offsets in the kernel segment that point to the system procedures. In this premature version there are 6 system procedures: #0 GetVersion #1 Print #2 Puts #3 Getch #4 Gets #5 Strcmp These functions were needed in the shell, so I put them in system procedures. Please see the source code STEAM.ASM and COAL.ASM on how to call these system procedures. (I'm wasting precious time documenting and writing a decent web page while I could be writing code!!) Note for hackers: The vector currently always is 0100:0002. This may change in the future. 7.4 CAN I USE ALL AVAILABLE SYSTEM MEMORY? No. The Steam Engine is a 16-bit real mode system. That means it only uses 640K of your computer (yes, so much for all the money you invested in upgrading memory). If I continue this project, I'll start from scratch some day and make it 32-bit. The main problem with 32-bit is that the standard BIOS calls don't work (or they work differently), so I'll be getting a book about that I guess. 7.5 DEVICE DRIVERS? No, please...! I have just written this thingie in a couple of hours... There are no device drivers. Console I/O and disk reads are done through BIOS calls. That may be changed later. (Note: Linux does not use BIOS. FreeBSD i386 and DOS do.) 7.6 FILE SYSTEMS? See Device Drivers. I think I'll be improving the disk I/O though, since the kernel and shell will grow and will soon not fit into one sector anymore. 7.7 MULTI-TASKING? NO! Not for a very long time. I know how this is done, but I'm not planning on attempting to write this first. Do not expect it to happen in a kazillion years. Dream on and on and on (or so I'm told). 7.8 MULTI-THREADING? You are out of your mind. See section 7.7. 7.9 VIRTUAL MACHINE KERNEL That's what my brother proposed. Neat idea, but I won't be trying it for now. 8. THE FUTURE LIES AT OUR FEET Well, whatever happens next... of course I hope I will remain interested in writing code for The Steam Engine and that all goes well... The code is pretty comprehensible, it's all written in easy 8086 code (I placed a .386P in the source for neatness, and because I needed immediate pushes - but you can work around this if you're developing on an XT), and it's quite extensible as long as you maintain the system call structure. Well, have fun with it (I'm already having it ;), --Walter de Jong aka WJ97 (or 2^64 ;) *** When you build it, they will come *** Feel free to mail me messages like: * 'Hey, I really like The Steam Engine. Please continue development!' * 'Hey, why are you wasting your time like this anyway?' * 'The Steam Engine doesn't work for me! I own a ... ...' * 'VeRY KewL M4n! u R r3411y Z+34M1nG!!' Just don't be angry if I leave any questions unanswered... I'm always busy. EOB