OS-9 Level 2 for (updated) Dragons

A place to discuss everything Dragon related that doesn't fall into the other categories.
pser1
Posts: 1846
Joined: Sun Mar 25, 2012 7:32 pm
Location: Barcelona (SPAIN)

Re: OS-9 Level 2 for (updated) Dragons

Post by pser1 »

From Mike Miller .docx, I do copy this text:
4.1 DragonDOS Startup Program
The startup program (COCOSWITCH) amongst other tasks:
• Sets up the MMU registers.
• Loads in the 3 Tandy modules REL, OS9P1 and BOOT from a .BIN file ("L2BOOT").
• Overlays the Tandy BOOT file (designed for the Tandy disk controller) with one ("BOOT6") designed for the Dragon DD controller.
• Patches REL.
• Disables interrupts, enables the MMU.
• Sets up the new interrupt vectors, pointing into the 'reserved common RAM', and then executes REL.
The contents of L2BOOT are taken from the bootstrap track on the Tandy Level Two disk.
A BASIC routine (L2STEAL) reads the 18 sectors of track 34 into memory. To do this work, I have used a clean DOS disk (W1) that ended containing
- L2STEAL.BAS and L2BOOT.BIN

Code: Select all

0 'L2STEAL
10 CLS:PCLEAR1:CLEAR1000:DIMB$(128):DIMA$(128):D=&H264:E=9728
20 I=INT(D/18):J=D-18*I+1:SREAD 2,I,J,A$,B$
30 FA=VARPTR(A$)+2:AD=256*PEEK(FA)+PEEK(FA+1):FOR CT=1TO128:POKEE,PEEK(AD):E=E+1:AD=AD+1:NEXT CT
40 FB=VARPTR(B$)+2:BD=256*PEEK(FB)+PEEK(FB+1):FOR CT=1TO128:POKEE,PEEK(BD):E=E+1:BD=BD+1:NEXT CT
50 D=D+1:ZZ=FRE$:PRINTI;J;ZZ::'INPUT TE$
55 IF J<17 GOTO20
70 SAVE"L2BOOT",&H2600,&H3800,&H2602
Bob's article indicates these values for the save command - SAVE "L2BOOT",&H2600,&H3900,&H2602
But &H3900-&H2600 = $1300 and this exceeds the track length ($1200). So, I have reduced one sector so that it fits inside 4,608 bytes
The binary file I have saved into W1 has been copied into disk F1 too.
Now we have the Level 2 boot modules in disk F2 and the Tandy boot and the Dragonized one in disk F1 ; -----------------------------------------------------------------------------------------------------------
It is time to put thinks together and create a basic program that will be the starting piece
COCOSWITCH — DragonDOS Startup Program
Written by Bob:
Optional lines 10–40 (load BASIC ROM into RAM) are only needed if using a design without a 6116.
Running 256k with OS9LII also needs a patch to the startup routine in OS9P1 which as supplied by Tandy only expects 128k or 512k machines
Lines 110–120 are the 256k OS9P1 patch — omit for 128k or 512k versions.
I have saved this program into disk F1 as "CCSWITCH.BAS" because DOS only supports 8 char names
When the program has loaded both files, it will be waiting for the user to press a key (line 70)
Remember to do that only after changing the F1 disk in drive #1 for the OS9L2 we have prepared (F2)

Code: Select all

