ARM cache operations

This commit is contained in:
plutoo 2018-01-22 20:29:34 +01:00
parent 9634a5467e
commit b34f59e179
9 changed files with 76 additions and 8 deletions

View File

@ -22,7 +22,8 @@ extern "C" {
#include "switch/kernel/random.h" #include "switch/kernel/random.h"
#include "switch/kernel/jit.h" #include "switch/kernel/jit.h"
#include "switch/arm.h" #include "switch/arm/tls.h"
#include "switch/arm/cache.h"
#include "switch/ipc.h" #include "switch/ipc.h"
#include "switch/services/sm.h" #include "switch/services/sm.h"

View File

@ -0,0 +1,7 @@
#pragma once
void armDCacheFlush(void* addr, size_t size);
void armDCacheClean(void* addr, size_t size);
void armICacheInvalidate(void* addr, size_t size);
void armDCacheZero(void* addr, size_t size);

View File

@ -1,10 +1,7 @@
#pragma once #pragma once
#include "types.h"
static inline void* armGetTls(void) { static inline void* armGetTls(void) {
void* ret; void* ret;
__asm__ ("mrs %x[data], tpidrro_el0" : [data] "=r" (ret)); __asm__ ("mrs %x[data], tpidrro_el0" : [data] "=r" (ret));
return ret; return ret;
} }
void armDCacheFlush(void* addr, size_t size);

View File

@ -1,7 +1,7 @@
// Copyright 2017 plutoo // Copyright 2017 plutoo
#pragma once #pragma once
#include "arm.h"
#include "result.h" #include "result.h"
#include "arm/tls.h"
#include "kernel/svc.h" #include "kernel/svc.h"
#define SFCI_MAGIC 0x49434653 #define SFCI_MAGIC 0x49434653

View File

@ -32,3 +32,64 @@ armDCacheFlush_L0:
ret ret
CODE_END CODE_END
CODE_BEGIN armDCacheClean
add x1, x1, x0
mrs x8, CTR_EL0
lsr x8, x8, #16
and x8, x8, #0xf
mov x9, #4
lsl x9, x9, x8
sub x10, x9, #1
bic x8, x0, x10
mov x10, x1
armDCacheClean_L0:
dc cvac, x8
add x8, x8, x9
cmp x8, x10
bcc armDCacheClean_L0
dsb sy
ret
CODE_END
CODE_BEGIN armICacheInvalidate
add x1, x1, x0
mrs x8, CTR_EL0
and x8, x8, #0xf
mov x9, #4
lsl x9, x9, x8
sub x10, x9, #1
bic x8, x0, x10
mov x10, x1
armICacheInvalidate_L0:
ic ivau, x8
add x8, x8, x9
cmp x8, x10
bcc armICacheInvalidate_L0
dsb sy
ret
CODE_END
CODE_BEGIN armDCacheZero
add x1, x1, x0
mrs x8, CTR_EL0
lsr x8, x8, #16
and x8, x8, #0xf
mov x9, #4
lsl x9, x9, x8
sub x10, x9, #1
bic x8, x0, x10
mov x10, x1
armDCacheZero_L0:
dc zva, x8
add x8, x8, x9
cmp x8, x10
bcc armDCacheZero_L0
dsb sy
ret
CODE_END

View File

@ -1,6 +1,7 @@
#include <string.h> #include <string.h>
#include "types.h" #include "types.h"
#include "result.h" #include "result.h"
#include "arm/cache.h"
#include "services/fatal.h" #include "services/fatal.h"
#include "services/vi.h" #include "services/vi.h"
#include "services/applet.h" #include "services/applet.h"

View File

@ -1,8 +1,8 @@
#include <string.h> #include <string.h>
#include <malloc.h> #include <malloc.h>
#include "types.h" #include "types.h"
#include "arm.h"
#include "result.h" #include "result.h"
#include "arm/cache.h"
#include "kernel/svc.h" #include "kernel/svc.h"
#include "services/nv.h" #include "services/nv.h"
#include "gfx/binder.h" #include "gfx/binder.h"

View File

@ -1,6 +1,6 @@
#pragma once #pragma once
#include "arm.h"
#include "types.h" #include "types.h"
#include "arm/tls.h"
#include "kernel/thread.h" #include "kernel/thread.h"
#define THREADVARS_MAGIC 0x21545624 // !TV$ #define THREADVARS_MAGIC 0x21545624 // !TV$

View File

@ -2,6 +2,7 @@
#include "types.h" #include "types.h"
#include "result.h" #include "result.h"
#include "ipc.h" #include "ipc.h"
#include "arm/cache.h"
#include "kernel/detect.h" #include "kernel/detect.h"
#include "services/usb.h" #include "services/usb.h"
#include "services/sm.h" #include "services/sm.h"