linux_compat.c 724 B

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