Heiko Schocher | 4f7a9a3 | 2014-06-24 10:10:03 +0200 | [diff] [blame] | 1 | |
| 2 | #include <common.h> |
| 3 | #include <linux/compat.h> |
| 4 | |
| 5 | struct p_current cur = { |
| 6 | .pid = 1, |
| 7 | }; |
| 8 | __maybe_unused struct p_current *current = &cur; |
| 9 | |
| 10 | unsigned long copy_from_user(void *dest, const void *src, |
| 11 | unsigned long count) |
| 12 | { |
| 13 | memcpy((void *)dest, (void *)src, count); |
| 14 | return 0; |
| 15 | } |
| 16 | |
| 17 | void *kmalloc(size_t size, int flags) |
| 18 | { |
Masahiro Yamada | 7b5ec7e | 2015-07-13 13:17:07 +0900 | [diff] [blame] | 19 | void *p; |
| 20 | |
| 21 | p = memalign(ARCH_DMA_MINALIGN, size); |
| 22 | if (flags & __GFP_ZERO) |
| 23 | memset(p, 0, size); |
Heiko Schocher | 4f7a9a3 | 2014-06-24 10:10:03 +0200 | [diff] [blame] | 24 | |
Masahiro Yamada | 7b5ec7e | 2015-07-13 13:17:07 +0900 | [diff] [blame] | 25 | return p; |
Heiko Schocher | 4f7a9a3 | 2014-06-24 10:10:03 +0200 | [diff] [blame] | 26 | } |
| 27 | |
Heiko Schocher | 4f7a9a3 | 2014-06-24 10:10:03 +0200 | [diff] [blame] | 28 | struct kmem_cache *get_mem(int element_sz) |
| 29 | { |
| 30 | struct kmem_cache *ret; |
| 31 | |
| 32 | ret = memalign(ARCH_DMA_MINALIGN, sizeof(struct kmem_cache)); |
| 33 | ret->sz = element_sz; |
| 34 | |
| 35 | return ret; |
| 36 | } |
| 37 | |
| 38 | void *kmem_cache_alloc(struct kmem_cache *obj, int flag) |
| 39 | { |
| 40 | return memalign(ARCH_DMA_MINALIGN, obj->sz); |
| 41 | } |