English Amiga Board


Go Back   English Amiga Board > Support > support.WinUAE

 
 
Thread Tools
Old 31 December 2012, 16:15   #1
Toni Wilen
WinUAE developer
 
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 49
Posts: 26,505
wd33c93 emulation debugging

[Moved from MMU thread]

Quote:
Originally Posted by mark_k View Post
Could the files /usr/sys/amiga/alien/a2091.c and /usr/sys/amiga/alien/a3091.c in the AMIX kernel configuration package (conf.cpio) be of any help there?
Interesting source stuff..

Anyway, problem is SCSI phase numbers. I haven't found documentation that describes exactly how scsi phases work, most of the stuff in emulation is guesses only.

This driver apparently checks SCSI phase value returned by SCSI chip and simply hangs if value is not any of expected values. (I guess this also explains guru rom problem, some phase value is wrong)

Quote:
I'll try testing the MMULib tools when booting from a clean floppy disk and report back.
Hopefully it is a real emulation bug and not some buggy software

Last edited by Toni Wilen; 01 January 2013 at 17:32. Reason: Moved from MMU thread
Toni Wilen is offline  
Old 31 December 2012, 17:06   #2
alexh
Thalion Webshrine
 
alexh's Avatar
 
Join Date: Jan 2004
Location: Oxford
Posts: 14,337
The only SCSI book I have has a very small section which you've probably already seen :

Quote:
SCSI COMMAND PHASES
Individual commands execute in subsequent parts called phases. Some phases are set by the Initiator, some by the Target. Following is a list of all 8 SCSI command phases:
  1. arbitration
  2. selection
  3. message
  4. reselection
  5. command
  6. data
  7. status
  8. bus free
The SCSI specification allows execution of command phases in any order, with the exception that each command must start with arbitration and selection. In practice however, we will see SCSI commands executing in phases as though in a certain predefined sequence. Some phases are missing in some commands, but the general sequence is always the same; it is usually:
  1. arbitration
  2. selection (with Attention)
  3. message out
  4. command data in/out
  5. status
  6. message in
This is a link to the SCSI Phase section of the SCSI-II specification with diagrams

http://www.staff.uni-mainz.de/tacke/scsi/SCSI2-06.html

I appreciate that this information is widely available and what you're probably after is how the WD chip actually works.
alexh is offline  
Old 31 December 2012, 18:13   #3
Toni Wilen
WinUAE developer
 
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 49
Posts: 26,505
Quote:
Originally Posted by alexh View Post
The only SCSI book I have has a very small section which you've probably already seen :
I have seen similar documents but they never show any real world examples.
Toni Wilen is offline  
Old 31 December 2012, 21:43   #4
Toni Wilen
WinUAE developer
 
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 49
Posts: 26,505
WD SCSI chip documentation seems to miss some information..

