Changeset b96e09c in rtems for cpukit/libblock
- Timestamp:
- 10/13/09 07:58:33 (14 years ago)
- Branches:
- 4.10, 4.11, 5, master
- Children:
- 94d7bd7
- Parents:
- 2e92a5d
- Location:
- cpukit/libblock
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
cpukit/libblock/include/rtems/blkdev.h
r2e92a5d rb96e09c 18 18 19 19 #include <rtems.h> 20 #include <rtems/diskdevs.h> 20 21 #include <sys/ioctl.h> 21 22 … … 39 40 * @{ 40 41 */ 41 42 /**43 * Block device block index type.44 */45 typedef uint32_t rtems_blkdev_bnum;46 42 47 43 /** … … 251 247 */ 252 248 int 253 rtems_blkdev_ioctl( dev_t dev, uint32_t req, void *argp);249 rtems_blkdev_ioctl(rtems_disk_device *dd, uint32_t req, void *argp); 254 250 255 251 /** @} */ -
cpukit/libblock/include/rtems/diskdevs.h
r2e92a5d rb96e09c 21 21 #include <stdlib.h> 22 22 23 #include <rtems/blkdev.h>24 25 23 #ifdef __cplusplus 26 24 extern "C" { 27 25 #endif 28 26 27 typedef struct rtems_disk_device rtems_disk_device; 28 29 29 /** 30 30 * @defgroup rtems_disk Block Device Disk Management … … 32 32 * @ingroup rtems_libblock 33 33 * 34 * This module provides functions to manage disk devices.34 * @brief This module provides functions to manage disk devices. 35 35 * 36 36 * A disk is a set of blocks which are identified by a consecutive set of … … 44 44 45 45 /** 46 * Block device IO control handler type. 47 */ 48 typedef int (*rtems_block_device_ioctl)( dev_t dev, uint32_t req, void *argp); 49 50 /** 51 * Description of a disk device (logical and physical disks). 46 * @brief Block device block index type. 47 */ 48 typedef uint32_t rtems_blkdev_bnum; 49 50 /** 51 * @brief Block device IO control handler type. 52 */ 53 typedef int (*rtems_block_device_ioctl)( 54 rtems_disk_device *dd, 55 uint32_t req, 56 void *argp 57 ); 58 59 /** 60 * @brief Description of a disk device (logical and physical disks). 52 61 * 53 62 * An array of pointer tables to rtems_disk_device structures is maintained. … … 56 65 * structure of moderated size. 57 66 */ 58 typedefstruct rtems_disk_device {59 /** 60 * Device identifier (concatenation of major and minor number).67 struct rtems_disk_device { 68 /** 69 * @brief Device identifier (concatenation of major and minor number). 61 70 */ 62 71 dev_t dev; 63 72 64 73 /** 65 * Physical device identifier (equals the @c dev entry if it specifies a74 * @brief Physical device identifier (equals the @c dev entry if it specifies a 66 75 * physical device). 67 76 */ 68 structrtems_disk_device *phys_dev;69 70 /** 71 * Driver capabilities.77 rtems_disk_device *phys_dev; 78 79 /** 80 * @brief Driver capabilities. 72 81 */ 73 82 uint32_t capabilities; 74 83 75 84 /** 76 * Disk device name.85 * @brief Disk device name. 77 86 */ 78 87 char *name; 79 88 80 89 /** 81 * Usage counter.90 * @brief Usage counter. 82 91 * 83 92 * Devices cannot be removed if they are in use. … … 86 95 87 96 /** 88 * Start block number.97 * @brief Start block number. 89 98 * 90 99 * Equals zero for physical devices. It is a block offset to the related … … 94 103 95 104 /** 96 * Size of the physical or logical disk in blocks.105 * @brief Size of the physical or logical disk in blocks. 97 106 */ 98 107 rtems_blkdev_bnum size; 99 108 100 109 /** 101 * Device block size in bytes.110 * @brief Device block size in bytes. 102 111 * 103 112 * This is the minimum transfer unit. It can be any size. … … 106 115 107 116 /** 108 * Device media block size in bytes.117 * @brief Device media block size in bytes. 109 118 * 110 119 * This is the media transfer unit the hardware defaults to. … … 113 122 114 123 /** 115 * IO control handler for this disk.124 * @brief IO control handler for this disk. 116 125 */ 117 126 rtems_block_device_ioctl ioctl; 118 } rtems_disk_device; 119 120 /** 121 * Creates a physical disk with device identifier @a dev. 127 128 /** 129 * @brief Private data for the disk driver. 130 */ 131 void *driver_data; 132 }; 133 134 /** 135 * @name Disk Device Data 136 * 137 * @{ 138 */ 139 140 static inline dev_t rtems_disk_physical_device_number( 141 const rtems_disk_device *dd 142 ) 143 { 144 return dd->phys_dev->dev; 145 } 146 147 static inline rtems_device_major_number rtems_disk_physical_major_number( 148 const rtems_disk_device *dd 149 ) 150 { 151 return rtems_filesystem_dev_major_t(dd->phys_dev->dev); 152 } 153 154 static inline rtems_device_minor_number rtems_disk_physical_minor_number( 155 const rtems_disk_device *dd 156 ) 157 { 158 return rtems_filesystem_dev_minor_t(dd->phys_dev->dev); 159 } 160 161 static inline dev_t rtems_disk_device_number(const rtems_disk_device *dd) 162 { 163 return dd->dev; 164 } 165 166 static inline rtems_device_major_number rtems_disk_major_number( 167 const rtems_disk_device *dd 168 ) 169 { 170 return rtems_filesystem_dev_major_t(dd->dev); 171 } 172 173 static inline rtems_device_minor_number rtems_disk_minor_number( 174 const rtems_disk_device *dd 175 ) 176 { 177 return rtems_filesystem_dev_minor_t(dd->dev); 178 } 179 180 static inline void *rtems_disk_driver_data(const rtems_disk_device *dd) 181 { 182 return dd->driver_data; 183 } 184 185 static inline uint32_t rtems_disk_block_size(const rtems_disk_device *dd) 186 { 187 return dd->block_size; 188 } 189 190 static inline uint32_t rtems_disk_media_block_size(const rtems_disk_device *dd) 191 { 192 return dd->media_block_size; 193 } 194 195 /** @} */ 196 197 /** 198 * @name Disk Device Maintainance 199 * 200 * @{ 201 */ 202 203 /** 204 * @brief Creates a physical disk with device identifier @a dev. 122 205 * 123 206 * The block size @a block_size must be a power of two. The disk size @a … … 135 218 rtems_blkdev_bnum disk_size, 136 219 rtems_block_device_ioctl handler, 220 void *driver_data, 137 221 const char *name 138 222 ); 139 223 140 224 /** 141 * Creates a logical disk with device identifier @a dev.142 * 143 * A logical disk manages a subset of consecutive blocks contain d in the225 * @brief Creates a logical disk with device identifier @a dev. 226 * 227 * A logical disk manages a subset of consecutive blocks contained in the 144 228 * physical disk with identifier @a phys. The start block index of the logical 145 229 * disk device is @a start. The block number of the logcal disk will be @a … … 158 242 159 243 /** 160 * Deletes a physical or logical disk device with identifier @a dev.244 * @brief Deletes a physical or logical disk device with identifier @a dev. 161 245 * 162 246 * Disk devices may be deleted if there usage counter (and the usage counters … … 168 252 169 253 /** 170 * Returns the disk device descriptor for the device identifier @a dev.254 * @brief Returns the disk device descriptor for the device identifier @a dev. 171 255 * 172 256 * Increments usage counter by one. You should release the disk device … … 177 261 178 262 /** 179 * Releases the disk device description @a dd.263 * @brief Releases the disk device description @a dd. 180 264 * 181 265 * Decrements usage counter by one. … … 183 267 rtems_status_code rtems_disk_release(rtems_disk_device *dd); 184 268 185 /** 186 * Disk device iterator. 269 /** @} */ 270 271 /** 272 * @name Disk Management 273 * 274 * @{ 275 */ 276 277 /** 278 * @brief Disk device iterator. 187 279 * 188 280 * Returns the next disk device descriptor with a device identifier larger than … … 201 293 202 294 /** 203 * Initializes the disk device management.295 * @brief Initializes the disk device management. 204 296 * 205 297 * This functions returns successful if the disk device management is already … … 209 301 210 302 /** 211 * Releases all resources allocated for disk device management.303 * @brief Releases all resources allocated for disk device management. 212 304 */ 213 305 rtems_status_code rtems_disk_io_done(void); … … 215 307 /** @} */ 216 308 309 /** @} */ 310 217 311 #ifdef __cplusplus 218 312 } -
cpukit/libblock/src/bdbuf.c
r2e92a5d rb96e09c 1976 1976 req->error = 0; 1977 1977 1978 result = dd->ioctl (dd ->phys_dev->dev, RTEMS_BLKIO_REQUEST, req);1978 result = dd->ioctl (dd, RTEMS_BLKIO_REQUEST, req); 1979 1979 1980 1980 /* … … 2402 2402 * device is being held. 2403 2403 */ 2404 result = dd->phys_dev->ioctl (dd->phys_dev->dev, 2405 RTEMS_BLKIO_REQUEST, transfer->write_req); 2406 2404 result = dd->ioctl (dd, RTEMS_BLKIO_REQUEST, transfer->write_req); 2407 2405 if (result < 0) 2408 2406 { -
cpukit/libblock/src/blkdev.c
r2e92a5d rb96e09c 238 238 case RTEMS_BLKIO_SYNCDEV: 239 239 rc = rtems_bdbuf_syncdev(dd->dev); 240 args->ioctl_return = ( rc == RTEMS_SUCCESSFUL ? 0 : -1);240 args->ioctl_return = (uint32_t) (rc == RTEMS_SUCCESSFUL ? 0 : -1); 241 241 break; 242 242 … … 244 244 { 245 245 rtems_blkdev_request *req = args->buffer; 246 args->ioctl_return = dd->ioctl(dd->phys_dev->dev, args->command, 247 req); 246 args->ioctl_return = (uint32_t) dd->ioctl(dd, args->command, req); 248 247 break; 249 248 } 250 249 251 250 default: 252 args->ioctl_return = dd->ioctl(dd->phys_dev->dev, args->command,253 251 args->ioctl_return = (uint32_t) dd->ioctl(dd, args->command, 252 args->buffer); 254 253 break; 255 254 } … … 260 259 261 260 int 262 rtems_blkdev_ioctl(dev_t dev, uint32_t req, void *argp) 263 { 264 rtems_disk_device *dd; 261 rtems_blkdev_ioctl(rtems_disk_device *dd, uint32_t req, void *argp) 262 { 265 263 size_t *arg_size = argp; 266 264 int rc = 0; 267 268 dd = rtems_disk_obtain(dev);269 if (dd == NULL)270 {271 errno = ENODEV;272 return -1;273 }274 265 275 266 switch (req) … … 296 287 break; 297 288 } 298 299 rtems_disk_release(dd);300 289 301 290 return rc; -
cpukit/libblock/src/diskdevs.c
r2e92a5d rb96e09c 224 224 rtems_blkdev_bnum disk_size, 225 225 rtems_block_device_ioctl handler, 226 void *driver_data, 226 227 const char *name 227 228 ) … … 253 254 dd->block_size = dd->media_block_size = block_size; 254 255 dd->ioctl = handler; 256 dd->driver_data = driver_data; 255 257 256 258 rc = rtems_io_register_name(name, major, minor); 257 259 258 if (handler (dd->phys_dev->dev, 259 RTEMS_BLKDEV_CAPABILITIES, 260 &dd->capabilities) < 0) 260 if (handler (dd, RTEMS_BLKDEV_CAPABILITIES, &dd->capabilities) < 0) 261 261 dd->capabilities = 0; 262 262 … … 317 317 dd->block_size = dd->media_block_size = pdd->block_size; 318 318 dd->ioctl = pdd->ioctl; 319 dd->driver_data = pdd->driver_data; 319 320 320 321 rc = rtems_io_register_name(name, major, minor); -
cpukit/libblock/src/flashdisk.c
r2e92a5d rb96e09c 2336 2336 * Flash disk IOCTL handler. 2337 2337 * 2338 * @param d ev Device number (major, minor number).2338 * @param dd Disk device. 2339 2339 * @param req IOCTL request code. 2340 2340 * @param argp IOCTL argument. … … 2342 2342 */ 2343 2343 static int 2344 rtems_fdisk_ioctl (dev_t dev, uint32_t req, void* argp) 2345 { 2344 rtems_fdisk_ioctl (rtems_disk_device *dd, uint32_t req, void* argp) 2345 { 2346 dev_t dev = rtems_disk_physical_device_number (dd); 2346 2347 rtems_device_minor_number minor = rtems_filesystem_dev_minor_t (dev); 2347 2348 rtems_blkdev_request* r = argp; … … 2409 2410 2410 2411 default: 2411 rtems_blkdev_ioctl (d ev, req, argp);2412 rtems_blkdev_ioctl (dd, req, argp); 2412 2413 break; 2413 2414 } … … 2480 2481 sc = rtems_disk_create_phys(dev, c->block_size, 2481 2482 blocks - fd->unavail_blocks, 2482 rtems_fdisk_ioctl, name);2483 rtems_fdisk_ioctl, NULL, name); 2483 2484 if (sc != RTEMS_SUCCESSFUL) 2484 2485 { -
cpukit/libblock/src/nvdisk.c
r2e92a5d rb96e09c 675 675 * NV disk IOCTL handler. 676 676 * 677 * @param d ev Device number (major, minor number).677 * @param dd Disk device. 678 678 * @param req IOCTL request code. 679 679 * @param argp IOCTL argument. … … 681 681 */ 682 682 static int 683 rtems_nvdisk_ioctl (dev_t dev, uint32_t req, void* argp) 684 { 683 rtems_nvdisk_ioctl (rtems_disk_device *dd, uint32_t req, void* argp) 684 { 685 dev_t dev = rtems_disk_physical_device_number (dd); 685 686 rtems_device_minor_number minor = rtems_filesystem_dev_minor_t (dev); 686 687 rtems_blkdev_request* r = argp; … … 735 736 736 737 default: 737 rtems_blkdev_ioctl (d ev, req, argp);738 rtems_blkdev_ioctl (dd, req, argp); 738 739 break; 739 740 } … … 818 819 819 820 sc = rtems_disk_create_phys(dev, c->block_size, blocks, 820 rtems_nvdisk_ioctl, name);821 rtems_nvdisk_ioctl, NULL, name); 821 822 if (sc != RTEMS_SUCCESSFUL) 822 823 { -
cpukit/libblock/src/ramdisk.c
r2e92a5d rb96e09c 164 164 */ 165 165 static int 166 ramdisk_ioctl( dev_t dev, uint32_t req, void *argp)166 ramdisk_ioctl(rtems_disk_device *dd, uint32_t req, void *argp) 167 167 { 168 168 switch (req) … … 170 170 case RTEMS_BLKIO_REQUEST: 171 171 { 172 rtems_device_minor_number minor;173 172 rtems_blkdev_request *r = argp; 174 struct ramdisk *rd; 175 176 minor = rtems_filesystem_dev_minor_t(dev); 177 if ((minor >= nramdisks) || !ramdisk[minor].initialized) 178 { 179 errno = ENODEV; 180 return -1; 181 } 182 183 rd = ramdisk + minor; 173 struct ramdisk *rd = rtems_disk_driver_data(dd); 184 174 185 175 switch (r->req) … … 199 189 200 190 default: 201 return rtems_blkdev_ioctl (d ev, req, argp);191 return rtems_blkdev_ioctl (dd, req, argp); 202 192 break; 203 193 } … … 267 257 } 268 258 rc = rtems_disk_create_phys(dev, c->block_size, c->block_num, 269 ramdisk_ioctl, name);259 ramdisk_ioctl, r, name); 270 260 if (rc != RTEMS_SUCCESSFUL) 271 261 {
Note: See TracChangeset
for help on using the changeset viewer.