Mobile Development Integrated System (MoDIS)

tediousfifthΚινητά – Ασύρματες Τεχνολογίες

12 Νοε 2013 (πριν από 3 χρόνια και 9 μήνες)

154 εμφανίσεις











Release Date: May 29, 2007
Revision: 0.30
Preliminary (Released) Information
Document Number:
High-Level Design Document and User Manual

Mobile Development
Integrated System (MoDIS)
MediaTek
Mobile Development Integrated System (MoDIS)
Preliminary Information High Level Design Document and User Manual
MediaTek Confidential
Revision 0.20 – August 14, 2006 Page: 2 of 71
© 2006 MediaTek Inc.
The information contained in this document can be modified without notice.
Legal Disclaimer

BY OPENING OR USING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES THAT
THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS (“MoDIS”) RECEIVED FROM MEDIATEK AND/OR ITS
REPRESENTATIVES ARE PROVIDED TO BUYER ON AN “AS-IS” BASIS ONLY. MEDIATEK EXPRESSLY
DISCLAIMS ANY AND ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
NONINFRINGEMENT. NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT
TO THE SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR SUPPLIED
WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH THIRD PARTY FOR ANY
WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO NOT BE RESPONSIBLE FOR ANY
MEDIATEK SOFTWARE RELEASES MADE TO BUYER’S SPECIFICATION OR TO CONFORM TO A PARTICULAR
STANDARD OR OPEN FORUM.

BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE LIABILITY WITH
RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE, AT MEDIATEK'S OPTION, TO
REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE, OR REFUND ANY SOFTWARE LICENSE FEES
OR SERVICE CHARGE PAID BY BUYER TO MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.

THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE WITH THE
LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF LAWS PRINCIPLES.


Mobile Development Integrated System (MoDIS)
Preliminary Information High Level Design Document and User Manual
MediaTek Confidential
Revision 0.20 – August 14, 2006 Page: 3 of 71
© 2006 MediaTek Inc.
The information contained in this document can be modified without notice.
Revision History

Revision
Date (yyyy/mm/dd)
Author
Comments
0.00
2006/02/15
Max Chen
Initial version
0.01
2006/03/19
KS Hsueh
Add Section

5.1 (UART)
0.02
2006/03/19
JI Huang
Add Chapter

3 (File System)
0.03
2006/03/20
Gilbert Wang
Add Section

10.2 (How to Check Call Stack in MoDIS)
0.04
2006/03/24
Karen Hsu
Add Chapter

8 (OS Core Adapter)
0.05
2006/03/25
JI Huang
Update File System Simulator Run-Time Configuration in
Section

3.1
0.06
2006/03/26
Joe Wang
Add Chapter

2 (Start Using MoDIS) (draft)
0.07
2006/03/28
PC Huang
Add Chapter

5.3 (LCD Interfaces)
0.08
2006/03/31
Bear Wang
Add Chapter

9 (Add-in Tools)
0.09
2006/04/01
PH Shih
Add Chapter

5.2 (SIM Simulator)
0.10
2006/04/10
Max Chen
Add Chapter

1 (Introduction)
0.11
2006/04/10
KS Hsueh
Add Chapter

7.1 (Log Messages via Catcher)
0.12
2006/04/13
Cylen Yao
Add Chapter

10.1 (How to Format NVRAM)
0.13
2006/04/17
Joe Wang
Refine Chapter

2 (Start Using MoDIS)
0.14
2006/06/13
Naomi Ko
English review and document formatting.
0.15
2006/06/30
Wayne Chen
Refine Chapter

9.1 (Skin Layout and Version): add Skin,
LCD Screen and Sub LCD Screen resizing
0.17
2006/07/16
JI Huang
Update Chapter

3.3 to Sync File System API Notes
0.18
2006/07/18
Leo Hu
Update Chapter

2.8 for resource management under
Vendor Release mode.
0.19
2006/07/19
Bear Wang
Update Chapter

2.8 for sample code
0.20
2006/08/14
Naomi Ko
English review and document formatting.
0.30
2007/05/30
KS Hsueh
Add Ch5.2.2.5-4, Ch6, Ch10

Mobile Development Integrated System (MoDIS)
Preliminary Information High Level Design Document and User Manual
MediaTek Confidential
Revision 0.20 – August 14, 2006 Page: 4 of 71
© 2006 MediaTek Inc.
The information contained in this document can be modified without notice.
Table of Contents
Legal Disclaimer..........................................................................................................................................................2

Revision History..........................................................................................................................................................3

Table of Contents.........................................................................................................................................................4

1

Introduction......................................................................................................................................................8

1.1

Overview....................................................................................................................................................8

1.2

System Requirement.................................................................................................................................8

1.3

Function and Feature List..........................................................................................................................9

1.4

File and Folder Structure............................................................................................................................9

1.4.1

Major Folders.....................................................................................................................................10

1.4.2

Major Files..........................................................................................................................................10

1.5

Terms and Definitions...............................................................................................................................11

2

Start Using MoDIS..........................................................................................................................................12

2.1

Build Environment Settings......................................................................................................................12

2.2

Configure the MoDIS Workspace Based on Target Load.........................................................................12

2.2.1

createMoDIS.ini..................................................................................................................................13

2.2.2

GLOBAL_SETTINGS Section............................................................................................................14

2.2.3

ENABLE_INC_PATH and DISABLE_INC_PATH Sections.................................................................14

2.2.4

ENABLE_OPTION and DISABLE_OPTION Sections........................................................................14

2.2.5

ENABLE_FILE and DISABLE_FILE Sections....................................................................................14

2.3

Generate a MoDIS Workspace by Target Load........................................................................................14

2.3.1

Generate a MoDIS Project Using the “make” Command....................................................................14

2.3.2

Generate a MoDIS Project Using the Batch Utility.............................................................................14

2.3.3

Generation Result..............................................................................................................................14

2.4

Database Codegen..................................................................................................................................15

2.4.1

Database Codegen Using the “make” Command...............................................................................15

2.4.2

Database Codegen Using the Batch Utility........................................................................................15

2.5

Compile the Source Code........................................................................................................................15

2.5.1

Compile the Source Code Using Microsoft Visual C++......................................................................15

2.5.2

Compile the Source Code Using the “make” Command.....................................................................16

2.5.3

Compile the Source Code Using the Batch Utility..............................................................................16

2.6

Slim MoDIS..............................................................................................................................................16

2.7

Summary of MoDIS Build Command.......................................................................................................17

2.8

Vendor Release Sample Code.................................................................................................................17

3

File System.....................................................................................................................................................18

3.1

Overview..................................................................................................................................................18

3.2

Design......................................................................................................................................................18

3.3

Interfaces/API..........................................................................................................................................19

3.3.1

FS_OpenHint() does not speed up.....................................................................................................19

3.3.2

FS_Extend() does not allocate any clusters.......................................................................................19

3.3.3

FS_SetSeekHint() does nothing.........................................................................................................19

3.3.4

FS_GetFirstClusterValue() returns a random integer.........................................................................19

3.3.5

FS_CheckFile() does nothing.............................................................................................................20

Mobile Development Integrated System (MoDIS)
Preliminary Information High Level Design Document and User Manual
MediaTek Confidential
Revision 0.20 – August 14, 2006 Page: 5 of 71
© 2006 MediaTek Inc.
The information contained in this document can be modified without notice.
3.3.6

FS_GetFolderSize() calculates size on ideal folder assumption........................................................20

3.3.7

FS_QmGetFree() is based on pseudo disk space calculation............................................................20

3.3.8

FS_Abort() cannot abort FS_CheckDrive() and FS_XDelete()...........................................................20

3.3.9

FS_GetDevStatus() does not support the FS_FEATURE_STATE_ENUM query................................20

3.3.10

FS_TestMSDC() always returns FS_MSDC_NOT_PRESENT...........................................................20

3.3.11

FS_CloseMSDC() is an empty function..............................................................................................20

3.3.12

FS_CreateBootSector() always returns 32 (meaning FAT32)............................................................20

3.3.13

FS_GetPartitionInfo() fills fake data....................................................................................................20

3.3.14

FS_CheckDrive() is an empty function...............................................................................................20

3.3.15

FS_CreateMasterBootRecord() is an empty function.........................................................................21

3.3.16

FS_SplitPartition() is an empty function..............................................................................................21

3.3.17

FS_Shutdown() is an empty function..................................................................................................21

3.3.18

FS_UnlockAll() is an empty function...................................................................................................21

