wdenk | 2262cfe | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 1 | /* |
| 2 | * (C) Copyright 2002 |
Albert ARIBAUD | fa82f87 | 2011-08-04 18:45:45 +0200 | [diff] [blame] | 3 | * Stäubli Faverges - <www.staubli.com> |
wdenk | 2262cfe | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 4 | * Pierre AUBERT p.aubert@staubli.com |
| 5 | * |
Wolfgang Denk | 1a45966 | 2013-07-08 09:37:19 +0200 | [diff] [blame] | 6 | * SPDX-License-Identifier: GPL-2.0+ |
wdenk | 2262cfe | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 7 | */ |
| 8 | |
| 9 | #ifndef _FDOS_H_ |
| 10 | #define _FDOS_H_ |
| 11 | |
| 12 | |
| 13 | #undef FDOS_DEBUG |
| 14 | |
| 15 | #ifdef FDOS_DEBUG |
| 16 | #define PRINTF(fmt,args...) printf (fmt ,##args) |
| 17 | #else |
| 18 | #define PRINTF(fmt,args...) |
| 19 | #endif |
| 20 | |
| 21 | /* Data structure describing media */ |
| 22 | typedef struct fs |
| 23 | { |
| 24 | unsigned long tot_sectors; |
| 25 | |
| 26 | int cluster_size; |
| 27 | int num_clus; |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 28 | |
wdenk | 2262cfe | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 29 | int fat_start; |
| 30 | int fat_len; |
| 31 | int nb_fat; |
| 32 | int num_fat; |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 33 | |
wdenk | 2262cfe | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 34 | int dir_start; |
| 35 | int dir_len; |
| 36 | |
| 37 | unsigned char *fat_buf; |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 38 | |
wdenk | 2262cfe | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 39 | } Fs_t; |
| 40 | |
| 41 | /* Data structure describing one file system slot */ |
| 42 | typedef struct slot { |
| 43 | int (*map) (struct fs *fs, |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 44 | struct slot *file, |
| 45 | int where, |
| 46 | int *len); |
wdenk | 2262cfe | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 47 | unsigned long FileSize; |
| 48 | |
| 49 | unsigned short int FirstAbsCluNr; |
| 50 | unsigned short int PreviousAbsCluNr; |
| 51 | unsigned short int PreviousRelCluNr; |
| 52 | |
| 53 | Directory_t dir; |
| 54 | } Slot_t; |
| 55 | |
| 56 | typedef struct file { |
| 57 | char *name; |
| 58 | int Case; |
| 59 | Fs_t *fs; |
| 60 | Slot_t subdir; |
| 61 | Slot_t file; |
| 62 | } File_t; |
| 63 | |
| 64 | |
| 65 | /* dev.c */ |
| 66 | int dev_read (void *buffer, int where, int len); |
| 67 | int dev_open (void); |
| 68 | int check_dev (BootSector_t *boot, Fs_t *fs); |
| 69 | |
| 70 | /* fat.c */ |
| 71 | unsigned int fat_decode (Fs_t *fs, unsigned int num); |
| 72 | int read_fat (BootSector_t *boot, Fs_t *fs); |
| 73 | |
| 74 | /* vfat.c */ |
| 75 | int vfat_lookup (Slot_t *dir, |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 76 | Fs_t *fs, |
| 77 | Directory_t *dirent, |
| 78 | int *entry, |
| 79 | int *vfat_start, |
| 80 | char *filename, |
| 81 | int flags, |
| 82 | char *outname, |
| 83 | Slot_t *file); |
wdenk | 2262cfe | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 84 | |
| 85 | /* subdir.c */ |
| 86 | char *basename (char *name); |
| 87 | int open_subdir (File_t *desc); |
| 88 | int open_file (Slot_t *file, Directory_t *dir); |
| 89 | int read_file (Fs_t *fs, |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 90 | Slot_t *file, |
| 91 | char *buf, |
| 92 | int where, |
| 93 | int len); |
wdenk | 2262cfe | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 94 | void init_subdir (void); |
| 95 | |
| 96 | /* fs.c */ |
| 97 | int fs_init (Fs_t *fs); |
| 98 | |
| 99 | |
| 100 | #endif |