update DOS_GetMemory() to carry with it a string to convey the purpose

of the allocation.
This commit is contained in:
Jonathan Campbell
2014-01-21 15:01:00 -08:00
parent 7857c9566b
commit 34aecc57cf
11 changed files with 36 additions and 32 deletions

View File

@@ -213,8 +213,8 @@ bool DOS_AllocateMemory(Bit16u * segment,Bit16u * blocks);
bool DOS_ResizeMemory(Bit16u segment,Bit16u * blocks);
bool DOS_FreeMemory(Bit16u segment);
void DOS_FreeProcessMemory(Bit16u pspseg);
Bit16u BIOS_GetMemory(Bit16u pages);
Bit16u DOS_GetMemory(Bit16u pages);
Bit16u BIOS_GetMemory(Bit16u pages,const char *who=NULL);
Bit16u DOS_GetMemory(Bit16u pages,const char *who=NULL);
bool DOS_SetMemAllocStrategy(Bit16u strat);
Bit16u DOS_GetMemAllocStrategy(void);
void DOS_BuildUMBChain(bool umb_active,bool ems_active);

View File

@@ -1437,14 +1437,14 @@ public:
fprintf(stderr,"Dynamic DOS kernel mode, structures will be allocated from pool 0x%04x-0x%04x\n",
DOS_PRIVATE_SEGMENT,DOS_PRIVATE_SEGMENT_END-1);
if (!mainline_compatible_mapping) DOS_IHSEG = DOS_GetMemory(1);
DOS_INFOBLOCK_SEG = DOS_GetMemory(0x20); // was 0x80
DOS_CONDRV_SEG = DOS_GetMemory(0x08); // was 0xA0
DOS_CONSTRING_SEG = DOS_GetMemory(0x0A); // was 0xA8
DOS_SDA_SEG = DOS_GetMemory(0x56); // was 0xB2 (0xB2 + 0x56 = 0x108)
if (!mainline_compatible_mapping) DOS_IHSEG = DOS_GetMemory(1,"DOS_IHSEG");
DOS_INFOBLOCK_SEG = DOS_GetMemory(0x20,"DOS_INFOBLOCK_SEG"); // was 0x80
DOS_CONDRV_SEG = DOS_GetMemory(0x08,"DOS_CONDRV_SEG"); // was 0xA0
DOS_CONSTRING_SEG = DOS_GetMemory(0x0A,"DOS_CONSTRING_SEG"); // was 0xA8
DOS_SDA_SEG = DOS_GetMemory(0x56,"DOS_SDA_SEG"); // was 0xB2 (0xB2 + 0x56 = 0x108)
DOS_SDA_OFS = 0;
DOS_CDS_SEG = DOS_GetMemory(0x10); // was 0x108
DOS_FIRST_SHELL = DOS_GetMemory(0x40); // was 0x118
DOS_CDS_SEG = DOS_GetMemory(0x10,"DOS_CDA_SEG"); // was 0x108
DOS_FIRST_SHELL = DOS_GetMemory(0x40,"DOS_FIRST_SHELL"); // was 0x118
/* defer DOS_MEM_START until right before SetupMemory */
}
else {
@@ -1527,7 +1527,7 @@ public:
* we then need to move the DOS private segment somewere else so that additional allocations do not
* corrupt the MCB chain */
if (dynamic_dos_kernel_alloc)
DOS_MEM_START = DOS_GetMemory(0); // was 0x158 (pass 0 to alloc nothing, get the pointer)
DOS_MEM_START = DOS_GetMemory(0,"DOS_MEM_START"); // was 0x158 (pass 0 to alloc nothing, get the pointer)
/* move the private segment elsewhere to avoid conflict with the MCB structure.
* either set to 0 to cause the decision making to choose an upper memory address,

View File

@@ -307,7 +307,7 @@ bool DOS_PSP::SetNumFiles(Bit16u fileNum) {
// Allocate needed paragraphs
fileNum+=2; // Add a few more files for safety
Bit16u para = (fileNum/16)+((fileNum%16)>0);
RealPt data = RealMake(DOS_GetMemory(para),0);
RealPt data = RealMake(DOS_GetMemory(para,"SetNumFiles data"),0);
sSave(sPSP,file_table,data);
sSave(sPSP,max_files,fileNum);
Bit16u i;

View File

@@ -323,7 +323,7 @@ int CMscdex::AddDrive(Bit16u _drive, char* physicalPath, Bit8u& subUnit)
Bit16u driverSize = sizeof(DOS_DeviceHeader::sDeviceHeader) + 10; // 10 = Bytes for 3 callbacks
// Create Device Header
Bit16u seg = DOS_GetMemory(driverSize/16+((driverSize%16)>0));
Bit16u seg = DOS_GetMemory(driverSize/16+((driverSize%16)>0),"MSCDEX device header");
DOS_DeviceHeader devHeader(PhysMake(seg,0));
devHeader.SetNextDeviceHeader (0xFFFFFFFF);
devHeader.SetAttribute(0xc800);
@@ -418,7 +418,7 @@ void CMscdex::ReplaceDrive(CDROM_Interface* newCdrom, Bit8u subUnit) {
PhysPt CMscdex::GetDefaultBuffer(void) {
if (defaultBufSeg==0) {
Bit16u size = (2352*2+15)/16;
defaultBufSeg = DOS_GetMemory(size);
defaultBufSeg = DOS_GetMemory(size,"MSCDEX default buffer");
};
return PhysMake(defaultBufSeg,2352);
}
@@ -426,7 +426,7 @@ PhysPt CMscdex::GetDefaultBuffer(void) {
PhysPt CMscdex::GetTempBuffer(void) {
if (defaultBufSeg==0) {
Bit16u size = (2352*2+15)/16;
defaultBufSeg = DOS_GetMemory(size);
defaultBufSeg = DOS_GetMemory(size,"MSCDEX temp buffer");
};
return PhysMake(defaultBufSeg,0);
}

View File

@@ -51,11 +51,13 @@ static Bitu call_casemap;
static Bit16u dos_memseg=0;//DOS_PRIVATE_SEGMENT;
static Bit16u bios_memseg=BIOS_PRIVATE_SEGMENT;
Bit16u BIOS_GetMemory(Bit16u pages) {
Bit16u BIOS_GetMemory(Bit16u pages,const char *who) {
if (who == NULL) who = "";
if (((Bitu)pages+(Bitu)bios_memseg) > BIOS_PRIVATE_SEGMENT_END) {
E_Exit("BIOS:Not enough memory for internal tables");
}
Bit16u page=bios_memseg;
fprintf(stderr,"BIOS_GetMemory(0x%04x pages,\"%s\") = 0x%04x\n",pages,who,page);
bios_memseg+=pages;
return page;
}
@@ -101,7 +103,8 @@ void DOS_GetMemory_Choose() {
}
}
Bit16u DOS_GetMemory(Bit16u pages) {
Bit16u DOS_GetMemory(Bit16u pages,const char *who) {
if (who == NULL) who = "";
if (dos_memseg == 0) {
if (DOS_GetMemory_unmapped) E_Exit("DOS:Attempt to use DOS_GetMemory() when private area was unmapped by BOOT\n");
if (DOS_PRIVATE_SEGMENT == 0) DOS_GetMemory_Choose();
@@ -115,6 +118,7 @@ Bit16u DOS_GetMemory(Bit16u pages) {
E_Exit("DOS:Not enough memory for internal tables");
}
Bit16u page=dos_memseg;
fprintf(stderr,"DOS_GetMemory(0x%04x pages,\"%s\") = 0x%04x\n",pages,who,page);
dos_memseg+=pages;
return page;
}
@@ -146,9 +150,9 @@ extern bool enable_collating_uppercase;
void DOS_SetupTables(void) {
Bit16u seg;Bitu i;
dos.tables.mediaid=RealMake(DOS_GetMemory(4),0);
dos.tables.tempdta=RealMake(DOS_GetMemory(4),0);
dos.tables.tempdta_fcbdelete=RealMake(DOS_GetMemory(4),0);
dos.tables.mediaid=RealMake(DOS_GetMemory(4,"dos.tables.mediaid"),0);
dos.tables.tempdta=RealMake(DOS_GetMemory(4,"dos.tables.tempdta"),0);
dos.tables.tempdta_fcbdelete=RealMake(DOS_GetMemory(4,"dos.tables.fcbdelete"),0);
for (i=0;i<DOS_DRIVES;i++) mem_writew(Real2Phys(dos.tables.mediaid)+i*2,0);
/* Create the DOS Info Block */
dos_infoblock.SetLocation(DOS_INFOBLOCK_SEG); //c2woody
@@ -180,7 +184,7 @@ void DOS_SetupTables(void) {
/* Allocate DCBS DOUBLE BYTE CHARACTER SET LEAD-BYTE TABLE */
if (enable_dbcs_tables) {
dos.tables.dbcs=RealMake(DOS_GetMemory(12),0);
dos.tables.dbcs=RealMake(DOS_GetMemory(12,"dos.tables.dbcs"),0);
mem_writed(Real2Phys(dos.tables.dbcs),0); //empty table
}
else {
@@ -188,7 +192,7 @@ void DOS_SetupTables(void) {
}
/* FILENAME CHARACTER TABLE */
if (enable_filenamechar) {
dos.tables.filenamechar=RealMake(DOS_GetMemory(2),0);
dos.tables.filenamechar=RealMake(DOS_GetMemory(2,"dos.tables.filenamechar"),0);
mem_writew(Real2Phys(dos.tables.filenamechar)+0x00,0x16);
mem_writeb(Real2Phys(dos.tables.filenamechar)+0x02,0x01);
mem_writeb(Real2Phys(dos.tables.filenamechar)+0x03,0x00); // allowed chars from
@@ -219,7 +223,7 @@ void DOS_SetupTables(void) {
/* COLLATING SEQUENCE TABLE + UPCASE TABLE*/
// 256 bytes for col table, 128 for upcase, 4 for number of entries
if (enable_collating_uppercase) {
dos.tables.collatingseq=RealMake(DOS_GetMemory(25),0);
dos.tables.collatingseq=RealMake(DOS_GetMemory(25,"dos.tables.collatingseq"),0);
mem_writew(Real2Phys(dos.tables.collatingseq),0x100);
for (i=0; i<256; i++) mem_writeb(Real2Phys(dos.tables.collatingseq)+i+2,i);
dos.tables.upcase=dos.tables.collatingseq+258;
@@ -232,17 +236,17 @@ void DOS_SetupTables(void) {
}
/* Create a fake FCB SFT */
seg=DOS_GetMemory(4);
seg=DOS_GetMemory(4,"Fake FCB SFT");
real_writed(seg,0,0xffffffff); //Last File Table
real_writew(seg,4,100); //File Table supports 100 files
dos_infoblock.SetFCBTable(RealMake(seg,0));
/* Create a fake DPB */
dos.tables.dpb=DOS_GetMemory(2);
dos.tables.dpb=DOS_GetMemory(2,"dos.tables.dpb");
for(Bitu d=0;d<26;d++) real_writeb(dos.tables.dpb,d,d);
/* Create a fake disk buffer head */
seg=DOS_GetMemory(6);
seg=DOS_GetMemory(6,"Fake disk buffer head");
for (Bitu ct=0; ct<0x20; ct++) real_writeb(seg,ct,0);
real_writew(seg,0x00,0xffff); // forward ptr
real_writew(seg,0x02,0xffff); // backward ptr

View File

@@ -640,7 +640,7 @@ fatDrive::fatDrive(const char *sysFilename, Bit32u bytesector, Bit32u cylsector,
struct partTable mbrData;
if(imgDTASeg == 0) {
imgDTASeg = DOS_GetMemory(2);
imgDTASeg = DOS_GetMemory(2,"imgDTASeg");
imgDTAPtr = RealMake(imgDTASeg, 0);
imgDTA = new DOS_DTA(imgDTAPtr);
}

View File

@@ -1119,7 +1119,7 @@ public:
callback_esr.Allocate(&IPX_ESRHandler,"IPX_ESR");
Bit16u call_ipxesr1 = callback_esr.Get_callback();
if(!dospage) dospage = DOS_GetMemory(2); // can not be freed yet
if(!dospage) dospage = DOS_GetMemory(2,"IPX dospage"); // can not be freed yet
PhysPt phyDospage = PhysMake(dospage,0);

View File

@@ -131,7 +131,7 @@ bool device_EMM::ReadFromControlChannel(PhysPt bufptr,Bit16u size,Bit16u * retco
case 0x01: {
if (!is_emm386) return false;
if (size!=6) return false;
if (GEMMIS_seg==0) GEMMIS_seg=DOS_GetMemory(0x20);
if (GEMMIS_seg==0) GEMMIS_seg=DOS_GetMemory(0x20,"GEMMIS_seg");
PhysPt GEMMIS_addr=PhysMake(GEMMIS_seg,0);
mem_writew(GEMMIS_addr+0x00,0x0004); // flags
@@ -1334,7 +1334,7 @@ public:
}
BIOS_ZeroExtendedSize(true);
if (!ems_baseseg) ems_baseseg=DOS_GetMemory(2); //We have 32 bytes
if (!ems_baseseg) ems_baseseg=DOS_GetMemory(2,"ems_baseseg"); //We have 32 bytes
/* Add a little hack so it appears that there is an actual ems device installed */
char const* emsname="EMMXXXX0";

View File

@@ -1143,7 +1143,7 @@ void MOUSE_Init(Section* sec) {
// Callback for mouse interrupt 0x33
call_int33=CALLBACK_Allocate();
// i33loc=RealMake(CB_SEG+1,(call_int33*CB_SIZE)-0x10);
i33loc=RealMake(DOS_GetMemory(0x1)-1,0x10);
i33loc=RealMake(DOS_GetMemory(0x1,"i33loc")-1,0x10);
CALLBACK_Setup(call_int33,&INT33_Handler,CB_MOUSE,Real2Phys(i33loc),"Mouse");
// Wasteland needs low(seg(int33))!=0 and low(ofs(int33))!=0
real_writed(0,0x33<<2,i33loc);

View File

@@ -453,7 +453,7 @@ public:
DOS_AddMultiplexHandler(multiplex_xms);
/* place hookable callback in writable memory area */
xms_callback=RealMake(DOS_GetMemory(0x1)-1,0x10);
xms_callback=RealMake(DOS_GetMemory(0x1,"xms_callback")-1,0x10);
callbackhandler.Install(&XMS_Handler,CB_HOOKABLE,Real2Phys(xms_callback),"XMS Handler");
// pseudocode for CB_HOOKABLE:
// jump near skip

View File

@@ -715,7 +715,7 @@ void SHELL_Init() {
/* Now call up the shell for the first time */
Bit16u psp_seg=DOS_FIRST_SHELL;
Bit16u env_seg=DOS_FIRST_SHELL+19; //DOS_GetMemory(1+(4096/16))+1;
Bit16u stack_seg=DOS_GetMemory(2048/16);
Bit16u stack_seg=DOS_GetMemory(2048/16,"COMMAND.COM stack");
SegSet16(ss,stack_seg);
reg_sp=2046;