mov [freeEMSpages],bx
or bx,bx
jz noEMS // no EMS at all to allocate
-
+ //EXPAND DONG!!!!
+ cmp [EMSVer],0x40
+ jb low
+ cmp bx,[freeEMSpages]
+ jle getpages
+ mov bx,[freeEMSpages]
+ jmp getpages
+
+low:
cmp bx,4
jle getpages // there is only 1,2,3,or 4 pages
mov bx,4 // we can't use more than 4 pages
mov ah,XMS_ALLOCUMB
mov dx,0xffff // try for largest block possible
+ //mov ax,dx // Set available Kbytes.
call [DWORD PTR XMSaddr]
or ax,ax
jnz gotone
mov [size],dx
done:
}
+ printf("base=%u ", base); printf("size=%u\n", size);
MML_UseSpace(base,size, mm);
mmi->XMSmem += size*16;
mm->UMBbase[mm->numUMBs] = base;
======================
*/
-void MML_UseSpace(unsigned segstart, dword seglength, mminfo_t *mm)
+void MML_UseSpace(/*d*/word segstart, dword seglength, mminfo_t *mm)
{
mmblocktype huge *scan,huge *last;
- unsigned oldend;
- //++++if(mm->EMSVer)
+ dword oldend;
+ ///*d*/word fat=0;
dword extra;
scan = last = mm->mmhead;
mm->mmrover = mm->mmhead; // reset rover to start of memory
+ scan->segm=1;
+ scan->segmlen=seglength;
//
// search for the block that contains the range of segments
scan = scan->next;
}
+ //find out how many blocks it span!
+ if(seglength>0xfffflu)
+ {
+ scan->segm=seglength/0xfffflu;
+ }
+
//
// take the given range out of the block
//
oldend = scan->start + scan->length;
extra = oldend - (segstart+seglength);
//++++emsver stuff!
- if(extra > 0xfffflu)
+ if(extra>0xfffflu)
{
- printf("MML_UseSpace: Segment spans two blocks!\n");
- //return;
+ /*__asm
+ {
+ push ds
+ mov ax,ds
+ inc ax
+ mov ds,ax
+ }*/
+printf("segm=%u ", scan->segm);
+printf("ex=%lu ", extra);
+printf("len=%u ", scan->length);
+printf("segsta=%u ", segstart);
+printf("seglen=%lu\n", seglength);
+
+//MML_UseSpace(?segstart?, ?length?, mm);
+
+ /*__asm
+ {
+ pop ds
+ }*/
+ //printf("MML_UseSpace: Segment spans two blocks!\n");
}
-
+//segu:
+//++++todo: linked list of segment!
+//printf("segm=%lu\n", segm);
if(segstart == scan->start)
{
last->next = scan->next; // unlink block
else
scan->length = segstart-scan->start; // shorten block
- if(0xfffflu > extra > 0)
+// segm--;
+
+ if(extra > 0)
{
MM_GetNewBlock(mm);
mm->mmnew->next = scan->next;
mm->mmnew->start = segstart+seglength;
mm->mmnew->length = extra;
mm->mmnew->attributes = LOCKBIT;
- }
+ }//else if(segm>0) goto segu;
}
scan = scan->next;
}
- printf("MM_ClearBlock: No purgable blocks!");
+ printf("MM_ClearBlock: No purgable blocks!\n");
}
_fheapgrow();
length=_memavl();
//length-=farlen;
- start = mm->farheap = halloc(length, sizeof(length));
+ start = mm->farheap = halloc(length, sizeof(dword));
//start = mm->farheap = _fmalloc(length);
length -= 16-(FP_OFF(start)&15);
length -= SAVEFARHEAP;
//
// detect EMS and allocate up to 64K at page frame
//
+ printf("EMS!\n\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"); //bug!
mmi->EMSmem = 0;
for(i = 1;i < __argc;i++)
{
MML_SetupEMS(mm); // allocate space
printf("\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"); //bug!
//TODO: EMS4! AND EMS 3.2 MASSIVE DATA HANDLMENT!
- if(mm->EMSVer>=0x40) MML_UseSpace(mm->EMSpageframe,((dword)mm->EMSpagesmapped)*((dword)mm->freeEMSpages), mm);
- else MML_UseSpace(mm->EMSpageframe,mm->EMSpagesmapped*0x400, mm);
+ MML_UseSpace(mm->EMSpageframe,(/*++++mm->EMSpagesmapped++++*/4)*0x4000lu, mm);
//printf("EMS3\n");
MM_MapEMS(mm); // map in used pages
//printf("EMS4\n");
- if(mm->EMSVer>=0x40) mmi->EMSmem = ((dword)mm->EMSpagesmapped)*((dword)mm->freeEMSpages);
- else mmi->EMSmem = mm->EMSpagesmapped*0x4000l;
+ mmi->EMSmem = (/*++++mm->EMSpagesmapped++++*/4)*0x4000lu;
}
//
// printf("\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"); //bug!
if(MML_CheckForXMS(mm))
{
-//printf("XMS!\n");
- MML_SetupXMS(mm, mmi); // allocate as many UMBs as possible
+ printf("XMS!\n");
+ //++++++++MML_SetupXMS(mm, mmi); // allocate as many UMBs as possible
}
//
mmblocktype huge *scan;
unsigned color,temp;//, i;
long end,owner;
- char scratch[80],str[10];
+ char scratch[160],str[16];
//**** VW_SetDefaultColors();
//**** VW_SetLineWidth(40);
//CA_OpenDebug ();
- while (scan)
+ while(scan)
{
if(scan->attributes & PURGEBITS)
color = 5; // dark purple = purgable
color = 12; // red = locked
if(scan->start<=end)
{
- printf("MM_ShowMemory: Memory block order currupted!");
+ printf("\nMM_ShowMemory: Memory block order currupted!\n");
return;
}
end = scan->start+scan->length-1;
//++++ VW_Hlin(end+1,scan->next->start,0,0); // black = free
//****#if 0
-printf("Location:");
-printf("%x\t", scan->start);
-strcpy (scratch,"Size:");
+printf("\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"); //bug!
+strcpy(scratch,"Location:");
+ultoa (scan->start,str,16);
+strcat (scratch,str);
+strcat (scratch,"\tSize:");
ltoa ((dword)scan->length*16,str,10);
strcat (scratch,str);
strcat (scratch,"\tOwner:0x");
dword MM_UnusedMemory(mminfo_t *mm)
{
- unsigned free;
+ dword free;
mmblocktype huge *scan;
free = 0;
dword MM_TotalFree(mminfo_t *mm)
{
- unsigned free;
+ dword free;
mmblocktype huge *scan;
free = 0;
printf("freeEMSpages=%u\n", mm->freeEMSpages);
printf("EMSpageframe=%x\n", mm->EMSpageframe);
}
- if(MML_CheckForXMS(mm)) printf("XMSaddr=%x\n", *XMSaddr);
+ if(MML_CheckForXMS(mm)) printf("XMSaddr=%Fp\n", *XMSaddr);
printf("near=%lu\n", mmi->nearheap);
printf("far=%lu\n", mmi->farheap);
printf("EMSmem=%lu\n", mmi->EMSmem);
x->next=mm->mmfree;
mm->mmfree=x;
}
+
+void MM_seguin(void)
+{
+ __asm
+ {
+ push ds
+ mov ax,ds
+ inc ax
+ mov ds,ax
+ }
+}
+
+void MM_segude(void)
+{
+ __asm
+ {
+ pop ds
+ }
+}
+
+/*
+pull data from far and put it into ds var
+mov ax,es:si
+mov x,ax
+*/
+/*
+ss stack segment
+sp top of stack
+bp bottem of stack
+*/