threadx_mips
所属分类:嵌入式/单片机/硬件编程
开发工具:C/C++
文件大小:764KB
下载次数:38
上传日期:2013-03-17 20:45:07
上 传 者:
doomduke
说明: rtos,threadx源码,对实时操作系统的了解非常有帮助
(rtos,threadx source code)
文件列表:
threadx_mips\build\default.con (6475, 2008-01-07)
threadx_mips\build\libosf.gpj (2302, 2008-01-07)
threadx_mips\build\vssver.scc (64, 2008-01-07)
threadx_mips\inc\osf.h (30006, 2008-01-07)
threadx_mips\inc\tx_api.h (46067, 2008-01-07)
threadx_mips\inc\tx_blo.h (8923, 2008-01-07)
threadx_mips\inc\tx_byt.h (9193, 2008-01-07)
threadx_mips\inc\tx_el.h (45207, 2008-01-07)
threadx_mips\inc\tx_eve.h (9078, 2008-01-07)
threadx_mips\inc\tx_ghs.h (1549, 2008-01-07)
threadx_mips\inc\tx_ini.h (6870, 2008-01-07)
threadx_mips\inc\tx_mut.h (7758, 2008-01-07)
threadx_mips\inc\tx_port.h (10162, 2008-01-07)
threadx_mips\inc\tx_que.h (9384, 2008-01-07)
threadx_mips\inc\tx_sem.h (8689, 2008-01-07)
threadx_mips\inc\tx_thr.h (14212, 2008-01-07)
threadx_mips\inc\tx_tim.h (10218, 2008-01-07)
threadx_mips\inc\vssver.scc (256, 2008-01-07)
threadx_mips\lib\tx.a (371818, 2008-01-07)
threadx_mips\lib\tx.dba (1255518, 2008-01-07)
threadx_mips\lib\txe.a (382876, 2008-01-07)
threadx_mips\lib\txe.dba (264812, 2008-01-07)
threadx_mips\lib\vssver.scc (96, 2008-01-07)
threadx_mips\src\threadx\build_ap.bat (305, 2008-01-07)
threadx_mips\src\threadx\build_tx.bat (13850, 2008-01-07)
threadx_mips\src\threadx\build_txe.bat (19195, 2008-01-07)
threadx_mips\src\threadx\demo.bld (279, 2008-01-07)
threadx_mips\src\threadx\demo.c (11279, 2008-01-07)
threadx_mips\src\threadx\demo.con (383, 2008-01-07)
threadx_mips\src\threadx\demo.dbo (16246, 2008-01-07)
threadx_mips\src\threadx\demo.inf (131, 2008-01-07)
threadx_mips\src\threadx\demo.ld (496, 2008-01-07)
threadx_mips\src\threadx\demo.o (6999, 2008-01-07)
threadx_mips\src\threadx\demo_el (71612, 2008-01-07)
threadx_mips\src\threadx\demo_el.bld (318, 2008-01-07)
threadx_mips\src\threadx\demo_el.dla (97856, 2008-01-07)
threadx_mips\src\threadx\demo_el.dnm (51501, 2008-01-07)
threadx_mips\src\threadx\demo_el.ld (536, 2008-01-07)
threadx_mips\src\threadx\demo_el.map (19619, 2008-01-07)
... ...
Express Logic's ThreadX for MIPS MIPS32_4Kx
Using the Green Hills Tools
1. Installation
ThreadX for the MIPS MIPS32_4Kx 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 directory on your
hard-disk (we recommend C:\THREADX\MIPS32_4Kx\GREEN) and copy all the contents
of the THREADX sub-directory on the distribution disk. The following
is an example MS-DOS copy command from the distribution directory
(assuming source is D: and C: is your hard-drive):
D:\THREADX> xcopy /S *.* C:\THREADX\MIPS32_4Kx\GREEN
2. Building the ThreadX run-time Library
Building the ThreadX library is easy, simply load the MULTI project file
TX.BLD, which is located inside your ThreadX directory:
C:\THREADX\MIPS32_4Kx\GREEN\TX.BLD
Once the ThreadX library files are displayed in the MULTI project window,
select the "Project Build" operation and observe the compilation and assembly
of the ThreadX library. This project build produces the ThreadX library
file TX.A.
3. Demonstration System
The ThreadX demonstration is designed to execute under the MULTI environment
using the MULTI MIPS instruction set simulator. The instructions that
follow will show you how to get the ThreadX demonstration running in this
environment.
Building the demonstration is easy, simply load the MULTI project file
DEMO.BLD, which is located inside your ThreadX directory:
C:\THREADX\MIPS32_4Kx\GREEN\DEMO.BLD
You should observe the following files in the project view area:
DEMO.BLD
RESET.MIP
TX_ILL.MIP
DEMO.C
DEMO.LD
README.TXT
DEMO.CON
At this point, select the "Project Build" operation and observe the
compilation, assembly, and linkage of the ThreadX application.
After the demonstration is built, invoke the MIPS simulator
by selecting the CONNECT button. Now select the DEBUG button.
You should now observe the main function of DEMO.C.
Once the debug server is connected, select the MULTI "Debug" option.
You should now observe the main function in DEMO.C.
You are now ready to execute the ThreadX demonstration system. The
MULTI MIPS32_4Kx simulator also simulates interrupts. To setup a simulated
timer interrupt for ThreadX, please enter the following command at the
"Target" window prompt:
timer 9999 7
This command will cause a simulated interrupt 5 every 9999 cycles. ThreadX
is setup to use this interrupt as its periodic timer interrupt source.
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 the TXE.BAT build 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.MIP 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 main initialization function is _tx_initialize_low_level and
is located in the file TX_ILL.MIP. This function is responsible for setting
up various system data structures, and interrupt vectors.
In addition, _tx_initialize_low_level also determines the first available
address for use by the application. By default, the first available address
is assumed to start at the beginning of the ThreadX section .free_mem. If
changes are made to the DEMO.LD file, the .free_mem section should remain
the last allocated section in the main RAM area. The starting address of
this section is passed to the application definition function,
tx_application_define.
5. Assembler / Compiler Switches
The following are compiler switches used in building the demonstration
system:
Compiler Switch Meaning
-G Specifies debug information
-c Specifies object code generation
-cpu=mips32_4kc Specifies MIPS32_4Kx code generation
-noasmwarn Disable in-line assembly warnings
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 MIPS compiler assumes that registers t0-t9 ($8-$15, $24, $25)
and f0-f19 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
0x04 s8 ($30) s8 ($30)
0x08 s7 ($23) s7 ($23)
0x0C s6 ($22) s6 ($22)
0x10 s5 ($21) s5 ($21)
0x14 s4 ($20) s4 ($20)
0x18 s3 ($19) s3 ($19)
0x1C s2 ($18) s2 ($18)
0x20 s1 ($17) s1 ($17)
0x24 s0 ($16) s0 ($16)
0x28 hi hi
0x2C lo lo
0x30 t9 ($25) ra ($31)
0x34 t8 ($24) SR
0x38 t7 ($15)
0x3C t6 ($14)
0x40 t5 ($13)
0x44 t4 ($12)
0x48 t3 ($11)
0x4C t2 ($10)
0x50 t1 ($9)
0x54 t0 ($8)
0x58 a3 ($7)
0x5C a2 ($6)
0x60 a1 ($5)
0x*** a0 ($4)
0x68 v1 ($3)
0x6C v0 ($2)
0x70 at ($1)
0x74 ra ($31)
0x78 SR
0x7C EPC
7. Improving Performance
The distribution version of ThreadX is built without any compiler
optimizations. This makes it easy to debug because you can trace or set
breakpoints inside of ThreadX itself. Of course, this costs some
performance. To make ThreadX run faster, you can change the TX.BLD project
to disable debug information and enable the desired optimizations.
In addition, you can eliminate the ThreadX basic API error checking by
compiling your application code with the symbol TX_DISABLE_ERROR_CHECKING
defined before TX_API.H is included.
8. Interrupt Handling
ThreadX provides complete and high-performance interrupt handling for MIPS32_4Kx
targets. The general exception handler is at address: 0x80000180 (0xBFC00380 non-
cached). The ThreadX general exception handler is defined in the file tx_ill.MIP at
the label _tx_exception_handler. A small piece of code to jump to this exception
handler is copied to the general exception handler address during initialization.
8.1 Application ISRs
Multiple exceptions may be processed with a single execution of the exception
handler. This is because the Cause register could indicate more than a single
exception. Processing for each exception is also located in the general
exception handler that starts at the label: _tx_exception_handler. Application
ISRs can be added into this handler.
9. Revision History
01/01/2003 ThreadX update of MIPS32_4Kx/Green Hills port and new ThreadX
Version 4.0b Generic Code. The following files were changed/added
for version G4.0b.4.0b:
TX_PORT.H Modified comments, changed VOID typedefs,
and changed version ID.
TX_BLO.H Modified the in-line initialization code.
TX_BYT.H Modified the in-line initialization code.
TX_EVE.H Modified the in-line initialization code.
TX_MUT.H Modified the in-line initialization code.
TX_QUE.H Modified the in-line initialization code.
TX_SEM.H Modified the in-line initialization code.
TX_THR.H Added volatile modifier for several system variables
and added function prototype.
TX_BPI.C Modified in-line initialization logic.
TX_BYTI.C Modified in-line initialization logic.
TX_EFI.C Modified in-line initialization logic.
TX_IHL.C Changed and moved in-line initialization code.
TX_MI.C Modified in-line initialization logic.
TX_QF.C Fixed problem relating to not decrementing the
_tx_thread_preempt_disable flag under interrupt
protection.
TX_QI.C Modified in-line initialization logic.
TX_SI.C Modified in-line initialization logic.
TX_TWA.C Fixed problem relating to not decrementing the
_tx_thread_preempt_disable flag.
TX_ILL.MIP Added logic for count/compare timer interrupt
setup and handling.
TX*.MIP Changed comments and copyright header.
TX*.C Changed comments and copyright header.
TX*.H Changed comments and copyright header.
07/15/2002 ThreadX update of MIPS32_4Kx/Green Hills port and new ThreadX
Version 4.0a Generic Code. The following files were changed/added
for version G4.0a.4.0a:
TX_API.H Added logic to select API runtime errors,
declared tx_application_define as extern "C",
and changed constant TX_FOREVER to TX_LOOP_FOREVER.
TX_PORT.H Added in-line initialization define, added
system timer stack and priority constants,
modified interrupt restore macro, and changed
version ID.
TX_TIM.H Added logic for setup of the system timer
thread's stack area.
TX_BA.C Changed to use ULONG_PTR type.
TX_BPCLE.C Optimized out extra disable interrupts call.
TX_BPI.C Added logic to detect in-line initialization
and avoid duplicate data declarations.
TX_BYTA.C Changed to use ULONG_PTR and UCHAR_PTR types.
TX_BYTC.C Changed to use ULONG_PTR type.
TX_BYTCL.C Corrected double restore of interrupts problem.
TX_BYTI.C Added logic to detect in-line initialization
and avoid duplicate data declarations.
TX_BYTR.C Changed to use ULONG_PTR type and added update
of search pointer to the released memory block.
TX_BYTS.C Changed to use ULONG_PTR type.
TX_EFCLE.C Optimized out extra disable interrupts call.
TX_EFI.C Added logic to detect in-line initialization
and avoid duplicate data declarations.
TX_EFS.C Changed to use ULONG_PTR type.
TX_GHS.C Corrected __ghs_flock_create() for thread-safe
I/O, remove MULTI stack checking code when
TX_DISABLE_STACK_CHECKING is defined.
TX_IHL.C Moved TX_INLINE_INITIALIZATION define to tx_port.h.
TX_MCLE.C Optimized out extra disable interrupts call.
TX_MI.C Added logic to detect in-line initialization
and avoid duplicate data declarations.
TX_QCLE.C Optimized out extra disable interrupts call.
TX_QFS.C Changed to use ULONG_PTR type.
TX_QI.C Added logic to detect in-line initialization
and avoid duplicate data declarations.
TX_QR.C Changed to use ULONG_PTR type.
TX_QS.C Changed to use ULONG_PTR type.
TX_SCLE.C Optimized out extra disable interrupts call.
TX_SI.C Added logic to detect in-line initialization
and avoid duplicate data declarations.
TX_TI.C Changed to use UCHAR_PTR type.
TX_TIMI.C Added logic for setting up the system timer
thread's stack and priority, moving the setup
from the TX_ILL.
TX_TPCH.C Moved check for valid preemption-threshold to
txe_tpch.c and optimized return case when
preemption is needed.
TX_TPRCH.C Moved check for valid priority to txe_trpc.c.
TX_TSA.C Optimized out extra disable interrupts call.
TX_TTE.C Changed constant from TX_FOREVER to TX_LOOP_FOREVER.
TX_TTO.C Optimized out extra disable interrupts call.
TXE_MG.C Added check for valid caller of this service.
TXE_QF.C Allow this service to be called from anywhere.
TXE_TPCH.C Moved check for valid preemption-threshold here.
TXE_TRPC.C Moved check for valid priority here.
TX_ILL.MIP Removed timer thread stack and priority setup.
TX_TS.MIP Changed addi to addu.
TXR*.C Added run-time error checking routines for MULTI,
including the run-time stack checking function
_stkchk() which is defined in TXR_GHS.C. User
programs built with the -Xstackcheck option
can take advantage of this feature.
TX*.C Changed comments and copyright header.
TX*.H Changed comments and copyright header.
TX*.MIP Changed comments and copyright header.
01/28/2001 ThreadX update of MIPS32_4Kx/Green Hills port and new ThreadX
Version 4.0 Generic Code. The following files were changed/added
for version G4.0.4.0:
TX_API.H Added TX_MUTEX object, added a new member to the
thread control block, and added new Version 4.0
service call prototypes and constants.
TX_BLO.H Added in-line block pool initialize capability
and new block pool service prototypes.
TX_BYT.H Added in-line byte pool initialize capability
and new byte pool service prototypes.
TX_EL.H Corrected problem with filtering semaphore events,
added new Version 4.0 service calls, and made the
include file more generic.
TX_EVE.H Added in-line event flag initialize capability
and new event flag service prototypes.
TX_GHS.H Simplified and cleaned up.
TX_PORT.H Changed version ID.
TX_QUE.H Added in-line queue initialize capability and
new queue service prototypes.
TX_SEM.H Added in-line initialization capability and new
semaphore service prototypes.
TX_THR.H Added group masks for optimizing and added new
service prototypes.
TX_TIM.H Added new service prototypes.
TX_BYTR.C Removed reset of the search pointer on memory release.
TX_BYTS.C Added code to updated search pointer to next block
on a successful search.
TX_EL.C Converted into a generic file that is the same on all
ports of ThreadX.
TX_GHS.C Simplified by using new ThreadX Version 4.0 MUTEX and
cleaned up.
TX_IHL.C Added mutex initialization and in-line initialization.
TX_QR.C Optimized message copy code.
TX_QS.C Optimized message copy code.
TX_TC.C Added zero initi ... ...
近期下载者:
相关文件:
收藏者: