Herramientas de usuario

Herramientas del sitio


notas:programacion:console_ioctls_under_linux

Diferencias

Muestra las diferencias entre dos versiones de la página.

Enlace a la vista de comparación

Ambos lados, revisión anteriorRevisión previa
Próxima revisión
Revisión previa
Última revisiónAmbos lados, revisión siguiente
notas:programacion:console_ioctls_under_linux [2011/06/09 18:41] cayunotas:programacion:console_ioctls_under_linux [2011/06/09 18:51] cayu
Línea 5: Línea 5:
  
  
-The function prototype for ioctl() as defined in /usr/include/sys/ioctl.h  +The function prototype for ioctl() as defined in /usr/include/sys/ioctl.h is:
-is: +
-  int ioctl(int fd, int request, ...) +
  
-  Technically the ioctl function prototype uses 'int d' but I think 'int +<code c> 
-  fd' is a lot clearer.+  int ioctl(int fd, int request, ...) 
 +</code>
  
-  'fd' is the file descriptor of the console (/dev/tty), 'requestis the +Technically the ioctl function prototype uses 'int dbut I think 'int fd' is a lot clearer.
-  IOCTL we are requesting (such as KDGETLED), and '...' is argp, the +
-  arguments we are passing to ioctl(). When getting values from ioctl() we +
-  use pointer and when the function returns, the value will be stored in +
-  our argument. ioctl() is specified in /usr/include/sys/ioctl.h+
  
-We will now briefly describe the IOCTLs, the arguments it uses, and an +'fd' is the file descriptor of the console (/dev/tty), 'request' is the IOCTL we are requesting (such as KDGETLED), and '...' is argp, the arguments we are passing to ioctl(). When getting values from ioctl() we use a pointer and when the function returns, the value will be stored in our argument. ioctl() is specified in /usr/include/sys/ioctl.h 
-example on how to use it where applicable.+ 
 +We will now briefly describe the IOCTLs, the arguments it uses, and an example on how to use it where applicable.
  
 KDGETLED: KDGETLED:
- This will return the current state of the LEDs. These lights on +This will return the current state of the LEDs. These lights on your keyboard that are on or off when something such as Caps Lock is on. 
-  your keyboard that are on or off when something such as Caps Lock is on. +Although you can turn the LEDs on or off with KDSETLED (described next) without affecting the Caps Lock, Numeric Lock, or Scroll Lock.  
-  Although you can turn the LEDs on or off with KDSETLED (described next) +It places one of the following values (or a combination of them) into a pointer, that points to a long int:
-  without affecting the Caps Lock, Numeric Lock, or Scroll Lock.  +
- It places one of the following values (or a combination of them) +
-  into a pointer, that points to a long int:+
  
-        Defined in: /usr/include/linux/kd.h 
- 0x1 - LED_SCR, set when the Scroll Lock LED is on 
- 0x2 - LED_NUM, set when the Numeric Lock LED is on 
- 0x4 - LED_CAP, set when the Caps Lock LED is on 
  
-        As I previously mentioned, it can return combinations (or the sum) +Defined in: /usr/include/linux/kd.h
-  of the LEDs turned on. For example, if the Numeric Lock and Caps Lock +
-  are both on, it will return 0x6 (0x2 + 0x4). So when no lights are on, +
-  it will return 0x0. This is also how you turn all the LEDs off as  +
-  described next in KDSETLED.+
  
-  Example:+  * 0x1 - LED_SCR, set when the Scroll Lock LED is on 
 +  * 0x2 - LED_NUM, set when the Numeric Lock LED is on 
 +  * 0x4 - LED_CAP, set when the Caps Lock LED is on 
 + 
 +As I previously mentioned, it can return combinations (or the sum) of the LEDs turned on. For example, if the Numeric Lock and Caps Lock are both on, it will return 0x6 (0x2 + 0x4). So when no lights are on, it will return 0x0. This is also how you turn all the LEDs off as described next in KDSETLED. 
 + 
 +Example:
  
 <code c> <code c>
Línea 2045: Línea 2036:
     (which will be 10) and one of the following types:     (which will be 10) and one of the following types:
  
- 0: Screen blanking is disabled. +  *  0: Screen blanking is disabled. 
- 1: Video adapter registers are saved and the monitor is put into +  * 1: Video adapter registers are saved and the monitor is put into standby mode (it turns off vertical sychronization pulses). If your monitor has an Off_Mode timer, it will eventually power down by itself. 
-           standby mode (it turns off vertical sychronization pulses). +  * 2: The settings are saved and then it turns the monitor off (it turns off both vertical and horizontal sychronization pulses. If your monitor doesn't have an Off_Mode timer, or you want your monitor to power down immediately when the blank_timer times out, use this.
-    If your monitor has an Off_Mode timer, it will eventually power +
-    down by itself. +
- 2: The settings are saved and then it turns the monitor off (it +
-           turns off both vertical and horizontal sychronization pulses.  +
-    If your monitor doesn't have an Off_Mode timer, or you want +
-           your monitor to power down immediately when the blank_timer +
-           times out, use this.+
  
-    We will use the following structure:+We will use the following structure:
  
 <code c> <code c>
Línea 2067: Línea 2051:
 </code> </code>
  
-  Conclusion: +Conclusion: 
- I am sorry for the length of this article, but I wanted to give+ 
 +I am sorry for the length of this article, but I wanted to give
 examples for many of these to show the uses of console IOCTLs. As I examples for many of these to show the uses of console IOCTLs. As I
 mentioned in the introduction, IOCTLs are being replaced by POSIX, but mentioned in the introduction, IOCTLs are being replaced by POSIX, but
Línea 2075: Línea 2060:
 otherwise (for example, ACS and CAP). otherwise (for example, ACS and CAP).
  
- Shok (Matt Conover) 
  
  
-Email: shok@dataforce.net+Shok (Matt Conover)\\ 
 +Email: shok@dataforce.net \\
 Web: http://www.w00w00.org Web: http://www.w00w00.org
notas/programacion/console_ioctls_under_linux.txt · Última modificación: 2011/06/10 12:24 por cayu