MCPcopy Create free account
hub / github.com/F-Stack/f-stack / vmm_is_pptdev

Function vmm_is_pptdev

freebsd/amd64/vmm/vmm.c:2274–2314  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2272}
2273
2274bool
2275vmm_is_pptdev(int bus, int slot, int func)
2276{
2277 int b, f, i, n, s;
2278 char *val, *cp, *cp2;
2279 bool found;
2280
2281 /*
2282 * XXX
2283 * The length of an environment variable is limited to 128 bytes which
2284 * puts an upper limit on the number of passthru devices that may be
2285 * specified using a single environment variable.
2286 *
2287 * Work around this by scanning multiple environment variable
2288 * names instead of a single one - yuck!
2289 */
2290 const char *names[] = { "pptdevs", "pptdevs2", "pptdevs3", NULL };
2291
2292 /* set pptdevs="1/2/3 4/5/6 7/8/9 10/11/12" */
2293 found = false;
2294 for (i = 0; names[i] != NULL && !found; i++) {
2295 cp = val = kern_getenv(names[i]);
2296 while (cp != NULL && *cp != '\0') {
2297 if ((cp2 = strchr(cp, ' ')) != NULL)
2298 *cp2 = '\0';
2299
2300 n = sscanf(cp, "%d/%d/%d", &b, &s, &f);
2301 if (n == 3 && bus == b && slot == s && func == f) {
2302 found = true;
2303 break;
2304 }
2305
2306 if (cp2 != NULL)
2307 *cp2++ = ' ';
2308
2309 cp = cp2;
2310 }
2311 freeenv(val);
2312 }
2313 return (found);
2314}
2315
2316void *
2317vm_iommu_domain(struct vm *vm)

Callers 1

ppt_probeFunction · 0.85

Calls 4

strchrFunction · 0.85
sscanfFunction · 0.85
kern_getenvFunction · 0.50
freeenvFunction · 0.50

Tested by

no test coverage detected