1 | /* Copyright (c) 2012, 2013 Red Hat, Inc. All rights reserved. |
---|
2 | |
---|
3 | This copyrighted material is made available to anyone wishing to use, modify, |
---|
4 | copy, or redistribute it subject to the terms and conditions of the BSD |
---|
5 | License. This program is distributed in the hope that it will be useful, |
---|
6 | but WITHOUT ANY WARRANTY expressed or implied, including the implied warranties |
---|
7 | of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. A copy of this license |
---|
8 | is available at http://www.opensource.org/licenses. Any Red Hat trademarks that |
---|
9 | are incorporated in the source code or documentation are not subject to the BSD |
---|
10 | License and may only be used or replicated with the express permission of |
---|
11 | Red Hat, Inc. |
---|
12 | */ |
---|
13 | |
---|
14 | /* Be wary: the lower N bits of the *address* of the function |
---|
15 | determines the syscall used by the simulator. Thus, the addresses |
---|
16 | listed here depend on the syscall numbers in ../syscalls.h. */ |
---|
17 | |
---|
18 | /* As per the MSP430x200 Family Users Guide, section 1.5, "An |
---|
19 | instruction fetch from the address range 0x0000 - 0x01FF will reset |
---|
20 | the device." We take advantage of that to do syscalls in the |
---|
21 | simulator, by trying to execute specific addresses in that range |
---|
22 | and letting the simulator catch them while simulating the CALL |
---|
23 | instruction. In theory, this is an operation that the physical |
---|
24 | hardware will never attempt to do, so it won't interfere with the |
---|
25 | simulation's accuracy (i.e. we aren't abusing holes in the opcode |
---|
26 | map, for example). */ |
---|
27 | |
---|
28 | #include "../syscall.h" |
---|
29 | #include "memmodel.h" |
---|
30 | |
---|
31 | .macro sc,a |
---|
32 | sc2 \a,\a |
---|
33 | .endm |
---|
34 | |
---|
35 | .macro sc2,name,num |
---|
36 | .weak \name |
---|
37 | .global \name |
---|
38 | \name = 0x180 + \num |
---|
39 | .endm |
---|
40 | |
---|
41 | #define SC(n) sc2 n,SYS_##n |
---|
42 | |
---|
43 | sc2 _exit,SYS_exit |
---|
44 | SC (exit) |
---|
45 | SC (open) |
---|
46 | SC (close) |
---|
47 | SC (read) |
---|
48 | /* SC (write)*/ |
---|
49 | SC (fstat) |
---|
50 | SC (lseek) |
---|
51 | SC (kill) |
---|
52 | |
---|
53 | .weak isatty |
---|
54 | .global isatty |
---|
55 | isatty: |
---|
56 | .weak _isatty |
---|
57 | .global _isatty |
---|
58 | _isatty: |
---|
59 | MOV #1,R12 |
---|
60 | ret_ |
---|
61 | |
---|
62 | .weak getpid |
---|
63 | .global getpid |
---|
64 | getpid: |
---|
65 | MOV #42,R12 |
---|
66 | ret_ |
---|
67 | |
---|
68 | .weak gettimeofday |
---|
69 | .global gettimeofday |
---|
70 | gettimeofday: |
---|
71 | MOV #0,R12 |
---|
72 | ret_ |
---|
73 | .size gettimeofday , . - gettimeofday |
---|