Changeset View
Changeset View
Standalone View
Standalone View
sys/cam/cam_sim.c
Show First 20 Lines • Show All 110 Lines • ▼ Show 20 Lines | cam_sim_alloc(sim_action_func sim_action, sim_poll_func sim_poll, | ||||
if (sim == NULL) | if (sim == NULL) | ||||
return (NULL); | return (NULL); | ||||
sim->sim_action = sim_action; | sim->sim_action = sim_action; | ||||
sim->sim_poll = sim_poll; | sim->sim_poll = sim_poll; | ||||
sim->sim_name = sim_name; | sim->sim_name = sim_name; | ||||
sim->softc = softc; | sim->softc = softc; | ||||
sim->path_id = CAM_PATH_ANY; | sim->path_id = CAM_PATH_ANY; | ||||
sim->sim_dev = NULL; /* set only by cam_sim_alloc_dev */ | |||||
sim->unit_number = unit; | sim->unit_number = unit; | ||||
sim->bus_id = 0; /* set in xpt_bus_register */ | sim->bus_id = 0; /* set in xpt_bus_register */ | ||||
sim->max_tagged_dev_openings = max_tagged_dev_transactions; | sim->max_tagged_dev_openings = max_tagged_dev_transactions; | ||||
sim->max_dev_openings = max_dev_transactions; | sim->max_dev_openings = max_dev_transactions; | ||||
sim->flags = 0; | sim->flags = 0; | ||||
sim->refcount = 1; | sim->refcount = 1; | ||||
sim->devq = queue; | sim->devq = queue; | ||||
sim->mtx = mtx; | sim->mtx = mtx; | ||||
return (sim); | |||||
} | |||||
/** | |||||
* @brief allocate a new sim and fill in the details with a device_t | |||||
* | |||||
* Just like @c cam_sim_alloc, but with an additional paramter. | |||||
* | |||||
* @param dev A newbus device that's associated with the | |||||
* sim. Must be non-NULL. | |||||
*/ | |||||
struct cam_sim * | |||||
cam_sim_alloc_dev(sim_action_func sim_action, sim_poll_func sim_poll, | |||||
const char *sim_name, void *softc, device_t dev, struct mtx *mtx, | |||||
int max_dev_transactions, int max_tagged_dev_transactions, | |||||
struct cam_devq *queue) | |||||
{ | |||||
struct cam_sim *sim; | |||||
KASSERT(dev != NULL, ("%s: dev is null for sim_name %s softc %p\n", | |||||
__func__, sim_name, softc)); | |||||
sim = cam_sim_alloc(sim_action, sim_poll, sim_name, softc, | |||||
device_get_unit(dev), mtx, max_dev_transactions, | |||||
max_tagged_dev_transactions, queue); | |||||
if (sim != NULL) | |||||
sim->sim_dev = dev; | |||||
return (sim); | return (sim); | ||||
} | } | ||||
void | void | ||||
cam_sim_free(struct cam_sim *sim, int free_devq) | cam_sim_free(struct cam_sim *sim, int free_devq) | ||||
{ | { | ||||
struct mtx *mtx; | struct mtx *mtx; | ||||
int error; | int error; | ||||
▲ Show 20 Lines • Show All 68 Lines • Show Last 20 Lines |