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