cp: guest layer revamp, part 1
[hvf.git] / cp / include / vdevice.h
blobac435c046c6d1bc067adf0841f61844fbb0c8f69
1 /*
2 * (C) Copyright 2007-2011 Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
4 * This file is released under the GPLv2. See the COPYING file for more
5 * details.
6 */
8 #ifndef __VDEVICE_H
9 #define __VDEVICE_H
11 #include <list.h>
12 #include <directory.h>
13 #include <sched.h>
14 #include <mutex.h>
15 #include <spool.h>
16 #include <vcpu.h>
19 * VDEV_SPOOL and VDEV_CONS related definitions
21 struct virt_device;
22 struct spdev_state;
24 struct spool_ops {
25 void (*f[16])(struct virt_sys *sys, struct virt_device *vdev,
26 struct ccw *ccw, struct spdev_state *st);
29 extern struct spool_ops spool_cons_ops; /* for VDEV_CONS */
31 struct spdev_state {
32 u8 dev_status; /* device/CU status */
33 u8 sch_status; /* subchannel status */
35 u32 addr; /* ccw address */
36 int f; /* ccw format */
38 u8 *iobuf;
40 u32 rem; /* current record remaining count */
41 u32 pos; /* current record remaining offset */
43 int cd; /* chain data bool */
44 u8 cmd; /* chain data command */
46 int tic2tic;
48 struct spool_ops *ops;
52 * The virtual device struct definition
54 struct virt_device {
55 struct list_head devices;
58 * protects the R/W fields:
59 * - pmcw
60 * - scsw
62 mutex_t lock;
64 enum directory_vdevtype vtype; /* VDEV_CONS, VDEV_DED, ... */
65 u32 sch; /* subchannel id */
66 u16 type; /* 3330, 3215, ... */
67 u8 model;
69 union {
70 struct {
71 struct device *rdev;
72 /* real device */
73 } dedicate;
74 struct {
75 struct spool_file *file;
76 /* the spool file backing this dev */
77 struct spool_ops *ops;
78 /* ops vector used for CCW exec */
79 } spool;
80 } u;
82 u8 sense; /* sense info */
84 struct pmcw pmcw; /* path info */
85 struct scsw scsw; /* subchannel-status */
86 struct orb orb;
90 * VDEV_SPOOL and VDEV_CONS: generate command reject
92 static inline void spooldev_cmdrej(struct virt_sys *sys,
93 struct virt_device *vdev,
94 struct spdev_state *st)
96 st->dev_status = SC_STATUS_CE | SC_STATUS_DE | SC_STATUS_UC;
97 vdev->sense = SENSE_CMDREJ;
101 * misc virtual device functions
103 extern int alloc_virt_dev(struct virt_sys *sys,
104 struct directory_vdev *dirdev, u32 sch);
106 #define for_each_vdev(sys, v) list_for_each_entry((v), &(sys)->virt_devs, \
107 devices)
109 #endif