aboutsummaryrefslogtreecommitdiff
path: root/pk/sbi_impl.c
blob: 4af0cd415774cb6d1ea50d955a51ef96268b50a8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include "mtrap.h"
#include "sbi.h"
#include "boot.h"

uintptr_t __sbi_query_memory(uintptr_t id, memory_block_info *p)
{
  if (id == 0) {
    p->base = current.first_free_paddr;
    p->size = mem_size - p->base;
    return 0;
  }

  return -1;
}

#define LOW_IRQ_OK(n) ((n) == IRQ_S_SOFT || (n) == IRQ_S_TIMER)

uintptr_t __sbi_mask_interrupt(uintptr_t which)
{
  if (!LOW_IRQ_OK(which))
    return -1;

  clear_csr(sie, 1UL << which);
  return 0;
}

uintptr_t __sbi_unmask_interrupt(uintptr_t which)
{
  if (!LOW_IRQ_OK(which))
    return -1;

  set_csr(sie, 1UL << which);
  return 0;
}