From 220d3378f7217f50373370f1e88b56b29406ed7f Mon Sep 17 00:00:00 2001 From: Alexander Kuleshov Date: Tue, 12 Sep 2017 00:53:18 +0600 Subject: [PATCH] boot: STACK_SIZE is 1024 now since https://github.com/torvalds/linux/commit/d594aa0277e541bb997aef0bc0a55172d8138340#diff-0af1468d3dc7f373d70011eda7be1592 --- Booting/linux-bootstrap-1.md | 2 +- Booting/linux-bootstrap-2.md | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Booting/linux-bootstrap-1.md b/Booting/linux-bootstrap-1.md index d60496e..31930c5 100644 --- a/Booting/linux-bootstrap-1.md +++ b/Booting/linux-bootstrap-1.md @@ -432,7 +432,7 @@ Field name: loadflags functionality will be disabled. ``` -If the `CAN_USE_HEAP` bit is set, we put `heap_end_ptr` into `dx` (which points to `_end`) and add `STACK_SIZE` (minimum stack size, `512` bytes) to it. After this, if `dx` is not carried (it will not be carried, `dx = _end + 512`), jump to label `2` (as in the previous case) and make a correct stack. +If the `CAN_USE_HEAP` bit is set, we put `heap_end_ptr` into `dx` (which points to `_end`) and add `STACK_SIZE` (minimum stack size, `1024` bytes) to it. After this, if `dx` is not carried (it will not be carried, `dx = _end + 1024`), jump to label `2` (as in the previous case) and make a correct stack. ![stack](http://oi62.tinypic.com/dr7b5w.jpg) diff --git a/Booting/linux-bootstrap-2.md b/Booting/linux-bootstrap-2.md index b4bc0b3..e82c4f2 100644 --- a/Booting/linux-bootstrap-2.md +++ b/Booting/linux-bootstrap-2.md @@ -329,10 +329,12 @@ First of all `init_heap` checks the [`CAN_USE_HEAP`](https://github.com/torvalds or in other words `stack_end = esp - STACK_SIZE`. Then there is the `heap_end` calculation: -```c - heap_end = (char *)((size_t)boot_params.hdr.heap_end_ptr + 0x200); + +```C + heap_end = (char *)((size_t)boot_params.hdr.heap_end_ptr + 0x200); ``` -which means `heap_end_ptr` or `_end` + `512`(`0x200h`). The last check is whether `heap_end` is greater than `stack_end`. If it is then `stack_end` is assigned to `heap_end` to make them equal. + +which means `heap_end_ptr` or `_end` + `512` (`0x200h`). The last check is whether `heap_end` is greater than `stack_end`. If it is then `stack_end` is assigned to `heap_end` to make them equal. Now the heap is initialized and we can use it using the `GET_HEAP` method. We will see how it is used, how to use it and how it is implemented in the next posts.