blob: 553e5bb55444a2098883834521386fc8cbe77436 [file] [log] [blame]
rjw6c1fd8f2022-11-30 14:33:01 +08001/*****************************************************************************
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 * fs_iprot.h
41 *
42 * Project:
43 * --------
44 * Maui Software
45 *
46 * Description:
47 * ------------
48 * This file provides the header of MTK file system internal prototypes.
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 * removed!
79 * removed!
80 * removed!
81 *
82 * removed!
83 * removed!
84 * removed!
85 *
86 * removed!
87 * removed!
88 * removed!
89 *
90 * removed!
91 * removed!
92 * removed!
93 *
94 * removed!
95 * removed!
96 * removed!
97 *
98 * removed!
99 * removed!
100 * removed!
101 *
102 * removed!
103 * removed!
104 * removed!
105 *
106 * removed!
107 * removed!
108 * removed!
109 *------------------------------------------------------------------------------
110 * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
111 *============================================================================
112 ****************************************************************************/
113#ifndef _FS_IPROT_H
114#define _FS_IPROT_H
115
116#include "fs_gprot.h"
117
118//-----------------------------------------------------------------------------
119// Internal Macros
120//-----------------------------------------------------------------------------
121// FS_DeviceInfo (RTFDeviceInfo) related definition (internal)
122#define FS_DEVICE_FLAG_VISIBLE (0x00000001)
123#define FS_DEVICE_FLAG_PRESENT (0x00000010)
124
125//-- TLS (internal)
126#ifndef MAX_TLS_INDEX
127#define MAX_TLS_INDEX 2
128#endif
129
130//-- Trace (internal)
131#define FS_TRACE_INDEX 2 // (should obsolete)
132
133//-- Flag of FS_Buffer.recoverable_flag (internal)
134#define FS_RECOVERABLE_WRITE 1
135#define FS_NORMAL_WRITE 0
136
137//-- Recursive Engine maximum level
138#define FS_MAX_FOLDER_LEVEL (128) // The maximum folder level for FAT FS
139
140//-- Short filename
141#define FS_PRIVATE_FLAG_IGNORE_SFN_GENERATION (0x0001)
142
143
144//-----------------------------------------------------------------------------
145// Internal Enumerations
146//-----------------------------------------------------------------------------
147//-- For Driver only
148typedef enum
149{
150 FS_DEVICE_UNKNOWN,
151 FS_DEVICE_FLOPPY,
152 FS_DEVICE_FDISK
153} FS_DRIVER_DEVICE_ENUM;
154
155//-- For Driver->MessageAck
156typedef enum
157{
158 FS_DEV_IN_ACK_ENUM = 1,
159 FS_DEV_SLOT_ACK_ENUM,
160 FS_DEV_OUT_ACK_ENUM
161} FS_ACK_TYPE_ENUM;
162
163//-- For exception memory
164typedef enum
165{
166 FS_MEM_TYPE_DEFAULT = 0x00, // (invalid type)
167 FS_MEM_TYPE_XDATA = 0x01, // for _XData
168 FS_MEM_TYPE_INVALID = 0xFF // (invalid type)
169} fs_mem_type_enum;
170
171//-- Open Hint Cache
172typedef enum {
173 FS_HINT_FREE = 0,
174 FS_HINT_ALLOCATED,
175 FS_HINT_CREATING,
176 FS_HINT_STABLE,
177 FS_HINT_STABLE_LOCKED,
178 FS_HINT_DELETED_LOCKED
179} FS_OpenHintStatusEnum;
180
181//-- Device CFI information query
182typedef enum
183{
184 FS_DEV_NO_BOOT = 0,
185 FS_DEV_DUAL_BOOT,
186 FS_DEV_TOP_BOOT,
187 FS_DEV_BOTTOM_BOOT
188} FS_DEVICE_BOOT_LOCATION_ENUM;
189
190//-- FS trace file enumeration
191typedef enum {
192 rtfiles_c = 0,
193 rtfcore_c,
194 rtfbuf_c,
195 rtfex_c,
196 fs_func_c,
197 fs_func_adv_c,
198 fs_func_async_c,
199 fs_internal_c,
200 fs_internal_api_c,
201 fs_kal_c,
202 fs_task_c,
203 fs_utility_c,
204 fs_usbms_c,
205 fs_unknown_src_file
206} fs_src_file_enum;
207
208
209//-----------------------------------------------------------------------------
210// Internal Structure
211//-----------------------------------------------------------------------------
212//-- Exception Handler: TLS
213typedef struct
214{
215 fs_job_id current_job;
216 kal_bool aborted;
217} fs_tls_struct;
218
219
220// Open Hint Location
221typedef struct {
222 kal_uint32 Cluster; // zero if none
223 kal_uint32 Index; // undefined if none
224 kal_uint32 DirCluster;
225} FS_OpenHintLocation;
226
227// FS Internal open hint
228typedef struct {
229 FS_OpenHintStatusEnum Status;
230 kal_uint8 FirstLevel;
231 kal_uint8 HintNum;
232 kal_uint8 FirstHint;
233 kal_uint8 HitStamp;
234 kal_uint8 Flag;
235 kal_uint16 PathLength;
236 FS_Drive * Drive;
237 kal_uint32 SerialNumber;
238 FS_OpenHintLocation * Location;
239 WCHAR Path[FS_MAX_PATH / 2];
240} FS_OpenHintPath;
241
242// FS external open hint
243typedef struct {
244 // Dir Location
245 kal_uint32 Cluster;
246 kal_uint32 Index;
247 // Extension
248 kal_uint8 Level;
249 kal_uint8 PathIndex;
250 kal_uint8 MatchType;
251 kal_uint8 Flag;
252 kal_uint32 DirCluster;
253} FS_OpenHintInt;
254
255// SD Format
256typedef enum
257{
258 FS_SD_FMT_OK = 0,
259 FS_SD_FMT_SIGNATURE_FAIL = 1,
260 FS_SD_FMT_MBR_FAIL = 2,
261 FS_SD_FMT_BS_FAIL = 3
262} FS_SD_FMT_ENUM;
263
264//-----------------------------------------------------------------------------
265// Internal API Prototype
266//-----------------------------------------------------------------------------
267#if !(defined(__CCCIFS_SUPPORT__) && defined(__MTK_TARGET__))
268
269/* DOM-NOT_FOR_SDK-BEGIN */
270
271// Feature Phone
272
273/*****************************************************************************
274 * <GROUP FileContent>
275 *
276 * FUNCTION
277 * FS_Close
278 * DESCRIPTION
279 * To Close all currently open files.
280 * <WARNING>
281 * PARAMETERS
282 * N/A
283 * RETURNS
284 * If the function succeeds, the return value is the number of open files found
285 * and closed. If the function fails, the return value is a negative error code.
286 * In case of failure, some files may have been closed successfully, while others
287 * could not be closed.This function also invalidates all of FS's file handles,
288 * which may be in use by the application. Subsequent use of such handles will
289 * fail.
290 *****************************************************************************/
291extern int FS_CloseAll(void);
292
293/*****************************************************************************
294 * <GROUP FileOperation>
295 *
296 * FUNCTION
297 * FS_ReleaseFH
298 * DESCRIPTION
299 * This function can release all the file handles used by the specified task.
300 * PARAMETERS
301 * TaskId : [IN]<P>Specified the file handled owned by the task. If this value
302 * is NULL, FS will release all the file handles occupied by
303 * the current task.
304 * RETURNS
305 * Always returns FS_NO_ERROR.
306 *****************************************************************************/
307extern int FS_ReleaseFH(void * TaskId);
308
309/*****************************************************************************
310 * <GROUP Obsolete >
311 *
312 * FUNCTION
313 * FS_GetFirstCluster
314 * DESCRIPTION
315 * This function provides facility to get the first cluster (unique file/folder
316 * information in a drive).
317 * PARAMETERS
318 * FileHandle : [IN] <P>User provides specified file handle
319 * Cluster : [OUT]<P>The first cluster number to return
320 * RETURNS
321 * Successful : FS_NO_ERROR
322 * Failed : Please refer to fs_error_enum.
323 *****************************************************************************/
324extern int FS_GetFirstCluster(FS_HANDLE FileHandle, UINT * Cluster);
325
326/*****************************************************************************
327 * <GROUP VolumeManagement>
328 *
329 * FUNCTION
330 * FS_CreateBootSector
331 * DESCRIPTION
332 * Create a valid boot sector for a logical drive.
333 * PARAMETERS
334 * BootSector : [OUT] <P>Must point to a buffer of at least 512 bytes. It will receive the boot sector data.
335 * Partition : [IN] <P>Must point to a partition record describing the partition for which the boot sector is intended. If the boot record is to be written to a hard disk, this data must be identical to the respective partition record in the partition table.
336 * MediaDescriptor : [IN] <P>It's the value to be written into the BIOS parameter block. FS never uses this value, but other operating systems may require it to mount a volume. MediaDescriptors usually supplied by the device driver.
337 * MinSectorsPerCluster : [IN] <P>Specifies the minimum number of sectors per cluster.
338 * Flags : [IN] <P>Controls additional properties of the file system to set up. Please refer to the documentation of function FS_Format for details about parameters MinSectorsPerCluster and Flags.
339 * RETURNS
340 * If the function succeeds, it returns the first data sector number (if flag has FS_FMT_GET_DATA_SECTOR) or the FAT type. If it fails, the return value is a negative error code.
341 * NOTE
342 * (1) Path name should be exactly the same as one in QuotaSet.
343 * (2) To save more resource, we use ¡§BYTE¡¨ (unsigned char) instead of FS traditional WCHAR here.
344 *****************************************************************************/
345extern int FS_CreateBootSector(void * BootSector, const FS_PartitionRecord * Partition, BYTE MediaDescriptor, UINT MinSectorsPerCluster, UINT Flags);
346
347/*****************************************************************************
348 * <GROUP VolumeManagement>
349 *
350 * FUNCTION
351 * FS_GetPartitionInfo
352 * DESCRIPTION
353 * Return information about a partition or physical disk.
354 * PARAMETERS
355 * DriveName : [IN] <P>Must be a valid file name (for example, a root directory named "C:\"), a logical drive name ("\\.\C:"), or a physical disk name ("\\.\PHYSICALDRIVE0"). If the name refers to a physical disk file, the returned partition information applies to the whole disk, not just a single logical drive.
356 * PartitionInfo : [OUT] <P>Please refer to FS_PartitionRecord.
357 * RETURNS
358 * If the function succeeds, the return value is FS_NO_ERROR and the structure is filled as described below. If the function fails, the return value is a negative error code.
359 * <xtable>
360 * Value Meaning
361 * ----------------- -------------------------------------------------------
362 * Partition This field contains a physical copy of the partition record read from the partition table to mount this partition. For floppy disks and physical disks, FS will create a fake partition record describing the whole disk.
363 * PartitionSector The physical sector number of the hosting device containing the partition table containing the above partition record. This value will be 0 for all primary partitions.
364 * PhysicalDiskIndex The index of the physical disk device hosting this partition, or -1 for a floppy disk. The first hard disk in the system has index 0.
365 * BytesPerSector The sector size of the disk.
366 * MediaDescriptor The media byte of the hosting device. This value will be F8h for hard disks and some other value read from the boot sector for floppies. If this value is 0, FS was unable to determine the media descriptor. This situation can occur when the boot sector of a floppy disk is unreadable.
367 * DeviceListIndex The zero-based index of the device hosting the partition in FS's device list.
368 * </xtable>
369 * NOTE
370 * Please note that actual values must be calculated as follows:
371 * ActualStartSector = StartSector & 63;
372 * ActualStartTrack = StartTrack | ((StartSector & 0xC0) << 2);
373 * ActualEndSector = EndSector & 63;
374 * ActualEndTrack = EndTrack | ((EndSector & 0xC0) << 2);
375 * For large hard disks, the EndTrack value may be incorrect, because it is limited to 1024 cylinders. If you need to calculate the size of a disk or partition, rely on field Sectors.
376 *****************************************************************************/
377extern int FS_GetPartitionInfo(const WCHAR * DriveName, FS_PartitionRecord * PartitionInfo);
378
379/*****************************************************************************
380 * <GROUP VolumeManagement>
381 *
382 * FUNCTION
383 * FS_MappingDrive
384 * DESCRIPTION
385 * This function can map one drive to another drive name. The first user, FS_SanityCheck
386 * in system booting up, will call FS_GetDrive to get the system drive name and map it
387 * to another fixed drive in all project. <color red>Here we decided to map it to ¡¥Z¡¦ drive in
388 * all projects.<color>
389 * PARAMETERS
390 * UpperOldDrv : [IN] <P>Capital system drive name you get
391 * UpperNewDrv : [IN] <P>Capital fixed drive name you want
392 * RETURN VALUES
393 * FS_PARAM_ERROR (-2):
394 * Drive number over range.
395 * For an example: if this project has 6 drive,
396 * UpperOldDrv should be 67~70, UpperNewDrv should be 71~90 (not include 88)
397 * FS_ACCESS_DENIED (-16):
398 * Call this function without initialize file system
399 * One should call function, FS_GetDrive, to get system drive number (UpperOldDrv) first.
400 * The function will help you to initialize file system if it has not been initiated yet.
401 * NOTE
402 * (1) This function now only supports one mapping. If you map it to another drive again, the former configuration will be reset.
403 * (2) Drive ¡¥X¡¦ is reserved in file system. You should not map system drive to ¡¥X¡¦.
404 * (3) If you map system drive, say ¡¥D¡¦ drive, to ¡¥Z¡¦ drive. Then you can access system drive either via ¡¥D¡¦ or ¡¥Z¡¦ later.
405 *****************************************************************************/
406extern int FS_MappingDrive(UINT UpperOldDrv, UINT UpperNewDrv);
407
408/*****************************************************************************
409 * <GROUP DiskManagement>
410 *
411 * FUNCTION
412 * FS_SetDiskFlag
413 * DESCRIPTION
414 * Create a flag file in system drive for sanity check indication. If the system shutdown normally, FS_ClearDiskFlag should be called to delete the file. If the file exists when system boot up, sanity check will be triggered.
415 * PARAMETERS
416 * N/A
417 * RETURNS
418 * Refer to fs_error_enum. If the function succeeds, the return value is FS_NO_ERROR. If the function fails, the return value is a negative error code.
419 *****************************************************************************/
420extern int FS_SetDiskFlag(void);
421
422/*****************************************************************************
423 * <GROUP DiskManagement>
424 *
425 * FUNCTION
426 * FS_ClearDiskFlag
427 * DESCRIPTION
428 * Delete the flag file in system drive.
429 * PARAMETERS
430 * N/A
431 * RETURNS
432 * If the function succeeds, the return value is FS_NO_ERROR. If the function fails, the return value is a negative error code.
433 *****************************************************************************/
434extern int FS_ClearDiskFlag(void);
435
436/*****************************************************************************
437 * <GROUP DiskManagement>
438 *
439 * FUNCTION
440 * FS_CreateMasterBootRecord
441 * DESCRIPTION
442 * Create a valid master boot record with a partition table for a hard disk.
443 * PARAMETERS
444 * SectorBuffer: [OUT] <P>Must point to a buffer of at least 512 bytes size. It will receive the new master boot record.
445 * DiskGeometry: [OUT] <P>It's a pointer to a partition record describing the complete hard disk. This information will usually supplied by a device driver.
446 * RETURNS
447 * If the function succeeds, the return value is FS_NO_ERROR.
448 * If the function fails, the return value is a negative error code.
449 * FS_CreateMasterBootRecord fills the supplied buffer with a master boot loader and a partition table containing exactly one primary active partition spanning the complete disk.
450 * Please refer to FS_GetPartitionInfo for more information about structure FS_PartitionRecord.
451 *****************************************************************************/
452extern int FS_CreateMasterBootRecord(void * SectorBuffer, const FS_PartitionRecord * DiskGeometry);
453
454/*****************************************************************************
455 * <GROUP DiskManagement>
456 *
457 * FUNCTION
458 * FS_SplitPartition
459 * DESCRIPTION
460 * Split the last partition in a partition table into two partitions.
461 * PARAMETERS
462 * MasterBootRecord : [OUT] <P>Must point to a buffer of at least 512 bytes size containing a valid master boot record with a partition table.
463 * Sectors : [IN] <P>Specifies how many sectors to allocate to the currently last partition. It must be less than the number of sectors it currently has. All remaining sectors are then allocated to a new partition.
464 * RETURNS
465 * If the function succeeds, the return value is a zero-based index of the created partition (a value between 1 and 3). If the function fails, the return value is a negative error code.
466 * Parameter Sectors is rounded down to a multiple of a cylinder, so the actual number of sectors can be less than the specified value.
467 *****************************************************************************/
468extern int FS_SplitPartition(void * MasterBootRecord, UINT Sectors);
469
470/*****************************************************************************
471 * <GROUP LifeCycle>
472 *
473 * FUNCTION
474 * FS_ShutDown
475 * DESCRIPTION
476 * This function will un-mount all devices and calls disk drivers to shutdown all the disks. This API is limited used by system process.
477 * RETURNS
478 * N/A
479 *****************************************************************************/
480extern void FS_ShutDown(void);
481
482/*****************************************************************************
483 * <GROUP LifeCycle>
484 *
485 * FUNCTION
486 * FS_UnlockAll
487 * DESCRIPTION
488 * Unlock all devices and files. This API is limited to be used in system error handling processing.
489 * RETURNS
490 * Return the number of devices that have been unlocked.
491 * Refer to fs_error_enum.
492 * Note
493 * This function should only be called by the system.
494 *****************************************************************************/
495extern int FS_UnlockAll(void);
496
497/*****************************************************************************
498 * <GROUP LifeCycle>
499 *
500 * FUNCTION
501 * FS_LockFAT
502 * DESCRIPTION
503 * This function provides interface to switch global state in whole file system
504 * to work well under specific system mode. USB Boot Mode, Low Cost Single Bank
505 * Mode and Mass Storage Mode require File System to lock or limit application
506 * access.
507 * PARAMETERS
508 * Type : [IN] <P>New File System State. Refer to FS_LOCK_TYPE_ENUM.
509 * RETURNS
510 * Refer to fs_error_enum.
511 *****************************************************************************/
512extern int FS_LockFAT(UINT Type);
513
514/*************************************************************************
515 * <GROUP DirectIOCtrl>
516 *
517 * FUNCTION
518 * FS_OTPWrite
519 * DESCRIPTION
520 * Some flash devices provide OTP (One-Time Program) zone. This API is a
521 * driver wrapper function for application to support multiple device
522 * drivers and prevent re-entrance problem on the same device driver.
523 * Applications can read the specific content segment from OTP zone by
524 * this API.
525 * First it enters secured silicon sector, and write data from "Offset",
526 * totally write "Length" bytes, then exit secured silicon sector mode.
527 * <color red>Be careful</color>, do not set bit to one if it is zero
528 * PARAMETERS
529 * devtype : [IN] <P>FS_DEVICE_TYPE_NOR or FS_DEVICE_TYPE_NAND can be assigned.
530 * Offset : [IN] <P>The start position to read from (unit: bytes).
531 * BufferPtr : [IN] <P>The buffer address to keep copied data
532 * Length : [IN] <P>Specific total length of this read operation (unit: bytes)
533 * RETURN VALUES
534 * FS_NO_ERROR : success
535 * FS_UNSUPPORTED_DEVICE (-11): no such OTP device configured
536 * FS_UNSUPPORTED_DRIVER_FUNCTION (-12): no OTP function supported on configured device
537 * FS_FLASH_OTP_OVERSCOPE (-124): writing range is out of OTP range
538 * FS_FLASH_OTP_LOCK_ALREADY (-127): the OTP zone already locked.
539 *************************************************************************/
540extern int FS_OTPWrite(int devtype, UINT Offset, void * BufferPtr, kal_uint32 Length);
541
542/*************************************************************************
543 * <GROUP DirectIOCtrl>
544 *
545 * FUNCTION
546 * FS_OTPRead
547 * DESCRIPTION
548 * Some flash devices provide OTP (One-Time Program) zone. This API is a
549 * driver wrapper function for application to support multiple device
550 * drivers and prevent re-entrance problem on the same device driver.
551 * Applications can read the specific content segment from OTP zone by
552 * this API.
553 * first it enters secured silicon sector, and read data from "Offset",
554 * totally read "Length" bytes, then exit secured silicon sector mode
555 * PARAMETERS
556 * devtype : [IN] <P>FS_DEVICE_TYPE_NOR or FS_DEVICE_TYPE_NAND can be assigned.
557 * Offset : [IN] <P>The start position to read from (unit: bytes).
558 * BufferPtr : [IN] <P>The buffer address to keep copied data
559 * Length : [IN] <P>Specific total length of this read operation (unit: bytes)
560 * RETURN VALUES
561 * FS_NO_ERROR : success
562 * FS_UNSUPPORTED_DEVICE (-11): no such OTP device configured
563 * FS_UNSUPPORTED_DRIVER_FUNCTION (-12): no OTP function supported on configured device
564 * FS_FLASH_OTP_OVERSCOPE (-124): reading range is out of OTP range
565 *************************************************************************/
566extern int FS_OTPRead(int devtype, UINT Offset, void * BufferPtr, kal_uint32 Length);
567
568/*************************************************************************
569 * <GROUP DirectIOCtrl>
570 *
571 * FUNCTION
572 * FS_OTPQueryLength
573 * DESCRIPTION
574 * This function implements the OTP length query function.
575 * PARAMETERS
576 * devtype : [IN] <P>FS_DEVICE_TYPE_NOR or FS_DEVICE_TYPE_NAND can be assigned.
577 * Offset : [IN] <P>The start position to read from (unit: bytes).
578 * RETURN VALUES
579 * FS_NO_ERROR: no error
580 * FS_UNSUPPORTED_DEVICE: no OTP device configured
581 * FS_UNSUPPORTED_DRIVER_FUNCTION: no OTP function support on configured device
582 *************************************************************************/
583extern int FS_OTPQueryLength(int devtype, UINT *Length);
584
585/*************************************************************************
586 * <GROUP DirectIOCtrl>
587 *
588 * FUNCTION
589 * FS_OTPLock
590 * DESCRIPTION
591 * Some flash devices provide OTP (One-Time Program) zone. This API is a
592 * driver wrapper function for application to permanently lock OTP zone.
593 * <color red><b>WARNING!!</b></color> If this API is executed, OTP zone can't be written again.
594 * PARAMETERS
595 * devtype : [IN] <P>FS_DEVICE_TYPE_NOR or FS_DEVICE_TYPE_NAND can be assigned.
596 * RETURN VALUES
597 * FS_NO_ERROR : success
598 * FS_UNSUPPORTED_DEVICE (-11): no such OTP device configured
599 * FS_UNSUPPORTED_DRIVER_FUNCTION (-12): no OTP function supported on configured device
600 * FS_FLASH_OTP_LOCK_ALREADY (-127): the OTP zone already locked.
601 *************************************************************************/
602extern int FS_OTPLock(int devtype);
603
604/*****************************************************************************
605 * <GROUP DiskManagement>
606 *
607 * FUNCTION
608 * FS_SweepDevice
609 * DESCRIPTION
610 * File system provides this API to sweep out all unused data sectors.
611 * This API is designed to be called by background and low priority task.
612 * So API cannot hold the device lock too long to degrade system throughput.
613 * Note that it will return FS_CHECKDISK_RETRY(-41) to indicate caller to try
614 * again until FS_NO_ERROR return.
615 * PARAMETERS
616 * devtype : [IN] <P>FS_DEVICE_TYPE_NOR or FS_DEVICE_TYPE_NAND can be assigned.
617 * RETURN VALUES
618 * FS_NO_ERROR : success and finished
619 * FS_PARAM_ERROR (-2): No such device configured
620 * FS_CHECKDISK_RETRY (-41): please retry again until FS_NO_ERROR return.
621 *****************************************************************************/
622extern int FS_SweepDevice(const int devtype);
623
624extern int FS_OpenLR(const WCHAR * FileName, kal_uint32 Flag, kal_uint32 caller_address);
625extern int FS_OpenHintLR(const WCHAR * FileName, kal_uint32 Flag, FS_FileOpenHint * DSR_Hint, kal_uint32 caller_address);
626extern int FS_MoveLR(const WCHAR * SrcFullPath, const WCHAR * DstFullPath, kal_uint32 Flag, FS_ProgressCallback Progress,
627 kal_uint8 *RecursiveStack, const kal_uint32 StackSize, kal_uint32 caller_address);
628
629extern FS_TaskIOStatistics *gFS_TaskIOStatistics;
630
631/*****************************************************************************
632 * <GROUP DiskManagement>
633 *
634 * FUNCTION
635 * SDCreateMasterBootRecord
636 * DESCRIPTION
637 * Create SDHC Master Boot Record, follow SDHC file system spec. V3
638 * PARAMETERS
639 * MasterBootRecord :[OUT] <P> Master Boot Record sector buffer
640 * Sectors :[IN] <P> Number of sectors on the device
641 * RETURN VALUES
642 * 0: Error
643 * >0: Success, the offset to the partition starting sector (Boot Sector).
644 *****************************************************************************/
645extern int SDCreateMasterBootRecord(void * MasterBootRecord, kal_uint32 Sectors);
646
647/*****************************************************************************
648 * <GROUP DiskManagement>
649 *
650 * FUNCTION
651 * SDCreateBootSector
652 * DESCRIPTION
653 * Create SDHC Boot Sector, follow SDHC file system spec. V3
654 * PARAMETERS
655 * BootSector :[OUT] <P> Boot sector buffer
656 * Sectors :[IN] <P> Number of sectors on the device
657 * Partition :[IN] <P> First partition record created from SDCreateMasterBootRecord()
658 * RETURN VALUES
659 * 0: Error
660 * 12: Created File System Type is FAT12
661 * 16: Created File System Type is FAT16
662 * 32: Created File System Type is FAT32
663 *****************************************************************************/
664extern int SDCreateBootSector(void * BootSector, kal_uint32 Sectors, FS_PartitionRecord *Partition);
665
666/*****************************************************************************
667 * <GROUP DiskManagement>
668 *
669 * FUNCTION
670 * SDCheckFormatParameter
671 * DESCRIPTION
672 * Compare SDHC format parameters, including BootSector(BS) and MasterBootRecord(MBR)
673 * PARAMETERS
674 * MBR1 :[IN] <P> Master Boot Record 1 (Read from Device)
675 * MBR2 :[IN] <P> Master Boot Record 2 (Created from SDCreateMasterBootRecord)
676 * BS1 :[IN] <P> Boot Sector 1 (Read from Device)
677 * BS2 :[IN] <P> Boot Sector 2 (Created from SDCreateBootSector)
678 * RETURN VALUES
679 * FS_SD_FMT_OK : (0): Format parameters are match.
680 * FS_SD_FMT_SIGNATURE_FAIL (1): BS or MBR Signature are mismatch.
681 * FS_SD_FMT_MBR_FAIL (2): MBR1/MBR2 parameters are mismatch.
682 * FS_SD_FMT_BS_FAIL (3): BS1/BS2 parameters are mismatch.
683 *****************************************************************************/
684extern int SDCheckFormatParameter(void *MBR1, void *BS1, void *MBR2, void *BS2);
685
686#else
687
688// Smart Phone Modem Wrapper
689//------------------------------------------------------------
690/* DOM-NOT_FOR_SDK-BEGIN */
691
692/* DOM-NOT_FOR_SDK-END */
693
694#endif
695
696#endif // _FS_IPROT_H
697