Example #1
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 #2
0
void VBEAPI VBE_callESDI(RMREGS *regs, void *buffer, int size)
/****************************************************************************
*
* Function:     VBE_callESDI
* Parameters:   regs    - Registers to load when calling VBE
*               buffer  - Buffer to copy VBE info block to
*               size    - Size of buffer to fill
*
* Description:  Calls the VESA VBE and passes in a buffer for the VBE to
*               store information in, which is then copied into the users
*               buffer space. This works in protected mode as the buffer
*               passed to the VESA VBE is allocated in conventional
*               memory, and is then copied into the users memory block.
*
****************************************************************************/
{
    RMSREGS sregs;

    if (!state->VESABuf_ptr)
	PM_fatalError("You *MUST* call VBE_init() before you can call the VESAVBE.C module!");
    sregs.es = (ushort)state->VESABuf_rseg;
    regs->x.di = (ushort)state->VESABuf_roff;
    memcpy(state->VESABuf_ptr, buffer, size);
    PM_int86x(0x10, regs, regs, &sregs);
    memcpy(buffer, state->VESABuf_ptr, size);
}
Example #3
0
int main(void)
{
    RMREGS          regs;
    RMSREGS         sregs;
    VgaInfoBlock    vgaInfo;
    ushort          *mode;
    uint            vgLen;
    uchar           *vgPtr;
    unsigned        r_vgseg,r_vgoff;

    /* Allocate a 256 byte block of real memory for communicating with
     * the VESA BIOS.
     */
    if ((vgPtr = PM_getVESABuf(&vgLen,&r_vgseg,&r_vgoff)) == NULL) {
        printf("Unable to allocate VESA memory buffer!\n");
        exit(1);
        }

    /* Call the VESA VBE to see if it is out there */
    regs.x.ax = 0x4F00;
    regs.x.di = r_vgoff;
    sregs.es = r_vgseg;
    memcpy(vgPtr,"VBE2",4);
    PM_int86x(0x10, &regs, &regs, &sregs);
    memcpy(&vgaInfo,vgPtr,sizeof(VgaInfoBlock));
    if (regs.x.ax == 0x4F && strncmp(vgaInfo.VESASignature,"VESA",4) == 0) {
        printf("VESA VBE version %d.%d BIOS detected\n\n",
            vgaInfo.VESAVersion >> 8, vgaInfo.VESAVersion & 0xF);
        printf("Available video modes:\n");
        mode = PM_mapRealPointer(vgaInfo.VideoModePtr >> 16, vgaInfo.VideoModePtr & 0xFFFF);
        while (*mode != 0xFFFF) {
            printf("    %04hXh (%08X)\n", *mode, (int)mode);
            mode++;
            }
        }
Example #4
0
/****************************************************************************
REMARKS:
Determines if we have a mouse attached and functioning.
****************************************************************************/
static ibool detectMouse(void)
{
	RMREGS	regs;
	RMSREGS	sregs;
	uchar	*p;
	ibool	retval;

	regs.x.ax = 0x3533;					/* Get interrupt vector 0x33	*/
	PM_int86x(0x21,&regs,&regs,&sregs);

	/* Check that interrupt vector 0x33 is not a zero, and that the first
	 * instruction in the interrupt vector is not an IRET instruction
	 */
	p = PM_mapRealPointer(sregs.es, regs.x.bx);
	retval = (sregs.es != 0) && (regs.x.bx != 0) && (PM_getByte(p) != 207);
	return retval;
}
Example #5
0
int PMAPI PM_setMouseHandler(int mask, PM_mouseHandler mh)
{
    RMREGS      regs;
    RMSREGS     sregs;
    uint    rseg,roff;

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

    if (!installCallback(_PM_mouseISR, &mouseSel, &mouseOff, &rseg, &roff))
	return 0;
    _PM_mouseHandler = mh;

    /* Install the real mode mouse handler  */
    sregs.es = rseg;
    regs.x.dx = roff;
    regs.x.cx = _PM_mouseMask = mask;
    regs.x.ax = 0xC;
    PM_int86x(0x33, &regs, &regs, &sregs);
    return 1;
}
Example #6
0
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,&regs,&regs,&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();
	    }
	}
}