1107571Sgrehan/*- 2107571Sgrehan * Copyright (c) 2002 Peter Grehan. 3107571Sgrehan * All rights reserved. 4107571Sgrehan * 5107571Sgrehan * Redistribution and use in source and binary forms, with or without 6107571Sgrehan * modification, are permitted provided that the following conditions 7107571Sgrehan * are met: 8107571Sgrehan * 1. Redistributions of source code must retain the above copyright 9107571Sgrehan * notice, this list of conditions and the following disclaimer. 10107571Sgrehan * 2. Redistributions in binary form must reproduce the above copyright 11107571Sgrehan * notice, this list of conditions and the following disclaimer in the 12107571Sgrehan * documentation and/or other materials provided with the distribution. 13107571Sgrehan * 14107571Sgrehan * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15107571Sgrehan * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16107571Sgrehan * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17107571Sgrehan * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18107571Sgrehan * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19107571Sgrehan * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20107571Sgrehan * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21107571Sgrehan * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22107571Sgrehan * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23107571Sgrehan * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24107571Sgrehan * SUCH DAMAGE. 25107571Sgrehan */ 26107571Sgrehan/* $NetBSD: sbrk.S,v 1.8 2000/06/26 06:25:44 kleink Exp $ */ 27107571Sgrehan 28107571Sgrehan#include <machine/asm.h> 29107571Sgrehan__FBSDID("$FreeBSD$"); 30107571Sgrehan 31107571Sgrehan#include "SYS.h" 32107571Sgrehan 33107571Sgrehan .globl HIDENAME(curbrk) 34107571Sgrehan .globl CNAME(_end) 35107571Sgrehan 36107571Sgrehan .data 37107571SgrehanHIDENAME(curbrk): 38107571Sgrehan .long CNAME(_end) 39107571Sgrehan 40107571Sgrehan .text 41107571SgrehanENTRY(sbrk) 42107571Sgrehan 43107571Sgrehan#ifdef PIC 44107571Sgrehan mflr %r10 45107571Sgrehan bl _GLOBAL_OFFSET_TABLE_@local-4 46107571Sgrehan mflr %r5 47107571Sgrehan mtlr %r10 48107571Sgrehan lwz %r5,HIDENAME(curbrk)@got(%r5) 49107571Sgrehan lwz %r6,0(%r5) 50107571Sgrehan#else 51107571Sgrehan lis %r5,HIDENAME(curbrk)@ha 52107571Sgrehan lwz %r6,HIDENAME(curbrk)@l(%r5) /* r6 = old break */ 53107571Sgrehan#endif 54107571Sgrehan cmpwi %r3,0 /* sbrk(0) - return curbrk */ 55107571Sgrehan beq 1f 56107571Sgrehan add %r3,%r3,%r6 57107571Sgrehan mr %r7,%r3 /* r7 = new break */ 58107571Sgrehan li %r0,SYS_break 59107571Sgrehan sc /* break(new_break) */ 60107571Sgrehan bso 2f 61107571Sgrehan#ifdef PIC 62107571Sgrehan stw %r7,0(%r5) 63107571Sgrehan#else 64107571Sgrehan stw %r7,HIDENAME(curbrk)@l(%r5) /* record new break */ 65107571Sgrehan#endif 66107571Sgrehan1: 67107571Sgrehan mr %r3,%r6 /* set return value */ 68107571Sgrehan blr 69107571Sgrehan2: 70107571Sgrehan b PIC_PLT(HIDENAME(cerror)) 71217398Skib 72217398Skib .section .note.GNU-stack,"",%progbits 73