VisionFive2 Linux kernel

StarFive Tech Linux Kernel for VisionFive (JH7110) boards (mirror)

More than 9999 Commits   32 Branches   54 Tags
1acf1a564b603 (Namjae Jeon      2020-03-02 15:21:32 +0900   1) /* SPDX-License-Identifier: GPL-2.0-or-later */
1acf1a564b603 (Namjae Jeon      2020-03-02 15:21:32 +0900   2) /*
1acf1a564b603 (Namjae Jeon      2020-03-02 15:21:32 +0900   3)  * Copyright (C) 2012-2013 Samsung Electronics Co., Ltd.
1acf1a564b603 (Namjae Jeon      2020-03-02 15:21:32 +0900   4)  */
1acf1a564b603 (Namjae Jeon      2020-03-02 15:21:32 +0900   5) 
1acf1a564b603 (Namjae Jeon      2020-03-02 15:21:32 +0900   6) #ifndef _EXFAT_RAW_H
1acf1a564b603 (Namjae Jeon      2020-03-02 15:21:32 +0900   7) #define _EXFAT_RAW_H
1acf1a564b603 (Namjae Jeon      2020-03-02 15:21:32 +0900   8) 
1acf1a564b603 (Namjae Jeon      2020-03-02 15:21:32 +0900   9) #include <linux/types.h>
1acf1a564b603 (Namjae Jeon      2020-03-02 15:21:32 +0900  10) 
181a9e8009a8a (Tetsuhiro Kohada 2020-05-29 19:14:56 +0900  11) #define BOOT_SIGNATURE		0xAA55
181a9e8009a8a (Tetsuhiro Kohada 2020-05-29 19:14:56 +0900  12) #define EXBOOT_SIGNATURE	0xAA550000
33404a159828a (Tetsuhiro Kohada 2020-05-29 19:14:57 +0900  13) #define STR_EXFAT		"EXFAT   "	/* size should be 8 */
1acf1a564b603 (Namjae Jeon      2020-03-02 15:21:32 +0900  14) 
1acf1a564b603 (Namjae Jeon      2020-03-02 15:21:32 +0900  15) #define EXFAT_MAX_FILE_LEN	255
1acf1a564b603 (Namjae Jeon      2020-03-02 15:21:32 +0900  16) 
7018ec68f0824 (Tetsuhiro Kohada 2020-07-31 14:58:26 +0900  17) #define VOLUME_DIRTY		0x0002
7018ec68f0824 (Tetsuhiro Kohada 2020-07-31 14:58:26 +0900  18) #define MEDIA_FAILURE		0x0004
1acf1a564b603 (Namjae Jeon      2020-03-02 15:21:32 +0900  19) 
1acf1a564b603 (Namjae Jeon      2020-03-02 15:21:32 +0900  20) #define EXFAT_EOF_CLUSTER	0xFFFFFFFFu
1acf1a564b603 (Namjae Jeon      2020-03-02 15:21:32 +0900  21) #define EXFAT_BAD_CLUSTER	0xFFFFFFF7u
1acf1a564b603 (Namjae Jeon      2020-03-02 15:21:32 +0900  22) #define EXFAT_FREE_CLUSTER	0
1acf1a564b603 (Namjae Jeon      2020-03-02 15:21:32 +0900  23) /* Cluster 0, 1 are reserved, the first cluster is 2 in the cluster heap. */
1acf1a564b603 (Namjae Jeon      2020-03-02 15:21:32 +0900  24) #define EXFAT_RESERVED_CLUSTERS	2
1acf1a564b603 (Namjae Jeon      2020-03-02 15:21:32 +0900  25) #define EXFAT_FIRST_CLUSTER	2
1acf1a564b603 (Namjae Jeon      2020-03-02 15:21:32 +0900  26) #define EXFAT_DATA_CLUSTER_COUNT(sbi)	\
1acf1a564b603 (Namjae Jeon      2020-03-02 15:21:32 +0900  27) 	((sbi)->num_clusters - EXFAT_RESERVED_CLUSTERS)
1acf1a564b603 (Namjae Jeon      2020-03-02 15:21:32 +0900  28) 
1acf1a564b603 (Namjae Jeon      2020-03-02 15:21:32 +0900  29) /* AllocationPossible and NoFatChain field in GeneralSecondaryFlags Field */
1acf1a564b603 (Namjae Jeon      2020-03-02 15:21:32 +0900  30) #define ALLOC_FAT_CHAIN		0x01
1acf1a564b603 (Namjae Jeon      2020-03-02 15:21:32 +0900  31) #define ALLOC_NO_FAT_CHAIN	0x03
1acf1a564b603 (Namjae Jeon      2020-03-02 15:21:32 +0900  32) 
1acf1a564b603 (Namjae Jeon      2020-03-02 15:21:32 +0900  33) #define DENTRY_SIZE		32 /* directory entry size */
1acf1a564b603 (Namjae Jeon      2020-03-02 15:21:32 +0900  34) #define DENTRY_SIZE_BITS	5
1acf1a564b603 (Namjae Jeon      2020-03-02 15:21:32 +0900  35) /* exFAT allows 8388608(256MB) directory entries */
1acf1a564b603 (Namjae Jeon      2020-03-02 15:21:32 +0900  36) #define MAX_EXFAT_DENTRIES	8388608
1acf1a564b603 (Namjae Jeon      2020-03-02 15:21:32 +0900  37) 
1acf1a564b603 (Namjae Jeon      2020-03-02 15:21:32 +0900  38) /* dentry types */
1acf1a564b603 (Namjae Jeon      2020-03-02 15:21:32 +0900  39) #define EXFAT_UNUSED		0x00	/* end of directory */
1acf1a564b603 (Namjae Jeon      2020-03-02 15:21:32 +0900  40) #define EXFAT_DELETE		(~0x80)
1acf1a564b603 (Namjae Jeon      2020-03-02 15:21:32 +0900  41) #define IS_EXFAT_DELETED(x)	((x) < 0x80) /* deleted file (0x01~0x7F) */
1acf1a564b603 (Namjae Jeon      2020-03-02 15:21:32 +0900  42) #define EXFAT_INVAL		0x80	/* invalid value */
1acf1a564b603 (Namjae Jeon      2020-03-02 15:21:32 +0900  43) #define EXFAT_BITMAP		0x81	/* allocation bitmap */
1acf1a564b603 (Namjae Jeon      2020-03-02 15:21:32 +0900  44) #define EXFAT_UPCASE		0x82	/* upcase table */
1acf1a564b603 (Namjae Jeon      2020-03-02 15:21:32 +0900  45) #define EXFAT_VOLUME		0x83	/* volume label */
1acf1a564b603 (Namjae Jeon      2020-03-02 15:21:32 +0900  46) #define EXFAT_FILE		0x85	/* file or dir */
1acf1a564b603 (Namjae Jeon      2020-03-02 15:21:32 +0900  47) #define EXFAT_GUID		0xA0
1acf1a564b603 (Namjae Jeon      2020-03-02 15:21:32 +0900  48) #define EXFAT_PADDING		0xA1
1acf1a564b603 (Namjae Jeon      2020-03-02 15:21:32 +0900  49) #define EXFAT_ACLTAB		0xA2
1acf1a564b603 (Namjae Jeon      2020-03-02 15:21:32 +0900  50) #define EXFAT_STREAM		0xC0	/* stream entry */
1acf1a564b603 (Namjae Jeon      2020-03-02 15:21:32 +0900  51) #define EXFAT_NAME		0xC1	/* file name entry */
1acf1a564b603 (Namjae Jeon      2020-03-02 15:21:32 +0900  52) #define EXFAT_ACL		0xC2	/* stream entry */
1acf1a564b603 (Namjae Jeon      2020-03-02 15:21:32 +0900  53) 
1acf1a564b603 (Namjae Jeon      2020-03-02 15:21:32 +0900  54) #define IS_EXFAT_CRITICAL_PRI(x)	(x < 0xA0)
1acf1a564b603 (Namjae Jeon      2020-03-02 15:21:32 +0900  55) #define IS_EXFAT_BENIGN_PRI(x)		(x < 0xC0)
1acf1a564b603 (Namjae Jeon      2020-03-02 15:21:32 +0900  56) #define IS_EXFAT_CRITICAL_SEC(x)	(x < 0xE0)
1acf1a564b603 (Namjae Jeon      2020-03-02 15:21:32 +0900  57) 
1acf1a564b603 (Namjae Jeon      2020-03-02 15:21:32 +0900  58) /* checksum types */
1acf1a564b603 (Namjae Jeon      2020-03-02 15:21:32 +0900  59) #define CS_DIR_ENTRY		0
181a9e8009a8a (Tetsuhiro Kohada 2020-05-29 19:14:56 +0900  60) #define CS_BOOT_SECTOR		1
1acf1a564b603 (Namjae Jeon      2020-03-02 15:21:32 +0900  61) #define CS_DEFAULT		2
1acf1a564b603 (Namjae Jeon      2020-03-02 15:21:32 +0900  62) 
1acf1a564b603 (Namjae Jeon      2020-03-02 15:21:32 +0900  63) /* file attributes */
1acf1a564b603 (Namjae Jeon      2020-03-02 15:21:32 +0900  64) #define ATTR_READONLY		0x0001
1acf1a564b603 (Namjae Jeon      2020-03-02 15:21:32 +0900  65) #define ATTR_HIDDEN		0x0002
1acf1a564b603 (Namjae Jeon      2020-03-02 15:21:32 +0900  66) #define ATTR_SYSTEM		0x0004
1acf1a564b603 (Namjae Jeon      2020-03-02 15:21:32 +0900  67) #define ATTR_VOLUME		0x0008
1acf1a564b603 (Namjae Jeon      2020-03-02 15:21:32 +0900  68) #define ATTR_SUBDIR		0x0010
1acf1a564b603 (Namjae Jeon      2020-03-02 15:21:32 +0900  69) #define ATTR_ARCHIVE		0x0020
1acf1a564b603 (Namjae Jeon      2020-03-02 15:21:32 +0900  70) 
1acf1a564b603 (Namjae Jeon      2020-03-02 15:21:32 +0900  71) #define ATTR_RWMASK		(ATTR_HIDDEN | ATTR_SYSTEM | ATTR_VOLUME | \
1acf1a564b603 (Namjae Jeon      2020-03-02 15:21:32 +0900  72) 				 ATTR_SUBDIR | ATTR_ARCHIVE)
1acf1a564b603 (Namjae Jeon      2020-03-02 15:21:32 +0900  73) 
181a9e8009a8a (Tetsuhiro Kohada 2020-05-29 19:14:56 +0900  74) #define BOOTSEC_JUMP_BOOT_LEN		3
181a9e8009a8a (Tetsuhiro Kohada 2020-05-29 19:14:56 +0900  75) #define BOOTSEC_FS_NAME_LEN		8
181a9e8009a8a (Tetsuhiro Kohada 2020-05-29 19:14:56 +0900  76) #define BOOTSEC_OLDBPB_LEN		53
1acf1a564b603 (Namjae Jeon      2020-03-02 15:21:32 +0900  77) 
1acf1a564b603 (Namjae Jeon      2020-03-02 15:21:32 +0900  78) #define EXFAT_FILE_NAME_LEN		15
1acf1a564b603 (Namjae Jeon      2020-03-02 15:21:32 +0900  79) 
78c276f5495aa (Namjae Jeon      2021-02-01 09:23:37 +0900  80) #define EXFAT_MIN_SECT_SIZE_BITS		9
78c276f5495aa (Namjae Jeon      2021-02-01 09:23:37 +0900  81) #define EXFAT_MAX_SECT_SIZE_BITS		12
78c276f5495aa (Namjae Jeon      2021-02-01 09:23:37 +0900  82) #define EXFAT_MAX_SECT_PER_CLUS_BITS(x)		(25 - (x)->sect_size_bits)
78c276f5495aa (Namjae Jeon      2021-02-01 09:23:37 +0900  83) 
181a9e8009a8a (Tetsuhiro Kohada 2020-05-29 19:14:56 +0900  84) /* EXFAT: Main and Backup Boot Sector (512 bytes) */
181a9e8009a8a (Tetsuhiro Kohada 2020-05-29 19:14:56 +0900  85) struct boot_sector {
181a9e8009a8a (Tetsuhiro Kohada 2020-05-29 19:14:56 +0900  86) 	__u8	jmp_boot[BOOTSEC_JUMP_BOOT_LEN];
181a9e8009a8a (Tetsuhiro Kohada 2020-05-29 19:14:56 +0900  87) 	__u8	fs_name[BOOTSEC_FS_NAME_LEN];
181a9e8009a8a (Tetsuhiro Kohada 2020-05-29 19:14:56 +0900  88) 	__u8	must_be_zero[BOOTSEC_OLDBPB_LEN];
181a9e8009a8a (Tetsuhiro Kohada 2020-05-29 19:14:56 +0900  89) 	__le64	partition_offset;
181a9e8009a8a (Tetsuhiro Kohada 2020-05-29 19:14:56 +0900  90) 	__le64	vol_length;
181a9e8009a8a (Tetsuhiro Kohada 2020-05-29 19:14:56 +0900  91) 	__le32	fat_offset;
181a9e8009a8a (Tetsuhiro Kohada 2020-05-29 19:14:56 +0900  92) 	__le32	fat_length;
181a9e8009a8a (Tetsuhiro Kohada 2020-05-29 19:14:56 +0900  93) 	__le32	clu_offset;
181a9e8009a8a (Tetsuhiro Kohada 2020-05-29 19:14:56 +0900  94) 	__le32	clu_count;
181a9e8009a8a (Tetsuhiro Kohada 2020-05-29 19:14:56 +0900  95) 	__le32	root_cluster;
181a9e8009a8a (Tetsuhiro Kohada 2020-05-29 19:14:56 +0900  96) 	__le32	vol_serial;
181a9e8009a8a (Tetsuhiro Kohada 2020-05-29 19:14:56 +0900  97) 	__u8	fs_revision[2];
181a9e8009a8a (Tetsuhiro Kohada 2020-05-29 19:14:56 +0900  98) 	__le16	vol_flags;
181a9e8009a8a (Tetsuhiro Kohada 2020-05-29 19:14:56 +0900  99) 	__u8	sect_size_bits;
181a9e8009a8a (Tetsuhiro Kohada 2020-05-29 19:14:56 +0900 100) 	__u8	sect_per_clus_bits;
181a9e8009a8a (Tetsuhiro Kohada 2020-05-29 19:14:56 +0900 101) 	__u8	num_fats;
181a9e8009a8a (Tetsuhiro Kohada 2020-05-29 19:14:56 +0900 102) 	__u8	drv_sel;
181a9e8009a8a (Tetsuhiro Kohada 2020-05-29 19:14:56 +0900 103) 	__u8	percent_in_use;
181a9e8009a8a (Tetsuhiro Kohada 2020-05-29 19:14:56 +0900 104) 	__u8	reserved[7];
181a9e8009a8a (Tetsuhiro Kohada 2020-05-29 19:14:56 +0900 105) 	__u8	boot_code[390];
181a9e8009a8a (Tetsuhiro Kohada 2020-05-29 19:14:56 +0900 106) 	__le16	signature;
1acf1a564b603 (Namjae Jeon      2020-03-02 15:21:32 +0900 107) } __packed;
1acf1a564b603 (Namjae Jeon      2020-03-02 15:21:32 +0900 108) 
1acf1a564b603 (Namjae Jeon      2020-03-02 15:21:32 +0900 109) struct exfat_dentry {
1acf1a564b603 (Namjae Jeon      2020-03-02 15:21:32 +0900 110) 	__u8 type;
1acf1a564b603 (Namjae Jeon      2020-03-02 15:21:32 +0900 111) 	union {
1acf1a564b603 (Namjae Jeon      2020-03-02 15:21:32 +0900 112) 		struct {
1acf1a564b603 (Namjae Jeon      2020-03-02 15:21:32 +0900 113) 			__u8 num_ext;
1acf1a564b603 (Namjae Jeon      2020-03-02 15:21:32 +0900 114) 			__le16 checksum;
1acf1a564b603 (Namjae Jeon      2020-03-02 15:21:32 +0900 115) 			__le16 attr;
1acf1a564b603 (Namjae Jeon      2020-03-02 15:21:32 +0900 116) 			__le16 reserved1;
1acf1a564b603 (Namjae Jeon      2020-03-02 15:21:32 +0900 117) 			__le16 create_time;
1acf1a564b603 (Namjae Jeon      2020-03-02 15:21:32 +0900 118) 			__le16 create_date;
1acf1a564b603 (Namjae Jeon      2020-03-02 15:21:32 +0900 119) 			__le16 modify_time;
1acf1a564b603 (Namjae Jeon      2020-03-02 15:21:32 +0900 120) 			__le16 modify_date;
1acf1a564b603 (Namjae Jeon      2020-03-02 15:21:32 +0900 121) 			__le16 access_time;
1acf1a564b603 (Namjae Jeon      2020-03-02 15:21:32 +0900 122) 			__le16 access_date;
ed0f84d30ba65 (Tetsuhiro Kohada 2020-04-22 08:30:56 +0900 123) 			__u8 create_time_cs;
ed0f84d30ba65 (Tetsuhiro Kohada 2020-04-22 08:30:56 +0900 124) 			__u8 modify_time_cs;
1acf1a564b603 (Namjae Jeon      2020-03-02 15:21:32 +0900 125) 			__u8 create_tz;
1acf1a564b603 (Namjae Jeon      2020-03-02 15:21:32 +0900 126) 			__u8 modify_tz;
1acf1a564b603 (Namjae Jeon      2020-03-02 15:21:32 +0900 127) 			__u8 access_tz;
1acf1a564b603 (Namjae Jeon      2020-03-02 15:21:32 +0900 128) 			__u8 reserved2[7];
1acf1a564b603 (Namjae Jeon      2020-03-02 15:21:32 +0900 129) 		} __packed file; /* file directory entry */
1acf1a564b603 (Namjae Jeon      2020-03-02 15:21:32 +0900 130) 		struct {
1acf1a564b603 (Namjae Jeon      2020-03-02 15:21:32 +0900 131) 			__u8 flags;
1acf1a564b603 (Namjae Jeon      2020-03-02 15:21:32 +0900 132) 			__u8 reserved1;
1acf1a564b603 (Namjae Jeon      2020-03-02 15:21:32 +0900 133) 			__u8 name_len;
1acf1a564b603 (Namjae Jeon      2020-03-02 15:21:32 +0900 134) 			__le16 name_hash;
1acf1a564b603 (Namjae Jeon      2020-03-02 15:21:32 +0900 135) 			__le16 reserved2;
1acf1a564b603 (Namjae Jeon      2020-03-02 15:21:32 +0900 136) 			__le64 valid_size;
1acf1a564b603 (Namjae Jeon      2020-03-02 15:21:32 +0900 137) 			__le32 reserved3;
1acf1a564b603 (Namjae Jeon      2020-03-02 15:21:32 +0900 138) 			__le32 start_clu;
1acf1a564b603 (Namjae Jeon      2020-03-02 15:21:32 +0900 139) 			__le64 size;
1acf1a564b603 (Namjae Jeon      2020-03-02 15:21:32 +0900 140) 		} __packed stream; /* stream extension directory entry */
1acf1a564b603 (Namjae Jeon      2020-03-02 15:21:32 +0900 141) 		struct {
1acf1a564b603 (Namjae Jeon      2020-03-02 15:21:32 +0900 142) 			__u8 flags;
1acf1a564b603 (Namjae Jeon      2020-03-02 15:21:32 +0900 143) 			__le16 unicode_0_14[EXFAT_FILE_NAME_LEN];
1acf1a564b603 (Namjae Jeon      2020-03-02 15:21:32 +0900 144) 		} __packed name; /* file name directory entry */
1acf1a564b603 (Namjae Jeon      2020-03-02 15:21:32 +0900 145) 		struct {
1acf1a564b603 (Namjae Jeon      2020-03-02 15:21:32 +0900 146) 			__u8 flags;
1acf1a564b603 (Namjae Jeon      2020-03-02 15:21:32 +0900 147) 			__u8 reserved[18];
1acf1a564b603 (Namjae Jeon      2020-03-02 15:21:32 +0900 148) 			__le32 start_clu;
1acf1a564b603 (Namjae Jeon      2020-03-02 15:21:32 +0900 149) 			__le64 size;
1acf1a564b603 (Namjae Jeon      2020-03-02 15:21:32 +0900 150) 		} __packed bitmap; /* allocation bitmap directory entry */
1acf1a564b603 (Namjae Jeon      2020-03-02 15:21:32 +0900 151) 		struct {
1acf1a564b603 (Namjae Jeon      2020-03-02 15:21:32 +0900 152) 			__u8 reserved1[3];
1acf1a564b603 (Namjae Jeon      2020-03-02 15:21:32 +0900 153) 			__le32 checksum;
1acf1a564b603 (Namjae Jeon      2020-03-02 15:21:32 +0900 154) 			__u8 reserved2[12];
1acf1a564b603 (Namjae Jeon      2020-03-02 15:21:32 +0900 155) 			__le32 start_clu;
1acf1a564b603 (Namjae Jeon      2020-03-02 15:21:32 +0900 156) 			__le64 size;
1acf1a564b603 (Namjae Jeon      2020-03-02 15:21:32 +0900 157) 		} __packed upcase; /* up-case table directory entry */
1acf1a564b603 (Namjae Jeon      2020-03-02 15:21:32 +0900 158) 	} __packed dentry;
1acf1a564b603 (Namjae Jeon      2020-03-02 15:21:32 +0900 159) } __packed;
1acf1a564b603 (Namjae Jeon      2020-03-02 15:21:32 +0900 160) 
1acf1a564b603 (Namjae Jeon      2020-03-02 15:21:32 +0900 161) #define EXFAT_TZ_VALID		(1 << 7)
1acf1a564b603 (Namjae Jeon      2020-03-02 15:21:32 +0900 162) 
1acf1a564b603 (Namjae Jeon      2020-03-02 15:21:32 +0900 163) /* Jan 1 GMT 00:00:00 1980 */
1acf1a564b603 (Namjae Jeon      2020-03-02 15:21:32 +0900 164) #define EXFAT_MIN_TIMESTAMP_SECS    315532800LL
1acf1a564b603 (Namjae Jeon      2020-03-02 15:21:32 +0900 165) /* Dec 31 GMT 23:59:59 2107 */
1acf1a564b603 (Namjae Jeon      2020-03-02 15:21:32 +0900 166) #define EXFAT_MAX_TIMESTAMP_SECS    4354819199LL
1acf1a564b603 (Namjae Jeon      2020-03-02 15:21:32 +0900 167) 
1acf1a564b603 (Namjae Jeon      2020-03-02 15:21:32 +0900 168) #endif /* !_EXFAT_RAW_H */