-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure
executable file
·94 lines (77 loc) · 6.53 KB
/
configure
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#!/bin/bash
SED_HEX_OR_NUMBER_REGEX='\([[:digit:]]\+\|0x[0-9A-Fa-f]\+\)'
# Configure bootloader padding
BOOTLOADER_PADDING=32
sed -i "s/\#define BOOTLOADER_PADDING $SED_HEX_OR_NUMBER_REGEX/\#define BOOTLOADER_PADDING $BOOTLOADER_PADDING/" utilities/format_iso.cpp
sed -i "s/BOOTLOADER_PADDING equ $SED_HEX_OR_NUMBER_REGEX/BOOTLOADER_PADDING equ $BOOTLOADER_PADDING/" src/boot/stage1/bootload.asm
# Configure bootloader segment
BOOTLOADER_SEGMENT=0x07c0
sed -i "s/BOOTLOADER_SEGMENT equ $SED_HEX_OR_NUMBER_REGEX/BOOTLOADER_SEGMENT equ $BOOTLOADER_SEGMENT/" src/boot/stage1/bootload.asm
sed -i "s/BOOTLOADER_SEGMENT equ $SED_HEX_OR_NUMBER_REGEX/BOOTLOADER_SEGMENT equ $BOOTLOADER_SEGMENT/" src/boot/stage2/elfparse.asm
sed -i "s/BOOTLOADER_SEGMENT equ $SED_HEX_OR_NUMBER_REGEX/BOOTLOADER_SEGMENT equ $BOOTLOADER_SEGMENT/" src/boot/stage2/k64load.asm
# Configure bootloader stack size
BOOTLOADER_STACK_SIZE=0x0c00
sed -i "s/BOOTLOADER_STACK_SIZE equ $SED_HEX_OR_NUMBER_REGEX/BOOTLOADER_STACK_SIZE equ $BOOTLOADER_STACK_SIZE/" src/boot/stage1/bootload.asm
sed -i "s/BOOTLOADER_STACK_SIZE equ $SED_HEX_OR_NUMBER_REGEX/BOOTLOADER_STACK_SIZE equ $BOOTLOADER_STACK_SIZE/" src/boot/stage2/k64load.asm
# Configure per CPU stack size for 64-bit mode
CPU_STACK_SIZE=0x10000
sed -i "s/CPU_STACK_SIZE equ $SED_HEX_OR_NUMBER_REGEX/CPU_STACK_SIZE equ $CPU_STACK_SIZE/" src/boot/kernelasm.asm
sed -i "s/\#define CPU_STACK_SIZE $SED_HEX_OR_NUMBER_REGEX/\#define CPU_STACK_SIZE $CPU_STACK_SIZE/" src/include/kernel/kernel.h
# Configure ISO sector size
ISO_SECTOR_SIZE=2048
sed -i "s/\#define ISO_SECTOR_SIZE $SED_HEX_OR_NUMBER_REGEX/\#define ISO_SECTOR_SIZE $ISO_SECTOR_SIZE/" utilities/format_iso.cpp
sed -i "s/\#define ISO_SECTOR_SIZE $SED_HEX_OR_NUMBER_REGEX/\#define ISO_SECTOR_SIZE $ISO_SECTOR_SIZE/" src/boot/stage2/loader32.cpp
sed -i "s/ISO_SECTOR_SIZE equ $SED_HEX_OR_NUMBER_REGEX/ISO_SECTOR_SIZE equ $ISO_SECTOR_SIZE/" src/boot/stage1/bootload.asm
# Configure VBE modes info location
VBE_MODES_INFO_LOCATION=0x30000
sed -i "s/VBE_MODES_INFO_LOCATION equ $SED_HEX_OR_NUMBER_REGEX/VBE_MODES_INFO_LOCATION equ $VBE_MODES_INFO_LOCATION/" src/boot/stage1/videoModes.asm
# Configure ELF parser origin
ELFPARSE_ORIGIN=0x00020000
sed -i "s/\#define ELFPARSE_ORIGIN $SED_HEX_OR_NUMBER_REGEX/\#define ELFPARSE_ORIGIN $ELFPARSE_ORIGIN/" utilities/format_iso.cpp
sed -i "s/ELFPARSE_ORIGIN equ $SED_HEX_OR_NUMBER_REGEX/ELFPARSE_ORIGIN equ $ELFPARSE_ORIGIN/" src/boot/stage1/bootload.asm
sed -i "2s/\[org $SED_HEX_OR_NUMBER_REGEX\]/\[org $ELFPARSE_ORIGIN\]/" src/boot/stage2/elfparse.asm
# Configure loader32 origin
LOADER32_ORIGIN=0x00100000
sed -i "s/\. = $SED_HEX_OR_NUMBER_REGEX;/\. = $LOADER32_ORIGIN;/" src/boot/stage2/link.ld
sed -i "s/\#define LOADER32_ORIGIN $SED_HEX_OR_NUMBER_REGEX/\#define LOADER32_ORIGIN $LOADER32_ORIGIN/" src/boot/stage2/loader32.cpp
sed -i "s/LOADER32_ORIGIN equ $SED_HEX_OR_NUMBER_REGEX/LOADER32_ORIGIN equ $LOADER32_ORIGIN/" src/boot/stage2/elfparse.asm
# Configure the scratch memory base where kernel and loader32 is loaded from
L32K64_SCRATCH_BASE=0x80000
sed -i "s/\#define L32K64_SCRATCH_BASE $SED_HEX_OR_NUMBER_REGEX/\#define L32K64_SCRATCH_BASE $L32K64_SCRATCH_BASE/" utilities/format_iso.cpp
sed -i "s/\#define L32K64_SCRATCH_BASE $SED_HEX_OR_NUMBER_REGEX/\#define L32K64_SCRATCH_BASE $L32K64_SCRATCH_BASE/" src/boot/stage2/loader32.cpp
sed -i "s/\#define L32K64_SCRATCH_BASE $SED_HEX_OR_NUMBER_REGEX/\#define L32K64_SCRATCH_BASE $L32K64_SCRATCH_BASE/" src/include/kernel/kernel.h
sed -i "s/L32K64_SCRATCH_BASE equ $SED_HEX_OR_NUMBER_REGEX/L32K64_SCRATCH_BASE equ $L32K64_SCRATCH_BASE/" src/boot/stage2/elfparse.asm
# Configure the scratch memory length where kernel and loader32 is loaded from
L32K64_SCRATCH_LENGTH=0x10000
sed -i "s/\#define L32K64_SCRATCH_LENGTH $SED_HEX_OR_NUMBER_REGEX/\#define L32K64_SCRATCH_LENGTH $L32K64_SCRATCH_LENGTH/" src/boot/stage2/loader32.cpp
sed -i "s/\#define L32K64_SCRATCH_LENGTH $SED_HEX_OR_NUMBER_REGEX/\#define L32K64_SCRATCH_LENGTH $L32K64_SCRATCH_LENGTH/" src/include/kernel/kernel.h
sed -i "s/L32K64_SCRATCH_LENGTH equ $SED_HEX_OR_NUMBER_REGEX/L32K64_SCRATCH_LENGTH equ $L32K64_SCRATCH_LENGTH/" src/boot/stage1/mmap.asm
# Configure the size of physical memory in MiBs that loader32 will identity map for kernel's initial setup
# Should never exceed 256MiB
L32_IDENTITY_MAP_SIZE=32
sed -i "s/\#define L32_IDENTITY_MAP_SIZE $SED_HEX_OR_NUMBER_REGEX/\#define L32_IDENTITY_MAP_SIZE $L32_IDENTITY_MAP_SIZE/" src/boot/stage2/loader32.cpp
sed -i "s/\#define L32_IDENTITY_MAP_SIZE $SED_HEX_OR_NUMBER_REGEX/\#define L32_IDENTITY_MAP_SIZE $L32_IDENTITY_MAP_SIZE/" src/include/kernel/kernel.h
# Configure kernel origin
# Should always fit in the last 4 GiB of virtual address space to allow mcmodel=kernel during linking
KERNEL_ORIGIN=0xffffffff80000000
sed -i "s/KERNEL_ORIGIN equ $SED_HEX_OR_NUMBER_REGEX/KERNEL_ORIGIN equ $KERNEL_ORIGIN/" src/boot/stage2/loader32asm.asm
sed -i "s/\. = $SED_HEX_OR_NUMBER_REGEX; \/\* kernel origin \*\//\. = $KERNEL_ORIGIN; \/\* kernel origin \*\//" src/boot/link.ld
sed -i "s/\#define KERNEL_ORIGIN $SED_HEX_OR_NUMBER_REGEX/\#define KERNEL_ORIGIN $KERNEL_ORIGIN/" src/boot/stage2/loader32.cpp
sed -i "s/\#define KERNEL_ORIGIN $SED_HEX_OR_NUMBER_REGEX/\#define KERNEL_ORIGIN $KERNEL_ORIGIN/" src/include/kernel/kernel.h
# Configure scheduler event loop dispatch limit
SCHEDULER_EVENT_DISPATCH_LIMIT=100
sed -i "s/\#define SCHEDULER_EVENT_DISPATCH_LIMIT $SED_HEX_OR_NUMBER_REGEX/\#define SCHEDULER_EVENT_DISPATCH_LIMIT $SCHEDULER_EVENT_DISPATCH_LIMIT/" src/boot/scheduler.cpp
# Configure scheduler event loop frequency
SCHEDULER_FREQUENCY=100
sed -i "s/\#define SCHEDULER_FREQUENCY $SED_HEX_OR_NUMBER_REGEX/\#define SCHEDULER_FREQUENCY $SCHEDULER_FREQUENCY/" src/boot/scheduler.cpp
# Configure APU bootloader padding
APU_BOOTLOADER_PADDING=32
sed -i "s/APU_BOOTLOADER_PADDING equ $SED_HEX_OR_NUMBER_REGEX/APU_BOOTLOADER_PADDING equ $APU_BOOTLOADER_PADDING/" src/boot/stage1/apu.asm
sed -i "s/\#define APU_BOOTLOADER_PADDING $SED_HEX_OR_NUMBER_REGEX/\#define APU_BOOTLOADER_PADDING $APU_BOOTLOADER_PADDING/" src/include/kernel/kernel.h
# Configure APU bootloader origin
# Should always be >= 0x1000 (to avoid null page access)
# and <= 0xf000 (0x0:APU_BOOTLOADER_ORIGIN effective address should within be 16-bit real mode segment limits)
# and 4KiB (page size) aligned
APU_BOOTLOADER_ORIGIN=0x8000
sed -i "s/APU_BOOTLOADER_ORIGIN equ $SED_HEX_OR_NUMBER_REGEX/APU_BOOTLOADER_ORIGIN equ $APU_BOOTLOADER_ORIGIN/" src/boot/stage1/apu.asm
sed -i "s/\#define APU_BOOTLOADER_ORIGIN $SED_HEX_OR_NUMBER_REGEX/\#define APU_BOOTLOADER_ORIGIN $APU_BOOTLOADER_ORIGIN/" src/include/kernel/kernel.h