3.3.19

FS_SanityCheck() tries to trigger fssim_init() only..............................................................................21

3.3.20

FS_SetDiskFlag() is an empty function..............................................................................................21

3.3.21

FS_CheckDiskFlag() is an empty function.........................................................................................21

3.3.22

FS_ClearDiskFlag() is an empty function...........................................................................................21

3.3.23

FS_LockFAT() is an empty function....................................................................................................21

3.3.24

FS_SetTrace() is an empty function...................................................................................................21

3.3.25

FS_DumpFHTable() is an empty function...........................................................................................21

3.3.26

FS_SetDirCache() is an empty function.............................................................................................22

3.3.27

FS_GetDirCache () always returns FS_DIRCACHE_EXPIRED.........................................................22

3.3.28

FS_OTPRead() is an empty function..................................................................................................22

3.3.29

FS_OTPWrite() is an empty function..................................................................................................22

3.3.30

FS_OTPQueryLength() is an empty function.....................................................................................22

3.3.31

FS_SweepDevice() is an empty function............................................................................................22

4

Network Ability...............................................................................................................................................23

4.1

Socket......................................................................................................................................................23

4.1.1

Overview............................................................................................................................................23

4.1.2

Design................................................................................................................................................23

4.1.3

Interfaces/API.....................................................................................................................................24

4.1.3.1

soc_create()........................................................................................................................................24

4.1.3.2

soc_shutdown() is an empty function..................................................................................................24

4.1.3.3

soc_select() is an empty function........................................................................................................24

4.1.3.4

soc_setsockopt() only supports SOC_NBIO and SOC_ASYNC..........................................................24

4.1.3.5

soc_getsockopt() only supports SOC_NBIO and SOC_ASYNC.........................................................24

4.1.3.6

soc_gethostbyname() only blocking is supported................................................................................25

4.1.3.7

soc_gethostbyaddr() is an empty function...........................................................................................25

4.1.3.8

soc_get_last_error() is an empty function...........................................................................................25

4.1.3.9

soc_set_last_error() is an empty function............................................................................................25

4.1.3.10

soc_abort_dns_query() is an empty function.......................................................................................25

5

Driver Simulating............................................................................................................................................26

5.1

UART.......................................................................................................................................................26

5.1.1

Overview............................................................................................................................................26

5.1.2

Design................................................................................................................................................26

5.1.3

Virtual COM Port................................................................................................................................26

5.1.4

Interfaces/API.....................................................................................................................................27

Mobile Development Integrated System (MoDIS)
Preliminary Information High Level Design Document and User Manual
MediaTek Confidential
Revision 0.20 – August 14, 2006 Page: 6 of 71
© 2006 MediaTek Inc.
The information contained in this document can be modified without notice.
5.1.4.1

UART_Open........................................................................................................................................27

5.1.4.2

UART_Close.......................................................................................................................................27

5.1.4.3

UART_GetBytes..................................................................................................................................27

5.1.4.4

UART_PutBytes..................................................................................................................................28

5.1.4.5

Message MSG_ID_UART_READY_TO_WRITE_IND........................................................................29

5.1.4.6

Message MSG_ID_UART_READY_TO_READ_IND..........................................................................29

5.2

SIM Simulator..........................................................................................................................................30

5.2.1

Overview............................................................................................................................................30

5.2.2

Design................................................................................................................................................31

5.2.2.1

MoDIS SIM Simulator Design..............................................................................................................32

5.2.2.2

SIM Card Files on WIN32 File System................................................................................................33

5.2.2.3

Mapping of SIM File Structure to WIN32 File System.........................................................................33

5.2.2.4

Details WIN32 File Structures of 3 Types of SIM Elementary Files.....................................................34

5.2.2.5

Add a New SIM File to the MoDIS SIM Simulator...............................................................................34

5.2.3

Interfaces/API.....................................................................................................................................38

5.2.3.1

L1sim_Reset_All ( ).............................................................................................................................38

5.2.3.2

L1sim_Cmd_All ( )...............................................................................................................................38

5.2.3.3

L1sim_Enable_Enhanced_Speed_All ( ).............................................................................................39

5.2.3.4

L1sim_Get_Card_Info_All ( )...............................................................................................................39

5.2.3.5

L1sim_PowerOff_All ( ).......................................................................................................................39

5.2.3.6

L1sim_Set_ClockStopMode_All ( )......................................................................................................39

5.3

LCD Interfaces.........................................................................................................................................39

5.3.1

Overview............................................................................................................................................39

5.3.2

Design................................................................................................................................................40

5.3.2.1

lcd_layer_struct...................................................................................................................................40

5.3.2.2

lcd_frame_update_struct.....................................................................................................................41

5.3.2.3

lcd_frame_update_to_mem_struct......................................................................................................43

5.3.3

Interfaces/API.....................................................................................................................................44

5.3.3.1

void lcd_init(kal_uint8 lcd_id, kal_uint16 background_color)...............................................................44

5.3.3.2

kal_bool config_lcd_layer_window(kal_uint8 lcd_layer, lcd_layer_struct *layer_data)........................44

5.3.3.3

void set_lcd_color_palette(kal_uint8 color_palette_select, kal_uint32 *color_palette_addr_ptr,
kal_uint8 start_index, kal_uint8 number_of_color)..............................................................................44

5.3.3.4

void lcd_fb_update(lcd_frame_update_struct *lcd_para)....................................................................45

5.3.3.5

void lcd_fb_update_to_memory(lcd_frame_update_to_mem_struct *lcd_para)..................................45

5.4

PC Keyboard Simulation..........................................................................................................................45

5.4.1

Overview............................................................................................................................................45

5.4.2

Keyboard Setting Customization........................................................................................................45

5.4.2.1

Design.................................................................................................................................................46

5.4.2.2

Interfaces/API......................................................................................................................................46

5.4.2.3

int w32_convert_key_code (unsigned int vk).......................................................................................46

5.5

Direct Input Editor....................................................................................................................................47

5.5.1.1

Design.................................................................................................................................................48

5.5.1.2

Interfaces/API......................................................................................................................................48

5.5.1.3

int w32_push_input_into_editor_component (char *szItemInput, int szItemInputLen).........................48

5.5.1.4

int mmi_get_current_editor_style(void)...............................................................................................48

5.5.1.5

MMI_BOOL mmi_is_input_content_valid (unsigned short *input).......................................................48

5.6

Unsupported Driver Abilities.....................................................................................................................49

Mobile Development Integrated System (MoDIS)
Preliminary Information High Level Design Document and User Manual
MediaTek Confidential
Revision 0.20 – August 14, 2006 Page: 7 of 71
© 2006 MediaTek Inc.
The information contained in this document can be modified without notice.
6

Using Network Simulator on MoDIS.............................................................................................................50

6.1

Introduction..............................................................................................................................................50

6.2

Getting Start.............................................................................................................................................51

6.3

MoDIS Network Simulator Property Pages..............................................................................................52

6.3.1

Daemon Page....................................................................................................................................52

6.3.2

Inject Page.........................................................................................................................................53

6.3.3

Setting Page.......................................................................................................................................54

6.4

MoDIS Network Simulator Architecture....................................................................................................55

6.5

INI file setting...........................................................................................................................................56

6.5.1

[Setting]..............................................................................................................................................56

6.5.2

[MSG_GROUP]..................................................................................................................................56

6.5.3

[Toolbar].............................................................................................................................................56

6.5.4

[Position]............................................................................................................................................57

7

Using Catcher on MoDIS...............................................................................................................................58

7.1

Log Messages via Catcher......................................................................................................................58

8

OS Core Adapter............................................................................................................................................59

8.1

Interrupt Mechanism................................................................................................................................59

8.1.1

Choose Your Interrupt Index...............................................................................................................59

8.1.2

Register Your ISR...............................................................................................................................60

8.1.3

Activate Your ISR...............................................................................................................................60

9

Add-in Tools....................................................................................................................................................61

9.1

Skin Layout and Version..........................................................................................................................61

9.1.1

Introduction........................................................................................................................................61

9.1.2

Skin Customization.............................................................................................................................62

9.1.2.1

Change the Skin Size..........................................................................................................................63

9.1.2.2

Change the LCD Screen Size.............................................................................................................63

9.1.2.3

Change the SubLCD Screen Size.......................................................................................................63

9.1.3

Display Version..................................................................................................................................64

9.2

Layer Monitor...........................................................................................................................................64

10

Techniques......................................................................................................................................................66

10.1

How to Format NVRAM...........................................................................................................................66

10.2

How to Check Call Stack in MoDIS..........................................................................................................67

Index of Figures.........................................................................................................................................................70

Index of Tables...........................................................................................................................................................71

Mobile Development Integrated System (MoDIS)
Preliminary Information High Level Design Document and User Manual
MediaTek Confidential
Revision 0.20 – August 14, 2006 Page: 8 of 71
© 2006 MediaTek Inc.
The information contained in this document can be modified without notice.
1 Introduction
1.1 Overview
MoDIS is a development-supported simulator, which accelerates the software development process on an as-real
environment. MoDIS simulates the target in software, emulating the functions and features of the target mobile phone
when a software build is applied. The basic layout of MoDIS contains a basic simulator window and a command-
prompt-based debug window (Figure 1).
Figure 1: MoDIS Simulator Window









1.2 System Requirement
For smooth operation of the simulator, the following system requirements are suggested:
• CPU: 1.5G MHz or faster
• RAM: 512 MB or more

Simulator
main
window
Ke
y
pad
LCD
simulator
Debug
window
Side ke
y
s
Sub LCD
simulato
r
Mobile Development Integrated System (MoDIS)
Preliminary Information High Level Design Document and User Manual
MediaTek Confidential
Revision 0.20 – August 14, 2006 Page: 9 of 71
© 2006 MediaTek Inc.
The information contained in this document can be modified without notice.
1.3 Function and Feature List
Table 1: Function and Feature List
Class
Function
Description
General Multi-tasking Launches new tasks on MoDIS the same way as in the
target environment.
File System File system Simulates a file system and adapts all required
interfaces.
COM port simulation
SIM
Simulates UART.
LCD Adapts multiple LCD interfaces.
SIM/USIM Simulates SIM EF on the file system.
CSR Bluetooth Drives a CSR Bluetooth dongle to simulate a Bluetooth
application on the target.
Driver Ability
Image codec Uses FreeImage library to provide GIF, PNG, and JPEG
decoders on MoDIS.
Socket interface Provides the same interface as target to development
TCP/IP related applications.
Obigo WAP Provides the same function as target
Obigo MMS Provides the same function as target
OMA PoC (without audio) Provides the same function as target
OMA IMPS Provides the same function as target
Network Ability
Email Provides the same function as target
OS ISR simulator Provides an easy to simulate LISR/HISR mechanism on
MoDIS.
Catcher Tool MoDIS logging mode Logs messages as the target, via Catcher Tool.
Unit Test UT environment Provides unit test environment for protocol unit test
Skin layout Provides the ability to select phone skin for different
LCM size.
Layer monitor Provides an interface for developer to investigate
content of each GDI layer.
Add-In Tools
OSCAR tool Helps developer to know the status of system resource.

1.4 File and Folder Structure
All MoDIS-related files are located in mcu\MoDIS. The module workspaces are placed in corresponding folders
(Figure 2).
Mobile Development Integrated System (MoDIS)
Preliminary Information High Level Design Document and User Manual
MediaTek Confidential
Revision 0.20 – August 14, 2006 Page: 10 of 71
© 2006 MediaTek Inc.
The information contained in this document can be modified without notice.
Figure 2: MoDIS File and Folder Structure


1.4.1 Major Folders
Folder
Description
_BUILD_LOG Logs of command-line compiles
drv_sim Source code for driver simulating functions
File System Source code for file system
MoDIS Source code for the main function of MoDIS
MoDIS_lib Necessary libraries for MoDIS
MoDIS_UI Files for MoDIS skins
Oscar Source code for OSCAR Tool
WIN32FS Simulates the drives for the Windows file system.

1.4.2 Major Files
File
Description
MoDIS.dsw Workspace of MoDIS
MoDIS_Custom.dsw Customized workspace of MoDIS
ModisReleaseL1.pl Batch file to generate Level 1 release package
ModisReleaseL2obj.pl Batch file to generate Level 2 object release package
ModisReleaseL2src.pl Batch file to generate Level 2 source release package
MoDISReleaseCustom.pl Batch file to generate customized workspace
createMoDIS.pl Batch file to generate MoDIS project from target load
createMoDIS.ini Global configuration file of MoDIS

VC workspace
of each module
Command line
compile result
Mobile Development Integrated System (MoDIS)
Preliminary Information High Level Design Document and User Manual
MediaTek Confidential
Revision 0.20 – August 14, 2006 Page: 11 of 71
© 2006 MediaTek Inc.
The information contained in this document can be modified without notice.

1.5 Terms and Definitions
Term
Definition
DF Dedicated file (SIM card file system)
EF Elementary file (SIM card file system)
HISR High-level Interrupt Service Routine
ISR Interrupt Service Routine
LCD Liquid Crystal Display
Mutex Mutual exclusion (when referring to access rights)
OSCAR OS Core Adapter
ROI Region of interest
UART Universal Asynchronous Receiver-Transmitter


Mobile Development Integrated System (MoDIS)
Preliminary Information High Level Design Document and User Manual
MediaTek Confidential
Revision 0.20 – August 14, 2006 Page: 12 of 71
© 2006 MediaTek Inc.
The information contained in this document can be modified without notice.
2 Start Using MoDIS
MoDIS creation is based on the target’s setting. First build the target with the action “new”, with no errors until the
resgen step. We recommend that you build the target successfully first, then follow the below instructions to create
the MoDIS project.
2.1 Build Environment Settings
Before starting, verify the following settings on your PC:
1. msdev.exe and cl.exe are in the PATH settings.
2. LIB setting should include VC98\LIB and VC98\MFC\LIB.

E.g.
Path=C:\Program Files\Microsoft Visual Studio\Common\MSDev98\Bin;C:\Program Files\Microsoft Visual Studio\VC98\bin
LIB=C:\Program Files\Microsoft Visual Studio\VC98\lib ;C:\Program Files\Microsoft Visual Studio\VC98\mfc\lib

2.2 Configure the MoDIS Workspace Based on Target Load
MoDIS is created based on the target’s settings. But you can add extra settings or delete original settings by using
createMoDIS.ini.

createMoDIS.ini can:
1. Add or remove global compile options, global include path, and modules;
2. Add or remove module-based compile options, include path, and compile file list; and,
3. Add or remove file-based compile options.
Figure 3: MoDIS Workspace




Module Name
Module.dsp
Module.ini
Mobile Development Integrated System (MoDIS)
Preliminary Information High Level Design Document and User Manual
MediaTek Confidential
Revision 0.20 – August 14, 2006 Page: 13 of 71
© 2006 MediaTek Inc.
The information contained in this document can be modified without notice.




2.2.1 createMoDIS.ini
The createMoDIS.ini file has 7 sections: GLOBAL_SETTINGS, ENABLE_INC_PATH, ENABLE_OPTION,
DISABLE_OPTION, ENABLE_FILE, and DISABLE_FILE.
Figure 4: MoDIS INI File






MoDIS.ds
p
MoDIS.ds
w
SECTION NAME
RESERVED
KEY NAME
Values, settings
Set filename
as key
Concatenate
to same key
Set module
name as key
Mobile Development Integrated System (MoDIS)
Preliminary Information High Level Design Document and User Manual
MediaTek Confidential
Revision 0.20 – August 14, 2006 Page: 14 of 71
© 2006 MediaTek Inc.
The information contained in this document can be modified without notice.
2.2.2 GLOBAL_SETTINGS Section
In the GLOBAL_SETTINGS section, extra modules can be added to MoDIS, and unnecessary target modules can be
removed by setting disable_libs or enable_libs. To add extra modules, remember also to add module.lis, module.inc,
module.pth and module.def into mcu\make\module.
2.2.3 ENABLE_INC_PATH and DISABLE_INC_PATH Sections
Enable or disable global include paths by setting the value for “global”. An include path can also enabled or disabled
by module base, where the key’s name becomes the module’s name.
2.2.4 ENABLE_OPTION and DISABLE_OPTION Sections
Enable or disable global options by setting the value for “global”. An option can also enabled or disabled by module
base, where the key’s name becomes the module’s name. An option can only be enabled by file base, using the key’s
name as the filename.
2.2.5 ENABLE_FILE and DISABLE_FILE Sections
Files for each module can be enabled or disabled, using the key’s name as the module’s name.

2.3 Generate a MoDIS Workspace by Target Load
If no project exists in the MoDIS folder, or the target’s settings have already changed and have been compiled
successfully with no errors until the resgen step, the MoDIS workspace can be built with a target load by one of the
two methods.
2.3.1 Generate a MoDIS Project Using the “make” Command
In the mcu folder, execute the following command:
make <project name> <gsm|gprs> gen_modis

Example:
make dragonfly_demo gprs gen_modis
2.3.2 Generate a MoDIS Project Using the Batch Utility
In the mcu\MoDIS folder, use the createMoDIS.pl script:
createMoDIS.pl ..\make\<project name>_<gsm|gprs>.mak

Example:
createMoDIS.pl ..\make\ SAPPHIRE28_DEMO_GPRS.mak
2.3.3 Generation Result
The .ini and .dsp files for each module are generated in the folder mcu\MoDIS\module. The INI file can be modified to
change include paths and compile options for this module.

The file MoDIS.dsw is generated, and MoDIS.dsp is updated. We strongly suggest not to modify any files directly.
Please modify by using msdev IDE instead.

Mobile Development Integrated System (MoDIS)
Preliminary Information High Level Design Document and User Manual
MediaTek Confidential
Revision 0.20 – August 14, 2006 Page: 15 of 71
© 2006 MediaTek Inc.
The information contained in this document can be modified without notice.

2.4 Database Codegen
After generating the MoDIS workspace, the MoDIS database must be generated.
2.4.1 Database Codegen Using the “make” Command
In the mcu folder, execute the following command:
make <project name> <gsm|gprs> codegen_modis

Example:
make dragonfly_demo gprs codegen_modis
2.4.2 Database Codegen Using the Batch Utility
In the mcu\MoDIS folder, use the modiscodegen.pl:
modiscodegen.pl ..\make\<project name>_<gsm|gprs>.mak

Example:
modiscodegen.pl ..\make\ SAPPHIRE28_DEMO_GPRS.mak

2.5 Compile the Source Code
Use the workspace to build MoDIS.
2.5.1 Compile the Source Code Using Microsoft Visual C++
Double click the MoDIS.dsw file in mcu\MoDIS to launch the MoDIS project using Microsoft Visual C++.
Figure 5: Compiling Source Code Using Microsoft Visual C++


Workspace of
each module
Mobile Development Integrated System (MoDIS)
Preliminary Information High Level Design Document and User Manual
MediaTek Confidential
Revision 0.20 – August 14, 2006 Page: 16 of 71
© 2006 MediaTek Inc.
The information contained in this document can be modified without notice.

2.5.2 Compile the Source Code Using the “make” Command
In the mcu folder, execute the following command:
make <-release|-debug> <project name> <gsm|gprs> <clean_modis|remake_modis> [modules]

Example:
make <-release|-debug> dragonfly_demo gprs remake_modis

Note: We only support building MoDIS.dsw by “make” command.
2.5.3 Compile the Source Code Using the Batch Utility
In the mcu\MoDIS folder, build the whole project using the following command:
Msdev <MoDIS.dsw|MoDIS_Custom.dsw> /MAKE “MoDIS –Win32 <Debug|Release>” [/clean]

To build a specific module:
Msdev <MoDIS.dsw|MoDIS_Custom /MAKE “<module> –Win32 <Debug|Release>” [/clean]
<put all possible command here>

2.6 Slim MoDIS
Because the MoDIS workspace is too big to be loaded by MSDEV easily, a utility MoDISReleaseCustom.pl slims
down the MoDIS project. First, MoDIS must be built successfully. Then, in the mcu\MoDIS folder, execute
MoDISReleaseCustom.pl [-release|-debug]. The result is shown in Figure 6.
Figure 6: Slim MoDIS


Select your desired modules one by one. Enter “GO” to generate the VC workspace “MoDIS_Custom.dsw”.
MoDIS_Custom.dsw is the same as MoDIS.dsw except that unselected modules are replaced with libraries.
Mobile Development Integrated System (MoDIS)
Preliminary Information High Level Design Document and User Manual
MediaTek Confidential
Revision 0.20 – August 14, 2006 Page: 17 of 71
© 2006 MediaTek Inc.
The information contained in this document can be modified without notice.

2.7 Summary of MoDIS Build Command
Description
Make command
msdev or script command
Generate, codegen,
and build MoDIS
make <-release|-debug> <project name>
<gsm|gprs> new_modis

Generate MoDIS
make <project name> <gsm|gprs>
gen_modis
createMoDIS.pl ..\make\<project
name>_<gsm|gprs>.mak
Codegen MoDIS
make <project name> <gsm|gprs>
codegen_modis
codegenMoDIS.pl ..\make\<project
name>_<gsm|gprs>.mak
Build MoDIS
make <-release|-debug> <project name>
<gsm|gprs> <remake_modis> [modules]
msdev MoDIS.dsw /MAKE “MoDIS –Win32
<Debug|Release>” [/clean]
MoDIS Level 1 release
ModisReleaseL1.pl <-release|-debug] <release dir>
MoDIS Level 2 Object
release
ModisReleaseL2obj.pl <-release|-debug].\make\<project
name>_<gsm|gprs>.mak
MoDIS Level 2 Source
release
ModisReleaseL2src.pl <-release|-debug]..\make\<project
name>_<gsm|gprs>.mak
MoDIS Vendor release
ModisReleaseVendor.pl <-release|-
debug]..\make\<project name>_<gsm|gprs>.mak
Slim MoDIS MoDISReleaseCustom.pl <-release|-debug]


2.8 Vendor Release Sample Code
The user may find sample code (source code) in mcu\plutommi\VendorApp\DevSample\DevSampleSrc.
File Name
Description
Sample_3DGame.c
Sample code for enter / exit game screen.
Sample_Audio.c
Sample code for audio APIs.
Sample_DeviceCtrl.c
Sample code for device control. LCD on/off, vibration.
Sample_Drawing.c
Sample code for drawing.
Sample_GUI.c
Sample code for timer.
Sample_Input.c
Sample code for key input and touch screen input.
Sample_Memory.c
Sample code for memory management.
Sample_Storage.c
Sample code for File System and NVRAM access.

In a Vendor release, place:
• image files in \plutommi\VendorApp\DevResource\Images,
• audio files in \plutommi\VendorApp\DevResource\Audio, and,
• Res_*.c files in plutommi\VendorApp\DevResource\Res_MM.

To generate resource, use make resgen, or execute plutommi\VendorApp\DevResource\ResGenerator.bat.

Mobile Development Integrated System (MoDIS)
Preliminary Information High Level Design Document and User Manual
MediaTek Confidential
Revision 0.20 – August 14, 2006 Page: 18 of 71
© 2006 MediaTek Inc.
The information contained in this document can be modified without notice.
3 File System
The File System software in MoDIS is a simulation and translation layer between applications (such as MMI level
features) and the Win32 File Service API. For portability, the File System API on MoDIS follows the same File System
API naming and arguments convention as on the real target.

The storage data managed by File System is translated to the specific directory tree in Win32 OS. For example, for
an image file C:\Photos\ABC.JPG in the MoDIS environment, the corresponding Win32 OS image file is in
$FS_SIM_ROOTDIR$\DRIVE_C\Photos\ABC.JPG, where $FS_SIM_ROOTDIR$ is mcu\MoDIS\WIN32FS by default.

3.1 Overview
The source code layout in File System:
• FileSystemInc/fssim_def.h: File System Simulator internal structure definitions.
• FileSystemSrc/fssim_data.c: File System Simulator global data declarations.
• FileSystemSrc/fssim_core.c: File System Simulator source code. Common functions are placed in the first
half of the file. The FS_XXX API functions are in the latter half.

Note that the File System API interface definition is not listed above. The interface is synchronized with the target
source and defined in:
• kal/Efs/include/fs_fat.h: Standard header file for all File System interface and related structure definitions.

When initializing, File System Simulator tries to locate $FS_SIM_ROOTDIR$ first, then checks that the drive
subfolder (such as DRIVE_C) is accessible. If not found, the drive subfolder is created.

$FS_SIM_ROOTDIR$ is located by the relative path setting of the execution binary (.exe). The relative path setting is
FSSIM_RELATIVE_PATH_FOR_ROOT_DIR, defined as “..\..\WIN32FS” in the FileSystemInc/fssim_def.h header file.

$FS_SIM_ROOTDIR$ can be overridden by the MoDIS.ini run-time configuration file. The default value is an empty
string, which turns off the override feature. To overwrite $FS_SIM_ROOTDIR$ at run-time, modify the value
Local_Map_Path in the File System section of MoDIS.ini. For example:

[FileSystem]
Local_Map_Path = D:\WorkSpace\FileSystem\TestBed\

If $FS_SIM_ROOTDIR$ is not properly configured and location of the directory fails, check the console message to
determine whether the INI run-time configuration is applied first, then check the configured path accessible on your
local PC.

3.2 Design
From the application software perspective, the file and directory operations are processed by Win32 OS, not MoDIS
File System.

From the storage manager perspective, the disk geometry information is pre-configured and simulated on MoDIS File
System since Win32 OS cannot provide pseudo-information.
Mobile Development Integrated System (MoDIS)
Preliminary Information High Level Design Document and User Manual
MediaTek Confidential
Revision 0.20 – August 14, 2006 Page: 19 of 71
© 2006 MediaTek Inc.
The information contained in this document can be modified without notice.

The user can configure the total disk space. A simple “fssim_drvinfo[ ]” array entry in fssim_data.c is:

{ DriveLetter, , , DEVICE_TYPE, SectorSize(512), SectorsPerCluster(4), TotalClusters = Disk Size, , }

The default is 3 disks, pre-configured as shown in Table 2.
Table 2: Default Disk Space Configuration
Drive Letter
Storage Type
Disk Size
Note
Default Drive
C:\ NOR Flash 2154 kB System Drive Yes
D:\ NAND Flash 135 MB Public Drive No
E:\ Card 135 MB Removable No

Note that the system drive is not visible from MoDIS (Main Menu  File Manager Application). But the system drive is
accessible via the MoDIS application File System API.

3.3 Interfaces/API
MoDIS File System attempts to simulate the File System API as closely as possible and maintain full portability for
different operating systems. However, some core information cannot be handled due to potential limitation. In this
section, we focus on the differences. For more details on File System API, refer to the File System documentation.

3.3.1 FS_OpenHint() does not speed up.
The hint parameter in FS_OpenHint() is discarded, because disk geometry information is unavailable in a simulation
environment.

3.3.2 FS_Extend() does not allocate any clusters.
Each drive has a watermark, and the “disk space” is pre-defined in fssim_drvinfo[]. FS_Extend() checks if the file
extend operation runs out of disk space. However, the watermark is not changed after this call. On a real target, the
cluster is allocated and disk free space is subtracted in the target environment. In the MoDIS simulator, FS_Extend()
cannot allocate any clusters and thus has no effect.

Note that the FS_Extend() function has not been modified.

3.3.3 FS_SetSeekHint() does nothing.
On the target, FS_SetSeekHint() speeds up random access, especially useful for large files. However, because of the
lack of disk geometry information, the function becomes meaningless here. In fact, the access performance on
simulator is determined by Windows.

3.3.4 FS_GetFirstClusterValue() returns a random integer.
The real first cluster value cannot be retrieved because disk geometry information is unavailable in the simulation
environment. Instead, we return a consistent pseudo-random value associated with the file. The value is calculated
from the lower 32 bits of the 64-bit file creation time. Two files may have the same value but the possibility is low.
Mobile Development Integrated System (MoDIS)
Preliminary Information High Level Design Document and User Manual
MediaTek Confidential
Revision 0.20 – August 14, 2006 Page: 20 of 71
© 2006 MediaTek Inc.
The information contained in this document can be modified without notice.

3.3.5 FS_CheckFile() does nothing.
In the simulator environment, all files are quite ideal and FAT-Chain problems do not occur.

3.3.6 FS_GetFolderSize() calculates size on ideal folder assumption.
In the target environment, folder entries typically contain fractional holes after many folder creations and deletions.
These holes contribute to disk usage. In the simulation environment, folder sizes are calculated based on ideal folder
sizes: fractional holes are neglected.

3.3.7 FS_QmGetFree() is based on pseudo disk space calculation.
Because of inaccurate disk space updates, the simulator and target environments may report slightly different disk
spaces. For example, if many empty files are opened under the quota monitoring folder (e.g. Z:\@USER), the quota
is not decreased on the simulator but does occupy disk space on the target side.

3.3.8 FS_Abort() cannot abort FS_CheckDrive() and FS_XDelete().
This function is not implemented because FS_CheckDrive() is an empty function, and FS_XDelete() cannot be
stopped in the Windows API.

3.3.9 FS_GetDevStatus() does not support the FS_FEATURE_STATE_ENUM query.
FS_FEATURE_STATE_ENUM is used in the target to query the device status, like whether the device is busy or not.
However, the query is not supported in this simulated API.

3.3.10 FS_TestMSDC() always returns FS_MSDC_NOT_PRESENT.
The SIM card plug-in/out mechanism is not supported.

3.3.11 FS_CloseMSDC() is an empty function.
The SIM card plug-in/out mechanism is not supported.

3.3.12 FS_CreateBootSector() always returns 32 (meaning FAT32).
In a simulated environment, disk geometry and partition information are not required, nor available.

3.3.13 FS_GetPartitionInfo() fills fake data.
In simulated environment, disk geometry and partition information are not required, nor available. The data request
structure is filled with dummy data.

3.3.14 FS_CheckDrive() is an empty function.
In the simulated environment, the disk geometry information is unavailable and no FAT problems occur.
Mobile Development Integrated System (MoDIS)
Preliminary Information High Level Design Document and User Manual
MediaTek Confidential
Revision 0.20 – August 14, 2006 Page: 21 of 71
© 2006 MediaTek Inc.
The information contained in this document can be modified without notice.

3.3.15 FS_CreateMasterBootRecord() is an empty function.
In a simulated environment, disk geometry and partition information are not required, nor available.

3.3.16 FS_SplitPartition() is an empty function.
In a simulated environment, disk geometry and partition information are not required, nor available.

3.3.17 FS_Shutdown() is an empty function.
This function is not supported in the simulator.

3.3.18 FS_UnlockAll() is an empty function.
This function is not supported in the simulator.

3.3.19 FS_SanityCheck() tries to trigger fssim_init() only.
The FS_SanityCheck function attempts to trigger fssim_init(), the first File System API function called on the target. In
the simulation environment, power loss recovery is unnecessary and unavailable. FS_SanityCheck() only provides
the initialization function.

3.3.20 FS_SetDiskFlag() is an empty function.
This function is not supported in the simulator.

3.3.21 FS_CheckDiskFlag() is an empty function.
This function is not supported in the simulator.

3.3.22 FS_ClearDiskFlag() is an empty function.
This function is not supported in the simulator.

3.3.23 FS_LockFAT() is an empty function.
This function is not supported in the simulator.

3.3.24 FS_SetTrace() is an empty function.
This function is not supported in the simulator.

3.3.25 FS_DumpFHTable() is an empty function.
This function is not supported in the simulator.

Mobile Development Integrated System (MoDIS)
Preliminary Information High Level Design Document and User Manual
MediaTek Confidential
Revision 0.20 – August 14, 2006 Page: 22 of 71
© 2006 MediaTek Inc.
The information contained in this document can be modified without notice.
3.3.26 FS_SetDirCache() is an empty function.
This function is not supported in the simulator.

3.3.27 FS_GetDirCache () always returns FS_DIRCACHE_EXPIRED.
This function is not supported in the simulator.

3.3.28 FS_OTPRead() is an empty function.
This function is not supported in the simulator.

3.3.29 FS_OTPWrite() is an empty function.
This function is not supported in the simulator.

3.3.30 FS_OTPQueryLength() is an empty function.
This function is not supported in the simulator.

3.3.31 FS_SweepDevice() is an empty function.
This function is not supported in the simulator.


Mobile Development Integrated System (MoDIS)
Preliminary Information High Level Design Document and User Manual
MediaTek Confidential
Revision 0.20 – August 14, 2006 Page: 23 of 71
© 2006 MediaTek Inc.
The information contained in this document can be modified without notice.
4 Network Ability
4.1 Socket
The Socket software in MoDIS is a simulation and translation layer between applications and the Win32 Socket
Service API. For portability, the Socket API on MoDIS follows the same Socket API naming and arguments
convention as on the real target.

4.1.1 Overview
The source code layout in Socket:
• drv_sim/src/w32_socket: Socket simulator source code.

Note that the Socket API interface definition is not listed above. The interface is synchronized with the target source
and defined in:
• interface/ps/soc_api.h: Standard header file for all socket interface and related structure definitions.

