FreeBSD/sys/dev/aic7xxx/aic79xx_osm.c
/*
 * Attach all the sub-devices we can find
 */
Attach all the sub-devices we can find
Attach all the sub - devices we can find
int
ahd_attach(struct ahd_softc *ahd)
{
	char   ahd_info[256];
	struct ccb_setasync csa;
	struct cam_devq *devq;
	struct cam_sim *sim;
	struct cam_path *path;
	int count;
	count = 0;
	devq = NULL;
	sim = NULL;
	path = NULL;
	if (ahd_spawn_recovery_thread(ahd) != 0)
		goto fail;
	ahd_controller_info(ahd, ahd_info);
	printf("%s\n", ahd_info);
	ahd_lock(ahd);
	devq = cam_simq_alloc(AHD_MAX_QUEUE);
	if (devq == NULL)
		goto fail;
	sim = cam_sim_alloc(ahd_action, ahd_poll, "ahd", ahd,
			    device_get_unit(ahd->dev_softc),
			    &ahd->platform_data->mtx, 1, 256, devq);
	if (sim == NULL) {
		cam_simq_free(devq);
		goto fail;
	}
	if (xpt_bus_register(sim, ahd->dev_softc, 0) != CAM_SUCCESS) {
		cam_sim_free(sim, TRUE);
		sim = NULL;
		goto fail;
	}
	if (xpt_create_path(&path, NULL,
			    cam_sim_path(sim), CAM_TARGET_WILDCARD,
			    CAM_LUN_WILDCARD) != CAM_REQ_CMP) {
		xpt_bus_deregister(cam_sim_path(sim));
		cam_sim_free(sim, TRUE);
		sim = NULL;
		goto fail;
	}
	xpt_setup_ccb(&csa.ccb_h, path, 5);
	csa.ccb_h.func_code = XPT_SASYNC_CB;
	csa.event_enable = AC_LOST_DEVICE;
	csa.callback = ahd_async;
	csa.callback_arg = sim;
	xpt_action((union ccb *)&csa);
	count++;
fail:
	ahd->platform_data->sim = sim;
	ahd->platform_data->path = path;
	ahd_unlock(ahd);
	if (count != 0) {
		ahd->platform_data->eh =
		    EVENTHANDLER_REGISTER(shutdown_final, ahd_shutdown,
					  ahd, SHUTDOWN_PRI_DEFAULT);
		ahd_intr_enable(ahd, TRUE);
	}
	return (count);
}
int ahd_attach ( struct ahd_softc * ahd ) { char ahd_info [ 256 ] ; struct ccb_setasync csa ; struct cam_devq * devq ; struct cam_sim * sim ; struct cam_path * path ; int count ; count = 0 ; devq = NULL ; sim = NULL ; path = NULL ; if ( ahd_spawn_recovery_thread ( ahd ) != 0 ) goto fail ; ahd_controller_info ( ahd , ahd_info ) ; printf ( " \n " , ahd_info ) ; ahd_lock ( ahd ) ; devq = cam_simq_alloc ( AHD_MAX_QUEUE ) ; if ( devq == NULL ) goto fail ; sim = cam_sim_alloc ( ahd_action , ahd_poll , " " , ahd , device_get_unit ( ahd -> dev_softc ) , & ahd -> platform_data -> mtx , 1 , 256 , devq ) ; if ( sim == NULL ) { cam_simq_free ( devq ) ; goto fail ; } if ( xpt_bus_register ( sim , ahd -> dev_softc , 0 ) != CAM_SUCCESS ) { cam_sim_free ( sim , TRUE ) ; sim = NULL ; goto fail ; } if ( xpt_create_path ( & path , NULL , cam_sim_path ( sim ) , CAM_TARGET_WILDCARD , CAM_LUN_WILDCARD ) != CAM_REQ_CMP ) { xpt_bus_deregister ( cam_sim_path ( sim ) ) ; cam_sim_free ( sim , TRUE ) ; sim = NULL ; goto fail ; } xpt_setup_ccb ( & csa . ccb_h , path , 5 ) ; csa . ccb_h . func_code = XPT_SASYNC_CB ; csa . event_enable = AC_LOST_DEVICE ; csa . callback = ahd_async ; csa . callback_arg = sim ; xpt_action ( ( union ccb * ) & csa ) ; count ++ ; fail : ahd -> platform_data -> sim = sim ; ahd -> platform_data -> path = path ; ahd_unlock ( ahd ) ; if ( count != 0 ) { ahd -> platform_data -> eh = EVENTHANDLER_REGISTER ( shutdown_final , ahd_shutdown , ahd , SHUTDOWN_PRI_DEFAULT ) ; ahd_intr_enable ( ahd , TRUE ) ; } return ( count ) ; }
Attach all the sub-devices we can find
Attach all the sub - devices we can find
/*
	 * Create a thread to perform all recovery.
	 */ /*
	 * Create the device queue for our SIM(s).
	 */ /*
	 * Construct our SIM entry
	 */ /*XXX*/ /*bus_id*/ /*free_devq*/ /*periph*/ /*free_devq*/ /*priority*/ /* We have to wait until after any system dumps... */