1 /*---------------------------------------------------------------------------*
2 
3   Copyright 2010-2011 Nintendo.  All rights reserved.
4 
5   These coded instructions, statements, and computer programs contain
6   proprietary information of Nintendo of America Inc. and/or Nintendo
7   Company Ltd., and are protected by Federal copyright law.  They may
8   not be disclosed to third parties or copied or duplicated in any form,
9   in whole or in part, without the prior written consent of Nintendo.
10 
11  *---------------------------------------------------------------------------*/
12 // --------------------------------------------------
13 // windows/gx2.h
14 //
15 //      Conglomeration include file for GX2 files that are also built on the PC.
16 //
17 //      This should only be included by Windows Projects!
18 //
19 // This file should probably be moved to a different directory.
20 // (One for common private include files for gfx tools; it doesn't exist yet.)
21 //
22 // --------------------------------------------------
23 
24 #ifndef __WINDOWS_GX2_H__
25 #define __WINDOWS_GX2_H__
26 
27 // This PC header file replaces the following cafe headers
28 #define __OS_H__
29 #define __OSTIME_H__
30 #define __MEM_H__
31 #define MEM_HEAPCOMMON_H__
32 #define _CAFE_GX2_UBMHELPER_H_
33 
34 // Public header needed by all Cafe projects:
35 #include <types.h>
36 
37 // Include our PC stub functionality
38 #include <windows/os.h>
39 #include <windows/mem.h>
40 
41 // We need these on the PC
42 #include <stdio.h>
43 #include <stdlib.h>
44 #include <stdarg.h>
45 
46 #define __func__ __FUNCTION__
47 #define ALIGNVAR(x)
48 
49 // Provide replacement for PPC native instruction
50 // if you get a compile error here, you need to force CPP compilation, /TP
__cntlzw(u32 val)51 inline u32 __cntlzw(u32 val)
52 {
53     u32 cnt = 32;
54     while (val) { val >>=1; cnt--; }
55     return cnt;
56 }
57 
58 // In some cases, need this:
59 #define __bytereversed
60 
61 // Make GX2 easier to build on the PC
62 #define GX2_OFFLINE_COMPILE
63 #define GX2_SURFACE_STANDALONE
64 #define GX2_DIRECT_CALLBACK
65 #define GX2_DONT_USE_WG
66 #define GX2_USE_INFINITELY_FAST_HARDWARE
67 #define GX2_PERFORMANCE_DISABLED
68 #define _GX2CreateUBMDevice(u32)
69 
70 // It's now safe to include cafe/gx2.h
71 #include <cafe/gx2.h>
72 
73 // This is part of GX2_SURFACE_STANDALONE
74 #define GPU_V1 0
75 #define GPU_V2 1
76 #define GPU_Cafe 2
77 
78 // Context utility structure.
79 typedef struct
80 {
81     u32     gbTilingConfig; // Used to change default register value. Set to zero to use default
82     u32     gpu;            // Target gpu
83     void*   addrLib;        // address library handle
84     BOOL    bugFix2197;     // Apply fix for bug 2197 in GX2CalcSurfaceSizeAndAlignment
85 } gx2UtilsContext;
86 
87 // Other details:
88 extern void* gAddrLibHandle;
89 extern gx2UtilsContext gContext;
90 extern gx2UtilsContext* gContextPtr;
91 
92 BOOL InitAddressLib(u32 gpu, u32 gbAddrConfigValue);
93 BOOL DestroyAddressLib();
94 
95 // We might find the capture interface helpful
96 #undef GX2DebugCaptureInit
97 #define GX2DebugCaptureInit(initAttribs)
98 
99 #endif // __WINDOWS_GX2_H__
100