Changeset 300 for soft


Ignore:
Timestamp:
Apr 10, 2014, 2:33:56 PM (11 years ago)
Author:
cfuguet
Message:

The disk image used by the GIET_VM does not contain
anymore a Master Boot Record (MBR) as we do not need
multiple partitions.

The only filesystem in the disk is the FAT32 which
starts at sector 0 (Volume Boot Record).

Location:
soft/giet_vm
Files:
1 deleted
4 edited

Legend:

Unmodified
Added
Removed
  • soft/giet_vm/Makefile

    r299 r300  
    1111### partition sectors    = 524832
    1212
    13 MAP_XML      = mappings/4c_1p_sort_iob.xml
     13MAP_XML     ?= mappings/4c_1p_iob_sort.xml
    1414
    1515### Objects to be linked for kernel.elf
     
    159159        cp -r hdd/misc hdd/virt_hdd
    160160        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 $@)
    165163### 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
    171165
    172166### mapping compilation
  • soft/giet_vm/create_dmg

    r261 r300  
    66sector_size=512
    77sectors_per_cluster=8
    8 reserved_sectors=32
     8reserved_sectors=512
    99
    1010# FAT32 SPEC: The first two clusters are not present in the data region but
     
    5959                        format="UDRW"
    6060
    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"
    6268                        hdiutil create \
    6369                                -fs MS-DOS \
     
    6672                                -sectors $sectors \
    6773                                -ov \
    68                                 -fsargs "-F32 -c$sectors_per_cluster -n1 -r$reserved_sectors" \
     74                                -fsargs "$fsargs" \
    6975                                -format $format \
    7076                                $3;
  • soft/giet_vm/giet_fat32/fat32.c

    r295 r300  
    66//////////////////////////////////////////////////////////////////////////////////
    77// The fat32.h and fat32.c files define a library of access functions
    8 // to a FAT32 partition on a block device. It is intended to be used
     8// to a FAT32 disk on a block device. It is intended to be used
    99// by the GIET_VM nano-kernel for both the boot code and the kernel code.
    1010// This code uses functions defined in the utils.c and drivers.c files.
     
    175175/////////////////////////////////////////////////////////////////////////////////
    176176// This function search the FAT (using the FAT cache), and returns
    177 // the next cluster index from the curent cluster index in the FAT.
     177// the next cluster index from the current cluster index in the FAT.
    178178// remark: a sector of FAT contains 128 cluster indexes.
    179179/////////////////////////////////////////////////////////////////////////////////
     
    182182{
    183183    // 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);
    185185
    186186    if ( lba == fat.cache_lba )      // hit in cache
     
    666666                                       unsigned int value  )
    667667{
    668     unsigned int lba = fat.partition_lba + 32 + (cluster / 128);
     668    unsigned int lba = fat.fat_lba + (cluster / 128);
    669669
    670670#if GIET_DEBUG_FAT
     
    818818
    819819#if GIET_DEBUG_FAT
    820 _printf("\n[FAT DEBUG] enter _scan_directory() searching dir/file %s", filename );
     820_printf("\n[FAT DEBUG] enter _scan_directory() searching dir/file %s", file_name );
    821821#endif
    822822
     
    10301030        x, y, lpid );
    10311031#endif
    1032 
    1033     // load Master Boot Record (sector 0) into fat cache
    1034     if ( _ioc_read( 0,                // channel
    1035                     mode,             // mode for IOC driver
    1036                     0,                // sector index
    1037                     fat.fat_cache,    // buffer address
    1038                     1 ) )             // one sector
    1039     {
    1040         _printf("\n[FAT ERROR] in _fat_init() cannot load Boot Sector\n");
    1041         return -1;
    1042     }
    1043     fat.cache_lba = 0;
    10441032   
    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
    10651034    if ( _ioc_read( 0,                   // channel
    10661035                    mode,                // mode for IOC driver
    1067                     fat.partition_lba,   // sector index
     1036                    0,                   // sector index
    10681037                    fat.fat_cache,       // buffer address
    10691038                    1 ) )                // one sector
    10701039    {
    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");
    10721041        return -1;
    10731042    }
    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
    10801048
    10811049    // checking various FAT32 assuptions from boot sector
     
    10851053        return -1; 
    10861054    }
    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     }
    10921055    if( read_entry( BPB_NUMFATS, fat.fat_cache, 1 ) != 1 )
    10931056    {
     
    11051068        return -1; 
    11061069    }
    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
    11101074    fat.sectors_per_cluster = read_entry( BPB_SECPERCLUS, fat.fat_cache, 1 );
    11111075    fat.sector_size         = read_entry( BPB_BYTSPERSEC, fat.fat_cache, 1 );
    11121076    fat.cluster_size        = fat.sectors_per_cluster * 512;
    11131077    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;
    11151080    fat.initialised         = FAT_INITIALISED;
    11161081
     
    11531118    _printf("\nSector Size  (bytes)           %x", fat.sector_size );
    11541119    _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 );
    11571121    _printf("\nData region first lba          %x", fat.data_lba );
    11581122    _printf("\nNumber of sectors for one FAT  %x", fat.fat_sectors );
  • soft/giet_vm/giet_fat32/fat32.h

    r295 r300  
    126126{
    127127   unsigned int  used;                      // descriptor contains an open file
    128    unsigned int  first_cluster;             // first cluster index in partition
     128   unsigned int  first_cluster;             // first cluster index on disk
    129129   unsigned int  file_size;                 // number of bytes   
    130130   unsigned int  lba_dir_entry;             // lba of dir_entry for an open file
     
    133133/***************************************************************************************/
    134134
    135 /************ This struct describes a FAT32 partition **********************************/
     135/************ This struct describes a FAT32 disk **********************************/
    136136typedef struct fat32_fs_s
    137137{
     
    143143    unsigned int    cluster_size;            // sector_size * sector_per_cluster (bytes)
    144144    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
    147146    unsigned int    data_lba;                // lba of first data sector 
    148147    unsigned int    cache_lba;               // lba of sector loaded in fat_cache
Note: See TracChangeset for help on using the changeset viewer.