Kmsg debug routine
[akaros.git] / kern / arch / sparc / cpuinfo.c
1 #include <arch/sparc.h>
2 #include <arch/arch.h>
3 #include <arch/mmu.h>
4 #include <stdio.h>
5 #include <assert.h>
6 #include <smp.h>
7 #include <umem.h>
8 #include <pmap.h>
9
10 #ifdef __SHARC__
11 #pragma nosharc
12 #endif
13
14 #ifdef __DEPUTY__
15 #pragma nodeputy
16 #endif
17
18 void
19 static_asserts_can_go_here()
20 {
21         static_assert(SIZEOF_TRAPFRAME_T == sizeof(trapframe_t));
22         static_assert(SIZEOF_TRAPFRAME_T % 8 == 0);
23         static_assert(SIZEOF_KERNEL_MESSAGE_T == sizeof(kernel_message_t));
24         static_assert(SIZEOF_KERNEL_MESSAGE_T % 8 == 0);
25         static_assert(offsetof(env_t,env_tf) % 8 == 0);
26         static_assert(offsetof(env_t,env_ancillary_state) % 8 == 0);
27 }
28
29 void
30 print_cpuinfo(void)
31 {
32         uint32_t psr = read_psr();
33         uint32_t wim = read_wim();
34         uint32_t tbr = read_tbr();
35
36         uint32_t mmucr  = read_mmu_reg(MMU_REG_CTRL);
37         uint32_t mmuctp = read_mmu_reg(MMU_REG_CTXTBL);
38         uint32_t mmuctx = read_mmu_reg(MMU_REG_CTX);
39         uint32_t mmufsr = read_mmu_reg(MMU_REG_FSR);
40         uint32_t mmufar = read_mmu_reg(MMU_REG_FAR);
41
42         cprintf("CPU Info:\n");
43         cprintf("ISA:             SPARC V8\n");
44         cprintf("Number of cores: %d\n",num_cpus);
45         cprintf("Implementation:  0x%x\n",(psr >> 28) & 0xF);
46         cprintf("Version:         0x%x\n",(psr >> 24) & 0xF);
47         cprintf("Current PSR:     0x%08x\n",psr);
48         cprintf("Current WIM:     0x%08x\n",wim);
49         cprintf("Current TBR:     0x%08x\n",tbr);
50
51         cprintf("SRMMU Info:\n");
52         cprintf("Implementation:  0x%x\n",(mmucr >> 28) & 0xF);
53         cprintf("Version:         0x%x\n",(mmucr >> 24) & 0xF);
54         cprintf("Current CR:      0x%08x\n",mmucr);
55         cprintf("Current CTP:     0x%08x\n",mmuctp);
56         cprintf("Current CTX:     0x%08x\n",mmuctx);
57         cprintf("Current FSR:     0x%08x\n",mmufsr);
58         cprintf("Current FAR:     0x%08x\n",mmufar);
59 }
60
61 void show_mapping(uintptr_t start, size_t size)
62 {
63         extern pde_t l1_page_table[NL1ENTRIES];
64         pte_t* pte;
65         uintptr_t i;
66         page_t* page;
67
68         cprintf("   Virtual    Physical  C M R ACC P\n");
69         cprintf("------------------------------------------\n");
70         for(i = 0; i < size; i += PGSIZE, start += PGSIZE)
71         {
72                 page = page_lookup(l1_page_table,(void*)start,&pte);
73                 cprintf("%08p  ",start);
74                 if(page)
75                 {
76                         cprintf("%08p  %1d %1d %1d  %1x  %1d\n",page2pa(page),
77                                 !!(*pte & PTE_C),!!(*pte & PTE_M),
78                                 !!(*pte & PTE_R),(*pte & PTE_ACC) >> 2,
79                                 !!(*pte & PTE_PTE));
80                 }
81                 else
82                         cprintf("%08p\n",0);
83         }
84 }