Improve handling for sectors not 512 bytes in size (up to 2048 bytes)

git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@1702 6ac86273-5f31-0410-b378-82cca8765d1b
This commit is contained in:
Kenneth J Davis 2012-02-04 08:46:16 +00:00
parent 869e077227
commit 9199c37a45
10 changed files with 66 additions and 27 deletions

View File

@ -37,7 +37,9 @@ static BYTE *buffer_hRcsId =
#endif
#endif
#define BUFFERSIZE 512
#include "dsk.h" /* only for MAX_SEC_SIZE */
#define BUFFERSIZE MAX_SEC_SIZE
struct buffer {
UWORD b_next; /* next buffer in LRU list */
UWORD b_prev; /* previous buffer in LRU list */

View File

@ -177,7 +177,8 @@ typedef struct {
} bpb;
#define N_RETRY 5 /* number of retries permitted */
#define SEC_SIZE 512 /* size of sector in bytes */
#include "dsk.h"
#define LBA_READ 0x4200
#define LBA_WRITE 0x4300

33
hdr/dsk.h Normal file
View File

@ -0,0 +1,33 @@
/****************************************************************/
/* */
/* dsk.h */
/* Disk access Header File */
/* */
/* November 20, 1991 */
/* */
/* Copyright (c) 1995 */
/* Pasquale J. Villani */
/* All Rights Reserved */
/* */
/* This file is part of DOS-C. */
/* */
/* DOS-C is free software; you can redistribute it and/or */
/* modify it under the terms of the GNU General Public License */
/* as published by the Free Software Foundation; either version */
/* 2, or (at your option) any later version. */
/* */
/* DOS-C is distributed in the hope that it will be useful, but */
/* WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See */
/* the GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public */
/* License along with DOS-C; see the file COPYING. If not, */
/* write to the Free Software Foundation, 675 Mass Ave, */
/* Cambridge, MA 02139, USA. */
/****************************************************************/
#ifndef MAX_SEC_SIZE
#define MAX_SEC_SIZE (4*512) /* max supported size of sector in bytes */
#endif

View File

@ -39,7 +39,7 @@ struct lol {
struct sfttbl far *sfthead; /* 4 System File Table head */
struct dhdr far *clock; /* 8 CLOCK$ device */
struct dhdr far *syscon; /* c console device */
unsigned short maxsecbytes; /* 10 max bytes per sector for any blkdev */
unsigned short maxsecsize; /* 10 max bytes per sector for any blkdev */
void far *inforecptr; /* 12 pointer to disk buffer info record */
struct cds far *CDSp; /* 16 Current Directory Structure */
struct sfttbl far *FCBp; /* 1a FCB table pointer */

View File

@ -436,10 +436,10 @@ UWORD dskxfer(COUNT dsk, ULONG blkno, VOID FAR * buf, UWORD numblocks,
{
IoReqHdr.r_trans = deblock_buf;
if (mode == DSKWRITE)
fmemcpy(deblock_buf, buf, SEC_SIZE);
fmemcpy(deblock_buf, buf, dpbp->dpb_secsize);
execrh((request FAR *) & IoReqHdr, dpbp->dpb_device);
if (mode == DSKREAD)
fmemcpy(buf, deblock_buf, SEC_SIZE);
fmemcpy(buf, deblock_buf, dpbp->dpb_secsize);
}
else
{

View File

@ -81,7 +81,7 @@ UWORD LBA_WRITE_VERIFY = 0x4302;
this is certainly true, if located somewhere
at 0xf+1000 and must hold already during BOOT time
*/
UBYTE DiskTransferBuffer[1 * SEC_SIZE];
UBYTE DiskTransferBuffer[MAX_SEC_SIZE];
struct FS_info {
ULONG serialno;
@ -388,7 +388,7 @@ STATIC WORD getbpb(ddt * pddt)
pbpbarray->bpb_nbyte = getword(&DiskTransferBuffer[BT_BPB]);
if (DiskTransferBuffer[0x1fe] != 0x55
|| DiskTransferBuffer[0x1ff] != 0xaa || pbpbarray->bpb_nbyte != 512)
|| DiskTransferBuffer[0x1ff] != 0xaa || pbpbarray->bpb_nbyte % 512)
{
/* copy default bpb to be sure that there is no bogus data */
memcpy(pbpbarray, &pddt->ddt_defbpb, sizeof(bpb));
@ -891,8 +891,8 @@ STATIC unsigned DMA_max_transfer(void FAR * buffer, unsigned count)
{
unsigned dma_off = (UWORD)((FP_SEG(buffer) << 4) + FP_OFF(buffer));
unsigned sectors_to_dma_boundary = (dma_off == 0 ?
0xffff / SEC_SIZE :
(UWORD)(-dma_off) / SEC_SIZE);
0xffff / maxsecsize :
(UWORD)(-dma_off) / maxsecsize);
return min(count, sectors_to_dma_boundary);
}
@ -941,6 +941,7 @@ STATIC int LBA_Transfer(ddt * pddt, UWORD mode, VOID FAR * buffer,
int num_retries;
UWORD bytes_sector = pddt->ddt_bpb.bpb_nbyte; /* bytes per sector, usually 512 */
*transferred = 0;
/* only low-level format floppies for now ! */
@ -983,7 +984,7 @@ STATIC int LBA_Transfer(ddt * pddt, UWORD mode, VOID FAR * buffer,
if ((mode & 0xff00) == (LBA_WRITE & 0xff00))
{
fmemcpy(DiskTransferBuffer, buffer, 512);
fmemcpy(DiskTransferBuffer, buffer, bytes_sector);
}
}
else
@ -1066,14 +1067,14 @@ STATIC int LBA_Transfer(ddt * pddt, UWORD mode, VOID FAR * buffer,
if (transfer_address == DiskTransferBuffer &&
(mode & 0xff00) == (LBA_READ & 0xff00))
{
fmemcpy(buffer, DiskTransferBuffer, 512);
fmemcpy(buffer, DiskTransferBuffer, bytes_sector);
}
*transferred += count;
LBA_address += count;
totaltodo -= count;
buffer = adjust_far((char FAR *)buffer + count * 512);
buffer = adjust_far((char FAR *)buffer + count * bytes_sector);
}
return (error_code);

View File

@ -239,7 +239,7 @@ extern sfttbl FAR * ASM sfthead; /* System File Table head */
extern struct dhdr
FAR * ASM clock, /* CLOCK$ device */
FAR * ASM syscon; /* console device */
extern WORD ASM maxbksize; /* Number of Drives in system */
extern WORD ASM maxsecsize; /* largest sector size in use (can use) */
extern struct buffer
FAR *ASM firstbuf; /* head of buffers linked list */
enum {LOC_CONV=0, LOC_HMA=1};
@ -332,7 +332,7 @@ extern UBYTE ASM BootDrive, /* Drive we came up from */
extern keyboard ASM kb_buf;
extern char ASM local_buffer[LINEBUFSIZE0A];
extern UBYTE DiskTransferBuffer[SEC_SIZE];
extern UBYTE DiskTransferBuffer[/*SEC_SIZE*/];
extern struct cds
ASM TempCDS;

View File

@ -292,7 +292,7 @@ extern struct lowvec {
/* floppy parameter table, at 70:xxxx */
extern unsigned char DOSTEXTFAR ASM int1e_table[0xe];
extern char DOSFAR DiskTransferBuffer[SEC_SIZE]; /* in dsk.c */
extern char DOSFAR DiskTransferBuffer[/*MAX_SEC_SIZE*/]; /* in dsk.c */
struct RelocationTable {
UBYTE jmpFar;

View File

@ -29,7 +29,9 @@
#include "init-mod.h"
#include "dyndata.h"
UBYTE InitDiskTransferBuffer[SEC_SIZE] BSS_INIT({0});
#define FLOPPY_SEC_SIZE 512u /* common sector size */
UBYTE InitDiskTransferBuffer[MAX_SEC_SIZE] BSS_INIT({0});
COUNT nUnits BSS_INIT(0);
/*
@ -279,11 +281,11 @@ typedef struct {
floppy_bpb floppy_bpbs[5] = {
/* copied from Brian Reifsnyder's FORMAT, bpb.h */
{SEC_SIZE, 2, 1, 2, 112, 720, 0xfd, 2, 9, 2}, /* FD360 5.25 DS */
{SEC_SIZE, 1, 1, 2, 224, 2400, 0xf9, 7, 15, 2}, /* FD1200 5.25 HD */
{SEC_SIZE, 2, 1, 2, 112, 1440, 0xf9, 3, 9, 2}, /* FD720 3.5 LD */
{SEC_SIZE, 1, 1, 2, 224, 2880, 0xf0, 9, 18, 2}, /* FD1440 3.5 HD */
{SEC_SIZE, 2, 1, 2, 240, 5760, 0xf0, 9, 36, 2} /* FD2880 3.5 ED */
{FLOPPY_SEC_SIZE, 2, 1, 2, 112, 720, 0xfd, 2, 9, 2}, /* FD360 5.25 DS */
{FLOPPY_SEC_SIZE, 1, 1, 2, 224, 2400, 0xf9, 7, 15, 2}, /* FD1200 5.25 HD */
{FLOPPY_SEC_SIZE, 2, 1, 2, 112, 1440, 0xf9, 3, 9, 2}, /* FD720 3.5 LD */
{FLOPPY_SEC_SIZE, 1, 1, 2, 224, 2880, 0xf0, 9, 18, 2}, /* FD1440 3.5 HD */
{FLOPPY_SEC_SIZE, 2, 1, 2, 240, 5760, 0xf0, 9, 36, 2} /* FD2880 3.5 ED */
};
COUNT init_getdriveparm(UBYTE drive, bpb * pbpbarray)
@ -407,7 +409,7 @@ VOID CalculateFATData(ddt * pddt, ULONG NumSectors, UBYTE FileSystem)
fatdat = 32640;
/* The "+2*NSECTORFAT12" is for the reserved first two FAT entries */
defbpb->bpb_nfsect = (UWORD)cdiv((fatdat + 2 * NSECTORFAT12) * 3UL,
SEC_SIZE * 2 * NSECTORFAT12 + NFAT*3);
FLOPPY_SEC_SIZE * 2 * NSECTORFAT12 + NFAT*3);
#ifdef DEBUG
/* Need to calculate number of clusters, since the unused parts of the
* FATS and data area together could make up space for an additional,
@ -456,7 +458,7 @@ VOID CalculateFATData(ddt * pddt, ULONG NumSectors, UBYTE FileSystem)
defbpb->bpb_ndirent = 0;
defbpb->bpb_nreserved = 0x20;
fatdata = NumSectors - 0x20;
fatentpersec = SEC_SIZE/4;
fatentpersec = FLOPPY_SEC_SIZE/4;
maxcl = FAT32MAX;
}
else
@ -471,7 +473,7 @@ VOID CalculateFATData(ddt * pddt, ULONG NumSectors, UBYTE FileSystem)
max FAT16 size for FreeDOS = 4,293,984,256 bytes = 4GiB-983,040 */
if (fatdata > 8386688ul)
fatdata = 8386688ul;
fatentpersec = SEC_SIZE/2;
fatentpersec = FLOPPY_SEC_SIZE/2;
maxcl = FAT16MAX;
}
@ -571,7 +573,7 @@ void DosDefinePartition(struct DriveParamS *driveParam,
pddt->ddt_offset = StartSector;
pddt->ddt_defbpb.bpb_nbyte = SEC_SIZE;
pddt->ddt_defbpb.bpb_nbyte = FLOPPY_SEC_SIZE;
pddt->ddt_defbpb.bpb_mdesc = 0xf8;
pddt->ddt_defbpb.bpb_nheads = driveParam->chs.Head;
pddt->ddt_defbpb.bpb_nsecs = driveParam->chs.Sector;

View File

@ -301,8 +301,8 @@ _sfthead dd 0 ; 0004 System File Table head
_clock dd 0 ; 0008 CLOCK$ device
global _syscon
_syscon dw _con_dev,seg _con_dev ; 000c console device
global _maxbksize
_maxbksize dw 512 ; 0010 maximum bytes/sector of any block device
global _maxsecsize
_maxsecsize dw 4096 ; 0010 maximum bytes/sector of any block device
dd 0 ; 0012 pointer to buffers info structure
global _CDSp
_CDSp dd 0 ; 0016 Current Directory Structure