sbrk.S revision 1.3.6.2 1 1.3.6.2 rmind /* $NetBSD: sbrk.S,v 1.3.6.2 2008/07/02 20:07:44 rmind Exp $ */
2 1.3.6.2 rmind
3 1.3.6.2 rmind /*-
4 1.3.6.2 rmind * Copyright (c) 1990 The Regents of the University of California.
5 1.3.6.2 rmind * All rights reserved.
6 1.3.6.2 rmind *
7 1.3.6.2 rmind * This code is derived from software contributed to Berkeley by
8 1.3.6.2 rmind * William Jolitz.
9 1.3.6.2 rmind *
10 1.3.6.2 rmind * Redistribution and use in source and binary forms, with or without
11 1.3.6.2 rmind * modification, are permitted provided that the following conditions
12 1.3.6.2 rmind * are met:
13 1.3.6.2 rmind * 1. Redistributions of source code must retain the above copyright
14 1.3.6.2 rmind * notice, this list of conditions and the following disclaimer.
15 1.3.6.2 rmind * 2. Redistributions in binary form must reproduce the above copyright
16 1.3.6.2 rmind * notice, this list of conditions and the following disclaimer in the
17 1.3.6.2 rmind * documentation and/or other materials provided with the distribution.
18 1.3.6.2 rmind * 3. Neither the name of the University nor the names of its contributors
19 1.3.6.2 rmind * may be used to endorse or promote products derived from this software
20 1.3.6.2 rmind * without specific prior written permission.
21 1.3.6.2 rmind *
22 1.3.6.2 rmind * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23 1.3.6.2 rmind * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 1.3.6.2 rmind * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 1.3.6.2 rmind * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26 1.3.6.2 rmind * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27 1.3.6.2 rmind * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28 1.3.6.2 rmind * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29 1.3.6.2 rmind * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 1.3.6.2 rmind * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 1.3.6.2 rmind * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 1.3.6.2 rmind * SUCH DAMAGE.
33 1.3.6.2 rmind *
34 1.3.6.2 rmind * from: @(#)sbrk.s 5.1 (Berkeley) 4/23/90
35 1.3.6.2 rmind */
36 1.3.6.2 rmind
37 1.3.6.2 rmind #include <machine/asm.h>
38 1.3.6.2 rmind #if defined(SYSLIBC_SCCS) && !defined(lint)
39 1.3.6.2 rmind RCSID("$NetBSD: sbrk.S,v 1.3.6.2 2008/07/02 20:07:44 rmind Exp $")
40 1.3.6.2 rmind #endif /* SYSLIBC_SCCS and not lint */
41 1.3.6.2 rmind
42 1.3.6.2 rmind #include "SYS.h"
43 1.3.6.2 rmind
44 1.3.6.2 rmind .globl _end
45 1.3.6.2 rmind .globl CURBRK
46 1.3.6.2 rmind
47 1.3.6.2 rmind #ifdef WEAK_ALIAS
48 1.3.6.2 rmind WEAK_ALIAS(sbrk, _sbrk)
49 1.3.6.2 rmind #endif
50 1.3.6.2 rmind
51 1.3.6.2 rmind .data
52 1.3.6.2 rmind CURBRK: .quad _end
53 1.3.6.2 rmind .text
54 1.3.6.2 rmind
55 1.3.6.2 rmind ENTRY(_sbrk)
56 1.3.6.2 rmind #ifdef PIC
57 1.3.6.2 rmind movq PIC_GOT(CURBRK),%rdx
58 1.3.6.2 rmind movq (%rdx),%rax
59 1.3.6.2 rmind test %rdi,%rdi
60 1.3.6.2 rmind jz out
61 1.3.6.2 rmind addq %rax,%rdi
62 1.3.6.2 rmind SYSTRAP(break)
63 1.3.6.2 rmind jc err
64 1.3.6.2 rmind movq PIC_GOT(CURBRK),%rdx
65 1.3.6.2 rmind movq (%rdx),%rax
66 1.3.6.2 rmind movq %rdi,(%rdx)
67 1.3.6.2 rmind out:
68 1.3.6.2 rmind ret
69 1.3.6.2 rmind err:
70 1.3.6.2 rmind mov PIC_GOT(CERROR),%rdx
71 1.3.6.2 rmind jmp *%rdx
72 1.3.6.2 rmind #else
73 1.3.6.2 rmind movq CURBRK(%rip),%rax
74 1.3.6.2 rmind test %rdi,%rdi
75 1.3.6.2 rmind jz out
76 1.3.6.2 rmind movq %rdi,%rsi
77 1.3.6.2 rmind addq %rax,%rdi
78 1.3.6.2 rmind SYSTRAP(break)
79 1.3.6.2 rmind jc err
80 1.3.6.2 rmind movq CURBRK(%rip),%rax
81 1.3.6.2 rmind addq %rsi,CURBRK(%rip)
82 1.3.6.2 rmind out:
83 1.3.6.2 rmind ret
84 1.3.6.2 rmind err:
85 1.3.6.2 rmind jmp CERROR
86 1.3.6.2 rmind #endif
87