osproject.c 1.26 KB
/*
* * hello.c ­ The simplest kernel module.
* */
#include <stdio.h>
#define ARMV7_PMNC_E (1 << 0) /* Enable all counters */
#define ARMV7_PMNC_P (1 << 1) /* Reset all counters */
#define ARMV7_PMNC_C (1 << 2) /* Cycle counter reset */
#define ARMV7_PMNC_D (1 << 3) /* CCNT counts every 64th cpu cycle */
#define ARMV7_PMNC_X (1 << 4) /* Export to ETM */
#define ARMV7_PMNC_DP (1 << 5) /* Disable CCNT if non-invasive debug*/
#define ARMV7_PMNC_N_SHIFT 11 /* Number of counters supported */
#define ARMV7_PMNC_N_MASK 0x1f
#define ARMV7_PMNC_MASK 0x3f /* Mask for writable bits */
/*101b9173
static u32 armv7_pmnc_read(void)
{
u32 val;
asm volatile("mrc p15, 0, %0, c9, c12, 0" : "=r"(val));
return val;
}
static void armv7_pmnc_write(u32 val)
{
val &= ARMV7_PMNC_MASK;
isb();
asm volatile("mcr p15, 0, %0, c9, c12, 0" :: "r"(val));
}
*/
static void dummy()
{
}
int main()
{
unsigned int regr;
unsigned int i;
unsigned int a, b;
printf("CSE237A: Hello world.\n");
asm volatile("mrc p15, 0, %0, c9, c14, 0" : "=r" (regr));
printf("regr: %x\n", regr);
for (i = 0; i < 10; i++) {
asm volatile("mrc p15, 0, %0, c9, c13, 0" : "=r" (a));
asm volatile("mrc p15, 0, %0, c9, c13, 0" : "=r" (b));
printf("c[%u]: %u\n", i, b - a);
}
return 1;
}