Enabled reading performance counters in user space
authorAndrew Waterman <waterman@ubuntu.(none)>
Sun, 3 Jan 2010 01:03:03 +0000 (17:03 -0800)
committerAndrew Waterman <waterman@ubuntu.(none)>
Sun, 3 Jan 2010 01:03:03 +0000 (17:03 -0800)
I used a fast-trap (user trap 0x89) rather than a full syscall

kern/arch/sparc/sparc.h
kern/arch/sparc/trap_entry.S
kern/arch/sparc/trap_table.S

index fac8912..192ac4c 100644 (file)
@@ -95,10 +95,15 @@ read_fsr(void)
 static __inline uint64_t
 read_perfctr(uint32_t cpu, uint32_t which)
 {
-       uint32_t hi,lo;
+       register uint32_t hi asm("o0"), lo asm("o1");
        intptr_t addr = cpu<<10 | which<<3;
-       hi = load_alternate(addr,2);
-       lo = load_alternate(addr+4,2);
+       #ifdef ROS_KERNEL
+               hi = load_alternate(addr,2);
+               lo = load_alternate(addr+4,2);
+       #else
+               asm volatile("mov %2,%%o0; ta 9"
+                            : "=r"(hi),"=r"(lo) : "r"(addr));
+       #endif
        return (((uint64_t)hi) << 32) | lo;
 }
 
index 8ddb25f..afb6bcf 100644 (file)
@@ -234,6 +234,15 @@ env_pop_tf:
        jmp     %l1
        rett    %l2
 
+       .global handle_perfctr
+handle_perfctr:
+       andn    %i0,7,%i1
+       lda     [%i1] 2,%i0
+       add     %i1,4,%i1
+       lda     [%i1] 2,%i1
+       jmp     %l2
+        rett   %l2+4
+
        .global send_active_message_raw
 send_active_message_raw:
        retl
index d736284..b9a6df2 100644 (file)
@@ -144,8 +144,8 @@ trap_table:
        UNHANDLED_TRAP                          ! 0x85
        UNHANDLED_TRAP                          ! 0x86
        UNHANDLED_TRAP                          ! 0x87
-       TRAP_TABLE_ENTRY(handle_syscall)        ! 0x80
-       UNHANDLED_TRAP                          ! 0x89
+       TRAP_TABLE_ENTRY(handle_syscall)        ! 0x88
+       JMP(handle_perfctr)                     ! 0x89
        UNHANDLED_TRAP                          ! 0x8A
        UNHANDLED_TRAP                          ! 0x8B
        UNHANDLED_TRAP                          ! 0x8C