| 89 | |
| 90 | #ifdef CFE |
| 91 | static int |
| 92 | uart_getenv_cfe(int devtype, struct uart_devinfo *di) |
| 93 | { |
| 94 | char device[sizeof("uartXX")]; |
| 95 | int baud, fd, len; |
| 96 | int ret; |
| 97 | u_int uart; |
| 98 | |
| 99 | /* CFE only vends console configuration */ |
| 100 | if (devtype != UART_DEV_CONSOLE) |
| 101 | return (ENODEV); |
| 102 | |
| 103 | /* Fetch console device */ |
| 104 | ret = cfe_getenv("BOOT_CONSOLE", device, sizeof(device)); |
| 105 | if (ret != CFE_OK) |
| 106 | return (ENXIO); |
| 107 | |
| 108 | /* Parse serial console unit. Fails on non-uart devices. */ |
| 109 | if (sscanf(device, "uart%u", &uart) != 1) |
| 110 | return (ENXIO); |
| 111 | |
| 112 | /* Fetch device handle */ |
| 113 | fd = bcm_get_platform()->cfe_console; |
| 114 | if (fd < 0) |
| 115 | return (ENXIO); |
| 116 | |
| 117 | /* Fetch serial configuration */ |
| 118 | ret = cfe_ioctl(fd, IOCTL_SERIAL_GETSPEED, (unsigned char *)&baud, |
| 119 | sizeof(baud), &len, 0); |
| 120 | if (ret != CFE_OK) |
| 121 | baud = CHIPC_UART_BAUDRATE; |
| 122 | |
| 123 | /* Initialize device info */ |
| 124 | return (uart_cpu_init(di, uart, baud)); |
| 125 | } |
| 126 | #endif /* CFE */ |
| 127 | |
| 128 | int |
no test coverage detected