From 2263bab8705a34ba9cc7af595f35149051cb4001 Mon Sep 17 00:00:00 2001 From: Peter Avalos Date: Mon, 12 Nov 2007 07:27:50 +0000 Subject: [PATCH] Build CAM as a module. This should make it possible to compile a kernel without SCSI support and load it when, for example, a USB floppy is connected. Obtained-from: FreeBSD --- sys/bus/cam/Makefile | 4 ++-- sys/bus/cam/cam/Makefile | 32 ++++++++++++++++++++++++++++++++ sys/bus/cam/cam_xpt.c | 27 +++++++++++++++++++++++++-- 3 files changed, 59 insertions(+), 4 deletions(-) create mode 100644 sys/bus/cam/cam/Makefile diff --git a/sys/bus/cam/Makefile b/sys/bus/cam/Makefile index 0dd16fd810..a47602b9f1 100644 --- a/sys/bus/cam/Makefile +++ b/sys/bus/cam/Makefile @@ -1,6 +1,6 @@ -# $DragonFly: src/sys/bus/cam/Makefile,v 1.1 2003/08/15 01:19:45 dillon Exp $ +# $DragonFly: src/sys/bus/cam/Makefile,v 1.2 2007/11/12 07:27:50 pavalos Exp $ # -SUBDIR=scsi +SUBDIR= cam scsi .include diff --git a/sys/bus/cam/cam/Makefile b/sys/bus/cam/cam/Makefile new file mode 100644 index 0000000000..544e731ef9 --- /dev/null +++ b/sys/bus/cam/cam/Makefile @@ -0,0 +1,32 @@ +# $FreeBSD: src/sys/modules/cam/Makefile,v 1.10.2.2 2004/04/19 17:32:16 njl Exp $ +# $DragonFly: src/sys/bus/cam/cam/Makefile,v 1.1 2007/11/12 07:27:50 pavalos Exp $ + +.PATH: ${.CURDIR}/.. ${.CURDIR}/../scsi + +KMOD= cam + +# See sys/conf/options for the flags that go into the different opt_*.h files. +SRCS= opt_cam.h +SRCS+= opt_scsi.h +SRCS+= opt_cd.h +SRCS+= opt_pt.h +SRCS+= opt_sa.h +SRCS+= opt_ses.h +SRCS+= device_if.h bus_if.h +SRCS+= cam.c cam_periph.c cam_queue.c +SRCS+= cam_sim.c cam_xpt.c +SRCS+= cam_extend.c +SRCS+= scsi_all.c scsi_cd.c scsi_ch.c +SRCS+= scsi_da.c +SRCS+= scsi_pass.c +SRCS+= scsi_pt.c +SRCS+= scsi_sa.c +SRCS+= scsi_ses.c +SRCS+= scsi_targ_bh.c scsi_target.c + +EXPORT_SYMS= YES # XXX evaluate + +opt_scsi.h: + echo "#define SCSI_DELAY 15000" > ${.TARGET} + +.include diff --git a/sys/bus/cam/cam_xpt.c b/sys/bus/cam/cam_xpt.c index e58c95450c..ac9e9d1f6b 100644 --- a/sys/bus/cam/cam_xpt.c +++ b/sys/bus/cam/cam_xpt.c @@ -27,7 +27,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/cam/cam_xpt.c,v 1.80.2.18 2002/12/09 17:31:55 gibbs Exp $ - * $DragonFly: src/sys/bus/cam/cam_xpt.c,v 1.35 2007/07/28 23:24:34 dillon Exp $ + * $DragonFly: src/sys/bus/cam/cam_xpt.c,v 1.36 2007/11/12 07:27:50 pavalos Exp $ */ #include #include @@ -644,8 +644,19 @@ u_int32_t cam_debug_delay; #endif /* CAM_DEBUG_BUS || CAM_DEBUG_TARGET || CAM_DEBUG_LUN */ /* Our boot-time initialization hook */ +static int cam_module_event_handler(module_t, int /*modeventtype_t*/, void *); + +static moduledata_t cam_moduledata = { + "cam", + cam_module_event_handler, + NULL +}; + static void xpt_init(void *); -SYSINIT(cam, SI_SUB_CONFIGURE, SI_ORDER_SECOND, xpt_init, NULL); + +DECLARE_MODULE(cam, cam_moduledata, SI_SUB_CONFIGURE, SI_ORDER_SECOND); +MODULE_VERSION(cam, 1); + static cam_status xpt_compile_path(struct cam_path *new_path, struct cam_periph *perph, @@ -1290,6 +1301,18 @@ ptstartover: return(error); } +static int +cam_module_event_handler(module_t mod, int what, void *arg) +{ + if (what == MOD_LOAD) { + xpt_init(NULL); + } else if (what == MOD_UNLOAD) { + return EBUSY; + } + + return 0; +} + /* Functions accessed by the peripheral drivers */ static void xpt_init(void *dummy) -- 2.41.0