Warning
This branch is for historical purposes only. It is used as a monument to the year 2022, and may be used as a "nostalgia kit" to build older SalernOS versions from that year.
The SalernOS Kernel is a fundamental component of SalernOS: a toy OS I'm working on.
The source tree is structured as follows:
src
Contains all the source code for the core parts of the kernelintf
Contains headers for kernel librariesarch
Contains architecture-specific code (Not yet) and BootStandard-specific code, like the linker script used to link the kernelkstd
Contains a pseudo C Standard Library for the kernelklib
Contains code that is dependent on other parts of the kernel (Such askstd
,include
andsrc
), but are not important enough to keep inside the core sourcemake
Contains files included by the mainMakefile
obj
Is created by theMakefile
and contains the object files (.o
) derived from the compilation of the kernelbin
Is created by theMakefile
and contains the final kernel ELF64 binary
To set the environment up, just type make setup
and hit enter.
To compile the entire kernel, just type make kernel
and hit enter.
- A C Compiler (GCC) for x86_64
- An assembler (NASM) for x86_64
- A linker (LD)
- Make
All required software is bundled with the SalernOS-Buildenv
- Folders in the main directory must be named using short series of lowercase characters
- Subfolders must be named using
CamelCase
notation and may not exceed 1 word - File names must NOT contain spaces or other special characters, and shall only consist of short series of lowercase characters
These rules do not apply to special files and folders such as Makefiles.
- Source Files must contain commented notices, such as licenses, warnings and comments as their first sections.
- Source Files must contain Compiler Directives in order:
- Include statements (From longest to shortest)
- Macros and constants (Horizontaly aligned)
- Source Files can contain optional sections in the following order:
- Type definitions
- Static global variables (Horizontaly aligned)
- Other global variables (Horizontaly aligned)
- Static functions
- Function implementations
Sections must be separated by two blank lines and the file must end with an empty line as well.
// LICENSE
// WARNING
// DESCRIPTION
#include <kerninc.h>
#include "other.h"
static bool aStaticBool;
static uint32_t aStaticUint32;
bool aBool;
uint32_t aUint32;
static void __static_function__() {
return;
}
uint32_t kernel_other_implementation() {
return 50;
}
- Header Files must contain commented notices, such as licenses, warnings and comments as their first sections.
- Header Files must contain Compiler Directives in order:
- Include guards
- Include statements (From longest to shortest)
- Macros and constants (Horizontaly aligned)
- Header Files can contain optional sections in the following order:
- Type definitions
extern
variables (Part of a table of variables comprised of two columns: type and name - Horizontaly and verticaly aligned)- Function declarations (Part of a table of functions comprised of three columns: return type, name and arguments - Horizontaly and verticaly aligned)
- Header Files must NOT contain:
- Non
extern
global variables - Static functions
- Non
- The body of Header Files must be indented
#ifndef SALERNOS_CORE_KERNEL_HEADERFILE
#define SALERNOS_CORE_KERNEL_HEADERFILE
#include <kerntypes.h>
/*************************
TYPE NAME
**************************/
extern bool anExternBool;
/*********************************************
RET TYPE FUNCTION NAME ARGUMENTS
*********************************************/
void kernel_other_declaration ();
#endif
The variables and functions tables must be organized as follows:
- The top border must start with
/
and end with*
in the precise column where the bottom border ends - The bottom border must start with
*
and end with/
. If the header exceeds the longest element's length (Like in the function table example), the/
must be one column to the right of the header. Otherwise, the/
must be on the same column as the semicolon of the longest element
A structure for .asm
files will soon be defined. In the meanwhile, try to match the style of existing files.
- Type names must follow the POSIX Standard type notation (
name_t
) and should be as short as possible - Function names must follow the scheme
kernel_category_target_action
, such askernel_kdd_pxcolor_set
andkernel_kdd_pxcolor_get
. If the category is the target, such askernel_mmap_initialize
, thetarget
section can be dropped - Static function names must follow the scheme
__action_target__
, such as__get_pxptr__
- Static global variables and global variables must use
pascalCase
notation - Static local variables and local variables must be comprised of lowecase characters and must start with a
_
as in_local_variable
- Function arguments must be comprised of lowercase characters and must start with
__
as in__function_argument
- Struct fields must use
CamelCase
notation and must start with_
- Constants and macros defined using
#define
must be comprised of UPPERCASE characters, with words separated by_
such as inARGRET(__arg, __val)
orPIC1_COMMAND
- Constants declared with
const
must be comprised of UPPERCASE characters, with words separated by_
and must start with_
, such as in_KERNEL_START
- Use 4-space indentation
- Put brackets on the same line as the declaration
- Put
*
next to the type in pointer declarations (int* p
notint *p
) - Avoid
if
statements whenever possible - Try to use case-specific types (Such as
uint16_t
) instead of generic types likeint
- Try to leave blank lines inside scopes to separate code areas
- Try to be as precise as possible with padding and spaces. Any request containing
(){
ora=b
instead of() {
anda = b
WILL BE REJECTED WITHOUT FURTHER INSPECTION
The master
branch is used for the current INDEV version. A support
branch will be created for every Kernel release (kernel-florence-support
for example).
You can find the roadmap here