更新日期: 2022/06/01 来源: https://gitee.com/weharmony/kernel_liteos_a_note
disk_pri.h 文件参考

浏览源代码.

函数

UINT32 GetFatBlockNums (VOID)
 
VOID SetFatBlockNums (UINT32 blockNums)
 
UINT32 GetFatSectorsPerBlock (VOID)
 
VOID SetFatSectorsPerBlock (UINT32 sectorsPerBlock)
 设置FAR每块扇区数 更多...
 
INT32 SetDiskPartName (los_part *part, const CHAR *src)
 设置分区名称 更多...
 
INT32 EraseDiskByID (UINT32 diskID, size_t startSector, UINT32 sectors)
 

变量

spinlock_t g_diskSpinlock
 磁盘自锁锁 更多...
 
spinlock_t g_diskFatBlockSpinlock
 磁盘Fat块自旋锁 更多...
 

函数说明

◆ EraseDiskByID()

INT32 EraseDiskByID ( UINT32  diskID,
size_t  startSector,
UINT32  sectors 
)

在文件 disk.c1831 行定义.

1832{
1833 INT32 ret = VFS_ERROR;
1834#ifdef LOSCFG_DRIVERS_MMC //使能MMC
1835 los_disk *disk = get_disk((INT32)diskID);//找到磁盘信息
1836 if (disk != NULL) {
1837 ret = StorageBlockMmcErase(diskID, startSector, sectors);
1838 }//..\code-2.0-canary\device\hisilicon\third_party\uboot\u-boot-2020.01\cmd\mmc.c
1839#endif
1840
1841 return ret;
1842}
ssize_t StorageBlockMmcErase(uint32_t blockId, size_t secStart, size_t secNr)
通过磁盘ID 擦除磁盘信息
los_disk * get_disk(INT32 id)
Find disk driver.
Definition: disk.c:263
signed int INT32
Definition: los_typedef.h:60
函数调用图:
这是这个函数的调用关系图:

◆ GetFatBlockNums()

UINT32 GetFatBlockNums ( VOID  )

在文件 disk.c110 行定义.

111{
112 return g_uwFatBlockNums;
113}
UINT32 g_uwFatBlockNums
块数量 默认28
Definition: disk.c:80
这是这个函数的调用关系图:

◆ GetFatSectorsPerBlock()

UINT32 GetFatSectorsPerBlock ( VOID  )

在文件 disk.c120 行定义.

121{
123}
UINT32 g_uwFatSectorsPerBlock
每块支持扇区数 默认64个扇区
Definition: disk.c:79

◆ SetDiskPartName()

INT32 SetDiskPartName ( los_part part,
const CHAR src 
)

设置分区名称

在文件 disk.c1726 行定义.

1727{
1728 size_t len;
1729 los_disk *disk = NULL;
1730
1731 if ((part == NULL) || (src == NULL)) {
1732 return VFS_ERROR;
1733 }
1734
1735 len = strlen(src);
1736 if ((len == 0) || (len >= DISK_NAME)) {
1737 return VFS_ERROR;
1738 }
1739
1740 disk = get_disk((INT32)part->disk_id);
1741 if (disk == NULL) {
1742 return VFS_ERROR;
1743 }
1744
1745 DISK_LOCK(&disk->disk_mutex);
1746 if (disk->disk_status != STAT_INUSED) {
1747 goto ERROR_HANDLE;
1748 }
1749
1750 part->part_name = (CHAR *)zalloc(len + 1);//分区名称内存需来自内核空间
1751 if (part->part_name == NULL) {
1752 PRINT_ERR("%s[%d] zalloc failure\n", __FUNCTION__, __LINE__);
1753 goto ERROR_HANDLE;
1754 }
1755
1756 if (strcpy_s(part->part_name, len + 1, src) != EOK) {
1757 free(part->part_name);
1758 part->part_name = NULL;
1759 goto ERROR_HANDLE;
1760 }
1761
1762 DISK_UNLOCK(&disk->disk_mutex);
1763 return ENOERR;
1764
1765ERROR_HANDLE:
1766 DISK_UNLOCK(&disk->disk_mutex);
1767 return VFS_ERROR;
1768}
@ STAT_INUSED
Definition: disk.h:172
char CHAR
Definition: los_typedef.h:63
void * zalloc(size_t size)
Definition: malloc.c:91
void free(void *ptr)
释放ptr所指向的内存空间
Definition: malloc.c:66
struct pthread_mutex disk_mutex
Definition: disk.h:191
UINT32 disk_status
Definition: disk.h:178
UINT32 disk_id
Definition: disk.h:198
CHAR * part_name
Definition: disk.h:206
函数调用图:
这是这个函数的调用关系图:

◆ SetFatBlockNums()

VOID SetFatBlockNums ( UINT32  blockNums)

在文件 disk.c115 行定义.

116{
117 g_uwFatBlockNums = blockNums;
118}

◆ SetFatSectorsPerBlock()

VOID SetFatSectorsPerBlock ( UINT32  sectorsPerBlock)

设置FAR每块扇区数

在文件 disk.c125 行定义.

126{
127 if (((sectorsPerBlock % UNSIGNED_INTEGER_BITS) == 0) && //1.必须是整数倍
128 ((sectorsPerBlock >> UNINT_LOG2_SHIFT) <= BCACHE_BLOCK_FLAGS)) {
129 g_uwFatSectorsPerBlock = sectorsPerBlock;
130 }
131}

变量说明

◆ g_diskFatBlockSpinlock

spinlock_t g_diskFatBlockSpinlock
extern

磁盘Fat块自旋锁

在文件 disk.c83 行定义.

◆ g_diskSpinlock

spinlock_t g_diskSpinlock
extern

磁盘自锁锁

在文件 disk.c82 行定义.