aboutsummaryrefslogtreecommitdiff
path: root/common/uapi/mem.c
blob: 8c63a87774c07bde353223ce308ec106f07fa1ec (plain) (blame)
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#include <apos/dev.h>
#include <apos/uapi.h>
#include <apos/utils.h>
#include <apos/vmem.h>

vm_t sys_req_mem(vm_t size, vm_t flags, vm_t u0, vm_t u1)
{
	UNUSED(u0); UNUSED(u1);
	/* proc_tcb should give the tcb of the TID currently running */
	struct tcb *r = cur_tcb();
	return alloc_uvmem(r, size, flags);
}

vm_t sys_req_fixmem(vm_t start, vm_t size, vm_t flags, vm_t u0)
{
	UNUSED(u0);
	struct tcb *r = cur_tcb();
	return alloc_fixed_uvmem(r, start, size, flags);
}

vm_t sys_free_mem(vm_t start, vm_t u0, vm_t u1, vm_t u2)
{
	UNUSED(u0); UNUSED(u1); UNUSED(u2);
	struct tcb *r = cur_tcb();
	if(start > __pre_top && start < __post_base)
		free_uvmem(r, start);
	else
		free_devmem(r, start);

	return 0;
}

vm_t sys_req_pmem(vm_t paddr, vm_t size, vm_t flags, vm_t u0)
{
	UNUSED(u0);
	/* this will require some pondering, but essentially this syscall should
	 * only be used for device access, so any addresses requested should be
	 * outside the RAM area, and I'll probably have to implement some method
	 * that keeps track of used regions outside of RAM. We'll see.
	 */
	struct tcb *r = cur_tcb();
	return alloc_devmem(r, paddr, size, flags);
}

vm_t sys_req_sharedmem(vm_t pid, vm_t start, vm_t size, vm_t flags)
{
	/* take memory in PID's vaddr and map it somewhere in our own memory
	 * region.
	 */
	return 0;
}