Skip to content

Commit 7cf81cd

Browse files
committed
Merge pull request 0xAX#71 from polachok/patch-1
Update linux-initialization-3.md
2 parents 49d66d6 + b1179cb commit 7cf81cd

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

Initialization/linux-initialization-3.md

+11-11
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Kernel initialization. Part 3.
44
Last preparations before the kernel entry point
55
--------------------------------------------------------------------------------
66

7-
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.
88

99
Again boot_params
1010
--------------------------------------------------------------------------------
@@ -224,7 +224,7 @@ only with one difference: we pass argument with the `phys_addr_t` which depends
224224
#endif
225225
```
226226

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.
228228

229229
In the next step we check that address of the extended BIOS data area and low memory is not less than `INSANE_CUTOFF` macro
230230

@@ -242,25 +242,25 @@ which is:
242242
#define INSANE_CUTOFF 0x20000U
243243
```
244244

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:
246246

247247
```C
248248
lowmem = min(lowmem, ebda_addr);
249249
lowmem = min(lowmem, LOWMEM_CAP);
250250
memblock_reserve(lowmem, 0x100000 - lowmem);
251251
```
252252
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:
254254
255255
* base physical address;
256256
* region size.
257257
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.
259259
260260
First touch of the linux kernel memory manager framework
261261
--------------------------------------------------------------------------------
262262
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 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:
264264
265265
```C
266266
memblock_reserve_region(base, size, MAX_NUMNODES, 0);
@@ -324,7 +324,7 @@ struct memblock memblock __initdata_memblock = {
324324
};
325325
```
326326

327-
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:
328328

329329
```C
330330
#define __initdata_memblock __meminitdata
@@ -376,7 +376,7 @@ struct memblock_region {
376376
};
377377
```
378378

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):
380380

381381
```C
382382
#define MAX_NUMNODES (1 << NODES_SHIFT)
@@ -401,15 +401,15 @@ static inline void memblock_set_region_node(struct memblock_region *r, int nid)
401401
}
402402
```
403403
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 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).
405405
406406
We finished all preparations before the kernel entry point! The last step in the `x86_64_start_reservations` function is the call of the:
407407
408408
```C
409409
start_kernel()
410410
```
411411

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.
413413

414414
That's all for this part.
415415

@@ -418,7 +418,7 @@ Conclusion
418418

419419
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.
420420

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).
422422

423423
**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).**
424424

0 commit comments

Comments
 (0)