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