1 //<MStar Software> 2 //****************************************************************************** 3 // MStar Software 4 // Copyright (c) 2010 - 2012 MStar Semiconductor, Inc. All rights reserved. 5 // All software, firmware and related documentation herein ("MStar Software") are 6 // intellectual property of MStar Semiconductor, Inc. ("MStar") and protected by 7 // law, including, but not limited to, copyright law and international treaties. 8 // Any use, modification, reproduction, retransmission, or republication of all 9 // or part of MStar Software is expressly prohibited, unless prior written 10 // permission has been granted by MStar. 11 // 12 // By accessing, browsing and/or using MStar Software, you acknowledge that you 13 // have read, understood, and agree, to be bound by below terms ("Terms") and to 14 // comply with all applicable laws and regulations: 15 // 16 // 1. MStar shall retain any and all right, ownership and interest to MStar 17 // Software and any modification/derivatives thereof. 18 // No right, ownership, or interest to MStar Software and any 19 // modification/derivatives thereof is transferred to you under Terms. 20 // 21 // 2. You understand that MStar Software might include, incorporate or be 22 // supplied together with third party`s software and the use of MStar 23 // Software may require additional licenses from third parties. 24 // Therefore, you hereby agree it is your sole responsibility to separately 25 // obtain any and all third party right and license necessary for your use of 26 // such third party`s software. 27 // 28 // 3. MStar Software and any modification/derivatives thereof shall be deemed as 29 // MStar`s confidential information and you agree to keep MStar`s 30 // confidential information in strictest confidence and not disclose to any 31 // third party. 32 // 33 // 4. MStar Software is provided on an "AS IS" basis without warranties of any 34 // kind. Any warranties are hereby expressly disclaimed by MStar, including 35 // without limitation, any warranties of merchantability, non-infringement of 36 // intellectual property rights, fitness for a particular purpose, error free 37 // and in conformity with any international standard. You agree to waive any 38 // claim against MStar for any loss, damage, cost or expense that you may 39 // incur related to your use of MStar Software. 40 // In no event shall MStar be liable for any direct, indirect, incidental or 41 // consequential damages, including without limitation, lost of profit or 42 // revenues, lost or damage of data, and unauthorized system use. 43 // You agree that this Section 4 shall still apply without being affected 44 // even if MStar Software has been modified by MStar in accordance with your 45 // request or instruction for your use, except otherwise agreed by both 46 // parties in writing. 47 // 48 // 5. If requested, MStar may from time to time provide technical supports or 49 // services in relation with MStar Software to you for your use of 50 // MStar Software in conjunction with your or your customer`s product 51 // ("Services"). 52 // You understand and agree that, except otherwise agreed by both parties in 53 // writing, Services are provided on an "AS IS" basis and the warranty 54 // disclaimer set forth in Section 4 above shall apply. 55 // 56 // 6. Nothing contained herein shall be construed as by implication, estoppels 57 // or otherwise: 58 // (a) conferring any license or right to use MStar name, trademark, service 59 // mark, symbol or any other identification; 60 // (b) obligating MStar or any of its affiliates to furnish any person, 61 // including without limitation, you and your customers, any assistance 62 // of any kind whatsoever, or any information; or 63 // (c) conferring any license or right under any intellectual property right. 64 // 65 // 7. These terms shall be governed by and construed in accordance with the laws 66 // of Taiwan, R.O.C., excluding its conflict of law rules. 67 // Any and all dispute arising out hereof or related hereto shall be finally 68 // settled by arbitration referred to the Chinese Arbitration Association, 69 // Taipei in accordance with the ROC Arbitration Law and the Arbitration 70 // Rules of the Association by three (3) arbitrators appointed in accordance 71 // with the said Rules. 72 // The place of arbitration shall be in Taipei, Taiwan and the language shall 73 // be English. 74 // The arbitration award shall be final and binding to both parties. 75 // 76 //****************************************************************************** 77 //<MStar Software> 78 #ifndef __USBCOMMON_H 79 #define __USBCOMMON_H 80 81 #include "asmCPU.h" 82 83 84 typedef void* (*mem_Alloc)(int size); 85 typedef void (*mem_Free)(void* pBuf); 86 typedef MS_U32 (*mem_VA2PA)(MS_U32 addr); 87 typedef MS_U32 (*mem_PA2VA)(MS_U32 addr, int bCached); 88 typedef void* (*mem_Cached2Noncached)(MS_U32 addr); 89 typedef void* (*mem_NonCached2Cached)(MS_U32 addr); 90 91 92 extern mem_Alloc pfnAllocCachedMem, pfnAllocNoncachedMem; 93 extern mem_Free pfnFreeCachedMem, pfnFreeNoncachedMem; 94 extern mem_VA2PA pfnVA2PA; 95 extern mem_PA2VA pfnPA2VA; 96 extern mem_Cached2Noncached pfnCached2Noncached; 97 extern mem_NonCached2Cached pfnNoncached2Cached; 98 99 #if 1 100 #define Usb_AllocateNonCachedMemory(x) pfnAllocNoncachedMem(x) 101 #define Usb_FreeNonCachedMemory(x) pfnFreeNoncachedMem(x) 102 #define Usb_AllocateCachedMemory(x) pfnAllocCachedMem(x) 103 #define Usb_FreeCachedMemory(x) pfnFreeCachedMem(x) 104 105 106 //extern void* (*kmalloc)(int size, int flag); 107 //extern void (*kfree)(void* pBuf); 108 #define kmalloc(size, flag) pfnAllocCachedMem(size) 109 #define kfree(pBuf) pfnFreeCachedMem(pBuf) 110 111 #define USB_VA2PA(addr) pfnVA2PA(addr) 112 #else 113 #define Usb_AllocateNonCachedMemory(x) kmalloc(x, 0) 114 #define Usb_FreeNonCachedMemory(x) kfree(x) 115 #define Usb_AllocateCachedMemory(x) kmalloc(x, 0) 116 #define Usb_FreeCachedMemory(x) kfree(x) 117 #endif 118 119 #if 1 120 #define KSEG02KSEG1(addr) pfnCached2Noncached((MS_U32)addr) //cached -> unchched, 20111017 for K2 121 #define KSEG12KSEG0(addr) pfnNoncached2Cached((MS_U32)addr) //unchched -> cached 122 #else 123 #define KSEG02KSEG1(addr) ((void *)((MS_U32)(addr)|0x20000000)) //cached -> unchched 124 #define KSEG12KSEG0(addr) ((void *)((MS_U32)(addr)&~0x20000000)) //unchched -> cached 125 #endif 126 127 #ifndef U32 128 #define U32 MS_U32 129 #endif 130 131 #ifndef U16 132 #define U16 MS_U16 133 #endif 134 135 #ifndef U8 136 #define U8 MS_U8 137 #endif 138 139 #ifndef S32 140 #define S32 MS_S32 141 #endif 142 143 #ifndef S16 144 #define S16 MS_S16 145 #endif 146 147 #ifndef S8 148 #define S8 MS_S8 149 #endif 150 151 #ifndef __u32 152 #define __u32 MS_U32 153 #endif 154 155 #ifndef __u16 156 #define __u16 MS_U16 157 #endif 158 159 #ifndef __u8 160 #define __u8 MS_U8 161 #endif 162 163 #ifndef __s32 164 #define __s32 MS_S32 165 #endif 166 167 #ifndef __s16 168 #define __s16 MS_S16 169 #endif 170 171 #ifndef __s8 172 #define __s8 MS_S8 173 #endif 174 175 #ifndef BOOL 176 #define BOOL MS_BOOL 177 #endif 178 179 #ifndef BOOLEAN 180 #define BOOLEAN MS_BOOL 181 #endif 182 183 184 #ifdef MS_DEBUG 185 #define ASSERT(_bool_) \ 186 { \ 187 if ( ! ( _bool_ ) ) \ 188 { \ 189 diag_printf("ASSERT FAIL: %s, %s %s %d\n", #_bool_, __FILE__, __PRETTY_FUNCTION__, __LINE__);\ 190 MAsm_CPU_SwDbgBp(); \ 191 } \ 192 } 193 #else 194 #define ASSERT(_bool_) \ 195 { \ 196 if ( ! ( _bool_ ) ) \ 197 { \ 198 diag_printf("ASSERT FAIL: %s %s %s %d\n", #_bool_, __FILE__, __PRETTY_FUNCTION__, __LINE__); \ 199 } \ 200 } 201 #endif 202 203 204 205 #define MsOS_DiableAllInterrupts() MsOS_DisableAllInterrupts() 206 207 externC int diag_printf( const char *fmt, ... ); 208 209 //Chip ID deifinition 210 #define CHIPID_NEPTUNE 0x2 211 #define CHIPID_ERIS 0x3 212 #define CHIPID_TITANIA 0x4 213 #define CHIPID_PLUTO 0x5 214 #define CHIPID_TRITON 0x6 215 #define CHIPID_TITANIA2 0xB 216 #define CHIPID_TITANIA3 0xF 217 #define CHIPID_EUCLID 0x15 218 #define CHIPID_TITANIA4 0x18 219 #define CHIPID_URANUS4 0x1B 220 #define CHIPID_TITANIA7 0x1C 221 #define CHIPID_JANUS 0x1D 222 #define CHIPID_TITANIA8 0x1F 223 #define CHIPID_TITANIA9 0x23 224 #define CHIPID_KRONUS 0x2F 225 #define CHIPID_KAISERIN 0x41 226 227 228 #endif 229 230