mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-12-27 04:45:23 +07:00
ac036f9570
Where possible, call memset16(), memmove() or memcpy() instead of using open-coded loops. I don't like the calling convention that uses a byte count instead of a count of u16s, but it's a little late to change that. Reduces code size of fbcon.o by almost 400 bytes on my laptop build. [akpm@linux-foundation.org: fix build] Link: http://lkml.kernel.org/r/20170720184539.31609-9-willy@infradead.org Signed-off-by: Matthew Wilcox <mawilcox@microsoft.com> Cc: Ralf Baechle <ralf@linux-mips.org> Cc: David Miller <davem@davemloft.net> Cc: Sam Ravnborg <sam@ravnborg.org> Cc: "H. Peter Anvin" <hpa@zytor.com> Cc: "James E.J. Bottomley" <jejb@linux.vnet.ibm.com> Cc: "Martin K. Petersen" <martin.petersen@oracle.com> Cc: Ingo Molnar <mingo@elte.hu> Cc: Ivan Kokshaysky <ink@jurassic.park.msu.ru> Cc: Matt Turner <mattst88@gmail.com> Cc: Michael Ellerman <mpe@ellerman.id.au> Cc: Minchan Kim <minchan@kernel.org> Cc: Richard Henderson <rth@twiddle.net> Cc: Russell King <rmk+kernel@armlinux.org.uk> Cc: Sergey Senozhatsky <sergey.senozhatsky@gmail.com> Cc: Thomas Gleixner <tglx@linutronix.de> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
73 lines
1.5 KiB
C
73 lines
1.5 KiB
C
/*
|
|
* include/linux/vt_buffer.h -- Access to VT screen buffer
|
|
*
|
|
* (c) 1998 Martin Mares <mj@ucw.cz>
|
|
*
|
|
* This is a set of macros and functions which are used in the
|
|
* console driver and related code to access the screen buffer.
|
|
* In most cases the console works with simple in-memory buffer,
|
|
* but when handling hardware text mode consoles, we store
|
|
* the foreground console directly in video memory.
|
|
*/
|
|
|
|
#ifndef _LINUX_VT_BUFFER_H_
|
|
#define _LINUX_VT_BUFFER_H_
|
|
|
|
#include <linux/string.h>
|
|
|
|
#if defined(CONFIG_VGA_CONSOLE) || defined(CONFIG_MDA_CONSOLE)
|
|
#include <asm/vga.h>
|
|
#endif
|
|
|
|
#ifndef VT_BUF_HAVE_RW
|
|
#define scr_writew(val, addr) (*(addr) = (val))
|
|
#define scr_readw(addr) (*(addr))
|
|
#endif
|
|
|
|
#ifndef VT_BUF_HAVE_MEMSETW
|
|
static inline void scr_memsetw(u16 *s, u16 c, unsigned int count)
|
|
{
|
|
#ifdef VT_BUF_HAVE_RW
|
|
count /= 2;
|
|
while (count--)
|
|
scr_writew(c, s++);
|
|
#else
|
|
memset16(s, c, count / 2);
|
|
#endif
|
|
}
|
|
#endif
|
|
|
|
#ifndef VT_BUF_HAVE_MEMCPYW
|
|
static inline void scr_memcpyw(u16 *d, const u16 *s, unsigned int count)
|
|
{
|
|
#ifdef VT_BUF_HAVE_RW
|
|
count /= 2;
|
|
while (count--)
|
|
scr_writew(scr_readw(s++), d++);
|
|
#else
|
|
memcpy(d, s, count);
|
|
#endif
|
|
}
|
|
#endif
|
|
|
|
#ifndef VT_BUF_HAVE_MEMMOVEW
|
|
static inline void scr_memmovew(u16 *d, const u16 *s, unsigned int count)
|
|
{
|
|
#ifdef VT_BUF_HAVE_RW
|
|
if (d < s)
|
|
scr_memcpyw(d, s, count);
|
|
else {
|
|
count /= 2;
|
|
d += count;
|
|
s += count;
|
|
while (count--)
|
|
scr_writew(scr_readw(--s), --d);
|
|
}
|
|
#else
|
|
memmove(d, s, count);
|
|
#endif
|
|
}
|
|
#endif
|
|
|
|
#endif
|