rjw | 6c1fd8f | 2022-11-30 14:33:01 +0800 | [diff] [blame] | 1 | /***************************************************************************** |
| 2 | * Copyright Statement: |
| 3 | * -------------------- |
| 4 | * This software is protected by Copyright and the information contained |
| 5 | * herein is confidential. The software may not be copied and the information |
| 6 | * contained herein may not be used or disclosed except with the written |
| 7 | * permission of MediaTek Inc. (C) 2005 |
| 8 | * |
| 9 | * BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES |
| 10 | * THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE") |
| 11 | * RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON |
| 12 | * AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES, |
| 13 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF |
| 14 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. |
| 15 | * NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE |
| 16 | * SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR |
| 17 | * SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH |
| 18 | * THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO |
| 19 | * NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S |
| 20 | * SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM. |
| 21 | * |
| 22 | * BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE |
| 23 | * LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE, |
| 24 | * AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE, |
| 25 | * OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO |
| 26 | * MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. |
| 27 | * |
| 28 | * THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE |
| 29 | * WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF |
| 30 | * LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND |
| 31 | * RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER |
| 32 | * THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC). |
| 33 | * |
| 34 | *****************************************************************************/ |
| 35 | |
| 36 | /***************************************************************************** |
| 37 | * |
| 38 | * Filename: |
| 39 | * --------- |
| 40 | * ramdisk_gprot.h |
| 41 | * |
| 42 | * Project: |
| 43 | * -------- |
| 44 | * Maui |
| 45 | * |
| 46 | * Description: |
| 47 | * ------------ |
| 48 | * This is header file for RAM Disk drivers. |
| 49 | * |
| 50 | * Author: |
| 51 | * ------- |
| 52 | * ------- |
| 53 | * |
| 54 | *============================================================================ |
| 55 | * HISTORY |
| 56 | * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!! |
| 57 | *------------------------------------------------------------------------------ |
| 58 | * removed! |
| 59 | * removed! |
| 60 | * removed! |
| 61 | * |
| 62 | * removed! |
| 63 | * removed! |
| 64 | * removed! |
| 65 | * |
| 66 | * removed! |
| 67 | * removed! |
| 68 | * removed! |
| 69 | * |
| 70 | * removed! |
| 71 | * removed! |
| 72 | * removed! |
| 73 | * |
| 74 | * removed! |
| 75 | * removed! |
| 76 | * removed! |
| 77 | * removed! |
| 78 | * |
| 79 | * removed! |
| 80 | * removed! |
| 81 | * removed! |
| 82 | * |
| 83 | * removed! |
| 84 | * removed! |
| 85 | * removed! |
| 86 | *------------------------------------------------------------------------------ |
| 87 | * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!! |
| 88 | *============================================================================ |
| 89 | *******************************************************************************/ |
| 90 | #ifndef __RAMDISK_DRV_H__ |
| 91 | #define __RAMDISK_DRV_H__ |
| 92 | |
| 93 | #include "custom_MemoryDevice.h" |
| 94 | #include "kal_general_types.h" |
| 95 | #include "fs_gprot.h" |
| 96 | |
| 97 | /*-------------------------------------------------------- |
| 98 | * RAM Disk Size Configurations |
| 99 | *--------------------------------------------------------*/ |
| 100 | |
| 101 | |
| 102 | #ifdef RAMDISK_FS_SIZE |
| 103 | #define RAM_FS_SIZE (RAMDISK_FS_SIZE) // read FS size setting in custom_MemoryDevice.h |
| 104 | #else |
| 105 | #define RAM_FS_SIZE (0x01000000) // default total RAM disk size: 16 MB |
| 106 | #endif |
| 107 | |
| 108 | #ifdef RAMDISK_FS_FIRST_DRIVE_SECTORS |
| 109 | #define RAM_FS_FIRST_DRIVE_SECTORS (RAMDISK_FS_FIRST_DRIVE_SECTORS) // read FS first partition size setting in custom_MemoryDevice.h |
| 110 | #else |
| 111 | #define RAM_FS_FIRST_DRIVE_SECTORS (0) // default public drive size: 0 (unit: number of 512-byte-sectors) |
| 112 | #endif |
| 113 | |
| 114 | /*-------------------------------------------------------- |
| 115 | * RAM Disk Internal Definitions |
| 116 | *--------------------------------------------------------*/ |
| 117 | |
| 118 | #define RAM_SECTOR_SIZE (512) |
| 119 | |
| 120 | /*-------------------------------------------------------- |
| 121 | * RAM Disk Error Codes |
| 122 | *--------------------------------------------------------*/ |
| 123 | |
| 124 | typedef enum |
| 125 | { |
| 126 | RAMDISK_NO_ERROR = 0, |
| 127 | RAMDISK_INVALID_DISK_OFFSET = -1, |
| 128 | RAMDISK_INVALID_DISK_SIZE = -2, |
| 129 | RAMDISK_NOT_EXISTED = -3, |
| 130 | RAMDISK_ERROR_CODE_END = -65536 |
| 131 | } ramdisk_error_code; |
| 132 | |
| 133 | /*-------------------------------------------------------- |
| 134 | * RAM Disk Query and Read Tool (for META Tool only now) |
| 135 | *--------------------------------------------------------*/ |
| 136 | |
| 137 | /* |
| 138 | * Check if RAM Disk is supported in this project. Please use this API to detect RAM Disk before using any other RAM Disk APIs. |
| 139 | * |
| 140 | * Return Value: |
| 141 | * 1: RAM Disk is existed. |
| 142 | * 0: RAM Disk is not existed. |
| 143 | */ |
| 144 | kal_uint32 ramdisk_is_existed(void); |
| 145 | |
| 146 | /* |
| 147 | * Get start address of RAM Disk. |
| 148 | * |
| 149 | * Return Value: |
| 150 | * Valid address must be a non-zero value. 0 means an invalid address. |
| 151 | */ |
| 152 | kal_uint32 ramdisk_get_raw_start_address(void); |
| 153 | |
| 154 | /* |
| 155 | * Get length of RAM Disk. |
| 156 | * |
| 157 | * Return Value: |
| 158 | * Valid length must be a non-zero value. 0 means an invalid length. |
| 159 | */ |
| 160 | kal_uint32 ramdisk_get_raw_length(void); |
| 161 | |
| 162 | /* |
| 163 | * Get raw data from RAM Disk. |
| 164 | * |
| 165 | * Parameters: |
| 166 | * [in/out] buf: Buffer address to read RAM Disk data (Buffer address could be byte-aligned) |
| 167 | * [in] offset: Start offset. The valid range is 0 to disk size. |
| 168 | * [in] length: Total read length |
| 169 | * |
| 170 | * Return Value: |
| 171 | * Positive integer: Number of bytes read to buffer successfully. |
| 172 | * Negative integer: It is an error code. Please refer to ramdisk_error_code enum defined in ramdisk_gprot.h for the meaning of error codes. |
| 173 | */ |
| 174 | kal_int32 ramdisk_get_raw_data(void * buf, kal_uint32 offset, kal_uint32 length); |
| 175 | |
| 176 | /*-------------------------------------------------------- |
| 177 | * RAM Disk Management Layer |
| 178 | *--------------------------------------------------------*/ |
| 179 | int ramdisk_fdm_mount_device(void * DriveData, int DeviceNumber, int DeviceType, kal_uint32 Flags); |
| 180 | int ramdisk_fdm_shutdown(void * DriveData); |
| 181 | int ramdisk_fdm_read_sectors(void * DriveData, kal_uint32 Sector, kal_uint32 Sectors, void * Data); |
| 182 | int ramdisk_fdm_write_sectors(void * DriveData, kal_uint32 Sector, kal_uint32 Sectors, void * Data); |
| 183 | int ramdisk_fdm_media_changed(void * DriveData); |
| 184 | int ramdisk_fdm_get_disk_geometry(void * DriveData, FS_PartitionRecord * DiskGeometry, kal_uint8 * MediaDescriptor); |
| 185 | int ramdisk_fdm_recoverable_write_sectors(void * DriveData, kal_uint32 Sector, kal_uint32 Sectors, void * Buffer); |
| 186 | int ramdisk_fdm_resume_sector_states(void * DriveData); |
| 187 | void ramdisk_util_memcpy(void * dst, void * src, kal_uint32 len); |
| 188 | |
| 189 | #endif // __RAMDISK_DRV_H__ |
| 190 | |