diff options
author | Keith Wansbrough <keith@lochan.org> | 2008-09-22 17:57:17 -0400 |
---|---|---|
committer | Jens Axboe <jens.axboe@oracle.com> | 2008-10-09 02:56:19 -0400 |
commit | 9e49184c82e9ec3ab4d45f9ea5a17ccaf43869f0 (patch) | |
tree | 532d70e75854e1f7c070d4818f3b44cefe528d3e /drivers/block | |
parent | 061837bc8687edc2739ef02f721b7ae0b8076390 (diff) |
floppy: support arbitrary first-sector numbers
The current floppy_struct allows floppies to number sectors starting
from 0 or 1. This patch allows arbitrary first-sector numbers - for
example, 0xC1 for Amstrad CPC disks.
This extends the existing 1-bit field (FD_ZEROBASED, bit 2 of stretch)
to 8 bits (FD_SECTMASK, bits 2 to 9).
Currently 0x00 denotes a first sector number of 1, and 0x01 denotes a
first sector number of 0. We extend this by interpreting FD_SECTMASK
as the first sector number with the LSB flipped.
Signed-off-by: Keith Wansbrough <keith@lochan.org>
Cc: Alain Knaff <alain@linux.lu>
Cc: Michael Kerrisk <mtk.manpages@googlemail.com>
Cc: Karel Zak <kzak@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
Diffstat (limited to 'drivers/block')
-rw-r--r-- | drivers/block/floppy.c | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/drivers/block/floppy.c b/drivers/block/floppy.c index 9c0b494f5e87..cf64ddf5d839 100644 --- a/drivers/block/floppy.c +++ b/drivers/block/floppy.c | |||
@@ -423,8 +423,15 @@ static struct floppy_raw_cmd *raw_cmd, default_raw_cmd; | |||
423 | * 1581's logical side 0 is on physical side 1, whereas the Sharp's logical | 423 | * 1581's logical side 0 is on physical side 1, whereas the Sharp's logical |
424 | * side 0 is on physical side 0 (but with the misnamed sector IDs). | 424 | * side 0 is on physical side 0 (but with the misnamed sector IDs). |
425 | * 'stretch' should probably be renamed to something more general, like | 425 | * 'stretch' should probably be renamed to something more general, like |
426 | * 'options'. Other parameters should be self-explanatory (see also | 426 | * 'options'. |
427 | * setfdprm(8)). | 427 | * |
428 | * Bits 2 through 9 of 'stretch' tell the number of the first sector. | ||
429 | * The LSB (bit 2) is flipped. For most disks, the first sector | ||
430 | * is 1 (represented by 0x00<<2). For some CP/M and music sampler | ||
431 | * disks (such as Ensoniq EPS 16plus) it is 0 (represented as 0x01<<2). | ||
432 | * For Amstrad CPC disks it is 0xC1 (represented as 0xC0<<2). | ||
433 | * | ||
434 | * Other parameters should be self-explanatory (see also setfdprm(8)). | ||
428 | */ | 435 | */ |
429 | /* | 436 | /* |
430 | Size | 437 | Size |
@@ -2236,9 +2243,9 @@ static void setup_format_params(int track) | |||
2236 | } | 2243 | } |
2237 | } | 2244 | } |
2238 | } | 2245 | } |
2239 | if (_floppy->stretch & FD_ZEROBASED) { | 2246 | if (_floppy->stretch & FD_SECTBASEMASK) { |
2240 | for (count = 0; count < F_SECT_PER_TRACK; count++) | 2247 | for (count = 0; count < F_SECT_PER_TRACK; count++) |
2241 | here[count].sect--; | 2248 | here[count].sect += FD_SECTBASE(_floppy) - 1; |
2242 | } | 2249 | } |
2243 | } | 2250 | } |
2244 | 2251 | ||
@@ -2649,7 +2656,7 @@ static int make_raw_rw_request(void) | |||
2649 | } | 2656 | } |
2650 | HEAD = fsector_t / _floppy->sect; | 2657 | HEAD = fsector_t / _floppy->sect; |
2651 | 2658 | ||
2652 | if (((_floppy->stretch & (FD_SWAPSIDES | FD_ZEROBASED)) || | 2659 | if (((_floppy->stretch & (FD_SWAPSIDES | FD_SECTBASEMASK)) || |
2653 | TESTF(FD_NEED_TWADDLE)) && fsector_t < _floppy->sect) | 2660 | TESTF(FD_NEED_TWADDLE)) && fsector_t < _floppy->sect) |
2654 | max_sector = _floppy->sect; | 2661 | max_sector = _floppy->sect; |
2655 | 2662 | ||
@@ -2679,7 +2686,7 @@ static int make_raw_rw_request(void) | |||
2679 | CODE2SIZE; | 2686 | CODE2SIZE; |
2680 | SECT_PER_TRACK = _floppy->sect << 2 >> SIZECODE; | 2687 | SECT_PER_TRACK = _floppy->sect << 2 >> SIZECODE; |
2681 | SECTOR = ((fsector_t % _floppy->sect) << 2 >> SIZECODE) + | 2688 | SECTOR = ((fsector_t % _floppy->sect) << 2 >> SIZECODE) + |
2682 | ((_floppy->stretch & FD_ZEROBASED) ? 0 : 1); | 2689 | FD_SECTBASE(_floppy); |
2683 | 2690 | ||
2684 | /* tracksize describes the size which can be filled up with sectors | 2691 | /* tracksize describes the size which can be filled up with sectors |
2685 | * of size ssize. | 2692 | * of size ssize. |
@@ -3311,7 +3318,7 @@ static inline int set_geometry(unsigned int cmd, struct floppy_struct *g, | |||
3311 | g->head <= 0 || | 3318 | g->head <= 0 || |
3312 | g->track <= 0 || g->track > UDP->tracks >> STRETCH(g) || | 3319 | g->track <= 0 || g->track > UDP->tracks >> STRETCH(g) || |
3313 | /* check if reserved bits are set */ | 3320 | /* check if reserved bits are set */ |
3314 | (g->stretch & ~(FD_STRETCH | FD_SWAPSIDES | FD_ZEROBASED)) != 0) | 3321 | (g->stretch & ~(FD_STRETCH | FD_SWAPSIDES | FD_SECTBASEMASK)) != 0) |
3315 | return -EINVAL; | 3322 | return -EINVAL; |
3316 | if (type) { | 3323 | if (type) { |
3317 | if (!capable(CAP_SYS_ADMIN)) | 3324 | if (!capable(CAP_SYS_ADMIN)) |
@@ -3356,7 +3363,7 @@ static inline int set_geometry(unsigned int cmd, struct floppy_struct *g, | |||
3356 | if (DRS->maxblock > user_params[drive].sect || | 3363 | if (DRS->maxblock > user_params[drive].sect || |
3357 | DRS->maxtrack || | 3364 | DRS->maxtrack || |
3358 | ((user_params[drive].sect ^ oldStretch) & | 3365 | ((user_params[drive].sect ^ oldStretch) & |
3359 | (FD_SWAPSIDES | FD_ZEROBASED))) | 3366 | (FD_SWAPSIDES | FD_SECTBASEMASK))) |
3360 | invalidate_drive(bdev); | 3367 | invalidate_drive(bdev); |
3361 | else | 3368 | else |
3362 | process_fd_request(); | 3369 | process_fd_request(); |