1
0
mirror of https://github.com/dschmenk/PLASMA.git synced 2025-08-09 01:25:00 +00:00

change opensys to allocate number of I/O buffers for open

This commit is contained in:
David Schmenk
2018-02-04 13:01:07 -08:00
parent 384c6e8a18
commit 16932e90f7
5 changed files with 78 additions and 36 deletions

View File

@@ -38,7 +38,7 @@ import fileio
word setpfx word setpfx
word getfileinfo word getfileinfo
word geteof word geteof
word openbuf word iobufalloc
word open word open
word close word close
word read word read

View File

@@ -27,7 +27,7 @@ struc t_fileio
word setpfx word setpfx
word getfileinfo word getfileinfo
word geteof word geteof
word openbuf word iobufalloc
word open word open
word close word close
word read word read
@@ -38,14 +38,14 @@ struc t_fileio
word readblock word readblock
word writeblock word writeblock
end end
predef a2getpfx(path), a23setpfx(path), a2getfileinfo(path, fileinfo), a23geteof(refnum), a2openbuf(path, iobuf), a2open(path), a23close(refnum) predef a2getpfx(path), a23setpfx(path), a2getfileinfo(path, fileinfo), a23geteof(refnum), a2iobufs(iobufs), a2open(path), a2close(refnum)
predef a23read(refnum, buf, len), a2write(refnum, buf, len), a2create(path, type, aux), a23destroy(path) predef a23read(refnum, buf, len), a2write(refnum, buf, len), a2create(path, type, aux), a23destroy(path)
predef a2newline(refnum, emask, nlchar), a2readblock(unit, buf, block), a2writeblock(unit, buf, block) predef a2newline(refnum, emask, nlchar), a2readblock(unit, buf, block), a2writeblock(unit, buf, block)
// //
// Exported function table. // Exported function table.
// //
word fileio[] word fileio[]
word = @a2getpfx, @a23setpfx, @a2getfileinfo, @a23geteof, @a2openbuf, @a2open, @a23close word = @a2getpfx, @a23setpfx, @a2getfileinfo, @a23geteof, @a2iobufs, @a2open, @a2close
word = @a23read, @a2write, @a2create, @a23destroy word = @a23read, @a2write, @a2create, @a23destroy
word = @a2newline, @a2readblock, @a2writeblock word = @a2newline, @a2readblock, @a2writeblock
// //
@@ -53,6 +53,12 @@ word = @a2newline, @a2readblock, @a2writeblock
// //
export byte perr export byte perr
// //
// I/O buffers
//
const MAX_IOBUFS = 4
byte iobuf_ref[MAX_IOBUFS]
word iobuf_addr[MAX_IOBUFS] = sysbuf
//
// ProDOS/SOS routines // ProDOS/SOS routines
// //
def a1getpfx(path) def a1getpfx(path)
@@ -128,34 +134,54 @@ def a1open(path)
*CFFA1FileName = path *CFFA1FileName = path
return 0 return 0
end end
def a2openbuf(path, iobuf) def a2iobufs(iobufs)
byte params[6] byte i
params.0 = 3 word freebuf, bufaddr
params:1 = path
params:3 = iobuf if iobufs > MAX_IOBUFS
params.5 = 0 iobufs = MAX_IOBUFS
perr = syscall($C8, @params) fin
return params.5 if iobufs
iobufs-- // Subtract off system I/O buffer
if iobufs
bufaddr = heapallocalign(1024 * iobufs, 8, @freebuf)
for i = 1 to MAX_IOBUFS-1
if not iobuf_addr[i]
iobuf_addr[i] = bufaddr
bufaddr = bufaddr + 1024
iobufs--
if not iobufs
return freebuf
fin
fin
next
return freebuf
fin
else
for i = 1 to MAX_IOBUFS-1
iobuf_addr[i] = 0 // Free I/O buffers if 0 passed in
next
fin
return 0
end
def a13iobufs(iobufs)
return 0
end end
def a2open(path) def a2open(path)
byte params[6] byte i, params[6]
params.0 = 3
params:1 = path for i = 0 to MAX_IOBUFS-1
params:3 = sysbuf if iobuf_addr[i] and not iobuf_ref[i]
params.5 = 0 params.0 = 3
perr = syscall($C8, @params) params:1 = path
return params.5 params:3 = iobuf_addr[i]
end params.5 = 0
def a3openbuf(path, iobuf) perr = syscall($C8, @params)
byte params[7] iobuf_ref[i] = params.5
return params.5
params.0 = 4 fin
params:1 = path next
params.3 = 0 return 0
params:4 = iobuf
params.6 = 0
perr = syscall($C8, @params)
return params.3
end end
def a3open(path) def a3open(path)
byte params[7] byte params[7]
@@ -171,7 +197,22 @@ end
def a1close(refnum) def a1close(refnum)
return perr return perr
end end
def a23close(refnum) def a2close(refnum)
byte i, params[2]
for i = 0 to MAX_IOBUFS-1
if refnum == iobuf_ref[i]
iobuf_ref[i] = 0
params.0 = 1
params.1 = refnum
perr = syscall($CC, @params)
return perr
fin
next
perr = $45
return perr
end
def a3close(refnum)
byte params[2] byte params[2]
params.0 = 1 params.0 = 1
@@ -318,7 +359,9 @@ when MACHID & MACHID_MODEL
is MACHID_III is MACHID_III
fileio:getpfx = @a3getpfx fileio:getpfx = @a3getpfx
fileio:getfileinfo = @a3getfileinfo fileio:getfileinfo = @a3getfileinfo
fileio:iobufalloc = @a13iobufs
fileio:open = @a3open fileio:open = @a3open
fileio:close = @a3close
fileio:write = @a3write fileio:write = @a3write
fileio:create = @a3create fileio:create = @a3create
fileio:newline = @a3newline fileio:newline = @a3newline
@@ -330,6 +373,7 @@ when MACHID & MACHID_MODEL
fileio:setpfx = @a1setpfx fileio:setpfx = @a1setpfx
fileio:getfileinfo = @a1getfileinfo fileio:getfileinfo = @a1getfileinfo
fileio:geteof = @a1geteof fileio:geteof = @a1geteof
fileio:iobufalloc = @a13iobufs
fileio:open = @a1open fileio:open = @a1open
fileio:close = @a1close fileio:close = @a1close
fileio:read = @a1read fileio:read = @a1read

