From 1ad8f714829d698ba8370bd25f43b6b5d70e7126 Mon Sep 17 00:00:00 2001 From: Remi Rampin Date: Sun, 20 Sep 2015 14:08:10 -0400 Subject: [PATCH 1/5] TYPO: wether -> whether --- Booting/linux-bootstrap-1.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Booting/linux-bootstrap-1.md b/Booting/linux-bootstrap-1.md index 2ec9b27..e0004b7 100644 --- a/Booting/linux-bootstrap-1.md +++ b/Booting/linux-bootstrap-1.md @@ -399,11 +399,11 @@ Let's look at all three of these scenarios: sti ``` -Here we can see aligning of `dx` (contains `sp` given by bootloader) to 4 bytes and checking wether it is zero. If it is zero, we put `0xfffc` (4 byte aligned address before maximum segment size - 64 KB) in `dx`. If it is not zero we continue to use `sp` given by the bootloader (0xf7f4 in my case). After this we put the `ax` value to `ss` which stores the correct segment address of `0x10000` and sets up a correct `sp`. We now have a correct stack: +Here we can see aligning of `dx` (contains `sp` given by bootloader) to 4 bytes and checking whether it is zero. If it is zero, we put `0xfffc` (4 byte aligned address before maximum segment size - 64 KB) in `dx`. If it is not zero we continue to use `sp` given by the bootloader (0xf7f4 in my case). After this we put the `ax` value to `ss` which stores the correct segment address of `0x10000` and sets up a correct `sp`. We now have a correct stack: ![stack](http://oi58.tinypic.com/16iwcis.jpg) -2. In the second scenario, (`ss` != `ds`). First of all put the [_end](https://github.com/torvalds/linux/blob/master/arch/x86/boot/setup.ld#L52) (address of end of setup code) value in `dx` and check the `loadflags` header field with the `testb` instruction too see wether we can use heap or not. [loadflags](https://github.com/torvalds/linux/blob/master/arch/x86/boot/header.S#L321) is a bitmask header which is defined as: +2. In the second scenario, (`ss` != `ds`). First of all put the [_end](https://github.com/torvalds/linux/blob/master/arch/x86/boot/setup.ld#L52) (address of end of setup code) value in `dx` and check the `loadflags` header field with the `testb` instruction too see whether we can use heap or not. [loadflags](https://github.com/torvalds/linux/blob/master/arch/x86/boot/header.S#L321) is a bitmask header which is defined as: ```C #define LOADED_HIGH (1<<0) From 72cc33c3c647abe25800265512215d508fe7b437 Mon Sep 17 00:00:00 2001 From: Remi Rampin Date: Sun, 20 Sep 2015 15:30:58 -0400 Subject: [PATCH 2/5] TYPO: minor fixes in booting section --- Booting/linux-bootstrap-2.md | 2 +- Booting/linux-bootstrap-3.md | 10 +++++----- Booting/linux-bootstrap-5.md | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Booting/linux-bootstrap-2.md b/Booting/linux-bootstrap-2.md index 2379001..fd0fe58 100644 --- a/Booting/linux-bootstrap-2.md +++ b/Booting/linux-bootstrap-2.md @@ -224,7 +224,7 @@ Console initialization After the `hdr` is copied into `boot_params.hdr`, the next step is console initialization by calling the `console_init` function which is defined in [arch/x86/boot/early_serial_console.c](https://github.com/torvalds/linux/blob/master/arch/x86/boot/early_serial_console.c). -It tries to find the `earlyprintk` option in the command line and if the search was successful, it parses the port address and baud rate of the serial port and initializes the serial port. Value of `earlyprintk` command line option can be one of the: +It tries to find the `earlyprintk` option in the command line and if the search was successful, it parses the port address and baud rate of the serial port and initializes the serial port. Value of `earlyprintk` command line option can be one of these: * serial,0x3f8,115200 * serial,ttyS0,115200 diff --git a/Booting/linux-bootstrap-3.md b/Booting/linux-bootstrap-3.md index df31090..e3c7503 100644 --- a/Booting/linux-bootstrap-3.md +++ b/Booting/linux-bootstrap-3.md @@ -37,11 +37,11 @@ vga= line is parsed. ``` -So we can add `vga` option to the grub or another bootloader configuration file and it will pass this option to the kernel command line. This option can have different values as we can mentioned in the description, for example it can be an integer number `0xFFFD` or `ask`. If you pass `ask` t `vga`, you will see a menu like this: +So we can add `vga` option to the grub or another bootloader configuration file and it will pass this option to the kernel command line. This option can have different values as we can mentioned in the description, for example it can be an integer number `0xFFFD` or `ask`. If you pass `ask` to `vga`, you will see a menu like this: ![video mode setup menu](http://oi59.tinypic.com/ejcz81.jpg) -which will ask to select a video mode. We will look at it's implementation, but before diving into the implementation we have to look at some other things. +which will ask to select a video mode. We will look at its implementation, but before diving into the implementation we have to look at some other things. Kernel data types -------------------------------------------------------------------------------- @@ -79,10 +79,10 @@ Next is `GET_HEAP` macro: ((type *)__get_heap(sizeof(type),__alignof__(type),(n))) ``` -for heap allocation. It calls internal function `__get_heap` with 3 parameters: +for heap allocation. It calls the internal function `__get_heap` with 3 parameters: * size of a type in bytes, which need be allocated -* `__alignof__(type)` shows how type of variable is aligned +* `__alignof__(type)` shows how variables of this type are aligned * `n` tells how many bytes to allocate Implementation of `__get_heap` is: @@ -567,7 +567,7 @@ That's all we're in the protected mode and stop at it's entry point. What happen Conclusion -------------------------------------------------------------------------------- -It is the end of the third part about linux kernel internals. In next part we will see first steps in the protected mode and transition into the [long mode](http://en.wikipedia.org/wiki/Long_mode). +This is the end of the third part about linux kernel internals. In next part we will see first steps in the protected mode and transition into the [long mode](http://en.wikipedia.org/wiki/Long_mode). If you have any questions or suggestions write me a comment or ping me at [twitter](https://twitter.com/0xAX). diff --git a/Booting/linux-bootstrap-5.md b/Booting/linux-bootstrap-5.md index 5e0c90e..a94ee12 100644 --- a/Booting/linux-bootstrap-5.md +++ b/Booting/linux-bootstrap-5.md @@ -154,7 +154,7 @@ Note that there is `std` instruction before data copying, it sets `DF` flag and In the end we clear `DF` flag with `cld` instruction and restore `boot_params` structure to the `rsi`. -After it we get `.text` section address address and jump to it: +After it we get `.text` section address and jump to it: ```assembly leaq relocated(%rbx), %rax From 6aaa477bc696474acb01d70e8d0189ac17fc69ea Mon Sep 17 00:00:00 2001 From: Remi Rampin Date: Sun, 20 Sep 2015 15:31:16 -0400 Subject: [PATCH 3/5] TYPO: put_char -> putchar --- Booting/linux-bootstrap-2.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Booting/linux-bootstrap-2.md b/Booting/linux-bootstrap-2.md index fd0fe58..07d74cb 100644 --- a/Booting/linux-bootstrap-2.md +++ b/Booting/linux-bootstrap-2.md @@ -254,7 +254,7 @@ void __attribute__((section(".inittext"))) putchar(int ch) `__attribute__((section(".inittext")))` means that this code will be in the `.inittext` section. We can find it in the linker file [setup.ld](https://github.com/torvalds/linux/blob/master/arch/x86/boot/setup.ld#L19). -First of all, `put_char` checks for the `\n` symbol and if it is found, prints `\r` before. After that it outputs the character on the VGA screen by calling the BIOS with the `0x10` interrupt call: +First of all, `putchar` checks for the `\n` symbol and if it is found, prints `\r` before. After that it outputs the character on the VGA screen by calling the BIOS with the `0x10` interrupt call: ```C static void __attribute__((section(".inittext"))) bios_putchar(int ch) From be59a42e94e3c3aa77f2c26952a9faa7b92c5bf0 Mon Sep 17 00:00:00 2001 From: Remi Rampin Date: Sun, 20 Sep 2015 15:31:23 -0400 Subject: [PATCH 4/5] Fix get_heap arguments meaning `n` is not the number of bytes but the number of items which are each of the given size. --- Booting/linux-bootstrap-3.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Booting/linux-bootstrap-3.md b/Booting/linux-bootstrap-3.md index e3c7503..06497c5 100644 --- a/Booting/linux-bootstrap-3.md +++ b/Booting/linux-bootstrap-3.md @@ -83,7 +83,7 @@ for heap allocation. It calls the internal function `__get_heap` with 3 paramete * size of a type in bytes, which need be allocated * `__alignof__(type)` shows how variables of this type are aligned -* `n` tells how many bytes to allocate +* `n` tells how many items to allocate Implementation of `__get_heap` is: From 4f39905d724b27d86c18fc633dad8c7778dc9823 Mon Sep 17 00:00:00 2001 From: Josua Krause Date: Sun, 20 Sep 2015 15:35:00 -0400 Subject: [PATCH 5/5] TYPO: 'git check' alias in Misc/contribute --- Misc/contribute.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Misc/contribute.md b/Misc/contribute.md index 1ffc484..a9d9652 100644 --- a/Misc/contribute.md +++ b/Misc/contribute.md @@ -66,7 +66,7 @@ $ git clone git@github.com:torvalds/linux.git Actually I'm using my [fork](https://github.com/0xAX/linux) for development and when I want to pull updates from the main repository I just execute following command: ``` -$ git check master +$ git checkout master $ git pull upstream master ```