top of page

Building a W65C265S Operating System (?)

Updated: 2 days ago

As my W65C265S hardware build is coming along well, I would like to develop an operating system (OS) for it. While I have done miscellaneous 65xxx development over the years, my code has always been a mishmash of routines. The closest I have come to better understanding operating systems is implementing FreeDOS on my 286/386 builds, where I was adding core BIOS routines to support FreeDOS. So, can I hack my way through this and develop and operating system? Time will tell.


So what is an operating system?

I am going to work off this definition: An operating system is the software layer that sits between programs and the hardware, providing the essential services, abstractions, and control needed to run code safely, consistently, and efficiently.


Three fundamentals of an operating system:

  1. Resource management: CPU, memory, I/O devices, storage.

  2. Hardware abstraction: read files, draw a shape, etc.

  3. Program execution environment: startup, system calls, memory layout, multitasking, error handling.



Roadmap

If I have any chance of success, I will need to continue to build my knowledge of 65816 development. I will also benefit from a plan of attack. Given that, I am thinking of working through OS development in the following general order (knowing that I will need to loop back at times as I learn).


  1. Foundations

    1. Reset, startup code

      1. Set CPU to native mode

      2. Configure M/X flags

      3. Initialize stack

      4. Set up Direct Page

      5. Configure memory map

      6. Initialize internal peripherals

    2. Console and video drivers (ILI LCD, VGA)

      1. TX/RX routines

      2. Video primitives (pixels, lines, rectangles, circles) and character support

    3. Basic interrupt handling

  2. Kernel core

    1. Timer driver

    2. Syscall mechanism

      1. COP handler

      2. Syscall table

    3. Memory management

      1. Static memory map

      2. Kernel heap

  3. Device abstraction

    1. Video functions

    2. Block devices

  4. Filesystem

    1. Program loader

    2. FAT16

  5. OS Tools

    1. Shell, monitor

    2. Libraries, runtime

  6. Multitasking

  7. Graphic user interface


As with most of my posts, this will be a 'living' post that I will continue to update as I learn and progress on a '265 OS. More to come!


C Apps

My initial plan is to use my secondary flash to store applications. From my primary flash, I can jsl to an app. The app will get exclusive access to the extended SRAM (or a portion of it). The app will be able to leverage system hardware through syscall jump table. Ideally, these apps could be written in either 65816 assembly or C.


Steps I am working through:

  1. Compile a simple app with Calypsi.

    1. Create OS.h with syscall indices and CallOS stub.

    2. Create CallOS.s with syscall address in OS flash and _CallOS.

    3. Use CallOS to access operating system routines.

  2. Store app on secondar flash ($40:0000 to $47:FFFF).

  3. App will use extended SRAM ($01:0000 to $07:FFFF).

  4. In the operating system flash, setup a syscall jump table and routines to be exposes to apps (OS_PrintChar, OS_PrintString, OS_DrawPixel). Routines use rtl.

  5. Test it. Use jsl to load the app from the OS.

  6. ...more to come...




COP instruction for system calls, vertical scrolling, and PIB improvements




C Applications




Additional Info

 
 
 

Comments


bottom of page