License and readme

This commit is contained in:
DeaDvey 2025-06-07 15:06:10 +01:00
parent c99ecaa620
commit 392a70bb39
15 changed files with 40 additions and 12170 deletions

74
doc/LICENSE.TXT → LICENSE Executable file → Normal file
View File

@ -1,37 +1,37 @@
==================================================================
MikeOS -- License
==================================================================
Copyright (C) 2006 - 2022 MikeOS Developers -- http://mikeos.sourceforge.net
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name MikeOS nor the names of any MikeOS contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY MIKEOS DEVELOPERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL MIKEOS DEVELOPERS BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
==================================================================
==================================================================
MikeOS -- License
==================================================================
Copyright (C) 2006 - 2020 MikeOS Developers -- http://mikeos.sourceforge.net
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name MikeOS nor the names of any MikeOS contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY MIKEOS DEVELOPERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL MIKEOS DEVELOPERS BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
==================================================================

3
README.md Normal file
View File

@ -0,0 +1,3 @@
Kernel written in Assmebly
I don't really know what I'm doing
I am using the MikeOS bootloader (which is why I've got the MikeOS license)

Binary file not shown.

Binary file not shown.

File diff suppressed because it is too large Load Diff

View File

@ -1,41 +0,0 @@
==================================================================
MikeOS -- Open source 16-bit operating system for x86 PCs
Copyright (C) 2006 - 2022 MikeOS Developers -- see doc/LICENSE.TXT
==================================================================
PROJECT ADMIN (MAIN CODE AND HANDBOOKS)
* Mike Saunders -- okachi@gmail.com
DEVELOPMENT
* E Dehling
* Ian Seyler
* John Endler
* Joshua Beck
* Justin Tokarchuk
* Mark M
* Matej Horvat
* Michael van Tellingen
* Mike Gonta
* Pablo Gonzales
* Peter Nemeth
* Paulo Valongo
* Takayoshi Sasano
* Tomasz Gorol
* Tslil Clingman
* Walt Nagel
* Yutaka Saiko
WEBSITE, DOCS AND ARTWORK
* Nitin Reddy Katkam -- logo and site design
* Paul Sommers -- Handbook API reference
* Helen Ewart -- MikeOS cat mascot
==================================================================

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,505 +0,0 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>The MikeOS System Developer Handbook</title>
<style type="text/css">
body {
font-family: sans-serif;
}
h1 {
margin-top:5px;
color: #A00000;
}
h2 {
color: #A00000;
}
h3 {
margin-top:5px;
color: #A00000;
}
hr {
border: 0;
color: #A00000;
background-color: #A00000;
height: 3px;
}
pre {
background-color: #F0F0F0;
border: 5px solid #F0F0F0;
}
a {
text-decoration: none;
color: #0000F0;
}
a:visited {
text-decoration: none;
color: #0000F0;
}
a:hover {
text-decoration: underline;
}
li {
margin-left: -1ex;
}
</style>
</head>
<body>
<table border="0" cellpadding="10">
<tr>
<!-- NAVIGATION PANEL -->
<td style="border:1px solid black; width:160px;" valign="top">
<h3>Navigate</h3>
<p><strong>Overview</strong></p>
<ul>
<li><a href="#introduction">Introduction</a></li>
<li><a href="#structure">Structure</a></li>
<li><a href="#memorymap">Memory map</a></li>
<li><a href="#codepath">Code path</a></li>
</ul>
<p><strong>Building</strong></p>
<ul>
<li><a href="#buildlinux">Linux</a></li>
<li><a href="#buildwindows">Windows</a></li>
<li><a href="#buildothers">Others</a></li>
</ul>
<p><strong>Modifying</strong></p>
<ul>
<li><a href="#modoverview">Overview</a></li>
<li><a href="#systemcalls">System calls</a></li>
<li><a href="#patches">Patches</a></li>
</ul>
<p><strong>Extra</strong></p>
<ul>
<li><a href="#help">Help</a></li>
<li><a href="#license">License</a></li>
</ul>
</td>
<!-- MAIN CONTENT PANEL -->
<td valign="top">
<h1>The MikeOS System Developer Handbook</h1>
<h3>For version 4.7, 9 April 2022 - (C) MikeOS Developers</h3>
<p>This documentation file explains how to build MikeOS from the source code, make changes
to the kernel, and add new system calls. If you have any questions, see
<a href="http://mikeos.sourceforge.net">the MikeOS website</a> for contact details
and mailing list information.</p>
<p>Click the links on the left to navigate around this guide.</p>
<br />
<hr noshade="noshade" />
<h2>Overview</h2>
<a name="introduction"></a>
<h3>Introduction</h3>
<p>The MikeOS kernel is written in 16-bit x86 real mode assembly language. This provides easy access
to BIOS routines for handling the keyboard, screen and floppy drive, so that we don't need complicated
drivers. Therefore most of the code is focused on actual OS aspects: loading programs,
system calls and so forth.</p>
<p>Additionally, MikeOS avoids the real mode segmentation complications by existing in a single 64KiB segment.
The first 32KiB (0 - 32767) of RAM is reserved for the kernel; the second 32KiB is for external program code
and memory.</p>
<br />
<a name="structure"></a>
<h3>Structure</h3>
<p>These are the most important files and directories in the MikeOS zip file:</p>
<ul>
<li><strong>source/</strong> -- Contains the entire OS source code</li>
<li><strong>source/bootload/</strong> -- Source to generate BOOTLOAD.BIN, which is added to the disk image when building</li>
<li><strong>source/features/</strong> -- Components of MikeOS such as FAT12 support, string routines, the BASIC interpreter etc</li>
<li><strong>source/kernel.asm</strong> -- The core kernel source file, which pulls in other source files</li>
<li><strong>programs/</strong> -- Source code for programs added to the disk image</li>
</ul>
<br />
<a name="memorymap"></a>
<h3>Memory map</h3>
<p>This is the makeup of the 64KiB memory segment after MikeOS has loaded:</p>
<br />
<center>
<table border="1" cellpadding="10">
<tr><td><center><br />
<strong>0 - 24575 (hex: 0h - 5FFFh)</strong><br />
24KiB kernel executable code<br />
<br />- - - - - - - - - - - - - - -<br /><br />
<strong>24576 - 32767 (hex: 6000h - 7FFFh)</strong><br />
8KiB kernel disk operation buffer<br /><br />
</center></td></tr>
<tr><td><center>
<strong>32768 - 65535 (hex: 8000h - FFFFh</strong><br />
32KiB space for external programs</center></td></tr>
</table>
</center>
<br />
<p>So, the first 32KiB is devoted to the MikeOS kernel code and its 8KiB buffer for performing disk operations.
After that we have another 32KiB of memory, this time for external programs. These are loaded at the 32KiB point
and hence need to be ORGed to 32768 as described in the App Developer Handbook.</p>
<br />
<a name="codepath"></a>
<h3>Code path</h3>
<p>When the PC starts up, it loads the bootblock, <strong>BOOTLOAD.BIN</strong>, that was inserted into
the first sector (512 bytes) of the floppy disk image by the build script. It loads this at memory location
31744 (7C00h in hex) and begins executing it.</p>
<p><strong>BOOTLOAD.BIN</strong> then scans the floppy disk for <strong>KERNEL.BIN</strong> and loads it at
memory location <strong>2000h:0000h</strong>. Here, the 2000h is the segment and 0000h is the offset
in that segment -- you don't need to concern yourself with this, but effectively it means that the kernel is
loaded at location 131072 (128KiB) in the PC's RAM. (You get a complete memory location by multiplying the segment
by 16 and adding the offset.)</p>
<p>Once the bootloader has loaded the kernel, it jumps to memory location 131072 (aka 2000h:0000h)
to begin executing it. After this, for simplicity we ignore segments and just use offsets (0000h to FFFFh),
thereby giving us 64KiB of RAM to use.</p>
<p>At the start of the kernel we have a series of <strong>jmp</strong> instructions.
Why are these here? Well, the system calls are in semi-random places in the kernel executable.
As MikeOS evolves, the exact locations of these system calls shifts around; an external program can't guarantee
where they are. So we have a list of vectors right at the very start of the kernel which <strong>jmp</strong> to these
calls, so an external program can <strong>call</strong> these vectors and know that they'll never move!</p>
<p>There's a <strong>jmp</strong> just before these vectors to skip over them, and then the main kernel execution
starts, setting up various things and offering the user a choice of a program list or command line interface.</p>
<br />
<hr noshade="noshade" />
<h2>Building</h2>
<a name="buildlinux"></a>
<h3>Linux</h3>
<p><strong>Build requirements:</strong> the NASM assembler, dosfstools package, 'mkisofs' utility and root access. We need root
access because we loopback-mount the floppy disk image to insert our files.</p>
<p>To build MikeOS, open a terminal and switch into the expanded MikeOS package. Enter <strong>sudo bash</strong>
in Ubuntu-flavoured distros, or just <strong>su</strong> in others, to switch to the root user. Then enter:</p>
<pre>
./build-linux.sh
</pre>
<p>This will use NASM to assemble the bootloader, kernel and supplied programs, then write the bootloader to the
<strong>mikeos.flp</strong> floppy disk image in the <strong>disk_images/</strong> directory. (It writes the 512-byte
bootloader to the first sector of the floppy disk image to create a boot sector and set up a DOS-like
filesystem.) Next, the build script loopback-mounts the <strong>mikeos.flp</strong> image onto the filesystem - in other
words, mounting the image as if it was a real floppy. The script copies over the kernel (<strong>kernel.bin</strong>)
and binaries from the <strong>programs/</strong> directory, before unmounting the floppy image.</p>
<p>With that done, the script runs the 'mkisofs' utility to generate a CD-ROM ISO image of MikeOS, injecting
the floppy image as a boot section. So we end up with two files in the <strong>disk_images/</strong> directory:
one for floppy disks and one for CD-Rs. You can now use them in an emulator or on a real PC as described in
the Running section above.</p>
<br />
<a name="buildwindows"></a>
<h3>Windows</h3>
<p>Get the latest version of NASM for Windows from <a href="http://www.nasm.us/pub/nasm/releasebuilds/">this site</a>
(look for the 'win32' package. Then extract the <strong>nasm.exe</strong> file into your Windows folder (or somewhere in the path).</p>
<p>The ImDisk Virtual Disk Driver is needed since Windows does not have a
built-in mechanism for loopback drives. Get it from <a href="http://www.ltr-data.se/files/imdiskinst.exe">here</a>
(or Google it if the link is outdated). After downloading run imdiskinst.exe to install. Follow the default prompts
during the install. Also get <a href="http://www.osdever.net/downloads/other/pcopy02.zip">PartCopy</a> for copying
the bootloader on to the disk image.</p>
<p>To build MikeOS, double-click on <strong>build-win.bat</strong> or run it from the command line.
This batch file calls NASM to do the work needed to compile MikeOS and its applications.
This script mounts the floppy disk image as if it were a real disk, using:</p>
<pre>
imdisk -a -f mikeos.flp -s 1440K -m B:
</pre>
<p>You can use that command outside of <strong>build-win.bat</strong> if you want to add files to <strong>mikeos.flp</strong>,
and unmount it with:</p>
<pre>
imdisk -d -m B:
</pre>
<p>Lastly, to test in the <a href="http://www.omledom.com">QEMU PC emulator</a>,
Extract QEMU to somewhere on your computer -- <strong>C:\</strong> is best. Then enter: the following to run MikeOS under QEMU:</p>
<pre>
qemu.exe -L . -m 4 -boot a -fda mikeos.flp -soundhw all -localtime
</pre>
<p>Make sure you put the proper path names in! Ask on the mailing list if you have any problems.</p>
<br />
<a name="buildothers"></a>
<h3>Others</h3>
<p>Along with the scripts for building on Linux and Windows, you'll also find scripts for macOS and OpenBSD.
These have not been as thoroughly tested as the others, so if you find any glitches, please let us know!</p>
<p>If you want to make a build script for a new platform, it needs to:</p>
<ol>
<li>Assemble the bootloader and add it to the first sector of <strong>mikeos.flp</strong></li>
<li>Assemble the kernel and copy it onto the floppy</li>
<li>Assemble the add-on programs and copy them onto the floppy</li>
</ol>
<p>So you will need some way of copying the 512 byte bootsector into a floppy image, and loopback mounting the
image to copy across the kernel and programs.</p>
<br />
<hr noshade="noshade" />
<h2>Modifying</h2>
<a name="modoverview"></a>
<h3>Overview</h3>
<p>To test out code, the simplest approach is to create a new app in the <strong>programs/</strong> directory, build
MikeOS and run your program. You can then be guaranteed that your code isn't interfering with the kernel code (at least
at the assembling stage!). When you're happy with it, you may want to introduce it into <strong>source/kernel.asm</strong>
or a specific file in <strong>source/features/</strong>.</p>
<p>Note that the files in <strong>source/features/</strong> correspond to the system calls in <strong>programs/mikedev.inc</strong>
(and detailed in the App Developer Handbook), but those source files also include internal calls that are used by the kernel and
are not accessible to user programs. So use 'grep' or the search tool of your choice to find specific calls if they're not
available through the API.</p>
<br />
<a name="systemcalls"></a>
<h3>System calls</h3>
<p>Adding new system calls is easy and fun - it extends MikeOS! So if you want to help out, this is the best way to start.
Open up <strong>source/features/screen.asm</strong> in a text editor and paste in the following after the header text:</p>
<pre>
; -----------------------------------------------------------------
; os_say_hello -- Prints 'Hello' to the screen
; IN/OUT: Nothing
os_say_hello:
pusha
mov si, .message
call os_print_string
popa
ret
.message db 'Hello', 0
</pre>
<p>There we have it: a new system call that prints 'Hello' to the screen. Hardly a much-needed feature, but it's
a starting point. The first three lines are comments explaining what the call does, and what registers it accepts
or returns (like variable passing in high-level languages). Then we have the <strong>os_say_hello:</strong> label
which indicates where the code starts, before a <strong>pusha</strong>.</p>
<p>All system calls should start with <strong>pusha</strong> and end with <strong>popa</strong> before <strong>ret</strong>:
this stores registers on the stack at the start, and then pops them off at the end, so that we don't end up changing
a bunch of registers and confusing the calling program. (If you're passing back a value, say in AX, you should
store AX in a temporary word and drop it back in between the <strong>popa</strong> and <strong>ret</strong>, as
seen in <strong>os_wait_for_key</strong> in <strong>keyboard.asm</strong>.)</p>
<p>The body of our code simply places the location of our message string into the SI register, then calls another
MikeOS routine, <strong>os_print_string</strong>. You can freely call other routines from your own system call.</p>
<p>Once we've done this, we can access this routine throughout the kernel. But what about external programs? They
have no idea where this call is in the kernel! The trick we use is <strong>vectors</strong> - a bunch of <strong>jmp</strong>
instructions at the start of our kernel code, which jump to these routines. Because these vectors are at the start,
they never change their position, so we always know where they are.</p>
<p>For instance, right now, your new system call may be at 0x9B9D in the kernel. But if you add another call before it,
or someone else does, it may move to 0x9FA6 in the kernel binary. We simply don't know where it's going to be. But
if we put at vector at the start of our kernel, before anything else happens, we can use that as the starting point
as the vector will never move!</p>
<p>Open up <strong>source/kernel.asm</strong> and scroll down to the list of system call vectors. You can see they start
from 0003h. Scroll to the bottom of the list and you'll see something like this:</p>
<pre>
jmp os_string_tokenize ; 00CFh
</pre>
<p>The comment here indicates where this bit of code lies in the kernel binary. Once again, it's static, and
basically says: if your program wants to call <strong>os_string_tokenize</strong>, it should call 00CFh, as
this jumps to the required routine and will never change position.</p>
<p>Let's add a vector to our new call. Add this beneath the existing vectors:</p>
<pre>
jmp os_say_hello ; 00D2h
</pre>
<p>How do we know this <strong>jmp</strong> is at 00D2h in the kernel binary? Well, just follow the pattern in the
<strong>jmp</strong>s above - it's pretty easy to guess. If you're unsure, you can always use
<strong>ndisasm</strong> to disassemble the kernel and look for the location of the final
<strong>jmp</strong> in the list.</p>
<p>That's all good and well, but there's one last thing: people writing external programs don't want to
call an ugly number like 00C9h when they run our routine. They want to access it by name, so we need
to add a line to <strong>mikedev.inc</strong> in the <strong>programs/</strong> directory:</p>
<pre>
os_say_hello equ 00D2h ; Prints 'Hello' to screen
</pre>
<p>Now, any program that includes <strong>mikedev.inc</strong> will be able to call our routine by name.
Et voila: a brand new system call for MikeOS!</p>
<br />
<a name="patches"></a>
<h3>Patches</h3>
<p>If you've made some improvements or additions to MikeOS and wish to submit them, great! If they're small changes -
such as a bugfix or minor tweak - you can paste the altered code into an email. Explain what it does and where it
goes in the source code, and if it's OK, we'll include it.</p>
<p>If your change is larger (e.g. a system call) and affects various parts of the code, you're better off with a
patch. On UNIX-like systems such as Linux, you can use the <strong>diff</strong> command-line utility to generate
a list of your changes. For this, you will need the original (release) source code tree of MikeOS, along with the
tree of your modified code. For instance, you may have the original code in a directory called
<strong>mikeos-4.2/</strong> and your enhanced version in <strong>new-mikeos-4.0/</strong>.</p>
<p>Switch to the directory beneath these, and enter:</p>
<pre>
diff -ru mikeos-4.2 new-mikeos-4.2 &gt; patch.txt
</pre>
<p>This collates the differences between the two directories, and directs the output to the file <strong>patch.txt</strong>.
Have a look at the file to make sure it's OK (you can see how it shows which lines have changed), and then attach the
file to an email.</p>
<p>Please post fixes and patches to the MikeOS mailing list (see <a href="http://mikeos.sourceforge.net">the website</a>).</p>
<br />
<hr noshade="noshade" />
<h2>Extra</h2>
<a name="help"></a>
<h3>Help</h3>
<p>If you have any questions about MikeOS, or you're developing a similar OS and want
to share code and ideas, go to <a href="http://mikeos.sourceforge.net/">the MikeOS website</a>
and join the mailing list as described.</p>
<br />
<a name="license"></a>
<h3>License</h3>
<p>MikeOS is open source and released under a BSD-like license (see <strong>doc/LICENSE.TXT</strong>
in the MikeOS <strong>.zip</strong> file). Essentially, it means you can do anything you like with the
code, including basing your own project on it, providing you retain the license file and give credit
to the MikeOS developers for their work.</p>
<br />
<hr noshade="noshade" />
</td>
</tr>
</table>
</body>
</html>

View File

@ -1,469 +0,0 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>The MikeOS User Handbook</title>
<style type="text/css">
body {
font-family: sans-serif;
}
h1 {
margin-top:5px;
color: #69A000;
}
h2 {
color: #69A000;
}
h3 {
margin-top:5px;
color: #69A000;
}
hr {
border: 0;
color: #69A000;
background-color: #69A000;
height: 3px;
}
pre {
background-color: #F0F0F0;
border: 5px solid #F0F0F0;
}
a {
text-decoration: none;
color: #0000F0;
}
a:visited {
text-decoration: none;
color: #0000F0;
}
a:hover {
text-decoration: underline;
}
li {
margin-left: -1ex;
}
</style>
</head>
<body>
<table border="0" cellpadding="10">
<tr>
<!-- NAVIGATION PANEL -->
<td style="border:1px solid black; width:160px;" valign="top">
<h3>Navigate</h3>
<p><strong>Booting</strong></p>
<ul>
<li><a href="#diskimages">Disk images</a></li>
<li><a href="#writing">Writing</a></li>
<li><a href="#realpcs">Real PCs</a></li>
<li><a href="#emulators">Emulators</a></li>
</ul>
<p><strong>Running</strong></p>
<ul>
<li><a href="#usage">Usage</a></li>
<li><a href="#programs">Programs</a></li>
<li><a href="#copyingfiles">Copying files</a></li>
<li><a href="#monitor">Monitor</a></li>
<li><a href="#serialport">Serial port</a></li>
</ul>
<p><strong>Extra</strong></p>
<ul>
<li><a href="#help">Help</a></li>
<li><a href="#license">License</a></li>
</ul>
</td>
<!-- MAIN CONTENT PANEL -->
<td valign="top">
<h1>The MikeOS User Handbook</h1>
<h3>For version 4.7, 9 April 2022 - (C) MikeOS Developers</h3>
<p>This documentation file explains how to boot and use the MikeOS operating system on a real PC or an
emulator. If you have just downloaded MikeOS and want to run it, this is the guide you need. If you have
any questions, see <a href="http://mikeos.sourceforge.net">the MikeOS website</a> for contact details
and mailing list information.</p>
<p>Click the links on the left to navigate around this guide.</p>
<br />
<hr noshade="noshade" />
<h2>Booting</h2>
<a name="diskimages"></a>
<h3>Disk images</h3>
<p>After you have extracted the MikeOS <strong>.zip</strong> file, switch into the
<strong>disk_images/</strong> directory and you'll see three files:</p>
<ul>
<li><strong>mikeos.flp</strong> -- Floppy disk image containing MikeOS and programs</li>
<li><strong>mikeos.dmg</strong> -- Same as above, but with a Mac-friendly extension</li>
<li><strong>mikeos.iso</strong> -- CD ISO image built using the floppy disk image</li>
</ul>
<p>So, these files are virtual disk images that you can write to real floppy disks or
CD-Rs, or run in a PC emulator as described in a moment.</p>
<br />
<a name="writing"></a>
<h3>Writing</h3>
<p>For running MikeOS on a real PC, you will need to write one of the virtual disk images
to physical media. If you have a USB key then this is simple -- we can write the floppy disk
image to the USB key, and the PC will boot it like a virtual floppy.</p>
<p>On Linux, insert your USB key and unmount it when it appears (but don't remove it). Then open a command line
window and enter <strong>dmesg</strong> to view the kernel messages. You will see an indication at the end of the messages of the device you just plugged
in -- eg <strong>/dev/sdb</strong>. Note that you just need the device, eg /dev/sdb, rather than the number (eg /dev/sdb1). Then enter (in the disk_images directory):</p>
<pre>dd if=mikeos.flp of=/dev/sdb</pre>
<p>Of course, replace sdb with the device node. The key is now ready for booting.</p>
<p>On Windows, download the open source <a href="http://translate.google.com/translate?u=http%3A%2F%2Fshounen.ru%2Fsoft%2Fflashnul%2F&amp;hl=en&amp;ie=UTF8&amp;sl=ru&amp;tl=en">Flashnul</a> program, plug in your USB key and
enter <strong>flashnul -p</strong> to get a list of drives. When you've spotted your USB key, enter
<strong>flashnul [number] -L mikeos.flp</strong> (in the disk_images directory), replacing [number]
with the number you got before. The key is now ready for booting.</p>
<p>Note: if you plug your USB key back into the machine, the operating system may try to alter the
partition structure and stop it from working properly. So treat it as a MikeOS-only key until you
want to reformat it for normal use.</p>
<p>For floppy disks, on Windows you can use a program called <a href="http://www.chrysocome.net/rawwrite">RawWrite</a>
to copy <strong>mikeos.flp</strong> to a floppy disk. On Linux, use the <strong>dd</strong>
utility like this:</p>
<pre>dd if=mikeos.flp of=/dev/fd0</pre>
<p>If you want to run MikeOS on a machine that doesn't have a floppy drive and doesn't
boot from USB keys, you can burn and boot the <strong>mikeos.iso</strong> CD image. Any decent Windows CD burning software will
allow you to write an ISO image to a CD-R; if you don't have one, try <a href="http://infrarecorder.org">InfraRecorder.</a></p>
<p>On Linux, a graphical burning program such as K3b should do the trick, or you can use
the command line:</p>
<pre>cdrecord -dao dev=/dev/cdrom mikeos.iso</pre>
<br />
<a name="realpcs"></a>
<h3>Real PCs</h3>
<p>At a minimum, any 386 PC with 1MB of memory and a keyboard should be able to run MikeOS. In
fact, you may be able to get it running on an older machine -- please do let us know if so! Just
start your PC with the MikeOS floppy, CD-ROM or USB key inserted, and you should see the initial
dialog screen.</p>
<p>On some systems, you may need to change the boot order in your BIOS so that the PC boots
from the floppy, CD or USB key rather than the hard drive.</p>
<br />
<a name="emulators"></a>
<h3>Emulators</h3>
<p>A quick way to try MikeOS, and one that doesn't involve writing disk images to physical media,
is to use an emulator. This is particularly useful if you're writing MikeOS software or changing
the OS as described in the other two Handbooks.</p>
<p>Some of the best emulators:</p>
<ul>
<li><strong>QEMU</strong> -- Small, simple and open source (<a href="http://www.qemu.org">link</a>)</li>
<li><strong>VirtualBox</strong> -- Very powerful with a good GUI (<a href="http://www.virtualbox.org">link</a>)</li>
<li><strong>VMware</strong> -- Popular proprietary virtualisation app (<a href="http://www.vmware.com">link</a>)</li>
<li><strong>Bochs</strong> -- Takes a bit of work to set up, but good debugging tools (<a href="http://bochs.sourceforge.net">link</a>)</li>
</ul>
<p>For VirtualBox and VMware, configure the boot device to use the MikeOS floppy disk or CD ISO image.
With QEMU on Linux, run <strong>test-linux.sh</strong>, or for QEMU on Windows switch into the directory
where you installed the emulator and enter:</p>
<pre>
qemu.exe -L . -m 4 -boot a -fda mikeos.flp -soundhw all -localtime
</pre>
<p>You will need to change the path to <strong>mikeos.flp</strong> accordingly.</p>
<br />
<hr noshade="noshade" />
<h2>Running</h2>
<a name="usage"></a>
<h3>Usage</h3>
<p>When MikeOS starts up, you'll see a dialog box which gives you the option of a program
list of a command line interface. Using the cursor keys and Enter, choose OK for the former
and Cancel for the latter.</p>
<p>In the program list you can select a <strong>.BIN</strong> or <strong>.BAS</strong> program with the up/down cursor
keys and hit Enter to run it. Also, you can press Esc to return back to the original list/CLI
selection screen.</p>
<p>At the command line, enter <strong>DIR</strong> to show a list of programs, and <strong>HELP</strong>
to display inbuilt commands. You can run a program by entering the full filename (eg <strong>EDIT.BIN</strong>)
or just the name without the extension (eg <strong>EDIT</strong>). There are also file management commands such
as COPY, REN, DEL and SIZE.</p>
<br />
<a name="programs"></a>
<h3>Programs</h3>
<p>MikeOS includes several programs to perform various tasks and demonstrate features of the OS, such as:</p>
<ul>
<li><strong>EDIT.BIN</strong> -- Simple full-screen text editor (Unix-type text files only)</li>
<li><strong>VEDIT.BIN</strong> -- An alternative Vi-like editor</li>
<li><strong>EXAMPLE.BAS</strong> -- Demonstration of BASIC features (open it in EDIT.BIN to explore)</li>
<li><strong>FILEMAN.BIN</strong> -- Delete, rename and copy files on the floppy disk</li>
<li><strong>HANGMAN.BIN</strong> -- Guess the names of cities around the world</li>
<li><strong>MEMEDIT.BAS</strong> -- Colourful, powerful memory editor</li>
<li><strong>DRAW.BAS</strong> -- ASCII art drawing program</li>
<li><strong>CALC.BAS</strong> -- Powerful calculator</li>
<li><strong>SUDOKU.BAS</strong> -- Sudoku game</li>
<li><strong>LIFE.BIN</strong> -- An implementation of Conway's Game of Life</li>
<li><strong>CF.BAS</strong> -- Cosmic Flight game</li>
<li><strong>FORTH.BIN</strong> -- Forth interpreter</li>
<li><strong>PONG.BIN</strong> -- Pong game (press Esc to exit)</li>
<li><strong>LINES.BIN</strong> -- VGA video mode demo (press F to speed up, S to slow down, C to clear and Esc to exit)</li>
<li><strong>MUNCHER.BAS</strong> -- Snake-like game (use WASD keys)</li>
<li><strong>ADVNTURE.BAS</strong> -- A text adventure</li>
<li><strong>KEYBOARD.BIN</strong> -- Musical keyboard; use the bottom row of keys to play and Q to quit</li>
<li><strong>MONITOR.BIN</strong> -- Simple machine code monitor (see below)</li>
<li><strong>TERMINAL.BIN</strong> -- Minicom-like serial terminal program (see below)</li>
<li><strong>VIEWER.BIN</strong> -- Views text files and 320x200x16 PCX images such as <strong>SAMPLE.PCX</strong></li>
<li><strong>CODEBYTE.BIN</strong> -- Machine code editor; load <strong>HELLO.512</strong> for an example</li>
</ul>
<p>Note that <strong>FILEMAN.BIN</strong> and <strong>EDIT.BIN</strong> try to write to the floppy drive,
so if you've booted from a CD-R and try to manipulate files you will see write errors as it's a read-only
medium after burning.</p>
<br />
<a name="copyingfiles"></a>
<h3>Copying files</h3>
<p>If you've written MikeOS to a real floppy disk, you can just copy extra files
onto that disk in your file manager. But if you want to add files to the floppy disk images,
that requires a bit of extra work -- you need to access the disk image as if it was a real
floppy. First up is Linux: switch to the MikeOS main directory, then enter the following
commands as root:</p>
<pre>
mkdir looptmp
mount -o loop -t vfat disk_images/mikeos.flp looptmp
</pre>
<p>Now the contents of the MikeOS virtual floppy disk image are accessible in the newly-created <strong>looptmp/</strong>
directory. (We have loopback-mounted the disk image onto our filesystem.) Copy your programs into that directory, for example:</p>
<pre>
cp MYPROG.BIN looptmp/
</pre>
<p>When you're done, unmount the virtual floppy image and remove the temporary directory:</p>
<pre>
umount looptmp
rm -rf looptmp
</pre>
<p>You can now write <strong>mikeos.flp</strong> to a floppy disk or boot it in an emulator. If you want
to recreate the CD ISO image, run <strong>build-linux.sh</strong> as root; this will update <strong>mikeos.iso</strong>
with the new floppy contents.</p>
<p>If you're running Windows, you will need a special program to access <strong>mikeos.flp</strong> as if it
was a real floppy. One tool you can use is the <a href="http://www.ltr-data.se/files/imdiskinst.exe">ImDisk
Virtual Disk Driver</a>; download and run it to install. You can then mount the floppy disk image like this:</p>
<pre>
imdisk -a -f mikeos.flp -s 1440K -m B:
</pre>
Copy your files into the <strong>B:</strong> drive. When you are finished, enter:
<pre>
imdisk -d -m B:
</pre>
<p>Now the files that you copied to <strong>B:</strong> have been written into <strong>mikeos.flp</strong>.</p>
<br />
<a name="monitor"></a>
<h3>Monitor</h3>
<p>Yutaka Saito has contributed a MikeOS program that lets you enter machine code in hexadecimal format
and execute it. Run <strong>MONITOR.BIN</strong> from the command line and you'll be presented
with a '=' prompt. Now you can enter your instructions, or just 'x' to exit back to the OS.</p>
<p>MikeOS programs are loaded at the 32KiB (32768) point. The monitor converts hex code and executes
it at location 36864 in RAM -- that is, 4KiB after the where the monitor program is loaded. This is
so that your code doesn't overwrite the monitor! Consequently, any code you run should
be ORGed to 36864. For example, this is a small MikeOS program which displays the letter 'M' on
the screen. After we've assembled it, we can run <strong>ndisasm</strong> on the resulting binary
to see the hexadecimal codes:</p>
<br />
<center>
<table width="50%" cellpadding="3" border="1">
<tr><td><strong>Source code</strong></td><td><strong>Hexadecimal</strong></td></tr>
<tr><td>BITS 16</td><td>&nbsp;</td></tr>
<tr><td>%INCLUDE "mikedev.inc"</td><td>&nbsp;</td></tr>
<tr><td>ORG 36864</td><td>&nbsp;</td></tr>
<tr><td>&nbsp;</td><td>&nbsp;</td></tr>
<tr><td>mov si, message</td><td>BE0790</td></tr>
<tr><td>call os_print_string</td><td>E8FD6F</td></tr>
<tr><td>ret</td><td>C3</td></tr>
<tr><td>&nbsp;</td><td>&nbsp;</td></tr>
<tr><td>message db 'M', 0</td><td>4D00</td></tr>
</table>
</center>
<br />
<p>(The first three lines are merely assembly directives, so they don't generate any code.) Now
that we have the hex codes, we can enter them into the monitor. Note that the code must be terminated
with a dollar sign ($) character, and spaces are allowed. So, you can enter at the '=' prompt:</p>
<pre>BE0790 E8FD6F C3 4D00$</pre>
<p>When you enter this, the monitor will convert the hex codes to machine code at location 36864 in
RAM, and call that location to execute it. (Just like normal MikeOS programs, you should finish with
a <strong>ret</strong> instruction.) After execution, you'll be returned to the monitor. You can then
enter 'r' to re-run the converted code, or 'x' to exit.</p>
<br />
<a name="serialport"></a>
<h3>Serial port</h3>
<p>You can use MikeOS as a Minicom-like serial terminal emulator with <strong>TERMINAL.BIN</strong>. This lets
you connect a MikeOS machine to, for instance, a UNIX machine, and operate the UNIX machine from
MikeOS. Connect a serial (null-modem) cable between the two machines, then set up your UNIX machine
with a terminal session on the serial port.</p>
<p>For instance, if you have a Linux machine, you would add a line like this to /etc/inittab:</p>
<pre>
T0:2345:respawn:/sbin/getty/ -L ttyS0 9600 vt100
</pre>
<p>When you restart your Linux machine, it will wait for a login on the serial port. Connect
the null-modem cable to a MikeOS machine, and run TERMINAL.BIN in MikeOS. You can now enter your
username and password to log in.</p>
<p>Note that MikeOS configures the serial port to be 9600 baud, no parity, 8 data bits, 1 stop
bit. If you wish to change these settings, edit <strong>source/features/serial.asm</strong> and see the port
port setup code at the start of the file (then rebuild MikeOS as described in the <em>System Developer Handbook</em>).
Also note that only a handful of VT100 commands have been implemented at present, so programs which do complicated
things with the screen (such as Emacs) may not display properly.</p>
<p>To exit the program, press the F8 key. (You can change this to a different key by editing
the source code near the start of <strong>programs/terminal.asm</strong>.)</p>
<br />
<hr noshade="noshade" />
<h2>Extra</h2>
<a name="help"></a>
<h3>Help</h3>
<p>If you have any questions about MikeOS, or you're developing a similar OS and want
to share code and ideas, go to <a href="http://mikeos.sourceforge.net/">the MikeOS website</a>
and join the mailing list as described.</p>
<br />
<a name="license"></a>
<h3>License</h3>
<p>MikeOS is open source and released under a BSD-like license (see <strong>doc/LICENSE.TXT</strong>
in the MikeOS <strong>.zip</strong> file). Essentially, it means you can do anything you like with the
code, including basing your own project on it, providing you retain the license file and give credit
to the MikeOS developers for their work.</p>
<br />
<hr noshade="noshade" />
</td>
</tr>
</table>
</body>
</html>

Binary file not shown.

View File

@ -1,14 +1,3 @@
; ==================================================================
; MikeOS -- The Mike Operating System kernel
; Copyright (C) 2006 - 2022 MikeOS Developers -- see doc/LICENSE.TXT
;
; This is loaded from the drive by BOOTLOAD.BIN, as KERNEL.BIN.
; First we have the system call vectors, which start at a static point
; for programs to use. Following that is the main kernel code and
; then additional system call code is included.
; ==================================================================
BITS 16
CPU 386 ; pusha offsets depends on a 386 or better
; FS and GS require a 386 or better
@ -24,22 +13,6 @@
disk_buffer equ 24576
; ------------------------------------------------------------------
; OS CALL VECTORS -- Static locations for system call vectors
; Note: these cannot be moved, or it'll break the calls!
; The comments show exact locations of instructions in this section,
; and are used in programs/mikedev.inc so that an external program can
; use a CrawOS system call without having to know its exact position
; in the kernel source code...
os_call_vectors:
jmp os_main ; 0000h -- Called from bootloader
jmp os_print_string ; 0003h
jmp os_read_input
jmp os_display_input
jmp os_start_cli
; ------------------------------------------------------------------
; START OF MAIN KERNEL CODE
@ -62,16 +35,6 @@ os_main:
cmp dl, 0
je no_change
mov [bootdev], dl ; Save boot device number
push es
mov ah, 8 ; Get drive parameters
int 13h
pop es
and cx, 3Fh ; Maximum sector number
mov [SecsPerTrack], cx ; Sector numbers start at 1
movzx dx, dh ; Maximum head number
add dx, 1 ; Head numbers start at 0 - add 1 for total
mov [Sides], dx
no_change:
call os_clear_screen

BIN
source/kernel.bin Normal file

Binary file not shown.