Microcode Cleanup
I’ve gotten a bit derailed from the task of writing the keyboard scan code handler, into the bigger issue of how device drivers like this should work in general in BMOW. That’s led me to an entirely different question of the BMOW operating system (if you can call it that), and what kind of instruction support might be needed for the OS and user programs to communicate. It’s not something I need to resolve now, really, but I’d rather give it some thought and hopefully get it right the first time.
The simplest approach would be a single-user machine, similar to how vintage 8-bit computers like the Apple II typically worked. Then the “OS” wouldn’t be much more than just a library of helpful routines for programs to call to interface with the hardware.
It may be a pipe dream, but one of my larger goals is to support some kind of multi-tasking OS, at least in a simple form. The key to this is some kind task scheduler, and a protected memory design to prevent one user program from interfering with another. My plan is to make all the user programs run as if BMOW had 16-bit addresses, with a 64KB memory space. Since BMOW actually has 24-bit addresses, the uppper 8-bits will be treated as a process ID. None of the normal CPU instructions will be able to view or modify the upper 8-bits of an address register. When an interrupt hits or an OS routine is called, however, the upper 8-bits will be set to zero, which will essentially be the OS’s process ID, with its own memory space. I can then add some additional CPU instructions for manipulating full 24-bit addresses, whose microprograms verify the upper 8-bits of the PC are zero before doing anything else. So in theory at least, each user program will exist in its own 64KB space and be invisible to other user programs, but the OS can still view and modify them all. There are still many details to work out, however, and my original hardware design didn’t exactly foresee all this, so it’s a challenge.
For task switching, I would use the yet-to-be-installed real-time clock, and set it to trigger an interrupt every few milliseconds. The interrupt mechanism would then push all the CPU registers onto the current user program’s stack, then jump to an OS interrupt handler. This handler would need to copy the stack pointer into a process table somewhere in OS memory, install the stack pointer from a different process, pop the saved registers off the stack, and continue execution of the next process. Boom, it’s a multi-tasking OS. Of course I’m glossing over many details, and in practice it will probably be much more complicated than this. There are many questions to answer, such as whether the OS itself can be pre-empted by an interrupt.
Assuming this all works, BMOW should be able to support as many processes as there are 64KB banks available, minus one for the OS. With the 512KB currently installed, that’s 7 user processes, which is probably plenty. Increasing the installed RAM to the 1MB I originally planned for would raise the user process limit to 15. I can’t imagine that I could run 15 simultaneous programs on this hardware at any kind of useful speed, but it might be interesting to try!
Read 4 comments and join the conversation4 Comments so far
Leave a reply. For customer support issues, please use the Customer Support link instead of writing comments.
Oh, and how about sound? Do you think that falls withing the BMOW’s capabilities?
Then you’d be able to code up some sort of video + sound demo! (if you don’t have already, I think you mentioned, video will be a pain)
Separate microcontroller for video, just reads RAM out to DAC, yes yes. Color of course!
Video and sound, hopefully yes, eventually. Video with a microcontroller, hopefully not. As with the CPU itself, my goal is to build all the peripherals from basic logic gates. Admittedly I cheated in the case of the USB interface, but I didn’t have much alternative.
Hello!
Don Lancaster, wrote three books on video and computers. One was called TV Typewriter cookbook, and described the right way to go about building one of these things for either an I8008 based system which was what existed when he started, to almost anything that supported his general ideas.
The two Cheap Video cookbooks, (Cheap Video and Son of Cheap Video) support the antics behind the SY6502 on a SYM-1 system. He does state that those ideas are adaptable, and could be used elsewhere. Further his ideas behind the TVT cookbook ended up being used for all sorts of systems as they evolved.
Thanks, I’ll certainly see if I can dig those up. That’s a very timely suggestion, as I hope to start work on a video system soon. I wrote some thoughts about a few months ago– scroll down to the “Video Madness” heading in this entry: http://www.bigmessowires.com/2008/02/26/peripherals-galore/