2 ===========================================================================
5 Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
7 This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
9 Doom 3 Source Code is free software: you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation, either version 3 of the License, or
12 (at your option) any later version.
14 Doom 3 Source Code is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
22 In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
24 If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
26 ===========================================================================
30 #import "../../idlib/precompiled.h"
32 #import <Foundation/Foundation.h>
34 #import <mach/vm_map.h>
37 #define CD_MOUNT_NAME "DOOM"
39 #include "macosx_local.h"
40 #include "macosx_sys.h"
42 //extern "C" void *vm_allocate(unsigned, unsigned*, unsigned, int);
43 //extern "C" void vm_deallocate(unsigned, unsigned*, unsigned);
45 const char *macosx_scanForLibraryDirectory(void)
47 return "/Library/DOOM";
51 static long size_save;
53 void *osxAllocateMemoryNV(long size, float readFrequency, float writeFrequency, float priority)
58 kr = vm_allocate(mach_task_self(),
59 (vm_address_t *)&buffer,
74 void osxFreeMemoryNV(void *pointer)
77 vm_deallocate(mach_task_self(),
78 (vm_address_t)pointer,
84 void *osxAllocateMemory(long size)
89 size += sizeof( int );
90 kr = vm_allocate(mach_task_self(),
91 (vm_address_t *)&buffer,
107 void osxFreeMemory(void *pointer)
113 vm_deallocate(mach_task_self(), (vm_address_t)ptr, size);
117 static inline void __eieio(void)
122 static inline void __sync(void)
127 static inline void __isync(void)
132 static inline void __dcbf(void *base, unsigned long offset)
134 __asm__ ("dcbf %0, %1"
136 : "r" (base), "r" (offset)
140 static inline void __dcbst(void *base, unsigned long offset)
142 __asm__ ("dcbst %0, %1"
144 : "r" (base), "r" (offset)
148 static inline void __dcbz(void *base, unsigned long offset)
150 __asm__ ("dcbz %0, %1"
152 : "r" (base), "r" (offset)
156 void Sys_FlushCacheMemory( void *base, int bytes ) {
159 for(i = 0; i < bytes; i+= 32) {
167 *(volatile unsigned long *)(base + i);