diff options
author | Michael Sevakis <jethead71@rockbox.org> | 2008-04-06 22:08:36 +0000 |
---|---|---|
committer | Michael Sevakis <jethead71@rockbox.org> | 2008-04-06 22:08:36 +0000 |
commit | 9ba80c9641e19b421d5c7544d081a2d458c509b1 (patch) | |
tree | c6a93fd7afc3c6264db1becd699ab57197256e44 | |
parent | c2a01fdc7a4f80e0d8e6305944ac1efca3040df0 (diff) | |
download | rockbox-9ba80c9641e19b421d5c7544d081a2d458c509b1.tar.gz rockbox-9ba80c9641e19b421d5c7544d081a2d458c509b1.zip |
Get device-specific code out of init_threads and add core_thread_init to be implemented for multicore devices.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@17000 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r-- | firmware/thread.c | 51 |
1 files changed, 37 insertions, 14 deletions
diff --git a/firmware/thread.c b/firmware/thread.c index 0f5378de7b..0049df3e90 100644 --- a/firmware/thread.c +++ b/firmware/thread.c | |||
@@ -733,6 +733,31 @@ static void __attribute__((naked)) | |||
733 | ); | 733 | ); |
734 | (void)core; (void)thread; | 734 | (void)core; (void)thread; |
735 | } | 735 | } |
736 | |||
737 | /*--------------------------------------------------------------------------- | ||
738 | * Do any device-specific inits for the threads and synchronize the kernel | ||
739 | * initializations. | ||
740 | *--------------------------------------------------------------------------- | ||
741 | */ | ||
742 | static void core_thread_init(unsigned int core) | ||
743 | { | ||
744 | if (core == CPU) | ||
745 | { | ||
746 | /* Wake up coprocessor and let it initialize kernel and threads */ | ||
747 | #ifdef CPU_PP502x | ||
748 | MBX_MSG_CLR = 0x3f; | ||
749 | #endif | ||
750 | COP_CTL = PROC_WAKE; | ||
751 | /* Sleep until COP has finished */ | ||
752 | CPU_CTL = PROC_SLEEP; | ||
753 | nop; nop; nop; | ||
754 | } | ||
755 | else | ||
756 | { | ||
757 | /* Wake the CPU and return */ | ||
758 | CPU_CTL = PROC_WAKE; | ||
759 | } | ||
760 | } | ||
736 | #endif /* NUM_CORES */ | 761 | #endif /* NUM_CORES */ |
737 | 762 | ||
738 | #elif CONFIG_CPU == S3C2440 | 763 | #elif CONFIG_CPU == S3C2440 |
@@ -2955,24 +2980,22 @@ void init_threads(void) | |||
2955 | thread->stack = stackbegin; | 2980 | thread->stack = stackbegin; |
2956 | thread->stack_size = (uintptr_t)stackend - (uintptr_t)stackbegin; | 2981 | thread->stack_size = (uintptr_t)stackend - (uintptr_t)stackbegin; |
2957 | #if NUM_CORES > 1 /* This code path will not be run on single core targets */ | 2982 | #if NUM_CORES > 1 /* This code path will not be run on single core targets */ |
2958 | /* TODO: HAL interface for this */ | 2983 | /* Wait for other processors to finish their inits since create_thread |
2959 | /* Wake up coprocessor and let it initialize kernel and threads */ | 2984 | * isn't safe to call until the kernel inits are done. The first |
2960 | #ifdef CPU_PP502x | 2985 | * threads created in the system must of course be created by CPU. */ |
2961 | MBX_MSG_CLR = 0x3f; | 2986 | core_thread_init(CPU); |
2962 | #endif | ||
2963 | COP_CTL = PROC_WAKE; | ||
2964 | /* Sleep until finished */ | ||
2965 | CPU_CTL = PROC_SLEEP; | ||
2966 | nop; nop; nop; nop; | ||
2967 | } | 2987 | } |
2968 | else | 2988 | else |
2969 | { | 2989 | { |
2970 | /* Initial stack is the COP idle stack */ | 2990 | /* Initial stack is the idle stack */ |
2971 | thread->stack = cop_idlestackbegin; | 2991 | thread->stack = idle_stacks[core]; |
2972 | thread->stack_size = IDLE_STACK_SIZE; | 2992 | thread->stack_size = IDLE_STACK_SIZE; |
2973 | /* Get COP safely primed inside switch_thread where it will remain | 2993 | /* After last processor completes, it should signal all others to |
2974 | * until a thread actually exists on it */ | 2994 | * proceed or may signal the next and call thread_exit(). The last one |
2975 | CPU_CTL = PROC_WAKE; | 2995 | * to finish will signal CPU. */ |
2996 | core_thread_init(core); | ||
2997 | /* Other cores do not have a main thread - go idle inside switch_thread | ||
2998 | * until a thread can run on the core. */ | ||
2976 | thread_exit(); | 2999 | thread_exit(); |
2977 | #endif /* NUM_CORES */ | 3000 | #endif /* NUM_CORES */ |
2978 | } | 3001 | } |