Express Logic's ThreadX for 68332
Using the Green Hills Tools
1. Installation
ThreadX for the 68332 is delivered on a single CD-ROM compatible disk. The
entire distribution can be found in the sub-directory:
\THREADX
To install ThreadX to your hard-disk, make a THREADX\68332\GREEN directory
on your hard-disk and copy all the contents of the THREADX sub-directory on the
distribution disk. The following is an example MS-DOS copy command
(assuming source is D: and C: is your hard-drive):
D:\THREADX>XCOPY /S *.* C:\THREADX\68332\GREEN
2. Building the ThreadX run-time Library
First make sure you are in the ThreadX directory you have created on
your hard-drive. Also, make sure that you have setup your path and other
environment variables necessary for the Green Hills development environment.
At this point you may run the BUILD_TX.BAT batch file. This will
build the ThreadX run-time environment in the THREADX directory.
C:\THREADX\68332\GREEN> build_tx
You should observe assembly and compilation of a series of ThreadX source
files. At the end of the batch file, they are all combined into the
run-time library file: TX.OLB. This file must be linked with your
application in order to use ThreadX.
3. Demonstration System
The ThreadX demonstration is designed to execute on the 68332 QUADS evaluation
board and under the MULTI environment using MULTI's 68000 simulator. The
instructions that follow will show you how to get the ThreadX demonstration
running in these environments.
Building the demonstration is easy, simply load the MULTI project file
DEMO.BLD, which is located inside your ThreadX directory:
C:\THREADX\68332\GREEN\DEMO.BLD
You should observe the following files in the project view area:
DEMO.BLD
TX_ILL.68
DEMO.C
DEMO.LNK
README.TXT
At this point, select the "Project Build" operation and observe the
compilation, assembly, and linkage of the ThreadX application. After
the demonstration is built, you are now ready for debugging!
To run on under MULTI's 68000 simulator, select the "Remote" button
from the MULTI builder (you should see "s68 68020" in the remote window).
This invokes MULTI's 68020 simulator and you should observe several new
windows for it. Next, select the "Debug" button from the MULTI builder.
You should now observe the demonstration program in the debugger window.
At this point, you are free to debug with breakpoints, data watches, etc.
The demonstration system attempts to setup a 68332 periodic timer. Since
the 68020 simulator does not simulate the 68332 peripherals, the timer
interrupts will not work under simulation until the following commands
are entered in the simulation control window:
> interrupt dev1 vector 16
> interrupt dev1 priority 2
> interrupt dev1 time 10000 every 10000
> trap 16
To run on the 68332 Evaluation board, simply convert the demo output image
to S-records and download it to the evaluation board. The following
command can be used to do the conversion:
> gsrec demo.cfe -o demo.mot
3.1 EventAnalyzer Demonstration
To build a demonstration system that will also log events for the
MULTI EventAnalyzer, perform the same steps as the regular demo,
except build the ThreadX library with BUILD_TXE.BAT file and use
the DEMO_EL.BLD build file to build the demonstration that logs
all system events.
4. System Initialization
The system entry point using Green Hills tools is at the label _start.
This is defined within the CRT0.O file supplied by Green Hills. In addition,
this is where all static and global pre-set C variable initialization
processing is called from.
After the Green Hills startup function returns, ThreadX initialization is
is called. The 68332 specific initialization is done in the function
_tx_initialize_low_level, which is located in the file TX_ILL.68. This
function is responsible for setting up various system data structures,
interrupt vectors, and a periodic timer interrupt source for ThreadX.
In addition, _tx_initialize_low_level defines the system timer thread�s stack
and determines the first available address for use by the application.
By default free memory is assumed to start at the linker defined symbol
__ghsbegin_freemem. The ThreadX system timer's stack is allocated here and
the memory address after the timer thread's stack is passed to the
application definition function, tx_application_define.
5. Assembler / Compiler / Linker Switches
The following are Green Hills switches used in building the demonstration
system:
Compiler/Assembler Meaning
Switches
-G Specifies debug information
-c Specifies object code output
-68332 Specifies 68332 code generation
There are additional linker commands inside of the file DEMO.LNK. Please
use this file as a template for your application.
5.1 User defines
The following defines and their associated action are as follows:
Define Meaning
TX_DISABLE_ERROR_CHECKING If defined before tx_api.h is included,
this define causes basic ThreadX error
checking to be disabled. Please see
Chapter 4 in the "ThreadX User Guide"
for more details.
TX_DISABLE_STACK_CHECKING By default, the thread create function
fills the thread's stack with a 0xEF
data pattern, which is used by the MULTI
debugger to calculate stack usage. This
can be bypassed by compiling tx_tc.c with
this define.
TX_ENABLE_EVENT_LOGGING This define enables event logging for any
or all of the ThreadX source code. If this
option is used anywhere, the tx_ihl.c file
must be compiled with it as well, since this
is where the event log is initialized.
TX_NO_EVENT_INFO This is a sub-option for event logging.
If this is enabled, only basic information
is saved in the log.
TX_ENABLE_EVENT_FILTERS This is also a sub-option for event-logging.
If this is enabled, run-time filtering logic
is added to the event logging code.
6. Register Usage and Stack Frames
The Green Hills 68K compiler assumes that registers d0-d1, and a0-a1 are
scratch registers for each function. All other registers used by a C function
must be preserved by the function. ThreadX takes advantage of this in
situations where a context switch happens as a result of making a ThreadX
service call (which is itself a C function). In such cases, the saved
context of a thread is only the non-scratch registers.
The following defines the saved context stack frames for context switches
that occur as a result of interrupt handling or from thread-level API calls.
All suspended threads have one of these two types of stack frames. The top
of the suspended thread's stack is pointed to by tx_stack_ptr in the
associated thread control block TX_THREAD.
Offset Interrupted Stack Frame Non-Interrupt Stack Frame
0x00 1 0
0x02 d0 d2
0x06 d1 d3
0x0A d2
Threadx操作系统源代码(1.02M)
5星 · 超过95%的资源 需积分: 0 33 浏览量
更新于2008-03-15
9
收藏 1.02MB ZIP 举报
ThreadX是一个著名的实时操作系统(RTOS),它被广泛用于嵌入式系统开发,特别是在需要高度可靠性和性能的领域。源代码的提供使得开发者可以深入理解其内部机制,进行定制化开发和优化,以满足特定项目的需求。
ThreadX的核心特性包括:
1. **线程管理**:ThreadX支持多线程并发执行,线程可以通过优先级进行调度,高优先级的线程可以在低优先级线程运行时被中断并抢占CPU。线程间通信可以通过消息队列、信号量、事件标志组等方式实现。
2. **内存管理**:ThreadX提供了动态内存分配和释放功能,通过内存池机制,确保内存的安全和高效使用。开发者可以自定义内存池大小和数量,以适应不同内存需求。
3. **同步与通信**:ThreadX提供了丰富的同步机制,如信号量、互斥量、事件标志组和消息队列,这些机制用于线程间的协调和数据交换。
4. **定时器**:ThreadX具有硬件抽象层的定时器服务,可以设置周期性任务或一次性任务,增强了实时系统的灵活性。
5. **中断管理**:ThreadX对中断进行了高级封装,允许在中断服务例程中安全地与用户线程交互,提升了中断处理的效率。
6. **文件系统支持**:虽然这里没有明确提到,ThreadX通常会提供对文件系统的支持,允许在嵌入式设备上进行文件操作。
7. **网络协议栈**:ThreadX可能集成了TCP/IP协议栈,使得嵌入式设备能够接入网络,实现各种网络服务。
8. **调试工具**:ThreadX通常会附带一些调试工具,如TraceX,它可以帮助开发者跟踪线程行为,分析系统性能,找出潜在的问题。
`express.pdf`可能是关于ThreadX的使用手册或者快速入门指南,包含详细的操作步骤和API说明,对于理解和使用ThreadX至关重要。而`threadx`文件可能是ThreadX的源代码本身,通过阅读和分析源代码,开发者可以学习到RTOS的设计原则和实现技巧,这对于提升自身的嵌入式系统开发能力非常有帮助。
由于描述中提到这是较旧的版本,开发者如果需要最新版本的ThreadX源代码,建议直接访问官方网站或者通过在线资源库查找更新,以获取最新的特性和修复。
ThreadX源代码的学习和研究为开发者提供了深入了解嵌入式实时操作系统的机会,有助于提高系统设计和优化的能力,同时,通过实际操作和实践,也能提升解决实际问题的经验。
--纯技术领域--
- 粉丝: 64
- 资源: 75
最新资源
- springboot078民宿在线预定平台.zip
- springboot078民宿在线预定平台_0303152757.zip
- springboot266基于Web的农产品直卖平台的设计与实现_0303174040.zip
- C#+Winform+SQLServer+图书管理系统
- 基于mobilenet的垃圾分类系统,TensorFlow开发
- springboot080房屋租赁管理系统的设计与实现.zip
- springboot079信息化在线教学平台的设计与实现.zip
- springboot267大学生科创项目在线管理系统的设计与实现.zip
- PL330 DMAC技术参考手册
- springboot082在线宠物用品交易网站的设计与实现.zip
- springboot267大学生科创项目在线管理系统的设计与实现_0303174040.zip
- springboot268码头船只货柜管理系统.zip
- springboot091创新创业教育中心项目申报管理系统a.zip
- 西门子smart200与3台台达MS300变频器通讯程序 器件:西门子s7 200 smart PLC,3台台达ms300变频器,昆仑通态触摸屏(带以太网),中途可以加路由器 控制方式:触摸屏与plc
- springboot268码头船只货柜管理系统_0303174040.zip
- springboot093基于springboot的厨艺交流平台的设计与实现代码.zip
- 1
- 2
- 3
- 4
- 5
- 6
前往页