Index: head/sys/mips/broadcom/uart_cpu_chipc.c =================================================================== --- head/sys/mips/broadcom/uart_cpu_chipc.c +++ head/sys/mips/broadcom/uart_cpu_chipc.c @@ -47,6 +47,12 @@ #include "bcm_socinfo.h" +#ifdef CFE +#include +#include +#include +#endif + bus_space_tag_t uart_bus_space_io; bus_space_tag_t uart_bus_space_mem; @@ -61,7 +67,7 @@ } static int -uart_cpu_init(struct uart_devinfo *di, int uart, int baudrate) +uart_cpu_init(struct uart_devinfo *di, u_int uart, int baudrate) { struct bcm_socinfo *socinfo; @@ -83,6 +89,44 @@ return (0); } +#ifdef CFE +static int +uart_getenv_cfe(int devtype, struct uart_devinfo *di) +{ + char device[sizeof("uartXX")]; + int baud, fd, len; + int ret; + u_int uart; + + /* CFE only vends console configuration */ + if (devtype != UART_DEV_CONSOLE) + return (ENODEV); + + /* Fetch console device */ + ret = cfe_getenv("BOOT_CONSOLE", device, sizeof(device)); + if (ret != CFE_OK) + return (ENXIO); + + /* Parse serial console unit. Fails on non-uart devices. */ + if (sscanf(device, "uart%u", &uart) != 1) + return (ENXIO); + + /* Fetch device handle */ + fd = cfe_getstdhandle(CFE_STDHANDLE_CONSOLE); + if (fd < 0) + return (ENXIO); + + /* Fetch serial configuration */ + ret = cfe_ioctl(fd, IOCTL_SERIAL_GETSPEED, (unsigned char *)&baud, + sizeof(baud), &len, 0); + if (ret != CFE_OK) + baud = CHIPC_UART_BAUDRATE; + + /* Initialize device info */ + return (uart_cpu_init(di, uart, baud)); +} +#endif /* CFE */ + int uart_cpu_getdev(int devtype, struct uart_devinfo *di) { @@ -91,12 +135,18 @@ uart_bus_space_io = NULL; uart_bus_space_mem = mips_bus_space_generic; - /* Check the environment. */ +#ifdef CFE + /* Check the CFE environment */ + if (uart_getenv_cfe(devtype, di) == 0) + return (0); +#endif /* CFE */ + + /* Check the kernel environment. */ if (uart_getenv(devtype, di, chipc_uart_class) == 0) return (0); /* Scan the device hints for the first matching device */ - for (int i = 0; i < CHIPC_UART_MAX; i++) { + for (u_int i = 0; i < CHIPC_UART_MAX; i++) { if (resource_int_value("uart", i, "flags", &ivar)) continue; Index: head/sys/mips/conf/SENTRY5.hints =================================================================== --- head/sys/mips/conf/SENTRY5.hints +++ head/sys/mips/conf/SENTRY5.hints @@ -2,6 +2,3 @@ hint.bhnd.0.at="nexus0" hint.bhnd.0.maddr="0x18000000" hint.bhnd.0.msize="0x00100000" - -# console on uart1 -hint.uart.1.flags="0x10"