cam_xpt.c (9ec5d7cd350b0b1a43ee73a620a55e32f897ec52) | cam_xpt.c (75f51904b5b62332719ffaaedafb36cef6940905) |
---|---|
1/* 2 * Implementation of the Common Access Method Transport (XPT) layer. 3 * 4 * Copyright (c) 1997, 1998, 1999 Justin T. Gibbs. 5 * Copyright (c) 1997, 1998, 1999 Kenneth D. Merry. 6 * All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 25 unchanged lines hidden (view full) --- 34#include <sys/malloc.h> 35#include <sys/kernel.h> 36#include <sys/time.h> 37#include <sys/conf.h> 38#include <sys/fcntl.h> 39#include <sys/md5.h> 40#include <sys/devicestat.h> 41#include <sys/interrupt.h> | 1/* 2 * Implementation of the Common Access Method Transport (XPT) layer. 3 * 4 * Copyright (c) 1997, 1998, 1999 Justin T. Gibbs. 5 * Copyright (c) 1997, 1998, 1999 Kenneth D. Merry. 6 * All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 25 unchanged lines hidden (view full) --- 34#include <sys/malloc.h> 35#include <sys/kernel.h> 36#include <sys/time.h> 37#include <sys/conf.h> 38#include <sys/fcntl.h> 39#include <sys/md5.h> 40#include <sys/devicestat.h> 41#include <sys/interrupt.h> |
42#include <sys/bus.h> |
|
42 43#ifdef PC98 44#include <pc98/pc98/pc98_machdep.h> /* geometry translation */ 45#endif 46 47#include <machine/clock.h> 48#include <machine/ipl.h> 49 50#include <cam/cam.h> | 43 44#ifdef PC98 45#include <pc98/pc98/pc98_machdep.h> /* geometry translation */ 46#endif 47 48#include <machine/clock.h> 49#include <machine/ipl.h> 50 51#include <cam/cam.h> |
51#include <cam/cam_conf.h> | |
52#include <cam/cam_ccb.h> 53#include <cam/cam_periph.h> 54#include <cam/cam_sim.h> 55#include <cam/cam_xpt.h> 56#include <cam/cam_xpt_sim.h> 57#include <cam/cam_xpt_periph.h> 58#include <cam/cam_debug.h> 59 --- 4023 unchanged lines hidden (view full) --- 4083 return (CAM_REQ_CMP); 4084} 4085 4086static path_id_t 4087xptnextfreepathid(void) 4088{ 4089 struct cam_eb *bus; 4090 path_id_t pathid; | 52#include <cam/cam_ccb.h> 53#include <cam/cam_periph.h> 54#include <cam/cam_sim.h> 55#include <cam/cam_xpt.h> 56#include <cam/cam_xpt_sim.h> 57#include <cam/cam_xpt_periph.h> 58#include <cam/cam_debug.h> 59 --- 4023 unchanged lines hidden (view full) --- 4083 return (CAM_REQ_CMP); 4084} 4085 4086static path_id_t 4087xptnextfreepathid(void) 4088{ 4089 struct cam_eb *bus; 4090 path_id_t pathid; |
4091 struct cam_sim_config *sim_conf; | 4091 char *strval; |
4092 4093 pathid = 0; 4094 bus = TAILQ_FIRST(&xpt_busses); 4095retry: 4096 /* Find an unoccupied pathid */ 4097 while (bus != NULL 4098 && bus->path_id <= pathid) { 4099 if (bus->path_id == pathid) 4100 pathid++; 4101 bus = TAILQ_NEXT(bus, links); 4102 } 4103 4104 /* 4105 * Ensure that this pathid is not reserved for 4106 * a bus that may be registered in the future. 4107 */ | 4092 4093 pathid = 0; 4094 bus = TAILQ_FIRST(&xpt_busses); 4095retry: 4096 /* Find an unoccupied pathid */ 4097 while (bus != NULL 4098 && bus->path_id <= pathid) { 4099 if (bus->path_id == pathid) 4100 pathid++; 4101 bus = TAILQ_NEXT(bus, links); 4102 } 4103 4104 /* 4105 * Ensure that this pathid is not reserved for 4106 * a bus that may be registered in the future. 4107 */ |
4108 sim_conf = cam_sinit; 4109 while (sim_conf->sim_name != NULL) { 4110 4111 if (IS_SPECIFIED(sim_conf->pathid) 4112 && (pathid == sim_conf->pathid)) { 4113 ++pathid; 4114 /* Start the search over */ 4115 goto retry; 4116 } else { 4117 sim_conf++; 4118 } | 4108 if (resource_string_value("scbus", pathid, "at", &strval) == 0) { 4109 ++pathid; 4110 /* Start the search over */ 4111 goto retry; |
4119 } 4120 return (pathid); 4121} 4122 4123static path_id_t 4124xptpathid(const char *sim_name, int sim_unit, int sim_bus) 4125{ | 4112 } 4113 return (pathid); 4114} 4115 4116static path_id_t 4117xptpathid(const char *sim_name, int sim_unit, int sim_bus) 4118{ |
4126 struct cam_sim_config *sim_conf; | |
4127 path_id_t pathid; | 4119 path_id_t pathid; |
4120 int i, dunit, val; 4121 char buf[32], *strval; |
|
4128 4129 pathid = CAM_XPT_PATH_ID; | 4122 4123 pathid = CAM_XPT_PATH_ID; |
4130 for (sim_conf = cam_sinit; sim_conf->sim_name != NULL; sim_conf++) { 4131 4132 if (!IS_SPECIFIED(sim_conf->pathid)) | 4124 snprintf(buf, sizeof(buf), "%s%d", sim_name, sim_unit); 4125 i = -1; 4126 while ((i = resource_locate(i, "scbus")) != -1) { 4127 dunit = resource_query_unit(i); 4128 if (dunit < 0) /* unwired?! */ |
4133 continue; | 4129 continue; |
4134 4135 if (!strcmp(sim_name, sim_conf->sim_name) 4136 && (sim_unit == sim_conf->sim_unit)) { 4137 4138 if (IS_SPECIFIED(sim_conf->sim_bus)) { 4139 if (sim_bus == sim_conf->sim_bus) { 4140 pathid = sim_conf->pathid; 4141 break; 4142 } 4143 } else if (sim_bus == 0) { 4144 /* Unspecified matches bus 0 */ 4145 pathid = sim_conf->pathid; | 4130 if (resource_string_value("scbus", dunit, "at", &strval) != 0) 4131 continue; 4132 if (strcmp(buf, strval) != 0) 4133 continue; 4134 if (resource_int_value("scbus", dunit, "bus", &val) == 0) { 4135 if (sim_bus == val) { 4136 pathid = dunit; |
4146 break; | 4137 break; |
4147 } else { 4148 printf("Ambiguous scbus configuration for %s%d " 4149 "bus %d, cannot wire down. The kernel " 4150 "config entry for scbus%d should " 4151 "specify a controller bus.\n" 4152 "Scbus will be assigned dynamically.\n", 4153 sim_name, sim_unit, sim_bus, 4154 sim_conf->pathid); 4155 break; | |
4156 } | 4138 } |
4139 } else if (sim_bus == 0) { 4140 /* Unspecified matches bus 0 */ 4141 pathid = dunit; 4142 break; 4143 } else { 4144 printf("Ambiguous scbus configuration for %s%d " 4145 "bus %d, cannot wire down. The kernel " 4146 "config entry for scbus%d should " 4147 "specify a controller bus.\n" 4148 "Scbus will be assigned dynamically.\n", 4149 sim_name, sim_unit, sim_bus, dunit); 4150 break; |
|
4157 } 4158 } 4159 4160 if (pathid == CAM_XPT_PATH_ID) 4161 pathid = xptnextfreepathid(); 4162 return (pathid); 4163} 4164 --- 2151 unchanged lines hidden --- | 4151 } 4152 } 4153 4154 if (pathid == CAM_XPT_PATH_ID) 4155 pathid = xptnextfreepathid(); 4156 return (pathid); 4157} 4158 --- 2151 unchanged lines hidden --- |