mirror of
https://github.com/dschmenk/PLASMA.git
synced 2025-01-10 06:30:41 +00:00
Update memmgr to fileio library
This commit is contained in:
parent
685e9f63b3
commit
0d484e75d2
@ -76,6 +76,7 @@ const HMOD = $4321
|
||||
const PG_SIZE = 512
|
||||
const PG_ENTRIES = 256
|
||||
const PG_TBL_SIZE = 8
|
||||
word sysbuf
|
||||
word[PG_TBL_SIZE] hpgtbl // Handle page table
|
||||
word pooladdr
|
||||
word poolsize
|
||||
@ -271,14 +272,14 @@ def swapout(accessed)
|
||||
hmem.lsb = page
|
||||
hmem.msb = entry
|
||||
swapfile(@filename, hmem)
|
||||
create(@filename, $C3, $00, size) // embed size in aux type
|
||||
fileio:create(@filename, $00, size) // embed size in aux type
|
||||
//puts(@swapoutstr);puts(@filename);putc('@');puth(memblk);putc(':');puth(size);putln
|
||||
ref = open(@filename)
|
||||
ref = fileio:open(@filename)
|
||||
if ref
|
||||
//
|
||||
// Write it out
|
||||
//
|
||||
if write(ref, memblk, size) == size
|
||||
if fileio:write(ref, memblk, size) == size
|
||||
//
|
||||
// Zero size in page table flags swapin to read from disk
|
||||
//
|
||||
@ -286,7 +287,7 @@ def swapout(accessed)
|
||||
addfre(memblk)
|
||||
swapped = 1
|
||||
fin
|
||||
close(ref)
|
||||
fileio:close(ref)
|
||||
fin
|
||||
fin
|
||||
fin
|
||||
@ -384,7 +385,7 @@ def swapin(hmem)
|
||||
// Swap this block back in
|
||||
//
|
||||
swapfile(@filename, hmem)
|
||||
getfileinfo(@filename, @info)
|
||||
fileio:getfileinfo(@filename, @info)
|
||||
size = info:2 // Size encoded in aux type
|
||||
memblk = findblk(size)
|
||||
//puts(@swapinstr);puts(@filename);putc('@');puth(memblk);putc(':');puth(size);putln
|
||||
@ -392,11 +393,11 @@ def swapin(hmem)
|
||||
//
|
||||
// Read it in
|
||||
//
|
||||
ref = open(@filename)
|
||||
ref = fileio:open(@filename)
|
||||
if ref
|
||||
read(ref, memblk, size)
|
||||
close(ref)
|
||||
destroy(@filename)
|
||||
fileio:read(ref, memblk, size)
|
||||
fileio:close(ref)
|
||||
fileio:destroy(@filename)
|
||||
fin
|
||||
fin
|
||||
fin
|
||||
@ -658,6 +659,9 @@ end
|
||||
//
|
||||
// Search for best swap volume
|
||||
//
|
||||
// !!! Does this work on Apple ///???
|
||||
//
|
||||
sysbuf = $0800 // heapallocalign(1024, 8, 0)
|
||||
initdata = heapmark // Use data at top of heap for initialization
|
||||
initdata=>volparms.0 = 2
|
||||
initdata=>volparms.1 = 0
|
||||
@ -671,7 +675,7 @@ for sweepen = 0 to 15
|
||||
if ^initdata=>volptr
|
||||
memcpy(@swapvol + 2, initdata=>volptr + 1, ^initdata=>volptr)
|
||||
swapvol = ^initdata=>volptr + 1
|
||||
getfileinfo(@swapvol, @initdata->volinfo)
|
||||
fileio:getfileinfo(@swapvol, @initdata->volinfo)
|
||||
initdata=>freeblks = initdata=>volinfo:2 - initdata=>volinfo:5
|
||||
if initdata=>volptr:1 == $522F and initdata=>volptr:3 == $4D41 // '/RAM'
|
||||
if isugt(initdata=>freeblks, initdata=>ramfree)
|
||||
@ -693,15 +697,15 @@ memcpy(@swapvol + 2, initdata=>bestvol + 1, ^initdata=>bestvol)
|
||||
swapvol = ^initdata=>bestvol + 1
|
||||
memcpy(@swapvol + swapvol + 1, @swapdir + 1, swapdir)
|
||||
swapvol = swapvol + swapdir
|
||||
create(@swapvol, $C3, $0F, $0000) // Create the swap directory
|
||||
fileio:create(@swapvol, $0F, $0000) // Create the swap directory
|
||||
//
|
||||
// Clear out left over swap files
|
||||
//
|
||||
initdata->catref = open(@swapvol)
|
||||
initdata->catref = fileio:open(@swapvol)
|
||||
initdata->firstblk = 1
|
||||
initdata->swapstrlen = swapvol
|
||||
repeat
|
||||
if read(initdata->catref, @initdata->catalog, 512) == 512
|
||||
if fileio:read(initdata->catref, @initdata->catalog, 512) == 512
|
||||
initdata=>catentry = @initdata->catalog.4
|
||||
if initdata->firstblk
|
||||
initdata->entrylen = initdata->catalog.$23
|
||||
@ -714,7 +718,7 @@ repeat
|
||||
if ^initdata=>catentry
|
||||
memcpy(@swapvol + swapvol + 1, initdata=>catentry + 1, ^initdata=>catentry)
|
||||
swapvol = swapvol + ^initdata=>catentry
|
||||
destroy(@swapvol)
|
||||
fileio:destroy(@swapvol)
|
||||
swapvol = initdata->swapstrlen
|
||||
fin
|
||||
initdata=>catentry = initdata=>catentry + initdata->entrylen
|
||||
@ -724,6 +728,6 @@ repeat
|
||||
initdata->filecnt = 0
|
||||
fin
|
||||
until !initdata->filecnt
|
||||
close(initdata->catref)
|
||||
fileio:close(initdata->catref)
|
||||
//puts(@swapvol); putln
|
||||
done
|
||||
|
Loading…
x
Reference in New Issue
Block a user