1*d5c9a868SElliott Hughes /* Copyright 1997,1998,2001-2003,2006,2009 Alain Knaff. 2*d5c9a868SElliott Hughes * This file is part of mtools. 3*d5c9a868SElliott Hughes * 4*d5c9a868SElliott Hughes * Mtools is free software: you can redistribute it and/or modify 5*d5c9a868SElliott Hughes * it under the terms of the GNU General Public License as published by 6*d5c9a868SElliott Hughes * the Free Software Foundation, either version 3 of the License, or 7*d5c9a868SElliott Hughes * (at your option) any later version. 8*d5c9a868SElliott Hughes * 9*d5c9a868SElliott Hughes * Mtools is distributed in the hope that it will be useful, 10*d5c9a868SElliott Hughes * but WITHOUT ANY WARRANTY; without even the implied warranty of 11*d5c9a868SElliott Hughes * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12*d5c9a868SElliott Hughes * GNU General Public License for more details. 13*d5c9a868SElliott Hughes * 14*d5c9a868SElliott Hughes * You should have received a copy of the GNU General Public License 15*d5c9a868SElliott Hughes * along with Mtools. If not, see <http://www.gnu.org/licenses/>. 16*d5c9a868SElliott Hughes */ 17*d5c9a868SElliott Hughes 18*d5c9a868SElliott Hughes typedef struct hsc { 19*d5c9a868SElliott Hughes unsigned char byte0; 20*d5c9a868SElliott Hughes unsigned char head; /* starting head */ 21*d5c9a868SElliott Hughes unsigned char sector; /* starting sector */ 22*d5c9a868SElliott Hughes unsigned char cyl; /* starting cylinder */ 23*d5c9a868SElliott Hughes } hsc; 24*d5c9a868SElliott Hughes 25*d5c9a868SElliott Hughes #define head(x) ((uint8_t)((x).head)) 26*d5c9a868SElliott Hughes #define sector(x) ((uint8_t)((x).sector & 0x3f)) 27*d5c9a868SElliott Hughes #define cyl(x) ((uint16_t)((x).cyl | (((x).sector & 0xc0)<<2))) 28*d5c9a868SElliott Hughes 29*d5c9a868SElliott Hughes #define BEGIN(p) _DWORD((p)->start_sect) 30*d5c9a868SElliott Hughes #define END(p) (_DWORD((p)->start_sect)+(_DWORD((p)->nr_sects))) 31*d5c9a868SElliott Hughes #define PART_SIZE(p) (_DWORD((p)->nr_sects)) 32*d5c9a868SElliott Hughes 33*d5c9a868SElliott Hughes 34*d5c9a868SElliott Hughes struct partition { 35*d5c9a868SElliott Hughes hsc start; 36*d5c9a868SElliott Hughes hsc end; 37*d5c9a868SElliott Hughes unsigned char start_sect[4]; /* starting sector counting from 0 */ 38*d5c9a868SElliott Hughes unsigned char nr_sects[4]; /* nr of sectors in partition */ 39*d5c9a868SElliott Hughes }; 40*d5c9a868SElliott Hughes 41*d5c9a868SElliott Hughes #define boot_ind start.byte0 42*d5c9a868SElliott Hughes #define sys_ind end.byte0 43*d5c9a868SElliott Hughes 44*d5c9a868SElliott Hughes int consistencyCheck(struct partition *partTable, int doprint, int verbose, 45*d5c9a868SElliott Hughes int *has_activated, uint32_t tot_sectors, 46*d5c9a868SElliott Hughes struct device *used_dev, unsigned int target_partition); 47*d5c9a868SElliott Hughes 48*d5c9a868SElliott Hughes void setBeginEnd(struct partition *partTable, 49*d5c9a868SElliott Hughes uint32_t begin, uint32_t end, 50*d5c9a868SElliott Hughes uint16_t iheads, uint16_t isectors, 51*d5c9a868SElliott Hughes int activate, uint8_t type, unsigned int fat_bits); 52*d5c9a868SElliott Hughes 53*d5c9a868SElliott Hughes Stream_t *OpenPartition(Stream_t *Next, struct device *dev, 54*d5c9a868SElliott Hughes char *errmsg, mt_off_t *maxSize); 55*d5c9a868SElliott Hughes 56*d5c9a868SElliott Hughes unsigned int findOverlap(struct partition *partTable, unsigned int until, 57*d5c9a868SElliott Hughes uint32_t start, uint32_t end); 58