/**************************************************************************** REMARKS: PM_calloc override function for SNAP drivers loaded in VxD's. ****************************************************************************/ void * NTDRV_calloc( size_t nelem, size_t size) { void *p = PM_mallocShared(nelem * size); if (p) memset(p,0,nelem * size); return p; }
/**************************************************************************** REMARKS: PM_realloc override function for SNAP drivers loaded in VxD's. ****************************************************************************/ void * NTDRV_realloc( void *ptr, size_t size) { void *p = PM_mallocShared(size); if (p) { memcpy(p,ptr,size); PM_freeShared(ptr); } return p; }
/**************************************************************************** REMARKS: PM_malloc override function for SNAP drivers loaded in VxD's. ****************************************************************************/ void * NTDRV_malloc( size_t size) { return PM_mallocShared(size); }
static void InitPMCode(void) /**************************************************************************** * * Function: InitPMCode - 32 bit protected mode version * * Description: Finds the address of and relocates the protected mode * code block from the VBE 2.0 into a local memory block. The * memory block is allocated with malloc() and must be freed * with VBE_freePMCode() after graphics processing is complete. * * Note that this buffer _must_ be recopied after each mode set, * as the routines will change depending on the underlying * video mode. * ****************************************************************************/ { RMREGS regs; RMSREGS sregs; uchar *code; int pmLen; if (!state->pmInfo && state->VBEVersion >= 0x200) { regs.x.ax = 0x4F0A; regs.x.bx = 0; PM_int86x(0x10,®s,®s,&sregs); if (regs.x.ax != VBE_SUCCESS) return; if (VBE_shared) state->pmInfo = PM_mallocShared(regs.x.cx); else state->pmInfo = PM_malloc(regs.x.cx); if (state->pmInfo == NULL) return; state->pmInfo32 = state->pmInfo; pmLen = regs.x.cx; /* Relocate the block into our local data segment */ code = PM_mapRealPointer(sregs.es,regs.x.di); memcpy(state->pmInfo,code,pmLen); /* Now do a sanity check on the information we recieve to ensure * that is is correct. Some BIOS return totally bogus information * in here (Matrox is one)! Under DOS this works OK, but under OS/2 * we are screwed. */ if (state->pmInfo->setWindow >= pmLen || state->pmInfo->setDisplayStart >= pmLen || state->pmInfo->setPalette >= pmLen || state->pmInfo->IOPrivInfo >= pmLen) { if (VBE_shared) PM_freeShared(state->pmInfo); else PM_free(state->pmInfo); state->pmInfo32 = state->pmInfo = NULL; return; } /* Read the IO priveledge info and determine if we need to * pass a selector to MMIO registers to the bank switch code. * Since we no longer support selector allocation, we no longer * support this mechanism so we disable the protected mode * interface in this case. */ if (state->pmInfo->IOPrivInfo && !state->MMIOSel) { ushort *p = (ushort*)((uchar*)state->pmInfo + state->pmInfo->IOPrivInfo); while (*p != 0xFFFF) p++; p++; if (*p != 0xFFFF) VBE_freePMCode(); } } }