akaros/kern/arch/riscv/cpuinfo.c
<<
>>
Prefs
   1#include <arch/arch.h>
   2#include <arch/mmu.h>
   3#include <assert.h>
   4#include <pmap.h>
   5#include <smp.h>
   6#include <stdio.h>
   7#include <umem.h>
   8
   9static void static_asserts_can_go_here(void)
  10{
  11        static_assert(SIZEOF_HW_TRAPFRAME == sizeof(struct hw_trapframe));
  12}
  13
  14void print_cpuinfo(void)
  15{
  16        int id = mfpcr(PCR_IMPL);
  17        const char *name = "(unknown implementation)";
  18        if (id == 1)
  19                name = "ISA Simulator";
  20        else if (id == 2)
  21                name = "Rocket64";
  22        cprintf("CPU Info: RISC-V %s\n", name);
  23}
  24
  25#warning "convert pgdir* to pgdir_t"
  26void show_mapping(pgdir_t *pt, uintptr_t start, size_t size)
  27{
  28        pte_t *pte;
  29        uintptr_t i;
  30        page_t *page;
  31
  32        cprintf(
  33            "      Virtual            Physical      SR SW SX UR UW UX D R\n");
  34        cprintf(
  35            "------------------------------------------------------------\n");
  36        for (i = 0; i < size; i += PGSIZE, start += PGSIZE) {
  37                page = page_lookup(pt, (void *)start, &pte);
  38                cprintf("%016p  ", start);
  39                if (page) {
  40                        cprintf("%016p  %1d  %1d  %1d  %1d  %1d  %1d %1d %1d\n",
  41                                page2pa(page), !!(*pte & PTE_SR),
  42                                !!(*pte & PTE_SW), !!(*pte & PTE_SX),
  43                                !!(*pte & PTE_UR), !!(*pte & PTE_UW),
  44                                !!(*pte & PTE_UX), !!(*pte & PTE_D),
  45                                !!(*pte & PTE_R));
  46                } else
  47                        cprintf("%016p\n", 0);
  48        }
  49}
  50