00001 #ifndef FS_PHATVOL_H_ 00002 #define FS_PHATVOL_H_ 00003 00004 /* 00005 * Copyright (C) 2005 by egnite Software GmbH. All rights reserved. 00006 * 00007 * Redistribution and use in source and binary forms, with or without 00008 * modification, are permitted provided that the following conditions 00009 * are met: 00010 * 00011 * 1. Redistributions of source code must retain the above copyright 00012 * notice, this list of conditions and the following disclaimer. 00013 * 2. Redistributions in binary form must reproduce the above copyright 00014 * notice, this list of conditions and the following disclaimer in the 00015 * documentation and/or other materials provided with the distribution. 00016 * 3. Neither the name of the copyright holders nor the names of 00017 * contributors may be used to endorse or promote products derived 00018 * from this software without specific prior written permission. 00019 * 00020 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 00021 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 00022 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 00023 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 00024 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 00025 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 00026 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 00027 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 00028 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 00029 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF 00030 * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 00031 * SUCH DAMAGE. 00032 * 00033 * For additional information see http://www.ethernut.de/ 00034 */ 00035 00069 #include <cfg/fs.h> 00070 00071 #include <sys/types.h> 00072 #include <sys/file.h> 00073 #include <sys/device.h> 00074 00079 00083 typedef struct __attribute__ ((packed)) _PHATVBR { 00085 uint8_t boot_jump[3]; 00087 uint8_t boot_oem[8]; 00092 uint16_t bios_sectsz; 00094 uint8_t bios_clustsz; 00100 uint16_t bios_rsvd_sects; 00102 uint8_t bios_ntabs; 00104 uint16_t bios_rootsz; 00106 uint16_t bios_volsz; 00108 uint8_t bios_media; 00113 uint16_t bios_tabsz; 00115 uint16_t bios_sects_p_trk; 00117 uint16_t bios_heads; 00122 uint32_t bios_sects_hidd; 00127 uint32_t bios_volsz_big; 00128 00133 uint32_t bios_tabsz_big; 00140 uint16_t bios_xflags; 00142 uint16_t bios_fsver; 00144 uint32_t bios_root_clust; 00146 uint16_t bios_fsinfo; 00148 uint16_t bios_boot_bak; 00153 uint8_t bios_rsvd32[12]; 00154 00160 uint8_t boot_drive; 00162 uint8_t boot_rsvd_nt; 00167 uint8_t boot_xsig; 00169 uint32_t boot_vol_id; 00171 uint8_t boot_vol_lbl[11]; 00173 uint8_t boot_vol_fs[8]; 00174 } PHATVBR; 00175 00179 typedef struct _PHATSECTBUF { 00181 uint8_t *sect_data; 00183 uint32_t sect_num; 00185 int sect_dirty; 00187 int sect_lock; 00188 } PHATSECTBUF; 00189 00193 typedef struct _PHATVOL { 00198 int vol_type; 00200 uint32_t vol_numfree; 00202 uint32_t vol_nxtfree; 00204 #if PHAT_SECTOR_BUFFERS 00205 PHATSECTBUF vol_buf[PHAT_SECTOR_BUFFERS]; 00207 int vol_usenext; 00208 #else 00209 PHATSECTBUF vol_buf[1]; 00210 #endif 00211 00212 HANDLE vol_fsmutex; 00214 HANDLE vol_iomutex; 00216 unsigned int vol_sectsz; 00218 unsigned int vol_clustsz; 00219 00221 uint32_t vol_tabsz; 00226 uint32_t vol_tab_sect[2]; 00227 00229 unsigned int vol_rootsz; 00231 uint32_t vol_root_sect; 00233 uint32_t vol_root_clust; 00234 00240 uint32_t vol_last_clust; 00245 uint32_t vol_data_sect; 00246 } PHATVOL; 00247 00250 extern int PhatVolMount(NUTDEVICE * dev, NUTFILE * blkmnt, uint8_t part_type); 00251 extern int PhatVolUnmount(NUTDEVICE * dev); 00252 extern uint32_t PhatClusterSector(NUTFILE * nfp, uint32_t clust); 00253 00254 #endif