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
This is third part of the Linux kernel initialization process series. In the previous [part](https://github.com/0xAX/linux-insides/blob/master/Initialization/linux-initialization-2.md) we saw early interupt and exception handling and will continue to dive into the linux kernel initialization process in the current part. Our next point is 'kernel entry point' - `start_kernel` function from the [init/main.c](https://github.com/torvalds/linux/blob/master/init/main.c) source code file. Yes, technically it is not kernel's entry point but the start of the generic kernel code which does not depend on certain architecture. But before we will see call of the `start_kernel` function, we must do some preparations. So let's continue.
7
+
This is the third part of the Linux kernel initialization process series. In the previous [part](https://github.com/0xAX/linux-insides/blob/master/Initialization/linux-initialization-2.md) we saw early interupt and exception handling and will continue to dive into the linux kernel initialization process in the current part. Our next point is 'kernel entry point' - `start_kernel` function from the [init/main.c](https://github.com/torvalds/linux/blob/master/init/main.c) source code file. Yes, technically it is not kernel's entry point but the start of the generic kernel code which does not depend on certain architecture. But before we will see call of the `start_kernel` function, we must do some preparations. So let's continue.
@@ -224,7 +224,7 @@ only with one difference: we pass argument with the `phys_addr_t` which depends
224
224
#endif
225
225
```
226
226
227
-
This configuration option enabled for`CONFIG_PHYS_ADDR_T_64BIT`. After that we got virtual address of the segment which stores the base address of the extended BIOS data area we shift it on 4 and return. After this `ebda_addr` variables contains the base address of the extended BIOS data area.
227
+
This configuration option is enabled by`CONFIG_PHYS_ADDR_T_64BIT`. After that we got virtual address of the segment which stores the base address of the extended BIOS data area, we shift it on 4 and return. After this `ebda_addr` variables contains the base address of the extended BIOS data area.
228
228
229
229
In the next step we check that address of the extended BIOS data area and low memory is not less than `INSANE_CUTOFF` macro
230
230
@@ -242,25 +242,25 @@ which is:
242
242
#defineINSANE_CUTOFF 0x20000U
243
243
```
244
244
245
-
or 128 kilobytes. In the last step we get lower part in the low memory and extended bios data area and call `memblock_reserve` function which will reserve memory region for extended bios data are between low memory and one megabyte mark:
245
+
or 128 kilobytes. In the last step we get lower part in the low memory and extended bios data area and call `memblock_reserve` function which will reserve memory region for extended bios data between low memory and one megabyte mark:
246
246
247
247
```C
248
248
lowmem = min(lowmem, ebda_addr);
249
249
lowmem = min(lowmem, LOWMEM_CAP);
250
250
memblock_reserve(lowmem, 0x100000 - lowmem);
251
251
```
252
252
253
-
`memblock_reserve` function defined in the [mm/block.c](https://github.com/torvalds/linux/blob/master/mm/block.c) and takes two paramters:
253
+
`memblock_reserve` function is defined at [mm/block.c](https://github.com/torvalds/linux/blob/master/mm/block.c) and takes two paramters:
254
254
255
255
* base physical address;
256
256
* region size.
257
257
258
-
and reserves memory region for the given base address and size. `memblock_reserve` is a first function in this book from linux kernel memory manager framework. Soon we will take a closer look on memory manager, but now let's look on it's implementation.
258
+
and reserves memory region for the given base address and size. `memblock_reserve` is the first function in this book from linux kernel memory manager framework. We will take a closer look on memory manager soon, but now let's look at its implementation.
259
259
260
260
First touch of the linux kernel memory manager framework
In the previous paragraph we stopped at the call of the `memblock_reserve` function and as i sad before it is the first function from the memory manager framework. Let's try to understand how it works. `memblock_reserve` function make just makes an one call of the:
263
+
In the previous paragraph we stopped at the call of the `memblock_reserve` function and as i sad before it is the first function from the memory manager framework. Let's try to understand how it works. `memblock_reserve` function just calls:
We will not dive into detail about this varaible, but we will see all details about it in the parts about memory manager. Just note that `memblock` variable defined with the `__initdata_memblock` which is:
327
+
We will not dive into detail of this varaible, but we will see all details about it in the parts about memory manager. Just note that `memblock` variable defined with the `__initdata_memblock` which is:
328
328
329
329
```C
330
330
#define__initdata_memblock__meminitdata
@@ -376,7 +376,7 @@ struct memblock_region {
376
376
};
377
377
```
378
378
379
-
NUMA node id depends on `MAX_NUMNODES` macro which defined in the [include/linux/numa.h](https://github.com/torvalds/linux/blob/master/include/linux/numa.h):
379
+
NUMA node id depends on `MAX_NUMNODES` macro which is defined in the [include/linux/numa.h](https://github.com/torvalds/linux/blob/master/include/linux/numa.h):
After this we will have first reserved `memblock` for the extended bios data area in the `.meminit.data` section. `reserve_ebda_region` function finished it's work on this step and we can back to the [arch/x86/kernel/head64.c](https://github.com/torvalds/linux/blob/master/arch/x86/kernel/head64.c).
404
+
After this we will have first reserved `memblock` for the extended bios data area in the `.meminit.data` section. `reserve_ebda_region` function finished its work on this step and we can go back to the [arch/x86/kernel/head64.c](https://github.com/torvalds/linux/blob/master/arch/x86/kernel/head64.c).
405
405
406
406
We finished all preparations before the kernel entry point! The last step in the `x86_64_start_reservations` function is the call of the:
407
407
408
408
```C
409
409
start_kernel()
410
410
```
411
411
412
-
function from the [init/main.c](https://github.com/torvalds/linux/blob/master/init/main.c) source code file.
412
+
function from [init/main.c](https://github.com/torvalds/linux/blob/master/init/main.c) file.
413
413
414
414
That's all for this part.
415
415
@@ -418,7 +418,7 @@ Conclusion
418
418
419
419
It is the end of the third part about linux kernel internals. In next part we will see the first initialization steps in the kernel entry point - `start_kernel` function. It will be the first step before we will see launch of the first `init` process.
420
420
421
-
If you will have any questions or suggestions write me a comment or ping me at [twitter](https://twitter.com/0xAX).
421
+
If you have any questions or suggestions write me a comment or ping me at [twitter](https://twitter.com/0xAX).
422
422
423
423
**Please note that English is not my first language, And I am really sorry for any inconvenience. If you will find any mistakes please send me PR to [linux-internals](https://github.com/0xAX/linux-internals).**
0 commit comments