CHRE:代码框架

Table of Contents

 

CHRE代码组成

EventLoopManager

platform相关类的实现

 platform/slpi下的代码分为SMGR、SEE两类

SMGR实现

SEE实现

CHRE入口点

chre::init()

 chreThreadEntry

sensor的data event事件是怎么发送到event loop的

chre_api

 chre.h

re.h runtime environment

 common.h

 event.h

 nanoapp.h

 sensor

gnss/wifi/wwan

​ 

sensor chre_api的实现

SensorRequestManager的构造函数

chreSensorConfigure


CHRE代码组成

chre_api是向nanoapp提供的接口,core、platform是实现chre的核心代码

EventLoopManager

EventLoopManager包含管理sensor等各种manager,通过EventLoopManger访问其他资源

//! Provide an alias to the EventLoopManager singleton.
typedef Singleton<EventLoopManager> EventLoopManagerSingleton;

类实例化,通过static等实现Singleton,EventLoopManagerSingleton::init()会创建对象

class EventLoopManager : public NonCopyable {
  //---
private:
  //! The audio request manager handles requests for all nanoapps and manages
  //! the state of the audio subsystem that the runtime subscribes to.
  AudioRequestManager mAudioRequestManager;

  //! The event loop managed by this event loop manager.
  EventLoop mEventLoop;

  //! The GnssManager that handles requests for all nanoapps. This manages the
  //! state of the GNSS subsystem that the runtime subscribes to.
  GnssManager mGnssManager;

  //! Handles communications with the host processor.
  HostCommsManager mHostCommsManager;

  //! The SensorRequestManager that handles requests for all nanoapps. This
  //! manages the state of all sensors that runtime subscribes to.
  SensorRequestManager mSensorRequestManager;

  //! The WifiRequestManager that handles requests for nanoapps. This manages
  //! the state of the wifi subsystem that the runtime subscribes to.
  WifiRequestManager mWifiRequestManager;

  //! The WwanRequestManager that handles requests for nanoapps. This manages
  //! the state of the WWAN subsystem that the runtime subscribes to.
  WwanRequestManager mWwanRequestManager;

  //! The MemoryManager that handles malloc/free call from nanoapps and also
  //! controls upper limits on the heap allocation amount.
  MemoryManager mMemoryManager;
};

platform相关类的实现

platform/include/chre/platform/platform_sensor.h 目录下有各种类的实现如PlatformSensor,但具体到不同platform有不同的实现方法,具体使用哪一个是通过编译选项控制的。

 

 platform/slpi下的代码分为SMGR、SEE两类

SLPI是高通sensor DSP,代码框架原来是SMGR,后来更新为SEE

Sensor manager (SMGR) – Master of all sensor device drivers (DD);
handles all scheduling and sensor-client interface

Sensors Execution Environment (SEE) – New generation of sensor management software on
Qualcomm All-Ways AwareTM Hub (AAH) introduced in SDM845 in 2017 and implemented in
subsequent chipsets

还有两个术语明确下:

µImage mode – Low Power mode – no double data rate (DDR)或者说静态memory不需要动态刷新

bigImage mode – DDR in use

 

SMGR实现

SMGR的实现依赖slpi_proc的源码,如果源码没有使用smgr框架就没有对应的代码,如下面的Sensors路径

 

SEE实现

 

CHRE入口点

chre的入口点肯定包含 "chre::init()",以chre在slpi上的实现为例。CHRE host 通过 fastRPC 函数 chre_slpi_start_thread调用到slpi环境。

chre::init()

PlatformSensor中创建了SeeHelper并赋值了seeHelperCallback, 该callback的具体作用后面会看到;调用EventLoopMangerSingleton::init()创建对象EventLoopManger和其他manager对象

 chreThreadEntry

调用qurt函数设置thread属性创建线程后进入chreThreadEntry,最后进入整个控制流程EventLoop.run.

event的push/pop控制这整个代码的流程。

sensor的data event事件是怎么发送到event loop的

SeeHelper注册了SeeHelperCallback::onSensorDataEvent,该函数会调用postEvent,至于callback函数是怎么被调到的看上图

chre_api

 chre.h

chre api都是为nanoapp服务的

re.h runtime environment

 common.h

 event.h

 nanoapp.h

 sensor

gnss/wifi/wwan

 

sensor chre_api的实现

bool chreSensorFindDefault(uint8_t sensorType, uint32_t *handle)
后面都依赖获得的handle

chreSensorxxx的实现在文件chre_api_sensor.cc中,//todo

SensorRequestManager的构造函数

从getSuidAndAttrs 可以看出和see通信的过程encodeSnsSuidReq (encode成pb格式),然后调用sendReq。这里维护一个全局变量mSensorRequests, 获得sensor infor等直接访问该变量。

chreSensorConfigure

 

注册当前的nanoapp接听该事件。 

  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值