📄 gencluster.c
字号:
/*
* Copyright (c) 1995,2000 TriMedia Technologies Inc.
*
* +------------------------------------------------------------------+
* | This software is furnished under a license and may only be used |
* | and copied in accordance with the terms and conditions of such |
* | a license and with the inclusion of this copyright notice. This |
* | software or any other copies of this software may not be provided|
* | or otherwise made available to any other person. The ownership |
* | and title of this software is not transferred. |
* | |
* | The information in this software is subject to change without |
* | any prior notice and should not be construed as a commitment by |
* | TriMedia Technologies. |
* | |
* | this code and information is provided "as is" without any |
* | warranty of any kind, either expressed or implied, including but |
* | not limited to the implied warranties of merchantability and/or |
* | fitness for any particular purpose. |
* +------------------------------------------------------------------+
*
* Module name : GenCluster.c 1.2
*
* Last update : 16:52:57 - 00/06/16
*
* Description :
*
* This program is a demonstration of a multiprocessor
* cluster image generator (object files to image files).
* Cluster information is hardcoded in a number of static arrays.
*
*/
#include "tmlib/TMDownLoader.h"
#include "assert.h"
#include "stdio.h"
#include "stdlib.h"
#include "sys/types.h"
#include "sys/stat.h"
static void EE( TMDwnLdr_Status status, Int line)
{
if (status != TMDwnLdr_OK) {
fprintf(stderr, "Error at line %d: %s\n", line, TMDwnLdr_get_last_error(status) );
}
}
#define E(x) EE(x,__LINE__)
static void
write_image(String filename, Pointer image, Int length)
{
FILE *f;
f = fopen(filename, "wb");
assert(f != Null);
fwrite(image, 1, length, f);
fclose(f);
}
static void
GenerateMPCluster(UInt nrof_nodes,
String input_filenames[],
String output_filenames[],
tmHostType_t host_type,
UInt mmio_bases[],
UInt cpu_frequencies[],
UInt sdram_bases[],
UInt sdram_lengths[]
)
{
Int node;
TMDwnLdr_SharedSectionTab_Handle shared_sections;
TMDwnLdr_create_shared_section_table(&shared_sections);
for (node = 0; node < nrof_nodes; node++) {
TMDwnLdr_Object_Handle handle;
Int alignment, minimal_image_size;
Pointer image;
E(TMDwnLdr_load_object_from_file(input_filenames[node], shared_sections, &handle));
E(TMDwnLdr_multiproc_relocate(handle, host_type, (Pointer)mmio_bases, node, nrof_nodes,
cpu_frequencies[node], (Address)sdram_bases[node], sdram_lengths[node],
TMDwnLdr_LeaveCachingToDownloader));
E(TMDwnLdr_get_image_size(handle, &minimal_image_size, &alignment));
image= malloc(minimal_image_size);
assert(image != Null);
assert(minimal_image_size < (Int) sdram_bases[node] + sdram_lengths[node]);
assert((Int) sdram_bases[node] % alignment == 0);
E(TMDwnLdr_get_memory_image(handle, image));
write_image( output_filenames[node], image, minimal_image_size );
free(image);
E(TMDwnLdr_unload_object(handle));
}
TMDwnLdr_unload_shared_section_table(shared_sections);
}
static String input_filenames []= { "a.out", "b.out", "a.out" } ; /* need not be different */
static String output_filenames []= { "0.mi", "1.mi", "2.mi" } ;
static UInt mmio_bases []= { 0x00000000, 0x00000000, 0x00000000 } ; /* fill */
static UInt cpu_frequencies []= { 133000000, 133000000, 133000000 } ; /* in */
static UInt sdram_bases []= { 0x00000000, 0x00000000, 0x00000000 } ; /* proper */
static UInt sdram_lengths []= { 0x00800000, 0x00800000, 0x00800000 } ; /* values */
main()
{
GenerateMPCluster( 3, input_filenames, output_filenames, tmNoHost, mmio_bases, cpu_frequencies, sdram_bases, sdram_lengths );
exit(0);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -