inline void * RM2PMPtr ( void * ptr ) // convert pointer
// from real mode to { // protected mode ptr
return (void *)(((( (unsigned long) ptr ) » 16 ) « 4 )+ ( (unsigned long) ptr ) & OxFFFF );
}
void DPMIAIIocDosMem ( DPMIDosPtr& ptr, int paras )
{
regs.w.ax = 0x0100, // allocate DOS memory
regs.w.bx = paras; // # of memory in paragraphs
int386 ( 0x31, ®s, ®s );
// addr. of block: ptr.segment = regs.w.ax; // real-mode segment of block

4. Работа с основными графическими устройствам

ptr.selector = regs.w.dx; // selector of block
}
void DPMIFreeDosMem ( DPMIDosPtr& ptr)
{
regs.w.ax = 0x0101; //free DOS memory
regs.w.dx = ptr.selector;
int386 ( 0x31, ®s, ®s );
}
void * DPMIMapPhysical ( void * ptr, unsigned long size ) {
regs.w.ax = 0x0800; // map physical memory
regs.w.bx = (unsigned short)(((unsigned long) ptr) » 16); regs.w.cx = (unsigned short)(((unsigned long) ptr)&0xFFFF); regs.w.si = (unsigned short)( size » 16 ); regs.w.di = (unsigned short)( size & OxFFFF );
int386 ( 0x31, ®s, ®s );
return (void *) ((regs.w.bx « 16 ) + regs.w.cx );
}
void DPMIUnmapPhysical ( void * ptr) {
regs.w.ax = 0x0801; // free physical address
// mapping
regs.w.bx = (unsigned short)(((unsigned long) ptr) » 16 ); regs.w.cx = (unsigned short)(((unsigned long) ptr)&0xFFFF);
int386 ( 0x31, ®s, ®s );
}
void RMVideoInt () // execute real-mode { // video interrupt
regs.w.ax = 0x0300;
regs.w.bx = 0x0010;
regs.w.cx = 0;
regs.x.edi = FP_OFF ( &rmRegs ); sregs.es = FP_SEG ( &rmRegs );
int386x ( 0x31, ®s, ®s, &sregs );
}
initVBE2 ()
{
memset ( ®s, '\0', sizeof (regs )); memset ( &sregs, '\0\ sizeof ( sregs )); memset ( &rmRegs, '\0', sizeof (rmRegs ));
DPMIAIIocDosMem ( vbelnfoPool, 512 /16 ); DPMIAIIocDosMem ( vbeModePool, 256 /16 );
vbelnfoPtr = (VESAInfo *)(vbelnfoPool.segment * 16); vbeModelnfoPtr = (VESAModelnfo *)(vbeModePool.segment * 16);

⇐ Предыдущая| |Следующая ⇒