1/*
2 * Copyright (c) 2020-2021 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License")
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 *     http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16#ifndef KERNEL_CONSTANTS_H
17#define KERNEL_CONSTANTS_H
18
19#include <unistd.h>
20
21/**
22 * ================ DAC and Caps ================
23 */
24const uid_t SHELL_UID = 2;
25const uid_t SHELL_GID = 2;
26
27
28/**
29 * ================ Process Manager ================
30 */
31#define MAX_PROCESS_GROUPS  255  // max number of groups a process can have
32#define MAX_PROCESS_NUMBER  63   // max allowd process [0,63]
33#define MAX_TASK_NUMBER     128  // max allowd task(process+thread)
34
35#define INIT_PROCESS_ID     1    // pid of init
36#define KERNEL_PROCESS_ID   2    // pid of KProcess
37
38#define HIGHEST_USER_PROCESS_PRIORITY    10
39#define LOWEST_USER_PROCESS_PRIORITY     31
40#define HIGHEST_USER_THREAD_PRIORITY     0
41#define LOWEST_USER_THREAD_PRIORITY      31
42
43#define DEFAULT_SHELL_PROCESS_PRIORITY   15
44#define DEFAULT_INIT_PROCESS_PRIORITY    28
45#define DEFAULT_KERNEL_PROCESS_PRIORITY  0
46#define DEFAULT_THREAD_PRIORITY          25
47#define DEFAULT_RR_SCHED_INTERVAL        5000000    // defalult sched interval of RR, in ms
48
49/**
50 * ================ Memory Manager ================
51 */
52typedef unsigned long addr_t;
53
54#define USER_ASPACE_BASE            ((addr_t)0x01000000UL)
55#define USER_ASPACE_TOP_MAX         ((addr_t)0x3FFFFFFFUL)
56#define USER_ASPACE_SIZE            ((addr_t)(USER_ASPACE_TOP_MAX - USER_ASPACE_BASE))
57#define USER_HEAP_BASE              ((addr_t)(USER_ASPACE_TOP_MAX >> 2))
58#define USER_MAP_BASE               ((addr_t)(USER_ASPACE_TOP_MAX >> 1))
59#define USER_MAP_SIZE               ((addr_t)(USER_ASPACE_SIZE >> 3))
60
61#ifndef PAGE_SIZE
62#define PAGE_SIZE                   0x1000U
63#endif
64#define PAGE_MASK                   (~(PAGE_SIZE - 1))
65#define PAGE_SHIFT                  12
66
67#define MEM_PAGESTART(addr)         ((addr) & ~(PAGE_SIZE - 1))
68#define MEM_PAGEOFFSET(addr)        ((addr) & (PAGE_SIZE - 1))
69#define MEM_PAGEALIGN(addr)         (((addr) + PAGE_SIZE - 1) & ~(PAGE_SIZE - 1))
70
71
72/**
73 * ================ IPC ================
74 */
75const int MAX_SIGNAL_NUMBER = 64;   // max number of allowed signal, [1,64]
76const int MAX_PIPE_BUFFER = 1023;   // max size of a pipe buffer
77const int MAX_PIPE_NUMBER = 32;     // max pipe number
78
79const int MAX_MQ_NUMBER   = 256;   // max mqueue number
80const int MAX_MQ_NAME_LEN = 2560;    // max mqueue name length
81const int MAX_MQ_MSG_SIZE = 65530;  // max mqueue message size
82
83
84/**
85 * ================ FS ================
86 */
87const int MAX_PATH_SIZE = 256;      // max size of path string
88
89/**
90 * ================ SYSTEM ================
91 */
92#define SYSINFO_SYSNAME "Huawei LiteOS"   // sys name from 'uname'
93
94/**
95 * ================ XTS ================
96 */
97#define RES_DIR_KERNEL "/test_root/kernel/"   // top dir of test resource of kernel
98#define WRITABLE_TEST_DIR "/storage/"         // writable dir for test file
99
100#endif
101