⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 powerpc_sys5.h

📁 system C源码 一种替代verilog的语言
💻 H
📖 第 1 页 / 共 2 页
字号:
/*   + * QuickThreads -- Threads-building toolkit.   + * Copyright (c) 1993 by David Keppel   + *   + * Permission to use, copy, modify and distribute this software and   + * its documentation for any purpose and without fee is hereby   + * granted, provided that the above copyright notice and this notice   + * appear in all copies.  This software is provided as a   + * proof-of-concept and for demonstration purposes; there is no   + * representation about the suitability of this software for any   + * purpose.   + *   + * PowerPC-Sys5 thread switching module.   + *    + * This software is largely based on the original PowerPC-Linux porting   + * developed by Ken Aaker <kenaaker@silverbacksystems.com>   + *    + * Marco Bucci <marco.bucci@inwind.it>   + * December 2002   + *   + */#ifndef QUICKTHREADS_POWERPC_H#define QUICKTHREADS_POWERPC_H/***************************************************************************** * * DESCRIPTION * * This is the QuickThreads switching module implementation for PowerPC  * running under System V ABI (Application Binary Interface) [2]. It was * developed by porting the MacOS X version and tested under LinuxPPC. * * Notice that this is not the same than the PowerPC Mach  ABI used by MacOSX * [1]. * * IMPLEMENTATION NOTES * * 1) Porting on System V ABI * Excluding the variant argument calling convention, Mach and System V ABI * are enough similar and it could be possible to use some simple macro, to * adapt the code for both the ABIs. Actually, the only relevant difference  * is in the linkage area structure and in the position where the Link and * the Condition registers are saved. As to the calling conventions, there * are differences with floating points argument passing and with variant * argument lists. Notice that, on Mach, the caller's stack frame allocates * space to hold all arguments ([1] p.51), while on System V, the caller's * stack frame allocates space to hold just the arguments that don't fit into * registers ([2] p.3.18). * * 2) Variant argument list implementation * Variant argument calling on a RISC machine is not easy to implement since * parameters are passed via registers instead of via stack. In a general * variant argument implementation, the caller's stack must map the whole * parameter list following the rules related to the use of the GPR and FPR * parameter registers and the stack alignment ([2] p.3-21).  * This implementation is quite simple and not general. It works under the * hypothesis that arguments are 4-bytes aligned integers. * * 3) This heather file organisation * I preferred to not make confusion between macros that are needed (i.e. * directly used) by QuickThreads and internal "implementation" macros. You * will find QuickThreds macros in the end of this header. Sometime they just * refer to an analogous "internal" macro. On the top, there are the macros * that I used to make more clean (I hope) the implementation. I could include * some system heather (as to stack layout definitions, prologs and epilogs, * etc.), but I preferred to have a self-contained heather in order to make * all more clear for mantaining and for possible porting on another ABI. * * * REFERENCES * * [1] - Mach-O Runtime Architecture *       Runtime Concepts and Conventions for Mac OS X Programs *       Preliminary July 2002 * * [2] - SYSTEM V APPLICATION BINARY INTERFACE *       PowerPC Processor Supplement *       September 1995 * *****************************************************************************//***************************************************************************** * *  PowerPC System V Stack frame (see [2]) *                          ................                +                          +                |                          |                 +--------------------------+                |                          | Caller's LR                +  CALLER'S LINKAGE AREA   + backchain ->   |                          | Caller's backchain                +==========================+                |                          | FPR31                +      FPR SAVE AREA       +                       ..............                +                          +                |                          | FPRn                +--------------------------+                |                          | GPR31                +      GPR SAVE AREA       +                       ..............                +                          +                |                          | GPRn                +--------------------------+                |                          |                 +      ALIGNMEBNT PAD      +                       ..............                +       (if needed)        +                |                          |                +--------------------------+                |         CR SAVE          |                +--------------------------+                |                          |                 +   LOCAL VARIABLES AREA   +                       ..............                +                          +                |                          |                +--------------------------+                |                          | PAR(n-7)                +                          +                |                          |                 +      PARAMETER AREA      +                       ..............                +      for FUTURE call     +                |                          | PAR(9)                +                          + SP + 8 ->      |                          | PAR(8)                +--------------------------+ SP + 4 ->      |                          | LR callee-save for FUTURE call                +       LINKAGE AREA       + SP ->          |                          | backchain                +==========================+                STACK TOP (lower address)                       Stack grows down                             |                             V  * NOTE: * * 1) In this figure parameter are supposed to be integer 4-bytes aligned and * are numbered 0, 1, 2,... n. * * 2) Parameter are allocated in the CALLER's parameter area. This area must * be large enough to hold all parameters that cannot fit in registers (no  * more parameter registers are available); * * 3) The callee saves LR in the caller's linkage area. CR as all other * callee's state are saved in its own stack frame. *  *****************************************************************************/ /***************************************************************************** *  * Stack initialization for a single argument thread * top + QUICKTHREADS_STKBASE ->           STACK BOTTOM (higher address)                               +==========================+                               |                          |                               +                          +                                     ..............                               +                          +                               |                          |                               +--------------------------+ top + QUICKTHREADS_ONLY_INDEX * 4 ->    | only param               | PAR(3)                               +                          + top + QUICKTHREADS_USER_INDEX * 4 ->    | userf param              | PAR(2)                               +                          + top + QUICKTHREADS_ARGT_INDEX * 4 ->    | t param                  | PAR(1)                               +                          + top + QUICKTHREADS_ARGU_INDEX * 4 ->    | u param                  | PAR(0)                               +--------------------------+ top + QUICKTHREADS_RETURN_INDEX * 4 ->  | qt_start                 | LR save                               +                          + top + QUICKTHREADS_BLOCKI_FRAME_SIZE -> | top + QUICKTHREADS_STKBASE         | backchain                                                    +==========================+                               |                          |                               +                          +                                     ..............                               +                          +                               |                          |                               +--------------------------+                               |                          |                                +                          + top ->                        |top + QUICKTHREADS_BLOCKI_FRAME_SIZE| backchain                               +==========================+                               STACK TOP (lower address)                                      Stack grows down                                           |                                           V ***************************************************************************** * * Stack initialization for a variant argument thread * bottom ->                     STACK BOTTOM (higher address)                               +==========================+                               |                          |                               +                          +                                     ..............                               +                          + top + QUICKTHREADS_VSTKBASE ->          | arg(0)                   | PAR(4)                               +--------------------------+ top + QUICKTHREADS_CLEANUP_INDEX * 4 -> | cleanup param            | PAR(3)                               +                          + top + QUICKTHREADS_USER_INDEX * 4 ->    | userf param              | PAR(2)                                 +                          + top + QUICKTHREADS_VSTARTUP_INDEX * 4 ->| startup param            | PAR(1)                               +                          + top + QUICKTHREADS_ARGT_INDEX * 4 ->    | t param                  | PAR(0)                               +--------------------------+ top + QUICKTHREADS_RETURN_INDEX * 4 ->  | qt_start                 | LR save                               +                          + top + QUICKTHREADS_BLOCKI_FRAME_SIZE -> | top + QUICKTHREADS_STKBASE         | backchain                                                    +==========================+                               |                          |                               +                          +                                     ..............                               +                          +                               |                          |                               +--------------------------+                               |                          |                                +                          + top ->                        |top + QUICKTHREADS_BLOCKI_FRAME_SIZE| backchain                               +==========================+                               STACK TOP (lower address)                                      Stack grows down                                          |                                          V* NOTE:** Parameters are passed to "qt_start" or to "qt_vstart" putting them into* the stack frames of "qt_start" or "qt_vstart" themselves. This not a* conventional parameter passing because parameters should be put into the* caller's stack, not into the callee's one. Actually  we must consider* that as a preload of the parameter area that "qt_start" or "qt_vstart"* will use for their own calls.*  Be aware of the fact that, during a call, the caller's parameter area is,* in a certain sense, volatile. In facts, the callee can save parameter* registers on the caller's parameter area.* *****************************************************************************/ /*****************************************************************************    Define PowerPC System V related macros  *****************************************************************************/ typedef unsigned long PPC_W;/* Stack pointer must always be a multiple of 16 */#define	PPC_STACK_INCR	16		#define	PPC_ROUND_STACK(length)	\	(((length)+PPC_STACK_INCR-1) & ~(PPC_STACK_INCR-1))#define PPC_LINKAGE_AREA 8					#define PPC_LR_SAVE 4#define PPC_PARAM_AREA(n) (4*(n))#define PPC_GPR_SAVE_AREA (4*19)		/* GPR13-GPR31 must be saved */#define PPC_FPR_SAVE_AREA (8*18)		/* FPR14-FPR31 must be saved */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -