The file system is very simple. It is based on a FAT (file allocation table). Each file entry (file or folder) contains the following information:
The index of a FAT entry is its position on the FAT table. I limit the file number to 1024, which is enough for 16MB, and the demonstrations.
The filesystem enables a tree structure, of course, with the help of the “folder field” of each FAT entry.
The FAT is the portion of the Flash that is re-written the most. Each modification of the file system leads to a FAT modification. I wanted to avoid re-writing always the same Flash blocs, therefore I implemented a mechanism that writes the FAT in 8 different places, written successively at each FAT update. A FAT index is used to find the freshest FAT out of the 8 FAT stored.
It is a bit useless because the usage of this computer is very small, but I coded that especially for fun.
The FAT is small (less than 64kB) and it is therefore always stored in RAM.
- The filesystem do not manage fragmentation of files. Files are stored in a row. If there is not enough contiguous free space, a new file cannot be created.
- Each file has a fixed size, declared once at the file creation. The file size cannot be modified later.
Flash Memory organization:
Human – Machine Interface : the file explorer.
I didn’t want a “command line” HMI. I hate command line OS, since my young age, when I used MS/DOS.
Therefore, I have coded a simple file explorer, with pseudo graphic interface, that shows the content of a folder, allows the user to select one file/folder with arrows, and propose actions to the user depending on the type of file/folder selected. This looks like the old “Norton Commander” on MS/DOS.
All the basic commands of a file explorer are available : copy, cut, paste, rename, create a new file or folder, delete.
You can also open a file. The action made while opening a file depends on the file type:
- For an EXEC file, the program is loaded to RAM, and then executed
- For TEXT or IMAG files, the explorer loads the right program for the file type, and executes it. The program will then open the selected file by itself; the OS just passes the index of the selected file as an argument. The EXEC files corresponding to programs used to open these types of files must have specific file indexes:
- Text editor : index 2
- Image viewer : index 3
In the “action menu”, a specific action allows to update the content of the selected file, from the PC to the Flash. This is made in 2 manners:
- Choice 1 for real A2Z hardware, uses the serial link, with the same protocol than the bootloader. All download must end with a “goto” instruction, that will not be executed, but that is just present to detect the end of transfer. For example, you can download a “bina” file, and then the file “goto.bine”.
- Choice 2 On emulator : you can download a bina/bine/binc file. The transfer is initiated with an F9 command. The transfer of the file must be done before validating the selection of “choice 2” in the OS.
OS or not OS ?
Finally, what I call “OS” is not really an OS. It is just a file explorer. All applications are almost totally independent from the OS, and they integrate their own driver to access to the hardware. There is no hardware abstraction made by the OS.