Ignore:
Timestamp:
Mar 27, 2015, 12:10:20 PM (10 years ago)
Author:
alain
Message:

1) The FAT library supports now only two modes to access the block device:

  • synchronous: the calling task detect transfer completion by polling the block device status. This mode is used by the boot code.
  • descheduling: The calling task is descheduled, and transfer completion is signaled by an IRQ. This mode is used by the kernel code to handle user system calls.

2) The generic IOC driver has been integrate in the FAT library: the _fat_ioc_access() function

select the proper driver (BDV,HBA,SDC,RDK), with the requested access mode.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • soft/giet_vm/giet_fat32/fat32.h

    r503 r530  
    1 ////////////////////////////////////////////////////////////////////////////
     1////////////////////////////////////////////////////////////////////////////////
    22// File     : fat32.h
    33// Date     : 01/09/2013
    44// Author   : Marco Jankovic / Alain Greiner
    55// Copyright (c) UPMC-LIP6
    6 ////////////////////////////////////////////////////////////////////////////
     6////////////////////////////////////////////////////////////////////////////////
    77
    88#ifndef _FAT32_H
     
    1212#include "kernel_locks.h"
    1313
    14 /*************** Partition Boot Sector Format ******************************************/
     14/*************** Partition Boot Sector Format **********************************/
    1515//                                     offset |  length
    1616#define BS_JMPBOOT                          0 ,  3
     
    5656#define FOURTH_PARTITION_BEGIN_LBA        502 ,  4
    5757#define FOURTH_PARTITION_SIZE             506 ,  4   
    58 /***************************************************************************************/
     58/*******************************************************************************/
    5959
    6060#define MBR_SIGNATURE_POSITION            510 , 2
    6161#define MBR_SIGNATURE_VALUE               0xAA55 
    6262
    63 /************** FAT_FS_INFO SECTOR  ****************************************************/
     63/************** FAT_FS_INFO SECTOR  ********************************************/
    6464#define FS_SIGNATURE_VALUE_1              0x52526141
    6565#define FS_SIGNATURE_VALUE_2              0x72724161
     
    7070#define FS_FREE_CLUSTER                   488 , 4
    7171#define FS_FREE_CLUSTER_HINT              492 , 4
    72 /***************************************************************************************/
     72/*******************************************************************************/
    7373
    7474#define DIR_ENTRY_SIZE          32
    7575                   
    76 /******* Directory Entry Structure (32 bytes) ******************************************/
     76/******* Directory Entry Structure (32 bytes) **********************************/
    7777//                          offset | length
    7878#define DIR_NAME                 0 , 11   // dir_entry name
     
    8585#define DIR_FST_CLUS_LO         26 ,  2   // cluster index 16 LSB bit
    8686#define DIR_FILE_SIZE           28 ,  4   // file size (up to 4 giga bytes)
    87 /***************************************************************************************/
    88 
    89 /******* LFN Directory Entry Structure  (32 bytes) *************************************/
     87/*******************************************************************************/
     88
     89/******* LFN Directory Entry Structure  (32 bytes) *****************************/
    9090//                          offset | length
    9191#define LDIR_ORD                 0 ,  1   // Sequence number (from 0x01 to 0x0f)   
     
    9797#define LDIR_RSVD               26 ,  2   // artifact of previous fat (must be 0)
    9898#define LDIR_NAME_3             28 ,  4   
    99 /***************************************************************************************/
    100 
    101 /***********************  DIR_ATTR values  (attributes) ********************************/
     99/*******************************************************************************/
     100
     101/***********************  DIR_ATTR values  (attributes) ************************/
    102102#define ATTR_READ_ONLY          0x01
    103103#define ATTR_HIDDEN             0x02
     
    107107#define ATTR_ARCHIVE            0x20
    108108#define ATTR_LONG_NAME_MASK     0x0f      // READ_ONLY|HIDDEN|SYSTEM|VOLUME_ID
    109 /***************************************************************************************/
    110 
    111 /********************* DIR_ORD special values ******************************************/
     109/*******************************************************************************/
     110
     111/********************* DIR_ORD special values **********************************/
    112112#define FREE_ENTRY              0xE5     // this entry is free in the directory
    113113#define NO_MORE_ENTRY           0x00     // no more entry in the directory
    114 /***************************************************************************************/
    115 
    116 /******************** CLuster Index Special Values *************************************/
     114/*******************************************************************************/
     115
     116/******************** CLuster Index Special Values *****************************/
    117117#define FREE_CLUSTER            0x00000000
    118118#define RESERVED_CLUSTER        0x00000001
    119119#define BAD_CLUSTER             0x0FFFFFF7
    120120#define END_OF_CHAIN_CLUSTER    0x0ffffff8
    121 /***************************************************************************************/
     121/*******************************************************************************/
    122122
    123123#define FAT_INITIALISED         0xBABEF00D
    124124
    125 /************ This struct defines a file descriptor ************************************/
     125/************ This struct defines a file descriptor ****************************/
    126126typedef struct file_descriptor_s
    127127{
     
    132132   char          name[244];                 // pathname
    133133}  file_desc_t;
    134 /***************************************************************************************/
    135 
    136 /************ This struct describes a FAT32 disk **********************************/
     134/*******************************************************************************/
     135
     136/************ This struct describes a FAT32 disk *******************************/
    137137typedef struct fat32_fs_s
    138138{
    139     char            fat_cache[512];          // FAT cache: 1 sector = 128 cluster indexes
     139    char            fat_cache[512];          // FAT cache: 1 sector
    140140    spin_lock_t     fat_lock;                // lock protecting exclusive access
    141141    file_desc_t     fd[GIET_OPEN_FILES_MAX]; // file descriptors array
    142     unsigned int    initialised;             // contains 0xBABEF00D when FAT initialised
     142    unsigned int    initialised;             // 0xBABEF00D when FAT initialised
    143143    unsigned int    sector_size;             // number of bytes (power of 2)
    144144    unsigned int    sectors_per_cluster;     // power of 2 (must be greater than 4)
    145     unsigned int    cluster_size;            // sector_size * sector_per_cluster (bytes)
    146     unsigned int    fat_sectors;             // number of sectors occupied by one FAT copy
     145    unsigned int    cluster_size;            // sector_size * sector_per_cluster
     146    unsigned int    fat_sectors;             // number of sectors for 1 FAT copy
    147147    unsigned int    fat_lba;                 // lba of first FAT sector
    148148    unsigned int    data_lba;                // lba of first data sector 
     
    152152    unsigned int    fs_info_lba;             // lba of fs_info
    153153} fat32_fs_t;
    154 /***************************************************************************************/
    155 
    156 /*********************** Export Functions  *********************************************/
    157 
    158 extern void _fat_print();
    159 
    160 // functions used for low level access to fat
    161 // (move sectors between block device and system buffers)
    162 
    163 extern int _fat_init(  unsigned int mode );        // mode for IOC driver
    164 
    165 extern int _fat_open(  unsigned int mode,          // mode for IOC driver
    166                        char*  pathname,            // file pathname from root
    167                        unsigned int create );      // create new file if non zero
    168 
    169 extern int _fat_read(  unsigned int mode,          // mode for IOC driver
    170                        unsigned int fd_id,         // file descriptor index
    171                        void*        buffer,        // destination buffer
    172                        unsigned int count,            // number of sectors to read
    173                        unsigned int offset );      // offset sector in file
    174 
    175 extern int _fat_write( unsigned int mode,         // mode for IOC driver
    176                        unsigned int fd_id,        // file descriptor index
    177                        void*        buffer,               // source buffer
    178                        unsigned int count,        // number of sectors to write
    179                        unsigned int offset );     // offset sector in file
    180 
    181 extern int _fat_fstat( unsigned int fd_id );      // file descriptor index
    182 
    183 extern int _fat_close( unsigned int fd_id );      // file descriptor index
    184 
    185 
    186 // functions used by user system calls
    187 // (should move bytes between system buffers and user buffers)
    188 
    189 extern int _fat_user_open(  char*        pathname,  // file pathname from root
    190                             unsigned int flags );   // unused
     154/*******************************************************************************/
     155
     156/*********************** Extern Functions  *************************************/
     157
     158extern int _fat_init( unsigned int use_irq );       // use IRQ if possible
     159
     160extern int _fat_open(  unsigned int use_irq,        // use IRQ if possible
     161                       char*  pathname,             // file pathname from root
     162                       unsigned int create );       // create new file if non zero
     163
     164extern int _fat_read(  unsigned int use_irq,        // use IRQ if possible
     165                       unsigned int fd_id,          // file descriptor index
     166                       void*        buffer,         // destination buffer
     167                       unsigned int count,          // number of sectors to read
     168                       unsigned int offset );       // offset sector in file
     169
     170extern int _fat_write( unsigned int use_irq,        // use IRQ if possible
     171                       unsigned int fd_id,          // file descriptor index
     172                       void*        buffer,                 // source buffer
     173                       unsigned int count,          // number of sectors to write
     174                       unsigned int offset );       // offset sector in file
     175
     176extern int _fat_fstat( unsigned int fd_id );        // file descriptor index
     177
     178extern int _fat_close( unsigned int fd_id );        // file descriptor index
     179
     180
     181extern int _fat_user_open( char*        pathname,   // file pathname from root
     182                           unsigned int flags );    // unused
    191183
    192184extern int _fat_user_read(  unsigned int fd_id,     // file descriptor index
    193185                            void*        buffer,    // destination buffer
    194186                            unsigned int count,     // number of sectors to read
    195                             unsigned int offset );  // number of sectors to skip in file
     187                            unsigned int offset );  // sectors to skip in file
    196188
    197189extern int _fat_user_write( unsigned int fd_id,     // file descriptor index
    198190                            void*        buffer,    // source buffer
    199191                            unsigned int count,     // number of sectors to write
    200                             unsigned int offset );  // number of sectors to skip in file
     192                            unsigned int offset );  // sectors to skip in file
    201193
    202194extern int _fat_user_lseek( unsigned int fd_id,
     
    204196                            unsigned int whence ); 
    205197
    206 /***************************************************************************************/
     198/*******************************************************************************/
    207199
    208200
Note: See TracChangeset for help on using the changeset viewer.