mirror of
https://github.com/SerenityOS/serenity
synced 2024-10-15 20:33:10 +00:00
Kernel: Don't use MMX memcpy() in the kernel.
I just discovered the hard way that clobbering FPU/MMX/SSE registers in the kernel makes things very confusing for userspace (and other kernel threads.) Let's banish all of those things from the kernel to keep things simple.
This commit is contained in:
parent
1d02c7b6f1
commit
6693cfb26a
|
@ -5,6 +5,7 @@
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
|
||||||
|
#ifndef KERNEL
|
||||||
void* mmx_memcpy(void* dest, const void* src, size_t len)
|
void* mmx_memcpy(void* dest, const void* src, size_t len)
|
||||||
{
|
{
|
||||||
ASSERT(len >= 1024);
|
ASSERT(len >= 1024);
|
||||||
|
@ -51,6 +52,7 @@ void* mmx_memcpy(void* dest, const void* src, size_t len)
|
||||||
memcpy(dest_ptr, src_ptr, len);
|
memcpy(dest_ptr, src_ptr, len);
|
||||||
return dest;
|
return dest;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef KERNEL
|
#ifdef KERNEL
|
||||||
|
|
||||||
|
|
|
@ -11,14 +11,18 @@
|
||||||
|
|
||||||
#include <AK/Types.h>
|
#include <AK/Types.h>
|
||||||
|
|
||||||
|
#ifndef KERNEL
|
||||||
extern "C" void* mmx_memcpy(void* to, const void* from, size_t);
|
extern "C" void* mmx_memcpy(void* to, const void* from, size_t);
|
||||||
|
#endif
|
||||||
|
|
||||||
[[gnu::always_inline]] inline void fast_dword_copy(dword* dest, const dword* src, size_t count)
|
[[gnu::always_inline]] inline void fast_dword_copy(dword* dest, const dword* src, size_t count)
|
||||||
{
|
{
|
||||||
|
#ifndef KERNEL
|
||||||
if (count >= 256) {
|
if (count >= 256) {
|
||||||
mmx_memcpy(dest, src, count * sizeof(count));
|
mmx_memcpy(dest, src, count * sizeof(count));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
asm volatile(
|
asm volatile(
|
||||||
"rep movsl\n"
|
"rep movsl\n"
|
||||||
: "=S"(src), "=D"(dest), "=c"(count)
|
: "=S"(src), "=D"(dest), "=c"(count)
|
||||||
|
|
|
@ -8,9 +8,10 @@ extern "C" {
|
||||||
|
|
||||||
void* memcpy(void* dest_ptr, const void* src_ptr, size_t n)
|
void* memcpy(void* dest_ptr, const void* src_ptr, size_t n)
|
||||||
{
|
{
|
||||||
if (n >= 1024) {
|
#ifndef KERNEL
|
||||||
|
if (n >= 1024)
|
||||||
return mmx_memcpy(dest_ptr, src_ptr, n);
|
return mmx_memcpy(dest_ptr, src_ptr, n);
|
||||||
}
|
#endif
|
||||||
|
|
||||||
size_t dest = (size_t)dest_ptr;
|
size_t dest = (size_t)dest_ptr;
|
||||||
size_t src = (size_t)src_ptr;
|
size_t src = (size_t)src_ptr;
|
||||||
|
|
Loading…
Reference in a new issue