A2osX/ProDOS.203/ProDOS.S.XDOS.M.txt

546 lines
14 KiB
Plaintext
Raw Normal View History

2019-09-10 20:53:18 +00:00
NEW
AUTO 3,1
* MEMMGR memory manager
*
* allocate buffer in memory tables
2019-09-13 06:37:52 +00:00
alcbuffr .EQ *-ofsX
2019-09-10 20:53:18 +00:00
ldy #$04 index to user specified buffer.
2019-09-13 06:37:52 +00:00
alcbufr1 .EQ *-ofsX
2019-09-10 20:53:18 +00:00
lda (A3L),y this buffer must be on a page boundary.
tax save for validation.
cmp #$08
bcc L4E1E cannot be lower than video !
cmp #$BC nor greater than $BB00
bcs L4E1E since it would wipe out globals...
sta datptr+1
dey
lda (A3L),y low address should be zero !
sta datptr
bne L4E1E error if not page boundary.
inx add 4 pages for 1k buffer.
inx
inx
inx
2019-09-13 06:37:52 +00:00
L4DED dex test for conflicts.
2019-09-10 20:53:18 +00:00
jsr cmembit test for free buffer space
and memmap,y P8 memory bitmap
bne L4E1E report memory conflict, if any.
cpx datptr+1 test all 4 pages.
bne L4DED
inx add 4 pages again for allocation.
inx
inx
inx
2019-09-13 15:39:37 +00:00
L4DFE dex set proper bits to 1
2019-09-10 20:53:18 +00:00
jsr cmembit
ora memmap,y to mark it's allocation.
sta memmap,y
cpx datptr+1 set all 4 pages
bne L4DFE
ldy fcbptr calculate buffer number
lda fcbbuf,y
asl buffer number = (entnum) * 2.
sta fcbbuf+11,y save it in fcb.
tax use entnum * 2 as index to global
lda datptr+1 buffer addr tables. get addr already
sta buftbl-1,x validated as good. store hi addr
clc (entnums start at 1, not 0)
rts
2019-09-13 15:39:37 +00:00
L4E1E lda #$56 buffer is in use or not legal
2019-09-10 20:53:18 +00:00
sec
rts
getbufadr .EQ *-ofsX
tax index into global buffer table.
lda buftbl-2,x
sta bufaddrl
lda buftbl-1,x
sta bufaddrh
rts
relbuffr .EQ *-ofsX preserve buffer address in 'bufaddr'
jsr getbufadr
tay returns high buffer address in acc.
beq L4E54 branch if unallocated buffer space.
stz buftbl-1,x take address out of buffer list.
stz buftbl-2,x (x was set up by getbufadr)
freebuf .EQ *-ofsX
ldx bufaddrh get hi buffer address
inx add 4 pages to account for 1k space.
inx
inx
inx
2019-09-13 15:39:37 +00:00
L4E43 dex drop to next lower page.
2019-09-10 20:53:18 +00:00
jsr cmembit get bit and position to memtable of
eor #$FF this page. invert mask.
and memmap,y mark address as free space.
sta memmap,y
cpx bufaddrh all pages freed ?
bne L4E43 no.
2019-09-13 15:39:37 +00:00
L4E54 clc no error.
2019-09-10 20:53:18 +00:00
rts
* calculate memory allocation bit position.
* on entry: x = high address of buffer, low address assumed zero.
* on exit: acc = allocation bit mask, x = unchanged, y = pointer to memtabl byte
2019-09-13 15:39:37 +00:00
cmembit .EQ *-ofsX
2019-09-10 20:53:18 +00:00
txa page address
and #$07 which page in any 2k set ?
tay use as index to determine
lda whichbit,y bit position representation.
pha save bit position mask for now.
txa page address.
2019-09-11 15:53:33 +00:00
lsr
lsr determine 2k set
lsr
2019-09-10 20:53:18 +00:00
tay return it in y.
pla restore bit mask. return bit position
rts in a & y, pointer to memtabl in x.
valdbuf .EQ *-ofsX
lda usrbuf+1 high address of user's buffer
cmp #$02 must be greater than page 2.
bcc L4E1E report bad buffer
ldx cbytes+1
lda cbytes get cbytes-1 value.
sbc #$01 (carry is set)
bcs L4E76
dex
2019-09-13 15:39:37 +00:00
L4E76 clc
2019-09-10 20:53:18 +00:00
adc usrbuf calculate end of request address.
txa do high address.
adc usrbuf+1 the final address
tax must be less than $BFnn (globals)
cpx #$BF
bcs L4E1E report bad buffer.
inx loop thru all affected pages.
2019-09-13 15:39:37 +00:00
vldbuf1 .EQ *-ofsX
L4E82 dex check next lower page.
2019-09-10 20:53:18 +00:00
jsr cmembit
and memmap,y if 0 then no conflict.
bne L4E1E branch if conflict.
cpx usrbuf+1 was that the last (lowest) page ?
bne L4E82 if not.
clc all pages ok.
rts
2019-09-13 15:39:37 +00:00
getbuf .EQ *-ofsX give user address of file buffer
2019-09-10 20:53:18 +00:00
ldy #$02 referenced by refnum.
lda bufaddrl
sta (A3L),y
iny
lda bufaddrh
sta (A3L),y
clc no errors possible
rts
2019-09-13 15:39:37 +00:00
setbuf .EQ *-ofsX
2019-09-10 20:53:18 +00:00
ldy #$03
jsr alcbufr1 allocate new buffer address over old one
bcs L4EC7 report any errors immediately
lda bufaddrh
sta usrbuf+1
lda bufaddrl
sta usrbuf
jsr freebuf free address space of old buffer
ldy #$00
ldx #$03
2019-09-13 15:39:37 +00:00
L4EB8 lda (usrbuf),y move all 4 pages of the buffer to
2019-09-10 20:53:18 +00:00
sta (datptr),y new location.
iny
bne L4EB8
inc datptr+1
inc usrbuf+1
dex
bpl L4EB8
clc no errors
2019-09-13 15:39:37 +00:00
L4EC7 rts
2019-09-10 20:53:18 +00:00
* move 3 pages of dispatcher from 'displc2' to 'dispadr'
* this move routine must be resident above $E000 at all times
calldisp .EQ *-ofsX
2019-09-12 06:39:47 +00:00
lda RRAMWRAMBNK2 read/write RAM bank 2
lda RRAMWRAMBNK2
2019-09-11 15:53:33 +00:00
lda /dispadr
2019-09-10 20:53:18 +00:00
sta A2L+1
2019-09-11 15:53:33 +00:00
lda #dispadr
2019-09-10 20:53:18 +00:00
sta A2L
2019-09-11 15:53:33 +00:00
lda /displc2
2019-09-10 20:53:18 +00:00
sta A1L+1
stz A1L
ldy #$00
ldx #$03 3 pages to move.
2019-09-13 15:39:37 +00:00
L4EE0 dey move a page of code.
2019-09-10 20:53:18 +00:00
lda (A1L),y
sta (A2L),y
tya
bne L4EE0
2019-09-11 15:53:33 +00:00
inc A1L+1 pointers to next page
inc A2L+1
2019-09-10 20:53:18 +00:00
dex move all pages needed
bne L4EE0
2019-09-12 06:39:47 +00:00
lda RRAMWRAMBNK1 read/write RAM bank 1
lda RRAMWRAMBNK1 swap mli space back in
2019-09-10 20:53:18 +00:00
stz mliact MLI active flag
stz softev
2019-09-11 15:53:33 +00:00
lda /dispadr point RESET to dispatch entry
2019-09-10 20:53:18 +00:00
sta softev+1
eor #$A5
sta pwredup power up byte
jmp dispadr
* translate a prodos call into a smartport call
* to access unseen smartport devices
2019-09-13 15:39:37 +00:00
remap_sp .EQ *-ofsX
2019-09-10 20:53:18 +00:00
ldx #$03 assume 3 parameters.
lda A4L command number
sta cmdnum
bne L4F1B taken if not status call
2019-09-11 15:53:33 +00:00
ldy #spstatlist set up memory for the status list buffer
2019-09-10 20:53:18 +00:00
sty buf fake up the prodos parameters
2019-09-11 15:53:33 +00:00
ldy /spstatlist
2019-09-10 20:53:18 +00:00
sty buf+1
stz bloknml set statcode = 0 for simple status call
2019-09-13 15:39:37 +00:00
L4F1B cmp #$03 format command ?
2019-09-10 20:53:18 +00:00
bne L4F21 no.
ldx #$01 format has only 1 parameter.
2019-09-13 15:39:37 +00:00
L4F21 stx statparms set # of parms.
2019-09-10 20:53:18 +00:00
lda unitnum
2019-09-11 15:53:33 +00:00
lsr turn unit number into an index
lsr
lsr
lsr
2019-09-10 20:53:18 +00:00
tax
lda spunit-1,x get the smartport unit number and
sta sp_unitnum store into smartport parm list.
lda spvectlo-1,x
sta sp_vector+1 copy smartport entry address
lda spvecthi-1,x
sta sp_vector+2
ldx #$04 copy buffer pointer and block #
2019-09-13 15:39:37 +00:00
L4F3F lda buf-1,x from prodos parameters
2019-09-10 20:53:18 +00:00
sta sp_bufptr-1,x to smartport parameter block
dex
bne L4F3F
2019-09-13 15:39:37 +00:00
sp_vector .EQ *-ofsX smartport call
2019-09-10 20:53:18 +00:00
jsr $0000 (entry address gets modified)
2019-09-13 15:39:37 +00:00
cmdnum .EQ *-ofsX
2019-09-12 06:39:47 +00:00
.HS 00 command #
2019-09-11 15:53:33 +00:00
.DA statparms
2019-09-10 20:53:18 +00:00
bcs L4F6E
ldx cmdnum status call ?
bne L4F6E no...
ldx spstatlist+1 else get the block count
ldy spstatlist+2
lda spstatlist get the returned status.
bit #$10 is there a disk present ?
bne L4F65 yes, check for write protected.
lda #$2F return offline error.
bra L4F6D
2019-09-13 15:39:37 +00:00
L4F65 and #$44 mask all but write allowed and write
2019-09-10 20:53:18 +00:00
eor #$40 protected bits. if allowed and not
beq L4F6E protected, exit with carry clear
lda #$2B else return write protected error.
2019-09-13 15:39:37 +00:00
L4F6D sec
L4F6E rts
spvectlo .EQ *-ofsX storage for low byte of smartport
.HS 0000000000000000 entry.
.HS 00000000000000
spvecthi .EQ *-ofsX storage for high byte of smartport
.HS 0000000000000000 entry.
.HS 00000000000000
statparms .EQ *-ofsX # of parms (always 3 except format)
.HS 03
sp_unitnum .EQ *-ofsX
.HS 00 unit number
sp_bufptr .EQ *-ofsX
.HS 0000 data buffer
2019-09-11 15:53:33 +00:00
.HS 000000 block number (3 bytes)
2019-09-10 20:53:18 +00:00
* data tables
2019-09-13 15:39:37 +00:00
scnums .EQ *-ofsX table of valid mli command numbers.
.HS D3000000
.HS 40410000808182
.HS 65C0C1C2C3C4C5C6
.HS C7C8C9CACBCCCDCE
.HS CF00D0D1D2
pcntbl .EQ *-ofsX parameter counts for the calls
.HS 02FFFF
.HS FF0201FFFF030300
.HS 04070102070A0201
.HS 0103030404010102
.HS 02FF020202
2019-09-10 20:53:18 +00:00
* command table
2019-09-13 15:39:37 +00:00
cmdtable .EQ *-ofsX
.DA create create
.DA destroy destroy
.DA rename rename
.DA setinfo setinfo
.DA getinfo getinfo
.DA online online
.DA setprefx set prefix
.DA getprefx get prefix
.DA openf open
.DA newline newline
.DA readf read
.DA writef write
.DA closef close
.DA flushf flush
.DA setmark set mark
.DA getmark get mark
.DA seteof seteof
.DA geteof geteof
.DA setbuf setbuf
.DA getbuf getbuf
2019-09-10 20:53:18 +00:00
* corresponding command function bytes
2019-09-13 15:39:37 +00:00
disptch .EQ *-ofsX
.HS A0A1A2A3
.HS 84050607
2019-09-11 15:53:33 +00:00
.HS 88494A4B
2019-09-13 15:39:37 +00:00
.HS 2C2D4E4F
.HS 50515253
2019-09-10 20:53:18 +00:00
2019-09-13 15:39:37 +00:00
dinctbl .EQ *-ofsX table to increment
.HS 0100000200 directory usage/eof counts
pass .EQ *-ofsX
.HS 75
xdosver .EQ *-ofsX
.HS 00
compat .EQ *-ofsX
2019-09-10 20:53:18 +00:00
.HS 00
2019-09-11 15:53:33 +00:00
.HS C3270D000000
2019-09-13 15:39:37 +00:00
rootstuf .EQ *-ofsX
.HS 0F02000400000800
whichbit .EQ *-ofsX
.HS 8040201008040201
ofcbtbl .EQ *-ofsX
.HS 0C0D1819151617
inftabl .EQ *-ofsX
.HS 1E101F2080939421
.HS 22232418191A1B
deathmsg .EQ *-ofsX
.HS 20
.AS -"RESTART SYSTEM-$01"
.HS 20
2019-09-10 20:53:18 +00:00
*** work space ***
* note: this area is accessed by code that depends on the order of these
* variables in the file control block and temporary directory.
2019-09-13 15:39:37 +00:00
own_blk .EQ *-ofsX
.HS 0000
own_ent .EQ *-ofsX
.HS 00
own_len .EQ *-ofsX
.HS 00
h_credt .EQ *-ofsX
.HS 0000 directory creation date
.HS 0000 directory creation time
.HS 00 version under which this dir created
.HS 00 earliest version that it's compatible
h_attr .EQ *-ofsX attributes (protect bit, etc.)
.HS 00
h_entln .EQ *-ofsX length of each entry in this directory
.HS 00
h_maxent .EQ *-ofsX maximum number of entries per block
.HS 00
h_fcnt .EQ *-ofsX current # of files in this directory
.HS 0000
h_bmap .EQ *-ofsX address of first allocation bitmap
.HS 0000
h_tblk .EQ *-ofsX total number of blocks on this unit
.HS 0000
d_dev .EQ *-ofsX device number of this directory entry
.HS 00
d_head .EQ *-ofsX address of <sub> directory header
.HS 0000
d_entblk .EQ *-ofsX address of block which contains entry
.HS 0000
d_entnum .EQ *-ofsX entry number within block
.HS 00
d_stor .EQ *-ofsX
.HS 0000000000000000 file name
.HS 0000000000000000
d_filid .EQ *-ofsX user's identification byte
.HS 00
d_frst .EQ *-ofsX first block of file
.HS 0000
d_usage .EQ *-ofsX # of blocks allocated to this file
.HS 0000
d_eof .EQ *-ofsX current end of file marker
.HS 000000
d_credt .EQ *-ofsX
.HS 0000 file creation date
.HS 0000 file creation time
d_sosver .EQ *-ofsX sos version that created this file
.HS 00
d_comp .EQ *-ofsX backward version compatibility
.HS 00
d_attr .EQ *-ofsX attributes (protect, r/w, enable, etc.)
.HS 00
d_auxid .EQ *-ofsX user auxilliary identification
.HS 0000
d_moddt .EQ *-ofsX
.HS 0000 file's last modification date
.HS 0000 file's last modification time
d_dhdr .EQ *-ofsX file directory header block address
.HS 0000
scrtch .EQ *-ofsX scratch area for
.HS 00000000 allocation address conversion.
oldeof .EQ *-ofsX temp used in r/w
.HS 000000
oldmark .EQ *-ofsX
.HS 000000
xvcbptr .EQ *-ofsX used in 'cmpvcb' as a temp
.HS 00
vcbptr .EQ *-ofsX
.HS 00
fcbptr .EQ *-ofsX
.HS 00
fcbflg .EQ *-ofsX
.HS 00
reql .EQ *-ofsX
.HS 00
reqh .EQ *-ofsX
.HS 00
levels .EQ *-ofsX
.HS 00
totent .EQ *-ofsX
.HS 00
entcntl .EQ *-ofsX
.HS 00
entcnth .EQ *-ofsX
.HS 00
cntent .EQ *-ofsX
.HS 00
nofree .EQ *-ofsX
.HS 00
bmcnt .EQ *-ofsX
.HS 00
saptr .EQ *-ofsX
.HS 00
pathcnt .EQ *-ofsX
.HS 00
p_dev .EQ *-ofsX
.HS 00
p_blok .EQ *-ofsX
.HS 0000
bmptr .EQ *-ofsX
.HS 00
basval .EQ *-ofsX
.HS 00
half .EQ *-ofsX
.HS 00
2019-09-10 20:53:18 +00:00
* bitmap info tables
2019-09-13 15:39:37 +00:00
bmastat .EQ *-ofsX
.HS 00
bmadev .EQ *-ofsX
.HS 00
bmadadr .EQ *-ofsX
.HS 0000
bmacmap .EQ *-ofsX
.HS 00
tposll .EQ *-ofsX
.HS 00
tposlh .EQ *-ofsX
.HS 00
tposhi .EQ *-ofsX
.HS 00
rwreql .EQ *-ofsX
.HS 00
rwreqh .EQ *-ofsX
.HS 00
nlchar .EQ *-ofsX
.HS 00
nlmask .EQ *-ofsX
.HS 00
ioaccess .EQ *-ofsX has a call been made to
.HS 00 disk device handler ?
cmdtemp .EQ *-ofsX
.HS 00
bkbitflg .EQ *-ofsX used to set or clear backup bit
.HS 00
duplflag .EQ *-ofsX
.HS 00
vcbentry .EQ *-ofsX
.HS 00
2019-09-10 20:53:18 +00:00
* xdos temporary variables
2019-09-13 15:39:37 +00:00
namcnt .EQ *-ofsX
.HS 00
rnptr .EQ *-ofsX
.HS 00
namptr .EQ *-ofsX
.HS 00
vnptr .EQ *-ofsX
.HS 00
prfxflg .EQ *-ofsX
.HS 00
cferr .EQ *-ofsX
.HS 00
2019-09-10 20:53:18 +00:00
* deallocation temporary variables
2019-09-13 15:39:37 +00:00
firstbl .EQ *-ofsX
.HS 00
firstbh .EQ *-ofsX
.HS 00
stortyp .EQ *-ofsX
.HS 00
deblock .EQ *-ofsX
.HS 0000
dtree .EQ *-ofsX
.HS 00
dsap .EQ *-ofsX
.HS 00
dseed .EQ *-ofsX
.HS 0000
topdest .EQ *-ofsX
.HS 00
dtmpx .EQ *-ofsX
.HS 00
loklst .EQ *-ofsX look list of recognized device numbers
dealbufl .EQ *-ofsX
.HS 0000000000000000
dealbufh .EQ *-ofsX
2019-09-10 20:53:18 +00:00
.HS 0000000000000000
2019-09-13 15:39:37 +00:00
cbytes .EQ *-ofsX
.HS 0000
.HS 00 cbytes+2 must = 0
bufaddrl .EQ *-ofsX
.HS 00
bufaddrh .EQ *-ofsX
.HS 00
goadr .EQ *-ofsX
.HS 0000
delflag .EQ *-ofsX used by 'detree' to know if called
.HS 00 from delete (destroy).
2019-09-10 20:53:18 +00:00
* zero fill to page boundary - 3 ($FEFD). so that cortland flag stays
* within page boundary.
.HS 00000000000000
.HS 0000000000
.DA calldisp
2019-09-13 15:39:37 +00:00
cortflag .EQ *-ofsX cortland flag. 1 = Cortland system
.HS 00 (must stay within page boundary)
2019-09-10 20:53:18 +00:00
* end of obj mli_2
*--------------------------------------
MAN
SAVE USR/SRC/PRODOS.203/PRODOS.S.XDOS.M
LOAD USR/SRC/PRODOS.203/PRODOS.S
ASM