00001 #include <malloc_align.h> 00002 #include <free_align.h> 00003 #include <stdlib.h> 00004 #include <string.h> 00005 00006 #include <moc.h> 00007 #include <ppu/moc.h> 00008 #include <internal/imoc.h> 00009 #include <internal/ppu/imoc_core_ppu.h> 00010 00011 int MOC_Finalize() 00012 { 00013 unsigned int i; 00014 extern moc_internal_buffer_node_t* bmalloc_first_node; 00015 /* wait till all SPU-threads are finished */ 00016 for (i = 0; i < moc_spu_thread_count; i++) 00017 { 00018 while (spe_out_mbox_status(moc_spu_thread_list[i].speid) < 1) 00019 ; 00020 } 00021 for (i = 0; i < moc_spu_thread_count; i++) 00022 { 00023 if (spe_in_mbox_write(moc_spu_thread_list[i].speid, &i, 1, 00024 SPE_MBOX_ALL_BLOCKING) != 1) 00025 return MOC_ERR_INTERN; 00026 _free_align((void*) moc_spu_thread_list[i].buffer_base); 00027 } 00028 /* free local resources */ 00029 _free_align((void*) node_handle.message_queue_base); 00030 _free_align((void*) node_handle.status_array_base); 00031 _free_align((void*) node_handle.buffer_base); 00032 _free_align((void*) node_handle.signal_area); 00033 _free_align((void*) node_handle.moc_process_list); 00034 while (bmalloc_first_node) 00035 { 00036 moc_internal_buffer_node_t* temp = bmalloc_first_node; 00037 bmalloc_first_node = bmalloc_first_node->next_node; 00038 free(temp); 00039 } 00040 return 0; 00041 } 00042
1.5.6