1
2#include <common.h>
3#include <malloc.h>
4#include <memalign.h>
5#include <asm/cache.h>
6#include <linux/compat.h>
7
8struct p_current cur = {
9 .pid = 1,
10};
11__maybe_unused struct p_current *current = &cur;
12
13unsigned long copy_from_user(void *dest, const void *src,
14 unsigned long count)
15{
16 memcpy((void *)dest, (void *)src, count);
17 return 0;
18}
19
20void *kmalloc(size_t size, int flags)
21{
22 void *p;
23
24 p = malloc_cache_aligned(size);
25 if (p && flags & __GFP_ZERO)
26 memset(p, 0, size);
27
28 return p;
29}
30
31struct kmem_cache *get_mem(int element_sz)
32{
33 struct kmem_cache *ret;
34
35 ret = memalign(ARCH_DMA_MINALIGN, sizeof(struct kmem_cache));
36 ret->sz = element_sz;
37
38 return ret;
39}
40
41void *kmem_cache_alloc(struct kmem_cache *obj, int flag)
42{
43 return malloc_cache_aligned(obj->sz);
44}
45
46
47
48
49
50
51
52
53
54
55void *kmemdup(const void *src, size_t len, gfp_t gfp)
56{
57 void *p;
58
59 p = kmalloc(len, gfp);
60 if (p)
61 memcpy(p, src, len);
62 return p;
63}
64