|
|
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: /* ! 26: * Copyright (c) 1993 NeXT Computer, Inc. ! 27: * ! 28: * Inline functions to access the task address space. ! 29: * ! 30: * HISTORY ! 31: * ! 32: * 15 Jan 1993 ? at NeXT ! 33: * Created. ! 34: */ ! 35: ! 36: #if KERNEL_PRIVATE ! 37: ! 38: #import <mach/mach_types.h> ! 39: ! 40: static __inline__ ! 41: boolean_t ! 42: fetchByte( ! 43: thread_t thread, ! 44: vm_offset_t address, ! 45: unsigned char *data ! 46: ) ! 47: { ! 48: thread->recover = (vm_offset_t)&&fault; ! 49: ! 50: asm volatile( ! 51: "movb %%fs:%1,%0" ! 52: : "=q" (*data) ! 53: : "m" (*(unsigned char *)address)); ! 54: ! 55: thread->recover = 0; ! 56: return (TRUE); ! 57: ! 58: fault: ! 59: thread->recover = 0; ! 60: return (FALSE); ! 61: } ! 62: ! 63: static __inline__ ! 64: boolean_t ! 65: fetch2Byte( ! 66: thread_t thread, ! 67: vm_offset_t address, ! 68: unsigned short *data ! 69: ) ! 70: { ! 71: thread->recover = (vm_offset_t)&&fault; ! 72: ! 73: asm volatile( ! 74: "movw %%fs:%1,%0" ! 75: : "=q" (*data) ! 76: : "m" (*(unsigned short *)address)); ! 77: ! 78: thread->recover = 0; ! 79: return (TRUE); ! 80: ! 81: fault: ! 82: thread->recover = 0; ! 83: return (FALSE); ! 84: } ! 85: ! 86: static __inline__ ! 87: boolean_t ! 88: store2Byte( ! 89: thread_t thread, ! 90: vm_offset_t address, ! 91: unsigned short data ! 92: ) ! 93: { ! 94: thread->recover = (vm_offset_t)&&fault; ! 95: ! 96: asm volatile( ! 97: "movw %0,%%fs:%1" ! 98: : ! 99: : "r" (data), "m" (*(unsigned short *)address)); ! 100: ! 101: thread->recover = 0; ! 102: return (TRUE); ! 103: ! 104: fault: ! 105: thread->recover = 0; ! 106: return (FALSE); ! 107: } ! 108: ! 109: static __inline__ ! 110: boolean_t ! 111: fetch4Byte( ! 112: thread_t thread, ! 113: vm_offset_t address, ! 114: unsigned long *data ! 115: ) ! 116: { ! 117: thread->recover = (vm_offset_t)&&fault; ! 118: ! 119: asm volatile( ! 120: "movl %%fs:%1,%0" ! 121: : "=r" (*data) ! 122: : "m" (*(unsigned long *)address)); ! 123: ! 124: thread->recover = 0; ! 125: return (TRUE); ! 126: ! 127: fault: ! 128: thread->recover = 0; ! 129: return (FALSE); ! 130: } ! 131: ! 132: static __inline__ ! 133: boolean_t ! 134: store4Byte( ! 135: thread_t thread, ! 136: vm_offset_t address, ! 137: unsigned long data ! 138: ) ! 139: { ! 140: thread->recover = (vm_offset_t)&&fault; ! 141: ! 142: asm volatile( ! 143: "movl %0,%%fs:%1" ! 144: : ! 145: : "r" (data), "m" (*(unsigned long *)address)); ! 146: ! 147: thread->recover = 0; ! 148: return (TRUE); ! 149: ! 150: fault: ! 151: thread->recover = 0; ! 152: return (FALSE); ! 153: } ! 154: ! 155: static __inline__ ! 156: boolean_t ! 157: fetch8Byte( ! 158: thread_t thread, ! 159: vm_offset_t address, ! 160: void *data ! 161: ) ! 162: { ! 163: thread->recover = (vm_offset_t)&&fault; ! 164: ! 165: asm volatile( ! 166: "movl %%fs:%1,%0" ! 167: : "=r" ( *(unsigned long *)data ) ! 168: : "m" ( *(unsigned long *)address )); ! 169: asm volatile( ! 170: "movl %%fs:%1,%0" ! 171: : "=r" ( *(((unsigned long *)data)+1) ) ! 172: : "m" ( *(((unsigned long *)address)+1) )); ! 173: ! 174: thread->recover = 0; ! 175: return (TRUE); ! 176: ! 177: fault: ! 178: thread->recover = 0; ! 179: return (FALSE); ! 180: } ! 181: ! 182: #endif
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.