You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Chapter-1/README.md
+3-4Lines changed: 3 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -10,14 +10,14 @@ In this course we are not going to design an operating system for x86-64 archite
10
10
11
11
### Our Operating System
12
12
13
-
The goal is to build a very simple UNIX-based operating system in C++, but the goal is not to just build a "proof-of-concept". The OS should be able to boot, start an userland shell and be extensible.
13
+
The goal is to build a very simple UNIX-based operating system in C++, but the goal is not to just build a "proof-of-concept". The OS should be able to boot, start a userland shell and be extensible.
14
14
15
-
The OS will be built for x86 32bits architecture and IBM compatible PCs.
15
+
The OS will be built for x86 architecture, running on 32 bits, and compatible on IBM PCs.
16
16
17
17
**Specifications:**
18
18
19
19
* Code in C++
20
-
* x86-32 architecture
20
+
* x86, 32 bit architecture
21
21
* Boot with Grub
22
22
* Kind of modular system for drivers
23
23
* Kind of UNIX style
@@ -33,4 +33,3 @@ The OS will be built for x86 32bits architecture and IBM compatible PCs.
33
33
* API Posix
34
34
* LibC
35
35
* "Can" run a shell or some excutables like Lua, ...
Copy file name to clipboardExpand all lines: Chapter-3/README.md
+4-4Lines changed: 4 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -6,11 +6,11 @@ When an x86-based computer is turned on, it begins a complex path to get to the
6
6
7
7
The BIOS boot sequence is: RAM detection -> Hardware detection/Initialization -> Boot sequence.
8
8
9
-
The step important for us is the "Boot sequence", when the BIOS is done with its initialization and tries to transfer control to the next stage of the bootloader process.
9
+
The important step for us is the "Boot sequence", where the BIOS is done with its initialization and tries to transfer control to the next stage of the bootloader process.
10
10
11
-
During the "Boot sequence", the BIOS will first choose the "boot device" (floppy disk, hard-disk, CD, usb flash memory device or network). Our Operating system will first boot from the hard-disk (but it's possible to boot it from a CD or a usb flash memory device).
11
+
During the "Boot sequence", the BIOS will first choose the "boot device" (floppy disk, hard-disk, CD, usb flash memory device or network). Our Operating system will first boot from the hard-disk (but it will be possible to boot it from a CD or a usb flash memory device).
12
12
13
-
The BIOS will read the 512 bytes from the first valid bootsector (If the last two bytes are 0x55, and then 0xAA, then the BIOS considers this to be a valid bootsector), If the BIOS never finds a valid bootsector, it will lock up with an error message. And it'll transfer these 512 bytes into physical memory starting at address 0x7c00 then starts running the code that now begins at 0x7c00.
13
+
The BIOS will read 512 bytes from the first valid bootsector (where the last two bytes are 0x550xAA), or lock up with an error message if it cannot find one. And it'll transfer these 512 bytes into physical memory starting at address 0x7c00 then starts running the code that now begins at 0x7c00.
14
14
15
15
When the BIOS transfers control to the bootsector, the bootsector code is loaded and running at physical address 0x7c00 and the CPU is in 16-bit Real Mode but our kernel will be only 32bits so we need a bootloader to read our kernel switch to protected mode and starts running it.
16
16
@@ -68,7 +68,7 @@ struct multiboot_info {
68
68
};
69
69
```
70
70
71
-
You can use the command ```mbchk kernel.elf``` to valid your kernel.elf file with the multiboot standard. You also use the command ```nm -n kernel.elf``` to validate the offset of the differents objects in the ELF binary.
71
+
You can use the command ```mbchk kernel.elf``` to validate your kernel.elf file against the multiboot standard. You also use the command ```nm -n kernel.elf``` to validate the offset of the differents objects in the ELF binary.
Copy file name to clipboardExpand all lines: Chapter-4/README.md
+2-6Lines changed: 2 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -4,9 +4,7 @@
4
4
5
5
A kernel can be programmed in C++, it is very similar to making a kernel in C, except that there are a few pitfalls you must take into account (runtime support, constructors, ...)
6
6
7
-
The compiler will assume that all the C++ runtime support is available by default, however you are not linking in libsupc++ into your C++ kernel, which implements the necessary run-time support. So we need to add some basic run-time support.
8
-
9
-
Our basic C++ runtime can be found in the [cxx.cc](https://github.com/SamyPesse/How-to-Make-a-Computer-Operating-System/blob/master/src/kernel/runtime/cxx.cc) file.
7
+
The compiler will assume that all the necessary C++ runtime support is available by default, but as we are not linking in libsupc++ into your C++ kernel, we need to add some basic functions that can be found in the [cxx.cc](https://github.com/SamyPesse/How-to-Make-a-Computer-Operating-System/blob/master/src/kernel/runtime/cxx.cc) file.
10
8
11
9
**Caution:** The operators `new` and `delete` cannot be used before virtual memory and pagination have been initialized.
Copy file name to clipboardExpand all lines: Chapter-5/README.md
+4-4Lines changed: 4 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -1,18 +1,18 @@
1
1
## Chapter 5: Base classes for managing x86 architecture
2
2
3
-
Now that we know how to compile our C++ kernel and boot the binary using GRUB, we can start to do some nice stuffs in C/C++.
3
+
Now that we know how to compile our C++ kernel and boot the binary using GRUB, we can start to do some cool things in C/C++.
4
4
5
5
#### Printing to the screen console
6
6
7
-
We are going to use VGA default mode (03h) to display some text to the user. The screen can be directly access using the video memory at 0xB8000. The screen resolution is 80x25 and each caracters in the screen is defined by 2 bytes: one for the caracter and one for the style flag. So the size of the video memory is 4000 = 80*25*2
7
+
We are going to use VGA default mode (03h) to display some text to the user. The screen can be directly access using the video memory at 0xB8000. The screen resolution is 80x25 and each character on the screen is defined by 2 bytes: one for the character code, and and one for the style flag. This means that the total size of the video memory is 4000B (80B*25B*2B).
8
8
9
9
In the IO class ([io.cc](https://github.com/SamyPesse/How-to-Make-a-Computer-Operating-System/blob/master/src/kernel/arch/x86/io.cc)),:
10
10
***x,y**: define the cursor position on the screen
11
11
***real_screen**: define the video memory pointer
12
12
***putc(char c)**: print a unique caracter on the screen and manage cursor position
13
13
***printf(char* s, ...)**: print a string
14
14
15
-
We add a method **putc** to the [IO Class](https://github.com/SamyPesse/How-to-Make-a-Computer-Operating-System/blob/master/src/kernel/arch/x86/io.cc) to put a caracter on the screen and update the x,y position.
15
+
We add a method **putc** to the [IO Class](https://github.com/SamyPesse/How-to-Make-a-Computer-Operating-System/blob/master/src/kernel/arch/x86/io.cc) to put a character on the screen and update the (x,y) position.
16
16
17
17
```cpp
18
18
/* put a byte on screen */
@@ -47,7 +47,7 @@ void Io::putc(char c){
47
47
}
48
48
```
49
49
50
-
We also add a usefull and very known method: [printf](https://github.com/SamyPesse/How-to-Make-a-Computer-Operating-System/blob/master/src/kernel/arch/x86/io.cc#L155)
50
+
We also add a useful and very known method: [printf](https://github.com/SamyPesse/How-to-Make-a-Computer-Operating-System/blob/master/src/kernel/arch/x86/io.cc#L155)
Copy file name to clipboardExpand all lines: Chapter-6/README.md
+6-8Lines changed: 6 additions & 8 deletions
Original file line number
Diff line number
Diff line change
@@ -1,12 +1,10 @@
1
1
## Chapter 6: GDT
2
2
3
-
Thanks to GRUB, your kernel is no more in real-mode, but already in [protected mode](http://en.wikipedia.org/wiki/Protected_mode), this mode allows us to use all the possibilities of the microprocessor such as virtual memory management, paging and safe multi-tasking.
3
+
Thanks to GRUB, your kernel is no longer in real-mode, but already in [protected mode](http://en.wikipedia.org/wiki/Protected_mode), this mode allows us to use all the possibilities of the microprocessor such as virtual memory management, paging and safe multi-tasking.
4
4
5
5
#### What is the GDT?
6
6
7
-
The [GDT](http://en.wikipedia.org/wiki/Global_Descriptor_Table) ("Global Descriptor Table") is a data structure used to define the different memory area: the base address, the size and access privileges like executability and writability.
8
-
9
-
These memory areas are called "segments".
7
+
The [GDT](http://en.wikipedia.org/wiki/Global_Descriptor_Table) ("Global Descriptor Table") is a data structure used to define the different memory area: the base address, the size and access privileges like executability and writability. These memory areas are called "segments".
10
8
11
9
We are going to use the GDT to define differents memory segments:
12
10
@@ -19,7 +17,7 @@ We are going to use the GDT to define differents memory segments:
19
17
20
18
#### How to load our GDT?
21
19
22
-
GRUB already initialize a GDT but this GDT is not corresponding to our kernel.
20
+
GRUB initializes a GDT but this GDT is does not correspond to our kernel.
23
21
The GDT is loaded using the LGDT assembly instruction. It expects the location of a GDT description structure:
24
22
25
23

@@ -33,9 +31,9 @@ struct gdtr {
33
31
} __attribute__ ((packed));
34
32
```
35
33
36
-
**Caution:** the directive ```__attribute__ ((packed))``` signal to gcc that the structure should use the less memory possible. Without this directive, gcc include some bytes to optimize the memory alignment and the access during execution.
34
+
**Caution:** the directive ```__attribute__ ((packed))``` signal to gcc that the structure should use as little memory as possible. Without this directive, gcc include some bytes to optimize the memory alignment and the access during execution.
37
35
38
-
So we need to define our GDT table and load it using LGDT. The GDT table can be stored wherever we want in memory, its address should just be signaled to the process using the GDTR registry.
36
+
Now we need to define our GDT table and then load it using LGDT. The GDT table can be stored wherever we want in memory, its address should just be signaled to the process using the GDTR registry.
39
37
40
38
The GDT table is composed of segments with the following structure:
0 commit comments