source: trunk/libs/newlib/src/libgloss/lm32/scall.S @ 547

Last change on this file since 547 was 444, checked in by satin@…, 7 years ago

add newlib,libalmos-mkh, restructure shared_syscalls.h and mini-libc

File size: 3.5 KB
Line 
1/*
2 * Lattice Mico32 system calls.
3 * Contributed by Jon Beniston <jon@beniston.com>
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 *
14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 */
26
27#include <syscall.h>
28
29/*
30 * System call convention (as implemented in simulator:
31 *    - System call number in register r8
32 *    - Return value in r1 and r2 (only if 64-bit value)
33 *    - errno in r3     
34 */
35
36        .extern errno
37
38        .global _write
39_write:
40        mvi     r8, SYS_write
41        scall   
42        mvhi    r4, hi(errno)
43        ori     r4, r4, lo(errno)
44        sw      (r4+0), r3
45        ret
46
47        .global _read
48_read:
49        mvi     r8, SYS_read
50        scall
51        mvhi    r4, hi(errno)
52        ori     r4, r4, lo(errno)
53        sw      (r4+0), r3
54        ret               
55
56        .global _open
57_open:   
58        mvi     r8, SYS_open
59        scall
60        mvhi    r4, hi(errno)
61        ori     r4, r4, lo(errno)
62        sw      (r4+0), r3
63        ret
64       
65        .global _close
66_close:   
67        mvi     r8, SYS_close
68        scall
69        mvhi    r4, hi(errno)
70        ori     r4, r4, lo(errno)
71        sw      (r4+0), r3
72        ret               
73           
74        .global _lseek
75_lseek:
76        mvi     r8, SYS_lseek
77        scall
78        mvhi    r4, hi(errno)
79        ori     r4, r4, lo(errno)
80        sw      (r4+0), r3
81        ret   
82                   
83        .global _fstat
84_fstat:
85        mvi     r8, SYS_fstat
86        scall
87        mvhi    r4, hi(errno)
88        ori     r4, r4, lo(errno)
89        sw      (r4+0), r3
90        ret                                           
91
92        .global _stat
93_stat:
94        mvi     r8, SYS_stat
95        scall
96        mvhi    r4, hi(errno)
97        ori     r4, r4, lo(errno)
98        sw      (r4+0), r3
99        ret                                           
100
101        .global _link
102_link:
103        mvi     r8, SYS_link
104        scall
105        mvhi    r4, hi(errno)
106        ori     r4, r4, lo(errno)
107        sw      (r4+0), r3
108        ret                                           
109           
110        .global _unlink
111_unlink:
112        mvi     r8, SYS_unlink
113        scall
114        mvhi    r4, hi(errno)
115        ori     r4, r4, lo(errno)
116        sw      (r4+0), r3
117        ret                                           
118                       
119        .global _exit
120_exit:
121        /* This call doesn't return */
122        mvi     r8, SYS_exit
123        scall   
Note: See TracBrowser for help on using the repository browser.