It says about "Select and Transfer" command that command phase 0x60 = Command completed but other SCSI phase document says (for example http://challenge.nvg.ntnu.no/sgistuf...csi-errors.txt)

Quote:
ST_SATOK 0x16 Select-And-Transfer completed successfully
that is, all phases have completed in a
normal manner
but it also says

Quote:
PH_COMPLETE 0x60 Command complete message received;
SCSI command is finished, and SCSI bus
is free.
Amix driver expects 0x16, not 0x60. Could someone explain the difference? WD documentation does not even mention phase code 0x16..
Toni Wilen is offline  
Old 31 December 2012, 22:23   #5
mark_k
Registered User
 
Join Date: Aug 2004
Location:
Posts: 3,335
I assume you have the 66-page WD33C93 datasheet (PDF available from http://www.datasheetcatalog.org/data.../501413_DS.pdf)?

From that, the PH_xxx values are what appear in the command phase register (address 10 hex). The ST_xxx values are put in the SCSI status register (address 17 hex). That's from pages 17-18 of the PDF.

There's also a WD33C93B data sheet (better quality than the other one) at http://bitsavers.informatik.uni-stut...3_WD33C93B.pdf
And WD33C93A: http://bitsavers.informatik.uni-stut...oller_1991.pdf

Last edited by mark_k; 31 December 2012 at 22:46.
mark_k is online now  
Old 31 December 2012, 23:39   #6
Toni Wilen
WinUAE developer
 
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 49
Posts: 26,505
Quote:
From that, the PH_xxx values are what appear in the command phase register (address 10 hex). The ST_xxx values are put in the SCSI status register (address 17 hex).
That explains the problem perfectly

After some tweaks (+implemented SCSI statefile support) I got slightly farther..
Attached Thumbnails
Click image for larger version

Name:	amix2.png
Views:	372
Size:	15.3 KB
ID:	33671  
Toni Wilen is offline  
Old 01 January 2013, 11:38   #7
Toni Wilen
WinUAE developer
 
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 49
Posts: 26,505
Documentation says: "After the Command phase, the 33C93B anticipates a Data phase if the TRANSFER COUNT register contains a non-zero value, a Status phase if this register contains zero,"

This actually means Select-and-Transfer command jumps directly to Status phase if TRANSFER COUNT = 0, skipping whole Command phase!

This is what A590 driver assumes. Funnily enough it seems A590 driver developer did it wrong but got lucky, code sets phase to $46 (which does nothing because Select-and-Transfer only writes to phase register, it does not care what it contains at the start of command) and code also does not clear transfer count (It was cleared by previous transfer).

This A590 (now weird looking) driver behavior really confused me because I of course assumed setting phase to $46 must mean something. It does absolutely nothing with Select-and-Transfer... TC == 0 was the important information.

Amix now detects partitions but partitioning fails with bus errors (and unfortunately they are real bus errors, some pointer has become null)

Whats the original A3000UX HD size? Perhaps it hates too small or too big drives?
Toni Wilen is offline  
Old 01 January 2013, 19:01   #8
alexh
Thalion Webshrine
 
alexh's Avatar
 
Join Date: Jan 2004
Location: Oxford
Posts: 14,337
Quote:
Originally Posted by Toni Wilen View Post
Whats the original A3000UX HD size? Perhaps it hates too small or too big drives?
200MBytes
alexh is offline  
Old 02 January 2013, 00:40   #9
dlfrsilver
CaptainM68K-SPS France
 
dlfrsilver's Avatar
 
Join Date: Dec 2004
Location: Melun nearby Paris/France
Age: 46
Posts: 10,412
Send a message via MSN to dlfrsilver
the w33c93 is used on the capcom CPS-3 system. maybe there is info in the mame driver about this device ?
dlfrsilver is offline  
Old 02 January 2013, 14:05   #10
Toni Wilen
WinUAE developer
 
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 49
Posts: 26,505
It seems only A590/A2091 and Guru ROM drivers do something weird with WD33C93.

All other drivers seem to use standard Select-and-Transfer command that does everything (select the drive, send command, send/receive data, disconnect) automatically.

Weird drivers seem to do part of the SCSI protocol using lower level SCSI commands and then some other part(s) with high level commands (like Select-and-Transfer with zero transfer count).

btw, I was wrong, Select-and-Transfer ignores scsi phase only if it started with non-zero transfer count. If transfer count = 0, it will check scsi phase number and jump to specific processing phase depending on scsi phase number. This is not fully documented in WD33C93 documentation.

EDIT: I was even more wrong, scsi phase number is only ignored (starts from beginning) if unit is not currently selected. If already selected = continue from current scsi phase.

Last edited by Toni Wilen; 08 January 2013 at 14:02.
Toni Wilen is offline  
Old 02 January 2013, 22:12   #11
mark_k
Registered User
 
Join Date: Aug 2004
Location:
Posts: 3,335
What with the new MMU support and improved A2091 emulation, I thought I'd try installing NetBSD 6.0.1 (using the 2013-01-02 winuae.exe).

I partitioned a hardfile and copied the miniroot.fs to it. On booting from that NetBSD repeatedly reports:
sbicwait TIMEO @1570 with asr=x0 csr=x1f

See attached pic. WinUAE config and hardfile attached too.
Attached Thumbnails
Click image for larger version

Name:	NetBSD_install_boot.png
Views:	318
Size:	14.2 KB
ID:	33709  
Attached Files
File Type: uae NetBSD_install.uae (13.0 KB, 166 views)
File Type: 7z NetBSD_4GB_HD.bin.tar.7z (1.77 MB, 172 views)
mark_k is online now  
Old 04 January 2013, 17:01   #12
Toni Wilen
WinUAE developer
 
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 49
Posts: 26,505
Quote:
Originally Posted by mark_k View Post
What with the new MMU support and improved A2091 emulation, I thought I'd try installing NetBSD 6.0.1 (using the 2013-01-02 winuae.exe).
Timeout fixed but now it does something really weird.

Does it really work with real hardware? It tries to send SCSI command to the drive with WD DMA mode but without programming DMAC for DMA operation. Normally commands are always send in PIO because DMA only makes sense with larger transfers.

EDIT: Wait a moment, perhaps it enables DMA after starting the command..

EDIT2: No, it does not still make any sense. It still uses CPU writes while WD is in DMA mode.. This can't be right.

Last edited by Toni Wilen; 04 January 2013 at 17:43.
Toni Wilen is offline  
Old 04 January 2013, 18:07   #13
mark_k
Registered User
 
Join Date: Aug 2004
Location:
Posts: 3,335
I haven't tested it on real hardware, but would assume it does work.

You can browse the source at http://cvsweb.netbsd.org/bsdweb.cgi/..._with_tag=MAIN. Scroll down and click wd33c93.c then click Download. Maybe that could help figure what the NetBSD devs are trying to do?

Edit: A better browse interface (e.g. with links to function definitions) would be here: http://fxr.watson.org/fxr/source/dev...v=NETBSD;im=10.

Last edited by mark_k; 04 January 2013 at 18:26.
mark_k is online now  
Old 04 January 2013, 18:28   #14
Toni Wilen
WinUAE developer
 
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 49
Posts: 26,505
Yes but as usual it isn't that simple and assumptions are bad idea. There is also similar looking driver under amiga (arch/amiga/dev/sbic.c)...
Toni Wilen is offline  
Old 04 January 2013, 18:49   #15
mark_k
Registered User
 
Join Date: Aug 2004
Location:
Posts: 3,335
Yes on second thoughts (bearing in mind the "atzsc0" text in the screenshot), probably these files are relevant:
arch/amiga/dev/atzsc.c
arch/amiga/dev/atzscreg.h
arch/amiga/dev/sbic.c
arch/amiga/dev/sbicreg.h
arch/amiga/dev/sbicvar.h

Last edited by mark_k; 04 January 2013 at 20:39. Reason: Fixed links!
mark_k is online now  
Old 04 January 2013, 20:29   #16
Toni Wilen
WinUAE developer
 
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 49
Posts: 26,505
All your links point to same file

I don't see anything obvious but perhaps it gets confused because not all scsi messages are generated during processing (like save pointers). I am still not familiar enough with SCSI stuff. It is soooo complex. (Guru ROM also seems to require this stuff)
Toni Wilen is offline  
Old 04 January 2013, 21:33   #17
jbenam
Italian Amiga Zealot
 
Join Date: Jan 2009
Location: Italy
Age: 36
Posts: 1,910
Strim (member here on EAB) is the one who handles the NetBSD Amiga port, so if you've got any questions, Toni, he should be your man
jbenam is offline  
Old 05 January 2013, 14:11   #18
strim
NetBSD developer
 
Join Date: May 2012
Location: Warsaw, Poland
Posts: 411
Hi guys.

I can't really comment on the problem you are seeing here. I don't know if A2091 driver still works, however I'm sure that A3000 driver does - I've tested it few months ago and I know of many users that installed 6.x on their A3000s. Both A2091 (atzsc) and A3000 (ahsc) use Amiga-specific 33C93 driver (sbic - SCSI phases are handled there). Differences between atzsc and ahsc are small, so I would expect that atzsc still works on a real hardware.

I have to admit, that I don't really understand how this driver works . It doesn't use any modern kernel abstraction layers. It was written almost 20 years ago and didn't change much in last 10 years. Perhaps, there are old time developers still lurking on port-amiga .at. netbsd.org list. Asking there might be useful.

I can prepare NetBSD kernel with DEBUG enabled for sbic driver if that helps.

Btw. I also remember that Michael van Elst (of bustest fame) has his own UAE version for NetBSD testing (source). AFAIR it doesn't support SCSI, but might be interesting because of MMU and VNC code.

Last edited by strim; 05 January 2013 at 14:46.
strim is offline  
Old 05 January 2013, 14:28   #19
mark_k
Registered User
 
Join Date: Aug 2004
Location:
Posts: 3,335
Testing with the 2013-01-04 18:50 winuae.exe, output for A2091 and A3000 emulation is similar. The output with emulated A2091 has an additional "sbic_save_ptrs: asr 21 canceled!" line. WinUAE A3000 config file attached.
Attached Thumbnails
Click image for larger version

Name:	A2091_WinUAE_2013-01-04_1850.png
Views:	249
Size:	13.2 KB
ID:	33753   Click image for larger version

Name:	A3000_WinUAE_2013-01-04_1850.png
Views:	223
Size:	12.5 KB
ID:	33754  
Attached Files
File Type: uae NetBSD_install_A3000.uae (13.1 KB, 134 views)
mark_k is online now  
Old 05 January 2013, 14:48   #20
Toni Wilen
WinUAE developer
 
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 49
Posts: 26,505
Quote:
Originally Posted by strim View Post
I can prepare NetBSD kernel with DEBUG enabled for sbic driver if that helps.
That would be great.

ADDED: Log from working A3000 boot phase would be nice too for comparison purposes. (I'll try to do one, different drives may use different scsi features)

Quote:
Btw. I also remember that Michael van Elst (of bustest fame) has his own UAE version for NetBSD testing (source). AFAIR it doesn't support SCSI, but might be interesting because of MMU and VNC code.
AFAIK that wasn't using real MMU emulation. NetBSD most likely works fine when using IDE emulation but we are trying to improve SCSI emulation

Last edited by Toni Wilen; 05 January 2013 at 18:07.
Toni Wilen is offline  
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Similar Threads
Thread Thread Starter Forum Replies Last Post
Debugging my dodgy asm! hypnoshock Coders. Asm / Hardware 5 01 May 2012 01:55
Debugging and JIT issues copse support.WinUAE 4 01 April 2012 05:50
Serial debugging while booting jman Coders. General 1 25 March 2012 03:02
Help debugging a faulty CD32 UberFreak support.Hardware 0 23 October 2009 03:29
Enforcer debugging tool M&F support.WinUAE 0 21 May 2002 22:53

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 15:47.

Top

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Page generated in 0.20950 seconds with 14 queries