mirror of
https://github.com/memtest86plus/memtest86plus.git
synced 2025-02-25 18:55:23 -06:00
Rearrange stack space to reduce memory footprint.
The BSP only needs extra stack space during program initialisation. The APs aren't running at that point, so by positioning the BSP stack above the AP stacks, it can extend down into the AP stack space without causing any problems.
This commit is contained in:
parent
a454174f3f
commit
0aa1b1fa97
11
boot/boot.h
11
boot/boot.h
@ -5,15 +5,20 @@
|
||||
* Definitions used in the boot code. Also defines exported symbols needed
|
||||
* in the main code.
|
||||
*
|
||||
* Copyright (C) 2020 Martin Whitaker.
|
||||
* Copyright (C) 2020-2022 Martin Whitaker.
|
||||
*/
|
||||
|
||||
#define MAX_APS 64 /* Maximum number of active APs. This
|
||||
only affects memory footprint, so
|
||||
can be increased if needed */
|
||||
|
||||
#define BSP_STACK_SIZE 4096 /* Stack size for the BSP */
|
||||
#define AP_STACK_SIZE 2048 /* Stack size for each AP */
|
||||
// NOTE: Before the APs are started, the BSP stack can extend downwards into
|
||||
// the area reserved for the AP stacks. So the stack size given here just
|
||||
// needs to be enough for running the main application once initialisation
|
||||
// is complete. The pmem initialisation needs ~12KB of stack, so make sure
|
||||
// the total stack size is at least that.
|
||||
|
||||
#define PCPU_STACK_SIZE 2048 /* Stack size for each CPU core */
|
||||
|
||||
#define LOW_LOAD_ADDR 0x00010000 /* The low load address for the main program */
|
||||
#define HIGH_LOAD_ADDR 0x00100000 /* The high load address for the main program */
|
||||
|
@ -6,7 +6,7 @@
|
||||
// It supports the 32-bit Linux boot protocol and EFI boot for the first
|
||||
// boot of the BSP.
|
||||
//
|
||||
// Copyright (C) 2020 Martin Whitaker.
|
||||
// Copyright (C) 2020-2022 Martin Whitaker.
|
||||
//
|
||||
// Derived from memtest86+ head.S:
|
||||
//
|
||||
@ -91,10 +91,10 @@ startup:
|
||||
# Pick the correct stack.
|
||||
|
||||
call smp_my_pcpu_num
|
||||
movl $AP_STACK_SIZE, %edx
|
||||
movl $PCPU_STACK_SIZE, %edx
|
||||
mul %edx
|
||||
leal bsp_stack_top@GOTOFF(%ebx), %esp
|
||||
addl %eax, %esp
|
||||
subl %eax, %esp
|
||||
|
||||
# Initialise the GDT descriptor.
|
||||
|
||||
@ -557,14 +557,14 @@ first_boot:
|
||||
.bss
|
||||
.align 16
|
||||
|
||||
bsp_stack_base:
|
||||
. = . + BSP_STACK_SIZE
|
||||
bsp_stack_top:
|
||||
|
||||
ap_stacks_base:
|
||||
. = . + (AP_STACK_SIZE * MAX_APS)
|
||||
. = . + (PCPU_STACK_SIZE * MAX_APS)
|
||||
ap_stacks_top:
|
||||
|
||||
bsp_stack_base:
|
||||
. = . + PCPU_STACK_SIZE
|
||||
bsp_stack_top:
|
||||
|
||||
startup_stack_base:
|
||||
. = . + 64
|
||||
startup_stack_top:
|
||||
|
@ -6,7 +6,7 @@
|
||||
// It supports both the 32-bit and 64-bit Linux boot protocols and EFI boot
|
||||
// for the first boot of the BSP.
|
||||
//
|
||||
// Copyright (C) 2020 Martin Whitaker.
|
||||
// Copyright (C) 2020-2022 Martin Whitaker.
|
||||
//
|
||||
// Derived from memtest86+ head.S:
|
||||
//
|
||||
@ -151,10 +151,10 @@ startup:
|
||||
|
||||
xorq %rax, %rax
|
||||
call smp_my_pcpu_num
|
||||
movl $AP_STACK_SIZE, %edx
|
||||
movl $PCPU_STACK_SIZE, %edx
|
||||
mul %edx
|
||||
leaq bsp_stack_top(%rip), %rsp
|
||||
addq %rax, %rsp
|
||||
subq %rax, %rsp
|
||||
|
||||
# Initialise the pml4 and pdp tables.
|
||||
|
||||
@ -602,14 +602,14 @@ first_boot:
|
||||
.bss
|
||||
.align 16
|
||||
|
||||
bsp_stack_base:
|
||||
. = . + BSP_STACK_SIZE
|
||||
bsp_stack_top:
|
||||
|
||||
ap_stacks_base:
|
||||
. = . + (AP_STACK_SIZE * MAX_APS)
|
||||
. = . + (PCPU_STACK_SIZE * MAX_APS)
|
||||
ap_stacks_top:
|
||||
|
||||
bsp_stack_base:
|
||||
. = . + PCPU_STACK_SIZE
|
||||
bsp_stack_top:
|
||||
|
||||
startup_stack_base:
|
||||
. = . + 64
|
||||
startup_stack_top:
|
||||
|
Loading…
Reference in New Issue
Block a user