1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140
|
/*
* Mach Operating System
* Copyright (c) 1991,1990,1989 Carnegie Mellon University
* All Rights Reserved.
*
* Permission to use, copy, modify and distribute this software and its
* documentation is hereby granted, provided that both the copyright
* notice and this permission notice appear in all copies of the
* software, derivative works or modified versions, and any portions
* thereof, and that both notices appear in supporting documentation.
*
* CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
* CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
* ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
*
* Carnegie Mellon requests users of this software to return to
*
* Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
* School of Computer Science
* Carnegie Mellon University
* Pittsburgh PA 15213-3890
*
* any improvements or extensions that they make and grant Carnegie Mellon
* the rights to redistribute these changes.
*/
/*
* Author: David B. Golub, Carnegie Mellon University
* Date: 3/89
*/
#ifndef DEVICE_TYPES_H
#define DEVICE_TYPES_H
/*
* Types for device interface.
*/
#include <mach/std_types.h>
#ifdef MACH_KERNEL
/*
* Get kernel-only type definitions.
*/
#include <device/device_types_kernel.h>
#else /* MACH_KERNEL */
/*
* Device handle.
*/
typedef mach_port_t device_t;
#endif /* MACH_KERNEL */
/*
* Device name string
*/
typedef char dev_name_t[128]; /* must match device_types.defs */
/*
* Mode for open/read/write
*/
typedef unsigned int dev_mode_t;
#define D_READ 0x1 /* read */
#define D_WRITE 0x2 /* write */
#define D_NODELAY 0x4 /* no delay on open */
#define D_NOWAIT 0x8 /* do not wait if data not available */
/*
* IO buffer - out-of-line array of characters.
*/
typedef char * io_buf_ptr_t;
/*
* IO buffer - in-line array of characters.
*/
#define IO_INBAND_MAX (128) /* must match device_types.defs */
typedef char io_buf_ptr_inband_t[IO_INBAND_MAX];
/*
* IO buffer vector - for scatter/gather IO.
*/
typedef struct {
vm_offset_t data;
vm_size_t count;
} io_buf_vec_t;
/*
* Record number for random-access devices
*/
typedef unsigned int recnum_t;
/*
* Flavors of set/get statuses
*/
typedef unsigned int dev_flavor_t;
/*
* Generic array for get/set status
*/
typedef int *dev_status_t; /* Variable-length array of integers */
#define DEV_STATUS_MAX (1024) /* Maximum array size */
typedef int dev_status_data_t[DEV_STATUS_MAX];
/*
* Mandatory get/set status operations
*/
/* size a device: op code and indexes for returned values */
#define DEV_GET_SIZE 0
# define DEV_GET_SIZE_DEVICE_SIZE 0 /* 0 if unknown */
# define DEV_GET_SIZE_RECORD_SIZE 1 /* 1 if sequential */
#define DEV_GET_SIZE_COUNT 2
/* size a device in record numbers, not bytes */
#define DEV_GET_RECORDS 1
# define DEV_GET_RECORDS_DEVICE_RECORDS 0 /* 0 if unknown */
# define DEV_GET_RECORDS_RECORD_SIZE 1 /* 1 if sequential */
#define DEV_GET_RECORDS_COUNT 2
/*
* Device error codes
*/
typedef int io_return_t;
#define D_IO_QUEUED (-1) /* IO queued - do not return result */
#define D_SUCCESS 0
#define D_IO_ERROR 2500 /* hardware IO error */
#define D_WOULD_BLOCK 2501 /* would block, but D_NOWAIT set */
#define D_NO_SUCH_DEVICE 2502 /* no such device */
#define D_ALREADY_OPEN 2503 /* exclusive-use device already open */
#define D_DEVICE_DOWN 2504 /* device has been shut down */
#define D_INVALID_OPERATION 2505 /* bad operation for device */
#define D_INVALID_RECNUM 2506 /* invalid record (block) number */
#define D_INVALID_SIZE 2507 /* invalid IO size */
#define D_NO_MEMORY 2508 /* memory allocation failure */
#define D_READ_ONLY 2509 /* device cannot be written to */
void device_deallocate(device_t);
#endif /* DEVICE_TYPES_H */
|