PERFORCE change 50769 for review
Scott Long
scottl at FreeBSD.org
Fri Apr 9 22:19:13 PDT 2004
http://perforce.freebsd.org/chv.cgi?CH=50769
Change 50769 by scottl at scottl-junior-camlock on 2004/04/09 22:18:20
Create basic workitem infrastructure. The only defined workitem
right now is to execute a provided CCB.
Affected files ...
.. //depot/projects/scottl-camlock/src/sys/cam/cam_probe.c#2 edit
Differences ...
==== //depot/projects/scottl-camlock/src/sys/cam/cam_probe.c#2 (text+ko) ====
@@ -42,6 +42,7 @@
#include <sys/md5.h>
#include <sys/interrupt.h>
#include <sys/sbuf.h>
+#include <sys/kthread.h>
#ifdef PC98
#include <pc98/pc98/pc98_machdep.h> /* geometry translation */
@@ -103,9 +104,59 @@
u_int8_t digest[16];
} probe_softc;
+typedef enum {
+ WORK_EXECUTE_CCB = 0x1,
+} cam_workflags;
+
+struct cam_workitem {
+ TAILQ_ENTRY(cam_workitem) work_links;
+ cam_workflags command;
+ void *data;
+ void (*cbfcnp)(void *);
+};
+
+static struct proc *probe_proc;
+static struct mtx probe_workmtx;
+static int probe_workflags;
+static TAILQ_HEAD(,cam_workitem) probe_worklist;
+
+#define PROBE_FLAG_EXIT 0x1
+
static void
+probe_work(void *dummy)
+{
+ struct cam_workitem *work;
+
+ mtx_lock(&probe_workmtx);
+ while ((probe_workflags & PROBE_FLAG_EXIT) == 0) {
+ if ((work = TAILQ_FIRST(&probe_worklist)) == NULL) {
+ msleep(&probe_worklist, &probe_workmtx, PRIBIO,
+ "probew", 0);
+ continue;
+ }
+ TAILQ_REMOVE(&probe_worklist, work, work_links);
+
+ switch (work->command) {
+ case WORK_EXECUTE_CCB:
+ xpt_action((union ccb *)work->data);
+ break;
+ default:
+ panic("Unknown CAM work item %d\n", work->command);
+ }
+ }
+ mtx_unlock(&probe_workmtx);
+
+ kthread_exit(0);
+}
+
+static void
probe_periph_init()
{
+
+ mtx_init(&probe_workmtx, "Probe Mutex", NULL, MTX_DEF);
+ TAILQ_INIT(&probe_worklist);
+ if (kthread_create(probe_work, NULL, &probe_proc, 0, 0, "probe_work"))
+ printf("Warning: cannot create probe kthread\n");
}
static cam_status
More information about the p4-projects
mailing list