blob: bc426794823e45211d4c94d6b6b73ca1f54799cd [file] [log] [blame]
yuezonghe824eb0c2024-06-27 02:32:26 -07001#
2# __mmap.S, part of the i960 support for the uClibc library.
3#
4# Copyright (C) 2002 by Okiok Data Ltd. http://www.okiok.com/
5#
6# This program is free software; you can redistribute it and/or modify it under
7# the terms of the GNU Library General Public License as published by the Free
8# Software Foundation; either version 2 of the License, or (at your option) any
9# later version.
10#
11# This program is distributed in the hope that it will be useful, but WITHOUT
12# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13# FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more
14# details.
15#
16# You should have received a copy of the GNU Library General Public License
17# along with this program; if not, write to the Free Software Foundation, Inc.,
18# at 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19#
20# Derived from an old port of uC-libc to the i960 by Keith Adams (kma@cse.ogi.edu).
21#
22
23#include <sys/syscall.h>
24
25/* This is a plain system call. The 6 arguments are already set up correctly */
26/* void * mmap(void *start, size_t length, int prot , int flags, int fd, off_t offset) */
27
28
29 .globl _mmap
30_mmap:
31 mov g13, r3
32 ldconst __NR_mmap, g13
33 calls 0
34 mov r3, g13
35
36 /* We now need to check if the return value is a small negative integer. */
37 /* This is somewhat tricky as the return code (normally an address) is an */
38 /* unsigned type, or an ordinal in i960 assembler. */
39 /* We'll use the fact that, integers from -256 to -1 are ordinals 0xFFFFFF00 to 0xFFFFFFFF. */
40 /* So by checking that the return address is in the top range of the ordinals, we'll */
41 /* in fact be checking if it's not an encoded negated erro code. */
42
43 /* The range -256 to -1 should be enough since that in uClinux 2.0.39, there are */
44 /* 124 system calls for the i960. */
45
46 ldconst 0xFFFFFF00, r3 /* This is the integer's -256 representation */
47 cmpobl g0, r3, 1f /* Something smaller than this means it's out of the range, and a valid address */
48 subi g0, 0, r3 /* If it's an errno, save its negated (now positive) value in _errno. */
49 st r3, _errno
50 subi 1, 0, g0 /* And return -1. */
511:
52 ret