Annotation of kernel/machdep/i386/libc/pagesize.c, revision 1.1.1.1

1.1       root        1: /*
                      2:  * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
                      3:  *
                      4:  * @APPLE_LICENSE_HEADER_START@
                      5:  * 
                      6:  * Portions Copyright (c) 1999 Apple Computer, Inc.  All Rights
                      7:  * Reserved.  This file contains Original Code and/or Modifications of
                      8:  * Original Code as defined in and that are subject to the Apple Public
                      9:  * Source License Version 1.1 (the "License").  You may not use this file
                     10:  * except in compliance with the License.  Please obtain a copy of the
                     11:  * License at http://www.apple.com/publicsource and read it before using
                     12:  * this file.
                     13:  * 
                     14:  * The Original Code and all software distributed under the License are
                     15:  * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
                     16:  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
                     17:  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
                     18:  * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
                     19:  * License for the specific language governing rights and limitations
                     20:  * under the License.
                     21:  * 
                     22:  * @APPLE_LICENSE_HEADER_END@
                     23:  */
                     24: 
                     25: /* Copyright (c) 1991 NeXT Computer, Inc.  All rights reserved.
                     26:  *
                     27:  *      File:   machdep/i386/libc/pagesize.c
                     28:  *      Author: Bruce Martin, NeXT Computer, Inc.
                     29:  *
                     30:  *      This file contains machine dependent code for block compares
                     31:  *      on NeXT i386-based products.  Currently tuned for the i486.
                     32:  *
                     33:  * HISTORY
                     34:  * 27-Sep-92  Bruce Martin ([email protected])
                     35:  *     Created.
                     36:  */
                     37: 
                     38: #include <mach/mach_types.h>
                     39: 
                     40: #if defined(NX_CURRENT_COMPILER_RELEASE) && (NX_CURRENT_COMPILER_RELEASE < 320)
                     41: #define SIREG "e"
                     42: #else
                     43: #define SIREG "S"
                     44: #endif
                     45: 
                     46: /*
                     47:  * A memory set function which requires its input address to be
                     48:  * integer aligned, and its span to be an integer mulitple of
                     49:  * 32 bytes.
                     50:  *
                     51:  * NOTE: we force this routine to use %ecx because
                     52:  * we have to note that these arguments are clobbered.  There
                     53:  * doesn't seem to be any other way - short of hard-wiring
                     54:  * a specific register.
                     55:  */
                     56: static __inline__ vm_offset_t
                     57: mem_set_a4_l32(vm_offset_t addr, unsigned int val, int len)
                     58: {
                     59:     asm volatile ("
                     60:        .align 2, 0x90
                     61:        movl %2, 0x00(%0);      movl %2, 0x04(%0)
                     62:        movl %2, 0x08(%0);      movl %2, 0x0C(%0)
                     63:        movl %2, 0x10(%0);      movl %2, 0x14(%0)
                     64:        movl %2, 0x18(%0);      movl %2, 0x1C(%0)
                     65:        addl $0x20, %0;         addl $-0x20,%1
                     66:        jne .-30
                     67:        "
                     68:        : "=r" (addr)
                     69:        : "c" (len), "a" (val), "0" (addr)
                     70:        : "eax", "ecx", "cc");
                     71:     return(addr);
                     72: }
                     73: 
                     74: 
                     75: /*
                     76:  * A memory copy which requires its input addresses to be
                     77:  * integer aligned, and its span to be an integer multiple of
                     78:  * four bytes.
                     79:  *
                     80:  * Benchmarking has shown the use of the rep;movsl opcode to be
                     81:  * slightly slower than the optimal unrolled loop on the 486, but
                     82:  * only by a few percent.  On the P5, you can't beat rep;movsl.
                     83:  */
                     84: static __inline__ void
                     85: mem_copy_forward_a4_l4(vm_offset_t dst, vm_offset_t src, vm_size_t len)
                     86: {
                     87:     asm("rep; movsl"
                     88:         : /* no outputs */
                     89:         : "c" (len>>2), "D" (dst), SIREG (src)
                     90:         : "ecx", "esi", "edi");
                     91:     return;
                     92: }
                     93: 
                     94: 
                     95: 
                     96: void
                     97: page_set(vm_offset_t addr, int val, vm_size_t size)
                     98: {
                     99:     (void) mem_set_a4_l32(addr, val, size);
                    100:     return;
                    101: }
                    102: 
                    103: 
                    104: void
                    105: page_copy(vm_offset_t dst, vm_offset_t src, vm_size_t size)
                    106: {
                    107:     (void) mem_copy_forward_a4_l4(dst, src, size);
                    108:     return;
                    109: }
                    110: 
                    111: 

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.