Skip to content

Commit

Permalink
80busfdc: add more formats
Browse files Browse the repository at this point in the history
  • Loading branch information
EtchedPixels committed Mar 8, 2024
1 parent c7984db commit aecf54b
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 10 deletions.
67 changes: 57 additions & 10 deletions Kernel/dev/80bus/devfdc.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,20 @@
* SD/DD, DD/HD switch, 5.25" HD speed control, 8 drives, SASI
* MAP80
* As GM809 ?
*
* Disk formats
* At the moment the driver is set up to favour PC style formats. NASCOM
* systems used a truely wild array of media types. For the moment we
* support (subject to controller limit and CPU speed)
* - PC 360K, 720K, 1.2MB, 1.44MB
* - NASCOM PolyDOS
*
* There were a lot of other formats and some probably need adding
* 35x18x128 QDOS, PolyDOS 1, DCS-DOS, Henelec (DSSD)
* 35x10x512 CP/M 1.4/2.2 on Henelec/GM805 (DSDD), Gemini CP/M 2.2
* POLYDOS 2
* 77x16x256 Lucas NASDOS/DCS-DOS II (DSDD)
* 77x10x512 , CPM 2.2, PolyDOS 3 (DSDD)
*/

#include <kernel.h>
Expand Down Expand Up @@ -47,15 +61,15 @@ static uint16_t wrcmd;
static struct fdcinfo fdcap = {
0,
0,
FDC_SEC0,
FDC_SEC0|FDC_DSTEP,
FDF_DD | FDF_DS | FDF_SEC128 | FDF_SEC256 | FDF_SEC512,
18,
40,
2, /* Actually most are single sided */
0 /* Precomp */
};

#define NUM_MODES 6
#define NUM_MODES 9
static struct fdcinfo fdcmodes[NUM_MODES] = {
{
0,
Expand Down Expand Up @@ -94,17 +108,43 @@ static struct fdcinfo fdcmodes[NUM_MODES] = {
FDTYPE_NASDSSD, /* Nascom 35 track DSSD */
FDF_SD | FDF_SEC128,
10,
40,
35,
2,
0 },
{
5,
FDTYPE_NASDSDD,
FDF_SD | FDF_SEC128,
FDTYPE_NASDSDD, /* Double density variant - 18 x 128 */
FDF_DD | FDF_SEC128,
18,
35,
2,
0 },
{
6,
FDTYPE_NASPDOS2, /* PolyDOS 40 track, like PC but 10spt */
FDF_DD | FDF_SEC512,
10,
40,
2,
0 }
0 },
{
7,
FDTYPE_NASPDOS3, /* PolyDOS 77/80 track, like PC but 10spt */
FDF_DD | FDF_SEC512,
10,
80,
2,
0 },
{
8,
FDTYPE_NASDOS,
FDF_DD | FDF_SEC256,
16,
77,
256,
2,
0
}
};


Expand Down Expand Up @@ -202,6 +242,7 @@ static int fdc80_transfer(uint_fast8_t minor, bool is_read, uint_fast8_t rawflag
uint8_t sv;
uint8_t side;
uint8_t err;
unsigned config = fdc->mode->config;

/* No floppy swap */
if (rawflag == 2)
Expand All @@ -222,6 +263,8 @@ static int fdc80_transfer(uint_fast8_t minor, bool is_read, uint_fast8_t rawflag
/* TODO: skew fdc->skew[] */
sector = udata.u_block % fdc->spt;
track = udata.u_block / fdc->spt;
if (config & FDC_DSTEP)
track += track;
if (sector >= fdc->ds) {
sector -= fdc->ds;
side = 1;
Expand All @@ -239,7 +282,10 @@ static int fdc80_transfer(uint_fast8_t minor, bool is_read, uint_fast8_t rawflag
}
}
/* Set up the sector register, hardcode base 1 for now */
out(0xE2, sector + 1);
if (config & FDC_SEC0)
out(0xE2, sector);
else
out(0xE2, sector + 1);
fdc80_dptr = (uint16_t) udata.u_dptr;
/* The timing on these is too tight to do with interrupts on */
plt_disable_nmi();
Expand Down Expand Up @@ -305,9 +351,10 @@ static void fdc80_setup(struct fdc *fdc)
break;
/* No 1K or higher support */
}
if (feat & FDF_DS)
fdc->ds = fdc->spt / 2;
else
if (feat & FDF_DS) {
fdc->ds = fdc->spt;
fdc->spt *= 2;
} else
fdc->ds = 255;
if (feat & FDF_8INCH)
den += 3;
Expand Down
4 changes: 4 additions & 0 deletions Kernel/include/fdc.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ struct fdcstep {
#define FDTYPE_UBEEDS84 0x53 /* Physically the same */
#define FDTYPE_PC800 0x53 /* PC style 800K */
#define FDTYPE_SAMCOUPE 0x53 /* Another user of the same format */
#define FDTYPE_PC400 0x51 /* PC style 400K */

/* NASCOM PolyDOS. Much like the BBC but 18spt not 16 for MFM. To
confuse further Nascom CP/M used 512x10x77 */
Expand All @@ -127,6 +128,9 @@ struct fdcstep {
#define FDTYPE_NASSS80 0x62 /* Nascom SSDD 80 track, 18spt */
#define FDTYPE_NASCPMS 0x63 /* 512bps/10spt/77 track SS DD */
#define FDTYPE_NASCPMD 0x64 /* 512bps/10spt/77 track SS DD */
#define FDTYPE_NASPDOS2 FDTYPE_PC400 /* PolyDOS 2 */
#define FDTYPE_NASPDOS3 FDTYPE_PC800 /* PolyDOS 3 (77 track though) */
#define FDTYPE_NASDOS FDTYPE_8DSDD

/* Geneve - mostly match other people's configurations as an alias */
#define FDTYPE_GENSD40 0x70 /* 40 track 9 sectors per track */
Expand Down

0 comments on commit aecf54b

Please sign in to comment.