X-Git-Url: https://git.saurik.com/apple/xnu.git/blobdiff_plain/e5568f75972dfc723778653c11cb6b4dc825716a..4a3eedf9ecc9bbe3f3a5c6ce5e53ad199d639d32:/osfmk/ppc/commpage/bcopy_970.s diff --git a/osfmk/ppc/commpage/bcopy_970.s b/osfmk/ppc/commpage/bcopy_970.s index 6294f16d7..61916abf2 100644 --- a/osfmk/ppc/commpage/bcopy_970.s +++ b/osfmk/ppc/commpage/bcopy_970.s @@ -1,23 +1,29 @@ /* * Copyright (c) 2003 Apple Computer, Inc. All rights reserved. * - * @APPLE_LICENSE_HEADER_START@ + * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ * - * The contents of this file constitute Original Code as defined in and - * are subject to the Apple Public Source License Version 1.1 (the - * "License"). You may not use this file except in compliance with the - * License. Please obtain a copy of the License at - * http://www.apple.com/publicsource and read it before using this file. + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. The rights granted to you under the License + * may not be used to create, or enable the creation or redistribution of, + * unlawful or unlicensed copies of an Apple operating system, or to + * circumvent, violate, or enable the circumvention or violation of, any + * terms of an Apple operating system software license agreement. * - * This Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * - * @APPLE_LICENSE_HEADER_END@ + * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ */ /* ======================================= * BCOPY, MEMCPY, and MEMMOVE for Mac OS X @@ -25,7 +31,6 @@ * * Version of 6/11/2003, tuned for the IBM 970. * - * * Register usage. Note the rather delicate way we assign multiple uses * to the same register. Beware. * r0 = temp (NB: cannot use r0 for any constant such as "c16") @@ -67,15 +72,28 @@ #define vy v11 #define vz v12 -#define ASSEMBLER #include #include #include #include .text - .globl EXT(bcopy_970) - +/* + * WARNING: this code is written for 32-bit mode, and ported by the kernel if necessary + * to 64-bit mode for use in the 64-bit commpage. This "port" consists of the following + * simple transformations: + * - all word compares are changed to doubleword + * - all "srwi[.]" opcodes are changed to "srdi[.]" + * Nothing else is done. For this to work, the following rules must be + * carefully followed: + * - do not use carry or overflow + * - only use record mode if you are sure the results are mode-invariant + * for example, all "andi." and almost all "rlwinm." are fine + * - do not use "slwi", "slw", or "srw" + * An imaginative programmer could break the porting model in other ways, but the above + * are the most likely problem areas. It is perhaps surprising how well in practice + * this simple method works. + */ #define kShort 64 #define kVeryLong (128*1024) @@ -347,7 +365,7 @@ LFwdLongVectors: lis w3,kVeryLong>>16 // cutoff for very-long-operand special case path cmplw cr1,rc,w3 // very long operand? rlwinm w3,rc,0,28,31 // move last 0-15 byte count to w3 - bgea-- cr1,_COMM_PAGE_BIGCOPY // handle big copies separately + bge-- cr1,LBigCopy // handle big copies separately mtctr r0 // set up loop count cmpwi cr6,w3,0 // set cr6 on leftover byte count oris w4,rv,0xFFF8 // we use v0-v12 @@ -586,4 +604,23 @@ LReverseVecUnal: bne cr6,LShortReverse16 // handle last 0-15 bytes iff any blr - COMMPAGE_DESCRIPTOR(bcopy_970,_COMM_PAGE_BCOPY,k64Bit+kHasAltivec,0,kCommPageMTCRF) + +// Very Big Copy Path. Save our return address in the stack for help decoding backtraces. +// The conditions bigcopy expects are: +// r0 = return address (also stored in caller's SF) +// r4 = source ptr +// r5 = length (at least several pages) +// r12 = dest ptr + +LBigCopy: + lis r2,0x4000 // r2 <- 0x40000000 + mflr r0 // get our return address + add. r2,r2,r2 // set cr0_lt if running in 32-bit mode + stw r0,8(r1) // save return, assuming 32-bit mode ("crsave" if 64-bit mode) + blta _COMM_PAGE_BIGCOPY // 32-bit mode, join big operand copy + std r0,16(r1) // save return in correct spot for 64-bit mode + ba _COMM_PAGE_BIGCOPY // then join big operand code + + + COMMPAGE_DESCRIPTOR(bcopy_970,_COMM_PAGE_BCOPY,k64Bit+kHasAltivec,0, \ + kCommPageMTCRF+kCommPageBoth+kPort32to64)