MTK 平台软件架构 软件二部王刚
一. MTK 方案简介 联发科技介绍 MTK 多媒体手机平台 GSM/GPRS 手机软件方案 二. MTK 软件分层介绍 软件结构图表 OS L1 protocol stack Device driver L2 L3 L4 protocol stack MMI 三. MTK 方案 Task 架构 MMI task 消息处理过程 example
一 MTK 方案简介
联发科技简介 1997 年成立, 全球第五大第五大集成电路设计公司 ( 台湾第一大 ), 年营业额为 10 亿美金 全球最大之光盘及 DVD 播放机芯片组芯片组制造商 研发及技术中心 : 台北新竹深圳安徽合肥 无线通信部门于 2000 年成立, 研发手机基带 /RF 芯片组及软件及发展平台, 部门约 200 工程师
联发多媒体手机平台 3G GSM/GPRS/WCDMA Multimedia Phone 2.5G MT6219 GSM/GPRS Video Platform MT6218 GSM/GPRS Multimedia Platform MT6205 GSM Low-End Platform
GSM/GPRS 手机软件方案 人机界面 Email Client 短信 /EMS WAP/MMS 中文输入 联发科技提供给客户 SIM Tool Kit Java GSM/GPRS 协议层 DSP/Layer1 驱动 RF/UART LCD/USB/IrDA/etc On-Time FAT Nucleus RTOS 联发科技已集成客户须取得原开发商之受权
二 MTK 软件分层介绍
MTK 软件架构图表 JAVA Catcher MMI WAP L2/L3 Protocol Stack Nucleus OS META Drivers L1 Protocol Stack
三大组成单元 MS (Mobile Station) 执行软件 : 运行于 MS 上 1 操作系统 Nucleus 2 物理层协议栈 3 驱动程序 4 gsm 协议栈 5 MMI META :The Mobile Engineering Testing Architecture Catcher
操作系统 Nucleus 实时操作系统,MTK 封装了适配层, 将 OS 封装了一些 API, 这些 API 为其他软件提供服务, 如 : 队列, 消息,timer, 内存管理等
L1 层协议栈 (GSM 物理层 ) L1 或者叫物理层, 提供物理介质上的 bit 流传输, 遵循 gsm 技术 05 系列规范 为上层软件提供服务, 且控制逻辑信道到物理信道的映射和安排 无线控制以及 TDMA 桢
L1 层逻辑图 Layer 1 Asynchronous Surrounding Cell Engine Layer 1 Control Layer 1 Driver
L1 各部分功能 L1 异步逻辑 : 处理上层软件的消息请求, 发送 L1 处理后的结果给上层软件 Surrounding Cell Engine : 处理相邻小区的功率测量以及同步信息获取 L1 层控制 : 处理无线环境中的 TDMA 时序安排, 包括定时提前以及来自基站的功率控制 L1 驱动 :DSP 以及无线控制
设备驱动 设备驱动支持所有 MCU( 微处理器单元 ) 外设的控制功能 本模块处理一些用户可见操作的一些设备, 如键盘,LCD 等 通过 L4 层接口, 访问寄存器来控制外设
MTK 平台外设 SIM SPI GPIO USB task UART LCD AUX task GPT, RTC, WDT IrDA task BMT PWM, Alerter MSDC Camera PMIC ADC Sched. KEYPAD JPEG Decoder
外设功能解释 SIM: Subscriber Identity Module UART: Universal Asynchronous Receiver/Transmitter SPI: Serial Port Interface LCD: Liquid Crystal Display GPIO: General Purpose Input/Output GPT: General Purpose Timer RTC: Real Time Clock WDT: Watch Dog Timer PWM: Pulse Width Modulation Alerter Keypad PMIC: Power Management IC BMT: Battery Charging Management task AUX task: Auxiliary task ADC Sched.: Analog to Digital Converter Scheduler USB task: The USB 1.1 protocol and driver IrDA task: The IrDA and driver Camera: Camera driver for integrating with 3rd party camera module MSDC: Memory card driver, supporting SD, MMC cards and Memory Stick JPEG Decoder: Software for controlling hardware JPEG decoder
L2/L3/L4 层协议栈 本部分覆盖了许多 gsm/gprs 协议需求点 为上层应用程序提供卓越的 gsm/gprs 平台 软件平台非常适合手机上面的操作以及通过 AT 命令进行 PC 操作
RMI FMI ATCI L4A L4 L4C UEM PHB SMU CSM - CC,SS,CSD RAC SMSAL TCM SS CC SMS SM NVRAM SIM FAX TDT L2R RLP RRM MM/GMM RMPC LLC RLC SNDCP RR PPP LAPDM MAC Data MPAL Drivers L1 UART KAL OS adaptation Nucleus OS
模块介绍 RMI Remote MMI,PC 端通过 UART 口与协议栈进行通讯 FMI Feature rich MM L4 MMI 通过 L4 与 gsm/gprs 协议栈进行通讯, 包括以下子模块 1 2 3 4 ATCI: AT Command Interpreter, 解释来自 PC 端的命令并命令 L4 做相应的动作 L4A: L4 adaptation Layer, MMI 与 L4A 通过消息通信 L4C: L4 Control entity, 处理所有的应用程序请求和响应 UEM: User equipments adaptation, 驱动相关的适配层
5 6 7 8 9 10 PHB: Phone book management, 电话簿相关的处理, 如分类等 SMU: SIM management Unit, 安全性管理以及 STK CSM: Circuit switching protocol stack management 电路交换协议栈管理 RAC: Registration access control SMSAL: Short message service application layer TCM: Terminal context management NVRAM Nor-volatile RAM, 是 MMI 到 Flash 的一个适配层, 保存一些默认设置 SIM Subscriber identity module. Handle SIM behavior as ETSI 11.11 description DATA 电路交换数据服务, 包括以下子模块
1 2 3 4 FAX: Group 3 Facsimile TDT: Transparent circuit switching data L2R: Layer 2 relay protocol for non-transparent circuit switching data RLP: Radio link protocol for non-transparent circuit switching data CC Circuit-switched call control 电路交换呼叫控制 SS supplementary service 附加服务 SMS short message service 短消息服务 SM session management 会话管理 MM/GMM mobility management 移动性能管理 SNDCP sub-network dependent convergence protocol
LLC Logical link control 逻辑连接控制 RR Radio resource management, 包括以下子模块 1 RRM: Handles cell selection and PLMN selection 2 RMPC: Handles the procedures in Idle/Dedicated state including the surrounding cell scheme and measurement reporting 3 LAPDM: Handles the procedure defined in GSM layer 2 4 RLC: Radio link control protocol 5 MAC: Medium access control protocol 6 MPAL: Adaptation layer for RR and L1A PPP Point to Point protocol layer, 客户端点对点协议
MMI 介绍 UI 架构 应用程序 与 ps 的通信 Applications MMI LC D Drivers GUI Fram ew ork L4
MMI Framework OLS 操作系统适配置层, 对操作系统进行封状 Task MMI 任务, 与 L4 task 进行通信 File system 与存储设备通信, 进行文件存取
MMI GUI 介绍 Theme 主题风格, 主要使菜单等颜色设置, 以及背景图片等 UI component Category Screen 每一个界面都是一个 screen Font 字体风格 Editor 编辑筐 输入法 访问 LCD 驱动 MMI 定制工具
MMI 应用程序 Phonebook Message Call History Setting User profile Fun and game Organizer Service Shortcut Camera.
三 MTK 方案 Task 架构
系统初始化 Hardware boot and setup system stack etc Nucleus Plus RTOS initialization Hardware Initialization Tasks/Modules initialization/configuration Tasks Creation TCT_schedule() for scheduler to context switch
MMI task 主要管理应用程序,task 从与之相关的队列中读取 event MMI Queue 协议栈 /L4 将 events 写入到队列中,MMI task 从队列中读取 event L4 Queue MMI task 将 MMI events 写入队列,L4 task 从队列中读取 event
MMI task MMI 注册消息事件 在 MMI 队列上面等待消息 协议栈将消息放入 MMI 消息队列 Framework Layer 处理 events Framework layer 调用应用程序注册的回调函数 回调函数中应用程序用 UI category 函数和风格进行 screen 显示
MTK Customer 创建 task typedef struct { kal_char *comp_name_ptr; kal_char *comp_qname_ptr; kal_uint32 comp_priority; kal_uint16 comp_stack_size; kal_uint8 comp_ext_qsize; kal_uint8 comp_int_qsize; kal_create_func_ptr comp_create_func; kal_bool comp_internal_ram_stack; } comptask_info_struct; const comptask_info_struct custom_comp_config_tbl[ MAX_CUSTOM_TASKS ] = { /* INDX_CUSTOM1 */ {"CUST1", "CUST1 Q", 210, 1024, 10, 0, custommmi_create, KAL_FALSE}, NULL, KAL_FALSE}, }
Tast create kal_bool custommmi_create(comptask_handler_struct **handle) { static const comptask_handler_struct customcms_handler_info = { MMI_task, /* task entry function */ NULL, /* task initialization function */ NULL, /* task configuration function */ NULL, /* task reset handler */ NULL, /* task termination handler */ }; } *handle = (comptask_handler_struct *)&customcms_handler_info; return KAL_TRUE;
注册消息事件 SetProtocolEventHandler (mmi_msg_handle_new_msg_ind, MSG_ID_SMS_NEW_MSG_INDEX_IND); for(count = 0; count < maxprotocolevent; count++) { if(protocoleventhandler[count].eventid == eventid) { isnewevent = FALSE; break; } } protocoleventhandler[count].eventid = eventid; protocoleventhandler[count].entryfuncptr = funcptr;
发送消息 typedef struct ilm_struct { module_type src_mod_id; module_type dest_mod_id; sap_type sap_id; msg_type msg_id; local_para_struct *local_para_ptr; peer_buff_struct *peer_buff_ptr; } ilm_struct; msg_send_ext_queue(send_ilm);
MMI task 等候消息 if(!oslreadcircularq(&message)) { OslReceiveMsgExtQ(qid, &Message); OslGetMyTaskIndex( &my_index ); OslStackSetActiveModuleID( my_index, MOD_MMI ); }
处理消息 void ProtocolEventHandler(U16 eventid,void* MsgStruct,int mod_src, void *peerbuf) { ExecuteCurrProtocolHandler((U16)eventID,MsgStruct,mod_src, peerbuf); } for(count = 0; count < maxprotocolevent; count++) { if(protocoleventhandler[count].eventid == eventid) { currfuncptr = (PsExtPeerFuncPtr)protocolEventHandler[count].entryFuncPtr; break; } } if ( (currfuncptr) && (!interrup_result) ) { MMI_TRACE( (MMI_TRACE_G1_FRM, MMI_FRM_INFO_EVENT_EXECURPTO_HDLR, eventid)); //(*currfuncptr)(msgstruct,mod_src); (*currfuncptr)(msgstruct, mod_src, peerbuf); }
Example: 按键处理过程 MMI task 注册某个按键的处理函数 硬件扫描键盘, 发现按键, 产生中断, 且修改相应的寄存器 ( 记录哪个键被按 ) 低级中断激活高级中断, 高级中断产生 event Keypad task 等待事件, 收到 event, 读取寄存器, 解析按键, 知道哪个键被按, 发送 message 到 UEM task UEM task 发送按键事件到 MMI task MMI Framework 找到 MMI 注册的该按键的处理函数, 执行相应的动作
THANKS!