外文文献翻译嵌入式.docx

上传人:牧羊曲112 文档编号:5089995 上传时间:2023-06-03 格式:DOCX 页数:20 大小:148.26KB
返回 下载 相关 举报
外文文献翻译嵌入式.docx_第1页
第1页 / 共20页
外文文献翻译嵌入式.docx_第2页
第2页 / 共20页
外文文献翻译嵌入式.docx_第3页
第3页 / 共20页
外文文献翻译嵌入式.docx_第4页
第4页 / 共20页
外文文献翻译嵌入式.docx_第5页
第5页 / 共20页
亲,该文档总共20页,到这儿已超出免费预览范围,如果喜欢就下载吧!
资源描述

《外文文献翻译嵌入式.docx》由会员分享,可在线阅读,更多相关《外文文献翻译嵌入式.docx(20页珍藏版)》请在三一办公上搜索。

1、期向理工年院毕业设计翻译文献文献题目:Construction of Embedded System Platform whichBased on pC/OS- II and ARM7 Kernel Microprocessor 构建基于日C/ OS- 和ARM7内核微处理器的嵌入式系统平台摘 要今天,嵌入式系统被广泛地应用于各行各业。引入嵌入式操作系统在嵌入式 发展中已经是一种趋势。嵌入式操作系统能够适用于不同的系统硬件,并能够显 著的减少开发费用,缩短研究周期。pC/ OS-II是一款优秀的开源,轻型内核, 占用少量资源并且在实时性方面有着高性能的嵌入式操作系统。pC/ OS-II适用 于

2、越来越多的32位ARM7核微处理器,本文介绍了基于ARM7微处理器的pC/ OS-II嵌入式操作系统的移植方法。最终实现了构建基于pC/ OS-II和ARM7内 核处理器的嵌入式开发平台。该平台能有效的简化软件程序开发流程,并缩短工 程研究的周期和显著提高系统的执行效率。关键字:嵌入式系统;嵌入式操作系统;ARM7内核;pC/ OS-II一、介绍所谓的操作系统移植是一个实时操作系统内核可以在运行在其他微处理器 上。移植部分对于不同的CPU具有对应的不同的代码。大多数pC/OS-II代码 是用C编程语言编写的,这对于移植pC / OS -11是非常方便的。但根据不同的微 处理器,用户仍然需要使用

3、汇编语言编写一些有关不同微处理器的硬件的程序。 这是因为当pC / OS-II读或写寄存器时,它只依赖于汇编语言。因为pC / OS - II操作系统的要求,有三个文件需要当pC / OS - II移植到一个 特定的微处理器。整个移植工作主要围绕创建这三个文件。这些文件显示如下:1、在C语言中的头文件OS_CPU中,一些与编译器无关的数据 类型需要定义OS_CPU中。这些数据类型包括使用的堆栈数据类型和堆栈的增长方向。一些与ARM7内核 相关的软件中断也被定义在该文件中。2、另一个OS_CPU_C.C是一个C源文件程序。该文件主要包括pC / OS- II的 任务堆栈的初始化函数和一些被pC

4、/ OS- II操作系统调用的用户函数。3、最后一个OS_CPU_A.S文件是一个汇编程序源文件。这是一个时钟中断服 务函数在运行的时候,也包含了一个用于引起中断的任务切换函数,并且也具有 总是运行最高优先级的任务当pC / OS-II系统首次进入多任务环境时。二、创建OS_CPU.H文件A、定义与编译器有关的数据类型因为不同的微处理器有不同的字长度,所以pC / OS- II的移植包含一系列的 数据类型的定义,这使移植能够实现。尤其是在C语言中使用的数据类型,例如短 型、整型、长型等等,这些数据类型不能直接用于pC / OS-II。因为这些数据类型 与编译器类型有关,它们不能被移植。所以这些

5、数据类型都定义为整型数据结构, 在许多情况下,他们是可移植的。B、系统软中断函数的定义中断是一种硬件机制,但在pC / OS - II操作系统,一些重要的任务函数的实现 应该取决于中断级的代码。所以,这种情况下,pC / OS-II操作系统需要一条预处 理器指令来模拟中断。它类似于一个硬件中断,所以它被称为软中断。大多数微 处理器的内核可以提供这种类型的软中断指令。在ARM7内核,它是“SWI”。为了使底层接口函数是独立的处理器状态并且底层任务函数不需要知道调用函 数的准确的地址当任务被调用时。SWI指令应该用作底层接口。并且不同的函数 能够通过不同的软件中断函数编号的方法进行区分。ADS1.

