Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 /*
0003  *  include/linux/vt_buffer.h -- Access to VT screen buffer
0004  *
0005  *  (c) 1998 Martin Mares <mj@ucw.cz>
0006  *
0007  *  This is a set of macros and functions which are used in the
0008  *  console driver and related code to access the screen buffer.
0009  *  In most cases the console works with simple in-memory buffer,
0010  *  but when handling hardware text mode consoles, we store
0011  *  the foreground console directly in video memory.
0012  */
0013 
0014 #ifndef _LINUX_VT_BUFFER_H_
0015 #define _LINUX_VT_BUFFER_H_
0016 
0017 #include <linux/string.h>
0018 
0019 #if defined(CONFIG_VGA_CONSOLE) || defined(CONFIG_MDA_CONSOLE)
0020 #include <asm/vga.h>
0021 #endif
0022 
0023 #ifndef VT_BUF_HAVE_RW
0024 #define scr_writew(val, addr) (*(addr) = (val))
0025 #define scr_readw(addr) (*(addr))
0026 #endif
0027 
0028 #ifndef VT_BUF_HAVE_MEMSETW
0029 static inline void scr_memsetw(u16 *s, u16 c, unsigned int count)
0030 {
0031 #ifdef VT_BUF_HAVE_RW
0032     count /= 2;
0033     while (count--)
0034         scr_writew(c, s++);
0035 #else
0036     memset16(s, c, count / 2);
0037 #endif
0038 }
0039 #endif
0040 
0041 #ifndef VT_BUF_HAVE_MEMCPYW
0042 static inline void scr_memcpyw(u16 *d, const u16 *s, unsigned int count)
0043 {
0044 #ifdef VT_BUF_HAVE_RW
0045     count /= 2;
0046     while (count--)
0047         scr_writew(scr_readw(s++), d++);
0048 #else
0049     memcpy(d, s, count);
0050 #endif
0051 }
0052 #endif
0053 
0054 #ifndef VT_BUF_HAVE_MEMMOVEW
0055 static inline void scr_memmovew(u16 *d, const u16 *s, unsigned int count)
0056 {
0057 #ifdef VT_BUF_HAVE_RW
0058     if (d < s)
0059         scr_memcpyw(d, s, count);
0060     else {
0061         count /= 2;
0062         d += count;
0063         s += count;
0064         while (count--)
0065             scr_writew(scr_readw(--s), --d);
0066     }
0067 #else
0068     memmove(d, s, count);
0069 #endif
0070 }
0071 #endif
0072 
0073 #endif