簡單追一下 kernel code
發現應該可以從userspace改,結果…不如預其
code: copy form here
/* show_msm_console - provide per-port serial console state. */ static ssize_t show_msm_console(struct device *dev, struct device_attribute *attr, char *buf) { int enable; struct uart_port *port; struct platform_device *pdev = to_platform_device(dev); port = get_port_from_line(get_line(pdev)); enable = get_console_state(port); return snprintf(buf, sizeof(enable), "%d\n", enable); } /* * set_msm_console - allow to enable/disable serial console on port. * * writing 1 enables serial console on UART port. * writing 0 disables serial console on UART port. */ static ssize_t set_msm_console(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { int enable, cur_state; struct uart_port *port; struct platform_device *pdev = to_platform_device(dev); port = get_port_from_line(get_line(pdev)); cur_state = get_console_state(port); enable = buf[0] - '0'; if (enable == cur_state) return count; switch (enable) { case 0: pr_debug("Calling stop_console\n"); console_stop(port->cons); pr_debug("Calling unregister_console\n"); unregister_console(port->cons); pm_runtime_put_sync(&pdev->dev); pm_runtime_disable(&pdev->dev); /* * Disable UART Core clk * 3 - to disable the UART clock * Thid parameter is not used here, but used in serial core. */ msm_hsl_power(port, 3, 1); break; case 1: pr_debug("Calling register_console\n"); /* * Disable UART Core clk * 0 - to enable the UART clock * Thid parameter is not used here, but used in serial core. */ msm_hsl_power(port, 0, 1); pm_runtime_enable(&pdev->dev); register_console(port->cons); break; default: return -EINVAL; } return count; } static DEVICE_ATTR(console, S_IWUSR | S_IRUGO, show_msm_console, set_msm_console);
因沒有 grep,這樣範圍太大
後來再 /sys/class/tty,有找到ttyHSL0
有個軟連結 device,就能連到目標/sys/devices/soc/78af000.serial,
也找到 console 了,可以 RW,
但, echo 0 > consle 後,就當機了...
只能換個暴力的方法了...
沒有留言:
張貼留言