View File

@@ -508,7 +508,7 @@ def init_idglobal#0
fixup_addr = heapalloc(fixup_num*2) fixup_addr = heapalloc(fixup_num*2)
idglobal_tbl = heapalloc(globalbufsz) idglobal_tbl = heapalloc(globalbufsz)
idlocal_tbl = heapalloc(localbufsz) idlocal_tbl = heapalloc(localbufsz)
codebufsz = heapavail - 4096 codebufsz = heapavail - 2048
codebuff = heapalloc(codebufsz) codebuff = heapalloc(codebufsz)
codeptr = codebuff codeptr = codebuff
lastglobal = idglobal_tbl lastglobal = idglobal_tbl

View File

@@ -343,8 +343,7 @@ def nextln
if incref; puts("Nested INCLUDEs not allowed\n"); exit_err(0); fin if incref; puts("Nested INCLUDEs not allowed\n"); exit_err(0); fin
if scan <> STR_TKN; puts("Missing INCLUDE file\n"); exit_err(0); fin if scan <> STR_TKN; puts("Missing INCLUDE file\n"); exit_err(0); fin
strcpy(@incfile, constval) strcpy(@incfile, constval)
sysincbuf = heapallocalign(1024, 8, @sysincfre) incref = fileio:open(@incfile)
incref = fileio:openbuf(@incfile, sysincbuf)
if not incref if not incref
puts("Unable to open INCLUDE file: ") puts("Unable to open INCLUDE file: ")
puts(@incfile) puts(@incfile)
@@ -362,7 +361,6 @@ def nextln
else else
if refnum == incref if refnum == incref
fileio:close(incref) fileio:close(incref)
heaprelease(sysincfre)
incref = 0 incref = 0
refnum = srcref refnum = srcref
parsefile = @srcfile parsefile = @srcfile

View File

@@ -278,7 +278,6 @@ byte outflags
byte refnum, srcref, incref byte refnum, srcref, incref
byte[32] srcfile, incfile, relfile byte[32] srcfile, incfile, relfile
word parsefile // Pointer to current file word parsefile // Pointer to current file
word sysincbuf, sysincfre // System I/O buffer for include files
word srcline // Saved source line number word srcline // Saved source line number
// //
// Scanner variables // Scanner variables
@@ -464,6 +463,7 @@ if ^arg
fin fin
fin fin
if srcfile and relfile if srcfile and relfile
fileio:iobufalloc(2) // Reserve two I/O buffers
srcref = fileio:open(@srcfile) srcref = fileio:open(@srcfile)
if srcref if srcref
fileio:newline(srcref, $7F, $0D) fileio:newline(srcref, $7F, $0D)