akaros/kern/arch/riscv/riscv.h
<<
>>
Prefs
   1#pragma once
   2
   3#include <arch/pcr.h>
   4
   5static __inline void
   6lcr3(uintptr_t val)
   7{
   8        mtpcr(PCR_PTBR, val);
   9}
  10
  11static __inline uintptr_t
  12rcr3(void)
  13{
  14        return mfpcr(PCR_PTBR);
  15}
  16
  17static __inline uintptr_t
  18read_pc(void)
  19{
  20        uintptr_t pc;
  21        asm ("rdpc %0" : "=r"(pc));
  22        return pc;
  23}
  24
  25static inline uintptr_t
  26read_bp(void)
  27{
  28        /* frame pointer.  yes, read_bp is a shitty name.  i'll change all of
  29         * them to read_fp when you read this and implement the function.  =) */
  30        return 0;
  31}
  32
  33static __inline void
  34send_ipi(uint32_t who, uint8_t vector)
  35{
  36        mtpcr(PCR_SEND_IPI, who);
  37}
  38
  39static __inline void
  40send_broadcast_ipi(uint8_t vector)
  41{
  42#warning "broadcast ipi?"
  43        /* num_cores might not be visible here */
  44        for (int i = 0; i < num_cores; i++)
  45                send_ipi(i, vector);
  46}
  47
  48static __inline void
  49clear_ipi()
  50{
  51        mtpcr(PCR_CLR_IPI, 0);
  52}
  53