minix/include/minix/devio.h

69 lines
2.4 KiB
C
Raw Normal View History

2005-04-21 16:53:53 +02:00
/* This file provides basic types and some constants for the
* SYS_DEVIO and SYS_VDEVIO system calls, which allow user-level
* processes to perform device I/O.
*
* Created:
* Apr 08, 2004 by Jorrit N. Herder
*/
#ifndef _DEVIO_H
#define _DEVIO_H
#include <minix/sys_config.h> /* needed to include <minix/type.h> */
#include <sys/types.h> /* u8_t, u16_t, u32_t needed */
2005-04-21 16:53:53 +02:00
typedef u16_t port_t;
2005-04-21 16:53:53 +02:00
/* We have different granularities of port I/O: 8, 16, 32 bits.
* Also see <ibm/portio.h>, which has functions for bytes, words,
* and longs. Hence, we need different (port,value)-pair types.
*/
typedef struct { u16_t port; u8_t value; } pvb_pair_t;
typedef struct { u16_t port; u16_t value; } pvw_pair_t;
typedef struct { u16_t port; u32_t value; } pvl_pair_t;
/* Macro shorthand to set (port,value)-pair. */
#define pv_set(pv, p, v) do { \
u32_t _p = (p), _v = (v); \
(pv).port = _p; \
(pv).value = _v; \
if((pv).port != _p || (pv).value != _v) { \
Split block/character protocols and libdriver This patch separates the character and block driver communication protocols. The old character protocol remains the same, but a new block protocol is introduced. The libdriver library is replaced by two new libraries: libchardriver and libblockdriver. Their exposed API, and drivers that use them, have been updated accordingly. Together, libbdev and libblockdriver now completely abstract away the message format used by the block protocol. As the memory driver is both a character and a block device driver, it now implements its own message loop. The most important semantic change made to the block protocol is that it is no longer possible to return both partial results and an error for a single transfer. This simplifies the interaction between the caller and the driver, as the I/O vector no longer needs to be copied back. Also, drivers are now no longer supposed to decide based on the layout of the I/O vector when a transfer should be cut short. Put simply, transfers are now supposed to either succeed completely, or result in an error. After this patch, the state of the various pieces is as follows: - block protocol: stable - libbdev API: stable for synchronous communication - libblockdriver API: needs slight revision (the drvlib/partition API in particular; the threading API will also change shortly) - character protocol: needs cleanup - libchardriver API: needs cleanup accordingly - driver restarts: largely unsupported until endpoint changes are reintroduced As a side effect, this patch eliminates several bugs, hacks, and gcc -Wall and -W warnings all over the place. It probably introduces a few new ones, too. Update warning: this patch changes the protocol between MFS and disk drivers, so in order to use old/new images, the MFS from the ramdisk must be used to mount all file systems.
2011-11-22 13:27:53 +01:00
printf("%s:%d: actual port: 0x%x != 0x%x || " \
"actual value: 0x%x != 0x%x\n", \
__FILE__, __LINE__, (pv).port, _p, (pv).value, _v); \
panic("pv_set(" #pv ", " #p ", " #v ")"); \
} \
} while(0)
2005-04-21 16:53:53 +02:00
#if 0 /* no longer in use !!! */
/* Define a number of flags to indicate granularity we are using. */
#define MASK_GRANULARITY 0x000F /* not in use! does not match flags */
#define PVB_FLAG 'b'
#define PVW_FLAG 'w'
#define PVL_FLAG 'l'
/* Flags indicating whether request wants to do input or output. */
#define MASK_IN_OR_OUT 0x00F0
#define DEVIO_INPUT 0x0010
#define DEVIO_OUTPUT 0x0020
#endif /* 0 */
#if 0 /* no longer used !!! */
/* Define how large the (port,value)-pair buffer in the kernel is.
* This buffer is used to copy the (port,value)-pairs in kernel space.
*/
#define PV_BUF_SIZE 64 /* creates char pv_buf[PV_BUF_SIZE] */
/* Note that SYS_VDEVIO sends a pointer to a vector of (port,value)-pairs,
* whereas SYS_DEVIO includes a single (port,value)-pair in the messages.
* Calculate maximum number of (port,value)-pairs that can be handled
* in a single SYS_VDEVIO system call with above struct definitions.
*/
#define MAX_PVB_PAIRS ((PV_BUF_SIZE * sizeof(char)) / sizeof(pvb_pair_t))
#define MAX_PVW_PAIRS ((PV_BUF_SIZE * sizeof(char)) / sizeof(pvw_pair_t))
#define MAX_PVL_PAIRS ((PV_BUF_SIZE * sizeof(char)) / sizeof(pvl_pair_t))
#endif /* 0 */
#endif /* _DEVIO_H */