Jump to content
IGNORED

Formatting a disk via SIOV


Recommended Posts

Posted (edited)

I've got a program, I am working on, that is sending the format command to the disk drive using SIOV.  After the drive starts formatting, should SIO wait until the drive is finished it's SIO format command before turning control back to the calling program?

 

I am asking because it's not waiting until the drive is finished before returning to the program that called it.

 

Thanks!

 

Brian

 

Edited by reifsnyderb
Link to comment
Share on other sites

Posted (edited)

Does the format timeout interval get returned from the drive when the command is sent ? Getting that status, I think it comes from the drive and then when you check status and if it exceeds the timeout period, the program should then report the failure.

 

3rd byte in the 0x53 get status command changes to 0xe0 for 1050 or rather 0xfe and for XF551 0xfe-That byte defines the timeout that should be used for the format command.

 

so query the status of the drive, verify it's correct

Edited by _The Doctor__
Link to comment
Share on other sites

Posted (edited)
15 minutes ago, _The Doctor__ said:

Does the format timeout interval get returned from the drive when the command is sent ? Getting that status, I think it comes from the drive and then when you check status and if it exceeds the timeout period, the program should then report the failure.

Well, I set the timeout to $E0 as follows:

 

    LDA        #$E0                ; Set timeout to seconds
    STA        DTIMLO

 

While I didn't bother to query the drive and ask, available documentation says this is the default returned by the drive.

 

 

 

Edited by reifsnyderb
Link to comment
Share on other sites

It's been a while... but the Format command should return a 128 byte record containing a list of bad sectors.

Done so in the same manner as if you'd issued a read sector command - as stated the longer timeout value is needed.

Bad sectors beyond a total of 64 aren't returned.

Not sure if this is the case for all disk types (256 byte sectors, dbl sided etc)

Link to comment
Share on other sites

1 minute ago, Rybags said:

It's been a while... but the Format command should return a 128 byte record containing a list of bad sectors.

Done so in the same manner as if you'd issued a read sector command - as stated the longer timeout value is needed.

Bad sectors beyond a total of 64 aren't returned.

Not sure if this is the case for all disk types (256 byte sectors, dbl sided etc)

I was just looking at the link @_The Doctor__ posted.  It appears format is a read command?  I have it configured as a write command.  Maybe this is the problem?

 

Link to comment
Share on other sites

Yes - the command type as such helps with scheduling of handshaking and such which has differences among operations - it's graphically illustrated around page 150 in the Technical Reference Notes.

  • Like 1
Link to comment
Share on other sites

  • 3 weeks later...
Posted (edited)

Since it may be helpful to somebody in the future, here's the code I used to read/write/and format disks via SIOV:

 

 

Equates:

 

;	Resident Disk Handler and SIO Command Equates
FOMAT				EQU		'!'								;format command
FOMATE				EQU		$22							;format enhance density command
PUTSEC				EQU		'P'							;put sector command
READ				EQU		'R'							;read command
STATC				EQU		'S'							;status command
WRITE				EQU		'W'							;write command


;**	IOCB Command Code Equates
OPEN			EQU	$03		;open
GETREC			EQU	$05		;get record
GETCHR			EQU	$07		;get character(s)
PUTREC			EQU	$09		;put record
PUTCHR			EQU	$0B	;put character(s)
CLOSE			EQU	$0C	;close
STATIS			EQU	$0D	;status
SPECIL			EQU	$0E	;special


;**	SIO Operations
NODAT			EQU	$00	;SIO immediate operation
GETDAT			EQU	$40	;SIO read data frame
PUTDAT			EQU	$80	;SIO write data frame

 

 

Code:

 

;	--------------------------------------------------------------------
;	WRITE SECTOR
;	--------------------------------------------------------------------
SR16:

	LDA		#WRITE			; Set command to write a sector.
	STA		DCOMND

	LDA		#$07			; Set timeout to 7 seconds
	STA		DTIMLO

	LDA		#PUTDAT			; Select PUT DATA
	STA		DSTATS

	BNE		SR15B			; Continue


;	--------------------------------------------------------------------
;	FORMAT DISK
;	--------------------------------------------------------------------
SR19:

	LDA		#FOMATE			; Set command to format disk.
	STA		DCOMND

	LDA		#$E0			; Set timeout to seconds
	STA		DTIMLO

	BNE		SR15A			; Continue


