Understanding CROCOS source code

Layout of the CROCOS archive
Layout of "first phases" directories
arch directories

This document explains how the CROCOS source code is organised and gives hints to port CROCOS on others architectures.

Layout of the CROCOS archive

|
+ doc/
|  + README, phases...          text files documention
|  + html/
|     + index.html...           html files documentation
|
+ disk_img/                     ext2 disk image used for tests
|
+ phase_1/                      code for phase 1
+ phase_2.1/                    code for phase 2.1
+ ...                           ...

Layout of "first phases" directories

The definition for "first phases" can be found in " How to build, test and use CROCOS ": In these phases, user programs and the kernel are linked together and the kernel is run inside a Linux process.

|
+ Makefile, rules.mk, var.mk    main Makefile files
|
+ crocos/                       kernel code
|  + main/
|  |  + main.c                  entry point for the kernel
|  |
|  + devices/                   devices related code (drivers)
|  + fs/                        file system code
|  + intr/                      interrupt handlers
|  + process/                   tasks manager
|  |
|  + include/
|     + config/config.h         system configuration
|     + devices/                include files for device drivers
|     + fs/                     include files for file system
|     + intr/                   include files for interrupt handlers
|     + process/                include files for the tasks manager
|
+ klibc                         klibc code
|  + src/                       source code
|  + include/
|  |  + klibc/                  include files
|  + test/                      test programs for the klic
|  + klibc.a                    klibc library after compilation
|
+ usr/                          user-space related files
   + lib/                       directory for user-space libraries
   |  + libcrocos.a             libcrocos library after compilation
   |                               (defines system calls)
   + src/
   |  + crocos/                 source files for libcrocos library
   |  + init/
   |  |  + init.c               init task code
   |  + test/                   test programs for CROCOS
   |     + fork.c, fork.res     test for fork + expected output
   |     + ...
   |
   + include/
      + crocos/                 include files for user programs
                                    (declare system calls, errno...)

Notes:

In "first phases", the device drivers directory contains code to print messages on the terminal (with the Linux write system call), to shuts the system down (with the Linux _exit system call) and to load the disk image file in memory (with the Linux open, read and close system calls).

The interrupt handler directory contains the code to manage system calls. Indeed, in later phases, system calls will be implemented with a software interruption.

arch directories

In the above layouts, arch directories are missing. Those directories contain code related to a specific architecture (one directory per architecture). Such directories can be found, for example, in klibc/include/klibc/arch or crocos/include/process/arch.

Porting CROCOS to a new architecture should only require changes in those arch directories. Basically, all the functions/macros defined in an arch directory need to be rewritten for a specific architecture in a dedicated directory. Note that the var.mk file (in the root directory of a phase) also needs to be updated so that the ARCH variable can be defined to a new architecture (see How to build, test and use CROCOS for more informations on the ARCH variable).