WS63 SDK 文档 7021f4f@fbb_ws63
ws63 和 ws63e 解决方案的 SDK 文档
载入中...
搜索中...
未找到
disk.h
浏览该文件的文档.
1/* ----------------------------------------------------------------------------
2 * Copyright (c) Huawei Technologies Co., Ltd. 2013-2019. All rights reserved.
3 * Description: LiteOS Disk Module Headfile
4 * Author: Huawei LiteOS Team
5 * Create: 2013-01-01
6 * Redistribution and use in source and binary forms, with or without modification,
7 * are permitted provided that the following conditions are met:
8 * 1. Redistributions of source code must retain the above copyright notice, this list of
9 * conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright notice, this list
11 * of conditions and the following disclaimer in the documentation and/or other materials
12 * provided with the distribution.
13 * 3. Neither the name of the copyright holder nor the names of its contributors may be used
14 * to endorse or promote products derived from this software without specific prior written
15 * permission.
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
18 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
20 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
21 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
22 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
23 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
24 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
25 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
26 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 * --------------------------------------------------------------------------- */
28
34#ifndef _DISK_H
35#define _DISK_H
36
37#include "los_base.h"
38#include "inode/inode.h"
39
40#ifdef __cplusplus
41extern "C" {
42#endif /* __cplusplus */
43
44#define SYS_MAX_DISK 5
45#define MAX_DIVIDE_PART_PER_DISK 16
46#define MAX_PRIMARY_PART_PER_DISK 4
47#define SYS_MAX_PART (SYS_MAX_DISK * MAX_DIVIDE_PART_PER_DISK)
48#define DISK_NAME 255
49#define EMMC 0xEC
50
51/* Command code for disk_ioctrl function */
52/* Generic command (Used by FatFs) */
53#define DISK_CTRL_SYNC 0 /* Complete pending write process */
54#define DISK_GET_SECTOR_COUNT 1 /* Get media size */
55#define DISK_GET_SECTOR_SIZE 2 /* Get sector size */
56#define DISK_GET_BLOCK_SIZE 3 /* Get erase block size */
57#define DISK_CTRL_TRIM 4 /* Inform device that the data on the block of sectors is no longer used */
58
59/* Generic command (Not used by FatFs) */
60#define DISK_CTRL_POWER 5 /* Get/Set power status */
61#define DISK_CTRL_LOCK 6 /* Lock/Unlock media removal */
62#define DISK_CTRL_EJECT 7 /* Eject media */
63#define DISK_CTRL_FORMAT 8 /* Create physical format on the media */
64
65/* MMC/SDC specific ioctl command */
66#define DISK_MMC_GET_TYPE 10 /* Get card type */
67#define DISK_MMC_GET_CSD 11 /* Get CSD */
68#define DISK_MMC_GET_CID 12 /* Get CID */
69#define DISK_MMC_GET_OCR 13 /* Get OCR */
70#define DISK_MMC_GET_SDSTAT 14 /* Get SD status */
71
72/* ATA/CF specific ioctl command */
73#define DISK_ATA_GET_REV 20 /* Get F/W revision */
74#define DISK_ATA_GET_MODEL 21 /* Get model name */
75#define DISK_ATA_GET_SN 22 /* Get serial number */
76
77#define DISK_CTRL_TRIM_REVERT 23 /* Inform device that the data on the block of sectors will be used */
78
79typedef struct _los_disk_ {
80 UINT32 disk_id : 8; /* physics disk number */
81 UINT32 disk_status : 2; /* status of disk */
82 UINT32 part_count : 8; /* current partition count */
84 struct inode *dev; /* device */
85#ifdef LOSCFG_FS_FAT_CACHE
86 VOID *bcache; /* cache of the disk, shared in all partitions */
87#endif
88 UINT32 sector_size; /* disk sector size */
89 UINT64 sector_start; /* disk start sector */
90 UINT64 sector_count; /* disk sector number */
93 LOS_DL_LIST head; /* link head of all the partitions */
96
97typedef struct _los_part_ {
98 UINT32 disk_id : 8; /* physics disk number */
99 UINT32 part_id : 8; /* partition number in the system */
100 UINT32 part_no_disk : 8; /* partition number in the disk */
101 UINT32 part_no_mbr : 5; /* partition number in the mbr */
103 UINT8 filesystem_type; /* filesystem used in the partition */
104 struct inode *dev; /* dev devices used in the partition */
106 * offset of a partition to the primary devices
107 * (multi-mbr partitions are seen as same parition)
108 */
110 * sector numbers of a partition. If there is no addpartition operation,
111 * then all the mbr devices equal to the primary device count.
112 */
115 LOS_DL_LIST list; /* linklist of partition */
116
117#ifdef LOSCFG_FS_FAT_UNI_TRIM
118 VOID *trimManager;
119#endif
121
127
132 /*
133 * The primary partition place should be reversed and set to 0 in case all the partitions are
134 * logical partition (maximum 16 currently). So the maximum part number should be 4 + 16.
135 */
137};
138
172INT32 los_disk_init(const CHAR *diskName, const struct block_operations *bops,
173 VOID *priv, INT32 diskId, VOID *info);
174
199
227INT32 los_disk_read(INT32 drvId, VOID *buf, UINT64 sector, UINT32 count);
228
256INT32 los_disk_write(INT32 drvId, const VOID *buf, UINT64 sector, UINT32 count);
257
289
314
341INT32 los_disk_set_bcache(INT32 drvId, UINT32 sectorPerBlock, UINT32 blockNum);
342
370INT32 los_part_read(INT32 pt, VOID *buf, UINT64 sector, UINT32 count);
371
399INT32 los_part_write(INT32 pt, const VOID *buf, UINT64 sector, UINT32 count);
400
433
458INT32 los_part_access(const CHAR *dev, mode_t mode);
459
483los_part *los_part_find(const struct inode *blkDriver);
484
509
534
556
582INT32 add_mmc_partition(struct disk_divide_info *info, size_t sectorStart, size_t sectorCount);
583
609
635
636#ifdef __cplusplus
637}
638#endif /* __cplusplus */
639
640#endif
struct _los_part_ los_part
#define DISK_NAME
Definition disk.h:48
#define MAX_PRIMARY_PART_PER_DISK
Definition disk.h:46
struct _los_disk_ los_disk
#define MAX_DIVIDE_PART_PER_DISK
Definition disk.h:45
INT32 add_mmc_partition(struct disk_divide_info *info, size_t sectorStart, size_t sectorCount)
Add a new mmc partition.
INT32 los_disk_init(const CHAR *diskName, const struct block_operations *bops, VOID *priv, INT32 diskId, VOID *info)
Disk driver initialization.
INT32 los_disk_write(INT32 drvId, const VOID *buf, UINT64 sector, UINT32 count)
Write data to a disk driver.
INT32 los_disk_deinit(INT32 diskId)
Destroy a disk driver.
los_disk * get_disk(INT32 id)
Find disk driver.
VOID show_part(const los_part *part)
Print partition information.
INT32 los_get_diskid_byname(const CHAR *diskName)
get the disk id in used.
INT32 los_disk_ioctl(INT32 drvId, INT32 cmd, VOID *buf)
Get information of disk driver.
INT32 los_disk_sync(INT32 drvId)
Sync blib cache.
los_part * get_part(INT32 id)
Find disk partition.
los_part * los_part_find(const struct inode *blkDriver)
Find disk partition.
INT32 los_part_access(const CHAR *dev, mode_t mode)
Decide the chosen partition is exist or not.
INT32 los_part_read(INT32 pt, VOID *buf, UINT64 sector, UINT32 count)
Read data from chosen partition.
INT32 los_alloc_diskid_byname(const CHAR *diskName)
alloc a new UNUSED disk id.
INT32 los_disk_read(INT32 drvId, VOID *buf, UINT64 sector, UINT32 count)
Read data from disk driver.
INT32 los_part_write(INT32 pt, const VOID *buf, UINT64 sector, UINT32 count)
Write data to chosen partition.
INT32 los_disk_set_bcache(INT32 drvId, UINT32 sectorPerBlock, UINT32 blockNum)
Set blib cache for the disk driver.
INT32 los_part_ioctl(INT32 pt, INT32 cmd, VOID *buf)
Get information of chosen partition.
signed int INT32
Definition los_typedef.h:55
unsigned long long UINT64
Definition los_typedef.h:72
#define VOID
Definition los_typedef.h:88
unsigned char UINT8
Definition los_typedef.h:50
unsigned int UINT32
Definition los_typedef.h:52
char CHAR
Definition los_typedef.h:58
Definition los_list.h:47
Definition disk.h:79
CHAR disk_name[255+1]
Definition disk.h:92
UINT32 disk_id
Definition disk.h:80
UINT8 type
Definition disk.h:91
LOS_DL_LIST head
Definition disk.h:93
UINT64 sector_start
Definition disk.h:89
UINT32 reserved
Definition disk.h:83
UINT32 sector_size
Definition disk.h:88
UINT32 disk_status
Definition disk.h:81
UINT32 part_count
Definition disk.h:82
UINT32 disk_mutex
Definition disk.h:94
UINT64 sector_count
Definition disk.h:90
struct inode * dev
Definition disk.h:84
Definition disk.h:97
UINT32 part_id
Definition disk.h:99
UINT32 disk_id
Definition disk.h:98
UINT32 part_no_disk
Definition disk.h:100
LOS_DL_LIST list
Definition disk.h:115
UINT32 reserved
Definition disk.h:102
UINT64 sector_count
Definition disk.h:109
CHAR * part_name
Definition disk.h:114
struct inode * dev
Definition disk.h:104
UINT8 filesystem_type
Definition disk.h:103
UINT32 part_no_mbr
Definition disk.h:101
UINT64 sector_start
Definition disk.h:105
UINT8 type
Definition disk.h:113
Definition disk.h:128
UINT32 part_count
Definition disk.h:131
UINT64 sector_count
Definition disk.h:129
struct partition_info part[16+4]
Definition disk.h:136
UINT32 sector_size
Definition disk.h:130
Definition disk.h:122
UINT8 type
Definition disk.h:123
UINT64 sector_count
Definition disk.h:125
UINT64 sector_start
Definition disk.h:124