repo_id
stringlengths
5
115
size
int64
590
5.01M
file_path
stringlengths
4
212
content
stringlengths
590
5.01M
stsp/newlib-ia16
1,673
libgloss/rx/crtn.S
/* Copyright (c) 2005 Red Hat Incorporated. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. The name of Red Hat Incorporated may not be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RED HAT INCORPORATED BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ .section .init,"ax" bsr.a _rx_run_preinit_array bsr.a _rx_run_init_array rts .global __rx_init_end __rx_init_end: .section .fini,"ax" rts .global __rx_fini_end __rx_fini_end: .text
stsp/newlib-ia16
1,658
libgloss/rx/abort.S
/* Copyright (c) 2005 Red Hat Incorporated. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. The name of Red Hat Incorporated may not be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RED HAT INCORPORATED BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "rxsys.h" .global _abort _abort: /* This is for debuggers. The simulator stops here too. */ brk mov #42, r1 SYSCALL(SYS_kill) /* Else, exit. */ bra.w __exit
stsp/newlib-ia16
1,507
libgloss/rx/time.S
/* Copyright (c) 2005 Red Hat Incorporated. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. The name of Red Hat Incorporated may not be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RED HAT INCORPORATED BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "rxsys.h" S(time)
stsp/newlib-ia16
5,102
libgloss/rx/crt0.S
/* Copyright (c) 2008, 2009, 2011 Red Hat Incorporated. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. The name of Red Hat Incorporated may not be used to endorse or promote products derived from this software without specific prior written permission. This software is provided by the copyright holders and contributors "AS IS" and any express or implied warranties, including, but not limited to, the implied warranties of merchantability and fitness for a particular purpose are disclaimed. In no event shall Red Hat incorporated be liable for any direct, indirect, incidental, special, exemplary, or consequential damages (including, but not limited to, procurement of substitute goods or services; loss of use, data, or profits; or business interruption) however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence or otherwise) arising in any way out of the use of this software, even if advised of the possibility of such damage. */ .text .global _start _start: .LFB2: mvtc #0, psw /* Enable the DN bit - this should have been done for us by the CPU reset, but it is best to make sure for ourselves. */ mvtc #0x100, fpsw mov #__stack, r0 mvtc #__vectors, intb /* Copy the .data section from ROM into RAM. */ mov #__datastart, r1 mov #__romdatastart, r2 mov #__romdatacopysize, r3 #ifdef __RX_DISALLOW_STRING_INSNS__ cmp #0, r3 beq 2f 1: mov.b [r2+], r5 mov.b r5, [r1+] sub #1, r3 bne 1b 2: #else smovf #endif /* Initialise the contents of the .bss section. */ mov #__bssstart, r1 mov #0, r2 mov #__bsssize, r3 sstr.l /* Initialize data pointer register(s). Note: The registers used here should agree with the definition of GP_BASE_REGNUM in gcc/config/rx/rx.h. Note: We are assuming that -mint-register has not been used when compiling the application. */ #ifdef _RX_PID /* Initialise the constant data pointer and small data pointers. */ mov #__pid_base, r13 mov #__gp, r12 #else /* Initialise the small data area pointer. */ mov #__gp, r13 #endif bsr.a __rx_init #ifdef PROFILE_SUPPORT /* Defined in gcrt0.S. */ mov # _start, r1 mov # _etext, r2 bsr.a __monstartup #endif mov #0, r1 /* argc */ mov #0, r2 /* argv */ mov #0, r3 /* envv */ bsr.a _main .LFE2: #ifdef PROFILE_SUPPORT mov r1, r13 ; Save return code. bsr.a __mcleanup mov r13, r1 #endif bsr.a _exit .global _rx_run_preinit_array .type _rx_run_preinit_array,@function _rx_run_preinit_array: mov #__preinit_array_start,r1 mov #__preinit_array_end,r2 bra.a _rx_run_inilist .global _rx_run_init_array .type _rx_run_init_array,@function _rx_run_init_array: mov #__init_array_start,r1 mov #__init_array_end,r2 mov #4, r3 bra.a _rx_run_inilist .global _rx_run_fini_array .type _rx_run_fini_array,@function _rx_run_fini_array: mov #__fini_array_start,r2 mov #__fini_array_end,r1 mov #-4, r3 /* fall through */ _rx_run_inilist: next_inilist: cmp r1,r2 beq.b done_inilist mov.l [r1],r4 cmp #-1, r4 beq.b skip_inilist cmp #0, r4 beq.b skip_inilist pushm r1-r3 jsr r4 popm r1-r3 skip_inilist: add r3,r1 bra.b next_inilist done_inilist: rts .section .init,"ax" .global __rx_init __rx_init: .section .fini,"ax" .global __rx_fini __rx_fini: bsr.a _rx_run_fini_array .section .rodata .balign 4 .global __pid_base .weak __pid_base __pid_base: .section .sdata .balign 4 .global __gp .weak __gp __gp: .section .data .global ___dso_handle .weak ___dso_handle ___dso_handle: .long 0 ;;; Provide Dwarf unwinding information that will help GDB stop ;;; backtraces at the right place. This is stolen from assembly ;;; code generated by GCC with -dA. .section .debug_frame,"",@progbits .Lframe0: .4byte .LECIE0-.LSCIE0 ; Length of Common Information Entry .LSCIE0: .4byte 0xffffffff ; CIE Identifier Tag .byte 0x1 ; CIE Version .ascii "\0" ; CIE Augmentation .uleb128 0x1 ; CIE Code Alignment Factor .sleb128 -1 ; CIE Data Alignment Factor .byte 0xd ; CIE RA Column .byte 0xc ; DW_CFA_def_cfa .uleb128 0xc .uleb128 0x3 .byte 0x8d ; DW_CFA_offset, column 0xd .uleb128 0x3 .p2align 2 .LECIE0: .LSFDE0: .4byte .LEFDE0-.LASFDE0 ; FDE Length .LASFDE0: .4byte .Lframe0 ; FDE CIE offset .4byte .LFB2 ; FDE initial location .4byte .LFE2-.LFB2 ; FDE address range .byte 0xf ; DW_CFA_def_cfa_expression .uleb128 1 ; length of expression .byte 0x30 ; DW_OP_lit0 .p2align 2 .LEFDE0: .text
stsp/newlib-ia16
1,508
libgloss/rx/utime.S
/* Copyright (c) 2005 Red Hat Incorporated. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. The name of Red Hat Incorporated may not be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RED HAT INCORPORATED BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "rxsys.h" S(utime)
stsp/newlib-ia16
1,508
libgloss/rx/close.S
/* Copyright (c) 2005 Red Hat Incorporated. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. The name of Red Hat Incorporated may not be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RED HAT INCORPORATED BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "rxsys.h" S(close)
stsp/newlib-ia16
1,593
libgloss/rx/isatty.S
/* Copyright (c) 2008, 2009 Red Hat Incorporated. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. The name of Red Hat Incorporated may not be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RED HAT INCORPORATED BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ .global __isatty __isatty: .weak _isatty _isatty: mov #1,r1 rts
stsp/newlib-ia16
1,508
libgloss/rx/lseek.S
/* Copyright (c) 2005 Red Hat Incorporated. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. The name of Red Hat Incorporated may not be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RED HAT INCORPORATED BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "rxsys.h" S(lseek)
stsp/newlib-ia16
1,508
libgloss/rx/write.S
/* Copyright (c) 2005 Red Hat Incorporated. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. The name of Red Hat Incorporated may not be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RED HAT INCORPORATED BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "rxsys.h" S(write)
stsp/newlib-ia16
1,507
libgloss/rx/open.S
/* Copyright (c) 2005 Red Hat Incorporated. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. The name of Red Hat Incorporated may not be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RED HAT INCORPORATED BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "rxsys.h" S(open)
stsp/newlib-ia16
1,507
libgloss/rx/argv.S
/* Copyright (c) 2005 Red Hat Incorporated. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. The name of Red Hat Incorporated may not be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RED HAT INCORPORATED BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "rxsys.h" S(argv)
stsp/newlib-ia16
1,509
libgloss/rx/getpid.S
/* Copyright (c) 2005 Red Hat Incorporated. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. The name of Red Hat Incorporated may not be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RED HAT INCORPORATED BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "rxsys.h" S(getpid)
stsp/newlib-ia16
1,584
libgloss/rx/exit.S
/* Copyright (c) 2005 Red Hat Incorporated. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. The name of Red Hat Incorporated may not be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RED HAT INCORPORATED BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "rxsys.h" .global __exit __exit: pushm r1-r2 bsr.a __rx_fini popm r1-r2 SYSCALL(SYS_exit)
stsp/newlib-ia16
1,507
libgloss/rx/link.S
/* Copyright (c) 2005 Red Hat Incorporated. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. The name of Red Hat Incorporated may not be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RED HAT INCORPORATED BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "rxsys.h" S(link)
stsp/newlib-ia16
1,508
libgloss/rx/chdir.S
/* Copyright (c) 2005 Red Hat Incorporated. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. The name of Red Hat Incorporated may not be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RED HAT INCORPORATED BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "rxsys.h" S(chdir)
stsp/newlib-ia16
2,945
libgloss/sparc/cygmon-crt0.S
/* * C startup code for the Fujitsu SPARClite demo board * * Copyright (c) 1995, 1996 Cygnus Support * * The authors hereby grant permission to use, copy, modify, distribute, * and license this software and its documentation for any purpose, provided * that existing copyright notices are retained in all copies and that this * notice is included verbatim in any distributions. No written agreement, * license, or royalty fee is required for any of the authorized uses. * Modifications to this software may be copyrighted by their authors * and need not follow the licensing terms described here, provided that * the new terms are clearly indicated on the first page of each file where * they apply. */ #include "asm.h" #ifdef TARGET_CPU_SPARC64 #define STACK_BIAS 2047 #define SAVE_SIZE -128 #else #define SAVE_SIZE -64 #endif .register %g2, #scratch .register %g3, #scratch .data .align 8 SYM(environ): ! this is the first address in the data section .long 0 SYM(argc): .long 0 .text .align 8 .globl SYM(start) .globl start SYM(start): start: /* see if the stack is already setup. if not, then default * to using the value of %sp as set by the ROM monitor */ sethi %hi(__stack), %g1 or %g1,%lo(__stack),%g1 cmp %g0,%g1 be 1f nop #ifdef STACK_BIAS sub %g1, STACK_BIAS, %g1 #endif mov %g1, %sp ! set the stack pointer mov 0, %fp 1: /* zero the bss section */ sethi %hi(__bss_start),%g2 or %g2,%lo(__bss_start),%g2 ! start of bss sethi %hi(_end),%g3 or %g3,%lo(_end),%g3 ! end of bss mov %g0,%g1 ! so std has two zeros zerobss: std %g0,[%g2] add %g2,8,%g2 cmp %g2,%g3 bleu,a zerobss nop /* * initialize target specific stuff. Only execute these * functions it they exist. */ init: sethi %hi(SYM(hardware_init_hook)), %g1 or %g1,%lo(SYM(hardware_init_hook)),%g1 cmp %g0,%g1 be 1f nop call SYM(hardware_init_hook) nop 1: sethi %hi(SYM(software_init_hook)), %g1 or %g1,%lo(SYM(software_init_hook)),%g1 cmp %g0,%g1 be 2f nop call SYM(software_init_hook) nop 2: set SYM(__sigtramp), %o0 call SYM(__install_signal_handler) nop set do_dtors,%o0 call SYM(atexit) nop call do_ctors nop set SYM(argc), %o0 call SYM(__getProgramArgs) nop mov %o0, %o1 set SYM(argc), %o0 ld [%o0], %o0 call SYM(main) nop /* call exit from the C library so atexit gets called, and the * C++ destructors get run. This calls our exit routine below * when it's done. */ call SYM(exit) nop do_ctors: save %sp,SAVE_SIZE,%sp set __CTOR_LIST__,%l0 our_entry: ld [%l0],%l1 add %l0,4,%l0 tst %l1 1: beq 2f nop ld [%l0],%l2 add %l0,4,%l0 call %l2 nop deccc %l1 b 1b nop 2: ret restore do_dtors: save %sp,SAVE_SIZE,%sp set __DTOR_LIST__,%l0 b our_entry nop
stsp/newlib-ia16
1,322
libgloss/sparc/crt0-701.S
/* crt0.S for the sparclet 701. At the moment, all the necessary syscalls are here. Convention has them in a separate file but libgloss is still in too much flux. */ .text .global start start: ! zero bss sethi %hi(_end), %o1 or %o1, %lo(_end), %o1 sethi %hi(_edata), %o0 or %o0, %lo (_edata), %o0 sub %o1, %o0, %o1 Lzero_bss: subcc %o1, 4, %o1 clr [%o0] bne Lzero_bss add %o0, 4, %o0 ! set up argc, argv, envp (?) ld [%sp+64], %o0 sll %o0, 2, %o2 add %o2, 4, %o2 add %sp, 68, %o1 add %o1, %o2, %o2 sethi %hi(_environ), %o3 st %o2, [%o3+%lo(_environ)] ! call main, exit call _main sub %sp, 32, %sp call _exit nop ! void _exit (int rc) .global __exit __exit: mov 1, %g1 ta 0 ! If that does not work, just loop forever. Lloop_forever: b Lloop_forever nop ! int _open (char *, int) .global _open _open: mov 5, %g1 ta 0 bcc Lnoerr nop b Lcerror nop ! int _close (int) .global _close _close: mov 6, %g1 ta 0 bcc Lnoerr nop b Lcerror nop ! int read (int, char *, int) .global _read _read: mov 3, %g1 ta 0 bcc Lnoerr nop b Lcerror nop ! int write (int, char *, int) .global _write _write: mov 4, %g1 ta 0 bcc Lnoerr nop b Lcerror nop Lnoerr: retl nop Lcerror: sethi %hi(__impure_ptr), %g1 st %o0, [%g1+%lo(__impure_ptr)] retl mov -1, %o0
stsp/newlib-ia16
1,842
libgloss/sparc/erc32-crt0.S
/* * This is based on the file srt0.s provided with the binary * distribution of the SPARC Instruction Simulator (SIS) found * at ftp://ftp.estec.esa.nl/pub/ws/wsd/erc32. */ #include "asm.h" .register %g2, #scratch .register %g3, #scratch .data .align 8 SYM(environ): .long 0 .text .globl SYM(start) SYM(start): sethi %hi(__stack), %g1 or %g1,%lo(__stack),%g1 mov %g1, %sp ! set the stack pointer mov %sp, %fp /* clear the bss */ sethi %hi(__bss_start),%g2 or %g2,%lo(__bss_start),%g2 ! start of bss sethi %hi(_end),%g3 or %g3,%lo(_end),%g3 ! end of bss mov %g0,%g1 ! so std has two zeros zerobss: std %g0,[%g2] add %g2,8,%g2 cmp %g2,%g3 bleu,a zerobss nop /* move data segment to proper location */ #if 0 relocd: set (_endtext),%g2 ! g2 = start of data in aout file set (_environ),%g4 ! g4 = start of where data should go set (_edata),%g3 ! g3 = end of where data should go subcc %g3, %g4, %g5 ! g5 = length of data subcc %g4, %g2, %g0 ! need to relocate data ? ble initok ld [%g4], %g6 subcc %g6, 1, %g0 be initok mvdata: subcc %g5, 8, %g5 ldd [%g2 + %g5], %g6 bg mvdata std %g6, [%g4 + %g5] initok: #endif call SYM(__fix_ctors) nop call SYM(main) nop /* call exit from the C library so atexit gets called, and the * C++ destructors get run. This calls our exit routine below * when it's done. */ call SYM(exit) nop .globl SYM(_exit) SYM(_exit): set 0xdeadd00d, %o1 ! Magic number for simulator. ta 0 ! Halt if _main returns ... nop
stsp/newlib-ia16
4,390
libgloss/sparc/crt0.S
/* * C startup code for the Fujitsu SPARClite demo board * * Copyright (c) 1995, 1996 Cygnus Support * * The authors hereby grant permission to use, copy, modify, distribute, * and license this software and its documentation for any purpose, provided * that existing copyright notices are retained in all copies and that this * notice is included verbatim in any distributions. No written agreement, * license, or royalty fee is required for any of the authorized uses. * Modifications to this software may be copyrighted by their authors * and need not follow the licensing terms described here, provided that * the new terms are clearly indicated on the first page of each file where * they apply. */ #include "asm.h" .register %g2, #scratch .register %g3, #scratch .data .align 8 .ascii "DaTa" ! this is the first address in the data section .long SYM(sdata) SYM(environ): .long 0 .text .align 8 .globl SYM(_start) SYM(_start): .globl SYM(start) SYM(start): /* see if the stack is already setup. if not, then default * to using the value of %sp as set by the ROM monitor */ sethi %hi(__stack), %g1 or %g1,%lo(__stack),%g1 cmp %g0,%g1 be 1f mov %g1, %sp ! set the stack pointer mov %sp, %fp 1: /* zero the bss section */ sethi %hi(__bss_start),%g2 or %g2,%lo(__bss_start),%g2 ! start of bss sethi %hi(_end),%g3 or %g3,%lo(_end),%g3 ! end of bss mov %g0,%g1 ! so std has two zeros zerobss: std %g0,[%g2] add %g2,8,%g2 cmp %g2,%g3 bleu,a zerobss nop /* * copy prom & trap vectors to sram. */ set 0x30000000, %l0 set 0xfff8, %l1 tst %l1 ! Set condition codes copyloop: ldd [%l1], %l2 std %l2, [%l0 + %l1] bg copyloop deccc 8, %l1 set 0x30000000, %l0 ! Base of new trap vector mov %l0, %tbr ! Install the new tbr set SYM(win_ovf_trap), %l1 ! Setup window overflow trap ldd [%l1], %l2 std %l2, [%l0 + 5 * 16] ldd [%l1 + 8], %l2 std %l2, [%l0 + 5 * 16 + 8] set SYM(win_unf_trap), %l1 ! Setup window underflow trap ldd [%l1], %l2 std %l2, [%l0 + 6 * 16] ldd [%l1 + 8], %l2 std %l2, [%l0 + 6 * 16 + 8] /* * Try enabling the FPU by setting EF. If that causes a trap, then we probably * don't have an FPU. */ ldd [%l0 + 2 * 16], %l4 ! Save original trap routine set SYM(no_fpu_trap), %l1 ! Install new one ldd [%l1], %l2 std %l2, [%l0 + 2 * 16] mov %psr, %l0 sethi %hi(0x1000), %l1 bset %l1, %l0 ! mov %l0, %psr std %l4, [2 * 16] ! Restore original trap routine /* * Move the data segment from it's ROM address to RAM where it * belongs. */ relocd: #if 0 /* This code is broken. FIXME */ set (_sdata),%g2 ! %g2 = start of data in aout file set SYM(environ),%g4 ! %g4 = actual data base address set (_edata),%g3 ! %g3 = end of where data should go subcc %g3, %g4, %g5 ! %g5 = length of data subcc %g4, %g2, %g0 ! need to relocate data ? ble init ld [%g4], %g6 subcc %g6, 1, %g0 be init mvdata: subcc %g5, 8, %g5 ldd [%g2 + %g5], %g6 bg mvdata #endif /* * initialize target specific stuff. Only execute these * functions it they exist. */ init: sethi %hi(SYM(hardware_init_hook)), %g1 or %g1,%lo(SYM(hardware_init_hook)),%g1 cmp %g0,%g1 be 1f nop call SYM(hardware_init_hook) nop 1: sethi %hi(SYM(software_init_hook)), %g1 or %g1,%lo(SYM(software_init_hook)),%g1 cmp %g0,%g1 be 2f nop call SYM(software_init_hook) nop 2: call SYM(main) nop /* call exit from the C library so atexit gets called, and the * C++ destructors get run. This calls our exit routine below * when it's done. */ call SYM(exit) nop /* * This should drop control back to the ROM monitor, if there is * one. */ .globl SYM(_exit) SYM(_exit): call 0 nop /* * Trap handlers. */ .align 8 SYM(win_ovf_trap): sethi %hi(SYM(win_ovf)), %l3 jmpl %lo(SYM(win_ovf))+%l3, %g0 mov %wim, %l0 nop SYM(win_unf_trap): sethi %hi(SYM(win_unf)), %l3 jmpl %lo(SYM(win_unf))+%l3, %g0 mov %wim, %l0 nop SYM(no_fpu_trap): ! Come here when no fpu exists. jmpl %l2, %g0 ! This just skips the rett %l2+4 ! offending instruction.
stsp/newlib-ia16
19,228
libgloss/sparc/traps.S
/* * Copyright (c) 1995, 1996, 1998 Cygnus Support * * The authors hereby grant permission to use, copy, modify, distribute, * and license this software and its documentation for any purpose, provided * that existing copyright notices are retained in all copies and that this * notice is included verbatim in any distributions. No written agreement, * license, or royalty fee is required for any of the authorized uses. * Modifications to this software may be copyrighted by their authors * and need not follow the licensing terms described here, provided that * the new terms are clearly indicated on the first page of each file where * they apply. */ #include "asm.h" #include "slite.h" .register %g2, #scratch .register %g3, #scratch .text .align 4 /* * The trap table has to be the first code in a boot PROM. But because * the Memory Configuration comes up thinking we only have 4K of PROM, we * cannot have a full trap table and still have room left over to * reprogram the Memory Configuration register correctly. This file * uses an abbreviated trap which has every entry which might be used * before RTEMS installs its own trap table. */ .globl _trap_table _trap_table: TRAP(SYM(ercinit)); ! 00 reset trap BAD_TRAP; ! 01 instruction access exception TRAP(SYM(no_fpu)); ! 02 illegal instruction BAD_TRAP; ! 03 privileged instruction BAD_TRAP; ! 04 fp disabled TRAP(SYM(win_overflow)); ! 05 window overflow TRAP(SYM(win_underflow)); ! 06 window underflow BAD_TRAP; ! 07 memory address not aligned BAD_TRAP; ! 08 fp exception BAD_TRAP; ! 09 data access exception BAD_TRAP; ! 0A tag overflow /* Trap levels from 0B to 0x10 are not defined (used for MEC init) */ SYM(ercinit): sethi %hi(_ERC32_MEC), %g1 ! 0B sethi %hi(0x001C1000), %g2 or %g1,%lo(0x001C1000),%g1 st %g2, [%g1 + 0x10] st %g0, [%g1 + 0x18] ! 0C nop nop nop TRAP(SYM(hard_reset)); ! 0D undefined BAD_TRAP; ! 0E undefined BAD_TRAP; ! 0F undefined BAD_TRAP; ! 10 undefined /* * ERC32 defined traps */ BAD_TRAP; ! 11 masked errors BAD_TRAP; ! 12 external 1 BAD_TRAP; ! 13 external 2 BAD_TRAP; ! 14 UART A RX/TX BAD_TRAP; ! 15 UART B RX/TX BAD_TRAP; ! 16 correctable memory error BAD_TRAP; ! 17 UART error BAD_TRAP; ! 18 DMA access error BAD_TRAP; ! 19 DMA timeout BAD_TRAP; ! 1A external 3 BAD_TRAP; ! 1B external 4 BAD_TRAP; ! 1C general purpose timer BAD_TRAP; ! 1D real time clock BAD_TRAP; ! 1E external 5 BAD_TRAP; ! 1F watchdog timeout BAD_TRAP; BAD_TRAP; BAD_TRAP; BAD_TRAP; ! 20 - 23 undefined BAD_TRAP; ! 24 cp_disabled BAD_TRAP; BAD_TRAP; BAD_TRAP; ! 25 - 27 undefined BAD_TRAP; ! 28 cp_exception BAD_TRAP; BAD_TRAP; BAD_TRAP; ! 29 - 2B undefined BAD_TRAP; BAD_TRAP; BAD_TRAP; BAD_TRAP; ! 2C - 2F undefined BAD_TRAP; BAD_TRAP; BAD_TRAP; BAD_TRAP; ! 30 - 33 undefined BAD_TRAP; BAD_TRAP; BAD_TRAP; BAD_TRAP; ! 34 - 37 undefined BAD_TRAP; BAD_TRAP; BAD_TRAP; BAD_TRAP; ! 38 - 3B undefined BAD_TRAP; BAD_TRAP; BAD_TRAP; BAD_TRAP; ! 3C - 3F undefined BAD_TRAP; BAD_TRAP; BAD_TRAP; BAD_TRAP; ! 40 - 43 undefined BAD_TRAP; BAD_TRAP; BAD_TRAP; BAD_TRAP; ! 44 - 47 undefined BAD_TRAP; BAD_TRAP; BAD_TRAP; BAD_TRAP; ! 48 - 4B undefined BAD_TRAP; BAD_TRAP; BAD_TRAP; BAD_TRAP; ! 4C - 4F undefined BAD_TRAP; BAD_TRAP; BAD_TRAP; BAD_TRAP; ! 50 - 53 undefined BAD_TRAP; BAD_TRAP; BAD_TRAP; BAD_TRAP; ! 54 - 57 undefined BAD_TRAP; BAD_TRAP; BAD_TRAP; BAD_TRAP; ! 58 - 5B undefined BAD_TRAP; BAD_TRAP; BAD_TRAP; BAD_TRAP; ! 5C - 5F undefined BAD_TRAP; BAD_TRAP; BAD_TRAP; BAD_TRAP; ! 60 - 63 undefined BAD_TRAP; BAD_TRAP; BAD_TRAP; BAD_TRAP; ! 64 - 67 undefined BAD_TRAP; BAD_TRAP; BAD_TRAP; BAD_TRAP; ! 68 - 6B undefined BAD_TRAP; BAD_TRAP; BAD_TRAP; BAD_TRAP; ! 6C - 6F undefined BAD_TRAP; BAD_TRAP; BAD_TRAP; BAD_TRAP; ! 70 - 73 undefined BAD_TRAP; BAD_TRAP; BAD_TRAP; BAD_TRAP; ! 74 - 77 undefined BAD_TRAP; BAD_TRAP; BAD_TRAP; BAD_TRAP; ! 78 - 7B undefined BAD_TRAP; BAD_TRAP; BAD_TRAP; BAD_TRAP; ! 7C - 7F undefined /* * Software traps * * NOTE: At the risk of being redundant... this is not a full * table. The setjmp on the SPARC requires a window flush trap * handler and RTEMS will preserve the entries that were * installed before. */ SOFT_TRAP; ! 80 #if 0 SOFT_TRAP; ! 81 #else TRAP(SYM(trap_low)) ! 81 #endif SOFT_TRAP; ! 82 TRAP(SYM(win_flush)); ! 83 flush windows SW trap SOFT_TRAP; SOFT_TRAP; SOFT_TRAP; SOFT_TRAP; ! 84 - 87 SOFT_TRAP; SOFT_TRAP; SOFT_TRAP; SOFT_TRAP; ! 88 - 8B SOFT_TRAP; SOFT_TRAP; SOFT_TRAP; SOFT_TRAP; ! 8C - 8F SOFT_TRAP; SOFT_TRAP; SOFT_TRAP; SOFT_TRAP; ! 90 - 93 SOFT_TRAP; SOFT_TRAP; SOFT_TRAP; SOFT_TRAP; ! 94 - 97 SOFT_TRAP; SOFT_TRAP; SOFT_TRAP; SOFT_TRAP; ! 98 - 9B SOFT_TRAP; SOFT_TRAP; SOFT_TRAP; SOFT_TRAP; ! 9C - 9F SOFT_TRAP; SOFT_TRAP; SOFT_TRAP; SOFT_TRAP; ! A0 - A3 SOFT_TRAP; SOFT_TRAP; SOFT_TRAP; SOFT_TRAP; ! A4 - A7 SOFT_TRAP; SOFT_TRAP; SOFT_TRAP; SOFT_TRAP; ! A8 - AB SOFT_TRAP; SOFT_TRAP; SOFT_TRAP; SOFT_TRAP; ! AC - AF SOFT_TRAP; SOFT_TRAP; SOFT_TRAP; SOFT_TRAP; ! B0 - B3 SOFT_TRAP; SOFT_TRAP; SOFT_TRAP; SOFT_TRAP; ! B4 - B7 SOFT_TRAP; SOFT_TRAP; SOFT_TRAP; SOFT_TRAP; ! B8 - BB SOFT_TRAP; SOFT_TRAP; SOFT_TRAP; SOFT_TRAP; ! BC - BF SOFT_TRAP; SOFT_TRAP; SOFT_TRAP; SOFT_TRAP; ! C0 - C3 SOFT_TRAP; SOFT_TRAP; SOFT_TRAP; SOFT_TRAP; ! C4 - C7 SOFT_TRAP; SOFT_TRAP; SOFT_TRAP; SOFT_TRAP; ! C8 - CB SOFT_TRAP; SOFT_TRAP; SOFT_TRAP; SOFT_TRAP; ! CC - CF SOFT_TRAP; SOFT_TRAP; SOFT_TRAP; SOFT_TRAP; ! D0 - D3 SOFT_TRAP; SOFT_TRAP; SOFT_TRAP; SOFT_TRAP; ! D4 - D7 SOFT_TRAP; SOFT_TRAP; SOFT_TRAP; SOFT_TRAP; ! D8 - DB SOFT_TRAP; SOFT_TRAP; SOFT_TRAP; SOFT_TRAP; ! DC - DF SOFT_TRAP; SOFT_TRAP; SOFT_TRAP; SOFT_TRAP; ! E0 - E3 SOFT_TRAP; SOFT_TRAP; SOFT_TRAP; SOFT_TRAP; ! E4 - E7 SOFT_TRAP; SOFT_TRAP; SOFT_TRAP; SOFT_TRAP; ! E8 - EB SOFT_TRAP; SOFT_TRAP; SOFT_TRAP; SOFT_TRAP; ! EC - EF SOFT_TRAP; SOFT_TRAP; SOFT_TRAP; SOFT_TRAP; ! F0 - F3 SOFT_TRAP; SOFT_TRAP; SOFT_TRAP; SOFT_TRAP; ! F4 - F7 SOFT_TRAP; SOFT_TRAP; SOFT_TRAP; SOFT_TRAP; ! F8 - FB SOFT_TRAP; SOFT_TRAP; SOFT_TRAP; SOFT_TRAP; ! FC - FF /* * Startup code for standalone system. Wash IU and FPU (if present) * registers. The registers have to be written to initiate the parity * bits. */ .globl SYM(hard_reset) SYM(hard_reset): sethi %hi(0x01FE0),%o0 or %o0,%lo(0x01FE0),%o0 mov %o0, %psr ! Set valid PSR nop mov %g0, %wim ! Set window invalid mask register mov %g0, %y ! Init Y-register nop sethi %hi(SYM(hard_reset)), %g1 mov %g1, %tbr ! Set TBR sethi %hi(SP_INIT),%sp or %g0, 1, %o0 ld [%g0], %f0 ! Check if FPU is present tst %o0 bz fixiu nop ba fixfpu ! FPU disabled trap address clr %i0 jmpl %l2, %g0 rett %l2 + 4 nop ! Wash register files (fix for 90C601E & 90C602E) fixfpu: ld [%g0], %f0 ld [%g0], %f1 ld [%g0], %f2 ld [%g0], %f3 ld [%g0], %f4 ld [%g0], %f5 ld [%g0], %f6 ld [%g0], %f7 ld [%g0], %f8 ld [%g0], %f9 ld [%g0], %f10 ld [%g0], %f11 ld [%g0], %f12 ld [%g0], %f13 ld [%g0], %f14 ld [%g0], %f15 ld [%g0], %f16 ld [%g0], %f17 ld [%g0], %f18 ld [%g0], %f19 ld [%g0], %f20 ld [%g0], %f21 ld [%g0], %f22 ld [%g0], %f23 ld [%g0], %f24 ld [%g0], %f25 ld [%g0], %f26 ld [%g0], %f27 ld [%g0], %f28 ld [%g0], %f29 ld [%g0], %f30 ld [%g0], %f31 fixiu: clr %g1 clr %g2 clr %g3 clr %g4 clr %g5 clr %g6 clr %g7 set 8,%g1 wl0: clr %i0 clr %i1 clr %i2 clr %i3 clr %i4 clr %i5 clr %i6 clr %i7 clr %l0 clr %l1 clr %l2 clr %l3 clr %l4 clr %l5 clr %l6 clr %l7 save subcc %g1, 1, %g1 bne wl0 nop ! ! Start the real-time clock with a tick of 150 clocks ! rtc: set 0x1f80000, %l0 ! MEC register base set 149, %l1 st %l1, [%l0 + 0x84] ! RTC scaler = 149 set 0x0d00, %l1 st %l1, [%l0 + 0x98] ! Start RTC st %g0, [%l0 + 0x64] ! Disable watchdog for now ld [%l0], %g1 or %g1, 1, %g1 st %g1, [%l0] ! Enable power-down mode _init: set PSR_INIT, %g1 ! Initialize psr mov %g1, %psr set WIM_INIT, %g1 ! Initialize WIM mov %g1, %wim set _trap_table, %g1 ! Initialize TBR mov %g1, %tbr nop;nop;nop set PSR_INIT, %g1 wr %g1, 0x20, %psr ! enable traps nop; nop; nop; call SYM(start) nop /* * Register window overflow handler. Come here when save would move us * into the invalid window. This routine runs with traps disabled, and * must be careful not to touch the condition codes, as PSR is never * restored. * * We are called with %l0 = wim, %l1 = pc, %l2 = npc */ .globl SYM(win_overflow) SYM(win_overflow): mov %g1, %l3 ! Save g1, we use it to hold the wim srl %l0, 1, %g1 ! Rotate wim right sll %l0, NUMBER_OF_REGISTER_WINDOWS - 1, %l0 or %l0, %g1, %g1 save %g0, %g0, %g0 ! Slip into next window mov %g1, %wim ! Install the new wim nop nop nop std %l0, [%sp + 0 * 4] ! save L & I registers std %l2, [%sp + 2 * 4] std %l4, [%sp + 4 * 4] std %l6, [%sp + 6 * 4] std %i0, [%sp + 8 * 4] std %i2, [%sp + 10 * 4] std %i4, [%sp + 12 * 4] std %i6, [%sp + 14 * 4] restore ! Go back to trap window. mov %l3, %g1 ! Restore %g1 jmpl %l1, %g0 rett %l2 /* * Register window underflow handler. Come here when restore would move us * into the invalid window. This routine runs with traps disabled, and * must be careful not to touch the condition codes, as PSR is never * restored. * * We are called with %l0 = wim, %l1 = pc, %l2 = npc */ .globl SYM(win_underflow) SYM(win_underflow): sll %l0, 1, %l3 ! Rotate wim left srl %l0, NUMBER_OF_REGISTER_WINDOWS - 1, %l0 or %l0, %l3, %l0 mov %l0, %wim ! Install the new wim restore ! Users window restore ! His callers window ldd [%sp + 0 * 4], %l0 ! restore L & I registers ldd [%sp + 2 * 4], %l2 ldd [%sp + 4 * 4], %l4 ldd [%sp + 6 * 4], %l6 ldd [%sp + 8 * 4], %i0 ldd [%sp + 10 * 4], %i2 ldd [%sp + 12 * 4], %i4 ldd [%sp + 14 * 4], %i6 save %g0, %g0, %g0 ! Back to trap window save %g0, %g0, %g0 jmpl %l1, %g0 rett %l2 /* * Register window flush handler, triggered by a "ta 3" instruction. * We are called with %l0 = wim, %l1 = pc, %l2 = npc */ .globl SYM(win_flush) SYM(win_flush): mov %psr, %l0 or %l0,0xf00,%l3 ! Disable interrupts mov %l3,%psr nop nop nop mov %wim, %l3 srl %l3, %l0, %l4 ! wim >> cwp cmp %l4, 1 bne flush_window_fine ! Branch if not in the invalid window nop /* Handle window overflow. We can't trap here. */ mov %g1, %l4 ! Save g1, we use it to hold the wim srl %l3, 1, %g1 ! Rotate wim right sll %l3, NUMBER_OF_REGISTER_WINDOWS - 1, %l3 or %l3, %g1, %g1 mov %g0, %wim ! Clear wim so that subsequent save nop ! wont trap nop nop save %g0, %g0, %g0 ! Slip into next window mov %g1, %wim ! Install the new wim std %l0, [%sp + 0 * 4] ! save L & I registers std %l2, [%sp + 2 * 4] std %l4, [%sp + 4 * 4] std %l6, [%sp + 6 * 4] std %i0, [%sp + 8 * 4] std %i2, [%sp + 10 * 4] std %i4, [%sp + 12 * 4] std %i6, [%sp + 14 * 4] restore ! Go back to trap window. mov %l4, %g1 ! Restore %g1 flush_window_fine: mov %psr,%l5 ! enable traps or %l5,0x20,%l5 mov %l5, %psr nop nop nop set save_buf,%l5 st %l2,[%l5] ! The stack pointer currently contains a bogus value [when a trap ! occurs CWP is decremented and points to an unused window]. ! Give it something useful before we flush every window. ! This does what a "save %sp,-64,$sp" would, except that CWP has ! already been decremented. add %fp, -64, %sp save %sp, -64, %sp ! Flush user register window to stack save %sp, -64, %sp save %sp, -64, %sp save %sp, -64, %sp save %sp, -64, %sp save %sp, -64, %sp save %sp, -64, %sp save %sp, -64, %sp restore restore restore restore restore restore restore restore restore ! Make sure we have a valid window save %g0, %g0, %g0 set save_buf, %l2 ! Get our return address back ld [%l2],%l2 mov %psr,%l5 ! disable traps for rett andn %l5,0x20,%l5 mov %l5,%psr nop nop nop jmpl %l2, %g0 rett %l2+4 /* * Read the TBR. */ .globl SYM(rdtbr) SYM(rdtbr): mov %tbr, %o0 nop retl nop /* * Read the psr */ .globl SYM(read_psr) SYM(read_psr): mov %psr, %o0 nop retl nop /* * Write the PSR. */ .globl SYM(write_psr) SYM(write_psr): mov %i0, %psr nop nop nop retl nop /* * Come here when no fpu exists. This just skips the offending * instruction. */ .globl SYM(no_fpu) SYM(no_fpu): jmpl %l2, %g0 rett %l2+4 .globl SYM(fltr_proto) .align 4 SYM(fltr_proto): ! First level trap routine prototype sethi 0, %l0 jmpl 0+%l0, %g0 nop nop /* * Trap handler for memory errors. This just sets mem_err to be * non-zero. It assumes that l1 is non-zero. This should be safe, * as it is doubtful that 0 would ever contain code that could mem * fault. This routine will skip past the faulting instruction after * setting mem_err. */ .globl SYM(fltr_set_mem_err) SYM(fltr_set_mem_err): sethi %hi(SYM(mem_err)), %l0 st %l1, [%l0 + %lo(SYM(mem_err))] jmpl %l2, %g0 rett %l2+4 .data .align 4 .ascii "DaTa" .long SYM(sdata) in_trap_handler: .word 0 save_buf: .word 0 /* place to save %g1 */ .word 0 /* place to save %g2 */ .text .align 4 /* * This function is called when any SPARC trap (except window overflow * or underflow) occurs. It makes sure that the invalid register * window is still available before jumping into C code. It will also * restore the world if you return from handle_exception. */ .globl SYM(trap_low) SYM(trap_low): mov %psr, %l0 mov %wim, %l3 srl %l3, %l0, %l4 ! wim >> cwp cmp %l4, 1 bne window_fine ! Branch if not in the invalid window nop mov %g1, %l4 ! Save g1, we use it to hold the wim srl %l3, 1, %g1 ! Rotate wim right sll %l3, 8-1, %l5 or %l5, %g1, %g1 save %g0, %g0, %g0 ! Slip into next window mov %g1, %wim ! Install the new wim std %l0, [%sp + 0 * 4] ! save L & I registers std %l2, [%sp + 2 * 4] std %l4, [%sp + 4 * 4] std %l6, [%sp + 6 * 4] std %i0, [%sp + 8 * 4] std %i2, [%sp + 10 * 4] std %i4, [%sp + 12 * 4] std %i6, [%sp + 14 * 4] restore ! Go back to trap window. mov %l4, %g1 ! Restore g1 window_fine: sethi %hi(in_trap_handler), %l4 ld [%lo(in_trap_handler) + %l4], %l5 tst %l5 bg recursive_trap inc %l5 /* use the stack we set in the linker script */ sethi %hi(__trap_stack), %l6 or %l6,%lo(__trap_stack),%l6 mov %l6, %sp ! set the stack pointer recursive_trap: st %l5, [%lo(in_trap_handler) + %l4] sub %sp,(16+1+6+1+72)*4,%sp ! Make room for input & locals ! + hidden arg + arg spill ! + doubleword alignment ! + registers[72] local var std %g0, [%sp + (24 + 0) * 4] ! registers[Gx] std %g2, [%sp + (24 + 2) * 4] std %g4, [%sp + (24 + 4) * 4] std %g6, [%sp + (24 + 6) * 4] std %i0, [%sp + (24 + 8) * 4] ! registers[Ox] std %i2, [%sp + (24 + 10) * 4] std %i4, [%sp + (24 + 12) * 4] std %i6, [%sp + (24 + 14) * 4] ! F0->F31 not implemented mov %y, %l4 mov %tbr, %l5 st %l4, [%sp + (24 + 64) * 4] ! Y st %l0, [%sp + (24 + 65) * 4] ! PSR st %l3, [%sp + (24 + 66) * 4] ! WIM st %l5, [%sp + (24 + 67) * 4] ! TBR st %l1, [%sp + (24 + 68) * 4] ! PC st %l2, [%sp + (24 + 69) * 4] ! NPC ! CPSR and FPSR not implemented or %l0, 0xf20, %l4 mov %l4, %psr ! Turn on traps, disable interrupts call SYM(handle_exception) add %sp, 24 * 4, %o0 ! Pass address of registers /* Reload all of the registers that aren't on the stack */ ld [%sp + (24 + 1) * 4], %g1 ! registers[Gx] ldd [%sp + (24 + 2) * 4], %g2 ldd [%sp + (24 + 4) * 4], %g4 ldd [%sp + (24 + 6) * 4], %g6 ldd [%sp + (24 + 8) * 4], %i0 ! registers[Ox] ldd [%sp + (24 + 10) * 4], %i2 ldd [%sp + (24 + 12) * 4], %i4 ldd [%sp + (24 + 14) * 4], %i6 ldd [%sp + (24 + 64) * 4], %l0 ! Y & PSR ldd [%sp + (24 + 68) * 4], %l2 ! PC & NPC restore ! Ensure that previous window is valid save %g0, %g0, %g0 ! by causing a window_underflow trap mov %l0, %y mov %l1, %psr ! Make sure that traps are disabled ! for rett sethi %hi(in_trap_handler), %l4 ld [%lo(in_trap_handler) + %l4], %l5 dec %l5 st %l5, [%lo(in_trap_handler) + %l4] jmpl %l2, %g0 ! Restore old PC rett %l3 ! Restore old nPC
stsp/newlib-ia16
19,048
libgloss/arm/cpu-init/rdimon-aem.S
/* Copyright (c) 2005-2013 ARM Ltd. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. The name of the company may not be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY ARM LTD ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ARM LTD BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* This file gives a basic initialisation of a Cortex-A series core. It is the bare minimum required to get Cortex-A core running with a semihosting interface. It sets up a basic 1:1 phsyical address to virtual address mapping; turns the MMU on; enables branch prediction; activates any integrated caches; enables the Advanced SIMD and VFP co-processors; and installs basic exception handlers. It does not handle peripherals, and assumes all memory is Normal. It does not change processor state from the startup privilege and security level. This has only been tested to work in ARM state. By default it assumes exception vectors are located from address 0. However, if this is not true they can be moved by defining the _rdimon_vector_base symbol. For example if you have HIVECS enabled you may pass --defsym _rdimon_vector_base=0xffff0000 on the linker command line. */ /* __ARM_ARCH_PROFILE is defined from GCC 4.8 onwards, however __ARM_ARCH_7A has been defined since 4.2 onwards, which is when v7-a support was added and hence 'A' profile support was added in the compiler. Allow for this file to be built with older compilers. */ #if defined(__ARM_ARCH_7A__) || (__ARM_ARCH_PROFILE == 'A') .syntax unified .arch armv7-a .arm @ CPU Initialisation .globl _rdimon_hw_init_hook .type _rdimon_hw_init_hook, %function _rdimon_hw_init_hook: @ Only run the code on CPU 0 - otherwise spin mrc 15, 0, r4, cr0, cr0, 5 @ Read MPIDR ands r4, r4, #15 spin: bne spin mov r10, lr @ Save LR for final return #ifdef __ARMEB__ @ Setup for Big Endian setend be mrc 15, 0, r4, cr1, cr0, 0 @ Read SCTLR orr r4, r4, #(1<<25) @ Switch to Big Endian (Set SCTLR.EE) mcr 15, 0, r4, cr1, cr0, 0 @ Write SCTLR #else @ Setup for Little Endian setend le mrc 15, 0, r4, cr1, cr0, 0 @ Read SCTLR bic r4, r4, #(1<<25) @ Switch to LE (unset SCTLR.EE) mcr 15, 0, r4, cr1, cr0, 0 @ Write SCTLR #endif bl is_a15_a7 @ For Cortex-A15 and Cortex-A7 only: @ Write zero into the ACTLR to turn everything on. itt eq moveq r4, #0 mcreq 15, 0, r4, c1, c0, 1 isb @ For Cortex-A15 and Cortex-A7 only: @ Set ACTLR:SMP bit before enabling the caches and MMU, @ or performing any cache and TLB maintenance operations. ittt eq mrceq 15, 0, r4, c1, c0, 1 @ Read ACTLR orreq r4, r4, #(1<<6) @ Enable ACTLR:SMP mcreq 15, 0, r4, c1, c0, 1 @ Write ACTLR isb @ Setup for exceptions being taken to Thumb/ARM state mrc 15, 0, r4, cr1, cr0, 0 @ Read SCTLR #if defined(__thumb__) orr r4, r4, #(1 << 30) @ Enable SCTLR.TE #else bic r4, r4, #(1 << 30) @ Disable SCTLR.TE #endif mcr 15, 0, r4, cr1, cr0, 0 @ Write SCTLR bl __reset_caches mrc 15, 0, r4, cr1, cr0, 0 @ Read SCTLR orr r4, r4, #(1<<22) @ Enable unaligned mode bic r4, r4, #2 @ Disable alignment faults bic r4, r4, #1 @ Disable MMU mcr 15, 0, r4, cr1, cr0, 0 @ Write SCTLR mov r4, #0 mcr 15, 0, r4, cr8, cr7, 0 @ Write TLBIALL - Invaliidate unified @ TLB @ Setup MMU Primary table P=V mapping. mvn r4, #0 mcr 15, 0, r4, cr3, cr0, 0 @ Write DACR mov r4, #0 @ Always use TTBR0, no LPAE mcr 15, 0, r4, cr2, cr0, 2 @ Write TTBCR adr r4, page_table_addr @ Load the base for vectors ldr r4, [r4] mrc p15, 0, r0, c0, c0, 5 @ read MPIDR tst r0, #0x80000000 @ bis[31] @ Set page table flags - there are two page table flag formats for the @ architecture. For systems without multiprocessor extensions we use 0x1 @ which is Inner cacheable/Outer non-cacheable. For systems with @ multiprocessor extensions we use 0x59 which is Inner/Outer write-back, @ no write-allocate, and cacheable. See the ARMARM-v7AR for more details. it ne addne r4, r4, #0x58 add r4, r4, #1 mcr 15, 0, r4, cr2, cr0, 0 @ Write TTBR0 mov r0, #34 @ 0x22 @ TR0 and TR1 - normal memory orr r0, r0, #(1 << 19) @ Shareable mcr 15, 0, r0, cr10, cr2, 0 @ Write PRRR movw r0, #0x33 movt r0, #0x33 mcr 15, 0, r0, cr10, cr2, 1 @ Write NMRR mrc 15, 0, r0, cr1, cr0, 0 @ Read SCTLR bic r0, r0, #(1 << 28) @ Clear TRE bit mcr 15, 0, r0, cr1, cr0, 0 @ Write SCTLR @ Now install the vector code - we move the Vector code from where it is @ in the image to be based at _rdimon_vector_base. We have to do this copy @ as the code is all PC-relative. We actually cheat and do a BX <reg> so @ that we are at a known address relatively quickly and have to move as @ little code as possible. mov r7, #(VectorCode_Limit - VectorCode) adr r5, VectorCode adr r6, vector_base_addr @ Load the base for vectors ldr r6, [r6] copy_loop: @ Do the copy ldr r4, [r5], #4 str r4, [r6], #4 subs r7, r7, #4 bne copy_loop mrc 15, 0, r4, cr1, cr0, 0 @ Read SCTLR bic r4, r4, #0x1000 @ Disable I Cache bic r4, r4, #4 @ Disable D Cache orr r4, r4, #1 @ Enable MMU bic r4, r4, #(1 << 28) @ Clear TRE bit mcr 15, 0, r4, cr1, cr0, 0 @ Write SCTLR mrc 15, 0, r4, cr1, cr0, 2 @ Read CPACR orr r4, r4, #0x00f00000 @ Turn on VFP Co-procs bic r4, r4, #0x80000000 @ Clear ASEDIS bit mcr 15, 0, r4, cr1, cr0, 2 @ Write CPACR isb mov r4, #0 mcr 15, 0, r4, cr7, cr5, 4 @ Flush prefetch buffer mrc 15, 0, r4, cr1, cr0, 2 @ Read CPACR ubfx r4, r4, #20, #4 @ Extract bits [20, 23) cmp r4, #0xf @ If not all set then the CPU does not itt eq @ have FP or Advanced SIMD. moveq r4, #0x40000000 @ Enable FP and Advanced SIMD mcreq 10, 7, r4, cr8, cr0, 0 @ vmsr fpexc, r4 skip_vfp_enable: bl __enable_caches @ Turn caches on bx r10 @ Return to CRT startup routine @ This enable us to be more precise about which caches we want init_cpu_client_enable_dcache: init_cpu_client_enable_icache: mov r0, #1 bx lr vector_base_addr: .word _rdimon_vector_base .weak _rdimon_vector_base page_table_addr: .word page_tables @ Vector code - must be PIC and in ARM state. VectorCode: b vector_reset b vector_undef b vector_swi b vector_prefetch b vector_dataabt b vector_reserved b vector_irq b vector_fiq vector_reset: adr sp, vector_sp_base push {r0, r1, r2, r3, r4, r5, r6, r7, r8, r9, sl, fp, ip, lr} mov r4, #0 b vector_common vector_undef: adr sp, vector_sp_base push {r0, r1, r2, r3, r4, r5, r6, r7, r8, r9, sl, fp, ip, lr} mov r4, #1 b vector_common vector_swi: adr sp, vector_sp_base push {r0, r1, r2, r3, r4, r5, r6, r7, r8, r9, sl, fp, ip, lr} mov r4, #2 b vector_common vector_prefetch: adr sp, vector_sp_base push {r0, r1, r2, r3, r4, r5, r6, r7, r8, r9, sl, fp, ip, lr} mov r4, #3 b vector_common vector_dataabt: adr sp, vector_sp_base push {r0, r1, r2, r3, r4, r5, r6, r7, r8, r9, sl, fp, ip, lr} mov r4, #4 b vector_common vector_reserved: adr sp, vector_sp_base push {r0, r1, r2, r3, r4, r5, r6, r7, r8, r9, sl, fp, ip, lr} mov r4, #5 b vector_common vector_irq: adr sp, vector_sp_base push {r0, r1, r2, r3, r4, r5, r6, r7, r8, r9, sl, fp, ip, lr} mov r4, #6 b vector_common vector_fiq: adr sp, vector_sp_base push {r0, r1, r2, r3, r4, r5, r6, r7, r8, r9, sl, fp, ip, lr} mov r4, #7 b vector_common vector_common: adr r1, vector_common_adr @ Find where we're going to ldr r1, [r1] bx r1 @ And branch there vector_common_adr: .word vector_common_2 @ Common handling code @ Vector stack .p2align 3 @ Align to 8 byte boundary boundary to @ keep ABI compatibility .fill 32, 4, 0 @ 32-entry stack is enough for vector @ handlers. vector_sp_base: VectorCode_Limit: @ End of PIC code for vectors @ Common Handling of vectors .type vector_common_2, %function vector_common_2: mrs r1, APSR mrs r2, SPSR push {r1, r2} @ Save PSRs @ Output the vector we have caught bl out_nl adr r0, which_vector bl out_string adr r0, vector_names mov r1, #11 mla r0, r4, r1, r0 bl out_string bl out_nl @ Dump the registers adrl r6, register_names mov r7, #0 dump_r_loop: mov r0, r6 bl out_string add r6, r6, #6 ldr r0, [sp, r7, lsl #2] bl out_word bl out_nl add r7, r7, #1 cmp r7, #16 blt dump_r_loop adr r0, end bl out_string @ And exit mov r0, #24 orr r1, r4, #0x20000 svc 0x00123456 @ Output the string in r0 out_string: push {lr} mov r1, r0 mov r0, #4 svc 0x00123456 pop {pc} @ Output a New-line out_nl: mov r0, #10 @ Fallthrough @ Output the character in r0 out_char: push {lr} strb r0, [sp, #-4]! mov r0, #3 mov r1, sp svc 0x00123456 add sp, sp, #4 pop {pc} @ Output the value of r0 as a hex-word out_word: push {r4, r5, r6, lr} mov r4, r0 mov r5, #28 adr r6, hexchars word_loop: lsr r0, r4, r5 and r0, r0, #15 ldrb r0, [r6, r0] bl out_char subs r5, r5, #4 bpl word_loop pop {r4, r5, r6, pc} hexchars: .ascii "0123456789abcdef" which_vector: .asciz "Hit vector:" end: .asciz "End.\n" vector_names: .asciz "reset " .asciz "undef " .asciz "swi " .asciz "prefetch " .asciz "data abort" .asciz "reserved " .asciz "irq " .asciz "fiq " register_names: .asciz "apsr " .asciz "spsr " .asciz "r0 " .asciz "r1 " .asciz "r2 " .asciz "r3 " .asciz "r4 " .asciz "r5 " .asciz "r6 " .asciz "r7 " .asciz "r8 " .asciz "r9 " .asciz "r10 " .asciz "r11 " .asciz "r12 " .asciz "r14 " .p2align 3 @ Enable the caches __enable_caches: mov r0, #0 mcr 15, 0, r0, cr8, cr7, 0 @ Invalidate all unified-TLB mov r0, #0 mcr 15, 0, r0, cr7, cr5, 6 @ Invalidate branch predictor mrc 15, 0, r4, cr1, cr0, 0 @ Read SCTLR orr r4, r4, #0x800 @ Enable branch predictor mcr 15, 0, r4, cr1, cr0, 0 @ Set SCTLR mov r5, lr @ Save LR as we're going to BL mrc 15, 0, r4, cr1, cr0, 0 @ Read SCTLR bl init_cpu_client_enable_icache cmp r0, #0 it ne orrne r4, r4, #0x1000 @ Enable I-Cache bl init_cpu_client_enable_dcache cmp r0, #0 it ne orrne r4, r4, #4 mcr 15, 0, r4, cr1, cr0, 0 @ Enable D-Cache bx r5 @ Return __reset_caches: mov ip, lr @ Save LR mov r0, #0 mcr 15, 0, r0, cr7, cr5, 6 @ Invalidate branch predictor mrc 15, 0, r6, cr1, cr0, 0 @ Read SCTLR mrc 15, 0, r0, cr1, cr0, 0 @ Read SCTLR! bic r0, r0, #0x1000 @ Disable I cache mcr 15, 0, r0, cr1, cr0, 0 @ Write SCTLR mrc 15, 1, r0, cr0, cr0, 1 @ Read CLIDR tst r0, #3 @ Harvard Cache? mov r0, #0 it ne mcrne 15, 0, r0, cr7, cr5, 0 @ Invalidate Instruction Cache? mrc 15, 0, r1, cr1, cr0, 0 @ Read SCTLR (again!) orr r1, r1, #0x800 @ Enable branch predictor @ If we're not enabling caches we have @ no more work to do. bl init_cpu_client_enable_icache cmp r0, #0 it ne orrne r1, r1, #0x1000 @ Enable I-Cache now - @ We actually only do this if we have a @ Harvard style cache. it eq bleq init_cpu_client_enable_dcache itt eq cmpeq r0, #0 beq Finished1 mcr 15, 0, r1, cr1, cr0, 0 @ Write SCTLR (turn on Branch predictor & I-cache) mrc 15, 1, r0, cr0, cr0, 1 @ Read CLIDR ands r3, r0, #0x7000000 lsr r3, r3, #23 @ Total cache levels << 1 beq Finished1 mov lr, #0 @ lr = cache level << 1 Loop11: mrc 15, 1, r0, cr0, cr0, 1 @ Read CLIDR add r2, lr, lr, lsr #1 @ r2 holds cache 'set' position lsr r1, r0, r2 @ Bottom 3-bits are Ctype for this level and r1, r1, #7 @ Get those 3-bits alone cmp r1, #2 blt Skip1 @ No cache or only I-Cache at this level mcr 15, 2, lr, cr0, cr0, 0 @ Write CSSELR mov r1, #0 isb sy mrc 15, 1, r1, cr0, cr0, 0 @ Read CCSIDR and r2, r1, #7 @ Extract line length field add r2, r2, #4 @ Add 4 for the line length offset (log2 16 bytes) movw r0, #0x3ff ands r0, r0, r1, lsr #3 @ r0 is the max number on the way size clz r4, r0 @ r4 is the bit position of the way size increment movw r5, #0x7fff ands r5, r5, r1, lsr #13 @ r5 is the max number of the index size (right aligned) Loop21: mov r7, r0 @ r7 working copy of max way size Loop31: orr r1, lr, r7, lsl r4 @ factor in way number and cache number orr r1, r1, r5, lsl r2 @ factor in set number tst r6, #4 @ D-Cache on? ite eq mcreq 15, 0, r1, cr7, cr6, 2 @ No - invalidate by set/way mcrne 15, 0, r1, cr7, cr14, 2 @ yes - clean + invalidate by set/way subs r7, r7, #1 @ Decrement way number bge Loop31 subs r5, r5, #1 @ Decrement set number bge Loop21 Skip1: add lr, lr, #2 @ increment cache number cmp r3, lr bgt Loop11 Finished1: @ Now we know the caches are clean we can: mrc 15, 0, r4, cr1, cr0, 0 @ Read SCTLR bic r4, r4, #4 @ Disable D-Cache mcr 15, 0, r4, cr1, cr0, 0 @ Write SCTLR mov r4, #0 mcr 15, 0, r4, cr7, cr5, 6 @ Write BPIALL bx ip @ Return @ Set Z if this is a Cortex-A15 or Cortex_A7 @ Other flags corrupted is_a15_a7: mrc 15, 0, r8, c0, c0, 0 movw r9, #0xfff0 movt r9, #0xff0f and r8, r8, r9 movw r9, #0xc0f0 movt r9, #0x410f cmp r8, r9 movw r9, #0xc070 movt r9, #0x410f it ne cmpne r8, r9 bx lr @ Descriptor type: Section @ Bufferable: True @ Cacheable: True @ Execute Never: False @ Domain: 0 @ Impl. Defined: 0 @ Access: 0/11 Full access @ TEX: 001 @ Shareable: False @ Not Global: False @ Supersection: False #define PT(X) \ .word X; #define PT2(X) \ PT(X) PT(X + 0x100000) PT(X + 0x200000) PT(X + 0x300000) #define PT3(X) \ PT2(X) PT2(X + 0x400000) PT2(X + 0x800000) PT2(X + 0xc00000) #define PT4(X) \ PT3(X) PT3(X + 0x1000000) PT3(X + 0x2000000) PT3(X + 0x3000000) #define PT5(X) \ PT4(X) PT4(X + 0x4000000) PT4(X + 0x8000000) PT4(X + 0xc000000) #define PT6(X) \ PT5(X) PT5(X + 0x10000000) PT5(X + 0x20000000) PT5(X + 0x30000000) #define PT7(X) \ PT6(X) PT6(X + 0x40000000) PT6(X + 0x80000000) PT6(X + 0xc0000000) .section page_tables_section, "aw", %progbits .p2align 14 page_tables: PT7(0x1c0e) #endif //#if defined(__ARM_ARCH_7A__) || __ARM_ARCH_PROFILE == 'A'
stsp/newlib-ia16
4,618
libgloss/aarch64/cpu-init/rdimon-aem-el3.S
/* Copyright (c) 2009, 2010, 2011, 2012 ARM Ltd. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. The name of the company may not be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY ARM LTD ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ARM LTD BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "newlib.h" #include "svc.h" /* ANSI concatenation macros. */ #define CONCAT(a, b) CONCAT2(a, b) #define CONCAT2(a, b) a ## b #ifdef __USER_LABEL_PREFIX__ #define FUNCTION( name ) CONCAT (__USER_LABEL_PREFIX__, name) #else #error __USER_LABEL_PREFIX is not defined #endif .text .align 2 _init_vectors: /* Installs a table of exception vectors to catch and handle all exceptions by terminating the process with a diagnostic. */ adr x0, vectors msr vbar_el3, x0 msr vbar_el2, x0 msr vbar_el1, x0 ret curr_sp0_sync: curr_sp0_irq: curr_sp0_fiq: curr_sp0_serror: curr_spx_sync: curr_spx_irq: curr_spx_fiq: curr_spx_serror: lower_a64_sync: lower_a64_irq: lower_a64_fiq: lower_a64_serror: lower_a32_sync: lower_a32_irq: lower_a32_fiq: lower_a32_serror: mov x0, 2 adr x1, .LC3 mov x2, 26 bl FUNCTION (write) mov x0, 126 b FUNCTION (exit) /* Cannot return. */ .LC3: .string "Terminated by exception.\n" .macro ventry label .align 7 b \label .endm /* AArch64 Exception Model -- 3.5.5 Exception Vectors. */ .align 12 vectors: /* Current EL with SP0. */ ventry curr_sp0_sync /* Synchronous */ ventry curr_sp0_irq /* Irq/vIRQ */ ventry curr_sp0_fiq /* Fiq/vFIQ */ ventry curr_sp0_serror /* SError/VSError */ /* Current EL with SPx. */ ventry curr_spx_sync /* Synchronous */ ventry curr_spx_irq /* IRQ/vIRQ */ ventry curr_spx_fiq /* FIQ/vFIQ */ ventry curr_spx_serror /* SError/VSError */ /* Lower EL using AArch64. */ ventry lower_a64_sync /* Synchronous */ ventry lower_a64_irq /* IRQ/vIRQ */ ventry lower_a64_fiq /* FIQ/vFIQ */ ventry lower_a64_serror /* SError/VSError */ /* Lower EL using AArch32. */ ventry lower_a32_sync /* Synchronous */ ventry lower_a32_irq /* IRQ/vIRQ */ ventry lower_a32_fiq /* FIQ/vFIQ */ ventry lower_a32_serror /* SError/VSError */ .text .align 2 _flat_map: /* Page table setup (identity mapping). */ adrp x0, ttb add x0, x0, :lo12:ttb msr ttbr0_el3, x0 adr x1, . /* phys address */ bic x1, x1, #(1 << 30) - 1 /* 1GB block alignment */ add x2, x0, x1, lsr #(30 - 3) /* offset in level 1 page table */ mov x3, #0x401 /* page table attributes (AF, block) */ orr x1, x1, x3 mov x3, #(1 << 30) /* 1GB block */ str x1, [x2], #8 /* 1st GB */ add x1, x1, x3 str x1, [x2] /* 2nd GB */ /* Setup/enable the MMU. */ /* RES1, RES1, 40-bit PA, 39-bit VA, inner/outer cacheable WB */ ldr x0, =(1 << 31) | (1 << 23) | (2 << 16) | 25 | (3 << 10) | (3 << 8) msr tcr_el3, x0 mov x0, #0xee /* Inner/outer cacheable WB */ msr mair_el3, x0 isb mrs x0, sctlr_el3 ldr x1, =0x100d /* bits I(12) SA(3) C(2) M(0) */ bic x0, x0, #(1 << 1) /* clear bit A(1) */ bic x0, x0, #(1 << 19) /* clear WXN */ orr x0, x0, x1 /* set bits */ dsb sy msr sctlr_el3, x0 isb ret .data .align 12 ttb: .space 4096, 0 .text .align 2 .global FUNCTION (_cpu_init_hook) .type FUNCTION (_cpu_init_hook), %function FUNCTION (_cpu_init_hook): sub sp, sp, #16 str x30, [sp, xzr] bl _init_vectors bl _flat_map ldr x30, [sp, xzr] add sp, sp, #16 ret .size FUNCTION (_cpu_init_hook), .-FUNCTION (_cpu_init_hook)
stsp/newlib-ia16
1,603
libgloss/or1k/boards/or1ksim.S
/* or1ksim.S -- Support for or1ksim. * * Copyright (c) 2011 Authors * * Contributor Julius Baxter <juliusbaxter@gmail.com> * * The authors hereby grant permission to use, copy, modify, distribute, * and license this software and its documentation for any purpose, provided * that existing copyright notices are retained in all copies and that this * notice is included verbatim in any distributions. No written agreement, * license, or royalty fee is required for any of the authorized uses. * Modifications to this software may be copyrighted by their authors * and need not follow the licensing terms described here, provided that * the new terms are clearly indicated on the first page of each file where * they apply. */ #include "../include/or1k-asm.h" #include "../include/or1k-nop.h" /* * Define symbols to be used during startup - file is linked at compile time * */ .weak _or1k_board_mem_base .weak _or1k_board_mem_size .weak _or1k_board_clk_freq _or1k_board_mem_base: .long 0x0 _or1k_board_mem_size: .long 0x800000 _or1k_board_clk_freq: .long 100000000 /* Peripheral information - Set base to 0 if not present*/ .weak _or1k_board_uart_base .weak _or1k_board_uart_baud .weak _or1k_board_uart_IRQ _or1k_board_uart_base: .long 0x0 _or1k_board_uart_baud: .long 115200 _or1k_board_uart_IRQ: .long 13 .weak _or1k_board_exit _or1k_board_exit: l.nop OR1K_NOP_K_EXIT_QUIET .Lexitloop: OR1K_DELAYED_NOP(l.j .Lexitloop) .global _or1k_board_init_early _or1k_board_init_early: OR1K_DELAYED_NOP(l.jr r9) .weak _or1k_board_init _or1k_board_init: OR1K_DELAYED_NOP(l.jr r9)
stsp/newlib-ia16
2,893
libgloss/or1k/boards/optimsoc.S
/* optimsoc.S -- Support for OpTiMSoC systems. * * Copyright (c) 2014 Authors * * Contributor Stefan Wallentowitz <stefan.wallentowitz@saunalahti.fi> * * The authors hereby grant permission to use, copy, modify, distribute, * and license this software and its documentation for any purpose, provided * that existing copyright notices are retained in all copies and that this * notice is included verbatim in any distributions. No written agreement, * license, or royalty fee is required for any of the authorized uses. * Modifications to this software may be copyrighted by their authors * and need not follow the licensing terms described here, provided that * the new terms are clearly indicated on the first page of each file where * they apply. */ #include "../include/or1k-asm.h" #include "../include/or1k-nop.h" #define OPTIMSOC_NA_BASE 0xe0000000 #define OPTIMSOC_NA_REGS OPTIMSOC_NA_BASE + 0x00000 #define OPTIMSOC_NA_LMEM_SIZE OPTIMSOC_NA_REGS + 0x24 #define OPTIMSOC_NA_GMEM_SIZE OPTIMSOC_NA_REGS + 0x1c #define OPTIMSOC_GZLL_STRING 0x677a6c6c #define OPTIMSOC_GZLL_IMAGE_LAYOUT 0x2000 /* * Define symbols to be used during startup - file is linked at compile time * */ .weak _or1k_board_mem_base .weak _or1k_board_mem_size .weak _or1k_board_clk_freq _or1k_board_mem_base: .long 0x0 _or1k_board_mem_size: .long 0x0 _or1k_board_clk_freq: .long 50000000 .weak _or1k_board_uart_base .weak _or1k_board_uart_baud .weak _or1k_board_uart_IRQ _or1k_board_uart_base: .long 0x0 _or1k_board_uart_baud: .long 0 _or1k_board_uart_IRQ: .long 0 .weak _or1k_board_exit _or1k_board_exit: l.nop OR1K_NOP_K_EXIT .Lexitloop: OR1K_DELAYED_NOP(l.j .Lexitloop) .extern _or1k_heap_start .global _or1k_board_init_early _or1k_board_init_early: #ifndef __OR1K_MULTICORE__ l.nop 0x1 .die: OR1K_DELAYED_NOP(l.j .die) #endif l.movhi r1,hi(OPTIMSOC_NA_LMEM_SIZE) l.ori r1,r1,lo(OPTIMSOC_NA_LMEM_SIZE) l.lwz r1,0(r1) l.movhi r2,hi(_or1k_board_mem_size) l.ori r2,r2,lo(_or1k_board_mem_size) l.sw 0(r2),r1 // Set stack beyond apps if single image in local memory // Is this a kernel running? l.movhi r3,hi(OPTIMSOC_GZLL_STRING) l.ori r3,r3,lo(OPTIMSOC_GZLL_STRING) l.movhi r4,hi(OPTIMSOC_GZLL_IMAGE_LAYOUT) l.ori r4,r4,lo(OPTIMSOC_GZLL_IMAGE_LAYOUT) l.lwz r5,0(r4) l.sfeq r3,r5 // If not, we are done OR1K_DELAYED_NOP(l.bnf ._or1k_board_init_early_done) // Else: are we running with global memory (loading)? l.movhi r6,hi(OPTIMSOC_NA_GMEM_SIZE) l.ori r6,r6,lo(OPTIMSOC_NA_GMEM_SIZE) l.lwz r6,0(r6) l.sfeqi r6,0 // If yes, we are done OR1K_DELAYED_NOP(l.bnf ._or1k_board_init_early_done) // Else: Read end of apps l.lwz r7,12(r4) l.movhi r8,hi(_or1k_heap_start) l.ori r8,r8,lo(_or1k_heap_start) l.sw 0(r8),r7 ._or1k_board_init_early_done: OR1K_DELAYED_NOP(l.jr r9) .weak _or1k_board_init _or1k_board_init: OR1K_DELAYED_NOP(l.jr r9)
stsp/newlib-ia16
1,626
libgloss/or1k/boards/ordb1a3pe1500.S
/* ordb1a3pe1500.S -- Support for orpsocv2 Actel board. * * Copyright (c) 2011 Authors * * Contributor Julius Baxter <juliusbaxter@gmail.com> * * The authors hereby grant permission to use, copy, modify, distribute, * and license this software and its documentation for any purpose, provided * that existing copyright notices are retained in all copies and that this * notice is included verbatim in any distributions. No written agreement, * license, or royalty fee is required for any of the authorized uses. * Modifications to this software may be copyrighted by their authors * and need not follow the licensing terms described here, provided that * the new terms are clearly indicated on the first page of each file where * they apply. */ #include "../include/or1k-asm.h" #include "../include/or1k-nop.h" /* * Define symbols to be used during startup - file is linked at compile time * */ .weak _or1k_board_mem_base .weak _or1k_board_mem_size .weak _or1k_board_clk_freq _or1k_board_mem_base: .long 0x0 _or1k_board_mem_size: .long 0x02000000 _or1k_board_clk_freq: .long 20000000 /* Peripheral information - Set base to 0 if not present*/ .weak _or1k_board_uart_base .weak _or1k_board_uart_baud .weak _or1k_board_uart_IRQ _or1k_board_uart_base: .long 0x90000000 _or1k_board_uart_baud: .long 115200 _or1k_board_uart_IRQ: .long 2 .weak _or1k_board_exit _or1k_board_exit: l.nop OR1K_NOP_K_EXIT_QUIET .Lexitloop: OR1K_DELAYED_NOP(l.j .Lexitloop) .global _or1k_board_init_early _or1k_board_init_early: OR1K_DELAYED_NOP(l.jr r9) .weak _or1k_board_init _or1k_board_init: OR1K_DELAYED_NOP(l.jr r9)
stsp/newlib-ia16
1,624
libgloss/or1k/boards/orpsocrefdesign.S
/* orpsocrefdesign.S -- Support for the orpsoc reference design. * * Copyright (c) 2011 Authors * * Contributor Julius Baxter <juliusbaxter@gmail.com> * * The authors hereby grant permission to use, copy, modify, distribute, * and license this software and its documentation for any purpose, provided * that existing copyright notices are retained in all copies and that this * notice is included verbatim in any distributions. No written agreement, * license, or royalty fee is required for any of the authorized uses. * Modifications to this software may be copyrighted by their authors * and need not follow the licensing terms described here, provided that * the new terms are clearly indicated on the first page of each file where * they apply. */ #include "../include/or1k-asm.h" #include "../include/or1k-nop.h" /* * Define symbols to be used during startup - file is linked at compile time * */ .weak _or1k_board_mem_base .weak _or1k_board_mem_size .weak _or1k_board_clk_freq _or1k_board_mem_base: .long 0x0 _or1k_board_mem_size: .long 0x800000 _or1k_board_clk_freq: .long 50000000 /* Peripheral information - Set base to 0 if not present*/ .weak _or1k_board_uart_base .weak _or1k_board_uart_baud .weak _or1k_board_uart_IRQ _or1k_board_uart_base: .long 0 _or1k_board_uart_baud: .long 115200 _or1k_board_uart_IRQ: .long 2 .weak _or1k_board_exit _or1k_board_exit: l.nop OR1K_NOP_K_EXIT_QUIET .Lexitloop: OR1K_DELAYED_NOP(l.j .Lexitloop) .global _or1k_board_init_early _or1k_board_init_early: OR1K_DELAYED_NOP(l.jr r9) .weak _or1k_board_init _or1k_board_init: OR1K_DELAYED_NOP(l.jr r9)
stsp/newlib-ia16
1,628
libgloss/or1k/boards/or1ksim-uart.S
/* or1ksim-uart.S -- Support for or1ksim with UART support. * * Copyright (c) 2011 Authors * * Contributor Julius Baxter <juliusbaxter@gmail.com> * * The authors hereby grant permission to use, copy, modify, distribute, * and license this software and its documentation for any purpose, provided * that existing copyright notices are retained in all copies and that this * notice is included verbatim in any distributions. No written agreement, * license, or royalty fee is required for any of the authorized uses. * Modifications to this software may be copyrighted by their authors * and need not follow the licensing terms described here, provided that * the new terms are clearly indicated on the first page of each file where * they apply. */ #include "../include/or1k-asm.h" #include "../include/or1k-nop.h" /* * Define symbols to be used during startup - file is linked at compile time * */ .weak _or1k_board_mem_base .weak _or1k_board_mem_size .weak _or1k_board_clk_freq _or1k_board_mem_base: .long 0x0 _or1k_board_mem_size: .long 0x800000 _or1k_board_clk_freq: .long 100000000 /* Peripheral information - Set base to 0 if not present*/ .weak _or1k_board_uart_base .weak _or1k_board_uart_baud .weak _or1k_board_uart_IRQ _or1k_board_uart_base: .long 0x90000000 _or1k_board_uart_baud: .long 115200 _or1k_board_uart_IRQ: .long 2 .weak _or1k_board_exit _or1k_board_exit: l.nop OR1K_NOP_K_EXIT_QUIET .Lexitloop: OR1K_DELAYED_NOP(l.j .Lexitloop) .global _or1k_board_init_early _or1k_board_init_early: OR1K_DELAYED_NOP(l.jr r9) .weak _or1k_board_init _or1k_board_init: OR1K_DELAYED_NOP(l.jr r9)
stsp/newlib-ia16
1,618
libgloss/or1k/boards/ml501.S
/* ml501.S -- Support for the Xilinx ML501 board. * * Copyright (c) 2011 Authors * * Contributor Julius Baxter <juliusbaxter@gmail.com> * * The authors hereby grant permission to use, copy, modify, distribute, * and license this software and its documentation for any purpose, provided * that existing copyright notices are retained in all copies and that this * notice is included verbatim in any distributions. No written agreement, * license, or royalty fee is required for any of the authorized uses. * Modifications to this software may be copyrighted by their authors * and need not follow the licensing terms described here, provided that * the new terms are clearly indicated on the first page of each file where * they apply. */ #include "../include/or1k-asm.h" #include "../include/or1k-nop.h" /* * Define symbols to be used during startup - file is linked at compile time * */ .weak _or1k_board_mem_base .weak _or1k_board_mem_size .weak _or1k_board_clk_freq _or1k_board_mem_base: .long 0x0 _or1k_board_mem_size: .long 0x800000 _or1k_board_clk_freq: .long 66666666 /* Peripheral information - Set base to 0 if not present*/ .weak _or1k_board_uart_base .weak _or1k_board_uart_baud .weak _or1k_board_uart_IRQ _or1k_board_uart_base: .long 0x90000000 _or1k_board_uart_baud: .long 115200 _or1k_board_uart_IRQ: .long 2 .weak _or1k_board_exit _or1k_board_exit: l.nop OR1K_NOP_K_EXIT_QUIET .Lexitloop: OR1K_DELAYED_NOP(l.j .Lexitloop) .global _or1k_board_init_early _or1k_board_init_early: OR1K_DELAYED_NOP(l.jr r9) .weak _or1k_board_init _or1k_board_init: OR1K_DELAYED_NOP(l.jr r9)
stsp/newlib-ia16
1,624
libgloss/or1k/boards/ml509.S
/* ml509.S -- Support for the Xilinx ML509 board (XUPV5). * * Copyright (c) 2014 Authors * * Contributor Matthew Hicks <firefalcon@gmail.com> * * The authors hereby grant permission to use, copy, modify, distribute, * and license this software and its documentation for any purpose, provided * that existing copyright notices are retained in all copies and that this * notice is included verbatim in any distributions. No written agreement, * license, or royalty fee is required for any of the authorized uses. * Modifications to this software may be copyrighted by their authors * and need not follow the licensing terms described here, provided that * the new terms are clearly indicated on the first page of each file where * they apply. */ #include "../include/or1k-asm.h" #include "../include/or1k-nop.h" /* * Define symbols to be used during startup - file is linked at compile time * */ .weak _or1k_board_mem_base .weak _or1k_board_mem_size .weak _or1k_board_clk_freq _or1k_board_mem_base: .long 0x0 _or1k_board_mem_size: .long 0x08000000 _or1k_board_clk_freq: .long 50000000 /* Peripheral information - Set base to 0 if not present*/ .weak _or1k_board_uart_base .weak _or1k_board_uart_baud .weak _or1k_board_uart_IRQ _or1k_board_uart_base: .long 0x90000000 _or1k_board_uart_baud: .long 115200 _or1k_board_uart_IRQ: .long 2 .weak _or1k_board_exit _or1k_board_exit: l.nop OR1K_NOP_K_EXIT_QUIET .Lexitloop: OR1K_DELAYED_NOP(l.j .Lexitloop) .global _or1k_board_init_early _or1k_board_init_early: OR1K_DELAYED_NOP(l.jr r9) .weak _or1k_board_init _or1k_board_init: OR1K_DELAYED_NOP(l.jr r9)
stsp/newlib-ia16
1,674
libgloss/or1k/boards/ordb2a.S
/* ordb2a.S -- Support for the new OpenRISC ORPSoC reference design. * * Copyright (c) 2012 Authors * * Contributor Olof Kindgren <olof.kindgren@gmail.com> * * The authors hereby grant permission to use, copy, modify, distribute, * and license this software and its documentation for any purpose, provided * that existing copyright notices are retained in all copies and that this * notice is included verbatim in any distributions. No written agreement, * license, or royalty fee is required for any of the authorized uses. * Modifications to this software may be copyrighted by their authors * and need not follow the licensing terms described here, provided that * the new terms are clearly indicated on the first page of each file where * they apply. */ #include "../include/or1k-asm.h" #include "../include/or1k-nop.h" /* * Define symbols to be used during startup - file is linked at compile time * Olof Kindgren olof at opencores.org */ .weak _or1k_board_mem_base .weak _or1k_board_mem_size .weak _or1k_board_clk_freq _or1k_board_mem_base: .long 0x0 _or1k_board_mem_size: .long 0x02000000 _or1k_board_clk_freq: .long 50000000 /* Peripheral information - Set base to 0 if not present*/ .weak _or1k_board_uart_base .weak _or1k_board_uart_baud .weak _or1k_board_uart_IRQ _or1k_board_uart_base: .long 0x90000000 _or1k_board_uart_baud: .long 115200 _or1k_board_uart_IRQ: .long 2 .weak _or1k_board_exit _or1k_board_exit: l.nop OR1K_NOP_K_EXIT_QUIET .Lexitloop: OR1K_DELAYED_NOP(l.j .Lexitloop) .global _or1k_board_init_early _or1k_board_init_early: OR1K_DELAYED_NOP(l.jr r9) .weak _or1k_board_init _or1k_board_init: OR1K_DELAYED_NOP(l.jr r9)
stsp/newlib-ia16
1,795
libgloss/or1k/boards/tmpl.S
/* tmpl.S -- Template for new boards. * * Copyright (c) 2014 Authors * * Contributor Stefan Wallentowitz <stefan.wallentowitz@saunalahti.fi> * * The authors hereby grant permission to use, copy, modify, distribute, * and license this software and its documentation for any purpose, provided * that existing copyright notices are retained in all copies and that this * notice is included verbatim in any distributions. No written agreement, * license, or royalty fee is required for any of the authorized uses. * Modifications to this software may be copyrighted by their authors * and need not follow the licensing terms described here, provided that * the new terms are clearly indicated on the first page of each file where * they apply. */ #include "../include/or1k-asm.h" #include "../include/or1k-nop.h" /* * Define symbols to be used during startup - file is linked at compile time * */ .weak _or1k_board_mem_base .weak _or1k_board_mem_size .weak _or1k_board_clk_freq // TODO: set memory base here _or1k_board_mem_base: .long 0x0 // TODO: set memory size here _or1k_board_mem_size: .long 0x0 // TODO: set board clock frequency here _or1k_board_clk_freq: .long 50000000 // TODO: UART configuration .weak _or1k_board_uart_base .weak _or1k_board_uart_baud .weak _or1k_board_uart_IRQ _or1k_board_uart_base: .long 0x0 _or1k_board_uart_baud: .long 0 _or1k_board_uart_IRQ: .long 0 // TODO: Board exit function, default: loop .weak _or1k_board_exit _or1k_board_exit: l.nop OR1K_NOP_EXIT_SILENT .Lexitloop: OR1K_DELAYED_NOP(l.j .Lexitloop) // TODO: Early initialization (if really needed!) .global _or1k_board_init_early _or1k_board_init_early: OR1K_DELAYED_NOP(l.jr r9) // TODO: Board initialization .weak _or1k_board_init _or1k_board_init: OR1K_DELAYED_NOP(l.jr r9)
stsp/newlib-ia16
1,627
libgloss/or1k/boards/atlys.S
/* atlys.S -- Support for the Atlys board. * * Copyright (c) 2012 Authors * * Contributor Stefan Kristiansson <stefan.kristiansson@saunalahti.fi> * * The authors hereby grant permission to use, copy, modify, distribute, * and license this software and its documentation for any purpose, provided * that existing copyright notices are retained in all copies and that this * notice is included verbatim in any distributions. No written agreement, * license, or royalty fee is required for any of the authorized uses. * Modifications to this software may be copyrighted by their authors * and need not follow the licensing terms described here, provided that * the new terms are clearly indicated on the first page of each file where * they apply. */ #include "../include/or1k-asm.h" #include "../include/or1k-nop.h" /* * Define symbols to be used during startup - file is linked at compile time * */ .weak _or1k_board_mem_base .weak _or1k_board_mem_size .weak _or1k_board_clk_freq _or1k_board_mem_base: .long 0x0 _or1k_board_mem_size: .long 0x2000000 _or1k_board_clk_freq: .long 50000000 /* Peripheral information - Set base to 0 if not present*/ .weak _or1k_board_uart_base .weak _or1k_board_uart_baud .weak _or1k_board_uart_IRQ _or1k_board_uart_base: .long 0x90000000 _or1k_board_uart_baud: .long 115200 _or1k_board_uart_IRQ: .long 2 .weak _or1k_board_exit _or1k_board_exit: l.nop OR1K_NOP_K_EXIT_QUIET .Lexitloop: OR1K_DELAYED_NOP(l.j .Lexitloop) .global _or1k_board_init_early _or1k_board_init_early: OR1K_DELAYED_NOP(l.jr r9) .weak _or1k_board_init _or1k_board_init: OR1K_DELAYED_NOP(l.jr r9)
stsp/newlib-ia16
1,635
libgloss/or1k/boards/de0_nano.S
/* de0_nano.S -- Support for the DE0 nano board. * * Copyright (c) 2012 Authors * * Contributor Stefan Kristiansson <stefan.kristiansson@saunalahti.fi> * * The authors hereby grant permission to use, copy, modify, distribute, * and license this software and its documentation for any purpose, provided * that existing copyright notices are retained in all copies and that this * notice is included verbatim in any distributions. No written agreement, * license, or royalty fee is required for any of the authorized uses. * Modifications to this software may be copyrighted by their authors * and need not follow the licensing terms described here, provided that * the new terms are clearly indicated on the first page of each file where * they apply. */ #include "../include/or1k-asm.h" #include "../include/or1k-nop.h" /* * Define symbols to be used during startup - file is linked at compile time * */ .weak _or1k_board_mem_base .weak _or1k_board_mem_size .weak _or1k_board_clk_freq _or1k_board_mem_base: .long 0x0 _or1k_board_mem_size: .long 0x2000000 _or1k_board_clk_freq: .long 50000000 /* Peripheral information - Set base to 0 if not present*/ .weak _or1k_board_uart_base .weak _or1k_board_uart_baud .weak _or1k_board_uart_IRQ _or1k_board_uart_base: .long 0x90000000 _or1k_board_uart_baud: .long 115200 _or1k_board_uart_IRQ: .long 2 .weak _or1k_board_exit _or1k_board_exit: l.nop OR1K_NOP_K_EXIT_QUIET .Lexitloop: OR1K_DELAYED_NOP(l.j .Lexitloop) .global _or1k_board_init_early _or1k_board_init_early: OR1K_DELAYED_NOP(l.jr r9) .weak _or1k_board_init _or1k_board_init: OR1K_DELAYED_NOP(l.jr r9)
stsp/newlib-ia16
3,131
libgloss/sparc/libsys/libsys-crt0.S
! C run time start off ! This file supports: ! ! - both 32bit pointer and 64bit pointer environments (at compile time) ! - an imposed stack bias (of 2047) (at run time) ! - medium/low and medium/anywhere code models (at run time) ! Initial stack setup: ! ! bottom of stack (higher memory address) ! ... ! text of environment strings ! text of argument strings ! envp[envc] = 0 (4/8 bytes) ! ... ! env[0] (4/8 bytes) ! argv[argc] = 0 (4/8 bytes) ! ... ! argv[0] (4/8 bytes) ! argc (4/8 bytes) ! register save area (64 bits by 16 registers = 128 bytes) ! top of stack (%sp) ! Stack Bias: ! ! It is the responsibility of the o/s to set this up. ! We handle both a 0 and 2047 value for the stack bias. ! Medium/Anywhere code model support: ! ! In this model %g4 points to the start of the data segment. ! The text segment can go anywhere, but %g4 points to the *data* segment. ! It is up to the compiler/linker to get this right. ! ! Since this model is statically linked the start of the data segment ! is known at link time. Eg: ! ! sethi %hh(data_start), %g1 ! sethi %lm(data_start), %g4 ! or %g1, %hm(data_start), %g1 ! or %g4, %lo(data_start), %g4 ! sllx %g1, 32, %g1 ! or %g4, %g1, %g4 ! ! FIXME: For now we just assume 0. ! FIXME: if %g1 contains a non-zero value, atexit() should be invoked ! with this value. #include "syscallasm.h" #ifndef TARGET_PTR_SIZE #define TARGET_PTR_SIZE 32 #endif TEXT_SECTION ALIGN (4) GLOBAL (ASM_PRIVATE_SYMBOL (start)) ASM_PRIVATE_SYMBOL (start): clr %fp ! We use %g4 even if the code model is Medium/Low (simplifies the code). clr %g4 ! Medium/Anywhere base reg ! If there is a stack bias in effect, account for it in %g5. Then always ! add %g5 to stack references below. This way the code can be used with ! or without an imposed bias. andcc %sp, 1, %g5 bnz,a .LHaveBias mov 2047, %g5 .LHaveBias: add %sp, %g5, %sp #if TARGET_PTR_SIZE == 32 ! FIXME: We apparently assume here that there is no reserved word. ! This is probably correct, but try to verify it. ld [%sp + 0x80], %o0 ! argc add %sp, 0x84, %o1 ! argv add %o0, 1, %o2 sll %o2, 2, %o2 #else /* TARGET_PTR_SIZE == 64 */ ld [%sp + 0x8c], %o0 ! argc.lo add %sp, 0x90, %o1 ! argv add %o0, 1, %o2 sll %o2, 3, %o2 #endif add %o1, %o2, %o2 ! envp sethi %hi (ASM_SYMBOL (environ)), %o3 or %o3, %lo (ASM_SYMBOL (environ)), %o3 #if TARGET_PTR_SIZE == 32 st %o2, [%o3 + %g4] #else /* TARGET_PTR_SIZE == 64 */ stx %o2, [%o3 + %g4] #endif ! Restore any stack bias before we call main() ... sub %sp, %g5, %sp GLOBAL (ASM_SYMBOL (main)) call ASM_SYMBOL (main) ! FIXME: Not sure if this is needed anymore. #if TARGET_PTR_SIZE == 32 sub %sp, 0x20, %sp ! room to push args #else /* TARGET_PTR_SIZE == 64 */ sub %sp, 0x30, %sp ! room to push args #endif GLOBAL (ASM_SYMBOL (exit)) call ASM_SYMBOL (exit) nop GLOBAL (ASM_SYMBOL (_exit)) call ASM_SYMBOL (_exit) nop set SYS_exit, %g1 ta SYSCALL_TRAP ! in case user redefines __exit ! If all the above methods fail to terminate the program, try an illegal insn. ! If that does not work, the o/s is hosed more than we are. WORD (0)
stsp/newlib-ia16
1,033
libgloss/sparc/libsys/cerror.S
! Set errno. ! This function is called by all the syscall stubs. ! ! FIXME: We assume errno is the first member of struct _reent. ! Not sure what to do about this. #include "syscallasm.h" DATA_SECTION ALIGN (4) GLOBAL (ASM_SYMBOL (errno)) ! FIXME: ASM_PRIVATE_SYMBOL ? ASM_SYMBOL (errno): WORD (0) TEXT_SECTION ALIGN (4) GLOBAL (ASM_PRIVATE_SYMBOL (cerror)) ASM_PRIVATE_SYMBOL (cerror): sethi %hi (ASM_SYMBOL (errno)),%g1 st %o0,[%g1+%lo (ASM_SYMBOL (errno))] jmpl %o7+8,%g0 mov -1,%o0 GLOBAL (ASM_PRIVATE_SYMBOL (cerror_r)) ASM_PRIVATE_SYMBOL (cerror_r): st %o0,[%o1] jmpl %o7+8,%g0 mov -1,%o0 ! Since all system calls need this file, we put various state globals ! here as well. DATA_SECTION ! CURBRK contains the current top of allocated space. ! END is a private symbol in svr4, but a public one in sunos4. ! FIXME: CURBRK is 4 bytes for now. ALIGN (4) GLOBAL (ASM_PRIVATE_SYMBOL (curbrk)) ASM_PRIVATE_SYMBOL (curbrk): #ifdef SVR4 WORD (ASM_PRIVATE_SYMBOL (end)) #else WORD (ASM_SYMBOL (end)) #endif
stsp/newlib-ia16
1,215
libgloss/sparc/libsys/sbrk.S
! sbrk() system call #include "syscallasm.h" TEXT_SECTION ALIGN (4) #ifdef REENT GLOBAL (ASM_SYMBOL (_sbrk_r)) ASM_SYMBOL (_sbrk_r): mov %o0,%o5 mov %o1,%o0 #else GLOBAL (ASM_SYMBOL (sbrk)) ASM_SYMBOL (sbrk): #endif add %o0,7,%o0 andn %o0,7,%o0 sethi %hi (ASM_PRIVATE_SYMBOL (curbrk)),%o2 #ifdef __sparc_v9__ lduw [%o2+%lo (ASM_PRIVATE_SYMBOL (curbrk))],%o3 #else ld [%o2+%lo (ASM_PRIVATE_SYMBOL (curbrk))],%o3 #endif add %o3,7,%o3 andn %o3,7,%o3 add %o3,%o0,%o0 mov %o0,%o4 mov SYS_brk,%g1 ta SYSCALL_TRAP bcs err nop st %o4,[%o2+%lo (ASM_PRIVATE_SYMBOL (curbrk))] jmpl %o7+8,%g0 mov %o3,%o0 #ifdef REENT GLOBAL (ASM_SYMBOL (_brk_r)) ASM_SYMBOL (_brk_r): mov %o0,%o5 mov %o1,%o0 #else GLOBAL (ASM_SYMBOL (brk)) ASM_SYMBOL (brk): #endif add %o0,7,%o0 andn %o0,7,%o0 mov %o0,%o2 mov SYS_brk,%g1 ta SYSCALL_TRAP bcs err nop sethi %hi (ASM_PRIVATE_SYMBOL (curbrk)),%o3 st %o2,[%o3+%lo (ASM_PRIVATE_SYMBOL (curbrk))] retl mov %g0,%o0 err: #ifdef REENT sethi %hi (ASM_PRIVATE_SYMBOL (cerror_r)),%g1 or %g1,%lo (ASM_PRIVATE_SYMBOL (cerror_r)),%g1 #else sethi %hi (ASM_PRIVATE_SYMBOL (cerror)),%g1 or %g1,%lo (ASM_PRIVATE_SYMBOL (cerror)),%g1 #endif jmpl %g1,%g0 mov %o5,%o1
stsp/newlib-ia16
2,465
newlib/libm/machine/nds32/wf_sqrt.S
/* Copyright (c) 2013-2014 Andes Technology Corporation. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. The name of the company may not be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RED HAT INCORPORATED BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ .text .align 1 .global sqrtf .type sqrtf, @function sqrtf: /* The input argument is supposed to be stored in $fs0. The return value is supposed to be stored in $fs0 either. */ /* Clear the IEEE cumulative exceptions flags. ($fpcsr.b[6:2]) */ FMFCSR $r0 bitci $r0, $r0, #0b1111100 FMTCSR $r0 fsqrts $fs0, $fs0 /* Check the IEEE cumulative exceptions flags. */ FMFCSR $r5 bmski33 $r5, #2 /* Is $fpcsr.IVO('b2) set ? */ bnez $r5, .L_EDOM /* Set errno as EDOM. */ bmski33 $r5, #4 /* Is $fpcsr.OVF('b4) set ? */ bnez $r5, .L_ERANGE /* Set errno as ERANGE. */ bmski33 $r5, #5 /* Is $fpcsr.UDF('b5) set ? */ bnez $r5, .L_ERANGE /* Set errno as ERANGE. */ /* No error at all. Just ret. */ ret .L_EDOM: movi $r0, #33 /* EDOM: Math arg out of domain of func. */ j .L_Set_errno .L_ERANGE: movi $r0, #34 /* ERANGE: Math result not representable. */ .L_Set_errno: l.w $r15, _impure_ptr swi $r0, [$r15] /* Set errno. */ ret .size sqrtf, .-sqrtf
stsp/newlib-ia16
2,461
newlib/libm/machine/nds32/w_sqrt.S
/* Copyright (c) 2013-2014 Andes Technology Corporation. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. The name of the company may not be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RED HAT INCORPORATED BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ .text .align 1 .global sqrt .type sqrt, @function sqrt: /* The input argument is supposed to be stored in $fd0. The return value is supposed to be stored in $fd0 either. */ /* Clear the IEEE cumulative exceptions flags. ($fpcsr.b[6:2]) */ FMFCSR $r0 bitci $r0, $r0, #0b1111100 FMTCSR $r0 fsqrtd $fd0, $fd0 /* Check the IEEE cumulative exceptions flags. */ FMFCSR $r0 bmski33 $r0, #2 /* Is $fpcsr.IVO('b2) set ? */ bnez $r0, .L_EDOM /* Set errno as EDOM. */ bmski33 $r0, #4 /* Is $fpcsr.OVF('b4) set ? */ bnez $r0, .L_ERANGE /* Set errno as ERANGE. */ bmski33 $r0, #5 /* Is $fpcsr.UDF('b5) set ? */ bnez $r0, .L_ERANGE /* Set errno as ERANGE. */ /* No error at all. Just ret. */ ret .L_EDOM: movi $r0, #33 /* EDOM: Math arg out of domain of func. */ j .L_Set_errno .L_ERANGE: movi $r0, #34 /* ERANGE: Math result not representable. */ .L_Set_errno: l.w $r15, _impure_ptr swi $r0, [$r15] /* Set errno. */ ret .size sqrt, .-sqrt
stsp/newlib-ia16
2,202
newlib/libc/sys/sh/crt0.S
#ifdef __SH5__ .section .data,"aw" .global ___data ___data: .section .rodata,"a" .global ___rodata ___rodata: #if __SH5__ == 64 .section .text,"ax" #define LOAD_ADDR(sym, reg) \ movi (sym >> 48) & 65535, reg; \ shori (sym >> 32) & 65535, reg; \ shori (sym >> 16) & 65535, reg; \ shori sym & 65535, reg #else .mode SHmedia .section .text..SHmedia32,"ax" #define LOAD_ADDR(sym, reg) \ movi (sym >> 16) & 65535, reg; \ shori sym & 65535, reg #endif .global start start: LOAD_ADDR (_stack, r15) pt/l zero_bss_loop, tr0 pt/l _atexit, tr1 pt/l _init, tr5 pt/l _main, tr6 pt/l _exit, tr7 ! zero out bss LOAD_ADDR (_edata, r0) LOAD_ADDR (_end, r1) zero_bss_loop: stx.q r0, r63, r63 addi r0, 8, r0 bgt/l r1, r0, tr0 LOAD_ADDR (___data, r26) LOAD_ADDR (___rodata, r27) #if ! __SH4_NOFPU__ getcon cr0, r0 movi 1, r1 shlli r1, 15, r1 or r1, r0, r0 putcon r0, cr0 #endif ! arrange for exit to call fini LOAD_ADDR (_fini, r2) blink tr1, r18 ! call init blink tr5, r18 ! call the mainline blink tr6, r18 ! call exit blink tr7, r18 #else .section .text .global start start: mov.l stack_k,r15 ! zero out bss mov.l edata_k,r0 mov.l end_k,r1 mov #0,r2 start_l: mov.l r2,@r0 add #4,r0 cmp/ge r0,r1 bt start_l #ifndef __SH2A_NOFPU__ #if defined (__SH3E__) || defined(__SH4_SINGLE__) || defined(__SH4__) || defined(__SH4_SINGLE_ONLY) || defined(__SH2A__) mov.l set_fpscr_k, r1 jsr @r1 mov #0,r4 lds r3,fpscr #endif /* defined (__SH3E__) || defined(__SH4_SINGLE__) || defined(__SH4__) || defined(__SH4_SINGLE_ONLY__) || defined(__SH2A__) */ #endif /* !__SH2A_NOFPU__ */ ! call the mainline mov.l main_k,r0 jsr @r0 or r0,r0 ! call exit mov r0,r4 mov.l exit_k,r0 jsr @r0 or r0,r0 .align 2 #ifndef __SH2A_NOFPU__ #if defined (__SH3E__) || defined(__SH4_SINGLE__) || defined(__SH4__) || defined(__SH4_SINGLE_ONLY__) || defined(__SH2A__) set_fpscr_k: .long ___set_fpscr #endif /* defined (__SH3E__) || defined(__SH4_SINGLE__) || defined(__SH4__) || defined(SH4_SINGLE_ONLY) || defined(__SH2A__) */ #endif /* !__SH2A_NOFPU__ */ stack_k: .long _stack edata_k: .long _edata end_k: .long _end main_k: .long _main exit_k: .long _exit #endif
stsp/newlib-ia16
1,538
newlib/libc/sys/a29khif/_open.S
; @(#)_open.s 1.4 90/10/14 21:57:30, AMD ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Copyright 1990 Advanced Micro Devices, Inc. ; ; This software is the property of Advanced Micro Devices, Inc (AMD) which ; specifically grants the user the right to modify, use and distribute this ; software provided this notice is not removed or altered. All other rights ; are reserved by AMD. ; ; AMD MAKES NO WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, WITH REGARD TO THIS ; SOFTWARE. IN NO EVENT SHALL AMD BE LIABLE FOR INCIDENTAL OR CONSEQUENTIAL ; DAMAGES IN CONNECTION WITH OR ARISING FROM THE FURNISHING, PERFORMANCE, OR ; USE OF THIS SOFTWARE. ; ; So that all may benefit from your experience, please report any problems ; or suggestions about this software to the 29K Technical Support Center at ; 800-29-29-AMD (800-292-9263) in the USA, or 0800-89-1131 in the UK, or ; 0031-11-1129 in Japan, toll free. The direct dial number is 512-462-4118. ; ; Advanced Micro Devices, Inc. ; 29K Support Products ; Mail Stop 573 ; 5900 E. Ben White Blvd. ; Austin, TX 78741 ; 800-292-9263 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; _open.s ; int fd = _open( char *path, int oflag [, int mode ] ); ; .file "_open.s" .include "sys/sysmac.h" .text .word 0x00050000 ; Debugger tag word .global __open __open: const tav,HIF_open @ asneq V_SYSCALL,gr1,gr1 @ jmpti tav,lr0 @ const tpc,_errno @ consth tpc,_errno @ store 0,0,tav,tpc @ jmpi lr0 @ constn v0,-1 .end
stsp/newlib-ia16
2,081
newlib/libc/sys/a29khif/read.S
; @(#)_read.s 1.4 90/10/14 21:57:32, AMD ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Copyright 1990 Advanced Micro Devices, Inc. ; ; This software is the property of Advanced Micro Devices, Inc (AMD) which ; specifically grants the user the right to modify, use and distribute this ; software provided this notice is not removed or altered. All other rights ; are reserved by AMD. ; ; AMD MAKES NO WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, WITH REGARD TO THIS ; SOFTWARE. IN NO EVENT SHALL AMD BE LIABLE FOR INCIDENTAL OR CONSEQUENTIAL ; DAMAGES IN CONNECTION WITH OR ARISING FROM THE FURNISHING, PERFORMANCE, OR ; USE OF THIS SOFTWARE. ; ; So that all may benefit from your experience, please report any problems ; or suggestions about this software to the 29K Technical Support Center at ; 800-29-29-AMD (800-292-9263) in the USA, or 0800-89-1131 in the UK, or ; 0031-11-1129 in Japan, toll free. The direct dial number is 512-462-4118. ; ; Advanced Micro Devices, Inc. ; 29K Support Products ; Mail Stop 573 ; 5900 E. Ben White Blvd. ; Austin, TX 78741 ; 800-292-9263 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; _read.s ; int nread = _read( int fd, char *buf, int count ); ; .file "_read.s" .include "sys/sysmac.h" .text .word 0x00050000 ; Debugger tag word .global __read ;; syscalls used now -- .global _read __read: ;; syscalls used now -- _read: .ifdef _BSD_OS ; BSD version - uses readv const tav,HIF_call @ asneq V_SYSCALL,gr1,gr1 @ jmpti tav,lr0 @ const tpc,_errno @ consth tpc,_errno @ store 0,0,tav,tpc @ jmpi lr0 @ constn v0,-1 sub msp, msp, 8 store 0, 0, lr3, msp add tav, msp, 4 add lr3, msp, 0 store 0, 0, lr4, tav const lr4, 1 const tav,HIF_readv @ asneq V_SYSCALL,gr1,gr1 jmpti tav, lr0 add msp, msp, 8 const tpc,_errno @ consth tpc,_errno @ store 0,0,tav,tpc @ jmpi lr0 @ constn v0,-1 .else const tav,HIF_read @ asneq V_SYSCALL,gr1,gr1 @ jmpti tav,lr0 @ const tpc,_errno @ consth tpc,_errno @ store 0,0,tav,tpc @ jmpi lr0 @ constn v0,-1 .endif .end
stsp/newlib-ia16
2,124
newlib/libc/sys/a29khif/stubs.S
; ; ; File of stubs so that unix applications can link into a HIF monitor ; ; sac@cygnus.com .text .global _sysalloc _sysalloc: const gr121,__sysalloc consth gr121,__sysalloc jmpi gr121 .global _sysfree _sysfree: const gr121,__sysfree consth gr121,__sysfree jmpi gr121 .global _cycles _cycles: const gr121,__cycles consth gr121,__cycles jmpi gr121 ; .global _exit ;_exit: ; const gr121,__exit ; consth gr121,__exit ; jmpi gr121 .global _getpsiz _getpsiz: const gr121,__getpsiz consth gr121,__getpsiz jmpi gr121 .global _gettz _gettz: const gr121,__gettz consth gr121,__gettz jmpi gr121 .global _ioctl _ioctl: const gr121,__ioctl consth gr121,__ioctl jmpi gr121 .global _iowait _iowait: const gr121,__iowait consth gr121,__iowait jmpi gr121 ;; syscalls used now -- .global _open ;; syscalls used now -- _open: ;; syscalls used now -- const gr121,__open ;; syscalls used now -- consth gr121,__open ;; syscalls used now -- jmpi gr121 .global _query _query: const gr121,__query consth gr121,__query jmpi gr121 .global _setim _setim: const gr121,__setim consth gr121,__setim jmpi gr121 .global _settrap _settrap: const gr121,__settrap consth gr121,__settrap jmpi gr121 .global _setvec _setvec: const gr121,__setvec consth gr121,__setvec jmpi gr121 .global _getargs _getargs: const gr121,__getargs consth gr121,__getargs jmpi gr121 ;; syscalls used now -- .global _unlink ;; syscalls used now -- _unlink: ;; syscalls used now -- const gr121,__unlink ;; syscalls used now -- consth gr121,__unlink ;; syscalls used now -- jmpi gr121 .global _sigret _sigret: const gr121,__sigret consth gr121,__sigret jmpi gr121 .global _sigdfl _sigdfl: const gr121,__sigdfl consth gr121,__sigdfl jmpi gr121 .global _sigrep _sigrep: const gr121,__sigrep consth gr121,__sigrep jmpi gr121 .global _sigskp _sigskp: const gr121,__sigskp consth gr121,__sigskp jmpi gr121 .global _sendsig _sendsig: const gr121,__sendsig consth gr121,__sendsig jmpi gr121 ; fill this jmpi delay slot ; the others are not done since they do not matter constn lr0,-1
stsp/newlib-ia16
1,655
newlib/libc/sys/a29khif/_tmpnam.S
; @(#)_tmpnam.s 1.2 90/10/14 21:57:36, AMD ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Copyright 1990 Advanced Micro Devices, Inc. ; ; This software is the property of Advanced Micro Devices, Inc (AMD) which ; specifically grants the user the right to modify, use and distribute this ; software provided this notice is not removed or altered. All other rights ; are reserved by AMD. ; ; AMD MAKES NO WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, WITH REGARD TO THIS ; SOFTWARE. IN NO EVENT SHALL AMD BE LIABLE FOR INCIDENTAL OR CONSEQUENTIAL ; DAMAGES IN CONNECTION WITH OR ARISING FROM THE FURNISHING, PERFORMANCE, OR ; USE OF THIS SOFTWARE. ; ; So that all may benefit from your experience, please report any problems ; or suggestions about this software to the 29K Technical Support Center at ; 800-29-29-AMD (800-292-9263) in the USA, or 0800-89-1131 in the UK, or ; 0031-11-1129 in Japan, toll free. The direct dial number is 512-462-4118. ; ; Advanced Micro Devices, Inc. ; 29K Support Products ; Mail Stop 573 ; 5900 E. Ben White Blvd. ; Austin, TX 78741 ; 800-292-9263 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; _tmpnam.s ; char *cp = _khif_tmpnam( char *bufr ); ; /* same as ANSI tmpnam(), but NULL arg is not allowed */ ; NOTE - Will not work on BSD (no tmpnam sys call) ; .file "_tmpnam.s" .include "sys/sysmac.h" .text .word 0x00030000 ; Debugger tag word .global __khif_tmpnam __khif_tmpnam: const tav,HIF_tmpnam @ asneq V_SYSCALL,gr1,gr1 @ jmpti tav,lr0 @ const tpc,_errno @ consth tpc,_errno @ store 0,0,tav,tpc @ jmpi lr0 @ constn v0,-1 .end
stsp/newlib-ia16
1,306
newlib/libc/sys/a29khif/_fstat.S
.file "_fstat.c" .sect .lit,lit gcc2_compiled.: .text .align 4 .global __fstat ;; syscalls used now -- .global _fstat .word 0x40000 __fstat: ;; syscalls used now -- _fstat: sub gr1,gr1,32 asgeu V_SPILL,gr1,gr126 add lr1,gr1,48 sll lr5,lr10,0 const gr116,__iostat consth gr116,__iostat calli lr0,gr116 sll lr2,lr5,0 sll lr10,gr96,0 jmpt lr10,L8 sll gr116,lr10,30 jmpf gr116,L3 add gr116,lr11,12 add gr117,lr11,12 const gr116,4096 store 0,0,gr116,gr117 add gr117,lr11,4 const gr116,1 jmp L4 store 0,0,gr116,gr117 L3: const gr117,8192 store 0,0,gr117,gr116 add gr116,lr11,4 store 0,0,gr117,gr116 L4: add gr117,lr11,20 const gr116,0 store 0,0,gr116,gr117 store 0,0,gr116,lr11 const gr116,_time consth gr116,_time calli lr0,gr116 const lr2,0 add gr116,lr11,16 store 0,0,gr96,gr116 sll lr2,lr5,0 const lr3,0 const lr7,__lseek consth lr7,__lseek calli lr0,lr7 const lr4,1 sll lr10,gr96,0 constn lr6,65535 cpneq gr116,lr10,lr6 jmpf gr116,L7 sll lr2,lr5,0 const lr3,0 calli lr0,lr7 const lr4,2 add gr116,lr11,8 store 0,0,gr96,gr116 cpneq gr96,gr96,lr6 jmpf gr96,L7 sll lr2,lr5,0 sll lr3,lr10,0 calli lr0,lr7 const lr4,0 cpneq gr96,gr96,lr6 jmpt gr96,L8 const gr96,0 L7: constn gr96,65535 L8: add gr1,gr1,32 nop jmpi lr0 asleu V_FILL,lr1,gr127
stsp/newlib-ia16
1,507
newlib/libc/sys/a29khif/_ioctl.S
; @(#)_ioctl.s 1.2 90/10/14 21:57:25, AMD ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Copyright 1990 Advanced Micro Devices, Inc. ; ; This software is the property of Advanced Micro Devices, Inc (AMD) which ; specifically grants the user the right to modify, use and distribute this ; software provided this notice is not removed or altered. All other rights ; are reserved by AMD. ; ; AMD MAKES NO WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, WITH REGARD TO THIS ; SOFTWARE. IN NO EVENT SHALL AMD BE LIABLE FOR INCIDENTAL OR CONSEQUENTIAL ; DAMAGES IN CONNECTION WITH OR ARISING FROM THE FURNISHING, PERFORMANCE, OR ; USE OF THIS SOFTWARE. ; ; So that all may benefit from your experience, please report any problems ; or suggestions about this software to the 29K Technical Support Center at ; 800-29-29-AMD (800-292-9263) in the USA, or 0800-89-1131 in the UK, or ; 0031-11-1129 in Japan, toll free. The direct dial number is 512-462-4118. ; ; Advanced Micro Devices, Inc. ; 29K Support Products ; Mail Stop 573 ; 5900 E. Ben White Blvd. ; Austin, TX 78741 ; 800-292-9263 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; _ioctl.s ; _ioctl( int fd ); ; .file "_ioctl.s" .include "sys/sysmac.h" .text .word 0x00030000 ; Debugger tag word .global __ioctl __ioctl: const tav,HIF_ioctl @ asneq V_SYSCALL,gr1,gr1 @ jmpti tav,lr0 @ const tpc,_errno @ consth tpc,_errno @ store 0,0,tav,tpc @ jmpi lr0 @ constn v0,-1 .end
stsp/newlib-ia16
1,533
newlib/libc/sys/a29khif/_read.S
; @(#)_read.s 1.4 90/10/14 21:57:32, AMD ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Copyright 1990 Advanced Micro Devices, Inc. ; ; This software is the property of Advanced Micro Devices, Inc (AMD) which ; specifically grants the user the right to modify, use and distribute this ; software provided this notice is not removed or altered. All other rights ; are reserved by AMD. ; ; AMD MAKES NO WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, WITH REGARD TO THIS ; SOFTWARE. IN NO EVENT SHALL AMD BE LIABLE FOR INCIDENTAL OR CONSEQUENTIAL ; DAMAGES IN CONNECTION WITH OR ARISING FROM THE FURNISHING, PERFORMANCE, OR ; USE OF THIS SOFTWARE. ; ; So that all may benefit from your experience, please report any problems ; or suggestions about this software to the 29K Technical Support Center at ; 800-29-29-AMD (800-292-9263) in the USA, or 0800-89-1131 in the UK, or ; 0031-11-1129 in Japan, toll free. The direct dial number is 512-462-4118. ; ; Advanced Micro Devices, Inc. ; 29K Support Products ; Mail Stop 573 ; 5900 E. Ben White Blvd. ; Austin, TX 78741 ; 800-292-9263 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; _read.s ; int nread = _read( int fd, char *buf, int count ); ; .file "_read.s" .include "sys/sysmac.h" .text .word 0x00050000 ; Debugger tag word .global __read __read: const tav,HIF_read @ asneq V_SYSCALL,gr1,gr1 @ jmpti tav,lr0 @ const tpc,_errno @ consth tpc,_errno @ store 0,0,tav,tpc @ jmpi lr0 @ constn v0,-1 .end
stsp/newlib-ia16
1,560
newlib/libc/sys/a29khif/_cycles.S
; @(#)_cycles.s 1.2 90/10/14 21:57:21, AMD ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Copyright 1990 Advanced Micro Devices, Inc. ; ; This software is the property of Advanced Micro Devices, Inc (AMD) which ; specifically grants the user the right to modify, use and distribute this ; software provided this notice is not removed or altered. All other rights ; are reserved by AMD. ; ; AMD MAKES NO WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, WITH REGARD TO THIS ; SOFTWARE. IN NO EVENT SHALL AMD BE LIABLE FOR INCIDENTAL OR CONSEQUENTIAL ; DAMAGES IN CONNECTION WITH OR ARISING FROM THE FURNISHING, PERFORMANCE, OR ; USE OF THIS SOFTWARE. ; ; So that all may benefit from your experience, please report any problems ; or suggestions about this software to the 29K Technical Support Center at ; 800-29-29-AMD (800-292-9263) in the USA, or 0800-89-1131 in the UK, or ; 0031-11-1129 in Japan, toll free. The direct dial number is 512-462-4118. ; ; Advanced Micro Devices, Inc. ; 29K Support Products ; Mail Stop 573 ; 5900 E. Ben White Blvd. ; Austin, TX 78741 ; 800-292-9263 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; _cycles.s ; struct { unsigned long low_ticks, long hi_ticks } = _cycles( ); ; .file "_cycles.s" .include "sys/sysmac.h" .text .word 0x00020000 ; Debugger tag word .global __cycles __cycles: const tav,HIF_cycles @ asneq V_SYSCALL,gr1,gr1 @ jmpti tav,lr0 @ const tpc,_errno @ consth tpc,_errno @ store 0,0,tav,tpc @ jmpi lr0 @ constn v0,-1 .end
stsp/newlib-ia16
1,559
newlib/libc/sys/a29khif/rename.S
; @(#)rename.s 1.3 90/10/14 21:57:54, AMD ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Copyright 1990 Advanced Micro Devices, Inc. ; ; This software is the property of Advanced Micro Devices, Inc (AMD) which ; specifically grants the user the right to modify, use and distribute this ; software provided this notice is not removed or altered. All other rights ; are reserved by AMD. ; ; AMD MAKES NO WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, WITH REGARD TO THIS ; SOFTWARE. IN NO EVENT SHALL AMD BE LIABLE FOR INCIDENTAL OR CONSEQUENTIAL ; DAMAGES IN CONNECTION WITH OR ARISING FROM THE FURNISHING, PERFORMANCE, OR ; USE OF THIS SOFTWARE. ; ; So that all may benefit from your experience, please report any problems ; or suggestions about this software to the 29K Technical Support Center at ; 800-29-29-AMD (800-292-9263) in the USA, or 0800-89-1131 in the UK, or ; 0031-11-1129 in Japan, toll free. The direct dial number is 512-462-4118. ; ; Advanced Micro Devices, Inc. ; 29K Support Products ; Mail Stop 573 ; 5900 E. Ben White Blvd. ; Austin, TX 78741 ; 800-292-9263 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; rename.s ; int cc = rename( char *from, char *to ); ; .file "rename.s" .include "sys/sysmac.h" .text .word 0x00040000 ; Debugger tag word .global _rename .global __rename _rename: __rename: const tav,HIF_rename @ asneq V_SYSCALL,gr1,gr1 @ jmpti tav,lr0 @ const tpc,_errno @ consth tpc,_errno @ store 0,0,tav,tpc @ jmpi lr0 @ constn v0,-1 .end
stsp/newlib-ia16
1,587
newlib/libc/sys/a29khif/_close.S
; @(#)_close.s 1.4 90/10/14 21:57:20, AMD ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Copyright 1990 Advanced Micro Devices, Inc. ; ; This software is the property of Advanced Micro Devices, Inc (AMD) which ; specifically grants the user the right to modify, use and distribute this ; software provided this notice is not removed or altered. All other rights ; are reserved by AMD. ; ; AMD MAKES NO WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, WITH REGARD TO THIS ; SOFTWARE. IN NO EVENT SHALL AMD BE LIABLE FOR INCIDENTAL OR CONSEQUENTIAL ; DAMAGES IN CONNECTION WITH OR ARISING FROM THE FURNISHING, PERFORMANCE, OR ; USE OF THIS SOFTWARE. ; ; So that all may benefit from your experience, please report any problems ; or suggestions about this software to the 29K Technical Support Center at ; 800-29-29-AMD (800-292-9263) in the USA, or 0800-89-1131 in the UK, or ; 0031-11-1129 in Japan, toll free. The direct dial number is 512-462-4118. ; ; Advanced Micro Devices, Inc.; 29K Support Products ; Mail Stop 573 ; 5900 E. Ben White Blvd. ; Austin, TX 78741 ; 800-292-9263 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; _close.s ; int cc = _close( int fd ); ; .file "_close.s" .include "sys/sysmac.h" .text .word 0x00030000 ; Debugger tag word .global __close ;; syscalls used now -- .global _close __close: ;; syscalls used now -- _close: const tav,HIF_close @ asneq V_SYSCALL,gr1,gr1 @ jmpti tav,lr0 @ const tpc,_errno @ consth tpc,_errno @ store 0,0,tav,tpc @ jmpi lr0 @ constn v0,-1 .end
stsp/newlib-ia16
7,204
newlib/libc/sys/a29khif/crt0.S
; @(#)crt0.s 2.7 90/10/15 13:17:57, AMD ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Copyright 1988, 1989, 1990 Advanced Micro Devices, Inc. ; ; This software is the property of Advanced Micro Devices, Inc (AMD) which ; specifically grants the user the right to modify, use and distribute this ; software provided this notice is not removed or altered. All other rights ; are reserved by AMD. ; ; AMD MAKES NO WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, WITH REGARD TO THIS ; SOFTWARE. IN NO EVENT SHALL AMD BE LIABLE FOR INCIDENTAL OR CONSEQUENTIAL ; DAMAGES IN CONNECTION WITH OR ARISING FROM THE FURNISHING, PERFORMANCE, OR ; USE OF THIS SOFTWARE. ; ; So that all may benefit from your experience, please report any problems ; or suggestions about this software to the 29K Technical Support Center at ; 800-29-29-AMD (800-292-9263) in the USA, or 0800-89-1131 in the UK, or ; 0031-11-1129 in Japan, toll free. The direct dial number is 512-462-4118. ; ; Advanced Micro Devices, Inc. ; 29K Support Products ; Mail Stop 573 ; 5900 E. Ben White Blvd. ; Austin, TX 78741 ; 800-292-9263 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; .file "crt0.s" ; crt0.s version 2.1-7 ; ; This module gets control from the OS. ; It saves away the Am29027 Mode register settings and ; then sets up the pointers to the resident spill and fill ; trap handlers. It then establishes argv and argc for passing ; to main. It then calls _main. If main returns, it calls _exit. ; ; void = start( ); ; NOTE - not C callable (no lead underscore) ; .include "sys/sysmac.h" ; ; .extern V_SPILL, V_FILL .comm __29027Mode, 8 ; A shadow of the mode register .comm __LibInit, 4 .comm __environ, 4 ; Environment variables, currently none. .text .extern _main, _exit .extern _memset .word 0 ; Terminating tag word .global start start: sub gr1, gr1, 6 * 4 asgeu V_SPILL, gr1, rab ; better not ever happen add lr1, gr1, 6 * 4 ; ; Initialize the .bss section to zero by using the memset library function. ; The .bss initialization section below has been commented out as it breaks ; XRAY29K that has been released. The operators sizeof and startof create ; new sections that are not recognized by XRAY29k, but will be implemented ; in the next release (2.0). ; ; const lr4, $sizeof(.bss) ; get size of .bss section to zero out ; consth lr4, $sizeof(.bss) ; const lr2, $startof(.bss) ; Get start address of .bss section ; consth lr2, $startof(.bss) ; const lr0, _memset ; address of memset function ; consth lr0, _memset ; calli lr0, lr0 ; call memset function ; const lr3, 0 ; Save the initial value of the Am29027's Mode register ; If your const tav,HIF_does @ asneq V_SYSCALL,gr1,gr1 @ jmpti tav,lr0 @ const tpc,_errno @ consth tpc,_errno @ store 0,0,tav,tpc @ jmpi lr0 @ constn v0,-1 not enter crt0 with value for Am29027's Mode register ; in gr96 and gr97, and also if the coprocessor is active uncomment the ; next 4 lines. ; const gr96, 0xfc00820 ; consth gr96, 0xfc00820 ; const gr97, 0x1375 ; store 1, 3, gr96, gr97 ; const gr98, __29027Mode consth gr98, __29027Mode store 0, 0, gr96, gr98 add gr98, gr98, 4 store 0, 0, gr97, gr98 ; ; Now call the const tav,HIF_to @ asneq V_SYSCALL,gr1,gr1 @ jmpti tav,lr0 @ const tpc,_errno @ consth tpc,_errno @ store 0,0,tav,tpc @ jmpi lr0 @ constn v0,-1 setup the spill and fill trap handlers ; const lr3, spill consth lr3, spill const lr2, V_SPILL const tav,HIF_setvec @ asneq V_SYSCALL,gr1,gr1 const lr3, fill consth lr3, fill const lr2, V_FILL const tav,HIF_setvec @ asneq V_SYSCALL,gr1,gr1 ; ; Set up dividu handler, since native one don't work?! ; Set it up by hand (FIXME) since HIF_settrap doesn't work either! ; ; const lr3,Edividu ; consth lr3,Edividu ; ; const lr2,35 ; const tav,HIF_settrap @ asneq V_SYSCALL,gr1,gr1 ; asge 0x50,gr121,0 ; check whether it failed ; const lr2,0x8000008c ; abs addr of dividu trap handler on EB ; consth lr2,0x8000008c ; store 0,0,lr3,lr2 ; Clobber vector FIXME ; ; Get the argv base address and calculate argc. ; const tav,HIF_getargs @ asneq V_SYSCALL,gr1,gr1 add lr3, v0, 0 ; argv add lr4, v0, 0 constn lr2, -1 argcloop: ; scan for NULL terminator load 0, 0, gr97, lr4 add lr4, lr4, 4 cpeq gr97, gr97, 0 jmpf gr97, argcloop add lr2, lr2, 1 ; ; Now call LibInit, if there is one. To aid runtime libraries ; that need to do some startup initialization, we have created ; a bss variable called LibInit. If the library doesn't need ; any run-time initialization, the variable is still 0. If the ; library does need run-time initialization, the library will ; contain a definition like ; void (*_LibInit)(void) = LibInitFunction; ; The linker will match up our bss LibInit with this data LibInit ; and the variable will not be 0. ; const lr0, __LibInit consth lr0, __LibInit load 0, 0, lr0, lr0 cpeq gr96, lr0, 0 jmpt gr96, NoLibInit nop calli lr0, lr0 nop NoLibInit: ; ; call main, passing it 2 arguments. main( argc, argv ) ; const lr0, _main consth lr0, _main calli lr0, lr0 nop ; ; call exit ; const lr0, _exit consth lr0, _exit calli lr0, lr0 add lr2, gr96, 0 ; ; Should never get here, but just in case ; loop: const tav,HIF_exit @ asneq V_SYSCALL,gr1,gr1 jmp loop nop .sbttl "Spill and Fill trap handlers" .eject ; ; SPILL, FILL trap handlers ; ; Note that these Spill and Fill trap handlers allow the OS to ; assume that the only registers of use are between gr1 and rfb. ; Therefore, if the OS desires to, it may simply preserve from ; lr0 for (rfb-gr1)/4 registers when doing a context save. ; ; ; Here is the spill handler ; ; spill registers from [*gr1..*rab) ; and move rab downto where gr1 points ; ; rab must change before rfb for signals to work ; ; On entry: rfb - rab = windowsize, gr1 < rab ; Near the end: rfb - rab > windowsize, gr1 == rab ; On exit: rfb - rab = windowsize, gr1 == rab ; .global spill spill: sub tav, rab, gr1 ; tav = number of bytes to spill srl tav, tav, 2 ; change byte count to word count sub tav, tav, 1 ; make count zero based mtsr cr, tav ; set Count Remaining register sub tav, rab, gr1 sub tav, rfb, tav ; pull down free bound and save it in rab add rab, gr1, 0 ; first pull down allocate bound storem 0, 0, lr0, tav ; store lr0..lr(tav) into rfb jmpi tpc ; return... add rfb, tav, 0 ; ; Here is the fill handler ; ; fill registers from [*rfb..*lr1) ; and move rfb upto where lr1 points. ; ; rab must change before rfb for signals to work ; ; On entry: rfb - rab = windowsize, lr1 > rfb ; Near the end: rfb - rab < windowsize, lr1 == rab + windowsize ; On exit: rfb - rab = windowsize, lr1 == rfb ; .global fill fill: const tav, 0x80 << 2 or tav, tav, rfb ; tav = ((rfb>>2) | 0x80)<<2 == [rfb]<<2 mtsr ipa, tav ; ipa = [rfb]<<2 == 1st reg to fill ; gr0 is now the first reg to spill sub tav, lr1, rfb ; tav = number of bytes to spill add rab, rab, tav ; push up allocate bound srl tav, tav, 2 ; change byte count to word count sub tav, tav, 1 ; make count zero based mtsr cr, tav ; set Count Remaining register loadm 0, 0, gr0, rfb ; load registers jmpi tpc ; return... add rfb, lr1, 0 ; ... first pushing up free bound .end
stsp/newlib-ia16
1,557
newlib/libc/sys/a29khif/_setvec.S
; @(#)_setvec.s 1.2 90/10/14 21:57:35, AMD ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Copyright 1990 Advanced Micro Devices, Inc. ; ; This software is the property of Advanced Micro Devices, Inc (AMD) which ; specifically grants the user the right to modify, use and distribute this ; software provided this notice is not removed or altered. All other rights ; are reserved by AMD. ; ; AMD MAKES NO WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, WITH REGARD TO THIS ; SOFTWARE. IN NO EVENT SHALL AMD BE LIABLE FOR INCIDENTAL OR CONSEQUENTIAL ; DAMAGES IN CONNECTION WITH OR ARISING FROM THE FURNISHING, PERFORMANCE, OR ; USE OF THIS SOFTWARE. ; ; So that all may benefit from your experience, please report any problems ; or suggestions about this software to the 29K Technical Support Center at ; 800-29-29-AMD (800-292-9263) in the USA, or 0800-89-1131 in the UK, or ; 0031-11-1129 in Japan, toll free. The direct dial number is 512-462-4118. ; ; Advanced Micro Devices, Inc. ; 29K Support Products ; Mail Stop 573 ; 5900 E. Ben White Blvd. ; Austin, TX 78741 ; 800-292-9263 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; _setvec.s ; int success = _setvec( int trap_no, void (*handler)( void ) ); ; .file "_setvec.s" .include "sys/sysmac.h" .text .word 0x00040000 ; Debugger tag word .global __setvec __setvec: const tav,HIF_setvec @ asneq V_SYSCALL,gr1,gr1 @ jmpti tav,lr0 @ const tpc,_errno @ consth tpc,_errno @ store 0,0,tav,tpc @ jmpi lr0 @ constn v0,-1 .end
stsp/newlib-ia16
1,982
newlib/libc/sys/a29khif/alloc.S
; ;(#)_alloc.s 1.4 90/10/14 21:57:19, AMD ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Copyright 1989, 1990 Advanced Micro Devices, Inc. ; ; This software is the property of Advanced Micro Devices, Inc (AMD) which ; specifically grants the user the right to modify, use and distribute this ; software provided this notice is not removed or altered. All other rights ; are reserved by AMD. ; ; AMD MAKES NO WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, WITH REGARD TO THIS ; SOFTWARE. IN NO EVENT SHALL AMD BE LIABLE FOR INCIDENTAL OR CONSEQUENTIAL ; DAMAGES IN CONNECTION WITH OR ARISING FROM THE FURNISHING, PERFORMANCE, OR ; USE OF THIS SOFTWARE. ; ; So that all may benefit from your experience, please report any problems ; or suggestions about this software to the 29K Technical Support Center at ; 800-29-29-AMD (800-292-9263) in the USA, or 0800-89-1131 in the UK, or ; 0031-11-1129 in Japan, toll free. The direct dial number is 512-462-4118. ; ; Advanced Micro Devices, Inc. ; 29K Support Products ; Mail Stop 573 ; 5900 E. Ben White Blvd. ; Austin, TX 78741 ; 800-292-9263 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; ; 07/06/89 (JS) Replaced call to const tav,HIF_macro ; and deleted call to reterr macro as a NULL needs to be ; returned on failure. ; _alloc.s ; void *vp = _sysalloc( int size ); ; .file "_alloc.s" .include "sys/sysmac.h" .text .word 0x00030000 ; Debugger tag word .global __sysalloc __sysalloc: const tav,HIF_alloc asneq V_SYSCALL,gr1,gr1 jmpti tav, lr0 const tpc, _errno consth tpc, _errno store 0, 0, tav, tpc jmpi lr0 const v0, 0 ; return NULL on error. ; ; int errret = _sysfree( void *addr, int size ); ; .global __sysfree __sysfree: const tav,HIF_free asneq V_SYSCALL,gr1,gr1 jmpti tav,lr0 const tpc,_errno consth tpc,_errno store 0,0,tav,tpc jmpi lr0 constn v0,-1 .end
stsp/newlib-ia16
1,533
newlib/libc/sys/a29khif/clock.S
; @(#)clock.s 1.3 90/10/14 21:57:43, AMD ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Copyright 1990 Advanced Micro Devices, Inc. ; ; This software is the property of Advanced Micro Devices, Inc (AMD) which ; specifically grants the user the right to modify, use and distribute this ; software provided this notice is not removed or altered. All other rights ; are reserved by AMD. ; ; AMD MAKES NO WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, WITH REGARD TO THIS ; SOFTWARE. IN NO EVENT SHALL AMD BE LIABLE FOR INCIDENTAL OR CONSEQUENTIAL ; DAMAGES IN CONNECTION WITH OR ARISING FROM THE FURNISHING, PERFORMANCE, OR ; USE OF THIS SOFTWARE. ; ; So that all may benefit from your experience, please report any problems ; or suggestions about this software to the 29K Technical Support Center at ; 800-29-29-AMD (800-292-9263) in the USA, or 0800-89-1131 in the UK, or ; 0031-11-1129 in Japan, toll free. The direct dial number is 512-462-4118. ; ; Advanced Micro Devices, Inc. ; 29K Support Products ; Mail Stop 573 ; 5900 E. Ben White Blvd. ; Austin, TX 78741 ; 800-292-9263 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; clock.s ; long ticks = clock( ); ; .file "clock.s" .include "sys/sysmac.h" .text .word 0x00020000 ; Debugger tag word .global _clock .global __clock _clock: __clock: const tav,HIF_clock @ asneq V_SYSCALL,gr1,gr1 @ jmpti tav,lr0 @ const tpc,_errno @ consth tpc,_errno @ store 0,0,tav,tpc @ jmpi lr0 @ constn v0,-1 .end
stsp/newlib-ia16
1,614
newlib/libc/sys/a29khif/_write.S
; @(#)_write.s 1.4 90/10/14 21:57:37, AMD ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Copyright 1990 Advanced Micro Devices, Inc. ; ; This software is the property of Advanced Micro Devices, Inc (AMD) which ; specifically grants the user the right to modify, use and distribute this ; software provided this notice is not removed or altered. All other rights ; are reserved by AMD. ; ; AMD MAKES NO WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, WITH REGARD TO THIS ; SOFTWARE. IN NO EVENT SHALL AMD BE LIABLE FOR INCIDENTAL OR CONSEQUENTIAL ; DAMAGES IN CONNECTION WITH OR ARISING FROM THE FURNISHING, PERFORMANCE, OR ; USE OF THIS SOFTWARE. ; ; So that all may benefit from your experience, please report any problems ; or suggestions about this software to the 29K Technical Support Center at ; 800-29-29-AMD (800-292-9263) in the USA, or 0800-89-1131 in the UK, or ; 0031-11-1129 in Japan, toll free. The direct dial number is 512-462-4118. ; ; Advanced Micro Devices, Inc. ; 29K Support Products ; Mail Stop 573 ; 5900 E. Ben White Blvd. ; Austin, TX 78741 ; 800-292-9263 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; _write.s ; int written = _write( int fd, char *buf, int count ); ; .file "_write.s" .include "sys/sysmac.h" .text .word 0x00050000 ; Debugger tag word .global __write ;; syscalls used now -- .global _write __write: ;; syscalls used now -- _write: const tav,HIF_write @ asneq V_SYSCALL,gr1,gr1 @ jmpti tav,lr0 @ const tpc,_errno @ consth tpc,_errno @ store 0,0,tav,tpc @ jmpi lr0 @ constn v0,-1 .end
stsp/newlib-ia16
1,334
newlib/libc/sys/a29khif/vec.S
; @(#)vec.s 1.2 90/10/14 21:58:01, AMD ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Copyright 1990 Advanced Micro Devices, Inc. ; ; This software is the property of Advanced Micro Devices, Inc (AMD) which ; specifically grants the user the right to modify, use and distribute this ; software provided this notice is not removed or altered. All other rights ; are reserved by AMD. ; ; AMD MAKES NO WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, WITH REGARD TO THIS ; SOFTWARE. IN NO EVENT SHALL AMD BE LIABLE FOR INCIDENTAL OR CONSEQUENTIAL ; DAMAGES IN CONNECTION WITH OR ARISING FROM THE FURNISHING, PERFORMANCE, OR ; USE OF THIS SOFTWARE. ; ; So that all may benefit from your experience, please report any problems ; or suggestions about this software to the 29K Technical Support Center at ; 800-29-29-AMD (800-292-9263) in the USA, or 0800-89-1131 in the UK, or ; 0031-11-1129 in Japan, toll free. The direct dial number is 512-462-4118. ; ; Advanced Micro Devices, Inc. ; 29K Support Products ; Mail Stop 573 ; 5900 E. Ben White Blvd. ; Austin, TX 78741 ; 800-292-9263 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; .global V_SPILL, V_FILL .global V_EPI_OS, V_BSD_OS .equ V_SPILL, 64 .equ V_FILL, 65 .equ V_BSD_OS, 66 .equ V_EPI_OS, 69 .end
stsp/newlib-ia16
1,558
newlib/libc/sys/a29khif/_settrap.S
; @(#)_settrap.s 2.2 90/10/14 21:57:34, AMD ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Copyright 1990 Advanced Micro Devices, Inc. ; ; This software is the property of Advanced Micro Devices, Inc (AMD) which ; specifically grants the user the right to modify, use and distribute this ; software provided this notice is not removed or altered. All other rights ; are reserved by AMD. ; ; AMD MAKES NO WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, WITH REGARD TO THIS ; SOFTWARE. IN NO EVENT SHALL AMD BE LIABLE FOR INCIDENTAL OR CONSEQUENTIAL ; DAMAGES IN CONNECTION WITH OR ARISING FROM THE FURNISHING, PERFORMANCE, OR ; USE OF THIS SOFTWARE. ; ; So that all may benefit from your experience, please report any problems ; or suggestions about this software to the 29K Technical Support Center at ; 800-29-29-AMD (800-292-9263) in the USA, or 0800-89-1131 in the UK, or ; 0031-11-1129 in Japan, toll free. The direct dial number is 512-462-4118. ; ; Advanced Micro Devices, Inc. ; 29K Support Products ; Mail Stop 573 ; 5900 E. Ben White Blvd. ; Austin, TX 78741 ; 800-292-9263 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; _settrap.s ; void *prevaddr = _settrap( int trapno, void *trapaddr ); ; .file "_settrap.s" .include "sys/sysmac.h" .text .word 0x00040000 ; Debugger tag word .global __settrap __settrap: const tav,HIF_settrap @ asneq V_SYSCALL,gr1,gr1 @ jmpti tav,lr0 @ const tpc,_errno @ consth tpc,_errno @ store 0,0,tav,tpc @ jmpi lr0 @ constn v0,-1 .end
stsp/newlib-ia16
12,702
newlib/libc/sys/a29khif/signal.S
;@(#)signal.s 2.15 90/10/14 21:57:55, AMD ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Copyright 1990 Advanced Micro Devices, Inc. ; ; This software is the property of Advanced Micro Devices, Inc (AMD) which ; specifically grants the user the right to modify, use and distribute this ; software provided this notice is not removed or altered. All other rights ; are reserved by AMD. ; ; AMD MAKES NO WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, WITH REGARD TO THIS ; SOFTWARE. IN NO EVENT SHALL AMD BE LIABLE FOR INCIDENTAL OR CONSEQUENTIAL ; DAMAGES IN CONNECTION WITH OR ARISING FROM THE FURNISHING, PERFORMANCE, OR ; USE OF THIS SOFTWARE. ; ; So that all may benefit from your experience, please report any problems ; or suggestions about this software to the 29K Technical Support Center at ; 800-29-29-AMD (800-292-9263) in the USA, or 0800-89-1131 in the UK, or ; 0031-11-1129 in Japan, toll free. The direct dial number is 512-462-4118. ; ; Advanced Micro Devices, Inc. ; 29K Support Products ; Mail Stop 573 ; 5900 E. Ben White Blvd. ; Austin, TX 78741 ; 800-292-9263 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; .file "signal.s" ; SigEntry is the address of an array of C-level user code signal handlers. ; They must return to the top-level before doing a sigret() return function. ; Nested signals are supported. .extern V_SPILL, V_FILL .extern fill ; In crt0.s .align 4 .comm WindowSize, 4 .data SigEntry: .word 0 ; reserved .word 0 ; adds. of #2 SIGINT handler .word 0 ; reserved .word 0 ; reserved .word 0 ; reserved .word 0 ; reserved .word 0 ; reserved .word 0 ; adds. of #8 SIGFPE handler .text .reg v0, gr96 .reg v1, gr97 .reg v2, gr98 .reg v3, gr99 .reg tav, gr121 .reg tpc, gr122 .reg lrp, gr123 .reg slp, gr124 .reg msp, gr125 .reg rab, gr126 .reg rfb, gr127 ;=================================================================== setjmp() ; int ; setjmp(label_t jmpbuf) ; { ; *jmpbuf = {gr1, msp, lr0, lr1}; ; return 0; ; } ; .global _setjmp _setjmp: store 0, 0, gr1, lr2 add lr2, lr2, 4 store 0, 0, msp, lr2 add lr2, lr2, 4 store 0, 0, lr0, lr2 add lr2, lr2, 4 store 0, 0, lr1, lr2 jmpi lr0 const v0, 0 ; ;==================================================================== longjmp() ; int ; longjmp(label_t jmpbuf, int value) ; { ; /* BUG: check for this ; if (msp > jmpbuf->msp || gr1 > jmpbuf->gr1) ; longjmperror(); ; */ ; ; gr1 = jmpbuf->gr1; ; lr2addr = jmpbuf->gr1 + 8; ; msp = jmpbuf->msp; ; ; /* saved lr1 is invalid if saved lr2addr > rfb */ ; if (lr2addr > rfb) { ; /* ; * None of the registers are useful. ; * Set rfb to lr2addr - 512 & rab to rfb - 512. ; * the FILL assert will take care of filling ; */ ; lr1 = jmpbuf->lr1; ; rab = lr2addr - windowsize; ; rfb = lr2addr; ; } ; ; lr0 = jmpbuf->lr0; ; if (rfb < lr1) ; raise V_FILL; ; return value; ; } ; .global _longjmp _longjmp: load 0, 0, tav, lr2 ; copy in gr1 add v1, lr2, 4 ; v1 points to msp ; make sure we return a non-zero value cpeq v0, lr3, 0 srl v0, v0, 31 or v0, lr3, v0 add gr1, tav, 0 ; now update gr1 add tav, tav, 8 ; calculate lr2addr load 0, 0, msp, v1 ; update msp from jmpbuf cpleu v3, tav, rfb ; if (lr2addr > rfb) jmpt v3, $1 ; { add v1, v1, 4 ; v1 points to lr0 add v2, v1, 4 ; v2 points to lr1 load 0, 0, lr1, v2 ; lr1 = value from jmpbuf sub v3, rfb, rab ; sub rab, tav, v3 ; rab = lr2addr - windowsize add rfb, tav, 0 ; rfb = lr2addr $1: ; } load 0, 0, lr0, v1 jmpi lr0 asgeu V_FILL, rfb, lr1 ; may fill from rfb to lr1 ; ;================================================================== sigcode ; About to deliver a signal to a user mode signal handler. ; msp+(15*4) = signal_number ; msp+(14*4) = gr1 ; msp+(13*4) = rab ; msp+(12*4) = PC0 ; msp+(11*4) = PC1 ; msp+(10*4) = PC2 ; msp+( 9*4) = CHA ; msp+( 8*4) = CHD ; msp+( 7*4) = CHC ; msp+( 6*4) = ALU ; msp+( 5*4) = OPS ; msp+( 4*4) = gr121 ; msp+( 3*4) = gr99 ; msp+( 2*4) = gr98 ; msp+( 1*4) = gr97 ; msp = gr96 ; The state of all the registers (except for msp, chc and rab) ; is the same as when the process was interrupted. ; ; We must make the stack and window consistent before calling the handler ; The orignal rab value is on the stack. The interrupt handler placed ; rfb-Windowsize in rab. This is required to support nested interrupts. ; ; Note that the window becomes incosistent only during certain ; critical sections in spill, fill, longjmp and sigcode. ; rfb - rab > windowsize => we are in spill ; rfb - rab < windowsize => we are in fill ; gr1 + 8 > rfb => we are in long-longjmp case ; In case of spill, fill and lonjmp; rab is modified first, ; so if we are in one of these critical sections, ; we set rab to rfb - WINDOWSIZE. ; .equ SIGCTX_SIZE, (16)*4 .equ SIGCTX_SIGNUMB, (15)*4 .equ SIGCTX_GR1_OFFSET, (14)*4 .equ SIGCTX_RAB_OFFSET, (13)*4 .equ SIGCTX_PC0_OFFSET, (12)*4 .equ SIGCTX_PC1_OFFSET, (11)*4 .equ SIGCTX_PC2_OFFSET, (10)*4 .equ SIGCTX_CHC_OFFSET, (7)*4 .equ SIGCTX_OPS_OFFSET, (5)*4 .equ SIGCTX_TAV_OFFSET, (4)*4 .global sigcode sigcode: ; -------------------------------------------------------- R-Stack fixup const v0, WindowSize ; get register cache size consth v0, WindowSize load 0, 0, v0, v0 add v2, msp, SIGCTX_RAB_OFFSET load 0, 0, v2, v2 ; get interrupted rab value sub v1, rfb, v2 ; determine if rfb-rab <= WINDOW_SIZE cpgeu v1, v1, v0 ; jmpt v1, nfill ; jmp if spill or 'normal' interrupt add v1, gr1, 8 cpgt v1, v1, rfb ; interrupted longjmp can look like fill jmpf v1, nfill ; test for long-longjmp interruption nop ; jmp if gr1+8 <= rfb ; Fixup signal stack to re-start interrupted fill ; backup pc1 -- this is needed for the partial fill case. ; Clear chc so an interrupted load/store does not restart. ; Reset rab to a window distance below rfb, rab shall be ; decremented again on re-starting the interrupted fill. ; The interrupt handler set rab=rfb-WindowSize. ; add v0, msp, SIGCTX_RAB_OFFSET store 0, 0, rab, v0 ; re-store (rfb-WindowSize) for rab const v2, fill consth v2, fill add v0, msp, SIGCTX_PC1_OFFSET store 0, 0, v2, v0 sub v2, v2, 4 ; determine pc0 add v0, msp, SIGCTX_PC0_OFFSET store 0, 0, v2, v0 const v2, 0 ; clear chc add v0, msp, SIGCTX_CHC_OFFSET store 0, 0, v2, v0 nfill: cpgt v0, gr1, rfb ; if gr1 > rfb then gr1 = rfb jmpt v0, lower cplt v0, gr1, rab ; if gr1 < rab then gr1 = rab jmpt v0, raise nop ; -------------------------------------------------------- save_regs sig1: sub msp, msp, (4+2+25)*4 ; reserve space for regs mfsr gr96, ipc mfsr gr97, ipa mfsr gr98, ipb mfsr gr99, q mtsrim cr, 4-1 storem 0, 0, gr96, msp ; "push" registers stack support add gr96, lr1, 0 add gr97, rfb, 0 mtsrim cr, 2-1 add gr99, msp, 2*4 storem 0, 0, gr96, gr99 ; "push" remaining global registers mtsrim cr, 25-1 ; gr100-gr124 add gr96, msp, (4+2)*4 storem 0, 0, gr100, gr96 ; ; -------------------------------------------------------- Dummy Call .equ RALLOC, 4*4 ; make space for function calls add v0, rfb, 0 ; store original rfb sub gr1, gr1, RALLOC asgeu V_SPILL, gr1, rab add lr1, v0, 0 ; set lr1 = original rfb add v1, msp, (4+2+25)*4 + SIGCTX_SIGNUMB load 0, 0, lr2, v1 ; restore signal number sub v1, lr2, 1 ; get handler index sll v1, v1, 2 ; point to addresses ; ; -------------------------------------------------------- call C-level ; Handler must not use HIF services other than the _sigret() type. const v0, SigEntry consth v0, SigEntry add v0, v0, v1 load 0, 0, v0, v0 ; determine if handler registered cpeq v1, v0, 0 jmpt v1, NoHandler nop calli lr0, v0 ; call C-level signal handler nop ; ; -------------------------------------------------------- default return NoHandler: jmp __sigdfl nop ; -------------------------------------------------------- support bits lower: sll gr1, rfb, 0 jmp sig1 nop raise: sll gr1, rab, 0 jmp sig1 nop /* ; -------------------------------------------------------- repair_regs mtsrim cr, 4-1 loadm 0, 0, gr96, msp mtsr ipc, gr96 mtsr ipa, gr97 mtsr ipb, gr98 mtsr Q, gr99 ; "pop" registers stack support mtsrim cr, 2-1 add gr99, msp, 2*4 loadm 0, 0, gr96, gr99 add lr1, gr96, 0 add rfb, gr97, 0 ; "pop" remaining global registers mtsrim cr, 25-1 ; gr100-gr124 add gr96, msp, (4+2)*4 loadm 0, 0, gr100, gr96 add msp, msp, (4+2+25)*4 ; repair msp to save_regs entry value ; -------------------------------------------------------- end repair */ ; ======================================================== _sigret() .global __sigret __sigret: ; repair_regs ; -------------------------------------------------------- repair_regs mtsrim cr, 4-1 loadm 0, 0, gr96, msp mtsr ipc, gr96 mtsr ipa, gr97 mtsr ipb, gr98 mtsr q, gr99 ; "pop" registers stack support mtsrim cr, 2-1 add gr99, msp, 2*4 loadm 0, 0, gr96, gr99 add lr1, gr96, 0 add rfb, gr97, 0 ; "pop" remaining global registers mtsrim cr, 25-1 ; gr100-gr124 add gr96, msp, (4+2)*4 loadm 0, 0, gr100, gr96 add msp, msp, (4+2+25)*4 ; repair msp to save_regs entry value ; -------------------------------------------------------- end repair const tav, 323 ; HIF _sigret asneq 69, gr1,gr1 halt ; commit suicide if returns ; ======================================================== _sigdfl() .global __sigdfl __sigdfl: ; repair_regs ; -------------------------------------------------------- repair_regs mtsrim cr, 4-1 loadm 0, 0, gr96, msp mtsr ipc, gr96 mtsr ipa, gr97 mtsr ipb, gr98 mtsr q, gr99 ; "pop" registers stack support mtsrim cr, 2-1 add gr99, msp, 2*4 loadm 0, 0, gr96, gr99 add lr1, gr96, 0 add rfb, gr97, 0 ; "pop" remaining global registers mtsrim cr, 25-1 ; gr100-gr124 add gr96, msp, (4+2)*4 loadm 0, 0, gr100, gr96 add msp, msp, (4+2+25)*4 ; repair msp to save_regs entry value ; -------------------------------------------------------- end repair const tav, 322 ; HIF _sigdfl asneq 69, gr1,gr1 halt ; commit suicide if returns ; ======================================================== _sigrep() __sigrep: .global __sigrep ; repair_regs ; -------------------------------------------------------- repair_regs mtsrim cr, 4-1 loadm 0, 0, gr96, msp mtsr ipc, gr96 mtsr ipa, gr97 mtsr ipb, gr98 mtsr q, gr99 ; "pop" registers stack support mtsrim cr, 2-1 add gr99, msp, 2*4 loadm 0, 0, gr96, gr99 add lr1, gr96, 0 add rfb, gr97, 0 ; "pop" remaining global registers mtsrim cr, 25-1 ; gr100-gr124 add gr96, msp, (4+2)*4 loadm 0, 0, gr100, gr96 add msp, msp, (4+2+25)*4 ; repair msp to save_regs entry value ; -------------------------------------------------------- end repair const tav, 324 ; HIF _sigrep asneq 69, gr1,gr1 halt ; commit suicide if returns ; ======================================================== _sigskp() .global __sigskp __sigskp: ; repair_regs ; -------------------------------------------------------- repair_regs mtsrim cr, 4-1 loadm 0, 0, gr96, msp mtsr ipc, gr96 mtsr ipa, gr97 mtsr ipb, gr98 mtsr q, gr99 ; "pop" registers stack support mtsrim cr, 2-1 add gr99, msp, 2*4 loadm 0, 0, gr96, gr99 add lr1, gr96, 0 add rfb, gr97, 0 ; "pop" remaining global registers mtsrim cr, 25-1 ; gr100-gr124 add gr96, msp, (4+2)*4 loadm 0, 0, gr100, gr96 add msp, msp, (4+2+25)*4 ; repair msp to save_regs entry value ; -------------------------------------------------------- end repair const tav, 325 ; HIF _sigskp asneq 69, gr1,gr1 halt ; commit suicide if returns ; ======================================================== _sendsig() ; lr2 = signal number .global _raise .global __sendsig _raise: __sendsig: const tav, 326 ; HIF sendsig asneq 69, gr1,gr1 jmpi lr0 nop ; ; ======================================================== signal() ; lr2 = signal number ; lr3 = handler address .global _signal _signal: ; the memory variable WindowSize must be initalised at the ; start when rfb and rab are a window size apart. const v0, WindowSize ; get register cache size consth v0, WindowSize load 0, 0, v1, v0 cpeq v1, v1, 0 jmpf v1, WindowSizeOK sub v1, rfb, rab ; rfb-rab = WINDOW_SIZE store 0, 0, v1, v0 WindowSizeOK: const v1, SigEntry consth v1, SigEntry sub v3, lr2, 1 ; get handler index sll v3, v3, 2 ; pointer to addresses add v1, v1, v3 store 0,0, lr3, v1 ; save new handler const lr2, sigcode consth lr2, sigcode ;Fall through to __signal ; ======================================================== _signal() .global __signal __signal: const tav, 321 ; HIF signal asneq 69, gr1,gr1 jmpi lr0 nop
stsp/newlib-ia16
1,507
newlib/libc/sys/a29khif/_setim.S
; @(#)_setim.s 2.2 90/10/14 21:57:33, AMD ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Copyright 1990 Advanced Micro Devices, Inc. ; ; This software is the property of Advanced Micro Devices, Inc (AMD) which ; specifically grants the user the right to modify, use and distribute this ; software provided this notice is not removed or altered. All other rights ; are reserved by AMD. ; ; AMD MAKES NO WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, WITH REGARD TO THIS ; SOFTWARE. IN NO EVENT SHALL AMD BE LIABLE FOR INCIDENTAL OR CONSEQUENTIAL ; DAMAGES IN CONNECTION WITH OR ARISING FROM THE FURNISHING, PERFORMANCE, OR ; USE OF THIS SOFTWARE. ; ; So that all may benefit from your experience, please report any problems ; or suggestions about this software to the 29K Technical Support Center at ; 800-29-29-AMD (800-292-9263) in the USA, or 0800-89-1131 in the UK, or ; 0031-11-1129 in Japan, toll free. The direct dial number is 512-462-4118. ; ; Advanced Micro Devices, Inc. ; 29K Support Products ; Mail Stop 573 ; 5900 E. Ben White Blvd. ; Austin, TX 78741 ; 800-292-9263 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; _setim.s ; _setim( im, di ); ; .file "_setim.s" .include "sys/sysmac.h" .text .word 0x00040000 ; Debugger tag word .global __setim __setim: const tav,HIF_setim @ asneq V_SYSCALL,gr1,gr1 @ jmpti tav,lr0 @ const tpc,_errno @ consth tpc,_errno @ store 0,0,tav,tpc @ jmpi lr0 @ constn v0,-1 .end
stsp/newlib-ia16
1,500
newlib/libc/sys/a29khif/_exit.S
; @(#)_exit.s 1.2 90/10/14 21:57:22, AMD ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Copyright 1990 Advanced Micro Devices, Inc. ; ; This software is the property of Advanced Micro Devices, Inc (AMD) which ; specifically grants the user the right to modify, use and distribute this ; software provided this notice is not removed or altered. All other rights ; are reserved by AMD. ; ; AMD MAKES NO WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, WITH REGARD TO THIS ; SOFTWARE. IN NO EVENT SHALL AMD BE LIABLE FOR INCIDENTAL OR CONSEQUENTIAL ; DAMAGES IN CONNECTION WITH OR ARISING FROM THE FURNISHING, PERFORMANCE, OR ; USE OF THIS SOFTWARE. ; ; So that all may benefit from your experience, please report any problems ; or suggestions about this software to the 29K Technical Support Center at ; 800-29-29-AMD (800-292-9263) in the USA, or 0800-89-1131 in the UK, or ; 0031-11-1129 in Japan, toll free. The direct dial number is 512-462-4118. ; ; Advanced Micro Devices, Inc. ; 29K Support Products ; Mail Stop 573 ; 5900 E. Ben White Blvd. ; Austin, TX 78741 ; 800-292-9263 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; _exit.s ; _exit( int rc ); ; .file "_exit.s" .include "sys/sysmac.h" .text .word 0x00030000 ; Debugger tag word .global __exit __exit: const tav,HIF_exit @ asneq V_SYSCALL,gr1,gr1 @ jmpti tav,lr0 @ const tpc,_errno @ consth tpc,_errno @ store 0,0,tav,tpc @ jmpi lr0 @ constn v0,-1 .end
stsp/newlib-ia16
1,514
newlib/libc/sys/a29khif/_iowait.S
; @(#)_iowait.s 1.3 90/10/14 21:57:27, AMD ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Copyright 1990 Advanced Micro Devices, Inc. ; ; This software is the property of Advanced Micro Devices, Inc (AMD) which ; specifically grants the user the right to modify, use and distribute this ; software provided this notice is not removed or altered. All other rights ; are reserved by AMD. ; ; AMD MAKES NO WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, WITH REGARD TO THIS ; SOFTWARE. IN NO EVENT SHALL AMD BE LIABLE FOR INCIDENTAL OR CONSEQUENTIAL ; DAMAGES IN CONNECTION WITH OR ARISING FROM THE FURNISHING, PERFORMANCE, OR ; USE OF THIS SOFTWARE. ; ; So that all may benefit from your experience, please report any problems ; or suggestions about this software to the 29K Technical Support Center at ; 800-29-29-AMD (800-292-9263) in the USA, or 0800-89-1131 in the UK, or ; 0031-11-1129 in Japan, toll free. The direct dial number is 512-462-4118. ; ; Advanced Micro Devices, Inc. ; 29K Support Products ; Mail Stop 573 ; 5900 E. Ben White Blvd. ; Austin, TX 78741 ; 800-292-9263 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; _iowait.s ; _iowait( int fd ); ; .file "_iowait.s" .include "sys/sysmac.h" .text .word 0x00030000 ; Debugger tag word .global __iowait __iowait: const tav,HIF_iowait @ asneq V_SYSCALL,gr1,gr1 @ jmpti tav,lr0 @ const tpc,_errno @ consth tpc,_errno @ store 0,0,tav,tpc @ jmpi lr0 @ constn v0,-1 .end
stsp/newlib-ia16
1,522
newlib/libc/sys/a29khif/getargs.S
; @(#)getargs.s 1.2 90/10/14 21:57:44, AMD ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Copyright 1990 Advanced Micro Devices, Inc. ; ; This software is the property of Advanced Micro Devices, Inc (AMD) which ; specifically grants the user the right to modify, use and distribute this ; software provided this notice is not removed or altered. All other rights ; are reserved by AMD. ; ; AMD MAKES NO WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, WITH REGARD TO THIS ; SOFTWARE. IN NO EVENT SHALL AMD BE LIABLE FOR INCIDENTAL OR CONSEQUENTIAL ; DAMAGES IN CONNECTION WITH OR ARISING FROM THE FURNISHING, PERFORMANCE, OR ; USE OF THIS SOFTWARE. ; ; So that all may benefit from your experience, please report any problems ; or suggestions about this software to the 29K Technical Support Center at ; 800-29-29-AMD (800-292-9263) in the USA, or 0800-89-1131 in the UK, or ; 0031-11-1129 in Japan, toll free. The direct dial number is 512-462-4118. ; ; Advanced Micro Devices, Inc. ; 29K Support Products ; Mail Stop 573 ; 5900 E. Ben White Blvd. ; Austin, TX 78741 ; 800-292-9263 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; _getargs.s ; void _getargs( void ); ; .file "_getargs.s" .include "sys/sysmac.h" .text .word 0x00020000 ; Debugger tag word .global __getargs __getargs: const tav,HIF_getargs @ asneq V_SYSCALL,gr1,gr1 @ jmpti tav,lr0 @ const tpc,_errno @ consth tpc,_errno @ store 0,0,tav,tpc @ jmpi lr0 @ constn v0,-1 .end
stsp/newlib-ia16
1,543
newlib/libc/sys/a29khif/systime.S
; @(#)systime.s 1.2 90/10/14 21:57:59, AMD ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Copyright 1990 Advanced Micro Devices, Inc. ; ; This software is the property of Advanced Micro Devices, Inc (AMD) which ; specifically grants the user the right to modify, use and distribute this ; software provided this notice is not removed or altered. All other rights ; are reserved by AMD. ; ; AMD MAKES NO WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, WITH REGARD TO THIS ; SOFTWARE. IN NO EVENT SHALL AMD BE LIABLE FOR INCIDENTAL OR CONSEQUENTIAL ; DAMAGES IN CONNECTION WITH OR ARISING FROM THE FURNISHING, PERFORMANCE, OR ; USE OF THIS SOFTWARE. ; ; So that all may benefit from your experience, please report any problems ; or suggestions about this software to the 29K Technical Support Center at ; 800-29-29-AMD (800-292-9263) in the USA, or 0800-89-1131 in the UK, or ; 0031-11-1129 in Japan, toll free. The direct dial number is 512-462-4118. ; ; Advanced Micro Devices, Inc. ; 29K Support Products ; Mail Stop 573 ; 5900 E. Ben White Blvd. ; Austin, TX 78741 ; 800-292-9263 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; _time.s ; time_t secs = time( time_t *secs ); ; ; NOTE - Will not work on BSD (no time sys call) ; .file "systime.s" .include "sys/sysmac.h" .text .word 0x00030000 ; Debugger tag word .global _time _time: const tav,HIF_time @ asneq V_SYSCALL,gr1,gr1 cpeq gr97, lr2, 0 jmpti gr97, lr0 nop jmpi lr0 store 0, 0, gr96, lr2 .end
stsp/newlib-ia16
2,125
newlib/libc/sys/a29khif/_alloc.S
; @(#)_alloc.s 1.4 90/10/14 21:57:19, AMD ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Copyright 1989, 1990 Advanced Micro Devices, Inc. ; ; This software is the property of Advanced Micro Devices, Inc (AMD) which ; specifically grants the user the right to modify, use and distribute this ; software provided this notice is not removed or altered. All other rights ; are reserved by AMD. ; ; AMD MAKES NO WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, WITH REGARD TO THIS ; SOFTWARE. IN NO EVENT SHALL AMD BE LIABLE FOR INCIDENTAL OR CONSEQUENTIAL ; DAMAGES IN CONNECTION WITH OR ARISING FROM THE FURNISHING, PERFORMANCE, OR ; USE OF THIS SOFTWARE. ; ; So that all may benefit from your experience, please report any problems ; or suggestions about this software to the 29K Technical Support Center at ; 800-29-29-AMD (800-292-9263) in the USA, or 0800-89-1131 in the UK, or ; 0031-11-1129 in Japan, toll free. The direct dial number is 512-462-4118. ; ; Advanced Micro Devices, Inc. ; 29K Support Products ; Mail Stop 573 ; 5900 E. Ben White Blvd. ; Austin, TX 78741 ; 800-292-9263 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; ; 07/06/89 (JS) Replaced call to const tav,HIF_macro @ asneq V_SYSCALL,gr1,gr1 @ jmpti tav,lr0 @ const tpc,_errno @ consth tpc,_errno @ store 0,0,tav,tpc @ jmpi lr0 @ constn v0,-1 to syscall macro, ; and deleted call to reterr macro as a NULL needs to be ; returned on failure. ; _alloc.s ; void *vp = _sysalloc( int size ); ; .file "_alloc.s" .include "sys/sysmac.h" .text .word 0x00030000 ; Debugger tag word .global __sysalloc __sysalloc: const tav,HIF_alloc @ asneq V_SYSCALL,gr1,gr1 jmpti tav, lr0 const tpc, _errno consth tpc, _errno store 0, 0, tav, tpc jmpi lr0 const v0, 0 ; return NULL on error. ; ; int errret = _sysfree( void *addr, int size ); ; .global __sysfree __sysfree: const tav,HIF_free @ asneq V_SYSCALL,gr1,gr1 @ jmpti tav,lr0 @ const tpc,_errno @ consth tpc,_errno @ store 0,0,tav,tpc @ jmpi lr0 @ constn v0,-1 .end
stsp/newlib-ia16
1,511
newlib/libc/sys/a29khif/_query.S
; @(#)_query.s 2.2 90/10/14 21:57:31, AMD ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Copyright 1990 Advanced Micro Devices, Inc. ; ; This software is the property of Advanced Micro Devices, Inc (AMD) which ; specifically grants the user the right to modify, use and distribute this ; software provided this notice is not removed or altered. All other rights ; are reserved by AMD. ; ; AMD MAKES NO WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, WITH REGARD TO THIS ; SOFTWARE. IN NO EVENT SHALL AMD BE LIABLE FOR INCIDENTAL OR CONSEQUENTIAL ; DAMAGES IN CONNECTION WITH OR ARISING FROM THE FURNISHING, PERFORMANCE, OR ; USE OF THIS SOFTWARE. ; ; So that all may benefit from your experience, please report any problems ; or suggestions about this software to the 29K Technical Support Center at ; 800-29-29-AMD (800-292-9263) in the USA, or 0800-89-1131 in the UK, or ; 0031-11-1129 in Japan, toll free. The direct dial number is 512-462-4118. ; ; Advanced Micro Devices, Inc. ; 29K Support Products ; Mail Stop 573 ; 5900 E. Ben White Blvd. ; Austin, TX 78741 ; 800-292-9263 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; _query.s ; _query( query_code ); ; .file "_query.s" .include "sys/sysmac.h" .text .word 0x00030000 ; Debugger tag word .global __query __query: const tav,HIF_query @ asneq V_SYSCALL,gr1,gr1 @ jmpti tav,lr0 @ const tpc,_errno @ consth tpc,_errno @ store 0,0,tav,tpc @ jmpi lr0 @ constn v0,-1 .end
stsp/newlib-ia16
1,505
newlib/libc/sys/a29khif/_gettz.S
; @(#)_gettz.s 2.2 90/10/14 21:57:24, AMD ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Copyright 1990 Advanced Micro Devices, Inc. ; ; This software is the property of Advanced Micro Devices, Inc (AMD) which ; specifically grants the user the right to modify, use and distribute this ; software provided this notice is not removed or altered. All other rights ; are reserved by AMD. ; ; AMD MAKES NO WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, WITH REGARD TO THIS ; SOFTWARE. IN NO EVENT SHALL AMD BE LIABLE FOR INCIDENTAL OR CONSEQUENTIAL ; DAMAGES IN CONNECTION WITH OR ARISING FROM THE FURNISHING, PERFORMANCE, OR ; USE OF THIS SOFTWARE. ; ; So that all may benefit from your experience, please report any problems ; or suggestions about this software to the 29K Technical Support Center at ; 800-29-29-AMD (800-292-9263) in the USA, or 0800-89-1131 in the UK, or ; 0031-11-1129 in Japan, toll free. The direct dial number is 512-462-4118. ; ; Advanced Micro Devices, Inc. ; 29K Support Products ; Mail Stop 573 ; 5900 E. Ben White Blvd. ; Austin, TX 78741 ; 800-292-9263 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; _gettz.s ; _gettz( void ); ; .file "_gettz.s" .include "sys/sysmac.h" .text .word 0x00020000 ; Debugger tag word .global __gettz __gettz: const tav,HIF_gettz @ asneq V_SYSCALL,gr1,gr1 @ jmpti tav,lr0 @ const tpc,_errno @ consth tpc,_errno @ store 0,0,tav,tpc @ jmpi lr0 @ constn v0,-1 .end
stsp/newlib-ia16
1,579
newlib/libc/sys/a29khif/_iostat.S
;---------------------------------------------------------------------------- ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Copyright 1990 Advanced Micro Devices, Inc. ; ; This software is the property of Advanced Micro Devices, Inc (AMD) which ; specifically grants the user the right to modify, use and distribute this ; software provided this notice is not removed or altered. All other rights ; are reserved by AMD. ; ; AMD MAKES NO WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, WITH REGARD TO THIS ; SOFTWARE. IN NO EVENT SHALL AMD BE LIABLE FOR INCIDENTAL OR CONSEQUENTIAL ; DAMAGES IN CONNECTION WITH OR ARISING FROM THE FURNISHING, PERFORMANCE, OR ; USE OF THIS SOFTWARE. ; ; So that all may benefit from your experience, please report any problems ; or suggestions about this software to the 29K Technical Support Center at ; 800-29-29-AMD (800-292-9263) in the USA, or 0800-89-1131 in the UK, or ; 0031-11-1129 in Japan, toll free. The direct dial number is 512-462-4118. ; ; Advanced Micro Devices, Inc. ; 29K Support Products ; Mail Stop 573 ; 5900 E. Ben White Blvd. ; Austin, TX 78741 ; 800-292-9263 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; _iostat.s ; _iostat( int fd ); ; .file "_iostat.s" .include "sys/sysmac.h" .text .word 0x00030000 ; Debugger tag word .global __iostat .global _iostat __iostat: _iostat: const tav,HIF_iostat @ asneq V_SYSCALL,gr1,gr1 @ jmpti tav,lr0 @ const tpc,_errno @ consth tpc,_errno @ store 0,0,tav,tpc @ jmpi lr0 @ constn v0,-1 .end
stsp/newlib-ia16
1,614
newlib/libc/sys/a29khif/_lseek.S
; @(#)_lseek.s 1.4 90/10/14 21:57:28, AMD ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Copyright 1990 Advanced Micro Devices, Inc. ; ; This software is the property of Advanced Micro Devices, Inc (AMD) which ; specifically grants the user the right to modify, use and distribute this ; software provided this notice is not removed or altered. All other rights ; are reserved by AMD. ; ; AMD MAKES NO WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, WITH REGARD TO THIS ; SOFTWARE. IN NO EVENT SHALL AMD BE LIABLE FOR INCIDENTAL OR CONSEQUENTIAL ; DAMAGES IN CONNECTION WITH OR ARISING FROM THE FURNISHING, PERFORMANCE, OR ; USE OF THIS SOFTWARE. ; ; So that all may benefit from your experience, please report any problems ; or suggestions about this software to the 29K Technical Support Center at ; 800-29-29-AMD (800-292-9263) in the USA, or 0800-89-1131 in the UK, or ; 0031-11-1129 in Japan, toll free. The direct dial number is 512-462-4118. ; ; Advanced Micro Devices, Inc. ; 29K Support Products ; Mail Stop 573 ; 5900 E. Ben White Blvd. ; Austin, TX 78741 ; 800-292-9263 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; _lseek.s ; int cc = _lseek( int fd, long offset, int whence ); ; .file "_lseek.s" .include "sys/sysmac.h" .text .word 0x00050000 ; Debugger tag word .global __lseek ;; syscalls used now -- .global _lseek __lseek: ;; syscalls used now -- _lseek: const tav,HIF_lseek @ asneq V_SYSCALL,gr1,gr1 @ jmpti tav,lr0 @ const tpc,_errno @ consth tpc,_errno @ store 0,0,tav,tpc @ jmpi lr0 @ constn v0,-1 .end
stsp/newlib-ia16
1,577
newlib/libc/sys/a29khif/remove.S
; @(#)remove.s 1.3 90/10/14 21:57:53, AMD ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Copyright 1990 Advanced Micro Devices, Inc. ; ; This software is the property of Advanced Micro Devices, Inc (AMD) which ; specifically grants the user the right to modify, use and distribute this ; software provided this notice is not removed or altered. All other rights ; are reserved by AMD. ; ; AMD MAKES NO WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, WITH REGARD TO THIS ; SOFTWARE. IN NO EVENT SHALL AMD BE LIABLE FOR INCIDENTAL OR CONSEQUENTIAL ; DAMAGES IN CONNECTION WITH OR ARISING FROM THE FURNISHING, PERFORMANCE, OR ; USE OF THIS SOFTWARE. ; ; So that all may benefit from your experience, please report any problems ; or suggestions about this software to the 29K Technical Support Center at ; 800-29-29-AMD (800-292-9263) in the USA, or 0800-89-1131 in the UK, or ; 0031-11-1129 in Japan, toll free. The direct dial number is 512-462-4118. ; ; Advanced Micro Devices, Inc. ; 29K Support Products ; Mail Stop 573 ; 5900 E. Ben White Blvd. ; Austin, TX 78741 ; 800-292-9263 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; remove.s ; int cc = remove( char *path ); ; .file "remove.s" .include "sys/sysmac.h" .text .word 0x00030000 ; Debugger tag word .global _remove .global __remove .global __unlink _remove: __remove: __unlink: const tav,HIF_remove @ asneq V_SYSCALL,gr1,gr1 @ jmpti tav,lr0 @ const tpc,_errno @ consth tpc,_errno @ store 0,0,tav,tpc @ jmpi lr0 @ constn v0,-1 .end
stsp/newlib-ia16
1,528
newlib/libc/sys/a29khif/_getpsiz.S
; @(#)_getpsiz.s 1.2 90/10/14 21:57:23, AMD ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Copyright 1990 Advanced Micro Devices, Inc. ; ; This software is the property of Advanced Micro Devices, Inc (AMD) which ; specifically grants the user the right to modify, use and distribute this ; software provided this notice is not removed or altered. All other rights ; are reserved by AMD. ; ; AMD MAKES NO WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, WITH REGARD TO THIS ; SOFTWARE. IN NO EVENT SHALL AMD BE LIABLE FOR INCIDENTAL OR CONSEQUENTIAL ; DAMAGES IN CONNECTION WITH OR ARISING FROM THE FURNISHING, PERFORMANCE, OR ; USE OF THIS SOFTWARE. ; ; So that all may benefit from your experience, please report any problems ; or suggestions about this software to the 29K Technical Support Center at ; 800-29-29-AMD (800-292-9263) in the USA, or 0800-89-1131 in the UK, or ; 0031-11-1129 in Japan, toll free. The direct dial number is 512-462-4118. ; ; Advanced Micro Devices, Inc. ; 29K Support Products ; Mail Stop 573 ; 5900 E. Ben White Blvd. ; Austin, TX 78741 ; 800-292-9263 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; _getpsiz.s ; int size = _getpsiz( ); ; .file "_getpsiz.s" .include "sys/sysmac.h" .text .word 0x00020000 ; Debugger tag word .global __getpsiz __getpsiz: const tav,HIF_getpagesize @ asneq V_SYSCALL,gr1,gr1 @ jmpti tav,lr0 @ const tpc,_errno @ consth tpc,_errno @ store 0,0,tav,tpc @ jmpi lr0 @ constn v0,-1 .end
stsp/newlib-ia16
1,721
newlib/libc/sys/a29khif/getenv.S
; @(#)getenv.s 1.4 90/10/14 21:57:45, AMD ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Copyright 1990 Advanced Micro Devices, Inc. ; ; This software is the property of Advanced Micro Devices, Inc (AMD) which ; specifically grants the user the right to modify, use and distribute this ; software provided this notice is not removed or altered. All other rights ; are reserved by AMD. ; ; AMD MAKES NO WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, WITH REGARD TO THIS ; SOFTWARE. IN NO EVENT SHALL AMD BE LIABLE FOR INCIDENTAL OR CONSEQUENTIAL ; DAMAGES IN CONNECTION WITH OR ARISING FROM THE FURNISHING, PERFORMANCE, OR ; USE OF THIS SOFTWARE. ; ; So that all may benefit from your experience, please report any problems ; or suggestions about this software to the 29K Technical Support Center at ; 800-29-29-AMD (800-292-9263) in the USA, or 0800-89-1131 in the UK, or ; 0031-11-1129 in Japan, toll free. The direct dial number is 512-462-4118. ; ; Advanced Micro Devices, Inc. ; 29K Support Products ; Mail Stop 573 ; 5900 E. Ben White Blvd. ; Austin, TX 78741 ; 800-292-9263 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; getenv.s ; char *value = getenv( const char *name ); ; .file "getenv.s" .include "sys/sysmac.h" .text .word 0x00030000 ; Debugger tag word .global _getenv .global __getenv _getenv: __getenv: const tav,HIF_getenv @ asneq V_SYSCALL,gr1,gr1 ; HIF service trap jmpti tav, lr0 ; If tav is true, were finished, return. const tpc, _errno consth tpc, _errno ; Otherwise, store 0, 0, tav, tpc ; store error code in _errno, jmpi lr0 ; then return const v0, 0 ; with a value of 0 (NULL pointer). .end
stsp/newlib-ia16
12,512
newlib/libc/sys/arm/crt0.S
#include "newlib.h" #include "arm.h" #include "swi.h" /* ANSI concatenation macros. */ #define CONCAT(a, b) CONCAT2(a, b) #define CONCAT2(a, b) a ## b #ifdef __USER_LABEL_PREFIX__ #define FUNCTION( name ) CONCAT (__USER_LABEL_PREFIX__, name) #else #error __USER_LABEL_PREFIX is not defined #endif #ifdef HAVE_INITFINI_ARRAY #define _init __libc_init_array #define _fini __libc_fini_array #endif #if defined(__ARM_EABI__) && defined(__thumb__) && !defined(__thumb2__) /* For Thumb1 we need to force the architecture to be sure that we get the correct attributes on the object file; otherwise the assembler will get confused and mark the object as being v6T2. */ #if defined(__ARM_ARCH_4T__) .arch armv4t #elif defined(__ARM_ARCH_5T__) || defined(__ARM_ARCH_5TE__) /* Nothing in this object requires higher than v5. */ .arch armv5t #elif defined(__ARM_ARCH_6__) || defined(__ARM_ARCH_6J__) \ || defined(__ARM_ARCH_6K__) || defined(__ARM_ARCH_6Z__) \ || defined(__ARM_ARCH_6ZK__) /* Nothing in this object requires higher than v6. */ .arch armv6 #elif defined(__ARM_ARCH_6M__) #ifdef ARM_RDP_MONITOR /* Object file uses SVC, so mark as v6s-m. */ .arch armv6s-m #else .arch armv6-m #endif #endif #endif /* .text is used instead of .section .text so it works with arm-aout too. */ .text .syntax unified #ifdef PREFER_THUMB .thumb .macro FUNC_START name .global \name .thumb_func \name: .endm #else .code 32 .macro FUNC_START name .global \name \name: .endm #endif .macro indirect_call reg #ifdef HAVE_CALL_INDIRECT blx \reg #else mov lr, pc mov pc, \reg #endif .endm .align 0 FUNC_START _mainCRTStartup FUNC_START _start #if defined(__ELF__) && !defined(__USING_SJLJ_EXCEPTIONS__) /* Annotation for EABI unwinding tables. */ .fnstart #endif /* Start by setting up a stack. */ #ifdef ARM_RDP_MONITOR /* Issue Demon SWI to read stack info. */ swi SWI_GetEnv /* Returns command line in r0. */ mov sp,r1 /* and the highest memory address in r1. */ /* Stack limit is at end of data. */ /* Allow slop for stack overflow handling and small frames. */ #ifdef __ARM_ARCH_6M__ ldr r0, .LC2 adds r0, #128 adds r0, #128 mov sl, r0 #else ldr sl, .LC2 add sl, sl, #256 #endif #else #ifdef ARM_RDI_MONITOR /* Issue Angel SWI to read stack info. */ movs r0, #AngelSWI_Reason_HeapInfo adr r1, .LC0 /* Point at ptr to 4 words to receive data. */ #ifdef THUMB_VXM bkpt AngelSWI #elif defined(__thumb2__) /* We are in thumb mode for startup on armv7 architectures. */ AngelSWIAsm AngelSWI #else /* We are always in ARM mode for startup on pre armv7 archs. */ AngelSWIAsm AngelSWI_ARM #endif ldr r0, .LC0 /* Point at values read. */ ldr r1, [r0, #0] cmp r1, #0 bne .LC32 /* If the heap base value [r0, #0] is 0 then the heap base is actually at the end of program data (i.e. __end__). See: http://infocenter.arm.com/help/topic/com.arm.doc.dui0471-/Bacbefaa.html for more information. */ ldr r1, .LC31 str r1, [r0, #0] .LC32: ldr r1, [r0, #8] ldr r2, [r0, #12] /* We skip setting sp/sl if 0 returned from semihosting. - According to semihosting docs, if 0 returned from semihosting, the system was unable to calculate the real value, so it's ok to skip setting sp/sl to 0 here. - Considering M-profile processors, We might want to initialize sp by the first entry of vector table and return 0 to SYS_HEAPINFO semihosting call, which will be skipped here. */ cmp r1, #0 beq .LC26 mov sp, r1 .LC26: cmp r2, #0 beq .LC27 /* Allow slop for stack overflow handling and small frames. */ #ifdef __ARM_ARCH_6M__ adds r2, #128 adds r2, #128 mov sl, r2 #else add sl, r2, #256 #endif .LC27: #else /* Set up the stack pointer to a fixed value. */ /* Changes by toralf: - Allow linker script to provide stack via __stack symbol - see defintion of .Lstack - Provide "hooks" that may be used by the application to add custom init code - see .Lhwinit and .Lswinit - Go through all execution modes and set up stack for each of them. Loosely based on init.s from ARM/Motorola example code. Note: Mode switch via CPSR is not allowed once in non-privileged mode, so we take care not to enter "User" to set up its sp, and also skip most operations if already in that mode. */ ldr r3, .Lstack cmp r3, #0 #ifdef __thumb2__ it eq #endif #ifdef __ARM_ARCH_6M__ bne .LC28 ldr r3, .LC0 .LC28: #else ldreq r3, .LC0 #endif /* Note: This 'mov' is essential when starting in User, and ensures we always get *some* sp value for the initial mode, even if we have somehow missed it below (in which case it gets the same value as FIQ - not ideal, but better than nothing). */ mov sp, r3 #ifdef PREFER_THUMB /* XXX Fill in stack assignments for interrupt modes. */ #else mrs r2, CPSR tst r2, #0x0F /* Test mode bits - in User of all are 0. */ beq .LC23 /* "eq" means r2 AND #0x0F is 0. */ msr CPSR_c, #0xD1 /* FIRQ mode, interrupts disabled. */ mov sp, r3 sub sl, sp, #0x1000 /* This mode also has its own sl (see below). */ mov r3, sl msr CPSR_c, #0xD7 /* Abort mode, interrupts disabled. */ mov sp, r3 sub r3, r3, #0x1000 msr CPSR_c, #0xDB /* Undefined mode, interrupts disabled. */ mov sp, r3 sub r3, r3, #0x1000 msr CPSR_c, #0xD2 /* IRQ mode, interrupts disabled. */ mov sp, r3 sub r3, r3, #0x2000 msr CPSR_c, #0xD3 /* Supervisory mode, interrupts disabled. */ mov sp, r3 sub r3, r3, #0x8000 /* Min size 32k. */ bic r3, r3, #0x00FF /* Align with current 64k block. */ bic r3, r3, #0xFF00 str r3, [r3, #-4] /* Move value into user mode sp without */ ldmdb r3, {sp}^ /* changing modes, via '^' form of ldm. */ orr r2, r2, #0xC0 /* Back to original mode, presumably SVC, */ msr CPSR_c, r2 /* with FIQ/IRQ disable bits forced to 1. */ #endif .LC23: /* Setup a default stack-limit in-case the code has been compiled with "-mapcs-stack-check". Hard-wiring this value is not ideal, since there is currently no support for checking that the heap and stack have not collided, or that this default 64k is enough for the program being executed. However, it ensures that this simple crt0 world will not immediately cause an overflow event: */ #ifdef __ARM_ARCH_6M__ movs r2, #64 lsls r2, r2, #10 subs r2, r3, r2 mov sl, r2 #else sub sl, r3, #64 << 10 /* Still assumes 256bytes below sl. */ #endif #endif #endif /* Zero the memory in the .bss section. */ movs a2, #0 /* Second arg: fill value. */ mov fp, a2 /* Null frame pointer. */ mov r7, a2 /* Null frame pointer for Thumb. */ ldr a1, .LC1 /* First arg: start of memory block. */ ldr a3, .LC2 subs a3, a3, a1 /* Third arg: length of block. */ #if __thumb__ && !defined(PREFER_THUMB) /* Enter Thumb mode... */ add a4, pc, #1 /* Get the address of the Thumb block. */ bx a4 /* Go there and start Thumb decoding. */ .code 16 .global __change_mode .thumb_func __change_mode: #endif bl FUNCTION (memset) #if !defined (ARM_RDP_MONITOR) && !defined (ARM_RDI_MONITOR) /* Changes by toralf: Taken from libgloss/m68k/crt0.S initialize target specific stuff. Only execute these functions it they exist. */ ldr r3, .Lhwinit cmp r3, #0 beq .LC24 indirect_call r3 .LC24: ldr r3, .Lswinit cmp r3, #0 beq .LC25 indirect_call r3 .LC25: movs r0, #0 /* No arguments. */ movs r1, #0 /* No argv either. */ #else /* Need to set up standard file handles. */ bl FUNCTION (initialise_monitor_handles) #ifdef ARM_RDP_MONITOR swi SWI_GetEnv /* Sets r0 to point to the command line. */ movs r1, r0 #else movs r0, #AngelSWI_Reason_GetCmdLine adr r1, .LC30 /* Space for command line. */ #ifdef THUMB_VXM bkpt AngelSWI #else AngelSWIAsm AngelSWI #endif ldr r1, .LC30 #endif /* Parse string at r1. */ movs r0, #0 /* Count of arguments so far. */ /* Push a NULL argument onto the end of the list. */ #ifdef __thumb__ push {r0} #else stmfd sp!, {r0} #endif .LC10: /* Skip leading blanks. */ #ifdef __thumb__ ldrb r3, [r1] adds r1, #1 #else ldrb r3, [r1], #1 #endif cmp r3, #0 beq .LC12 cmp r3, #' ' beq .LC10 /* See whether we are scanning a string. */ cmp r3, #'\"' #ifdef __thumb__ beq .LC20 cmp r3, #'\'' bne .LC21 .LC20: movs r2, r3 b .LC22 .LC21: movs r2, #' ' /* Terminator type. */ subs r1, r1, #1 /* Adjust back to point at start char. */ .LC22: #else cmpne r3, #'\'' moveq r2, r3 movne r2, #' ' /* Terminator type. */ subne r1, r1, #1 /* Adjust back to point at start char. */ #endif /* Stack a pointer to the current argument. */ #ifdef __thumb__ push {r1} #else stmfd sp!, {r1} #endif adds r0, r0, #1 .LC11: #ifdef __thumb__ ldrb r3, [r1] adds r1, #1 #else ldrb r3, [r1], #1 #endif cmp r3, #0 beq .LC12 cmp r2, r3 /* Reached terminator ? */ bne .LC11 movs r2, #0 subs r3, r1, #1 strb r2, [r3] /* Terminate the arg string. */ b .LC10 .LC12: mov r1, sp /* Point at stacked arg pointers. */ /* We've now got the stacked args in order, reverse them. */ #ifdef __thumb__ movs r2, r0 lsls r2, #2 add r2, sp mov r3, sp .LC15: cmp r2, r3 bls .LC14 subs r2, #4 ldr r4, [r2] ldr r5, [r3] str r5, [r2] str r4, [r3] adds r3, #4 b .LC15 .LC14: /* Ensure doubleword stack alignment. */ mov r4, sp movs r5, #7 bics r4, r5 mov sp, r4 #else add r2, sp, r0, LSL #2 /* End of args. */ mov r3, sp /* Start of args. */ .LC13: cmp r2, r3 ldrhi r4,[r2, #-4] /* Reverse ends of list. */ ldrhi r5, [r3] strhi r5, [r2, #-4]! strhi r4, [r3], #4 bhi .LC13 /* Ensure doubleword stack alignment. */ bic sp, sp, #7 #endif #endif #ifdef __USES_INITFINI__ /* Some arm/elf targets use the .init and .fini sections to create constructors and destructors, and for these targets we need to call the _init function and arrange for _fini to be called at program exit. */ movs r4, r0 movs r5, r1 ldr r0, .Lfini bl FUNCTION (atexit) bl FUNCTION (_init) movs r0, r4 movs r1, r5 #endif bl FUNCTION (main) bl FUNCTION (exit) /* Should not return. */ #if __thumb__ && !defined(PREFER_THUMB) /* Come out of Thumb mode. This code should be redundant. */ mov a4, pc bx a4 .code 32 .global change_back change_back: /* Halt the execution. This code should never be executed. */ /* With no debug monitor, this probably aborts (eventually). With a Demon debug monitor, this halts cleanly. With an Angel debug monitor, this will report 'Unknown SWI'. */ swi SWI_Exit #endif /* For Thumb, constants must be after the code since only positive offsets are supported for PC relative addresses. */ .align 0 .LC0: #ifdef ARM_RDI_MONITOR .word HeapBase #else #ifndef ARM_RDP_MONITOR /* Changes by toralf: Provide alternative "stack" variable whose value may be defined externally; .Lstack will be used instead of .LC0 if it points to a non-0 value. Also set up references to "hooks" that may be used by the application to provide additional init code. */ #ifdef __pe__ .word 0x800000 #else .word 0x80000 /* Top of RAM on the PIE board. */ #endif .Lstack: .word __stack .Lhwinit: .word FUNCTION (hardware_init_hook) .Lswinit: .word FUNCTION (software_init_hook) /* Set up defaults for the above variables in the form of weak symbols - so that application will link correctly, and get value 0 in runtime (meaning "ignore setting") for the variables, when the user does not provide the symbols. (The linker uses a weak symbol if, and only if, a normal version of the same symbol isn't provided e.g. by a linker script or another object file). */ .weak __stack .weak FUNCTION (hardware_init_hook) .weak FUNCTION (software_init_hook) #endif #endif #if defined(__ELF__) && !defined(__USING_SJLJ_EXCEPTIONS__) /* Protect against unhandled exceptions. */ .cantunwind .fnend #endif .LC1: .word __bss_start__ .LC2: .word __bss_end__ #ifdef __USES_INITFINI__ .Lfini: .word FUNCTION(_fini) #endif #ifdef ARM_RDI_MONITOR .LC30: .word CommandLine .word 255 .LC31: .word __end__ /* Workspace for Angel calls. */ .data /* Data returned by monitor SWI. */ .global __stack_base__ HeapBase: .word 0 HeapLimit: .word 0 __stack_base__: .word 0 StackLimit: .word 0 CommandLine: .space 256,0 /* Maximum length of 255 chars handled. */ #endif #ifdef __pe__ .section .idata$3 .long 0,0,0,0,0,0,0,0 #endif
stsp/newlib-ia16
5,015
newlib/libc/sys/arm/trap.S
/* Run-time exception support */ #if !defined(__thumb2__) #include "swi.h" /* .text is used instead of .section .text so it works with arm-aout too. */ .text .align 0 .global __rt_stkovf_split_big .global __rt_stkovf_split_small /* The following functions are provided for software stack checking. If hardware stack-checking is being used then the code can be compiled without the PCS entry checks, and simply rely on VM management to extend the stack for a thread. The stack extension event occurs when the PCS function entry code would result in a stack-pointer beneath the stack-limit register value. The system relies on the following map: +-----------------------------------+ <-- end of stack block | ... | | ... | | active stack | | ... | <-- sp (stack-pointer) somewhere in here | ... | +-----------------------------------+ <-- sl (stack-limit) | stack-extension handler workspace | +-----------------------------------+ <-- base of stack block The "stack-extension handler workspace" is an amount of memory in which the stack overflow support code must execute. It must be large enough to deal with the worst case path through the extension code. At the moment the compiler expects this to be AT LEAST 256bytes. It uses this fact to code functions with small local data usage within the overflow space. In a true target environment We may need to increase the space between sl and the true limit to allow for the stack extension code, SWI handlers and for undefined instruction handlers of the target environment. */ __rt_stkovf_split_small: mov ip,sp @ Ensure we can calculate the stack required @ and fall through to... __rt_stkovf_split_big: @ in: sp = current stack-pointer (beneath stack-limit) @ sl = current stack-limit @ ip = low stack point we require for the current function @ lr = return address into the current function @ fp = frame-pointer @ original sp --> +----------------------------------+ @ | pc (12 ahead of PCS entry store) | @ current fp ---> +----------------------------------+ @ | lr (on entry) pc (on exit) | @ +----------------------------------+ @ | sp ("original sp" on entry) | @ +----------------------------------+ @ | fp (on entry to function) | @ +----------------------------------+ @ | | @ | ..argument and work registers.. | @ | | @ current sp ---> +----------------------------------+ @ @ The "current sl" is somewhere between "original sp" and "current sp" @ but above "true sl". The "current sl" should be at least 256bytes @ above the "true sl". The 256byte stack guard should be large enough @ to deal with the worst case function entry stacking (160bytes) plus @ the stack overflow handler stacking requirements, plus the stack @ required for the memory allocation routines. @ @ Normal PCS entry (before stack overflow check) can stack 16 @ standard registers (64bytes) and 8 floating point registers @ (96bytes). This gives a minimum stack guard of 160bytes (excluding @ the stack required for the code). (Actually only a maximum of @ 14standard registers are ever stacked on entry to a function). @ @ NOTE: Structure returns are performed by the caller allocating a @ dummy space on the stack and passing in a "phantom" arg1 into @ the function. This means that we do not need to worry about @ preserving the stack under "sp" even on function return. @ @ Code should never poke values beneath sp. The sp register @ should always be "dropped" first to cover the data. This @ protects the data against any events that may try and use @ the stack. SUB ip, sp, ip @ extra stack required for function @ Add stack extension code here. If desired a new stack chunk @ can be allocated, and the register state updated suitably. @ We now know how much extra stack the function requires. @ Terminate the program for the moment: swi SWI_Exit #endif
stsp/newlib-ia16
1,596
newlib/libc/sys/h8300hms/crt0.S
; h8/300 and h8/300h start up file. #include "setarch.h" #ifdef __H8300__ .section .text .global _start _start: mov.w #_stack,sp mov.w #_edata,r0 mov.w #_end,r1 sub.w r2,r2 .Loop: mov.w r2,@r0 adds #2,r0 cmp r1,r0 blo .Loop #ifdef __ELF__ mov.l #__fini,r0 jsr @_atexit #ifdef __SIMULATOR__ jsr @0xcc #endif jsr @__init #else #ifdef __SIMULATOR__ jsr @0xcc #endif jsr @___main #endif jsr @_main jsr @_exit .section .stack _stack: .word 1 #endif #ifdef __H8300H__ .section .text .global _start _start: mov.l #_stack,sp mov.l #_edata,er0 mov.l #_end,er1 sub.w r2,r2 ; not sure about alignment requirements .Loop: mov.w r2,@er0 ; playing it safe for now adds #2,er0 cmp.l er1,er0 blo .Loop #ifdef __ELF__ mov.l #__fini,er0 jsr @_atexit #ifdef __SIMULATOR__ jsr @0xcc #endif jsr @__init #else #ifdef __SIMULATOR__ jsr @0xcc #endif jsr @___main #endif jsr @_main jsr @_exit .section .stack _stack: .long 1 #endif #if defined (__H8300S__) || defined (__H8300SX__) .section .text .global _start _start: mov.l #_stack,sp mov.l #_edata,er0 mov.l #_end,er1 sub.w r2,r2 ; not sure about alignment requirements .Loop: mov.w r2,@er0 ; playing it safe for now adds #2,er0 cmp.l er1,er0 blo .Loop #ifdef __ELF__ mov.l #__fini,er0 jsr @_atexit #ifdef __SIMULATOR__ jsr @0xcc #endif jsr @__init #else #ifdef __SIMULATOR__ jsr @0xcc #endif jsr @___main #endif jsr @_main jsr @_exit .section .stack _stack: .long 1 #endif
stsp/newlib-ia16
3,076
newlib/libc/sys/sparc64/crt0.S
! C run time start off ! This file supports: ! ! - both 32bit pointer and 64bit pointer environments (at compile time) ! - an imposed stack bias (of 2047) (at run time) ! - medium/low and medium/anywhere code models (at run time) ! Initial stack setup: ! ! bottom of stack (higher memory address) ! ... ! text of environment strings ! text of argument strings ! envp[envc] = 0 (4/8 bytes) ! ... ! env[0] (4/8 bytes) ! argv[argc] = 0 (4/8 bytes) ! ... ! argv[0] (4/8 bytes) ! argc (4/8 bytes) ! register save area (64 bits by 16 registers = 128 bytes) ! top of stack (%sp) ! Stack Bias: ! ! It is the responsibility of the o/s to set this up. ! We handle both a 0 and 2047 value for the stack bias. ! Medium/Anywhere code model support: ! ! In this model %g4 points to the start of the data segment. ! The text segment can go anywhere, but %g4 points to the *data* segment. ! It is up to the compiler/linker to get this right. ! ! Since this model is statically linked the start of the data segment ! is known at link time. Eg: ! ! sethi %hh(data_start), %g1 ! sethi %lm(data_start), %g4 ! or %g1, %hm(data_start), %g1 ! or %g4, %lo(data_start), %g4 ! sllx %g1, 32, %g1 ! or %g4, %g1, %g4 ! ! FIXME: For now we just assume 0. ! FIXME: if %g1 contains a non-zero value, atexit() should be invoked ! with this value. #include <sys/syscallasm.h> TEXT_SECTION ALIGN (4) GLOBAL (ASM_PRIVATE_SYMBOL (start)) ASM_PRIVATE_SYMBOL (start): clr %fp ! We use %g4 even if the code model is Medium/Low (simplifies the code). clr %g4 ! Medium/Anywhere base reg ! If there is a stack bias in effect, account for it in %g5. Then always ! add %g5 to stack references below. This way the code can be used with ! or without an imposed bias. andcc %sp, 1, %g5 bnz,a .LHaveBias mov 2047, %g5 .LHaveBias: add %sp, %g5, %sp #if TARGET_PTR_SIZE == 32 ! FIXME: We apparently assume here that there is no reserved word. ! This is probably correct, but try to verify it. ld [%sp + 0x80], %o0 ! argc add %sp, 0x84, %o1 ! argv add %o0, 1, %o2 sll %o2, 2, %o2 #else /* TARGET_PTR_SIZE == 64 */ ld [%sp + 0x8c], %o0 ! argc.lo add %sp, 0x90, %o1 ! argv add %o0, 1, %o2 sll %o2, 3, %o2 #endif add %o1, %o2, %o2 ! envp sethi %hi (ASM_SYMBOL (environ)), %o3 or %o3, %lo (ASM_SYMBOL (environ)), %o3 #if TARGET_PTR_SIZE == 32 st %o2, [%o3 + %g4] #else /* TARGET_PTR_SIZE == 64 */ stx %o2, [%o3 + %g4] #endif ! Restore any stack bias before we call main() ... sub %sp, %g5, %sp GLOBAL (ASM_SYMBOL (main)) call ASM_SYMBOL (main) ! FIXME: Not sure if this is needed anymore. #if TARGET_PTR_SIZE == 32 sub %sp, 0x20, %sp ! room to push args #else /* TARGET_PTR_SIZE == 64 */ sub %sp, 0x30, %sp ! room to push args #endif GLOBAL (ASM_SYMBOL (exit)) call ASM_SYMBOL (exit) nop GLOBAL (ASM_SYMBOL (_exit)) call ASM_SYMBOL (_exit) nop set SYS_exit, %g1 ta SYSCALL_TRAP ! in case user redefines __exit ! If all the above methods fail to terminate the program, try an illegal insn. ! If that does not work, the o/s is hosed more than we are. WORD (0)
stsp/newlib-ia16
1,678
newlib/libc/sys/sparc64/sigsetjmp.S
! This file is called sigsetjmp.s because that is what V8 uses. ! We do not define sigsetjmp() or setlongjmp() yet. ! Solaris has setjmp/longjmp in setjmp.o. Move this stuff there. #include <sys/syscallasm.h> TEXT_SECTION ALIGN (4) #ifdef __svr4__ GLOBAL (ASM_SYMBOL (setjmp)) .proc 04 ASM_SYMBOL (setjmp): clr [%o0] stx %sp,[%o0+8] add %o7,8,%g1 stx %g1,[%o0+16] retl mov %g0,%o0 GLOBAL (ASM_SYMBOL (longjmp)) .proc 04 ASM_SYMBOL (longjmp): flushw ! flush register windows sub %sp,136,%sp ldx [%o0+8],%fp ldx [%o0+16],%g1 tst %o1 bne L0 sub %g1,8,%o7 mov 1,%o1 L0: retl restore %o1,0,%o0 #else GLOBAL (ASM_SYMBOL (setjmp)) .proc 04 ASM_SYMBOL (setjmp): save %sp,-136,%sp or %g0,%g0,%o0 ! %o0 = 0 or %g0,0x6d,%g1 ! %g1 = 0x6d (syscall number) ta SYSCALL_TRAP stw %o0,[%i0+4] ! save result at [%i0+4] (sigmask?) add %fp,-8,%o1 ! %o1 -> tmp 8 byte buffer or %g0,%g0,%o0 ! %o0 = 0 or %g0,0x70,%g1 ! %g1 = 0x70 (syscall number) ta SYSCALL_TRAP lduw [%fp-4],%g1 ! %g1 = onsstack? stw %fp,[%i0+8] ! save %fp at [%i0+8] stw %g1,[%i0+0] ! save ? at [%i0+8] add %i7,8,%g1 ! %g1 = return address stw %g1,[%i0+12] ! save return address at [%i0+12] add %g1,4,%g1 ! %g1 = nPC stw %g1,[%i0+16] ! save nPC at [%i0+16] stw %g0,[%i0+20] stw %g0,[%i0+24] stw %g0,[%i0+32] jmpl %i7+8,%g0 restore %g0,0,%o0 GLOBAL (ASM_SYMBOL (longjmp)) .proc 04 ASM_SYMBOL (longjmp): orcc %g0,%o1,%g0 ! return val == 0 ? be,a L1 ! branch if 0 or %g0,1,%o1 ! make it 1 (executed if branch taken) L1: or %g0,0x8b,%g1 ! set syscall 0x8b stw %o1,[%o0+28] ! save return val for restoration ta SYSCALL_TRAP #endif /* ! __svr4__ */
stsp/newlib-ia16
1,475
newlib/libc/sys/sparc64/sbrk.S
! sbrk() system call #include "sys/syscallasm.h" DATA_SECTION ALIGN (4) ! CURBRK contains the current top of allocated space. ! END is a private symbol in svr4, but a public one in sunos4. ! FIXME: CURBRK is 4 bytes for now. GLOBAL (ASM_PRIVATE_SYMBOL (curbrk)) ASM_PRIVATE_SYMBOL (curbrk): #ifdef __svr4__ WORD (ASM_PRIVATE_SYMBOL (end)) #else WORD (ASM_SYMBOL (end)) #endif TEXT_SECTION ALIGN (4) #ifdef REENT GLOBAL (ASM_SYMBOL (_sbrk_r)) ASM_SYMBOL (_sbrk_r): mov %o0,%o5 mov %o1,%o0 #else GLOBAL (ASM_SYMBOL (sbrk)) ASM_SYMBOL (sbrk): #endif add %o0,7,%o0 andn %o0,7,%o0 sethi %hi (ASM_PRIVATE_SYMBOL (curbrk)),%o2 lduw [%o2+%lo (ASM_PRIVATE_SYMBOL (curbrk))],%o3 add %o3,7,%o3 andn %o3,7,%o3 add %o3,%o0,%o0 mov %o0,%o4 mov SYS_brk,%g1 ta SYSCALL_TRAP bcs err nop stw %o4,[%o2+%lo (ASM_PRIVATE_SYMBOL (curbrk))] jmpl %o7+8,%g0 mov %o3,%o0 #ifdef REENT GLOBAL (ASM_SYMBOL (_brk_r)) ASM_SYMBOL (_brk_r): mov %o0,%o5 mov %o1,%o0 #else GLOBAL (ASM_SYMBOL (brk)) ASM_SYMBOL (brk): #endif add %o0,7,%o0 andn %o0,7,%o0 mov %o0,%o2 mov SYS_brk,%g1 ta SYSCALL_TRAP bcs err nop sethi %hi (ASM_PRIVATE_SYMBOL (curbrk)),%o3 st %o2,[%o3+%lo (ASM_PRIVATE_SYMBOL (curbrk))] retl mov %g0,%o0 err: #ifdef REENT sethi %hi (ASM_PRIVATE_SYMBOL (cerror_r)),%g1 or %g1,%lo (ASM_PRIVATE_SYMBOL (cerror_r)),%g1 #else sethi %hi (ASM_PRIVATE_SYMBOL (cerror)),%g1 or %g1,%lo (ASM_PRIVATE_SYMBOL (cerror)),%g1 #endif jmpl %g1,%g0 mov %o5,%o1
stsp/newlib-ia16
1,119
newlib/libc/sys/sysmec/crt0.S
#ifdef __mn10300__ .section .text .global _start _start: mov _stack-8,a0 # Load up the stack pointer mov a0,sp mov _edata,a0 # Get the start/end of bss mov _end,a1 cmp a0,a1 # If no bss, then do nothing beq .L0 clr d0 # clear d0 .L1: movbu d0,(a0) # Clear a byte and bump pointer inc a0 cmp a0,a1 bne .L1 .L0: call ___main,[],0 # Call __main to run ctors/dtors clr d0 clr d1 mov d0,(4,sp) call _main,[],0 # Call main program call _exit,[],0 # All done, no need to return or # deallocate our stack. .section ._stack _stack: .long 1 #else .section .text .global _start _start: mov _stack-4,a3 # Load up the stack pointer and allocate # our current frame. mov _edata,a0 # Get the start/end of bss mov _end,a1 cmp a0,a1 # If no bss, then do nothing beqx .L0 sub d0,d0 # clear d0 .L1: movb d0,(a0) # Clear a byte and bump pointer add 1,a0 cmp a0,a1 bnex .L1 .L0: jsr ___main sub d0,d0 mov d0,d1 mov d0,(a3) jsr _main # Call main program jmp _exit # All done, no need to return or # deallocate our stack. .section ._stack _stack: .long 1 #endif
stsp/newlib-ia16
1,590
newlib/libc/sys/sysnecv850/crt0.S
# NEC V850 startup code .section .text .global _start _start: #if defined(__v850e__) || defined(__v850e2__) || defined(__v850e2v3__) || defined(__v850e3v5__) movea 255, r0, r20 mov 65535, r21 mov hilo(_stack), sp mov hilo(__ep), ep mov hilo(__gp), gp mov hilo(__ctbp), r6 ldsr r6, ctbp #if defined(__v850e2v3__) || defined(__v850e3v5__) // FPU enable stsr psw, r6 movhi 1, r0, r7 or r7, r6 ldsr r6, psw // Initialize the FPSR movhi 2, r0, r6 ldsr r6, fpsr #endif mov hilo(_edata), r6 mov hilo(_end), r7 .L0: st.w r0, 0[r6] addi 4, r6, r6 cmp r7, r6 bl .L0 .L1: jarl ___main, r31 addi -16, sp, sp mov 0, r6 mov 0, r7 mov 0, r8 jarl _main, r31 mov r10, r6 jarl _exit, r31 # else movea 255, r0, r20 mov r0, r21 ori 65535, r0, r21 movhi hi(_stack), r0, sp movea lo(_stack), sp, sp movhi hi(__ep), r0, ep movea lo(__ep), ep, ep movhi hi(__gp), r0, gp movea lo(__gp), gp, gp movhi hi(_edata), r0, r6 movea lo(_edata), r6, r6 movhi hi(_end), r0, r7 movea lo(_end), r7, r7 .L0: st.b r0, 0[r6] addi 1, r6, r6 cmp r7, r6 bl .L0 .L1: jarl ___main, r31 addi -16, sp, sp mov 0, r6 mov 0, r7 mov 0, r8 jarl _main, r31 mov r10, r6 jarl _exit, r31 # endif .section .stack _stack: .long 1 .section .data .global ___dso_handle .weak ___dso_handle ___dso_handle: .long 0
stsp/newlib-ia16
133,709
newlib/libc/sys/rdos/rdos.S
/*####################################################################### # RDOS operating system # Copyright (C) 1988-2006, Leif Ekblad # # This library is free software; you can redistribute it and/or modify # it under the terms of the GNU Lesser General Public License as published # by the Free Software Foundation; either version 2.1 of the License, or # (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # # The author of this program may be contacted at leif@rdos.net # # rdos.S # GCC based interface to RDOS kernel # ##########################################################################*/ #include "user.def" .macro UserGate nr .byte 0x9A .long \nr .word 2 .endm /*########################################################################## # # Name : RdosSwapShort # # Purpose....: Byte reverse a short int # # Returns....: Result # ##########################################################################*/ .global RdosSwapShort RdosSwapShort: pushl %ebp movl %esp,%ebp movw 8(%ebp),%ax xchgb %ah,%al leave ret /*########################################################################## # # Name : RdosSwapLong # # Purpose....: Byte reverse a long int # # Returns....: Result # ##########################################################################*/ .global RdosSwapLong RdosSwapLong: pushl %ebp movl %esp,%ebp movl 8(%ebp),%eax xchgb %ah,%al roll $16,%eax xchgb %ah,%al leave ret /*########################################################################## # # Name : LocalToNetworkLong # # Purpose....: Convert a local long to network format # # Returns....: Network format # ##########################################################################*/ .global LocalToNetworkLong LocalToNetworkLong: pushl %ebp movl %esp,%ebp movl 8(%ebp),%eax xchgb %ah,%al roll $16,%eax xchgb %ah,%al leave ret /*########################################################################## # # Name : NetworkToLocalLong # # Purpose....: Convert a network long to local format # # Returns....: Local format # ##########################################################################*/ .global NetworkToLocalLong NetworkToLocalLong: pushl %ebp movl %esp,%ebp movl 8(%ebp),%eax xchgb %ah,%al roll $16,%eax xchgb %ah,%al leave ret /*########################################################################## # # Name : RdosGetThreadHandle # # Purpose....: Get current thread handle # # Returns....: Thread ID # ##########################################################################*/ .global RdosGetThreadHandle RdosGetThreadHandle: pushl %ebp movl %esp,%ebp UserGate get_thread_nr movzx %ax,%eax leave ret /*########################################################################## # # Name : RdosGetThreadState # # Purpose....: Get thread state # # Parameters.: Thread # # State buffer # ##########################################################################*/ .global RdosGetThreadState RdosGetThreadState: pushl %ebp movl %esp,%ebp push %edi movl 8(%ebp),%eax movl 12(%ebp),%edx UserGate get_thread_state_nr jc rgtsFail movl $1,%eax jmp rgtsDone rgtsFail: xorl %eax,%eax rgtsDone: popl %edi leave ret /*########################################################################## # # Name : RdosSuspendThread # # Purpose....: Suspend thread # # Parameters.: Thread # # ##########################################################################*/ .global RdosSuspendThread RdosSuspendThread: pushl %ebp movl %esp,%ebp movl 8(%ebp),%eax UserGate suspend_thread_nr jc rsfFail movl $1,%eax jmp rsfDone rsfFail: xorl %eax,%eax rsfDone: leave ret /*########################################################################## # # Name : RdosExec # # Purpose....: Execute a program # # Parameters.: Program # Commandline # ##########################################################################*/ .global RdosExec RdosExec: pushl %ebp movl %esp,%ebp pushl %esi pushl %edi movl 8(%ebp),%esi movl 12(%ebp),%edi UserGate load_exe_nr UserGate get_exit_code_nr popl %edi popl %esi leave ret /*########################################################################## # # Name : RdosSpawn # # Purpose....: Create new process and run a program # # Parameters.: Program # Commandline # StartDir # ##########################################################################*/ .global RdosSpawn RdosSpawn: pushl %ebp movl %esp,%ebp pushl %fs pushl %ebx pushl %edx pushl %esi pushl %edi movw %ds,%dx movw %dx,%fs xorl %edx,%edx movl 8(%ebp),%esi movl 12(%ebp),%edi movl 16(%ebp),%ebx UserGate spawn_exe_nr jc rsFail movzx %dx,%eax jmp rsDone rsFail: xorl %eax,%eax rsDone: popl %edi popl %esi popl %edx popl %ebx popw %fs leave ret /*########################################################################## # # Name : RdosCpuReset # # Purpose....: Cpu reset # ##########################################################################*/ .global RdosCpuReset RdosCpuReset: pushl %ebp movl %esp,%ebp UserGate cpu_reset_nr leave ret /*########################################################################## # # Name : RdosGetVersion # # Purpose....: Get RDOS version # # Parameters.: &major # &minor # &release # ##########################################################################*/ .global RdosGetVersion RdosGetVersion: pushl %ebp movl %esp,%ebp pushl %eax pushl %ecx pushl %edx pushl %edi UserGate get_version_nr movzx %dx,%edx movl 8(%ebp),%edi movl %edx,(%edi) movzx %ax,%eax movl 12(%ebp),%edi movl %eax,(%edi) movzx %cx,%eax movl 16(%ebp),%edi movl %eax,(%edi) popl %edi popl %edx popl %ecx popl %eax leave ret /*########################################################################## # # Name : RdosAllocateMem # # Purpose....: Allocate memory # # Parameters.: Bytes to allocate # # Returns....: Memory pointer # ##########################################################################*/ .global RdosAllocateMem RdosAllocateMem: pushl %ebp movl %esp,%ebp pushl %edx movl 8(%ebp),%eax UserGate allocate_app_mem_nr movl %edx,%eax popl %edx leave ret /*########################################################################## # # Name : RdosFreeMem # # Purpose....: Free memory # # Parameters.: Memory pointer # ##########################################################################*/ .global RdosFreeMem RdosFreeMem: pushl %ebp movl %esp,%ebp pushl %edx movl 8(%ebp),%edx UserGate free_app_mem_nr popl %edx leave ret /*########################################################################## # # Name : RdosAppDebug # # Purpose....: App debug # ##########################################################################*/ .global RdosAppDebug RdosAppDebug: pushl %ebp movl %esp,%ebp UserGate app_debug_nr leave ret /*########################################################################## # # Name : RdosWaitMilli # # Purpose....: Wait a number of milliseconds # # Parameters.: Milliseconds to wait # ##########################################################################*/ .global RdosWaitMilli RdosWaitMilli: pushl %ebp movl %esp,%ebp pushl %eax movl 8(%ebp),%eax UserGate wait_milli_nr popl %eax leave ret /*########################################################################## # # Name : RdosCreateSection # # Purpose....: Create section # # Returns....: Section handle # ##########################################################################*/ .global RdosCreateSection RdosCreateSection: pushl %ebp movl %esp,%ebp pushl %ebx UserGate create_user_section_nr movzx %bx,%eax popl %ebx leave ret /*########################################################################## # # Name : RdosDeleteSection # # Purpose....: Delete section # # Parameters.: Section handle # ##########################################################################*/ .global RdosDeleteSection RdosDeleteSection: pushl %ebp movl %esp,%ebp pushl %ebx movw 8(%ebp),%bx UserGate delete_user_section_nr popl %ebx leave ret /*########################################################################## # # Name : RdosEnterSection # # Purpose....: Enter section # # Parameters.: Section handle # ##########################################################################*/ .global RdosEnterSection RdosEnterSection: pushl %ebp movl %esp,%ebp pushl %ebx movw 8(%ebp),%bx UserGate enter_user_section_nr popl %ebx leave ret /*########################################################################## # # Name : RdosLeaveSection # # Purpose....: Leave section # # Parameters.: Section handle # ##########################################################################*/ .global RdosLeaveSection RdosLeaveSection: pushl %ebp movl %esp,%ebp pushl %ebx movw 8(%ebp),%bx UserGate leave_user_section_nr popl %ebx leave ret /*########################################################################## # # Name : RdosCreateWait # # Purpose....: Create wait object # # Returns....: Wait handle # ##########################################################################*/ .global RdosCreateWait RdosCreateWait: pushl %ebp movl %esp,%ebp pushl %ebx UserGate create_wait_nr movzx %bx,%eax popl %ebx leave ret /*########################################################################## # # Name : RdosCloseWait # # Purpose....: Close wait # # Parameters.: Wait handle # ##########################################################################*/ .global RdosCloseWait RdosCloseWait: pushl %ebp movl %esp,%ebp pushl %ebx movw 8(%ebp),%bx UserGate close_wait_nr popl %ebx leave ret /*########################################################################## # # Name : RdosCheckWait # # Purpose....: Check wait state # # Parameters.: Wait handle # # Returns....: Signalled ID or 0 # ##########################################################################*/ .global RdosCheckWait RdosCheckWait: pushl %ebp movl %esp,%ebp pushl %ebx pushl %ecx movw 8(%ebp),%bx UserGate is_wait_idle_nr movl %ecx,%eax popl %ecx popl %ebx leave ret /*########################################################################## # # Name : RdosWaitForever # # Purpose....: Wait forever # # Parameters.: Wait handle # # Returns....: Signalled ID or 0 # ##########################################################################*/ .global RdosWaitForever RdosWaitForever: pushl %ebp movl %esp,%ebp pushl %ebx pushl %ecx movw 8(%ebp),%bx UserGate wait_no_timeout_nr jc rwfFail movl %ecx,%eax jmp rwfDone rwfFail: xorl %eax,%eax rwfDone: popl %ecx popl %ebx leave ret /*########################################################################## # # Name : RdosWaitTimeout # # Purpose....: Wait with timeout # # Parameters.: Wait handle # Timeout in ms # # Returns....: Signalled ID or 0 # ##########################################################################*/ .global RdosWaitTimeout RdosWaitTimeout: pushl %ebp movl %esp,%ebp pushl %ebx pushl %ecx pushl %edx movl 12(%ebp),%eax movl $1193,%edx mull %edx pushl %edx pushl %eax UserGate get_system_time_nr popl %ebx addl %ebx,%eax popl %ebx adcl %ebx,%edx movw 8(%ebp),%bx UserGate wait_timeout_nr jc rwtFail movl %ecx,%eax jmp rwtDone rwtFail: xorl %eax,%eax rwtDone: popl %edx popl %ecx popl %ebx leave ret /*########################################################################## # # Name : RdosStopWait # # Purpose....: Stop wait # # Parameters.: Wait handle # ##########################################################################*/ .global RdosStopWait RdosStopWait: pushl %ebp movl %esp,%ebp pushl %ebx movw 8(%ebp),%bx UserGate stop_wait_nr popl %ebx leave ret /*########################################################################## # # Name : RdosRemoveWait # # Purpose....: Remove wait object from wait handle # # Parameters.: Wait handle # ID # ##########################################################################*/ .global RdosRemoveWait RdosRemoveWait: pushl %ebp movl %esp,%ebp pushl %ebx pushl %ecx movw 8(%ebp),%bx movl 12(%ebp),%ecx UserGate remove_wait_nr popl %ecx popl %ebx leave ret /*########################################################################## # # Name : RdosCreateSignal # # Purpose....: Create signal object # # Returns....: Signal handle # ##########################################################################*/ .global RdosCreateSignal RdosCreateSignal: pushl %ebp movl %esp,%ebp pushl %ebx UserGate create_signal_nr movzx %bx,%eax popl %ebx leave ret /*########################################################################## # # Name : RdosResetSignal # # Purpose....: Reset signal # # Parameters.: Signal handle # ##########################################################################*/ .global RdosResetSignal RdosResetSignal: pushl %ebp movl %esp,%ebp pushl %ebx movw 8(%ebp),%bx UserGate reset_signal_nr popl %ebx leave ret /*########################################################################## # # Name : RdosIsSignalled # # Purpose....: Check if signalled # # Parameters.: Signal handle # # Returns....: TRUE if signalled # ##########################################################################*/ .global RdosIsSignalled RdosIsSignalled: pushl %ebp movl %esp,%ebp pushl %ebx movw 8(%ebp),%bx UserGate is_signalled_nr jc risdFree movl $1,%eax jmp risdDone risdFree: xorl %eax,%eax risdDone: popl %ebx leave ret /*########################################################################## # # Name : RdosSetSignal # # Purpose....: Set signal # # Parameters.: Signal handle # ##########################################################################*/ .global RdosSetSignal RdosSetSignal: pushl %ebp movl %esp,%ebp pushl %ebx movw 8(%ebp),%bx UserGate set_signal_nr popl %ebx leave ret /*########################################################################## # # Name : RdosFreeSignal # # Purpose....: Free signal handle # # Parameters.: Signal handle # ##########################################################################*/ .global RdosFreeSignal RdosFreeSignal: pushl %ebp movl %esp,%ebp pushl %ebx movw 8(%ebp),%bx UserGate free_signal_nr popl %ebx leave ret /*########################################################################## # # Name : RdosAddWaitForSignal # # Purpose....: Add signal object to wait handle # # Parameters.: Wait handle # Signal handle # ID # ##########################################################################*/ .global RdosAddWaitForSignal RdosAddWaitForSignal: pushl %ebp movl %esp,%ebp pushl %ebx pushl %ecx movw 8(%ebp),%bx movw 12(%ebp),%ax movl 16(%ebp),%ecx UserGate add_wait_for_signal_nr popl %ecx popl %ebx leave ret /*########################################################################## # # Name : RdosAddWaitForKeyboard # # Purpose....: Add keyboard to wait handle # # Parameters.: Wait handle # ID # ##########################################################################*/ .global RdosAddWaitForKeyboard RdosAddWaitForKeyboard: pushl %ebp movl %esp,%ebp pushl %ebx pushl %ecx movw 8(%ebp),%bx movl 12(%ebp),%ecx UserGate add_wait_for_keyboard_nr popl %ecx popl %ebx leave ret /*########################################################################## # # Name : RdosAddWaitForMouse # # Purpose....: Add mouse to wait handle # # Parameters.: Wait handle # ID # ##########################################################################*/ .global RdosAddWaitForMouse RdosAddWaitForMouse: pushl %ebp movl %esp,%ebp pushl %ebx pushl %ecx movw 8(%ebp),%bx movl 12(%ebp),%ecx UserGate add_wait_for_mouse_nr popl %ecx popl %ebx leave ret /*########################################################################## # # Name : RdosAddWaitForCom # # Purpose....: Add com object to wait handle # # Parameters.: Wait handle # Com handle # ID # ##########################################################################*/ .global RdosAddWaitForCom RdosAddWaitForCom: pushl %ebp movl %esp,%ebp pushl %ebx pushl %ecx movw 8(%ebp),%bx movw 12(%ebp),%ax movl 16(%ebp),%ecx UserGate add_wait_for_com_nr popl %ecx popl %ebx leave ret /*########################################################################## # # Name : RdosAddWaitForAdc # # Purpose....: Add ADC object to wait handle # # Parameters.: Wait handle # Adc handle # ID # ##########################################################################*/ .global RdosAddWaitForAdc RdosAddWaitForAdc: pushl %ebp movl %esp,%ebp pushl %ebx pushl %ecx movw 8(%ebp),%bx movw 12(%ebp),%ax movl 16(%ebp),%ecx UserGate add_wait_for_adc_nr popl %ecx popl %ebx leave ret /*########################################################################## # # Name : RdosSetTextMode # # Purpose....: Set text mode # ##########################################################################*/ .global RdosSetTextMode RdosSetTextMode: pushl %ebp movl %esp,%ebp movw $3,%ax UserGate set_video_mode_nr leave ret /*########################################################################## # # Name : RdosSetVideoMode # # Purpose....: Set video mode # # Parameters.: &xres # &yres # &linesize # &LFB # # Returns....: Bitmap handle # ##########################################################################*/ .global RdosSetVideoMode RdosSetVideoMode: pushl %ebp movl %esp,%ebp pushl %ebx pushl %ecx pushl %edx pushl %esi pushl %edi movl 8(%ebp),%edi movw (%edi),%ax movl 12(%ebp),%edi movw (%edi),%cx movl 16(%ebp),%edi movw (%edi),%dx UserGate get_video_mode_nr jc set_video_fail UserGate set_video_mode_nr jc set_video_fail pushl %edi movl 8(%ebp),%edi movzx %ax,%eax movl %eax,(%edi) movl 12(%ebp),%edi movzx %cx,%ecx movl %ecx,(%edi) movl 16(%ebp),%edi movzx %dx,%edx movl %edx,(%edi) movl 20(%ebp),%edi movzx %si,%esi movl %esi,(%edi) popl %edi movl 24(%ebp),%eax movl %edi,(%eax) movzx %bx,%eax jmp set_video_done set_video_fail: xorl %eax,%eax movl 8(%ebp),%edi movl %eax,(%edi) movl 12(%ebp),%edi movl %eax,(%edi) movl 16(%ebp),%edi movl %eax,(%edi) movl 20(%ebp),%edi movl %eax,(%edi) movl 24(%ebp),%edi movl %eax,(%edi) set_video_done: popl %edi popl %esi popl %edx popl %ecx popl %ebx leave ret /*########################################################################## # # Name : RdosSetClipRect # # Purpose....: Set clip rectangle # # Parameters.: Bitmap handle # xmin, xmax, ymin, ymax # ##########################################################################*/ .global RdosSetClipRect RdosSetClipRect: pushl %ebp movl %esp,%ebp pushl %ebx pushl %ecx pushl %edx pushl %esi pushl %edi movw 8(%ebp),%bx movw 12(%ebp),%cx movw 16(%ebp),%dx movw 20(%ebp),%si movw 24(%ebp),%di UserGate set_clip_rect_nr popl %edi popl %esi popl %edx popl %ecx popl %ebx leave ret /*########################################################################## # # Name : RdosClearClipRect # # Purpose....: Clear clip rectangle # # Parameters.: Bitmap handle # ##########################################################################*/ .global RdosClearClipRect RdosClearClipRect: pushl %ebp movl %esp,%ebp pushl %ebx movw 8(%ebp),%bx UserGate clear_clip_rect_nr popl %ebx leave ret /*########################################################################## # # Name : RdosSetDrawColor # # Purpose....: Set draw color # # Parameters.: Bitmap handle # Color # ##########################################################################*/ .global RdosSetDrawColor RdosSetDrawColor: pushl %ebp movl %esp,%ebp pushl %eax pushl %ebx movw 8(%ebp),%bx movl 12(%ebp),%eax UserGate set_drawcolor_nr popl %ebx popl %eax leave ret /*########################################################################## # # Name : RdosSetLGOP # # Purpose....: Set draw color # # Parameters.: Bitmap handle # LGOP # ##########################################################################*/ .global RdosSetLGOP RdosSetLGOP: pushl %ebp movl %esp,%ebp pushl %eax pushl %ebx movw 8(%ebp),%bx movw 12(%ebp),%ax UserGate set_lgop_nr popl %ebx popl %eax leave ret /*########################################################################## # # Name : RdosSetHollowStyle # # Purpose....: Set hollow fill style # # Parameters.: Bitmap handle # ##########################################################################*/ .global RdosSetHollowStyle RdosSetHollowStyle: pushl %ebp movl %esp,%ebp pushl %ebx movw 8(%ebp),%bx UserGate set_hollow_style_nr popl %ebx leave ret /*########################################################################## # # Name : RdosSetFilledStyle # # Purpose....: Set filled fill style # # Parameters.: Bitmap handle # ##########################################################################*/ .global RdosSetFilledStyle RdosSetFilledStyle: pushl %ebp movl %esp,%ebp pushl %ebx movw 8(%ebp),%bx UserGate set_filled_style_nr popl %ebx leave ret /*########################################################################## # # Name : RdosOpenFont # # Purpose....: Open a font # # Parameters.: height # # Returns....: Font handle # ##########################################################################*/ .global RdosOpenFont RdosOpenFont: pushl %ebp movl %esp,%ebp pushl %ebx movw 8(%ebp),%ax UserGate open_font_nr movzx %bx,%eax popl %ebx leave ret /*########################################################################## # # Name : RdosCloseFont # # Purpose....: Close font handle # # Parameters.: Font handle # ##########################################################################*/ .global RdosCloseFont RdosCloseFont: pushl %ebp movl %esp,%ebp pushl %ebx movw 8(%ebp),%bx UserGate close_font_nr popl %ebx leave ret /*########################################################################## # # Name : RdosGetStringMetrics # # Purpose....: Get string metrics for text using font # # Parameters.: Font handle # String # &width # &height # ##########################################################################*/ .global RdosGetStringMetrics RdosGetStringMetrics: pushl %ebp movl %esp,%ebp pushl %ebx pushl %ecx pushl %edx pushl %edi movw 8(%ebp),%bx movl 12(%ebp),%edi UserGate get_string_metrics_nr movl 16(%ebp),%edi movzx %cx,%ecx movl %ecx,(%edi) movl 20(%ebp),%edi movzx %dx,%edx movl %edx,(%edi) popl %edi popl %edx popl %ecx popl %ebx leave ret /*########################################################################## # # Name : RdosSetFont # # Purpose....: Set font # # Parameters.: Bitmap handle # Font handle # ##########################################################################*/ .global RdosSetFont RdosSetFont: pushl %ebp movl %esp,%ebp pushl %eax pushl %ebx movw 8(%ebp),%bx movw 12(%ebp),%ax UserGate set_font_nr popl %ebx popl %eax leave ret /*########################################################################## # # Name : RdosGetPixel # # Purpose....: Get pixel # # Parameters.: Bitmap handle # x, y # ##########################################################################*/ .global RdosGetPixel RdosGetPixel: pushl %ebp movl %esp,%ebp pushl %ebx pushl %ecx pushl %edx movw 8(%ebp),%bx movw 12(%ebp),%cx movw 16(%ebp),%dx UserGate get_pixel_nr popl %edx popl %ecx popl %ebx leave ret /*########################################################################## # # Name : RdosSetPixel # # Purpose....: Set pixel # # Parameters.: Bitmap handle # x, y # ##########################################################################*/ .global RdosSetPixel RdosSetPixel: pushl %ebp movl %esp,%ebp pushl %ebx pushl %ecx pushl %edx movw 8(%ebp),%bx movw 12(%ebp),%cx movw 16(%ebp),%dx UserGate set_pixel_nr popl %edx popl %ecx popl %ebx leave ret /*########################################################################## # # Name : RdosBlit # # Purpose....: Blit # # Parameters.: SrcHandle # DestHandle # width, height # SrcX, SrcY # DestX, DestY # ##########################################################################*/ .global RdosBlit RdosBlit: pushl %ebp movl %esp,%ebp pushl %eax pushl %ebx pushl %ecx pushl %edx pushl %esi pushl %edi ; movw 8(%ebp),%ax movw 12(%ebp),%bx movw 16(%ebp),%cx movw 20(%ebp),%dx movw 28(%ebp),%si shll $16,%esi movw 24(%ebp),%si movw 36(%ebp),%di shll $16,%edi movw 32(%ebp),%di UserGate blit_nr popl %edi popl %esi popl %edx popl %ecx popl %ebx popl %eax leave ret /*########################################################################## # # Name : RdosDrawMask # # Purpose....: Draw mask # # Parameters.: Bitmap handle # mask # RowSize # width, height # SrcX, SrcY # DestX, DestY # ##########################################################################*/ .global RdosDrawMask RdosDrawMask: pushl %ebp movl %esp,%ebp pushl %eax pushl %ebx pushl %ecx pushl %edx pushl %esi pushl %edi ; movw 8(%ebp),%bx movl 12(%ebp),%edi movw 16(%ebp),%ax movw 24(%ebp),%si shll $16,%esi movw 20(%ebp),%si movw 32(%ebp),%cx shll $16,%ecx movw 28(%ebp),%cx movw 40(%ebp),%dx shll $16,%edx movw 36(%ebp),%dx UserGate draw_mask_nr popl %edi popl %esi popl %edx popl %ecx popl %ebx popl %eax leave ret /*########################################################################## # # Name : RdosDrawLine # # Purpose....: Draw a line # # Parameters.: Bitmap handle # x1, y1 # x2, y2 # ##########################################################################*/ .global RdosDrawLine RdosDrawLine: pushl %ebp movl %esp,%ebp pushl %ebx pushl %ecx pushl %edx pushl %esi pushl %edi ; movw 8(%ebp),%bx movw 12(%ebp),%cx movw 16(%ebp),%dx movw 20(%ebp),%si movw 24(%ebp),%di UserGate draw_line_nr popl %edi popl %esi popl %edx popl %ecx popl %ebx leave ret /*########################################################################## # # Name : RdosDrawString # # Purpose....: Draw a string # # Parameters.: Bitmap handle # x, y # string # ##########################################################################*/ .global RdosDrawString RdosDrawString: pushl %ebp movl %esp,%ebp pushl %ebx pushl %ecx pushl %edx pushl %edi ; movw 8(%ebp),%bx movw 12(%ebp),%cx movw 16(%ebp),%dx movl 20(%ebp),%edi UserGate draw_string_nr popl %edi popl %edx popl %ecx popl %ebx leave ret /*########################################################################## # # Name : RdosDrawRect # # Purpose....: Draw a rect # # Parameters.: Bitmap handle # x, y # width, height # ##########################################################################*/ .global RdosDrawRect RdosDrawRect: pushl %ebp movl %esp,%ebp pushl %ebx pushl %ecx pushl %edx pushl %esi pushl %edi movw 8(%ebp),%bx movw 12(%ebp),%cx movw 16(%ebp),%dx movw 20(%ebp),%si movw 24(%ebp),%di UserGate draw_rect_nr popl %edi popl %esi popl %edx popl %ecx popl %ebx leave ret /*########################################################################## # # Name : RdosDrawEllipse # # Purpose....: Draw an ellipse # # Parameters.: Bitmap handle # x, y # width, height # ##########################################################################*/ .global RdosDrawEllipse RdosDrawEllipse: pushl %ebp movl %esp,%ebp pushl %ebx pushl %ecx pushl %edx pushl %esi pushl %edi movw 8(%ebp),%bx movw 12(%ebp),%cx movw 16(%ebp),%dx movw 20(%ebp),%si movw 24(%ebp),%di UserGate draw_ellipse_nr popl %edi popl %esi popl %edx popl %ecx popl %ebx leave ret /*########################################################################## # # Name : RdosCreateBitmap # # Purpose....: Create a bitmap # # Parameters.: BitsPerPixel # width, height # # Returns....: Bitmap handle # ##########################################################################*/ .global RdosCreateBitmap RdosCreateBitmap: pushl %ebp movl %esp,%ebp pushl %ebx pushl %ecx pushl %edx movw 8(%ebp),%ax movw 12(%ebp),%cx movw 16(%ebp),%dx UserGate create_bitmap_nr movzx %bx,%eax ; popl %edx popl %ecx popl %ebx leave ret /*########################################################################## # # Name : RdosDuplicateBitmapHandle # # Purpose....: Duplicate bitmap handle for use in another thread / object # # Parameters.: Bitmap handle # # Returns....: Bitmap handle # ##########################################################################*/ .global RdosDuplicateBitmapHandle RdosDuplicateBitmapHandle: pushl %ebp movl %esp,%ebp pushl %ebx movw 8(%ebp),%bx UserGate dup_bitmap_handle_nr movzx %bx,%eax popl %ebx leave ret /*########################################################################## # # Name : RdosCloseBitmap # # Purpose....: Close bitmap handle # # Parameters.: Bitmap handle # ##########################################################################*/ .global RdosCloseBitmap RdosCloseBitmap: pushl %ebp movl %esp,%ebp pushl %ebx movw 8(%ebp),%bx UserGate close_bitmap_nr popl %ebx leave ret /*########################################################################## # # Name : RdosCreateStringBitmap # # Purpose....: Create bitmap from string & font # # Parameters.: Font # string # # Returns....: Bitmap handle # ##########################################################################*/ .global RdosCreateStringBitmap RdosCreateStringBitmap: pushl %ebp movl %esp,%ebp pushl %ebx pushl %edi movw 8(%ebp),%bx movl 12(%ebp),%edi UserGate create_string_bitmap_nr movzx %bx,%eax ; popl %edi popl %ebx leave ret /*########################################################################## # # Name : RdosGetBitmapInfo # # Purpose....: Get info about bitmap # # Parameters.: Bitmap handle # &BitsPerPixel # &width, &height # &linesize # &LFB # ##########################################################################*/ .global RdosGetBitmapInfo RdosGetBitmapInfo: pushl %ebp movl %esp,%ebp pushl %eax pushl %ebx pushl %ecx pushl %edx pushl %esi pushl %edi movw 8(%ebp),%bx UserGate get_bitmap_info_nr jc gbiFail pushl %edi movl 12(%ebp),%edi movzx %al,%eax movl %eax,(%edi) movl 16(%ebp),%edi movzx %cx,%ecx movl %ecx,(%edi) movl 20(%ebp),%edi movzx %dx,%edx movl %edx,(%edi) movl 24(%ebp),%edi movzx %si,%esi movl %esi,(%edi) popl %edi movl 28(%ebp),%eax movl %edi,(%eax) jmp gbiDone gbiFail: xorl %eax,%eax movl 12(%ebp),%edi movl %eax,(%edi) movl 16(%ebp),%edi movl %eax,(%edi) movl 20(%ebp),%edi movl %eax,(%edi) movl 24(%ebp),%edi movl %eax,(%edi) movl 28(%ebp),%edi movl %eax,(%edi) gbiDone: popl %edi popl %esi popl %edx popl %ecx popl %ebx popl %eax leave ret /*########################################################################## # # Name : RdosCreateSprite # # Purpose....: Create a sprite # # Parameters.: dest # bitmap # mask # LGOP # # Returns....: Sprite handle # ##########################################################################*/ .global RdosCreateSprite RdosCreateSprite: pushl %ebp movl %esp,%ebp pushl %ebx pushl %ecx pushl %edx movw 8(%ebp),%bx movw 12(%ebp),%cx movw 16(%ebp),%dx movw 20(%ebp),%ax UserGate create_sprite_nr movzx %bx,%eax popl %edx popl %ecx popl %ebx leave ret /*########################################################################## # # Name : RdosCloseSprite # # Purpose....: Close sprite handle # # Parameters.: Sprite handle # ##########################################################################*/ .global RdosCloseSprite RdosCloseSprite: pushl %ebp movl %esp,%ebp pushl %ebx movw 8(%ebp),%bx UserGate close_sprite_nr popl %ebx leave ret /*########################################################################## # # Name : RdosShowSprite # # Purpose....: Show sprite # # Parameters.: Sprite handle # ##########################################################################*/ .global RdosShowSprite RdosShowSprite: pushl %ebp movl %esp,%ebp pushl %ebx movw 8(%ebp),%bx UserGate show_sprite_nr popl %ebx leave ret /*########################################################################## # # Name : RdosHideSprite # # Purpose....: Hide sprite # # Parameters.: Sprite handle # ##########################################################################*/ .global RdosHideSprite RdosHideSprite: pushl %ebp movl %esp,%ebp pushl %ebx movw 8(%ebp),%bx UserGate hide_sprite_nr popl %ebx leave ret /*########################################################################## # # Name : RdosMoveSprite # # Purpose....: Move sprite # # Parameters.: Sprite handle # x, y # ##########################################################################*/ .global RdosMoveSprite RdosMoveSprite: pushl %ebp movl %esp,%ebp pushl %ebx pushl %ecx pushl %edx movw 8(%ebp),%bx movw 12(%ebp),%cx movw 16(%ebp),%dx UserGate move_sprite_nr popl %edx popl %ecx popl %ebx leave ret /*########################################################################## # # Name : RdosSetForeColor # # Purpose....: Set text-mode fore color # # Parameters.: palette index # ##########################################################################*/ .global RdosSetForeColor RdosSetForeColor: pushl %ebp movl %esp,%ebp pushl %eax movb 8(%ebp),%al UserGate set_forecolor_nr popl %eax leave ret /*########################################################################## # # Name : RdosSetBackColor # # Purpose....: Set text-mode back color # # Parameters.: palette index # ##########################################################################*/ .global RdosSetBackColor RdosSetBackColor: pushl %ebp movl %esp,%ebp pushl %eax movb 8(%ebp),%al UserGate set_backcolor_nr popl %eax leave ret /*########################################################################## # # Name : RdosGetSysTime # # Purpose....: Get system time # # Parameters.: &year, &month, &day # &hour, &min, &sec, &ms # ##########################################################################*/ .global RdosGetSysTime RdosGetSysTime: pushl %ebp movl %esp,%ebp pushal UserGate get_system_time_nr pushl %eax UserGate binary_to_time_nr pushl %edx movl 8(%ebp),%esi movzx %dx,%edx movl %edx,(%esi) movl 12(%ebp),%esi movzx %ch,%edx movl %edx,(%esi) movl 16(%ebp),%esi movzx %cl,%edx movl %edx,(%esi) movl 20(%ebp),%esi movzx %bh,%edx movl %edx,(%esi) movl 24(%ebp),%esi movzx %bl,%edx movl %edx,(%esi) movl 28(%ebp),%esi movzx %ah,%edx movl %edx,(%esi) popl %edx UserGate time_to_binary_nr movl %eax,%ebx popl %eax subl %ebx,%eax xorl %edx,%edx movl $1192,%ebx divl %ebx movl 32(%ebp),%esi movzx %ax,%eax movl %eax,(%esi) popal leave ret /*########################################################################## # # Name : RdosGetTime # # Purpose....: Get time # # Parameters.: &year, &month, &day # &hour, &min, &sec, &ms # ##########################################################################*/ .global RdosGetTime RdosGetTime: pushl %ebp movl %esp,%ebp pushal UserGate get_time_nr pushl %eax UserGate binary_to_time_nr pushl %edx movl 8(%ebp),%esi movzx %dx,%edx movl %edx,(%esi) movl 12(%ebp),%esi movzx %ch,%edx movl %edx,(%esi) movl 16(%ebp),%esi movzx %cl,%edx movl %edx,(%esi) movl 20(%ebp),%esi movzx %bh,%edx movl %edx,(%esi) movl 24(%ebp),%esi movzx %bl,%edx movl %edx,(%esi) movl 28(%ebp),%esi movzx %ah,%edx movl %edx,(%esi) popl %edx UserGate time_to_binary_nr movl %eax,%ebx popl %eax subl %ebx,%eax xorl %edx,%edx movl $1192,%ebx divl %ebx movl 32(%ebp),%esi movzx %ax,%eax movl %eax,(%esi) popal leave ret /*########################################################################## # # Name : RdosSetTime # # Purpose....: Set time # # Parameters.: year, month, day # hour, min, sec, ms # ##########################################################################*/ .global RdosSetTime RdosSetTime: pushl %ebp movl %esp,%ebp pushal movw 8(%ebp),%dx movb 12(%ebp),%ch movb 16(%ebp),%cl movb 20(%ebp),%bh movb 24(%ebp),%bl movb 28(%ebp),%ah UserGate time_to_binary_nr movl %edx,%edi movl %eax,%esi movl 32(%ebp),%eax movl $1192,%edx mull %edx addl %eax,%esi adcl $0,%edi UserGate get_system_time_nr subl %eax,%esi sbbl %edx,%edi movl %esi,%eax movl %edi,%edx UserGate update_time_nr popal leave ret /*########################################################################## # # Name : RdosTicsToRecord # # Purpose....: Convert tics to record format # # Parameters.: MSB, LSB # &year, &month, &day # &hour, &min, &sec, &ms # ##########################################################################*/ .global RdosTicsToRecord RdosTicsToRecord: pushl %ebp movl %esp,%ebp pushal movl 8(%ebp),%edx movl 12(%ebp),%eax addl $596,%eax adcl $0,%edx UserGate binary_to_time_nr pushl %edx movl 16(%ebp),%esi movzx %dx,%edx movl %edx,(%esi) movl 20(%ebp),%esi movzx %ch,%edx movl %edx,(%esi) movl 24(%ebp),%esi movzx %cl,%edx movl %edx,(%esi) movl 28(%ebp),%esi movzx %bh,%edx movl %edx,(%esi) movl 32(%ebp),%esi movzx %bl,%edx movl %edx,(%esi) movl 36(%ebp),%esi movzx %ah,%edx movl %edx,(%esi) popl %edx UserGate time_to_binary_nr movl %eax,%ebx movl 12(%ebp),%eax subl %edx,%eax xorl %edx,%edx movl $1192,%ebx divl %ebx movl 40(%ebp),%esi cmpw %ax,1000 jne rttrSaveMs decw %ax rttrSaveMs: movzx %ax,%eax movl %eax,(%esi) popal leave ret /*########################################################################## # # Name : RdosRecordToTics # # Purpose....: Convert from record format to tics # # Parameters.: &MSB, &LSB # year, month, day # hour, min, sec, ms # ##########################################################################*/ .global RdosRecordToTics RdosRecordToTics: pushl %ebp movl %esp,%ebp pushal movl 40(%ebp),%eax movl $1192,%edx mull %edx pushl %eax movw 16(%ebp),%dx movb 20(%ebp),%ch movb 24(%ebp),%cl movb 28(%ebp),%bh movb 32(%ebp),%bl movb 36(%ebp),%ah UserGate time_to_binary_nr popl %ebx addl %ebx,%eax adcl $0,%edx movl 8(%ebp),%esi movl %edx,(%esi) movl 12(%ebp),%esi movl %eax,(%esi) popal leave ret /*########################################################################## # # Name : RdosDecodeMsbTics # # Purpose....: Decode MSB tics # # Parameters.: MSB # &day, &hour # ##########################################################################*/ .global RdosDecodeMsbTics RdosDecodeMsbTics: pushl %ebp movl %esp,%ebp pushal movl 8(%ebp),%eax xorl %edx,%edx movl $24,%ecx divl %ecx movl 12(%ebp),%ebx movl %eax,(%ebx) movl 16(%ebp),%ebx movl %edx,(%ebx) popal leave ret /*########################################################################## # # Name : RdosDecodeLsbTics # # Purpose....: Decode LSB tics # # Parameters.: LSB # &min, &sec, &ms, &us # ##########################################################################*/ .global RdosDecodeLsbTics RdosDecodeLsbTics: pushl %ebp movl %esp,%ebp pushal movl 8(%ebp),%eax movl $60,%edx mull %edx movl 12(%ebp),%ebx movl %edx,(%ebx) movl $60,%edx mull %edx movl 16(%ebp),%ebx movl %edx,(%ebx) movl $1000,%edx mull %edx movl 20(%ebp),%ebx movl %edx,(%ebx) movl $1000,%edx mull %edx movl 24(%ebp),%ebx movl %edx,(%ebx) popal leave ret /*########################################################################## # # Name : RdosDayOfWeek # # Purpose....: Get day of week # # Parameters.: year, month, day # # Returns....: day of week # ##########################################################################*/ .global RdosDayOfWeek RdosDayOfWeek: pushl %ebp movl %esp,%ebp pushl %ebx pushl %ecx pushl %edx movl 8(%ebp),%edx movb 12(%ebp),%ch movb 16(%ebp),%cl xorw %bx,%bx xorb %ah,%ah UserGate adjust_time_nr pushw %dx movl $365,%eax imulw %dx pushw %dx pushw %ax popl %ebx popw %dx UserGate passed_days_nr decw %dx shrw $2,%dx incw %dx addw %dx,%ax addl %ebx,%eax xorl %edx,%edx addl $5,%eax movl $7,%ebx divl %ebx movzx %dl,%eax popl %edx popl %ecx popl %ebx leave ret /*########################################################################## # # Name : RdosGetTics # # Purpose....: Get system tics # # Parameters.: &MSB, &LSB # ##########################################################################*/ .global RdosGetTics RdosGetTics: pushl %ebp movl %esp,%ebp pushl %edx pushl %esi UserGate get_time_nr movl 8(%ebp),%esi movl %edx,(%esi) movl 12(%ebp),%esi movl %eax,(%esi) popl %esi popl %edx leave ret /*########################################################################## # # Name : RdosAddTics # # Purpose....: Add tics to binary time # # Parameters.: &MSB, &LSB # tics # ##########################################################################*/ .global RdosAddTics RdosAddTics: pushl %ebp movl %esp,%ebp pushl %ebx movl 16(%ebp),%eax movl 12(%ebp),%ebx addl %eax,(%ebx) movl 8(%ebp),%ebx adcl $0,(%ebx) popl %ebx leave ret /*########################################################################## # # Name : RdosAddMilli # # Purpose....: Add milliseconds to binary time # # Parameters.: &MSB, &LSB # milli # ##########################################################################*/ .global RdosAddMilli RdosAddMilli: pushl %ebp movl %esp,%ebp pushl %ebx movl 16(%ebp),%eax movl $1193,%edx mull %edx movl 12(%ebp),%ebx addl %eax,(%ebx) movl 8(%ebp),%ebx adcl %edx,(%ebx) popl %ebx leave ret /*########################################################################## # # Name : RdosAddSec # # Purpose....: Add milliseconds to binary time # # Parameters.: &MSB, &LSB # sec # ##########################################################################*/ .global RdosAddSec RdosAddSec: pushl %ebp movl %esp,%ebp pushl %ebx movl 16(%ebp),%eax movl $1193000,%edx mull %edx movl 12(%ebp),%ebx addl %eax,(%ebx) movl 8(%ebp),%ebx adcl %edx,(%ebx) popl %ebx leave ret /*########################################################################## # # Name : RdosAddMin # # Purpose....: Add minutes to binary time # # Parameters.: &MSB, &LSB # min # ##########################################################################*/ .global RdosAddMin RdosAddMin: pushl %ebp movl %esp,%ebp pushl %ebx movl 16(%ebp),%eax movl $71582760,%edx mull %edx movl 12(%ebp),%ebx addl %eax,(%ebx) movl 8(%ebp),%ebx adcl %edx,(%ebx) popl %ebx leave ret /*########################################################################## # # Name : RdosAddHour # # Purpose....: Add hour to binary time # # Parameters.: &MSB, &LSB # hour # ##########################################################################*/ .global RdosAddHour RdosAddHour: pushl %ebp movl %esp,%ebp pushl %ebx movl 16(%ebp),%eax movl 8(%ebp),%ebx adc %eax,(%ebx) popl %ebx leave ret /*########################################################################## # # Name : RdosAddDay # # Purpose....: Add days to binary time # # Parameters.: &MSB, &LSB # days # ##########################################################################*/ .global RdosAddDay RdosAddDay: pushl %ebp movl %esp,%ebp pushl %ebx movl 16(%ebp),%eax movl $24,%edx mull %edx movl 8(%ebp),%ebx adc %eax,(%ebx) popl %ebx leave ret /*########################################################################## # # Name : RdosSyncTime # # Purpose....: Synchronize time with NTP # # Parameters.: IP # ##########################################################################*/ .global RdosSyncTime RdosSyncTime: pushl %ebp movl %esp,%ebp pushal movl 8(%ebp),%edx UserGate sync_time_nr jc RdosSyncTimeFail movl $1,%eax jmp RdosSyncTimeDone RdosSyncTimeFail: xorl %eax,%eax RdosSyncTimeDone: popal leave ret /*########################################################################## # # Name : RdosOpenCom # # Purpose....: Open com-port # # Parameters.: ID # baudrate # parity # data bits # stop bits # SendBufferSize # RecBufferSize # # Returns...: Com handle # ##########################################################################*/ .global RdosOpenCom RdosOpenCom: pushl %ebp movl %esp,%ebp pushl %ebx pushl %ecx pushl %edx pushl %esi pushl %edi movb 8(%ebp),%al movb 20(%ebp),%ah movb 24(%ebp),%bl movb 16(%ebp),%bh movl 12(%ebp),%ecx movw 28(%ebp),%si movw 32(%ebp),%di UserGate open_com_nr movzx %bx,%eax popl %edi popl %esi popl %edx popl %ecx popl %ebx leave ret /*########################################################################## # # Name : RdosCloseCom # # Purpose....: Close com-port # # Parameters.: Com handle # ##########################################################################*/ .global RdosCloseCom RdosCloseCom: pushl %ebp movl %esp,%ebp pushl %ebx movw 8(%ebp),%bx UserGate close_com_nr popl %ebx leave ret /*########################################################################## # # Name : RdosFlushCom # # Purpose....: Flush com-port # # Parameters.: Com handle # ##########################################################################*/ .global RdosFlushCom RdosFlushCom: pushl %ebp movl %esp,%ebp pushl %ebx movw 8(%ebp),%bx UserGate flush_com_nr popl %ebx leave ret /*########################################################################## # # Name : RdosReadCom # # Purpose....: Read com-port # # Parameters.: Com handle # # Returns....: Character # ##########################################################################*/ .global RdosReadCom RdosReadCom: pushl %ebp movl %esp,%ebp pushl %ebx movw 8(%ebp),%bx UserGate read_com_nr popl %ebx leave ret /*########################################################################## # # Name : RdosWriteCom # # Purpose....: Write com-port # # Parameters.: Com handle # char # # Returns....: 0 for success # ##########################################################################*/ .global RdosWriteCom RdosWriteCom: pushl %ebp movl %esp,%ebp pushl %ebx movw 8(%ebp),%bx movb 12(%ebp),%al UserGate write_com_nr movzx %al,%eax popl %ebx leave ret /*########################################################################## # # Name : RdosWaitForSendCompletedCom # # Purpose....: Wait until send buffer is empty # # Parameters.: Com handle # ##########################################################################*/ .global RdosWaitForSendCompletedCom RdosWaitForSendCompletedCom: pushl %ebp movl %esp,%ebp pushl %ebx movw 8(%ebp),%bx UserGate wait_for_send_completed_com_nr popl %ebx leave ret /*########################################################################## # # Name : RdosEnableCts # # Purpose....: Enable CTS signal # # Parameters.: Com handle # ##########################################################################*/ .global RdosEnableCts RdosEnableCts: pushl %ebp movl %esp,%ebp pushl %ebx movw 8(%ebp),%bx UserGate enable_cts_nr popl %ebx leave ret /*########################################################################## # # Name : RdosDisableCts # # Purpose....: Disable CTS signal # # Parameters.: Com handle # ##########################################################################*/ .global RdosDisableCts RdosDisableCts: pushl %ebp movl %esp,%ebp pushl %ebx movw 8(%ebp),%bx UserGate disable_cts_nr popl %ebx leave ret /*########################################################################## # # Name : RdosEnableAutoRts # # Purpose....: Enable auto RTS signal generation for RS485 # # Parameters.: Com handle # ##########################################################################*/ .global RdosEnableAutoRts RdosEnableAutoRts: pushl %ebp movl %esp,%ebp pushl %ebx movw 8(%ebp),%bx UserGate enable_auto_rts_nr popl %ebx leave ret /*########################################################################## # # Name : RdosDisableAutoRts # # Purpose....: Disable auto RTS signal generation for RS485 # # Parameters.: Com handle # ##########################################################################*/ .global RdosDisableAutoRts RdosDisableAutoRts: pushl %ebp movl %esp,%ebp pushl %ebx movw 8(%ebp),%bx UserGate disable_auto_rts_nr popl %ebx leave ret /*########################################################################## # # Name : RdosSetDtr # # Purpose....: Set DTR active # # Parameters.: Com handle # ##########################################################################*/ .global RdosSetDtr RdosSetDtr: pushl %ebp movl %esp,%ebp pushl %ebx movw 8(%ebp),%bx UserGate set_dtr_nr popl %ebx leave ret /*########################################################################## # # Name : RdosResetDtr # # Purpose....: Set DTR inactive # # Parameters.: Com handle # ##########################################################################*/ .global RdosResetDtr RdosResetDtr: pushl %ebp movl %esp,%ebp pushl %ebx movw 8(%ebp),%bx UserGate reset_dtr_nr popl %ebx leave ret /*########################################################################## # # Name : RdosSetRts # # Purpose....: Set RTS active # # Parameters.: Com handle # ##########################################################################*/ .global RdosSetRts RdosSetRts: pushl %ebp movl %esp,%ebp pushl %ebx movw 8(%ebp),%bx UserGate set_rts_nr popl %ebx leave ret /*########################################################################## # # Name : RdosResetRts # # Purpose....: Set RTS inactive # # Parameters.: Com handle # ##########################################################################*/ .global RdosResetRts RdosResetRts: pushl %ebp movl %esp,%ebp pushl %ebx movw 8(%ebp),%bx UserGate reset_rts_nr popl %ebx leave ret /*########################################################################## # # Name : RdosGetReceiveBufferSpace # # Purpose....: Get receive buffer free space # # Parameters.: Com handle # # Returns....: Free bytes # ##########################################################################*/ .global RdosGetReceiveBufferSpace RdosGetReceiveBufferSpace: pushl %ebp movl %esp,%ebp pushl %ebx movw 8(%ebp),%bx UserGate get_com_receive_space_nr popl %ebx leave ret /*########################################################################## # # Name : RdosGetSendBufferSpace # # Purpose....: Get send buffer free space # # Parameters.: Com handle # # Returns....: Free bytes # ##########################################################################*/ .global RdosGetSendBufferSpace RdosGetSendBufferSpace: pushl %ebp movl %esp,%ebp pushl %ebx movw 8(%ebp),%bx UserGate get_com_send_space_nr popl %ebx leave ret /*########################################################################## # # Name : RdosOpenFile # # Purpose....: Open file # # Parameters.: Filename # Access # # Returns...: File handle # ##########################################################################*/ .global RdosOpenFile RdosOpenFile: pushl %ebp movl %esp,%ebp pushl %ebx pushl %ecx pushl %edi movl 8(%ebp),%edi movb 12(%ebp),%cl UserGate open_file_nr jc OpenFileFailed movzx %bx,%eax jmp OpenFileDone OpenFileFailed: xorl %eax,%eax OpenFileDone: popl %edi popl %ecx popl %ebx leave ret /*########################################################################## # # Name : RdosCreateFile # # Purpose....: Create file # # Parameters.: Filename # Attribute # # Returns...: File handle # ##########################################################################*/ .global RdosCreateFile RdosCreateFile: pushl %ebp movl %esp,%ebp pushl %ebx pushl %ecx pushl %edi movl 8(%ebp),%edi movw 12(%ebp),%cx UserGate create_file_nr jc CreateFileFailed movzx %bx,%eax jmp CreateFileDone CreateFileFailed: xorl %eax,%eax CreateFileDone: popl %edi popl %ecx popl %ebx leave ret /*########################################################################## # # Name : RdosCloseFile # # Purpose....: Close file # # Parameters.: File handle # ##########################################################################*/ .global RdosCloseFile RdosCloseFile: pushl %ebp movl %esp,%ebp pushl %ebx movw 8(%ebp),%bx UserGate close_file_nr popl %ebx leave ret /*########################################################################## # # Name : RdosIsDevice # # Purpose....: Check if file is device # # Parameters.: TRUE if device # ##########################################################################*/ .global RdosIsDevice RdosIsDevice: pushl %ebp movl %esp,%ebp pushl %ebx movw 8(%ebp),%bx UserGate get_ioctl_data_nr testw $0x8000,%dx jz ridFail movl $1,%eax jmp ridDone ridFail: xorl %eax,%eax ridDone: popl %ebx leave ret /*########################################################################## # # Name : RdosDuplFile # # Purpose....: Duplicate file handle # # Parameters.: File handle # # Returns....: File handle # ##########################################################################*/ .global RdosDuplFile RdosDuplFile: pushl %ebp movl %esp,%ebp pushl %ebx movw 8(%ebp),%bx UserGate dupl_file_nr jc DuplFileFailed movzx %bx,%eax jmp DuplFileDone DuplFileFailed: xorl %eax,%eax DuplFileDone: popl %ebx leave ret /*########################################################################## # # Name : RdosGetFileSize # # Purpose....: Get file size # # Parameters.: File handle # # Returns....: Size # ##########################################################################*/ .global RdosGetFileSize RdosGetFileSize: pushl %ebp movl %esp,%ebp pushl %ebx movw 8(%ebp),%bx UserGate get_file_size_nr jnc GetFileSizeDone GetFileSizeFail: xorl %eax,%eax GetFileSizeDone: popl %ebx leave ret /*########################################################################## # # Name : RdosSetFileSize # # Purpose....: Set file size # # Parameters.: File handle # Size # ##########################################################################*/ .global RdosSetFileSize RdosSetFileSize: pushl %ebp movl %esp,%ebp pushl %eax pushl %ebx movw 8(%ebp),%bx movl 12(%ebp),%eax UserGate set_file_size_nr popl %ebx popl %eax leave ret /*########################################################################## # # Name : RdosGetFilePos # # Purpose....: Get file position # # Parameters.: File handle # # Returns....: Position # ##########################################################################*/ .global RdosGetFilePos RdosGetFilePos: pushl %ebp movl %esp,%ebp pushl %ebx movw 8(%ebp),%bx UserGate get_file_pos_nr jnc GetFilePosDone GetFilePosFail: xorl %eax,%eax GetFilePosDone: popl %ebx leave ret /*########################################################################## # # Name : RdosSetFilePos # # Purpose....: Set file position # # Parameters.: File handle # Position # ##########################################################################*/ .global RdosSetFilePos RdosSetFilePos: pushl %ebp movl %esp,%ebp pushl %eax pushl %ebx movw 8(%ebp),%bx movl 12(%ebp),%eax UserGate set_file_pos_nr popl %ebx popl %eax leave ret /*########################################################################## # # Name : RdosGetFileTime # # Purpose....: Get file time & date # # Parameters.: File handle # &MSB, &LSB # ##########################################################################*/ .global RdosGetFileTime RdosGetFileTime: pushl %ebp movl %esp,%ebp pushl %ebx pushl %edi movw 8(%ebp),%bx UserGate get_file_time_nr jc GetFileTimeDone movl 12(%ebp),%edi movl %edx,(%edi) movl 16(%ebp),%edi movl %eax,(%edi) GetFileTimeDone: popl %edi popl %ebx leave ret /*########################################################################## # # Name : RdosSetFileTime # # Purpose....: Set file time & date # # Parameters.: File handle # MSB, LSB # ##########################################################################*/ .global RdosSetFileTime RdosSetFileTime: pushl %ebp movl %esp,%ebp pushl %eax pushl %ebx pushl %edx movw 8(%ebp),%bx movl 12(%ebp),%edx movl 16(%ebp),%eax UserGate set_file_time_nr popl %edx popl %ebx popl %eax leave ret /*########################################################################## # # Name : RdosReadFile # # Purpose....: Read from file # # Parameters.: File handle # buffer # count # # Returns....: Read count # ##########################################################################*/ .global RdosReadFile RdosReadFile: pushl %ebp movl %esp,%ebp pushl %ebx pushl %ecx pushl %edi movw 8(%ebp),%bx movl 12(%ebp),%edi movl 16(%ebp),%ecx UserGate read_file_nr popl %edi popl %ecx popl %ebx leave ret /*########################################################################## # # Name : RdosWriteFile # # Purpose....: Write to file # # Parameters.: File handle # buffer # count # # Returns....: Written count # ##########################################################################*/ .global RdosWriteFile RdosWriteFile: pushl %ebp movl %esp,%ebp pushl %ebx pushl %ecx pushl %edi movw 8(%ebp),%bx movl 12(%ebp),%edi movl 16(%ebp),%ecx UserGate write_file_nr popl %edi popl %ecx popl %ebx leave ret /*########################################################################## # # Name : RdosCreateMapping # # Purpose....: Create file mapping # # Parameters.: Size # # Returns...: Filemap handle # ##########################################################################*/ .global RdosCreateMapping RdosCreateMapping: pushl %ebp movl %esp,%ebp pushl %ebx movl 8(%ebp),%eax UserGate create_mapping_nr movzx %bx,%eax popl %ebx leave ret /*########################################################################## # # Name : RdosCreateNamedMapping # # Purpose....: Create named file mapping # # Parameters.: Name # Size # # Returns...: Filemap handle # ##########################################################################*/ .global RdosCreateNamedMapping RdosCreateNamedMapping: pushl %ebp movl %esp,%ebp pushl %ebx pushl %edi movl 8(%ebp),%edi movl 12(%ebp),%eax UserGate create_named_mapping_nr movzx %bx,%eax popl %edi popl %ebx leave ret /*########################################################################## # # Name : RdosCreateNamedFileMapping # # Purpose....: Create file named file mapping # # Parameters.: Name # Size # File handle # # Returns...: Filemap handle # ##########################################################################*/ .global RdosCreateNamedFileMapping RdosCreateNamedFileMapping: pushl %ebp movl %esp,%ebp pushl %ebx pushl %edi movl 8(%ebp),%edi movl 12(%ebp),%eax movw 16(%ebp),%bx UserGate create_named_file_mapping_nr movzx %bx,%eax popl %edi popl %ebx leave ret /*########################################################################## # # Name : RdosOpenNamedMapping # # Purpose....: Open named file mapping # # Parameters.: Name # # Returns...: Filemap handle # ##########################################################################*/ .global RdosOpenNamedMapping RdosOpenNamedMapping: pushl %ebp movl %esp,%ebp pushl %ebx pushl %edi movl 8(%ebp),%edi UserGate open_named_mapping_nr movzx %bx,%eax popl %edi popl %ebx leave ret /*########################################################################## # # Name : RdosSyncMapping # # Purpose....: Sync file mapping # # Parameters.: Filemap handle # ##########################################################################*/ .global RdosSyncMapping RdosSyncMapping: pushl %ebp movl %esp,%ebp pushl %ebx movw 8(%ebp),%bx UserGate sync_mapping_nr popl %ebx leave ret /*########################################################################## # # Name : RdosCloseMapping # # Purpose....: Close file mapping # # Parameters.: Filemap handle # ##########################################################################*/ .global RdosCloseMapping RdosCloseMapping: pushl %ebp movl %esp,%ebp pushl %ebx movw 8(%ebp),%bx UserGate close_mapping_nr popl %ebx leave ret /*########################################################################## # # Name : RdosMapView # # Purpose....: Map view of file into memory # # Parameters.: Filemap handle # Offset # Address # Size # ##########################################################################*/ .global RdosMapView RdosMapView: pushl %ebp movl %esp,%ebp pushl %ebx pushl %ecx pushl %edi movw 8(%ebp),%bx movl 12(%ebp),%eax movl 16(%ebp),%edi movl 20(%ebp),%ecx UserGate map_view_nr popl %edi popl %ecx popl %ebx leave ret /*########################################################################## # # Name : RdosUnmapView # # Purpose....: Unmap view of file # # Parameters.: Filemap handle # ##########################################################################*/ .global RdosUnmapView RdosUnmapView: pushl %ebp movl %esp,%ebp pushl %ebx movw 8(%ebp),%bx UserGate unmap_view_nr popl %ebx leave ret /*########################################################################## # # Name : RdosSetCurDrive # # Purpose....: Set current drive # # Parameters.: Drive # ##########################################################################*/ .global RdosSetCurDrive RdosSetCurDrive: pushl %ebp movl %esp,%ebp movb 8(%ebp),%al UserGate set_cur_drive_nr jc rscdrFail movl $1,%eax jmp rscdrDone rscdrFail: xorl %eax,%eax rscdrDone: leave ret /*########################################################################## # # Name : RdosGetCurDrive # # Purpose....: Get current drive # # Returns....: Drive # ##########################################################################*/ .global RdosGetCurDrive RdosGetCurDrive: pushl %ebp movl %esp,%ebp xorl %eax,%eax UserGate get_cur_drive_nr movzx %al,%eax leave ret /*########################################################################## # # Name : RdosSetCurDir # # Purpose....: Set current directory # # Parameters.: Pathname # ##########################################################################*/ .global RdosSetCurDir RdosSetCurDir: pushl %ebp movl %esp,%ebp pushl %edi movl 8(%ebp),%edi UserGate set_cur_dir_nr jc rscdFail movl $1,%eax jmp rscdDone rscdFail: xorl %eax,%eax rscdDone: popl %edi leave ret /*########################################################################## # # Name : RdosGetCurDir # # Purpose....: Get current directory # # Parameters.: Drive # Pathname # ##########################################################################*/ .global RdosGetCurDir RdosGetCurDir: pushl %ebp movl %esp,%ebp pushl %edi movb 8(%ebp),%al movl 12(%ebp),%edi UserGate get_cur_dir_nr jc rgcdFail movl $1,%eax jmp rgcdDone rgcdFail: xorl %eax,%eax rgcdDone: popl %edi leave ret /*########################################################################## # # Name : RdosMakeDir # # Purpose....: Create directory # # Parameters.: Pathname # ##########################################################################*/ .global RdosMakeDir RdosMakeDir: pushl %ebp movl %esp,%ebp pushl %edi movl 8(%ebp),%edi UserGate make_dir_nr jc mdFail movl $1,%eax jmp mdDone mdFail: xorl %eax,%eax mdDone: popl %edi leave ret /*########################################################################## # # Name : RdosRemoveDir # # Purpose....: Remove directory # # Parameters.: Pathname # ##########################################################################*/ .global RdosRemoveDir RdosRemoveDir: pushl %ebp movl %esp,%ebp pushl %edi movl 8(%ebp),%edi UserGate remove_dir_nr jc rdFail movl $1,%eax jmp rdDone rdFail: xorl %eax,%eax rdDone: popl %edi leave ret /*########################################################################## # # Name : RdosRenameFile # # Purpose....: Rename file # # Parameters.: ToName # FromName # ##########################################################################*/ .global RdosRenameFile RdosRenameFile: pushl %ebp movl %esp,%ebp pushl %esi pushl %edi movl 8(%ebp),%edi movl 12(%ebp),%esi UserGate rename_file_nr jc rfFail mov $1,%eax jmp rfDone rfFail: xorl %eax,%eax rfDone: popl %edi popl %esi leave ret /*########################################################################## # # Name : RdosDeleteFile # # Purpose....: Delete file # # Parameters.: Pathname # ##########################################################################*/ .global RdosDeleteFile RdosDeleteFile: pushl %ebp movl %esp,%ebp pushl %edi movl 8(%ebp),%edi UserGate delete_file_nr jc dfFail mov $1,%eax jmp dfDone dfFail: xorl %eax,%eax dfDone: popl %edi leave ret /*########################################################################## # # Name : RdosGetFileAttribute # # Purpose....: Get file attribute # # Parameters.: Pathname # &Attrib # ##########################################################################*/ .global RdosGetFileAttribute RdosGetFileAttribute: pushl %ebp movl %esp,%ebp pushl %ecx pushl %edi movl 8(%ebp),%edi UserGate get_file_attribute_nr jc gfaFail movl 12(%ebp),%edi movzx %cx,%ecx movl %ecx,(%edi) movl $1,%eax jmp gfaDone gfaFail: xorl %eax,%eax gfaDone: popl %edi popl %ecx leave ret /*########################################################################## # # Name : RdosSetFileAttribute # # Purpose....: Set file attribute # # Parameters.: Pathname # Attrib # ##########################################################################*/ .global RdosSetFileAttribute RdosSetFileAttribute: pushl %ebp movl %esp,%ebp pushl %ecx pushl %edi movl 8(%ebp),%edi movw 12(%ebp),%cx UserGate set_file_attribute_nr jc sfaFail movl $1,%eax jmp sfaDone sfaFail: xorl %eax,%eax sfaDone: popl %edi popl %ecx leave ret /*########################################################################## # # Name : RdosOpenDir # # Purpose....: Open directory # # Parameters.: Pathname # # Returns....: Dir handle # ##########################################################################*/ .global RdosOpenDir RdosOpenDir: pushl %ebp movl %esp,%ebp pushl %ebx pushl %edi movl 8(%ebp),%edi UserGate open_dir_nr jc odFail movzx %bx,%eax jmp odDone odFail: xorl %eax,%eax odDone: popl %edi popl %ebx leave ret /*########################################################################## # # Name : RdosCloseDir # # Purpose....: Close directory # # Parameters.: Dir handle # ##########################################################################*/ .global RdosCloseDir RdosCloseDir: pushl %ebp movl %esp,%ebp pushl %ebx movw 8(%ebp),%bx UserGate close_dir_nr popl %ebx leave ret /*########################################################################## # # Name : RdosReadDir # # Purpose....: Read directory entry # # Parameters.: Dir handle # Entry # # MaxNameSize # Name buffer # &FileSize # &Attribute # &Msb time # &Lsb time # ##########################################################################*/ .global RdosReadDir RdosReadDir: pushl %ebp movl %esp,%ebp pushl %ebx pushl %ecx pushl %edi movw 8(%ebp),%bx movw 12(%ebp),%dx movw 16(%ebp),%cx movl 20(%ebp),%edi UserGate read_dir_nr jc rdiFail movl 24(%ebp),%edi movl %ecx,(%edi) movl 28(%ebp),%edi movzx %bx,%ebx movl %ebx,(%edi) movl 32(%ebp),%edi movl %edx,(%edi) movl 36(%ebp),%edi movl %eax,(%edi) movl $1,%eax jmp rdiDone rdiFail: xorl %eax,%eax rdiDone: popl %edi popl %ecx popl %ebx leave ret /*########################################################################## # # Name : RdosSetFocus # # Purpose....: Set input focus # # Parameters.: Focus handle # ##########################################################################*/ .global RdosSetFocus RdosSetFocus: pushl %ebp movl %esp,%ebp movl 8(%ebp),%eax UserGate set_focus_nr leave ret /*########################################################################## # # Name : RdosGetFocus # # Purpose....: Get input focus # # Returns....: Focus handle # ##########################################################################*/ .global RdosGetFocus RdosGetFocus: pushl %ebp movl %esp,%ebp UserGate get_focus_nr leave ret /*########################################################################## # # Name : RdosClearKeyboard # # Purpose....: Clear keyboard buffer # ##########################################################################*/ .global RdosClearKeyboard RdosClearKeyboard: pushl %ebp movl %esp,%ebp UserGate flush_keyboard_nr leave ret /*########################################################################## # # Name : RdosPollKeyboard # # Purpose....: Poll keyboard buffer # # Returns....: TRUE if non-empty # ##########################################################################*/ .global RdosPollKeyboard RdosPollKeyboard: pushl %ebp movl %esp,%ebp UserGate poll_keyboard_nr jc rpkEmpty mov $1,%eax jmp rpkDone rpkEmpty: xorl %eax,%eax rpkDone: leave ret /*########################################################################## # # Name : RdosReadKeyboard # # Purpose....: Read keyboard buffer # # Returns....: Scan code # ##########################################################################*/ .global RdosReadKeyboard RdosReadKeyboard: pushl %ebp movl %esp,%ebp UserGate read_keyboard_nr movzx %ax,%eax leave ret /*########################################################################## # # Name : RdosGetKeyboardState # # Purpose....: Get keyboard buffer # # Returns....: Keyboard state # ##########################################################################*/ .global RdosGetKeyboardState RdosGetKeyboardState: pushl %ebp movl %esp,%ebp UserGate get_keyboard_state_nr movzx %ax,%eax leave ret /*########################################################################## # # Name : RdosPutKeyboard # # Purpose....: Put scancode in keyboard buffer # ##########################################################################*/ .global RdosPutKeyboard RdosPutKeyboard: pushl %ebp movl %esp,%ebp pushl %edx movw 8(%ebp),%ax movb 12(%ebp),%dl movb 16(%ebp),%dh UserGate put_keyboard_code_nr popl %edx leave ret /*########################################################################## # # Name : RdosPeekKeyEvent # # Purpose....: Peek keyboard event # ##########################################################################*/ .global RdosPeekKeyEvent RdosPeekKeyEvent: pushl %ebp movl %esp,%ebp pushl %ecx pushl %edx pushl %edi UserGate peek_key_event_nr jc rpeFail movl 8(%ebp),%edi movzx %ax,%eax movl %eax,(%edi) movl 12(%ebp),%edi movzx %cx,%eax movl %eax,(%edi) movl 16(%ebp),%edi movzx %dl,%eax movl %eax,(%edi) movl 20(%ebp),%edi movzx %dh,%eax movl %eax,(%edi) movl $1,%eax jmp rpeDone rpeFail: xorl %eax,%eax rpeDone: popl %edi popl %edx popl %ecx leave ret /*########################################################################## # # Name : RdosReadKeyEvent # # Purpose....: Read keyboard event # ##########################################################################*/ .global RdosReadKeyEvent RdosReadKeyEvent: pushl %ebp movl %esp,%ebp pushl %ecx pushl %edx pushl %edi UserGate read_key_event_nr jc rkeFail movl 8(%ebp),%edi movzx %ax,%eax movl %eax,(%edi) movl 12(%ebp),%edi movzx %cx,%eax movl %eax,(%edi) movl 16(%ebp),%edi movzx %dl,%eax movl %eax,(%edi) movl 20(%ebp),%edi movzx %dh,%eax movl %eax,(%edi) movl $1,%eax jmp rkeDone rkeFail: xorl %eax,%eax rkeDone: popl %edi popl %edx popl %ecx leave ret /*########################################################################## # # Name : RdosHideMouse # # Purpose....: Hide mouse cursor # ##########################################################################*/ .global RdosHideMouse RdosHideMouse: pushl %ebp movl %esp,%ebp UserGate hide_mouse_nr leave ret /*########################################################################## # # Name : RdosShowMouse # # Purpose....: Show mouse cursor # ##########################################################################*/ .global RdosShowMouse RdosShowMouse: pushl %ebp movl %esp,%ebp UserGate show_mouse_nr leave ret /*########################################################################## # # Name : RdosGetMousePosition # # Purpose....: Get mouse position # # Parameters.: &x, &y # ##########################################################################*/ .global RdosGetMousePosition RdosGetMousePosition: pushl %ebp movl %esp,%ebp pushl %ecx pushl %edx UserGate get_mouse_position_nr movl 8(%ebp),%eax movzx %cx,%ecx movl %ecx,(%eax) movl 12(%ebp),%eax movzx %dx,%edx movl %edx,(%eax) popl %edx popl %ecx leave ret /*########################################################################## # # Name : RdosSetMousePosition # # Purpose....: Set mouse position # # Parameters.: x, y # ##########################################################################*/ .global RdosSetMousePosition RdosSetMousePosition: pushl %ebp movl %esp,%ebp pushl %ecx pushl %edx movw 8(%ebp),%cx movw 12(%ebp),%dx UserGate set_mouse_position_nr popl %edx popl %ecx leave ret /*########################################################################## # # Name : RdosSetMouseWindow # # Purpose....: Set mouse window # # Parameters.: start x, start y # end x, end y # ##########################################################################*/ .global RdosSetMouseWindow RdosSetMouseWindow: pushl %ebp movl %esp,%ebp pushl %eax pushl %ebx pushl %ecx pushl %edx movw 8(%ebp),%ax movw 12(%ebp),%bx movw 16(%ebp),%cx movw 20(%ebp),%dx UserGate set_mouse_window_nr popl %edx popl %ecx popl %ebx popl %eax leave ret /*########################################################################## # # Name : RdosSetMouseMickey # # Purpose....: Set mouse mickey # # Parameters.: x, y # ##########################################################################*/ .global RdosSetMouseMickey RdosSetMouseMickey: pushl %ebp movl %esp,%ebp pushl %ecx pushl %edx movw 8(%ebp),%cx movw 12(%ebp),%dx UserGate set_mouse_mickey_nr popl %edx popl %ecx leave ret /*########################################################################## # # Name : RdosGetCursorPosition # # Purpose....: Get cursor position # # Parameters.: &x, &y # ##########################################################################*/ .global RdosGetCursorPosition RdosGetCursorPosition: pushl %ebp movl %esp,%ebp pushl %ecx pushl %edx UserGate get_cursor_position_nr movl 8(%ebp),%eax movzx %cx,%ecx movl %ecx,(%eax) movl 12(%ebp),%eax movzx %dx,%edx movl %edx,(%eax) popl %edx popl %ecx leave ret /*########################################################################## # # Name : RdosSetCursorPosition # # Purpose....: Set cursor position # # Parameters.: x, y # ##########################################################################*/ .global RdosSetCursorPosition RdosSetCursorPosition: pushl %ebp movl %esp,%ebp pushl %ecx pushl %edx movw 8(%ebp),%cx movw 12(%ebp),%dx UserGate set_cursor_position_nr popl %edx popl %ecx leave ret /*########################################################################## # # Name : RdosGetLeftButton # # Purpose....: Check if left button is pressed # # Returns....: TRUE if pressed # ##########################################################################*/ .global RdosGetLeftButton RdosGetLeftButton: pushl %ebp movl %esp,%ebp UserGate get_left_button_nr jc get_left_rel mov $1,%eax jmp get_left_done get_left_rel: xorl %eax,%eax get_left_done: leave ret /*########################################################################## # # Name : RdosGetRightButton # # Purpose....: Check if right button is pressed # # Returns....: TRUE if pressed # ##########################################################################*/ .global RdosGetRightButton RdosGetRightButton: pushl %ebp movl %esp,%ebp UserGate get_right_button_nr jc get_right_rel mov $1,%eax jmp get_right_done get_right_rel: xorl %eax,%eax get_right_done: leave ret /*########################################################################## # # Name : RdosGetLeftButtonPressPosition # # Purpose....: Get left button press position # # Parameters.: &x, &y # ##########################################################################*/ .global RdosGetLeftButtonPressPosition RdosGetLeftButtonPressPosition: pushl %ebp movl %esp,%ebp pushl %ecx pushl %edx UserGate get_left_button_press_position_nr movl 8(%ebp),%eax movzx %cx,%ecx movl %ecx,(%eax) movl 12(%ebp),%eax movzx %dx,%edx movl %edx,(%eax) popl %edx popl %ecx leave ret /*########################################################################## # # Name : RdosGetRightButtonPressPosition # # Purpose....: Get right button press position # # Parameters.: &x, &y # ##########################################################################*/ .global RdosGetRightButtonPressPosition RdosGetRightButtonPressPosition: pushl %ebp movl %esp,%ebp pushl %ecx pushl %edx UserGate get_right_button_press_position_nr movl 8(%ebp),%eax movzx %cx,%ecx movl %ecx,(%eax) movl 12(%ebp),%eax movzx %dx,%edx movl %edx,(%eax) popl %edx popl %ecx leave ret /*########################################################################## # # Name : RdosGetLeftButtonReleasePosition # # Purpose....: Get left button release position # # Parameters.: &x, &y # ##########################################################################*/ .global RdosGetLeftButtonReleasePosition RdosGetLeftButtonReleasePosition: pushl %ebp movl %esp,%ebp pushl %ecx pushl %edx UserGate get_left_button_release_position_nr movl 8(%ebp),%eax movzx %cx,%ecx movl %ecx,(%eax) movl 12(%ebp),%eax movzx %dx,%edx movl %edx,(%eax) popl %edx popl %ecx leave ret /*########################################################################## # # Name : RdosGetRightButtonReleasePosition # # Purpose....: Get right button release position # # Parameters.: &x, &y # ##########################################################################*/ .global RdosGetRightButtonReleasePosition RdosGetRightButtonReleasePosition: pushl %ebp movl %esp,%ebp pushl %ecx pushl %edx UserGate get_right_button_release_position_nr movl 8(%ebp),%eax movzx %cx,%ecx movl %ecx,(%eax) movl 12(%ebp),%eax movzx %dx,%edx movl %edx,(%eax) popl %edx popl %ecx leave ret /*########################################################################## # # Name : RdosReadLine # # Purpose....: Read a line from keyboard # # Parameters.: Buffer # Size # # Returns....: Read count # ##########################################################################*/ .global RdosReadLine RdosReadLine: pushl %ebp movl %esp,%ebp pushl %ecx pushl %edi movl 8(%ebp),%edi movl 12(%ebp),%ecx UserGate read_con_nr popl %edi popl %ecx leave ret /*########################################################################## # # Name : RdosWriteChar # # Purpose....: Write a character to screen # # Parameters.: Char # ##########################################################################*/ .global RdosWriteChar RdosWriteChar: pushl %ebp movl %esp,%ebp movb 8(%ebp),%al UserGate write_char_nr leave ret /*########################################################################## # # Name : RdosWriteSizeString # # Purpose....: Write a fixed number of characters to screen # # Parameters.: String # Count # ##########################################################################*/ .global RdosWriteSizeString RdosWriteSizeString: pushl %ebp movl %esp,%ebp pushl %ecx pushl %edi movl 8(%ebp),%edi movl 12(%ebp),%ecx UserGate write_size_string_nr popl %edi popl %ecx leave ret /*########################################################################## # # Name : RdosWriteString # # Purpose....: Write a string to screen # # Parameters.: String # ##########################################################################*/ .global RdosWriteString RdosWriteString: pushl %ebp movl %esp,%ebp pushl %edi movl 8(%ebp),%edi UserGate write_asciiz_nr popl %edi leave ret /*########################################################################## # # Name : RdosNameToIp # # Purpose....: Convert host name to IP address # # Parameters.: Name # # Returns....: IP # ##########################################################################*/ .global RdosNameToIp RdosNameToIp: pushl %ebp movl %esp,%ebp pushl %edi movl 8(%ebp),%edi UserGate name_to_ip_nr jc rntiFail movl %edx,%eax jmp rntiDone rntiFail: xorl %eax,%eax rntiDone: popl %edi leave ret /*########################################################################## # # Name : RdosGetIp # # Purpose....: Get my IP # # Returns....: IP # ##########################################################################*/ .global RdosGetIp RdosGetIp: pushl %ebp movl %esp,%ebp UserGate get_ip_address_nr movl %edx,%eax leave ret /*########################################################################## # # Name : RdosIpToName # # Purpose....: Convert IP address to host name # # Parameters.: IP # Name # Size # ##########################################################################*/ .global RdosIpToName RdosIpToName: pushl %ebp movl %esp,%ebp pushl %ecx pushl %edx pushl %edi ; movl 8(%ebp),%edx movl 12(%ebp),%edi movl 16(%ebp),%ecx UserGate ip_to_name_nr jnc ritnDone ritnFail: xorl %eax,%eax ritnDone: popl %edi popl %edx popl %ecx leave ret /*########################################################################## # # Name : RdosPing # # Purpose....: Ping node # # Parameters.: IP # Timeout # ##########################################################################*/ .global RdosPing RdosPing: pushl %ebp movl %esp,%ebp pushl %edx ; movl 8(%ebp),%edx movl 12(%ebp),%eax UserGate ping_nr jc ping_failed movl $1,%eax jmp ping_done ping_failed: xorl %eax,%eax ping_done: popl %edx leave ret /*########################################################################## # # Name : RdosOpenTcpConnection # # Purpose....: Open an active connection over TCP # # Parameters.: RemoteIp # LocalPort # RemotePort # Timeout in ms # BufferSize # # Returns....: Conn handle # ##########################################################################*/ .global RdosOpenTcpConnection RdosOpenTcpConnection: pushl %ebp movl %esp,%ebp pushl %ebx pushl %esi pushl %edi movl 8(%ebp),%edx movw 12(%ebp),%si movw 16(%ebp),%di movl 20(%ebp),%eax movl 24(%ebp),%ecx UserGate open_tcp_connection_nr mov $0,%eax jc rotcDone movl %ebx,%eax rotcDone: popl %edi popl %esi popl %ebx leave ret /*########################################################################## # # Name : RdosCreateTcpListen # # Purpose....: Create listen handle # # Parameters.: Port # MaxConnections # BufferSize # # Returns....: Listen handle # ##########################################################################*/ .global RdosCreateTcpListen RdosCreateTcpListen: pushl %ebp movl %esp,%ebp pushl %ebx pushl %esi movw 8(%ebp),%si movw 12(%ebp),%ax movl 16(%ebp),%ecx UserGate create_tcp_listen_nr movzx %bx,%eax jnc ctlDone xorl %eax,%eax ctlDone: popl %esi popl %ebx leave ret /*########################################################################## # # Name : RdosGetTcpListen # # Purpose....: Get connection from listen # # Parameters.: Listen handle # # Returns....: Conn handle # ##########################################################################*/ .global RdosGetTcpListen RdosGetTcpListen: pushl %ebp movl %esp,%ebp pushl %ebx movw 8(%ebp),%bx UserGate get_tcp_listen_nr movzx %ax,%eax jnc gtlDone xorl %eax,%eax gtlDone: popl %ebx leave ret /*########################################################################## # # Name : RdosCloseTcpListen # # Purpose....: Close TCP listen # # Parameters.: Listen handle # ##########################################################################*/ .global RdosCloseTcpListen RdosCloseTcpListen: pushl %ebp movl %esp,%ebp pushl %ebx movw 8(%ebp),%bx UserGate close_tcp_listen_nr popl %ebx leave ret /*########################################################################## # # Name : RdosAddWaitForTcpListen # # Purpose....: Add wait object to tcp listen # # Parameters.: Wait handle # Listen handle # ID # ##########################################################################*/ .global RdosAddWaitForTcpListen RdosAddWaitForTcpListen: pushl %ebp movl %esp,%ebp pushl %ebx pushl %ecx movw 8(%ebp),%bx movw 12(%ebp),%ax movl 16(%ebp),%ecx UserGate add_wait_for_tcp_listen_nr movl $1,%eax jnc awftlDone xorl %eax,%eax awftlDone: popl %ecx popl %ebx leave ret /*########################################################################## # # Name : RdosWaitForTcpConnection # # Purpose....: Wait for Tcp connection to be established # # Parameters.: Conn handle # Timeout ms # ##########################################################################*/ .global RdosWaitForTcpConnection RdosWaitForTcpConnection: pushl %ebp movl %esp,%ebp pushl %ebx movw 8(%ebp),%bx movl 12(%ebp),%eax UserGate wait_for_tcp_connection_nr movl $1,%eax jnc wftcDone xorl %eax,%eax wftcDone: popl %ebx leave ret /*########################################################################## # # Name : RdosAddWaitForTcpConnection # # Purpose....: Add wait object to tcp connection # # Parameters.: Wait handle # Conn handle # ID # ##########################################################################*/ .global RdosAddWaitForTcpConnection RdosAddWaitForTcpConnection: pushl %ebp movl %esp,%ebp pushl %ebx pushl %ecx movw 8(%ebp),%bx movw 12(%ebp),%ax movl 16(%ebp),%ecx UserGate add_wait_for_tcp_connection_nr movl $1,%eax jnc awftcDone xorl %eax,%eax awftcDone: popl %ecx popl %ebx leave ret /*########################################################################## # # Name : RdosCloseTcpConnection # # Purpose....: Close Tcp connection # # Parameters.: Conn handle # ##########################################################################*/ .global RdosCloseTcpConnection RdosCloseTcpConnection: pushl %ebp movl %esp,%ebp pushl %ebx movw 8(%ebp),%bx UserGate close_tcp_connection_nr popl %ebx leave ret /*########################################################################## # # Name : RdosDeleteTcpConnection # # Purpose....: Delete Tcp connection # # Parameters.: Conn handle # ##########################################################################*/ .global RdosDeleteTcpConnection RdosDeleteTcpConnection: pushl %ebp movl %esp,%ebp pushl %ebx movw 8(%ebp),%bx UserGate delete_tcp_connection_nr popl %ebx leave ret /*########################################################################## # # Name : RdosAbortTcpConnection # # Purpose....: Abort Tcp connection # # Parameters.: Conn handle # ##########################################################################*/ .global RdosAbortTcpConnection RdosAbortTcpConnection: pushl %ebp movl %esp,%ebp pushl %ebx movw 8(%ebp),%bx UserGate abort_tcp_connection_nr popl %ebx leave ret /*########################################################################## # # Name : RdosPushTcpConnection # # Purpose....: Push Tcp connection # # Parameters.: Conn handle # ##########################################################################*/ .global RdosPushTcpConnection RdosPushTcpConnection: pushl %ebp movl %esp,%ebp pushl %ebx movw 8(%ebp),%bx UserGate push_tcp_connection_nr popl %ebx leave ret /*########################################################################## # # Name : RdosPollTcpConnection # # Purpose....: Poll Tcp connection # # Parameters.: Conn handle # # Returns....: Available bytes in receive buffer # ##########################################################################*/ .global RdosPollTcpConnection RdosPollTcpConnection: pushl %ebp movl %esp,%ebp pushl %ebx movw 8(%ebp),%bx UserGate poll_tcp_connection_nr popl %ebx leave ret /*########################################################################## # # Name : RdosIsTcpConnectionClosed # # Purpose....: Check if connection is closed # # Parameters.: Conn handle # # Returns....: TRUE if closed # ##########################################################################*/ .global RdosIsTcpConnectionClosed RdosIsTcpConnectionClosed: pushl %ebp movl %esp,%ebp pushl %ebx movw 8(%ebp),%bx UserGate is_tcp_connection_closed_nr jc rptcClosed xorl %eax,%eax jmp rptcDone rptcClosed: movl $1,%eax rptcDone: popl %ebx leave ret /*########################################################################## # # Name : RdosGetRemoteTcpConnectionIp # # Purpose....: Get remote IP # # Parameters.: Conn handle # # Returns....: IP # ##########################################################################*/ .global RdosGetRemoteTcpConnectionIp RdosGetRemoteTcpConnectionIp: pushl %ebp movl %esp,%ebp pushl %ebx movw 8(%ebp),%bx UserGate get_remote_tcp_connection_ip_nr jnc grtciDone movl $0xFFFFFFFF,%eax grtciDone: popl %ebx leave ret /*########################################################################## # # Name : RdosGetRemoteTcpConnectionPort # # Purpose....: Get remote port # # Parameters.: Conn handle # # Returns....: Port # ##########################################################################*/ .global RdosGetRemoteTcpConnectionPort RdosGetRemoteTcpConnectionPort: pushl %ebp movl %esp,%ebp pushl %ebx movw 8(%ebp),%bx UserGate get_remote_tcp_connection_port_nr jnc grtcpDone movl $0,%eax grtcpDone: movzx %ax,%eax popl %ebx leave ret /*########################################################################## # # Name : RdosGetLocalTcpConnectionPort # # Purpose....: Get local port # # Parameters.: Conn handle # # Returns....: Port # ##########################################################################*/ .global RdosGetLocalTcpConnectionPort RdosGetLocalTcpConnectionPort: pushl %ebp movl %esp,%ebp pushl %ebx movw 8(%ebp),%bx UserGate get_local_tcp_connection_port_nr jnc gltcpDone movl $0,%eax gltcpDone: movzx %ax,%eax popl %ebx leave ret /*########################################################################## # # Name : RdosReadTcpConnection # # Purpose....: Read data from connection # # Parameters.: Conn handle # Buffer # Size # # Returns....: Read bytes # ##########################################################################*/ .global RdosReadTcpConnection RdosReadTcpConnection: pushl %ebp movl %esp,%ebp pushl %ebx pushl %ecx pushl %edi movw 8(%ebp),%bx movl 12(%ebp),%edi movl 16(%ebp),%ecx UserGate read_tcp_connection_nr popl %edi popl %ecx popl %ebx leave ret /*########################################################################## # # Name : RdosWriteTcpConnection # # Purpose....: Write data fto connection # # Parameters.: Conn handle # Buffer # Size # # Returns....: Written bytes # ##########################################################################*/ .global RdosWriteTcpConnection RdosWriteTcpConnection: pushl %ebp movl %esp,%ebp pushl %ebx pushl %ecx pushl %edi movw 8(%ebp),%bx movl 12(%ebp),%edi movl 16(%ebp),%ecx UserGate write_tcp_connection_nr popl %edi popl %ecx popl %ebx leave ret /*########################################################################## # # Name : RdosGetLocalMailslot # # Purpose....: Get local mailslot from name # # Parameters.: Name # # Returns....: Mailslot handle # ##########################################################################*/ .global RdosGetLocalMailslot RdosGetLocalMailslot: pushl %ebp movl %esp,%ebp pushl %ebx pushl %edi movl 8(%ebp),%edi UserGate get_local_mailslot_nr jc rglmFail movzx %bx,%eax jmp rglmDone rglmFail: xorl %eax,%eax rglmDone: popl %edi popl %ebx leave ret /*########################################################################## # # Name : RdosGetRemoteMailslot # # Purpose....: Get remote mailslot from name # # Parameters.: IP # Name # # Returns....: Mailslot handle # ##########################################################################*/ .global RdosGetRemoteMailslot RdosGetRemoteMailslot: pushl %ebp movl %esp,%ebp pushl %ebx pushl %edx pushl %edi movl 8(%ebp),%edx movl 12(%ebp),%edi UserGate get_remote_mailslot_nr jc rgrmFail movzx %bx,%eax jmp rgrmDone rgrmFail: xorl %eax,%eax rgrmDone: popl %edi popl %edx popl %ebx leave ret /*########################################################################## # # Name : RdosFreeMailslot # # Purpose....: Free mailslot # # Parameters.: Mailslot handle # ##########################################################################*/ .global RdosFreeMailslot RdosFreeMailslot: pushl %ebp movl %esp,%ebp pushl %ebx movl 8(%ebp),%ebx UserGate free_mailslot_nr popl %ebx leave ret /*########################################################################## # # Name : RdosSendMailslot # # Purpose....: Send mailslot # # Parameters.: Mailslot handle # Msg # Size # ReplyBuf # MaxReplySize # # Returns....: Size of reply # ##########################################################################*/ .global RdosSendMailslot RdosSendMailslot: pushl %ebp movl %esp,%ebp pushl %ebx pushl %esi pushl %edi movw 8(%ebp),%bx movl 12(%ebp),%esi movl 16(%ebp),%ecx movl 20(%ebp),%edi movl 24(%ebp),%eax UserGate send_mailslot_nr jc smFail movl %ecx,%eax jmp smDone smFail: movl $0xFFFFFFFF,%eax smDone: popl %edi popl %esi popl %ebx leave ret /*########################################################################## # # Name : RdosDefineMailslot # # Purpose....: Define mailslot # # Parameters.: Name # Max msg size # ##########################################################################*/ .global RdosDefineMailslot RdosDefineMailslot: pushl %ebp movl %esp,%ebp pushl %ecx pushl %edi movl 8(%ebp),%edi movl 12(%ebp),%ecx UserGate define_mailslot_nr popl %edi popl %ecx leave ret /*########################################################################## # # Name : RdosReceiveMailslot # # Purpose....: Receive from mailslot # # Parameters.: Msg buffer # # Returns....: Msg size # ##########################################################################*/ .global RdosReceiveMailslot RdosReceiveMailslot: pushl %ebp movl %esp,%ebp pushl %ecx pushl %edi movl 8(%ebp),%edi UserGate receive_mailslot_nr movl %ecx,%eax popl %edi popl %ecx leave ret /*########################################################################## # # Name : RdosReplyMailslot # # Purpose....: Reply to mailslot # # Parameters.: Msg buffer # Msg size # ##########################################################################*/ .global RdosReplyMailslot RdosReplyMailslot: pushl %ebp movl %esp,%ebp pushl %ecx pushl %edi movl 8(%ebp),%edi movl 12(%ebp),%ecx UserGate reply_mailslot_nr popl %edi popl %ecx leave ret /*########################################################################## # # Name : RdosGetIdeDisc # # Purpose....: Get IDE disc # # Parameters.: Unit # # # Returns....: Disc # # ##########################################################################*/ .global RdosGetIdeDisc RdosGetIdeDisc: pushl %ebp movl %esp,%ebp pushl %ebx movb 8(%ebp),%bl UserGate get_ide_disc_nr jc get_ide_disc_fail movzx %al,%eax jmp get_ide_disc_done get_ide_disc_fail: movl $0xFFFFFFFF,%eax get_ide_disc_done: popl %ebx leave ret /*########################################################################## # # Name : RdosGetFloppyDisc # # Purpose....: Get floppy disc # # Parameters.: Unit # # # Returns....: Disc # # ##########################################################################*/ .global RdosGetFloppyDisc RdosGetFloppyDisc: pushl %ebp movl %esp,%ebp pushl %ebx movb 8(%ebp),%bl UserGate get_floppy_disc_nr jc get_floppy_disc_fail movzx %al,%eax jmp get_floppy_disc_done get_floppy_disc_fail: movl $0xFFFFFFFF,%eax get_floppy_disc_done: popl %ebx leave ret /*########################################################################## # # Name : RdosGetDiscInfo # # Purpose....: Get disc info # # Parameters.: Disc # # Bytes / sector # Total sectors # BIOS sectors / cyl # BIOS heads # # Returns....: TRUE if ok # ##########################################################################*/ .global RdosGetDiscInfo RdosGetDiscInfo: pushl %ebp movl %esp,%ebp pushl %ebx pushl %ecx pushl %edx pushl %esi pushl %edi movb 8(%ebp),%al UserGate get_disc_info_nr jc get_disc_info_fail movl 12(%ebp),%ebx movzx %cx,%ecx movl %ecx,(%ebx) movl 16(%ebp),%ebx movl %edx,(%ebx) movl 20(%ebp),%ebx movzx %si,%esi movl %esi,(%ebx) movl 24(%ebp),%ebx movzx %di,%edi movl %edi,(%ebx) movl $1,%eax jmp get_disc_info_done get_disc_info_fail: xorl %eax,%eax get_disc_info_done: popl %edi popl %esi popl %edx popl %ecx popl %ebx leave ret /*########################################################################## # # Name : RdosSetDiscInfo # # Purpose....: Set disc info # # Parameters.: Disc # # Bytes / sector # Total sectors # BIOS sectors / cyl # BIOS heads # # Returns....: TRUE if ok # ##########################################################################*/ .global RdosSetDiscInfo RdosSetDiscInfo: pushl %ebp movl %esp,%ebp pushl %ebx pushl %ecx pushl %edx pushl %esi pushl %edi movb 8(%ebp),%al movl 12(%ebp),%ecx movl 16(%ebp),%edx movl 20(%ebp),%esi movl 24(%ebp),%edi UserGate set_disc_info_nr jc set_disc_info_fail movl $1,%eax jmp set_disc_info_done set_disc_info_fail: xorl %eax,%eax set_disc_info_done: popl %edi popl %esi popl %edx popl %ecx popl %ebx leave ret /*########################################################################## # # Name : RdosReadDisc # # Purpose....: Read from disc # # Parameters.: Disc # # Sector # # Buffer # Size # # Returns....: TRUE if ok # ##########################################################################*/ .global RdosReadDisc RdosReadDisc: pushl %ebp movl %esp,%ebp pushl %ecx pushl %edx pushl %edi movb 8(%ebp),%al movl 12(%ebp),%edx movl 16(%ebp),%edi movl 20(%ebp),%ecx UserGate read_disc_nr jc read_disc_fail movl $1,%eax jmp read_disc_done read_disc_fail: xorl %eax,%eax read_disc_done: popl %edi popl %edx popl %ecx leave ret /*########################################################################## # # Name : RdosWriteDisc # # Purpose....: Write to disc # # Parameters.: Disc # # Sector # # Buffer # Size # # Returns....: TRUE if ok # ##########################################################################*/ .global RdosWriteDisc RdosWriteDisc: pushl %ebp movl %esp,%ebp pushl %ecx pushl %edx pushl %edi movb 8(%ebp),%al movl 12(%ebp),%edx movl 16(%ebp),%edi movl 20(%ebp),%ecx UserGate write_disc_nr jc write_disc_fail movl $1,%eax jmp write_disc_done write_disc_fail: xorl %eax,%eax write_disc_done: popl %edi popl %edx popl %ecx leave ret /*########################################################################## # # Name : RdosAllocateFixedDrive # # Purpose....: Allocate fixed drive # # Parameters.: Drive # # # Returns....: TRUE if ok # ##########################################################################*/ .global RdosAllocateFixedDrive RdosAllocateFixedDrive: pushl %ebp movl %esp,%ebp movb 8(%ebp),%al UserGate allocate_fixed_drive_nr jc allocate_fixed_drive_fail movl $1,%eax jmp allocate_fixed_drive_done allocate_fixed_drive_fail: xorl %eax,%eax allocate_fixed_drive_done: leave ret /*########################################################################## # # Name : RdosAllocateStaticDrive # # Purpose....: Allocate static drive # # Returns....: Drive # # ##########################################################################*/ .global RdosAllocateStaticDrive RdosAllocateStaticDrive: pushl %ebp movl %esp,%ebp UserGate allocate_static_drive_nr jc allocate_static_drive_fail movzx %al,%eax jmp allocate_static_drive_done allocate_static_drive_fail: xorl %eax,%eax allocate_static_drive_done: leave ret /*########################################################################## # # Name : RdosAllocateDynamicDrive # # Purpose....: Allocate dynamic drive # # Returns....: Drive # # ##########################################################################*/ .global RdosAllocateDynamicDrive RdosAllocateDynamicDrive: pushl %ebp movl %esp,%ebp UserGate allocate_dynamic_drive_nr jc allocate_dynamic_drive_fail movzx %al,%eax jmp allocate_dynamic_drive_done allocate_dynamic_drive_fail: xorl %eax,%eax allocate_dynamic_drive_done: leave ret /*########################################################################## # # Name : RdosGetRdfsInfo # # Purpose....: Get rdfs info # # Parameters.: Crypt tab # Key tab # Extent size tab # ##########################################################################*/ .global RdosGetRdfsInfo RdosGetRdfsInfo: pushl %ebp movl %esp,%ebp pushl %ebx pushl %esi pushl %edi movl 8(%ebp),%esi movl 12(%ebp),%edi movl 16(%ebp),%ebx UserGate get_rdfs_info_nr popl %edi popl %esi popl %ebx leave ret /*########################################################################## # # Name : RdosGetDriveInfo # # Purpose....: Get drive info # # Parameters.: Drive # # Free units # Bytes per unit # Total units # # Returns....: TRUE if ok # ##########################################################################*/ .global RdosGetDriveInfo RdosGetDriveInfo: pushl %ebp movl %esp,%ebp pushl %ebx pushl %ecx pushl %edx movb 8(%ebp),%al UserGate get_drive_info_nr jc get_drive_info_fail movl 12(%ebp),%ebx movl %eax,(%ebx) movl 16(%ebp),%ebx movzx %cx,%ecx movl %ecx,(%ebx) movl 20(%ebp),%ebx movl %edx,(%ebx) movl $1,%eax jmp get_drive_info_done get_drive_info_fail: xorl %eax,%eax get_drive_info_done: popl %edx popl %ecx popl %ebx leave ret /*########################################################################## # # Name : RdosDemandLoadDrive # # Purpose....: Demand load drive # # Parameters.: Drive # # ##########################################################################*/ .global RdosDemandLoadDrive RdosDemandLoadDrive: pushl %ebp movl %esp,%ebp movb 8(%ebp),%al UserGate demand_load_drive_nr leave ret /*########################################################################## # # Name : RdosGetDriveDiscParam # # Purpose....: Get drive disc parameters # # Parameters.: Drive # # Disc # # Start sector # Total sectors # # Returns....: TRUE if ok # ##########################################################################*/ .global RdosGetDriveDiscParam RdosGetDriveDiscParam: pushl %ebp movl %esp,%ebp pushl %ebx pushl %ecx pushl %edx movb 8(%ebp),%al UserGate get_drive_disc_param_nr jc get_drive_disc_param_fail movl 12(%ebp),%ebx movzx %al,%eax movl %eax,(%ebx) movl 16(%ebp),%ebx movl %edx,(%ebx) movl 20(%ebp),%ebx movl %ecx,(%ebx) movl $1,%eax jmp get_drive_disc_param_done get_drive_disc_param_fail: xorl %eax,%eax get_drive_disc_param_done: popl %edx popl %ecx popl %ebx leave ret /*########################################################################## # # Name : RdosFormatDrive # # Purpose....: Format drive # # Parameters.: Disc # # Start sector # Sectors # FS name # # Returns....: Drive # # ##########################################################################*/ .global RdosFormatDrive RdosFormatDrive: pushl %ebp movl %esp,%ebp pushl %ecx pushl %edx pushl %edi movb 8(%ebp),%al movl 12(%ebp),%edx movl 16(%ebp),%ecx movl 20(%ebp),%edi UserGate format_drive_nr jc rfdFail movzx %al,%eax jmp rfdDone rfdFail: xorl %eax,%eax rfdDone: popl %edi popl %edx popl %ecx leave ret /*########################################################################## # # Name : RdosGetExeName # # Purpose....: Get name of executable file # # Returns....: Exe pathname # ##########################################################################*/ .global RdosGetExeName RdosGetExeName: pushl %ebp movl %esp,%ebp pushl %edi UserGate get_exe_name_nr jc rgenFail movl %edi,%eax jmp rgenDone rgenFail: xorl %eax,%eax rgenDone: popl %edi leave ret /*########################################################################## # # Name : RdosOpenAdc # # Purpose....: Open handle to ADC channel # # Parameters.: Channel # # # Returns....: Adc handle # ##########################################################################*/ .global RdosOpenAdc RdosOpenAdc: pushl %ebp movl %esp,%ebp pushl %ebx movl 8(%ebp),%eax UserGate open_adc_nr movw %bx,%ax popl %ebx leave ret /*########################################################################## # # Name : RdosCloseAdc # # Purpose....: Close ADC handle # # Parameters.: Adc handle # ##########################################################################*/ .global RdosCloseAdc RdosCloseAdc: pushl %ebp movl %esp,%ebp pushl %ebx movl 8(%ebp),%ebx UserGate close_adc_nr popl %ebx leave ret /*########################################################################## # # Name : RdosDefineAdcTime # # Purpose....: Define time of next conversion # # Parameters.: Adc handle # MSB time # LSB time # ##########################################################################*/ .global RdosDefineAdcTime RdosDefineAdcTime: pushl %ebp movl %esp,%ebp pushl %ebx pushl %edx movl 8(%ebp),%ebx movl 12(%ebp),%edx movl 16(%ebp),%eax UserGate define_adc_time_nr popl %edx popl %ebx leave ret /*########################################################################## # # Name : RdosReadAdc # # Purpose....: Read ADC # # Parameters.: Adc handle # # Returns....: Value # ##########################################################################*/ .global RdosReadAdc RdosReadAdc: pushl %ebp movl %esp,%ebp pushl %ebx movl 8(%ebp),%ebx UserGate read_adc_nr popl %ebx leave ret /*########################################################################## # # Name : RdosReadSerialLines # # Purpose....: Read serial lines # # Parameters.: Device # &Value # # Returns....: TRUE if ok # ##########################################################################*/ .global RdosReadSerialLines RdosReadSerialLines: pushl %ebp movl %esp,%ebp pushl %edx pushl %esi movb 8(%ebp),%dh UserGate read_serial_lines_nr jc rdsFail movzx %al,%eax movl 12(%ebp),%esi movl %eax,(%esi) movl $1,%eax jmp rdsDone rdsFail: xorl %eax,%eax rdsDone: popl %esi popl %edx leave ret /*########################################################################## # # Name : RdosToggleSerialLine # # Purpose....: Toggle serial line # # Parameters.: Device # Line # # Returns....: TRUE if ok # ##########################################################################*/ .global RdosToggleSerialLine RdosToggleSerialLine: pushl %ebp movl %esp,%ebp pushl %edx movb 8(%ebp),%dh movb 12(%ebp),%dl UserGate toggle_serial_line_nr jc rtsFail movl $1,%eax jmp rtsDone rtsFail: xorl %eax,%eax rtsDone: popl %edx leave ret /*########################################################################## # # Name : RdosReadSerialVal # # Purpose....: Read serial value # # Parameters.: Device # Line # &Val # # Returns....: TRUE if ok # ##########################################################################*/ .global RdosReadSerialVal RdosReadSerialVal: pushl %ebp movl %esp,%ebp pushl %edx pushl %esi movb 8(%ebp),%dh movb 12(%ebp),%dl UserGate read_serial_val_nr pushfw shll $8,%eax movl 16(%ebp),%esi movl %eax,(%esi) popfw jc rdvFail movl $1,%eax jmp rdvDone rdvFail: xorl %eax,%eax rdvDone: popl %esi popl %edx leave ret /*########################################################################## # # Name : RdosWriteSerialVal # # Purpose....: Write serial value # # Parameters.: Device # Line # Val # # Returns....: TRUE if ok # ##########################################################################*/ .global RdosWriteSerialVal RdosWriteSerialVal: pushl %ebp movl %esp,%ebp pushl %edx movb 8(%ebp),%dh movb 12(%ebp),%dl movl 16(%ebp),%eax sarl $8,%eax UserGate write_serial_val_nr jc rwvFail movl $1,%eax jmp rwvDone rwvFail: xorl %eax,%eax rwvDone: popl %edx leave ret /*########################################################################## # # Name : RdosReadSerialRaw # # Purpose....: Read serial raw value # # Parameters.: Device # Line # &Val # # Returns....: TRUE if ok # ##########################################################################*/ .global RdosReadSerialRaw RdosReadSerialRaw: pushl %ebp movl %esp,%ebp pushl %edx pushl %esi movb 8(%ebp),%dh movb 12(%ebp),%dl UserGate read_serial_val_nr pushfw movl 16(%ebp),%esi movl %eax,(%esi) popfw jc rdrFail movl $1,%eax jmp rdrDone rdrFail: xorl %eax,%eax rdrDone: popl %esi popl %edx leave ret /*########################################################################## # # Name : RdosWriteSerialRaw # # Purpose....: Write serial raw value # # Parameters.: Device # Line # Val # # Returns....: TRUE if ok # ##########################################################################*/ .global RdosWriteSerialRaw RdosWriteSerialRaw: pushl %ebp movl %esp,%ebp pushl %edx movb 8(%ebp),%dh movb 12(%ebp),%dl movl 16(%ebp),%eax UserGate write_serial_val_nr jc rwrFail movl $1,%eax jmp rwrDone rwrFail: xorl %eax,%eax rwrDone: popl %edx leave ret /*########################################################################## # # Name : RdosOpenSysEnv # # Purpose....: Open system environment # # Returns....: Env handle # ##########################################################################*/ .global RdosOpenSysEnv RdosOpenSysEnv: pushl %ebp movl %esp,%ebp pushl %ebx UserGate open_sys_env_nr jc oseFail movzx %bx,%eax jmp oseDone oseFail: xorl %eax,%eax oseDone: popl %ebx leave ret /*########################################################################## # # Name : RdosOpenProcessEnv # # Purpose....: Open process environment # # Returns....: Env handle # ##########################################################################*/ .global RdosOpenProcessEnv RdosOpenProcessEnv: pushl %ebp movl %esp,%ebp pushl %ebx UserGate open_proc_env_nr jc opeFail movzx %bx,%eax jmp opeDone opeFail: xorl %eax,%eax opeDone: popl %ebx leave ret /*########################################################################## # # Name : RdosCloseEnv # # Purpose....: Close environment # # Parameters.: Env handle # ##########################################################################*/ .global RdosCloseEnv RdosCloseEnv: pushl %ebp movl %esp,%ebp pushl %ebx movl 8(%ebp),%ebx UserGate close_env_nr popl %ebx leave ret /*########################################################################## # # Name : RdosAddEnvVar # # Purpose....: Add environment variable # # Parameters.: Env handle # var # data # ##########################################################################*/ .global RdosAddEnvVar RdosAddEnvVar: pushl %ebp movl %esp,%ebp pushl %ebx pushl %esi pushl %edi movl 8(%ebp),%ebx movl 12(%ebp),%esi movl 16(%ebp),%edi UserGate add_env_var_nr popl %edi popl %esi popl %ebx leave ret /*########################################################################## # # Name : RdosDeleteEnvVar # # Purpose....: Delete environment variable # # Parameters.: Env handle # var # ##########################################################################*/ .global RdosDeleteEnvVar RdosDeleteEnvVar: pushl %ebp movl %esp,%ebp pushl %ebx pushl %esi movl 8(%ebp),%ebx movl 12(%ebp),%esi UserGate delete_env_var_nr popl %esi popl %ebx leave ret /*########################################################################## # # Name : RdosFindEnvVar # # Purpose....: Find environment variable # # Parameters.: Env handle # var # data # ##########################################################################*/ .global RdosFindEnvVar RdosFindEnvVar: pushl %ebp movl %esp,%ebp pushl %ebx pushl %esi pushl %edi movl 8(%ebp),%ebx movl 12(%ebp),%esi movl 16(%ebp),%edi UserGate find_env_var_nr jc fevFail movl $1,%eax jmp fevDone fevFail: xorl %eax,%eax fevDone: popl %edi popl %esi popl %ebx leave ret /*########################################################################## # # Name : RdosGetEnvData # # Purpose....: Get raw environment data # # Parameters.: Env handle # data # ##########################################################################*/ .global RdosGetEnvData RdosGetEnvData: pushl %ebp movl %esp,%ebp pushl %ebx pushl %edi movl 8(%ebp),%ebx movl 12(%ebp),%edi UserGate get_env_data_nr jnc gedDone xorw %ax,%ax stosw gedDone: popl %edi popl %ebx leave ret /*########################################################################## # # Name : RdosSetEnvData # # Purpose....: Set raw environment data # # Parameters.: Env handle # data # ##########################################################################*/ .global RdosSetEnvData RdosSetEnvData: pushl %ebp movl %esp,%ebp pushl %ebx pushl %edi movl 8(%ebp),%ebx movl 12(%ebp),%edi UserGate set_env_data_nr popl %edi popl %ebx leave ret /*########################################################################## # # Name : RdosOpenSysIni # # Purpose....: Open system ini-file # # Returns....: Ini handle # ##########################################################################*/ .global RdosOpenSysIni RdosOpenSysIni: pushl %ebp movl %esp,%ebp pushl %ebx UserGate open_sys_ini_nr jc osiFail movzx %bx,%eax jmp osiDone osiFail: xorl %eax,%eax osiDone: popl %ebx leave ret /*########################################################################## # # Name : RdosCloseIni # # Purpose....: Close ini-file # # Parameters.: Ini handle # ##########################################################################*/ .global RdosCloseIni RdosCloseIni: pushl %ebp movl %esp,%ebp pushl %ebx movl 8(%ebp),%ebx UserGate close_ini_nr popl %ebx leave ret /*########################################################################## # # Name : RdosGotoIniSection # # Purpose....: Goto ini section # # Parameters.: Ini handle # SectionName # ##########################################################################*/ .global RdosGotoIniSection RdosGotoIniSection: pushl %ebp movl %esp,%ebp pushl %ebx pushl %edi movl 8(%ebp),%ebx movl 12(%ebp),%edi UserGate goto_ini_section_nr jc gisFail movl $1,%eax jmp gisDone gisFail: xorl %eax,%eax gisDone: popl %edi popl %ebx leave ret /*########################################################################## # # Name : RdosRemoveIniSection # # Purpose....: Remove current ini section # # Parameters.: Ini handle # ##########################################################################*/ .global RdosRemoveIniSection RdosRemoveIniSection: pushl %ebp movl %esp,%ebp pushl %ebx movl 8(%ebp),%ebx UserGate remove_ini_section_nr jc risFail movl $1,%eax jmp risDone risFail: xorl %eax,%eax risDone: popl %ebx leave ret /*########################################################################## # # Name : RdosReadIni # # Purpose....: Read ini var in current section # # Parameters.: Ini handle # VarName # Data # MaxSize # ##########################################################################*/ .global RdosReadIni RdosReadIni: pushl %ebp movl %esp,%ebp pushl %ebx pushl %ecx pushl %esi pushl %edi movl 8(%ebp),%ebx movl 12(%ebp),%esi movl 16(%ebp),%edi movl 20(%ebp),%ecx UserGate read_ini_nr jc riFail movl $1,%eax jmp riDone riFail: xorl %eax,%eax riDone: popl %edi popl %esi popl %ecx popl %ebx leave ret /*########################################################################## # # Name : RdosWriteIni # # Purpose....: Write ini var in current section # # Parameters.: Ini handle # VarName # Data # ##########################################################################*/ .global RdosWriteIni RdosWriteIni: pushl %ebp movl %esp,%ebp pushl %ebx pushl %esi pushl %edi movl 8(%ebp),%ebx movl 12(%ebp),%esi movl 16(%ebp),%edi UserGate write_ini_nr jc wiFail movl $1,%eax jmp wiDone wiFail: xorl %eax,%eax wiDone: popl %edi popl %esi popl %ebx leave ret /*########################################################################## # # Name : RdosDeleteIni # # Purpose....: Delete ini var in current section # # Parameters.: Ini handle # VarName # ##########################################################################*/ .global RdosDeleteIni RdosDeleteIni: pushl %ebp movl %esp,%ebp pushl %ebx pushl %esi movl 8(%ebp),%ebx movl 12(%ebp),%esi UserGate delete_ini_nr jc diFail movl $1,%eax jmp diDone diFail: xorl %eax,%eax diDone: popl %esi popl %ebx leave ret /*########################################################################## # # Name : RdosCreateFileDrive # # Purpose....: Create a new file-drive # # Parameters.: Drive # Size # FS name # Filename # ##########################################################################*/ .global RdosCreateFileDrive RdosCreateFileDrive: pushl %ebp movl %esp,%ebp pushl %ecx pushl %esi pushl %edi movb 8(%ebp),%al movl 12(%ebp),%ecx movl 16(%ebp),%esi movl 20(%ebp),%edi UserGate create_file_drive_nr jnc cfdOk xorl %eax,%eax jmp cfdDone cfdOk: movl $1,%eax cfdDone: popl %edi popl %esi popl %ecx leave ret /*########################################################################## # # Name : RdosOpenFileDrive # # Purpose....: Open a new file-drive # # Parameters.: Drive # Filename # ##########################################################################*/ .global RdosOpenFileDrive RdosOpenFileDrive: pushl %ebp movl %esp,%ebp pushl %edi movb 8(%ebp),%al movl 12(%ebp),%edi UserGate open_file_drive_nr jnc ofdOk xorl %eax,%eax jmp ofdDone ofdOk: movl $1,%eax ofdDone: popl %edi leave ret /*########################################################################## # # Name : RdosEnableStatusLed # # Purpose....: Enable status LED # ##########################################################################*/ .global RdosEnableStatusLed RdosEnableStatusLed: pushl %ebp movl %esp,%ebp UserGate enable_status_led_nr leave ret /*########################################################################## # # Name : RdosDisableStatusLed # # Purpose....: Disable status LED # ##########################################################################*/ .global RdosDisableStatusLed RdosDisableStatusLed: pushl %ebp movl %esp,%ebp UserGate disable_status_led_nr leave ret /*########################################################################## # # Name : RdosStartWatchdog # # Purpose....: Start watchdog # # Parameters.: Timeout, ms # ##########################################################################*/ .global RdosStartWatchdog RdosStartWatchdog: pushl %ebp movl %esp,%ebp ; movl 8(%ebp),%eax UserGate start_watchdog_nr ; leave ret /*########################################################################## # # Name : RdosKickWatchdog # # Purpose....: Kick watchdog # ##########################################################################*/ .global RdosKickWatchdog RdosKickWatchdog: pushl %ebp movl %esp,%ebp UserGate kick_watchdog_nr leave ret
stsp/newlib-ia16
7,258
newlib/libc/sys/rdos/crt0.S
/*####################################################################### # RDOS operating system # Copyright (C) 1988-2006, Leif Ekblad # # This library is free software; you can redistribute it and/or modify # it under the terms of the GNU Lesser General Public License as published # by the Free Software Foundation; either version 2.1 of the License, or # (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # # The author of this program may be contacted at leif@rdos.net # # crt0.S # GCC startupcode for RDOS # ##########################################################################*/ #include "user.def" KEY_ENTRIES = 256 .macro UserGate nr .byte 0x9A .long \nr .word 2 .endm .data .align 8 _key_section: .word 0 _key_ref_arr: .long 0 _key_dtor_arr: .long 0 .text .align 4 /*########################################################################## # # Name : _start # # Purpose....: GCC startup-code # ##########################################################################*/ .global _start _start: call get_impure_data_size movl %eax,%ecx UserGate allocate_app_mem_nr xorl %eax,%eax .byte 0x64 movl %edx,(%eax) movl %edx,%edi rep stosb pushl %edx movl $(4 * KEY_ENTRIES),%eax movl %eax,%ecx UserGate allocate_app_mem_nr movl $4,%eax .byte 0x64 movl %edx,(%eax) movl %edx,%edi xorl %eax,%eax rep stosb movl $(4 * KEY_ENTRIES),%eax movl %eax,%ecx UserGate allocate_app_mem_nr movl %edx,_key_ref_arr movl %edx,%edi xorl %eax,%eax rep stosb movl $(4 * KEY_ENTRIES),%eax movl %eax,%ecx UserGate allocate_app_mem_nr movl %edx,_key_dtor_arr movl %edx,%edi xorl %eax,%eax rep stosb UserGate create_user_section_nr movw %bx,_key_section call __init_rdos add $4, %esp movl $0x1000,%eax UserGate allocate_app_mem_nr pushl %edx UserGate get_cmd_line_nr xorl %ecx,%ecx xorb %ah,%ah arg_loop: movl %edi,(%edx) addl $4,%edx movb (%edi),%al orb %al,%al je arg_done arg_scan: movb (%edi),%al orb %al,%al je next_arg cmpb $0x22,%al jne arg_no_quote xorb $1,%ah jmp arg_scan_next arg_no_quote: orb %ah,%ah jnz arg_scan_next cmpb $0x20,%al je next_arg cmpb $0x8,%al je next_arg arg_scan_next: incl %edi jmp arg_scan next_arg: incl %ecx to_next_arg: orb %al,%al je arg_done xorb %al,%al movb %al,(%edi) incl %edi movb (%edi),%al cmpb $0x20,%al je to_next_arg cmpb $0x8,%al je to_next_arg jmp arg_loop arg_done: int $3 pushl %ecx call main add $8, %esp pushl %eax call exit /*########################################################################## # # Name : _exit # # Purpose....: GCC exit-code # ##########################################################################*/ .global _exit _exit: pushl %ebp movl %esp,%ebp movl 8(%ebp),%eax UserGate unload_exe_nr /*########################################################################## # # Name : __getreent # # Purpose....: ? # ##########################################################################*/ .global __getreent __getreent: xorl %eax,%eax .byte 0x64 movl (%eax),%eax ret /*########################################################################## # # Name : __rdos_thread_key_create # # Purpose....: Emulate GCC pthread_key_create # # Parameters.: dtor # # Returns....: Key index # ##########################################################################*/ .global __rdos_thread_key_create __rdos_thread_key_create: int $3 pushl %ebp movl %esp,%ebp pushl %ebx pushl %ecx mov _key_section,%bx UserGate enter_user_section_nr movl _key_ref_arr,%ebx movl KEY_ENTRIES,%ecx rtkc_scan_loop: movl (%ebx), %eax orl %eax, %eax jz rtkc_entry_found add $4, %ebx loop rtkc_scan_loop movl $-1, %eax jmp rtkc_leave rtkc_entry_found: movb $255,3(%ebx) subl _key_ref_arr,%ebx addl _key_dtor_arr,%ebx movl 8(%ebp),%eax movl %eax,(%ebx) subl _key_dtor_arr,%ebx movl %ebx,%eax rtkc_leave: mov _key_section, %bx UserGate leave_user_section_nr popl %ecx popl %ebx leave ret /*########################################################################## # # Name : __rdos_thread_key_delete # # Purpose....: Emulate GCC pthread_key_delete # # Parameters.: index # # Returns....: result # ##########################################################################*/ .global __rdos_thread_key_delete __rdos_thread_key_delete: int $3 pushl %ebp movl %esp,%ebp pushl %ebx mov _key_section,%bx UserGate enter_user_section_nr movl 8(%ebp),%ebx testb $3,%bl jnz rtkd_fail cmpl $(4 * KEY_ENTRIES),%ebx jae rtkd_fail addl _key_ref_arr,%ebx movb $0,3(%ebx) mov (%ebx),%eax orl %eax,%eax jz rtkd_ok subl _key_ref_arr,%ebx movl $0,(%ebx) jmp rtkd_ok rtkd_fail: movl $1,%eax jmp rtkd_leave rtkd_ok: xorl %eax,%eax rtkd_leave: mov _key_section, %bx UserGate leave_user_section_nr popl %ebx leave ret /*########################################################################## # # Name : __rdos_thread_getspecific # # Purpose....: Emulate GCC pthread_getspecific # # Parameters.: index # # Returns....: value # ##########################################################################*/ .global __rdos_thread_getspecific __rdos_thread_getspecific: int $3 pushl %ebp movl %esp,%ebp pushl %ebx movl 8(%ebp),%ebx testb $3,%bl jnz rtg_fail cmpl $(4 * KEY_ENTRIES),%ebx jae rtg_fail movl $4,%eax .byte 0x64 movl (%eax),%eax addl %eax,%ebx movl (%ebx),%eax jmp rtg_done rtg_fail: xorl %eax,%eax rtg_done: popl %ebx leave ret /*########################################################################## # # Name : __rdos_thread_setspecific # # Purpose....: Emulate GCC pthread_setspecific # # Parameters.: index # value # ##########################################################################*/ .global __rdos_thread_setspecific __rdos_thread_setspecific: int $3 pushl %ebp movl %esp,%ebp pushl %ebx pushl %ecx movl 8(%ebp),%ebx testb $3,%bl jnz rts_fail cmpl $(4 * KEY_ENTRIES),%ebx jae rts_fail movl $4,%eax .byte 0x64 movl (%eax),%eax addl %eax,%ebx movl 12(%ebp),%eax movl %eax,(%ebx) xorl %eax,%eax jmp rts_done rts_fail: movl $1,%eax rts_done: popl %ebx leave ret
stsp/newlib-ia16
1,486
newlib/libc/sys/d10v/crt0.S
.text .global _start .type _start,@function .stabs "crt0.S",100,0,0,_start .stabs "int:t(0,1)=r(0,1);-32768;32767;",128,0,0,0 .stabs "_start:F(0,1)",36,0,1,_start _start: ; R14 always contains memory base address (0) ldi r14,0 ; Set the USER and SYSTEM stack pointers. ldi r0, 0 ; zero arguments ldi r1, 0 mvtc r0, psw ; select SPI and set it ldi sp, _stack ldi r10, 0x8000 ; select SPU/FP and set it mvtc r10, psw || ldi r11, 0; clear stack frame ldi sp, _stack - 0x200 ldi r13, 0 ; Clear the BSS. Do it in two parts for efficiency: longwords first ; for most of it, then the remaining 0 to 3 bytes. ldi r2, __bss_start ; R2 = start of BSS ldi r3, _end ; R3 = end of BSS + 1 sub r3, r2 ; R3 = BSS size in bytes mv r4, r3 srli r4, 2 ; R4 = BSS size in longwords (rounded down) loop1: cmpeqi r4, 0 ; more longords to zero out? brf0t.s endloop1 ; nope st2w r0, @r2+ ; yep, zero out another longword subi r4, 1 ; decrement count bra.l loop1 ; go do some more endloop1: and3 r4, r3, 3 ; get no. of remaining BSS bytes to clear loop2: cmpeqi r4, 0 ; more bytes to zero out? brf0t.s endloop2 ; nope stb r0, @r2 ; yep, zero out another byte addi r2, 1 ; bump address subi r4, 1 ; decrement count bra.s loop2 ; go do some more endloop2: ; Call main, then stop simulator st r11, @-sp st r13, @-sp mv r11, sp bl main bl exit stop .Lstart: .size _start,.Lstart-_start .stabs "",36,0,0,.Lstart-_start .section .stack _stack: .long 1
stsp/newlib-ia16
6,544
newlib/libc/sys/d10v/trap.S
#include "sys/syscall.h" #define SYSCALL(name) \ .global name ; \ name: ; \ ldi r4, SYS ## name ; \ bra __trap0 .text .stabs "trap.S",100,0,0,__trap0 .stabs "int:t(0,1)=r(0,1);-65536;65535;",128,0,0,0 .stabs "long int:t(0,2)=r(0,1);0020000000000;0017777777777;",128,0,0,0 .stabs "_trap0:F(0,1)",36,0,1,__trap0 .stabs "arg1:P(0,1)",64,0,1,0 .stabs "arg2:P(0,1)",64,0,1,1 .stabs "arg3:P(0,1)",64,0,1,2 .stabs "arg4:P(0,1)",64,0,1,3 .stabs "number:P(0,1)",64,0,1,4 .global __trap0 .type __trap0,@function __trap0: trap 15 /* trap 15 returns result in r0, error code in r4 */ cmpeqi r4,0 /* is error code zero? */ brf0t ret /* yes, skip setting errno */ #if __INT__==32 st r4,@(errno+2,r14) /* no, set errno */ srai r4,15 /* sign extend high word */ st r4,@(errno,r14) #else st r4,@(errno,r14) /* no, set errno */ #endif ret: jmp r13 /* return to caller */ .Ltrap0: .size __trap0,.Ltrap0-__trap0 .stabs "",36,0,0,.Ltrap0-__trap0 #define CONCAT(a,b) a ## b #define STRING(a) #a #define XSTRING(a) STRING(a) #define XSTRING2(a,b) XSTRING(CONCAT(a,b)) #if __INT__==32 #define _read _read16 #define _lseek _lseek16 #define _write _write16 #define _close _close16 #define _open _open16 #define _creat _creat16 #define _exit _exit16 #define _stat _stat16 #define _chmod _chmod16 #define _chown _chown16 #define _fork _fork16 #define _wait _wait16 #define _execve _execve16 #define _execv _execv16 #define _pipe _pipe16 #define _kill _kill16 #define _getpid _getpid16 #endif /* Until the assembler allows semicolon as a statement separator, */ /* we cannot use the SYSCALL macro. So expand it manually for now. */ /* #SYSCALL(_read) */ /* #SYSCALL(_lseek) */ /* #SYSCALL(_write) */ /* #SYSCALL(_close) */ /* #SYSCALL(_open) */ /* #SYSCALL(_creat) */ /* #SYSCALL(_exit) */ /* #SYSCALL(_stat) */ /* #SYSCALL(_chmod) */ /* #SYSCALL(_chown) */ /* #SYSCALL(_fork) */ /* #SYSCALL(_wait) */ /* #SYSCALL(_execve) */ /* #SYSCALL(_execv) */ /* #SYSCALL(_pipe) */ /* #SYSCALL(_getpid) */ /* #SYSCALL(_kill) */ .global _read .type _read,@function .stabs XSTRING2(_read,:F(0,1)),36,0,2,_read .stabs "fd:P(0,1)",64,0,1,0 .stabs "ptr:P(0,1)",64,0,1,1 .stabs "len:P(0,1)",64,0,1,2 _read: ldi r4, SYS_read bra __trap0 .Lread: .size _read,.-_read .stabs "",36,0,0,.Lread-_read .global _lseek .type _lseek,@function .stabs XSTRING2(_lseek,:F(0,1)),36,0,3,_lseek .stabs "fd:P(0,1)",64,0,1,0 .stabs "offset:P(0,1)",64,0,1,2 .stabs "whence:p(0,1)",160,0,1,0 _lseek: ldi r4, SYS_lseek bra __trap0 .Llseek: .size _lseek,.Llseek-_lseek .stabs "",36,0,0,.Llseek-_lseek .global _write .type _write,@function .stabs XSTRING2(_write,:F(0,1)),36,0,4,_write .stabs "fd:P(0,1)",64,0,1,0 .stabs "ptr:P(0,1)",64,0,1,1 .stabs "len:P(0,1)",64,0,1,2 _write: ldi r4, SYS_write bra __trap0 .Lwrite: .size _write,.Lwrite-_write .stabs "",36,0,0,.Lwrite-_write .global _close .type _close,@function .stabs XSTRING2(_close,:F(0,1)),36,0,5,_close .stabs "fd:P(0,1)",64,0,1,0 _close: ldi r4, SYS_close bra __trap0 .Lclose: .size _close,.Lclose-_close .stabs "",36,0,0,.Lclose-_close .global _open .type _open,@function .stabs XSTRING2(_open,:F(0,1)),36,0,6,_open .stabs "name:P(0,1)",64,0,1,0 .stabs "flags:P(0,1)",64,0,1,1 .stabs "mode:P(0,1)",64,0,1,2 _open: ldi r4, SYS_open bra __trap0 .Lopen: .size _open,.Lopen-_open .stabs "",36,0,0,.Lopen-_open .global _creat .type _creat,@function .stabs XSTRING2(_creat,:F(0,1)),36,0,7,_creat .stabs "name:P(0,1)",64,0,1,0 .stabs "mode:P(0,1)",64,0,1,1 _creat: ldi r4, SYS_creat bra __trap0 .Lcreat: .size _creat,.Lcreat-_creat .stabs "",36,0,0,.Lcreat-_creat .global _exit .type _exit,@function .stabs XSTRING2(_exit,:F(0,1)),36,0,8,_exit .stabs "status:P(0,1)",64,0,1,0 _exit: ldi r4, SYS_exit bra __trap0 .Lexit: .size _exit,.Lexit-_exit .stabs "",36,0,0,.Lexit-_exit .global _stat .type _stat,@function .stabs XSTRING2(_stat,:F(0,1)),36,0,9,_stat .stabs "name:P(0,1)",64,0,1,0 .stabs "packet:P(0,1)",64,0,1,1 _stat: ldi r4, SYS_stat bra __trap0 .Lstat: .size _stat,.Lstat-_stat .stabs "",36,0,0,.Lstat-_stat .global _chmod .type _chmod,@function .stabs XSTRING2(_chmod,:F(0,1)),36,0,10,_chmod .stabs "name:P(0,1)",64,0,1,0 .stabs "mode:P(0,1)",64,0,1,1 _chmod: ldi r4, SYS_chmod bra __trap0 .Lchmod: .size _chmod,.Lchmod-_chmod .stabs "",36,0,0,.Lchmod-_chmod .global _chown .type _chown,@function .stabs XSTRING2(_chown,:F(0,1)),36,0,11,_chown .stabs "name:P(0,1)",64,0,1,0 .stabs "uid:P(0,1)",64,0,1,1 .stabs "gid:P(0,1)",64,0,1,2 _chown: ldi r4, SYS_chown bra __trap0 .Lchown: .size _chown,.Lchown-_chown .stabs "",36,0,0,.Lchown-_chown .global _fork .type _fork,@function .stabs XSTRING2(_fork,:F(0,1)),36,0,12,_fork _fork: ldi r4, SYS_fork bra __trap0 .Lfork: .size _fork,.Lfork-_fork .stabs "",36,0,0,.Lfork-_fork .global _wait .type _wait,@function .stabs "status:P(0,1)",64,0,1,0 .stabs XSTRING2(_wait,:F(0,1)),36,0,13,_wait _wait: ldi r4, SYS_wait bra __trap0 .Lwait: .size _wait,.Lwait-_wait .stabs "",36,0,0,.Lwait-_wait .global _execve .type _execve,@function .stabs "name:P(0,1)",64,0,1,0 .stabs "argv:P(0,1)",64,0,1,1 .stabs "envp:P(0,1)",64,0,1,2 .stabs XSTRING2(_execve,:F(0,1)),36,0,14,_execve _execve: ldi r4, SYS_execve bra __trap0 .Lexecve: .size _execve,.Lexecve-_execve .stabs "",36,0,0,.Lexecve-_execve .global _execv .type _execv,@function .stabs XSTRING2(_execv,:F(0,1)),36,0,15,_execv .stabs "name:P(0,1)",64,0,1,0 .stabs "argv:P(0,1)",64,0,1,1 _execv: ldi r4, SYS_execv bra __trap0 .Lexecv: .size _execv,.Lexecv-_execv .stabs "",36,0,0,.Lexecv-_execv .global _pipe .type _pipe,@function .stabs XSTRING2(_pipe,:F(0,1)),36,0,16,_pipe .stabs "fds:P(0,1)",64,0,1,0 _pipe: ldi r4, SYS_pipe bra __trap0 .Lpipe: .size _pipe,.Lpipe-_pipe .stabs "",36,0,0,.Lpipe-_pipe .global time .type time,@function .stabs XSTRING2(time,:F(0,1)),36,0,17,time .stabs "ptr:P(0,1)",64,0,1,0 time: ldi r4, SYS_time bra __trap0 .Ltime: .size time,.Ltime-time .stabs "",36,0,0,.Ltime-time .global _kill .type _kill,@function .stabs XSTRING2(_kill,:F(0,1)),36,0,18,_kill .stabs "pid:P(0,1)",64,0,1,0 .stabs "sig:P(0,1)",64,0,1,1 _kill: ldi r4, SYS_kill bra __trap0 .Lkill: .size _kill,.Lkill-_kill .stabs "",36,0,0,.Lkill-_kill .global _getpid .type _getpid,@function .stabs XSTRING2(_getpid,:F(0,1)),36,0,19,_getpid _getpid: ldi r4, SYS_getpid bra __trap0 .Lgetpid: .size _getpid,.Lgetpid-_getpid .stabs "",36,0,0,.Lgetpid-_getpid
stsp/newlib-ia16
2,372
newlib/libc/sys/mmixware/setjmp.S
/* Setjmp and longjmp for mmix. Copyright (C) 2001 Hans-Peter Nilsson Permission to use, copy, modify, and distribute this software is freely granted, provided that the above copyright notice, this notice and the following disclaimer are preserved with no changes. THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. jmp_buf[5]: 0: fp 1: rJ (return-address) 2: sp 3: rO *before* the setjmp call. 4: temporary storage. Reserved between setjmp and longjmp. */ #ifdef __MMIX_ABI_GNU__ #define arg1 $231 #define arg2 $232 #define outret $231 #define popval 0 #else #define arg1 $0 #define arg2 $1 #define outret $0 #define popval 1 #endif .section .text.setjmp,"ax",@progbits .global setjmp setjmp: % Store fp, sp and return address. Recycle the static-chain and % structure-return registers as temporary register, since we need to keep % the jmp_buf (parameter 1) and the return address across a "POP". SET $251,arg1 STOU $253,$251,0 GET $252,rJ STOU $252,$251,8 STOU $254,$251,16 SETL outret,0 % Jump through hoops to get the value of rO *before* the setjmp call. GETA $255,0f PUT rJ,$255 POP popval,0 0: GET $255,rO STOU $255,$251,24 GO $255,$252,0 .size setjmp,.-setjmp .section .text.longjmp,"ax",@progbits .global longjmp longjmp: % Reset arg2 to 1 if it is 0 (see longjmp(2)) and store it in jmp_buf. % Save arg1 in a global register, since it will be destroyed by the POPs % (in the mmixware ABI). CSZ arg2,arg2,1 STOU arg2,arg1,32 SET $251,arg1 % Loop and "POP 0,0" until rO is the expected value, like % the expansion of nonlocal_goto_receiver, except that we put the return % value in the right register and make sure that the POP causes it to % enter the right return-value register as seen by the caller. For the % GNU ABI, it is unnecessary to do this in the loop and perhaps the memory % access can be hoisted outside the loop, but this is safe and simple and % I see no need to optimize longjmps. GETA $255,0f PUT rJ,$255 LDOU $255,$251,24 0: GET $252,rO CMPU $252,$252,$255 BNP $252,1f LDOU outret,$251,32 POP popval,0 1: LDOU $253,$251,0 LDOU $255,$251,8 LDOU $254,$251,16 GO $255,$255,0 .size longjmp,.-longjmp
stsp/newlib-ia16
1,481
newlib/libc/sys/linux/linuxthreads/machine/i386/sysdep.S
/* Copyright (C) 1995, 1996, 1997, 1998 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. The GNU C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ #include <sysdep.h> /* The following code is only used in the shared library when we compile the reentrant version. Otherwise each system call defines each own version. */ #ifndef PIC /* The syscall stubs jump here when they detect an error. The code for Linux is almost identical to the canonical Unix/i386 code, except that the error number in %eax is negated. */ #undef CALL_MCOUNT #define CALL_MCOUNT /* Don't insert the profiling call, it clobbers %eax. */ .text ENTRY (__syscall_error) negl %eax #define __syscall_error __syscall_error_1 #include <i386-sysdep.S> #endif /* !PIC */
stsp/newlib-ia16
1,953
newlib/libc/sys/linux/linuxthreads/machine/i386/i386-sysdep.S
/* Copyright (C) 1991, 92, 93, 94, 95, 96, 97, 2000 Free Software Foundation, Inc. This file has been modified from the GNU C Library. The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. The GNU C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ #include <sysdep.h> #define _ERRNO_H #include <bits/errno.h> #include <bp-asm.h> #include <bp-sym.h> .globl __syscall_error __syscall_error: #if defined (EWOULDBLOCK_sys) && EWOULDBLOCK_sys != EAGAIN /* We translate the system's EWOULDBLOCK error into EAGAIN. The GNU C library always defines EWOULDBLOCK==EAGAIN. EWOULDBLOCK_sys is the original number. */ cmpl $EWOULDBLOCK_sys, %eax /* Is it the old EWOULDBLOCK? */ jne notb /* Branch if not. */ movl $EAGAIN, %eax /* Yes; translate it to EAGAIN. */ notb: #endif #ifndef PIC pushl %eax PUSH_ERRNO_LOCATION_RETURN call BP_SYM (__errno) POP_ERRNO_LOCATION_RETURN popl %ecx movl %ecx, (%eax) #else /* The caller has pushed %ebx and then set it up to point to the GOT before calling us through the PLT. */ pushl %eax PUSH_ERRNO_LOCATION_RETURN call C_SYMBOL_NAME (BP_SYM (__errno)@PLT) POP_ERRNO_LOCATION_RETURN popl %ecx /* Pop %ebx value saved before jumping here. */ popl %ebx movl %ecx, (%eax) #endif movl $-1, %eax ret #undef __syscall_error END (__syscall_error)
stsp/newlib-ia16
2,585
newlib/libc/sys/linux/linuxthreads/machine/i386/clone.S
/* Copyright (C) 1996, 1997, 1998, 1999, 2000 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Richard Henderson (rth@tamu.edu) The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. The GNU C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ /* clone() is even more special than fork() as it mucks with stacks and invokes a function in the right context after its all over. */ #include <sysdep.h> #define _ERRNO_H 1 #include <bits/errno.h> #include <asm/unistd.h> #include <bp-sym.h> #include <bp-asm.h> /* int clone(int (*fn)(void *arg), void *child_stack, int flags, void *arg); */ #define PARMS LINKAGE /* no space for saved regs */ #define FUNC PARMS #define STACK FUNC+4 #define FLAGS STACK+PTR_SIZE #define ARG FLAGS+4 .text ENTRY (BP_SYM (__clone)) /* Sanity check arguments. */ movl $-EINVAL,%eax movl FUNC(%esp),%ecx /* no NULL function pointers */ #ifdef PIC jecxz SYSCALL_ERROR_LABEL #else testl %ecx,%ecx jz SYSCALL_ERROR_LABEL #endif movl STACK(%esp),%ecx /* no NULL stack pointers */ #ifdef PIC jecxz SYSCALL_ERROR_LABEL #else testl %ecx,%ecx jz SYSCALL_ERROR_LABEL #endif /* Insert the argument onto the new stack. */ subl $8,%ecx movl ARG(%esp),%eax /* no negative argument counts */ movl %eax,4(%ecx) /* Save the function pointer as the zeroth argument. It will be popped off in the child in the ebx frobbing below. */ movl FUNC(%esp),%eax movl %eax,0(%ecx) /* Do the system call */ pushl %ebx movl FLAGS+4(%esp),%ebx movl $SYS_ify(clone),%eax int $0x80 popl %ebx test %eax,%eax jl SYSCALL_ERROR_LABEL jz thread_start L(pseudo_end): ret thread_start: subl %ebp,%ebp /* terminate the stack frame */ call *%ebx #ifdef PIC call L(here) L(here): popl %ebx addl $_GLOBAL_OFFSET_TABLE_+[.-L(here)], %ebx #endif pushl %eax call JUMPTARGET (_exit) PSEUDO_END (BP_SYM (__clone)) weak_alias (BP_SYM (__clone), BP_SYM (clone))
stsp/newlib-ia16
1,771
newlib/libc/sys/linux/machine/i386/setjmp.S
/* This is file is a merger of SETJMP.S and LONGJMP.S */ /* * This file was modified to use the __USER_LABEL_PREFIX__ and * __REGISTER_PREFIX__ macros defined by later versions of GNU cpp by * Joel Sherrill (joel@OARcorp.com) * Slight change: now includes i386mach.h for this (Werner Almesberger) * * Copyright (C) 1991 DJ Delorie * All rights reserved. * * Redistribution, modification, and use in source and binary forms is permitted * provided that the above copyright notice and following paragraph are * duplicated in all such forms. * * This file is distributed WITHOUT ANY WARRANTY; without even the implied * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. */ /* ** jmp_buf: ** eax ebx ecx edx esi edi ebp esp eip ** 0 4 8 12 16 20 24 28 32 */ #include "i386mach.h" .global SYM (setjmp) .global SYM (__libc_longjmp) .weak SYM (longjmp) SOTYPE_FUNCTION(setjmp) SOTYPE_FUNCTION(longjmp) SOTYPE_FUNCTION(__libc_longjmp) SYM (setjmp): pushl ebp movl esp,ebp pushl edi movl 8 (ebp),edi movl eax,0 (edi) movl ebx,4 (edi) movl ecx,8 (edi) movl edx,12 (edi) movl esi,16 (edi) movl -4 (ebp),eax movl eax,20 (edi) movl 0 (ebp),eax movl eax,24 (edi) movl esp,eax addl $12,eax movl eax,28 (edi) movl 4 (ebp),eax movl eax,32 (edi) popl edi movl $0,eax leave ret SYM (__libc_longjmp): SYM (longjmp): .weak longjmp pushl ebp movl esp,ebp movl 8(ebp),edi /* get jmp_buf */ movl 12(ebp),eax /* store retval in j->eax */ movl eax,0(edi) movl 24(edi),ebp __CLI movl 28(edi),esp pushl 32(edi) movl 0(edi),eax movl 4(edi),ebx movl 8(edi),ecx movl 12(edi),edx movl 16(edi),esi movl 20(edi),edi __STI ret
stsp/newlib-ia16
4,945
newlib/libc/machine/sh/strncpy.S
/* Copyright 2003 SuperH Ltd. */ #include "asm.h" #ifdef __SH5__ #if __SHMEDIA__ #ifdef __LITTLE_ENDIAN__ #define ZPAD_MASK(src, dst) addi src, -1, dst #else #define ZPAD_MASK(src, dst) \ byterev src, dst; addi dst, -1, dst; byterev dst, dst #endif /* We assume that the destination is not in the first 16 bytes of memory. A typical linker script will put the text section first, and as this code is longer that 16 bytes, you have to get out of your way to put data there. */ ENTRY(strncpy) pt L_small, tr2 ldlo.q r3, 0, r0 shlli r3, 3, r19 mcmpeq.b r0, r63, r1 SHHI r1, r19, r7 add r2, r4, r20 addi r20, -8, r5 /* If the size is greater than 8, we know we can read beyond the first (possibly partial) quadword, and write out a full first and last (possibly unaligned and/or overlapping) quadword. */ bge/u r2, r5, tr2 // L_small pt L_found0, tr0 addi r2, 8, r22 bnei/u r7, 0, tr0 // L_found0 ori r3, -8, r38 pt L_end_early, tr1 sub r2, r38, r22 stlo.q r2, 0, r0 sthi.q r2, 7, r0 sub r3, r2, r6 ldx.q r22, r6, r0 /* Before each iteration, check that we can store in full the next quad we are about to fetch. */ addi r5, -8, r36 bgtu/u r22, r36, tr1 // L_end_early pt L_scan0, tr1 L_scan0: addi r22, 8, r22 mcmpeq.b r0, r63, r1 stlo.q r22, -8, r0 bnei/u r1, 0, tr0 // L_found0 sthi.q r22, -1, r0 ldx.q r22, r6, r0 bgeu/l r36, r22, tr1 // L_scan0 L_end: // At end; we might re-read a few bytes when we fetch the last quad. // branch mispredict, so load is ready now. mcmpeq.b r0, r63, r1 addi r22, 8, r22 bnei/u r1, 0, tr0 // L_found0 add r3, r4, r7 ldlo.q r7, -8, r1 ldhi.q r7, -1, r7 ptabs r18, tr0 stlo.q r22, -8, r0 or r1, r7, r1 mcmpeq.b r1, r63, r7 sthi.q r22, -1, r0 ZPAD_MASK (r7, r7) and r1, r7, r1 // mask out non-zero bytes after first zero byte stlo.q r20, -8, r1 sthi.q r20, -1, r1 blink tr0, r63 L_end_early: /* Check if we can store the current quad in full. */ pt L_end, tr1 add r3, r4, r7 bgtu/u r5, r22, tr1 // L_end // Not really unlikely, but gap is short. /* If not, that means we can just proceed to process the last quad. Two pipeline stalls are unavoidable, as we don't have enough ILP. */ ldlo.q r7, -8, r1 ldhi.q r7, -1, r7 ptabs r18, tr0 or r1, r7, r1 mcmpeq.b r1, r63, r7 ZPAD_MASK (r7, r7) and r1, r7, r1 // mask out non-zero bytes after first zero byte stlo.q r20, -8, r1 sthi.q r20, -1, r1 blink tr0, r63 L_found0: // r0: string to store, not yet zero-padding normalized. // r1: result of mcmpeq.b r0, r63, r1. // r22: store address plus 8. I.e. address where zero padding beyond the // string in r0 goes. // r20: store end address. // r5: store end address minus 8. pt L_write0_multiquad, tr0 ZPAD_MASK (r1, r1) and r0, r1, r0 // mask out non-zero bytes after first zero byte stlo.q r22, -8, r0 sthi.q r22, -1, r0 andi r22, -8, r1 // Check if zeros to write fit in one quad word. bgtu/l r5, r1, tr0 // L_write0_multiquad ptabs r18, tr1 sub r20, r22, r1 shlli r1, 2, r1 // Do shift in two steps so that 64 bit case is SHLO r0, r1, r0 // handled correctly. SHLO r0, r1, r0 sthi.q r20, -1, r0 blink tr1, r63 L_write0_multiquad: pt L_write0_loop, tr0 ptabs r18, tr1 stlo.q r22, 0, r63 sthi.q r20, -1, r63 addi r1, 8, r1 bgeu/l r5, r1, tr0 // L_write0_loop blink tr1, r63 L_write0_loop: st.q r1, 0 ,r63 addi r1, 8, r1 bgeu/l r5, r1, tr0 // L_write0_loop blink tr1, r63 L_small: // r0: string to store, not yet zero-padding normalized. // r1: result of mcmpeq.b r0, r63, r1. // r7: nonzero indicates relevant zero found r0. // r2: store address. // r3: read address. // r4: size, max 8 // r20: store end address. // r5: store end address minus 8. pt L_nohi, tr0 pt L_small_storelong, tr1 ptabs r18, tr2 sub r63, r4, r23 bnei/u r7, 0, tr0 // L_nohi ori r3, -8, r7 bge/l r23, r7, tr0 // L_nohi ldhi.q r3, 7, r1 or r0, r1, r0 mcmpeq.b r0, r63, r1 L_nohi: ZPAD_MASK (r1, r1) and r0, r1, r0 movi 4, r19 bge/u r4, r19, tr1 // L_small_storelong pt L_small_end, tr0 #ifndef __LITTLE_ENDIAN__ byterev r0, r0 #endif beqi/u r4, 0, tr0 // L_small_end st.b r2, 0, r0 beqi/u r4, 1, tr0 // L_small_end shlri r0, 8, r0 st.b r2, 1, r0 beqi/u r4, 2, tr0 // L_small_end shlri r0, 8, r0 st.b r2, 2, r0 L_small_end: blink tr2, r63 L_small_storelong: shlli r23, 3, r7 SHHI r0, r7, r1 #ifdef __LITTLE_ENDIAN__ shlri r1, 32, r1 #else shlri r0, 32, r0 #endif stlo.l r2, 0, r0 sthi.l r2, 3, r0 stlo.l r20, -4, r1 sthi.l r20, -1, r1 blink tr2, r63 #else /* SHcompact */ /* This code is optimized for size. Instruction selection is SH5 specific. SH4 should use a different version. */ ENTRY(strncpy) mov #0, r6 cmp/eq r4, r6 bt return mov r2, r5 add #-1, r5 add r5, r4 loop: bt/s found0 add #1, r5 mov.b @r3+, r1 found0: cmp/eq r5,r4 mov.b r1, @r5 bf/s loop cmp/eq r1, r6 return: rts nop #endif /* SHcompact */ #endif /* __SH5__ */
stsp/newlib-ia16
1,370
newlib/libc/machine/sh/strlen.S
! Entry: arg0: string start address ! Exit: result: length ! ! Copyright 2002 SuperH Ltd. #include "asm.h" ENTRY(strlen) #if __SHMEDIA__ ldlo.q r2,0,r3 ptabs/l r18,tr0 pta/l loop,tr1 andi r2,-8,r0 shlli r2,3,r1 mcmpeq.b r3,r63,r3 SHHI r3,r1,r4 beqi/u r4,0,tr1 // loop #ifdef __LITTLE_ENDIAN__ movi -1,r2 addi r3,-1,r4 msad.ubq r3,r4,r2 #else shlri r3,1,r3 nsb r3,r3 shlri r3,3,r2 #endif blink tr0,r63 loop: ldlo.q r0,8,r3 addi r0,8,r0 ldlo.q r0,8,r63 mcmpeq.b r3,r63,r3 beqi/l r3,0,tr1 // loop sub r0,r2,r2 #ifdef __LITTLE_ENDIAN__ addi r3,-1,r4 addi r2,-1,r2 msad.ubq r3,r4,r2 #else shlri r3,1,r3 nsb r3,r3 shlri r3,3,r3 add r2,r3,r2 #endif blink tr0,r63 #else /* ! __SHMEDIA__, i.e. SH 1..4 / SHcompact */ #ifdef __SH5__ #define STR_INIT r2 #define STR_ORIG r0 #define STR_COPY STR_ORIG #define MASK r1 #define TMP r3 #define RESULT r2 ! r0,r1,r3: clobbered #else #define STR_INIT r4 #define STR_ORIG STR_INIT #define STR_COPY STR #define MASK r1 #define TMP r3 #define RESULT r0 ! r1,r3: clobbered #endif #define STR RESULT mov #3,MASK and STR_INIT,MASK tst MASK,MASK SL(bf, L_char_loop, mov STR_INIT, STR_COPY) L_word_loop: mov.l @STR+,TMP cmp/str MASK,TMP bf L_word_loop add #-4,STR L_char_loop: mov.b @STR+,TMP tst TMP,TMP bf L_char_loop add #-1,STR rts sub STR_ORIG,STR #endif /* ! __SHMEDIA__ */
stsp/newlib-ia16
3,191
newlib/libc/machine/sh/memset.S
! ! Fast SH memset ! ! by Toshiyasu Morita (tm@netcom.com) ! ! SH5 code by J"orn Rennecke (joern.rennecke@superh.com) ! Copyright 2002 SuperH Ltd. ! #include "asm.h" ENTRY(memset) #if __SHMEDIA__ pta/l multiquad, tr0 ptabs r18, tr2 andi r2, -8, r25 add r2, r4, r5 addi r5, -1, r20 // calculate end address. andi r20, -8, r20 cmveq r4, r25, r20 bne/u r25, r20, tr0 // multiquad ! This sequence could clobber volatile objects that are in the same ! quadword as a very short char array. ! ldlo.q r2, 0, r7 ! shlli r4, 2, r4 ! movi -1, r8 ! SHHI r8, r4, r8 ! SHHI r8, r4, r8 ! mcmv r7, r8, r3 ! stlo.q r2, 0, r3 pta/l setlongs, tr0 movi 4, r8 bgeu/u r4, r8, tr0 pta/l endset, tr0 beqi/u r4, 0, tr0 st.b r2, 0, r3 beqi/u r4, 1, tr0 nop st.b r2, 1, r3 beqi/l r4, 2, tr0 st.b r2,2,r3 endset: blink tr2, r63 setlongs: mshflo.b r3, r3, r3 mperm.w r3, r63, r3 // Fill pattern now in every byte of r3 stlo.l r2, 0, r3 nop nop sthi.l r5, -1, r3 blink tr2, r63 multiquad: mshflo.b r3, r3, r3 mperm.w r3, r63, r3 // Fill pattern now in every byte of r3 pta/l lastquad, tr0 stlo.q r2, 0, r3 sub r20, r25, r24 movi 64, r9 beqi/u r24, 8, tr0 // lastquad pta/l loop, tr1 addi r20, -7*8, r8 // loop end address; This might overflow, so we need // to use a different test before we start the loop bgeu/u r24, r9, tr1// loop st.q r25, 8, r3 shlri r24, 4, r24 st.q r20, -8, r3 beqi/u r24, 1, tr0 // lastquad st.q r25, 16, r3 st.q r20, -16, r3 beqi/u r24, 2, tr0 // lastquad st.q r25, 24, r3 st.q r20, -24, r3 lastquad: sthi.q r5, -1, r3 blink tr2,r63 loop: alloco r25, 32 st.q r25, 8, r3 st.q r25, 16, r3 st.q r25, 24, r3 st.q r25, 32, r3 addi r25, 32, r25 bgeu/l r8, r25, tr1 // loop st.q r20, -40, r3 st.q r20, -32, r3 st.q r20, -24, r3 st.q r20, -16, r3 st.q r20, -8, r3 sthi.q r5, -1, r3 blink tr2,r63 #else /* ! SHMEDIA, i.e. SH1 .. SH4 / SHcompact */ ! Entry: r4: destination pointer ! r5: fill value ! r6: byte count ! ! Exit: r0-r3: trashed ! ! This assumes that the first four bytes of the address space (0..3) are ! reserved - usually by the linker script. Otherwise, we would had to check ! for the case of objects of the size 12..15 at address 0..3 . #ifdef __SH5__ #define DST r2 #define VAL r3 #define CNT r4 #define TMP r5 #else #define DST r4 #define VAL r5 #define CNT r6 #define TMP r2 #endif mov #12,r0 ! Check for small number of bytes cmp/gt CNT,r0 mov DST,r0 SL(bt, L_store_byte_loop_check0, add DST,CNT) tst #3,r0 ! Align destination SL(bt, L_dup_bytes, extu.b r5,r5) .balignw 4,0x0009 L_align_loop: mov.b VAL,@r0 add #1,r0 tst #3,r0 bf L_align_loop L_dup_bytes: swap.b VAL,TMP ! Duplicate bytes across longword or TMP,VAL swap.w VAL,TMP or TMP,VAL add #-16,CNT .balignw 4,0x0009 L_store_long_loop: mov.l VAL,@r0 ! Store double longs to memory cmp/hs CNT,r0 mov.l VAL,@(4,r0) SL(bf, L_store_long_loop, add #8,r0) add #16,CNT L_store_byte_loop_check0: cmp/eq CNT,r0 bt L_exit .balignw 4,0x0009 L_store_byte_loop: mov.b VAL,@r0 ! Store bytes to memory add #1,r0 cmp/eq CNT,r0 bf L_store_byte_loop L_exit: rts mov r4,r0 #endif /* ! SHMEDIA */
stsp/newlib-ia16
7,726
newlib/libc/machine/sh/memcpy.S
! ! Fast SH memcpy ! ! by Toshiyasu Morita (tm@netcom.com) ! hacked by J"orn Rernnecke (joern.rennecke@superh.com) ("o for o-umlaut) ! SH5 code Copyright 2002 SuperH Ltd. ! ! Entry: ARG0: destination pointer ! ARG1: source pointer ! ARG3: byte count ! ! Exit: RESULT: destination pointer ! any other registers in the range r0-r7: trashed ! ! Notes: Usually one wants to do small reads and write a longword, but ! unfortunately it is difficult in some cases to concatanate bytes ! into a longword on the SH, so this does a longword read and small ! writes. ! ! This implementation makes two assumptions about how it is called: ! ! 1.: If the byte count is nonzero, the address of the last byte to be ! copied is unsigned greater than the address of the first byte to ! be copied. This could be easily swapped for a signed comparison, ! but the algorithm used needs some comparison. ! ! 2.: When there are two or three bytes in the last word of an 11-or-more ! bytes memory chunk to b copied, the rest of the word can be read ! without side effects. ! This could be easily changed by increasing the minumum size of ! a fast memcpy and the amount subtracted from r7 before L_2l_loop be 2, ! however, this would cost a few extra cyles on average. ! For SHmedia, the assumption is that any quadword can be read in its ! enirety if at least one byte is included in the copy. ! #include "asm.h" ENTRY(memcpy) #if __SHMEDIA__ #define LDUAQ(P,O,D0,D1) ldlo.q P,O,D0; ldhi.q P,O+7,D1 #define STUAQ(P,O,D0,D1) stlo.q P,O,D0; sthi.q P,O+7,D1 #define LDUAL(P,O,D0,D1) ldlo.l P,O,D0; ldhi.l P,O+3,D1 #define STUAL(P,O,D0,D1) stlo.l P,O,D0; sthi.l P,O+3,D1 ld.b r3,0,r63 pta/l Large,tr0 movi 25,r0 bgeu/u r4,r0,tr0 nsb r4,r0 shlli r0,5,r0 movi (L1-L0+63*32 + 1) & 0xffff,r1 sub r1, r0, r0 L0: ptrel r0,tr0 add r2,r4,r5 ptabs r18,tr1 add r3,r4,r6 blink tr0,r63 .balign 8 L1: /* 0 byte memcpy */ blink tr1,r63 L4_7: /* 4..7 byte memcpy cntd. */ stlo.l r2, 0, r0 or r6, r7, r6 sthi.l r5, -1, r6 stlo.l r5, -4, r6 blink tr1,r63 L2_3: /* 2 or 3 byte memcpy cntd. */ st.b r5,-1,r6 blink tr1,r63 /* 1 byte memcpy */ ld.b r3,0,r0 st.b r2,0,r0 blink tr1,r63 L8_15: /* 8..15 byte memcpy cntd. */ stlo.q r2, 0, r0 or r6, r7, r6 sthi.q r5, -1, r6 stlo.q r5, -8, r6 blink tr1,r63 /* 2 or 3 byte memcpy */ ld.b r3,0,r0 ld.b r2,0,r63 ld.b r3,1,r1 st.b r2,0,r0 pta/l L2_3,tr0 ld.b r6,-1,r6 st.b r2,1,r1 blink tr0, r63 /* 4 .. 7 byte memcpy */ LDUAL (r3, 0, r0, r1) pta L4_7, tr0 ldlo.l r6, -4, r7 or r0, r1, r0 sthi.l r2, 3, r0 ldhi.l r6, -1, r6 blink tr0, r63 /* 8 .. 15 byte memcpy */ LDUAQ (r3, 0, r0, r1) pta L8_15, tr0 ldlo.q r6, -8, r7 or r0, r1, r0 sthi.q r2, 7, r0 ldhi.q r6, -1, r6 blink tr0, r63 /* 16 .. 24 byte memcpy */ LDUAQ (r3, 0, r0, r1) LDUAQ (r3, 8, r8, r9) or r0, r1, r0 sthi.q r2, 7, r0 or r8, r9, r8 sthi.q r2, 15, r8 ldlo.q r6, -8, r7 ldhi.q r6, -1, r6 stlo.q r2, 8, r8 stlo.q r2, 0, r0 or r6, r7, r6 sthi.q r5, -1, r6 stlo.q r5, -8, r6 blink tr1,r63 Large: ld.b r2, 0, r63 pta/l Loop_ua, tr1 ori r3, -8, r7 sub r2, r7, r22 sub r3, r2, r6 add r2, r4, r5 ldlo.q r3, 0, r0 addi r5, -16, r5 movi 64+8, r27 // could subtract r7 from that. stlo.q r2, 0, r0 sthi.q r2, 7, r0 ldx.q r22, r6, r0 bgtu/l r27, r4, tr1 addi r5, -48, r27 pta/l Loop_line, tr0 addi r6, 64, r36 addi r6, -24, r19 addi r6, -16, r20 addi r6, -8, r21 Loop_line: ldx.q r22, r36, r63 alloco r22, 32 addi r22, 32, r22 ldx.q r22, r19, r23 sthi.q r22, -25, r0 ldx.q r22, r20, r24 ldx.q r22, r21, r25 stlo.q r22, -32, r0 ldx.q r22, r6, r0 sthi.q r22, -17, r23 sthi.q r22, -9, r24 sthi.q r22, -1, r25 stlo.q r22, -24, r23 stlo.q r22, -16, r24 stlo.q r22, -8, r25 bgeu r27, r22, tr0 Loop_ua: addi r22, 8, r22 sthi.q r22, -1, r0 stlo.q r22, -8, r0 ldx.q r22, r6, r0 bgtu/l r5, r22, tr1 add r3, r4, r7 ldlo.q r7, -8, r1 sthi.q r22, 7, r0 ldhi.q r7, -1, r7 ptabs r18,tr1 stlo.q r22, 0, r0 or r1, r7, r1 sthi.q r5, 15, r1 stlo.q r5, 8, r1 blink tr1, r63 #else /* ! SHMEDIA, i.e. SH1 .. SH4 / SHcompact */ #ifdef __SH5__ #define DST r2 #define SRC r3 #define COUNT r4 #define TMP0 r5 #define TMP1 r6 #define RESULT r2 #else #define DST r4 #define SRC r5 #define COUNT r6 #define TMP0 r2 #define TMP1 r3 #define RESULT r0 #endif #ifdef __LITTLE_ENDIAN__ ! Little endian version copies with increasing addresses. mov DST,TMP1 ! Save return value mov #11,r0 ! Check if small number of bytes cmp/hs r0,COUNT ! COUNT becomes src end address SL(bf, L_small, add SRC,COUNT) mov #1,r1 tst r1,SRC ! check if source even SL(bt, L_even, mov COUNT,r7) mov.b @SRC+,r0 ! no, make it even. mov.b r0,@DST add #1,DST L_even: tst r1,DST ! check if destination is even add #-3,r7 SL(bf, L_odddst, mov #2,r1) tst r1,DST ! check if destination is 4-byte aligned mov DST,r0 SL(bt, L_al4dst, sub SRC,r0) mov.w @SRC+,TMP0 mov.w TMP0,@DST ! add #2,DST DST is dead here. L_al4dst: tst r1,SRC bt L_al4both mov.w @SRC+,r1 swap.w r1,r1 add #-6,r0 add #-6,r7 ! r7 := src end address minus 9. .align 2 L_2l_loop: mov.l @SRC+,TMP0 ! Read & write two longwords per iteration xtrct TMP0,r1 mov.l r1,@(r0,SRC) cmp/hs r7,SRC mov.l @SRC+,r1 xtrct r1,TMP0 mov.l TMP0,@(r0,SRC) bf L_2l_loop add #-2,SRC bra L_cleanup add #5,r0 L_al4both: add #-4,r0 .align 2 L_al4both_loop: mov.l @SRC+,DST ! Read longword, write longword per iteration cmp/hs r7,SRC SL(bf, L_al4both_loop, mov.l DST,@(r0,SRC)) bra L_cleanup add #3,r0 L_odddst: tst r1,SRC SL(bt, L_al4src, add #-1,DST) mov.w @SRC+,r0 mov.b r0,@(1,DST) shlr8 r0 mov.b r0,@(2,DST) add #2,DST L_al4src: .align 2 L_odd_loop: mov.l @SRC+,r0 ! Read longword, write byte, word, byte per iteration cmp/hs r7,SRC mov.b r0,@(1,DST) shlr8 r0 mov.w r0,@(2,DST) shlr16 r0 mov.b r0,@(4,DST) SL(bf, L_odd_loop, add #4,DST) .align 2 ! avoid nop in more frequently executed code. L_cleanup2: mov DST,r0 sub SRC,r0 L_cleanup: cmp/eq COUNT,SRC bt L_ready .align 2 L_cleanup_loop: mov.b @SRC+,r1 cmp/eq COUNT,SRC mov.b r1,@(r0,SRC) bf L_cleanup_loop L_ready: rts mov TMP1,RESULT L_small: bra L_cleanup2 add #-1,DST #else /* ! __LITTLE_ENDIAN__ */ ! Big endian version copies with decreasing addresses. mov DST,r0 add COUNT,r0 sub DST,SRC mov #11,r1 cmp/hs r1,COUNT SL(bf, L_small, add #-1,SRC) mov SRC,TMP1 add r0,TMP1 shlr TMP1 SL(bt, L_even, mov DST,r7) mov.b @(r0,SRC),TMP0 add #-1,TMP1 mov.b TMP0,@-r0 L_even: tst #1,r0 add #-1,SRC SL(bf, L_odddst, add #8,r7) tst #2,r0 bt L_al4dst add #-1,TMP1 mov.w @(r0,SRC),r1 mov.w r1,@-r0 L_al4dst: shlr TMP1 bt L_al4both mov.w @(r0,SRC),r1 swap.w r1,r1 add #4,r7 add #-4,SRC .align 2 L_2l_loop: mov.l @(r0,SRC),TMP0 xtrct TMP0,r1 mov.l r1,@-r0 cmp/hs r7,r0 mov.l @(r0,SRC),r1 xtrct r1,TMP0 mov.l TMP0,@-r0 bt L_2l_loop bra L_cleanup add #5,SRC nop ! avoid nop in executed code. L_al4both: add #-2,SRC .align 2 L_al4both_loop: mov.l @(r0,SRC),r1 cmp/hs r7,r0 SL(bt, L_al4both_loop, mov.l r1,@-r0) bra L_cleanup add #3,SRC nop ! avoid nop in executed code. L_odddst: shlr TMP1 bt L_al4src mov.w @(r0,SRC),r1 mov.b r1,@-r0 shlr8 r1 mov.b r1,@-r0 L_al4src: add #-2,SRC .align 2 L_odd_loop: mov.l @(r0,SRC),TMP0 cmp/hs r7,r0 mov.b TMP0,@-r0 shlr8 TMP0 mov.w TMP0,@-r0 shlr16 TMP0 mov.b TMP0,@-r0 bt L_odd_loop add #3,SRC L_cleanup: L_small: cmp/eq DST,r0 bt L_ready add #1,DST .align 2 L_cleanup_loop: mov.b @(r0,SRC),TMP0 cmp/eq DST,r0 mov.b TMP0,@-r0 bf L_cleanup_loop L_ready: rts mov r0,RESULT #endif /* ! __LITTLE_ENDIAN__ */ #endif /* ! SHMEDIA */
stsp/newlib-ia16
4,092
newlib/libc/machine/sh/strcmp.S
! SH5 code Copyright 2002 SuperH Ltd. #include "asm.h" ENTRY(strcmp) #if __SHMEDIA__ ld.ub r2,0,r4 pt/l quickret0,tr0 ld.ub r3,0,r5 ptabs r18,tr2 beqi/u r4,0,tr0 ld.ub r2,1,r6 bne/u r4,r5,tr0 pt/l quickret1,tr1 ld.ub r3,1,r7 beqi/u r6,0,tr1 ld.ub r2,2,r4 bne/u r6,r7,tr1 ld.ub r3,2,r5 beqi/u r4,0,tr0 ld.ub r2,3,r6 bne/u r4,r5,tr0 ld.ub r3,3,r7 beqi/u r6,0,tr1 ld.ub r2,4,r4 bne/u r6,r7,tr1 ld.ub r3,4,r5 beqi/u r4,0,tr0 ld.ub r2,5,r6 bne/u r4,r5,tr0 ld.ub r3,5,r7 beqi/u r6,0,tr1 ld.ub r2,6,r4 bne/u r6,r7,tr1 ld.ub r3,6,r5 beqi/u r4,0,tr0 ld.ub r2,7,r6 bne/u r4,r5,tr0 ld.ub r3,7,r7 beqi/u r6,0,tr1 sub r3,r2,r3 bne/u r6,r7,tr1 andi r2,-8,r2 add r3,r2,r3 ldlo.q r3,8,r23 pt r23_zero,tr0 shlli r3,3,r22 sub r63,r22,r20 movi 0x101,r6 mperm.w r6,r63,r6 SHLO r6,r22,r7 msubs.ub r7,r23,r8 pt loop,tr1 bnei/u r8,0,tr0 // r23_zero pt found_zero,tr0 addi r3,15,r3 andi r3,-8,r3 sub r3,r2,r3 bne/l r7,r6,tr1 // loop /* The strings are aligned to each other. */ /* It is possible to have a loop with six cycles / iteration by re-ordering the exit conditions, but then it needs extra time and/or code to sort out the r4 != r5 case. */ pt al_loop,tr1 pt al_found_zero,tr0 al_loop: ld.q r2,8,r4 ldx.q r2,r3,r5 addi r2,8,r2 mcmpeq.b r63,r4,r8 pt cmp_quad,tr3 bnei/u r8,0,tr0 // al_found_zero beq/l r4,r5,tr1 // al_loop blink tr3,r63 // cmp_quad .balign 8 quickret0: sub r4,r5,r2 blink tr2,r63 quickret1: sub r6,r7,r2 blink tr2,r63 loop: ld.q r2,8,r4 ldx.q r2,r3,r19 addi r2,8,r2 msubs.ub r6,r4,r8 mcmpeq.b r63,r19,r9 SHHI r19,r20,r21 or r21,r23,r5 SHLO r19,r22,r23 bne/u r8,r9,tr0 // found_zero beq/l r4,r5,tr1 // loop cmp_quad: #ifdef __LITTLE_ENDIAN__ byterev r4,r4 byterev r5,r5 #endif cmpgtu r4,r5,r6 cmpgtu r5,r4,r7 sub r6,r7,r2 blink tr2,r63 found_zero: pt zero_now,tr0 pt cmp_quad,tr1 SHHI r9,r20,r7 bne/u r8,r7,tr0 // zero_now bne/u r4,r5,tr1 // cmp_quad SHLO r9,r22,r8 r23_zero: ld.q r2,8,r4 add r23,r63,r5 zero_now: al_found_zero: /* We konw that one of the values has at lest one zero, and r8 holds an 0x01 or 0xff mask for every zero found in one of the operands. If both operands have the first zero in the same place, this mask allows us to truncate the comparison to the valid bytes in the strings. If the first zero is in different places, it doesn't matter if some invalid bytes are included, since the comparison of the zero with the non-zero will determine the outcome. */ #ifdef __LITTLE_ENDIAN__ shlli r8,8,r8 addi r8,-1,r9 andc r9,r8,r8 and r8,r4,r4 and r8,r5,r5 #else shlri r8,1,r8 nsb r8,r8 addi r8,8,r8 andi r8,56,r8 sub r63,r8,r8 shlrd r4,r8,r4 shlrd r5,r8,r5 #endif #ifdef __LITTLE_ENDIAN__ byterev r4,r4 byterev r5,r5 #endif cmpgtu r4,r5,r6 cmpgtu r5,r4,r7 sub r6,r7,r2 blink tr2,r63 #else /* ! __SHMEDIA__, i.e. SH 1..4 / SHcompact */ #ifdef __SH5__ #define STR1 r2 #define STR2 r3 #define RESULT r2 #define TMP r4 #else ! Entry: r4: string1 ! r5: string2 ! Exit: r0: result ! r1-r2,r4-r5: clobbered #define STR1 r4 #define STR2 r5 #define RESULT r0 #define TMP r2 #endif /* __SH5__ */ mov STR1,r0 or STR2,r0 tst #3,r0 bf L_setup_char_loop mov #0,r0 #ifdef DELAYED_BRANCHES mov.l @STR1+,r1 .align 2 Longword_loop: mov.l @STR2+,TMP cmp/str r0,r1 bt Longword_loop_end cmp/eq r1,TMP bt.s Longword_loop mov.l @STR1+,r1 add #-4, STR1 Longword_loop_end: add #-4, STR1 add #-4, STR2 L_setup_char_loop: mov.b @STR1+,r0 .align 2 L_char_loop: mov.b @STR2+,r1 tst r0,r0 bt L_return cmp/eq r0,r1 bt.s L_char_loop mov.b @STR1+,r0 add #-2,STR1 mov.b @STR1,r0 #else /* ! DELAYED_BRANCHES */ .align 2 Longword_loop: mov.l @r4+,r1 mov.l @r5+,r2 cmp/str r0,r1 bt Longword_loop_end cmp/eq r1,r2 bt Longword_loop Longword_loop_end: add #-4, r4 add #-4, r5 .align 2 L_setup_char_loop: L_char_loop: mov.b @r4+,r0 mov.b @r5+,r1 tst r0,r0 bt L_return cmp/eq r0,r1 bt L_char_loop #endif L_return: extu.b r0,RESULT extu.b r1,r1 rts sub r1,RESULT #endif /* ! __SHMEDIA__ */
stsp/newlib-ia16
2,524
newlib/libc/machine/sh/strcpy.S
! Entry: arg0: destination ! arg1: source ! Exit: result: destination ! ! SH5 code Copyright 2002 SuperH Ltd. #include "asm.h" ENTRY(strcpy) #if __SHMEDIA__ pta/l shortstring,tr1 ldlo.q r3,0,r4 ptabs r18,tr4 shlli r3,3,r7 addi r2, 8, r0 mcmpeq.b r4,r63,r6 SHHI r6,r7,r6 bnei/u r6,0,tr1 // shortstring pta/l no_lddst, tr2 ori r3,-8,r23 sub r2, r23, r0 sub r3, r2, r21 addi r21, 8, r20 ldx.q r0, r21, r5 pta/l loop, tr0 ori r2,-8,r22 mcmpeq.b r5, r63, r6 bgt/u r22, r23, tr2 // no_lddst // r22 < r23 : Need to do a load from the destination. // r22 == r23 : Doesn't actually need to load from destination, // but still can be handled here. ldlo.q r2, 0, r9 movi -1, r8 SHLO r8, r7, r8 mcmv r4, r8, r9 stlo.q r2, 0, r9 beqi/l r6, 0, tr0 // loop add r5, r63, r4 addi r0, 8, r0 blink tr1, r63 // shortstring no_lddst: // r22 > r23: note that for r22 == r23 the sthi.q would clobber // bytes before the destination region. stlo.q r2, 0, r4 SHHI r4, r7, r4 sthi.q r0, -1, r4 beqi/l r6, 0, tr0 // loop add r5, r63, r4 addi r0, 8, r0 shortstring: #ifndef __LITTLE_ENDIAN__ pta/l shortstring2,tr1 byterev r4,r4 #endif shortstring2: st.b r0,-8,r4 andi r4,0xff,r5 shlri r4,8,r4 addi r0,1,r0 bnei/l r5,0,tr1 blink tr4,r63 // return .balign 8 loop: stlo.q r0, 0, r5 ldx.q r0, r20, r4 addi r0, 16, r0 sthi.q r0, -9, r5 mcmpeq.b r4, r63, r6 bnei/u r6, 0, tr1 // shortstring ldx.q r0, r21, r5 stlo.q r0, -8, r4 sthi.q r0, -1, r4 mcmpeq.b r5, r63, r6 beqi/l r6, 0, tr0 // loop add r5, r63, r4 addi r0, 8, r0 blink tr1, r63 // shortstring #else /* ! __SHMEDIA__, i.e. SH 1..4 / SHcompact */ #ifdef __SH5__ #define DST r2 #define SRC r3 #define TMP r4 #define RESULT R2 ! r0,r1,r3,r4: clobbered #else #define DST r4 #define SRC r5 #define TMP r2 #define RESULT r0 ! r1-r2,r5: clobbered #endif mov DST,r0 or SRC,r0 tst #3,r0 SL(bf, L_setup_char_loop, mov DST,r0) mov.l @SRC+,r1 mov #0,TMP cmp/str TMP,r1 SL(bt, Longword_loop_end, sub SRC,r0) .align 2 Longword_loop: mov.l r1,@(r0,SRC) mov.l @SRC+,r1 cmp/str TMP,r1 bt Longword_loop_end mov.l r1,@(r0,SRC) mov.l @SRC+,r1 cmp/str TMP,r1 bf Longword_loop Longword_loop_end: add #-4,SRC add #3,r0 .align 2 L_char_loop: mov.b @SRC+,r1 L_char_loop_start: tst r1,r1 SL(bf, L_char_loop, mov.b r1,@(r0,SRC)) rts mov DST,RESULT L_setup_char_loop: mov.b @SRC+,r1 bra L_char_loop_start sub SRC,r0 #endif /* ! __SHMEDIA__ */
stsp/newlib-ia16
3,695
newlib/libc/machine/sh/setjmp.S
/* We want to pretend we're in SHmedia mode, even when assembling for SHcompact. */ #if __SH5__ == 32 && ! __SHMEDIA__ # undef __SHMEDIA__ # define __SHMEDIA__ 1 #endif #if __SHMEDIA__ .mode SHmedia #endif #include "asm.h" ENTRY(setjmp) #if __SH5__ ptabs r18, tr0 gettr tr5, r5 gettr tr6, r6 gettr tr7, r7 st.q r2, 0*8, r18 st.q r2, 1*8, r10 st.q r2, 2*8, r11 st.q r2, 3*8, r12 st.q r2, 4*8, r13 st.q r2, 5*8, r14 st.q r2, 6*8, r15 st.q r2, 7*8, r28 st.q r2, 8*8, r29 st.q r2, 9*8, r30 st.q r2, 10*8, r31 st.q r2, 11*8, r32 st.q r2, 12*8, r33 st.q r2, 13*8, r34 st.q r2, 14*8, r35 st.q r2, 15*8, r44 st.q r2, 16*8, r45 st.q r2, 17*8, r46 st.q r2, 18*8, r47 st.q r2, 19*8, r48 st.q r2, 20*8, r49 st.q r2, 21*8, r50 st.q r2, 22*8, r51 st.q r2, 23*8, r52 st.q r2, 24*8, r53 st.q r2, 25*8, r54 st.q r2, 26*8, r55 st.q r2, 27*8, r56 st.q r2, 28*8, r57 st.q r2, 29*8, r58 st.q r2, 30*8, r59 st.q r2, 31*8, r5 st.q r2, 32*8, r6 st.q r2, 33*8, r7 #if ! __SH4_NOFPU__ fst.d r2, 34*8, dr12 fst.d r2, 35*8, dr14 fst.d r2, 36*8, dr36 fst.d r2, 37*8, dr38 fst.d r2, 38*8, dr40 fst.d r2, 39*8, dr42 fst.d r2, 40*8, dr44 fst.d r2, 41*8, dr46 fst.d r2, 42*8, dr48 fst.d r2, 43*8, dr50 fst.d r2, 44*8, dr52 fst.d r2, 45*8, dr54 fst.d r2, 46*8, dr56 fst.d r2, 47*8, dr58 fst.d r2, 48*8, dr60 fst.d r2, 49*8, dr62 #endif movi 0, r2 blink tr0, r63 #else #if defined (__SH2E__) || defined (__SH3E__) || defined(__SH4_SINGLE__) || defined(__SH4__) || defined(__SH4_SINGLE_ONLY__) add #(13*4),r4 #else add #(9*4),r4 #endif sts.l pr,@-r4 #if defined (__SH2E__) || defined (__SH3E__) || defined(__SH4_SINGLE__) || defined(__SH4__) || defined(__SH4_SINGLE_ONLY__) fmov.s fr15,@-r4 ! call saved floating point registers fmov.s fr14,@-r4 fmov.s fr13,@-r4 fmov.s fr12,@-r4 #endif mov.l r15,@-r4 ! call saved integer registers mov.l r14,@-r4 mov.l r13,@-r4 mov.l r12,@-r4 mov.l r11,@-r4 mov.l r10,@-r4 mov.l r9,@-r4 mov.l r8,@-r4 rts mov #0,r0 #endif /* __SH5__ */ ENTRY(longjmp) #if __SH5__ ld.q r2, 0*8, r18 ptabs r18, tr0 ld.q r2, 1*8, r10 ld.q r2, 2*8, r11 ld.q r2, 3*8, r12 ld.q r2, 4*8, r13 ld.q r2, 5*8, r14 ld.q r2, 6*8, r15 ld.q r2, 7*8, r28 ld.q r2, 8*8, r29 ld.q r2, 9*8, r30 ld.q r2, 10*8, r31 ld.q r2, 11*8, r32 ld.q r2, 12*8, r33 ld.q r2, 13*8, r34 ld.q r2, 14*8, r35 ld.q r2, 15*8, r44 ld.q r2, 16*8, r45 ld.q r2, 17*8, r46 ld.q r2, 18*8, r47 ld.q r2, 19*8, r48 ld.q r2, 20*8, r49 ld.q r2, 21*8, r50 ld.q r2, 22*8, r51 ld.q r2, 23*8, r52 ld.q r2, 24*8, r53 ld.q r2, 25*8, r54 ld.q r2, 26*8, r55 ld.q r2, 27*8, r56 ld.q r2, 28*8, r57 ld.q r2, 29*8, r58 ld.q r2, 30*8, r59 ld.q r2, 31*8, r5 ld.q r2, 32*8, r6 ld.q r2, 33*8, r7 ptabs r5, tr5 ptabs r6, tr6 ptabs r7, tr7 #if ! __SH4_NOFPU__ fld.d r2, 34*8, dr12 fld.d r2, 35*8, dr14 fld.d r2, 36*8, dr36 fld.d r2, 37*8, dr38 fld.d r2, 38*8, dr40 fld.d r2, 39*8, dr42 fld.d r2, 40*8, dr44 fld.d r2, 41*8, dr46 fld.d r2, 42*8, dr48 fld.d r2, 43*8, dr50 fld.d r2, 44*8, dr52 fld.d r2, 45*8, dr54 fld.d r2, 46*8, dr56 fld.d r2, 47*8, dr58 fld.d r2, 48*8, dr60 fld.d r2, 49*8, dr62 #endif movi 1, r2 cmvne r3, r3, r2 blink tr0, r63 #else mov.l @r4+,r8 mov.l @r4+,r9 mov.l @r4+,r10 mov.l @r4+,r11 mov.l @r4+,r12 mov.l @r4+,r13 mov.l @r4+,r14 mov.l @r4+,r15 #if defined (__SH2E__) || defined (__SH3E__) || defined(__SH4_SINGLE__) || defined(__SH4__) || defined(__SH4_SINGLE_ONLY__) fmov.s @r4+,fr12 ! call saved floating point registers fmov.s @r4+,fr13 fmov.s @r4+,fr14 fmov.s @r4+,fr15 #endif lds.l @r4+,pr mov r5,r0 tst r0,r0 bf retr4 movt r0 retr4: rts nop #endif /* __SH5__ */
stsp/newlib-ia16
2,327
newlib/libc/machine/bfin/longjmp.S
/* * longjmp for the Blackfin processor * * Copyright (C) 2006 Analog Devices, Inc. * * The authors hereby grant permission to use, copy, modify, distribute, * and license this software and its documentation for any purpose, provided * that existing copyright notices are retained in all copies and that this * notice is included verbatim in any distributions. No written agreement, * license, or royalty fee is required for any of the authorized uses. * Modifications to this software may be copyrighted by their authors * and need not follow the licensing terms described here, provided that * the new terms are clearly indicated on the first page of each file where * they apply. */ #define _ASM #define _SETJMP_H .text; .align 4; .globl _longjmp; .type _longjmp, STT_FUNC; _longjmp: P0 = R0; R0 = [P0 + 0x00]; [--SP] = R0; /* Put P0 on the stack */ P1 = [P0 + 0x04]; P2 = [P0 + 0x08]; P3 = [P0 + 0x0C]; P4 = [P0 + 0x10]; P5 = [P0 + 0x14]; FP = [P0 + 0x18]; R0 = [SP++]; /* Grab P0 from old stack */ SP = [P0 + 0x1C]; /* Update Stack Pointer */ [--SP] = R0; /* Put P0 on new stack */ [--SP] = R1; /* Put VAL arg on new stack */ R0 = [P0 + 0x20]; /* Data Registers */ R1 = [P0 + 0x24]; R2 = [P0 + 0x28]; R3 = [P0 + 0x2C]; R4 = [P0 + 0x30]; R5 = [P0 + 0x34]; R6 = [P0 + 0x38]; R7 = [P0 + 0x3C]; R0 = [P0 + 0x40]; ASTAT = R0; R0 = [P0 + 0x44]; /* Loop Counters */ LC0 = R0; R0 = [P0 + 0x48]; LC1 = R0; R0 = [P0 + 0x4C]; /* Accumulators */ A0.W = R0; R0 = [P0 + 0x50]; A0.X = R0; R0 = [P0 + 0x54]; A1.W = R0; R0 = [P0 + 0x58]; A1.X = R0; R0 = [P0 + 0x5C]; /* Index Registers */ I0 = R0; R0 = [P0 + 0x60]; I1 = R0; R0 = [P0 + 0x64]; I2 = R0; R0 = [P0 + 0x68]; I3 = R0; R0 = [P0 + 0x6C]; /* Modifier Registers */ M0 = R0; R0 = [P0 + 0x70]; M1 = R0; R0 = [P0 + 0x74]; M2 = R0; R0 = [P0 + 0x78]; M3 = R0; R0 = [P0 + 0x7C]; /* Length Registers */ L0 = R0; R0 = [P0 + 0x80]; L1 = R0; R0 = [P0 + 0x84]; L2 = R0; R0 = [P0 + 0x88]; L3 = R0; R0 = [P0 + 0x8C]; /* Base Registers */ B0 = R0; R0 = [P0 + 0x90]; B1 = R0; R0 = [P0 + 0x94]; B2 = R0; R0 = [P0 + 0x98]; B3 = R0; R0 = [P0 + 0x9C]; /* Return Address (PC) */ RETS = R0; R0 = [SP++]; P0 = [SP++]; CC = R0 == 0; IF !CC JUMP 1f; R0 = 1; 1: RTS; .size _longjmp, .-_longjmp;
stsp/newlib-ia16
2,140
newlib/libc/machine/bfin/setjmp.S
/* * setjmp for the Blackfin processor * * Copyright (C) 2006 Analog Devices, Inc. * * The authors hereby grant permission to use, copy, modify, distribute, * and license this software and its documentation for any purpose, provided * that existing copyright notices are retained in all copies and that this * notice is included verbatim in any distributions. No written agreement, * license, or royalty fee is required for any of the authorized uses. * Modifications to this software may be copyrighted by their authors * and need not follow the licensing terms described here, provided that * the new terms are clearly indicated on the first page of each file where * they apply. */ #define _ASM #define _SETJMP_H .text; .align 4; .globl _setjmp; .type _setjmp, STT_FUNC; _setjmp: [--SP] = P0; /* Save P0 */ P0 = R0; R0 = [SP++]; [P0 + 0x00] = R0; /* Save saved P0 */ [P0 + 0x04] = P1; [P0 + 0x08] = P2; [P0 + 0x0C] = P3; [P0 + 0x10] = P4; [P0 + 0x14] = P5; [P0 + 0x18] = FP; /* Frame Pointer */ [P0 + 0x1C] = SP; /* Stack Pointer */ [P0 + 0x20] = P0; /* Data Registers */ [P0 + 0x24] = R1; [P0 + 0x28] = R2; [P0 + 0x2C] = R3; [P0 + 0x30] = R4; [P0 + 0x34] = R5; [P0 + 0x38] = R6; [P0 + 0x3C] = R7; R0 = ASTAT; [P0 + 0x40] = R0; R0 = LC0; /* Loop Counters */ [P0 + 0x44] = R0; R0 = LC1; [P0 + 0x48] = R0; R0 = A0.W; /* Accumulators */ [P0 + 0x4C] = R0; R0 = A0.X; [P0 + 0x50] = R0; R0 = A1.W; [P0 + 0x54] = R0; R0 = A1.X; [P0 + 0x58] = R0; R0 = I0; /* Index Registers */ [P0 + 0x5C] = R0; R0 = I1; [P0 + 0x60] = R0; R0 = I2; [P0 + 0x64] = R0; R0 = I3; [P0 + 0x68] = R0; R0 = M0; /* Modifier Registers */ [P0 + 0x6C] = R0; R0 = M1; [P0 + 0x70] = R0; R0 = M2; [P0 + 0x74] = R0; R0 = M3; [P0 + 0x78] = R0; R0 = L0; /* Length Registers */ [P0 + 0x7c] = R0; R0 = L1; [P0 + 0x80] = R0; R0 = L2; [P0 + 0x84] = R0; R0 = L3; [P0 + 0x88] = R0; R0 = B0; /* Base Registers */ [P0 + 0x8C] = R0; R0 = B1; [P0 + 0x90] = R0; R0 = B2; [P0 + 0x94] = R0; R0 = B3; [P0 + 0x98] = R0; R0 = RETS; [P0 + 0x9C] = R0; R0 = 0; RTS; .size _setjmp, .-_setjmp;
stsp/newlib-ia16
13,649
newlib/libc/machine/mips/memset.S
/* * Copyright (c) 2013 * MIPS Technologies, Inc., California. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the MIPS Technologies, Inc., nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE MIPS TECHNOLOGIES, INC. ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE MIPS TECHNOLOGIES, INC. BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #ifdef ANDROID_CHANGES # include "machine/asm.h" # include "machine/regdef.h" # define PREFETCH_STORE_HINT PREFETCH_HINT_PREPAREFORSTORE #elif _LIBC # include <sysdep.h> # include <regdef.h> # include <sys/asm.h> # define PREFETCH_STORE_HINT PREFETCH_HINT_PREPAREFORSTORE #elif _COMPILING_NEWLIB # include "machine/asm.h" # include "machine/regdef.h" # define PREFETCH_STORE_HINT PREFETCH_HINT_PREPAREFORSTORE #else # include <regdef.h> # include <sys/asm.h> #endif /* Check to see if the MIPS architecture we are compiling for supports prefetching. */ #if (__mips == 4) || (__mips == 5) || (__mips == 32) || (__mips == 64) # ifndef DISABLE_PREFETCH # define USE_PREFETCH # endif #endif #if defined(_MIPS_SIM) && ((_MIPS_SIM == _ABI64) || (_MIPS_SIM == _ABIN32)) # ifndef DISABLE_DOUBLE # define USE_DOUBLE # endif #endif #ifndef USE_DOUBLE # ifndef DISABLE_DOUBLE_ALIGN # define DOUBLE_ALIGN # endif #endif /* Some asm.h files do not have the L macro definition. */ #ifndef L # if _MIPS_SIM == _ABIO32 # define L(label) $L ## label # else # define L(label) .L ## label # endif #endif /* Some asm.h files do not have the PTR_ADDIU macro definition. */ #ifndef PTR_ADDIU # ifdef USE_DOUBLE # define PTR_ADDIU daddiu # else # define PTR_ADDIU addiu # endif #endif /* New R6 instructions that may not be in asm.h. */ #ifndef PTR_LSA # if _MIPS_SIM == _ABI64 # define PTR_LSA dlsa # else # define PTR_LSA lsa # endif #endif /* Using PREFETCH_HINT_PREPAREFORSTORE instead of PREFETCH_STORE or PREFETCH_STORE_STREAMED offers a large performance advantage but PREPAREFORSTORE has some special restrictions to consider. Prefetch with the 'prepare for store' hint does not copy a memory location into the cache, it just allocates a cache line and zeros it out. This means that if you do not write to the entire cache line before writing it out to memory some data will get zero'ed out when the cache line is written back to memory and data will be lost. There are ifdef'ed sections of this memcpy to make sure that it does not do prefetches on cache lines that are not going to be completely written. This code is only needed and only used when PREFETCH_STORE_HINT is set to PREFETCH_HINT_PREPAREFORSTORE. This code assumes that cache lines are less than MAX_PREFETCH_SIZE bytes and if the cache line is larger it will not work correctly. */ #ifdef USE_PREFETCH # define PREFETCH_HINT_STORE 1 # define PREFETCH_HINT_STORE_STREAMED 5 # define PREFETCH_HINT_STORE_RETAINED 7 # define PREFETCH_HINT_PREPAREFORSTORE 30 /* If we have not picked out what hints to use at this point use the standard load and store prefetch hints. */ # ifndef PREFETCH_STORE_HINT # define PREFETCH_STORE_HINT PREFETCH_HINT_STORE # endif /* We double everything when USE_DOUBLE is true so we do 2 prefetches to get 64 bytes in that case. The assumption is that each individual prefetch brings in 32 bytes. */ # ifdef USE_DOUBLE # define PREFETCH_CHUNK 64 # define PREFETCH_FOR_STORE(chunk, reg) \ pref PREFETCH_STORE_HINT, (chunk)*64(reg); \ pref PREFETCH_STORE_HINT, ((chunk)*64)+32(reg) # else # define PREFETCH_CHUNK 32 # define PREFETCH_FOR_STORE(chunk, reg) \ pref PREFETCH_STORE_HINT, (chunk)*32(reg) # endif /* MAX_PREFETCH_SIZE is the maximum size of a prefetch, it must not be less than PREFETCH_CHUNK, the assumed size of each prefetch. If the real size of a prefetch is greater than MAX_PREFETCH_SIZE and the PREPAREFORSTORE hint is used, the code will not work correctly. If PREPAREFORSTORE is not used than MAX_PREFETCH_SIZE does not matter. */ # define MAX_PREFETCH_SIZE 128 /* PREFETCH_LIMIT is set based on the fact that we never use an offset greater than 5 on a STORE prefetch and that a single prefetch can never be larger than MAX_PREFETCH_SIZE. We add the extra 32 when USE_DOUBLE is set because we actually do two prefetches in that case, one 32 bytes after the other. */ # ifdef USE_DOUBLE # define PREFETCH_LIMIT (5 * PREFETCH_CHUNK) + 32 + MAX_PREFETCH_SIZE # else # define PREFETCH_LIMIT (5 * PREFETCH_CHUNK) + MAX_PREFETCH_SIZE # endif # if (PREFETCH_STORE_HINT == PREFETCH_HINT_PREPAREFORSTORE) \ && ((PREFETCH_CHUNK * 4) < MAX_PREFETCH_SIZE) /* We cannot handle this because the initial prefetches may fetch bytes that are before the buffer being copied. We start copies with an offset of 4 so avoid this situation when using PREPAREFORSTORE. */ # error "PREFETCH_CHUNK is too large and/or MAX_PREFETCH_SIZE is too small." # endif #else /* USE_PREFETCH not defined */ # define PREFETCH_FOR_STORE(offset, reg) #endif #if __mips_isa_rev > 5 # if (PREFETCH_STORE_HINT == PREFETCH_HINT_PREPAREFORSTORE) # undef PREFETCH_STORE_HINT # define PREFETCH_STORE_HINT PREFETCH_HINT_STORE_STREAMED # endif # define R6_CODE #endif /* Allow the routine to be named something else if desired. */ #ifndef MEMSET_NAME # define MEMSET_NAME memset #endif /* We load/store 64 bits at a time when USE_DOUBLE is true. The C_ prefix stands for CHUNK and is used to avoid macro name conflicts with system header files. */ #ifdef USE_DOUBLE # define C_ST sd # if __MIPSEB # define C_STHI sdl /* high part is left in big-endian */ # else # define C_STHI sdr /* high part is right in little-endian */ # endif #else # define C_ST sw # if __MIPSEB # define C_STHI swl /* high part is left in big-endian */ # else # define C_STHI swr /* high part is right in little-endian */ # endif #endif /* Bookkeeping values for 32 vs. 64 bit mode. */ #ifdef USE_DOUBLE # define NSIZE 8 # define NSIZEMASK 0x3f # define NSIZEDMASK 0x7f #else # define NSIZE 4 # define NSIZEMASK 0x1f # define NSIZEDMASK 0x3f #endif #define UNIT(unit) ((unit)*NSIZE) #define UNITM1(unit) (((unit)*NSIZE)-1) #ifdef ANDROID_CHANGES LEAF(MEMSET_NAME,0) #else LEAF(MEMSET_NAME) #endif .set nomips16 .set noreorder /* If the size is less than 2*NSIZE (8 or 16), go to L(lastb). Regardless of size, copy dst pointer to v0 for the return value. */ slti t2,a2,(2 * NSIZE) bne t2,zero,L(lastb) move v0,a0 /* If memset value is not zero, we copy it to all the bytes in a 32 or 64 bit word. */ beq a1,zero,L(set0) /* If memset value is zero no smear */ PTR_SUBU a3,zero,a0 nop /* smear byte into 32 or 64 bit word */ #if ((__mips == 64) || (__mips == 32)) && (__mips_isa_rev >= 2) # ifdef USE_DOUBLE dins a1, a1, 8, 8 /* Replicate fill byte into half-word. */ dins a1, a1, 16, 16 /* Replicate fill byte into word. */ dins a1, a1, 32, 32 /* Replicate fill byte into dbl word. */ # else ins a1, a1, 8, 8 /* Replicate fill byte into half-word. */ ins a1, a1, 16, 16 /* Replicate fill byte into word. */ # endif #else # ifdef USE_DOUBLE and a1,0xff dsll t2,a1,8 or a1,t2 dsll t2,a1,16 or a1,t2 dsll t2,a1,32 or a1,t2 # else and a1,0xff sll t2,a1,8 or a1,t2 sll t2,a1,16 or a1,t2 # endif #endif /* If the destination address is not aligned do a partial store to get it aligned. If it is already aligned just jump to L(aligned). */ L(set0): #ifndef R6_CODE andi t2,a3,(NSIZE-1) /* word-unaligned address? */ beq t2,zero,L(aligned) /* t2 is the unalignment count */ PTR_SUBU a2,a2,t2 C_STHI a1,0(a0) PTR_ADDU a0,a0,t2 #else /* R6_CODE */ andi t2,a0,(NSIZE-1) lapc t9,L(atable) PTR_LSA t9,t2,t9,2 jrc t9 L(atable): bc L(aligned) # ifdef USE_DOUBLE bc L(lb7) bc L(lb6) bc L(lb5) bc L(lb4) # endif bc L(lb3) bc L(lb2) bc L(lb1) L(lb7): sb a1,6(a0) L(lb6): sb a1,5(a0) L(lb5): sb a1,4(a0) L(lb4): sb a1,3(a0) L(lb3): sb a1,2(a0) L(lb2): sb a1,1(a0) L(lb1): sb a1,0(a0) li t9,NSIZE subu t2,t9,t2 PTR_SUBU a2,a2,t2 PTR_ADDU a0,a0,t2 #endif /* R6_CODE */ L(aligned): /* If USE_DOUBLE is not set we may still want to align the data on a 16 byte boundry instead of an 8 byte boundry to maximize the opportunity of proAptiv chips to do memory bonding (combining two sequential 4 byte stores into one 8 byte store). We know there are at least 4 bytes left to store or we would have jumped to L(lastb) earlier in the code. */ #ifdef DOUBLE_ALIGN andi t2,a3,4 beq t2,zero,L(double_aligned) PTR_SUBU a2,a2,t2 sw a1,0(a0) PTR_ADDU a0,a0,t2 L(double_aligned): #endif /* Now the destination is aligned to (word or double word) aligned address Set a2 to count how many bytes we have to copy after all the 64/128 byte chunks are copied and a3 to the dest pointer after all the 64/128 byte chunks have been copied. We will loop, incrementing a0 until it equals a3. */ andi t8,a2,NSIZEDMASK /* any whole 64-byte/128-byte chunks? */ beq a2,t8,L(chkw) /* if a2==t8, no 64-byte/128-byte chunks */ PTR_SUBU a3,a2,t8 /* subtract from a2 the reminder */ PTR_ADDU a3,a0,a3 /* Now a3 is the final dst after loop */ /* When in the loop we may prefetch with the 'prepare to store' hint, in this case the a0+x should not be past the "t0-32" address. This means: for x=128 the last "safe" a0 address is "t0-160". Alternatively, for x=64 the last "safe" a0 address is "t0-96" In the current version we will use "prefetch hint,128(a0)", so "t0-160" is the limit. */ #if defined(USE_PREFETCH) \ && (PREFETCH_STORE_HINT == PREFETCH_HINT_PREPAREFORSTORE) PTR_ADDU t0,a0,a2 /* t0 is the "past the end" address */ PTR_SUBU t9,t0,PREFETCH_LIMIT /* t9 is the "last safe pref" address */ #endif #if defined(USE_PREFETCH) \ && (PREFETCH_STORE_HINT != PREFETCH_HINT_PREPAREFORSTORE) PREFETCH_FOR_STORE (1, a0) PREFETCH_FOR_STORE (2, a0) PREFETCH_FOR_STORE (3, a0) #endif L(loop16w): #if defined(USE_PREFETCH) \ && (PREFETCH_STORE_HINT == PREFETCH_HINT_PREPAREFORSTORE) sltu v1,t9,a0 /* If a0 > t9 don't use next prefetch */ bgtz v1,L(skip_pref) nop #endif #ifndef R6_CODE PREFETCH_FOR_STORE (4, a0) PREFETCH_FOR_STORE (5, a0) #else PREFETCH_FOR_STORE (2, a0) #endif L(skip_pref): C_ST a1,UNIT(0)(a0) C_ST a1,UNIT(1)(a0) C_ST a1,UNIT(2)(a0) C_ST a1,UNIT(3)(a0) C_ST a1,UNIT(4)(a0) C_ST a1,UNIT(5)(a0) C_ST a1,UNIT(6)(a0) C_ST a1,UNIT(7)(a0) C_ST a1,UNIT(8)(a0) C_ST a1,UNIT(9)(a0) C_ST a1,UNIT(10)(a0) C_ST a1,UNIT(11)(a0) C_ST a1,UNIT(12)(a0) C_ST a1,UNIT(13)(a0) C_ST a1,UNIT(14)(a0) C_ST a1,UNIT(15)(a0) PTR_ADDIU a0,a0,UNIT(16) /* adding 64/128 to dest */ bne a0,a3,L(loop16w) nop move a2,t8 /* Here we have dest word-aligned but less than 64-bytes or 128 bytes to go. Check for a 32(64) byte chunk and copy if if there is one. Otherwise jump down to L(chk1w) to handle the tail end of the copy. */ L(chkw): andi t8,a2,NSIZEMASK /* is there a 32-byte/64-byte chunk. */ /* the t8 is the reminder count past 32-bytes */ beq a2,t8,L(chk1w)/* when a2==t8, no 32-byte chunk */ nop C_ST a1,UNIT(0)(a0) C_ST a1,UNIT(1)(a0) C_ST a1,UNIT(2)(a0) C_ST a1,UNIT(3)(a0) C_ST a1,UNIT(4)(a0) C_ST a1,UNIT(5)(a0) C_ST a1,UNIT(6)(a0) C_ST a1,UNIT(7)(a0) PTR_ADDIU a0,a0,UNIT(8) /* Here we have less than 32(64) bytes to set. Set up for a loop to copy one word (or double word) at a time. Set a2 to count how many bytes we have to copy after all the word (or double word) chunks are copied and a3 to the dest pointer after all the (d)word chunks have been copied. We will loop, incrementing a0 until a0 equals a3. */ L(chk1w): andi a2,t8,(NSIZE-1) /* a2 is the reminder past one (d)word chunks */ beq a2,t8,L(lastb) PTR_SUBU a3,t8,a2 /* a3 is count of bytes in one (d)word chunks */ PTR_ADDU a3,a0,a3 /* a3 is the dst address after loop */ /* copying in words (4-byte or 8 byte chunks) */ L(wordCopy_loop): PTR_ADDIU a0,a0,UNIT(1) bne a0,a3,L(wordCopy_loop) C_ST a1,UNIT(-1)(a0) /* Copy the last 8 (or 16) bytes */ L(lastb): blez a2,L(leave) PTR_ADDU a3,a0,a2 /* a3 is the last dst address */ L(lastbloop): PTR_ADDIU a0,a0,1 bne a0,a3,L(lastbloop) sb a1,-1(a0) L(leave): j ra nop .set at .set reorder END(MEMSET_NAME) #ifndef ANDROID_CHANGES # ifdef _LIBC libc_hidden_builtin_def (MEMSET_NAME) # endif #endif
stsp/newlib-ia16
26,292
newlib/libc/machine/mips/memcpy.S
/* * Copyright (c) 2012-2015 * MIPS Technologies, Inc., California. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the MIPS Technologies, Inc., nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE MIPS TECHNOLOGIES, INC. ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE MIPS TECHNOLOGIES, INC. BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #ifdef ANDROID_CHANGES # include "machine/asm.h" # include "machine/regdef.h" # define USE_MEMMOVE_FOR_OVERLAP # define PREFETCH_LOAD_HINT PREFETCH_HINT_LOAD_STREAMED # define PREFETCH_STORE_HINT PREFETCH_HINT_PREPAREFORSTORE #elif _LIBC # include <sysdep.h> # include <regdef.h> # include <sys/asm.h> # define PREFETCH_LOAD_HINT PREFETCH_HINT_LOAD_STREAMED # define PREFETCH_STORE_HINT PREFETCH_HINT_PREPAREFORSTORE #elif _COMPILING_NEWLIB # include "machine/asm.h" # include "machine/regdef.h" # define PREFETCH_LOAD_HINT PREFETCH_HINT_LOAD_STREAMED # define PREFETCH_STORE_HINT PREFETCH_HINT_PREPAREFORSTORE #else # include <regdef.h> # include <sys/asm.h> #endif /* Check to see if the MIPS architecture we are compiling for supports * prefetching. */ #if (__mips == 4) || (__mips == 5) || (__mips == 32) || (__mips == 64) # ifndef DISABLE_PREFETCH # define USE_PREFETCH # endif #endif #if defined(_MIPS_SIM) && ((_MIPS_SIM == _ABI64) || (_MIPS_SIM == _ABIN32)) # ifndef DISABLE_DOUBLE # define USE_DOUBLE # endif #endif #if __mips_isa_rev > 5 # if (PREFETCH_STORE_HINT == PREFETCH_HINT_PREPAREFORSTORE) # undef PREFETCH_STORE_HINT # define PREFETCH_STORE_HINT PREFETCH_HINT_STORE_STREAMED # endif # define R6_CODE #endif /* Some asm.h files do not have the L macro definition. */ #ifndef L # if _MIPS_SIM == _ABIO32 # define L(label) $L ## label # else # define L(label) .L ## label # endif #endif /* Some asm.h files do not have the PTR_ADDIU macro definition. */ #ifndef PTR_ADDIU # ifdef USE_DOUBLE # define PTR_ADDIU daddiu # else # define PTR_ADDIU addiu # endif #endif /* Some asm.h files do not have the PTR_SRA macro definition. */ #ifndef PTR_SRA # ifdef USE_DOUBLE # define PTR_SRA dsra # else # define PTR_SRA sra # endif #endif /* New R6 instructions that may not be in asm.h. */ #ifndef PTR_LSA # if _MIPS_SIM == _ABI64 # define PTR_LSA dlsa # else # define PTR_LSA lsa # endif #endif /* * Using PREFETCH_HINT_LOAD_STREAMED instead of PREFETCH_LOAD on load * prefetches appears to offer a slight preformance advantage. * * Using PREFETCH_HINT_PREPAREFORSTORE instead of PREFETCH_STORE * or PREFETCH_STORE_STREAMED offers a large performance advantage * but PREPAREFORSTORE has some special restrictions to consider. * * Prefetch with the 'prepare for store' hint does not copy a memory * location into the cache, it just allocates a cache line and zeros * it out. This means that if you do not write to the entire cache * line before writing it out to memory some data will get zero'ed out * when the cache line is written back to memory and data will be lost. * * Also if you are using this memcpy to copy overlapping buffers it may * not behave correctly when using the 'prepare for store' hint. If you * use the 'prepare for store' prefetch on a memory area that is in the * memcpy source (as well as the memcpy destination), then you will get * some data zero'ed out before you have a chance to read it and data will * be lost. * * If you are going to use this memcpy routine with the 'prepare for store' * prefetch you may want to set USE_MEMMOVE_FOR_OVERLAP in order to avoid * the problem of running memcpy on overlapping buffers. * * There are ifdef'ed sections of this memcpy to make sure that it does not * do prefetches on cache lines that are not going to be completely written. * This code is only needed and only used when PREFETCH_STORE_HINT is set to * PREFETCH_HINT_PREPAREFORSTORE. This code assumes that cache lines are * 32 bytes and if the cache line is larger it will not work correctly. */ #ifdef USE_PREFETCH # define PREFETCH_HINT_LOAD 0 # define PREFETCH_HINT_STORE 1 # define PREFETCH_HINT_LOAD_STREAMED 4 # define PREFETCH_HINT_STORE_STREAMED 5 # define PREFETCH_HINT_LOAD_RETAINED 6 # define PREFETCH_HINT_STORE_RETAINED 7 # define PREFETCH_HINT_WRITEBACK_INVAL 25 # define PREFETCH_HINT_PREPAREFORSTORE 30 /* * If we have not picked out what hints to use at this point use the * standard load and store prefetch hints. */ # ifndef PREFETCH_STORE_HINT # define PREFETCH_STORE_HINT PREFETCH_HINT_STORE # endif # ifndef PREFETCH_LOAD_HINT # define PREFETCH_LOAD_HINT PREFETCH_HINT_LOAD # endif /* * We double everything when USE_DOUBLE is true so we do 2 prefetches to * get 64 bytes in that case. The assumption is that each individual * prefetch brings in 32 bytes. */ # ifdef USE_DOUBLE # define PREFETCH_CHUNK 64 # define PREFETCH_FOR_LOAD(chunk, reg) \ pref PREFETCH_LOAD_HINT, (chunk)*64(reg); \ pref PREFETCH_LOAD_HINT, ((chunk)*64)+32(reg) # define PREFETCH_FOR_STORE(chunk, reg) \ pref PREFETCH_STORE_HINT, (chunk)*64(reg); \ pref PREFETCH_STORE_HINT, ((chunk)*64)+32(reg) # else # define PREFETCH_CHUNK 32 # define PREFETCH_FOR_LOAD(chunk, reg) \ pref PREFETCH_LOAD_HINT, (chunk)*32(reg) # define PREFETCH_FOR_STORE(chunk, reg) \ pref PREFETCH_STORE_HINT, (chunk)*32(reg) # endif /* MAX_PREFETCH_SIZE is the maximum size of a prefetch, it must not be less * than PREFETCH_CHUNK, the assumed size of each prefetch. If the real size * of a prefetch is greater than MAX_PREFETCH_SIZE and the PREPAREFORSTORE * hint is used, the code will not work correctly. If PREPAREFORSTORE is not * used then MAX_PREFETCH_SIZE does not matter. */ # define MAX_PREFETCH_SIZE 128 /* PREFETCH_LIMIT is set based on the fact that we never use an offset greater * than 5 on a STORE prefetch and that a single prefetch can never be larger * than MAX_PREFETCH_SIZE. We add the extra 32 when USE_DOUBLE is set because * we actually do two prefetches in that case, one 32 bytes after the other. */ # ifdef USE_DOUBLE # define PREFETCH_LIMIT (5 * PREFETCH_CHUNK) + 32 + MAX_PREFETCH_SIZE # else # define PREFETCH_LIMIT (5 * PREFETCH_CHUNK) + MAX_PREFETCH_SIZE # endif # if (PREFETCH_STORE_HINT == PREFETCH_HINT_PREPAREFORSTORE) \ && ((PREFETCH_CHUNK * 4) < MAX_PREFETCH_SIZE) /* We cannot handle this because the initial prefetches may fetch bytes that * are before the buffer being copied. We start copies with an offset * of 4 so avoid this situation when using PREPAREFORSTORE. */ #error "PREFETCH_CHUNK is too large and/or MAX_PREFETCH_SIZE is too small." # endif #else /* USE_PREFETCH not defined */ # define PREFETCH_FOR_LOAD(offset, reg) # define PREFETCH_FOR_STORE(offset, reg) #endif /* Allow the routine to be named something else if desired. */ #ifndef MEMCPY_NAME # define MEMCPY_NAME memcpy #endif /* We use these 32/64 bit registers as temporaries to do the copying. */ #define REG0 t0 #define REG1 t1 #define REG2 t2 #define REG3 t3 #if defined(_MIPS_SIM) && (_MIPS_SIM == _ABIO32 || _MIPS_SIM == _ABIO64) # define REG4 t4 # define REG5 t5 # define REG6 t6 # define REG7 t7 #else # define REG4 ta0 # define REG5 ta1 # define REG6 ta2 # define REG7 ta3 #endif /* We load/store 64 bits at a time when USE_DOUBLE is true. * The C_ prefix stands for CHUNK and is used to avoid macro name * conflicts with system header files. */ #ifdef USE_DOUBLE # define C_ST sd # define C_LD ld # if __MIPSEB # define C_LDHI ldl /* high part is left in big-endian */ # define C_STHI sdl /* high part is left in big-endian */ # define C_LDLO ldr /* low part is right in big-endian */ # define C_STLO sdr /* low part is right in big-endian */ # else # define C_LDHI ldr /* high part is right in little-endian */ # define C_STHI sdr /* high part is right in little-endian */ # define C_LDLO ldl /* low part is left in little-endian */ # define C_STLO sdl /* low part is left in little-endian */ # endif # define C_ALIGN dalign /* r6 align instruction */ #else # define C_ST sw # define C_LD lw # if __MIPSEB # define C_LDHI lwl /* high part is left in big-endian */ # define C_STHI swl /* high part is left in big-endian */ # define C_LDLO lwr /* low part is right in big-endian */ # define C_STLO swr /* low part is right in big-endian */ # else # define C_LDHI lwr /* high part is right in little-endian */ # define C_STHI swr /* high part is right in little-endian */ # define C_LDLO lwl /* low part is left in little-endian */ # define C_STLO swl /* low part is left in little-endian */ # endif # define C_ALIGN align /* r6 align instruction */ #endif /* Bookkeeping values for 32 vs. 64 bit mode. */ #ifdef USE_DOUBLE # define NSIZE 8 # define NSIZEMASK 0x3f # define NSIZEDMASK 0x7f #else # define NSIZE 4 # define NSIZEMASK 0x1f # define NSIZEDMASK 0x3f #endif #define UNIT(unit) ((unit)*NSIZE) #define UNITM1(unit) (((unit)*NSIZE)-1) #ifdef ANDROID_CHANGES LEAF(MEMCPY_NAME, 0) #else LEAF(MEMCPY_NAME) #endif .set nomips16 .set noreorder /* * Below we handle the case where memcpy is called with overlapping src and dst. * Although memcpy is not required to handle this case, some parts of Android * like Skia rely on such usage. We call memmove to handle such cases. */ #ifdef USE_MEMMOVE_FOR_OVERLAP PTR_SUBU t0,a0,a1 PTR_SRA t2,t0,31 xor t1,t0,t2 PTR_SUBU t0,t1,t2 sltu t2,t0,a2 beq t2,zero,L(memcpy) la t9,memmove jr t9 nop L(memcpy): #endif /* * If the size is less than 2*NSIZE (8 or 16), go to L(lastb). Regardless of * size, copy dst pointer to v0 for the return value. */ slti t2,a2,(2 * NSIZE) bne t2,zero,L(lasts) #if defined(RETURN_FIRST_PREFETCH) || defined(RETURN_LAST_PREFETCH) move v0,zero #else move v0,a0 #endif #ifndef R6_CODE /* * If src and dst have different alignments, go to L(unaligned), if they * have the same alignment (but are not actually aligned) do a partial * load/store to make them aligned. If they are both already aligned * we can start copying at L(aligned). */ xor t8,a1,a0 andi t8,t8,(NSIZE-1) /* t8 is a0/a1 word-displacement */ bne t8,zero,L(unaligned) PTR_SUBU a3, zero, a0 andi a3,a3,(NSIZE-1) /* copy a3 bytes to align a0/a1 */ beq a3,zero,L(aligned) /* if a3=0, it is already aligned */ PTR_SUBU a2,a2,a3 /* a2 is the remining bytes count */ C_LDHI t8,0(a1) PTR_ADDU a1,a1,a3 C_STHI t8,0(a0) PTR_ADDU a0,a0,a3 #else /* R6_CODE */ /* * Align the destination and hope that the source gets aligned too. If it * doesn't we jump to L(r6_unaligned*) to do unaligned copies using the r6 * align instruction. */ andi t8,a0,7 lapc t9,L(atable) PTR_LSA t9,t8,t9,2 jrc t9 L(atable): bc L(lb0) bc L(lb7) bc L(lb6) bc L(lb5) bc L(lb4) bc L(lb3) bc L(lb2) bc L(lb1) L(lb7): lb a3, 6(a1) sb a3, 6(a0) L(lb6): lb a3, 5(a1) sb a3, 5(a0) L(lb5): lb a3, 4(a1) sb a3, 4(a0) L(lb4): lb a3, 3(a1) sb a3, 3(a0) L(lb3): lb a3, 2(a1) sb a3, 2(a0) L(lb2): lb a3, 1(a1) sb a3, 1(a0) L(lb1): lb a3, 0(a1) sb a3, 0(a0) li t9,8 subu t8,t9,t8 PTR_SUBU a2,a2,t8 PTR_ADDU a0,a0,t8 PTR_ADDU a1,a1,t8 L(lb0): andi t8,a1,(NSIZE-1) lapc t9,L(jtable) PTR_LSA t9,t8,t9,2 jrc t9 L(jtable): bc L(aligned) bc L(r6_unaligned1) bc L(r6_unaligned2) bc L(r6_unaligned3) # ifdef USE_DOUBLE bc L(r6_unaligned4) bc L(r6_unaligned5) bc L(r6_unaligned6) bc L(r6_unaligned7) # endif #endif /* R6_CODE */ L(aligned): /* * Now dst/src are both aligned to (word or double word) aligned addresses * Set a2 to count how many bytes we have to copy after all the 64/128 byte * chunks are copied and a3 to the dst pointer after all the 64/128 byte * chunks have been copied. We will loop, incrementing a0 and a1 until a0 * equals a3. */ andi t8,a2,NSIZEDMASK /* any whole 64-byte/128-byte chunks? */ beq a2,t8,L(chkw) /* if a2==t8, no 64-byte/128-byte chunks */ PTR_SUBU a3,a2,t8 /* subtract from a2 the reminder */ PTR_ADDU a3,a0,a3 /* Now a3 is the final dst after loop */ /* When in the loop we may prefetch with the 'prepare to store' hint, * in this case the a0+x should not be past the "t0-32" address. This * means: for x=128 the last "safe" a0 address is "t0-160". Alternatively, * for x=64 the last "safe" a0 address is "t0-96" In the current version we * will use "prefetch hint,128(a0)", so "t0-160" is the limit. */ #if defined(USE_PREFETCH) && (PREFETCH_STORE_HINT == PREFETCH_HINT_PREPAREFORSTORE) PTR_ADDU t0,a0,a2 /* t0 is the "past the end" address */ PTR_SUBU t9,t0,PREFETCH_LIMIT /* t9 is the "last safe pref" address */ #endif PREFETCH_FOR_LOAD (0, a1) PREFETCH_FOR_LOAD (1, a1) PREFETCH_FOR_LOAD (2, a1) PREFETCH_FOR_LOAD (3, a1) #if defined(USE_PREFETCH) && (PREFETCH_STORE_HINT != PREFETCH_HINT_PREPAREFORSTORE) PREFETCH_FOR_STORE (1, a0) PREFETCH_FOR_STORE (2, a0) PREFETCH_FOR_STORE (3, a0) #endif #if defined(RETURN_FIRST_PREFETCH) && defined(USE_PREFETCH) # if PREFETCH_STORE_HINT == PREFETCH_HINT_PREPAREFORSTORE sltu v1,t9,a0 bgtz v1,L(skip_set) nop PTR_ADDIU v0,a0,(PREFETCH_CHUNK*4) L(skip_set): # else PTR_ADDIU v0,a0,(PREFETCH_CHUNK*1) # endif #endif #if defined(RETURN_LAST_PREFETCH) && defined(USE_PREFETCH) \ && (PREFETCH_STORE_HINT != PREFETCH_HINT_PREPAREFORSTORE) PTR_ADDIU v0,a0,(PREFETCH_CHUNK*3) # ifdef USE_DOUBLE PTR_ADDIU v0,v0,32 # endif #endif L(loop16w): C_LD t0,UNIT(0)(a1) #if defined(USE_PREFETCH) && (PREFETCH_STORE_HINT == PREFETCH_HINT_PREPAREFORSTORE) sltu v1,t9,a0 /* If a0 > t9 don't use next prefetch */ bgtz v1,L(skip_pref) #endif C_LD t1,UNIT(1)(a1) #ifndef R6_CODE PREFETCH_FOR_STORE (4, a0) PREFETCH_FOR_STORE (5, a0) #else PREFETCH_FOR_STORE (2, a0) #endif #if defined(RETURN_LAST_PREFETCH) && defined(USE_PREFETCH) PTR_ADDIU v0,a0,(PREFETCH_CHUNK*5) # ifdef USE_DOUBLE PTR_ADDIU v0,v0,32 # endif #endif L(skip_pref): C_LD REG2,UNIT(2)(a1) C_LD REG3,UNIT(3)(a1) C_LD REG4,UNIT(4)(a1) C_LD REG5,UNIT(5)(a1) C_LD REG6,UNIT(6)(a1) C_LD REG7,UNIT(7)(a1) #ifndef R6_CODE PREFETCH_FOR_LOAD (4, a1) #else PREFETCH_FOR_LOAD (3, a1) #endif C_ST t0,UNIT(0)(a0) C_ST t1,UNIT(1)(a0) C_ST REG2,UNIT(2)(a0) C_ST REG3,UNIT(3)(a0) C_ST REG4,UNIT(4)(a0) C_ST REG5,UNIT(5)(a0) C_ST REG6,UNIT(6)(a0) C_ST REG7,UNIT(7)(a0) C_LD t0,UNIT(8)(a1) C_LD t1,UNIT(9)(a1) C_LD REG2,UNIT(10)(a1) C_LD REG3,UNIT(11)(a1) C_LD REG4,UNIT(12)(a1) C_LD REG5,UNIT(13)(a1) C_LD REG6,UNIT(14)(a1) C_LD REG7,UNIT(15)(a1) #ifndef R6_CODE PREFETCH_FOR_LOAD (5, a1) #endif C_ST t0,UNIT(8)(a0) C_ST t1,UNIT(9)(a0) C_ST REG2,UNIT(10)(a0) C_ST REG3,UNIT(11)(a0) C_ST REG4,UNIT(12)(a0) C_ST REG5,UNIT(13)(a0) C_ST REG6,UNIT(14)(a0) C_ST REG7,UNIT(15)(a0) PTR_ADDIU a0,a0,UNIT(16) /* adding 64/128 to dest */ bne a0,a3,L(loop16w) PTR_ADDIU a1,a1,UNIT(16) /* adding 64/128 to src */ move a2,t8 /* Here we have src and dest word-aligned but less than 64-bytes or * 128 bytes to go. Check for a 32(64) byte chunk and copy if if there * is one. Otherwise jump down to L(chk1w) to handle the tail end of * the copy. */ L(chkw): PREFETCH_FOR_LOAD (0, a1) andi t8,a2,NSIZEMASK /* Is there a 32-byte/64-byte chunk. */ /* The t8 is the reminder count past 32-bytes */ beq a2,t8,L(chk1w) /* When a2=t8, no 32-byte chunk */ nop C_LD t0,UNIT(0)(a1) C_LD t1,UNIT(1)(a1) C_LD REG2,UNIT(2)(a1) C_LD REG3,UNIT(3)(a1) C_LD REG4,UNIT(4)(a1) C_LD REG5,UNIT(5)(a1) C_LD REG6,UNIT(6)(a1) C_LD REG7,UNIT(7)(a1) PTR_ADDIU a1,a1,UNIT(8) C_ST t0,UNIT(0)(a0) C_ST t1,UNIT(1)(a0) C_ST REG2,UNIT(2)(a0) C_ST REG3,UNIT(3)(a0) C_ST REG4,UNIT(4)(a0) C_ST REG5,UNIT(5)(a0) C_ST REG6,UNIT(6)(a0) C_ST REG7,UNIT(7)(a0) PTR_ADDIU a0,a0,UNIT(8) /* * Here we have less than 32(64) bytes to copy. Set up for a loop to * copy one word (or double word) at a time. Set a2 to count how many * bytes we have to copy after all the word (or double word) chunks are * copied and a3 to the dst pointer after all the (d)word chunks have * been copied. We will loop, incrementing a0 and a1 until a0 equals a3. */ L(chk1w): andi a2,t8,(NSIZE-1) /* a2 is the reminder past one (d)word chunks */ beq a2,t8,L(lastw) PTR_SUBU a3,t8,a2 /* a3 is count of bytes in one (d)word chunks */ PTR_ADDU a3,a0,a3 /* a3 is the dst address after loop */ /* copying in words (4-byte or 8-byte chunks) */ L(wordCopy_loop): C_LD REG3,UNIT(0)(a1) PTR_ADDIU a0,a0,UNIT(1) PTR_ADDIU a1,a1,UNIT(1) bne a0,a3,L(wordCopy_loop) C_ST REG3,UNIT(-1)(a0) /* If we have been copying double words, see if we can copy a single word before doing byte copies. We can have, at most, one word to copy. */ L(lastw): #ifdef USE_DOUBLE andi t8,a2,3 /* a2 is the remainder past 4 byte chunks. */ beq t8,a2,L(lastb) move a2,t8 lw REG3,0(a1) sw REG3,0(a0) PTR_ADDIU a0,a0,4 PTR_ADDIU a1,a1,4 #endif /* Copy the last 8 (or 16) bytes */ L(lastb): blez a2,L(leave) PTR_ADDU a3,a0,a2 /* a3 is the last dst address */ L(lastbloop): lb v1,0(a1) PTR_ADDIU a0,a0,1 PTR_ADDIU a1,a1,1 bne a0,a3,L(lastbloop) sb v1,-1(a0) L(leave): j ra nop /* We jump here with a memcpy of less than 8 or 16 bytes, depending on whether or not USE_DOUBLE is defined. Instead of just doing byte copies, check the alignment and size and use lw/sw if possible. Otherwise, do byte copies. */ L(lasts): andi t8,a2,3 beq t8,a2,L(lastb) andi t9,a0,3 bne t9,zero,L(lastb) andi t9,a1,3 bne t9,zero,L(lastb) PTR_SUBU a3,a2,t8 PTR_ADDU a3,a0,a3 L(wcopy_loop): lw REG3,0(a1) PTR_ADDIU a0,a0,4 PTR_ADDIU a1,a1,4 bne a0,a3,L(wcopy_loop) sw REG3,-4(a0) b L(lastb) move a2,t8 #ifndef R6_CODE /* * UNALIGNED case, got here with a3 = "negu a0" * This code is nearly identical to the aligned code above * but only the destination (not the source) gets aligned * so we need to do partial loads of the source followed * by normal stores to the destination (once we have aligned * the destination). */ L(unaligned): andi a3,a3,(NSIZE-1) /* copy a3 bytes to align a0/a1 */ beqz a3,L(ua_chk16w) /* if a3=0, it is already aligned */ PTR_SUBU a2,a2,a3 /* a2 is the remining bytes count */ C_LDHI v1,UNIT(0)(a1) C_LDLO v1,UNITM1(1)(a1) PTR_ADDU a1,a1,a3 C_STHI v1,UNIT(0)(a0) PTR_ADDU a0,a0,a3 /* * Now the destination (but not the source) is aligned * Set a2 to count how many bytes we have to copy after all the 64/128 byte * chunks are copied and a3 to the dst pointer after all the 64/128 byte * chunks have been copied. We will loop, incrementing a0 and a1 until a0 * equals a3. */ L(ua_chk16w): andi t8,a2,NSIZEDMASK /* any whole 64-byte/128-byte chunks? */ beq a2,t8,L(ua_chkw) /* if a2==t8, no 64-byte/128-byte chunks */ PTR_SUBU a3,a2,t8 /* subtract from a2 the reminder */ PTR_ADDU a3,a0,a3 /* Now a3 is the final dst after loop */ # if defined(USE_PREFETCH) && (PREFETCH_STORE_HINT == PREFETCH_HINT_PREPAREFORSTORE) PTR_ADDU t0,a0,a2 /* t0 is the "past the end" address */ PTR_SUBU t9,t0,PREFETCH_LIMIT /* t9 is the "last safe pref" address */ # endif PREFETCH_FOR_LOAD (0, a1) PREFETCH_FOR_LOAD (1, a1) PREFETCH_FOR_LOAD (2, a1) # if defined(USE_PREFETCH) && (PREFETCH_STORE_HINT != PREFETCH_HINT_PREPAREFORSTORE) PREFETCH_FOR_STORE (1, a0) PREFETCH_FOR_STORE (2, a0) PREFETCH_FOR_STORE (3, a0) # endif # if defined(RETURN_FIRST_PREFETCH) && defined(USE_PREFETCH) # if (PREFETCH_STORE_HINT == PREFETCH_HINT_PREPAREFORSTORE) sltu v1,t9,a0 bgtz v1,L(ua_skip_set) nop PTR_ADDIU v0,a0,(PREFETCH_CHUNK*4) L(ua_skip_set): # else PTR_ADDIU v0,a0,(PREFETCH_CHUNK*1) # endif # endif L(ua_loop16w): PREFETCH_FOR_LOAD (3, a1) C_LDHI t0,UNIT(0)(a1) C_LDHI t1,UNIT(1)(a1) C_LDHI REG2,UNIT(2)(a1) # if defined(USE_PREFETCH) && (PREFETCH_STORE_HINT == PREFETCH_HINT_PREPAREFORSTORE) sltu v1,t9,a0 bgtz v1,L(ua_skip_pref) # endif C_LDHI REG3,UNIT(3)(a1) PREFETCH_FOR_STORE (4, a0) PREFETCH_FOR_STORE (5, a0) L(ua_skip_pref): C_LDHI REG4,UNIT(4)(a1) C_LDHI REG5,UNIT(5)(a1) C_LDHI REG6,UNIT(6)(a1) C_LDHI REG7,UNIT(7)(a1) C_LDLO t0,UNITM1(1)(a1) C_LDLO t1,UNITM1(2)(a1) C_LDLO REG2,UNITM1(3)(a1) C_LDLO REG3,UNITM1(4)(a1) C_LDLO REG4,UNITM1(5)(a1) C_LDLO REG5,UNITM1(6)(a1) C_LDLO REG6,UNITM1(7)(a1) C_LDLO REG7,UNITM1(8)(a1) PREFETCH_FOR_LOAD (4, a1) C_ST t0,UNIT(0)(a0) C_ST t1,UNIT(1)(a0) C_ST REG2,UNIT(2)(a0) C_ST REG3,UNIT(3)(a0) C_ST REG4,UNIT(4)(a0) C_ST REG5,UNIT(5)(a0) C_ST REG6,UNIT(6)(a0) C_ST REG7,UNIT(7)(a0) C_LDHI t0,UNIT(8)(a1) C_LDHI t1,UNIT(9)(a1) C_LDHI REG2,UNIT(10)(a1) C_LDHI REG3,UNIT(11)(a1) C_LDHI REG4,UNIT(12)(a1) C_LDHI REG5,UNIT(13)(a1) C_LDHI REG6,UNIT(14)(a1) C_LDHI REG7,UNIT(15)(a1) C_LDLO t0,UNITM1(9)(a1) C_LDLO t1,UNITM1(10)(a1) C_LDLO REG2,UNITM1(11)(a1) C_LDLO REG3,UNITM1(12)(a1) C_LDLO REG4,UNITM1(13)(a1) C_LDLO REG5,UNITM1(14)(a1) C_LDLO REG6,UNITM1(15)(a1) C_LDLO REG7,UNITM1(16)(a1) PREFETCH_FOR_LOAD (5, a1) C_ST t0,UNIT(8)(a0) C_ST t1,UNIT(9)(a0) C_ST REG2,UNIT(10)(a0) C_ST REG3,UNIT(11)(a0) C_ST REG4,UNIT(12)(a0) C_ST REG5,UNIT(13)(a0) C_ST REG6,UNIT(14)(a0) C_ST REG7,UNIT(15)(a0) PTR_ADDIU a0,a0,UNIT(16) /* adding 64/128 to dest */ bne a0,a3,L(ua_loop16w) PTR_ADDIU a1,a1,UNIT(16) /* adding 64/128 to src */ move a2,t8 /* Here we have src and dest word-aligned but less than 64-bytes or * 128 bytes to go. Check for a 32(64) byte chunk and copy if if there * is one. Otherwise jump down to L(ua_chk1w) to handle the tail end of * the copy. */ L(ua_chkw): PREFETCH_FOR_LOAD (0, a1) andi t8,a2,NSIZEMASK /* Is there a 32-byte/64-byte chunk. */ /* t8 is the reminder count past 32-bytes */ beq a2,t8,L(ua_chk1w) /* When a2=t8, no 32-byte chunk */ nop C_LDHI t0,UNIT(0)(a1) C_LDHI t1,UNIT(1)(a1) C_LDHI REG2,UNIT(2)(a1) C_LDHI REG3,UNIT(3)(a1) C_LDHI REG4,UNIT(4)(a1) C_LDHI REG5,UNIT(5)(a1) C_LDHI REG6,UNIT(6)(a1) C_LDHI REG7,UNIT(7)(a1) C_LDLO t0,UNITM1(1)(a1) C_LDLO t1,UNITM1(2)(a1) C_LDLO REG2,UNITM1(3)(a1) C_LDLO REG3,UNITM1(4)(a1) C_LDLO REG4,UNITM1(5)(a1) C_LDLO REG5,UNITM1(6)(a1) C_LDLO REG6,UNITM1(7)(a1) C_LDLO REG7,UNITM1(8)(a1) PTR_ADDIU a1,a1,UNIT(8) C_ST t0,UNIT(0)(a0) C_ST t1,UNIT(1)(a0) C_ST REG2,UNIT(2)(a0) C_ST REG3,UNIT(3)(a0) C_ST REG4,UNIT(4)(a0) C_ST REG5,UNIT(5)(a0) C_ST REG6,UNIT(6)(a0) C_ST REG7,UNIT(7)(a0) PTR_ADDIU a0,a0,UNIT(8) /* * Here we have less than 32(64) bytes to copy. Set up for a loop to * copy one word (or double word) at a time. */ L(ua_chk1w): andi a2,t8,(NSIZE-1) /* a2 is the reminder past one (d)word chunks */ beq a2,t8,L(ua_smallCopy) PTR_SUBU a3,t8,a2 /* a3 is count of bytes in one (d)word chunks */ PTR_ADDU a3,a0,a3 /* a3 is the dst address after loop */ /* copying in words (4-byte or 8-byte chunks) */ L(ua_wordCopy_loop): C_LDHI v1,UNIT(0)(a1) C_LDLO v1,UNITM1(1)(a1) PTR_ADDIU a0,a0,UNIT(1) PTR_ADDIU a1,a1,UNIT(1) bne a0,a3,L(ua_wordCopy_loop) C_ST v1,UNIT(-1)(a0) /* Copy the last 8 (or 16) bytes */ L(ua_smallCopy): beqz a2,L(leave) PTR_ADDU a3,a0,a2 /* a3 is the last dst address */ L(ua_smallCopy_loop): lb v1,0(a1) PTR_ADDIU a0,a0,1 PTR_ADDIU a1,a1,1 bne a0,a3,L(ua_smallCopy_loop) sb v1,-1(a0) j ra nop #else /* R6_CODE */ # if __MIPSEB # define SWAP_REGS(X,Y) X, Y # define ALIGN_OFFSET(N) (N) # else # define SWAP_REGS(X,Y) Y, X # define ALIGN_OFFSET(N) (NSIZE-N) # endif # define R6_UNALIGNED_WORD_COPY(BYTEOFFSET) \ andi REG7, a2, (NSIZE-1);/* REG7 is # of bytes to by bytes. */ \ beq REG7, a2, L(lastb); /* Check for bytes to copy by word */ \ PTR_SUBU a3, a2, REG7; /* a3 is number of bytes to be copied in */ \ /* (d)word chunks. */ \ move a2, REG7; /* a2 is # of bytes to copy byte by byte */ \ /* after word loop is finished. */ \ PTR_ADDU REG6, a0, a3; /* REG6 is the dst address after loop. */ \ PTR_SUBU REG2, a1, t8; /* REG2 is the aligned src address. */ \ PTR_ADDU a1, a1, a3; /* a1 is addr of source after word loop. */ \ C_LD t0, UNIT(0)(REG2); /* Load first part of source. */ \ L(r6_ua_wordcopy##BYTEOFFSET): \ C_LD t1, UNIT(1)(REG2); /* Load second part of source. */ \ C_ALIGN REG3, SWAP_REGS(t1,t0), ALIGN_OFFSET(BYTEOFFSET); \ PTR_ADDIU a0, a0, UNIT(1); /* Increment destination pointer. */ \ PTR_ADDIU REG2, REG2, UNIT(1); /* Increment aligned source pointer.*/ \ move t0, t1; /* Move second part of source to first. */ \ bne a0, REG6,L(r6_ua_wordcopy##BYTEOFFSET); \ C_ST REG3, UNIT(-1)(a0); \ j L(lastb); \ nop /* We are generating R6 code, the destination is 4 byte aligned and the source is not 4 byte aligned. t8 is 1, 2, or 3 depending on the alignment of the source. */ L(r6_unaligned1): R6_UNALIGNED_WORD_COPY(1) L(r6_unaligned2): R6_UNALIGNED_WORD_COPY(2) L(r6_unaligned3): R6_UNALIGNED_WORD_COPY(3) # ifdef USE_DOUBLE L(r6_unaligned4): R6_UNALIGNED_WORD_COPY(4) L(r6_unaligned5): R6_UNALIGNED_WORD_COPY(5) L(r6_unaligned6): R6_UNALIGNED_WORD_COPY(6) L(r6_unaligned7): R6_UNALIGNED_WORD_COPY(7) # endif #endif /* R6_CODE */ .set at .set reorder END(MEMCPY_NAME) #ifndef ANDROID_CHANGES # ifdef _LIBC libc_hidden_builtin_def (MEMCPY_NAME) # endif #endif
stsp/newlib-ia16
6,068
newlib/libc/machine/mips/strcmp.S
/* * Copyright (c) 2014 * Imagination Technologies Limited. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the MIPS Technologies, Inc., nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY IMAGINATION TECHNOLOGIES LIMITED ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL IMAGINATION TECHNOLOGIES LIMITED BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #ifdef ANDROID_CHANGES # include "machine/asm.h" # include "machine/regdef.h" #elif _LIBC # include <sysdep.h> # include <regdef.h> # include <sys/asm.h> #elif _COMPILING_NEWLIB # include "machine/asm.h" # include "machine/regdef.h" #else # include <regdef.h> # include <sys/asm.h> #endif /* Technically strcmp should not read past the end of the strings being compared. We will read a full word that may contain excess bits beyond the NULL string terminator but unless ENABLE_READAHEAD is set, we will not read the next word after the end of string. Setting ENABLE_READAHEAD will improve performance but is technically illegal based on the definition of strcmp. */ #ifdef ENABLE_READAHEAD # define DELAY_READ #else # define DELAY_READ nop #endif /* Testing on a little endian machine showed using CLZ was a performance loss, so we are not turning it on by default. */ #if defined(ENABLE_CLZ) && (__mips_isa_rev > 1) # define USE_CLZ #endif /* Some asm.h files do not have the L macro definition. */ #ifndef L # if _MIPS_SIM == _ABIO32 # define L(label) $L ## label # else # define L(label) .L ## label # endif #endif /* Some asm.h files do not have the PTR_ADDIU macro definition. */ #ifndef PTR_ADDIU # ifdef USE_DOUBLE # define PTR_ADDIU daddiu # else # define PTR_ADDIU addiu # endif #endif /* Allow the routine to be named something else if desired. */ #ifndef STRCMP_NAME # define STRCMP_NAME strcmp #endif #ifdef ANDROID_CHANGES LEAF(STRCMP_NAME, 0) #else LEAF(STRCMP_NAME) #endif .set nomips16 .set noreorder or t0, a0, a1 andi t0,0x3 bne t0, zero, L(byteloop) /* Both strings are 4 byte aligned at this point. */ lui t8, 0x0101 ori t8, t8, 0x0101 lui t9, 0x7f7f ori t9, 0x7f7f #define STRCMP32(OFFSET) \ lw v0, OFFSET(a0); \ lw v1, OFFSET(a1); \ subu t0, v0, t8; \ bne v0, v1, L(worddiff); \ nor t1, v0, t9; \ and t0, t0, t1; \ bne t0, zero, L(returnzero) L(wordloop): STRCMP32(0) DELAY_READ STRCMP32(4) DELAY_READ STRCMP32(8) DELAY_READ STRCMP32(12) DELAY_READ STRCMP32(16) DELAY_READ STRCMP32(20) DELAY_READ STRCMP32(24) DELAY_READ STRCMP32(28) PTR_ADDIU a0, a0, 32 b L(wordloop) PTR_ADDIU a1, a1, 32 L(returnzero): j ra move v0, zero L(worddiff): #ifdef USE_CLZ subu t0, v0, t8 nor t1, v0, t9 and t1, t0, t1 xor t0, v0, v1 or t0, t0, t1 # if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ wsbh t0, t0 rotr t0, t0, 16 # endif clz t1, t0 and t1, 0xf8 # if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ neg t1 addu t1, 24 # endif rotrv v0, v0, t1 rotrv v1, v1, t1 and v0, v0, 0xff and v1, v1, 0xff j ra subu v0, v0, v1 #else /* USE_CLZ */ # if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ andi t0, v0, 0xff beq t0, zero, L(wexit01) andi t1, v1, 0xff bne t0, t1, L(wexit01) srl t8, v0, 8 srl t9, v1, 8 andi t8, t8, 0xff beq t8, zero, L(wexit89) andi t9, t9, 0xff bne t8, t9, L(wexit89) srl t0, v0, 16 srl t1, v1, 16 andi t0, t0, 0xff beq t0, zero, L(wexit01) andi t1, t1, 0xff bne t0, t1, L(wexit01) srl t8, v0, 24 srl t9, v1, 24 # else /* __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ */ srl t0, v0, 24 beq t0, zero, L(wexit01) srl t1, v1, 24 bne t0, t1, L(wexit01) srl t8, v0, 16 srl t9, v1, 16 andi t8, t8, 0xff beq t8, zero, L(wexit89) andi t9, t9, 0xff bne t8, t9, L(wexit89) srl t0, v0, 8 srl t1, v1, 8 andi t0, t0, 0xff beq t0, zero, L(wexit01) andi t1, t1, 0xff bne t0, t1, L(wexit01) andi t8, v0, 0xff andi t9, v1, 0xff # endif /* __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ */ L(wexit89): j ra subu v0, t8, t9 L(wexit01): j ra subu v0, t0, t1 #endif /* USE_CLZ */ /* It might seem better to do the 'beq' instruction between the two 'lbu' instructions so that the nop is not needed but testing showed that this code is actually faster (based on glibc strcmp test). */ #define BYTECMP01(OFFSET) \ lbu v0, OFFSET(a0); \ lbu v1, OFFSET(a1); \ beq v0, zero, L(bexit01); \ nop; \ bne v0, v1, L(bexit01) #define BYTECMP89(OFFSET) \ lbu t8, OFFSET(a0); \ lbu t9, OFFSET(a1); \ beq t8, zero, L(bexit89); \ nop; \ bne t8, t9, L(bexit89) L(byteloop): BYTECMP01(0) BYTECMP89(1) BYTECMP01(2) BYTECMP89(3) BYTECMP01(4) BYTECMP89(5) BYTECMP01(6) BYTECMP89(7) PTR_ADDIU a0, a0, 8 b L(byteloop) PTR_ADDIU a1, a1, 8 L(bexit01): j ra subu v0, v0, v1 L(bexit89): j ra subu v0, t8, t9 .set at .set reorder END(STRCMP_NAME) #ifndef ANDROID_CHANGES # ifdef _LIBC libc_hidden_builtin_def (STRCMP_NAME) # endif #endif
stsp/newlib-ia16
3,986
newlib/libc/machine/mips/setjmp.S
/* This is a simple version of setjmp and longjmp for MIPS 32 and 64. Ian Lance Taylor, Cygnus Support, 13 May 1993. */ #ifdef __mips16 /* This file contains 32 bit assembly code. */ .set nomips16 #endif #define GPR_LAYOUT \ GPR_OFFSET ($16, 0); \ GPR_OFFSET ($17, 1); \ GPR_OFFSET ($18, 2); \ GPR_OFFSET ($19, 3); \ GPR_OFFSET ($20, 4); \ GPR_OFFSET ($21, 5); \ GPR_OFFSET ($22, 6); \ GPR_OFFSET ($23, 7); \ GPR_OFFSET ($29, 8); \ GPR_OFFSET ($30, 9); \ GPR_OFFSET ($31, 10) #define NUM_GPRS_SAVED 11 #ifdef __mips_hard_float #if _MIPS_SIM == _ABIN32 #define FPR_LAYOUT \ FPR_OFFSET ($f20, 0); \ FPR_OFFSET ($f22, 1); \ FPR_OFFSET ($f24, 2); \ FPR_OFFSET ($f26, 3); \ FPR_OFFSET ($f28, 4); \ FPR_OFFSET ($f30, 5); #elif _MIPS_SIM == _ABI64 #define FPR_LAYOUT \ FPR_OFFSET ($f24, 0); \ FPR_OFFSET ($f25, 1); \ FPR_OFFSET ($f26, 2); \ FPR_OFFSET ($f27, 3); \ FPR_OFFSET ($f28, 4); \ FPR_OFFSET ($f29, 5); \ FPR_OFFSET ($f30, 6); \ FPR_OFFSET ($f31, 7); #elif __mips_fpr == 0 || __mips_fpr == 64 /* This deals with the o32 FPXX and FP64 cases. Here we must use SDC1 and LDC1 to access the FPRs. These instructions require 8-byte aligned addresses. Unfortunately, the MIPS jmp_buf only guarantees 4-byte alignment and this cannot be increased without breaking compatibility with pre-existing objects built against newlib. There are 11 GPRS saved in the jmp_buf so a buffer that happens to be 8-byte aligned ends up leaving the FPR slots 4-byte aligned and an (only) 4-byte aligned buffer leads to the FPR slots being 8-byte aligned! To resolve this, we move the location of $31 to the last slot in the jmp_buf when the overall buffer is 8-byte aligned. $31 is simply loaded/stored twice to avoid adding complexity to the GPR_LAYOUT macro above as well as FPR_LAYOUT. The location of the last slot is index 22 which is calculated from there being 11 GPRs saved and then 12 FPRs saved so the index of the last FPR is 11+11. The base of the jmp_buf is modified in $4 to allow the FPR_OFFSET macros to just use the usual constant slot numbers regardless of whether the realignment happened or not. */ #define FPR_LAYOUT \ and $8, $4, 4; \ bne $8, $0, 1f; \ GPR_OFFSET ($31, 22); \ addiu $4, $4, -4; \ 1: \ FPR_OFFSET ($f20, 0); \ FPR_OFFSET ($f22, 2); \ FPR_OFFSET ($f24, 4); \ FPR_OFFSET ($f26, 6); \ FPR_OFFSET ($f28, 8); \ FPR_OFFSET ($f30, 10); #else /* Assuming _MIPS_SIM == _ABIO32 */ #define FPR_LAYOUT \ FPR_OFFSET ($f20, 0); \ FPR_OFFSET ($f21, 1); \ FPR_OFFSET ($f22, 2); \ FPR_OFFSET ($f23, 3); \ FPR_OFFSET ($f24, 4); \ FPR_OFFSET ($f25, 5); \ FPR_OFFSET ($f26, 6); \ FPR_OFFSET ($f27, 7); \ FPR_OFFSET ($f28, 8); \ FPR_OFFSET ($f29, 9); \ FPR_OFFSET ($f30, 10); \ FPR_OFFSET ($f31, 11); #endif #else #define FPR_LAYOUT #endif #ifdef __mips64 #define BYTES_PER_WORD 8 #define LOAD_GPR ld #define LOAD_FPR ldc1 #define STORE_GPR sd #define STORE_FPR sdc1 #else #define LOAD_GPR lw #define STORE_GPR sw #define BYTES_PER_WORD 4 #if __mips_fpr == 0 || __mips_fpr == 64 #define LOAD_FPR ldc1 #define STORE_FPR sdc1 #else #define LOAD_FPR lwc1 #define STORE_FPR swc1 #endif #endif #define GPOFF(INDEX) (INDEX * BYTES_PER_WORD) #define FPOFF(INDEX) ((INDEX + NUM_GPRS_SAVED) * BYTES_PER_WORD) /* int setjmp (jmp_buf); */ .globl setjmp .ent setjmp setjmp: .frame $sp,0,$31 #define GPR_OFFSET(REG, INDEX) STORE_GPR REG,GPOFF(INDEX)($4) #define FPR_OFFSET(REG, INDEX) STORE_FPR REG,FPOFF(INDEX)($4) GPR_LAYOUT FPR_LAYOUT #undef GPR_OFFSET #undef FPR_OFFSET move $2,$0 j $31 .end setjmp /* volatile void longjmp (jmp_buf, int); */ .globl longjmp .ent longjmp longjmp: .frame $sp,0,$31 #define GPR_OFFSET(REG, INDEX) LOAD_GPR REG,GPOFF(INDEX)($4) #define FPR_OFFSET(REG, INDEX) LOAD_FPR REG,FPOFF(INDEX)($4) GPR_LAYOUT FPR_LAYOUT #undef GPR_OFFSET #undef FPR_OFFSET bne $5,$0,1f li $5,1 1: move $2,$5 j $31 .end longjmp