Skip to content

Internals: Structure

Jens Nyberg edited this page Oct 2, 2013 · 18 revisions

File naming convention

  • C source files must have the suffix .c
  • C header files must have the suffix .h
  • Assembly source files must have the suffix .s

Every C source file must have all public definitions in a C header file with the same prefix.

Function naming convention

All functions that are ment to be publicly accessible must use a prefix that is the same as the header and source filename in which they are defined and implemented. This naming convention is especially important for modules because the prefix of any external relocatable reference determines where the loader will assume it can be found.

All functions that are not ment to be publicly accessible must not be added to a header file and must be defined as static. For clarity it should not use a similar prefix as public functions of the same file.

Coding convention

The code does not follow any well-known coding convention. Instead I invented one myself. I have heard complaints by people who thinks it has to many newlines but they have simply failed to understand it's greatness. Compared to many other conventions, it is easier to read and actually have more determined set of rules.

Filesystem layout

From the top directory you can see the following directories:

  • libs: Contains most of the code.

  • libs/fudge: Contains the default library that userspace programs can link with. Some files like memory.c and string.c is also linked together with the kernel but this might change.

  • libs/kernel: Contains the code for the kernel. All code here will run in previleged mode.

  • libs/x86: Contains x86 architecture specific code.

  • libs/x86/abi: Contains the abi for x86. Let's a program talk to the kernel through a syscall.

  • libs/x86/arch: Contains kernel code specific for 86.

  • libs/x86/mboot: Contains multiboot code for the x86 architecture. This is the default loader that is linked but it is possible to link with other loaders as well.

  • modules: Contains code that can be dynamically loaded on demand. When loaded it will become part of the kernel meaning it will run in privileged mode. They often consist of driver and device specific code that is only loaded if such a device exist. Examples include pci, ata and mouse and keyboard drivers.

  • packages: Contains userspace programs. A group of programs are called a package. What packages you wish to use are up to you. If you are not interested in network programs you don't need to include it.

  • system: Contains userspace data. This folder contains stuff that packages could need. It can be any kind of data like configuration, documents or bitmap images.