Пример #1
0
int main(int argc, char *argv[])
{
	int *in, *out, i;

	/* Initialise libbc using MPI. */
	MPI_Init(&argc, &argv);
	bc_init(BC_ERR);

	if (bc_size != 9) {
		if (bc_rank == 0)
			printf("ERROR: 9 processes are required.\n"
				   "\n\tUSAGE: mpirun -c 9 pipeline_farm\n\n");
		bc_final();
		MPI_Finalize();
		return -1;
	}

	/* SPMD, per process stage function. */
	switch(bc_rank) {
	case 0:
		in = (int *) malloc(sizeof(int)*100);
		printf("[%d] Input:\n", bc_rank);
		for (i = 0; i < 100; i++) {
			in[i] = i;
  			printf("%d ", in[i]);
		}
		printf("\n");
		stage_0(in);
		free(in);
		break;
	case 1:
		stage_1();
		break;
	case 2:
		stage_3();
		break;
	case 3:
		out = (int *) malloc(sizeof(int)*2);
		stage_4(out);
 		printf("[%d] Sum: %d\n", bc_rank, out[0]);
		free(out);
		break;
	case 4:
	case 5:
	case 6:
	case 7:
	case 8:
		stage_2();
		break;
	default :
		break;
	}
	bc_final();
	MPI_Finalize();
	return 0;
}
Пример #2
0
int     main            (int argc, char * argv [])
{
    int     x;
    uchar   *buf = (uchar*) malloc (65536);
    char    *pc;

    assert (buf != 0);

    rc = libusb_init (NULL);
    assert (rc == 0);

    if (NULL == (realpath (argv [0], szBasePath)))
      {
        printf ("Can't get realpath\n");
        return (1);
      }
    for (pc = strchr (szBasePath, '\0'); *pc != '/'; pc--) *pc = '\0';

    FN = &FN_sun7i;                             // A20 by default.

    while (argc > 1)
      {
        if (strcmp (argv [1], (char *) "-t") == 0)
          {
            USBTests (buf);
            goto bye;
          }
        if (strcmp (argv [1], (char *) "-H") == 0)
          {
            H3_Tests (buf);
            goto bye;
          }
        if (strcmp (argv [1], (char *) "-l") == 0)
          {
            Lime_Tests (buf);
            goto bye;
          }
        if (strcmp (argv [1], (char *) "-a") == 0)
          {
            A20_Tests (buf);
            goto bye;
          }
        if (strcmp (argv [1], (char *) "-h") == 0)
          {
            printf ("no flags = update boot0 and boot1.\n");
            printf ("-x = allow force continue when error.\n");
            printf ("-e = erase chip before boot update.\n");
            printf ("-r = read all NAND, save to NAND.DAT.\n");
            printf ("-w = write NAND.DAT to device NAND.\n");
            printf ("-t = USB tests.\n");
            printf ("-i <file list> = create NAND MBR, write MBR and files to NAND,\n");
            printf ("  each file is a partition to write, the file name is used as\n");
            printf ("  the partition name in the MBR.\n");
            printf ("  Each file entry consists of a name and start and size enclosed in quotes.\n");
            printf ("  The start is the sector key (0 = use next available sector).\n");
            printf ("  The size is the partition size in sectors (0 = use file size).\n");
            printf ("  e.g. bootfix -i \"/data/boot 2048 0\" \"/data/rootfs 0 0\" \"/data/extra 0 0\"\n");
            goto bye;
          }
        if (strcmp (argv [1], (char *) "-x") == 0)
            forceable = 1;
        else if (strcmp (argv [1], (char *) "-e") == 0)
            bEraseReqd = 1;
        else if (strcmp (argv [1], (char *) "-r") == 0)
          {
            readNAND = 1;
            if (argc > 2)
                strcpy (NAND_FID, argv [2]);
            break;
          }  
        else if (strcmp (argv [1], (char *) "-w") == 0)
          {
            writeNAND = 1;
            if (argc > 2)
                strcpy (NAND_FID, argv [2]);
            break;
          }
        else if (strcmp (argv [1], (char *) "-i") == 0)
          {
            loadNAND = 1;
            part_cnt = argc - 2;
            if (part_cnt > 16)
                part_cnt = 16;
            BOJLoadNANDCheck (part_cnt, &argv [2], part_start, part_secs);
            bEraseReqd = true;
            break;
          }
        argc--;
        argv++;
      }

    handle = open_usb ();                               // stage 1
    stage_1 (handle, buf);
    handle = close_usb (handle);

    printf ("Re-opening");                              // stage 2
    fflush (stdout);
    for (x = 0; !handle; x++)
      {
        usleep (1000000);                               // wait 1 sec
        printf (".");
        fflush (stdout);
        handle = open_usb (x < 10);                     // try to open
      }
    printf ("done\n");
    stage_2 (handle, buf);
    handle = close_usb (handle);

    printf ("All done\n");

bye:
    libusb_exit (NULL);

    return 0;
}