Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Preserve Context and SWRAM #2

Open
SteveFosdick opened this issue Feb 10, 2018 · 17 comments
Open

Preserve Context and SWRAM #2

SteveFosdick opened this issue Feb 10, 2018 · 17 comments

Comments

@SteveFosdick
Copy link

See http://stardot.org.uk/forums/viewtopic.php?f=54&t=14511

If I load this into sideways RAM with PATCH_PRESERVE_CONTEXT=TRUE it never initialises its workspace and always crashes in response to service call 2 on startup.

@hoglet67
Copy link
Owner

hoglet67 commented Feb 11, 2018

That thread refers to a Model B with a 65C02.

So this is issue trying to run the 1.5x ADFS code on a Model B with OS 1.20, correct?

Did you make any code changes apart from the workspace?

I wonder if the cause of this hang is the lack of the Master's service calls, specifically:
&21-&27

From the Sprow document, the ordering of master service calls is:
&24; &21; &22; &01; &02; &23,

Lack of service Call &22 might be the problematic one here, because it sets the private workspace pointer:
https://github.com/hoglet67/ADFS/blob/master/src/adfs150.asm#L4530
which is then used by Service Call &02, which is the one that is breaking.

Service Call &02 is already trying to deal with hazel workspace being full, but that relies on Service Call &22 writing a value >= &DC to the workspace pointer.

Can you provide a link to the code in the SD Driver that only initialises on power up reset. I can't spot it at the moment. I though the SD Driver initialised lazily on first use.

Oh, and are you using my master branch, or Jonathan's fork, which are now quite divergent?

Dave

@SteveFosdick
Copy link
Author

SteveFosdick commented Feb 11, 2018

I have made other changes too - I hope I get everything as running a diff is not very useful at the moment - as the workspace change affects so many lines the output is not very useful.

So I added Service Call 1 in:

;; Low service call routines address-1 low bytes
;; ---------------------------------------------
.L9AAC EQUB <(L9AD5-1)                   ;; Serv0 - L9AD5 - Null
IF ABSWS = &0E00
       EQUB <(LOWABS-1)                  ;; Serv1 - L9AD5 - Low abs w/s
ELSE
       EQUB <(L9AD5-1)                   ;; Serv1 - L9AD5 - Null
ENDIF       
       EQUB <(L9AFF-1)                   ;; Serv2 - L9AFF - Low w/s

and

;;
;; Serv1 - Low absolute workspace claim
;;
.LOWABS CPY #&1C         ;; ADFS needs up to &CE00-1
        BCS labsok       ;; Exit if Y>&CE
        LDY #&1C         ;; ADFS needs up to &CE00-1
.labsok RTS

The I also changed service call 2:

;; Serv2 - Low workspace claim
;; ===========================
;; If insufficient workspace was available in high memory, ADFS claims
;; a page of workspace from low memory. ADFS also does some initialisation
;; on this call.
;;
.L9AFF TYA
;;       LDA &0DF0,X      ;; Get workspace pointer
;;       CMP #&DC         ;; Is it set to <&DC00?
;;       BCC L9B0A        ;; Use existing value if it is
;;       TYA
       STA &0DF0,X      ;; Use low workspace
.L9B0A PHY              ;; Save current pointer

so it no longer depends on call &22 having found the high workspace to be full.

That got me to the point where creating a virtual machine in B-Em with a 65C02 but no other Master features would allow the modified ROM to complete the initialisation, i,e, the BASIC prompt would appear but running on my real BBC B from sideways RAM it would hang in service call 2 in the bit that does the early initialisation, not the bit involved in the workspace claim.

I am still waiting for the parts for the FTDI-based bus snoop and I couldn't get into EXMON so to try working out what was going on I went for sticking in calls to a pair of subroutines that printed begin/end and places these around successilve sub-routines but beyond that I can't remember exacty what I did. I do remember I discovered the test for the type of break as part of the initialisation and how this is altered by the conditional compilation PRESERVE_CONTEXT so I tried turning off PRESERVE_CONTEXT and re-building. This resulted in a ROM that no longer hung in service call 2 on the real BBC B but got as far as the BASIC prompt.

That is what lead to the conclusion that this was connected with when initialisation happens because when I was running in B-Em, B-Em was loading the image, i.e. it is as if it were in ROM, whereas on the real BBC I am loading it via MMFS into sideways RAM.

SInce then I have made a couple of other discoveries:

  1. It is necessary to disable the code that writes to FE34 to manipulate the shadow screen. It looks like on the B this is not fully decoded and writes to the normal ROM select latch paging out the ADFS ROM and paging in BASIC instead.
  2. The partition on the SD card needs the IDE bodge of spacing the real data out into only even numbered bytes.

That got me to the point where it would list an empty directory.

@SteveFosdick
Copy link
Author

SteveFosdick commented Feb 11, 2018

I forgot to say, my starting point was your master here in GitHub.

When I mentioned this being SD-card specific I was referring to this bit of code:

