1/*
2 * This file is part of the Free Pascal run time library.
3 * Copyright (c) 2011 by Thomas Schatzl,
4 * member of the Free Pascal development team.
5 *
6 * Startup code for shared libraries, ARM version.
7 *
8 * See the file COPYING.FPC, included in this distribution,
9 * for details about the copyright.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14 */
15
16.file   "dllprt0.as"
17.text
18        .globl  _startlib
19        .type   _startlib,#function
20_startlib:
21        .globl  FPC_SHARED_LIB_START
22        .type   FPC_SHARED_LIB_START,#function
23FPC_SHARED_LIB_START:
24        mov ip, sp
25        stmfd sp!,{fp, ip, lr, pc}
26        sub fp, ip, #4
27
28        /* a1 contains argc, a2 contains argv and a3 contains envp */
29        ldr ip, =operatingsystem_parameter_argc
30        str a1, [ip]
31
32        ldr ip, =operatingsystem_parameter_argv
33        str a2, [ip]
34
35        ldr ip, =operatingsystem_parameter_envp
36        str a3, [ip]
37
38        /* save initial stackpointer */
39        ldr ip, =__stklen
40        str sp, [ip]
41
42        /* call main and exit normally */
43        bl PASCALMAIN
44        ldmdb fp, {fp, sp, pc}
45
46        .globl  _haltproc
47        .type   _haltproc,#function
48_haltproc:
49        /* reload exitcode */
50        ldr r0,=operatingsystem_result
51        ldr r0,[r0]
52        swi 0x900001
53        b _haltproc
54
55        .globl  _haltproc_eabi
56        .type   _haltproc_eabi,#function
57_haltproc_eabi:
58        /* reload exitcode */
59        ldr r0,=operatingsystem_result
60        ldr r0,[r0]
61        mov r7,#248
62        swi 0x0
63        b _haltproc_eabi
64
65.data
66
67        .type operatingsystem_parameters,#object
68        .size operatingsystem_parameters,12
69operatingsystem_parameters:
70        .skip 3*4
71        .global operatingsystem_parameter_envp
72        .global operatingsystem_parameter_argc
73        .global operatingsystem_parameter_argv
74        .set operatingsystem_parameter_envp,operatingsystem_parameters+0
75        .set operatingsystem_parameter_argc,operatingsystem_parameters+4
76        .set operatingsystem_parameter_argv,operatingsystem_parameters+8
77
78.bss
79
80        .comm __stkptr,4
81
82