コード例 #1
0
ファイル: sd-card-init.c プロジェクト: zhongweiy/rtems
rtems_status_code mpc55xx_sd_card_init( bool mount)
{
    rtems_status_code sc = RTEMS_SUCCESSFUL;
    int rv = 0;
    sd_card_driver_entry *e = &sd_card_driver_table [0];

    RTEMS_DEBUG_PRINT( "Task started\n");

    sc = mpc55xx_dspi_init();
    RTEMS_CHECK_SC( rv, "Intitalize DSPI bus");

    e->bus = mpc55xx_dspi_bus_table [0].bus_number;

    sc = sd_card_register();
    RTEMS_CHECK_SC( sc, "Register SD Card");

    if (mount) {
        sc = rtems_bdpart_register_from_disk( MPC55XX_DEVICE_FILE);
        RTEMS_CHECK_SC( sc, "Initialize IDE partition table");

        rv = rtems_fsmount( mpc55xx_fs_table, sizeof( mpc55xx_fs_table) / sizeof( mpc55xx_fs_table [0]), NULL);
        RTEMS_CHECK_RV_SC( rv, "Mount file systems");
    }

    return RTEMS_SUCCESSFUL;
}
コード例 #2
0
ファイル: init.c プロジェクト: RTEMS/examples-v2
/*
 * RTEMS Startup Task
 */