;;
;; Set SCSI to command mode
;; ------------------------
IF PATCH_SD
.L807E RTS
.ReadBreak
       JSR L9A88
       AND #&01
       RTS
.MountCheck

(https://github.com/hoglet67/ADFS/blob/master/src/adfs150.asm#L4530)

@hoglet67
Copy link
Owner

I have made other changes too - I hope I get everything as running a diff is not very useful at the moment - as the workspace change affects so many lines the output is not very useful.

Would it be possible to stage this as two commits:

  • the first commit would be the workspace change
  • the second commit would be everything else

Then it becomes clearer what the everything else is...

(I'm also quite keen to see a version of 1.5x ADFS that will run on a Model B)

@SteveFosdick
Copy link
Author

Ok, I am working on doing that.

@SteveFosdick
Copy link
Author

SteveFosdick commented Feb 12, 2018

I have pushed what I have so far to https://github.com/SteveFosdick/ADFS

This is working a bit better now - I have managed to save and load a basic program from the root directory and create a sub-directory. Attempting to delete anything crashes through and it gives broken directory if you try to write to the sub-directory. I suspect this is just a case of a few more references to the static workspace hiding somewhere. I found a few where a pair of values were being loaded to adjacent memory location and was &CX but there are some where it would need a much closer look to see what is happening with the values to see if this is a workspace reference of something else.

@hoglet67
Copy link
Owner

This looks great, thanks for splitting it up like this. I'll have a look this afternoon and see if I can reproduce the current issues, and spot anything wrong.

One think it might be worth doing (probably with ICE T65) is set a memory watch break point to look for any remaining data read/writes to the old workspace area.

@SteveFosdick
Copy link
Author

Ok, I don't have an ICE but I suspect the remaining workspace references are in the core ADFS code, not in anything SD card specific so I added a low-workspace SCSI build to the set. I have been running in B-Em which is now modified to trap on access to the old workspace if the accessing code is in the sideways ROM area and it is indeed finding accesses.

I have solved one so far which was embedded in a template SCSI command block. I have pushed that fix and the extra low SCSI config to my repo as above.

@SteveFosdick
Copy link
Author

The latest commit does now seem to working, at least in B-Em without provoking the new trap. I can load/save files, create and delete sub-directories etc., delete files. I'll try the SD version on the real machine too.

@SteveFosdick
Copy link
Author

SteveFosdick commented Feb 12, 2018

SD card version also works on the real BBC B. Passed OSFILE and OSGBPB tests. Created a sub-dir of a sub-dir OK. Willl try some more of the less commonly used bits later on.

@hoglet67
Copy link
Owner

I was going to give it a try with the 32016 Co Pro and see if I could get Panos to boot.

@SteveFosdick
Copy link
Author

That would be good. I have no way of testing the tube access bit on real hardware and I haven't tested that in B-Em either so that would be a worthwhile test.

@hoglet67
Copy link
Owner

Panos boots and successfully runs my standard quick test, which is to compile, link and the run the C Hello World program, which is good.

DosPlus doesn't boot. In fact, it fails very quickly with Bad Command. After some debugging (with the FX2 Logic Analyzer), it seems the command in question is *CLOSE.

In ADFS 1.3x, *CLOSE is part of ADFS.

In ADFS 1.5x, *CLOSE is provided by the Master MOS, so isn't included in ADFS.

Comparing *HELP, the list of commands missing from ADFS 1.5x are:

  • *CLOSE
  • *DELETE
  • *EX
  • *INFO
  • *RENAME

The implementation should be present in ADFS 1.5x, it's just the command that is missing:

  • *CLOSE (OSFIND A=00 Y=00)
  • *DELETE (OSFILE A=06)
  • *EX (FSCV A=09)
  • *INFO (FSCV A=0A)
  • *RENAME (FSCV A=0C)

So it seems like we need to add these to the command table.

Seems there is space, as the floppy drivers were dropped.

Building BBCB...
code ends at &BCFD ( 771 bytes free )
mdsum is 1b3d3ea49d04d7baec0681d8261ccf7d -

@hoglet67
Copy link
Owner

hoglet67 commented Feb 12, 2018

I quickly added a *CLOSE to the command table, pointing to existing code:

IF ABSWS < &8000
       EQUS "CLOSE", >(LB210-1), <(LB210-1), &00
ENDIF   

And now DosPlus boots successfully.

Nice job!

@SteveFosdick
Copy link
Author

Ok, I have copied that and added the others in too, though when I look I found RENAME was already there.

I have introduced a separate compilation flag for these. I am considering options for high paged RAM, i.e. either cmorley's OS RAM module or something that comes as part of a screen shadow board so I may want a version with workspace back high but otherwise runs on a BBC-B with 65C02, i.e. master-specific shadow screen out, and these commands in.

@hoglet67
Copy link
Owner

Sorry, it's *REMOVE that is missing, not *RENAME (as you found).

If the file is not found:

  • *DELETE gives a "Not found" error
  • *REMOVE doesn't give any error

@SteveFosdick
Copy link
Author

Ok, that is sorted in the latest commit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants