Whether ttySAC0 and/dev/tts/0 correspond to the serial port 0 of the same physical device

Source: Internet
Author: User

This is indeed a bit confusing:
1. the command line parameter "console = ttySAC0" has nothing to do with the/dev/directory. It is used to select the device from which to output the kernel and driver printk information:

① In kernel/printk. c, there is this line of code:

__setup("console=", console_setup);

For the command line parameter "console = ttySAC0", the console_setup function will parse the device name and index:
The name is ttySAC and the index is 0, indicating the first device.

②. The serial driver file drivers/serial/S3C2410. c of s3c2410 has the following data structure:

1882 static struct console s3c24xx_serial_console = 1883 {1884. name = S3C24XX_SERIAL_NAME, // This macro is defined as "ttySAC" 1885. device = uart_lele_device, // init. 1886 is used when the user program opens/dev/console. flags = CON_PRINTBUFFER, // print the information previously saved in log_buf 1887. index =-1, // indicates which serial port to use is determined by the command line parameter 1888. write = s3c24xx_serial_console_write, // output function 1889 of the serial port console. setup = s3c24xx_serial_lele_setup // set function 1890 on the serial port console };

① The name (name) and index (index) of ② are exactly the same, so the printk information will be output through the s3c24xx_serial_lele_write function in ②.

2. In the/dev directory, which device file corresponds to a specific device depends on the master and sub-device numbers of the device file, rather than their names.
①. The serial driver file drivers/serial/S3C2410. c of s3c2410 also has the following data structure:

Static struct uart_driver s3c24xx_uart_drv = {. owner = THIS_MODULE ,. dev_name = "s3c2410_serial ",. nr = 3 ,. cons = S3C24XX_SERIAL_CONSOLE ,. driver_name = S3C24XX_SERIAL_NAME ,. major = S3C24XX_SERIAL_MAJOR, // The master device number is 204. minor = S3C24XX_SERIAL_MINOR, // The device number is 64, which indicates 1st serial ports; 2nd is 65 };


②. Run the ls-l command to view a device file in the/dev directory, for example:
$ Ls-l/dev/tts/0
If its primary device number is 204 and its secondary device number is 64, it corresponds to the first serial port

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.