Lines Matching +full:device +full:- +full:handle
1 /*-
38 #define PNP0501 0x501 /* 16550A-compatible COM port */
49 EFI_HANDLE currdev; /* current serial device */
50 EFI_HANDLE condev; /* EFI Console device */
104 status = BS->LocateHandle(ByProtocol, &serial, NULL, &bufsz, handles); in efi_serial_init()
113 * get handle array in efi_serial_init()
115 status = BS->LocateHandle(ByProtocol, &serial, NULL, &bufsz, handles); in efi_serial_init()
125 * Find serial device number from device path.
126 * Return -1 if not found.
144 if (acpi->HID == EISA_PNP_ID(PNP0501)) { in efi_serial_get_index()
145 return (acpi->UID); in efi_serial_get_index()
151 return (-1); in efi_serial_get_index()
156 * iterate handles, pick device path for handle, and check the device
163 EFI_HANDLE *handles, handle; in efi_serial_get_handle() local
167 if (port == -1) in efi_serial_get_handle()
177 * We have console handle, set ioaddr for it. in efi_serial_get_handle()
183 comc_port->ioaddr = in efi_serial_get_handle()
192 handle = NULL; in efi_serial_get_handle()
193 for (index = 0; handle == NULL && index < nhandles; index++) { in efi_serial_get_handle()
196 handle = (handles[index]); in efi_serial_get_handle()
201 * In case we did fail to identify the device by path, use port as in efi_serial_get_handle()
202 * array index. Note, we did check port == -1 above. in efi_serial_get_handle()
204 if (port < nhandles && handle == NULL) in efi_serial_get_handle()
205 handle = handles[port]; in efi_serial_get_handle()
208 return (handle); in efi_serial_get_handle()
214 EFI_HANDLE handle; in comc_get_con_serial_handle() local
237 status = BS->LocateDevicePath(&serial, &node, &handle); in comc_get_con_serial_handle()
240 return (handle); in comc_get_con_serial_handle()
247 /* Start of next device path in list. */ in comc_get_con_serial_handle()
255 * Called from cons_probe() to see if this device is available.
263 EFI_HANDLE handle; in comc_probe() local
277 if (env == NULL || strncmp(env, "Hyper-V", 7) != 0) { in comc_probe()
289 comc_port->databits = 8; in comc_probe()
290 comc_port->parity = DefaultParity; in comc_probe()
291 comc_port->stopbits = DefaultStopBits; in comc_probe()
293 handle = NULL; in comc_probe()
296 comc_port->ioaddr = val; in comc_probe()
302 * pick first device. in comc_probe()
304 handle = comc_get_con_serial_handle("ConOut"); in comc_probe()
305 comc_port->condev = handle; in comc_probe()
308 handle = efi_serial_get_handle(comc_port->ioaddr, handle); in comc_probe()
309 if (handle != NULL) { in comc_probe()
310 comc_port->currdev = handle; in comc_probe()
311 status = BS->OpenProtocol(handle, &serial, in comc_probe()
312 (void**)&comc_port->sio, IH, NULL, in comc_probe()
316 comc_port->sio = NULL; in comc_probe()
318 comc_port->newbaudrate = in comc_probe()
319 comc_port->baudrate = comc_port->sio->Mode->BaudRate; in comc_probe()
320 comc_port->timeout = comc_port->sio->Mode->Timeout; in comc_probe()
321 comc_port->receivefifodepth = in comc_probe()
322 comc_port->sio->Mode->ReceiveFifoDepth; in comc_probe()
323 comc_port->databits = comc_port->sio->Mode->DataBits; in comc_probe()
324 comc_port->parity = comc_port->sio->Mode->Parity; in comc_probe()
325 comc_port->stopbits = comc_port->sio->Mode->StopBits; in comc_probe()
330 * If there's no sio, then the device isn't there, so just return since in comc_probe()
333 if (comc_port->sio == NULL) { in comc_probe()
341 snprintf(value, sizeof (value), "%u", comc_port->ioaddr); in comc_probe()
351 comc_port->newbaudrate = val; in comc_probe()
355 snprintf(value, sizeof (value), "%ju", (uintmax_t)comc_port->baudrate); in comc_probe()
360 sc->c_flags = C_PRESENTIN | C_PRESENTOUT; in comc_probe()
362 sc->c_flags &= ~(C_PRESENTIN | C_PRESENTOUT); in comc_probe()
374 printf("comconsole: comconsole device name is deprecated, switch to eficom\n"); in comc_probe_compat()
384 * device, comc_port will be NULL, and comc_setup will fail. It may be called
385 * even when the device isn't present as a 'fallback' console or when listed
407 if (comc_port->sio == NULL) in comc_putchar()
410 for (wait = COMC_TXWAIT; wait > 0; wait--) { in comc_putchar()
411 status = comc_port->sio->Write(comc_port->sio, &bufsz, &cb); in comc_putchar()
426 * if this device is also used as ConIn, some firmwares in comc_getchar()
429 if (comc_port->currdev == comc_port->condev) { in comc_getchar()
432 return (-1); in comc_getchar()
435 if (comc_port->sio == NULL) in comc_getchar()
436 return (-1); in comc_getchar()
438 status = comc_port->sio->Read(comc_port->sio, &bufsz, &c); in comc_getchar()
440 return (-1); in comc_getchar()
452 * if this device is also used as ConIn, some firmwares in comc_ischar()
455 if (comc_port->currdev == comc_port->condev) { in comc_ischar()
461 if (comc_port->sio == NULL) in comc_ischar()
464 status = comc_port->sio->GetControl(comc_port->sio, &control); in comc_ischar()
494 EFI_HANDLE handle; in comc_port_set() local
503 handle = efi_serial_get_handle(port, NULL); in comc_port_set()
504 if (handle == NULL) { in comc_port_set()
505 printf("no handle\n"); in comc_port_set()
509 status = BS->OpenProtocol(handle, &serial, in comc_port_set()
517 comc_port->currdev = handle; in comc_port_set()
518 comc_port->ioaddr = port; in comc_port_set()
519 comc_port->sio = sio; in comc_port_set()
523 env_setenv(ev->ev_name, flags | EV_NOHOOK, value, NULL, NULL); in comc_port_set()
538 comc_port->newbaudrate = speed; in comc_speed_set()
540 env_setenv(ev->ev_name, flags | EV_NOHOOK, value, NULL, NULL); in comc_speed_set()
556 * If the device isn't active, or there's no port present. in comc_setup()
561 if (comc_port->sio->Reset != NULL) { in comc_setup()
562 status = comc_port->sio->Reset(comc_port->sio); in comc_setup()
568 * Avoid setting the baud rate on Hyper-V. Also, only set the baud rate in comc_setup()
574 if (comc_port->sio->SetAttributes != NULL && in comc_setup()
575 comc_port->newbaudrate != comc_port->baudrate) { in comc_setup()
577 if (ev != NULL && strncmp(ev, "Hyper-V", 7) != 0) { in comc_setup()
578 status = comc_port->sio->SetAttributes(comc_port->sio, in comc_setup()
579 comc_port->newbaudrate, 0, 0, DefaultParity, 0, in comc_setup()
583 comc_port->baudrate = comc_port->newbaudrate; in comc_setup()
588 if (comc_port->sio->GetControl != NULL && comc_port->sio->SetControl != NULL) { in comc_setup()
591 status = comc_port->sio->GetControl(comc_port->sio, &control); in comc_setup()
595 (void) comc_port->sio->SetControl(comc_port->sio, control); in comc_setup()