1/*
2*
3*                Language Independent Library
4*
5*       Copyright 1983-2000 Green Hills Software,Inc.
6*
7*  This program is the property of Green Hills Software, Inc,
8*  its contents are proprietary information and no part of it
9*  is to be disclosed to anyone except employees of Green Hills
10*  Software, Inc., or as agreed in writing signed by the President
11*  of Green Hills Software, Inc.
12*
13*/
14/* ind_call.ppc: C callable wrapper for Host I/O system calls (PPC family). */
15
16	.file	"ind_call.ppc"
17#include "ppc_regs.ppc"
18
19#if defined(EMBEDDED) || defined(__OSE)
20
21#ifdef __vle
22	.section ".vletext", "vax"
23	.vle
24
25	.globl	__ghs_syscall
26__ghs_syscall:
27        se_mflr r0			# prolog
28        se_stw  r0, 4(sp)		# ''
29        e_stwu  sp, -8(sp)		# ''
30	crset	2			# set Z(EQ) flag
31#if defined(TRANSFER_VECTOR)
32	e_bl	%tv(__dotsyscall) 	# call into .syscall section
33	se_beq	__noerr			# if no error, return
34	e_bl	%tv(__gh_set_errno)	# else set errno with r3 error code
35#else
36	e_bl	__dotsyscall		# call into .syscall section
37	se_beq	__noerr			# if no error, return
38	e_bl	__gh_set_errno		# else set errno with r3 error code
39#endif
40	se_bmaski r3, 0			# and return -1
41__noerr:
42	se_lwz	r0, 12(sp)		# epilog
43	se_mtlr	r0			# ''
44	se_addi	sp, 8			# ''
45	se_blr				# done
46#else /* __vle */
47	.text
48
49# if defined(__PPC64_ABI__) && !defined(__PPC64_NO_FUNC_DESC)
50	.section ".opd", "aw"
51	.align 3
52	.global __ghs_syscall
53__ghs_syscall:
54	.quad	.__ghs_syscall, .TOC.@tocbase, 0
55	.size 	__ghs_syscall, 24
56
57	.text
58	.globl	.__ghs_syscall
59.__ghs_syscall:
60# else
61	.globl	__ghs_syscall
62__ghs_syscall:
63# endif
64        mflr    r0			# prolog
65#ifdef __PPC64__
66#  ifdef __PPC64_ABI__
67	std	r0, 16(sp)
68	stdu	sp, -112(sp)		# 6(header)+8(parm save area) double words
69#  else
70	std     r0, 8(sp)
71	stdu    sp, -16(sp)
72#  endif
73#else
74        stw     r0, 4(sp)		# ''
75        stwu    sp, -8(sp)		# ''
76#endif
77	crset	2			# set Z(EQ) flag
78/* Note: the + on the beq below sidesteps the PPC860 erratum that may otherwise
79   result (as we hit the beq after executing a blr in ind_dots.ppc)
80   This erratum is numbered CPU3(CPU8) */
81#if defined(TRANSFER_VECTOR)
82	bl	%tv(__dotsyscall) 	# call into .syscall section
83	beq+	__noerr			# if no error, return
84	bl	%tv(__gh_set_errno)	# else set errno with r3 error code
85#else
86	bl	__dotsyscall		# call into .syscall section
87	beq+	__noerr			# if no error, return
88	bl	__gh_set_errno		# else set errno with r3 error code
89#endif
90	li	r3, -1			# and return -1
91__noerr:
92#ifdef __PPC64__
93#  ifdef __PPC64_ABI__
94	ld	r0, 128(sp)
95	mtlr	r0
96	addi	sp, sp, 112
97	blr
98#  else
99	ld      r0, 24(sp)
100	mtlr    r0
101	addi    sp, sp, 16
102	blr
103#  endif
104#else
105	lwz	r0, 12(sp)		# epilog
106	mtlr	r0			# ''
107	addi	sp, sp, 8		# ''
108	blr				# done
109#endif
110#endif /* __vle */
111
112#ifdef __ELF
113	.fsize	8
114	.scall	__dotsyscall
115	.scall	__gh_set_errno
116# if defined(__PPC64_ABI__) && !defined(__PPC64_NO_FUNC_DESC)
117	.type .__ghs_syscall,@function
118	.size .__ghs_syscall,$-.__ghs_syscall
119# else
120	.type __ghs_syscall,@function
121	.size __ghs_syscall,$-__ghs_syscall
122# endif
123#endif /* __ELF */
124
125#endif
126
127