 Welcome everybody to my little talk about DOS emu and free DOS. Just a kind idea about what people have done. Is there anybody in this room who's ever used DOS emu in the past 20 years? Oh, it's quite a few hands. How about free DOS? Probably about the same crowd. A few may have used free DOS on bare hardware. That's nice to see so many users. It's actually the very first time in my life that I'm giving a talk about about these two projects. So let me introduce myself. My name is Bart Oldman. I've been a long-term maintainer of DOS emu between about 2001 and 2013. I started contributing about a year before and I've also maintained the mem utility for a while. I bought a few slides for this talk from Jim Hall who is the long-term free DOS project coordinator. I myself had to step down a little bit from open source project just because of family life taking over and running after two little kids that it takes a lot of time away from doing programming. In my real life I work for a supercomputing center at McGillian first in Canada. So this because we're in a retro computing workshop this very old started this was the kind of computer that my parents had when I was a teenager. I was a Commodore PC-23. Actually this is what I found on Wikipedia. It's not the real one. We had one with a 720k floppy drive instead of the five and a quarter one that is displayed over here. So we had somewhat more than floppies and in the beginning sometimes we had floppies that didn't fit and we had to copy them over to the small ones. That's quite a few years ago. So this is probably most of you will know this is how DOS at the time before free DOS existed. You only had MS DOS and when you when you installed MS DOS you were given this f-disk welcome screen which was a purely tech space of course. The computer I just saw had I just showed at our house was connected to a monochrome monitor which only had a Hercules graphics mode of 720 by 348 pixels and with a bit of tricks you could make it either amber or dark amber if you make one out of every pixel black. So DOS AMU is one of the oldest projects around that was purely aimed at Linux. So when I go back into history and I that's one point that downloaded all the old tarbles the very first version was a 0.1 version released on September 3, 1992 which makes DOS AMU almost 26 years old. Maybe older than some of the people in this room actually. So he released it as DOS emulator for Linux 0.97 PL2 and 0.97 PL2 was of course the version of the Linux kernel at that time because there was very fast-paced development so things were very tightly coupled. There was a feature added to Linux kernel and DOS AMU started using it straight away and it was very hectic development at those times. So of course it was a pre-alpha release with some bugs but people started using it and in the years from 1993 to 97 there was quite rapid development. A lot of people contributed to it. It was kind of one of the standard parts of a Linux distribution just because many people were still using DOS. Usually on a separate partition there was usually a fat partition and an x2 partition at the time. One to run DOS, the other one to run Linux. Now things stabilized a little bit when so we had Robert Sanders and James McLean who added DOS protected modes support DPMI. It's very useful because many of the DOS programs developed in the 90s used protected mode using this DOS protected mode interface. Hans Lerman took over. He sadly passed away a few years ago but he stabilized DOS AMU really into a 1.0 version which made it possible to run it without needing root anymore and a lot of things stabilized during those years. Still there was still a lot of work to be done and we I took over in 2001, worked on it for a little while. The page went down a little bit and at some point a long-time contributor starts there gave started his own project. It's got a little bit for legal issues that he basically was responsible for it and it's called DOS AMU 2. So this is basically what you get when you start DOS AMU. This is DOS AMU 2 in a box. So this is when you run it without any command line options. You get a box on your screen which has the DOS emulator and then you can start whatever DOS program you like as long as you've installed it. One way I actually like to run DOS AMU is if I need to do something for for freedom like a compilation or things like that. I run it in dump mode which means it runs in the terminal and it just displays whatever text is given to the terminal. So it actually it doesn't you cannot do any graphics or even text mode utilities that use a full screen that will not work in this mode because it just doesn't understand it. But it's very helpful because if you compile problems you just run as if in a Linux terminal you can go use a scroll back preferential these features. So this is just running it in an X term and it took the screenshot of the X term. Then there's some intermediate mode. So the default is I believe it's SDL or X depending on these libraries you've installed. There's also an S-lang terminal mode which means you can run it in a terminal but all the text mode utilities work okay. As long as you make the terminals 80 by 25 it will work okay. If you use different sizes it may not work. You can run of course many games in DOS AMU. This is one I liked at the time SimCity 2000 but with just about 99% of all DOS games will work in DOS AMU. There's a couple of exceptions that do weird things with VGA graphics or sometimes we're tricks with protected mode and they don't work. But mostly it works and there's also other solutions to run DOS games these days. We have DOS Box which is squarely aimed at games and can handle some of these very weird cases. One of the most heavily weighted protected mode applications that we can run in DOS AMU is Windows 3.1 including networking. So this is a contributed screenshot. It contributed a long time ago to the DOS AMU website running Windows 3.1 with Netscape with the network. So he's running a very old version of Netscape to browse the web. It's probably completely insecure and but I don't understand basic HTML anyway so I don't think it supports Javascript yet. So I was curious. So what use people use DOS AMU for? Of course they run it to run their favorite old DOS games or favorite old DOS applications. So I asked around on the mailing list I said so what do you guys use it for? So I said well some people use it to run very old specialized cross compilers. So they had DOS compilers and they've just never been updated and so you can run it all set up with wrappers. So from the user point of view there are just Linux programs that probably goes via that dump mode. They just type the Linux command and behind the scenes it's starting up the same way and it does an internal exit AMU which quits the emulator and then the user doesn't even know they're running DOS AMU. One user was claiming that they did a yearly fMRS for astrologers with a quick basic IDE. He's slowly porting it to Linux by a database but just to be able to do the porting he has to start somewhere and be able what he's working with and he uses DOS AMU for that. Some people run old DOS CAD CAD programs for the design of electronics and astronomical instruments. There was one user who has a very old silent free personal organizer and he still claims that it's the ideal way of doing his calendar etc. He was nothing of modern films etc. But still he's an old organizer and he had link software from Psyon from 1991 which he then has to connect to his computer. So he's using a USB serial hardware module on his computer and then the serial cable can be connected from the adapter to the Psyon personal organizer and then with DOS AMU he can run that program and link to his organizer. Some people interested in running MIDI sequencers. The MIDI emulation is quite mature, it's been for a while. Some people use it in post terminals so post terminals have been running and still some are running plain DOS for quite a while. I believe Stas Segev had a little bit of a commercial like a paid for project where he made that work. There is also, there's a retro, there's a community of people who are still interested in PCTOS. It's one of the old GUIs that were available for DOS and according to them DOS AMU is one of the best ways of running it. And then there is a group in Scotland I believe. They're using it at university to receive satellite images. They have an old program that uses ISA hardware. There is a hook in the Linux kernel that lets DOS AMU directly talk to ISA hardware and catch the interrupts and he said that ISA motherboards are still for sale so he didn't even have to port it to a PSI motherboard yet. So where does it fit? DOS AMU has somewhat heterogeneous competition. It's competition in open source sense so we're not really fighting for money but of course there's DOS box but whenever you ask to on DOS box user forums about anything that's not a game they say sorry we only do games. So they've done an awesome job with running games. They've been doing very well and trying to emulate exactly the hardware for several computers from the time. There's now even a DOS box X fork that basically tries to even more accurately emulate hardware from the time even when as far as to emulate snow from old CGA monitors. So this is cool if you really want the old experience including the speed etc. from the old days because it uses completely CPU emulations which may have absolute control about what happens. DOS AMU has always been more about performance so we're we're still a waste to run on the on the on the real CPU. And this way it goes faster than DOS box typically but it just depends on the task at hand. And of course we have the heavyweight emulators and virtual machine likes box boxes pure emulator as you might know QM and virtual box are are are more virtual machines they're used all over the place and in most businesses these days but they feel heavy to me compared to DOS AMU. When you run DOS AMU you start it up it starts up in split second and you have direct access to the Linux file system. With these virtual machines you feel like you're more in a separate box that is sort of attached to your computer and you need to set up a network and a network file system and it it it just doesn't feel it feels a bit too remote from the host compared to DOS AMU and just the typical experience of just needing to run an old DOS application. So one of the development challenges we've had over the years with DOS AMU was Linux kernel and the hardware. So every now and then the Linux kernel developers gave us a challenge and we had to adapt otherwise we wouldn't run anymore. So and that sort of stems that DOS AMU was talking very intimately to the Linux kernel. In the beginning DOS AMU was just ran as route I mean people just ran it on their own PC they ran things as route and then well who cares about said UID these were their old 12 days and people were typically not connected to the internet anyway so so it was ran as as route or said UID route with direct VTA hardware access so you basically ran DOS AMU and you open up all the ports to the VTA hardware and you could just display whatever the DOS application sent to the screen it was displayed directly on the monitor. That usually worked very well in the early years sometimes people would burn the monitor but typically it wouldn't happen. Usually what would happen is the system is locked up and you get a black screen you have to reboot your computer and the other thing they could do was direct FAT partition disk access because people typically had a FAT partition so you could just say to DOS AMU just access that partition as if it's a DOS partition and will this work just just make sure that there are no Linux programs running writing to that partition at the same time we can get really odd things happening. So we had some some changes first thing is that there was an memory mapping of procself X which means that you have the image of executable can be mapped into memory and that way you can inspect it and even map it a different place in memory which we have to use for a system called EMS expanded memory mapping which has a piece of memory that is banked into a particular place in DOS memory. So we had to use the different methods we can also do it via file or SHM open so that day cables are alternatives which were useful. What was harder is the disabled M-map of page zero so this is something for the VM86 system call it maps the low memory page zero for DOS to page zero in Linux user space. At some point they found out that people were exploiting that zero page to do very security exploits and for security reason it was disabled the M-map for page zero by default. You can still set it via sysctl. However we need to do ways around so that people who didn't have root privilege for instance didn't have to or were concerned about security didn't have to set that sysctl and we had to use CPU emulation or later on KVM which I'll get in a couple slides instead of VM86. The DPMI stuff can still be used because modify LBT is another system call we can offset the system base addresses. Also with kernel mode setting direct VGA was gone for most people most computers it didn't work anymore but we had VGA emulation and it usually works okay. Of course x8664 it doesn't do VM86 it doesn't have V86 mode anymore and in the beginning we just had to use CPU emulation later on KVM came to the rescue. So DOS ME2 which is the Stas Serges product. He's been doing a lot of heavy development at some point it was a little bit unstable then it stabilized again they've been doing a lot of bug fixes. A lot of internal changes made things a little bit more reliable in some cases a lot more reliable and another cool thing is that there was a little product called the HX DOS extender which can run Windows 32 binaries in DOS and it works in in bare DOS but it also works in DOS ME2 and the support for that has been improved a lot and so you can run most common line with 32 binaries in DOS ME2 it's kind of a little alternative to wine in some cases. So for KVM basically I was my contribution to DOS ME2 I read an article on LWN very useful that explained how to use KVM and even cable a little example how to how to get into a very basic DOS style setup and I implement that into into DOS ME2 and I found out that that that still gives a significant performance boost. I went from doing like a compilation of a DOS utility named command.com. We went from 57 seconds with our fastest emulator the JIT emulator just in a time or even four minutes with the simulated CPU emulators that we use as a backup in case the JIT fails it went to nine and a half seconds so it's still using it on bare hardware was quite a boost and so at this point there was no advantage to booting your computer in using an i386 kernel just because it provided VM86 because the KVM is just as fast. We can also do the protected mode in KVM but it hasn't been finished yet. So that was basically the overview for for DOS ME2 now to move to free DOS. So free DOS started a little bit later than DOS ME2 in 1994 it's also 24 years ago so this was Jim Hall who came up with the idea of starting a free DOS when MS DOS was sort of winding down and being replaced by Windows 95. It still had a sort of DOS under the hood DOS 7.1, DOS 7.0 but at that point he thought well if we can make a free Unix-like operating system we can also make a free DOS-style operating system so he was starting the project and cut some people around him and at the same time he cut somebody Pat Filani who had written a DOS kernel in C he contributed the DOS C kernel to the free DOS project and that sort of cut it started in getting a kernel and then developed that further. So there was a first release in 1998 called free DOS Beta-1 and then that moved into few other betas and eventually free DOS 1.0 was 2006 by that time free DOS was quite stable and it was actually seen all over the place Dell and other manufacturers put as a backup operating system in case they wanted to ship a computer without an operating system which they couldn't do so they just put free DOS on there and it's probably also in various computers in your backup BIOS updates partition or things like that I've seen I've seen it all over the place. So this is the free DOS 1.0 announced on the website that's when about 10 years ago and a few years after only 2016 there was updated to free DOS 1.2 mostly update of the utilities a bit more complete and at the moment there's some discussion on the mailing list about what what should do for the next free DOS version 2.0. So there's this there's a strong consensus on the mailing list that that compatibility is key I mean if you change the operating system to 32-bit operating system you may end up with something that's not compatible anymore because it's really thoroughly a 16-bit OS with DOS programs that do all kind of weird things in memory and it may not work anymore. You may get some compatibility but it may not be completely compatible anymore. So what is a modern DOS tools and utilities are there lots of things in free DOS that the original DOS didn't have but they're mostly part of the tools. The command.com is a lot friendlier than where Microsoft originally shipped. There's VAT32 support. There's all kind of things in the tools and utilities that were not there at the time. And there's a couple things that may not be needed anymore some old tools that hardly anybody uses but I personally not sure if these should go. They have their use and they're only very small so if you remove them you're saving maybe 150 kilobytes so it's not a big deal. One of the things that's been plaguing the distribution of DOS for a while is the distribution issue. So at some points around 2000 distribution started to get more conscious about various licensing issues and particularly it was discussed in Debian. The problem was that DOS MU cannot run without a DOS. You need to provide a DOS. It isn't included like in DOS box. It includes its own little DOS enough to play games but in DOS MU you need a DOS or the way it doesn't boot. However that DOS was still compiled in the 90s. It was compiled with a Borland C compiler and that's proprietary. So you have a build dependency to get free DOS which in turn is needed for DOS MU. So for instance this was like Debian said oh we need to move the whole thing into the contrip repository instead of main so it wasn't shipped anymore unless you downloaded it somewhere. So eventually we got an open source compiler finally which was OpenWatcom. OpenWatcom was released by Cybase who wasn't interested in it anymore. They basically bought Waterloo software but they released it but they based their license on an Apple Public Software license and it has a lot of clots in it which was somewhat dubious and even some people think what was the OSI smoking when they approved that license. So it's released on a license that is open source but not free software. This is what live is but in practice OpenWatcom is considered as open sources on GitHub etc. There's a version 2 in the works. However it would still be nice to compile these free DOS utilities for GCC to make it properly free software and there's been some attempts to have a 16-bit code send added to GCC. This only happened quite recently compared to the development of GCC. In the 90s and 80s when 16-bit was very common GCC was free to bit only. So there were some 16-bit contributions. Andrew Jenner first was Rusk Ingerman Lambertson in 2007. The patch was sort of forgotten. Andrew Jenner refined it and made it based on TCC 6.2 and now there's another guy TK Tia who contributed a small model and far pointers to this IA16 LTC. It actually creates elf objects. I've been emailing and bugging his GitHub repository with quite a few books when I tried to compile the free DOS kernel with it and eventually I succeeded and I had the free DOS kernel compiled with GCC and the same with the free DOS command com. It needs a few tricks with linker scripts etc. It's a bit too technical for this for this talk but it works. Stas has also been bordered by this hiatus and he started to do a different thing. This slide has a lot of text on it but what he's been doing is basically try to rewrite the free DOS kernel in free to bit just to have the assembly code in 16-bit mostly C code in free to bit and then have little steps to switch back and forth to protected mode. He was quite proud that he got it somewhat working and has to copyright notice debugging the protected mode in CDB and the real mode in the DOS enemy debugger utility and he wanted me to share it with you so because he's quite proud of it. There's actually quite a work doing this all in very modern C++ template programming. So maybe at some point we will finally have some kind of reliable free to bit DOS kernel after all. So this is just a bunch of links where you can find these DOS M3 DOS utilities but I think I've covered everything now just in time and thank you for your attention. We have a few minutes for questions so don't be shy. Just make sure you repeat. Yes. Why not use DJGPP to compile DOS code? We do for 32-bit. That's a very mature solution was mature in the 90s but it does new 16-bit. The question is how does free DOS work with IBM non-competibles. I don't think there is much but it relies on certain BIOS functions being available. So at the moment there's some efforts to get free DOS working on some things like core boot and things like that and they actually implement these BIOS functions typically. So it hasn't been a big problem in practice but maybe there's some very old computers that are not completely IBM compatible. There hasn't been any special effort for that that I know of just because nobody had them. Yeah. If it's possible to yes so he's asking if it's possible to to load free DOS via a grub. On the modern computer it's possible you may have to switch off secure boot and all kind of UAV stuff make it as basic legacy as possible and then you can load free DOS via a grub via a chain loader. Just a little 512 bytes boot sector style piece of code that the grub can load and in turn that loads the free DOS kernel. It's possible. Yeah. A tiny bit. It means that for instance when DOS box implemented their free GA emulator they they looked at our code because I could see a comment in the free GA emulator on a nice one from DOS emulator and I did the same thing that I ported a few things from DOS box into DOS emulator. But beyond a little bit of porting there's not any code sharing. They're very different code bases. DOS box from the from the get go was developed as a portable C program that runs with STL whereas DOS emulator is a much longer history of being more Linux specific. Another question. Games were protected with very special disc-capped formatting. Copy write protection. How do we deal with special formatting for old games? In some cases we can't. I mean often often they are for these kind of things apparently their cracks available is not very legal but I think that's what people do. Yeah. When they want to run these things. Yes. I mean but yeah. Just to add to your question I mean it is possible to emulate a disc-capped and just have a have an image as a floppy drive. Yeah. OK. Yeah. Yeah. So so very few computers have floppy drives anymore but you can have a colon as a 720 kilobyte image or whatever image you throw that. Yeah. Could be easier with you so that is VMware. DOS 1.0 running under VMware but it's more difficult. OK. Yeah. Now with DOS emulator is one of the configuration options that you can set the a drive to an image file. Yeah. Thanks.