1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3  *	include/linux/vt_buffer.h -- Access to VT screen buffer
4  *
5  *	(c) 1998 Martin Mares <[email protected]>
6  *
7  *	This is a set of macros and functions which are used in the
8  *	console driver and related code to access the screen buffer.
9  *	In most cases the console works with simple in-memory buffer,
10  *	but when handling hardware text mode consoles, we store
11  *	the foreground console directly in video memory.
12  */
13 
14 #ifndef _LINUX_VT_BUFFER_H_
15 #define _LINUX_VT_BUFFER_H_
16 
17 #include <linux/string.h>
18 
19 #if IS_ENABLED(CONFIG_VGA_CONSOLE) || IS_ENABLED(CONFIG_MDA_CONSOLE)
20 #include <asm/vga.h>
21 #endif
22 
23 #ifndef VT_BUF_HAVE_RW
24 #define scr_writew(val, addr) (*(addr) = (val))
25 #define scr_readw(addr) (*(addr))
26 #endif
27 
28 #ifndef VT_BUF_HAVE_MEMSETW
scr_memsetw(u16 * s,u16 c,unsigned int count)29 static inline void scr_memsetw(u16 *s, u16 c, unsigned int count)
30 {
31 	memset16(s, c, count / 2);
32 }
33 #endif
34 
35 #ifndef VT_BUF_HAVE_MEMCPYW
scr_memcpyw(u16 * d,const u16 * s,unsigned int count)36 static inline void scr_memcpyw(u16 *d, const u16 *s, unsigned int count)
37 {
38 	memcpy(d, s, count);
39 }
40 #endif
41 
42 #ifndef VT_BUF_HAVE_MEMMOVEW
scr_memmovew(u16 * d,const u16 * s,unsigned int count)43 static inline void scr_memmovew(u16 *d, const u16 *s, unsigned int count)
44 {
45 	memmove(d, s, count);
46 }
47 #endif
48 
49 #endif
50