Skip to content

Commit d134a23

Browse files
committed
Allocated space for CPU-local data
We don't yet have support for CPU-local data, but when we do, we will need space to store each CPU's copy of the data. Signed-off-by: SlyMarbo <[email protected]>
1 parent d44f3fa commit d134a23

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

kernel/src/memory/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ Firefly uses the following layout of virtual memory:
1313
| Kernel stack 0 | `0xffff_8000_5555_0000` | `0xffff_8000_555c_ffff` | 128x 4 KiB page | 512 KiB |
1414
| Kernel stacks 1+ | `0xffff_8000_555d_0000` | `0xffff_8000_5d5c_ffff` | 32,768x 4 KiB page | 128 MiB |
1515
| MMIO address space | `0xffff_8000_6666_0000` | `0xffff_8000_6675_ffff` | 256x 4 KiB page | 1 MiB |
16+
| CPU-local storage | `0xffff_8000_7777_0000` | `0xffff_8000_7f76_ffff` | 32,768x 4 KiB page | 128 MiB |
1617
| Physical memory map | `0xffff_8000_8000_0000` | `0xffff_ffff_ffff_ffff` | rest of memory | < 128 TiB |
1718

1819
## Paging

kernel/src/memory/constants.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ use x86_64::{PhysAddr, VirtAddr};
2525
// | Kernel stack 0 | 0xffff_8000_5555_0000 | 0xffff_8000_555c_ffff |
2626
// | Kernel stacks 1+ | 0xffff_8000_555d_0000 | 0xffff_8000_5d5c_ffff |
2727
// | MMIO address space | 0xffff_8000_6666_0000 | 0xffff_8000_6675_ffff |
28+
// | CPU-local storage | 0xffff_8000_7777_0000 | 0xffff_8000_7f76_ffff |
2829
// | Physical memory map | 0xffff_8000_8000_0000 | 0xffff_ffff_ffff_ffff |
2930

3031
/// NULL_PAGE is reserved and always unmapped to ensure that null pointer
@@ -91,6 +92,15 @@ pub const MMIO_SPACE: VirtAddrRange = VirtAddrRange::new(MMIO_SPACE_START, MMIO_
9192
const MMIO_SPACE_START: VirtAddr = const_virt_addr(0xffff_8000_6666_0000 as u64);
9293
const MMIO_SPACE_END: VirtAddr = const_virt_addr(0xffff_8000_6675_ffff as u64);
9394

95+
/// CPU_LOCAL is the virtual address space used for storing
96+
/// CPU-local data. Successive CPU cores use successive chunks of
97+
/// the address space, with each chunk containing a copy of the
98+
/// .tdata and .tbss segments from the TLS template.
99+
///
100+
pub const CPU_LOCAL: VirtAddrRange = VirtAddrRange::new(CPU_LOCAL_START, CPU_LOCAL_END);
101+
const CPU_LOCAL_START: VirtAddr = const_virt_addr(0xffff_8000_7777_0000 as u64);
102+
const CPU_LOCAL_END: VirtAddr = const_virt_addr(0xffff_8000_7f76_ffff as u64);
103+
94104
/// PHYSICAL_MEMORY_OFFSET is the virtual address at which the mapping of
95105
/// all physical memory begins. That is, for any valid physical address,
96106
/// that address can be reached at the same virtual address, plus

kernel/src/memory/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ pub mod pmm;
3131
pub mod vmm;
3232

3333
pub use crate::memory::constants::{
34-
phys_to_virt_addr, VirtAddrRange, BOOT_INFO, KERNEL_BINARY, KERNEL_HEAP, KERNEL_STACK,
35-
KERNEL_STACK_0, KERNEL_STACK_GUARD, MMIO_SPACE, NULL_PAGE, PHYSICAL_MEMORY,
34+
phys_to_virt_addr, VirtAddrRange, BOOT_INFO, CPU_LOCAL, KERNEL_BINARY, KERNEL_HEAP,
35+
KERNEL_STACK, KERNEL_STACK_0, KERNEL_STACK_GUARD, MMIO_SPACE, NULL_PAGE, PHYSICAL_MEMORY,
3636
PHYSICAL_MEMORY_OFFSET, USERSPACE,
3737
};
3838

0 commit comments

Comments
 (0)