同步官方,开机代码微调

    鸿蒙研究站 | http://weharmonyos.com (国内)
              | https://weharmony.github.io (国外)
    论坛 | http://bbs.weharmonyos.com
    文档中心 | http://open.weharmonyos.com
    参考手册 | http://doxygen.weharmonyos.com
上级 23438ce8
......@@ -202,6 +202,7 @@
### 四大码仓发布 | 源码同步官方
内核注解同时在 [gitee](https://gitee.com/weharmony/kernel_liteos_a_note) | [github](https://github.com/kuangyufei/kernel_liteos_a_note) | [coding](https://weharmony.coding.net/public/harmony/kernel_liteos_a_note/git/files) | [gitcode](https://gitcode.net/kuangyufei/kernel_liteos_a_note) 发布,并与官方源码按月保持同步,同步历史如下:
* `2022/07/18` -- 开机代码微调
* `2022/06/03` -- 增加 jffs2 编译选项
* `2022/05/09` -- 标准库(musl , newlib) 目录调整
* `2022/04/16` -- 任务调度模块有很大更新
......
......@@ -134,7 +134,8 @@ reset_vector: //内核启动入口
/* do some early cpu setup: i/d cache disable, mmu disabled */
mrc p15, 0, r0, c1, c0, 0 //System Control Register-SCTLR | 读取系统控制寄存器内容
bic r0, #(1<<12) //禁用指令缓存功能
bic r0, #(1<<2 | 1<<0) //禁用数据和TLB的缓存功能(bit2) | mmu功能(bit0)
bic r0, #(1<<2) //禁用数据和TLB的缓存功能(bit2) | mmu功能(bit0)
bic r0, #(1 << 0) /* mmu */
mcr p15, 0, r0, c1, c0, 0 //写系统控制寄存器
/* enable fpu+neon 一些系统寄存器的操作
......@@ -198,8 +199,7 @@ reloc_img_to_bottom_loop://重定位镜像到内核物理内存基地址,将内
//内核总大小 __bss_start - __exception_handlers
reloc_img_to_bottom_done:
#ifdef LOSCFG_KERNEL_MMU
ldr r4, =g_firstPageTable /* r4: physical address of translation table and clear it
内核页表是用数组g_firstPageTable存储 见于los_arch_mmu.c */
ldr r4, =g_firstPageTable /* r4: physical address of translation table and clear it | 内核页表是用数组g_firstPageTable存储 见于los_arch_mmu.c */
add r4, r4, r11 //计算g_firstPageTable页表物理地址
mov r0, r4 //因为默认r0 将作为memset_optimized的第一个参数
mov r1, #0 //第二个参数,0
......@@ -227,7 +227,7 @@ init_mmu_done:
*/
mov r6, pc
mov r7, r6 /* r7: pa (MB aligned)*/
lsr r6, r6, #20 /* r6: pa l1 index */
lsr r6, r6, #20 /* r6: va l1 index */
ldr r10, =MMU_DESCRIPTOR_KERNEL_L1_PTE_FLAGS
add r12, r10, r6, lsl #20 /* r12: pa |flags */
str r12, [r4, r7, lsr #(20 - 2)] /* jumpTable[paIndex] = pt entry */
......@@ -472,14 +472,14 @@ pa_va_offset: //物理地址和虚拟地址偏移量
.word . ////定义一个4字节的pa_va_offset 变量, 链接器生成一个链接地址, . 表示 pa_va_offset = 链接地址 举例: 在地址 0x17321796 中保存了 0x17321796
/*
* set magic num to stack bottom for all cpu | 给所有CPU核设置魔法数字到栈底
* r0 is stack bottom, r1 is stack size, r2 is magic num
* set magic num to stack top for all cpu | 给所有CPU核设置魔法数字到栈顶
* r0 is stack top, r1 is stack size, r2 is magic num
*/
excstack_magic:
mov r3, #0 //r3 = 0
excstack_magic_loop:
str r2, [r0] //栈顶设置魔法数字
add r0, r0, r1 //定位到栈
add r0, r0, r1 //定位到栈
add r3, r3, #1 //r3++
cmp r3, #CORE_NUM //栈空间等分成core_num个空间,所以每个core的栈顶需要magic num
blt excstack_magic_loop
......
......@@ -243,9 +243,6 @@ warm_reset:
LDR r0, =__exception_handlers
MCR p15, 0, r0, c12, c0, 0
cmp r11, #0 @是否为0CPU,注意0CPU为主寄存器
bne cpu_start @不是0号时,跳到cpu_start启动次级CPU
clear_bss:
ldr r0, =__bss_start
ldr r2, =__bss_end
......@@ -340,11 +337,6 @@ reset_platform:
mov r0, #0
mov pc, r0 // Jump to reset vector
#endif
cpu_start: /* 启动次级CPU */
bl secondary_cpu_start @此处用了BL,说明执行完后要回到这里继续执行
b . @B为无条件跳转,跳到当前地址,意思就是进入死循环
/*
* set sp for current cpu
......
......@@ -64,12 +64,8 @@ EXIT:
static int Testcase(void)
{
struct sched_param param = { 0 };
int ret;
void *res = nullptr;
pthread_attr_t a = { 0 };
pthread_t thread = pthread_self();
pthread_t newPthread, newPthread1;
pthread_t newPthread;
pthread_mutexattr_t mutex;
int index = 0;
pthread_mutexattr_settype(&mutex, PTHREAD_MUTEX_NORMAL);
......
......@@ -65,10 +65,8 @@ static int Testcase(void)
{
struct sched_param param = { 0 };
int ret;
void *res = nullptr;
pthread_attr_t a = { 0 };
pthread_t thread = pthread_self();
pthread_t newPthread, newPthread1;
pthread_t newPthread;
pthread_mutexattr_t mutex;
int index = 0;
int currThreadPri, currThreadPolicy;
......
......@@ -74,12 +74,9 @@ static int Testcase(void)
{
struct sched_param param = { 0 };
int ret;
void *res = nullptr;
pthread_attr_t a = { 0 };
pthread_t thread = pthread_self();
pthread_t newPthread, newPthread1;
pthread_t newPthread;
pthread_mutexattr_t mutex;
int count = 0;
int currThreadPri, currThreadPolicy;
g_preTaskPri = 0xffffffff;
......
......@@ -49,8 +49,6 @@ static void *ThreadFuncTest3(void *a)
int ret;
int tid = Gettid();
pthread_t thread = pthread_self();
int currThreadPri, currThreadPolicy;
struct sched_param param = { 0 };
ret = pthread_detach(thread);
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
......@@ -124,14 +122,10 @@ EXIT:
static int Testcase(void)
{
struct sched_param param = { 0 };
int ret;
void *res = nullptr;
pthread_attr_t a = { 0 };
pthread_t thread = pthread_self();
pthread_t newPthread, newPthread1;
pthread_t newPthread;
pthread_mutexattr_t mutex;
int index = 0;
pthread_mutexattr_settype(&mutex, PTHREAD_MUTEX_NORMAL);
pthread_mutex_init(&g_muxLock001, &mutex);
pthread_mutex_init(&g_muxLock002, &mutex);
......
......@@ -49,8 +49,6 @@ static void *ThreadFuncTest3(void *a)
int ret;
int tid;
pthread_t thread = pthread_self();
int currThreadPri, currThreadPolicy;
struct sched_param param = { 0 };
ret = pthread_detach(thread);
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
......@@ -126,14 +124,10 @@ EXIT:
static int Testcase(void)
{
struct sched_param param = { 0 };
int ret;
void *res = nullptr;
pthread_attr_t a = { 0 };
pthread_t thread = pthread_self();
pthread_t newPthread, newPthread1;
pthread_t newPthread;
pthread_mutexattr_t mutex;
int index = 0;
pthread_mutexattr_settype(&mutex, PTHREAD_MUTEX_NORMAL);
pthread_mutex_init(&g_muxLock001, &mutex);
pthread_mutex_init(&g_muxLock002, &mutex);
......
......@@ -48,8 +48,6 @@ static void *ThreadFuncTest3(void *a)
{
int ret;
int tid = Gettid();
int currThreadPri, currThreadPolicy;
struct sched_param param = { 0 };
pthread_t thread = pthread_self();
ret = pthread_detach(thread);
......@@ -118,18 +116,14 @@ static void *ThreadFuncTest1(void *a)
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
EXIT:
return nullptr;
return nullptr;
}
static int Testcase(void)
{
struct sched_param param = { 0 };
int ret;
void *res = nullptr;
pthread_attr_t a = { 0 };
pthread_t newPthread, newPthread1;
pthread_t newPthread;
pthread_mutexattr_t mutex;
int index = 0;
pthread_mutexattr_settype(&mutex, PTHREAD_MUTEX_NORMAL);
pthread_mutex_init(&g_mutexLock001, &mutex);
pthread_mutex_init(&g_mutexLock002, &mutex);
......
......@@ -43,7 +43,6 @@ static void *ThreadFuncTest3(void *a)
{
int ret;
pthread_t thread = pthread_self();
int currThreadPri, currThreadPolicy;
struct sched_param param = { 0 };
struct timespec time;
struct timeval timeVal = { 0 };
......@@ -62,7 +61,7 @@ static void *ThreadFuncTest3(void *a)
g_testToCount003++;
while (g_testToCount002 == 0) {
SLEEP_AND_YIELD(2); // 2, delay enouge time
SLEEP_AND_YIELD(2); // 2, delay enough time
}
ret = pthread_mutex_unlock(&g_muxLock003);
......@@ -96,7 +95,7 @@ static void *ThreadFuncTest2(void *a)
g_testToCount002++;
while (g_testToCount001 == 0) {
SLEEP_AND_YIELD(2); // 2, delay enouge time
SLEEP_AND_YIELD(2); // 2, delay enough time
}
ret = pthread_mutex_unlock(&g_muxLock002);
......@@ -141,12 +140,8 @@ EXIT:
static int Testcase(void)
{
struct sched_param param = { 0 };
int ret;
void *res = nullptr;
pthread_attr_t a = { 0 };
pthread_t thread = pthread_self();
pthread_t newPthread, newPthread1;
pthread_t newPthread;
pthread_mutexattr_t mutex = { 0 };
int index = TEST_COUNT;
......
......@@ -41,8 +41,6 @@ static void *ThreadFuncTest3(void *a)
{
int ret;
pthread_t thread = pthread_self();
int currThreadPri, currThreadPolicy;
struct sched_param param = { 0 };
struct timespec time;
struct timeval timeVal = { 0 };
......@@ -120,12 +118,8 @@ EXIT:
static int Testcase(void)
{
struct sched_param param = { 0 };
int ret;
void *res = nullptr;
pthread_attr_t a = { 0 };
pthread_t thread = pthread_self();
pthread_t newPthread, newPthread1;
pthread_t newPthread;
pthread_mutexattr_t mutex;
int index = TEST_COUNT;
......
......@@ -38,7 +38,6 @@ static int g_testBackCount = 0;
static void *ThreadFuncTest3(void *a)
{
int ret;
int tid = Gettid();
pthread_t thread = pthread_self();
ret = pthread_detach(thread);
......@@ -59,8 +58,6 @@ EXIT:
static void *ThreadFuncTest2(void *a)
{
int ret;
int tid = Gettid();
pthread_t thread = pthread_self();
g_testBackCount++;
ret = pthread_mutex_lock(&g_mutexLock);
......@@ -78,10 +75,8 @@ static int TestCase(void)
{
struct sched_param param = { 0 };
int ret;
void *res = nullptr;
int currThreadPri, currThreadPolicy;
pthread_attr_t a = { 0 };
pthread_t thread = pthread_self();
pthread_t newPthread;
pthread_mutexattr_t mutex;
pthread_mutexattr_settype(&mutex, PTHREAD_MUTEX_NORMAL);
......
......@@ -45,8 +45,6 @@ static void *ThreadFuncTest2(void *a)
{
int ret;
pthread_t thread = pthread_self();
struct timespec time;
struct timeval timeVal = { 0 };
ret = pthread_detach(thread);
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
......@@ -69,7 +67,6 @@ EXIT:
static void *ThreadFuncTest1(void *a)
{
int ret;
pthread_t thread = pthread_self();
struct timespec time;
struct timeval timeVal = { 0 };
......@@ -106,9 +103,7 @@ static int Testcase(void)
struct sched_param param = { 0 };
int ret;
int threadCount;
void *res = nullptr;
pthread_attr_t a = { 0 };
pthread_t thread = pthread_self();
pthread_t newPthread[10], newPthread1;
pthread_mutexattr_t mutex;
int index = TEST_COUNT;
......
......@@ -45,8 +45,6 @@ static void *ThreadFuncTest2(void *a)
{
int ret;
pthread_t thread = pthread_self();
struct timespec time;
struct timeval timeVal = { 0 };
ret = pthread_detach(thread);
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
......@@ -69,9 +67,6 @@ EXIT:
static void *ThreadFuncTest1(void *a)
{
int ret;
pthread_t thread = pthread_self();
struct timespec time;
struct timeval timeVal = { 0 };
ret = pthread_mutex_lock(&g_muxLock001);
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
......@@ -96,7 +91,6 @@ EXIT:
static void *ThreadFuncTest0(void *a)
{
int ret;
pthread_t thread = pthread_self();
struct timespec time;
struct timeval timeVal = { 0 };
......@@ -136,9 +130,7 @@ static int Testcase(void)
struct sched_param param = { 0 };
int ret;
int threadCount;
void *res = nullptr;
pthread_attr_t a = { 0 };
pthread_t thread = pthread_self();
pthread_t newPthread[10], newPthread1;
pthread_mutexattr_t mutex;
int index = TEST_COUNT;
......
......@@ -45,8 +45,6 @@ static void *ThreadFuncTest2(void *a)
{
int ret;
pthread_t thread = pthread_self();
struct timespec time;
struct timeval timeVal = { 0 };
ret = pthread_detach(thread);
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
......@@ -69,9 +67,6 @@ EXIT:
static void *ThreadFuncTest1(void *a)
{
int ret;
pthread_t thread = pthread_self();
struct timespec time;
struct timeval timeVal = { 0 };
ret = pthread_mutex_lock(&g_muxLock001);
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
......@@ -96,7 +91,6 @@ EXIT:
static void *ThreadFuncTest0(void *a)
{
int ret;
pthread_t thread = pthread_self();
struct timespec time;
struct timeval timeVal = { 0 };
......@@ -136,9 +130,7 @@ static int Testcase(void)
struct sched_param param = { 0 };
int ret;
int threadCount;
void *res = nullptr;
pthread_attr_t a = { 0 };
pthread_t thread = pthread_self();
pthread_t newPthread[10], newPthread1;
pthread_mutexattr_t mutex;
int index = TEST_COUNT;
......
......@@ -45,8 +45,6 @@ static void *ThreadFuncTest2(void *a)
{
int ret;
pthread_t thread = pthread_self();
struct timespec time;
struct timeval timeVal = { 0 };
ret = pthread_detach(thread);
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
......@@ -69,9 +67,6 @@ EXIT:
static void *ThreadFuncTest1(void *a)
{
int ret;
pthread_t thread = pthread_self();
struct timespec time;
struct timeval timeVal = { 0 };
ret = pthread_mutex_lock(&g_muxLock001);
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
......@@ -96,7 +91,6 @@ EXIT:
static void *ThreadFuncTest0(void *a)
{
int ret;
pthread_t thread = pthread_self();
struct timespec time;
struct timeval timeVal = { 0 };
......@@ -136,9 +130,7 @@ static int Testcase(void)
struct sched_param param = { 0 };
int ret;
int threadCount;
void *res = nullptr;
pthread_attr_t a = { 0 };
pthread_t thread = pthread_self();
pthread_t newPthread[10], newPthread1;
pthread_mutexattr_t mutex;
int index = TEST_COUNT;
......
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
# Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
#
# Copyright (c) 2021 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# Redistribution and use in source and binary forms, with or without modification,
# are permitted provided that the following conditions are met:
#
# http://www.apache.org/licenses/LICENSE-2.0
# 1. Redistributions of source code must retain the above copyright notice, this list of
# conditions and the following disclaimer.
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# 2. Redistributions in binary form must reproduce the above copyright notice, this list
# of conditions and the following disclaimer in the documentation and/or other materials
# provided with the distribution.
#
# 3. Neither the name of the copyright holder nor the names of its contributors may be used
# to endorse or promote products derived from this software without specific prior written
# permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
import sys
import os
......
git add -A
git commit -m ' 纠正一些错误单词拼写
git commit -m ' 同步官方,开机代码微调
鸿蒙研究站 | http://weharmonyos.com (国内)
| https://weharmony.github.io (国外)
论坛 | http://bbs.weharmonyos.com
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册