0  ' COCOSWITCH
10 REM DATA 34,7F,1A,50,8E,80,00
20 REM DATA B7,FF,DE,A6,84,B7,FF,DF,A7,80
30 REM DATA 8C,F0,00,2F,F1,B7,FF,DF,35,FF
40 REM BA=&H200:FOR I=BA TO BA+26:READ V$: V=VAL("&H"+V$):POKE I,V:NEXT I: EXEC BA
50 PCLEAR 1
60 FOR I=0 TO 7: POKE&HFFA0+I,(&HF8+I):POKE&HFFA8+I,(&HF8+I): NEXT
70 LOAD"L2BOOT.BIN":LOAD"BOOT6.BIN":PRINT"READY TO RUN":INPUT J
80 POKE&HFF03,&H34:POKE&HFF90,0
85 REM THIS PATCHES REL MODULE
90 POKE&H2682,&HDF:POKE&H2631,0:POKE&H26E0,&H48
100 POKE&H272D,&H94:POKE&H272E,&HA9:POKE&H272F,&H55:REM THESE ARE CRC
105 REM PATCH FOR 256K OF RAM - NOT FOR 1-2M
110 REM POKE&H2A20,&H0F:POKE&H2A3B,&H1F
120 REM POKE&H37D6,&H9D:POKE&H37D7,&H5D:POKE&H37D8,&H96:REM THESE ARE CRC
130 POKE&HFFA2,&HFF:FOR I=0 TO 7:POKE(&H5FF0+I+I),&HFE:NEXT
140 POKE&H5FF3,&HEE:POKE&H5FF5,&HF1:POKE&H5FF7,&HF4
150 POKE&H5FF9,&HF7:POKE&H5FFB,&HFA:POKE&H5FFD,&HFD
160 POKE&H5FFE,&H26:POKE&H5FFF,02
170 POKE&HFFA2,&HFA:POKE&HFF48,0:EXEC&H2602
; ---------------------------------------------------------------------------------
Some points before attempting to make the very first test running CCSWITCH ...
The OS9L2 disk (F2) that contains the OS9 modules, needs some changes for sure
I have not yet added 'acia51.new' from Eurohard OS9L1 and probably I should update
after applying more patches the already present modules OS9P1 and clock.50hz

1) Bob Hall patches the module OS9P1 from CCSSWITCH.BAS but only for the case of 256K RAM
Well, we will be using modules that have 1Mb-2Mb so we should have a peek at that module in order to find a way to ensure that all RAM
will be detected/used by OS9P1. We need to modify the patch to that module that is loaded into RAM @ $28FA(10,490)
so lines 110-120 should be modified.

I have been working on that module (from Tandy OS9Level2) adding some comments, most of
them coming from NitrOS-9 Level 2 documentation and variable names coming from os9defs-l2v3
OS9P1-Analysis.zip
(23.52 KiB) Downloaded 6 times
I have seen too many differences between the two systems, so I have extracted the code
used in NitrOS-9L2 to calculate the present RAM. I attach it here
CalculateRAM - NitrOS9 L2 kernel.zip
(878 Bytes) Downloaded 6 times
I don't get how Tandy L2 OS9P1 module does the calculations, so maybe someone could give
us some ideas to understand the way it does. help! help! help!
One possible alternative could be deleting all that code and substituting it with the
code from NitrOS-9L2 kernel module shown in file 'CalculateRAM.asm'

2) I have extracted the REL module too, I have unassembled it and then applied the patches that we see in CCSWITCH Basic program in lines 90-100 just to see what these changes do.
REL sends the initial values to the GIMME registers and I found that $FF98 is set to zero, that means that clock rate will be 60Hz.
According to CC3 docs it should be $08 to force the clock to work at 50hz as we really want!
RELP.zip
(3.15 KiB) Downloaded 5 times
Then I have open the clock.50hz to see if that is corrected there, but I have found something
very suspicious to me about code line 246 of the asm file

Code: Select all

lda  <$98  ; get copy from direct page of register $FF98
ora  #$08   ; set bit3 to work @50hz
sta  <$98   ; update copy
*sta $FF98  ; WHY NOT UPDATE THE GIMME REGISTER TOO?
nop       ; these three bytes overwrite previous old code
nop
nop
So, as usual, there are a few points we need to analyze more in deep to decide what to do next!
I will really appreciate any hint/idea you'd want to share with us to clarify this situation!
Fear not to chime!!
thanks a bunch
cheers!
pere
pser1
Posts: 1846
Joined: Sun Mar 25, 2012 7:32 pm
Location: Barcelona (SPAIN)

Re: OS-9 Level 2 for (updated) Dragons

Post by pser1 »

Hello,
I have not yet added the acia51.new nor have I modified the clock.50hz that are inside the OS9Boot file in the final OS9L2 disk F2,
because I am still scratching my head trying to understand how OS-9 controls the present RAM pages
There are two system variables
<$40 D.BlkMap (MemoryBlockMap pointer) - initial value = $0200
<$42 SecondBlockMap pointer - initial value = $0240
As the Tandy OS9L2 version was created supporting only 128K or 512K. I asume there is place enough for the 64 pages, each 8K,
to be controlled in the bytes from $200 to $23F (<$40 to <$42)
But I can not be sure if there has to be another bigger table to contain the status of the pages $40 till $FF.
That would need from $240 to $2FF (?)

