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

Function uart_getenv_cfe

freebsd/mips/broadcom/uart_cpu_chipc.c:91–125  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

89
90#ifdef CFE
91static int
92uart_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
128int

Callers 1

uart_cpu_getdevFunction · 0.85

Calls 3

sscanfFunction · 0.85
bcm_get_platformFunction · 0.85
uart_cpu_initFunction · 0.85

Tested by

no test coverage detected