Subject: FyOS Test

From: "Jeff" <fyberoptic1979@...>
Date: Mon, 27 Aug 2007 04:38:43 -0000

This is far from an actual OS just yet, but I made considerable 
strides now that I have full I/O in C, and made a pretty decent 
command-line interface to do some various tasks.  I haven't touched 
up the source to everything just enough yet to release that, but I 
thought I'd let folks test the binary to see if there's anything I 
might need to do before I release anything else.  Plus I just think 
it's kind of neat to play with!

So let me just get to the link, first of all:
http://www.fybertech.net/mailstation/fyos_001.bin

You need a loader app already, which is outside of the scope of this 
particular post.  I might write up some documentation on that aspect 
and include a loader app when I release the full source.  But for the 
time being, this assumes you're using something or other that gets a 
binary file into ram at 0x8000, and executes it.  It also expects to 
have interrupts enabled when it starts.

Now I know there's a few different firmware versions floating around 
out there, but one of the neater aspects is that I wrote support into 
CRT0 initialization to detect the firmware version and dynamically 
fill in the shadow vars (I only use p2 and p3 shadow for now).  This 
means it SHOULD support v2.53, v2.54, and v3.03 just fine, despite 
each being different.  But I've only tested it on v3.03, because 
that's the only MS I have.

When it loads up, you get some info where it shows the firmware 
version, tells you if it's satisfied with that version (and what 
fallback it used if not), then shows some other stuff.  One is where 
I was testing to verify globals were being initialized, which 
probably isn't needed anymore.  The shadow byte addresses should help 
you verify if it's using the proper ones.  And cgafont_addr is just 
for reference, and probably isn't really needed anymore either.

Then you get a > (unfortunately no blinking cursor yet), where you 
type in commands.  To get a list, use "help".  Case insensitive.

You have:

CLS - Clears the screen.
EXIT - Launches original page4000 loader (in case you want to reload 
it or other code, which I do often for testing).
HELP - Gets help on individual commands.
HEXTOINT - Displays hex strings as integers.  Was used to test a 
function I wrote to do this, but I left the command in anyway.
PEEK - Displays memory locations in hex.
POKE - Writes a byte to a memory location.
RESET - Resets FyOS to initial screen.
REBOOT - Resets the Mailstation to 0x0000.
POWERDOWN - Turns off the Mailstation via firmware function 0x0A6B.

The screen will scroll downwards when you reach the bottom, just like 
any other text screen.  Text wraps around the right edge.  Backspace 
goes past the left edge to the previous line (unless at line 0).  The 
text I/O is really pretty nifty if I do say so myself.

Not all of the code is optimized yet, some of which still being 
written in C functions.  Some of the assembly could be written in a 
better manner, as well.  But hey, it works.  I'd rather focus on 
functionality than speed at the moment.

I should point out that I am NOT using a custom interrupt here.  I'm 
not using custom keyboard functions or any of that.  This is working 
purely off the Mailstation firmware, which is why it was important to 
use the proper shadow vars.  To get a blinking cursor though, I may 
have to hook the interrupt sometime.

I can't think of anything else in particular to mention about it, so 
I hope it works on other Mailstations!

---

From: "Jeff" <fyberoptic1979@...>
Date: Wed, 29 Aug 2007 02:32:02 -0000

Welp, I finished a whole bunch of documenation, commented my source 
files, and included the tools I use (short of SDCC itself), all in 
one zip file.  If you have a PC and a Mailstation, then you should be 
able to use this I hope!

http://www.fybertech.net/mailstation/fyos_c_002.zip

Check out the readme.txt first.

It's actually v0.02 of FyOS included this time, instead of simply the 
source to v0.01.  I made a bunch of changes to the code, and since 
the FyOS command interpreter basically makes for a big example of how 
to use this stuff, I figured it only made sense to go ahead and 
include the newest.  I included a binary version too if you want to 
get right to playing with it.

Version 0.02 has a lot of optimizations (particularly in screen 
scrolling and clearing), as well as some additional commands, like to 
poke and peek values into ports now (since before you could only do 
memory locations).  There's also an interactive scancode viewer.

I included the binary to v0.01 too if anyone wants to compare the 
two.  This might give you an idea of how writing code in C will 
perform as opposed to assembly.  Screen scrolling and clearing is 
particularly noticable between the two.

Unfortunately, it's starting to get pretty fat already!  I'm going to 
have to figure out an alternative storage method.  I have some things 
in mind though.

But yeah, FyOS aside, you should be able to just write your own apps 
fairly easily now I hope.  There's hardly any difference in writing 
for the Mailstation as to just a normal console window in DOS or 
Linux, to be honest.  printf/getchar/gets are the most used functions 
for console interaction that I know of, and they work fine with no 
setup necessary by the user.  Only thing you truly have to worry 
about is your code and data sizes, since the MS can only hold so much.

As always, let me know if you have any problems or questions.

---

From: "Jeff" <fyberoptic1979@...>
Date: Wed, 05 Sep 2007 04:31:12 -0000

