1*4d12bfcdSjoerg/* $NetBSD: sbrk.S,v 1.11 2013/09/12 15:36:16 joerg Exp $ */ 21394f01bSchristos 30b9f5089Scgd/* 40b9f5089Scgd * Copyright (c) 1992, 1993 50b9f5089Scgd * The Regents of the University of California. All rights reserved. 60b9f5089Scgd * 70b9f5089Scgd * This software was developed by the Computer Systems Engineering group 80b9f5089Scgd * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and 90b9f5089Scgd * contributed to Berkeley. 100b9f5089Scgd * 110b9f5089Scgd * Redistribution and use in source and binary forms, with or without 120b9f5089Scgd * modification, are permitted provided that the following conditions 130b9f5089Scgd * are met: 140b9f5089Scgd * 1. Redistributions of source code must retain the above copyright 150b9f5089Scgd * notice, this list of conditions and the following disclaimer. 160b9f5089Scgd * 2. Redistributions in binary form must reproduce the above copyright 170b9f5089Scgd * notice, this list of conditions and the following disclaimer in the 180b9f5089Scgd * documentation and/or other materials provided with the distribution. 19eb7c1594Sagc * 3. Neither the name of the University nor the names of its contributors 200b9f5089Scgd * may be used to endorse or promote products derived from this software 210b9f5089Scgd * without specific prior written permission. 220b9f5089Scgd * 230b9f5089Scgd * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 240b9f5089Scgd * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 250b9f5089Scgd * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 260b9f5089Scgd * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 270b9f5089Scgd * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 280b9f5089Scgd * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 290b9f5089Scgd * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 300b9f5089Scgd * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 310b9f5089Scgd * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 320b9f5089Scgd * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 330b9f5089Scgd * SUCH DAMAGE. 340b9f5089Scgd * 350b9f5089Scgd * from: Header: sbrk.s,v 1.3 92/07/02 00:56:49 torek Exp 360b9f5089Scgd */ 370b9f5089Scgd 381394f01bSchristos#include <machine/asm.h> 391394f01bSchristos#if defined(SYSLIBC_SCCS) && !defined(lint) 401394f01bSchristos#if 0 410b9f5089Scgd .asciz "@(#)sbrk.s 8.1 (Berkeley) 6/4/93" 421394f01bSchristos#else 43*4d12bfcdSjoerg RCSID("$NetBSD: sbrk.S,v 1.11 2013/09/12 15:36:16 joerg Exp $") 441394f01bSchristos#endif 451394f01bSchristos#endif /* SYSLIBC_SCCS and not lint */ 460b9f5089Scgd 470b9f5089Scgd#include "SYS.h" 480b9f5089Scgd 4915fb0e43Skleink .globl _end 50dccf2a15Skleink .globl CURBRK 510b9f5089Scgd 5203f996bdSkleink#ifdef WEAK_ALIAS 5303f996bdSkleinkWEAK_ALIAS(sbrk, _sbrk) 5403f996bdSkleink#endif 5503f996bdSkleink 560b9f5089Scgd .data 5715fb0e43SkleinkCURBRK: .long _end 580b9f5089Scgd .text 590b9f5089Scgd 6003f996bdSkleinkENTRY(_sbrk) 61*4d12bfcdSjoerg#ifdef __PIC__ 62e0bf9676Spk PIC_PROLOGUE(%o5,%o4) 63a34b3f87Suwe set CURBRK, %o2 64a34b3f87Suwe ld [%o5 + %o2], %o2 65e0bf9676Spk ld [%o2], %o3 ! %o3 = old break 66e0bf9676Spk add %o3, %o0, %o4 ! %o4 = new break 67e0bf9676Spk mov %o4, %o0 ! copy for syscall 68e0bf9676Spk mov SYS_break, %g1 69e0bf9676Spk t ST_SYSCALL ! break(new_break) 70e0bf9676Spk bcc,a 1f ! if success, 71e0bf9676Spk mov %o3, %o0 ! set return value 72e0bf9676Spk ERROR() 73e0bf9676Spk1: 74e0bf9676Spk retl ! and update curbrk 75e0bf9676Spk st %o4, [%o2] 76e0bf9676Spk#else 77dccf2a15Skleink sethi %hi(CURBRK), %o2 78dccf2a15Skleink ld [%o2 + %lo(CURBRK)], %o3 ! %o3 = old break 790b9f5089Scgd add %o3, %o0, %o4 ! %o4 = new break 800b9f5089Scgd mov %o4, %o0 ! copy for syscall 810b9f5089Scgd mov SYS_break, %g1 820b9f5089Scgd t ST_SYSCALL ! break(new_break) 830b9f5089Scgd bcc,a 1f ! if success, 840b9f5089Scgd mov %o3, %o0 ! set return value 850b9f5089Scgd ERROR() 860b9f5089Scgd1: 870b9f5089Scgd retl ! and update curbrk 88dccf2a15Skleink st %o4, [%o2 + %lo(CURBRK)] 89e0bf9676Spk#endif 90