arch_misc.h 源码
2026/7/20大约 1 分钟源码参考架构层工具函数头文件
arch_misc.h — 架构杂项工具接口头文件
源文件路径: arch/arm/armv7m/include/arch_misc.h
引用章节: 4.2 任务管理
完整源码
/**
***********************************************************************************************************************
* Copyright (c) 2020, China Mobile Communications Group 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
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* 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.
*
* @file arch_misc.h
*
* @brief Header file for misc related functions.
*
* @revision
* Date Author Notes
* 2021-01-12 OneOS Team First version.
***********************************************************************************************************************
*/
#ifndef __ARCH_MISC_H__
#define __ARCH_MISC_H__
#include <os_types.h>
#ifdef __cplusplus
extern "C" {
#endif
extern int32_t os_ffs(uint32_t value);
extern int32_t os_fls(uint32_t value);
extern void *os_get_current_task_sp(void);
extern void *_arch_get_interrupt_sp(void);
#ifdef __cplusplus
}
#endif
#endif /* __ARCH_MISC_H__ */关键说明
| 模块 | 说明 |
|---|---|
| os_ffs | Find First Set:查找最低位 1 的位置(从 1 开始计数),ARMv7-M 使用 RBIT+CLZ 指令实现 |
| os_fls | Find Last Set:查找最高位 1 的位置(从 1 开始计数),纯 C 二分查找实现 |
| os_get_current_task_sp | 获取当前任务栈指针(读取 PSP 寄存器),用于栈使用量检测和异常信息收集 |
| _arch_get_interrupt_sp | 获取中断栈 |