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

📄 powerpc_mach.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-Mach 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 Mach kernel. It was developed and tested under MacOS X, that * is under Darwin (the UNIX-BSD fundation of MacOS X). * * Notice that the Mach PowerPC ABI (Application Binary Interface) [1] is * not the same than System V ABI [2] used by most of the LINUX PowerPC * implementations. * * 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 ([1] p.54).  * 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 * * On MacOS X, more documentation is available by installing the "Developer * Tools". Useful macros and documentation can be found in the system headers * files such as asm.h, asm_help.h etc. (see /usr/architecture/ppc/ or * /System/Library/Frameworks/Kernel.framework/Headers/architecture/ppc/).	 *****************************************************************************//***************************************************************************** * *  PowerPC Mach-O Stack frame (see [1]) *                          ................                +                          +                |                          | reserved                +  CALLER'S LINKAGE AREA   +                |                          | Caller's LR                +                          +                 |                          | Caller's CR                +                          + backchain ->   |                          | Caller's backchain                +==========================+                |                          | FPR31                +      FPR SAVE AREA       +                       ..............                +                          +                |                          | FPRn                +--------------------------+                |                          | GPR31                +      GPR SAVE AREA       +                       ..............                +                          +                |                          | GPRn                +--------------------------+                |                          |                 +      ALIGNMEBNT PAD      +                       ..............                +       (if needed)        +                |                          |                +--------------------------+                |                          |                 +   LOCAL VARIABLES AREA   +                       ..............                +                          +                |                          |                +--------------------------+                |                          | PAR(n)                +                          +                |                          |                 +      PARAMETER AREA      +                       ..............                +      for FUTURE call     +                |                          | PAR(1)                +                          + SP + 24 ->     |                          | PAR(0)                +--------------------------+ SP + 20 ->     |                          | Caller's TOC                +                          +  SP + 16 ->     |                          | reserved                +                          + SP + 12 ->     |                          | reserved                +       LINKAGE AREA       + SP + 8 ->      |                          | LR callee-save for FUTURE call                +                          +  SP + 4 ->      |                          | CR callee-save for FUTURE call                +                          + SP ->          |                          | backchain                +==========================+                STACK TOP (lower address)                       Stack grows down                             |                             V * NOTE: * * 1) Parameter are allocated in the CALLER's parameter area. This area must * be large enough to hold all parameters regardless if they are or not passed * in registers. * * The caller parameter area is used: * - by the caller, to store parameters to the callee that cannot fit in *  registers (no more parameter registers are available); * - by the callee, to save parameter registers (for istance because they are * needed for a further call). * * Obviously, the callee saves parameter registers, in the location in which * they are mapped on the caller's stack frame. So, be aware that, if * something else is stored in that location, it could be deleted after a call.  * * 2) The callee saves LR and CR in the caller's linkage area. 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 Mach-O 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)	\

⌨️ 快捷键说明

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