changeset 3088:fa4b4ae537c1

Add comments based on my learnings while debugging boot on multicomp09
author Neal Crook <foofoobedoo@gmail.com>
date Tue, 13 Oct 2015 22:23:27 +0100
parents a938d0f26711
children 3244c2e1b6ed
files level1/modules/kernel/krn.asm level1/modules/kernel/krnp2.asm
diffstat 2 files changed, 42 insertions(+), 22 deletions(-) [+]
line wrap: on
line diff
--- a/level1/modules/kernel/krn.asm	Sat Oct 03 14:51:30 2015 -0500
+++ b/level1/modules/kernel/krn.asm	Tue Oct 13 22:23:27 2015 +0100
@@ -260,24 +260,27 @@
 GetMem   equ   *			Initially I tried GetMem clra
 *                                       that is redundant. See last line. RG
 L0158    ldx   <D.FMBM
-		IFNE	atari
+* Free-memory bitmap. Bit7 of 0,x corresponds to page 0, bit6 to page 1 etc.
+* Bit7 of 1,x corresponds to page 8, bit6 to page 9 etc, etc.
+         IFNE  atari
 * In the Atari, memory $0000-$08FF is used by the system
          ldb   #%11111111
-         stb   ,x				mark $0000-$07FF as allocated
-         stb   $1A,x			mark $D000-$D7FF I/O area as allocated
-         ldb   #%10000000		
-         stb   1,x				mark $0800-$08FF as allocated
-		ELSE
-* In the CoCo, memory $0000-$04FF is used by the system
+         stb   ,x                       mark $0000-$07FF as allocated
+         stb   $1A,x                    mark $D000-$D7FF I/O area as allocated
+         ldb   #%10000000
+         stb   1,x                      mark $0800-$08FF as allocated
+         ELSE
+* For all (other) platforms, memory $0000-$04FF is used by the system
          ldb   #%11111000
          stb   ,x
-         	ENDC
+         ENDC
+* For all platforms exclude high memory as defined (earlier) by D.MLIM
          clra
          ldb   <D.MLIM
          negb
          tfr   d,y
          negb
-         lbsr  L065A
+         lbsr  L065A                    in included fallbit.asm
 
 * jump into krnp2 here
          leax  >P2Nam,pcr
--- a/level1/modules/kernel/krnp2.asm	Sat Oct 03 14:51:30 2015 -0500
+++ b/level1/modules/kernel/krnp2.asm	Tue Oct 13 22:23:27 2015 +0100
@@ -84,7 +84,7 @@
          os9   F$SSvc
          ldx   <D.PrcDBT
          os9   F$All64
-         bcs   L0081
+         bcs   fatalerr                 failed to allocate
          stx   <D.PrcDBT
          sty   <D.Proc
          tfr   s,d
@@ -94,31 +94,44 @@
          lda   #SysState
          sta   P$State,y
          ldu   <D.Init
-         bsr   ChdDir
-         bcc   L006A
+
+* ChdDir should identify system device, result in a call to IOCall which links and
+* initialises IOMan then calls JmpBoot to load and validate the boot file
+         bsr   ChdDir                   U = address of init module
+         bcc   L006A                    success
+
+* Maybe we failed because we didn't have all the modules we needed? Load and
+* validate the boot file and then try again.
          lbsr  JmpBoot
          bsr   ChdDir
-L006A    bsr   OpenCons
-         bcc   L0073
+
+L006A    bsr   OpenCons                 U = address of init module, still
+         bcc   L0073                    success
+
+* Maybe we were able to get this far without needing anything from the boot file, but now
+* we need it for the console device
          lbsr  JmpBoot
          bsr   OpenCons
+
+* Hmm. No check for success. Probably should "bcs fatalerr" here?
+
 L0073    ldd   InitStr,u
          leax  d,u
          lda   #$01
          clrb
          ldy   #$0000
          os9   F$Chain
-L0081    jmp   [$FFFE]
+fatalerr jmp   [$FFFE]
 
-*
+* change directory
 * U = address of init module
-ChdDir   clrb
+ChdDir   clrb                           clear carry
          ldd   <SysStr,u		get system device
-         beq   ChdDir10			branch if none
-         leax  d,u
-         lda   #READ.+EXEC.
-         os9   I$ChgDir			else change directory to it
-ChdDir10 rts
+         beq   ChdDir10			branch if none - carry still clear
+         leax  d,u                      address of the path list
+         lda   #READ.+EXEC.             access mode
+         os9   I$ChgDir			change directory to it
+ChdDir10 rts                            carry set -> error
 
 * open console device
 * U = address of init module
@@ -715,8 +728,12 @@
          os9   F$Link
          rts
 
+* Attempt to load bootfile and validate the modules it contains
 *
+* Entry:
 * U = address of init module
+* Exit:
+* CC Carry set on Error
 JmpBoot  pshs  u
          comb
          tst   <D.Boot                 already booted?