yu.dong | c33b307 | 2024-08-21 23:14:49 -0700 | [diff] [blame^] | 1 | |
| 2 | /***************************************************************************** |
| 3 | * Copyright Statement: |
| 4 | * -------------------- |
| 5 | * This software is protected by Copyright and the information contained |
| 6 | * herein is confidential. The software may not be copied and the information |
| 7 | * contained herein may not be used or disclosed except with the written |
| 8 | * permission of MediaTek Inc. (C) 2005 |
| 9 | * |
| 10 | * BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES |
| 11 | * THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE") |
| 12 | * RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON |
| 13 | * AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES, |
| 14 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF |
| 15 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. |
| 16 | * NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE |
| 17 | * SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR |
| 18 | * SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH |
| 19 | * THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO |
| 20 | * NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S |
| 21 | * SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM. |
| 22 | * |
| 23 | * BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE |
| 24 | * LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE, |
| 25 | * AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE, |
| 26 | * OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO |
| 27 | * MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. |
| 28 | * |
| 29 | * THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE |
| 30 | * WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF |
| 31 | * LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND |
| 32 | * RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER |
| 33 | * THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC). |
| 34 | * |
| 35 | *****************************************************************************/ |
| 36 | |
| 37 | /***************************************************************************** |
| 38 | * |
| 39 | * Filename: |
| 40 | * --------- |
| 41 | * BC_drv.c |
| 42 | * |
| 43 | * Project: |
| 44 | * -------- |
| 45 | * Maui_Software |
| 46 | * |
| 47 | * Description: |
| 48 | * ------------ |
| 49 | * Driver 0f Bit Copy. |
| 50 | * |
| 51 | * Author: |
| 52 | * ------- |
| 53 | * ------- |
| 54 | * |
| 55 | *============================================================================ |
| 56 | * HISTORY |
| 57 | * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!! |
| 58 | *------------------------------------------------------------------------------ |
| 59 | * removed! |
| 60 | * removed! |
| 61 | * removed! |
| 62 | * |
| 63 | * removed! |
| 64 | * removed! |
| 65 | * removed! |
| 66 | * |
| 67 | *------------------------------------------------------------------------------ |
| 68 | * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!! |
| 69 | *============================================================================ |
| 70 | ****************************************************************************/ |
| 71 | |
| 72 | #include "drv_comm.h" |
| 73 | #include "intrCtrl.h" |
| 74 | #include "drv_hisr.h" |
| 75 | #include "BC_drv.h" |
| 76 | |
| 77 | #if defined(__3G_F8F9BC_HW_DRV_V1__) |
| 78 | |
| 79 | static kal_mutexid BC_mutex; |
| 80 | |
| 81 | |
| 82 | /***************************************************************************** |
| 83 | * FUNCTION |
| 84 | * F8Cipher |
| 85 | * |
| 86 | * DESCRIPTION |
| 87 | * Do the F8 Cipher funtion. |
| 88 | * |
| 89 | * PARAMETERS |
| 90 | * src [IN] : source data pointer |
| 91 | * srcOffset [IN] : source data bit offset |
| 92 | * dest [IN] : destination data pointer |
| 93 | * destOffset [IN] : destination data bit offset |
| 94 | * length [IN] : total bit length |
| 95 | * |
| 96 | * RETURNS |
| 97 | * None |
| 98 | *****************************************************************************/ |
| 99 | |
| 100 | |
| 101 | void BitCopy(const kal_uint8 *src, kal_uint16 srcOffset, kal_uint8 *dest, kal_uint16 *destOffset, kal_uint16 length) |
| 102 | { |
| 103 | |
| 104 | kal_uint32 Input32Temp, BC_it; |
| 105 | kal_uint32 srcStartAddr, dstStartAddr; |
| 106 | kal_uint16 destOffsetTemp = *destOffset; |
| 107 | |
| 108 | srcStartAddr = (kal_uint32) (src + ( srcOffset / 8 )); |
| 109 | srcOffset = srcOffset % 8; |
| 110 | |
| 111 | dstStartAddr = (kal_uint32) (dest + ( (*destOffset) / 8 )); |
| 112 | (*destOffset) = (*destOffset) % 8; |
| 113 | |
| 114 | |
| 115 | if (!BC_mutex){ |
| 116 | BC_mutex = kal_create_mutex("BC_mutex");} |
| 117 | |
| 118 | |
| 119 | kal_take_mutex(BC_mutex); |
| 120 | |
| 121 | //reset all register |
| 122 | DRV_WriteReg32(BC_REG_START,0); |
| 123 | |
| 124 | //input source addr |
| 125 | DRV_WriteReg32(BC_REG_SRC, ((kal_uint32)(srcStartAddr))); |
| 126 | |
| 127 | //output destination addr |
| 128 | DRV_WriteReg32(BC_REG_DST, ((kal_uint32)(dstStartAddr))); |
| 129 | |
| 130 | |
| 131 | //output destination last byte addr |
| 132 | Input32Temp = ((length - (8 - (*destOffset))) > 0) ? (kal_uint32)(dstStartAddr + ((length - (8 - (*destOffset)) + 7) / 8)) : (kal_uint32)dstStartAddr; |
| 133 | DRV_WriteReg32(BC_REG_LDST, ((kal_uint32)Input32Temp)); |
| 134 | |
| 135 | |
| 136 | //input copy length |
| 137 | Input32Temp = 0; |
| 138 | Input32Temp = length & 0x0000FFFF; |
| 139 | DRV_WriteReg32(BC_REG_SIZE, ((kal_uint32)Input32Temp)); |
| 140 | |
| 141 | |
| 142 | //set wo and ro(also reset all) |
| 143 | Input32Temp = 0; |
| 144 | Input32Temp = (kal_uint32)(( ((kal_uint32)(*destOffset))<<4) | ((kal_uint32)srcOffset) | (0x00030000)); |
| 145 | DRV_WriteReg32(BC_REG_CON, (kal_uint32)Input32Temp); |
| 146 | |
| 147 | |
| 148 | //start the BC engine |
| 149 | DRV_WriteReg32(BC_REG_START, 0x00008000); |
| 150 | |
| 151 | |
| 152 | //polling completed interrupt |
| 153 | while(1){ |
| 154 | BC_it = DRV_Reg32(BC_REG_STA); |
| 155 | if((BC_it&0x00000002)!=0) |
| 156 | break; |
| 157 | } |
| 158 | |
| 159 | kal_give_mutex(BC_mutex); |
| 160 | |
| 161 | (*destOffset) = destOffsetTemp + length; |
| 162 | } |
| 163 | |
| 164 | #endif /* __3G_F8F9BC_HW_DRV_V1__ */ |