PERFORCE change 173079 for review
Alexander Motin
mav at FreeBSD.org
Wed Jan 13 20:25:59 UTC 2010
http://p4web.freebsd.org/chv.cgi?CH=173079
Change 173079 by mav at mav_mavtest on 2010/01/13 20:25:44
Clean XPT initialization a bit, preparing to boot scan refactoring.
Affected files ...
.. //depot/projects/scottl-camlock/src/sys/cam/cam_periph.c#46 edit
.. //depot/projects/scottl-camlock/src/sys/cam/cam_periph.h#25 edit
.. //depot/projects/scottl-camlock/src/sys/cam/cam_xpt.c#135 edit
Differences ...
==== //depot/projects/scottl-camlock/src/sys/cam/cam_periph.c#46 (text+ko) ====
@@ -84,6 +84,7 @@
u_int32_t *timeout);
static int nperiph_drivers;
+static int initialized = 0;
struct periph_driver **periph_drivers;
MALLOC_DEFINE(M_CAMPERIPH, "CAM periph", "CAM peripheral buffers");
@@ -99,6 +100,7 @@
void
periphdriver_register(void *data)
{
+ struct periph_driver *drv = (struct periph_driver *)data;
struct periph_driver **newdrivers, **old;
int ndrivers;
@@ -108,13 +110,30 @@
if (periph_drivers)
bcopy(periph_drivers, newdrivers,
sizeof(*newdrivers) * nperiph_drivers);
- newdrivers[nperiph_drivers] = (struct periph_driver *)data;
+ newdrivers[nperiph_drivers] = drv;
newdrivers[nperiph_drivers + 1] = NULL;
old = periph_drivers;
periph_drivers = newdrivers;
if (old)
free(old, M_CAMPERIPH);
nperiph_drivers++;
+ /* If driver marked as early or it is late now, initialize it. */
+ if (((drv->flags & CAM_PERIPH_DRV_EARLY) != 0 && initialized > 0) ||
+ initialized > 1)
+ (*drv->init)();
+}
+
+void
+periphdriver_init(int level)
+{
+ int i, early;
+
+ initialized = max(initialized, level);
+ for (i = 0; periph_drivers[i] != NULL; i++) {
+ early = (periph_drivers[i]->flags & CAM_PERIPH_DRV_EARLY) ? 1 : 2;
+ if (early == initialized)
+ (*periph_drivers[i]->init)();
+ }
}
cam_status
==== //depot/projects/scottl-camlock/src/sys/cam/cam_periph.h#25 (text+ko) ====
@@ -42,6 +42,7 @@
extern struct periph_driver **periph_drivers;
void periphdriver_register(void *);
+void periphdriver_init(int level);
#include <sys/module.h>
#define PERIPHDRIVER_DECLARE(name, driver) \
==== //depot/projects/scottl-camlock/src/sys/cam/cam_xpt.c#135 (text+ko) ====
@@ -939,7 +939,8 @@
path, NULL, 0, xpt_sim);
xpt_free_path(path);
mtx_unlock(&xsoftc.xpt_lock);
-
+ /* Install our software interrupt handlers */
+ swi_add(NULL, "cambio", camisr, NULL, SWI_CAMBIO, INTR_MPSAFE, &cambio_ih);
/*
* Register a callback for when interrupts are enabled.
*/
@@ -951,7 +952,6 @@
"- failing attach\n");
return (ENOMEM);
}
-
xsoftc.xpt_config_hook->ich_func = xpt_config;
if (config_intrhook_establish(xsoftc.xpt_config_hook) != 0) {
free (xsoftc.xpt_config_hook, M_CAMXPT);
@@ -959,13 +959,6 @@
"- failing attach\n");
}
- /* fire up rescan thread */
- if (kproc_create(xpt_scanner_thread, NULL, NULL, 0, 0, "xpt_thrd")) {
- printf("xpt_init: failed to create rescan thread\n");
- }
- /* Install our software interrupt handlers */
- swi_add(NULL, "cambio", camisr, NULL, SWI_CAMBIO, INTR_MPSAFE, &cambio_ih);
-
return (0);
}
@@ -4736,9 +4729,6 @@
static void
xpt_config(void *arg)
{
- struct periph_driver **p_drv;
- int i;
-
/*
* Now that interrupts are enabled, go find our devices
*/
@@ -4772,13 +4762,11 @@
#endif /* CAM_DEBUG_BUS */
#endif /* CAMDEBUG */
- /* Register early peripheral drivers */
- /* XXX This will have to change when we have loadable modules */
- p_drv = periph_drivers;
- for (i = 0; p_drv[i] != NULL; i++) {
- if ((p_drv[i]->flags & CAM_PERIPH_DRV_EARLY) != 0)
- (*p_drv[i]->init)();
+ /* Fire up rescan thread. */
+ if (kproc_create(xpt_scanner_thread, NULL, NULL, 0, 0, "xpt_thrd")) {
+ printf("xpt_init: failed to create rescan thread\n");
}
+ periphdriver_init(1);
/*
* Scan all installed busses.
*/
@@ -4821,18 +4809,9 @@
static void
xpt_finishconfig_task(void *context, int pending)
{
- struct periph_driver **p_drv;
- int i;
if (busses_to_config == 0) {
- /* Register all the peripheral drivers */
- /* XXX This will have to change when we have loadable modules */
- p_drv = periph_drivers;
- for (i = 0; p_drv[i] != NULL; i++) {
- if ((p_drv[i]->flags & CAM_PERIPH_DRV_EARLY) == 0)
- (*p_drv[i]->init)();
- }
-
+ periphdriver_init(2);
/*
* Check for devices with no "standard" peripheral driver
* attached. For any devices like that, announce the
More information about the p4-projects
mailing list