add some experiments with the cache
This commit is contained in:
@@ -7,6 +7,7 @@ typedef enum
|
||||
{
|
||||
PAYLOAD_AES_BUSY,
|
||||
PAYLOAD_AES_SW,
|
||||
PAYLOAD_CACHELIB,
|
||||
PAYLOAD_EXIT_USB_TASK,
|
||||
PAYLOAD_FLOPPYSLEEP,
|
||||
PAYLOAD_SYNC,
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
set(PL_NAMES
|
||||
aes_busy
|
||||
aes_sw
|
||||
cachelib
|
||||
exit_usb_task
|
||||
floppysleep
|
||||
sync
|
||||
|
||||
62
c8_remote/lib/payload/include/cacheutil.h
Normal file
62
c8_remote/lib/payload/include/cacheutil.h
Normal file
@@ -0,0 +1,62 @@
|
||||
#ifndef CHECKM8_TOOL_CACHEUTIL_H
|
||||
#define CHECKM8_TOOL_CACHEUTIL_H
|
||||
|
||||
#include "dev_util.h"
|
||||
|
||||
PAYLOAD_SECTION
|
||||
static inline unsigned long long get_ccsidr_el1()
|
||||
{
|
||||
unsigned long long cacheconfig = 0;
|
||||
__asm__ volatile ("mrs %0, ccsidr_el1" : "=r" (cacheconfig));
|
||||
return cacheconfig;
|
||||
}
|
||||
|
||||
PAYLOAD_SECTION
|
||||
static inline void sel_ccsidr_el1(unsigned int level, unsigned int i_or_d)
|
||||
{
|
||||
unsigned long long cachesel = (level & 0b111u) << 1u | (i_or_d & 0b1u);
|
||||
__asm__ volatile ("msr csselr_el1, %0"::"r" (cachesel));
|
||||
}
|
||||
|
||||
PAYLOAD_SECTION
|
||||
static inline unsigned long long get_ctr_el0()
|
||||
{
|
||||
unsigned long long cacheconfig;
|
||||
__asm__ volatile ("mrs %0, CTR_EL0" : "=r" (cacheconfig));
|
||||
return cacheconfig;
|
||||
}
|
||||
|
||||
PAYLOAD_SECTION
|
||||
static inline void inv_l1_setway(unsigned int set, unsigned int way)
|
||||
{
|
||||
unsigned long long val = ((way & 0b11u) << 30u) | ((set & 0xFFu) << 6u);
|
||||
__asm__ volatile ("dc isw, %0"::"r" (val));
|
||||
}
|
||||
|
||||
PAYLOAD_SECTION
|
||||
static inline void clean_l1_setway(unsigned int set, unsigned int way)
|
||||
{
|
||||
unsigned long long val = ((way & 0b11u) << 30u) | ((set & 0xFFu) << 6u);
|
||||
__asm__ volatile ("dc csw, %0"::"r" (val));
|
||||
}
|
||||
|
||||
PAYLOAD_SECTION
|
||||
static inline void clean_inv_l1_setway(unsigned int set, unsigned int way)
|
||||
{
|
||||
unsigned long long val = ((way & 0b11u) << 30u) | ((set & 0xFFu) << 6u);
|
||||
__asm__ volatile ("dc cisw, %0"::"r" (val));
|
||||
}
|
||||
|
||||
PAYLOAD_SECTION
|
||||
static inline void inv_l1_va(unsigned long long *addr)
|
||||
{
|
||||
__asm__ volatile ("dc ivac, %0"::"r" (addr));
|
||||
}
|
||||
|
||||
PAYLOAD_SECTION
|
||||
static inline void clean_inv_l1_va(unsigned long long *addr)
|
||||
{
|
||||
__asm__ volatile ("dc ivac, %0"::"r" (addr));
|
||||
}
|
||||
|
||||
#endif //CHECKM8_TOOL_CACHEUTIL_H
|
||||
33
c8_remote/lib/payload/src/cachelib.c
Normal file
33
c8_remote/lib/payload/src/cachelib.c
Normal file
@@ -0,0 +1,33 @@
|
||||
#include "bootrom_func.h"
|
||||
#include "cacheutil.h"
|
||||
|
||||
|
||||
PAYLOAD_SECTION
|
||||
unsigned long long l1_experiment()
|
||||
{
|
||||
int i;
|
||||
unsigned long long start, f;
|
||||
volatile unsigned long long val = 0;
|
||||
clean_inv_l1_va((unsigned long long *) &val);
|
||||
|
||||
start = get_ticks();
|
||||
for(i = 0; i < 10000000; i++)
|
||||
{
|
||||
val;
|
||||
clean_inv_l1_va((unsigned long long *) &val);
|
||||
}
|
||||
|
||||
return get_ticks() - start;
|
||||
}
|
||||
|
||||
PAYLOAD_SECTION
|
||||
unsigned long long entry_sync()
|
||||
{
|
||||
return l1_experiment();
|
||||
}
|
||||
|
||||
PAYLOAD_SECTION
|
||||
void entry_async()
|
||||
{
|
||||
|
||||
}
|
||||
@@ -50,6 +50,11 @@ struct payload *get_payload(PAYLOAD_T p)
|
||||
len = PAYLOAD_AES_SW_SZ;
|
||||
break;
|
||||
|
||||
case PAYLOAD_CACHELIB:
|
||||
pl = payload_cachelib;
|
||||
len = PAYLOAD_CACHELIB_SZ;
|
||||
break;
|
||||
|
||||
case PAYLOAD_EXIT_USB_TASK:
|
||||
pl = payload_exit_usb_task;
|
||||
len = PAYLOAD_EXIT_USB_TASK_SZ;
|
||||
|
||||
Reference in New Issue
Block a user