rtems_task
Init (rtems_task_argument ignored)
{
  rtems_status_code rc;

  puts( "\n\n*** QEMU VFAT AND SHELL TEST ***" );

  rc = rtems_bdpart_register_from_disk("/dev/hda");
  if ( rc != RTEMS_SUCCESSFUL ) {
    fprintf( stderr, "Unable to initialize partition table from /dev/hda\n" );
    exit(1);
  }

  rc = rtems_fsmount(
    fs_table,
    sizeof(fs_table)/sizeof(fs_table[0]),
    NULL
  );
  if ( rc != RTEMS_SUCCESSFUL ) {
    fprintf( stderr, "Unable to mount /dev/hda1\n" );
    exit(1);
  }

#if defined(USE_SHELL)
  fileio_start_shell ();
#endif
#if defined(USE_START_TEST)
  chdir( MOUNT_POINT );
  start_test ();
#endif
  puts( "*** END OF QEMU VFAT AND SHELL TEST ***" );
  exit(0);
}
コード例 #3
0
void fileio_fsmount(void)
{
  rtems_status_code rc;

  printf(" =========================\n");
  printf(" Process fsmount table\n");
  printf(" =========================\n");
  fileio_print_free_heap();
  /*
   * call function
   */
  rc = rtems_fsmount( fs_table,
		      sizeof(fs_table)/sizeof(fs_table[0]),
		      NULL);
  printf("result = %d\n",rc);
  fileio_print_free_heap();
}
コード例 #4
0
ファイル: init.c プロジェクト: nbkolchin/iozone-rtems
static int init_ide()
{
  int rc = 0;

  char buf[512];

#ifndef COMBO_RTEMS
  rtems_status_code sc = RTEMS_SUCCESSFUL;
  size_t abort_index = 0;

#ifndef FAT_BENCH
  rtems_rfs_format_config rfs_config =
  {
     .block_size = 0,        /* The size of a block. */
     .group_blocks = 0,      /* The number of blocks in a group. */
     .group_inodes = 0,      /* The number of inodes in a group. */
     .inode_overhead = 0,    /* The percentage overhead allocated to inodes. */
     .max_name_length = 0,   /* The maximum length of a name. */
     .initialise_inodes = 0, /* Initialise the inode tables to all ones. */
     .verbose = 1            /* Is the format verbose.  */
  };
#endif
#endif

#ifdef COMBO_RTEMS
  printk(".. COMBO RTEMS ..\n");
#else
  printk(".. VANILLA RTEMS ..\n");
#endif

#ifdef FAT_BENCH
  printk(".. FAT benchmarking. Preparing/formatting partition\n");
#ifdef FORMAT_ENABLE
  rc = msdos_format("/dev/hda", NULL);
  if (rc != 0)
     printk(".. msdos_format(/dev/hda) failed: %s\n", strerror(errno));
  else
     printk(".. msdos_format is OK\n");
#endif
#else
  printk(".. RFS benchmarking. Preparing/formatting disk\n");
#if 0
  {
      int i;

#define PARTITION_COUNT 1

      rtems_bdpart_partition created_partitions[PARTITION_COUNT];

      static const rtems_bdpart_format format = {
         .mbr = {
            .type = RTEMS_BDPART_FORMAT_MBR,
            .disk_id = 0xdeadbeef,
            .dos_compatibility = false
         }
      };

      static const unsigned distribution[PARTITION_COUNT] = {
            1
      };

      memset(&created_partitions[0], 0, sizeof(created_partitions));

      for (i = 0; i < PARTITION_COUNT; ++i) {
          rtems_bdpart_to_partition_type(RTEMS_BDPART_MBR_EMPTY,
                                         created_partitions[i].type);
      }

      sc = rtems_bdpart_create("/dev/hda", &format,
                               &created_partitions[0],
                               &distribution[0],
                               PARTITION_COUNT);
      if (sc != 0)
          printk(".. rtems_bdpart_create(/dev/hda) failed: %s\n", strerror(errno));
      else
          printk(".. rtems_bdpart_create() is OK\n");

      sc = rtems_bdpart_write("/dev/hda", &format,
                              &created_partitions[0],
                              PARTITION_COUNT);
      if (sc != 0)
          printk(".. rtems_bdpart_write(/dev/hda) failed: %s\n", strerror(errno));
      else
          printk(".. rtems_bdpart_write() is OK\n");
  }
#endif

#ifdef FORMAT_ENABLE
  rc = rtems_rfs_format("/dev/hda", &rfs_config);
  if (rc != 0)
     printk(".. rfs_format(/dev/hda) failed: %s\n", strerror(errno));
  else
     printk(".. rfs_format is OK\n");
#endif

#endif /* FAT_BENCH */

  /* Create a mount point folder */
  rc = mkdir("/mnt", 0777);
  if(rc == -1)
  {
    printk("mkdir failed: %s\n", strerror(errno));
    exit(3);
  }

#ifdef COMBO_RTEMS
  /* Some checking needed for combo version only */
  rc = open(DEVNAME, O_RDWR);
  if(rc == -1)
  {
    printk("dev open failed: %s\n", strerror(errno));
    exit(1);
  }
  if(read(rc, buf, 512) != 512)
  {
    printk("dev read failed: %s\n", strerror(errno));
    exit(2);
  }
  close(rc);
  /* end of checking */

#if 0
  rc = rtems_ide_part_table_initialize(DEVNAME);
  if(rc != RTEMS_SUCCESSFUL)
  {
    printk("ide_part_table failed: %i\n", rc);
    exit(4);
  }
#endif

  rc = rtems_fsmount(&fs_table, 1, NULL);
  if(rc != 1)
  {
    printk("rtems_fsmount failed: %i\n", rc);
    exit(5);
  }
#else

#if 0
  sc = rtems_bdpart_register_from_disk("/dev/hda");
  if (sc != RTEMS_SUCCESSFUL) {
    printk("read partition table failed: %s\n", rtems_status_text(sc));
    exit(4);
  }
  else
  {
    printk(".. partition table of \"/dev/hda\" is OK\n");
  }
#endif

  rc = rtems_fsmount(fstab, sizeof(fstab) / sizeof(fstab [0]), &abort_index);
  if (rc != 0) {
    printk("mount failed: %s\n", strerror(errno));
    exit(5);
  }
  else
  {
    printk(".. %s() returns OK\n", __FUNCTION__);
  }

  if (abort_index)
      printf("mount aborted at %zu\n", abort_index);
#endif

  printf(".. CompactFlash logical disk has been mounted\n");
  return 0;
}

static int iozone_func(int argc, char** argv)
{
  return main_iozone(argc, argv);
}

static rtems_shell_cmd_t iozone_cmd = {
  "iozone",         /* name */
  "execute iozone", /* help text */
  "misc",           /* topic */
  iozone_func,      /* function */
  NULL,             /* alias */
  NULL              /* next */
};

/* initialize shell, network and telnet */
static void init_telnetd()
{
  rtems_status_code rc;
  rtems_termios_initialize();
  rtems_initialize_network();
  rtems_telnetd_initialize();
#ifdef COMBO_RTEMS
  rc = rtems_shell_init("SHll", 32000, 100, "/dev/tty1", 1, 0);
#else
  rc = rtems_shell_init("SHll", 32000, 100, "/dev/tty1", 1, 0, NULL);
#endif
  if(rc != RTEMS_SUCCESSFUL)
    printk("init shell on console failed\n");
}