mmap.S 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /* Copyright (C) 2005, 2007 Free Software Foundation, Inc.
  2. This file is part of the GNU C Library.
  3. The GNU C Library is free software; you can redistribute it and/or
  4. modify it under the terms of the GNU Lesser General Public
  5. License as published by the Free Software Foundation; either
  6. version 2.1 of the License, or (at your option) any later version.
  7. The GNU C Library is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  10. Lesser General Public License for more details.
  11. You should have received a copy of the GNU Lesser General Public
  12. License along with the GNU C Library; if not, write to the Free
  13. Software Foundation, Inc., 51 Franklin Street - Fifth Floor,
  14. Boston, MA 02110-1301, USA. */
  15. #include "sysdep.h"
  16. #include <sys/syscall.h>
  17. #define PAGE_SHIFT 12
  18. /* __ptr_t __mmap (a2 = __ptr_t addr,
  19. a3 = size_t len,
  20. a4 = int prot,
  21. a5 = int flags,
  22. a6 = int fd,
  23. a7 = off_t offset) */
  24. ENTRY (__mmap)
  25. /* We only support mmap2 in the kernel, so shift offset by
  26. page - size. */
  27. mov a8, a6
  28. mov a6, a2
  29. movi a2, SYS_ify (mmap2)
  30. srli a9, a7, PAGE_SHIFT
  31. /* syscall (a2 = NR_mmap2,
  32. a6 = arg0,
  33. a3 = arg1,
  34. a4 = arg2,
  35. a5 = arg3,
  36. a8 = arg4,
  37. a9 = arg5) */
  38. syscall
  39. bltz a2, SYSCALL_ERROR_LABEL
  40. .Lpseudo_end:
  41. retw
  42. PSEUDO_END (__mmap)
  43. weak_alias (__mmap, mmap)
  44. libc_hidden_weak (mmap)