Project

General

Profile

Statistics
| Revision:

root / lab4 / .minix-src / include / minix / devio.h @ 14

History | View | Annotate | Download (2.36 KB)

1
/* This file provides basic types and some constants for the 
2
 * SYS_DEVIO and SYS_VDEVIO system calls, which allow user-level 
3
 * processes to perform device I/O. 
4
 *
5
 * Created: 
6
 *        Apr 08, 2004 by Jorrit N. Herder
7
 */
8

    
9
#ifndef _DEVIO_H
10
#define _DEVIO_H
11

    
12
#include <minix/sys_config.h>     /* needed to include <minix/type.h> */
13
#include <sys/types.h>        /* u8_t, u16_t, u32_t needed */
14

    
15
typedef u16_t port_t;
16

    
17
/* We have different granularities of port I/O: 8, 16, 32 bits.
18
 * Also see <ibm/portio.h>, which has functions for bytes, words,  
19
 * and longs. Hence, we need different (port,value)-pair types. 
20
 */
21
typedef struct { u16_t port;  u8_t value; } pvb_pair_t;
22
typedef struct { u16_t port; u16_t value; } pvw_pair_t;
23
typedef struct { u16_t port; u32_t value; } pvl_pair_t;
24

    
25
/* Macro shorthand to set (port,value)-pair. */
26
#define pv_set(pv, p, v) do {                                        \
27
        u32_t _p = (p), _v = (v);                                \
28
        (pv).port = _p;                                                \
29
        (pv).value = _v;                                        \
30
        if((pv).port != _p || (pv).value != _v) {                \
31
                printf("%s:%d: actual port: 0x%x != 0x%x || "        \
32
                        "actual value: 0x%x != 0x%x\n",        \
33
                        __FILE__, __LINE__, (pv).port, _p, (pv).value, _v); \
34
                panic("pv_set(" #pv ", " #p ", " #v ")"); \
35
        }                                                        \
36
} while(0)
37

    
38
#if 0        /* no longer in use !!! */
39
/* Define a number of flags to indicate granularity we are using. */
40
#define MASK_GRANULARITY 0x000F  /* not in use! does not match flags */
41
#define PVB_FLAG 'b'
42
#define PVW_FLAG 'w'
43
#define PVL_FLAG 'l'
44

45
/* Flags indicating whether request wants to do input or output. */
46
#define MASK_IN_OR_OUT 0x00F0
47
#define DEVIO_INPUT 0x0010
48
#define DEVIO_OUTPUT 0x0020
49
#endif        /* 0 */
50

    
51
#if 0        /* no longer used !!! */
52
/* Define how large the (port,value)-pair buffer in the kernel is. 
53
 * This buffer is used to copy the (port,value)-pairs in kernel space.
54
 */
55
#define PV_BUF_SIZE  64      /* creates char pv_buf[PV_BUF_SIZE] */
56

57
/* Note that SYS_VDEVIO sends a pointer to a vector of (port,value)-pairs, 
58
 * whereas SYS_DEVIO includes a single (port,value)-pair in the messages.
59
 * Calculate maximum number of (port,value)-pairs that can be handled 
60
 * in a single SYS_VDEVIO system call with above struct definitions. 
61
 */
62
#define MAX_PVB_PAIRS ((PV_BUF_SIZE * sizeof(char)) / sizeof(pvb_pair_t))
63
#define MAX_PVW_PAIRS ((PV_BUF_SIZE * sizeof(char)) / sizeof(pvw_pair_t))
64
#define MAX_PVL_PAIRS ((PV_BUF_SIZE * sizeof(char)) / sizeof(pvl_pair_t))
65
#endif /* 0 */
66
        
67

    
68
#endif  /* _DEVIO_H */