Changeset c649976 in rtems


Ignore:
Timestamp:
Feb 28, 2012, 12:28:42 PM (7 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
4.11, master
Children:
c93fc2b3
Parents:
4f3cbd9
git-author:
Sebastian Huber <sebastian.huber@…> (02/28/12 12:28:42)
git-committer:
Sebastian Huber <sebastian.huber@…> (03/13/12 11:24:17)
Message:

libblock: New block IO control support functions

Files:
3 edited

Legend:

Unmodified
Added
Removed
  • cpukit/libblock/include/rtems/blkdev.h

    r4f3cbd9 rc649976  
    166166/** @} */
    167167
     168static inline int rtems_disk_fd_get_media_block_size(
     169  int fd,
     170  uint32_t *media_block_size
     171)
     172{
     173  return ioctl(fd, RTEMS_BLKIO_GETMEDIABLKSIZE, media_block_size);
     174}
     175
     176static inline int rtems_disk_fd_get_block_size(int fd, uint32_t *block_size)
     177{
     178  return ioctl(fd, RTEMS_BLKIO_GETBLKSIZE, block_size);
     179}
     180
     181static inline int rtems_disk_fd_set_block_size(int fd, uint32_t block_size)
     182{
     183  return ioctl(fd, RTEMS_BLKIO_SETBLKSIZE, &block_size);
     184}
     185
     186static inline int rtems_disk_fd_get_block_count(
     187  int fd,
     188  rtems_blkdev_bnum *block_count
     189)
     190{
     191  return ioctl(fd, RTEMS_BLKIO_GETSIZE, block_count);
     192}
     193
     194static inline int rtems_disk_fd_get_disk_device(
     195  int fd,
     196  const rtems_disk_device **dd_ptr
     197)
     198{
     199  return ioctl(fd, RTEMS_BLKIO_GETDISKDEV, dd_ptr);
     200}
     201
     202static inline int rtems_disk_fd_sync(int fd)
     203{
     204  return ioctl(fd, RTEMS_BLKIO_SYNCDEV);
     205}
     206
    168207/**
    169208 * Only consecutive multi-sector buffer requests are supported.
  • cpukit/libmisc/shell/main_blksync.c

    r4f3cbd9 rc649976  
    5959  }
    6060
    61   if (ioctl (fd, RTEMS_BLKIO_SYNCDEV) < 0) {
     61  if (rtems_disk_fd_sync (fd) < 0) {
    6262    fprintf( stderr, "%s: driver sync failed: %s\n", argv[0], strerror (errno));
    6363    return 1;
  • testsuites/libtests/block01/init.c

    r4f3cbd9 rc649976  
    88
    99/*
    10  * Copyright (c) 2009
    11  * embedded brains GmbH
    12  * Obere Lagerstr. 30
    13  * D-82178 Puchheim
    14  * Germany
    15  * <rtems@embedded-brains.de>
     10 * Copyright (c) 2009-2012 embedded brains GmbH.  All rights reserved.
     11 *
     12 *  embedded brains GmbH
     13 *  Obere Lagerstr. 30
     14 *  82178 Puchheim
     15 *  Germany
     16 *  <rtems@embedded-brains.de>
    1617 *
    1718 * The license and distribution terms for this file may be
     
    2627#endif
    2728
     29#include <sys/stat.h>
    2830#include <stdio.h>
     31#include <fcntl.h>
    2932#include "tmacros.h"
    3033
     
    4043
    4144#define BLOCK_COUNT 16U
     45
     46static void test_block_io_control_api(dev_t dev, ramdisk *rd)
     47{
     48  rtems_status_code sc = RTEMS_SUCCESSFUL;
     49  rtems_disk_device *dd = NULL;
     50  const rtems_disk_device *fd_dd = NULL;
     51  int fd = -1;
     52  int rv = -1;
     53  uint32_t value = 0;
     54  rtems_blkdev_bnum block_count = 0;
     55
     56  sc = rtems_disk_create_phys(dev, BLOCK_SIZE, BLOCK_COUNT, ramdisk_ioctl, rd, "/dev/rda");
     57  ASSERT_SC(sc);
     58
     59  dd = rtems_disk_obtain(dev);
     60  rtems_test_assert(dd != NULL);
     61
     62  fd = open("/dev/rda", O_RDWR);
     63  rtems_test_assert(fd >= 0);
     64
     65  value = 0;
     66  rv = rtems_disk_fd_get_media_block_size(fd, &value);
     67  rtems_test_assert(rv == 0);
     68  rtems_test_assert(value == BLOCK_SIZE);
     69
     70  value = 0;
     71  rv = rtems_disk_fd_get_block_size(fd, &value);
     72  rtems_test_assert(rv == 0);
     73  rtems_test_assert(value == BLOCK_SIZE);
     74
     75  value = 1024;
     76  rv = rtems_disk_fd_set_block_size(fd, value);
     77  rtems_test_assert(rv == 0);
     78
     79  value = 0;
     80  rv = rtems_disk_fd_get_block_size(fd, &value);
     81  rtems_test_assert(rv == 0);
     82  rtems_test_assert(value == 1024);
     83
     84  block_count = 0;
     85  rv = rtems_disk_fd_get_block_count(fd, &block_count);
     86  rtems_test_assert(rv == 0);
     87  rtems_test_assert(block_count == BLOCK_COUNT);
     88
     89  rv = rtems_disk_fd_get_disk_device(fd, &fd_dd);
     90  rtems_test_assert(rv == 0);
     91  rtems_test_assert(fd_dd == dd);
     92
     93  rv = rtems_disk_fd_sync(fd);
     94  rtems_test_assert(rv == 0);
     95
     96  rv = close(fd);
     97  rtems_test_assert(rv == 0);
     98
     99  sc = rtems_disk_release(dd);
     100  ASSERT_SC(sc);
     101
     102  sc = rtems_disk_delete(dev);
     103  ASSERT_SC(sc);
     104}
    42105
    43106static void test_diskdevs(void)
     
    155218  ASSERT_SC(sc);
    156219
     220  /* Test block IO control API */
     221
     222  test_block_io_control_api(physical_dev, rd);
     223
    157224  /* Cleanup */
    158225
     
    184251
    185252#define CONFIGURE_USE_IMFS_AS_BASE_FILESYSTEM
     253#define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 4
    186254
    187255#define CONFIGURE_MAXIMUM_TASKS 2
Note: See TracChangeset for help on using the changeset viewer.