Ejemplo n.º 1
0
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");
}
Ejemplo n.º 2
0
static void test_bdpart(void)
{
  rtems_status_code sc = RTEMS_SUCCESSFUL;
  rtems_bdpart_partition created_partitions [PARTITION_COUNT];
  rtems_bdpart_format actual_format;
  rtems_bdpart_partition actual_partitions [PARTITION_COUNT];
  rtems_resource_snapshot before;
  size_t actual_count = PARTITION_COUNT;
  size_t i = 0;

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

  rtems_resource_snapshot_take(&before);

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

  sc = rtems_bdpart_create(
    rda,
    &format,
    &created_partitions [0],
    &distribution [0],
    PARTITION_COUNT
  );
  ASSERT_SC(sc);

  sc = rtems_bdpart_write(
    rda,
    &format,
    &created_partitions [0],
    PARTITION_COUNT
  );
  ASSERT_SC(sc);

  sc = rtems_bdpart_read(
    rda,
    &actual_format,
    &actual_partitions [0],
    &actual_count
  );
  ASSERT_SC(sc);
  rtems_test_assert(actual_format.mbr.disk_id == format.mbr.disk_id);
  rtems_test_assert(
    memcmp(
      &actual_partitions [0],
      &created_partitions [0],
      PARTITION_COUNT
    ) == 0
  );

  sc = rtems_bdpart_register(
    rda,
    actual_partitions,
    actual_count
  );
  ASSERT_SC(sc);
  test_logical_disks(&bdpart_rdax [0], true);

  sc = rtems_bdpart_unregister(
    rda,
    actual_partitions,
    actual_count
  );
  ASSERT_SC(sc);
  test_logical_disks(&bdpart_rdax [0], false);

  rtems_test_assert(rtems_resource_snapshot_check(&before));

  sc = rtems_bdpart_register_from_disk(rda);
  ASSERT_SC(sc);
  test_logical_disks(&bdpart_rdax [0], true);

  sc = rtems_bdpart_unregister(
    rda,
    actual_partitions,
    actual_count
  );
  ASSERT_SC(sc);
  test_logical_disks(&bdpart_rdax [0], false);

  rtems_test_assert(rtems_resource_snapshot_check(&before));

  rtems_bdpart_dump(&actual_partitions [0], actual_count);
}