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
13 static int __setup_vdev_ded(struct virt_sys
*sys
,
14 struct directory_vdev
*dirdev
,
15 struct virt_device
*vdev
)
20 rdev
= find_device_by_ccuu(dirdev
->u
.dedicate
.rdev
);
24 mutex_lock(&rdev
->lock
);
33 vdev
->u
.dedicate
.rdev
= rdev
;
34 vdev
->type
= rdev
->type
;
35 vdev
->model
= rdev
->model
;
40 mutex_unlock(&rdev
->lock
);
44 static LOCK_CLASS(vdev_lc
);
46 /* assumes sys->virt_devs_lock is held */
47 int alloc_virt_dev(struct virt_sys
*sys
, struct directory_vdev
*dirdev
,
50 struct virt_device
*vdev
;
53 vdev
= malloc(sizeof(struct virt_device
), ZONE_NORMAL
);
57 mutex_init(&vdev
->lock
, &vdev_lc
);
59 vdev
->vtype
= dirdev
->type
;
62 vdev
->pmcw
.dev_num
= dirdev
->vdev
;
63 vdev
->pmcw
.lpm
= 0x80;
64 vdev
->pmcw
.pim
= 0x80;
65 vdev
->pmcw
.pom
= 0xff;
66 vdev
->pmcw
.pam
= 0x80;
68 switch(dirdev
->type
) {
70 /* CONS is really just a special case of SPOOL */
71 vdev
->u
.spool
.file
= NULL
;
72 vdev
->u
.spool
.ops
= &spool_cons_ops
;
77 vdev
->u
.spool
.file
= NULL
;
78 vdev
->u
.spool
.ops
= NULL
;
79 vdev
->type
= dirdev
->u
.spool
.type
;
80 vdev
->model
= dirdev
->u
.spool
.model
;
83 ret
= __setup_vdev_ded(sys
, dirdev
, vdev
);
88 FIXME("hook it up to mdisk driver");
97 list_add_tail(&vdev
->devices
, &sys
->virt_devs
);