reifsnyderb Posted May 31 Share Posted May 31 (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 May 31 by reifsnyderb Quote Link to comment Share on other sites More sharing options...
_The Doctor__ Posted May 31 Share Posted May 31 (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 May 31 by _The Doctor__ Quote Link to comment Share on other sites More sharing options...
reifsnyderb Posted May 31 Author Share Posted May 31 (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 May 31 by reifsnyderb Quote Link to comment Share on other sites More sharing options...
_The Doctor__ Posted May 31 Share Posted May 31 It depends on the drive and possibly density. See above, it's different for an XF etc. so don't use a default follow procedure. Check out jindroush notes also. Quote Link to comment Share on other sites More sharing options...
reifsnyderb Posted May 31 Author Share Posted May 31 It's a 1050. I didn't want to add the extra code to get the status....at least yet. At this time, I don't want to take up the extra space. So, I put the default timeout in place. Quote Link to comment Share on other sites More sharing options...
_The Doctor__ Posted May 31 Share Posted May 31 (edited) might be something to double check from here... give it a skim Edited May 31 by _The Doctor__ Quote Link to comment Share on other sites More sharing options...
Rybags Posted May 31 Share Posted May 31 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) Quote Link to comment Share on other sites More sharing options...
reifsnyderb Posted May 31 Author Share Posted May 31 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? Quote Link to comment Share on other sites More sharing options...
_The Doctor__ Posted May 31 Share Posted May 31 ummm that would be a part of it. Quote Link to comment Share on other sites More sharing options...
Rybags Posted May 31 Share Posted May 31 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. 1 Quote Link to comment Share on other sites More sharing options...
reifsnyderb Posted May 31 Author Share Posted May 31 Got it working. See CP/M thread: https://forums.atariage.com/topic/362513-cpmz-80-card-for-the-1090xl-calling-anyone-with-z-80-experience/ Thanks! 2 Quote Link to comment Share on other sites More sharing options...
_The Doctor__ Posted May 31 Share Posted May 31 anytime Quote Link to comment Share on other sites More sharing options...
reifsnyderb Posted June 20 Author Share Posted June 20 (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 June 20 by reifsnyderb 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.