Developing a Multithreaded Kernel From Scratch!

Developing a Multithreaded Kernel From Scratch!

English | MP4 | AVC 1920×1080 | AAC 44KHz 2ch | 138 lectures (28h 13m) | 17.17 GB

Build a multitasking operating system and kernel with an interactive shell!

This course is designed to teach you how to create your very own multitasking operating system and kernel from scratch. It is assumed you have no experience in programming kernels and you are taught from the ground up.

Real Mode Development

Real mode is a legacy mode in all Intel processors that causes the processor to start in a legacy state, it performs like the old 8086 Intel processors did back in the way.

In the “Real Mode Development” section of the course we start by learning about the boot process and how memory works, we then move on to creating our very own boot loader that we test on our real machine! This boot loader will output a simple “Hello World!” message to the screen and we write this boot loader in purely assembly language.

In this section we also read a sector(512 bytes) from the hard disk and learn all about interrupts in real mode and how to create them.

This section gives you a nice taster into kernel development, without over whelming you with information. You are taught the basics and enough about the legacy processors to be able to move forward to more modern kernel development further into this course.

Protected Mode Development

In this section we create a 32 bit multi-tasking kernel that has the FAT16 filesystem. Our kernel will use Intel’s built in memory protection and security mechanisms that allow us to instruct the processor to protect our kernel and prevent user programs from damaging it.

This section is very in depth, you are taught all about paging and virtual memory. We take advantage of clever instructions in Intel processors to allow all processes to share the same memory addresses, this is known as memory virtualization. We map memory addresses to point to different physical memory addresses to create the illusion that every process that is running is loaded at the same address. This is a very common technique in kernel development and is also how swap files work (Those files that are used to compensate for when you run out of usable RAM).

We create our own virtual filesystem layer that uses a design that is similar to the Linux kernel. This clever abstraction that will be taught to you was inspired by the instructors knowledge of writing Linux kernel drivers in his past.

You are taught about the design of the FAT16 filesystem and how the FAT16 filesystem is broken down into clusters and that they can chain together. We then implement our very own FAT16 filesystem driver allowing files to be born!

We implement functionality for tasks and processes and write our own keyboard drivers.

In this course you also get to learn how memory management works, we implement the “malloc” and “free” functions creating our very own heap that’s designed to keep track of what memory is being used. Memory management is essential in any operating system and kernel.

Let us not forget that we even create an ELF file loader, we will compile all our operating systems programs into ELF files and allow the loading of binary programs or ELF programs. ELF files contain a lot of information that describes our program for example where our program should be loaded into memory and the different sections of the program.

By the end of this course you will have a fully functioning 32 bit multi-tasking kernel that can have many processes and tasks running at the same time. You will have a working shell that we can use as well.

Assembly language bonus

This is a bonus section designed to bring your assembly skills up to scratch should you struggle a little bit with the assembly language in this course. It’s however advised you come to this course with experience in assembly language, we do use it and its important. Never the less if you want to take a chance on this course with no assembly experience then this section will help point you in the right direction so your able to take what you learned and apply it to the kernel.

Taught by an expert that has created Linux kernel modules professionally in the work place. 15 Years Experience As A Software Engineer

What you’ll learn

  • How to create a kernel from scratch
  • How to create a multi-tasking kernel
  • How to handle malicious or problematic programs in your operating system. Terminating them if they misbehave.
  • How memory works in computers
  • The difference between kernel land, user land and the protection rings that make up modern computing
  • Kernel design patterns used by the Linux kernel its self
  • You will learn all about virtual memory and how to map virtual addresses to physical addresses
  • You will learn how to make the kernel understand processes and tasks
  • You will learn how to load ELF files
  • You will learn how to debug disassembled machine code
  • You will learn how to debug your kernel in an emulator with GDB.
Table of Contents

Introduction
1 Introduction

Setup And A Brief Explanation Of Kernel Development
2 What Is Memory
3 The Boot Process
4 Installing What We Need For Real Mode Development

Real Mode Development
5 Hello World Bootloader
6 Understanding Real Mode
7 Segmentation Memory Model
8 Improving Our Bootloader
9 Preparing our bootloader to be booted on real hardware
10 Writing our bootloader to a USB stick
11 Booting the bootloader
12 The Interrupt Vector Table Explained
13 Implementing our own interrupts in real mode
14 Disk Access And How It Works
15 Reading from the hard disk

