Renamed the "blkman" module to "block_io".

Also renamed some defines and structures, although the structure and some other names are still odd.
This module should probably be moved into the kernel anyway, as it provides basic and crucial services.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@12646 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2005-05-12 15:43:02 +00:00
parent 9bdb0522c1
commit 879d9c6b6e
20 changed files with 286 additions and 330 deletions
@@ -1,7 +1,9 @@
/*
** Copyright 2002/03, Thomas Kurschel. All rights reserved.
** Distributed under the terms of the OpenBeOS License.
*/
* Copyright 2002/03, Thomas Kurschel. All rights reserved.
* Distributed under the terms of the MIT License.
*/
#ifndef __BLOCK_IO_H__
#define __BLOCK_IO_H__
/*
Part of Open block device manager
@@ -13,19 +15,17 @@
by using a buffer (performance will suffer, though).
*/
#ifndef __BLKMAN_H__
#define __BLKMAN_H__
#include <KernelExport.h>
#include <device_manager.h>
// cookies issued by blkman
typedef struct blkman_device_info *blkman_device;
typedef struct blkman_handle_info *blkman_handle;
// cookies issued by block_io
typedef struct block_io_device_info *block_io_device;
typedef struct block_io_handle_info *block_io_handle;
// cookies issued by device driver
typedef struct blkdev_device_cookie *blkdev_device_cookie;
typedef struct blkdev_handle_cookie *blkdev_handle_cookie;
typedef struct block_device_device_cookie *block_device_device_cookie;
typedef struct block_device_handle_cookie *block_device_handle_cookie;
// two reason why to use array of size 1:
@@ -46,57 +46,55 @@ typedef struct phys_vecs {
// attributes:
// type code for block devices
#define BLKDEV_TYPE_NAME "blkdev"
// if true, this device may be a BIOS drive (uint8, optional, default: false)
#define BLKDEV_IS_BIOS_DRIVE "blkdev/is_bios_drive"
#define B_BLOCK_DEVICE_IS_BIOS_DRIVE "block_device/is_bios_drive"
// address bits that must be 0 - must be 2^i-1 for some i (uint32, optional, default: 0)
#define BLKDEV_DMA_ALIGNMENT "blkdev/dma_alignment"
#define B_BLOCK_DEVICE_DMA_ALIGNMENT "block_device/dma_alignment"
// maximum number of blocks per transfer (uint32, optional, default: unlimited)
#define BLKDEV_MAX_BLOCKS_ITEM "blkdev/max_blocks"
#define B_BLOCK_DEVICE_MAX_BLOCKS_ITEM "block_device/max_blocks"
// mask of bits that can change in one sg block (uint32, optional, default: ~0)
#define BLKDEV_DMA_BOUNDARY "blkdev/dma_boundary"
#define B_BLOCK_DEVICE_DMA_BOUNDARY "block_device/dma_boundary"
// maximum size of one block in scatter/gather list (uint32, optional, default: ~0)
#define BLKDEV_MAX_SG_BLOCK_SIZE "blkdev/max_sg_block_size"
#define B_BLOCK_DEVICE_MAX_SG_BLOCK_SIZE "block_device/max_sg_block_size"
// maximum number of scatter/gather blocks (uint32, optional, default: unlimited)
#define BLKDEV_MAX_SG_BLOCKS "blkdev/max_sg_blocks"
#define B_BLOCK_DEVICE_MAX_SG_BLOCKS "block_device/max_sg_blocks"
// interface to be provided by device driver
typedef struct blkdev_interface {
driver_module_info dinfo;
typedef struct block_device_interface {
driver_module_info info;
// iovecs are physical address here
// pos and num_blocks are in blocks; bytes_transferred in bytes
// vecs are guaranteed to describe enough data for given block count
status_t (*open)(blkdev_device_cookie device, blkdev_handle_cookie *handle);
status_t (*close)(blkdev_handle_cookie handle);
status_t (*free)(blkdev_handle_cookie handle);
status_t (*open)(block_device_device_cookie device, block_device_handle_cookie *handle);
status_t (*close)(block_device_handle_cookie handle);
status_t (*free)(block_device_handle_cookie handle);
status_t (*read)(blkdev_handle_cookie handle, const phys_vecs *vecs, off_t pos,
status_t (*read)(block_device_handle_cookie handle, const phys_vecs *vecs, off_t pos,
size_t num_blocks, uint32 block_size, size_t *bytes_transferred);
status_t (*write)(blkdev_handle_cookie handle, const phys_vecs *vecs, off_t pos,
status_t (*write)(block_device_handle_cookie handle, const phys_vecs *vecs, off_t pos,
size_t num_blocks, uint32 block_size, size_t *bytes_transferred);
status_t (*ioctl)(blkdev_handle_cookie handle, int op, void *buf, size_t len);
} blkdev_interface;
status_t (*ioctl)(block_device_handle_cookie handle, int op, void *buf, size_t len);
} block_device_interface;
#define BLKMAN_MODULE_NAME "generic/blkman/v1"
#define B_BLOCK_IO_MODULE_NAME "generic/block_io/v1"
// Interface for Drivers
// blkman interface used for callbacks done by driver
typedef struct blkman_for_driver_interface {
module_info minfo;
typedef struct block_io_for_driver_interface {
module_info info;
// block_size - block size in bytes
// ld_block_size - log2( block_size) (set to zero if block_size is not power of two)
// capacity - capacity in blocks
void (*set_media_params)(blkman_device device, uint32 block_size, uint32 ld_block_size,
void (*set_media_params)(block_io_device device, uint32 block_size, uint32 ld_block_size,
uint64 capacity);
} blkman_for_driver_interface;
} block_io_for_driver_interface;
#define BLKMAN_FOR_DRIVER_MODULE_NAME "generic/blkman/driver/v1"
#define B_BLOCK_IO_FOR_DRIVER_MODULE_NAME "generic/block_io/driver/v1"
#endif
#endif /* __BLOCK_IO_H__ */
+4 -4
View File
@@ -1,7 +1,7 @@
/*
** Copyright 2002/03, Thomas Kurschel. All rights reserved.
** Distributed under the terms of the OpenBeOS License.
*/
* Copyright 2002/03, Thomas Kurschel. All rights reserved.
* Distributed under the terms of the MIT License.
*/
/*
Part of Open SCSI Peripheral Driver
@@ -19,7 +19,7 @@
#define __SCSI_PERIPH_H__
#include <bus/SCSI.h>
#include <blkman.h>
#include <block_io.h>
#include <bus/scsi/scsi_cmds.h>
#include <Drivers.h>
@@ -32,7 +32,7 @@ cd_init_device(device_node_handle node, void *user_cookie, void **cookie)
memset(device, 0, sizeof(*device));
device->blkman_device = user_cookie;
device->block_io_device = user_cookie;
device->node = node;
res = pnp->get_attr_uint8(node, "removable",
@@ -119,7 +119,7 @@ cd_device_added(device_node_handle node)
goto err;
// get block limit of underlying hardware to lower it (if necessary)
if( pnp->get_attr_uint32( node, BLKDEV_MAX_BLOCKS_ITEM,
if( pnp->get_attr_uint32( node, B_BLOCK_DEVICE_MAX_BLOCKS_ITEM,
&max_blocks, true ) != B_OK )
max_blocks = INT_MAX;
@@ -140,14 +140,14 @@ cd_device_added(device_node_handle node)
{
device_attr attrs[] = {
{ B_DRIVER_MODULE, B_STRING_TYPE, { string: SCSI_CD_MODULE_NAME }},
// we always want blkman on top of us
{ B_DRIVER_FIXED_CHILD, B_STRING_TYPE, { string: BLKMAN_MODULE_NAME }},
// tell blkman whether the device is removable
{ B_DRIVER_FIXED_CHILD, B_STRING_TYPE, { string: B_BLOCK_IO_MODULE_NAME }},
// tell block_io whether the device is removable
{ "removable", B_UINT8_TYPE, { ui8: device_inquiry->RMB }},
// tell which name we want to have in devfs
{ PNP_DEVFS_FILENAME, B_STRING_TYPE, { string: name }},
// impose own max block restriction
{ BLKDEV_MAX_BLOCKS_ITEM, B_UINT32_TYPE, { ui32: max_blocks }},
{ B_BLOCK_DEVICE_MAX_BLOCKS_ITEM, B_UINT32_TYPE, { ui32: max_blocks }},
{ NULL }
};
status_t res;
@@ -14,11 +14,11 @@
#include <scsi.h>
#include <malloc.h>
extern blkdev_interface cd_interface;
extern block_device_interface cd_interface;
scsi_periph_interface *scsi_periph;
device_manager_info *pnp;
blkman_for_driver_interface *blkman;
block_io_for_driver_interface *sBlockIO;
#define SCSI_CD_STD_TIMEOUT 10
@@ -663,7 +663,7 @@ cd_set_capacity(cd_device_info *device, uint64 capacity,
device->capacity = capacity;
device->block_size = block_size;
blkman->set_media_params(device->blkman_device, block_size,
sBlockIO->set_media_params(device->block_io_device, block_size,
ld_block_size, capacity);
}
@@ -699,12 +699,12 @@ std_ops(int32 op, ...)
module_dependency module_dependencies[] = {
{ SCSI_PERIPH_MODULE_NAME, (module_info **)&scsi_periph },
{ BLKMAN_FOR_DRIVER_MODULE_NAME, (module_info **)&blkman },
{ B_BLOCK_IO_FOR_DRIVER_MODULE_NAME, (module_info **)&sBlockIO },
{ B_DEVICE_MANAGER_MODULE_NAME, (module_info **)&pnp },
{}
};
blkdev_interface scsi_cd_module = {
block_device_interface scsi_cd_module = {
{
{
SCSI_CD_MODULE_NAME,
@@ -719,16 +719,16 @@ blkdev_interface scsi_cd_module = {
NULL
},
(status_t (*)( blkdev_device_cookie, blkdev_handle_cookie * )) &cd_open,
(status_t (*)( blkdev_handle_cookie )) &cd_close,
(status_t (*)( blkdev_handle_cookie )) &cd_free,
(status_t (*)(block_device_device_cookie, block_device_handle_cookie *))&cd_open,
(status_t (*)(block_device_handle_cookie)) &cd_close,
(status_t (*)(block_device_handle_cookie)) &cd_free,
(status_t (*)( blkdev_handle_cookie, const phys_vecs *,
off_t, size_t, uint32, size_t * )) &cd_read,
(status_t (*)( blkdev_handle_cookie, const phys_vecs *,
off_t, size_t, uint32, size_t * )) &cd_write,
(status_t (*)(block_device_handle_cookie, const phys_vecs *,
off_t, size_t, uint32, size_t *)) &cd_read,
(status_t (*)(block_device_handle_cookie, const phys_vecs *,
off_t, size_t, uint32, size_t *)) &cd_write,
(status_t (*)( blkdev_handle_cookie, int, void *, size_t )) &cd_ioctl,
(status_t (*)(block_device_handle_cookie, int, void *, size_t))&cd_ioctl,
};
module_info *modules[] = {
@@ -1,7 +1,7 @@
/*
** Copyright 2003, Thomas Kurschel. All rights reserved.
** Distributed under the terms of the OpenBeOS License.
*/
* Copyright 2003, Thomas Kurschel. All rights reserved.
* Distributed under the terms of the MIT License.
*/
/*
Part of Open SCSI CD Driver
@@ -10,7 +10,7 @@
#include <device_manager.h>
#include "scsi_cd.h"
#include <bus/scsi/scsi_periph.h>
#include <blkman.h>
#include <block_io.h>
#define debug_level_flow 0
#define debug_level_error 3
@@ -26,7 +26,7 @@ typedef struct cd_device_info {
scsi_periph_device scsi_periph_device;
scsi_device scsi_device;
scsi_device_interface *scsi;
blkman_device blkman_device;
block_io_device block_io_device;
uint64 capacity;
uint32 block_size;
@@ -43,7 +43,6 @@ typedef struct cd_handle_info {
extern scsi_periph_interface *scsi_periph;
extern device_manager_info *pnp;
extern scsi_periph_callbacks callbacks;
extern blkman_for_driver_interface *blkman;
// device_mgr.c
@@ -32,7 +32,7 @@ das_init_device(device_node_handle node, void *user_cookie, void **cookie)
memset(device, 0, sizeof(*device));
device->blkman_device = user_cookie;
device->block_io_device = user_cookie;
device->node = node;
res = pnp->get_attr_uint8(node, "removable",
@@ -92,7 +92,7 @@ das_uninit_device(das_device_info *device)
/** called whenever a new device was added to system;
* if we really support it, we create a new node that gets
* server by blkdev
* server by the block_io module
*/
status_t
@@ -116,12 +116,12 @@ das_device_added(device_node_handle node)
goto err;
// get block limit of underlying hardware to lower it (if necessary)
if (pnp->get_attr_uint32(node, BLKDEV_MAX_BLOCKS_ITEM, &max_blocks, true) != B_OK)
if (pnp->get_attr_uint32(node, B_BLOCK_DEVICE_MAX_BLOCKS_ITEM, &max_blocks, true) != B_OK)
max_blocks = INT_MAX;
// using 10 byte commands, at most 0xffff blocks can be transmitted at once
// (sadly, we cannot update this value later on if only 6 byte commands
// are supported, but the blkdev can live with that)
// are supported, but the block_io module can live with that)
max_blocks = min(max_blocks, 0xffff);
name = scsi_periph->compose_device_name(node, "disk/scsi");
@@ -136,16 +136,15 @@ das_device_added(device_node_handle node)
{
device_attr attrs[] = {
{ B_DRIVER_MODULE, B_STRING_TYPE, { string: SCSI_DSK_MODULE_NAME }},
// we always want blkman on top of us
{ B_DRIVER_FIXED_CHILD, B_STRING_TYPE, { string: BLKMAN_MODULE_NAME }},
// tell blkman whether the device is removable
{ B_DRIVER_FIXED_CHILD, B_STRING_TYPE, { string: B_BLOCK_IO_MODULE_NAME }},
// tell block_io whether the device is removable
{ "removable", B_UINT8_TYPE, { ui8: device_inquiry->RMB }},
// tell which name we want to have in devfs
{ PNP_DEVFS_FILENAME, B_STRING_TYPE, { string: name }},
// impose own max block restriction
{ BLKDEV_MAX_BLOCKS_ITEM, B_UINT32_TYPE, { ui32: max_blocks }},
{ B_BLOCK_DEVICE_MAX_BLOCKS_ITEM, B_UINT32_TYPE, { ui32: max_blocks }},
// in general, any disk can be a BIOS drive (even ZIP-disks)
{ BLKDEV_IS_BIOS_DRIVE, B_UINT8_TYPE, { ui8: 1 }},
{ B_BLOCK_DEVICE_IS_BIOS_DRIVE, B_UINT8_TYPE, { ui8: 1 }},
{ NULL }
};
@@ -21,11 +21,11 @@
#include <stdlib.h>
extern blkdev_interface das_interface;
extern block_device_interface das_interface;
scsi_periph_interface *scsi_periph;
device_manager_info *pnp;
blkman_for_driver_interface *blkman;
block_io_for_driver_interface *gBlockIO;
static status_t
@@ -161,7 +161,7 @@ das_set_capacity(das_device_info *device, uint64 capacity,
device->capacity = capacity;
device->block_size = block_size;
blkman->set_media_params(device->blkman_device, block_size,
gBlockIO->set_media_params(device->block_io_device, block_size,
ld_block_size, capacity);
}
@@ -271,12 +271,12 @@ std_ops(int32 op, ...)
module_dependency module_dependencies[] = {
{ SCSI_PERIPH_MODULE_NAME, (module_info **)&scsi_periph },
{ BLKMAN_FOR_DRIVER_MODULE_NAME, (module_info **)&blkman },
{ B_BLOCK_IO_FOR_DRIVER_MODULE_NAME, (module_info **)&gBlockIO },
{ B_DEVICE_MANAGER_MODULE_NAME, (module_info **)&pnp },
{}
};
blkdev_interface scsi_dsk_module = {
block_device_interface scsi_dsk_module = {
{
{
SCSI_DSK_MODULE_NAME,
@@ -293,16 +293,16 @@ blkdev_interface scsi_dsk_module = {
das_get_paths,
},
(status_t (*)(blkdev_device_cookie, blkdev_handle_cookie *)) &das_open,
(status_t (*)(blkdev_handle_cookie)) &das_close,
(status_t (*)(blkdev_handle_cookie)) &das_free,
(status_t (*)(block_device_device_cookie, block_device_handle_cookie *))&das_open,
(status_t (*)(block_device_handle_cookie)) &das_close,
(status_t (*)(block_device_handle_cookie)) &das_free,
(status_t (*)(blkdev_handle_cookie, const phys_vecs *,
(status_t (*)(block_device_handle_cookie, const phys_vecs *,
off_t, size_t, uint32, size_t *)) &das_read,
(status_t (*)(blkdev_handle_cookie, const phys_vecs *,
(status_t (*)(block_device_handle_cookie, const phys_vecs *,
off_t, size_t, uint32, size_t *)) &das_write,
(status_t (*)(blkdev_handle_cookie, int, void *, size_t)) &das_ioctl,
(status_t (*)(block_device_handle_cookie, int, void *, size_t))&das_ioctl,
};
#if !_BUILDING_kernel && !BOOT
@@ -12,7 +12,7 @@
#include <device_manager.h>
#include "scsi_dsk.h"
#include <bus/scsi/scsi_periph.h>
#include <blkman.h>
#include <block_io.h>
#define debug_level_flow 0
#define debug_level_info 1
@@ -28,7 +28,7 @@ typedef struct das_device_info {
scsi_periph_device scsi_periph_device;
scsi_device scsi_device;
scsi_device_interface *scsi;
blkman_device blkman_device;
block_io_device block_io_device;
uint64 capacity;
uint32 block_size;
@@ -44,7 +44,7 @@ typedef struct das_handle_info {
extern scsi_periph_interface *scsi_periph;
extern device_manager_info *pnp;
extern scsi_periph_callbacks callbacks;
extern blkman_for_driver_interface *blkman;
extern block_io_for_driver_interface *gBlockIO;
// device_mgr.c
+3 -3
View File
@@ -1,4 +1,4 @@
SubDir OBOS_TOP src add-ons kernel generic blkman ;
SubDir OBOS_TOP src add-ons kernel generic block_io ;
UsePrivateHeaders kernel ;
UsePrivateHeaders [ FDirName kernel arch $(OBOS_ARCH) ] ;
@@ -9,8 +9,8 @@ if $(DEBUG) = 0 {
SubDirCcFlags [ FDefines DEBUG_MAX_LEVEL_FLOW=0 DEBUG_MAX_LEVEL_INFO=0 ] ;
}
KernelAddon blkman : kernel generic :
blkman.c
KernelAddon block_io : kernel generic :
block_io.c
io.c
virtual_memory.c
;
@@ -1,40 +0,0 @@
/*
** Copyright 2002/03, Thomas Kurschel. All rights reserved.
** Distributed under the terms of the OpenBeOS License.
*/
/*
Functions that are missing in kernel.
*/
#ifndef _KERNEL_EXPORT_EXT_H
#define _KERNEL_EXPORT_EXT_H
#include <KernelExport.h>
#include <iovec.h>
// get memory map of iovec
status_t get_iovec_memory_map(
iovec *vec, // iovec to analyze
size_t vec_count, // number of entries in vec
size_t vec_offset, // number of bytes to skip at beginning of vec
size_t len, // number of bytes to analyze
physical_entry *map, // resulting memory map
size_t max_entries, // max number of entries in map
size_t *num_entries, // actual number of map entries used
size_t *mapped_len // actual number of bytes described by map
);
// map main memory into virtual address space
status_t map_mainmemory(
addr_t physical_addr, // physical address to map
void **virtual_addr // receives corresponding virtual address
);
// unmap main memory from virtual address space
status_t unmap_mainmemory(
void *virtual_addr // virtual address to release
);
#endif
@@ -12,7 +12,7 @@
*/
#include "blkman_int.h"
#include "block_io_private.h"
#include <stdio.h>
@@ -24,28 +24,28 @@
#endif
uint blkman_buffer_size;
sem_id blkman_buffer_lock;
struct iovec blkman_buffer_vec[1];
void *blkman_buffer_phys;
char *blkman_buffer;
phys_vecs blkman_buffer_phys_vec;
area_id blkman_buffer_area;
uint block_io_buffer_size;
sem_id block_io_buffer_lock;
struct iovec block_io_buffer_vec[1];
void *block_io_buffer_phys;
char *block_io_buffer;
phys_vecs block_io_buffer_phys_vec;
static area_id block_io_buffer_area;
locked_pool_interface *locked_pool;
device_manager_info *pnp;
static status_t
blkman_open(blkman_device_info *device, uint32 flags,
blkman_handle_info **res_handle)
block_io_open(block_io_device_info *device, uint32 flags,
block_io_handle_info **res_handle)
{
blkman_handle_info *handle;
block_io_handle_info *handle;
status_t res;
TRACE(("blkman_open()\n"));
TRACE(("block_io_open()\n"));
handle = (blkman_handle_info *)malloc(sizeof(*handle));
handle = (block_io_handle_info *)malloc(sizeof(*handle));
if (handle == NULL)
return B_NO_MEMORY;
@@ -69,11 +69,11 @@ err:
static status_t
blkman_close(blkman_handle_info *handle)
block_io_close(block_io_handle_info *handle)
{
blkman_device_info *device = handle->device;
block_io_device_info *device = handle->device;
TRACE(("blkman_close()\n"));
TRACE(("block_io_close()\n"));
device->interface->close(handle->cookie);
return B_OK;
@@ -81,11 +81,11 @@ blkman_close(blkman_handle_info *handle)
static status_t
blkman_freecookie(blkman_handle_info *handle)
block_io_freecookie(block_io_handle_info *handle)
{
blkman_device_info *device = handle->device;
block_io_device_info *device = handle->device;
TRACE(("blkman_freecookie()\n"));
TRACE(("block_io_freecookie()\n"));
device->interface->free(handle->cookie);
free(handle);
@@ -101,7 +101,7 @@ blkman_freecookie(blkman_handle_info *handle)
*/
static status_t
verify_checksum(blkman_handle_info *handle, uint64 offset, uint32 len, uint32 chksum)
verify_checksum(block_io_handle_info *handle, uint64 offset, uint32 len, uint32 chksum)
{
void *buffer;
uint32 readlen;
@@ -115,7 +115,7 @@ verify_checksum(blkman_handle_info *handle, uint64 offset, uint32 len, uint32 ch
readlen = len;
res = blkman_read(handle, offset, buffer, &readlen);
res = block_io_read(handle, offset, buffer, &readlen);
if (res < B_OK || readlen < len)
goto err;
@@ -138,10 +138,10 @@ err:
/** store BIOS drive id in node's attribute */
static status_t
store_bios_drive_in_node(blkman_device_info *device)
store_bios_drive_in_node(block_io_device_info *device)
{
device_attr attribute = {
BLKDEV_BIOS_ID, B_UINT8_TYPE, { ui8:
B_BLOCK_DEVICE_BIOS_ID, B_UINT8_TYPE, { ui8:
device->bios_drive != NULL ? device->bios_drive->bios_id : 0 }
};
@@ -153,15 +153,15 @@ store_bios_drive_in_node(blkman_device_info *device)
* this must be called whenever someone wants to access BIOS infos about the drive;
* there are two reasons to not call this during probe():
* - perhaps nobody is interested in BIOS info
* - we need a working blkman device to handle lower level driver
* - we need a working block_io device to handle lower level driver
* restrictions, so this method can only be safely called once the
* node has been loaded
*/
static void
find_bios_drive_info(blkman_handle_info *handle)
find_bios_drive_info(block_io_handle_info *handle)
{
blkman_device_info *device = handle->device;
block_io_device_info *device = handle->device;
bios_drive *drive = NULL; //, *colliding_drive;
char name[32];
uint8 bios_id;
@@ -174,7 +174,7 @@ find_bios_drive_info(blkman_handle_info *handle)
// check whether BIOS info was found during one of the previous
// loads
if (pnp->get_attr_uint8(device->node, BLKDEV_BIOS_ID, &bios_id, false) == B_OK) {
if (pnp->get_attr_uint8(device->node, B_BLOCK_DEVICE_BIOS_ID, &bios_id, false) == B_OK) {
TRACE(("use previous BIOS ID 0x%x\n", bios_id));
// ToDo: this assumes private R5 kernel functions to be present
@@ -287,9 +287,9 @@ no_bios_drive:
static status_t
blkman_ioctl(blkman_handle_info *handle, uint32 op, void *buf, size_t len)
block_io_ioctl(block_io_handle_info *handle, uint32 op, void *buf, size_t len)
{
blkman_device_info *device = handle->device;
block_io_device_info *device = handle->device;
status_t res;
if (device->is_bios_drive) {
@@ -340,17 +340,17 @@ blkman_ioctl(blkman_handle_info *handle, uint32 op, void *buf, size_t len)
static status_t
blkman_register_device(device_node_handle parent)
block_io_register_device(device_node_handle parent)
{
TRACE(("blkman_probe()\n"));
TRACE(("block_io_register_device()\n"));
// ready to register at devfs
{
device_attr attrs[] = {
{ B_DRIVER_MODULE, B_STRING_TYPE, { string: BLKMAN_MODULE_NAME }},
// we always want devfs on top of us
{ B_DRIVER_MODULE, B_STRING_TYPE, { string: B_BLOCK_IO_MODULE_NAME }},
{ PNP_DRIVER_CONNECTION, B_STRING_TYPE, { string: "block_io" }},
{ B_DRIVER_FIXED_CHILD, B_STRING_TYPE, { string: PNP_DEVFS_MODULE_NAME }},
{ PNP_DRIVER_CONNECTION, B_STRING_TYPE, { string: "blkman" }},
{ NULL }
};
@@ -362,13 +362,13 @@ blkman_register_device(device_node_handle parent)
static void
blkman_remove(device_node_handle node, void *cookie)
block_io_remove(device_node_handle node, void *cookie)
{
uint8 bios_id;
//bios_drive *drive;
// if this drive has a BIOS ID, remove it from BIOS drive list
if (pnp->get_attr_uint8(node, BLKDEV_BIOS_ID, &bios_id, false) != B_OK
if (pnp->get_attr_uint8(node, B_BLOCK_DEVICE_BIOS_ID, &bios_id, false) != B_OK
|| bios_id == 0 )
return;
@@ -388,26 +388,26 @@ blkman_remove(device_node_handle node, void *cookie)
static status_t
blkman_init_device(device_node_handle node, void *user_cookie, void **cookie)
block_io_init_device(device_node_handle node, void *user_cookie, void **cookie)
{
blkman_device_info *device;
blkdev_params params;
block_io_device_info *device;
block_device_params params;
char *name, *tmp_name;
uint8 is_bios_drive;
status_t res;
TRACE(("blkman_init_device()\n"));
TRACE(("block_io_init_device()\n"));
// extract controller/protocoll restrictions from node
if (pnp->get_attr_uint32(node, BLKDEV_DMA_ALIGNMENT, &params.alignment, true) != B_OK)
if (pnp->get_attr_uint32(node, B_BLOCK_DEVICE_DMA_ALIGNMENT, &params.alignment, true) != B_OK)
params.alignment = 0;
if (pnp->get_attr_uint32(node, BLKDEV_MAX_BLOCKS_ITEM, &params.max_blocks, true) != B_OK)
if (pnp->get_attr_uint32(node, B_BLOCK_DEVICE_MAX_BLOCKS_ITEM, &params.max_blocks, true) != B_OK)
params.max_blocks = 0xffffffff;
if (pnp->get_attr_uint32(node, BLKDEV_DMA_BOUNDARY, &params.dma_boundary, true) != B_OK)
if (pnp->get_attr_uint32(node, B_BLOCK_DEVICE_DMA_BOUNDARY, &params.dma_boundary, true) != B_OK)
params.dma_boundary = ~0;
if (pnp->get_attr_uint32(node, BLKDEV_MAX_SG_BLOCK_SIZE, &params.max_sg_block_size, true) != B_OK)
if (pnp->get_attr_uint32(node, B_BLOCK_DEVICE_MAX_SG_BLOCK_SIZE, &params.max_sg_block_size, true) != B_OK)
params.max_sg_block_size = 0xffffffff;
if (pnp->get_attr_uint32(node, BLKDEV_MAX_SG_BLOCKS, &params.max_sg_blocks, true) != B_OK)
if (pnp->get_attr_uint32(node, B_BLOCK_DEVICE_MAX_SG_BLOCKS, &params.max_sg_blocks, true) != B_OK)
params.max_sg_blocks = ~0;
// do some sanity check:
@@ -439,7 +439,7 @@ blkman_init_device(device_node_handle node, void *user_cookie, void **cookie)
// (they consume 4KB and can describe up to 2MB virtual cont. memory!)
params.max_sg_blocks = min(params.max_sg_blocks, 512);
if (pnp->get_attr_uint8(node, BLKDEV_IS_BIOS_DRIVE, &is_bios_drive, true) != B_OK)
if (pnp->get_attr_uint8(node, B_BLOCK_DEVICE_IS_BIOS_DRIVE, &is_bios_drive, true) != B_OK)
is_bios_drive = false;
// we don't really care about /dev name, but if it is
@@ -449,7 +449,7 @@ blkman_init_device(device_node_handle node, void *user_cookie, void **cookie)
return B_ERROR;
}
device = (blkman_device_info *)malloc(sizeof(*device));
device = (block_io_device_info *)malloc(sizeof(*device));
if (device == NULL) {
res = B_NO_MEMORY;
goto err1;
@@ -459,7 +459,7 @@ blkman_init_device(device_node_handle node, void *user_cookie, void **cookie)
device->node = node;
res = benaphore_init(&device->lock, "blkdev_mutex");
res = benaphore_init(&device->lock, "block_device_mutex");
if (res < 0)
goto err2;
@@ -517,7 +517,7 @@ err1:
static status_t
blkman_uninit_device(blkman_device_info *device)
block_io_uninit_device(block_io_device_info *device)
{
pnp->uninit_driver(pnp->get_parent(device->node));
@@ -530,54 +530,54 @@ blkman_uninit_device(blkman_device_info *device)
static status_t
blkman_init_buffer(void)
block_io_init_buffer(void)
{
physical_entry physicalTable[2];
status_t res;
TRACE(("blkman_init_buffer()\n"));
TRACE(("block_io_init_buffer()\n"));
blkman_buffer_size = 32*1024;
block_io_buffer_size = 32*1024;
blkman_buffer_lock = create_sem(1, "blkman_buffer_mutex");
if (blkman_buffer_lock < 0) {
res = blkman_buffer_lock;
block_io_buffer_lock = create_sem(1, "block_io_buffer_mutex");
if (block_io_buffer_lock < 0) {
res = block_io_buffer_lock;
goto err1;
}
res = blkman_buffer_area = create_area("blkman_buffer",
(void **)&blkman_buffer, B_ANY_KERNEL_ADDRESS,
blkman_buffer_size, B_FULL_LOCK | B_CONTIGUOUS, B_READ_AREA | B_WRITE_AREA);
res = block_io_buffer_area = create_area("block_io_buffer",
(void **)&block_io_buffer, B_ANY_KERNEL_ADDRESS,
block_io_buffer_size, B_FULL_LOCK | B_CONTIGUOUS, B_READ_AREA | B_WRITE_AREA);
if (res < 0)
goto err2;
res = get_memory_map(blkman_buffer, blkman_buffer_size, physicalTable, 2);
res = get_memory_map(block_io_buffer, block_io_buffer_size, physicalTable, 2);
if (res < 0)
goto err3;
blkman_buffer_vec[0].iov_base = blkman_buffer;
blkman_buffer_vec[0].iov_len = blkman_buffer_size;
block_io_buffer_vec[0].iov_base = block_io_buffer;
block_io_buffer_vec[0].iov_len = block_io_buffer_size;
blkman_buffer_phys_vec.num = 1;
blkman_buffer_phys_vec.total_len = blkman_buffer_size;
blkman_buffer_phys_vec.vec[0] = physicalTable[0];
block_io_buffer_phys_vec.num = 1;
block_io_buffer_phys_vec.total_len = block_io_buffer_size;
block_io_buffer_phys_vec.vec[0] = physicalTable[0];
return B_OK;
err3:
delete_area(blkman_buffer_area);
delete_area(block_io_buffer_area);
err2:
delete_sem(blkman_buffer_lock);
delete_sem(block_io_buffer_lock);
err1:
return res;
}
static status_t
blkman_uninit_buffer(void)
block_io_uninit_buffer(void)
{
delete_area(blkman_buffer_area);
delete_sem(blkman_buffer_lock);
delete_area(block_io_buffer_area);
delete_sem(block_io_buffer_lock);
return B_OK;
}
@@ -588,9 +588,9 @@ std_ops(int32 op, ...)
{
switch (op) {
case B_MODULE_INIT:
return blkman_init_buffer();
return block_io_init_buffer();
case B_MODULE_UNINIT:
blkman_uninit_buffer();
block_io_uninit_buffer();
return B_OK;
default:
@@ -606,38 +606,38 @@ module_dependency module_dependencies[] = {
};
pnp_devfs_driver_info blkman_module = {
pnp_devfs_driver_info block_io_module = {
{
{
BLKMAN_MODULE_NAME,
B_BLOCK_IO_MODULE_NAME,
0,
std_ops
},
NULL, // supports device
blkman_register_device,
blkman_init_device,
(status_t (*)( void * )) blkman_uninit_device,
blkman_remove,
block_io_register_device,
block_io_init_device,
(status_t (*)( void * )) block_io_uninit_device,
block_io_remove,
NULL, // cleanup
NULL, // get paths
},
(status_t (*)(void *, uint32, void **))blkman_open,
(status_t (*)(void *))blkman_close,
(status_t (*)(void *))blkman_freecookie,
(status_t (*)(void *, uint32, void **))block_io_open,
(status_t (*)(void *))block_io_close,
(status_t (*)(void *))block_io_freecookie,
(status_t (*)(void *, uint32, void *, size_t))blkman_ioctl,
(status_t (*)(void *, uint32, void *, size_t))block_io_ioctl,
(status_t (*)(void *, off_t, void *, size_t *))blkman_read,
(status_t (*)(void *, off_t, const void *, size_t *))blkman_write,
(status_t (*)(void *, off_t, void *, size_t *))block_io_read,
(status_t (*)(void *, off_t, const void *, size_t *))block_io_write,
NULL,
NULL,
(status_t (*)(void *, off_t, const iovec *, size_t, size_t *))blkman_readv,
(status_t (*)(void *, off_t, const iovec *, size_t, size_t *))blkman_writev
(status_t (*)(void *, off_t, const iovec *, size_t, size_t *))block_io_readv,
(status_t (*)(void *, off_t, const iovec *, size_t, size_t *))block_io_writev
};
@@ -657,19 +657,19 @@ std_ops_for_driver(int32 op, ...)
}
blkman_for_driver_interface blkman_for_driver_module = {
block_io_for_driver_interface block_io_for_driver_module = {
{
BLKMAN_FOR_DRIVER_MODULE_NAME,
B_BLOCK_IO_FOR_DRIVER_MODULE_NAME,
0,
std_ops_for_driver
},
blkman_set_media_params,
block_io_set_media_params,
};
module_info *modules[] = {
&blkman_module.info.info,
&blkman_for_driver_module.minfo,
&block_io_module.info.info,
&block_io_for_driver_module.info,
NULL
};
@@ -9,70 +9,72 @@
Internal header.
*/
#include <blkman.h>
#include <string.h>
#include <block_io.h>
#include <module.h>
#include <locked_pool.h>
#include <malloc.h>
#include <pnp_devfs.h>
#include <device_manager.h>
#include <bios_drive.h>
#include <stdlib.h>
#include <string.h>
#include "bios_drive.h"
#include "wrapper.h"
// controller restrictions (see blkman.h)
typedef struct blkdev_params {
// controller restrictions (see block_io.h)
typedef struct block_device_params {
uint32 alignment;
uint32 max_blocks;
uint32 dma_boundary;
uint32 max_sg_block_size;
uint32 max_sg_blocks;
} blkdev_params;
} block_device_params;
// device info
typedef struct blkman_device_info {
typedef struct block_io_device_info {
device_node_handle node;
blkdev_interface *interface;
blkdev_device_cookie cookie;
block_device_interface *interface;
block_device_device_cookie cookie;
benaphore lock; // used for access to following variables
uint32 block_size;
uint32 ld_block_size;
uint64 capacity;
blkdev_params params;
block_device_params params;
bool is_bios_drive; // could be a BIOS drive
locked_pool_cookie phys_vecs_pool; // pool of temporary phys_vecs
bios_drive *bios_drive; // info about corresponding BIOS drive
} blkman_device_info;
} block_io_device_info;
// file handle info
typedef struct blkman_handle_info {
blkman_device_info *device;
blkdev_handle_cookie cookie;
} blkman_handle_info;
typedef struct block_io_handle_info {
block_io_device_info *device;
block_device_handle_cookie cookie;
} block_io_handle_info;
// attribute containing BIOS drive ID (or 0, if it's no BIOS drive) (uint8)
#define BLKDEV_BIOS_ID "blkdev/bios_id"
#define B_BLOCK_DEVICE_BIOS_ID "blkdev/bios_id"
// transmission buffer data:
// size in bytes
extern uint blkman_buffer_size;
extern uint block_io_buffer_size;
// to use the buffer, you must own this semaphore
extern sem_id blkman_buffer_lock;
extern sem_id block_io_buffer_lock;
// iovec
extern struct iovec blkman_buffer_vec[1];
extern struct iovec block_io_buffer_vec[1];
// physical address
extern void *blkman_buffer_phys;
extern void *block_io_buffer_phys;
// virtual address
extern char *blkman_buffer;
extern char *block_io_buffer;
// phys_vec of it (always linear)
extern phys_vecs blkman_buffer_phys_vec;
extern phys_vecs block_io_buffer_phys_vec;
// area containing buffer
extern area_id blkman_buffer_area;
extern area_id block_io_buffer_area;
extern locked_pool_interface *locked_pool;
extern device_manager_info *pnp;
@@ -80,11 +82,11 @@ extern device_manager_info *pnp;
// io.c
status_t blkman_readv(blkman_handle_info *handle, off_t pos, struct iovec *vec,
status_t block_io_readv(block_io_handle_info *handle, off_t pos, struct iovec *vec,
size_t vec_count, size_t *len);
status_t blkman_read(blkman_handle_info *handle, off_t pos, void *buf, size_t *len);
ssize_t blkman_writev(blkman_handle_info *handle, off_t pos, struct iovec *vec,
status_t block_io_read(block_io_handle_info *handle, off_t pos, void *buf, size_t *len);
ssize_t block_io_writev(block_io_handle_info *handle, off_t pos, struct iovec *vec,
size_t vec_count, ssize_t *len);
ssize_t blkman_write(blkman_handle_info *handle, off_t pos, void *buf, size_t *len);
void blkman_set_media_params(blkman_device_info *device,
ssize_t block_io_write(block_io_handle_info *handle, off_t pos, void *buf, size_t *len);
void block_io_set_media_params(block_io_device_info *device,
uint32 block_size, uint32 ld_block_size, uint64 capacity);
+44 -45
View File
@@ -29,9 +29,8 @@
*/
#include "blkman_int.h"
#include "KernelExport_ext.h"
#include <thread_types.h>
#include "block_io_private.h"
#include "virtual_memory.h"
/** get sg list of iovecs, taking dma boundaries and maximum size of
@@ -40,7 +39,7 @@
*/
static int
blkman_map_iovecs(iovec *vec, size_t vec_count, size_t vec_offset, size_t len,
block_io_map_iovecs(iovec *vec, size_t vec_count, size_t vec_offset, size_t len,
phys_vecs *map, size_t max_phys_entries, size_t dma_boundary,
size_t max_sg_block_size)
{
@@ -104,7 +103,7 @@ blkman_map_iovecs(iovec *vec, size_t vec_count, size_t vec_offset, size_t len,
*/
static bool
blkman_check_alignment(struct iovec *vecs, uint num_vecs,
block_io_check_alignment(struct iovec *vecs, uint num_vecs,
size_t vec_offset, uint alignment)
{
if (alignment == 0)
@@ -138,7 +137,7 @@ blkman_check_alignment(struct iovec *vecs, uint num_vecs,
*/
static size_t
blkman_lock_iovecs(struct iovec *vecs, uint num_vecs,
block_io_lock_iovecs(struct iovec *vecs, uint num_vecs,
size_t vec_offset, size_t len, int flags)
{
size_t orig_len = len;
@@ -172,7 +171,7 @@ blkman_lock_iovecs(struct iovec *vecs, uint num_vecs,
/** unlock iovecs */
static void
blkman_unlock_iovecs(struct iovec *vecs, uint num_vecs,
block_io_unlock_iovecs(struct iovec *vecs, uint num_vecs,
size_t vec_offset, size_t len, int flags)
{
SHOW_FLOW(3, "len = %lu", len);
@@ -197,7 +196,7 @@ blkman_unlock_iovecs(struct iovec *vecs, uint num_vecs,
*/
static void
blkman_copy_buffer(char *buffer, struct iovec *vecs, uint num_vecs,
block_io_copy_buffer(char *buffer, struct iovec *vecs, uint num_vecs,
size_t vec_offset, size_t len, bool to_buffer)
{
for (; len > 0 && num_vecs > 0; ++vecs, --num_vecs) {
@@ -219,7 +218,7 @@ blkman_copy_buffer(char *buffer, struct iovec *vecs, uint num_vecs,
/** determine number of bytes described by iovecs */
static size_t
blkman_iovec_len(struct iovec *vecs, uint num_vecs, size_t vec_offset)
block_io_iovec_len(struct iovec *vecs, uint num_vecs, size_t vec_offset)
{
size_t len = 0;
@@ -240,10 +239,10 @@ blkman_iovec_len(struct iovec *vecs, uint num_vecs, size_t vec_offset)
*/
static inline status_t
blkman_readwrite(blkman_handle_info *handle, off_t pos, struct iovec *vec,
block_io_readwrite(block_io_handle_info *handle, off_t pos, struct iovec *vec,
int vec_count, size_t *total_len, bool need_locking, bool write)
{
blkman_device_info *device = handle->device;
block_io_device_info *device = handle->device;
uint32 block_size, ld_block_size;
uint64 capacity;
bool need_buffer;
@@ -355,7 +354,7 @@ blkman_readwrite(blkman_handle_info *handle, off_t pos, struct iovec *vec,
// you deserve)
need_buffer = block_ofs != 0
|| len < block_size
|| !blkman_check_alignment(vec, vec_count, vec_offset, device->params.alignment);
|| !block_io_check_alignment(vec, vec_count, vec_offset, device->params.alignment);
retry:
if (need_buffer) {
@@ -365,7 +364,7 @@ retry:
SHOW_FLOW(1, "buffer required: len=%ld, block_ofs=%ld",
len, block_ofs);
acquire_sem(blkman_buffer_lock);
acquire_sem(block_io_buffer_lock);
// nobody helps us if there are too few iovecs, so test
// for that explicitely
@@ -373,7 +372,7 @@ retry:
// we would get trouble when we try to round up to next
// block size, which would lead to zero, making trouble
// during lock)
tmp_len = blkman_iovec_len(vec, vec_count, vec_offset);
tmp_len = block_io_iovec_len(vec, vec_count, vec_offset);
tmp_len = min(tmp_len, len);
SHOW_FLOW(3, "tmp_len: %lu", tmp_len);
@@ -385,7 +384,7 @@ retry:
SHOW_FLOW0(3, "partial write at beginning: reading content of first block");
res = device->interface->read(handle->cookie,
&blkman_buffer_phys_vec, block_pos,
&block_io_buffer_phys_vec, block_pos,
cur_blocks, block_size, &bytes_transferred);
} else {
// alignment problem or partial block read - find out how many
@@ -395,8 +394,8 @@ retry:
SHOW_FLOW(3, "cur_blocks: %ld", cur_blocks);
// restrict block count to buffer size
if (cur_blocks * block_size > blkman_buffer_size)
cur_blocks = blkman_buffer_size / block_size;
if (cur_blocks * block_size > block_io_buffer_size)
cur_blocks = block_io_buffer_size / block_size;
}
// copy data into buffer before write
@@ -404,12 +403,12 @@ retry:
if (write) {
SHOW_FLOW(3, "copy data to buffer (%ld bytes)",
cur_blocks * block_size - block_ofs);
blkman_copy_buffer(blkman_buffer + block_ofs,
block_io_copy_buffer(block_io_buffer + block_ofs,
vec, vec_count, vec_offset, cur_blocks * block_size - block_ofs,
true);
}
cur_vecs = blkman_buffer_vec;
cur_vecs = block_io_buffer_vec;
cur_vec_count = 1;
cur_vec_offset = 0;
} else {
@@ -449,7 +448,7 @@ retry:
SHOW_FLOW(3, "trying to lock %lu bytes", cur_len);
locked_len = blkman_lock_iovecs(cur_vecs, cur_vec_count,
locked_len = block_io_lock_iovecs(cur_vecs, cur_vec_count,
cur_vec_offset, cur_len, B_DMA_IO | (write ? 0 : B_READ_DEVICE));
if (locked_len == cur_len)
@@ -469,7 +468,7 @@ retry:
// got less then one block locked - unlock and retry
SHOW_FLOW0(3, "too few bytes locked - trying again with fewer bytes");
blkman_unlock_iovecs(cur_vecs, cur_vec_count, cur_vec_offset, locked_len,
block_io_unlock_iovecs(cur_vecs, cur_vec_count, cur_vec_offset, locked_len,
B_DMA_IO | (write ? 0 : B_READ_DEVICE));
}
@@ -495,7 +494,7 @@ retry:
// time to setup sg list
SHOW_FLOW0(3, "Creating SG list");
res = blkman_map_iovecs(cur_vecs, cur_vec_count, cur_vec_offset, cur_len,
res = block_io_map_iovecs(cur_vecs, cur_vec_count, cur_vec_offset, cur_len,
phys_vecs, device->params.max_sg_blocks, device->params.dma_boundary,
device->params.max_sg_block_size);
@@ -515,7 +514,7 @@ retry:
SHOW_FLOW0(3, "SG too small to handle even one block");
if (need_locking) {
blkman_unlock_iovecs(cur_vecs, cur_vec_count, cur_vec_offset,
block_io_unlock_iovecs(cur_vecs, cur_vec_count, cur_vec_offset,
cur_len, B_DMA_IO | (write ? 0 : B_READ_DEVICE));
}
@@ -553,7 +552,7 @@ retry:
cannot_map:
// unlock data
if (need_locking) {
blkman_unlock_iovecs(cur_vecs, cur_vec_count, cur_vec_offset,
block_io_unlock_iovecs(cur_vecs, cur_vec_count, cur_vec_offset,
cur_len, B_DMA_IO | (write ? 0 : B_READ_DEVICE));
}
@@ -572,11 +571,11 @@ cannot_map:
if (!write) {
SHOW_FLOW(3, "copying data back from buffer (%ld bytes)",
bytes_transferred);
blkman_copy_buffer(blkman_buffer + block_ofs,
block_io_copy_buffer(block_io_buffer + block_ofs,
vec, vec_count, vec_offset, bytes_transferred, false);
}
release_sem(blkman_buffer_lock);
release_sem(block_io_buffer_lock);
}
len -= bytes_transferred;
@@ -592,7 +591,7 @@ cannot_map:
err3:
if (need_buffer)
release_sem(blkman_buffer_lock);
release_sem(block_io_buffer_lock);
err2:
locked_pool->free(device->phys_vecs_pool, phys_vecs);
err:
@@ -605,18 +604,18 @@ err:
static status_t
blkman_readv_int(blkman_handle_info *handle, off_t pos, struct iovec *vec,
block_io_readv_int(block_io_handle_info *handle, off_t pos, struct iovec *vec,
size_t vec_count, size_t *len, bool need_locking)
{
return blkman_readwrite(handle, pos, vec, vec_count, len, need_locking, false);
return block_io_readwrite(handle, pos, vec, vec_count, len, need_locking, false);
}
static status_t
blkman_writev_int(blkman_handle_info *handle, off_t pos, struct iovec *vec,
block_io_writev_int(block_io_handle_info *handle, off_t pos, struct iovec *vec,
size_t vec_count, size_t *len, bool need_locking)
{
return blkman_readwrite(handle, pos, vec, vec_count, len, need_locking, true);
return block_io_readwrite(handle, pos, vec, vec_count, len, need_locking, true);
}
@@ -626,7 +625,7 @@ blkman_writev_int(blkman_handle_info *handle, off_t pos, struct iovec *vec,
*/
static inline status_t
blkman_readwritev(blkman_handle_info *handle, off_t pos, struct iovec *vec,
block_io_readwritev(block_io_handle_info *handle, off_t pos, struct iovec *vec,
size_t vec_count, size_t *len, bool write)
{
@@ -649,9 +648,9 @@ blkman_readwritev(blkman_handle_info *handle, off_t pos, struct iovec *vec,
*len = total_len;
if (write)
res = blkman_writev_int(handle, pos, vec, vec_count, len, true);
res = block_io_writev_int(handle, pos, vec, vec_count, len, true);
else
res = blkman_readv_int(handle, pos, vec, vec_count, len, true);
res = block_io_readv_int(handle, pos, vec, vec_count, len, true);
unlock_memory(vec, vec_count * sizeof(vec[0]), 0);
@@ -660,7 +659,7 @@ blkman_readwritev(blkman_handle_info *handle, off_t pos, struct iovec *vec,
status_t
blkman_readv(blkman_handle_info *handle, off_t pos, struct iovec *vec,
block_io_readv(block_io_handle_info *handle, off_t pos, struct iovec *vec,
size_t vec_count, size_t *len)
{
/* SHOW_FLOW( 4, "len=%d", (int)*len );
@@ -670,12 +669,12 @@ blkman_readv(blkman_handle_info *handle, off_t pos, struct iovec *vec,
(int)cur_vec->iov_base, (int)cur_vec->iov_len );
}*/
return blkman_readwritev(handle, pos, vec, vec_count, len, false);
return block_io_readwritev(handle, pos, vec, vec_count, len, false);
}
status_t
blkman_read(blkman_handle_info *handle, off_t pos, void *buf, size_t *len)
block_io_read(block_io_handle_info *handle, off_t pos, void *buf, size_t *len)
{
iovec vec[1];
@@ -685,37 +684,37 @@ blkman_read(blkman_handle_info *handle, off_t pos, void *buf, size_t *len)
SHOW_FLOW0( 3, "" );
// This assumes that the thread stack is not paged,
// else you want to use blkman_readv
// else you want to use block_io_readv
// But this is not a problem, since kernel stacks
// are always paged in (since they can be used by
// an interrupt at any time)
return blkman_readv_int(handle, pos, vec, 1, len, true);
return block_io_readv_int(handle, pos, vec, 1, len, true);
}
ssize_t
blkman_writev(blkman_handle_info *handle, off_t pos, struct iovec *vec,
block_io_writev(block_io_handle_info *handle, off_t pos, struct iovec *vec,
size_t vec_count, ssize_t *len)
{
return blkman_readwritev(handle, pos, vec, vec_count, len, true);
return block_io_readwritev(handle, pos, vec, vec_count, len, true);
}
ssize_t
blkman_write(blkman_handle_info *handle, off_t pos, void *buf, size_t *len)
block_io_write(block_io_handle_info *handle, off_t pos, void *buf, size_t *len)
{
iovec vec[1];
vec[0].iov_base = buf;
vec[0].iov_len = *len;
// see blkman_read
return blkman_writev_int(handle, pos, vec, 1, len, true);
// see block_io_read
return block_io_writev_int(handle, pos, vec, 1, len, true);
}
void
blkman_set_media_params(blkman_device_info *device, uint32 block_size,
block_io_set_media_params(block_io_device_info *device, uint32 block_size,
uint32 ld_block_size, uint64 capacity)
{
SHOW_FLOW(3, "block_size = %lu, ld_block_size = %lu, capacity = %Lu\n", block_size,
@@ -1,7 +1,7 @@
/*
** Copyright 2002/03, Thomas Kurschel. All rights reserved.
** Distributed under the terms of the OpenBeOS License.
*/
* Copyright 2002/03, Thomas Kurschel. All rights reserved.
* Distributed under the terms of the MIT License.
*/
/*
VM helper functions.
@@ -11,7 +11,7 @@
list of length one.
*/
#include "KernelExport_ext.h"
#include "virtual_memory.h"
#include "wrapper.h"
#include <vm.h>
@@ -118,22 +118,3 @@ get_iovec_memory_map(iovec *vec, size_t vec_count, size_t vec_offset, size_t len
return B_OK;
}
/** map main memory into virtual address space */
status_t
map_mainmemory(addr_t physicalAddress, void **_virtualAddress)
{
return vm_get_physical_page(physicalAddress, (addr_t *)_virtualAddress, PHYSICAL_PAGE_CAN_WAIT);
// ToDo: check if CAN_WAIT is correct
}
/** unmap main memory from virtual address space */
status_t
unmap_mainmemory(void *virtualAddress)
{
return vm_put_physical_page((addr_t)virtualAddress);
}
@@ -0,0 +1,19 @@
/*
* Copyright 2002/03, Thomas Kurschel. All rights reserved.
* Distributed under the terms of the MIT License.
*/
#ifndef _VIRTUAL_MEMORY_H
#define _VIRTUAL_MEMORY_H
#include <KernelExport.h>
#include <iovec.h>
// get memory map of iovec
extern status_t get_iovec_memory_map(iovec *vec, size_t vecCount,
size_t vecOffset, size_t length, physical_entry *map,
size_t maxMapEntries, size_t *_numEntries,
size_t *_mappedLength);
#endif /* _VIRTUAL_MEMORY_H */
@@ -12,11 +12,10 @@
#include "scsi_periph_int.h"
#include <blkman.h>
#include <string.h>
#include <stdio.h>
#include <malloc.h>
#include <stdlib.h>
#define SCSI_PERIPH_STD_TIMEOUT 10
@@ -1,7 +1,7 @@
/*
** Copyright 2002/03, Thomas Kurschel. All rights reserved.
** Distributed under the terms of the OpenBeOS License.
*/
* Copyright 2002/03, Thomas Kurschel. All rights reserved.
* Distributed under the terms of the MIT License.
*/
/*
Part of Open SCSI Peripheral Driver
@@ -9,9 +9,8 @@
Error handling
*/
#include "scsi_periph_int.h"
#include <blkman.h>
#include "scsi_periph_int.h"
/** decode sense data and generate error code */
@@ -1,7 +1,7 @@
/*
** Copyright 2002/03, Thomas Kurschel. All rights reserved.
** Distributed under the terms of the OpenBeOS License.
*/
* Copyright 2002/03, Thomas Kurschel. All rights reserved.
* Distributed under the terms of the MIT License.
*/
/*
Part of Open SCSI Peripheral Driver
@@ -12,7 +12,6 @@
#include "scsi_periph_int.h"
#include <blkman.h>
#include <string.h>
@@ -6,10 +6,12 @@
#define __SCSI_PERIPH_INT_H__
#include <stddef.h>
#include <bus/scsi/scsi_periph.h>
#include <blkman.h>
#include <block_io.h>
#include <device_manager.h>
#include <stddef.h>
#include "wrapper.h"