Skip to content

Commit cbeb767

Browse files
committed
Added address space for additional kernel stacks
This will allow us to allocate extra kernel stacks for kernel threads. Signed-off-by: SlyMarbo <[email protected]>
1 parent 2aa297d commit cbeb767

File tree

2 files changed

+26
-23
lines changed

2 files changed

+26
-23
lines changed

kernel/src/memory/README.md

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,15 @@
22

33
Firefly uses the following layout of virtual memory:
44

5-
| Region | Start address | Last address | Pages | Size |
6-
| ------------------- | ----------------------: | ----------------------: | --------------------: | --------: |
7-
| NULL page | `0x0` | `0x1f_ffff` | not mapped | 2 MiB |
8-
| Userspace | `0x20_0000` | `0x7fff_ffff_ffff` | rest of memory | < 128 TiB |
9-
| Kernel binary | `0xffff_8000_0000_0000` | `0xffff_8000_3fff_ffff` | up to 512x 2 MiB page | 1 GiB |
10-
| Bootloader info | `0xffff_8000_4000_0000` | `0xffff_8000_4000_0fff` | 1x 4 KiB page | 4 KiB |
11-
| Kernel heap | `0xffff_8000_4444_0000` | `0xffff_8000_444b_ffff` | 128x 4 KiB page | 512 KiB |
12-
| Kernel stack guard | `0xffff_8000_5554_f000` | `0xffff_8000_5554_ffff` | not mapped | 4 KiB |
13-
| Kernel stack | `0xffff_8000_5555_0000` | `0xffff_8000_555c_ffff` | 128x 4 KiB page | 512 KiB |
14-
| MMIO address space | `0xffff_8000_6666_0000` | `0xffff_8000_6675_ffff` | 256x 4 KiB page | 1 MiB |
15-
| Physical memory map | `0xffff_8000_8000_0000` | `0xffff_ffff_ffff_ffff` | rest of memory | < 128 TiB |
5+
| Region | Start address | Last address | Pages | Size |
6+
| -------------------- | ----------------------: | ----------------------: | --------------------: | --------: |
7+
| NULL page | `0x0` | `0x1f_ffff` | not mapped | 2 MiB |
8+
| Userspace | `0x20_0000` | `0x7fff_ffff_ffff` | rest of memory | < 128 TiB |
9+
| Kernel binary | `0xffff_8000_0000_0000` | `0xffff_8000_3fff_ffff` | up to 512x 2 MiB page | 1 GiB |
10+
| Bootloader info | `0xffff_8000_4000_0000` | `0xffff_8000_4000_0fff` | 1x 4 KiB page | 4 KiB |
11+
| Kernel heap | `0xffff_8000_4444_0000` | `0xffff_8000_444b_ffff` | 128x 4 KiB page | 512 KiB |
12+
| Kernel stack 0 guard | `0xffff_8000_5554_f000` | `0xffff_8000_5554_ffff` | not mapped | 4 KiB |
13+
| Kernel stack 0 | `0xffff_8000_5555_0000` | `0xffff_8000_555c_ffff` | 128x 4 KiB page | 512 KiB |
14+
| Kernel stacks 1+ | `0xffff_8000_555d_0000` | `0xffff_8000_5d5c_ffff` | 32,768x 4 KiB page | 128 MiB |
15+
| MMIO address space | `0xffff_8000_6666_0000` | `0xffff_8000_6675_ffff` | 256x 4 KiB page | 1 MiB |
16+
| Physical memory map | `0xffff_8000_8000_0000` | `0xffff_ffff_ffff_ffff` | rest of memory | < 128 TiB |

kernel/src/memory/constants.rs

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,18 @@ use x86_64::{PhysAddr, VirtAddr};
1414
// Reminder of the memory layout (documented in more
1515
// detail in README.md):
1616
//
17-
// | Region | Start address | Last address |
18-
// | ------------------- | --------------------- | --------------------- |
19-
// | NULL page | 0x0 | 0x1f_ffff |
20-
// | Userspace | 0x20_0000 | 0x7fff_ffff_ffff |
21-
// | Kernel binary | 0xffff_8000_0000_0000 | 0xffff_8000_3fff_ffff |
22-
// | Bootloader info | 0xffff_8000_4000_0000 | 0xffff_8000_4000_0fff |
23-
// | Kernel heap | 0xffff_8000_4444_0000 | 0xffff_8000_444b_ffff |
24-
// | Kernel stack guard | 0xffff_8000_5554_f000 | 0xffff_8000_5554_ffff |
25-
// | Kernel stack | 0xffff_8000_5555_0000 | 0xffff_8000_555c_ffff |
26-
// | MMIO address space | 0xffff_8000_6666_0000 | 0xffff_8000_6675_ffff |
27-
// | Physical memory map | 0xffff_8000_8000_0000 | 0xffff_ffff_ffff_ffff |
17+
// | Region | Start address | Last address |
18+
// | -------------------- | --------------------- | --------------------- |
19+
// | NULL page | 0x0 | 0x1f_ffff |
20+
// | Userspace | 0x20_0000 | 0x7fff_ffff_ffff |
21+
// | Kernel binary | 0xffff_8000_0000_0000 | 0xffff_8000_3fff_ffff |
22+
// | Bootloader info | 0xffff_8000_4000_0000 | 0xffff_8000_4000_0fff |
23+
// | Kernel heap | 0xffff_8000_4444_0000 | 0xffff_8000_444b_ffff |
24+
// | Kernel stack 0 guard | 0xffff_8000_5554_f000 | 0xffff_8000_5554_ffff |
25+
// | Kernel stack 0 | 0xffff_8000_5555_0000 | 0xffff_8000_555c_ffff |
26+
// | Kernel stacks 1+ | 0xffff_8000_555d_0000 | 0xffff_8000_5d5c_ffff |
27+
// | MMIO address space | 0xffff_8000_6666_0000 | 0xffff_8000_6675_ffff |
28+
// | Physical memory map | 0xffff_8000_8000_0000 | 0xffff_ffff_ffff_ffff |
2829

2930
/// NULL_PAGE is reserved and always unmapped to ensure that null pointer
3031
/// dereferences always result in a page fault.
@@ -75,8 +76,9 @@ const KERNEL_STACK_GUARD_END: VirtAddr = const_virt_addr(0xffff_8000_5554_ffff a
7576
/// the end address.
7677
///
7778
pub const KERNEL_STACK: VirtAddrRange = VirtAddrRange::new(KERNEL_STACK_END, KERNEL_STACK_START);
78-
const KERNEL_STACK_START: VirtAddr = const_virt_addr(0xffff_8000_555c_ffff as u64);
79+
const KERNEL_STACK_START: VirtAddr = const_virt_addr(0xffff_8000_5d5c_ffff as u64);
7980
const KERNEL_STACK_END: VirtAddr = const_virt_addr(0xffff_8000_5555_0000 as u64);
81+
pub const KERNEL_STACK_1_START: VirtAddr = const_virt_addr(0xffff_8000_555d_0000 as u64);
8082

8183
/// MMIO_SPACE is the virtual address space used for accessing
8284
/// hardware devices via memory mapped I/O.

0 commit comments

Comments
 (0)