diff options
author | Maurus Cuelenaere <mcuelenaere@gmail.com> | 2009-05-06 19:51:34 +0000 |
---|---|---|
committer | Maurus Cuelenaere <mcuelenaere@gmail.com> | 2009-05-06 19:51:34 +0000 |
commit | 580b1a5c4b305c7cb320415267c5e1b88b053948 (patch) | |
tree | 556252fdb384d4f26f027f6586becbe793ded2c6 | |
parent | 84ea3f25300aa70d00093c64a5d6301fcde572a9 (diff) | |
download | rockbox-580b1a5c4b305c7cb320415267c5e1b88b053948.tar.gz rockbox-580b1a5c4b305c7cb320415267c5e1b88b053948.zip |
MIPS: don't save gp register when switching threads
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@20863 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r-- | firmware/export/thread.h | 8 | ||||
-rw-r--r-- | firmware/thread.c | 31 |
2 files changed, 18 insertions, 21 deletions
diff --git a/firmware/export/thread.h b/firmware/export/thread.h index 7fe128d599..cd27324740 100644 --- a/firmware/export/thread.h +++ b/firmware/export/thread.h | |||
@@ -109,10 +109,10 @@ struct regs | |||
109 | #elif defined(CPU_MIPS) | 109 | #elif defined(CPU_MIPS) |
110 | struct regs | 110 | struct regs |
111 | { | 111 | { |
112 | uint32_t r[10]; /* 0-36 - Registers s0-s7, gp, fp */ | 112 | uint32_t r[9]; /* 0-32 - Registers s0-s7, fp */ |
113 | uint32_t sp; /* 40 - Stack pointer */ | 113 | uint32_t sp; /* 36 - Stack pointer */ |
114 | uint32_t ra; /* 44 - Return address */ | 114 | uint32_t ra; /* 40 - Return address */ |
115 | uint32_t start; /* 48 - Thread start address, or NULL when started */ | 115 | uint32_t start; /* 44 - Thread start address, or NULL when started */ |
116 | }; | 116 | }; |
117 | #endif /* CONFIG_CPU */ | 117 | #endif /* CONFIG_CPU */ |
118 | #else | 118 | #else |
diff --git a/firmware/thread.c b/firmware/thread.c index 6efe8252e7..755dd7af3a 100644 --- a/firmware/thread.c +++ b/firmware/thread.c | |||
@@ -943,21 +943,20 @@ static void __attribute__((used)) _start_thread(void) | |||
943 | ".set noreorder \n" | 943 | ".set noreorder \n" |
944 | ".set noat \n" | 944 | ".set noat \n" |
945 | "lw $8, 4($9) \n" /* Fetch thread function pointer ($8 = t0, $9 = t1) */ | 945 | "lw $8, 4($9) \n" /* Fetch thread function pointer ($8 = t0, $9 = t1) */ |
946 | "lw $29, 40($9) \n" /* Set initial sp(=$29) */ | 946 | "lw $29, 36($9) \n" /* Set initial sp(=$29) */ |
947 | "jalr $8 \n" /* Start the thread */ | 947 | "jalr $8 \n" /* Start the thread */ |
948 | "sw $0, 48($9) \n" /* Clear start address */ | 948 | "sw $0, 44($9) \n" /* Clear start address */ |
949 | ".set at \n" | 949 | ".set at \n" |
950 | ".set reorder \n" | 950 | ".set reorder \n" |
951 | ::: "t0" | ||
952 | ); | 951 | ); |
953 | thread_exit(); | 952 | thread_exit(); |
954 | } | 953 | } |
955 | 954 | ||
956 | /* Place context pointer in s0 slot, function pointer in s1 slot, and | 955 | /* Place context pointer in s0 slot, function pointer in s1 slot, and |
957 | * start_thread pointer in context_start */ | 956 | * start_thread pointer in context_start */ |
958 | #define THREAD_STARTUP_INIT(core, thread, function) \ | 957 | #define THREAD_STARTUP_INIT(core, thread, function) \ |
959 | ({ (thread)->context.r[0] = (uint32_t)&(thread)->context, \ | 958 | ({ (thread)->context.r[0] = (uint32_t)&(thread)->context, \ |
960 | (thread)->context.r[1] = (uint32_t)(function), \ | 959 | (thread)->context.r[1] = (uint32_t)(function), \ |
961 | (thread)->context.start = (uint32_t)start_thread; }) | 960 | (thread)->context.start = (uint32_t)start_thread; }) |
962 | 961 | ||
963 | /*--------------------------------------------------------------------------- | 962 | /*--------------------------------------------------------------------------- |
@@ -977,10 +976,9 @@ static inline void store_context(void* addr) | |||
977 | "sw $21, 20(%0) \n" /* s5 */ | 976 | "sw $21, 20(%0) \n" /* s5 */ |
978 | "sw $22, 24(%0) \n" /* s6 */ | 977 | "sw $22, 24(%0) \n" /* s6 */ |
979 | "sw $23, 28(%0) \n" /* s7 */ | 978 | "sw $23, 28(%0) \n" /* s7 */ |
980 | "sw $28, 32(%0) \n" /* gp */ | 979 | "sw $30, 32(%0) \n" /* fp */ |
981 | "sw $30, 36(%0) \n" /* fp */ | 980 | "sw $29, 36(%0) \n" /* sp */ |
982 | "sw $29, 40(%0) \n" /* sp */ | 981 | "sw $31, 40(%0) \n" /* ra */ |
983 | "sw $31, 44(%0) \n" /* ra */ | ||
984 | ".set at \n" | 982 | ".set at \n" |
985 | ".set reorder \n" | 983 | ".set reorder \n" |
986 | : : "r" (addr) | 984 | : : "r" (addr) |
@@ -996,7 +994,7 @@ static inline void load_context(const void* addr) | |||
996 | asm volatile ( | 994 | asm volatile ( |
997 | ".set noat \n" | 995 | ".set noat \n" |
998 | ".set noreorder \n" | 996 | ".set noreorder \n" |
999 | "lw $8, 48(%0) \n" /* Get start address ($8 = t0) */ | 997 | "lw $8, 44(%0) \n" /* Get start address ($8 = t0) */ |
1000 | "beqz $8, running \n" /* NULL -> already running */ | 998 | "beqz $8, running \n" /* NULL -> already running */ |
1001 | "nop \n" | 999 | "nop \n" |
1002 | "jr $8 \n" | 1000 | "jr $8 \n" |
@@ -1010,10 +1008,9 @@ static inline void load_context(const void* addr) | |||
1010 | "lw $21, 20(%0) \n" /* s5 */ | 1008 | "lw $21, 20(%0) \n" /* s5 */ |
1011 | "lw $22, 24(%0) \n" /* s6 */ | 1009 | "lw $22, 24(%0) \n" /* s6 */ |
1012 | "lw $23, 28(%0) \n" /* s7 */ | 1010 | "lw $23, 28(%0) \n" /* s7 */ |
1013 | "lw $28, 32(%0) \n" /* gp */ | 1011 | "lw $30, 32(%0) \n" /* fp */ |
1014 | "lw $30, 36(%0) \n" /* fp */ | 1012 | "lw $29, 36(%0) \n" /* sp */ |
1015 | "lw $29, 40(%0) \n" /* sp */ | 1013 | "lw $31, 40(%0) \n" /* ra */ |
1016 | "lw $31, 44(%0) \n" /* ra */ | ||
1017 | ".set at \n" | 1014 | ".set at \n" |
1018 | ".set reorder \n" | 1015 | ".set reorder \n" |
1019 | : : "r" (addr) : "t0", "t1" | 1016 | : : "r" (addr) : "t0", "t1" |
@@ -1034,9 +1031,9 @@ static inline void core_sleep(void) | |||
1034 | "move $9, $8 \n" /* move t1, t0 */ | 1031 | "move $9, $8 \n" /* move t1, t0 */ |
1035 | "la $10, 0x8000000 \n" /* la t2, 0x8000000 */ | 1032 | "la $10, 0x8000000 \n" /* la t2, 0x8000000 */ |
1036 | "or $8, $8, $10 \n" /* Enable reduced power mode */ | 1033 | "or $8, $8, $10 \n" /* Enable reduced power mode */ |
1037 | "mtc0 $8, $12 \n" | 1034 | "mtc0 $8, $12 \n" /* mtc t0, $12 */ |
1038 | "wait \n" | 1035 | "wait \n" |
1039 | "mtc0 $9, $12 \n" | 1036 | "mtc0 $9, $12 \n" /* mtc t1, $12 */ |
1040 | ".set mips0 \n" | 1037 | ".set mips0 \n" |
1041 | ::: "t0", "t1", "t2" | 1038 | ::: "t0", "t1", "t2" |
1042 | ); | 1039 | ); |