Example #1
0
int installCallback(void (PMAPI *pmCB)(),uint *psel, uint *poff,
    uint *rseg, uint *roff)
{
    PMREGS          regs;
    PMSREGS         sregs;

    regs.x.ax = 0x250D;
    PM_segread(&sregs);
    PM_int386x(0x21,&regs,&regs,&sregs);    /* Get RM callback address  */

    /* Fill in the values in the real mode code segment so that it will
     * call the correct routine.
     */
    *((ulong*)&realHandler[0]) = regs.e.eax;
    *((ushort*)&realHandler[4]) = sregs.cs;
    *((ulong*)&realHandler[6]) = (ulong)pmCB;

    /* Copy the real mode handler to real mode memory (only allocate the
     * buffer once since we cant dealloate it with X32).
     */
    if (*psel == 0) {
	if (!PM_allocRealSeg(sizeof(realHandler),psel,poff,rseg,roff))
	    return 0;
	}
    PM_memcpyfn(*psel,*poff,realHandler,sizeof(realHandler));

    /* Skip past global variables in real mode code segment */
    *roff += 0x0A;
    return 1;
}
Example #2
0
uchar * installCallback(void (PMAPI *pmCB)(),uint *rseg, uint *roff)
{
    CONFIG_INF  config;
    REALPTR     realBufAdr,callProtp;
    ULONG       bufSize;
    FARPTR      protBufAdr;
    uchar       *p;

    /* Get address of real mode routine to call up to protected mode    */
    _dx_rmlink_get(&callProtp, &realBufAdr, &bufSize, &protBufAdr);
    _dx_config_inf(&config, (UCHAR*)&config);

    /* Fill in the values in the real mode code segment so that it will
     * call the correct routine.
     */
    *((REALPTR*)&realHandler[0]) = callProtp;
    *((USHORT*)&realHandler[4]) = config.c_cs_sel;
    *((ULONG*)&realHandler[6]) = (ULONG)pmCB;

    /* Copy the real mode handler to real mode memory   */
    if ((p = PM_allocRealSeg(sizeof(realHandler),rseg,roff)) == NULL)
	return NULL;
    memcpy(p,realHandler,sizeof(realHandler));

    /* Skip past global variabls in real mode code segment */
    *roff += 0x0A;
    return p;
}
Example #3
0
int PMAPI PM_setMouseHandler(int mask, PM_mouseHandler mh)
{
    RMREGS      regs;
    RMSREGS     sregs;
    uint        rseg,roff;

    lockPMHandlers();           /* Ensure our handlers are locked   */

    /* Copy the real mode handler to real mode memory   */
    if ((mousePtr = PM_allocRealSeg(sizeof(mouseHandler),&rseg,&roff)) == NULL)
	return 0;
    memcpy(mousePtr,mouseHandler,sizeof(mouseHandler));
    if (!_DPMI_allocateCallback(_PM_mousePMCB, mouseRegs, &mouseRMCB))
	PM_fatalError("Unable to allocate real mode callback!\n");
    PM_setLong(mousePtr,mouseRMCB);

    /* Install the real mode mouse handler  */
    _PM_mouseHandler = mh;
    sregs.es = rseg;
    regs.x.dx = roff+4;
    regs.x.cx = _PM_mouseMask = mask;
    regs.x.ax = 0xC;
    PM_int86x(0x33, &regs, &regs, &sregs);
    return 1;
}
Example #4
0
void * PMAPI PM_getVESABuf(uint *len,uint *rseg,uint *roff)
{
    if (!VESABuf_ptr) {
        /* Allocate a global buffer for communicating with the VESA VBE */
        if ((VESABuf_ptr = PM_allocRealSeg(VESABuf_len, &VESABuf_rseg, &VESABuf_roff)) == NULL)
            return NULL;
        atexit(ExitVBEBuf);
        }
    *len = VESABuf_len;
    *rseg = VESABuf_rseg;
    *roff = VESABuf_roff;
    return VESABuf_ptr;
}
Example #5
0
/****************************************************************************
REMARKS:
Allocate the real mode VESA transfer buffer for communicating with the BIOS.
****************************************************************************/
void * PMAPI PM_getVESABuf(
    uint *len,
    uint *rseg,
    uint *roff)
{
    // TODO: If you do not have BIOS access, simply delete the guts of
    //       this function and return NULL.
    if (!VESABuf_ptr) {
        /* Allocate a global buffer for communicating with the VESA VBE */
        if ((VESABuf_ptr = PM_allocRealSeg(VESABuf_len, &VESABuf_rseg, &VESABuf_roff)) == NULL)
            return NULL;
        atexit(ExitVBEBuf);
        }
    *len = VESABuf_len;
    *rseg = VESABuf_rseg;
    *roff = VESABuf_roff;
    return VESABuf_ptr;
}