Changeset fca4207 in mainline
- Timestamp:
- 2006-05-04T11:04:23Z (19 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 4a7c273
- Parents:
- f33cb0b9
- Location:
- libc/arch/ppc32
- Files:
-
- 1 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
libc/arch/ppc32/include/context_offset.h
rf33cb0b9 rfca4207 1 /* struct context */ 2 #define OFFSET_SP 0x0 3 #define OFFSET_PC 0x4 4 #define OFFSET_R2 0x8 5 #define OFFSET_R13 0xc 6 #define OFFSET_R14 0x10 7 #define OFFSET_R15 0x14 8 #define OFFSET_R16 0x18 9 #define OFFSET_R17 0x1c 10 #define OFFSET_R18 0x20 11 #define OFFSET_R19 0x24 12 #define OFFSET_R20 0x28 13 #define OFFSET_R21 0x2c 14 #define OFFSET_R22 0x30 15 #define OFFSET_R23 0x34 16 #define OFFSET_R24 0x38 17 #define OFFSET_R25 0x3c 18 #define OFFSET_R26 0x40 19 #define OFFSET_R27 0x44 20 #define OFFSET_R28 0x48 21 #define OFFSET_R29 0x4c 22 #define OFFSET_R30 0x50 23 #define OFFSET_R31 0x54 24 #define OFFSET_CR 0x58 25 #define OFFSET_CR 0x58 -
libc/arch/ppc32/include/psthread.h
rf33cb0b9 rfca4207 32 32 #include <types.h> 33 33 34 /* We define our own context_set, because we need to set 35 * the TLS pointer to the tcb+0x7000 36 * 37 * See tls_set in thread.h 38 */ 34 39 #define context_set(c, _pc, stack, size, ptls) \ 35 40 (c)->pc = (sysarg_t) (_pc); \ 36 41 (c)->sp = ((sysarg_t) (stack)) + (size) - SP_DELTA; \ 37 (c)->tls = ((sysarg_t)(ptls)) + 0x7000 + sizeof(tcb_t);42 (c)->tls = ((sysarg_t) (ptls)) + 0x7000 + sizeof(tcb_t); 38 43 39 #define SP_DELTA (8+16)44 #define SP_DELTA 16 40 45 41 typedef struct 46 typedef struct { 42 47 uint32_t sp; 43 48 uint32_t pc; 44 49 45 50 uint32_t tls; 46 } context_t; 51 uint32_t r13; 52 uint32_t r14; 53 uint32_t r15; 54 uint32_t r16; 55 uint32_t r17; 56 uint32_t r18; 57 uint32_t r19; 58 uint32_t r20; 59 uint32_t r21; 60 uint32_t r22; 61 uint32_t r23; 62 uint32_t r24; 63 uint32_t r25; 64 uint32_t r26; 65 uint32_t r27; 66 uint32_t r28; 67 uint32_t r29; 68 uint32_t r30; 69 uint32_t r31; 70 71 uint32_t cr; 72 } __attribute__ ((packed)) context_t; 47 73 48 74 #endif -
libc/arch/ppc32/include/thread.h
rf33cb0b9 rfca4207 30 30 #define __LIBC__ppc32__THREAD_H__ 31 31 32 /* I did not find any specification (neither MIPS nor PowerPC), but 33 * as I found it 34 * - it uses Variant II 35 * - TCB is at Address(First TLS Block)+0x7000. 36 * - DTV is at Address(First TLS Block)+0x8000 37 * - What would happen if the TLS data was larger then 0x7000? 38 * - The linker never accesses DTV directly, has the second definition any 39 * sense? 40 * We will make it this way: 41 * - TCB is at TP-0x7000-sizeof(tcb) 42 * - No assumption about DTV etc., but it will not have a fixed address 43 */ 44 #define PPC_TP_OFFSET 0x7000 45 32 46 typedef struct { 33 47 void *pst_data; … … 36 50 static inline void __tcb_set(tcb_t *tcb) 37 51 { 52 void *tp = tcb; 53 tp += PPC_TP_OFFSET + sizeof(tcb_t); 54 55 asm volatile ( 56 "mr %%r2, %0\n" 57 : 58 : "r" (tp) 59 ); 38 60 } 39 61 40 62 static inline tcb_t * __tcb_get(void) 41 63 { 64 void * retval; 65 66 asm volatile ( 67 "mr %0, %%r2\n" 68 : "=r" (retval) 69 ); 70 71 return (tcb_t *)(retval - PPC_TP_OFFSET - sizeof(tcb_t)); 42 72 } 43 73 -
libc/arch/ppc32/src/psthread.S
rf33cb0b9 rfca4207 32 32 .global context_restore 33 33 34 #include <libarch/regname.h> 34 35 #include <libarch/context_offset.h> 35 36 37 .macro CONTEXT_STORE r 38 stw sp, OFFSET_SP(\r) 39 stw r2, OFFSET_R2(\r) 40 stw r13, OFFSET_R13(\r) 41 stw r14, OFFSET_R14(\r) 42 stw r15, OFFSET_R15(\r) 43 stw r16, OFFSET_R16(\r) 44 stw r17, OFFSET_R17(\r) 45 stw r18, OFFSET_R18(\r) 46 stw r19, OFFSET_R19(\r) 47 stw r20, OFFSET_R20(\r) 48 stw r21, OFFSET_R21(\r) 49 stw r22, OFFSET_R22(\r) 50 stw r23, OFFSET_R23(\r) 51 stw r24, OFFSET_R24(\r) 52 stw r25, OFFSET_R25(\r) 53 stw r26, OFFSET_R26(\r) 54 stw r27, OFFSET_R27(\r) 55 stw r28, OFFSET_R28(\r) 56 stw r29, OFFSET_R29(\r) 57 stw r30, OFFSET_R30(\r) 58 stw r31, OFFSET_R31(\r) 59 .endm 60 61 .macro CONTEXT_LOAD r 62 lwz sp, OFFSET_SP(\r) 63 lwz r2, OFFSET_R2(\r) 64 lwz r13, OFFSET_R13(\r) 65 lwz r14, OFFSET_R14(\r) 66 lwz r15, OFFSET_R15(\r) 67 lwz r16, OFFSET_R16(\r) 68 lwz r17, OFFSET_R17(\r) 69 lwz r18, OFFSET_R18(\r) 70 lwz r19, OFFSET_R19(\r) 71 lwz r20, OFFSET_R20(\r) 72 lwz r21, OFFSET_R21(\r) 73 lwz r22, OFFSET_R22(\r) 74 lwz r23, OFFSET_R23(\r) 75 lwz r24, OFFSET_R24(\r) 76 lwz r25, OFFSET_R25(\r) 77 lwz r26, OFFSET_R26(\r) 78 lwz r27, OFFSET_R27(\r) 79 lwz r28, OFFSET_R28(\r) 80 lwz r29, OFFSET_R29(\r) 81 lwz r30, OFFSET_R30(\r) 82 lwz r31, OFFSET_R31(\r) 83 .endm 84 36 85 context_save: 86 CONTEXT_STORE r3 87 88 mflr r4 89 stw r4, OFFSET_PC(r3) 90 91 mfcr r4 92 stw r4, OFFSET_CR(r3) 93 94 # context_save returns 1 95 li r3, 1 37 96 blr 38 97 39 98 40 99 context_restore: 100 CONTEXT_LOAD r3 101 102 lwz r4, OFFSET_CR(r3) 103 mtcr r4 104 105 lwz r4, OFFSET_PC(r3) 106 mtlr r4 107 108 # context_restore returns 0 109 li r3, 0 41 110 blr -
libc/arch/ppc32/src/thread.c
rf33cb0b9 rfca4207 34 34 * @param data Start of data section 35 35 * @return pointer to tcb_t structure 36 * 36 37 */ 37 38 tcb_t * __alloc_tls(void **data, size_t size) … … 40 41 41 42 *data = malloc(sizeof(tcb_t) + size); 42 43 43 tcb = (tcb_t *) (*data + size); 44 45 44 return tcb; 46 45 }
Note:
See TracChangeset
for help on using the changeset viewer.