4.1.2 Design
From the applications’ perspective, a socket on MoDIS is the same as a socket on the target (Figure 7).
Figure 7: Socket Simulator
Applications
Socket Simulator
Win32 Socket Layer
Mutex Protection
Socket APIs
Socket Primitives


• Socket simulator has the following properties:
○ Mutex protection for concurrent SOC API access by different applications.
○ Periodically polling for any incoming data, connections, and exceptions.

Mobile Development Integrated System (MoDIS)
Preliminary Information High Level Design Document and User Manual
MediaTek Confidential
Revision 0.20 – August 14, 2006 Page: 24 of 71
© 2006 MediaTek Inc.
The information contained in this document can be modified without notice.
To dump socket debug information (e.g. data sent or received), the user can define SOC_DBG_ENABLE in
drv_sim/w32_socket.c:
/* To print dbg info in console, turn on SOC_DBG_ENABLE */
//#define SOC_DBG_ENABLE /* off by default */

Restriction: The header file “includes” for using Socket simulator in Plutommi are ordered.

#ifndef __MTK_TARGET__
#include <windows.h>
#endif

…. /* include other files */

#include “PixteDataTypes.h” /* MMIDataType.h for 06A / maintrunk */

…. /* include other files */

#include “soc_api.h”

…. /* include other files */

4.1.3 Interfaces/API
4.1.3.1 soc_create()
The soc_create() function does not support the RAW socket type.
SMS socket types are accepted but operations are not executed for SMS sockets.
Data account IDs are not verified; data accounts are not considered in MoDIS.

4.1.3.2 soc_shutdown() is an empty function.
This function is not supported in simulator.

4.1.3.3 soc_select() is an empty function.
This function is not supported in simulator.

4.1.3.4 soc_setsockopt() only supports SOC_NBIO and SOC_ASYNC.
Socket ignores options other than SOC_NBIO and SOC_ASYNC.

4.1.3.5 soc_getsockopt() only supports SOC_NBIO and SOC_ASYNC.
Socket ignores options other than SOC_NBIO and SOC_ASYNC.

Mobile Development Integrated System (MoDIS)
Preliminary Information High Level Design Document and User Manual
MediaTek Confidential
Revision 0.20 – August 14, 2006 Page: 25 of 71
© 2006 MediaTek Inc.
The information contained in this document can be modified without notice.
4.1.3.6 soc_gethostbyname() only blocking is supported.
Only blocking in this function is supported.

4.1.3.7 soc_gethostbyaddr() is an empty function.
This function is not supported in simulator.

4.1.3.8 soc_get_last_error() is an empty function.
This function is not supported in simulator.

4.1.3.9 soc_set_last_error() is an empty function.
This function is not supported in simulator.

4.1.3.10 soc_abort_dns_query() is an empty function.
This function is not supported in simulator.

Mobile Development Integrated System (MoDIS)
Preliminary Information High Level Design Document and User Manual
MediaTek Confidential
Revision 0.20 – August 14, 2006 Page: 26 of 71
© 2006 MediaTek Inc.
The information contained in this document can be modified without notice.
5 Driver Simulating
5.1 UART
5.1.1 Overview
MoDIS can simulate target UART functionality. The UART API functions are the same as those on the target, so
modules can use the same code to access UART functions in MoDIS.

By connecting to the COM port on the PC, modules can send and receive data from UART. The mapping between
the target UART and PC COM port is defined in MoDIS.ini. Users can use a null modem device or virtual COM driver
to make the connection. For example, if COM3 and COM4 are connected by virtual COM driver, users can set COM3
for target UART1, and open COM4 for “Hyper Terminal”. L4C on the target receives AT commands issued via “Hyper
Terminal”.
5.1.2 Design
The source file of UART Simulator is “MoDIS\drv_sim\src\w32_uart.c”. UART Simulator reads the INI file and uses
Win32 Communication API to access the COM port on the PC. The COM port, baud rate and flow control are set in
the INI file. The format of the file is:

[UART1]
COM_PORT = COM3
flowcontrol = 1
baud_rate = 115200

Section [UART1] is the UART number on the target. Usually the target has three UARTs, so the INI file has three
sections UART1, UART2, and UART3. Property COM_PORT is the COM port number on the PC and can be either a
real or a virtual COM port. An MTK tool named “VComConsole.exe” can be used to create a virtual COM port pair on
the PC.

Property flowcontrol sets the flow control mode of the COM port (0: no flow control, 1: hardware, 2: software).
Property baud_rate sets the baud rate. When UART_Open is called, UART Simulator uses the mapping in the INI file
to open the COM port.

5.1.3 Virtual COM Port
Users can use VComConsole.exe to create a virtual COM port pair on the PC. MoDIS only requires one COM port;
the other port can be used for another program. Follow the steps to use virtual COM port.

1. Run VComConsole.exe and create one virtual COM pair, ex. COM3 and COM4.
2. Modify MoDIS.ini, and set COM3 to UART1.
3. Run MoDIS.
4. Run Hyper Terminal and connect to COM4.
5. The user can send AT commands to MoDIS using Hyper Terminal.

Mobile Development Integrated System (MoDIS)
Preliminary Information High Level Design Document and User Manual
MediaTek Confidential
Revision 0.20 – August 14, 2006 Page: 27 of 71
© 2006 MediaTek Inc.
The information contained in this document can be modified without notice.
5.1.4 Interfaces/API
The MoDIS UART API is the same as the target’s, and some functions that are not suitable for MoDIS are empty. The
following functions are implemented in the MoDIS environment.

5.1.4.1 UART_Open
kal_bool UART_Open(UART_PORT port, module_type owner)

This function allocates memory in UART driver, refreshes UART FIFO, enables the UART interrupt, etc. This function
must also be called before any action accessing the UART interface.

Parameters:
Members
Description
port UART port.
owner Owner id. The owner after the port is opened.

Return Value:
Return value
Description
KAL_TRUE (1) UART can be opened successfully.
KAL_FALSE (0) UART cannot be opened successfully.

Example:
None

5.1.4.2 UART_Close
void UART_Close (UART_PORT port)

This function frees any memory allocated by UART_Open, disables UART interrupt, etc. This function is called when
the UART owner no longer wishes to use the UART port.

Parameters:
Members
Description
port UART port.

Return Value:
None

Example:
None

5.1.4.3 UART_GetBytes
kal_uint16 UART_GetBytes (UART_PORT port, kal_uint8 *Buffaddr, kal_uint16 Length, kal_uint8 *status,
module_type ownerid)

This function receives data from the UART. This interface returns the actual length of the received bytes.
Mobile Development Integrated System (MoDIS)
Preliminary Information High Level Design Document and User Manual
MediaTek Confidential
Revision 0.20 – August 14, 2006 Page: 28 of 71
© 2006 MediaTek Inc.
The information contained in this document can be modified without notice.

Parameters:
Members
Description
port UART port.
Buffaddr Pointer to the data addr.
Length maximum length
status Bit 0
=1, Escape sequence is detected.
=0, Escape sequence is not detected.
Bit 1
=1, Break signal is detected.
=0, Break signal is detected.
NOTE:
1.When the escape sequence/break signal is detected, data in the RX/TX
buffer is cleared.
2.When the escape sequence is detected, the next call of UART_GetBytes
returns no data but the escape sequence detected status flag is toggled.
ownerid UART owner id

Return Value:
The actual length of the received bytes.

Example:
None

5.1.4.4 UART_PutBytes
kal_uint16 UART_PutBytes(UART_PORT port, kal_uint8 *Buffaddr, kal_uint16 Length, module_type ownerid)

This function sends data to UART. This interface returns the actual length of the transmitted bytes.

Note: This function is only called at the task level.

Parameters:
Members
Description
port UART port.
Buffaddr Pointer to the data addr.
Length The maximum length
ownerid UART owner id

Return Value:
The actual length of the transmitted bytes.

Example:
None

Mobile Development Integrated System (MoDIS)
Preliminary Information High Level Design Document and User Manual
MediaTek Confidential
Revision 0.20 – August 14, 2006 Page: 29 of 71
© 2006 MediaTek Inc.
The information contained in this document can be modified without notice.
5.1.4.5 Message MSG_ID_UART_READY_TO_WRITE_IND
Description:
This primitive notifies the UART owner to write data to the driver.

Local Parameter:
Members
Type
Description
ref_count kal_uint8 Reference count
meg_len kal_uint16 Total length of the message
Port UART_PORT UART port

Reference:
N/A

