mirror of
https://github.com/Interlisp/maiko.git
synced 2026-01-16 16:19:10 +00:00
This also involves removing unnecessary forward declarations, inserting
includes for all cross-file function references, making some definitions
static if they are not otherwise used, correcting errors that were exposed
by having correct prototypes.
new file: inc/allocmdsdefs.h
new file: inc/arith2defs.h
new file: inc/arith3defs.h
new file: inc/arith4defs.h
new file: inc/array2defs.h
new file: inc/array3defs.h
new file: inc/array4defs.h
new file: inc/array5defs.h
new file: inc/array6defs.h
new file: inc/arraydefs.h
new file: inc/bbtsubdefs.h
new file: inc/bindefs.h
new file: inc/bindsdefs.h
new file: inc/bitbltdefs.h
new file: inc/bltdefs.h
new file: inc/byteswapdefs.h
new file: inc/car-cdrdefs.h
new file: inc/chardevdefs.h
new file: inc/commondefs.h
new file: inc/conspagedefs.h
new file: inc/dbgtooldefs.h
new file: inc/dirdefs.h
new file: inc/drawdefs.h
new file: inc/dskdefs.h
new file: inc/dspifdefs.h
new file: inc/dspsubrsdefs.h
new file: inc/eqfdefs.h
new file: inc/etherdefs.h
new file: inc/findkeydefs.h
new file: inc/fpdefs.h
new file: inc/fvardefs.h
new file: inc/gc2defs.h
new file: inc/gcarraydefs.h
new file: inc/gccodedefs.h
new file: inc/gcdefs.h
new file: inc/gcfinaldefs.h
new file: inc/gchtfinddefs.h
new file: inc/gcmain3defs.h
new file: inc/gcoflowdefs.h
new file: inc/gcrcelldefs.h
new file: inc/gcrdefs.h
new file: inc/gcscandefs.h
new file: inc/gvar2defs.h
new file: inc/hacksdefs.h
new file: inc/hardrtndefs.h
new file: inc/inetdefs.h
new file: inc/initdspdefs.h
new file: inc/initkbddefs.h
new file: inc/initsoutdefs.h
modified: inc/inlineC.h
new file: inc/intcalldefs.h
new file: inc/kbdsubrsdefs.h
new file: inc/keyeventdefs.h
new file: inc/keylibdefs.h
new file: inc/kprintdefs.h
new file: inc/ldsoutdefs.h
new file: inc/lineblt8defs.h
new file: inc/lisp2cdefs.h
modified: inc/lispemul.h
new file: inc/llcolordefs.h
new file: inc/llstkdefs.h
modified: inc/lnk-inlineC.h
new file: inc/loopsopsdefs.h
new file: inc/lowlev1defs.h
new file: inc/lowlev2defs.h
new file: inc/lsthandldefs.h
new file: inc/maindefs.h
new file: inc/misc7defs.h
new file: inc/miscndefs.h
new file: inc/mkatomdefs.h
new file: inc/mkcelldefs.h
new file: inc/mvsdefs.h
new file: inc/osmsgdefs.h
new file: inc/perrnodefs.h
new file: inc/returndefs.h
new file: inc/rpcdefs.h
new file: inc/rplconsdefs.h
new file: inc/shiftdefs.h
new file: inc/storagedefs.h
new file: inc/subr0374defs.h
new file: inc/subrdefs.h
new file: inc/sxhashdefs.h
new file: inc/testtooldefs.h
new file: inc/timerdefs.h
new file: inc/typeofdefs.h
new file: inc/ubf1defs.h
new file: inc/ubf2defs.h
new file: inc/ubf3defs.h
new file: inc/ufsdefs.h
new file: inc/unixcommdefs.h
new file: inc/unwinddefs.h
new file: inc/uraiddefs.h
new file: inc/usrsubrdefs.h
new file: inc/uutilsdefs.h
new file: inc/vars3defs.h
new file: inc/vmemsavedefs.h
new file: inc/xbbtdefs.h
new file: inc/xcdefs.h
new file: inc/xcursordefs.h
new file: inc/xinitdefs.h
new file: inc/xlspwindefs.h
new file: inc/xmkicondefs.h
new file: inc/xrdoptdefs.h
new file: inc/xscrolldefs.h
new file: inc/xwinmandefs.h
new file: inc/z2defs.h
modified: src/allocmds.c
modified: src/arith2.c
modified: src/arith3.c
modified: src/arith4.c
modified: src/array.c
modified: src/array2.c
modified: src/array3.c
modified: src/array4.c
modified: src/array5.c
modified: src/array6.c
modified: src/bbtsub.c
modified: src/bin.c
modified: src/binds.c
modified: src/bitblt.c
modified: src/blt.c
modified: src/byteswap.c
modified: src/car-cdr.c
modified: src/chardev.c
modified: src/common.c
modified: src/conspage.c
modified: src/dbgtool.c
modified: src/dir.c
modified: src/draw.c
modified: src/dsk.c
modified: src/dspif.c
modified: src/dspsubrs.c
modified: src/eqf.c
modified: src/ether.c
modified: src/findkey.c
modified: src/foreign.c
modified: src/fp.c
modified: src/fvar.c
modified: src/gc.c
modified: src/gc2.c
modified: src/gcarray.c
modified: src/gccode.c
modified: src/gcfinal.c
modified: src/gchtfind.c
modified: src/gcmain3.c
modified: src/gcoflow.c
modified: src/gcr.c
modified: src/gcrcell.c
modified: src/gcscan.c
modified: src/gvar2.c
modified: src/hacks.c
modified: src/hardrtn.c
modified: src/inet.c
modified: src/initdsp.c
modified: src/initkbd.c
modified: src/initsout.c
modified: src/intcall.c
modified: src/kbdsubrs.c
modified: src/keyevent.c
modified: src/keylib.c
modified: src/kprint.c
modified: src/ldsout.c
modified: src/lineblt8.c
modified: src/lisp2c.c
modified: src/llcolor.c
modified: src/llstk.c
modified: src/loopsops.c
modified: src/lowlev1.c
modified: src/lowlev2.c
modified: src/lsthandl.c
modified: src/main.c
modified: src/misc7.c
modified: src/miscn.c
modified: src/mkatom.c
modified: src/mkcell.c
modified: src/mvs.c
modified: src/osmsg.c
modified: src/perrno.c
modified: src/return.c
modified: src/rpc.c
modified: src/rplcons.c
modified: src/setsout.c
modified: src/shift.c
modified: src/storage.c
modified: src/subr.c
modified: src/subr0374.c
modified: src/sxhash.c
modified: src/testtool.c
modified: src/timer.c
modified: src/truecolor.c
modified: src/tstsout.c
modified: src/typeof.c
modified: src/ubf1.c
modified: src/ubf2.c
modified: src/ubf3.c
modified: src/ufn.c
modified: src/ufs.c
modified: src/unixcomm.c
modified: src/unwind.c
modified: src/uraid.c
modified: src/usrsubr.c
modified: src/uutils.c
modified: src/vars3.c
modified: src/vmemsave.c
modified: src/xbbt.c
modified: src/xc.c
modified: src/xcursor.c
modified: src/xinit.c
modified: src/xlspwin.c
modified: src/xmkicon.c
modified: src/xrdopt.c
modified: src/xscroll.c
modified: src/xwinman.c
modified: src/z2.c
400 lines
12 KiB
C
400 lines
12 KiB
C
/* $Id: storage.c,v 1.5 2001/12/26 22:17:04 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved
|
|
*/
|
|
static const char *id =
|
|
"$Id: storage.c,v 1.5 2001/12/26 22:17:04 sybalsky Exp $ Copyright (C) Venue";
|
|
|
|
/************************************************************************/
|
|
/* */
|
|
/* (C) Copyright 1989-94 Venue. All Rights Reserved. */
|
|
/* Manufactured in the United States of America. */
|
|
/* */
|
|
/************************************************************************/
|
|
|
|
#include "version.h"
|
|
|
|
/*****************************************************************/
|
|
/*
|
|
File Name : storage.c
|
|
|
|
*/
|
|
/*****************************************************************/
|
|
#include <stdio.h> /* for printf */
|
|
#include "hdw_conf.h"
|
|
#include "lispemul.h"
|
|
#include "address.h"
|
|
#include "adr68k.h"
|
|
#include "lispmap.h"
|
|
#include "stack.h"
|
|
#include "lspglob.h"
|
|
#include "cell.h"
|
|
#include "lsptypes.h"
|
|
#include "ifpage.h"
|
|
#include "gc.h"
|
|
|
|
#include "storagedefs.h"
|
|
#include "car-cdrdefs.h"
|
|
#include "commondefs.h"
|
|
#include "conspagedefs.h"
|
|
#include "gcfinaldefs.h"
|
|
#include "gchtfinddefs.h"
|
|
#include "mkatomdefs.h"
|
|
|
|
#define MINARRAYBLOCKSIZE 4
|
|
#define GUARDVMEMFULL 500
|
|
#define IFPVALID_KEY 5603
|
|
|
|
static void advance_array_seg(register unsigned int nxtpage);
|
|
static void advance_storagestate(DLword flg);
|
|
static void set_storage_state(void);
|
|
|
|
/*****************************************************************/
|
|
/*
|
|
Func Name : checkfor_storagefull(npages)
|
|
|
|
Created : Oct. 7, 1987 Takeshi Shimizu
|
|
Changed : Oct. 12,1987 take
|
|
|
|
Used to be LispPTR T/NIL return, but result never used
|
|
*/
|
|
/*****************************************************************/
|
|
|
|
void checkfor_storagefull(register unsigned int npages) {
|
|
register int pagesleft;
|
|
register INTSTAT *int_state;
|
|
|
|
#ifdef BIGVM
|
|
pagesleft = (*Next_MDSpage_word) - (*Next_Array_word) - PAGESPER_MDSUNIT;
|
|
#else
|
|
pagesleft = (*Next_MDSpage_word & 0xffff) - (*Next_Array_word & 0xffff) - PAGESPER_MDSUNIT;
|
|
#endif
|
|
|
|
if ((pagesleft < GUARDSTORAGEFULL) || (npages != 0)) {
|
|
if (*STORAGEFULLSTATE_word == NIL) set_storage_state();
|
|
|
|
switch (*STORAGEFULLSTATE_word & 0xffff) {
|
|
case SFS_NOTSWITCHABLE:
|
|
case SFS_FULLYSWITCHED:
|
|
if (pagesleft < 0) {
|
|
while (T) { error("MP9320:Storage completly full"); }
|
|
} else if ((pagesleft <= GUARD1STORAGEFULL) && (*STORAGEFULL_word != NIL)) {
|
|
*STORAGEFULL_word = S_POSITIVE;
|
|
error(
|
|
"MP9325:Space getting VERY full.\
|
|
Please save and reload a.s.a.p.");
|
|
} else if (*STORAGEFULL_word == NIL) {
|
|
*STORAGEFULL_word = ATOM_T;
|
|
int_state = (INTSTAT *)Addr68k_from_LADDR(*INTERRUPTSTATE_word);
|
|
int_state->storagefull = T;
|
|
*PENDINGINTERRUPT_word = ATOM_T;
|
|
}
|
|
#ifdef DEBUG
|
|
printf("\n checkfor_storagefull:DORECLAIM.....\n");
|
|
#endif
|
|
return; /*(NIL); */
|
|
|
|
break;
|
|
|
|
case SFS_SWITCHABLE:
|
|
if (npages == NIL) {
|
|
if (pagesleft <= 0) {
|
|
*LeastMDSPage_word = *Next_Array_word;
|
|
*Next_MDSpage_word = *SecondMDSPage_word;
|
|
advance_storagestate(SFS_FULLYSWITCHED);
|
|
advance_array_seg(*SecondArrayPage_word);
|
|
return;
|
|
}
|
|
} else if (npages > pagesleft) {
|
|
/* Have to switch array space over,
|
|
but leave MDS to fill the rest of the low pages */
|
|
*LeastMDSPage_word = *Next_Array_word;
|
|
advance_storagestate(SFS_ARRAYSWITCHED);
|
|
advance_array_seg(*SecondArrayPage_word);
|
|
return;
|
|
}
|
|
break;
|
|
#ifdef BIGVM
|
|
case SFS_ARRAYSWITCHED:
|
|
if ((*Next_MDSpage_word) < (*LeastMDSPage_word))
|
|
#else
|
|
case SFS_ARRAYSWITCHED:
|
|
if ((*Next_MDSpage_word & 0xffff) < (*LeastMDSPage_word & 0xffff))
|
|
#endif
|
|
{
|
|
*Next_MDSpage_word = *SecondMDSPage_word;
|
|
advance_storagestate(SFS_FULLYSWITCHED);
|
|
return;
|
|
} else if (npages != NIL)
|
|
if ((npages + GUARDSTORAGEFULL) >=
|
|
#ifdef BIGVM
|
|
((*SecondMDSPage_word) - (*Next_Array_word)))
|
|
#else
|
|
((*SecondMDSPage_word & 0xffff) - (*Next_Array_word & 0xffff)))
|
|
#endif
|
|
return; /* (NIL); */
|
|
return; /* (T); */
|
|
/* break; */
|
|
|
|
default:
|
|
error("checkfor_storagefull: Shouldn't"); /* (*STORAGEFULLSTATE_word) & 0xffff) */
|
|
break;
|
|
}
|
|
} else
|
|
return; /*(NIL); */
|
|
} /* checkfor_storagefull end */
|
|
|
|
/*****************************************************************/
|
|
/*
|
|
Func Name : advance_array_seg(nxtpage)
|
|
|
|
Created : Oct. 7, 1987 Takeshi Shimizu
|
|
Changed :
|
|
|
|
*/
|
|
/*****************************************************************/
|
|
|
|
static void advance_array_seg(register unsigned int nxtpage)
|
|
/* rare page num */
|
|
{
|
|
unsigned int ncellsleft;
|
|
LispPTR mergebackward(LispPTR base);
|
|
LispPTR makefreearrayblock(LispPTR block, DLword length);
|
|
|
|
/* Called when 8Mb are exhausted,and we want to switch array space
|
|
into the extended area(Secondary space),starting with nextpage.
|
|
We MUST clean up old area first. */
|
|
|
|
#ifdef BIGVM
|
|
nxtpage &= 0xFFFFF; /* new VM, limit is 20 bits of page */
|
|
#else
|
|
nxtpage &= 0xFFFF; /* for old VM size, limit is 16 bits of page */
|
|
#endif
|
|
|
|
ncellsleft = (*Next_Array_word - POINTER_PAGE(*ArrayFrLst_word) - 1) * CELLSPER_PAGE +
|
|
(CELLSPER_PAGE - (((*ArrayFrLst_word) & 0xff) >> 1));
|
|
|
|
if (ncellsleft >= MINARRAYBLOCKSIZE) {
|
|
mergebackward(makefreearrayblock(*ArrayFrLst_word, ncellsleft));
|
|
#ifdef BIGVM
|
|
*ArrayFrLst2_word = (((*LeastMDSPage_word)) << 8);
|
|
#else
|
|
*ArrayFrLst2_word = (((*LeastMDSPage_word) & 0xffff) << 8);
|
|
#endif
|
|
} else {
|
|
*ArrayFrLst2_word = *ArrayFrLst_word;
|
|
}
|
|
#ifdef BIGVM
|
|
*Next_Array_word = nxtpage;
|
|
#else
|
|
*Next_Array_word = S_POSITIVE | nxtpage;
|
|
#endif
|
|
*ArrayFrLst_word = nxtpage << 8;
|
|
*ArraySpace2_word = *ArrayFrLst_word;
|
|
|
|
/* return(S_POSITIVE); making function void as result never used */
|
|
|
|
} /* advance_array_seg end */
|
|
|
|
/*****************************************************************/
|
|
/*
|
|
Func Name : advance_storagestate(flg)
|
|
|
|
Created : Oct. 7, 1987 Takeshi Shimizu
|
|
Changed :
|
|
|
|
*/
|
|
/*****************************************************************/
|
|
|
|
/* DLword */
|
|
static void advance_storagestate(DLword flg) {
|
|
LispPTR dremove(LispPTR x, LispPTR l);
|
|
#ifdef DEBUG
|
|
printf("STORAGEFULLSTATE is now set to %d \n", flg);
|
|
#endif
|
|
|
|
*STORAGEFULLSTATE_word = (S_POSITIVE | flg);
|
|
InterfacePage->fullspaceused = 65535;
|
|
*SYSTEMCACHEVARS_word = dremove(STORAGEFULLSTATE_index, *SYSTEMCACHEVARS_word);
|
|
}
|
|
|
|
/*****************************************************************/
|
|
/*
|
|
Func Name : set_storage_state()
|
|
|
|
Created : Oct. 7, 1987 Takeshi Shimizu
|
|
Changed :
|
|
|
|
*/
|
|
/*****************************************************************/
|
|
static void set_storage_state(void) {
|
|
LispPTR cons(LispPTR cons_car, LispPTR cons_cdr);
|
|
|
|
if ((*MACHINETYPE_word & 0xffff) == KATANA) {
|
|
if (InterfacePage->dl24bitaddressable != 0)
|
|
*STORAGEFULLSTATE_word = S_POSITIVE | SFS_SWITCHABLE;
|
|
else
|
|
*STORAGEFULLSTATE_word = S_POSITIVE | SFS_NOTSWITCHABLE;
|
|
|
|
*SYSTEMCACHEVARS_word = cons(STORAGEFULLSTATE_index, *SYSTEMCACHEVARS_word);
|
|
|
|
GCLOOKUP(*SYSTEMCACHEVARS_word, ADDREF);
|
|
|
|
#ifdef DEBUG
|
|
printf("SETSTATE: set to %d \n", (*STORAGEFULLSTATE_word) & 0xffff);
|
|
#endif
|
|
} else {
|
|
error("set_storage_state: Sorry! We can work on only KATANA");
|
|
}
|
|
|
|
} /* set_storage_state() end */
|
|
|
|
LispPTR dremove(LispPTR x, LispPTR l) {
|
|
LispPTR z;
|
|
|
|
if (Listp(l) == NIL)
|
|
return (NIL);
|
|
else if (x == car(l)) {
|
|
if (cdr(l) != NIL) {
|
|
rplaca(l, car(cdr(l)));
|
|
rplacd(l, cdr(cdr(l)));
|
|
return (dremove(x, l));
|
|
}
|
|
} else {
|
|
z = l;
|
|
lp:
|
|
if (Listp(cdr(l)) == NIL)
|
|
return (z);
|
|
else if (x == car(cdr(l)))
|
|
rplacd(l, cdr(cdr(l)));
|
|
else
|
|
l = cdr(l);
|
|
goto lp;
|
|
}
|
|
}
|
|
|
|
/*****************************************************************/
|
|
/*
|
|
Func Name : newpage(addr)
|
|
|
|
Created : Oct. 12, 1987 Takeshi Shimizu
|
|
Changed : Oct. 13, 1987 take
|
|
OCt. 20, 1987 take
|
|
|
|
*/
|
|
/*****************************************************************/
|
|
LispPTR newpage(LispPTR base) {
|
|
#ifdef BIGVM
|
|
register unsigned int vp; /* Virtual Page we're creating */
|
|
#else
|
|
register DLword vp; /* (built from base) */
|
|
#endif /* BIGVM */
|
|
|
|
register INTSTAT *int_state;
|
|
|
|
extern LispPTR *LASTVMEMFILEPAGE_word;
|
|
extern LispPTR *VMEM_FULL_STATE_word;
|
|
unsigned int nactive;
|
|
|
|
vp = base >> 8; /* Compute virtual-page # from Lisp address of the page */
|
|
|
|
#ifdef DEBUG
|
|
/************************/
|
|
if (vp == 0) error("newpage: vp=0");
|
|
printf("***newpage modify vmemsize %d ", InterfacePage->nactivepages);
|
|
/*************************/
|
|
#endif
|
|
nactive = ++(InterfacePage->nactivepages);
|
|
|
|
/* if nactive is a multiple of the # of FPTOVP entries */
|
|
/* on a page, we need to create a new FPTOVP page. */
|
|
#ifdef BIGVM
|
|
if ((nactive & 127) == 0) /* in BIGVM, they're cells */
|
|
#else
|
|
if ((nactive & 0xff) == 0) /* in old way, they're words */
|
|
#endif /* BIGVM */
|
|
{ /* need to add virtual page for fptovp first */
|
|
unsigned int vp_of_fp, fp_of_fptovp;
|
|
|
|
/* compute virtual page of new FPtoVP table page */
|
|
/* i.e., the vp that holds the next FPtoVP entry */
|
|
vp_of_fp = (LADDR_from_68k(FPtoVP + nactive) >> 8);
|
|
|
|
/* compute file page where this entry has to be to ensure
|
|
that FPtoVP is contiguous on the file */
|
|
|
|
fp_of_fptovp = InterfacePage->fptovpstart + (vp_of_fp - (LADDR_from_68k(FPtoVP) >> 8));
|
|
|
|
/* debugging check: make sure FPtoVP is contiguous */
|
|
|
|
if (GETFPTOVP(FPtoVP, fp_of_fptovp - 1) != vp_of_fp - 1) {
|
|
printf("FPtoVP not contiguous\n");
|
|
printf("vp_of_fp = 0x%x, fp = 0x%x\n", vp_of_fp, fp_of_fptovp);
|
|
printf("FPTOVP(fp-1) = 0x%x.\n", GETFPTOVP(FPtoVP, fp_of_fptovp - 1));
|
|
}
|
|
|
|
/* move the file page for the previous VMEM page */
|
|
GETFPTOVP(FPtoVP, nactive) = GETFPTOVP(FPtoVP, fp_of_fptovp);
|
|
|
|
/* now, store virtual page of FPtoVP in FPtoVP table */
|
|
|
|
GETFPTOVP(FPtoVP, fp_of_fptovp) = (vp_of_fp);
|
|
|
|
/* now we can make room for the new page we're adding */
|
|
nactive = ++(InterfacePage->nactivepages);
|
|
}
|
|
GETFPTOVP(FPtoVP, nactive) = vp;
|
|
|
|
#ifdef DEBUG
|
|
/*************************/
|
|
printf("to %d with VP:%d \n", InterfacePage->nactivepages, vp);
|
|
/************************/
|
|
#endif
|
|
|
|
if (InterfacePage->nactivepages >
|
|
#ifdef BIGVM
|
|
(((*LASTVMEMFILEPAGE_word)) - GUARDVMEMFULL))
|
|
#else
|
|
(((*LASTVMEMFILEPAGE_word) & 0xffff) - GUARDVMEMFULL))
|
|
#endif
|
|
{
|
|
/* set vmemfull state */
|
|
if (*VMEM_FULL_STATE_word == NIL) {
|
|
int_state = (INTSTAT *)Addr68k_from_LADDR(*INTERRUPTSTATE_word);
|
|
int_state->vmemfull = T;
|
|
*PENDINGINTERRUPT_word = ATOM_T;
|
|
}
|
|
#ifdef BIGVM
|
|
if (InterfacePage->nactivepages < ((*LASTVMEMFILEPAGE_word)))
|
|
#else
|
|
if (InterfacePage->nactivepages < ((*LASTVMEMFILEPAGE_word) & 0xffff))
|
|
#endif
|
|
{
|
|
*VMEM_FULL_STATE_word = S_POSITIVE; /* set 0 */
|
|
} else if (InterfacePage->key == IFPVALID_KEY) {
|
|
*VMEM_FULL_STATE_word = ATOM_T;
|
|
} else
|
|
*VMEM_FULL_STATE_word = make_atom("DIRTY", 0, 5, 0);
|
|
}
|
|
|
|
return (base);
|
|
|
|
} /* newpage */
|
|
|
|
/*****************************************************************/
|
|
/*
|
|
Func Name : init_storage()
|
|
Description:
|
|
Set values which are referenced by
|
|
Lisp Storage handling funcs
|
|
|
|
Created : Apr-23 1990 Takeshi Shimizu
|
|
Changed :
|
|
*/
|
|
/*****************************************************************/
|
|
void init_storage(void) {
|
|
#ifdef BIGVM
|
|
*SecondMDSPage_word = (InterfacePage->dllastvmempage - PAGESPER_MDSUNIT - 1);
|
|
#else
|
|
*SecondMDSPage_word = S_POSITIVE | (InterfacePage->dllastvmempage - PAGESPER_MDSUNIT - 1);
|
|
#endif
|
|
} /* init_storage */
|