Changeset 300 for soft/giet_vm
- Timestamp:
- Apr 10, 2014, 2:33:56 PM (11 years ago)
- Location:
- soft/giet_vm
- Files:
-
- 1 deleted
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
soft/giet_vm/Makefile
r299 r300 11 11 ### partition sectors = 524832 12 12 13 MAP_XML = mappings/4c_1p_sort_iob.xml13 MAP_XML ?= mappings/4c_1p_iob_sort.xml 14 14 15 15 ### Objects to be linked for kernel.elf … … 159 159 cp -r hdd/misc hdd/virt_hdd 160 160 cp map.bin hdd/virt_hdd 161 ### create temporary partition image (partition_image.dmg) 162 ./create_dmg create hdd/virt_hdd partition_image 163 ### copy standard MBR into virtual disk image (mbr.dmg) 164 cp hdd/mbr.dmg $@ 161 ### create temporary partition image 162 ./create_dmg create hdd/virt_hdd $(basename $@) 165 163 ### copy boot.elf into virtual disk image (sector 2) 166 dd if=build/boot/boot.elf of=$@ seek=2 167 ### copy partition image into virtual disk image (sector 300) 168 dd if=partition_image.dmg of=$@ seek=300 169 ### remove partition image 170 rm partition_image.dmg 164 dd if=build/boot/boot.elf of=$@ seek=2 conv=notrunc 171 165 172 166 ### mapping compilation -
soft/giet_vm/create_dmg
r261 r300 6 6 sector_size=512 7 7 sectors_per_cluster=8 8 reserved_sectors= 328 reserved_sectors=512 9 9 10 10 # FAT32 SPEC: The first two clusters are not present in the data region but … … 59 59 format="UDRW" 60 60 61 echo "Creating partition file $3 from $2 directory" 61 # -F FAT type = 32 (FAT32) 62 # -c sectors/cluster 63 # -n number of FATs 64 # -r reserved sectors 65 # -k backup boot sector (VBR and FS INFO) = 0xffff (no backup) 66 echo "Creating partition file $3.dmg from $2 directory" 67 fsargs="-F32 -c $sectors_per_cluster -n 1 -r $reserved_sectors -k 0xffff" 62 68 hdiutil create \ 63 69 -fs MS-DOS \ … … 66 72 -sectors $sectors \ 67 73 -ov \ 68 -fsargs " -F32 -c$sectors_per_cluster -n1 -r$reserved_sectors" \74 -fsargs "$fsargs" \ 69 75 -format $format \ 70 76 $3; -
soft/giet_vm/giet_fat32/fat32.c
r295 r300 6 6 ////////////////////////////////////////////////////////////////////////////////// 7 7 // The fat32.h and fat32.c files define a library of access functions 8 // to a FAT32 partitionon a block device. It is intended to be used8 // to a FAT32 disk on a block device. It is intended to be used 9 9 // by the GIET_VM nano-kernel for both the boot code and the kernel code. 10 10 // This code uses functions defined in the utils.c and drivers.c files. … … 175 175 ///////////////////////////////////////////////////////////////////////////////// 176 176 // This function search the FAT (using the FAT cache), and returns 177 // the next cluster index from the cur ent cluster index in the FAT.177 // the next cluster index from the current cluster index in the FAT. 178 178 // remark: a sector of FAT contains 128 cluster indexes. 179 179 ///////////////////////////////////////////////////////////////////////////////// … … 182 182 { 183 183 // compute lba of the sector containing the cluster index 184 unsigned int lba = fat. partition_lba + 32+ (cluster / 128);184 unsigned int lba = fat.fat_lba + (cluster / 128); 185 185 186 186 if ( lba == fat.cache_lba ) // hit in cache … … 666 666 unsigned int value ) 667 667 { 668 unsigned int lba = fat. partition_lba + 32+ (cluster / 128);668 unsigned int lba = fat.fat_lba + (cluster / 128); 669 669 670 670 #if GIET_DEBUG_FAT … … 818 818 819 819 #if GIET_DEBUG_FAT 820 _printf("\n[FAT DEBUG] enter _scan_directory() searching dir/file %s", file name );820 _printf("\n[FAT DEBUG] enter _scan_directory() searching dir/file %s", file_name ); 821 821 #endif 822 822 … … 1030 1030 x, y, lpid ); 1031 1031 #endif 1032 1033 // load Master Boot Record (sector 0) into fat cache1034 if ( _ioc_read( 0, // channel1035 mode, // mode for IOC driver1036 0, // sector index1037 fat.fat_cache, // buffer address1038 1 ) ) // one sector1039 {1040 _printf("\n[FAT ERROR] in _fat_init() cannot load Boot Sector\n");1041 return -1;1042 }1043 fat.cache_lba = 0;1044 1032 1045 #if GIET_DEBUG_FAT 1046 display_fat_cache(); 1047 #endif 1048 1049 // checking Boot sector integrity 1050 if( MBR_SIGNATURE_VALUE != read_entry( MBR_SIGNATURE_POSITION, fat.fat_cache, 1)) 1051 { 1052 _printf("\n[FAT ERROR] Boot sector not recognized or corrupt \n"); 1053 return -1; 1054 } 1055 1056 #if GIET_DEBUG_FAT 1057 _printf("\n[FAT DEBUG] Boot Sector Loaded\n"); 1058 #endif 1059 1060 // initialise fat descriptor from Boot sector 1061 fat.partition_lba = read_entry( FIRST_PARTITION_BEGIN_LBA, fat.fat_cache, 1 ); 1062 fat.partition_sectors = read_entry( FIRST_PARTITION_SIZE, fat.fat_cache, 1 ); 1063 1064 // load Partition Boot Record (first partition sector) into fat cache 1033 // load Boot Record (VBR) into fat cache 1065 1034 if ( _ioc_read( 0, // channel 1066 1035 mode, // mode for IOC driver 1067 fat.partition_lba,// sector index1036 0, // sector index 1068 1037 fat.fat_cache, // buffer address 1069 1038 1 ) ) // one sector 1070 1039 { 1071 _printf("\n[FAT ERROR] in _fat_init() cannot load block %x\n", fat.partition_lba);1040 _printf("\n[FAT ERROR] in _fat_init() cannot load VBR\n"); 1072 1041 return -1; 1073 1042 } 1074 fat.cache_lba = fat.partition_lba; 1075 1076 #if GIET_DEBUG_FAT 1077 _printf("\n[FAT DEBUG] Partition First Sector Loaded\n"); 1078 #endif 1079 1043 fat.cache_lba = 0; 1044 1045 #if GIET_DEBUG_FAT 1046 _printf("\n[FAT DEBUG] Boot Sector Loaded\n"); 1047 #endif 1080 1048 1081 1049 // checking various FAT32 assuptions from boot sector … … 1085 1053 return -1; 1086 1054 } 1087 if( read_entry( BPB_RSVDSECCNT, fat.fat_cache, 1 ) != 32 )1088 {1089 _printf("\n[FAT ERROR] The RSVD region in FAT32 must be 32 sectors\n");1090 return -1;1091 }1092 1055 if( read_entry( BPB_NUMFATS, fat.fat_cache, 1 ) != 1 ) 1093 1056 { … … 1105 1068 return -1; 1106 1069 } 1107 fat.fs_info_lba = read_entry( BPB_FAT32_FSINFO, fat.fat_cache, 1 ) + fat.partition_lba; 1108 1109 // initialise fat descriptor from partition first sector 1070 // FS Info always in sector 1 1071 fat.fs_info_lba = read_entry( BPB_FAT32_FSINFO, fat.fat_cache, 1 ); 1072 1073 // initialise fat descriptor from VBR 1110 1074 fat.sectors_per_cluster = read_entry( BPB_SECPERCLUS, fat.fat_cache, 1 ); 1111 1075 fat.sector_size = read_entry( BPB_BYTSPERSEC, fat.fat_cache, 1 ); 1112 1076 fat.cluster_size = fat.sectors_per_cluster * 512; 1113 1077 fat.fat_sectors = read_entry( BPB_FAT32_FATSZ32, fat.fat_cache, 1 ); 1114 fat.data_lba = 32 + fat.fat_sectors + fat.partition_lba; 1078 fat.fat_lba = read_entry( BPB_RSVDSECCNT, fat.fat_cache, 1 ); 1079 fat.data_lba = fat.fat_lba + fat.fat_sectors; 1115 1080 fat.initialised = FAT_INITIALISED; 1116 1081 … … 1153 1118 _printf("\nSector Size (bytes) %x", fat.sector_size ); 1154 1119 _printf("\nSectors per cluster %x", fat.sectors_per_cluster ); 1155 _printf("\nPartition size (sectors) %x", fat.partition_sectors ); 1156 _printf("\nPartition first lba %x", fat.partition_lba ); 1120 _printf("\nFAT region first lba %x", fat.fat_lba ); 1157 1121 _printf("\nData region first lba %x", fat.data_lba ); 1158 1122 _printf("\nNumber of sectors for one FAT %x", fat.fat_sectors ); -
soft/giet_vm/giet_fat32/fat32.h
r295 r300 126 126 { 127 127 unsigned int used; // descriptor contains an open file 128 unsigned int first_cluster; // first cluster index in partition128 unsigned int first_cluster; // first cluster index on disk 129 129 unsigned int file_size; // number of bytes 130 130 unsigned int lba_dir_entry; // lba of dir_entry for an open file … … 133 133 /***************************************************************************************/ 134 134 135 /************ This struct describes a FAT32 partition**********************************/135 /************ This struct describes a FAT32 disk **********************************/ 136 136 typedef struct fat32_fs_s 137 137 { … … 143 143 unsigned int cluster_size; // sector_size * sector_per_cluster (bytes) 144 144 unsigned int fat_sectors; // number of sectors occupied by one FAT copy 145 unsigned int partition_sectors; // total number of sectors (RESVD+FAT+DATA) 146 unsigned int partition_lba; // lba of first partiton sector 145 unsigned int fat_lba; // lba of first FAT sector 147 146 unsigned int data_lba; // lba of first data sector 148 147 unsigned int cache_lba; // lba of sector loaded in fat_cache
Note: See TracChangeset
for help on using the changeset viewer.