;	--------------------------------------------------------------------
;	READ SECTOR
;	--------------------------------------------------------------------
;	Note:  Read sector inserted here so as to remove 
;	the extra code during reads.  The assumption is 
;	that there are more reads than writes.


;DCB
;DDEVIC			EQU		$0300	; Serial Bus I.D.
;DUNIT			EQU		$0301	; Device number
;DCOMND			EQU		$0302	; Command byte
;DSTATS			EQU		$0303	; Status byte
;DBUFLO			EQU		$0304	; Low buffer address
;DBUFHI			EQU		$0305	; High buffer address
;DTIMLO			EQU		$0306	; Disk timeout
;DBYTLO			EQU		$0308	; Low byte count
;DBYTHI			EQU		$0309	; High byte count
;DAUX1				EQU		$030A	; Aux #1
;DAUX2				EQU		$030B	; Aux #2


SR15:

	LDA		#READ			; Set command to read a sector.
	STA		DCOMND

	LDA		#$07			; Set timeout to 7 seconds
	STA		DTIMLO

SR15A
	LDA		#GETDAT			; Select GET DATA
	STA		DSTATS

SR15B:
	LDA		#$31			; Set SIO device as disk drive
	STA		DDEVIC

	LDX		IODISK			; Store the disk drive number in DCB
	INX						; Increment as CP/M disk drive is zero based
	STX		DUNIT			

	LDA		#low SBUFF		; Set the sector buffer address
	STA		DBUFLO
	LDA		#high SBUFF
	STA		DBUFHI

	LDA		#$80			; Set disk sector size
	STA		DBYTLO
	LDA		#$00
	STA		DBYTHI

	JSR		GTSCTR			; Get and calculate the sector number.  It will be in DCB DAUX1 & DAUX2
	
	LDA		#$00			; Set cassette mode flag for standard SIO operation
	STA		CASFLG
	
	JSR	SIOV
	
	LDX	DSTATS				; Get status

	CPX	#$01				; Is status = #$01?
	BNE	SR15F				; No, an error was returned, return error

	DEX						; Set status to #$00 as #$00 is successful for CP/M
SR15F:
	STX	IOSTAT				; Store the status for CP/M
	JMP	Z80RET				; Restart the Z-80

 

GTSCTR calculates the Atari sector number from a Track/Sector combination provided by CP/M.  The conversion code is as follows:

 

;	--------------------------------------------------------------------
;	GET DISK SECTOR
;	--------------------------------------------------------------------
;	GTSCTR
;	Gets disk sector by converting track/sector to sector
;	Uses IOTRCK and IOSECT
;	Resulting sector number is in DAUX1/DAUX2
;	sector = (track * 26) + sector
;	sector = (track * 16) + (track * 8) + (track * 2) + sector
;	sector = (ASL track(4*)) + (ASL track(3*)) + (ASL track(1*)) + sector
GTSCTR:
	LDA		#$00
	STA		TRACKH+1
	STA		TRACKM+1
	STA		TRACKL+1
	LDA		IOTRCK
	STA		TRACKH
	STA		TRACKM
	STA		TRACKL

	ASL		TRACKH			; Multiply track by 16
	ROL		TRACKH+1
	ASL		TRACKH
	ROL		TRACKH+1
	ASL		TRACKH
	ROL		TRACKH+1
	ASL		TRACKH
	ROL		TRACKH+1
	
	ASL		TRACKM			; Multiply track by 8
	ROL		TRACKM+1
	ASL		TRACKM
	ROL		TRACKM+1
	ASL		TRACKM
	ROL		TRACKM+1

	ASL		TRACKL			; Multiply track by 2
	ROL		TRACKL+1

	CLC						; Add all three multiply results and IOSECT
	LDA		TRACKH
	ADC		TRACKM
	STA		TRACKM
	LDA		TRACKH+1
	ADC		TRACKM+1
	STA		TRACKM+1
	
	CLC
	LDA		TRACKM
	ADC		TRACKL
	STA		TRACKL
	LDA		TRACKM+1
	ADC		TRACKL+1
	STA		TRACKL+1

	LDX		IOSECT			; CPM passes 0-based sector numbers
	INX						; So, increment it.

	CLC
	TXA						; Load A with IOSECT + 1
	ADC		TRACKL
	STA		DAUX1			; Low byte of sector number
	LDA		#$00
	ADC		TRACKL+1
	STA		DAUX2			; High byte of sector number
	
	RTS

 

 

 

 

 

 

Edited by reifsnyderb
  • Like 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...