mmap.S 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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, see
  13. <http://www.gnu.org/licenses/>. */
  14. #include "sysdep.h"
  15. #include <sys/syscall.h>
  16. #define PAGE_SHIFT 12
  17. /* __ptr_t __mmap (a2 = __ptr_t addr,
  18. a3 = size_t len,
  19. a4 = int prot,
  20. a5 = int flags,
  21. a6 = int fd,
  22. a7 = off_t offset) */
  23. ENTRY (__mmap)
  24. /* We only support mmap2 in the kernel, so shift offset by
  25. page - size. */
  26. mov a8, a6
  27. mov a6, a2
  28. movi a2, SYS_ify (mmap2)
  29. srli a9, a7, PAGE_SHIFT
  30. /* syscall (a2 = NR_mmap2,
  31. a6 = arg0,
  32. a3 = arg1,
  33. a4 = arg2,
  34. a5 = arg3,
  35. a8 = arg4,
  36. a9 = arg5) */
  37. syscall
  38. bltz a2, SYSCALL_ERROR_LABEL
  39. .Lpseudo_end:
  40. abi_ret
  41. PSEUDO_END (__mmap)
  42. weak_alias (__mmap, mmap)
  43. libc_hidden_weak (mmap)