Skip to content

[ADD] Website For Docs #14

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions VuePress Tacos/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules
.temp
.cache
119 changes: 119 additions & 0 deletions VuePress Tacos/docs/.vuepress/config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
import defaultTheme from '@vuepress/theme-default'
import searchPlugin from '@vuepress/plugin-search'

module.exports = {
title: 'TacOS Documentation',
description: 'Un système d’exploitation libre et open source',
head: [
['link', { rel: 'icon', href: '/logo.png' }],
],
theme : defaultTheme({
logo: '/logo.png',
repo: 'https://github.com/epi-osdev/TacOS',

navbar: [
{
text: 'Guide',
children: [
{
text: 'Introduction',
link: '/guide/Introduction.md',
},
{
text: 'Code Introduction',
link: '/guide/code/Introduction.md',
},
{
text: 'Coding style',
link: '/guide/coding_style/CODING_STYLE.md',
},
],
},
],

sidebar: [
{
collapsible: true,
text: 'Introduction',
children: [
'/guide/Introduction.md',
],
},
{
collapsible: true,
text: 'Code',
children: [
'/guide/code/Introduction.md',
{
collapsible: true,
text: 'Boot',
children: [
'/guide/code/boot/boot.md',
'/guide/code/boot/boot_sector.md',
'/guide/code/boot/disk.md',
'/guide/code/boot/gdt.md',
'/guide/code/boot/kernel_entry.md',
'/guide/code/boot/switch_pm.md',
],
},
{
collapsible: true,
text: 'Drivers',
children: [
{
collapsible: true,
text: 'IDT',
children: [
'/guide/code/drivers/idt.md',
'/guide/code/drivers/idt/idt.md',
'/guide/code/drivers/idt/datas.md',
'/guide/code/drivers/idt/init.md',
],
},
'/guide/code/drivers/keyboard.md',
'/guide/code/drivers/pic.md',
]
},
{
collapsible: true,
text: 'Utils',
children: [
'/guide/code/utils/string.md',
'/guide/code/utils/UTILS.md',
'/guide/code/utils/VGA.md',
]
},
],
},
{
collapsible: true,
text: 'Coding style',
children: [
'/guide/coding_style/CODING_STYLE.md',
'/guide/coding_style/braces.md',
'/guide/coding_style/comments.md',
'/guide/coding_style/constants.md',
'/guide/coding_style/dry.md',
'/guide/coding_style/functions.md',
'/guide/coding_style/global_variables.md',
'/guide/coding_style/guards.md',
'/guide/coding_style/headers.md',
'/guide/coding_style/includes.md',
'/guide/coding_style/indentation.md',
'/guide/coding_style/line_length.md',
'/guide/coding_style/naming.md',
'/guide/coding_style/pointers.md',
'/guide/coding_style/spaces.md',
'/guide/coding_style/srp.md',
'/guide/coding_style/structures.md',
'/guide/coding_style/types.md',
]
},
],
}),
plugins: [
searchPlugin({
// options
}),
],
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added VuePress Tacos/docs/.vuepress/public/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added VuePress Tacos/docs/.vuepress/public/pc.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
31 changes: 31 additions & 0 deletions VuePress Tacos/docs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
---
home: true
heroImage: /pc.png
logo: /logo.png
features:
- title: ​​​​​​​Rapidité
details: Un OS basé sur Linux, rapide et léger.
image: /pc.png
- title: Sécurité
details: La sécurité est une priorité pour moi.
- title: Personnalisation
details: Personnalisez votre environnement de travail.
actions:
- text: Vers la présentation
link: /guide/Introduction.md
type: primary
- text: Voir le code source
link: https://github.com/epi-osdev/TacOS
type: secondary
footer: Made with ❤️ by MisTrale
---

<div style="text-align:center">
<img src="assets/chronometre.png" alt="chronometre" width="40" style="position:absolute; left:540px; top:700px;"/>
</div>
<div style="text-align:center">
<img src="assets/fermer-a-cle.png" alt="security" width="38" style="position:absolute; left:870px; top:700px;"/>
</div>
<div style="text-align:center">
<img src="assets/personnaliser.png" alt="perso" width="34" style="position:absolute; left:1300px; top:703px;"/>
</div>
12 changes: 12 additions & 0 deletions VuePress Tacos/docs/guide/Introduction.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# 🏁 Introduction

Here you can find the project documentation. It explains the following differents parts:

- [Code](./code/Introduction.md)

- [CODING_STYLE](./coding_style/CODING_STYLE.md)

## 🖇️ Links

For other docs you can check the following links:
- [Notion](https://puzzled-windshield-79c.notion.site/TacOS-Documentation-bb1b3698e706489998dd7b3c78c616af)
9 changes: 9 additions & 0 deletions VuePress Tacos/docs/guide/code/Introduction.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# 🗂️ Introduction

This is the **code documentation of the project**. You can find all the explainations about the differents parts of the code, and the differents theorical parts of the project. all the documentation is store in the `doc` folder. and splitted in differents parts:

### [Boot](./boot/boot.md)
this part explains all the differents parts of the boot process of the project (boot_sector, kernel entry, etc...).

### [Utils](./utils/UTILS.md)
This part explains all the differents utils of the project. All the utils (string lib, display lib, etc...) are store in the `utils` folder.
24 changes: 24 additions & 0 deletions VuePress Tacos/docs/guide/code/boot/boot.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Boot

## Introduction

this is the documentation of all the booting things, it's splitted into differents parts that explain all the differents parts of the booting process. You have several parts:

## Table of content

- [Boot sector](boot_sector.md)
- [Kernel entry](kernel_entry.md)

## Boot sector

The MD doc:
- [Boot sector](boot_sector.md)

The boot sector is the first part of the booting process. It's serve to load the kernel and give kernel precious informations about the hardware and how the processor should be configured.

## Kernel entry

The MD doc:
- [Kernel entry](kernel_entry.md)

The kernel entry is the entry point of the kernel. It's the first function that is called when the kernel is loaded. It's serve to initialize the kernel and to call the kernel main function. It's the equivalent of the C main function.
134 changes: 134 additions & 0 deletions VuePress Tacos/docs/guide/code/boot/boot_sector.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
# Boot sector

## Introduction

This document explains the boot sector stuff. It is splitted into different parts that explain the booting process. Every file that we will refers to are in `src/boot_sector/`.

## Table of content

- [Processor modes](#processor-modes)
- [Bios routines](#bios-routines)

## The existing modes <a name="processor-modes"></a>

This is the theorical documentation for the processor modes. In the Intel architecture, there are many different modes that the CPU can use. The CPU can boot in differents modes, **16 bits**, **32 bits** or **64 bits**, respectively named **Real mode**, **Protected mode** and **Long mode**. Every mode has differents features and limitations. More details below:

- [Real mode](#real-mode)
- [Protected mode](#protected-mode)
- [Long mode](#long-mode)

### Real mode (16 bits) <a name="real-mode"></a>

The real mode is the firt mode that we have access when booting the processor. It's a 16 bits mode that have a lot of limitations. The main limitation is that the processor can only access 64KB of memory (because the max amount of addresses is 65,536 bytes (2<sup>16</sup>) that represents 64KB. But with some tricky things you can upgrade to less that 1MB of memory

Here is a list of the quality and limitations of the real mode:

- Cons:
- Less than 1 MB of RAM is available for use.
- There is no hardware-based memory protection (GDT), nor virtual memory.
- There is no built in security mechanisms to protect against buggy or malicious applications.
- The default CPU operand length is only 16 bits.
- The memory addressing modes provided are more restrictive than other CPU modes.
- Accessing more than 64k requires the use of segment register that are difficult to work with.
- Pros
- The BIOS installs device drivers to control devices and handle interrupt.
- BIOS functions provide operating systems with a advanced collection of low level API functions.
- Memory access is faster due to the lack of descriptor tables to check and smaller registers.

### Protected mode (32 bits) <a name="protected-mode"></a>

the protected mode is the second mode that we have access when booting the processor. It's a 32 bits mode that have a lot of limitations. The main limitation is that the processor can only access 4GB of memory (because the max amount of addresses is 4,294,967,296 bytes (2<sup>32</sup>) that represents 4GB. But with some tricky things you can upgrade to less that 4GB of memory. \
It's a bit old now but it was for a long time the main mode of the processor. It's still used in some cases like windows 32 bits. The main advantage of the protected mode is that it's a lot more secure than the real mode. It's also a lot more powerful than the real mode. It's also a lot more easy to use than the real mode. But the main cons of the protected mode is that you cannot access to the BIOS interrupts and it's more complex to use but it's not a big deal.

### Long mode (64 bits) <a name="long-mode"></a>

the long mode is the third mode that we have access when booting the processor. It's a 64 bits mode that have a lot of limitations. The main limitation is that the processor can only access 256TB of memory (because the max amount of addresses is 256, terabytes (2<sup>48</sup>) that represents 256TB. But with some tricky things you can upgrade to less that 256TB of memory. \
Don't be affraid of this because you will not have to use this for now :).

## BIOS routine <a name="bios-routine"></a>

When you are starting your computer, the bios is doing some routine to check if in the current disk there is a bootable partition. To check this, it's checking if the address `0x7C00 + 510` has the two bytes `0x55` and `0xAA`. If it's the case, it's loading the first 512 bytes of the disk in the memory at the address `0x7C00` and running the code.

## [boot_sector.asm](../../../src/boot_sector/boot_sector.asm) explaination

Explaination of all the code in the file `src/boot_sector/boot_sector.asm`

```nasm
[org 0x7C00]
[bits 16]
```

Here you have the two first lines that you must understand. The first line is telling the assembler that the code will be at the address `0x7C00`. The second line is telling the assembler that the code will be in 16 bits mode. If you read the [BIOS Routine](#bios-routine) section, you will understand that the bios is loading the first 512 bytes of the disk in the memory at the address `0x7C00`. So we have to put our code at this address.
<br />
After this you have the first label

```nasm
start:
mov ax, 0x00
mov ds, ax
mov es, ax
mov ss, ax
mov bp, 0x7c00
mov sp, bp
```

This label is initializing every segment register to 0 (if you don't know what a segment register is, please see the [**Doc**](../memory/segmentation.md)) \
The `mov ax, 0x00` is moving the value `0x00` in the register `ax`. It's usefull for initializing the registers ds, es and ss to a default value

`bp` and `sp` are the stack register, (sp = stack pointer, bp = base pointer). The stack is the local memory of your program, it's where all the local variables are stored. By definition the stack is growing downward (from high address to low address). The base pointer is the beginning of the stack and the stack pointer is the current position of the stack. We are setting both to `0x7c00` because we are beginning all the kernel code at this address so when the stack is growing it will not overlapping the kernel code.

After the start label that will init all the usefull register we need to load the disk and switch to the protected mode. To do this we have a label in 16bits mode that manage all of this.

```nasm
[bits 16]
run_16:
mov [BOOT_DRIVE], dl
call load_kernel
call switch_to_pm
```
So as you can see it's a 16 bits label that load our kernel and switch to the protected mode. The hardest line in this label is the `mov [BOOT_DRIVE], dl`. When you are launching the kernel, BIOS store the id of the boot drive in the register `dl`. So we are moving the value of `dl` in the address `BOOT_DRIVE` to save the data.
The two other lines are just calling the two functions that we will see later.

The first function that will be called in our `run_16` label is the `load_kernel` function. This function is loading the entire kernel in the memory it's a 16 bits label that read the disk and store the content into the memory. Here is the actual code of the function:

```nasm
[bits 16]
load_kernel:
mov bx, KERNEL_OFFSET
mov dh, 31
mov dl, [BOOT_DRIVE]
call disk_load
ret
```
If you want to see what's doing the `disk_load` function, you can see it in the [disk.md](disk.md) file. this function ask to set some registers before using it:
- `bx`: it's the offset in the memory where the kernel will be loaded
- `dh`: it's the number of sectors that will be loaded
- `dl`: it's the id of the disk that will be loaded
once the function is called, it will load `dh` sector from the disk `dl` and store the result into the memory at the offset `bx`.

Once the kernel is loaded in memory, we have to switch to the protected mode. To do this we have to call the `switch_to_pm` function. This function is doing all the routine that we need to switch from RM to PM, if you want to see what is doing exactly this function you can see it in the [switch_pm.md](switch_pm.md) file.

When all is done we are in protected mode (finally), so we want to jump to the C kernel code. to do this we have a label called `entry_point`.

```nasm
entry_point:
call KERNEL_OFFSET
jmp $
```
Previously, we have loaded the kernel in the memory at the offset `KERNEL_OFFSET`. So we are calling the function at this offset. The `jmp $` is just a infinite loop.

The end of the file is for loading all the other files and writting the magic bytes at the end of the file.

```nasm
%include "src/boot_sector/disk.asm"
%include "src/boot_sector/gdt.asm"

times 510-($ - $$) db 0
dw 0xAA55
```
%include instruction is obviously for including the other files.
- [gdt.asm](gdt.md)
- [disk.asm](disk.md)
- [switch_pm.asm](switch_to_pm.md)

the `times 510-($ - $$) db 0` is writing 510 - (current address - start address) bytes of 0. It's just padding the file with 0 to have a size of 510 bytes. The last two bytes are the magic bytes `0xAA55` that are telling the bios that the file is bootable (necessary for the [BIOS routine](#bios-routine)).
Loading