From owner-p4-projects@FreeBSD.ORG Tue Apr 24 22:15:22 2007 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 1F14216A413; Tue, 24 Apr 2007 22:15:22 +0000 (UTC) X-Original-To: perforce@freebsd.org Delivered-To: perforce@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id E712016A40E for ; Tue, 24 Apr 2007 22:15:21 +0000 (UTC) (envelope-from scottl@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [69.147.83.41]) by mx1.freebsd.org (Postfix) with ESMTP id D641113C4AD for ; Tue, 24 Apr 2007 22:15:21 +0000 (UTC) (envelope-from scottl@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.8/8.13.8) with ESMTP id l3OMFLBx029975 for ; Tue, 24 Apr 2007 22:15:21 GMT (envelope-from scottl@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.8/8.13.8/Submit) id l3OMFLlL029972 for perforce@freebsd.org; Tue, 24 Apr 2007 22:15:21 GMT (envelope-from scottl@freebsd.org) Date: Tue, 24 Apr 2007 22:15:21 GMT Message-Id: <200704242215.l3OMFLlL029972@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to scottl@freebsd.org using -f From: Scott Long To: Perforce Change Reviews Cc: Subject: PERFORCE change 118756 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Apr 2007 22:15:22 -0000 http://perforce.freebsd.org/chv.cgi?CH=118756 Change 118756 by scottl@scottl-x64 on 2007/04/24 22:15:16 Turn the XPT SIM into a newbus driver. Remove pseudo-driver glue. Affected files ... .. //depot/projects/scottl-camlock/src/sys/cam/cam_xpt.c#64 edit Differences ... ==== //depot/projects/scottl-camlock/src/sys/cam/cam_xpt.c#64 (text+ko) ==== @@ -36,6 +36,7 @@ #include #include #include +#include #include #include #include @@ -170,13 +171,13 @@ static periph_init_t xpt_periph_init; -static struct periph_driver xpt_driver = +static struct periph_driver xpt_periph_driver = { xpt_periph_init, "xpt", - TAILQ_HEAD_INITIALIZER(xpt_driver.units) + TAILQ_HEAD_INITIALIZER(xpt_periph_driver.units) }; -PERIPHDRIVER_DECLARE(xpt, xpt_driver); +PERIPHDRIVER_DECLARE(xpt, xpt_periph_driver); static d_open_t xptopen; @@ -235,20 +236,27 @@ #endif /* CAMDEBUG */ #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 void xpt_identify(driver_t *driver, device_t parent); +static int xpt_probe(device_t dev); +static int xpt_attach(device_t dev); +static int xpt_detach(device_t dev); -static moduledata_t cam_moduledata = { - "cam", - cam_module_event_handler, - NULL +static device_method_t xpt_sim_methods[] = { + DEVMETHOD(device_identify, xpt_identify), + DEVMETHOD(device_probe, xpt_probe), + DEVMETHOD(device_attach, xpt_attach), + DEVMETHOD(device_detach, xpt_detach), + { 0, 0 } }; -static int xpt_init(void *); +static driver_t xpt_sim_driver = { + "xptsim", + xpt_sim_methods, + 1, /* XXX Need softc */ +}; -DECLARE_MODULE(cam, cam_moduledata, SI_SUB_CONFIGURE, SI_ORDER_SECOND); -MODULE_VERSION(cam, 1); - +static devclass_t xpt_devclass; +DRIVER_MODULE(xpt, nexus, xpt_sim_driver, xpt_devclass, 0, 0); static void xpt_async_bcast(struct async_list *async_head, u_int32_t async_code, @@ -837,25 +845,6 @@ return(error); } -static int -cam_module_event_handler(module_t mod, int what, void *arg) -{ - int error; - - switch (what) { - case MOD_LOAD: - if ((error = xpt_init(NULL)) != 0) - return (error); - break; - case MOD_UNLOAD: - return EBUSY; - default: - return EOPNOTSUPP; - } - - return 0; -} - /* thread to handle bus rescans */ static void xpt_scanner_thread(void *dummy) @@ -919,8 +908,26 @@ } /* Functions accessed by the peripheral drivers */ +static void +xpt_identify(driver_t *driver, device_t parent) +{ + + if (resource_disabled("xpt", 0)) + return; + if (BUS_ADD_CHILD(parent, 0, "xptsim", 0) == NULL) + panic("xpt_identify"); +} + +static int +xpt_probe(device_t dev) +{ + + device_set_desc(dev, "CAM Transport"); + return (0); +} + static int -xpt_init(void *dummy) +xpt_attach(device_t dev) { struct cam_sim *xpt_sim; struct cam_path *path; @@ -960,7 +967,7 @@ mtx_lock(&xsoftc.xpt_lock); if ((status = xpt_bus_register(xpt_sim, /*bus #*/0)) != CAM_SUCCESS) { - printf("xpt_init: xpt_bus_register failed with status %#x," + printf("xpt_attach: xpt_bus_register failed with status %#x," " failing attach\n", status); return (EINVAL); } @@ -973,7 +980,7 @@ if ((status = xpt_create_path(&path, NULL, CAM_XPT_PATH_ID, CAM_TARGET_WILDCARD, CAM_LUN_WILDCARD)) != CAM_REQ_CMP) { - printf("xpt_init: xpt_create_path failed with status %#x," + printf("xpt_attach: xpt_create_path failed with status %#x," " failing attach\n", status); return (EINVAL); } @@ -990,7 +997,7 @@ (struct intr_config_hook *)malloc(sizeof(struct intr_config_hook), M_TEMP, M_NOWAIT | M_ZERO); if (xsoftc.xpt_config_hook == NULL) { - printf("xpt_init: Cannot malloc config hook " + printf("xpt_attach: Cannot malloc config hook " "- failing attach\n"); return (ENOMEM); } @@ -998,13 +1005,13 @@ xsoftc.xpt_config_hook->ich_func = xpt_config; if (config_intrhook_establish(xsoftc.xpt_config_hook) != 0) { free (xsoftc.xpt_config_hook, M_TEMP); - printf("xpt_init: config_intrhook_establish failed " + printf("xpt_attach: config_intrhook_establish failed " "- failing attach\n"); } /* fire up rescan thread */ if (kthread_create(xpt_scanner_thread, NULL, NULL, 0, 0, "xpt_thrd")) { - printf("xpt_init: failed to create rescan thread\n"); + printf("xpt_attach: failed to create rescan thread\n"); } /* Install our software interrupt handlers */ swi_add(NULL, "cambio", camisr, NULL, SWI_CAMBIO, INTR_MPSAFE, &cambio_ih); @@ -1012,6 +1019,13 @@ return (0); } +static int +xpt_detach(device_t dev) +{ + + return (EBUSY); +} + static cam_status xptregister(struct cam_periph *periph, void *arg) { @@ -4033,7 +4047,7 @@ * If this wasn't a fully wildcarded async, tell all * clients that want all async events. */ - if (bus != xpt_periph->path->bus) + if (bus->path_id != CAM_XPT_PATH_ID) xpt_async_bcast(&xpt_periph->path->device->asyncs, async_code, path, async_arg); }