Protected Mode Development
16 What is Protected Mode
17 Switching To Protected Mode
18 Restructuring Our Project
19 Enabling the A20 line
20 Creating a Cross Compiler So We Can Code In C
21 Loading our 32 bit kernel into memory and working with debugging symbols
22 Cleaning our object files
23 Dealing With Alignment Issues
24 C Code In Protected Mode
25 Text Mode Explained
26 Writing To The Screen Hello World Tutorial
27 Interrupt Descriptor Table Explained
28 Implementing The Interrupt Descriptor Table
29 Implementing In and Out Functions
30 Programmable Interrupt Controller Explained
31 Programmable Interrupt Controller Implementation
32 Understanding The Heap And Memory Allocation
33 Implementing Our Heap
34 Creating the enable interrupts function
35 Understanding Paging
36 Implementing Paging
37 Modifying the page table
38 Preparing To Read From The Hard Disk
39 Reading from the disk in C with the ATA controller
40 Improving Our Disk Driver
41 What is a filesystem
42 Creating a path parser
43 Creating a disk stream
44 File Allocation Table Explained
45 Starting To Create our FAT File system
46 Understanding the VFSVirtual File System Layer
47 Implementing our virtual filesystem core functionality
48 implementing FAT16 filesystem driver core functionality
49 Implementing FAT16 Structures
50 Implementing The FAT16 Resolver Function
51 Implementing the VFS fopen function
52 Implementing FAT16 fopen function
53 Implementing the VFS fread function
54 Implementing FAT16 fread functionality
55 Implementing the VFS fseek functionality
56 Implementing the FAT16 fseek functionality
57 Implementing the fstat VFS functionality
58 Implementing the FAT16 fstat function
59 Implementing the VFS fclose functionality
60 Implementing the FAT16 fclose functionality
61 Implementing a kernel panic
62 Understanding User Land
63 Changing our kernel segment and data descriptors to be written in C
64 Implementing The TSSTask Switch Segment
65 Implementing Task Foundations
66 Implementing Process Foundations Part 1
67 Implementing Process Foundations Part 2
68 Packing the GDT
69 Implementing User Land Functionality
70 Creating our first user process application
71 Executing the process and dropping into user land privileges
72 Changing the paging functionality
73 Talking with the kernel from userland
74 Creating the interrupt 0x80 for user process to kernel communication
75 Creating the ability to create and execute kernel commands
76 Creating our first kernel command
77 Calling our kernel command
78 Copying strings from the tasks process
79 Reading the tasks stack
80 Creating the print command in the kernel
81 Understanding keyboard access in protected mode
82 Creating the virtual keyboard layer
83 Creating the PS2 port keyboard driver part 1
84 Improving our interrupt descriptor table design
85 Creating a cleaner way to create interrupt handlers in the interrupt descriptor
86 Changing The Current Process
87 Creating the PS2 port keyboard driver part 2
88 Getting a key from the keyboard buffer in user land
89 Creating a putchar command that writes one character to the terminal
90 Implementing backspace in the terminal
91 Revising our stream reader
92 Elf Files Explained
93 Implementing The Elf Loader Part 1
94 Implementing The Elf Loader Part 2
95 Implementing The Elf Loader Part 3
96 Implementing The Elf Loader Part 4
97 Implementing The Elf Loader Part 5
98 Implementing The Elf Loader Part 6
99 Writing User Programs In C
100 Implementing system print in stdlib
101 Implementing system get key in stdlib
102 Implementing Malloc In Our stdlib
103 Implementing Free In Our stdlib
104 Changing the way we map virtual pages for the process
105 Implementing itoa function
106 Implementing the putchar function
107 Implementing the printf function
108 Implementing the ability to read lines
109 Creating a shell
110 Loading other programs from our shell
111 Creating some important stdlib functions
112 Memory Mapping malloc in stdlib
113 Memory Unmapping free In stdlib
114 Process arguments Part 1
115 Process Arguments Part 2
116 Process Arguments Part 3
117 Implementing A System Command
118 Implementing program termination
119 Handling program crashes
120 Creating an exit command
121 Handling caps lock upper case and lower case letters
122 Running multiple tasks at the same time multitasking

Optional
123 README
124 Changing our fat16newfatitemfordirectoryitem function
125 Changing our fat16open function
126 Changing our fat16getrootdirectory function
127 Changing our processloadbinary function
128 Improvements to our fat16toproperstring function
129 Changing our restoregeneralpurposeregisters function

Assembly Language Catchup
130 Assembly Catchup
131 What is assembly language
132 Installing the emulator
133 Hello World In Assembly
134 Transistors And Logic Gates Understanding The Processor
135 Registers in the 8086
136 Segmentation Memory Model Explained
137 The Stack Subroutines And Endiness Explained

Conclusion
138 Bonus Lecture

Homepage