📄 powerpc_sys5.h
字号:
/* Define parameter offset on the stack. * NOTICE: Parameters are numbered 0, 1, ..., n. */#define PPC_PAR(i) (PPC_LINKAGE_AREA+(i)*4)/***************************************************************************** Define stack frames *****************************************************************************/ /* Define the "qt_blocki" and "qt_abort" stack frame. We use the same stack * frame for both. * top + S -> +==========================+ top + S - 4 -> | | GPR31 + GPR SAVE AREA + .............. + + top + S - 19 * 4 -> | | GPR13 +--------------------------+ | | + ALIGNMEBNT PAD + .............. + (if needed) + | | +--------------------------+ top + 8 -> | CR SAVE | +--------------------------+ | | + LINKAGE AREA + top -> | | +==========================+ */#define QUICKTHREADS_BLOCKI_FRAME_SIZE \ PPC_ROUND_STACK(PPC_LINKAGE_AREA+4+PPC_GPR_SAVE_AREA) #define QUICKTHREADS_BLOCKI_CR_SAVE 8/* Offset to the base of the GPR save area. Save from GPR13 to GPR31 * increasing address. */#define QUICKTHREADS_BLOCKI_GPR_SAVE(i) (QUICKTHREADS_BLOCKI_FRAME_SIZE-4+(i-31)*4)/* Define the "qt_block" stack frame. Notice that since "qt_black" calls * "qt_blocki", GPR registers are saved into "qt_blocki" stack frame. * top + S -> +==========================+ top + S - 8 -> | | FPR31 + FPR SAVE AREA + .............. + + top + S - 18 * 8 -> | | FPR14 +--------------------------+ | | + ALIGNMEBNT PAD + .............. + (if needed) + | | +--------------------------+ | | + LINKAGE AREA + top -> | | +==========================+ */#define QUICKTHREADS_BLOCK_FRAME_SIZE \ PPC_ROUND_STACK(PPC_LINKAGE_AREA+PPC_FPR_SAVE_AREA)/* Offset to the location where registers are saved. */#define QUICKTHREADS_BLOCK_FPR_SAVE(i) (QUICKTHREADS_BLOCK_FRAME_SIZE-8+(i-31)*8)/* Define the "qt_start" frame size. It consists just of the linkage area and * the parameter area. * +==========================+ | | + ALIGNMEBNT PAD + .............. + (if needed) + | | +--------------------------+ | | only par + + | | userf par + PARAMETER AREA + | | t par + + top + 8 -> | | u par +--------------------------+ | | + LINKAGE AREA + top -> | | +==========================+ */#define QUICKTHREADS_START_FRAME_SIZE PPC_ROUND_STACK(PPC_LINKAGE_AREA+PPC_PARAM_AREA(4))/* Define the "qt_vstart" frame. It consists of the linkage area, the fix parameter * area, the variant argument list and a local variable area used in "qt_vstart" * implementation. * backchain -> +==========================+ backchain - 4 -> | | + LOCAL VARIABLES AREA + .............. + + | | +--------------------------+ | | + ALIGNMEBNT PAD + .............. + (if needed) + | | +--------------------------+ | | arg(n) + + | | + VARIABLE ARGUMENT LIST + .............. + for userf call + | | arg(1) + + top + 8 + 16 -> | | arg(0) +--------------------------+ | | cleanup par + + | | userf par + PARAMETER AREA + | | startup par + + top + 8 -> | | t par +--------------------------+ | | + LINKAGE AREA + top -> | | +==========================+ */#define QUICKTHREADS_VARGS_LOCAL_AREA (4*4) /* local variable area *//* The offset the stack will be moved back before to call "userf(...)". * The linckage area must be moved to be adiacent to the part of the variant * argument list that is in the stack. Notice that, since the first 8 * parameters are passed via registers, the offset is equal to the size of * 4+8 parameters. */#define QUICKTHREADS_VARGS_BKOFF PPC_PARAM_AREA(4+8)#define QUICKTHREADS_VSTART_FRAME_SIZE(varbytes) \ PPC_ROUND_STACK(PPC_LINKAGE_AREA+QUICKTHREADS_VARGS_BKOFF+(varbytes)+ \ QUICKTHREADS_VARGS_LOCAL_AREA)/* Offset to the base of the varian argument list */#define QUICKTHREADS_VSTART_LIST_BASE (PPC_LINKAGE_AREA+PPC_PARAM_AREA(4))/* Notice that qt_start and qt_vstart have no parameters, actually their * parameters are written in their stack frame during thread initialization */extern void qt_start(void);extern void qt_vstart(void);/* Offset (in words) of the location where the block routine saves its return * address (i.e. LR). SP points the top of the block routine stack and, * following ppc calling conventions, the return address is saved in the * previous (caller's) stack frame. */#define QUICKTHREADS_RETURN_INDEX ((QUICKTHREADS_BLOCKI_FRAME_SIZE+PPC_LR_SAVE)/sizeof(PPC_W))/* static variable used to get the stack bottom in "VARGS" initialization */static void *qt_sp_bottom_save;#define QUICKTHREADS_ARG_INDEX(i) ((QUICKTHREADS_BLOCKI_FRAME_SIZE+PPC_PAR(i))/sizeof(PPC_W))/***************************************************************************** QuickThreads needed definitions *****************************************************************************/#define QUICKTHREADS_GROW_DOWN#define QUICKTHREADS_STKALIGN PPC_STACK_INCRtypedef PPC_W qt_word_t;/* This macro is used by "QUICKTHREADS_ARGS" to initialize a single argument thread. * - set "qt_start" as the "qt_block" or "qt_blocki" return address; * - set the top of the stack backchain; * - set the next backchain (not needed, but just to be "clean"). */#define QUICKTHREADS_ARGS_MD(sp) \ (QUICKTHREADS_SPUT (sp, QUICKTHREADS_RETURN_INDEX, qt_start), \ QUICKTHREADS_SPUT (sp, 0, sp+QUICKTHREADS_BLOCKI_FRAME_SIZE), \ QUICKTHREADS_SPUT (sp, QUICKTHREADS_BLOCKI_FRAME_SIZE/sizeof(PPC_W), \ sp+QUICKTHREADS_BLOCKI_FRAME_SIZE+QUICKTHREADS_START_FRAME_SIZE))/* This macro is used by "QUICKTHREADS_VARGS" to initialize a variant argument thread. * It returns the pointer to the top of the argument list. * We also use it to get the stack bottom via a static variable. This is a bit * "dirty", it could be better to do it in "qt_vargs", but we don't want change * anything out of this file. * We need the stack bottom to allocate a local variable area used by * "qt_vstart". */#define QUICKTHREADS_VARGS_MD0(sp, varbytes) \ ((qt_sp_bottom_save = sp), \ ((qt_t *)(((char *)(sp)) - \ (QUICKTHREADS_VSTART_FRAME_SIZE(varbytes)-QUICKTHREADS_VSTART_LIST_BASE))))/* This macro is used by "QUICKTHREADS_VARGS" to initialize a variant argument thread. * - set "qt_start" as the "qt_block" or "qt_blocki" return address; * - set the top of the stackback chain; * - set the next backchain (it points the stack botton). */#define QUICKTHREADS_VARGS_MD1(sp) \ (QUICKTHREADS_SPUT (sp, QUICKTHREADS_RETURN_INDEX, qt_vstart), \ QUICKTHREADS_SPUT (sp, 0, sp+QUICKTHREADS_BLOCKI_FRAME_SIZE), \ QUICKTHREADS_SPUT (sp, (QUICKTHREADS_BLOCKI_FRAME_SIZE)/sizeof(PPC_W), \ qt_sp_bottom_save))/* Activate "qt_vargs" as the initialization routine for the variant * argument threads */ #define QUICKTHREADS_VARGS_DEFAULT /* Override "qt_vargs" with "qt_vargs_stdarg". * On LinuxPPC "qt_vargs" doesn't work, "qt_vargs_stdarg" uses a more * standard way to retrieve arguments from the variant list. */#define QUICKTHREADS_VARGS(sp, nbytes, vargs, pt, startup, vuserf, cleanup) \ ((qt_t *)qt_vargs_stdarg (sp, nbytes, vargs, pt, startup, vuserf, cleanup))/* This macro is used by "QUICKTHREADS_ADJ(sp)" to get the stack top form the stack * bottom during a single argument thread initialization. * It is the space we need to allocate for a single argument thread: the stack * frame for the block routine ("qt_block" or "qt_blocki") and for "qt_start". */#define QUICKTHREADS_STKBASE \ (QUICKTHREADS_BLOCKI_FRAME_SIZE+QUICKTHREADS_START_FRAME_SIZE)/* This macro is used by "QUICKTHREADS_VADJ(sp)" to get the stack top from the base * of the variant argument list during a variant argument thread initialization. */#define QUICKTHREADS_VSTKBASE (QUICKTHREADS_BLOCKI_FRAME_SIZE+QUICKTHREADS_VSTART_LIST_BASE)/* The *index* (positive offset) of where to put each value. */#define QUICKTHREADS_ARGU_INDEX QUICKTHREADS_ARG_INDEX(0)#define QUICKTHREADS_ARGT_INDEX QUICKTHREADS_ARG_INDEX(1)#define QUICKTHREADS_USER_INDEX QUICKTHREADS_ARG_INDEX(2)#define QUICKTHREADS_ONLY_INDEX QUICKTHREADS_ARG_INDEX(3)#define QUICKTHREADS_VARGT_INDEX QUICKTHREADS_ARG_INDEX(0)#define QUICKTHREADS_VSTARTUP_INDEX QUICKTHREADS_ARG_INDEX(1)#define QUICKTHREADS_VUSERF_INDEX QUICKTHREADS_ARG_INDEX(2)#define QUICKTHREADS_VCLEANUP_INDEX QUICKTHREADS_ARG_INDEX(3)#endif /* ndef QUICKTHREADS_POWERPC_H */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -