os/
config.rs

1//! 平台无关的常量
2#![allow(unused)]
3
4// about memory management
5pub const PAGE_SIZE: usize = 4096;
6pub const KERNEL_HEAP_SIZE: usize = 32 * 1024 * 1024; // 32MB(临时扩容, 原16MB)
7pub const USER_STACK_SIZE: usize = 4 * 1024 * 1024; // 4MB
8
9pub const MAX_ARGV: usize = 256;
10
11// User space memory layout constants
12// Memory layout (from high to low address):
13// [USER_STACK]          <--
14// ...
15// [USER_HEAP]
16// [USER_DATA]
17// [USER_TEXT]
18
19pub const USER_STACK_TOP: usize = SV39_BOT_HALF_TOP - PAGE_SIZE; // leave another guard page
20
21/// Maximum heap size (prevent OOM)
22pub const MAX_USER_HEAP_SIZE: usize = 64 * 1024 * 1024; // 64MB
23
24// memory layout constants
25// temporarily set for QEMU RISC-V virt machine
26// FIXME: refactor it to arch/riscv because it's platform-dependent
27// TODO: fetch it form device tree in the future(after/while implemented devices feature)
28pub const MEMORY_END: usize = 0x88000000; // 128MB for QEMU RISC-V virt
29
30pub const DEFAULT_MAX_FDS: usize = 256;
31
32// Ext4 filesystem constants
33/// Ext4 文件系统块大小 (必须与 mkfs.ext4 -b 参数一致)
34pub const EXT4_BLOCK_SIZE: usize = 4096;
35/// VirtIO 块设备扇区大小 (标准扇区大小)
36pub const VIRTIO_BLK_SECTOR_SIZE: usize = 512;
37/// 文件系统镜像大小 (与 qemu-run.sh 中的 fs.img 大小一致)
38pub const FS_IMAGE_SIZE: usize = 1024 * 1024 * 1024; // 1 GB
39
40use crate::arch::constant::SV39_BOT_HALF_TOP;
41pub use crate::arch::platform::virt::*;