X-Git-Url: http://4ch.mooo.com/gitweb/?a=blobdiff_plain;f=src%2Flib%2F16_mm.c;h=524d7ae53892768a0012249766823faea0c689c2;hb=b74047609032f3e2c97d7afca3c63177005c5366;hp=a65c193f02c68b7335d0e20efc9077a74ae92ca5;hpb=7a43fe6b5c20dfd0e15b121a87d0bea1f6763de9;p=16.git diff --git a/src/lib/16_mm.c b/src/lib/16_mm.c index a65c193f..524d7ae5 100644 --- a/src/lib/16_mm.c +++ b/src/lib/16_mm.c @@ -270,7 +270,7 @@ unsigned MM_MapEMS(mminfo_t *mm) union REGS CPURegs; EMShandle=mm->EMShandle; - for (i=0;iEMSpagesmapped;i++) + for (i=0;i<4/*mm->EMSpagesmapped*/;i++) { __asm { @@ -292,13 +292,44 @@ unsigned MM_MapEMS(mminfo_t *mm) strcpy(str,"MM_MapEMS: EMS error 0x"); itoa(err,str2,16); strcpy(str,str2); - printf("%s\n",str); + //printf("%s\n",str); + printf("FACK! %u\n", err); return err; } } return 0; } +/* +SUB EMS.MapXPages (PhysicalStart, LogicalStart, NumPages, Handle) + + 'Maps up to 4 logical EMS pages to physical pages in the page frame, where: + ' + 'PhysicalStart = Physical page first logical page is mapped to + 'LogicalStart = First logical page to map + 'NumPages = Number of pages to map (1 to 4) + 'Handle = EMS handle logical pages are allocated to + + 'Create a buffer containing the page information + FOR x = 0 TO NumPages - 1 + MapInfo$ = MapInfo$ + MKI$(LogicalStart + x) + MKI$(PhysicalStart + x) + NEXT + + Regs.ax = &H5000 'Map the pages in the buffer + Regs.cx = NumPages 'to the pageframe + Regs.dx = Handle + Regs.ds = VARSEG(MapInfo$) + Regs.si = SADD(MapInfo$) + InterruptX &H67, Regs, Regs + EMS.Error = (Regs.ax AND &HFF00&) \ &H100 'Store the status code + +END SUB +*/ +void MM_MapXEMS(mminfo_t *mm) +{ + +} + //========================================================================== /* @@ -448,11 +479,6 @@ void MML_UseSpace(/*d*/word segstart, dword seglength, mminfo_t *mm) } else segm=1; -// -// take the given range out of the block -// - oldend = scan->start + scan->length; - extra = oldend - (segstart+seglength); //++++emsver stuff! if(segm>1/*extra>0xfffflu*/) { @@ -463,12 +489,7 @@ void MML_UseSpace(/*d*/word segstart, dword seglength, mminfo_t *mm) inc ax mov ds,ax }*/ -printf("segm=%u ", segm); -printf("ex=%lu ", extra); -printf("start+seglen=%lu ", segstart+seglength); -printf("len=%u ", scan->length); -printf("segsta=%x ", segstart); -printf("seglen=%lu\n", seglength); + //MML_UseSpace(?segstart?, ?length?, mm); @@ -479,6 +500,19 @@ printf("seglen=%lu\n", seglength); //printf("MML_UseSpace: Segment spans two blocks!\n"); } +// +// take the given range out of the block +// + oldend = scan->start + scan->length; + extra = oldend - (segstart+seglength); + +printf("segm=%u ", segm); +printf("ex=%lu ", extra); +printf("start+seglen=%lu ", segstart+seglength); +printf("len=%u ", scan->length); +printf("segsta=%x ", segstart); +printf("seglen=%lu\n", seglength); + //segu: //++++todo: linked list of segment! //printf("segm=%lu\n", segm); @@ -632,15 +666,16 @@ void MM_Startup(mminfo_t *mm, mminfotype *mmi) 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_CheckForEMS()) { -//printf("EMS1\n"); +printf("EMS1\n"); MML_SetupEMS(mm); // allocate space +printf("EMS2\n"); 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! - MML_UseSpace(mm->EMSpageframe,(mm->EMSpagesmapped)*0x4000lu, mm); -//printf("EMS3\n"); + MML_UseSpace(mm->EMSpageframe,(MAPPAGES)*0x4000lu, mm); +printf("EMS3\n"); MM_MapEMS(mm); // map in used pages -//printf("EMS4\n"); - mmi->EMSmem = (mm->EMSpagesmapped)*0x4000lu; +printf("EMS4\n"); + mmi->EMSmem = (MAPPAGES)*0x4000lu; } // @@ -1035,11 +1070,12 @@ void MM_SortMem(mminfo_t *mm) ===================== */ -void MM_ShowMemory(mminfo_t *mm) +void MM_ShowMemory(page_t *page, mminfo_t *mm) { mmblocktype huge *scan; unsigned color,temp; long end,owner; + word chx,chy; char scratch[160],str[16]; //**** VW_SetDefaultColors(); @@ -1052,7 +1088,10 @@ void MM_ShowMemory(mminfo_t *mm) end = -1; -//CA_OpenDebug (); +CA_OpenDebug (); + + chx=0; + chy=0; while(scan) { @@ -1064,18 +1103,26 @@ void MM_ShowMemory(mminfo_t *mm) color = 12; // red = locked if(scan->start<=end) { - printf("\nMM_ShowMemory: Memory block order currupted!\n"); + //printf("); + write (debughandle,"\nMM_ShowMemory: Memory block order currupted!\n",strlen("\nMM_ShowMemory: Memory block order currupted!\n")); + //modexprint(&page, chx, chy, 1, 0, 24, "\nMM_ShowMemory: Memory block order currupted!\n"); return; } end = scan->start+scan->length-1; + modexhlin(page, scan->start, (unsigned)end, chy, color); //++++ VW_Hlin(scan->start,(unsigned)end,0,color); +//void VW_Plot(unsigned x, unsigned y, unsigned color); +//void VW_Hlin(unsigned xl, unsigned xh, unsigned y, unsigned color); + //++++ VW_Plot(scan->start,0,15); + modexputPixel(page, scan->start, chy, 15); if(scan->next->start > end+1) //++++ VW_Hlin(end+1,scan->next->start,0,0); // black = free + modexhlin(page, end+1,scan->next->start, chy, color); //****#if 0 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:"); +strcpy(scratch,"Seg:"); ultoa (scan->start,str,16); strcat (scratch,str); strcat (scratch,"\tSize:"); @@ -1086,14 +1133,16 @@ owner = (unsigned)scan->useptr; ultoa (owner,str,16); strcat (scratch,str); strcat (scratch,"\n"); -//++++write (debughandle,scratch,strlen(scratch)); -fprintf(stdout, "%s", scratch); +write(debughandle,scratch,strlen(scratch)); +//modexprint(page, chx, chy, 1, 0, 24, &scratch); +//chy+=4; +//fprintf(stdout, "%s", scratch); //****#endif scan = scan->next; } -//CA_CloseDebug (); +CA_CloseDebug (); //++++mh IN_Ack(); //**** VW_SetLineWidth(64); @@ -1101,6 +1150,72 @@ fprintf(stdout, "%s", scratch); } //****#endif +//========================================================================== + +/* +===================== += += MM_DumpData += +===================== +*/ + +void MM_DumpData(mminfo_t *mm) +{ + mmblocktype far *scan,far *best; + long lowest,oldlowest; + unsigned owner; + char lock,purge; + FILE *dumpfile; + + + free (mm->nearheap); + dumpfile = fopen ("mmdump.txt","w"); + if (!dumpfile){ + printf("MM_DumpData: Couldn't open MMDUMP.TXT!"); + return; + } + + lowest = -1; + do + { + oldlowest = lowest; + lowest = 0xffff; + + scan = mm->mmhead; + while (scan) + { + owner = (unsigned)scan->useptr; + + if (owner && owner oldlowest) + { + best = scan; + lowest = owner; + } + + scan = scan->next; + } + + if (lowest != 0xffff) + { + if (best->attributes & PURGEBITS) + purge = 'P'; + else + purge = '-'; + if (best->attributes & LOCKBIT) + lock = 'L'; + else + lock = '-'; + fprintf (dumpfile,"0x%p (%c%c) = %u\n" + ,(unsigned)lowest,lock,purge,best->length); + } + + } while (lowest != 0xffff); + + fclose (dumpfile); + printf("MMDUMP.TXT created."); +} + //========================================================================== @@ -1175,11 +1290,11 @@ dword MM_TotalFree(mminfo_t *mm) ===================== */ -void MM_Report(mminfo_t *mm, mminfotype *mmi) +void MM_Report(page_t *page, mminfo_t *mm, mminfotype *mmi) { if(MML_CheckForEMS()) { - printf("EMM %x available\n", mm->EMSVer); + printf("EMM v%x.%x available\n", mm->EMSVer>>4,mm->EMSVer&0x0F); printf("totalEMSpages=%u\n", mm->totalEMSpages); printf("freeEMSpages=%u\n", mm->freeEMSpages); printf("EMSpageframe=%x\n", mm->EMSpageframe);