diff options
Diffstat (limited to 'board/MAI/bios_emulator/scitech/src/pm/smx')
-rw-r--r-- | board/MAI/bios_emulator/scitech/src/pm/smx/event.c | 228 | ||||
-rw-r--r-- | board/MAI/bios_emulator/scitech/src/pm/smx/pm.c | 344 | ||||
-rw-r--r-- | board/MAI/bios_emulator/scitech/src/pm/smx/pmsmx.c | 146 | ||||
-rw-r--r-- | board/MAI/bios_emulator/scitech/src/pm/smx/ztimer.c | 2 |
4 files changed, 360 insertions, 360 deletions
diff --git a/board/MAI/bios_emulator/scitech/src/pm/smx/event.c b/board/MAI/bios_emulator/scitech/src/pm/smx/event.c index fc13bbb..533c261 100644 --- a/board/MAI/bios_emulator/scitech/src/pm/smx/event.c +++ b/board/MAI/bios_emulator/scitech/src/pm/smx/event.c @@ -98,8 +98,8 @@ Adds a new mouse event to the event queue. This routine is called from within the mouse interrupt subroutine, so it must be efficient. NOTE: Interrupts MUST be OFF while this routine is called to ensure we have - mutually exclusive access to our internal data structures for - interrupt driven systems (like under DOS). + mutually exclusive access to our internal data structures for + interrupt driven systems (like under DOS). ****************************************************************************/ static void addMouseEvent( uint what, @@ -113,18 +113,18 @@ static void addMouseEvent( event_t evt; if (EVT.count < EVENTQSIZE) { - /* Save information in event record. */ - evt.when = _EVT_getTicks(); - evt.what = what; - evt.message = message; - evt.modifiers = but_stat; - evt.where_x = x; /* Save mouse event position */ - evt.where_y = y; - evt.relative_x = mickeyX; - evt.relative_y = mickeyY; - evt.modifiers |= EVT.keyModifiers; - addEvent(&evt); /* Add to tail of event queue */ - } + /* Save information in event record. */ + evt.when = _EVT_getTicks(); + evt.what = what; + evt.message = message; + evt.modifiers = but_stat; + evt.where_x = x; /* Save mouse event position */ + evt.where_y = y; + evt.relative_x = mickeyX; + evt.relative_y = mickeyY; + evt.modifiers |= EVT.keyModifiers; + addEvent(&evt); /* Add to tail of event queue */ + } } /**************************************************************************** @@ -140,8 +140,8 @@ and we call the addMouseEvent() routine to add the appropriate mouse event to the event queue. Note: Interrupts are ON when this routine is called by the mouse driver code. -//AM: NOTE: This function has not actually been ported from DOS yet and should not -//AM: be installed until it is. +/*AM: NOTE: This function has not actually been ported from DOS yet and should not */ +/*AM: be installed until it is. */ ****************************************************************************/ static void EVTAPI mouseISR( uint mask, @@ -155,39 +155,39 @@ static void EVTAPI mouseISR( uint ps; if (mask & 1) { - /* Save the current mouse coordinates */ - EVT.mx = x; EVT.my = y; - - /* If the last event was a movement event, then modify the last - * event rather than post a new one, so that the queue will not - * become saturated. Before we modify the data structures, we - * MUST ensure that interrupts are off. - */ - ps = _EVT_disableInt(); - if (EVT.oldMove != -1) { - EVT.evtq[EVT.oldMove].where_x = x; /* Modify existing one */ - EVT.evtq[EVT.oldMove].where_y = y; - EVT.evtq[EVT.oldMove].relative_x += mickeyX; - EVT.evtq[EVT.oldMove].relative_y += mickeyY; - } - else { - EVT.oldMove = EVT.freeHead; /* Save id of this move event */ - addMouseEvent(EVT_MOUSEMOVE,0,x,y,mickeyX,mickeyY,butstate); - } - _EVT_restoreInt(ps); - } + /* Save the current mouse coordinates */ + EVT.mx = x; EVT.my = y; + + /* If the last event was a movement event, then modify the last + * event rather than post a new one, so that the queue will not + * become saturated. Before we modify the data structures, we + * MUST ensure that interrupts are off. + */ + ps = _EVT_disableInt(); + if (EVT.oldMove != -1) { + EVT.evtq[EVT.oldMove].where_x = x; /* Modify existing one */ + EVT.evtq[EVT.oldMove].where_y = y; + EVT.evtq[EVT.oldMove].relative_x += mickeyX; + EVT.evtq[EVT.oldMove].relative_y += mickeyY; + } + else { + EVT.oldMove = EVT.freeHead; /* Save id of this move event */ + addMouseEvent(EVT_MOUSEMOVE,0,x,y,mickeyX,mickeyY,butstate); + } + _EVT_restoreInt(ps); + } if (mask & 0x2A) { - ps = _EVT_disableInt(); - addMouseEvent(EVT_MOUSEDOWN,mask >> 1,x,y,0,0,butstate); - EVT.oldMove = -1; - _EVT_restoreInt(ps); - } + ps = _EVT_disableInt(); + addMouseEvent(EVT_MOUSEDOWN,mask >> 1,x,y,0,0,butstate); + EVT.oldMove = -1; + _EVT_restoreInt(ps); + } if (mask & 0x54) { - ps = _EVT_disableInt(); - addMouseEvent(EVT_MOUSEUP,mask >> 2,x,y,0,0,butstate); - EVT.oldMove = -1; - _EVT_restoreInt(ps); - } + ps = _EVT_disableInt(); + addMouseEvent(EVT_MOUSEUP,mask >> 2,x,y,0,0,butstate); + EVT.oldMove = -1; + _EVT_restoreInt(ps); + } EVT.oldKey = -1; } @@ -196,7 +196,7 @@ REMARKS: Keyboard interrupt handler function. NOTE: Interrupts are OFF when this routine is called by the keyboard ISR, - and we leave them OFF the entire time. This has been modified to work + and we leave them OFF the entire time. This has been modified to work in conjunction with smx keyboard handler. ****************************************************************************/ static void EVTAPI keyboardISR(void) @@ -252,51 +252,51 @@ void EVTAPI EVT_resume(void) PM_lockHandle lh; if (_EVT_useEvents) { - /* Initialise the event queue and enable our interrupt handlers */ - initEventQueue(); - PM_setKeyHandler(keyboardISR); - if ((haveMouse = detectMouse()) != 0) - PM_setMouseHandler(0xFFFF,mouseISR); - - /* Read the keyboard modifier flags from the BIOS to get the - * correct initialisation state. The only state we care about is - * the correct toggle state flags such as SCROLLLOCK, NUMLOCK and - * CAPSLOCK. - */ - EVT.keyModifiers = 0; - mods = PM_getByte(_EVT_biosPtr+0x17); - if (mods & 0x10) - EVT.keyModifiers |= EVT_SCROLLLOCK; - if (mods & 0x20) - EVT.keyModifiers |= EVT_NUMLOCK; - if (mods & 0x40) - EVT.keyModifiers |= EVT_CAPSLOCK; - - /* Lock all of the code and data used by our protected mode interrupt - * handling routines, so that it will continue to work correctly - * under real mode. - */ - if (!locked) { - /* It is difficult to ensure that we lock our global data, so we - * do this by taking the address of a variable locking all data - * 2Kb on either side. This should properly cover the global data - * used by the module (the other alternative is to declare the - * variables in assembler, in which case we know it will be - * correct). - */ - stat = !PM_lockDataPages(&EVT,sizeof(EVT),&lh); - stat |= !PM_lockDataPages(&_EVT_biosPtr,sizeof(_EVT_biosPtr),&lh); - stat |= !PM_lockCodePages((__codePtr)_EVT_cCodeStart,(int)_EVT_cCodeEnd-(int)_EVT_cCodeStart,&lh); - stat |= !PM_lockCodePages((__codePtr)_EVT_codeStart,(int)_EVT_codeEnd-(int)_EVT_codeStart,&lh); - if (stat) { - PM_fatalError("Page locking services failed - interrupt handling not safe!"); - exit(1); - } - locked = 1; - } - - _EVT_installed = true; - } + /* Initialise the event queue and enable our interrupt handlers */ + initEventQueue(); + PM_setKeyHandler(keyboardISR); + if ((haveMouse = detectMouse()) != 0) + PM_setMouseHandler(0xFFFF,mouseISR); + + /* Read the keyboard modifier flags from the BIOS to get the + * correct initialisation state. The only state we care about is + * the correct toggle state flags such as SCROLLLOCK, NUMLOCK and + * CAPSLOCK. + */ + EVT.keyModifiers = 0; + mods = PM_getByte(_EVT_biosPtr+0x17); + if (mods & 0x10) + EVT.keyModifiers |= EVT_SCROLLLOCK; + if (mods & 0x20) + EVT.keyModifiers |= EVT_NUMLOCK; + if (mods & 0x40) + EVT.keyModifiers |= EVT_CAPSLOCK; + + /* Lock all of the code and data used by our protected mode interrupt + * handling routines, so that it will continue to work correctly + * under real mode. + */ + if (!locked) { + /* It is difficult to ensure that we lock our global data, so we + * do this by taking the address of a variable locking all data + * 2Kb on either side. This should properly cover the global data + * used by the module (the other alternative is to declare the + * variables in assembler, in which case we know it will be + * correct). + */ + stat = !PM_lockDataPages(&EVT,sizeof(EVT),&lh); + stat |= !PM_lockDataPages(&_EVT_biosPtr,sizeof(_EVT_biosPtr),&lh); + stat |= !PM_lockCodePages((__codePtr)_EVT_cCodeStart,(int)_EVT_cCodeEnd-(int)_EVT_cCodeStart,&lh); + stat |= !PM_lockCodePages((__codePtr)_EVT_codeStart,(int)_EVT_codeEnd-(int)_EVT_codeStart,&lh); + if (stat) { + PM_fatalError("Page locking services failed - interrupt handling not safe!"); + exit(1); + } + locked = 1; + } + + _EVT_installed = true; + } } /**************************************************************************** @@ -310,9 +310,9 @@ void EVTAPI EVT_setMouseRange( int yRes) { if (haveMouse) { - ps2MouseStop(); - ps2MouseStart( 0, xRes, 0, yRes, -1, -1, -1); - } + ps2MouseStop(); + ps2MouseStart( 0, xRes, 0, yRes, -1, -1, -1); + } } /**************************************************************************** @@ -325,7 +325,7 @@ void _EVT_setMousePos( int *y) { if (haveMouse) - ps2MouseMove(*x, *y); + ps2MouseMove(*x, *y); } /**************************************************************************** @@ -338,24 +338,24 @@ void EVTAPI EVT_suspend(void) uchar mods; if (_EVT_installed) { - PM_restoreKeyHandler(); + PM_restoreKeyHandler(); if (haveMouse) - PM_restoreMouseHandler(); - - /* Set the keyboard modifier flags in the BIOS to our values */ - EVT_allowLEDS(true); - mods = PM_getByte(_EVT_biosPtr+0x17) & ~0x70; - if (EVT.keyModifiers & EVT_SCROLLLOCK) - mods |= 0x10; - if (EVT.keyModifiers & EVT_NUMLOCK) - mods |= 0x20; - if (EVT.keyModifiers & EVT_CAPSLOCK) - mods |= 0x40; - PM_setByte(_EVT_biosPtr+0x17,mods); - - /* Flag that we are no longer installed */ - _EVT_installed = false; - } + PM_restoreMouseHandler(); + + /* Set the keyboard modifier flags in the BIOS to our values */ + EVT_allowLEDS(true); + mods = PM_getByte(_EVT_biosPtr+0x17) & ~0x70; + if (EVT.keyModifiers & EVT_SCROLLLOCK) + mods |= 0x10; + if (EVT.keyModifiers & EVT_NUMLOCK) + mods |= 0x20; + if (EVT.keyModifiers & EVT_CAPSLOCK) + mods |= 0x40; + PM_setByte(_EVT_biosPtr+0x17,mods); + + /* Flag that we are no longer installed */ + _EVT_installed = false; + } } /**************************************************************************** diff --git a/board/MAI/bios_emulator/scitech/src/pm/smx/pm.c b/board/MAI/bios_emulator/scitech/src/pm/smx/pm.c index d6c95d6..99ee3d4 100644 --- a/board/MAI/bios_emulator/scitech/src/pm/smx/pm.c +++ b/board/MAI/bios_emulator/scitech/src/pm/smx/pm.c @@ -147,9 +147,9 @@ void PMAPI PM_backslash(char *s) { uint pos = strlen(s); if (s[pos-1] != '\\') { - s[pos] = '\\'; - s[pos+1] = '\0'; - } + s[pos] = '\\'; + s[pos+1] = '\0'; + } } void PMAPI PM_setFatalErrorCleanup( @@ -163,28 +163,28 @@ void MGLOutput(char *); void PMAPI PM_fatalError(const char *msg) { if (fatalErrorCleanup) - fatalErrorCleanup(); + fatalErrorCleanup(); MGLOutput(msg); -// No support for fprintf() under smx currently! -// fprintf(stderr,"%s\n", msg); +/* No support for fprintf() under smx currently! */ +/* fprintf(stderr,"%s\n", msg); */ exit(1); } static void ExitVBEBuf(void) { if (VESABuf_ptr) - PM_freeRealSeg(VESABuf_ptr); + PM_freeRealSeg(VESABuf_ptr); VESABuf_ptr = 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); - } + /* 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; @@ -234,12 +234,12 @@ void PMAPI _PM_addRealModeBlock(void *mem,uint tag) int i; for (i = 0; i < MAX_RM_BLOCKS; i++) { - if (rmBlocks[i].p == NULL) { - rmBlocks[i].p = mem; - rmBlocks[i].tag = tag; - return; - } - } + if (rmBlocks[i].p == NULL) { + rmBlocks[i].p = mem; + rmBlocks[i].tag = tag; + return; + } + } PM_fatalError("To many real mode memory block allocations!"); } @@ -248,9 +248,9 @@ uint PMAPI _PM_findRealModeBlock(void *mem) int i; for (i = 0; i < MAX_RM_BLOCKS; i++) { - if (rmBlocks[i].p == mem) - return rmBlocks[i].tag; - } + if (rmBlocks[i].p == mem) + return rmBlocks[i].tag; + } PM_fatalError("Could not find prior real mode memory block allocation!"); return 0; } @@ -274,7 +274,7 @@ const char * PMAPI PM_getNucleusPath(void) char *env; if ((env = getenv("NUCLEUS_PATH")) != NULL) - return env; + return env; return "c:\\nucleus"; } @@ -339,12 +339,12 @@ void PMAPI PM_saveConsoleState(void *stateBuf,PM_HWND hwndConsole) sb->oldMode = regs.h.al & 0x7F; sb->old50Lines = false; if (sb->oldMode == 0x3) { - regs.x.ax = 0x1130; - regs.x.bx = 0; - regs.x.dx = 0; - PM_int86(0x10,®s,®s); - sb->old50Lines = (regs.h.dl == 42 || regs.h.dl == 49); - } + regs.x.ax = 0x1130; + regs.x.bx = 0; + regs.x.dx = 0; + PM_int86(0x10,®s,®s); + sb->old50Lines = (regs.h.dl == 42 || regs.h.dl == 49); + } (void)hwndConsole; } @@ -361,10 +361,10 @@ void PMAPI PM_restoreConsoleState(const void *stateBuf,PM_HWND hwndConsole) /* Retore 50 line mode if set */ if (sb->old50Lines) { - regs.x.ax = 0x1112; - regs.x.bx = 0; - PM_int86(0x10,®s,®s); - } + regs.x.ax = 0x1112; + regs.x.bx = 0; + PM_int86(0x10,®s,®s); + } (void)hwndConsole; } @@ -388,13 +388,13 @@ void PMAPI PM_setOSScreenWidth(int width,int height) PM_setWord(_biosPtr+0x4C,width*2); PM_setByte(_biosPtr+0x84,height-1); if (height > 25) { - PM_setWord(_biosPtr+0x60,0x0607); - PM_setByte(_biosPtr+0x85,0x08); - } + PM_setWord(_biosPtr+0x60,0x0607); + PM_setByte(_biosPtr+0x85,0x08); + } else { - PM_setWord(_biosPtr+0x60,0x0D0E); - PM_setByte(_biosPtr+0x85,0x016); - } + PM_setWord(_biosPtr+0x60,0x0D0E); + PM_setByte(_biosPtr+0x85,0x016); + } } void * PMAPI PM_mallocShared(long size) @@ -424,22 +424,22 @@ ibool PMAPI PM_doBIOSPOST( /* Create a zero memory mapping for us to use */ if (firstTime) { - rmZeroPtr = PM_mapPhysicalAddr(0,0x7FFF,true); - firstTime = false; - } + rmZeroPtr = PM_mapPhysicalAddr(0,0x7FFF,true); + firstTime = false; + } /* Remap the secondary BIOS to 0xC0000 physical */ if (BIOSPhysAddr != 0xC0000L || BIOSLen > 32768) { - /* SMX 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; - } + /* SMX 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; + } /* Save current handlers of int 10h and 6Dh */ GetRMVect(0x10,&Current10); @@ -457,9 +457,9 @@ ibool PMAPI PM_doBIOSPOST( /* Second the primary BIOS mappin 1:1 for 0xC0000 physical */ if (BIOSPhysAddr != 0xC0000L) { - /* SMX does not support this */ - (void)mappedBIOS; - } + /* SMX does not support this */ + (void)mappedBIOS; + } return true; } @@ -470,26 +470,26 @@ void PMAPI PM_sleep(ulong milliseconds) LZTimerOnExt(&tm); while (LZTimerLapExt(&tm) < microseconds) - ; + ; LZTimerOffExt(&tm); } int PMAPI PM_getCOMPort(int port) { switch (port) { - case 0: return 0x3F8; - case 1: return 0x2F8; - } + case 0: return 0x3F8; + case 1: return 0x2F8; + } return 0; } int PMAPI PM_getLPTPort(int port) { switch (port) { - case 0: return 0x3BC; - case 1: return 0x378; - case 2: return 0x278; - } + case 0: return 0x3BC; + case 1: return 0x378; + case 2: return 0x278; + } return 0; } @@ -534,15 +534,15 @@ static void convertFindData( memset(findData,0,findData->dwSize); findData->dwSize = dwSize; if (blk->attrib & _A_RDONLY) - findData->attrib |= PM_FILE_READONLY; + findData->attrib |= PM_FILE_READONLY; if (blk->attrib & _A_SUBDIR) - findData->attrib |= PM_FILE_DIRECTORY; + findData->attrib |= PM_FILE_DIRECTORY; if (blk->attrib & _A_ARCH) - findData->attrib |= PM_FILE_ARCHIVE; + findData->attrib |= PM_FILE_ARCHIVE; if (blk->attrib & _A_HIDDEN) - findData->attrib |= PM_FILE_HIDDEN; + findData->attrib |= PM_FILE_HIDDEN; if (blk->attrib & _A_SYSTEM) - findData->attrib |= PM_FILE_SYSTEM; + findData->attrib |= PM_FILE_SYSTEM; findData->sizeLo = blk->size; strncpy(findData->name,blk->name,PM_MAX_PATH); findData->name[PM_MAX_PATH-1] = 0; @@ -561,11 +561,11 @@ void * PMAPI PM_findFirstFile( struct find_t *blk; if ((blk = PM_malloc(sizeof(*blk))) == NULL) - return PM_FILE_INVALID; + return PM_FILE_INVALID; if (_dos_findfirst((char*)filename,FIND_MASK,blk) == 0) { - convertFindData(findData,blk); - return blk; - } + convertFindData(findData,blk); + return blk; + } return PM_FILE_INVALID; } @@ -580,9 +580,9 @@ ibool PMAPI PM_findNextFile( struct find_t *blk = handle; if (_dos_findnext(blk) == 0) { - convertFindData(findData,blk); - return true; - } + convertFindData(findData,blk); + return true; + } return false; } @@ -614,9 +614,9 @@ ibool PMAPI PM_driveValid( { RMREGS regs; regs.h.dl = (uchar)(drive - 'A' + 1); - regs.h.ah = 0x36; // Get disk information service + regs.h.ah = 0x36; /* Get disk information service */ PM_int86(0x21,®s,®s); - return regs.x.ax != 0xFFFF; // AX = 0xFFFF if disk is invalid + return regs.x.ax != 0xFFFF; /* AX = 0xFFFF if disk is invalid */ } /**************************************************************************** @@ -649,25 +649,25 @@ void PMAPI PM_setFileAttr( DWORD attr = 0; if (attrib & PM_FILE_READONLY) - attr |= FILE_ATTRIBUTE_READONLY; + attr |= FILE_ATTRIBUTE_READONLY; if (attrib & PM_FILE_ARCHIVE) - attr |= FILE_ATTRIBUTE_ARCHIVE; + attr |= FILE_ATTRIBUTE_ARCHIVE; if (attrib & PM_FILE_HIDDEN) - attr |= FILE_ATTRIBUTE_HIDDEN; + attr |= FILE_ATTRIBUTE_HIDDEN; if (attrib & PM_FILE_SYSTEM) - attr |= FILE_ATTRIBUTE_SYSTEM; + attr |= FILE_ATTRIBUTE_SYSTEM; SetFileAttributes((LPSTR)filename, attr); #else uint attr = 0; if (attrib & PM_FILE_READONLY) - attr |= _A_RDONLY; + attr |= _A_RDONLY; if (attrib & PM_FILE_ARCHIVE) - attr |= _A_ARCH; + attr |= _A_ARCH; if (attrib & PM_FILE_HIDDEN) - attr |= _A_HIDDEN; + attr |= _A_HIDDEN; if (attrib & PM_FILE_SYSTEM) - attr |= _A_SYSTEM; + attr |= _A_SYSTEM; _dos_setfileattr(filename,attr); #endif } @@ -682,7 +682,7 @@ ibool PMAPI PM_mkdir( #ifdef __GNUC__ return mkdir(filename,S_IRUSR) == 0; #else -//AM: return mkdir(filename) == 0; +/*AM: return mkdir(filename) == 0; */ return(false); #endif } @@ -694,7 +694,7 @@ Function to remove a directory. ibool PMAPI PM_rmdir( const char *filename) { -//AM: return rmdir(filename) == 0; +/*AM: return rmdir(filename) == 0; */ return(false); } @@ -719,9 +719,9 @@ void * PMAPI PM_allocLockedMem( * properly page align the start of the memory block for DMA operations. */ if (size > 4096) - return NULL; + return NULL; if ((p = PM_allocRealSeg((size + 0xFFF) & ~0xFFF,&r_seg,&r_off)) == NULL) - return NULL; + return NULL; *physAddr = ((r_seg << 4) + r_off + 0xFFF) & ~0xFFF; PM_lockDataPages(p,size*2,&lh); return p; @@ -743,11 +743,11 @@ ulong PMAPI DPMI_mapPhysicalToLinear(ulong physAddr,ulong limit) ulong physOfs; if (physAddr < 0x100000L) { - /* We can't map memory below 1Mb, but the linear address are already - * mapped 1:1 for this memory anyway so we just return the base address. - */ - return physAddr; - } + /* We can't map memory below 1Mb, but the linear address are already + * mapped 1:1 for this memory anyway so we just return the base address. + */ + return physAddr; + } /* Round the physical address to a 4Kb boundary and the limit to a * 4Kb-1 boundary before passing the values to DPMI as some extenders @@ -766,7 +766,7 @@ ulong PMAPI DPMI_mapPhysicalToLinear(ulong physAddr,ulong limit) r.x.di = limit & 0xFFFF; PM_int386(0x31, &r, &r); if (r.x.cflag) - return 0xFFFFFFFFUL; + return 0xFFFFFFFFUL; return ((ulong)r.x.bx << 16) + r.x.cx + physOfs; } @@ -780,7 +780,7 @@ int PMAPI DPMI_setSelectorBase(ushort sel,ulong linAddr) r.x.dx = linAddr & 0xFFFF; PM_int386(0x31, &r, &r); if (r.x.cflag) - return 0; + return 0; return 1; } @@ -804,7 +804,7 @@ int PMAPI DPMI_setSelectorLimit(ushort sel,ulong limit) r.x.dx = limit & 0xFFFF; PM_int386(0x31, &r, &r); if (r.x.cflag) - return 0; + return 0; return 1; } @@ -830,11 +830,11 @@ uint PMAPI DPMI_createSelector(ulong base,ulong limit) /* Map physical memory and create selector */ if ((base = DPMI_mapPhysicalToLinear(base,limit)) == 0xFFFFFFFFUL) - return 0; + return 0; if (!DPMI_setSelectorBase(sel,base)) - return 0; + return 0; if (!DPMI_setSelectorLimit(sel,limit)) - return 0; + return 0; return sel; } @@ -883,28 +883,28 @@ void * PMAPI DPMI_mapPhysicalAddr(ulong base,ulong limit,ibool isCached) PM_segread(&sregs); DSBaseAddr = DPMI_getSelectorBase(sregs.ds); if ((base < 0x100000) && (DSBaseAddr == 0)) { - /* DS is zero based, so we can directly access the first 1Mb of - * system memory (like under DOS4GW). - */ - return (void*)base; - } + /* DS is zero based, so we can directly access the first 1Mb of + * system memory (like under DOS4GW). + */ + return (void*)base; + } /* Map the memory to a linear address using DPMI function 0x800 */ if ((linAddr = DPMI_mapPhysicalToLinear(base,limit)) == 0) { - 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; + } /* Now expand the default DS selector to 4Gb so we can access it */ if (!DPMI_setSelectorLimit(sregs.ds,0xFFFFFFFFUL)) - return NULL; + return NULL; /* Finally enable caching for the page tables that we just mapped in, * since DOS4GW and PMODE/W create the page table entries without @@ -916,34 +916,34 @@ void * PMAPI DPMI_mapPhysicalAddr(ulong base,ulong limit,ibool isCached) * caching) so that MMIO register regions do not screw up. */ if (isCached) { - if ((PDB = _PM_getPDB()) != 0 && DSBaseAddr == 0) { - int startPDB,endPDB,iPDB,startPage,endPage,start,end,iPage; - ulong pageTable,*pPageTable; - if (!pPDB) { - if (PDB >= 0x100000) - pPDB = (ulong*)DPMI_mapPhysicalToLinear(PDB,0xFFF); - else - pPDB = (ulong*)PDB; - } - if (pPDB) { - startPDB = (linAddr >> 22) & 0x3FF; - startPage = (linAddr >> 12) & 0x3FF; - endPDB = ((linAddr+limit) >> 22) & 0x3FF; - endPage = ((linAddr+limit) >> 12) & 0x3FF; - for (iPDB = startPDB; iPDB <= endPDB; iPDB++) { - pageTable = pPDB[iPDB] & ~0xFFF; - if (pageTable >= 0x100000) - pPageTable = (ulong*)DPMI_mapPhysicalToLinear(pageTable,0xFFF); - else - pPageTable = (ulong*)pageTable; - start = (iPDB == startPDB) ? startPage : 0; - end = (iPDB == endPDB) ? endPage : 0x3FF; - for (iPage = start; iPage <= end; iPage++) - pPageTable[iPage] &= ~0x18; - } - } - } - } + if ((PDB = _PM_getPDB()) != 0 && DSBaseAddr == 0) { + int startPDB,endPDB,iPDB,startPage,endPage,start,end,iPage; + ulong pageTable,*pPageTable; + if (!pPDB) { + if (PDB >= 0x100000) + pPDB = (ulong*)DPMI_mapPhysicalToLinear(PDB,0xFFF); + else + pPDB = (ulong*)PDB; + } + if (pPDB) { + startPDB = (linAddr >> 22) & 0x3FF; + startPage = (linAddr >> 12) & 0x3FF; + endPDB = ((linAddr+limit) >> 22) & 0x3FF; + endPage = ((linAddr+limit) >> 12) & 0x3FF; + for (iPDB = startPDB; iPDB <= endPDB; iPDB++) { + pageTable = pPDB[iPDB] & ~0xFFF; + if (pageTable >= 0x100000) + pPageTable = (ulong*)DPMI_mapPhysicalToLinear(pageTable,0xFFF); + else + pPageTable = (ulong*)pageTable; + start = (iPDB == startPDB) ? startPage : 0; + end = (iPDB == endPDB) ? endPage : 0x3FF; + for (iPage = start; iPage <= end; iPage++) + pPageTable[iPage] &= ~0x18; + } + } + } + } /* Now return the base address of the memory into the default DS */ return (void*)(linAddr - DSBaseAddr); @@ -971,10 +971,10 @@ void PMAPI PM_callRealMode(uint seg,uint off, RMREGS *in, uint oldSeg,oldOff; if (!crPtr) { - /* 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)); + } PM_setWord(crPtr,off); /* Plug in address to call */ PM_setWord(crPtr+2,seg); p = PM_mapRealPointer(0,0x6A * 4); @@ -1003,8 +1003,8 @@ void PMAPI PM_freePhysicalAddr(void *ptr,ulong limit) ulong PMAPI PM_getPhysicalAddr(void *p) { - // TODO: This function should find the physical address of a linear - // address. + /* TODO: This function should find the physical address of a linear */ + /* address. */ (void)p; return 0xFFFFFFFFUL; } @@ -1020,7 +1020,7 @@ void * PMAPI PM_mapRealPointer(uint r_seg,uint r_off) static uchar *zeroPtr = NULL; if (!zeroPtr) - zeroPtr = PM_mapPhysicalAddr(0,0xFFFFF,true); + zeroPtr = PM_mapPhysicalAddr(0,0xFFFFF,true); return (void*)(zeroPtr + MK_PHYS(r_seg,r_off)); } @@ -1033,7 +1033,7 @@ void * PMAPI PM_allocRealSeg(uint size,uint *r_seg,uint *r_off) r.x.bx = (size + 0xF) >> 4; /* number of paragraphs */ PM_int386(0x31, &r, &r); if (r.x.cflag) - return NULL; /* DPMI call failed */ + return NULL; /* DPMI call failed */ *r_seg = r.x.ax; /* Real mode segment */ *r_off = 0; p = PM_mapRealPointer(*r_seg,*r_off); @@ -1063,9 +1063,9 @@ void PMAPI DPMI_int86(int intno, DPMI_regs *regs) PMSREGS sr; if (intno == 0x10 && DPMI_int10) { - if (DPMI_int10(regs)) - return; - } + if (DPMI_int10(regs)) + return; + } PM_segread(&sr); r.x.ax = 0x300; /* DPMI issue real interrupt */ r.h.bl = intno; @@ -1086,8 +1086,8 @@ int PMAPI PM_int86(int intno, RMREGS *in, RMREGS *out) memset(&rmregs, 0, sizeof(rmregs)); IN(eax); IN(ebx); IN(ecx); IN(edx); IN(esi); IN(edi); -// These real mode ints may cause crashes. -//AM: DPMI_int86(intno,&rmregs); /* DPMI issue real interrupt */ +/* These real mode ints may cause crashes. */ +/*AM: DPMI_int86(intno,&rmregs); /###* DPMI issue real interrupt */ OUT(eax); OUT(ebx); OUT(ecx); OUT(edx); OUT(esi); OUT(edi); out->x.cflag = rmregs.flags & 0x1; @@ -1104,7 +1104,7 @@ int PMAPI PM_int86x(int intno, RMREGS *in, RMREGS *out, rmregs.es = sregs->es; rmregs.ds = sregs->ds; -//AM: DPMI_int86(intno,&rmregs); /* DPMI issue real interrupt */ +/*AM: DPMI_int86(intno,&rmregs); /###* DPMI issue real interrupt */ OUT(eax); OUT(ebx); OUT(ecx); OUT(edx); OUT(esi); OUT(edi); sregs->es = rmregs.es; @@ -1118,17 +1118,17 @@ int PMAPI PM_int86x(int intno, RMREGS *in, RMREGS *out, #pragma pack(1) typedef struct { - 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; #pragma pack() @@ -1146,7 +1146,7 @@ void PMAPI PM_availableMemory(ulong *physical,ulong *total) *physical = memInfo.NumPhysicalPagesFree * 4096; *total = memInfo.LargestBlockAvail; if (*total < *physical) - *physical = *total; + *physical = *total; } /**************************************************************************** @@ -1156,7 +1156,7 @@ Function to get the file attributes for a specific file. uint PMAPI PM_getFileAttr( const char *filename) { - // TODO: Implement this! + /* TODO: Implement this! */ return 0; } @@ -1169,7 +1169,7 @@ ibool PMAPI PM_getFileTime( ibool gmTime, PM_time *time) { - // TODO: Implement this! + /* TODO: Implement this! */ return false; } @@ -1182,6 +1182,6 @@ ibool PMAPI PM_setFileTime( ibool gmTime, PM_time *time) { - // TODO: Implement this! + /* TODO: Implement this! */ return false; } diff --git a/board/MAI/bios_emulator/scitech/src/pm/smx/pmsmx.c b/board/MAI/bios_emulator/scitech/src/pm/smx/pmsmx.c index 2596c76..98e31bc 100644 --- a/board/MAI/bios_emulator/scitech/src/pm/smx/pmsmx.c +++ b/board/MAI/bios_emulator/scitech/src/pm/smx/pmsmx.c @@ -134,41 +134,41 @@ void PMAPI PM_resetMouseDriver(int hardReset) void PMAPI PM_setRealTimeClockFrequency(int frequency) { static short convert[] = { - 8192, - 4096, - 2048, - 1024, - 512, - 256, - 128, - 64, - 32, - 16, - 8, - 4, - 2, - -1, - }; + 8192, + 4096, + 2048, + 1024, + 512, + 256, + 128, + 64, + 32, + 16, + 8, + 4, + 2, + -1, + }; int i; /* First clear any pending RTC timeout if not cleared */ _PM_readCMOS(0x0C); if (frequency == 0) { - /* Disable RTC timout */ - _PM_writeCMOS(0x0A,_PM_oldCMOSRegA); - _PM_writeCMOS(0x0B,_PM_oldCMOSRegB & 0x0F); - } + /* Disable RTC timout */ + _PM_writeCMOS(0x0A,_PM_oldCMOSRegA); + _PM_writeCMOS(0x0B,_PM_oldCMOSRegB & 0x0F); + } else { - /* Convert frequency value to RTC clock indexes */ - for (i = 0; convert[i] != -1; i++) { - if (convert[i] == frequency) - break; - } - - /* Set RTC timout value and enable timeout */ - _PM_writeCMOS(0x0A,(_PM_oldCMOSRegA & 0xF0) | (i+3)); - _PM_writeCMOS(0x0B,(_PM_oldCMOSRegB & 0x0F) | 0x40); - } + /* Convert frequency value to RTC clock indexes */ + for (i = 0; convert[i] != -1; i++) { + if (convert[i] == frequency) + break; + } + + /* Set RTC timout value and enable timeout */ + _PM_writeCMOS(0x0A,(_PM_oldCMOSRegA & 0xF0) | (i+3)); + _PM_writeCMOS(0x0B,(_PM_oldCMOSRegB & 0x0F) | 0x40); + } } static void PMAPI lockPMHandlers(void) @@ -176,22 +176,22 @@ static void PMAPI lockPMHandlers(void) static int locked = 0; int stat = 0; PM_lockHandle lh; - + /* Lock all of the code and data used by our protected mode interrupt * handling routines, so that it will continue to work correctly * under real mode. */ if (!locked) { - PM_saveDS(); - stat = !PM_lockDataPages(&globalDataStart-2048,4096,&lh); - stat |= !PM_lockDataPages(&_PM_pmsmxDataStart,(int)&_PM_pmsmxDataEnd - (int)&_PM_pmsmxDataStart,&lh); - stat |= !PM_lockCodePages((__codePtr)_PM_pmsmxCodeStart,(int)_PM_pmsmxCodeEnd-(int)_PM_pmsmxCodeStart,&lh); - if (stat) { - printf("Page locking services failed - interrupt handling not safe!\n"); - exit(1); - } - locked = 1; - } + PM_saveDS(); + stat = !PM_lockDataPages(&globalDataStart-2048,4096,&lh); + stat |= !PM_lockDataPages(&_PM_pmsmxDataStart,(int)&_PM_pmsmxDataEnd - (int)&_PM_pmsmxDataStart,&lh); + stat |= !PM_lockCodePages((__codePtr)_PM_pmsmxCodeStart,(int)_PM_pmsmxCodeEnd-(int)_PM_pmsmxCodeStart,&lh); + if (stat) { + printf("Page locking services failed - interrupt handling not safe!\n"); + exit(1); + } + locked = 1; + } } void PMAPI PM_getPMvect(int intno, PMFARPTR *isr) @@ -245,7 +245,7 @@ int PMAPI PM_setMouseHandler(int mask, PM_mouseHandler mh) void PMAPI PM_restoreMouseHandler(void) { if (_PM_mouseHandler) - _PM_mouseHandler = NULL; + _PM_mouseHandler = NULL; } static void getISR(int intno, PMFARPTR *pmisr, long *realisr) @@ -274,9 +274,9 @@ void PMAPI PM_setTimerHandler(PM_intHandler th) void PMAPI PM_restoreTimerHandler(void) { if (_PM_timerHandler) { - restoreISR(PM_IRQ0, _PM_prevTimer, _PM_prevRealTimer); - _PM_timerHandler = NULL; - } + restoreISR(PM_IRQ0, _PM_prevTimer, _PM_prevRealTimer); + _PM_timerHandler = NULL; + } } ibool PMAPI PM_setRealTimeClockHandler(PM_intHandler th,int frequency) @@ -302,15 +302,15 @@ ibool PMAPI PM_setRealTimeClockHandler(PM_intHandler th,int frequency) void PMAPI PM_restoreRealTimeClockHandler(void) { if (_PM_rtcHandler) { - /* Restore CMOS registers and mask RTC clock */ - _PM_writeCMOS(0x0A,_PM_oldCMOSRegA); - _PM_writeCMOS(0x0B,_PM_oldCMOSRegB); - PM_outpb(0xA1,(PM_inpb(0xA1) & 0xFE) | (_PM_oldRTCPIC2 & ~0xFE)); - - /* Restore the interrupt vector */ - restoreISR(0x70, _PM_prevRTC, _PM_prevRealRTC); - _PM_rtcHandler = NULL; - } + /* Restore CMOS registers and mask RTC clock */ + _PM_writeCMOS(0x0A,_PM_oldCMOSRegA); + _PM_writeCMOS(0x0B,_PM_oldCMOSRegB); + PM_outpb(0xA1,(PM_inpb(0xA1) & 0xFE) | (_PM_oldRTCPIC2 & ~0xFE)); + + /* Restore the interrupt vector */ + restoreISR(0x70, _PM_prevRTC, _PM_prevRealRTC); + _PM_rtcHandler = NULL; + } } void PMAPI PM_setKeyHandler(PM_intHandler kh) @@ -323,9 +323,9 @@ void PMAPI PM_setKeyHandler(PM_intHandler kh) void PMAPI PM_restoreKeyHandler(void) { if (_PM_keyHandler) { - restoreISR(PM_IRQ1, _PM_prevKey, _PM_prevRealKey); - _PM_keyHandler = NULL; - } + restoreISR(PM_IRQ1, _PM_prevKey, _PM_prevRealKey); + _PM_keyHandler = NULL; + } } void PMAPI PM_setKey15Handler(PM_key15Handler kh) @@ -338,9 +338,9 @@ void PMAPI PM_setKey15Handler(PM_key15Handler kh) void PMAPI PM_restoreKey15Handler(void) { if (_PM_key15Handler) { - restoreISR(0x15, _PM_prevKey15, _PM_prevRealKey15); - _PM_key15Handler = NULL; - } + restoreISR(0x15, _PM_prevKey15, _PM_prevRealKey15); + _PM_key15Handler = NULL; + } } /* Real mode Ctrl-C and Ctrl-Break handler. This handler simply sets a @@ -385,12 +385,12 @@ void PMAPI PM_installBreakHandler(void) void PMAPI PM_restoreBreakHandler(void) { if (_PM_prevBreak.sel) { - restoreISR(0x1B, _PM_prevBreak, prevRealBreak); - restoreISR(0x23, _PM_prevCtrlC, prevRealCtrlC); - _PM_prevBreak.sel = 0; - _PM_breakHandler = NULL; - PM_freeRealSeg(_PM_ctrlBPtr); - } + restoreISR(0x1B, _PM_prevBreak, prevRealBreak); + restoreISR(0x23, _PM_prevCtrlC, prevRealCtrlC); + _PM_prevBreak.sel = 0; + _PM_breakHandler = NULL; + PM_freeRealSeg(_PM_ctrlBPtr); + } } /* Real mode Critical Error handler. This handler simply saves the AX and @@ -432,11 +432,11 @@ void PMAPI PM_installCriticalHandler(void) void PMAPI PM_restoreCriticalHandler(void) { if (_PM_prevCritical.sel) { - restoreISR(0x24, _PM_prevCritical, prevRealCritical); - PM_freeRealSeg(_PM_critPtr); - _PM_prevCritical.sel = 0; - _PM_critHandler = NULL; - } + restoreISR(0x24, _PM_prevCritical, prevRealCritical); + PM_freeRealSeg(_PM_critPtr); + _PM_prevCritical.sel = 0; + _PM_critHandler = NULL; + } } int PMAPI PM_lockDataPages(void *p,uint len,PM_lockHandle *lh) @@ -457,9 +457,9 @@ int PMAPI PM_lockCodePages(void (*p)(),uint len,PM_lockHandle *lh) { PMSREGS sregs; PM_segread(&sregs); -//AM: causes minor glitch with -//AM: older versions pmEasy which don't allow DPMI 06 on -//AM: Code selector 0x0C -- assume base is 0 which it should be. +/*AM: causes minor glitch with */ +/*AM: older versions pmEasy which don't allow DPMI 06 on */ +/*AM: Code selector 0x0C -- assume base is 0 which it should be. */ return DPMI_lockLinearPages((uint)p,len); } diff --git a/board/MAI/bios_emulator/scitech/src/pm/smx/ztimer.c b/board/MAI/bios_emulator/scitech/src/pm/smx/ztimer.c index 01e180b..7941192 100644 --- a/board/MAI/bios_emulator/scitech/src/pm/smx/ztimer.c +++ b/board/MAI/bios_emulator/scitech/src/pm/smx/ztimer.c @@ -110,6 +110,6 @@ passed, so if this happens we will be generating erronous results. ulong __ULZElapsedTime(ulong start,ulong finish) { if (finish < start) - finish += xticks_per_second() * 3600 *24; /* Number of ticks in 24 hours */ + finish += xticks_per_second() * 3600 *24; /* Number of ticks in 24 hours */ return finish - start; } |