5.1.4.6 Message MSG_ID_UART_READY_TO_READ_IND
Description:
This primitive notifies the UART owner to read data from the driver. The primitive is sent by the UART driver in the
following two cases:

1. Any character is received after UART port is opened; and,
2. UART RX ring buffer contains less characters than the size requested by UART owner.

Important note: read characters from the UART RX ring buffer until the buffer does not contain enough characters
every time or the UART_READY_TO_READ_IND indication ceases to be sent.

Local Parameters:
Members
Type
Description
Ref_count kal_uint8 Reference count
meg_len kal_uint16 Total length of message.
port UART_PORT UART port.

Reference:
N/A

Mobile Development Integrated System (MoDIS)
Preliminary Information High Level Design Document and User Manual
MediaTek Confidential
Revision 0.20 – August 14, 2006 Page: 30 of 71
© 2006 MediaTek Inc.
The information contained in this document can be modified without notice.

5.2 SIM Simulator
5.2.1 Overview
The MoDIS SIM Simulator emulates the physical layer of the SIM card in a WIN32 environment. The SIM card can be
seen as an external security and storage device of ME. The file identifiers and directory structures of the SIM card, as
defined in 3GPP TS 51.011, are listed as below in Figure 8.
Figure 8: File Identifiers and Directory Structures of GSM


Mobile Development Integrated System (MoDIS)
Preliminary Information High Level Design Document and User Manual
MediaTek Confidential
Revision 0.20 – August 14, 2006 Page: 31 of 71
© 2006 MediaTek Inc.
The information contained in this document can be modified without notice.
In MoDIS, the dedicated files and the elementary files stored on the SIM card are mapped to the directories and files
in the WIN32 file system. The directory and file names in WIN32 file system are mapped to the file identifiers of the
files stored on the SIM card. The files are listed in Figure 9.
Figure 9: Directory and File Structures of the SIM Card in MoDIS WIN32 Environment


The SIM card file structures are mapped to the WIN32 file structures, allowing the SIM task to access the SIM files in
the MoDIS environment (WIN32 file system) using similar procedures as accessing the SIM card files in a real target
environment.

5.2.2 Design
To achieve seamless file access of the SIM task between WIN32 and target environments, the MoDIS SIM simulator
adopts the SIM driver level from function L1sim_Cmd_All( ), and simulates the SIM card functions according to the
3GPP TS 51.011 specification. The interface architectures of the SIM task in both target and WIN32 environments are
shown in Figure 10.
Figure 10: Interface Architectures of the SIM Task in Target and in WIN32 Environments


Mobile Development Integrated System (MoDIS)
Preliminary Information High Level Design Document and User Manual
MediaTek Confidential
Revision 0.20 – August 14, 2006 Page: 32 of 71
© 2006 MediaTek Inc.
The information contained in this document can be modified without notice.
The default path for the MoDIS SIM card files is \mcu\MoDIS\WIN32FS\SIM_CARD. Two folders and one file are
stored under this directory:

• SIM folder: Stores the SIM-related directories and files.
• USIM folder: Stores the USIM-related directories and files.
• Config.bin: Configures the MoDIS SIM simulator if a SIM or USIM is inserted.
Config.bin has two templates:
o SIM: Config_sim.bin
o USIM: Config_usim.bin (not yet supported)
From MoDIS starting up, the SIM task loads this file to set the default directory to SIM or USIM.

5.2.2.1 MoDIS SIM Simulator Design
In MoDIS SIM Simulator, only part of the API defined in 3GPP TS 51.011 is supported. The basic functions which
access the SIM card files are supported, listed below in Table 3.
Table 3: Supported Functions in MoDIS SIM Simulator
CLA INS
SELECT FILE A0 A4 MSG_ID_SIM_FILE_INFO_REQ (CNF) L1sim_select( )
STATUS A0 F2 MSG_ID_SIM_STATUS_REQ (CNF) L1sim_status( )
READ BINARY A0 B0 L1sim_read_binary( )
READ RECORD A0 B2 L1sim_read_record( )
UPDATE BINARY A0 D6 L1sim_update_binary( )
UPDATE RECORD A0 DC L1sim_update_record( )
SEARCH RECORD A0 A2 MSG_ID_SIM_SEEK_REQ (CNF) Not support
INCREASE A0 32 MSG_ID_SIM_INCREASE_REQ (CNF) Not support
VERIFY A0 20 Not support
CHANGE PIN A0 24 Not support
DISABLE PIN A0 26 Not support
ENABLE PIN A0 28 Not support
UNBLOCK PIN A0 2C Not support
DEACTIVATE FILE A0 04 Not support
ACTIVATE FILE A0 44 Not support
AUTHENTICATE A0 88 MSG_ID_SIM_RUN_ALGO_REQ (CNF) Not support
GET CHALLENGE Not support
TERMINAL PROFIL
E
A0 10 Not support
ENVELOPE A0 C2 Not support
FETCH A0 12 MSG_ID_SAT_PROACTIVE_CMD_IND Not support
TERMINAL RESPO
N
A0 14 Not support
MANAGE CHANNE
L
Not support
GET RESPONSE A0 C0 L1sim_get_response( )
SLEEP A0 FA Not support
MoDIS SIM SimulatorSIM MESSAGE
MSG_ID_SIM_READ_REQ (CNF)
MSG_ID_SIM_WRITE_REQ (CNF)
COMMAND
SIM
MSG_ID_SIM_SECURITY_REQ (CNF)


Mobile Development Integrated System (MoDIS)
Preliminary Information High Level Design Document and User Manual
MediaTek Confidential
Revision 0.20 – August 14, 2006 Page: 33 of 71
© 2006 MediaTek Inc.
The information contained in this document can be modified without notice.
5.2.2.2 SIM Card Files on WIN32 File System
The basic file type of MoDIS SIM Simulator is a binary file in WIN32 file system with two parts, illustrated in Figure 11.
Figure 11: Basic File Structure of a MoDIS SIM File


• META data (256 bytes)
The META data contains the file’s basic file information.
Structure Name
Types
Members
Descriptions
kal_char file_name[16] e.g. EF_ADN
kal_uint8 path[6] e.g. 7F10 6F3A
kal_uint8 fcp_length Length of file control parameters
uicc_file_meta_struct
kal_uint8 fcp_tmp[233] File control parameters

• File data (n bytes)
The file data contains the raw data stored on the SIM card.

5.2.2.3 Mapping of SIM File Structure to WIN32 File System
Two categories of files are defined in 3GPP TS 51.011:
• Dedicated files (DF) map to folders in the WIN32 file system.
• Elementary files (EF) map to files in the WIN32 file system.

The file structure mapping of the WIN32 file system is listed in Table 4:
Table 4: SIM Card File to WIN32 File Mapping
File type
SIM file
Description
Maps to (WIN32 file)
3F00 Master file (root) Folder ‘3F00’ with a file ‘3F00’ containing META data
(get response data) for the ‘3F00’ folder
7FXX 1
st
level DF Folder ‘7FXX’ with a file ‘7FXX’ containing META data
(get response data) for the ‘7FXX’ folder
Dedicated file
(DF)
5FXX 2
nd
level DF Folder ‘5FXX’ with a file ‘5FXX’ containing META data
(get response data) for the ‘5FXX’ folder
2FXX EF under Master file File ‘2FXX’ under the folder ‘3F00’
6FXX EF under 1
st
level DF File ‘6FXX’ under the folder ‘7FXX’
Elementary file
(EF)
4FXX EF under 2
nd
level DF File ‘4FXX’ under the folder ‘5FXX’

Mobile Development Integrated System (MoDIS)
Preliminary Information High Level Design Document and User Manual
MediaTek Confidential
Revision 0.20 – August 14, 2006 Page: 34 of 71
© 2006 MediaTek Inc.
The information contained in this document can be modified without notice.
5.2.2.4 Details WIN32 File Structures of 3 Types of SIM Elementary Files
Three file types are defined in 3GPP TS 51.011. The file structures of each file are listed below:

• Transparent EF
A Transparent EF maps to a WIN32 binary file with 256 bytes META data followed by n bytes of file content.
Figure 12: WIN32 File Structure of a Transparent EF


• Linear Fixed and Cyclic EFs
Linear fixed and cyclic EFs map to a WIN32 binary file with 256 bytes of META data, followed by x records. Each
record contains an n-byte record length and has a maximum record length of 256 bytes.
Figure 13: WIN32 File Structure of a Linear Fixed EF or a Cyclic EF


