;================================================================================= ; VT_GETSTATE, VT_OPENQRY demonstration. ; ; Retrieves currently active and first available vt. ; ; The LSCR Project. ;================================================================================= format ELF include '../macros.inc' include '../../include/symbols.inc' include '../../include/structs.inc' extrn dw2ascii_dec extrn error_chk section '.text' executable public _start _start: mov eax, SYS_OPEN ; open '/dev/tty0' mov ebx, devtty_s mov ecx, O_RDWR mov edx, S_IWUSR or S_IRUSR int 0x80 ccall error_chk, <"SYS_OPEN has failed: ">, exit mov [file_d], eax mov eax, SYS_IOCTL ; get current active vt mov ebx, [file_d] mov ecx, VT_GETSTATE mov edx, term_stat int 0x80 ccall error_chk, <"VT_GETSTATE has failed: ">, close movzx eax, word [term_stat+vt_stat.v_active] ccall dw2ascii_dec, eax, cur_vt_s+cur_vt_s_sz-3, 0 mov eax, SYS_WRITE mov ebx, STDOUT mov ecx, cur_vt_s mov edx, cur_vt_s_sz int 0x80 mov eax, SYS_IOCTL ; get first available vt mov ebx, [file_d] mov ecx, VT_OPENQRY mov edx, vtnum int 0x80 ccall error_chk, <"VT_OPENQRY has failed: ">, close ccall dw2ascii_dec, [vtnum], avl_vt_s+avl_vt_s_sz-3, 0 mov eax, SYS_WRITE mov ebx, STDOUT mov ecx, avl_vt_s mov edx, avl_vt_s_sz int 0x80 close: mov eax, SYS_CLOSE mov ebx, [file_d] int 0x80 exit: mov eax, SYS_EXIT xor ebx, ebx int 0x80 section '.data' writeable devtty_s db "/dev/tty0",0 cur_vt_s db "Currently active VT is: /dev/tt ",0xa cur_vt_s_sz = $-cur_vt_s avl_vt_s db "First available VT is: /dev/tt ",0xa avl_vt_s_sz = $-avl_vt_s term_stat vt_stat file_d rd 1 vtnum rd 1