Not posted here lately, but I've been working nonetheless!  I made a 
ton of internal changes, so I went from v0.02 to just making this 
v0.1.  The source is still messy though so I'm only going to release 
a binary as a preview.  It not only needs more comments, but still 
needs some work to make it easier to access from outside code.  In 
other words, by the time I release the source next time, it'll likely 
have an actual programming interface similar to CP/M's BDOS 
functionality.

http://www.fybertech.net/mailstation/fyos_01_ldr.bin

The big internal changes are:

 - Interrupt has been fully replaced.  This means the firmware's 
keyboard routines were ripped out to be loaded from elsewhere, and to 
also use variables in different locations.  This was necessary 
because...

 - I added in key repeat.

 - And an actual blinking cursor.  

 - Replacing the interrupt meant I was no longer tied to using the 
firmware's p2shadow and p3shadow.  In other words, this should run on 
any version of the firmware, since I'm no longer using any firmware 
routines.  And I created my own shadow vars.

 - The entire thing now runs from the upper 16K of ram.  The command 
interpreter starts at 0xc000, and the "BDOS" starts at 0xe400.  The 
command interpreter is pretty fat right now, since it's all written 
in C.  It was all I could do to make it fit in that space, and I had 
to remove a couple of the help commands to do that!  The "BDOS" is 
all assembly.

Since the code starts at 0xc000 (though initially executed at 
0xe400), I tacked it onto the end of a tiny loader.  So you can still 
load the binary at the normal 0x8000, and once it runs, it'll take 
care of moving the code into the right place and executing it.

I have to say, the addition of a blinking cursor makes it look much 
more alive now than it has nearly the entire time I've worked on all 
this.  It was certainly worth the effort involved.  For all intents 
and purposes, it's now about as close to a true text console as one 
can get.

I don't know how many people actually have tried any of the other 
versions, but I hope you like this one!  And if you don't know how to 
load it, there's instructions and software in the v0.02 zip to let 
you do so.

Also, in a funny twist, it seems that there's a perfect sequence of 
bytes somewhere in my code/data which makes the Mailstation think it 
was shut down properly when you hit the reset button on the back.

---

From: "david_zmk" <David_zmk@...>
Date: Mon, 05 Nov 2007 14:32:49 -0000

Hi, a number of times i read that you have storage problems with the
mailstation, maybe my suggestion is not applicable or already
considered but, why not use the 8 megabits flash memory that the
mailstation uses to save e-mails and CFG files, to store the FS and/or
the program data? it's not a HUGE amount of memory but, 1MB is 1MB.

Zim_256

---

From: "david_zmk" <David_zmk@...>
Date: Tue, 06 Nov 2007 15:28:19 -0000

Or you can try using a IDE device for storage, like a CF card (A bit
difficult because of the connector) or a notebook HDD.

Take a look at:
http://www.z80.de/gide/

Documentation in:
http://www.z80.de/gide/GIDE.txt

Zim_256
> --- In [email-masked], "Jeff" <fyberoptic1979@> wrote:
> >

---

From: "Jeff" <fyberoptic1979@...>
Date: Mon, 12 Nov 2007 19:58:27 -0000

> the program data? it's not a HUGE amount of memory but, 1MB is 1MB.

There were a couple of problems with using the flash memory.  At 
least in my mind.  The codeflash was the larger one, and I didn't 
really want to mess with it for the time being.  Especially since 
it's broken up into 64KB sectors, meaning you have to erase the whole 
chunk to change anything in it.  The dataflash is only 512KB, but has 
256 byte sectors, which is much better for storing data.  However, 
they chose to use one with far less write cycles than even the 
codeflash.  So after some extended use, you'd eventually start 
wearing it down to the point that it wouldn't work anymore.  

So that leads me to the problem of making some sort of file system 
out of it that limits how much it writes to particular sectors.  For 
my little Fonera router thing that I reflashed a while back, it uses 
JFFS to deal with the flash memory, to write to it in kind of a 
circular loop, to extend the flash's life as long as possible.  But 
the problem is that that method is more memory-intensive and slow, 
and I think that's the last thing the Mailstation needs to contend 
with.  The Fonera has much more horsepower to deal with it.

I considered compact flash once (which is nearly identical to IDE), 
but that would require an actual hardware mod, and I've always wanted 
to keep this stuff as casual hobbyist friendly as possible.  Plus I 
didn't particularly want to risk the Mailstation itself for modding.  
That's why I thought of trying to use SD over the parallel port of 
the thing.  That'd be slow, but it would work.  It's just a matter of 
making some little adapter.  Such a thing would also have to adapt 
the 5v to 3.3v.  And I'm lazy and never did it!

In the end though, it will probably come down to some sort of 
internal flash storage.  I'll try to do some reading on what other 
people have done with other devices and see if I can get some idears, 
to avoid wearing the flash down as much as possible.  It's just one 
of those things where I'm still at the stage where it's daunting to 
think about.