- memset(&r,0,sizeof(r));
- r.eax = API_NUM(PMHELP_GETVER);
- _PM_VxDCall(&r,_PM_VXD_off,_PM_VXD_sel);
- return VXD_version = (uint)r.eax;
- }
+ memset(&r,0,sizeof(r));
+ r.eax = API_NUM(PMHELP_GETVER);
+ _PM_VxDCall(&r,_PM_VXD_off,_PM_VXD_sel);
+ return VXD_version = (uint)r.eax;
+ }
- /* Check if we are running under DPMI in which case we will not be
- * able to use our special ring 0 CauseWay functions.
- */
- _PM_haveCauseWay = false;
- regs.x.ax = 0xFF00;
- PM_int386(0x31,®s,®s);
- if (regs.x.cflag || !(regs.e.edi & 8)) {
- /* We are not under DPMI, so now check if CauseWay is active */
- regs.x.ax = 0xFFF9;
- PM_int386(0x31,®s,®s);
- if (!regs.x.cflag && regs.e.ecx == 0x43415553 && regs.e.edx == 0x45574159)
- _PM_haveCauseWay = true;
- }
-
- /* Now connect to PMHELP.VXD and initialise MTRR module */
- if (!PMHELP_connect())
- MTRR_init();
- }
+ /* Check if we are running under DPMI in which case we will not be
+ * able to use our special ring 0 CauseWay functions.
+ */
+ _PM_haveCauseWay = false;
+ regs.x.ax = 0xFF00;
+ PM_int386(0x31,®s,®s);
+ if (regs.x.cflag || !(regs.e.edi & 8)) {
+ /* We are not under DPMI, so now check if CauseWay is active */
+ regs.x.ax = 0xFFF9;
+ PM_int386(0x31,®s,®s);
+ if (!regs.x.cflag && regs.e.ecx == 0x43415553 && regs.e.edx == 0x45574159)
+ _PM_haveCauseWay = true;
+ }
+
+ /* Now connect to PMHELP.VXD and initialise MTRR module */
+ if (!PMHELP_connect())
+ MTRR_init();
+ }
- memset(®s,0,sizeof(regs));
- regs.eax = API_NUM(PMHELP_ENABLELFBCOMB);
- regs.ebx = base;
- regs.ecx = size;
- regs.edx = type;
- _PM_VxDCall(®s,_PM_VXD_off,_PM_VXD_sel);
- return regs.eax;
- }
+ memset(®s,0,sizeof(regs));
+ regs.eax = API_NUM(PMHELP_ENABLELFBCOMB);
+ regs.ebx = base;
+ regs.ecx = size;
+ regs.edx = type;
+ _PM_VxDCall(®s,_PM_VXD_off,_PM_VXD_sel);
+ return regs.eax;
+ }
- /* DOS cannot virtually remap the BIOS, so we can only work if all
- * the secondary controllers are identical, and we then use the
- * BIOS on the first controller for all the remaining controllers.
- *
- * For OS'es that do virtual memory, and remapping of 0xC0000
- * physical (perhaps a copy on write mapping) should be all that
- * is needed.
- */
- return false;
- }
+ /* DOS cannot virtually remap the BIOS, so we can only work if all
+ * the secondary controllers are identical, and we then use the
+ * BIOS on the first controller for all the remaining controllers.
+ *
+ * For OS'es that do virtual memory, and remapping of 0xC0000
+ * physical (perhaps a copy on write mapping) should be all that
+ * is needed.
+ */
+ return false;
+ }
memset(findData,0,findData->dwSize);
findData->dwSize = dwSize;
if (blk->attrib & _A_RDONLY)
memset(findData,0,findData->dwSize);
findData->dwSize = dwSize;
if (blk->attrib & _A_RDONLY)
findData->sizeLo = blk->size;
strncpy(findData->name,blk->name,PM_MAX_PATH);
findData->name[PM_MAX_PATH-1] = 0;
findData->sizeLo = blk->size;
strncpy(findData->name,blk->name,PM_MAX_PATH);
findData->name[PM_MAX_PATH-1] = 0;
- if (_PM_haveCauseWay) {
- /* CauseWay is a little different in the page table handling.
- * The code that we use for DOS4G/W does not appear to work
- * with CauseWay correctly as it does not appear to allow us
- * to map the page tables directly. Instead we can directly
- * access the page table entries in extended memory where
- * CauseWay always locates them (starting at 1024*4096*1023)
- */
- startPage = (linear >> 12);
- endPage = ((linear+limit) >> 12);
- pPageTable = (ulong*)CW_PAGE_TABLE_START;
- for (iPage = startPage; iPage <= endPage; iPage++)
- pPageTable[iPage] = (pPageTable[iPage] & andMask) | orMask;
- }
- else {
- pPDB = (ulong*)DPMI_mapPhysicalToLinear(PDB,0xFFF);
- if (pPDB) {
- startPDB = (linear >> 22) & 0x3FF;
- startPage = (linear >> 12) & 0x3FF;
- endPDB = ((linear+limit) >> 22) & 0x3FF;
- endPage = ((linear+limit) >> 12) & 0x3FF;
- for (iPDB = startPDB; iPDB <= endPDB; iPDB++) {
- pageTable = pPDB[iPDB] & ~0xFFF;
- pPageTable = (ulong*)DPMI_mapPhysicalToLinear(pageTable,0xFFF);
- start = (iPDB == startPDB) ? startPage : 0;
- end = (iPDB == endPDB) ? endPage : 0x3FF;
- for (iPage = start; iPage <= end; iPage++)
- pPageTable[iPage] = (pPageTable[iPage] & andMask) | orMask;
- }
- }
- }
- PM_flushTLB();
- }
+ if (_PM_haveCauseWay) {
+ /* CauseWay is a little different in the page table handling.
+ * The code that we use for DOS4G/W does not appear to work
+ * with CauseWay correctly as it does not appear to allow us
+ * to map the page tables directly. Instead we can directly
+ * access the page table entries in extended memory where
+ * CauseWay always locates them (starting at 1024*4096*1023)
+ */
+ startPage = (linear >> 12);
+ endPage = ((linear+limit) >> 12);
+ pPageTable = (ulong*)CW_PAGE_TABLE_START;
+ for (iPage = startPage; iPage <= endPage; iPage++)
+ pPageTable[iPage] = (pPageTable[iPage] & andMask) | orMask;
+ }
+ else {
+ pPDB = (ulong*)DPMI_mapPhysicalToLinear(PDB,0xFFF);
+ if (pPDB) {
+ startPDB = (linear >> 22) & 0x3FF;
+ startPage = (linear >> 12) & 0x3FF;
+ endPDB = ((linear+limit) >> 22) & 0x3FF;
+ endPage = ((linear+limit) >> 12) & 0x3FF;
+ for (iPDB = startPDB; iPDB <= endPDB; iPDB++) {
+ pageTable = pPDB[iPDB] & ~0xFFF;
+ pPageTable = (ulong*)DPMI_mapPhysicalToLinear(pageTable,0xFFF);
+ start = (iPDB == startPDB) ? startPage : 0;
+ end = (iPDB == endPDB) ? endPage : 0x3FF;
+ for (iPage = start; iPage <= end; iPage++)
+ pPageTable[iPage] = (pPageTable[iPage] & andMask) | orMask;
+ }
+ }
+ }
+ PM_flushTLB();
+ }
- if (base >= 0x100000)
- return NULL;
- /* If the linear address mapping fails but we are trying to
- * map an area in the first 1Mb of system memory, then we must
- * be running under a Windows or OS/2 DOS box. Under these
- * environments we can use the segment wrap around as a fallback
- * measure, as this does work properly.
- */
- linAddr = base;
- }
+ if (base >= 0x100000)
+ return NULL;
+ /* If the linear address mapping fails but we are trying to
+ * map an area in the first 1Mb of system memory, then we must
+ * be running under a Windows or OS/2 DOS box. Under these
+ * environments we can use the segment wrap around as a fallback
+ * measure, as this does work properly.
+ */
+ linAddr = base;
+ }
- /* Allocate and copy the memory block only once */
- crPtr = PM_allocRealSeg(sizeof(int6AHandler), &crRSeg, &crROff);
- memcpy(crPtr,int6AHandler,sizeof(int6AHandler));
- }
+ /* Allocate and copy the memory block only once */
+ crPtr = PM_allocRealSeg(sizeof(int6AHandler), &crRSeg, &crROff);
+ memcpy(crPtr,int6AHandler,sizeof(int6AHandler));
+ }
- memset(®s,0,sizeof(regs));
- regs.eax = API_NUM(PMHELP_ALLOCLOCKED);
- regs.ebx = size;
- regs.ecx = (ulong)physAddr;
- regs.edx = contiguous | (below16Meg << 8);
- _PM_VxDCall(®s,_PM_VXD_off,_PM_VXD_sel);
- return (void*)regs.eax;
- }
+ memset(®s,0,sizeof(regs));
+ regs.eax = API_NUM(PMHELP_ALLOCLOCKED);
+ regs.ebx = size;
+ regs.ecx = (ulong)physAddr;
+ regs.edx = contiguous | (below16Meg << 8);
+ _PM_VxDCall(®s,_PM_VXD_off,_PM_VXD_sel);
+ return (void*)regs.eax;
+ }
roundedP = (void*)(((ulong)p + 0xFFF) & ~0xFFF);
*((ulong*)(roundedP + size)) = (ulong)p;
PM_lockDataPages(roundedP,size,&lh);
if ((*physAddr = PM_getPhysicalAddr(roundedP)) == 0xFFFFFFFF) {
roundedP = (void*)(((ulong)p + 0xFFF) & ~0xFFF);
*((ulong*)(roundedP + size)) = (ulong)p;
PM_lockDataPages(roundedP,size,&lh);
if ((*physAddr = PM_getPhysicalAddr(roundedP)) == 0xFFFFFFFF) {
- memset(®s,0,sizeof(regs));
- regs.eax = API_NUM(PMHELP_FREELOCKED);
- regs.ebx = (ulong)p;
- regs.ecx = size;
- regs.edx = contiguous;
- _PM_VxDCall(®s,_PM_VXD_off,_PM_VXD_sel);
- return;
- }
+ memset(®s,0,sizeof(regs));
+ regs.eax = API_NUM(PMHELP_FREELOCKED);
+ regs.ebx = (ulong)p;
+ regs.ecx = size;
+ regs.edx = contiguous;
+ _PM_VxDCall(®s,_PM_VXD_off,_PM_VXD_sel);
+ return;
+ }
/* Allocate memory for the new page block, and add to head of list */
size = PAGES_PER_BLOCK * PM_PAGE_SIZE + (PM_PAGE_SIZE-1) + sizeof(pageblock);
if ((newBlock = PM_malloc(size)) == NULL)
/* Allocate memory for the new page block, and add to head of list */
size = PAGES_PER_BLOCK * PM_PAGE_SIZE + (PM_PAGE_SIZE-1) + sizeof(pageblock);
if ((newBlock = PM_malloc(size)) == NULL)
newBlock->freeListStart = newBlock->freeList;
newBlock->freeListEnd = p + (PAGES_PER_BLOCK-1) * PM_PAGE_SIZE;
for (i = 0; i < PAGES_PER_BLOCK; i++,p = next)
newBlock->freeListStart = newBlock->freeList;
newBlock->freeListEnd = p + (PAGES_PER_BLOCK-1) * PM_PAGE_SIZE;
for (i = 0; i < PAGES_PER_BLOCK; i++,p = next)
- memset(®s,0,sizeof(regs));
- regs.eax = API_NUM(PMHELP_ALLOCPAGE);
- regs.ebx = locked;
- _PM_VxDCall(®s,_PM_VXD_off,_PM_VXD_sel);
- return (void*)regs.eax;
- }
+ memset(®s,0,sizeof(regs));
+ regs.eax = API_NUM(PMHELP_ALLOCPAGE);
+ regs.ebx = locked;
+ _PM_VxDCall(®s,_PM_VXD_off,_PM_VXD_sel);
+ return (void*)regs.eax;
+ }
- memset(®s,0,sizeof(regs));
- regs.eax = API_NUM(PMHELP_FREEPAGE);
- regs.ebx = (ulong)p;
- _PM_VxDCall(®s,_PM_VXD_off,_PM_VXD_sel);
- return;
- }
+ memset(®s,0,sizeof(regs));
+ regs.eax = API_NUM(PMHELP_FREEPAGE);
+ regs.ebx = (ulong)p;
+ _PM_VxDCall(®s,_PM_VXD_off,_PM_VXD_sel);
+ return;
+ }
- /* If all pages in the page block are now free, free the entire
- * page block itself.
- */
- if (block == pageBlocks) {
- /* Delete from head */
- pageBlocks = block->next;
- if (block->next)
- block->next->prev = NULL;
- }
- else {
- /* Delete from middle of list */
- CHECK(block->prev != NULL);
- block->prev->next = block->next;
- if (block->next)
- block->next->prev = block->prev;
- }
- PM_free(block);
- }
+ /* If all pages in the page block are now free, free the entire
+ * page block itself.
+ */
+ if (block == pageBlocks) {
+ /* Delete from head */
+ pageBlocks = block->next;
+ if (block->next)
+ block->next->prev = NULL;
+ }
+ else {
+ /* Delete from middle of list */
+ CHECK(block->prev != NULL);
+ block->prev->next = block->next;
+ if (block->next)
+ block->next->prev = block->prev;
+ }
+ PM_free(block);
+ }
- memset(®s,0,sizeof(regs));
- regs.eax = API_NUM(PMHELP_MAPPHYS);
- regs.ebx = base;
- regs.ecx = limit;
- regs.edx = isCached;
- _PM_VxDCall(®s,_PM_VXD_off,_PM_VXD_sel);
- return (void*)regs.eax;
- }
+ memset(®s,0,sizeof(regs));
+ regs.eax = API_NUM(PMHELP_MAPPHYS);
+ regs.ebx = base;
+ regs.ecx = limit;
+ regs.edx = isCached;
+ _PM_VxDCall(®s,_PM_VXD_off,_PM_VXD_sel);
+ return (void*)regs.eax;
+ }
_dx_config_inf(&config, (UCHAR*)&config);
err = _dx_map_phys(config.c_ds_sel,baseAddr,(newLimit + 4095) / 4096,&offset);
if (err == 130) {
_dx_config_inf(&config, (UCHAR*)&config);
err = _dx_map_phys(config.c_ds_sel,baseAddr,(newLimit + 4095) / 4096,&offset);
if (err == 130) {
- /* If the TNT function failed, we are running in a DPMI environment
- * and this function does not work. However we know how to handle
- * DPMI properly, so we use our generic DPMI functions to do
- * what the TNT runtime libraries can't.
- */
- return DPMI_mapPhysicalAddr(base,limit,isCached);
- }
+ /* If the TNT function failed, we are running in a DPMI environment
+ * and this function does not work. However we know how to handle
+ * DPMI properly, so we use our generic DPMI functions to do
+ * what the TNT runtime libraries can't.
+ */
+ return DPMI_mapPhysicalAddr(base,limit,isCached);
+ }
- memset(®s,0,sizeof(regs));
- regs.eax = API_NUM(PMHELP_MAPPHYS);
- regs.ebx = base;
- regs.ecx = limit;
- regs.edx = isCached;
- _PM_VxDCall(®s,_PM_VXD_off,_PM_VXD_sel);
- return (void*)regs.eax;
- }
+ memset(®s,0,sizeof(regs));
+ regs.eax = API_NUM(PMHELP_MAPPHYS);
+ regs.ebx = base;
+ regs.ecx = limit;
+ regs.edx = isCached;
+ _PM_VxDCall(®s,_PM_VXD_off,_PM_VXD_sel);
+ return (void*)regs.eax;
+ }
- memset(®s,0,sizeof(regs));
- regs.eax = API_NUM(PMHELP_MAPPHYS);
- regs.ebx = base;
- regs.ecx = limit;
- regs.edx = isCached;
- _PM_VxDCall(®s,_PM_VXD_off,_PM_VXD_sel);
- return (void*)regs.eax;
- }
+ memset(®s,0,sizeof(regs));
+ regs.eax = API_NUM(PMHELP_MAPPHYS);
+ regs.ebx = base;
+ regs.ecx = limit;
+ regs.edx = isCached;
+ _PM_VxDCall(®s,_PM_VXD_off,_PM_VXD_sel);
+ return (void*)regs.eax;
+ }
- memset(®s,0,sizeof(regs));
- regs.eax = API_NUM(PMHELP_GETPHYSICALADDRRANGE);
- regs.ebx = (ulong)p;
- regs.ecx = (ulong)length;
- regs.edx = (ulong)physAddress;
- _PM_VxDCall(®s,_PM_VXD_off,_PM_VXD_sel);
- return regs.eax;
- }
+ memset(®s,0,sizeof(regs));
+ regs.eax = API_NUM(PMHELP_GETPHYSICALADDRRANGE);
+ regs.ebx = (ulong)p;
+ regs.ecx = (ulong)length;
+ regs.edx = (ulong)physAddress;
+ _PM_VxDCall(®s,_PM_VXD_off,_PM_VXD_sel);
+ return regs.eax;
+ }
- int count;
- ulong linAddr = (ulong)p;
-
- /* When paging is disabled physical=linear */
- for (count = (length+0xFFF) >> 12; count > 0; count--) {
- *physAddress++ = linAddr;
- linAddr += 4096;
- }
- return true;
- }
+ int count;
+ ulong linAddr = (ulong)p;
+
+ /* When paging is disabled physical=linear */
+ for (count = (length+0xFFF) >> 12; count > 0; count--) {
+ *physAddress++ = linAddr;
+ linAddr += 4096;
+ }
+ return true;
+ }
- int startPDB,endPDB,iPDB,startPage,endPage,start,end,iPage;
- ulong pageTable,*pPageTable,linAddr = (ulong)p;
- ulong limit = length-1;
-
- pPDB = (ulong*)DPMI_mapPhysicalToLinear(PDB,0xFFF);
- if (pPDB) {
- startPDB = (linAddr >> 22) & 0x3FFL;
- startPage = (linAddr >> 12) & 0x3FFL;
- endPDB = ((linAddr+limit) >> 22) & 0x3FFL;
- endPage = ((linAddr+limit) >> 12) & 0x3FFL;
- for (iPDB = startPDB; iPDB <= endPDB; iPDB++) {
- pageTable = pPDB[iPDB] & ~0xFFFL;
- pPageTable = (ulong*)DPMI_mapPhysicalToLinear(pageTable,0xFFF);
- start = (iPDB == startPDB) ? startPage : 0;
- end = (iPDB == endPDB) ? endPage : 0x3FFL;
- for (iPage = start; iPage <= end; iPage++)
- *physAddress++ = (pPageTable[iPage] & ~0xFFF);
- }
- return true;
- }
- }
+ int startPDB,endPDB,iPDB,startPage,endPage,start,end,iPage;
+ ulong pageTable,*pPageTable,linAddr = (ulong)p;
+ ulong limit = length-1;
+
+ pPDB = (ulong*)DPMI_mapPhysicalToLinear(PDB,0xFFF);
+ if (pPDB) {
+ startPDB = (linAddr >> 22) & 0x3FFL;
+ startPage = (linAddr >> 12) & 0x3FFL;
+ endPDB = ((linAddr+limit) >> 22) & 0x3FFL;
+ endPage = ((linAddr+limit) >> 12) & 0x3FFL;
+ for (iPDB = startPDB; iPDB <= endPDB; iPDB++) {
+ pageTable = pPDB[iPDB] & ~0xFFFL;
+ pPageTable = (ulong*)DPMI_mapPhysicalToLinear(pageTable,0xFFF);
+ start = (iPDB == startPDB) ? startPage : 0;
+ end = (iPDB == endPDB) ? endPage : 0x3FFL;
+ for (iPage = start; iPage <= end; iPage++)
+ *physAddress++ = (pPageTable[iPage] & ~0xFFF);
+ }
+ return true;
+ }
+ }
- r.x.ax = 0x101; /* DPMI free DOS memory */
- r.x.dx = _PM_findRealModeBlock(mem);/* DX := selector from 0x100 */
- PM_int386(0x31, &r, &r);
- }
+ r.x.ax = 0x101; /* DPMI free DOS memory */
+ r.x.dx = _PM_findRealModeBlock(mem);/* DX := selector from 0x100 */
+ PM_int386(0x31, &r, &r);
+ }
- uint LargestBlockAvail;
- uint MaxUnlockedPage;
- uint LargestLockablePage;
- uint LinAddrSpace;
- uint NumFreePagesAvail;
- uint NumPhysicalPagesFree;
- uint TotalPhysicalPages;
- uint FreeLinAddrSpace;
- uint SizeOfPageFile;
- uint res[3];
- } MemInfo;
+ uint LargestBlockAvail;
+ uint MaxUnlockedPage;
+ uint LargestLockablePage;
+ uint LinAddrSpace;
+ uint NumFreePagesAvail;
+ uint NumPhysicalPagesFree;
+ uint TotalPhysicalPages;
+ uint FreeLinAddrSpace;
+ uint SizeOfPageFile;
+ uint res[3];
+ } MemInfo;