提交 4b2d532e 编写于 作者: 鸿蒙内核源码分析's avatar 鸿蒙内核源码分析

python build.py ipcamera_hi3516dv300 编译kernel_liteos_a_note通过

搜索 @note_pic 可以查看全部字符图
搜索 @note_why 是注者尚未看明白的地方,如果您看明白了,请告诉注者完善
搜索 @note_thinking 是注者的思考和吐槽的地方
上级 e2dcea4f
...@@ -40,7 +40,7 @@ ...@@ -40,7 +40,7 @@
extern "C" { extern "C" {
#endif /* __cplusplus */ #endif /* __cplusplus */
#endif /* __cplusplus */ #endif /* __cplusplus */
//获取抢占式调度任务的最高优先级
int sched_get_priority_min(int policy) int sched_get_priority_min(int policy)
{ {
if (policy != SCHED_RR) { if (policy != SCHED_RR) {
...@@ -50,7 +50,7 @@ int sched_get_priority_min(int policy) ...@@ -50,7 +50,7 @@ int sched_get_priority_min(int policy)
return OS_TASK_PRIORITY_HIGHEST; return OS_TASK_PRIORITY_HIGHEST;
} }
//获取抢占式调度任务的最低优先级
int sched_get_priority_max(int policy) int sched_get_priority_max(int policy)
{ {
if (policy != SCHED_RR) { if (policy != SCHED_RR) {
...@@ -63,7 +63,7 @@ int sched_get_priority_max(int policy) ...@@ -63,7 +63,7 @@ int sched_get_priority_max(int policy)
/* /*
* This API is Linux-specific, not conforming to POSIX. * This API is Linux-specific, not conforming to POSIX.
*/ */ //这个API是Linux特有的,不适用于POSIX
int sched_setaffinity(pid_t pid, size_t set_size, const cpu_set_t* set) int sched_setaffinity(pid_t pid, size_t set_size, const cpu_set_t* set)
{ {
#if (LOSCFG_KERNEL_SMP == YES) #if (LOSCFG_KERNEL_SMP == YES)
...@@ -95,7 +95,7 @@ int sched_setaffinity(pid_t pid, size_t set_size, const cpu_set_t* set) ...@@ -95,7 +95,7 @@ int sched_setaffinity(pid_t pid, size_t set_size, const cpu_set_t* set)
/* /*
* This API is Linux-specific, not conforming to POSIX. * This API is Linux-specific, not conforming to POSIX.
*/ */ //这个API是Linux特有的,不适用于POSIX
int sched_getaffinity(pid_t pid, size_t set_size, cpu_set_t* set) int sched_getaffinity(pid_t pid, size_t set_size, cpu_set_t* set)
{ {
#if (LOSCFG_KERNEL_SMP == YES) #if (LOSCFG_KERNEL_SMP == YES)
......
...@@ -250,13 +250,13 @@ static VOID DiskPartAddToDisk(los_disk *disk, los_part *part) ...@@ -250,13 +250,13 @@ static VOID DiskPartAddToDisk(los_disk *disk, los_part *part)
LOS_ListTailInsert(&disk->head, &part->list); LOS_ListTailInsert(&disk->head, &part->list);
disk->part_count++; disk->part_count++;
} }
//从磁盘上删除分区
static VOID DiskPartDelFromDisk(los_disk *disk, los_part *part) static VOID DiskPartDelFromDisk(los_disk *disk, los_part *part)
{ {
LOS_ListDelete(&part->list); LOS_ListDelete(&part->list);//摘掉分区节点
disk->part_count--; disk->part_count--;//分区数减少
} }
//分配一个磁盘分区
static los_part *DiskPartAllocate(struct inode *dev, UINT64 start, UINT64 count) static los_part *DiskPartAllocate(struct inode *dev, UINT64 start, UINT64 count)
{ {
UINT32 i; UINT32 i;
......
...@@ -47,13 +47,32 @@ extern "C" { ...@@ -47,13 +47,32 @@ extern "C" {
#endif /* __cplusplus */ #endif /* __cplusplus */
#endif /* __cplusplus */ #endif /* __cplusplus */
#define SPIBLK_NAME "/dev/spinorblk" #define SPIBLK_NAME "/dev/spinorblk" //nor flash block 名称
#define SPICHR_NAME "/dev/spinorchr" #define SPICHR_NAME "/dev/spinorchr" //nor flash char 名称
#define NANDBLK_NAME "/dev/nandblk" #define NANDBLK_NAME "/dev/nandblk" //nand flash block 名称
#define NANDCHR_NAME "/dev/nandchr" #define NANDCHR_NAME "/dev/nandchr" //nand flash char 名称
/***************************************************************
https://blog.csdn.net/lwj103862095/article/details/21545791
typedef struct mtd_node { MTD,Memory Technology Device即内存技术设备,在Linux内核中,引入MTD层为
NOR FLASH和NAND FLASH设备提供统一接口。MTD将文件系统与底层FLASH存储器进行了隔离。
字符设备和块设备的区别在于前者只能被顺序读写,后者可以随机访问;同时,两者读写数据的基本单元不同。
字符设备,以字节为基本单位,在Linux中,字符设备实现的比较简单,不需要缓冲区即可直接读写,
内核例程和用户态API一一对应,用户层的Read函数直接对应了内核中的Read例程,这种映射关系由字符设备的
file_operations维护。
块设备,则以块为单位接受输入和返回输出。对这种设备的读写是按块进行的,其接口相对于字符设备复杂,
read、write API没有直接到块设备层,而是直接到文件系统层,然后再由文件系统层发起读写请求。
同时,由于块设备的IO性能与CPU相比很差,因此,块设备的数据流往往会引入文件系统的Cache机制。
MTD设备既非块设备也不是字符设备,但可以同时提供字符设备和块设备接口来操作它。
MTD设备通常可分为四层
这四层从上到下依次是:设备节点、MTD设备层、MTD原始设备层和硬件驱动层。
***************************************************************/
typedef struct mtd_node {//通过mknod在/dev子目录下建立MTD块设备节点(主设备号为31)和MTD字符设备节点(主设备号为90)
UINT32 start_block; UINT32 start_block;
UINT32 end_block; UINT32 end_block;
UINT32 patitionnum; UINT32 patitionnum;
...@@ -68,11 +87,11 @@ typedef struct mtd_node { ...@@ -68,11 +87,11 @@ typedef struct mtd_node {
typedef struct par_param { typedef struct par_param {
mtd_partition *partition_head; mtd_partition *partition_head;
struct MtdDev *flash_mtd; struct MtdDev *flash_mtd;
const struct block_operations *flash_ops; const struct block_operations *flash_ops;//块设备的操作方法
const struct file_operations_vfs *char_ops; const struct file_operations_vfs *char_ops;//字符设备的操作方法
CHAR *blockname; CHAR *blockname; //块设备名称
CHAR *charname; CHAR *charname; //字符设备名称
UINT32 block_size; UINT32 block_size;
} partition_param; } partition_param;
......
...@@ -181,7 +181,7 @@ static INT32 AddParamCheck(UINT32 startAddr, ...@@ -181,7 +181,7 @@ static INT32 AddParamCheck(UINT32 startAddr,
return ENOERR; return ENOERR;
} }
//注册块设备
static INT32 BlockDriverRegisterOperate(mtd_partition *newNode, static INT32 BlockDriverRegisterOperate(mtd_partition *newNode,
const partition_param *param, const partition_param *param,
UINT32 partitionNum) UINT32 partitionNum)
...@@ -203,7 +203,7 @@ static INT32 BlockDriverRegisterOperate(mtd_partition *newNode, ...@@ -203,7 +203,7 @@ static INT32 BlockDriverRegisterOperate(mtd_partition *newNode,
newNode->blockdriver_name = NULL; newNode->blockdriver_name = NULL;
return -ENAMETOOLONG; return -ENAMETOOLONG;
} }
//在伪文件系统中注册块驱动程序,生成设备结点 inode
ret = register_blockdriver(newNode->blockdriver_name, param->flash_ops, ret = register_blockdriver(newNode->blockdriver_name, param->flash_ops,
RWE_RW_RW, newNode); RWE_RW_RW, newNode);
if (ret) { if (ret) {
...@@ -217,7 +217,7 @@ static INT32 BlockDriverRegisterOperate(mtd_partition *newNode, ...@@ -217,7 +217,7 @@ static INT32 BlockDriverRegisterOperate(mtd_partition *newNode,
} }
return ENOERR; return ENOERR;
} }
//注册字符设备
static INT32 CharDriverRegisterOperate(mtd_partition *newNode, static INT32 CharDriverRegisterOperate(mtd_partition *newNode,
const partition_param *param, const partition_param *param,
UINT32 partitionNum) UINT32 partitionNum)
...@@ -239,7 +239,7 @@ static INT32 CharDriverRegisterOperate(mtd_partition *newNode, ...@@ -239,7 +239,7 @@ static INT32 CharDriverRegisterOperate(mtd_partition *newNode,
newNode->chardriver_name = NULL; newNode->chardriver_name = NULL;
return -ENAMETOOLONG; return -ENAMETOOLONG;
} }
//在伪文件系统中注册字符设备驱动程序,生成设备结点 inode
ret = register_driver(newNode->chardriver_name, param->char_ops, RWE_RW_RW, newNode); ret = register_driver(newNode->chardriver_name, param->char_ops, RWE_RW_RW, newNode);
if (ret) { if (ret) {
PRINT_ERR("register chardev partion error\n"); PRINT_ERR("register chardev partion error\n");
...@@ -252,7 +252,7 @@ static INT32 CharDriverRegisterOperate(mtd_partition *newNode, ...@@ -252,7 +252,7 @@ static INT32 CharDriverRegisterOperate(mtd_partition *newNode,
} }
return ENOERR; return ENOERR;
} }
//注销块设备驱动程序,从伪文件系统中删除“path”处的块驱动程序inode
static INT32 BlockDriverUnregister(mtd_partition *node) static INT32 BlockDriverUnregister(mtd_partition *node)
{ {
INT32 ret; INT32 ret;
...@@ -268,7 +268,7 @@ static INT32 BlockDriverUnregister(mtd_partition *node) ...@@ -268,7 +268,7 @@ static INT32 BlockDriverUnregister(mtd_partition *node)
} }
return ENOERR; return ENOERR;
} }
//注销字符设备驱动程序,从伪文件系统中删除“path”处的字符驱动程序inode
static INT32 CharDriverUnregister(mtd_partition *node) static INT32 CharDriverUnregister(mtd_partition *node)
{ {
INT32 ret; INT32 ret;
......
...@@ -70,7 +70,7 @@ inode->i_mode 的标签如下: ...@@ -70,7 +70,7 @@ inode->i_mode 的标签如下:
例如:chmod 777 (S_IRWXU S_IRWXG S_IRWXO) 例如:chmod 777 (S_IRWXU S_IRWXG S_IRWXO)
************************************************************************/ ************************************************************************/
void los_vfs_init(void) void los_vfs_init(void)//系统调用了los_vfs_init()后,会将"/"作为root_inode
{ {
int err; int err;
uint retval; uint retval;
......
...@@ -83,7 +83,7 @@ LITE_OS_SEC_BSS LOS_DL_LIST g_losFreeTask;//空闲任务链表 ...@@ -83,7 +83,7 @@ LITE_OS_SEC_BSS LOS_DL_LIST g_losFreeTask;//空闲任务链表
LITE_OS_SEC_BSS LOS_DL_LIST g_taskRecyleList;//回收任务链表 LITE_OS_SEC_BSS LOS_DL_LIST g_taskRecyleList;//回收任务链表
LITE_OS_SEC_BSS UINT32 g_taskMaxNum;//任务最大个数 LITE_OS_SEC_BSS UINT32 g_taskMaxNum;//任务最大个数
LITE_OS_SEC_BSS UINT32 g_taskScheduled; /* one bit for each cores *///一位代表一个CPU core 的调度 LITE_OS_SEC_BSS UINT32 g_taskScheduled; /* one bit for each cores *///一位代表一个CPU core 的调度
LITE_OS_SEC_BSS EVENT_CB_S g_resourceEvent;//资源事件 LITE_OS_SEC_BSS EVENT_CB_S g_resourceEvent;//关于资源的事件
/* spinlock for task module, only available on SMP mode */ /* spinlock for task module, only available on SMP mode */
LITE_OS_SEC_BSS SPIN_LOCK_INIT(g_taskSpin); LITE_OS_SEC_BSS SPIN_LOCK_INIT(g_taskSpin);
...@@ -234,7 +234,7 @@ LITE_OS_SEC_TEXT UINT32 OsTaskSetDeatchUnsafe(LosTaskCB *taskCB) ...@@ -234,7 +234,7 @@ LITE_OS_SEC_TEXT UINT32 OsTaskSetDeatchUnsafe(LosTaskCB *taskCB)
if (LOS_ListEmpty(&(taskCB->joinList))) {//joinlist中没有数据了 if (LOS_ListEmpty(&(taskCB->joinList))) {//joinlist中没有数据了
LOS_ListDelete(&(taskCB->joinList));//所谓删除就是自己指向自己 LOS_ListDelete(&(taskCB->joinList));//所谓删除就是自己指向自己
taskCB->taskStatus &= ~OS_TASK_FLAG_PTHREAD_JOIN;//去掉JOIN标签 taskCB->taskStatus &= ~OS_TASK_FLAG_PTHREAD_JOIN;//去掉JOIN标签
taskCB->taskStatus |= OS_TASK_FLAG_DETACHED;//贴上分离标签,自己独立存在,不和其他任务媾和,别的线程不能回收和干掉我,只能由系统来收我 taskCB->taskStatus |= OS_TASK_FLAG_DETACHED;//贴上分离标签,自己独立存在,不和其他任务媾和,不能被别的任务回收和干掉,只能由系统回收
return LOS_OK; return LOS_OK;
} }
/* This error code has a special purpose and is not allowed to appear again on the interface */ /* This error code has a special purpose and is not allowed to appear again on the interface */
...@@ -821,8 +821,8 @@ LITE_OS_SEC_TEXT_INIT UINT32 LOS_TaskCreateOnly(UINT32 *taskID, TSK_INIT_PARAM_S ...@@ -821,8 +821,8 @@ LITE_OS_SEC_TEXT_INIT UINT32 LOS_TaskCreateOnly(UINT32 *taskID, TSK_INIT_PARAM_S
if (errRet != LOS_OK) { if (errRet != LOS_OK) {
goto LOS_ERREND_TCB_INIT; goto LOS_ERREND_TCB_INIT;
} }
if (OsConsoleIDSetHook != NULL) { if (OsConsoleIDSetHook != NULL) {//每个人任务都可以有属于自己的控制台
OsConsoleIDSetHook(taskCB->taskID, OsCurrTaskGet()->taskID); OsConsoleIDSetHook(taskCB->taskID, OsCurrTaskGet()->taskID);//设置控制台ID
} }
*taskID = taskCB->taskID; *taskID = taskCB->taskID;
...@@ -1810,7 +1810,7 @@ UINT32 OsUserTaskOperatePermissionsCheck(LosTaskCB *taskCB) ...@@ -1810,7 +1810,7 @@ UINT32 OsUserTaskOperatePermissionsCheck(LosTaskCB *taskCB)
return LOS_OK; return LOS_OK;
} }
//创建任务之前,检查用户态任务栈的参数,是否地址在用户空间
LITE_OS_SEC_TEXT_INIT STATIC UINT32 OsCreateUserTaskParamCheck(UINT32 processID, TSK_INIT_PARAM_S *param) LITE_OS_SEC_TEXT_INIT STATIC UINT32 OsCreateUserTaskParamCheck(UINT32 processID, TSK_INIT_PARAM_S *param)
{ {
UserTaskParam *userParam = NULL; UserTaskParam *userParam = NULL;
...@@ -1975,30 +1975,29 @@ STATIC VOID OsResourceRecoveryTask(VOID) ...@@ -1975,30 +1975,29 @@ STATIC VOID OsResourceRecoveryTask(VOID)
{ {
UINT32 ret; UINT32 ret;
while (1) { while (1) {//死循环,回收资源不存在退出情况,只要系统在运行资源就需要回收
ret = LOS_EventRead(&g_resourceEvent, OS_RESOURCE_EVENT_MASK, ret = LOS_EventRead(&g_resourceEvent, OS_RESOURCE_EVENT_MASK,
LOS_WAITMODE_OR | LOS_WAITMODE_CLR, LOS_WAIT_FOREVER); LOS_WAITMODE_OR | LOS_WAITMODE_CLR, LOS_WAIT_FOREVER);//读取资源事件
if (ret & (OS_RESOURCE_EVENT_FREE | OS_RESOURCE_EVENT_OOM)) {//资源释放或异常情况 if (ret & (OS_RESOURCE_EVENT_FREE | OS_RESOURCE_EVENT_OOM)) {//资源释放或异常情况
OsTaskCBRecyleToFree();//回收任务到空闲任务池 OsTaskCBRecyleToFree();//回收任务到空闲任务池
OsProcessCBRecyleToFree();//回收进程到空闲进程池 OsProcessCBRecyleToFree();//回收进程到空闲进程池
} }
#ifdef LOSCFG_ENABLE_OOM_LOOP_TASK //内存溢出监测任务开关 #ifdef LOSCFG_ENABLE_OOM_LOOP_TASK //内存溢出监测任务开关
if (ret & OS_RESOURCE_EVENT_OOM) {//触发了这个事件 if (ret & OS_RESOURCE_EVENT_OOM) {//触发了这个事件
(VOID)OomCheckProcess();//检查进程 (VOID)OomCheckProcess();//检查进程的内存溢出情况
} }
#endif #endif
} }
} }
//创建一个回收资源的任务
LITE_OS_SEC_TEXT UINT32 OsCreateResourceFreeTask(VOID) LITE_OS_SEC_TEXT UINT32 OsCreateResourceFreeTask(VOID)
{ {
UINT32 ret; UINT32 ret;
UINT32 taskID; UINT32 taskID;
TSK_INIT_PARAM_S taskInitParam; TSK_INIT_PARAM_S taskInitParam;
ret = LOS_EventInit((PEVENT_CB_S)&g_resourceEvent); ret = LOS_EventInit((PEVENT_CB_S)&g_resourceEvent);//初始化资源事件
if (ret != LOS_OK) { if (ret != LOS_OK) {
return LOS_NOK; return LOS_NOK;
} }
...@@ -2007,7 +2006,7 @@ LITE_OS_SEC_TEXT UINT32 OsCreateResourceFreeTask(VOID) ...@@ -2007,7 +2006,7 @@ LITE_OS_SEC_TEXT UINT32 OsCreateResourceFreeTask(VOID)
taskInitParam.pfnTaskEntry = (TSK_ENTRY_FUNC)OsResourceRecoveryTask;//入口函数 taskInitParam.pfnTaskEntry = (TSK_ENTRY_FUNC)OsResourceRecoveryTask;//入口函数
taskInitParam.uwStackSize = OS_TASK_RESOURCE_STATCI_SIZE;// 4K taskInitParam.uwStackSize = OS_TASK_RESOURCE_STATCI_SIZE;// 4K
taskInitParam.pcName = "ResourcesTask"; taskInitParam.pcName = "ResourcesTask";
taskInitParam.usTaskPrio = OS_TASK_RESOURCE_FREE_PRIORITY;// 5 taskInitParam.usTaskPrio = OS_TASK_RESOURCE_FREE_PRIORITY;// 5 ,优先级很高
return LOS_TaskCreate(&taskID, &taskInitParam);//创建任务,并加入就绪队列,立即调度 return LOS_TaskCreate(&taskID, &taskInitParam);//创建任务,并加入就绪队列,立即调度
} }
......
...@@ -48,11 +48,11 @@ ...@@ -48,11 +48,11 @@
typedef UINT32 (*OomFn)(UINTPTR param); typedef UINT32 (*OomFn)(UINTPTR param);
typedef struct { typedef struct { //内存溢出控制块(描述符)
UINT32 lowMemThreshold; /* byte */ UINT32 lowMemThreshold; /* byte */ //最低运行内存
UINT32 reclaimMemThreshold; /* byte */ UINT32 reclaimMemThreshold; /* byte */ //回收内存起点
UINT32 checkInterval; /* microsecond */ UINT32 checkInterval; /* microsecond */
OomFn processVictimCB; /* process victim process cb function */ OomFn processVictimCB; /* process victim process cb function */
OomFn scoreCB; /* out of memory, the process score function */ OomFn scoreCB; /* out of memory, the process score function */
UINT16 swtmrID; UINT16 swtmrID;
BOOL enabled; /* oom is enabled or not */ BOOL enabled; /* oom is enabled or not */
......
...@@ -51,7 +51,7 @@ extern "C" { ...@@ -51,7 +51,7 @@ extern "C" {
#endif /* __cplusplus */ #endif /* __cplusplus */
LITE_OS_SEC_BSS OomCB *g_oomCB = NULL; LITE_OS_SEC_BSS OomCB *g_oomCB = NULL;
static SPIN_LOCK_INIT(g_oomSpinLock); static SPIN_LOCK_INIT(g_oomSpinLock);//内存溢出自旋锁
LITE_OS_SEC_TEXT_MINOR STATIC UINT32 OomScoreProcess(LosProcessCB *candidateProcess) LITE_OS_SEC_TEXT_MINOR STATIC UINT32 OomScoreProcess(LosProcessCB *candidateProcess)
{ {
...@@ -60,7 +60,7 @@ LITE_OS_SEC_TEXT_MINOR STATIC UINT32 OomScoreProcess(LosProcessCB *candidateProc ...@@ -60,7 +60,7 @@ LITE_OS_SEC_TEXT_MINOR STATIC UINT32 OomScoreProcess(LosProcessCB *candidateProc
#if (LOSCFG_KERNEL_SMP != YES) #if (LOSCFG_KERNEL_SMP != YES)
(VOID)LOS_MuxAcquire(&candidateProcess->vmSpace->regionMux); (VOID)LOS_MuxAcquire(&candidateProcess->vmSpace->regionMux);
#endif #endif
/* we only consider actual physical memory here. */ /* we only consider actual physical memory here. */ //只考虑实际的物理内存
OsUProcessPmUsage(candidateProcess->vmSpace, NULL, &actualPm); OsUProcessPmUsage(candidateProcess->vmSpace, NULL, &actualPm);
#if (LOSCFG_KERNEL_SMP != YES) #if (LOSCFG_KERNEL_SMP != YES)
(VOID)LOS_MuxRelease(&candidateProcess->vmSpace->regionMux); (VOID)LOS_MuxRelease(&candidateProcess->vmSpace->regionMux);
...@@ -129,8 +129,8 @@ LITE_OS_SEC_TEXT_MINOR BOOL OomCheckProcess(VOID) ...@@ -129,8 +129,8 @@ LITE_OS_SEC_TEXT_MINOR BOOL OomCheckProcess(VOID)
BOOL isLowMemory = FALSE; BOOL isLowMemory = FALSE;
/* /*
* spinlock the current core schedule, make sure oom process atomic * spinlock the current core schedule, make sure oom process atomic //旋转锁定当前核心计划,确保oom进程原子化
* spinlock other place entering OomCheckProcess, make sure oom process mutex * spinlock other place entering OomCheckProcess, make sure oom process mutex //旋转锁定其他进入OomCheckProcess的地方,确保oom进程互斥
*/ */
LOS_SpinLock(&g_oomSpinLock); LOS_SpinLock(&g_oomSpinLock);
...@@ -155,14 +155,14 @@ NO_VICTIM_PROCESS: ...@@ -155,14 +155,14 @@ NO_VICTIM_PROCESS:
return isLowMemory; return isLowMemory;
} }
#ifdef LOSCFG_ENABLE_OOM_LOOP_TASK #ifdef LOSCFG_ENABLE_OOM_LOOP_TASK //内存溢出监测任务开关
STATIC VOID OomWriteEvent(VOID) STATIC VOID OomWriteEvent(VOID) // OomTaskInit中创建的定时器回调
{ {
OsWriteResourceEvent(OS_RESOURCE_EVENT_OOM); OsWriteResourceEvent(OS_RESOURCE_EVENT_OOM);//写内存溢出事件
} }
#endif #endif
LITE_OS_SEC_TEXT_MINOR VOID OomInfodump(VOID) LITE_OS_SEC_TEXT_MINOR VOID OomInfodump(VOID) //打印内存溢出信息
{ {
PRINTK("[oom] oom loop task status: %s\n" PRINTK("[oom] oom loop task status: %s\n"
" oom low memory threshold: %#x(byte)\n" " oom low memory threshold: %#x(byte)\n"
...@@ -216,7 +216,7 @@ LITE_OS_SEC_TEXT_MINOR VOID OomSetCheckInterval(UINT32 checkInterval) ...@@ -216,7 +216,7 @@ LITE_OS_SEC_TEXT_MINOR VOID OomSetCheckInterval(UINT32 checkInterval)
g_oomCB->checkInterval, OOM_CHECK_MIN, OOM_CHECK_MAX); g_oomCB->checkInterval, OOM_CHECK_MIN, OOM_CHECK_MAX);
} }
} }
//内存溢出任务初始化
LITE_OS_SEC_TEXT_MINOR UINT32 OomTaskInit(VOID) LITE_OS_SEC_TEXT_MINOR UINT32 OomTaskInit(VOID)
{ {
g_oomCB = (OomCB *)LOS_MemAlloc(m_aucSysMem0, sizeof(OomCB)); g_oomCB = (OomCB *)LOS_MemAlloc(m_aucSysMem0, sizeof(OomCB));
...@@ -232,10 +232,10 @@ LITE_OS_SEC_TEXT_MINOR UINT32 OomTaskInit(VOID) ...@@ -232,10 +232,10 @@ LITE_OS_SEC_TEXT_MINOR UINT32 OomTaskInit(VOID)
g_oomCB->scoreCB = (OomFn)OomScoreProcess; g_oomCB->scoreCB = (OomFn)OomScoreProcess;
g_oomCB->enabled = FALSE; g_oomCB->enabled = FALSE;
#ifdef LOSCFG_ENABLE_OOM_LOOP_TASK #ifdef LOSCFG_ENABLE_OOM_LOOP_TASK //内存溢出检测开关
g_oomCB->enabled = TRUE; g_oomCB->enabled = TRUE;
UINT32 ret = LOS_SwtmrCreate(g_oomCB->checkInterval, LOS_SWTMR_MODE_PERIOD, (SWTMR_PROC_FUNC)OomWriteEvent, UINT32 ret = LOS_SwtmrCreate(g_oomCB->checkInterval, LOS_SWTMR_MODE_PERIOD, (SWTMR_PROC_FUNC)OomWriteEvent,
&g_oomCB->swtmrID, (UINTPTR)g_oomCB); &g_oomCB->swtmrID, (UINTPTR)g_oomCB);//创建检测定时器
if (ret != LOS_OK) { if (ret != LOS_OK) {
return ret; return ret;
} }
......
...@@ -30,8 +30,34 @@ ...@@ -30,8 +30,34 @@
*/ */
#include "include/board.h" #include "include/board.h"
/***********************************************
本文件经过
python build.py ipcamera_hi3516dv300
编译后生成 board.ld,内容如下:
#define TEXT_BASE KERNEL_VADDR_BASE OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm")
OUTPUT_ARCH(arm)
MEMORY
{
ram : ORIGIN = 0x40000000, LENGTH = 0x20000000
sram : ORIGIN = 0x40000000, LENGTH = 0x1000
user_ram : ORIGIN = 0x1000000, LENGTH = 0x100000
}
SECTIONS
{
/DISCARD/ : { *(.comment .note) }
.ram_vectors 0x40000000 : {
__ram_vectors_vma = .;
KEEP (*(.vectors))
} > ram
__ram_vectors_lma = LOADADDR(.ram_vectors);
}
USER_INIT_VM_START = 0x1000000;
***********************************************/
#define TEXT_BASE KERNEL_VADDR_BASE
OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm") OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm")
OUTPUT_ARCH(arm) OUTPUT_ARCH(arm)
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
# Automatically generated file; DO NOT EDIT. # Automatically generated file; DO NOT EDIT.
# Huawei LiteOS Configuration # Huawei LiteOS Configuration
# #
# #
# Compiler # Compiler
# #
...@@ -38,53 +38,53 @@ LOSCFG_PLATFORM_ROOTFS=y ...@@ -38,53 +38,53 @@ LOSCFG_PLATFORM_ROOTFS=y
# #
# Kernel # Kernel
# #
LOSCFG_KERNEL_SMP=y LOSCFG_KERNEL_SMP=y #打开多CPU核开关
LOSCFG_KERNEL_SMP_CORE_NUM=2 LOSCFG_KERNEL_SMP_CORE_NUM=2 #2个CPUcore
LOSCFG_KERNEL_SMP_LOCKDEP=y LOSCFG_KERNEL_SMP_LOCKDEP=y #打开多CPU的死锁检测
LOSCFG_KERNEL_SMP_TASK_SYNC=y LOSCFG_KERNEL_SMP_TASK_SYNC=y #打开多CPU下的任务同步
# LOSCFG_KERNEL_SCHED_STATISTICS is not set # LOSCFG_KERNEL_SCHED_STATISTICS is not set
LOSCFG_KERNEL_EXTKERNEL=y LOSCFG_KERNEL_EXTKERNEL=y #
LOSCFG_KERNEL_CPPSUPPORT=y LOSCFG_KERNEL_CPPSUPPORT=y #支持C++编译
LOSCFG_KERNEL_CPUP=y LOSCFG_KERNEL_CPUP=y #打开CPU检测 ,用于查询系统CPU的占用率。
LOSCFG_CPUP_INCLUDE_IRQ=y LOSCFG_CPUP_INCLUDE_IRQ=y #打开CPU检测(包含中断)
LOSCFG_KERNEL_DYNLOAD=y LOSCFG_KERNEL_DYNLOAD=y #打开内核动态加载ELF功能
LOSCFG_ASLR=y LOSCFG_ASLR=y #ASLR(Address space layout randomization)是一种针对缓冲区溢出的安全保护技术,通过对堆、栈、共享库映射等线性区布局的随机化,通过增加攻击者预测目的地址的难度,防止攻击者直接定位攻击代码位置,达到阻止溢出攻击的目的。
LOSCFG_KERNEL_VDSO=y LOSCFG_KERNEL_VDSO=y #VDSO就是Virtual Dynamic Shared Object,就是内核提供的虚拟的.so,这个.so文件不在磁盘上,而是在内核里头
# LOSCFG_KERNEL_TICKLESS is not set # LOSCFG_KERNEL_TICKLESS is not set
# LOSCFG_KERNEL_TRACE is not set # LOSCFG_KERNEL_TRACE is not set
LOSCFG_KERNEL_LITEIPC=y LOSCFG_KERNEL_LITEIPC=y #用于轻量级进程间通讯
LOSCFG_KERNEL_PIPE=y LOSCFG_KERNEL_PIPE=y #管道支持
LOSCFG_BASE_CORE_HILOG=y LOSCFG_BASE_CORE_HILOG=y #hilog 日志支持
# #
# Lib # Lib
# #
LOSCFG_LIB_LIBC=y LOSCFG_LIB_LIBC=y
LOSCFG_LIB_ZLIB=y LOSCFG_LIB_ZLIB=y
# #
# Compat # Compat
# #
LOSCFG_COMPAT_POSIX=y LOSCFG_COMPAT_POSIX=y #兼容posix
LOSCFG_COMPAT_BSD=y LOSCFG_COMPAT_BSD=y #兼容bsd
# #
# FileSystem # FileSystem
# #
LOSCFG_FS_VFS=y LOSCFG_FS_VFS=y #虚拟文件系统
LOSCFG_FS_VFS_BLOCK_DEVICE=y LOSCFG_FS_VFS_BLOCK_DEVICE=y #块设备支持
LOSCFG_FILE_MODE=y LOSCFG_FILE_MODE=y #文件权限支持 例如:chmod 777
LOSCFG_FS_FAT=y LOSCFG_FS_FAT=y #文件配置表(英语:File Allocation Table,首字母缩略字:FAT),是一种由微软发明并拥有部分专利的文件系统
LOSCFG_FS_FAT_CACHE=y LOSCFG_FS_FAT_CACHE=y #FAT缓存支持
# LOSCFG_FS_FAT_CACHE_SYNC_THREAD is not set # LOSCFG_FS_FAT_CACHE_SYNC_THREAD is not set
LOSCFG_FS_FAT_CHINESE=y LOSCFG_FS_FAT_CHINESE=y
LOSCFG_FS_FAT_VIRTUAL_PARTITION=y LOSCFG_FS_FAT_VIRTUAL_PARTITION=y
LOSCFG_FS_FAT_VOLUMES=16 LOSCFG_FS_FAT_VOLUMES=16
LOSCFG_FS_FAT_DISK=y LOSCFG_FS_FAT_DISK=y
LOSCFG_FS_RAMFS=y LOSCFG_FS_RAMFS=y
LOSCFG_FS_NFS=y LOSCFG_FS_NFS=y #网络文件系统,英文Network File System(NFS)
LOSCFG_FS_PROC=y LOSCFG_FS_PROC=y
LOSCFG_FS_JFFS=y LOSCFG_FS_JFFS=y #Journalling Flash File System(闪存设备日志型文件系统,JFFS)最初是由瑞典的 Axis Communication AB 开发
# #
# Net # Net
......
git add -A git add -A
git commit -m '对文件系统 磁盘,分区描述符的注释 git commit -m 'python build.py ipcamera_hi3516dv300 编译kernel_liteos_a_note通过
搜索 @note_pic 可以查看全部字符图 搜索 @note_pic 可以查看全部字符图
搜索 @note_why 是注者尚未看明白的地方,如果您看明白了,请告诉注者完善 搜索 @note_why 是注者尚未看明白的地方,如果您看明白了,请告诉注者完善
搜索 @note_thinking 是注者的思考和吐槽的地方 搜索 @note_thinking 是注者的思考和吐槽的地方
......
python ../../build/lite/build_ext_components.py --path=/harmony/kernel/liteos_a --prebuilts=sh\ build.sh\ hi3516dv300\ clang\ release --command=make\ clean\ OUTDIR=/harmony/out/ipcamera_hi3516dv300/obj/kernel/liteos_a\ \&\&\ make\ rootfs\ VERSION=\"OpenHarmony\ 1.0\"\ -j\ 16\ OUTDIR=/harmony/out/ipcamera_hi3516dv300/obj/kernel/liteos_a
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册