miware
Miware is a disk operating system for the ilo computer.
Note:this is definitely not a stable system at this point.
It's easy to crash, certainly has bugs, and some parts of the
design will probably change as development continues.
Background
The ilo computer is mostly known as the basis of my Konilo
system. But I've intended it to be more versatile, and have been
working on several alternative systems to run on it. These
currently include Poraka, a BASIC; BrainDead, a BrainFuck; and
a port of the core uxn vm. Miware is the fourth of the
alternate systems, and presents something different from the
others: a disk operating system, similar in style to an early
DOS or CP/M style OS.
A Barely Acceptable File System
ilo provides a block storage device. To make a useful disk
operating system I needed a file system, and, being lazy, I
put together something that'll suffice, though it's certainly
not a robust or flexable design. With that, here's my
barely acceptable file system.
BAFS starts with a directory covering the first 32 blocks.
Each directory block holds 16 file slots, for a total of 512
files. The slots contain a little information about each file.
+---------+--------------------+
| Offset | Contains |
+---------+--------------------+
| 0 | File name length |
| 1 .. 62 | File name |
| 63 | Apparent file size |
+---------+--------------------+
An entry with name length zero is considered free. I pad
unused name characters with zero.
Each file has an apparent size, from 0 through 32768. Each
file slot corresponds directly to a 32768 cell region of the
disk.
Finding the first block for a file is:
VOLUME-BASE + 32 + (32 * FILE-SLOT#)
There are no directories.
Memory Layout
The kernel and shell are located at the start of RAM, and
applications get loaded into the upper part.
cells owner
-------------- --------------------------------
00000 jump to start of actual kernel
00001 kernel entry address
00002 jump to system call handler
00003 address of system call handler
00004..06143 kernel, cache, transfer buffer
06144..08191 shell (loaded from shell.sys)
08192..65535 application code and data
System Calls
Miware has a kernel, with a few supported system calls. A
loaded program call set up the stack, then do this to perform
a system call:
i lica....
d 2
The system calls are:
+-----+----------------+-------------------+-------------------+
| sel | symbol | stack effect | |
+=====+================+===================+===================+
| 0 | EXIT | ( status -- ) | Jump only. Return |
| | | | to shell with |
| | | | status. |
| 1 | PUTC | ( cell -- ) | Write one |
| | | | terminal |
| | | | character through |
| | | | the ilo terminal |
| | | | device. |
| 2 | GETC | ( -- cell ) | Read one terminal |
| | | | character; host |
| | | | input may block. |
| 3 | FS_OPEN | ( name* -- flag ) | Open the sole |
| | | | application file |
| | | | at cell cursor |
| | | | zero. |
| 4 | FS_CLOSE | ( -- flag ) | Close the sole |
| | | | open application |
| | | | file. |
| 5 | FS_READ | ( -- cell flag ) | Read one cell and |
| | | | advance; 0 0 at |
| | | | EOF or failure. |
| 6 | FS_WRITE | ( cell -- flag ) | Write one |
| | | | existing cell and |
| | | | advance. |
| 7 | FS_APPEND | ( cell -- flag ) | Append one cell |
| | | | to the open file. |
| 8 | FS_SEEK | ( position -- | Set cursor from |
| | | flag ) | zero through |
| | | | apparent size, |
| | | | inclusive. |
| 9 | FS_SIZE | ( -- cells flag ) | Return the |
| | | | apparent size of |
| | | | the open file. |
| 10 | FS_SETSIZE | ( cells -- flag ) | Resize the open |
| | | | file within 0 |
| | | | through 32768 |
| | | | cells. |
| 11 | FS_CREATE | ( name* -- flag ) | Create a |
| | | | zero-length, |
| | | | zero-initialized |
| | | | file; fail if |
| | | | name exists. |
| 12 | FS_DELETE | ( name* -- flag ) | Delete a closed |
| | | | file. |
| 13 | FS_RENAME | ( old* new* -- | Replace a file |
| | | flag ) | name with a valid |
| | | | unique name. |
| 14 | FS_FIND | ( name* -- slot | Locate a valid |
| | | flag ) | live file; slot |
| | | | is diagnostic |
| | | | only. |
| 15 | FS_FIRST | ( -- slot flag ) | Find the first |
| | | | valid live file. |
| 16 | FS_NEXT | ( slot -- | Find the next |
| | | next-slot flag ) | valid live file. |
| 17 | FS_INFO | ( slot | Copy a name into |
| | | name-buffer* | an application |
| | | capacity -- size | buffer. Return |
| | | length flag ) | its size. |
| 18 | ERROR | ( -- error ) | Return the last |
| | | | error recorded |
| | | | for this |
| | | | application. |
| 19 | EXEC | ( shell-name* -- | Load and |
| | | exit-status flag )| synchronously run |
| | | | an application |
| | | | named by a shell |
| | | | string. Return |
| | | | its exit status |
| | | | and -1 on launch; |
| | | | return 0 0 on |
| | | | failure. |
| 20 | SET_ARGS | ( args* -- flag ) | Copy a counted |
| | | | raw argument |
| | | | string, up to 256 |
| | | | cells, into |
| | | | kernel storage. |
| 21 | GET_ARGS | ( destination* | Copy the current |
| | | capacity -- | counted argument |
| | | length flag ) | string into memory|
| 22 | FS_READ_INTO | ( dest* count -- | Read cells. |
| | | count flag ) | |
| 23 | FS_WRITE_FROM | ( source* count --| Write cells. |
| | | count flag ) | |
| 24 | FS_APPEND_FROM | ( source* count --| Append cells. |
| | | count flag ) | |
+-----+----------------+-------------------+-------------------+
The ERROR system call returns a limited number of errors that
miware may identify. These are:
0 no recorded error
1 unsupported selector
2 invalid argument (including a bad pointer or invalid
string, buffer, slot, position, size, or capacity)
3 no application file is open
4 file already exists
5 file was not found
6 file is open where a closed file is required
7 end of file
8 no directory slot or file capacity exceeded
9 application launch already active
Programs
Miware has only a few non-test/debugging related programs at
present. These are:
shell; 688 cells
poraka (basic);
konilo (forth);
pali (assembler); 4544 cells
dir; 239 cells
rename; 918 cells
copy; 2338 cells
del; 639 cells
rename; 918 cells
compare; 3258 cells
type; 699 cells
hexdump; 849 cells
These are being worked on:
ed (line editor)
hash (CRC-32)
list (file viewer)
find (search for strings)
strings (show identifiable strings in a file)
more (display a file, via paging)
stats (display disk stats)
diff (display changes between files)
The cell counts are expected to drop as I remove debug code
and finish up the implementations of each.