5.2.2.5 Add a New SIM File to the MoDIS SIM Simulator
1. Create a new file from an existing SIM file.
For example, to create a linear fixed EF, copy the file from EF_ADN (6F3A under 7F10). To create a transparent
EF, copy the file from EF_IMSI (6F07 under 7F20).
2. Modify the META fields to the correct settings.
a. Change the FILE NAME in the META field (bytes 0~15).
b. Change the PATH information in the META field (bytes 16~21).
c. Change the FCP length if needed. (byte 22).
d. Change the FCP tmp (bytes 23~255).
3. Modify the DATA field according to the file content defined in 3GPP TS 51.011.
Mobile Development Integrated System (MoDIS)
Preliminary Information High Level Design Document and User Manual
MediaTek Confidential
Revision 0.20 – August 14, 2006 Page: 35 of 71
© 2006 MediaTek Inc.
The information contained in this document can be modified without notice.

Figure 14 shows an example of EF
ICCID
(2FE2).
Figure 14: Details of File Content of EF
ICCID

00000000h:0x45 0x46 0x5F 0x49 0x43 0x43 0x49 0x44 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 File name: EF_ICCID
00000010h:0x2F 0xE2 0x00 0x00 0x00 0x00 0x0F 0x00 0x00 0x00 0x0A 0x2F 0xE2 0x04 0x00 0x04 Path; fcp length; fcp tmp
00000020h:0x00 0x44 0x01 0x01 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
00000030h:0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
00000040h:0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
00000050h:0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
00000060h:0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
00000070h:0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
00000080h:0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
00000090h:0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
000000a0h:0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
000000b0h:0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
000000c0h:0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
000000d0h 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
000000e0h:0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
000000f0h:0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
00000100h:0x98 0x88 0x96 0x07 0x02 0x05 0x27 0x01 0x01 0x22 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF Data filed of ICCID
00000110h:0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF
000001d0h:0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF
000001e0h:0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF
000001f0h:0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF
……


4. Detail of fcp_tmp array

fcp tmp[0-1] = RFU
fcp tmp[2-3] = File Size
fcp tmp[4-5] = File ID
fcp tmp[6] = Type of File
fcp tmp[7] = See Note1
fcp tmp[8-10] = Access Condition
fcp tmp[11] = File Status
fcp tmp[12] = Length of the Following Data
fcp tmp[13] = Structure of EF
fcp tmp[14] = Length of a record

Note1: For transparent and linear fixed EFs this byte is RFU. For a cyclic EF all bits except bit 7 are RFU. b7=1
indicates that the INCREASE command is allowed on the selected cyclic file


Example: Transparent EF
Mobile Development Integrated System (MoDIS)
Preliminary Information High Level Design Document and User Manual
MediaTek Confidential
Revision 0.20 – August 14, 2006 Page: 36 of 71
© 2006 MediaTek Inc.
The information contained in this document can be modified without notice.









Example: Linear Fixed EF

Mobile Development Integrated System (MoDIS)
Preliminary Information High Level Design Document and User Manual
MediaTek Confidential
Revision 0.20 – August 14, 2006 Page: 37 of 71
© 2006 MediaTek Inc.
The information contained in this document can be modified without notice.



Mobile Development Integrated System (MoDIS)
Preliminary Information High Level Design Document and User Manual
MediaTek Confidential
Revision 0.20 – August 14, 2006 Page: 38 of 71
© 2006 MediaTek Inc.
The information contained in this document can be modified without notice.

5.2.3 Interfaces/API
5.2.3.1 L1sim_Reset_All ( )
This function loads the default settings of the MoDIS SIM Simulator.
5.2.3.2 L1sim_Cmd_All ( )
This function dispatches the SIM commands to the corresponding handler (Figure 15).
Figure 15: Interfaces of L1sim_Cmd_All( )

Mobile Development Integrated System (MoDIS)
Preliminary Information High Level Design Document and User Manual
MediaTek Confidential
Revision 0.20 – August 14, 2006 Page: 39 of 71
© 2006 MediaTek Inc.
The information contained in this document can be modified without notice.
5.2.3.3 L1sim_Enable_Enhanced_Speed_All ( )
This function is a dummy function in the MoDIS SIM simulator and always returns true.
5.2.3.4 L1sim_Get_Card_Info_All ( )
This function is a dummy function in the MoDIS SIM simulator.
5.2.3.5 L1sim_PowerOff_All ( )
This function is a dummy function in the MoDIS SIM simulator.
5.2.3.6 L1sim_Set_ClockStopMode_All ( )
This function is a dummy function in the MoDIS SIM simulator.

5.3 LCD Interfaces
5.3.1 Overview
The LCD interface in MoDIS simulates the standard API for the upper layer application to develop its image display.
The LCD interface in MoDIS simulates the operation of LCD hardware interface of target. The LCD can overlay
multiple layers of the frame buffers and display the result on a simulated LCM on the PC. The interface also supports
source key and opacity functions. The source key color is set for each layer. In such a case, if an upper layer’s color
matches the source key color, the overlaid color of the lower layers is the output color until that layer. The opacity
function executes an alpha blending operation of layers if their opacity function is enabled.

Layer rotation is also applied in the LCD interface. Generally, a rotation of 270 degrees is sufficient (for rotating
between landscape and portrait). In MoDIS, only a 270-degree rotation is supported. The update area of the
simulated LCM can be assigned for simulating a real case.
Figure 16: LCD Interface

Mobile Development Integrated System (MoDIS)
Preliminary Information High Level Design Document and User Manual
MediaTek Confidential
Revision 0.20 – August 14, 2006 Page: 40 of 71
© 2006 MediaTek Inc.
The information contained in this document can be modified without notice.

5.3.2 Design
The source file of the LCD interface simulator is “Plutommi\mtkapp\GDI\GDIsrc\gdi_win32_lcd.c”.
5.3.2.1 lcd_layer_struct
Definition:
typedef struct
{
kal_bool layer_update_queue;
kal_bool source_key_enable;
kal_bool color_palette_enable;
kal_bool opacity_enable;
kal_uint8 source_color_format; /* For MT6628 and MT6229 */
kal_uint8 color_palette_select;
kal_uint8 opacity_value;
kal_uint8 rotate_value;
kal_uint16 x_offset;
kal_uint16 y_offset;
kal_uint16 row_number;
kal_uint16 column_number;
kal_uint16 source_key;
kal_uint32 frame_buffer_address;
kal_uint
} lcd_layer_struct;

Members:
Members
Description
layer_update_queue Whether or not the LCD layer parameter queue is activated.
(For MT6218B and MT6217 only.)
source_key_enable Enable or disable the source key for the specified layer.
color_palette_enable Enable or disable the color palette for the specified layer.
opacity_enable Enable or disable the opacity feature for the specified layer.
color_palette_select Color palette table selection
source_color_format Color format of source data for the specified layer. (For MT6228 only.)
opacity_value Opacity value for the specified layer.
rotate_value Rotate select for the specified layer. (For MT6219 only.)
x_offset X-axis offset from the main window for the specified layer.
y_offset Y-axis offset from the main window for the specified layer.
row_number Buffer height of the specified layer.
column_number Buffer width of the specified layer.
frame_buffer_address Frame buffer start address of the specified layer.
source_key Source key color for the specified layer.

Note1: layer_update_queue does not need to be set to any value.
Note2: If LCD_MAX_OPACITY is not set, opacity_value is in the range 0 to 31. Otherwise, opacity_value is in the
range 0 to 255.
Mobile Development Integrated System (MoDIS)
Preliminary Information High Level Design Document and User Manual
MediaTek Confidential
Revision 0.20 – August 14, 2006 Page: 41 of 71
© 2006 MediaTek Inc.
The information contained in this document can be modified without notice.
Note3: color_palette_select is LCD_COLOR_PALETTE0 or LCD_COLOR_PALETTE1.
Note4: rotate_value is one of the following values:
LCD_LAYER_ROTATE_NORMAL
LCD_LAYER_ROTATE_90
LCD_LAYER_ROTATE_180
LCD_LAYER_ROTATE_270
LCD_LAYER_MIRROR
LCD_LAYER_MIRROR_ROTATE_90
LCD_LAYER_MIRROR_ROTATE_180
LCD_LAYER_MIRROR_ROTATE_270
(Currently, only LCD_LAYER_ROTATE_270 is implemented in MoDIS.)
Note5: For MT6228 and MT6229, source_color_format is one of the following values:
LCD_LAYER_INDEX_COLOR