xref: /openbmc/u-boot/lib/linux_compat.c (revision da4cfa6b)
1 
2 #include <common.h>
3 #include <memalign.h>
4 #include <linux/compat.h>
5 
6 struct p_current cur = {
7 	.pid = 1,
8 };
9 __maybe_unused struct p_current *current = &cur;
10 
11 unsigned long copy_from_user(void *dest, const void *src,
12 		     unsigned long count)
13 {
14 	memcpy((void *)dest, (void *)src, count);
15 	return 0;
16 }
17 
18 void *kmalloc(size_t size, int flags)
19 {
20 	void *p;
21 
22 	p = malloc_cache_aligned(size);
23 	if (flags & __GFP_ZERO)
24 		memset(p, 0, size);
25 
26 	return p;
27 }
28 
29 struct kmem_cache *get_mem(int element_sz)
30 {
31 	struct kmem_cache *ret;
32 
33 	ret = memalign(ARCH_DMA_MINALIGN, sizeof(struct kmem_cache));
34 	ret->sz = element_sz;
35 
36 	return ret;
37 }
38 
39 void *kmem_cache_alloc(struct kmem_cache *obj, int flag)
40 {
41 	return malloc_cache_aligned(obj->sz);
42 }
43