1 /* SPDX-License-Identifier: GPL-2.0 */ << 2 /* 1 /* 3 * include/linux/vt_buffer.h -- Access to 2 * include/linux/vt_buffer.h -- Access to VT screen buffer 4 * 3 * 5 * (c) 1998 Martin Mares <mj@ucw.cz> 4 * (c) 1998 Martin Mares <mj@ucw.cz> 6 * 5 * 7 * This is a set of macros and functions 6 * This is a set of macros and functions which are used in the 8 * console driver and related code to acc 7 * console driver and related code to access the screen buffer. 9 * In most cases the console works with s 8 * In most cases the console works with simple in-memory buffer, 10 * but when handling hardware text mode c 9 * but when handling hardware text mode consoles, we store 11 * the foreground console directly in vid 10 * the foreground console directly in video memory. 12 */ 11 */ 13 12 14 #ifndef _LINUX_VT_BUFFER_H_ 13 #ifndef _LINUX_VT_BUFFER_H_ 15 #define _LINUX_VT_BUFFER_H_ 14 #define _LINUX_VT_BUFFER_H_ 16 15 17 #include <linux/string.h> << 18 16 19 #if IS_ENABLED(CONFIG_VGA_CONSOLE) || IS_ENABL !! 17 #if defined(CONFIG_VGA_CONSOLE) || defined(CONFIG_MDA_CONSOLE) 20 #include <asm/vga.h> 18 #include <asm/vga.h> 21 #endif 19 #endif 22 20 23 #ifndef VT_BUF_HAVE_RW 21 #ifndef VT_BUF_HAVE_RW 24 #define scr_writew(val, addr) (*(addr) = (val) 22 #define scr_writew(val, addr) (*(addr) = (val)) 25 #define scr_readw(addr) (*(addr)) 23 #define scr_readw(addr) (*(addr)) >> 24 #define scr_memcpyw(d, s, c) memcpy(d, s, c) >> 25 #define scr_memmovew(d, s, c) memmove(d, s, c) >> 26 #define VT_BUF_HAVE_MEMCPYW >> 27 #define VT_BUF_HAVE_MEMMOVEW 26 #endif 28 #endif 27 29 28 #ifndef VT_BUF_HAVE_MEMSETW 30 #ifndef VT_BUF_HAVE_MEMSETW 29 static inline void scr_memsetw(u16 *s, u16 c, 31 static inline void scr_memsetw(u16 *s, u16 c, unsigned int count) 30 { 32 { 31 #ifdef VT_BUF_HAVE_RW << 32 count /= 2; 33 count /= 2; 33 while (count--) 34 while (count--) 34 scr_writew(c, s++); 35 scr_writew(c, s++); 35 #else << 36 memset16(s, c, count / 2); << 37 #endif << 38 } 36 } 39 #endif 37 #endif 40 38 41 #ifndef VT_BUF_HAVE_MEMCPYW 39 #ifndef VT_BUF_HAVE_MEMCPYW 42 static inline void scr_memcpyw(u16 *d, const u 40 static inline void scr_memcpyw(u16 *d, const u16 *s, unsigned int count) 43 { 41 { 44 #ifdef VT_BUF_HAVE_RW << 45 count /= 2; 42 count /= 2; 46 while (count--) 43 while (count--) 47 scr_writew(scr_readw(s++), d++ 44 scr_writew(scr_readw(s++), d++); 48 #else << 49 memcpy(d, s, count); << 50 #endif << 51 } 45 } 52 #endif 46 #endif 53 47 54 #ifndef VT_BUF_HAVE_MEMMOVEW 48 #ifndef VT_BUF_HAVE_MEMMOVEW 55 static inline void scr_memmovew(u16 *d, const 49 static inline void scr_memmovew(u16 *d, const u16 *s, unsigned int count) 56 { 50 { 57 #ifdef VT_BUF_HAVE_RW << 58 if (d < s) 51 if (d < s) 59 scr_memcpyw(d, s, count); 52 scr_memcpyw(d, s, count); 60 else { 53 else { 61 count /= 2; 54 count /= 2; 62 d += count; 55 d += count; 63 s += count; 56 s += count; 64 while (count--) 57 while (count--) 65 scr_writew(scr_readw(- 58 scr_writew(scr_readw(--s), --d); 66 } 59 } 67 #else << 68 memmove(d, s, count); << 69 #endif << 70 } 60 } 71 #endif 61 #endif 72 62 73 #endif 63 #endif 74 64
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.