I have made the very first debugging session on Xoar emulating a Dragon 64 with the module iMMUnity (2Mb).
To do so I have loaded the F1 disk that contains the basic CCSWITCH program that loads the Tandy kernel and then overwrites the BOOT part
with the Dragonized BOOT6.BIN, applies some patches and ends starting the module REL
FirstDebuggingSession-OS9L2onDragon-iMMUnity.jpg
FirstDebuggingSession-OS9L2onDragon-iMMUnity.jpg (48.34 KiB) Viewed 133 times
I had several problems and everything went wrong when setting the GIMME registers. Finally, I have modified the basic program CCSWITCH
so that it fills all of the MMU slots from FFA0-A7 and FFA8-AF with values $38-$3F
At the same time I have modified the value sent to $FF90 from $EC to $48
CCSWITCH.ZIP
(623 Bytes) Downloaded 5 times
I don't know if this could be the source of future problems, but by now this allows me to debug-trace the REL module in full and then jump to OS9P1
This is the module that calculates the size of the present RAM. I have gone far past the calculations point, but have not found any place to detect
the status of the RAM over 512K (present or not)
Going too much farther from that point, it ends crashing the system (loops) because I have not put the OS9L2 (F2) disk in drive 1, only because it needs a few changes and then I should add the folders CMDS, SYS, DEFS, etc ...

I do attach here the files REL and OS9P1-Analysis for maybe someone would find how the program detects the end of present memory
thanks in advance
RELP.zip
(3.15 KiB) Downloaded 5 times
OS9P1-Analysis.zip
(23.81 KiB) Downloaded 4 times
cheers!
pere
pser1
Posts: 1846
Joined: Sun Mar 25, 2012 7:32 pm
Location: Barcelona (SPAIN)

Re: OS-9 Level 2 for (updated) Dragons

Post by pser1 »

Hi,
gone one step forward.
Now I see that the OS9P1 code from $F109 (Once moved high) begins verifying the RAM at page 0 by paging it to MMU slot #1 ($FFA1)
using memory from $2000-$3FFF (regY)
The code saves 2 bytes, then writes $00FF, verifies it has written correctly and the same with pattern $FF00, restoring the 2 bytes.
This test is done only on one byte. If success then it goes to page 1-2 ... till $3F
I think that this last page is not tested, presumably because that special page is always in use, so present!
Will have a peek at that point next time I do debug it.
The RAM between $200 to $23F has been used as a map where any not present RAM would have been marked with value $80
and, by what I have seen, $200 and $23f get marked value $01 being all the other bytes equal to $00
So, somehow the OS9 just tests for 512k because there is no extra bytes in any table to have info about RAM till 2Mb
I hope this won't be any problem to use our extra RAM
cheers!
pere
lcurtisboyle
Posts: 29
Joined: Thu Nov 05, 2020 9:47 pm

Re: OS-9 Level 2 for (updated) Dragons

Post by lcurtisboyle »

I don't have the code in front of me, but in NitrOS9 Level 2, the 2 MB RAM detection basically does a map in of pages by powers of 2 (so it works with the older Quarter Meg boards that Burke & Burke did, as well as 1 and 2 MB RAM options), and sees if the value written changes when mapping them back in. The memory map, if I remember correctly, already had 256 bytes reserved, although only the first 64 were used in the stock Tandy/Microware version of Level II (of course they are used in 1 or 2 MB RAM upgrades). Microware did plan ahead for future updates like this; the level 2 Process Descriptors have enough room to do 2K RAM pages (rather than the 8 actually used on the Coco 3). The Level III upgrade (that created two 16K "sub-maps" for RBF & RBF drivers/descriptors, and SCF & SCF drives descriptors (except Grfdrv) used some of those unused locations to allow quickly swapping the "regular" memory map for a process and the ones when an SCF or RBF system was happening.
pser1
Posts: 1846
Joined: Sun Mar 25, 2012 7:32 pm
Location: Barcelona (SPAIN)

Re: OS-9 Level 2 for (updated) Dragons

Post by pser1 »

