[comp.sys.m6809] OS9 RAMdisk driver for CoCoIII

ingoldsby@calgary.UUCP (11/06/86)

 Very soon now (my birthday is on Nov. 7) I hope to be the
proud owner of a CoCo III.  Since RS, in their infinite wisdom have
decided not to release OS9 Level II until February, we need some
software to take advantage of the extra RAM in the CoCo III in
the meantime.  A true hacker and OS9 wizard friend of mine has
written a RAMdisk driver for public use.  Here follows the source
and installation instructions.
                                     Terry Ingoldsby
          ...ihnp4!alberta!calgary!ingoldsby

       

	Here is a ramdisk driver for the coco3.  It consists of
	the device descriptor "tmp" and the driver "ccrdisk"
	assemble the following two files and put them in /d0/cmds
	(or in your boot file), then load them up, and format "/tmp"
	*before* accessing that directory.  You should get 56K of
	free space.


	Installation notes:
	- when assembling, be liberal with memory... give asm about 12K to
	  work with!
	- you only need to format /tmp when you are powering up, if you
	  are only rebooting, don't bother with formatting, the ramdisk
	  will survive the reboot.
	- i recommend putting "tmp" and "ccrdisk" in the boot file; the idea
	  is that since the ramdisk will get a lot of use, it might as well
	  be in there.
	- don't rely on the ramdisk too much.  If you happen to write a
	  program which 'features' a wild pointer, it is *possible* to
	  screw up the ramdisk, but this is not too likely since the ramdisk
	  is not usually in the address space of the cpu; so your program
	  must be mucking around with the MMU before it can access the
	  ramdisk content.  There may be a way to safeguard against this,
	  but until i find out more about the GIME, i can't say.



----- file: tmp (device descripor) -----

*
* Copyright 1986 by Caveh Jalali
*       Permission granted to use, distribute and modify
*	for non profit use only and only if this
*       copyright notice is included
*
*
* NOTE:
* page $35 gets munged by a reset, so it is not used by the ramdisk.
* due to this, you only get 56K of usable ramdisk space.  this area seems
* not to be affected by rebooting os9; even if you have to go back to basic
* to type 'dos'
*
* the base is $060000 on 128K machines, $000000 for 512K
* ioman only copies 2 bytes, so the actual value to be
* stored in it.port is the (base addr)/256
*

 mod modsiz,modnam,$f1,$81,fileman,driver
    fcb $ff -mode
    fcb $00,$06,$00
    fcb $0f   itbl size

    fcb   1 rbf device
    fcb   0 drive 0
    fcb $00 step rate
    fcb $20 dev type
    fcb $01 double dens
* 7 cyl on 128K machines, 55 on 512K
* each cyl is one page
    fdb   7 cylinders
    fcb   1 sides
    fcb   1 0=verify
    fdb  32 se/tr
    fdb  32 se/tr0
    fcb   1 interleave
    fcb $10 min seg alloc

modnam   fcs "tmp"
         fcb 3
driver   fcs "ccrdisk"
fileman  fcs "rbf"

    emod
modsiz   equ *
    end

----- end of tmp ---
----- file: ccrdisk (the device driver) -----

*
* Copyright 1986 by Caveh Jalali
*       permission granted to use, distribute and modify
*	for non profit use only.
*

 ifp1
    use /d0/defs/os9defs
    use /d0/defs/rbfdefs
MMU0     equ $ffa0
RAMBASE  equ $0000
MAGICPG  equ $34    (this page gets munged on reset)
 endc

    org DRVBEG
drivetbl equ .
         rmb DRVMEM

savemmu0 rmb 1

savestk  rmb 2
count    rmb 1

physbase rmb 1
track    rmb 1
rdbuf    rmb 2
ramsiz   equ .

 mod modsiz,modnam,$e1,$81,entry,ramsiz
         fcb $FF
modnam   fcs 'ccrdisk'
         fcb 3
********************
entry
    lbra init
    lbra read
    lbra write
    lbra getstt
    lbra setstt
    lbra term
********************
init
    leax drivetbl,u

    ldd  #$0001
    sta  dd.tot,x
    stb  dd.tot+2,x

    lda  #1
    sta  v.ndrv,u

    ldd  v.page+1,u  (base is / 256)
    lslb
    rola
    lslb
    rola
    lslb
    rola
    sta  physbase,u

    clrb
    rts

********************
read
*    stu  >$f0    debugging
    pshs dp,y
    exg  d,u
    tfr  a,dp
    exg  d,u
    leau drivetbl,u
    bsr  doseek
    bcs  read.q
    pshs x
    ldx  rdbuf
    ldy  pd.buf,y
    bsr  scopy
    ldx  ,s++
    bne  read.e
    ldx  1,s
    ldx  pd.buf,x
    ldb  #dd.siz
next.14
    lda  b,x
    sta  b,u
    decb
    bpl  next.14
read.e
    clrb
read.q
    puls dp,y,pc

********************
write
    pshs dp,y
    exg  d,u
    tfr  a,dp
    exg  d,u
    leau drivetbl,u
    bsr  doseek
    bcs  write.q

    ldx  pd.buf,y
    ldy  rdbuf
    bsr  scopy
    clrb
write.q
    puls dp,y,pc
********************

* copy ,x to ,y
scopy
    pshs cc,d,x,y,u
    sts  savestk

    orcc #$50
    lda  mmu0
    sta  savemmu0
    lda  track
    sta  mmu0

*    clrb
*scpy.2
*    lda  ,x+
*    sta  ,y+
*    decb
*    bne  scpy.2

    leas ,x
    leau 252,y
    lda  #14
    sta  count
scpy.2
    puls d,x,y
    pshu d,x,y
    puls d,x,y
    pshu d,x,y
    puls d,x,y
    pshu d,x,y
    dec  count
    bne  scpy.2
    leau 256,u
    puls d,x
    pshu d,x

    lda  savemmu0
    sta  mmu0

    lds  savestk
    puls cc,d,x,y,u,pc

********************

doseek
    pshs d
    tstb
    bne  e.lsn
    cmpx dd.tot+1,u
    bhs  e.lsn
    tfr  x,d
    tfr  b,a
    lsrb
    lsrb
    lsrb
    lsrb
    lsrb
    addb physbase
    cmpb #MAGICPG   (skip over this one!)
    blo  doseek.2
    incb
doseek.2
    stb  track
    anda #$1f
    clrb
    adda #RAMBASE/256
    std  rdbuf
    clrb
    puls d,pc

e.lsn
    comb
    puls d
    ldb  #e$sect
    rts

********************

setstt
    ldx  pd.rgs,y
    ldb  r$b,x
    cmpb #ss.reset
    beq  zz.reset
    cmpb #ss.wtrk
    beq  zz.wtrk
    comb
    ldb  #e$unksvc
    rts

zz.reset
zz.wtrk
term
    clrb
    rts

getstt
    comb
    ldb  #e$unksvc
    rts

********************
    emod
modsiz
    end

----- end ccrdisk -----
That's all folks.