summaryrefslogtreecommitdiff
path: root/src/kernel/arch/generic.h
blob: f816c71c68efab86edad5306515a910336829ac4 (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
#pragma once

#include <kernel/arch/i386/registers.h>
#include <kernel/arch/log.h>
#include <stdbool.h>

// i have no idea where else to put it
// some code assumes that it's a power of 2
#define PAGE_SIZE 4096
#define PAGE_MASK (PAGE_SIZE - 1)

// linker.ld
extern char _bss_end;

__attribute__((noreturn))
void halt_cpu();

// src/arch/i386/sysenter.s
void sysexit(void (*fun)(), void *stack_top);
void sysenter_setup();
int syscall_handler(int, int, int, int);

// all of those can allocate memory
struct pagedir *pagedir_new();
void pagedir_map(struct pagedir *dir, void *virt, void *phys,
                 bool user, bool writeable);
void pagedir_switch(struct pagedir *);

// return 0 on failure
void *pagedir_virt2phys(struct pagedir *dir, const void *virt,
                        bool user, bool writeable);