6、2编译器总是使用“_swi”来声明一个不存在的函数。而一旦不存在的函数被调用时,一条SWI的指 令应该插入调用函数并指定函数编号的位置。这里显示一些在pC / OS-II中重要 功能的软中断函数_swi(0x00) void OS_TASK_SW(void); 在任务间切换功能_swi(0x01) void _OSStartHighRdy(void); 首先运行最高优先级任务_swi(0x02) void OS_ENTER_CRITICAL(void); 关中断_swi(0x03) void OS_EXIT_CRITICAL(void); 开中断_swi(0x80) void ChangeTo

7、SYSMode(void); 切换到系统模式这些函数的具体代码在文件OS_CPU_C.C和OS_CPU_A.S中。根据pC / OS- II 的要求,所有在应用系统中的C文件必须包括文件INCLUDES.H。所以正常的做 法是使INCLUDES.H文件包含OS_CPU.H文件。三、创建OS_CPU_C.C文件在os_cpu_c.c文件中,pC / OS-II操作系统的移植规范要求创建十个简单 的函数 OSTaskStkInit(),OSTaskCreateHook(), OSTaskSwHook(), OSTaskDelHook(), OSTaskIdleHook(),OSTimeTickHo

8、ok(), OSTaskStatHook(),OSInitHookBegin(), OSInitHookEnd(),OSTCBInitHook()。除了 OSTaskStkInit()函数外并非所有的函数 都必须创建。在符合pC / OS -II操作系统的规范要求下,如果用户不想使用这些 函数,停用另外9个函数的功能并可以设置为空函数。A.编写 OSTaskStklnit()函数在 pC / OS - II 操作系统,这两个函数 OSTaskCreate()和 OSTaskCreateExt() 过调用OSTaskStkInit(涵数的方法初始化任务的堆栈结构,并保存所有寄存器数 据到各自的堆

9、栈中。当调用函数实现初始化后,它清除有关符合ARM7内核微处 理器的实际堆栈方向寄存器(堆栈方向是降序排列),并且最后返回堆栈顶的指针 值。递减堆栈指针处理器状态字中断返回地址寄存器保存值低地址图1堆栈结构初始化(参数pdata被传递给堆栈)图1展示了 OSTaskStkInit (涵数初始化堆栈的过程当四C/OS-II操作系统创建任 务的时候。在初始化后,OSTaskStkInit ()最后返回了堆栈顶的指针。B、系统软件中断函数在文件OS_CPU_C.C中,用C语言写的软中断函数总是第一个被介绍。该 文件包含所有的软件中断函数除了函数编号为0的任务(0$_丁人$3_$可()和函数 编号为1

10、的OSStartHighRdy()。在文件OS_CPU_A.S中,函数编号为0和为1 的是用汇编语言编写的。这是因为C语言不能确切提供这两个函数要求的堆栈 结构。另一个原因,如果用于切换任务的函数用汇编语言编写的话,能很方便的实 现跳转。由C语言编写的软中断函数的性质的介绍如下:由于使用了软中断,在 更改了 ARM7内核SPSR寄存器的相应控制位值后,当软中断结束后,通过将 SPSR寄存器的值复制到GPSR寄存器中特定的方式,更改微控制器的运行模式 的目的能够实现。四、创建OS_CPU_A.S文件根据四C / OS- II操作系统的移植规范,有四个函数 OSCtxSw(),OSIntCtxSw

11、(),OSTickISR(),OSStartHighRdy(),需要编写,而且必须用 汇编语言编写。在这个文件中,用于提取编号0和编号1的软中断函数编号的函 数也应该用汇编语言编写。A.提取软中断的函数编号ARM指令通过LR寄存器得到16位指令(LR-2寄存器值)通过LR寄存器得到32位指令(LR-4寄存器值)通过读取SWI指令得到8位常量通过读取SWI指令得到24位常量图2提取软中断号系统根据不同的软中断函数编号总是执行不同的函数。在ARM7内核微处 理器家族,LR寄存器总是用于存储子程序或异常的返回地址。LR寄存器可以获 得SWI指令代码。并且软件中断的编号包含在SWI指令中。所以软中断对

12、应的 函数编号可以通过读取指令代码的对应位段来得到。考虑到ARM7内核的三级 流水线架构和程序的运行状态可能是ARM态或Thumb状态,所以他们必须对应 不同的处理方式。图2显示了具体的流程图。B、编写 OSStartHighRdy(),OSCtxSw()和 OSIntCtxSw()函数四C / OS- II操作系统的调度函数OSSched()是通过调用实现任务切换功能 OS_TASK_SW()函数和OS_TASK_SW()函数完成整个任务切换,OS_TASK_SW() 函数和OS_TASK_SW(涵数是通过调用函数OSCtxSw()函数实现的。OSCtxSw()函数调用了 OS_TASK_S

13、W()用于最后切换任务。OSIntCtxSw()函 数的大多数源代码几乎与OSCtxSw()函数相同。它们具体的区别是 OS_TASK_SW(涵数需要存储CPU寄存器值。根据四C / OS- II操作系统的要求, 中断服务程序(ISR)已经存储了 CPU寄存器值。所以,OSIntExit()函数将不会处理 在最后的中断处理后(如果中断嵌套的存在)。这个时候,任务切换不需要再次存储 CPU寄存器的值。在四C / OS-II操作系统的移植过程中,为了使系统的代码高度可靠的, OSIntCtxSw()函数可以通过调用OSCtxSw()函数的方式实现。具体的实现方法是 再次保存CPU寄存器的值,但它对

14、整个系统没有任何影响。因为CPU寄存器必 须在OSCtxSw()函数写操作的时候执行,所以OSCtxSw()函数应该用汇编语言编 写。图3显示该函数的流程图。该函数与四C / OS -II操作系统的要求相比有一些差异移植,但这并不影响系 统的执行。在某种程度上,这证明了四C / OS-II是一个非常优秀的嵌入式操作系统, 它可以根据系统的需要进行裁剪。最后图3的流程图执行了LDMFD SP !,(R0 - R12,LR、PC ARM指令。因 为在pC / OS-II操作系统中,任务在异常模式中执行,它只可以在用户或系统模式 中执行。pC / OS- II操作系统通过调用OSStart()函数,

15、OSStart()最终调用 OSStartHighRdy()函数的方式开始任务环境。OSStartHighRdy()函数的编写应遵循 pC / OS-II操作系统的移植规范。具体的方法是通OSCtxSw()函数一样。它们两 者间唯一的区别是当第一次执行任务调度的时候OSStartHighRdy ()函数不必存储 寄存器的值。取得新的任务堆栈指针(SP=OSTCBHghRdy-OSTCBSKPtr)从新任务中返回CPU寄存器值返回到新任务执行图3. OSCtxsw()函数流程图创建了几个移植文件后,理论上巾C / OS - II操作系统可以正常的在ARM7内 核微处理器上执行了。但是在四C /

16、OS-II操作系统第一次执行前,需要提供 OSTickISR()系统时钟函数。这是系统时间的函数一定是写。四C / OS-II操作系统需要用户提供周期的时钟,并且时钟可以实现延迟函数 和超出时间函数。通常,周期时钟是由中断函数OSTicklSR()实现。事实上,调用 OSTimeTick(涵数的实质是通过调用OSTicklSR()函数实现的。因此,中断任务 OSTickISR()必须通过ARM7内核微处理器的硬件定时器实现,并且中断级应该 设置为最高。图4.四C/OS-II操作系统中断服务程序流程图(系统定时中断举例。)在四C / OS -II操作系统的移植上,中断服务子程序必须用汇编语言编写

17、。图4 显示了关于ARM7内核中断服务程序的流程图的写作规范。图4显示系统定时器中断的实现OSTimeISR()函数通过从执行用户程序转换 到四C / OS- II ()操作系统OSTimeTick()执行的方式实现。同样重要的是,如图4所示,已经实现了中断和退出中断处理,系统应再次选 择任务列表中最高优先级的任务,然后系统切换到最高的任务。保存在 OS_CPU_A.S函数OSIntCtxSw任务切换函数工作已经完成。也就是说在任务列 表种的初始中断任务不一定是最高优先级的任务。因为比初始任务更高优先级的 一个更高优先级的任务可能在中断处理中已经被执行。当然,当所有的中断已经执行后,如果初始中

18、断任务在任务列表中仍然是最高优 先级的任务,系统不需要切换任务,它再次直接通过恢复CPU任务寄存器的值 的方式执行。结论到目前为止,所有四C / OS- II操作系统的移植到ARM7内核微处理器的工作已 经完成。为了证明移植的正确性和合理性,在正常使用前,整个代码必须进行测 试。测试方法可以根据实际的应用程序微处理器模式编写几个小任务的方式实 现。测试可以有助于找到移植移植代码的缺陷,也可以修改移植代码。在移植没有漏洞后,可以将应用程序的任务运行在基于四C / OS -II操作系统 和ARM7内核微处理器系统平台上。引用1 Jean J. Labrosse (USA), gC/OS, The

19、Real-Time Kernel M, Beijing:BEIHANG UNIVERSITY PRESS, 2003.52 Xiong Zhenhua, Liao Jiaping, Based on S3C44B0x microprocessor and UCOS- II operating system J,China Water Transport,(2006)01.3 Xiang Huaikun, Liang Songfeng, Yuan Yuan, Design of Network-Enabled Traffic Signal Controller Based on CAN and

20、uCOS-I J,Journal of Shenzhen Polytechnic, (2008)03.4 Liu Miao, Wang Tianmiao, Wei Hongxing, Real-time Analysis of Embedded CNC System Based on uCOS-IIJ, Computer Engineering,(2006)22.5 Wang Lei, Wang Yaonan, Chen Sisi, The Application Of ucos-ii In Embedded Intelligent Vision Surveillance System J,

21、Control & Automation,(2008)04.6 Li Bei, Peng Chuwu, Building Hardware Application Layer in UCOS TransplantingJ, Electronic Engineering & Product World, (2006)16.Construction of Embedded System Platform which Based on mC/OS- II and ARM7 Kernel MicroprocessorYujun BaoSchool of Electronic Information &

22、 Electric Engineering,Changzhou Institute of Technology CZUChangzhou, ChinaXiaoyan JiangSchool of Electronic Information & Electric Engineering,Changzhou Institute of TechnologyCZUChangzhou, ChinaAbstractEmbedded System has more and more applications today. Introduced Embedded Operating System in Em

23、bedded System has been a tendency of Embedded system development.Embedded Operating System can avoid different Embedded System hardwares difference, it can greatly reduce the development costs, shorten the research cycle. gC/OS- II is a kind of excellent Embedded Operating System which is an open so

24、urce, tiny kernel, consuming little resource and high performance in real-time feature. In accordance with more and more 32 Bit ARM7 kernelMicroprocessor used in Embedded System, and here introduces the transplantation method of Embedded pC/OS- II Operating System which based on ARM7 kernel Micropro

25、cessor. So the construction of Embedded System Platform which based on p C/OS- II and ARM7 kernel Microprocessor can have been realized eventually. The platform can efficiently simplify the software developmenfs program flow,shorten the projecfs research cycle and improve the whole systems performan

26、ce greatly.Keywords: Embedded System;Embedded Operating System;ARM7 kernel; pC/OS - II. INTRODUCTIONThe so-called Operating System transplantation is that a real time Operating System kernel can be operated in others Microprocessors. That is special code for special CPU. Most codes of pC/OS - II are

27、 written by C programming language,and this is very convenient to transplant p C/OS- II .But according to the different Microprocessors, the users still need using assembly language to write some programs which are related to the different Microprocessors5 hardware. This is because when pC/OS- II re

28、ads or writes registers, it only relies on assembly language.1 With the p C/OS- II Operating Systems requirements,there are three files to be needed when pC/OS-I transplanted into a certain Microprocessor. And the whole transplantation mainly surrounds the work which creating these three files.These

29、 files showed next: . In the C language header file OS_CPU.H, some data types which are not concerned in compiler needed to be defined. These data types include the used stack data type and its growing direction. Some soft interrupts which are concerned in ARM7 kernel are defined in this file, too.

30、Another one OS_CPU_C.C is a source file of C program. The file mainly includes the task stack initialization function of pC/OS-II and some user functions which called by pC/OS- II Operating System. The last one OS_CPU_A.S is a assemble program source file. It is a clock ticks interrupt service funct

31、ion in practice. It is also a task switch function which used to quit interrupt. And it always runs the task of highest priority when pC/OS- II enters the multitask environment firstly.II. CREATING THE FILE OS_CPU.HA. Defining data types which are concerned in compilerBecause different Microprocesso

32、rs have different word length, so the transplantation of pC/OS- II includes a series of data types definition, and this make the transplantation possible. Especially for the data types used in C language, such as short,int,long and so on, these data types cant used in pC/OS-II directly. Because thes

33、e data types are concerned in the compliers type, they cant be transplanted. So these data types are always defined as Integer Data Structures in many cases, they are transplantable.B. Definition of system soft interrupt functionsInterrupt is a kind of hardware mechanism, but in pC/OS - II Operating

34、 System, some important task functions implementation are supposed to depend on interrupt level code.So, at this time, pC/OS- II Operating System needs a piece of preprocessor directive to simulate the interrupt. Ifs like a hardware interrupt, so it is called soft interrupt. Most Microprocessors ker

35、nel can provide this kind of soft interrupt directive. And in ARM7 kernel, it is the SWI.In order to make the bottom layer interface function be independent of Microprocessors state, and the responded task function neednt know the functions exact location when the task called. The used SWI directive

36、 should be as bottom layer interface. And the different functions can be distinguished by means of different soft interrupt Function Number. The ADS1.2 compiler always uses _swi to declare a non-existent function. And once the non-existent function is called, a piece of SWI directive should be inser

37、ted where the called function, and specifying the Function Number.Here shows some important functions soft interrupt function in pC/OS- II: _swi(0x00) void OS_TASK_SW(void) ; /Switching function between tasks _swi(0x01) void _OSStartHighRdy(void) ; / Running the task of highest priority firstly_swi(

38、0x02) void OS_ENTER_CRITICAL(void) ; / Interrupt Off_swi(0x03) void OS_EXIT_CRITICAL(void) ; / Interrupt On_swi(0x80) void ChangeToSYSMode(void); /Switching to system modelThese functions5 concrete codes existed in the files OS_CPU_C.C and OS_CPU_A.S. According to the requirements of pC/OS - II, all

39、 the C files in the application system must include the file INCLUDES.H.So a normal practice is make the file OS_CPU.H be included in the file INCLUDES.H.III. CREATING THE FILE OS_CPU_C.CIn the file OS_CPU_C.C, the transplantation specification of pC/OS- II Operating System requires to create ten si

40、mple functions: OSTaskStkInit(), OSTaskCreateHook( ),OSTaskDelHook( ), OSTaskSwHook( ), OSTaskIdleHook(), OSTaskStatHook( ), OSTimeTickHook( ), OSInitHookBegin(), OSInitHookEnd(), OSTCBInitHook( ). But not all the functions must be created except OSTaskStkInit () function. In accordance with the p C

41、/OS - II Operating Systems requirements, the hinder nine functions can be set to empty functions if users dont want to use.A. Writing the function OSTaskStklnit()In p C/OS- II Operating System, the two functions OSTaskCreate ( ) and OSTaskCreateExt( ) initialize tasks stack structure by means of cal

42、ling OSTaskStkInit ( ) function, and all the registers are stored in their respective stacks. When the called function implement the initialization, it clears the concerned registers in accordance with the ARM7 kernel Microprocessors practical stack direction (Provided the stackdirection is Full Des

43、cending.), and returns the stack tops pointer at last.LUO VV5 VI 5 piInterrupt 怎 return addressStacks pointerThe stored processors registers Low addressFigure 1. Stack structures initialization (The parameter pdata is sent to stack.)Fig.1 shows the process that OSTaskStkInit ( ) initializes the task

44、 stack when 四C/OS- II Operating System creates task.After the initialization, the OSTaskStkInit () returns the stack tops pointer at last.B. System soft interrupt functionsIn the file OS_CPU_C.C, the soft interrupt functions which written by C language are always introduced first. These include all

45、the soft interrupt functions except function Number Zero (OS_TASK_SW ( ) ) and function Number One (OSStartHighRdy ( ) ). And the functions Number Zero and Number One are written by assembly language in the file OS_CPU_A.S. This because C language cant provide exact stack structure which required by

46、 these two functions. And another reason, if the function which used to switch tasks is written by assembly language, it is very convenient to jump.The nature of soft interrupt functions which written by C language introduced here: Because of using soft interrupt, after changing the ARM7 kernel SPSR

47、 registers corresponding Control Bits, the purpose of changing Microprocessors running model can be realized by means of the characteristic that the SPSR registers value would be copied to the GPSR register during the soft interrupt is quitting.2IV CREATING THE FILE OS_CPU_A.SAccording to transplant

48、ation specification of 四C/OS-II Operating System, there are four functions ( OSStartHighRdy(), OSCtxSw( ), OSIntCtxSw( ), OSTickISR( ) ) needed to write, and they must be written in assembly language. And the function which used to extract the Number Zero and Number One soft interrupts5 Function Number should be written by assembly language in this file, too.A. Extracting the soft interrupts Function NumberThe system always carries out different functions in accordance with different soft interrupt Function Number. In ARM7 kernel Micropr

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 生活休闲 > 在线阅读


备案号:宁ICP备20000045号-2

经营许可证:宁B2-20210002

宁公网安备 64010402000987号