Hi L.Curtis,
thanks for that explanation.
As I am working to implement Bob Hall's procedure to convert OS9L2 to work on the Dragons, I have just unassembled
the OS9P1 module to have a peek at the points that Bob suggested to 'patch' in order to work with 256K for maybe I
could find a way to extend this check to 1-2Mb
But the code just checks pages from $00 till $3F and only writes to the map table if the page is not present, so when the
write/readback failed.
The area $200-$240 is used for the first 64 pages (512K), maybe just changing the control ,value $3F to $FF for the page
number it would work, but I am not sure. The last page get marked $01 ... I will make a test about that.
I do attach here the unassembled file I have been trying to understand, probably you will 'see' more details than me.
cheers!
pere
OS9P1 unassembled.ZIP
(80.22 KiB) Downloaded 1 time
pser1
Posts: 1846
Joined: Sun Mar 25, 2012 7:32 pm
Location: Barcelona (SPAIN)

Re: OS-9 Level 2 for (updated) Dragons

Post by pser1 »

Hello,
I have tried to modify OS9P1 so that it checks RAM memory till the 2Mb, so from page #0 till #255
I did that by changing the assignment made to pointer <$42 so that now it receives value $0300 instead if $0240
This is just one more than the maximum expected ram pages
The second change I did was in the control point where the program calculates how many pages have already been checked
there I substituted the $3F by a $FF
I have to say that this works just fine because now the ram map from $200 to $2FF is used.
As there is ram in all pages, all of them end with value $00 except for the 1st and last that get value $01
So far so good, but then there is some code that searches in ram for the beginning of a module ($87)
and now id doesn't find it the very first time it checks for it. But without my changes it found $87 at the first attempt
Now it loops some times till finally it founds the module beginning and then continues as before ...
But the result is again the same. The screen shows the mesage "OS9 BOOT" and freezes, hangs or whatever is to be discovered
When I have the time I will debug both ways to find what's the difference in one or more variables that change the behaviour
or the ram pointer value ...
Any idea/hint would be highly appreciated
I am attaching here the OS9P1.asm as is now after the patches to check for 2Mb together with the compiling listing
cheers!
pere
OS9P1-2Mb.ZIP
(80.45 KiB) Downloaded 2 times
pser1
Posts: 1846
Joined: Sun Mar 25, 2012 7:32 pm
Location: Barcelona (SPAIN)

Re: OS-9 Level 2 for (updated) Dragons

Post by pser1 »

Hello,
after some more tests/debug sessions I got to the point where the boot sequence calls for the first time an OS9 function.
These calls are made of an SWI2 followed by the code of the desired function
Once I wanted to see the SWI2 execution, my surprise was that the code jumped to address $0103
This is the std SWI2 hook that should have something like JMP $XXXX being that the address of the new Interrupt Service Routine
Unfortunately this area is filled with values $00/$FF, so never initiated.

Anyway, having a peek at $FFF0 where the CCSWITCH.BAS program has POKEd some values shows that these values have been 'lost'
Tracing the module REL, I have verified that the values from Basic are received but once REL sends the Gimme registers, those values get lost/substituted. The reason seems to be the fact that REL sends value $DC to FF90
Working with the iMMUnity module we use to send $40 or $48 instead, so I have changed $DC to be $48 (in the CCSWITCH.BAS program)
and that way I have verified that the values POKEd to FFF0... are preserved
CCSW52.ZIP
(446 Bytes) Downloaded 2 times
But, every hurdle we get to pass over shows up a bigger one ;-)
The values POKEd are:
FFF0 - UNUSED
FFF2 - FE EE SWI3
FFF4 - FE F1 SWI2
FFF6 - FE F4 FIRQ
FFF8 - FE F7 IRQ
FFFA - FE FA SWI
FFFC - FE FD NMI
FFFE - FE FF RESET
These 'secondary' vectors have never been initialized, so we have the very same problem another time.
I would expect the OS9 boot programs (REL-OS9P1) to do that task because only the OS9 knows which ISR has to be associated with each interrupt ...
If this is right, why hasn't the system filled those hooks before it calls them?

As the modules REL and OS9P1 have been picked from Tandy OS9L2, it could be an idea
to debug/trace the start sequence of that system on a CoCo3
Not sure if this could be a great help, but right now I have no more ideas :-(

This means, again, that it would be a great help if anyone could give us some pointers/ideas to solve that problem!
cheers!
pere
sixxie
Posts: 1469
Joined: Fri Jul 18, 2008 8:36 am
Location: Hertfordshire
Contact:

Re: OS-9 Level 2 for (updated) Dragons

Post by sixxie »

Perhaps it's depending on what the CoCo 3 has initialised those secondary vectors to?

Which is:

Code: Select all

$ xroar -q -m coco3 -trap write=0xfe00-0xfeff -trap-trace-n 1
4199| a780        STA   ,X+                 cc=51 a=55 b=13 dp=00 x=feee y=431b u=ffff s=5efc
4199| a780        STA   ,X+                 cc=51 a=16 b=12 dp=00 x=feef y=431c u=ffff s=5efc
4199| a780        STA   ,X+                 cc=51 a=02 b=11 dp=00 x=fef0 y=431d u=ffff s=5efc
4199| a780        STA   ,X+                 cc=51 a=0f b=10 dp=00 x=fef1 y=431e u=ffff s=5efc
4199| a780        STA   ,X+                 cc=51 a=16 b=0f dp=00 x=fef2 y=431f u=ffff s=5efc
4199| a780        STA   ,X+                 cc=51 a=02 b=0e dp=00 x=fef3 y=4320 u=ffff s=5efc
4199| a780        STA   ,X+                 cc=51 a=0f b=0d dp=00 x=fef4 y=4321 u=ffff s=5efc
4199| a780        STA   ,X+                 cc=51 a=16 b=0c dp=00 x=fef5 y=4322 u=ffff s=5efc
4199| a780        STA   ,X+                 cc=51 a=02 b=0b dp=00 x=fef6 y=4323 u=ffff s=5efc
4199| a780        STA   ,X+                 cc=51 a=18 b=0a dp=00 x=fef7 y=4324 u=ffff s=5efc
4199| a780        STA   ,X+                 cc=51 a=16 b=09 dp=00 x=fef8 y=4325 u=ffff s=5efc
4199| a780        STA   ,X+                 cc=51 a=02 b=08 dp=00 x=fef9 y=4326 u=ffff s=5efc
4199| a780        STA   ,X+                 cc=51 a=12 b=07 dp=00 x=fefa y=4327 u=ffff s=5efc
4199| a780        STA   ,X+                 cc=51 a=16 b=06 dp=00 x=fefb y=4328 u=ffff s=5efc
4199| a780        STA   ,X+                 cc=51 a=02 b=05 dp=00 x=fefc y=4329 u=ffff s=5efc
4199| a780        STA   ,X+                 cc=51 a=09 b=04 dp=00 x=fefd y=432a u=ffff s=5efc
4199| a780        STA   ,X+                 cc=51 a=16 b=03 dp=00 x=fefe y=432b u=ffff s=5efc
4199| a780        STA   ,X+                 cc=51 a=02 b=02 dp=00 x=feff y=432c u=ffff s=5efc
4199| a780        STA   ,X+                 cc=51 a=09 b=01 dp=00 x=ff00 y=432d u=ffff s=5efc
Which is (ignoring that $55, used as an initialisation flag):

Code: Select all

FEEE 16020F                           lbra    $0100
FEF1 16020F                           lbra    $0103
FEF4 160218                           lbra    $010F
FEF7 160212                           lbra    $010C
FEFA 160209                           lbra    $0106
FEFD 160209                           lbra    $0109
(I have no idea why they chose to use LBRA there).

You would think they'd override those in OS-9 to make things a bit quicker - I'm sure they'll be doing so in NitrOS-9...

..ciaran
Go4Retro
Posts: 24
Joined: Thu Feb 22, 2018 12:47 pm

Re: OS-9 Level 2 for (updated) Dragons

Post by Go4Retro »

pser1 wrote: Mon Jun 08, 2026 2:55 pm The reason seems to be the fact that REL sends value $DC to FF90
Working with the iMMUnity module we use to send $40 or $48 instead, so I have changed $DC to be $48 (in the CCSWITCH.BAS program)
and that way I have verified that the values POKEd to FFF0... are preserved
If you could help me out with a test program to this point, as $dc is 11011100, which has 48 in it. And, more importantly, bit 0 (COC1/2) is off, which enabled alternate vectors. So, $dc should function the same as $48. I am wondering why it does not.
Jim
Go4Retro
Posts: 24
Joined: Thu Feb 22, 2018 12:47 pm

Re: OS-9 Level 2 for (updated) Dragons

Post by Go4Retro »

sixxie wrote: Mon Jun 08, 2026 4:06 pm You would think they'd override those in OS-9 to make things a bit quicker - I'm sure they'll be doing so in NitrOS-9...

..ciaran
I believe they indeed do (OS9 and NitrOS9 both)

Otherwise, you have to waste all of 0-1fff to preserve the vectors.

Jim
Post Reply