2020-05-09 13:04:14 +01:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2020, Andreas Kling <kling@serenityos.org>
|
|
|
|
*
|
2021-04-22 01:24:48 -07:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-05-09 13:04:14 +01:00
|
|
|
*/
|
|
|
|
|
2020-03-08 12:34:33 +01:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <AK/Types.h>
|
|
|
|
|
2020-05-16 12:00:04 +02:00
|
|
|
#if defined(KERNEL)
|
|
|
|
# include <Kernel/StdLib.h>
|
2020-03-08 12:34:33 +01:00
|
|
|
#else
|
|
|
|
# include <stdlib.h>
|
|
|
|
# include <string.h>
|
|
|
|
#endif
|
|
|
|
|
2020-04-30 11:43:25 +02:00
|
|
|
ALWAYS_INLINE void fast_u32_copy(u32* dest, const u32* src, size_t count)
|
2020-03-08 12:34:33 +01:00
|
|
|
{
|
|
|
|
asm volatile(
|
|
|
|
"rep movsl\n"
|
2020-07-27 15:54:39 +02:00
|
|
|
: "+S"(src), "+D"(dest), "+c"(count)::"memory");
|
2020-03-08 12:34:33 +01:00
|
|
|
}
|
|
|
|
|
2020-04-30 11:43:25 +02:00
|
|
|
ALWAYS_INLINE void fast_u32_fill(u32* dest, u32 value, size_t count)
|
2020-03-08 12:34:33 +01:00
|
|
|
{
|
|
|
|
asm volatile(
|
|
|
|
"rep stosl\n"
|
|
|
|
: "=D"(dest), "=c"(count)
|
|
|
|
: "D"(dest), "c"(count), "a"(value)
|
|
|
|
: "memory");
|
|
|
|
}
|