36#include <sys/kernel.h>
38#include <sys/malloc.h>
47#define CAM_PATH_ANY (u_int32_t)-1
105 struct mtx *
mtx,
int max_dev_transactions,
106 int max_tagged_dev_transactions,
struct cam_devq *queue)
110 sim = malloc(
sizeof(
struct cam_sim), M_CAMSIM, M_ZERO | M_NOWAIT);
147 int error __diagused;
149 if (sim->
mtx == NULL) {
154 mtx_assert(mtx, MA_OWNED);
156 KASSERT(sim->
refcount >= 1, (
"sim->refcount >= 1"));
159 error = msleep(sim, mtx, PRIBIO,
"simfree", 0);
160 KASSERT(error == 0, (
"invalid error value for msleep(9)"));
162 KASSERT(sim->
refcount == 0, (
"sim->refcount == 0"));
176 if (sim->
mtx == NULL)
178 else if (!mtx_owned(sim->
mtx))
184 KASSERT(sim->
refcount >= 1, (
"sim->refcount >= 1"));
197 if (sim->
mtx == NULL)
199 else if (!mtx_owned(sim->
mtx))
205 KASSERT(sim->
refcount >= 1, (
"sim->refcount >= 1"));
struct cam_devq * cam_devq_alloc(int devices, int openings)
void cam_devq_free(struct cam_devq *devq)
struct cam_sim * cam_sim_alloc(sim_action_func sim_action, sim_poll_func sim_poll, const char *sim_name, void *softc, u_int32_t unit, struct mtx *mtx, int max_dev_transactions, int max_tagged_dev_transactions, struct cam_devq *queue)
allocate a new sim and fill in the details
struct cam_devq * cam_simq_alloc(u_int32_t max_sim_transactions)
static struct mtx cam_sim_free_mtx
void cam_sim_release(struct cam_sim *sim)
void cam_sim_free(struct cam_sim *sim, int free_devq)
frees up the sim
void cam_sim_hold(struct cam_sim *sim)
void cam_sim_set_path(struct cam_sim *sim, u_int32_t path_id)
void cam_simq_free(struct cam_devq *devq)
MTX_SYSINIT(cam_sim_free_init, &cam_sim_free_mtx, "CAM SIM free lock", MTX_DEF)
static MALLOC_DEFINE(M_CAMSIM, "CAM SIM", "CAM SIM buffers")
void(* sim_poll_func)(struct cam_sim *sim)
void(* sim_action_func)(struct cam_sim *sim, union ccb *ccb)
int max_tagged_dev_openings
sim_action_func sim_action