33#ifndef _CAM_CAM_PERIPH_H
34#define _CAM_CAM_PERIPH_H 1
42#include <sys/sysctl.h>
43#include <sys/taskqueue.h>
58#include <sys/module.h>
59#define PERIPHDRIVER_DECLARE(name, driver) \
60 static int name ## _modevent(module_t mod, int type, void *data) \
64 periphdriver_register(data); \
67 return (periphdriver_unregister(data)); \
73 static moduledata_t name ## _mod = { \
78 DECLARE_MODULE(name, name ## _mod, SI_SUB_DRIVERS, SI_ORDER_ANY); \
79 MODULE_DEPEND(name, cam, 1, 1, 1)
99#define CAM_PERIPH_DRV_EARLY 0x01
108#define ppriv_ptr0 periph_priv.entries[0].ptr
109#define ppriv_ptr1 periph_priv.entries[1].ptr
110#define ppriv_field0 periph_priv.entries[0].field
111#define ppriv_field1 periph_priv.entries[1].field
114 union ccb *start_ccb);
130#define CAM_PERIPH_RUNNING 0x01
131#define CAM_PERIPH_LOCKED 0x02
132#define CAM_PERIPH_LOCK_WANTED 0x04
133#define CAM_PERIPH_INVALID 0x08
134#define CAM_PERIPH_NEW_DEV_FOUND 0x10
135#define CAM_PERIPH_RECOVERY_INPROG 0x20
136#define CAM_PERIPH_RUN_TASK 0x40
137#define CAM_PERIPH_FREE 0x80
138#define CAM_PERIPH_ANNOUNCED 0x100
139#define CAM_PERIPH_RECOVERY_WAIT 0x200
140#define CAM_PERIPH_RECOVERY_WAIT_FAILED 0x400
155#define CAM_PERIPH_MAXMAPS 2
187 int (*error_routine)(
union ccb *
ccb,
189 u_int32_t sense_flags),
190 cam_flags camflags, u_int32_t sense_flags,
194 int (*error_routine)(
union ccb *
ccb,
196 u_int32_t sense_flags));
199 u_int32_t opening_reduction, u_int32_t arg,
204 u_int bus_settle_ms);
206 struct timeval* event_time,
209 u_int32_t sense_flags);
212static __inline
struct mtx *
221#define cam_periph_owned(periph) \
222 mtx_owned(xpt_path_mtx((periph)->path))
224#define cam_periph_lock(periph) \
225 mtx_lock(xpt_path_mtx((periph)->path))
227#define cam_periph_unlock(periph) \
228 mtx_unlock(xpt_path_mtx((periph)->path))
230#define cam_periph_assert(periph, what) \
231 mtx_assert(xpt_path_mtx((periph)->path), (what))
233#define cam_periph_sleep(periph, chan, priority, wmesg, timo) \
234 xpt_path_sleep((periph)->path, (chan), (priority), (wmesg), (timo))
242 periph = TAILQ_FIRST(&driver->units);
244 periph = TAILQ_NEXT(periph, unit_links);
259 periph = TAILQ_NEXT(periph, unit_links);
268#define CAM_PERIPH_FOREACH(periph, driver) \
269 for ((periph) = cam_periph_acquire_first(driver); \
271 (periph) = cam_periph_acquire_next(periph))
273#define CAM_PERIPH_PRINT(p, msg, args...) \
274 printf("%s%d:" msg, (periph)->periph_name, (periph)->unit_number, ##args)
void ac_callback_t(void *softc, u_int32_t code, struct cam_path *path, void *args)
cam_status periph_ctor_t(struct cam_periph *periph, void *arg)
void cam_periph_release_locked(struct cam_periph *periph)
void periphdriver_init(int level)
#define CAM_PERIPH_INVALID
void periph_oninv_t(struct cam_periph *periph)
static struct cam_periph * cam_periph_acquire_next(struct cam_periph *pperiph)
#define cam_periph_assert(periph, what)
void cam_freeze_devq(struct cam_path *path)
struct cam_periph * cam_periph_find(struct cam_path *path, char *name)
#define CAM_PERIPH_MAXMAPS
union ccb * cam_periph_getccb(struct cam_periph *periph, u_int32_t priority)
cam_status cam_periph_alloc(periph_ctor_t *periph_ctor, periph_oninv_t *periph_oninvalidate, periph_dtor_t *periph_dtor, periph_start_t *periph_start, char *name, cam_periph_type type, struct cam_path *, ac_callback_t *, ac_code, void *arg)
void cam_periph_unmapmem(union ccb *ccb, struct cam_periph_map_info *mapinfo)
int cam_periph_acquire(struct cam_periph *periph)
void cam_periph_doacquire(struct cam_periph *periph)
int() periph_deinit_t(void)
void cam_periph_bus_settle(struct cam_periph *periph, u_int bus_settle_ms)
void cam_periph_freeze_after_event(struct cam_periph *periph, struct timeval *event_time, u_int duration_ms)
void cam_periph_async(struct cam_periph *periph, u_int32_t code, struct cam_path *path, void *arg)
int cam_periph_list(struct cam_path *, struct sbuf *)
void cam_periph_release(struct cam_periph *periph)
void cam_periph_unhold(struct cam_periph *periph)
struct cam_periph * xpt_periph
static __inline struct mtx * cam_periph_mtx(struct cam_periph *periph)
void periph_dtor_t(struct cam_periph *periph)
void periphdriver_register(void *)
int cam_periph_hold(struct cam_periph *periph, int priority)
int cam_periph_runccb(union ccb *ccb, int(*error_routine)(union ccb *ccb, cam_flags camflags, u_int32_t sense_flags), cam_flags camflags, u_int32_t sense_flags, struct devstat *ds)
static struct cam_periph * cam_periph_acquire_first(struct periph_driver *driver)
void periph_start_t(struct cam_periph *periph, union ccb *start_ccb)
int cam_periph_invalidate_sysctl(SYSCTL_HANDLER_ARGS)
void cam_periph_invalidate(struct cam_periph *periph)
struct periph_driver ** periph_drivers
int cam_periph_error(union ccb *ccb, cam_flags camflags, u_int32_t sense_flags)
int cam_periph_mapmem(union ccb *ccb, struct cam_periph_map_info *mapinfo, u_int maxmap)
void cam_periph_release_locked_buses(struct cam_periph *periph)
int cam_periph_ioctl(struct cam_periph *periph, u_long cmd, caddr_t addr, int(*error_routine)(union ccb *ccb, cam_flags camflags, u_int32_t sense_flags))
u_int32_t cam_release_devq(struct cam_path *path, u_int32_t relsim_flags, u_int32_t opening_reduction, u_int32_t arg, int getcount_only)
int periphdriver_unregister(void *)
void() periph_init_t(void)
struct mtx * xpt_path_mtx(struct cam_path *path)
void xpt_unlock_buses(void)
void xpt_lock_buses(void)
void * orig[CAM_PERIPH_MAXMAPS]
struct buf * bp[CAM_PERIPH_MAXMAPS]
periph_start_t * periph_start
TAILQ_ENTRY(cam_periph) unit_links
periph_dtor_t * periph_dtor
SLIST_ENTRY(cam_periph) periph_links
uint32_t scheduled_priority
struct task periph_run_task
ac_callback_t * deferred_callback
periph_oninv_t * periph_oninval
uint32_t immediate_priority
SLIST_HEAD(, ccb_hdr) ccb_list
TAILQ_HEAD(, cam_periph) units