/* * Get the package handle of the UART that's selected as the debug port. * Since there's no place for this in the OF, we use the kernel environment * variable "hw.uart.dbgport". Note however that the variable is not a * list of attributes. It's single device name or alias, as known by * the OF. */ static phandle_t uart_cpu_getdev_dbgport(char *dev, size_t devsz) { char buf[sizeof("serial")]; phandle_t input; if (!getenv_string("hw.uart.dbgport", dev, devsz)) return (-1); if ((input = OF_finddevice(dev)) == -1) return (-1); if (OF_getprop(input, "device_type", buf, sizeof(buf)) == -1) return (-1); if (strcmp(buf, "serial") != 0) return (-1); return (input); }
BIF_RETTYPE os_getenv_0(BIF_ALIST_0) { GETENV_STATE state; char *cp; Eterm* hp; Eterm ret; Eterm str; init_getenv_state(&state); ret = NIL; while ((cp = getenv_string(&state)) != NULL) { str = erts_convert_native_to_filename(BIF_P,(byte *)cp); hp = HAlloc(BIF_P, 2); ret = CONS(hp, str, ret); } fini_getenv_state(&state); return ret; }
Eterm os_getenv_0(Process* p) { GETENV_STATE state; char *cp; Eterm* hp; Eterm ret; Eterm str; int len; init_getenv_state(&state); ret = NIL; while ((cp = getenv_string(&state)) != NULL) { len = strlen(cp); hp = HAlloc(p, len*2+2); str = buf_to_intlist(&hp, cp, len, NIL); ret = CONS(hp, str, ret); } fini_getenv_state(&state); return ret; }
int uart_cpu_getdev(int devtype, struct uart_devinfo *di) { char buf[64]; struct uart_class *class; phandle_t input, opts, chosen; int error; opts = OF_finddevice("/options"); chosen = OF_finddevice("/chosen"); switch (devtype) { case UART_DEV_CONSOLE: error = ENXIO; if (chosen != -1 && error != 0) error = ofw_get_uart_console(chosen, &input, "stdout-path", NULL); if (chosen != -1 && error != 0) error = ofw_get_uart_console(chosen, &input, "linux,stdout-path", NULL); if (chosen != -1 && error != 0) error = ofw_get_console_phandle_path(chosen, &input, "stdout"); if (chosen != -1 && error != 0) error = ofw_get_uart_console(chosen, &input, "stdin-path", NULL); if (chosen != -1 && error != 0) error = ofw_get_console_phandle_path(chosen, &input, "stdin"); if (opts != -1 && error != 0) error = ofw_get_uart_console(opts, &input, "input-device", "output-device"); if (opts != -1 && error != 0) error = ofw_get_uart_console(opts, &input, "input-device-1", "output-device-1"); if (error != 0) { input = OF_finddevice("serial0"); /* Last ditch */ if (input == -1) error = (ENXIO); } if (error != 0) return (error); break; case UART_DEV_DBGPORT: if (!getenv_string("hw.uart.dbgport", buf, sizeof(buf))) return (ENXIO); input = OF_finddevice(buf); if (input == -1) return (ENXIO); break; default: return (EINVAL); } if (OF_getprop(input, "device_type", buf, sizeof(buf)) == -1) return (ENXIO); if (strcmp(buf, "serial") != 0) return (ENXIO); if (OF_getprop(input, "compatible", buf, sizeof(buf)) == -1) return (ENXIO); if (strncmp(buf, "chrp,es", 7) == 0) { class = &uart_z8530_class; di->bas.regshft = 4; di->bas.chan = 1; } else if (strcmp(buf,"ns16550") == 0 || strcmp(buf,"ns8250") == 0) {