]> 4ch.mooo.com Git - 16.git/blobdiff - src/lib/16_mm.h
started to work on mm libery~
[16.git] / src / lib / 16_mm.h
index e864d042fb990d4916ac66346343224dcd2bfa5e..701f002de627324a2dae2d84e5c01e594cbb2294 100644 (file)
 #include <string.h>
 #include <malloc.h>
 #include "src/lib/lib_head.h"
-#include "src/lib/16_in.h"
+//++++mh       #include "src/lib/16_in.h"
 
-#if 1          // 1 == Debug/Dev  ;  0 == Production/final
+//****#if 1            // 1 == Debug/Dev  ;  0 == Production/final
 #define OUT_OF_MEM_MSG "MM_GetPtr: Out of memory!\nYou were short :%ld bytes"
-#else
-#define OUT_OF_MEM_MSG "\npee\n"
-#endif
+//****#else
+//****#define OUT_OF_MEM_MSG   "\npee\n"
+//****#endif
 
 
 #define SAVENEARHEAP   0x400           // space to leave in data segment
 #define        XMS_FREEUMB             0x11
 
 //==========================================================================
-
-typedef void /*_seg*/ * memptr;
+//__segment                seg;
+typedef void __based(__self) * memptr; //__based(seg) * memptr;
 
 typedef struct
 {
-       long    nearheap,farheap,EMSmem,XMSmem,mainmem;
+       dword   nearheap,farheap,EMSmem,XMSmem,mainmem;
+       boolean         mmstarted, bombonerror, mmerror;
 } mminfotype;
 
 //==========================================================================
 
-extern mminfotype      mminfo;
+/*extern       mminfotype      mminfo;
 extern memptr          bufferseg;
 extern boolean         mmerror;
 
 extern void            (* beforesort) (void);
-extern void            (* aftersort) (void);
+extern void            (* aftersort) (void);*/
+
+//==========================================================================
+
+/*
+=============================================================================
+
+                                                       LOCAL INFO
+
+=============================================================================
+*/
+
+#define LOCKBIT                0x80    // if set in attributes, block cannot be moved
+#define PURGEBITS      3               // 0-3 level, 0= unpurgable, 3= purge first
+#define PURGEMASK      0xfffc
+#define BASEATTRIBUTES 0       // unlocked, non purgable
+
+#define MAXUMBS                10
+
+typedef struct mmblockstruct
+{
+       unsigned        start,length;
+       unsigned        attributes;
+       memptr          *useptr;        // pointer to the segment start
+       struct mmblockstruct far *next;
+} mmblocktype;
+
+
+//#define GETNEWBLOCK {if(!(mmnew=mmfree))Quit("MM_GETNEWBLOCK: No free blocks!");mmfree=mmfree->next;}
+#define GETNEWBLOCK {if(!mmfree)MML_ClearBlock();mmnew=mmfree;mmfree=mmfree->next;}
+#define FREEBLOCK(x) {*x->useptr=NULL;x->next=mmfree;mmfree=x;}
+
+/*
+=============================================================================
+
+                                                GLOBAL VARIABLES
+
+=============================================================================
+*/
+
+/*static mminfotype    mminfo;
+static memptr          bufferseg;
+
+static void            (* beforesort) (void);
+static void            (* aftersort) (void);*/
+
+/*
+=============================================================================
+
+                                                LOCAL VARIABLES
+
+=============================================================================
+*/
+
+/*static void huge     *hugeheap;
+static void far        *farheap;
+static void            *nearheap;
+
+static mmblocktype     far mmblocks[MAXBLOCKS]
+                       ,far *mmhead,far *mmfree,far *mmrover,far *mmnew;
+
+
+static unsigned        totalEMSpages,freeEMSpages,EMSpageframe,EMSpagesmapped,EMShandle;
+static unsigned int EMSVer;
+
+static void            (* XMSaddr) (void);             // far pointer to XMS driver
+
+static unsigned        numUMBs,UMBbase[MAXUMBS];*/
 
 //==========================================================================
 
@@ -111,8 +179,10 @@ void MM_SortMem (void);
 
 void MM_ShowMemory (void);
 
-long MM_UnusedMemory (void);
-long MM_TotalFree (void);
+dword MM_UnusedMemory (void);
+dword MM_TotalFree (void);
+void MM_Report(void);
+//int MM_EMSVer(void);
 
 void MM_BombOnError (boolean bomb);
 
@@ -130,6 +200,8 @@ void                MML_ShutdownXMS (void);
 void           MML_UseSpace (unsigned segstart, unsigned seglength);
 void           MML_ClearBlock (void);
 
+int US_CheckParm(char *parm,char **strings);
+
 //==========================================================================
 
 #endif