/* xpformat.c 1.2 86/01/21 */
/* format disk on Xylogics controller - fsd/smd/fujitsu type */
#include "../machine/mtpr.h"
#include "../tahoevba/vbaparam.h"
#include "../tahoevba/xpreg.h"
char disk
[10] ; /* disk type (smd/fsd/fuj) */
char drive
[10] ; /* drive number */
char buf
[512]; /* format data buffer */
struct xp_iopb
*iopb
= &iopbx
;
#define XY_SHORT(x) (short)((((x) >> 8) & 0xff) + (((x) << 8) & 0xff00))
#define POLLTILLDONE(x) { xytimeout = 1000*(x); \
while (xpaddr->xpcsr & XP_GBSY) { \
printf("XY timeout\n"); \
printf("Drive type [fsd/smd/fuj]: ");
printf("Drive number [0-3]: ");
if ((strcmp(disk
,"fsd") || strcmp(disk
,"smd") ||
strcmp(disk
,"fuj")) && ( j
<= 3))
if (xpstart(disk
,j
) == 0) {
printf("Initialization failed (drive not ready?), giving up!\n");
printf("Type <return> to start formatting ");
printf("Formatting completed. \n");
else if (j
>3) printf("Illegal drive number\n");
else printf("Illegal drive type\n");
while (*response
== ' ' || *response
== '\t') response
++;
while (*response
>= '0' && *response
<= '9') {
j
= j
*10 + *response
- '0';
* Check if a drive is really there. (NOP selects the drive and
xpmkiopb(XP_NOP
,unit
,0,0,0,0,0,0);
iopb
->io_comm
&= ~XP_IEN
; /* disable interrupts */
xpaddr
= (struct xpdevice
*)(xpstand
[0] + VBIOBASE
); /* formatting on cntl 0 */
ret
= xpaddr
->xpreset
; /* reset controller */
DELAY(400); /* wait 400 ns */
xpdgo(xpaddr
,iopb
); /* start the controller */
DELAY(200); /* wait 200 ns before checking CSR for completion */
uncache((char *)&iopb
->io_status
);
if ((XY_SHORT(iopb
->io_status
) != 5) || /* 5 = no errors, xy450, DONE */
!(xpaddr
->xpcsr
& XP_DRDY
) || /* drive is not ready */
(xpaddr
->xpcsr
& (XP_ERR
| XP_DERR
))) { /* errors? */
printf("XY start error. Status = %x, xpcsr= %x\n",
XY_SHORT(iopb
->io_status
),xpaddr
->xpcsr
);
* now set the drive size parameters in the controller
if (strcmp(disk
,"fsd")) {
xpmkiopb(XP_DSIZE
,unit
,9,822,31,0,0,0); /* 160M fsd */
if (strcmp(disk
,"smd")) {
xpmkiopb(XP_DSIZE
,unit
,18,822,31,0,0,0x40); /* 300M smd */
xpmkiopb(XP_DSIZE
,unit
,19,841,45,0,0,0x80); /* 474M Fujitsu */
iopb
->io_comm
&= ~XP_IEN
; /* disable interrupts */
uncache((char *)&iopb
->io_status
);
if ((XY_SHORT(iopb
->io_status
) != 5) || /* errors */
!(xpaddr
->xpcsr
& XP_DRDY
) ||
(xpaddr
->xpcsr
& (XP_ERR
| XP_DERR
)))
printf("XY set size error. status= %x, drive $d, type %s\n",
XY_SHORT(iopb
->io_status
),unit
,disk
);
xpaddr
= (struct xpdevice
*)(xpstand
[0] + VBIOBASE
); /* formatting on cntl 0 */
xpmkiopb(XP_FORMAT
,unit
,0,0,0,nsect
,0,dsktype
);
iopb
->io_comm
&= ~XP_IEN
; /* disable interrupts */
iopb
->io_scnt
= XY_SHORT(nsect
*ntrack
);
iopb
->io_cyl
= XY_SHORT(i
);
uncache((char *)&iopb
->io_status
);
if ((XY_SHORT(iopb
->io_status
) != 5) ||
(xpaddr
->xpcsr
& (XP_ERR
| XP_DERR
)) )
printf("XY format error %x, drive $d, type %s\n",
XY_SHORT(iopb
->io_status
),unit
,disk
);
while (*str1
++ && *str2
++ )
if (*str1
!= *str2
) return(0) ;
* Now all ready to go, stuff the registers.
register struct xpdevice
*xpaddr
;
register struct xp_iopb
*iopb
;
movob(&xpaddr
->xpmrel
, (u_char
)((int)iopb
>> 24));
movob(&xpaddr
->xplrel
, (u_char
)((int)iopb
>> 16));
movob(&xpaddr
->xpmba
, (u_char
)((int)iopb
>> 8));
movob(&xpaddr
->xplba
, (u_char
)((int)iopb
));
movob(&xpaddr
->xpcsr
, XP_GBSY
) ;
* Fill the iopb with the appropriate data.
xpmkiopb(cmd
,unit
,head
,cylinder
,sector
,scount
,baddr
,xptype
)
unsigned int cmd
, unit
, head
, cylinder
, sector
, scount
, xptype
;
iopb
->io_comm
= cmd
| XP_RELO
;
iopb
->io_imode
= XPM_ASR
| XPM_EEF
| XPM_ECC
;
iopb
->io_throt
= XPT_T128
;
iopb
->io_drive
= xptype
| unit
;
iopb
->io_cyl
= XY_SHORT(cylinder
);
iopb
->io_scnt
= XY_SHORT(scount
);
iopb
->io_mladdr
= XY_SHORT((int)baddr
& 0xffff);
iopb
->io_mhaddr
= XY_SHORT(((int)baddr
>> 16) & 0xffff);