diff options
author | wdenk <wdenk> | 2003-06-27 21:31:46 +0000 |
---|---|---|
committer | wdenk <wdenk> | 2003-06-27 21:31:46 +0000 |
commit | 8bde7f776c77b343aca29b8c7b58464d915ac245 (patch) | |
tree | 20f1fd99975215e7c658454a15cdb4ed4694e2d4 /board/MAI/bios_emulator/scitech/src/pm | |
parent | 993cad9364c6b87ae429d1ed1130d8153f6f027e (diff) |
* Code cleanup:LABEL_2003_06_27_2340
- remove trailing white space, trailing empty lines, C++ comments, etc.
- split cmd_boot.c (separate cmd_bdinfo.c and cmd_load.c)
* Patches by Kenneth Johansson, 25 Jun 2003:
- major rework of command structure
(work done mostly by Michal Cendrowski and Joakim Kristiansen)
Diffstat (limited to 'board/MAI/bios_emulator/scitech/src/pm')
92 files changed, 8146 insertions, 8174 deletions
diff --git a/board/MAI/bios_emulator/scitech/src/pm/beos/cpuinfo.c b/board/MAI/bios_emulator/scitech/src/pm/beos/cpuinfo.c index c8f825e25ba..cb3afe20c18 100644 --- a/board/MAI/bios_emulator/scitech/src/pm/beos/cpuinfo.c +++ b/board/MAI/bios_emulator/scitech/src/pm/beos/cpuinfo.c @@ -64,8 +64,8 @@ Initialise the counter and return the frequency of the counter. static void GetCounterFrequency( CPU_largeInteger *freq) { - // TODO: Return the frequency of the counter in here. You should try to - // normalise this value to be around 100,000 ticks per second. + /* TODO: Return the frequency of the counter in here. You should try to */ + /* normalise this value to be around 100,000 ticks per second. */ freq->low = 1000000; freq->high = 0; } diff --git a/board/MAI/bios_emulator/scitech/src/pm/beos/event.c b/board/MAI/bios_emulator/scitech/src/pm/beos/event.c index 4c32ce7434d..93c6c0a8fc8 100644 --- a/board/MAI/bios_emulator/scitech/src/pm/beos/event.c +++ b/board/MAI/bios_emulator/scitech/src/pm/beos/event.c @@ -59,7 +59,7 @@ events. ****************************************************************************/ ulong _EVT_getTicks(void) { - // TODO: Implement this for your OS! + /* TODO: Implement this for your OS! */ } /**************************************************************************** @@ -68,36 +68,36 @@ Pumps all messages in the application message queue into our event queue. ****************************************************************************/ static void _EVT_pumpMessages(void) { - // TODO: The purpose of this function is to read all keyboard and mouse - // events from the OS specific event queue, translate them and post - // them into the SciTech event queue. - // - // NOTE: There are a couple of important things that this function must - // take care of: - // - // 1. Support for KEYDOWN, KEYREPEAT and KEYUP is required. - // - // 2. Support for reading hardware scan code as well as ASCII - // translated values is required. Games use the scan codes rather - // than ASCII values. Scan codes go into the high order byte of the - // keyboard message field. - // - // 3. Support for at least reading mouse motion data (mickeys) from the - // mouse is required. Using the mickey values, we can then translate - // to mouse cursor coordinates scaled to the range of the current - // graphics display mode. Mouse values are scaled based on the - // global 'rangeX' and 'rangeY'. - // - // 4. Support for a timestamp for the events is required, which is - // defined as the number of milliseconds since some event (usually - // system startup). This is the timestamp when the event occurred - // (ie: at interrupt time) not when it was stuff into the SciTech - // event queue. - // - // 5. Support for mouse double click events. If the OS has a native - // mechanism to determine this, it should be used. Otherwise the - // time stamp information will be used by the generic event code - // to generate double click events. + /* TODO: The purpose of this function is to read all keyboard and mouse */ + /* events from the OS specific event queue, translate them and post */ + /* them into the SciTech event queue. */ + /* */ + /* NOTE: There are a couple of important things that this function must */ + /* take care of: */ + /* */ + /* 1. Support for KEYDOWN, KEYREPEAT and KEYUP is required. */ + /* */ + /* 2. Support for reading hardware scan code as well as ASCII */ + /* translated values is required. Games use the scan codes rather */ + /* than ASCII values. Scan codes go into the high order byte of the */ + /* keyboard message field. */ + /* */ + /* 3. Support for at least reading mouse motion data (mickeys) from the */ + /* mouse is required. Using the mickey values, we can then translate */ + /* to mouse cursor coordinates scaled to the range of the current */ + /* graphics display mode. Mouse values are scaled based on the */ + /* global 'rangeX' and 'rangeY'. */ + /* */ + /* 4. Support for a timestamp for the events is required, which is */ + /* defined as the number of milliseconds since some event (usually */ + /* system startup). This is the timestamp when the event occurred */ + /* (ie: at interrupt time) not when it was stuff into the SciTech */ + /* event queue. */ + /* */ + /* 5. Support for mouse double click events. If the OS has a native */ + /* mechanism to determine this, it should be used. Otherwise the */ + /* time stamp information will be used by the generic event code */ + /* to generate double click events. */ } /**************************************************************************** @@ -141,7 +141,7 @@ void EVTAPI EVT_init( initEventQueue(); memset(keyUpMsg,0,sizeof(keyUpMsg)); - // TODO: Do any OS specific initialisation here + /* TODO: Do any OS specific initialisation here */ /* Catch program termination signals so we can clean up properly */ signal(SIGABRT, _EVT_abort); @@ -171,7 +171,7 @@ and this function can be used to resume it again later. ****************************************************************************/ void EVT_resume(void) { - // Do nothing for non DOS systems + /* Do nothing for non DOS systems */ } /**************************************************************************** @@ -181,7 +181,7 @@ de-install the event handling code. ****************************************************************************/ void EVT_suspend(void) { - // Do nothing for non DOS systems + /* Do nothing for non DOS systems */ } /**************************************************************************** @@ -195,5 +195,5 @@ void EVT_exit(void) signal(SIGFPE, SIG_DFL); signal(SIGINT, SIG_DFL); - // TODO: Do any OS specific cleanup in here + /* TODO: Do any OS specific cleanup in here */ } diff --git a/board/MAI/bios_emulator/scitech/src/pm/beos/oshdr.h b/board/MAI/bios_emulator/scitech/src/pm/beos/oshdr.h index ab423d4be6d..043d73ecd1b 100644 --- a/board/MAI/bios_emulator/scitech/src/pm/beos/oshdr.h +++ b/board/MAI/bios_emulator/scitech/src/pm/beos/oshdr.h @@ -28,5 +28,5 @@ * ****************************************************************************/ -// This is where you include OS specific headers for the event handling -// library. +/* This is where you include OS specific headers for the event handling */ +/* library. */ diff --git a/board/MAI/bios_emulator/scitech/src/pm/beos/pm.c b/board/MAI/bios_emulator/scitech/src/pm/beos/pm.c index c57d82ab688..2dcb1b81fb9 100644 --- a/board/MAI/bios_emulator/scitech/src/pm/beos/pm.c +++ b/board/MAI/bios_emulator/scitech/src/pm/beos/pm.c @@ -38,7 +38,7 @@ #include <stdlib.h> #include <string.h> -// TODO: Include any BeOS specific headers here! +/* TODO: Include any BeOS specific headers here! */ /*--------------------------- Global variables ----------------------------*/ @@ -48,12 +48,12 @@ static void (PMAPIP fatalErrorCleanup)(void) = NULL; void PMAPI PM_init(void) { - // TODO: Do any initialisation in here. This includes getting IOPL - // access for the process calling PM_init. This will get called - // more than once. + /* TODO: Do any initialisation in here. This includes getting IOPL */ + /* access for the process calling PM_init. This will get called */ + /* more than once. */ - // TODO: If you support the supplied MTRR register stuff (you need to - // be at ring 0 for this!), you should initialise it in here. + /* TODO: If you support the supplied MTRR register stuff (you need to */ + /* be at ring 0 for this!), you should initialise it in here. */ /* MTRR_init(); */ } @@ -68,9 +68,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( @@ -81,112 +81,112 @@ void PMAPI PM_setFatalErrorCleanup( void PMAPI PM_fatalError(const char *msg) { - // TODO: If you are running in a GUI environment without a console, - // this needs to be changed to bring up a fatal error message - // box and terminate the program. + /* TODO: If you are running in a GUI environment without a console, */ + /* this needs to be changed to bring up a fatal error message */ + /* box and terminate the program. */ if (fatalErrorCleanup) - fatalErrorCleanup(); + fatalErrorCleanup(); fprintf(stderr,"%s\n", msg); exit(1); } void * PMAPI PM_getVESABuf(uint *len,uint *rseg,uint *roff) { - // No BIOS access for the BeOS + /* No BIOS access for the BeOS */ return NULL; } int PMAPI PM_kbhit(void) { - // TODO: This function checks if a key is available to be read. This - // should be implemented, but is mostly used by the test programs - // these days. + /* TODO: This function checks if a key is available to be read. This */ + /* should be implemented, but is mostly used by the test programs */ + /* these days. */ return true; } int PMAPI PM_getch(void) { - // TODO: This returns the ASCII code of the key pressed. This - // should be implemented, but is mostly used by the test programs - // these days. + /* TODO: This returns the ASCII code of the key pressed. This */ + /* should be implemented, but is mostly used by the test programs */ + /* these days. */ return 0xD; } int PMAPI PM_openConsole(void) { - // TODO: Opens up a fullscreen console for graphics output. If your - // console does not have graphics/text modes, this can be left - // empty. The main purpose of this is to disable console switching - // when in graphics modes if you can switch away from fullscreen - // consoles (if you want to allow switching, this can be done - // elsewhere with a full save/restore state of the graphics mode). + /* TODO: Opens up a fullscreen console for graphics output. If your */ + /* console does not have graphics/text modes, this can be left */ + /* empty. The main purpose of this is to disable console switching */ + /* when in graphics modes if you can switch away from fullscreen */ + /* consoles (if you want to allow switching, this can be done */ + /* elsewhere with a full save/restore state of the graphics mode). */ return 0; } int PMAPI PM_getConsoleStateSize(void) { - // TODO: Returns the size of the console state buffer used to save the - // state of the console before going into graphics mode. This is - // used to restore the console back to normal when we are done. + /* TODO: Returns the size of the console state buffer used to save the */ + /* state of the console before going into graphics mode. This is */ + /* used to restore the console back to normal when we are done. */ return 1; } void PMAPI PM_saveConsoleState(void *stateBuf,int console_id) { - // TODO: Saves the state of the console into the state buffer. This is - // used to restore the console back to normal when we are done. - // We will always restore 80x25 text mode after being in graphics - // mode, so if restoring text mode is all you need to do this can - // be left empty. + /* TODO: Saves the state of the console into the state buffer. This is */ + /* used to restore the console back to normal when we are done. */ + /* We will always restore 80x25 text mode after being in graphics */ + /* mode, so if restoring text mode is all you need to do this can */ + /* be left empty. */ } void PMAPI PM_restoreConsoleState(const void *stateBuf,int console_id) { - // TODO: Restore the state of the console from the state buffer. This is - // used to restore the console back to normal when we are done. - // We will always restore 80x25 text mode after being in graphics - // mode, so if restoring text mode is all you need to do this can - // be left empty. + /* TODO: Restore the state of the console from the state buffer. This is */ + /* used to restore the console back to normal when we are done. */ + /* We will always restore 80x25 text mode after being in graphics */ + /* mode, so if restoring text mode is all you need to do this can */ + /* be left empty. */ } void PMAPI PM_closeConsole(int console_id) { - // TODO: Close the console when we are done, going back to text mode. + /* TODO: Close the console when we are done, going back to text mode. */ } void PM_setOSCursorLocation(int x,int y) { - // TODO: Set the OS console cursor location to the new value. This is - // generally used for new OS ports (used mostly for DOS). + /* TODO: Set the OS console cursor location to the new value. This is */ + /* generally used for new OS ports (used mostly for DOS). */ } void PM_setOSScreenWidth(int width,int height) { - // TODO: Set the OS console screen width. This is generally unused for - // new OS ports. + /* TODO: Set the OS console screen width. This is generally unused for */ + /* new OS ports. */ } ibool PMAPI PM_setRealTimeClockHandler(PM_intHandler ih, int frequency) { - // TODO: Install a real time clock interrupt handler. Normally this - // will not be supported from most OS'es in user land, so an - // alternative mechanism is needed to enable software stereo. - // Hence leave this unimplemented unless you have a high priority - // mechanism to call the 32-bit callback when the real time clock - // interrupt fires. + /* TODO: Install a real time clock interrupt handler. Normally this */ + /* will not be supported from most OS'es in user land, so an */ + /* alternative mechanism is needed to enable software stereo. */ + /* Hence leave this unimplemented unless you have a high priority */ + /* mechanism to call the 32-bit callback when the real time clock */ + /* interrupt fires. */ return false; } void PMAPI PM_setRealTimeClockFrequency(int frequency) { - // TODO: Set the real time clock interrupt frequency. Used for stereo - // LC shutter glasses when doing software stereo. Usually sets - // the frequency to around 2048 Hz. + /* TODO: Set the real time clock interrupt frequency. Used for stereo */ + /* LC shutter glasses when doing software stereo. Usually sets */ + /* the frequency to around 2048 Hz. */ } void PMAPI PM_restoreRealTimeClockHandler(void) { - // TODO: Restores the real time clock handler. + /* TODO: Restores the real time clock handler. */ } char * PMAPI PM_getCurrentPath( @@ -219,8 +219,8 @@ const char * PMAPI PM_getNucleusConfigPath(void) const char * PMAPI PM_getUniqueID(void) { - // TODO: Return a unique ID for the machine. If a unique ID is not - // available, return the machine name. + /* TODO: Return a unique ID for the machine. If a unique ID is not */ + /* available, return the machine name. */ static char buf[128]; gethostname(buf, 128); return buf; @@ -228,7 +228,7 @@ const char * PMAPI PM_getUniqueID(void) const char * PMAPI PM_getMachineName(void) { - // TODO: Return the network machine name for the machine. + /* TODO: Return the network machine name for the machine. */ static char buf[128]; gethostname(buf, 128); return buf; @@ -236,7 +236,7 @@ const char * PMAPI PM_getMachineName(void) void * PMAPI PM_getBIOSPointer(void) { - // No BIOS access on the BeOS + /* No BIOS access on the BeOS */ return NULL; } @@ -244,212 +244,212 @@ void * PMAPI PM_getA0000Pointer(void) { static void *bankPtr; if (!bankPtr) - bankPtr = PM_mapPhysicalAddr(0xA0000,0xFFFF,true); + bankPtr = PM_mapPhysicalAddr(0xA0000,0xFFFF,true); return bankPtr; } void * PMAPI PM_mapPhysicalAddr(ulong base,ulong limit,ibool isCached) { - // TODO: This function maps a physical memory address to a linear - // address in the address space of the calling process. - - // NOTE: This function *must* be able to handle any phsyical base - // address, and hence you will have to handle rounding of - // the physical base address to a page boundary (ie: 4Kb on - // x86 CPU's) to be able to properly map in the memory - // region. - - // NOTE: If possible the isCached bit should be used to ensure that - // the PCD (Page Cache Disable) and PWT (Page Write Through) - // bits are set to disable caching for a memory mapping used - // for MMIO register access. We also disable caching using - // the MTRR registers for Pentium Pro and later chipsets so if - // MTRR support is enabled for your OS then you can safely ignore - // the isCached flag and always enable caching in the page - // tables. + /* TODO: This function maps a physical memory address to a linear */ + /* address in the address space of the calling process. */ + + /* NOTE: This function *must* be able to handle any phsyical base */ + /* address, and hence you will have to handle rounding of */ + /* the physical base address to a page boundary (ie: 4Kb on */ + /* x86 CPU's) to be able to properly map in the memory */ + /* region. */ + + /* NOTE: If possible the isCached bit should be used to ensure that */ + /* the PCD (Page Cache Disable) and PWT (Page Write Through) */ + /* bits are set to disable caching for a memory mapping used */ + /* for MMIO register access. We also disable caching using */ + /* the MTRR registers for Pentium Pro and later chipsets so if */ + /* MTRR support is enabled for your OS then you can safely ignore */ + /* the isCached flag and always enable caching in the page */ + /* tables. */ return NULL; } void PMAPI PM_freePhysicalAddr(void *ptr,ulong limit) { - // TODO: This function will free a physical memory mapping previously - // allocated with PM_mapPhysicalAddr() if at all possible. If - // you can't free physical memory mappings, simply do nothing. + /* TODO: This function will free a physical memory mapping previously */ + /* allocated with PM_mapPhysicalAddr() if at all possible. If */ + /* you can't free physical memory mappings, simply do nothing. */ } 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. */ return 0xFFFFFFFFUL; } void PMAPI PM_sleep(ulong milliseconds) { - // TODO: Put the process to sleep for milliseconds + /* TODO: Put the process to sleep for milliseconds */ } int PMAPI PM_getCOMPort(int port) { - // TODO: Re-code this to determine real values using the Plug and Play - // manager for the OS. + /* TODO: Re-code this to determine real values using the Plug and Play */ + /* manager for the OS. */ 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) { - // TODO: Re-code this to determine real values using the Plug and Play - // manager for the OS. + /* TODO: Re-code this to determine real values using the Plug and Play */ + /* manager for the OS. */ 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; } void * PMAPI PM_mallocShared(long size) { - // TODO: This is used to allocate memory that is shared between process - // that all access the common Nucleus drivers via a common display - // driver DLL. If your OS does not support shared memory (or if - // the display driver does not need to allocate shared memory - // for each process address space), this should just call PM_malloc. + /* TODO: This is used to allocate memory that is shared between process */ + /* that all access the common Nucleus drivers via a common display */ + /* driver DLL. If your OS does not support shared memory (or if */ + /* the display driver does not need to allocate shared memory */ + /* for each process address space), this should just call PM_malloc. */ return PM_malloc(size); } void PMAPI PM_freeShared(void *ptr) { - // TODO: Free the shared memory block. This will be called in the context - // of the original calling process that allocated the shared - // memory with PM_mallocShared. Simply call free if you do not - // need this. + /* TODO: Free the shared memory block. This will be called in the context */ + /* of the original calling process that allocated the shared */ + /* memory with PM_mallocShared. Simply call free if you do not */ + /* need this. */ PM_free(ptr); } void * PMAPI PM_mapToProcess(void *base,ulong limit) { - // TODO: This function is used to map a physical memory mapping - // previously allocated with PM_mapPhysicalAddr into the - // address space of the calling process. If the memory mapping - // allocated by PM_mapPhysicalAddr is global to all processes, - // simply return the pointer. + /* TODO: This function is used to map a physical memory mapping */ + /* previously allocated with PM_mapPhysicalAddr into the */ + /* address space of the calling process. If the memory mapping */ + /* allocated by PM_mapPhysicalAddr is global to all processes, */ + /* simply return the pointer. */ return base; } void * PMAPI PM_mapRealPointer(uint r_seg,uint r_off) { - // No BIOS access on the BeOS + /* No BIOS access on the BeOS */ return NULL; } void * PMAPI PM_allocRealSeg(uint size,uint *r_seg,uint *r_off) { - // No BIOS access on the BeOS + /* No BIOS access on the BeOS */ return NULL; } void PMAPI PM_freeRealSeg(void *mem) { - // No BIOS access on the BeOS + /* No BIOS access on the BeOS */ } void PMAPI DPMI_int86(int intno, DPMI_regs *regs) { - // No BIOS access on the BeOS + /* No BIOS access on the BeOS */ } int PMAPI PM_int86(int intno, RMREGS *in, RMREGS *out) { - // No BIOS access on the BeOS + /* No BIOS access on the BeOS */ return 0; } int PMAPI PM_int86x(int intno, RMREGS *in, RMREGS *out, RMSREGS *sregs) { - // No BIOS access on the BeOS + /* No BIOS access on the BeOS */ return 0; } void PMAPI PM_callRealMode(uint seg,uint off, RMREGS *in, RMSREGS *sregs) { - // No BIOS access on the BeOS + /* No BIOS access on the BeOS */ } void PMAPI PM_availableMemory(ulong *physical,ulong *total) { - // TODO: Report the amount of available memory, both the amount of - // physical memory left and the amount of virtual memory left. - // If the OS does not provide these services, report 0's. + /* TODO: Report the amount of available memory, both the amount of */ + /* physical memory left and the amount of virtual memory left. */ + /* If the OS does not provide these services, report 0's. */ *physical = *total = 0; } void * PMAPI PM_allocLockedMem(uint size,ulong *physAddr,ibool contiguous,ibool below16Meg) { - // TODO: Allocate a block of locked, physical memory of the specified - // size. This is used for bus master operations. If this is not - // supported by the OS, return NULL and bus mastering will not - // be used. + /* TODO: Allocate a block of locked, physical memory of the specified */ + /* size. This is used for bus master operations. If this is not */ + /* supported by the OS, return NULL and bus mastering will not */ + /* be used. */ return NULL; } void PMAPI PM_freeLockedMem(void *p,uint size,ibool contiguous) { - // TODO: Free a memory block allocated with PM_allocLockedMem. + /* TODO: Free a memory block allocated with PM_allocLockedMem. */ } void PMAPI PM_setBankA(int bank) { - // No BIOS access on the BeOS + /* No BIOS access on the BeOS */ } void PMAPI PM_setBankAB(int bank) { - // No BIOS access on the BeOS + /* No BIOS access on the BeOS */ } void PMAPI PM_setCRTStart(int x,int y,int waitVRT) { - // No BIOS access on the BeOS + /* No BIOS access on the BeOS */ } ibool PMAPI PM_enableWriteCombine(ulong base,ulong length,uint type) { - // TODO: This function should enable Pentium Pro and Pentium II MTRR - // write combining for the passed in physical memory base address - // and length. Normally this is done via calls to an OS specific - // device driver as this can only be done at ring 0. - // - // NOTE: This is a *very* important function to implement! If you do - // not implement, graphics performance on the latest Intel chips - // will be severly impaired. For sample code that can be used - // directly in a ring 0 device driver, see the MSDOS implementation - // which includes assembler code to do this directly (if the - // program is running at ring 0). + /* TODO: This function should enable Pentium Pro and Pentium II MTRR */ + /* write combining for the passed in physical memory base address */ + /* and length. Normally this is done via calls to an OS specific */ + /* device driver as this can only be done at ring 0. */ + /* */ + /* NOTE: This is a *very* important function to implement! If you do */ + /* not implement, graphics performance on the latest Intel chips */ + /* will be severly impaired. For sample code that can be used */ + /* directly in a ring 0 device driver, see the MSDOS implementation */ + /* which includes assembler code to do this directly (if the */ + /* program is running at ring 0). */ return false; } ibool PMAPI PM_doBIOSPOST(ushort axVal,ulong BIOSPhysAddr,void *mappedBIOS) { - // TODO: This function is used to run the BIOS POST code on a secondary - // controller to initialise it for use. This is not necessary - // for multi-controller operation, but it will make it a lot - // more convenicent for end users (otherwise they have to boot - // the system once with the secondary controller as primary, and - // then boot with both controllers installed). - // - // Even if you don't support full BIOS access, it would be - // adviseable to be able to POST the secondary controllers in the - // system using this function as a minimum requirement. Some - // graphics hardware has registers that contain values that only - // the BIOS knows about, which makes bring up a card from cold - // reset difficult if the BIOS has not POST'ed it. + /* TODO: This function is used to run the BIOS POST code on a secondary */ + /* controller to initialise it for use. This is not necessary */ + /* for multi-controller operation, but it will make it a lot */ + /* more convenicent for end users (otherwise they have to boot */ + /* the system once with the secondary controller as primary, and */ + /* then boot with both controllers installed). */ + /* */ + /* Even if you don't support full BIOS access, it would be */ + /* adviseable to be able to POST the secondary controllers in the */ + /* system using this function as a minimum requirement. Some */ + /* graphics hardware has registers that contain values that only */ + /* the BIOS knows about, which makes bring up a card from cold */ + /* reset difficult if the BIOS has not POST'ed it. */ return false; } @@ -506,7 +506,7 @@ ibool PMAPI PM_driveValid( char drive) { if (drive == 3) - return true; + return true; return false; } @@ -533,7 +533,7 @@ void PMAPI PM_setFileAttr( const char *filename, uint attrib) { - // TODO: Set the file attributes for a file + /* TODO: Set the file attributes for a file */ (void)filename; (void)attrib; } diff --git a/board/MAI/bios_emulator/scitech/src/pm/beos/ztimer.c b/board/MAI/bios_emulator/scitech/src/pm/beos/ztimer.c index a5637a5ecf6..a528b731771 100644 --- a/board/MAI/bios_emulator/scitech/src/pm/beos/ztimer.c +++ b/board/MAI/bios_emulator/scitech/src/pm/beos/ztimer.c @@ -36,7 +36,7 @@ Initialise the Zen Timer module internals. ****************************************************************************/ void _ZTimerInit(void) { - // TODO: Do any specific internal initialisation in here + /* TODO: Do any specific internal initialisation in here */ } /**************************************************************************** @@ -46,8 +46,8 @@ Start the Zen Timer counting. static void _LZTimerOn( LZTimerObject *tm) { - // TODO: Start the Zen Timer counting. This should be a macro if - // possible. + /* TODO: Start the Zen Timer counting. This should be a macro if */ + /* possible. */ } /**************************************************************************** @@ -57,8 +57,8 @@ Compute the lap time since the timer was started. static ulong _LZTimerLap( LZTimerObject *tm) { - // TODO: Compute the lap time between the current time and when the - // timer was started. + /* TODO: Compute the lap time between the current time and when the */ + /* timer was started. */ return 0; } @@ -69,7 +69,7 @@ Stop the Zen Timer counting. static void _LZTimerOff( LZTimerObject *tm) { - // TODO: Stop the timer counting. Should be a macro if possible. + /* TODO: Stop the timer counting. Should be a macro if possible. */ } /**************************************************************************** @@ -79,7 +79,7 @@ Compute the elapsed time in microseconds between start and end timings. static ulong _LZTimerCount( LZTimerObject *tm) { - // TODO: Compute the elapsed time and return it. Always microseconds. + /* TODO: Compute the elapsed time and return it. Always microseconds. */ return 0; } @@ -95,9 +95,9 @@ Read the Long Period timer from the OS ****************************************************************************/ static ulong _ULZReadTime(void) { - // TODO: Read the long period timer from the OS. The resolution of this - // timer should be around 1/20 of a second for timing long - // periods if possible. + /* TODO: Read the long period timer from the OS. The resolution of this */ + /* timer should be around 1/20 of a second for timing long */ + /* periods if possible. */ } /**************************************************************************** diff --git a/board/MAI/bios_emulator/scitech/src/pm/common.c b/board/MAI/bios_emulator/scitech/src/pm/common.c index b100b8ad42e..d5a8e8f1c75 100644 --- a/board/MAI/bios_emulator/scitech/src/pm/common.c +++ b/board/MAI/bios_emulator/scitech/src/pm/common.c @@ -98,9 +98,9 @@ static ibool TryPath( strcpy(filename,bpdpath); strcat(filename,dllname); if ((f = fopen(filename,"rb")) == NULL) - return false; + return false; if (cachedpath) - strcpy(cachedpath,bpdpath); + strcpy(cachedpath,bpdpath); fclose(f); return true; } @@ -121,20 +121,20 @@ static ibool GetLocalOverride(void) static ibool local_override = -1; if (local_override == -1) { - local_override = false; - strcpy(filename,PM_getNucleusPath()); - PM_backslash(filename); - strcat(filename,"graphics.ini"); - if ((f = fopen(filename,"r")) != NULL) { - while (!feof(f) && fgets(filename,sizeof(filename),f)) { - if (strnicmp(filename,"uselocal",8) == 0) { - local_override = ((*(filename+9) - '0') == 1); - break; - } - } - fclose(f); - } - } + local_override = false; + strcpy(filename,PM_getNucleusPath()); + PM_backslash(filename); + strcat(filename,"graphics.ini"); + if ((f = fopen(filename,"r")) != NULL) { + while (!feof(f) && fgets(filename,sizeof(filename),f)) { + if (strnicmp(filename,"uselocal",8) == 0) { + local_override = ((*(filename+9) - '0') == 1); + break; + } + } + fclose(f); + } + } return local_override; } @@ -164,44 +164,44 @@ ibool PMAPI PM_findBPD( /* On the first call determine the path to the Nucleus drivers */ if (cachedpath[0] == 0) { - /* First try in the global system Nucleus driver path if - * the local override setting is not enabled. - */ - PM_init(); - if (!GetLocalOverride()) { - if (TryPath(bpdpath,cachedpath,PM_getNucleusPath(),"",dllname)) - return true; - } - - /* Next try in the local application directory if available */ - if (localBPDPath[0] != 0) { - if (TryPath(bpdpath,cachedpath,localBPDPath,"",dllname)) - return true; - } - else { + /* First try in the global system Nucleus driver path if + * the local override setting is not enabled. + */ + PM_init(); + if (!GetLocalOverride()) { + if (TryPath(bpdpath,cachedpath,PM_getNucleusPath(),"",dllname)) + return true; + } + + /* Next try in the local application directory if available */ + if (localBPDPath[0] != 0) { + if (TryPath(bpdpath,cachedpath,localBPDPath,"",dllname)) + return true; + } + else { #if !defined(__WIN32_VXD__) && !defined(__NT_DRIVER__) - char *mgl_root; - if ((mgl_root = getenv("MGL_ROOT")) != NULL) { - if (TryPath(bpdpath,cachedpath,mgl_root,"drivers",dllname)) - return true; - } + char *mgl_root; + if ((mgl_root = getenv("MGL_ROOT")) != NULL) { + if (TryPath(bpdpath,cachedpath,mgl_root,"drivers",dllname)) + return true; + } #endif - PM_getCurrentPath(bpdpath,PM_MAX_PATH); - if (TryPath(bpdpath,cachedpath,bpdpath,"drivers",dllname)) - return true; - } - - /* Finally try in the global system path again so that we - * will still find the drivers in the global system path if - * the local override option is on, but the application does - * not have any local override drivers. - */ - if (TryPath(bpdpath,cachedpath,PM_getNucleusPath(),"",dllname)) - return true; - - /* Whoops, we can't find the BPD file! */ - return false; - } + PM_getCurrentPath(bpdpath,PM_MAX_PATH); + if (TryPath(bpdpath,cachedpath,bpdpath,"drivers",dllname)) + return true; + } + + /* Finally try in the global system path again so that we + * will still find the drivers in the global system path if + * the local override option is on, but the application does + * not have any local override drivers. + */ + if (TryPath(bpdpath,cachedpath,PM_getNucleusPath(),"",dllname)) + return true; + + /* Whoops, we can't find the BPD file! */ + return false; + } /* Always try in the previously discovered path */ return TryPath(bpdpath,NULL,cachedpath,"",dllname); @@ -216,9 +216,9 @@ static char *_stpcpy( const char *_src) { if (!_dest || !_src) - return 0; + return 0; while ((*_dest++ = *_src++) != 0) - ; + ; return --_dest; } @@ -233,13 +233,13 @@ static void safe_strncpy( unsigned maxlen) { if (dst) { - if(strlen(src) >= maxlen) { - strncpy(dst, src, maxlen); - dst[maxlen] = 0; - } - else - strcpy(dst, src); - } + if(strlen(src) >= maxlen) { + strncpy(dst, src, maxlen); + dst[maxlen] = 0; + } + else + strcpy(dst, src); + } } /**************************************************************************** @@ -250,16 +250,16 @@ static int findDot( char *p) { if (*(p-1) == '.') - p--; + p--; switch (*--p) { - case ':': - if (*(p-2) != '\0') - break; - case '/': - case '\\': - case '\0': - return true; - } + case ':': + if (*(p-2) != '\0') + break; + case '/': + case '\\': + case '\0': + return true; + } return false; } @@ -299,25 +299,25 @@ void PMAPI PM_makepath( const char *ext) { if (drive && *drive) { - *path++ = *drive; - *path++ = ':'; - } + *path++ = *drive; + *path++ = ':'; + } if (dir && *dir) { - path = _stpcpy(path,dir); - if (*(path-1) != '\\' && *(path-1) != '/') + path = _stpcpy(path,dir); + if (*(path-1) != '\\' && *(path-1) != '/') #ifdef __UNIX__ - *path++ = '/'; + *path++ = '/'; #else - *path++ = '\\'; + *path++ = '\\'; #endif - } + } if (name) - path = _stpcpy(path,name); + path = _stpcpy(path,name); if (ext && *ext) { - if (*ext != '.') - *path++ = '.'; - path = _stpcpy(path,ext); - } + if (*ext != '.') + *path++ = '.'; + path = _stpcpy(path,ext); + } *path = 0; } @@ -377,7 +377,7 @@ int PMAPI PM_splitpath( /* Copy filename into template up to PM_MAX_PATH characters */ p = buf; if ((temp = strlen(path)) > PM_MAX_PATH) - temp = PM_MAX_PATH; + temp = PM_MAX_PATH; *p++ = 0; strncpy(p, path, temp); *(p += temp) = 0; @@ -385,53 +385,53 @@ int PMAPI PM_splitpath( /* Split the filename and fill corresponding nonzero pointers */ temp = 0; for (;;) { - switch (*--p) { - case '.': - if (!temp && (*(p+1) == '\0')) - temp = findDot(p); - if ((!temp) && ((ret & PM_HAS_EXTENSION) == 0)) { - ret |= PM_HAS_EXTENSION; - safe_strncpy(ext, p, PM_MAX_PATH - 1); - *p = 0; - } - continue; - case ':': - if (p != &buf[2]) - continue; - case '\0': - if (temp) { - if (*++p) - ret |= PM_HAS_DIRECTORY; - safe_strncpy(dir, p, PM_MAX_PATH - 1); - *p-- = 0; - break; - } - case '/': - case '\\': - if (!temp) { - temp++; - if (*++p) - ret |= PM_HAS_FILENAME; - safe_strncpy(name, p, PM_MAX_PATH - 1); - *p-- = 0; - if (*p == 0 || (*p == ':' && p == &buf[2])) - break; - } - continue; - case '*': - case '?': - if (!temp) - ret |= PM_HAS_WILDCARDS; - default: - continue; - } - break; - } + switch (*--p) { + case '.': + if (!temp && (*(p+1) == '\0')) + temp = findDot(p); + if ((!temp) && ((ret & PM_HAS_EXTENSION) == 0)) { + ret |= PM_HAS_EXTENSION; + safe_strncpy(ext, p, PM_MAX_PATH - 1); + *p = 0; + } + continue; + case ':': + if (p != &buf[2]) + continue; + case '\0': + if (temp) { + if (*++p) + ret |= PM_HAS_DIRECTORY; + safe_strncpy(dir, p, PM_MAX_PATH - 1); + *p-- = 0; + break; + } + case '/': + case '\\': + if (!temp) { + temp++; + if (*++p) + ret |= PM_HAS_FILENAME; + safe_strncpy(name, p, PM_MAX_PATH - 1); + *p-- = 0; + if (*p == 0 || (*p == ':' && p == &buf[2])) + break; + } + continue; + case '*': + case '?': + if (!temp) + ret |= PM_HAS_WILDCARDS; + default: + continue; + } + break; + } if (*p == ':') { - if (buf[1]) - ret |= PM_HAS_DRIVE; - safe_strncpy(drive, &buf[1], PM_MAX_DRIVE - 1); - } + if (buf[1]) + ret |= PM_HAS_DRIVE; + safe_strncpy(drive, &buf[1], PM_MAX_DRIVE - 1); + } return ret; } @@ -466,15 +466,15 @@ void PMAPI PM_blockUntilTimeout( static ibool firstTime = true; if (firstTime) { - firstTime = false; - LZTimerOnExt(&tm); - } + firstTime = false; + LZTimerOnExt(&tm); + } else { - if ((msDelay = (microseconds - LZTimerLapExt(&tm)) / 1000L) > 0) - PM_sleep(msDelay); - while (LZTimerLapExt(&tm) < microseconds) - ; - LZTimerOffExt(&tm); - LZTimerOnExt(&tm); - } + if ((msDelay = (microseconds - LZTimerLapExt(&tm)) / 1000L) > 0) + PM_sleep(msDelay); + while (LZTimerLapExt(&tm) < microseconds) + ; + LZTimerOffExt(&tm); + LZTimerOnExt(&tm); + } } diff --git a/board/MAI/bios_emulator/scitech/src/pm/common/agp.c b/board/MAI/bios_emulator/scitech/src/pm/common/agp.c index 23f7e1e1458..d53bc88e143 100644 --- a/board/MAI/bios_emulator/scitech/src/pm/common/agp.c +++ b/board/MAI/bios_emulator/scitech/src/pm/common/agp.c @@ -54,22 +54,22 @@ size of the available AGP aperture in megabytes. ulong PMAPI PM_agpInit(void) { if ((agp = AGP_loadDriver(0)) == NULL) - return 0; + return 0; driver.dwSize = sizeof(driver); if (!agp->QueryFunctions(AGP_GET_DRIVERFUNCS,&driver)) - return 0; + return 0; switch (driver.GetApertureSize()) { - case agpSize4MB: return 4; - case agpSize8MB: return 8; - case agpSize16MB: return 16; - case agpSize32MB: return 32; - case agpSize64MB: return 64; - case agpSize128MB: return 128; - case agpSize256MB: return 256; - case agpSize512MB: return 512; - case agpSize1GB: return 1024; - case agpSize2GB: return 2048; - } + case agpSize4MB: return 4; + case agpSize8MB: return 8; + case agpSize16MB: return 16; + case agpSize32MB: return 32; + case agpSize64MB: return 64; + case agpSize128MB: return 128; + case agpSize256MB: return 256; + case agpSize512MB: return 512; + case agpSize1GB: return 1024; + case agpSize2GB: return 2048; + } return 0; } @@ -106,18 +106,18 @@ ibool PMAPI PM_agpReservePhysical( PM_physAddr *physAddr) { switch (type) { - case PM_agpUncached: - type = agpUncached; - break; - case PM_agpWriteCombine: - type = agpWriteCombine; - break; - case PM_agpIntelDCACHE: - type = agpIntelDCACHE; - break; - default: - return false; - } + case PM_agpUncached: + type = agpUncached; + break; + case PM_agpWriteCombine: + type = agpWriteCombine; + break; + case PM_agpIntelDCACHE: + type = agpIntelDCACHE; + break; + default: + return false; + } return driver.ReservePhysical(numPages,type,physContext,physAddr) == nOK; } @@ -187,4 +187,3 @@ ibool PMAPI PM_agpFreePhysical( } #endif /* !REALMODE */ - diff --git a/board/MAI/bios_emulator/scitech/src/pm/common/keyboard.c b/board/MAI/bios_emulator/scitech/src/pm/common/keyboard.c index 79b4040ac1a..36867bdba71 100644 --- a/board/MAI/bios_emulator/scitech/src/pm/common/keyboard.c +++ b/board/MAI/bios_emulator/scitech/src/pm/common/keyboard.c @@ -52,18 +52,18 @@ static uchar translateScan( int n,pivot,val; for (n = count; n > 0; ) { - pivot = n >> 1; - test = table + pivot; - val = scanCode - test->scanCode; - if (val < 0) - n = pivot; - else if (val == 0) - return test->asciiCode; - else { - table = test + 1; - n -= pivot + 1; - } - } + pivot = n >> 1; + test = table + pivot; + val = scanCode - test->scanCode; + if (val < 0) + n = pivot; + else if (val == 0) + return test->asciiCode; + else { + table = test + 1; + n -= pivot + 1; + } + } return 0; } @@ -84,35 +84,35 @@ void _EVT_maskKeyCode( evt->message &= ~0xFF; if (evt->modifiers & EVT_NUMLOCK) { - if ((ascii = translateScan(scan,EVT.codePage->numPad,EVT.codePage->numPadLen)) != 0) { - evt->message |= ascii; - return; - } - } + if ((ascii = translateScan(scan,EVT.codePage->numPad,EVT.codePage->numPadLen)) != 0) { + evt->message |= ascii; + return; + } + } if (evt->modifiers & EVT_CTRLSTATE) { - evt->message |= translateScan(scan,EVT.codePage->ctrl,EVT.codePage->ctrlLen); - return; - } + evt->message |= translateScan(scan,EVT.codePage->ctrl,EVT.codePage->ctrlLen); + return; + } if (evt->modifiers & EVT_CAPSLOCK) { - if (evt->modifiers & EVT_SHIFTKEY) { - if ((ascii = translateScan(scan,EVT.codePage->shiftCaps,EVT.codePage->shiftCapsLen)) != 0) { - evt->message |= ascii; - return; - } - } - else { - if ((ascii = translateScan(scan,EVT.codePage->caps,EVT.codePage->capsLen)) != 0) { - evt->message |= ascii; - return; - } - } - } + if (evt->modifiers & EVT_SHIFTKEY) { + if ((ascii = translateScan(scan,EVT.codePage->shiftCaps,EVT.codePage->shiftCapsLen)) != 0) { + evt->message |= ascii; + return; + } + } + else { + if ((ascii = translateScan(scan,EVT.codePage->caps,EVT.codePage->capsLen)) != 0) { + evt->message |= ascii; + return; + } + } + } if (evt->modifiers & EVT_SHIFTKEY) { - if ((ascii = translateScan(scan,EVT.codePage->shift,EVT.codePage->shiftLen)) != 0) { - evt->message |= ascii; - return; - } - } + if ((ascii = translateScan(scan,EVT.codePage->shift,EVT.codePage->shiftLen)) != 0) { + evt->message |= ascii; + return; + } + } evt->message |= translateScan(scan,EVT.codePage->normal,EVT.codePage->normalLen); } @@ -124,9 +124,9 @@ static ibool _EVT_isKeyDown( uchar scanCode) { if (scanCode > 0x7F) - return false; + return false; else - return EVT.keyTable[scanCode] != 0; + return EVT.keyTable[scanCode] != 0; } /**************************************************************************** @@ -139,7 +139,7 @@ Adds a new keyboard event to the event queue. This routine is called from within the keyboard interrupt subroutine! NOTE: Interrupts are OFF when this routine is called by the keyboard ISR, - and we leave them OFF the entire time. + and we leave them OFF the entire time. ****************************************************************************/ static void addKeyEvent( uint what, @@ -148,31 +148,31 @@ static void addKeyEvent( event_t evt; if (EVT.count < EVENTQSIZE) { - /* Save information in event record */ - evt.when = _EVT_getTicks(); - evt.what = what; - evt.message = message | 0x10000UL; - evt.where_x = 0; - evt.where_y = 0; - evt.relative_x = 0; - evt.relative_y = 0; - evt.modifiers = EVT.keyModifiers; - if (evt.what == EVT_KEYREPEAT) { - if (EVT.oldKey != -1) - EVT.evtq[EVT.oldKey].message += 0x10000UL; - else { - EVT.oldKey = EVT.freeHead; - addEvent(&evt); /* Add to tail of event queue */ - } - } - else { + /* Save information in event record */ + evt.when = _EVT_getTicks(); + evt.what = what; + evt.message = message | 0x10000UL; + evt.where_x = 0; + evt.where_y = 0; + evt.relative_x = 0; + evt.relative_y = 0; + evt.modifiers = EVT.keyModifiers; + if (evt.what == EVT_KEYREPEAT) { + if (EVT.oldKey != -1) + EVT.evtq[EVT.oldKey].message += 0x10000UL; + else { + EVT.oldKey = EVT.freeHead; + addEvent(&evt); /* Add to tail of event queue */ + } + } + else { #ifdef __QNX__ - _EVT_maskKeyCode(&evt); + _EVT_maskKeyCode(&evt); #endif - addEvent(&evt); /* Add to tail of event queue */ - } - EVT.oldMove = -1; - } + addEvent(&evt); /* Add to tail of event queue */ + } + EVT.oldMove = -1; + } } /**************************************************************************** @@ -184,7 +184,7 @@ static int kbWaitForWriteReady(void) { int timeout = 8192; while ((timeout > 0) && (PM_inpb(0x64) & 0x02)) - timeout--; + timeout--; return (timeout > 0); } @@ -197,7 +197,7 @@ static int kbWaitForReadReady(void) { int timeout = 8192; while ((timeout > 0) && (!(PM_inpb(0x64) & 0x01))) - timeout--; + timeout--; return (timeout > 0); } @@ -215,20 +215,20 @@ static int kbSendData( int timeout, temp; do { - if (!kbWaitForWriteReady()) - return 0; - PM_outpb(0x60,data); - timeout = 8192; - while (--timeout > 0) { - if (!kbWaitForReadReady()) - return 0; - temp = PM_inpb(0x60); - if (temp == 0xFA) - return 1; - if (temp == 0xFE) - break; - } - } while ((resends-- > 0) && (timeout > 0)); + if (!kbWaitForWriteReady()) + return 0; + PM_outpb(0x60,data); + timeout = 8192; + while (--timeout > 0) { + if (!kbWaitForReadReady()) + return 0; + temp = PM_inpb(0x60); + if (temp == 0xFA) + return 1; + if (temp == 0xFE) + break; + } + } while ((resends-- > 0) && (timeout > 0)); return 0; } @@ -245,10 +245,10 @@ static void setLEDS( uint modifiers) { if (EVT.allowLEDS) { - if (!kbSendData(0xED) || !kbSendData((modifiers>>9) & 7)) { - kbSendData(0xF4); - } - } + if (!kbSendData(0xED) || !kbSendData((modifiers>>9) & 7)) { + kbSendData(0xF4); + } + } } /**************************************************************************** @@ -256,7 +256,7 @@ REMARKS: Function to process raw scan codes read from the keyboard controller. NOTE: Interrupts are OFF when this routine is called by the keyboard ISR, - and we leave them OFF the entire time. + and we leave them OFF the entire time. {secret} ****************************************************************************/ void processRawScanCode( @@ -267,156 +267,156 @@ void processRawScanCode( int what; if (pauseLoop) { - /* Skip scan codes until the pause key sequence has been read */ - pauseLoop--; - } + /* Skip scan codes until the pause key sequence has been read */ + pauseLoop--; + } else if (scan == 0xE0) { - /* This signals the start of an extended scan code sequence */ - extended = 1; - } + /* This signals the start of an extended scan code sequence */ + extended = 1; + } else if (scan == 0xE1) { - /* The Pause key sends a strange scan code sequence, which is: - * - * E1 1D 52 E1 9D D2 - * - * However there is never any release code nor any auto-repeat for - * this key. For this reason we simply ignore the key and skip the - * next 5 scan codes read from the keyboard. - */ - pauseLoop = 5; - } + /* The Pause key sends a strange scan code sequence, which is: + * + * E1 1D 52 E1 9D D2 + * + * However there is never any release code nor any auto-repeat for + * this key. For this reason we simply ignore the key and skip the + * next 5 scan codes read from the keyboard. + */ + pauseLoop = 5; + } else { - /* Process the scan code normally (it may be an extended code - * however!). Bit 7 means key was released, and bits 0-6 are the - * scan code. - */ - what = (scan & 0x80) ? EVT_KEYUP : EVT_KEYDOWN; - scan &= 0x7F; - if (extended) { - extended = 0; - if (scan == 0x2A || scan == 0x36) { - /* Ignore these extended scan code sequences. These are - * used by the keyboard controller to wrap around certain - * key sequences for the keypad (and when NUMLOCK is down - * internally). - */ - return; - } + /* Process the scan code normally (it may be an extended code + * however!). Bit 7 means key was released, and bits 0-6 are the + * scan code. + */ + what = (scan & 0x80) ? EVT_KEYUP : EVT_KEYDOWN; + scan &= 0x7F; + if (extended) { + extended = 0; + if (scan == 0x2A || scan == 0x36) { + /* Ignore these extended scan code sequences. These are + * used by the keyboard controller to wrap around certain + * key sequences for the keypad (and when NUMLOCK is down + * internally). + */ + return; + } - /* Convert extended codes for key sequences that we map to - * virtual scan codes so the user can detect them in their - * code. - */ - switch (scan) { - case KB_leftCtrl: scan = KB_rightCtrl; break; - case KB_leftAlt: scan = KB_rightAlt; break; - case KB_divide: scan = KB_padDivide; break; - case KB_enter: scan = KB_padEnter; break; - case KB_padTimes: scan = KB_sysReq; break; - } - } - else { - /* Convert regular scan codes for key sequences that we map to - * virtual scan codes so the user can detect them in their - * code. - */ - switch (scan) { - case KB_left: scan = KB_padLeft; break; - case KB_right: scan = KB_padRight; break; - case KB_up: scan = KB_padUp; break; - case KB_down: scan = KB_padDown; break; - case KB_insert: scan = KB_padInsert; break; - case KB_delete: scan = KB_padDelete; break; - case KB_home: scan = KB_padHome; break; - case KB_end: scan = KB_padEnd; break; - case KB_pageUp: scan = KB_padPageUp; break; - case KB_pageDown: scan = KB_padPageDown; break; - } - } + /* Convert extended codes for key sequences that we map to + * virtual scan codes so the user can detect them in their + * code. + */ + switch (scan) { + case KB_leftCtrl: scan = KB_rightCtrl; break; + case KB_leftAlt: scan = KB_rightAlt; break; + case KB_divide: scan = KB_padDivide; break; + case KB_enter: scan = KB_padEnter; break; + case KB_padTimes: scan = KB_sysReq; break; + } + } + else { + /* Convert regular scan codes for key sequences that we map to + * virtual scan codes so the user can detect them in their + * code. + */ + switch (scan) { + case KB_left: scan = KB_padLeft; break; + case KB_right: scan = KB_padRight; break; + case KB_up: scan = KB_padUp; break; + case KB_down: scan = KB_padDown; break; + case KB_insert: scan = KB_padInsert; break; + case KB_delete: scan = KB_padDelete; break; + case KB_home: scan = KB_padHome; break; + case KB_end: scan = KB_padEnd; break; + case KB_pageUp: scan = KB_padPageUp; break; + case KB_pageDown: scan = KB_padPageDown; break; + } + } - /* Determine if the key is an UP, DOWN or REPEAT and maintain the - * up/down status of all keys in our global key array. - */ - if (what == EVT_KEYDOWN) { - if (EVT.keyTable[scan]) - what = EVT_KEYREPEAT; - else - EVT.keyTable[scan] = scan; - } - else { - EVT.keyTable[scan] = 0; - } + /* Determine if the key is an UP, DOWN or REPEAT and maintain the + * up/down status of all keys in our global key array. + */ + if (what == EVT_KEYDOWN) { + if (EVT.keyTable[scan]) + what = EVT_KEYREPEAT; + else + EVT.keyTable[scan] = scan; + } + else { + EVT.keyTable[scan] = 0; + } - /* Handle shift key modifiers */ - if (what != EVT_KEYREPEAT) { - switch (scan) { - case KB_capsLock: - if (what == EVT_KEYDOWN) - EVT.keyModifiers ^= EVT_CAPSLOCK; - setLEDS(EVT.keyModifiers); - break; - case KB_numLock: - if (what == EVT_KEYDOWN) - EVT.keyModifiers ^= EVT_NUMLOCK; - setLEDS(EVT.keyModifiers); - break; - case KB_scrollLock: - if (what == EVT_KEYDOWN) - EVT.keyModifiers ^= EVT_SCROLLLOCK; - setLEDS(EVT.keyModifiers); - break; - case KB_leftShift: - if (what == EVT_KEYUP) - EVT.keyModifiers &= ~EVT_LEFTSHIFT; - else - EVT.keyModifiers |= EVT_LEFTSHIFT; - break; - case KB_rightShift: - if (what == EVT_KEYUP) - EVT.keyModifiers &= ~EVT_RIGHTSHIFT; - else - EVT.keyModifiers |= EVT_RIGHTSHIFT; - break; - case KB_leftCtrl: - if (what == EVT_KEYUP) - EVT.keyModifiers &= ~EVT_LEFTCTRL; - else - EVT.keyModifiers |= EVT_LEFTCTRL; - break; - case KB_rightCtrl: - if (what == EVT_KEYUP) - EVT.keyModifiers &= ~EVT_RIGHTCTRL; - else - EVT.keyModifiers |= EVT_RIGHTCTRL; - break; - case KB_leftAlt: - if (what == EVT_KEYUP) - EVT.keyModifiers &= ~EVT_LEFTALT; - else - EVT.keyModifiers |= EVT_LEFTALT; - break; - case KB_rightAlt: - if (what == EVT_KEYUP) - EVT.keyModifiers &= ~EVT_RIGHTALT; - else - EVT.keyModifiers |= EVT_RIGHTALT; - break; + /* Handle shift key modifiers */ + if (what != EVT_KEYREPEAT) { + switch (scan) { + case KB_capsLock: + if (what == EVT_KEYDOWN) + EVT.keyModifiers ^= EVT_CAPSLOCK; + setLEDS(EVT.keyModifiers); + break; + case KB_numLock: + if (what == EVT_KEYDOWN) + EVT.keyModifiers ^= EVT_NUMLOCK; + setLEDS(EVT.keyModifiers); + break; + case KB_scrollLock: + if (what == EVT_KEYDOWN) + EVT.keyModifiers ^= EVT_SCROLLLOCK; + setLEDS(EVT.keyModifiers); + break; + case KB_leftShift: + if (what == EVT_KEYUP) + EVT.keyModifiers &= ~EVT_LEFTSHIFT; + else + EVT.keyModifiers |= EVT_LEFTSHIFT; + break; + case KB_rightShift: + if (what == EVT_KEYUP) + EVT.keyModifiers &= ~EVT_RIGHTSHIFT; + else + EVT.keyModifiers |= EVT_RIGHTSHIFT; + break; + case KB_leftCtrl: + if (what == EVT_KEYUP) + EVT.keyModifiers &= ~EVT_LEFTCTRL; + else + EVT.keyModifiers |= EVT_LEFTCTRL; + break; + case KB_rightCtrl: + if (what == EVT_KEYUP) + EVT.keyModifiers &= ~EVT_RIGHTCTRL; + else + EVT.keyModifiers |= EVT_RIGHTCTRL; + break; + case KB_leftAlt: + if (what == EVT_KEYUP) + EVT.keyModifiers &= ~EVT_LEFTALT; + else + EVT.keyModifiers |= EVT_LEFTALT; + break; + case KB_rightAlt: + if (what == EVT_KEYUP) + EVT.keyModifiers &= ~EVT_RIGHTALT; + else + EVT.keyModifiers |= EVT_RIGHTALT; + break; #ifdef SUPPORT_CTRL_ALT_DEL - case KB_delete: - if ((EVT.keyModifiers & EVT_CTRLSTATE) && (EVT.keyModifiers & EVT_ALTSTATE)) - Reboot(); - break; + case KB_delete: + if ((EVT.keyModifiers & EVT_CTRLSTATE) && (EVT.keyModifiers & EVT_ALTSTATE)) + Reboot(); + break; #endif - } - } + } + } - /* Add the untranslated key code to the event queue. All - * translation to ASCII from the key codes occurs when the key - * is extracted from the queue, saving time in the low level - * interrupt handler. - */ - addKeyEvent(what,scan << 8); - } + /* Add the untranslated key code to the event queue. All + * translation to ASCII from the key codes occurs when the key + * is extracted from the queue, saving time in the low level + * interrupt handler. + */ + addKeyEvent(what,scan << 8); + } } /**************************************************************************** @@ -442,9 +442,8 @@ void EVTAPI EVT_allowLEDS( { EVT.allowLEDS = true; if (enable) - setLEDS(EVT.keyModifiers); + setLEDS(EVT.keyModifiers); else - setLEDS(0); + setLEDS(0); EVT.allowLEDS = enable; } - diff --git a/board/MAI/bios_emulator/scitech/src/pm/common/mtrr.c b/board/MAI/bios_emulator/scitech/src/pm/common/mtrr.c index d6ced6eadce..eed5f45c9e9 100644 --- a/board/MAI/bios_emulator/scitech/src/pm/common/mtrr.c +++ b/board/MAI/bios_emulator/scitech/src/pm/common/mtrr.c @@ -106,26 +106,26 @@ static int MTRR_haveWriteCombine(void) ulong config,dummy; switch (cpuFamily) { - case CPU_AMD: - if (cpuType < CPU_AMDAthlon) { - /* AMD K6-2 stepping 8 and later support the MTRR registers. - * The earlier K6-2 steppings (300Mhz models) do not - * support MTRR's. - */ - if ((cpuType < CPU_AMDK6_2) || (cpuType == CPU_AMDK6_2 && cpuStepping < 8)) - return 0; - return 1; - } - /* Fall through for AMD Athlon which uses P6 style MTRR's */ - case CPU_Intel: - _MTRR_readMSR(INTEL_cap_MSR,&config,&dummy); - return (config & (1 << 10)); - case CPU_Cyrix: - /* Cyrix 6x86 and later support the MTRR registers */ - if (cpuType < CPU_Cyrix6x86) - return 0; - return 1; - } + case CPU_AMD: + if (cpuType < CPU_AMDAthlon) { + /* AMD K6-2 stepping 8 and later support the MTRR registers. + * The earlier K6-2 steppings (300Mhz models) do not + * support MTRR's. + */ + if ((cpuType < CPU_AMDK6_2) || (cpuType == CPU_AMDK6_2 && cpuStepping < 8)) + return 0; + return 1; + } + /* Fall through for AMD Athlon which uses P6 style MTRR's */ + case CPU_Intel: + _MTRR_readMSR(INTEL_cap_MSR,&config,&dummy); + return (config & (1 << 10)); + case CPU_Cyrix: + /* Cyrix 6x86 and later support the MTRR registers */ + if (cpuType < CPU_Cyrix6x86) + return 0; + return 1; + } return 0; } @@ -149,10 +149,10 @@ static int GENERIC_getFreeRegion( ulong lbase,lsize; for (i = 0; i < numMTRR; i++) { - getMTRR(i,&lbase,&lsize,<ype); - if (lsize < 1) - return i; - } + getMTRR(i,&lbase,&lsize,<ype); + if (lsize < 1) + return i; + } (void)base; (void)size; return -1; @@ -178,10 +178,10 @@ static int AMDK6_getFreeRegion( ulong lbase,lsize; for (i = 0; i < numMTRR; i++) { - getMTRR(i,&lbase,&lsize,<ype); - if (lsize < 1) - return i; - } + getMTRR(i,&lbase,&lsize,<ype); + if (lsize < 1) + return i; + } (void)base; (void)size; return -1; @@ -207,23 +207,23 @@ static int CYRIX_getFreeRegion( ulong lbase, lsize; if (size > 0x2000000UL) { - /* If we are to set up a region >32M then look at ARR7 immediately */ - getMTRR(7,&lbase,&lsize,<ype); - if (lsize < 1) - return 7; - } + /* If we are to set up a region >32M then look at ARR7 immediately */ + getMTRR(7,&lbase,&lsize,<ype); + if (lsize < 1) + return 7; + } else { - /* Check ARR0-6 registers */ - for (i = 0; i < 7; i++) { - getMTRR(i,&lbase,&lsize,<ype); - if (lsize < 1) - return i; - } - /* Try ARR7 but its size must be at least 256K */ - getMTRR(7,&lbase,&lsize,<ype); - if ((lsize < 1) && (size >= 0x40000)) - return i; - } + /* Check ARR0-6 registers */ + for (i = 0; i < 7; i++) { + getMTRR(i,&lbase,&lsize,<ype); + if (lsize < 1) + return i; + } + /* Try ARR7 but its size must be at least 256K */ + getMTRR(7,&lbase,&lsize,<ype); + if ((lsize < 1) && (size >= 0x40000)) + return i; + } (void)base; return -1; } @@ -240,20 +240,20 @@ static void MTRR_beginUpdate( { c->flags = _MTRR_disableInt(); if (cpuFamily != CPU_AMD || (cpuFamily == CPU_AMD && cpuType >= CPU_AMDAthlon)) { - switch (cpuFamily) { - case CPU_Intel: - case CPU_AMD: - /* Disable MTRRs, and set the default type to uncached */ - c->cr4Val = _MTRR_saveCR4(); - _MTRR_readMSR(INTEL_defType_MSR,&c->defTypeLo,&c->defTypeHi); - _MTRR_writeMSR(INTEL_defType_MSR,c->defTypeLo & 0xF300UL,c->defTypeHi); - break; - case CPU_Cyrix: - c->ccr3 = _MTRR_getCx86(CX86_CCR3); - _MTRR_setCx86(CX86_CCR3, (uchar)((c->ccr3 & 0x0F) | 0x10)); - break; - } - } + switch (cpuFamily) { + case CPU_Intel: + case CPU_AMD: + /* Disable MTRRs, and set the default type to uncached */ + c->cr4Val = _MTRR_saveCR4(); + _MTRR_readMSR(INTEL_defType_MSR,&c->defTypeLo,&c->defTypeHi); + _MTRR_writeMSR(INTEL_defType_MSR,c->defTypeLo & 0xF300UL,c->defTypeHi); + break; + case CPU_Cyrix: + c->ccr3 = _MTRR_getCx86(CX86_CCR3); + _MTRR_setCx86(CX86_CCR3, (uchar)((c->ccr3 & 0x0F) | 0x10)); + break; + } + } } /**************************************************************************** @@ -267,18 +267,18 @@ static void MTRR_endUpdate( MTRRContext *c) { if (cpuFamily != CPU_AMD || (cpuFamily == CPU_AMD && cpuType >= CPU_AMDAthlon)) { - PM_flushTLB(); - switch (cpuFamily) { - case CPU_Intel: - case CPU_AMD: - _MTRR_writeMSR(INTEL_defType_MSR,c->defTypeLo,c->defTypeHi); - _MTRR_restoreCR4(c->cr4Val); - break; - case CPU_Cyrix: - _MTRR_setCx86(CX86_CCR3,(uchar)c->ccr3); - break; - } - } + PM_flushTLB(); + switch (cpuFamily) { + case CPU_Intel: + case CPU_AMD: + _MTRR_writeMSR(INTEL_defType_MSR,c->defTypeLo,c->defTypeHi); + _MTRR_restoreCR4(c->cr4Val); + break; + case CPU_Cyrix: + _MTRR_setCx86(CX86_CCR3,(uchar)c->ccr3); + break; + } + } /* Re-enable interrupts (if enabled previously) */ _MTRR_restoreInt(c->flags); @@ -304,12 +304,12 @@ static void INTEL_getMTRR( _MTRR_readMSR(INTEL_physMask_MSR(reg),&maskLo,&hi); if ((maskLo & 0x800) == 0) { - /* MTRR is disabled, so it is free */ - *base = 0; - *size = 0; - *type = 0; - return; - } + /* MTRR is disabled, so it is free */ + *base = 0; + *size = 0; + *type = 0; + return; + } _MTRR_readMSR(INTEL_physBase_MSR(reg),&baseLo,&hi); maskLo = (maskLo & 0xFFFFF000UL); *size = ~(maskLo - 1); @@ -338,15 +338,15 @@ static void INTEL_setMTRR( MTRR_beginUpdate(&c); if (size == 0) { - /* The invalid bit is kept in the mask, so we simply clear the - * relevant mask register to disable a range. - */ - _MTRR_writeMSR(INTEL_physMask_MSR(reg),0,0); - } + /* The invalid bit is kept in the mask, so we simply clear the + * relevant mask register to disable a range. + */ + _MTRR_writeMSR(INTEL_physMask_MSR(reg),0,0); + } else { - _MTRR_writeMSR(INTEL_physBase_MSR(reg),base | type,0); - _MTRR_writeMSR(INTEL_physMask_MSR(reg),~(size - 1) | 0x800,0); - } + _MTRR_writeMSR(INTEL_physBase_MSR(reg),base | type,0); + _MTRR_writeMSR(INTEL_physMask_MSR(reg),~(size - 1) | 0x800,0); + } MTRR_endUpdate(&c); } @@ -386,19 +386,19 @@ static void AMD_getMTRR( /* Upper dword is region 1, lower is region 0 */ _MTRR_readMSR(0xC0000085, &low, &high); if (reg == 1) - low = high; + low = high; /* Find the base and type for the region */ *base = low & 0xFFFE0000; *type = 0; if (low & 1) - *type = PM_MTRR_UNCACHABLE; + *type = PM_MTRR_UNCACHABLE; if (low & 2) - *type = PM_MTRR_WRCOMB; + *type = PM_MTRR_WRCOMB; if ((low & 3) == 0) { - *size = 0; - return; - } + *size = 0; + return; + } /* This needs a little explaining. The size is stored as an * inverted mask of bits of 128K granularity 15 bits long offset @@ -441,26 +441,26 @@ static void AMD_setMTRR( MTRR_beginUpdate(&c); _MTRR_readMSR(0xC0000085, &low, &high); if (size == 0) { - /* Clear register to disable */ - if (reg) - high = 0; - else - low = 0; - } + /* Clear register to disable */ + if (reg) + high = 0; + else + low = 0; + } else { - /* Set the register to the base (already shifted for us), the - * type (off by one) and an inverted bitmask of the size - * The size is the only odd bit. We are fed say 512K - * We invert this and we get 111 1111 1111 1011 but - * if you subtract one and invert you get the desired - * 111 1111 1111 1100 mask - */ - newVal = (((~(size-1)) >> 15) & 0x0001FFFC) | base | (type+1); - if (reg) - high = newVal; - else - low = newVal; - } + /* Set the register to the base (already shifted for us), the + * type (off by one) and an inverted bitmask of the size + * The size is the only odd bit. We are fed say 512K + * We invert this and we get 111 1111 1111 1011 but + * if you subtract one and invert you get the desired + * 111 1111 1111 1100 mask + */ + newVal = (((~(size-1)) >> 15) & 0x0001FFFC) | base | (type+1); + if (reg) + high = newVal; + else + low = newVal; + } /* The writeback rule is quite specific. See the manual. Its * disable local interrupts, write back the cache, set the MTRR @@ -507,29 +507,29 @@ static void CYRIX_getMTRR( * Note: shift==0xF means 4G, this is unsupported. */ if (shift) - *size = (reg < 7 ? 0x800UL : 0x20000UL) << shift; + *size = (reg < 7 ? 0x800UL : 0x20000UL) << shift; else - *size = 0; + *size = 0; /* Bit 0 is Cache Enable on ARR7, Cache Disable on ARR0-ARR6 */ if (reg < 7) { - switch (rcr) { - case 1: *type = PM_MTRR_UNCACHABLE; break; - case 8: *type = PM_MTRR_WRBACK; break; - case 9: *type = PM_MTRR_WRCOMB; break; - case 24: - default: *type = PM_MTRR_WRTHROUGH; break; - } - } + switch (rcr) { + case 1: *type = PM_MTRR_UNCACHABLE; break; + case 8: *type = PM_MTRR_WRBACK; break; + case 9: *type = PM_MTRR_WRCOMB; break; + case 24: + default: *type = PM_MTRR_WRTHROUGH; break; + } + } else { - switch (rcr) { - case 0: *type = PM_MTRR_UNCACHABLE; break; - case 8: *type = PM_MTRR_WRCOMB; break; - case 9: *type = PM_MTRR_WRBACK; break; - case 25: - default: *type = PM_MTRR_WRTHROUGH; break; - } - } + switch (rcr) { + case 0: *type = PM_MTRR_UNCACHABLE; break; + case 8: *type = PM_MTRR_WRCOMB; break; + case 9: *type = PM_MTRR_WRBACK; break; + case 25: + default: *type = PM_MTRR_WRTHROUGH; break; + } + } } /**************************************************************************** @@ -557,23 +557,23 @@ static void CYRIX_setMTRR( size >>= (reg < 7 ? 12 : 18); size &= 0x7FFF; /* Make sure arr_size <= 14 */ for (arr_size = 0; size; arr_size++, size >>= 1) - ; + ; if (reg < 7) { - switch (type) { - case PM_MTRR_UNCACHABLE: arr_type = 1; break; - case PM_MTRR_WRCOMB: arr_type = 9; break; - case PM_MTRR_WRTHROUGH: arr_type = 24; break; - default: arr_type = 8; break; - } - } + switch (type) { + case PM_MTRR_UNCACHABLE: arr_type = 1; break; + case PM_MTRR_WRCOMB: arr_type = 9; break; + case PM_MTRR_WRTHROUGH: arr_type = 24; break; + default: arr_type = 8; break; + } + } else { - switch (type) { - case PM_MTRR_UNCACHABLE: arr_type = 0; break; - case PM_MTRR_WRCOMB: arr_type = 8; break; - case PM_MTRR_WRTHROUGH: arr_type = 25; break; - default: arr_type = 9; break; - } - } + switch (type) { + case PM_MTRR_UNCACHABLE: arr_type = 0; break; + case PM_MTRR_WRCOMB: arr_type = 8; break; + case PM_MTRR_WRTHROUGH: arr_type = 25; break; + default: arr_type = 9; break; + } + } MTRR_beginUpdate(&c); _MTRR_setCx86((uchar)arr, ((uchar*)&base)[3]); _MTRR_setCx86((uchar)(arr+1), ((uchar*)&base)[2]); @@ -615,28 +615,28 @@ static void CYRIX_initARR(void) ccr[5] = _MTRR_getCx86(CX86_CCR5); ccr[6] = _MTRR_getCx86(CX86_CCR6); if (ccr[3] & 1) - ccrc[3] = 1; + ccrc[3] = 1; else { - /* Disable SMM mode (bit 1), access to SMM memory (bit 2) and - * access to SMM memory through ARR3 (bit 7). - */ - if (ccr[6] & 0x02) { - ccr[6] &= 0xFD; - ccrc[6] = 1; /* Disable write protection of ARR3. */ - _MTRR_setCx86(CX86_CCR6,ccr[6]); - } - } + /* Disable SMM mode (bit 1), access to SMM memory (bit 2) and + * access to SMM memory through ARR3 (bit 7). + */ + if (ccr[6] & 0x02) { + ccr[6] &= 0xFD; + ccrc[6] = 1; /* Disable write protection of ARR3. */ + _MTRR_setCx86(CX86_CCR6,ccr[6]); + } + } /* If we changed CCR1 in memory, change it in the processor, too. */ if (ccrc[1]) - _MTRR_setCx86(CX86_CCR1,ccr[1]); + _MTRR_setCx86(CX86_CCR1,ccr[1]); /* Enable ARR usage by the processor */ if (!(ccr[5] & 0x20)) { - ccr[5] |= 0x20; - ccrc[5] = 1; - _MTRR_setCx86(CX86_CCR5,ccr[5]); - } + ccr[5] |= 0x20; + ccrc[5] = 1; + _MTRR_setCx86(CX86_CCR5,ccr[5]); + } /* We are finished updating */ MTRR_endUpdate(&c); @@ -654,72 +654,72 @@ void MTRR_init(void) /* Check that we have a compatible CPU */ if (numMTRR == -1) { - numMTRR = 0; - if (!_MTRR_isRing0()) - return; - cpu = CPU_getProcessorType(); - cpuFamily = cpu & CPU_familyMask; - cpuType = cpu & CPU_mask; - cpuStepping = (cpu & CPU_steppingMask) >> CPU_steppingShift; - switch (cpuFamily) { - case CPU_Intel: - /* Intel Pentium Pro and later support the MTRR registers */ - if (cpuType < CPU_PentiumPro) - return; - _MTRR_readMSR(INTEL_cap_MSR,&eax,&edx); - numMTRR = eax & 0xFF; - getMTRR = INTEL_getMTRR; - setMTRR = INTEL_setMTRR; - getFreeRegion = GENERIC_getFreeRegion; - INTEL_disableBankedWriteCombine(); - break; - case CPU_AMD: - /* AMD K6-2 and later support the MTRR registers */ - if ((cpuType < CPU_AMDK6_2) || (cpuType == CPU_AMDK6_2 && cpuStepping < 8)) - return; - if (cpuType < CPU_AMDAthlon) { - numMTRR = 2; /* AMD CPU's have 2 MTRR's */ - getMTRR = AMD_getMTRR; - setMTRR = AMD_setMTRR; - getFreeRegion = AMDK6_getFreeRegion; - - /* For some reason some IBM systems with K6-2 processors - * have write combined enabled for the system BIOS - * region from 0xE0000 to 0xFFFFFF. We need *both* MTRR's - * for our own graphics drivers, so if we detect any - * regions below the 1Meg boundary, we remove them - * so we can use this MTRR register ourselves. - */ - for (i = 0; i < numMTRR; i++) { - getMTRR(i,&lbase,&lsize,<ype); - if (lbase < 0x100000) - setMTRR(i,0,0,0); - } - } - else { - /* AMD Athlon uses P6 style MTRR's */ - _MTRR_readMSR(INTEL_cap_MSR,&eax,&edx); - numMTRR = eax & 0xFF; - getMTRR = INTEL_getMTRR; - setMTRR = INTEL_setMTRR; - getFreeRegion = GENERIC_getFreeRegion; - INTEL_disableBankedWriteCombine(); - } - break; - case CPU_Cyrix: - /* Cyrix 6x86 and later support the MTRR registers */ - if (cpuType < CPU_Cyrix6x86 || cpuType >= CPU_CyrixMediaGX) - return; - numMTRR = 8; /* Cyrix CPU's have 8 ARR's */ - getMTRR = CYRIX_getMTRR; - setMTRR = CYRIX_setMTRR; - getFreeRegion = CYRIX_getFreeRegion; - CYRIX_initARR(); - break; - default: - return; - } - } + numMTRR = 0; + if (!_MTRR_isRing0()) + return; + cpu = CPU_getProcessorType(); + cpuFamily = cpu & CPU_familyMask; + cpuType = cpu & CPU_mask; + cpuStepping = (cpu & CPU_steppingMask) >> CPU_steppingShift; + switch (cpuFamily) { + case CPU_Intel: + /* Intel Pentium Pro and later support the MTRR registers */ + if (cpuType < CPU_PentiumPro) + return; + _MTRR_readMSR(INTEL_cap_MSR,&eax,&edx); + numMTRR = eax & 0xFF; + getMTRR = INTEL_getMTRR; + setMTRR = INTEL_setMTRR; + getFreeRegion = GENERIC_getFreeRegion; + INTEL_disableBankedWriteCombine(); + break; + case CPU_AMD: + /* AMD K6-2 and later support the MTRR registers */ + if ((cpuType < CPU_AMDK6_2) || (cpuType == CPU_AMDK6_2 && cpuStepping < 8)) + return; + if (cpuType < CPU_AMDAthlon) { + numMTRR = 2; /* AMD CPU's have 2 MTRR's */ + getMTRR = AMD_getMTRR; + setMTRR = AMD_setMTRR; + getFreeRegion = AMDK6_getFreeRegion; + + /* For some reason some IBM systems with K6-2 processors + * have write combined enabled for the system BIOS + * region from 0xE0000 to 0xFFFFFF. We need *both* MTRR's + * for our own graphics drivers, so if we detect any + * regions below the 1Meg boundary, we remove them + * so we can use this MTRR register ourselves. + */ + for (i = 0; i < numMTRR; i++) { + getMTRR(i,&lbase,&lsize,<ype); + if (lbase < 0x100000) + setMTRR(i,0,0,0); + } + } + else { + /* AMD Athlon uses P6 style MTRR's */ + _MTRR_readMSR(INTEL_cap_MSR,&eax,&edx); + numMTRR = eax & 0xFF; + getMTRR = INTEL_getMTRR; + setMTRR = INTEL_setMTRR; + getFreeRegion = GENERIC_getFreeRegion; + INTEL_disableBankedWriteCombine(); + } + break; + case CPU_Cyrix: + /* Cyrix 6x86 and later support the MTRR registers */ + if (cpuType < CPU_Cyrix6x86 || cpuType >= CPU_CyrixMediaGX) + return; + numMTRR = 8; /* Cyrix CPU's have 8 ARR's */ + getMTRR = CYRIX_getMTRR; + setMTRR = CYRIX_setMTRR; + getFreeRegion = CYRIX_getFreeRegion; + CYRIX_initARR(); + break; + default: + return; + } + } } /**************************************************************************** @@ -745,93 +745,93 @@ int MTRR_enableWriteCombine( /* Check that we have a CPU that supports MTRR's and type is valid */ if (numMTRR <= 0) { - if (!_MTRR_isRing0()) - return PM_MTRR_ERR_NO_OS_SUPPORT; - return PM_MTRR_NOT_SUPPORTED; - } + if (!_MTRR_isRing0()) + return PM_MTRR_ERR_NO_OS_SUPPORT; + return PM_MTRR_NOT_SUPPORTED; + } if (type >= PM_MTRR_MAX) - return PM_MTRR_ERR_PARAMS; + return PM_MTRR_ERR_PARAMS; /* If the type is WC, check that this processor supports it */ if (!MTRR_haveWriteCombine()) - return PM_MTRR_ERR_NOWRCOMB; + return PM_MTRR_ERR_NOWRCOMB; /* Adjust the boundaries depending on the CPU type */ switch (cpuFamily) { - case CPU_AMD: - if (cpuType < CPU_AMDAthlon) { - /* Apply the K6 block alignment and size rules. In order: - * o Uncached or gathering only - * o 128K or bigger block - * o Power of 2 block - * o base suitably aligned to the power - */ - if (type > PM_MTRR_WRCOMB && (size < (1 << 17) || (size & ~(size-1))-size || (base & (size-1)))) - return PM_MTRR_ERR_NOT_ALIGNED; - break; - } - /* Fall through for AMD Athlon which uses P6 style MTRR's */ - case CPU_Intel: - case CPU_Cyrix: - if ((base & 0xFFF) || (size & 0xFFF)) { - /* Base and size must be multiples of 4Kb */ - return PM_MTRR_ERR_NOT_4KB_ALIGNED; - } - if (base < 0x100000) { - /* Base must be >= 1Mb */ - return PM_MTRR_ERR_BELOW_1MB; - } - - /* Check upper bits of base and last are equal and lower bits - * are 0 for base and 1 for last - */ - last = base + size - 1; - for (lbase = base; !(lbase & 1) && (last & 1); lbase = lbase >> 1, last = last >> 1) - ; - if (lbase != last) { - /* Base is not aligned on the correct boundary */ - return PM_MTRR_ERR_NOT_ALIGNED; - } - break; - default: - return PM_MTRR_NOT_SUPPORTED; - } + case CPU_AMD: + if (cpuType < CPU_AMDAthlon) { + /* Apply the K6 block alignment and size rules. In order: + * o Uncached or gathering only + * o 128K or bigger block + * o Power of 2 block + * o base suitably aligned to the power + */ + if (type > PM_MTRR_WRCOMB && (size < (1 << 17) || (size & ~(size-1))-size || (base & (size-1)))) + return PM_MTRR_ERR_NOT_ALIGNED; + break; + } + /* Fall through for AMD Athlon which uses P6 style MTRR's */ + case CPU_Intel: + case CPU_Cyrix: + if ((base & 0xFFF) || (size & 0xFFF)) { + /* Base and size must be multiples of 4Kb */ + return PM_MTRR_ERR_NOT_4KB_ALIGNED; + } + if (base < 0x100000) { + /* Base must be >= 1Mb */ + return PM_MTRR_ERR_BELOW_1MB; + } + + /* Check upper bits of base and last are equal and lower bits + * are 0 for base and 1 for last + */ + last = base + size - 1; + for (lbase = base; !(lbase & 1) && (last & 1); lbase = lbase >> 1, last = last >> 1) + ; + if (lbase != last) { + /* Base is not aligned on the correct boundary */ + return PM_MTRR_ERR_NOT_ALIGNED; + } + break; + default: + return PM_MTRR_NOT_SUPPORTED; + } /* Search for existing MTRR */ for (i = 0; i < numMTRR; ++i) { - getMTRR(i,&lbase,&lsize,<ype); - if (lbase == 0 && lsize == 0) - continue; - if (base > lbase + (lsize-1)) - continue; - if ((base < lbase) && (base+size-1 < lbase)) - continue; - - /* Check that we don't overlap an existing region */ - if (type != PM_MTRR_UNCACHABLE) { - if ((base < lbase) || (base+size-1 > lbase+lsize-1)) - return PM_MTRR_ERR_OVERLAP; - } - else if (base == lbase && size == lsize) { - /* The region already exists so leave it alone */ - return PM_MTRR_ERR_OK; - } - - /* New region is enclosed by an existing region, so only allow - * a new type to be created if we are setting a region to be - * uncacheable (such as MMIO registers within a framebuffer). - */ - if (ltype != (int)type) { - if (type == PM_MTRR_UNCACHABLE) - continue; - return PM_MTRR_ERR_TYPE_MISMATCH; - } - return PM_MTRR_ERR_OK; - } + getMTRR(i,&lbase,&lsize,<ype); + if (lbase == 0 && lsize == 0) + continue; + if (base > lbase + (lsize-1)) + continue; + if ((base < lbase) && (base+size-1 < lbase)) + continue; + + /* Check that we don't overlap an existing region */ + if (type != PM_MTRR_UNCACHABLE) { + if ((base < lbase) || (base+size-1 > lbase+lsize-1)) + return PM_MTRR_ERR_OVERLAP; + } + else if (base == lbase && size == lsize) { + /* The region already exists so leave it alone */ + return PM_MTRR_ERR_OK; + } + + /* New region is enclosed by an existing region, so only allow + * a new type to be created if we are setting a region to be + * uncacheable (such as MMIO registers within a framebuffer). + */ + if (ltype != (int)type) { + if (type == PM_MTRR_UNCACHABLE) + continue; + return PM_MTRR_ERR_TYPE_MISMATCH; + } + return PM_MTRR_ERR_OK; + } /* Search for an empty MTRR */ if ((i = getFreeRegion(base,size)) < 0) - return PM_MTRR_ERR_NONE_FREE; + return PM_MTRR_ERR_NONE_FREE; setMTRR(i,base,size,type); return PM_MTRR_ERR_OK; } @@ -852,16 +852,16 @@ int PMAPI PM_enumWriteCombine( /* Check that we have a CPU that supports MTRR's and type is valid */ if (numMTRR <= 0) { - if (!_MTRR_isRing0()) - return PM_MTRR_ERR_NO_OS_SUPPORT; - return PM_MTRR_NOT_SUPPORTED; - } + if (!_MTRR_isRing0()) + return PM_MTRR_ERR_NO_OS_SUPPORT; + return PM_MTRR_NOT_SUPPORTED; + } /* Enumerate all existing MTRR's */ for (i = 0; i < numMTRR; ++i) { - getMTRR(i,&lbase,&lsize,<ype); - callback(lbase,lsize,ltype); - } + getMTRR(i,&lbase,&lsize,<ype); + callback(lbase,lsize,ltype); + } return PM_MTRR_ERR_OK; } #endif diff --git a/board/MAI/bios_emulator/scitech/src/pm/common/pcilib.c b/board/MAI/bios_emulator/scitech/src/pm/common/pcilib.c index 8dd6dd13e3a..1d542fc5df5 100644 --- a/board/MAI/bios_emulator/scitech/src/pm/common/pcilib.c +++ b/board/MAI/bios_emulator/scitech/src/pm/common/pcilib.c @@ -67,13 +67,13 @@ typedef union { struct { - ulong signature; /* _32_ */ - ulong entry; /* 32 bit physical address */ - uchar revision; /* Revision level, 0 */ - uchar length; /* Length in paragraphs should be 01 */ - uchar checksum; /* All bytes must add up to zero */ - uchar reserved[5]; /* Must be zero */ - } fields; + ulong signature; /* _32_ */ + ulong entry; /* 32 bit physical address */ + uchar revision; /* Revision level, 0 */ + uchar length; /* Length in paragraphs should be 01 */ + uchar checksum; /* All bytes must add up to zero */ + uchar reserved[5]; /* Must be zero */ + } fields; char chars[16]; } PCI_bios32; @@ -143,54 +143,54 @@ static int PCIBIOS_detect( /* Bail if we have already detected no BIOS is present */ if (PCIBIOSVersion == 0) - return 0; + return 0; /* First scan the memory from 0xE0000 to 0xFFFFF looking for the * BIOS32 service directory, so we can determine if we can call it * from 32-bit protected mode. */ if (PCIBIOSVersion == -1) { - PCIBIOSVersion = 0; - BIOSImage = PM_mapPhysicalAddr(0xE0000,BIOS_LIMIT,false); - if (!BIOSImage) - return 0; - BIOSEnd = BIOSImage + 0x20000; - for (BIOSDir = (PCI_bios32*)BIOSImage; BIOSDir < (PCI_bios32*)BIOSEnd; BIOSDir++) { - uchar sum; - int i,length; - - if (BIOSDir->fields.signature != BIOS32_SIGNATURE) - continue; - length = BIOSDir->fields.length * 16; - if (!length) - continue; - for (sum = i = 0; i < length ; i++) - sum += BIOSDir->chars[i]; - if (sum != 0) - continue; - BIOSEntry.address = (ulong)BIOSImage + (BIOSDir->fields.entry - 0xE0000); - BIOSEntry.segment = _PCI_getCS(); - break; - } - - /* If we found the BIOS32 directory, call it to get the address of the - * PCI services. - */ - if (BIOSEntry.address == 0) - return 0; - if (_BIOS32_service(PCI_SERVICE,0,&physBase,&length,&offset,BIOSEntry) != 0) - return 0; - PCIPhysEntry = physBase + offset; - PCIEntry.address = (ulong)BIOSImage + (PCIPhysEntry - 0xE0000); - PCIEntry.segment = _PCI_getCS(); - } + PCIBIOSVersion = 0; + BIOSImage = PM_mapPhysicalAddr(0xE0000,BIOS_LIMIT,false); + if (!BIOSImage) + return 0; + BIOSEnd = BIOSImage + 0x20000; + for (BIOSDir = (PCI_bios32*)BIOSImage; BIOSDir < (PCI_bios32*)BIOSEnd; BIOSDir++) { + uchar sum; + int i,length; + + if (BIOSDir->fields.signature != BIOS32_SIGNATURE) + continue; + length = BIOSDir->fields.length * 16; + if (!length) + continue; + for (sum = i = 0; i < length ; i++) + sum += BIOSDir->chars[i]; + if (sum != 0) + continue; + BIOSEntry.address = (ulong)BIOSImage + (BIOSDir->fields.entry - 0xE0000); + BIOSEntry.segment = _PCI_getCS(); + break; + } + + /* If we found the BIOS32 directory, call it to get the address of the + * PCI services. + */ + if (BIOSEntry.address == 0) + return 0; + if (_BIOS32_service(PCI_SERVICE,0,&physBase,&length,&offset,BIOSEntry) != 0) + return 0; + PCIPhysEntry = physBase + offset; + PCIEntry.address = (ulong)BIOSImage + (PCIPhysEntry - 0xE0000); + PCIEntry.segment = _PCI_getCS(); + } #endif /* We found the BIOS entry, so now do the version check */ version = _PCIBIOS_isPresent(PCI_BIOS_PRESENT,&signature,&stat,lastBus,PCIEntry); if (version > 0 && ((stat >> 8) == 0) && signature == PCI_SIGNATURE) { - *hwType = stat & 0xFF; - return PCIBIOSVersion = version; - } + *hwType = stat & 0xFF; + return PCIBIOSVersion = version; + } return 0; } @@ -215,16 +215,16 @@ static ibool CheckDuplicate( { /* Ignore devices with a vendor ID of 0 */ if (info->VendorID == 0) - return true; + return true; /* NOTE: We only check against the current device on * the bus to ensure that we do not exclude * multiple controllers of the same device ID. */ if (info->slot.p.Bus == prev->slot.p.Bus && - info->slot.p.Device == prev->slot.p.Device && - info->DeviceID == prev->DeviceID) - return true; + info->slot.p.Device == prev->slot.p.Device && + info->DeviceID == prev->DeviceID) + return true; return false; } @@ -253,41 +253,41 @@ static int PCI_enumerateMech1( tmp = PM_inpd(0xCF8); PM_outpd(0xCF8,slot.i); if ((PM_inpd(0xCF8) == slot.i) && (PM_inpd(0xCFC) != 0xFFFFFFFFUL)) { - /* PCI access mechanism 1 - the preferred mechanism */ - for (bus = 0; bus < 8; bus++) { - slot.p.Bus = bus; - for (device = 0; device < 32; device++) { - slot.p.Device = device; - for (function = 0; function < 8; function++) { - slot.p.Function = function; - slot.p.Register = 0; - PM_outpd(0xCF8,slot.i); - if (PM_inpd(0xCFC) != 0xFFFFFFFFUL) { - memset(&pci,0,sizeof(pci)); - pci.dwSize = sizeof(pci); - pci.mech1 = 1; - pci.slot = slot; - lp = (ulong*)&(pci.VendorID); - for (i = 0; i < NUM_PCI_REG; i++, lp++) { - slot.p.Register = i; - PM_outpd(0xCF8,slot.i); - *lp = PM_inpd(0xCFC); - } - if (!CheckDuplicate(&pci,&prev)) { - if (info) - COPY_STRUCTURE(&info[numFound],&pci); - ++numFound; - } - prev = pci; - } - } - } - } - - /* Disable PCI config cycle on exit */ - PM_outpd(0xCF8,0); - return numFound; - } + /* PCI access mechanism 1 - the preferred mechanism */ + for (bus = 0; bus < 8; bus++) { + slot.p.Bus = bus; + for (device = 0; device < 32; device++) { + slot.p.Device = device; + for (function = 0; function < 8; function++) { + slot.p.Function = function; + slot.p.Register = 0; + PM_outpd(0xCF8,slot.i); + if (PM_inpd(0xCFC) != 0xFFFFFFFFUL) { + memset(&pci,0,sizeof(pci)); + pci.dwSize = sizeof(pci); + pci.mech1 = 1; + pci.slot = slot; + lp = (ulong*)&(pci.VendorID); + for (i = 0; i < NUM_PCI_REG; i++, lp++) { + slot.p.Register = i; + PM_outpd(0xCF8,slot.i); + *lp = PM_inpd(0xCFC); + } + if (!CheckDuplicate(&pci,&prev)) { + if (info) + COPY_STRUCTURE(&info[numFound],&pci); + ++numFound; + } + prev = pci; + } + } + } + } + + /* Disable PCI config cycle on exit */ + PM_outpd(0xCF8,0); + return numFound; + } PM_outpd(0xCF8,tmp); /* No hardware access mechanism 1 found */ @@ -320,42 +320,42 @@ static int PCI_enumerateMech2( PM_outpb(0xCF8,0x00); PM_outpb(0xCFA,0x00); if (PM_inpb(0xCF8) == 0x00 && PM_inpb(0xCFB) == 0x00) { - /* PCI access mechanism 2 - the older mechanism for legacy busses */ - for (bus = 0; bus < 2; bus++) { - slot.p.Bus = bus; - PM_outpb(0xCFA,(uchar)bus); - for (device = 0; device < 16; device++) { - slot.p.Device = device; - deviceIO = 0xC000 + (device << 8); - for (function = 0; function < 8; function++) { - slot.p.Function = function; - slot.p.Register = 0; - PM_outpb(0xCF8,(uchar)((function << 1) | 0x10)); - if (PM_inpd(deviceIO) != 0xFFFFFFFFUL) { - memset(&pci,0,sizeof(pci)); - pci.dwSize = sizeof(pci); - pci.mech1 = 0; - pci.slot = slot; - lp = (ulong*)&(pci.VendorID); - for (i = 0; i < NUM_PCI_REG; i++, lp++) { - slot.p.Register = i; - *lp = PM_inpd(deviceIO + (i << 2)); - } - if (!CheckDuplicate(&pci,&prev)) { - if (info) - COPY_STRUCTURE(&info[numFound],&pci); - ++numFound; - } - prev = pci; - } - } - } - } - - /* Disable PCI config cycle on exit */ - PM_outpb(0xCF8,0); - return numFound; - } + /* PCI access mechanism 2 - the older mechanism for legacy busses */ + for (bus = 0; bus < 2; bus++) { + slot.p.Bus = bus; + PM_outpb(0xCFA,(uchar)bus); + for (device = 0; device < 16; device++) { + slot.p.Device = device; + deviceIO = 0xC000 + (device << 8); + for (function = 0; function < 8; function++) { + slot.p.Function = function; + slot.p.Register = 0; + PM_outpb(0xCF8,(uchar)((function << 1) | 0x10)); + if (PM_inpd(deviceIO) != 0xFFFFFFFFUL) { + memset(&pci,0,sizeof(pci)); + pci.dwSize = sizeof(pci); + pci.mech1 = 0; + pci.slot = slot; + lp = (ulong*)&(pci.VendorID); + for (i = 0; i < NUM_PCI_REG; i++, lp++) { + slot.p.Register = i; + *lp = PM_inpd(deviceIO + (i << 2)); + } + if (!CheckDuplicate(&pci,&prev)) { + if (info) + COPY_STRUCTURE(&info[numFound],&pci); + ++numFound; + } + prev = pci; + } + } + } + } + + /* Disable PCI config cycle on exit */ + PM_outpb(0xCF8,0); + return numFound; + } /* No hardware access mechanism 2 found */ return 0; @@ -394,32 +394,32 @@ static int PCI_enumerateBIOS( PCIDeviceInfo pci,prev = {0}; if (PCIBIOS_detect(&hwType,&lastBus)) { - /* PCI BIOS access - the ultimate fallback */ - for (bus = 0; bus <= lastBus; bus++) { - slot.p.Bus = bus; - for (device = 0; device < 32; device++) { - slot.p.Device = device; - for (function = 0; function < 8; function++) { - slot.p.Function = function; - if (PCIBIOS_readDWORD(0,slot.i) != 0xFFFFFFFFUL) { - memset(&pci,0,sizeof(pci)); - pci.dwSize = sizeof(pci); - pci.mech1 = 2; - pci.slot = slot; - lp = (ulong*)&(pci.VendorID); - for (i = 0; i < NUM_PCI_REG; i++, lp++) - *lp = PCIBIOS_readDWORD(i << 2,slot.i); - if (!CheckDuplicate(&pci,&prev)) { - if (info) - COPY_STRUCTURE(&info[numFound],&pci); - ++numFound; - } - prev = pci; - } - } - } - } - } + /* PCI BIOS access - the ultimate fallback */ + for (bus = 0; bus <= lastBus; bus++) { + slot.p.Bus = bus; + for (device = 0; device < 32; device++) { + slot.p.Device = device; + for (function = 0; function < 8; function++) { + slot.p.Function = function; + if (PCIBIOS_readDWORD(0,slot.i) != 0xFFFFFFFFUL) { + memset(&pci,0,sizeof(pci)); + pci.dwSize = sizeof(pci); + pci.mech1 = 2; + pci.slot = slot; + lp = (ulong*)&(pci.VendorID); + for (i = 0; i < NUM_PCI_REG; i++, lp++) + *lp = PCIBIOS_readDWORD(i << 2,slot.i); + if (!CheckDuplicate(&pci,&prev)) { + if (info) + COPY_STRUCTURE(&info[numFound],&pci); + ++numFound; + } + prev = pci; + } + } + } + } + } /* Return number of devices found */ return numFound; @@ -447,11 +447,11 @@ int _ASMAPI PCI_enumerate( * stuff we can't do directly. */ if ((numFound = PCI_enumerateMech1(info)) == 0) { - if ((numFound = PCI_enumerateMech2(info)) == 0) { - if ((numFound = PCI_enumerateBIOS(info)) == 0) - return 0; - } - } + if ((numFound = PCI_enumerateMech2(info)) == 0) { + if ((numFound = PCI_enumerateBIOS(info)) == 0) + return 0; + } + } return numFound; } @@ -493,22 +493,22 @@ ulong _ASMAPI PCI_findBARSize( base = PCI_accessReg(bar,0,PCI_READ_DWORD,pci); if (base && !(base & 0x1)) { - /* For some strange reason some devices don't properly decode - * their base address registers (Intel PCI/PCI bridges!), and - * we read completely bogus values. We check for that here - * and clear out those BAR's. - * - * We check for that here because at least the low 12 bits - * of the address range must be zeros, since the page size - * on IA32 processors is always 4Kb. - */ - if ((base & 0xFFF) == 0) { - PCI_accessReg(bar,0xFFFFFFFF,PCI_WRITE_DWORD,pci); - size = PCI_accessReg(bar,0,PCI_READ_DWORD,pci) & ~0xFF; - size = ~size+1; - PCI_accessReg(bar,base,PCI_WRITE_DWORD,pci); - } - } + /* For some strange reason some devices don't properly decode + * their base address registers (Intel PCI/PCI bridges!), and + * we read completely bogus values. We check for that here + * and clear out those BAR's. + * + * We check for that here because at least the low 12 bits + * of the address range must be zeros, since the page size + * on IA32 processors is always 4Kb. + */ + if ((base & 0xFFF) == 0) { + PCI_accessReg(bar,0xFFFFFFFF,PCI_WRITE_DWORD,pci); + size = PCI_accessReg(bar,0,PCI_READ_DWORD,pci) & ~0xFF; + size = ~size+1; + PCI_accessReg(bar,base,PCI_WRITE_DWORD,pci); + } + } pci->slot.p.Register = 0; return size; } @@ -542,49 +542,49 @@ ulong _ASMAPI PCI_accessReg( int iobase; if (info->mech1 == 2) { - /* Use PCI BIOS access since we dont have direct hardware access */ - switch (func) { - case PCI_READ_BYTE: - return (uchar)_PCIBIOS_service(READ_CONFIG_BYTE,info->slot.i >> 8,index,0,PCIEntry); - case PCI_READ_WORD: - return (ushort)_PCIBIOS_service(READ_CONFIG_WORD,info->slot.i >> 8,index,0,PCIEntry); - case PCI_READ_DWORD: - return (ulong)_PCIBIOS_service(READ_CONFIG_DWORD,info->slot.i >> 8,index,0,PCIEntry); - case PCI_WRITE_BYTE: - _PCIBIOS_service(WRITE_CONFIG_BYTE,info->slot.i >> 8,index,value,PCIEntry); - break; - case PCI_WRITE_WORD: - _PCIBIOS_service(WRITE_CONFIG_WORD,info->slot.i >> 8,index,value,PCIEntry); - break; - case PCI_WRITE_DWORD: - _PCIBIOS_service(WRITE_CONFIG_DWORD,info->slot.i >> 8,index,value,PCIEntry); - break; - } - } + /* Use PCI BIOS access since we dont have direct hardware access */ + switch (func) { + case PCI_READ_BYTE: + return (uchar)_PCIBIOS_service(READ_CONFIG_BYTE,info->slot.i >> 8,index,0,PCIEntry); + case PCI_READ_WORD: + return (ushort)_PCIBIOS_service(READ_CONFIG_WORD,info->slot.i >> 8,index,0,PCIEntry); + case PCI_READ_DWORD: + return (ulong)_PCIBIOS_service(READ_CONFIG_DWORD,info->slot.i >> 8,index,0,PCIEntry); + case PCI_WRITE_BYTE: + _PCIBIOS_service(WRITE_CONFIG_BYTE,info->slot.i >> 8,index,value,PCIEntry); + break; + case PCI_WRITE_WORD: + _PCIBIOS_service(WRITE_CONFIG_WORD,info->slot.i >> 8,index,value,PCIEntry); + break; + case PCI_WRITE_DWORD: + _PCIBIOS_service(WRITE_CONFIG_DWORD,info->slot.i >> 8,index,value,PCIEntry); + break; + } + } else { - /* Use direct hardware access mechanisms */ - if (info->mech1) { - /* PCI access mechanism 1 */ - iobase = 0xCFC + (index & 3); - info->slot.p.Register = index >> 2; - PM_outpd(0xCF8,info->slot.i); - } - else { - /* PCI access mechanism 2 */ - PM_outpb(0xCF8,(uchar)((info->slot.p.Function << 1) | 0x10)); - PM_outpb(0xCFA,(uchar)info->slot.p.Bus); - iobase = 0xC000 + (info->slot.p.Device << 8) + index; - } - switch (func) { - case PCI_READ_BYTE: - case PCI_READ_WORD: - case PCI_READ_DWORD: value = PM_inpd(iobase); break; - case PCI_WRITE_BYTE: PM_outpb(iobase,(uchar)value); break; - case PCI_WRITE_WORD: PM_outpw(iobase,(ushort)value); break; - case PCI_WRITE_DWORD: PM_outpd(iobase,(ulong)value); break; - } - PM_outpd(0xCF8,0); - } + /* Use direct hardware access mechanisms */ + if (info->mech1) { + /* PCI access mechanism 1 */ + iobase = 0xCFC + (index & 3); + info->slot.p.Register = index >> 2; + PM_outpd(0xCF8,info->slot.i); + } + else { + /* PCI access mechanism 2 */ + PM_outpb(0xCF8,(uchar)((info->slot.p.Function << 1) | 0x10)); + PM_outpb(0xCFA,(uchar)info->slot.p.Bus); + iobase = 0xC000 + (info->slot.p.Device << 8) + index; + } + switch (func) { + case PCI_READ_BYTE: + case PCI_READ_WORD: + case PCI_READ_DWORD: value = PM_inpd(iobase); break; + case PCI_WRITE_BYTE: PM_outpb(iobase,(uchar)value); break; + case PCI_WRITE_WORD: PM_outpw(iobase,(ushort)value); break; + case PCI_WRITE_DWORD: PM_outpd(iobase,(ulong)value); break; + } + PM_outpd(0xCF8,0); + } return value; } @@ -608,14 +608,14 @@ ibool _ASMAPI PCI_getIRQRoutingOptions( int ret; if (PCIPhysEntry) { - buf.BufferSize = numDevices * sizeof(PCIRouteInfo); - buf.DataBuffer = buffer; - if ((ret = _PCIBIOS_getRouting(&buf,PCIEntry)) == 0x89) - return buf.BufferSize / sizeof(PCIRouteInfo); - if (ret != 0) - return -1; - return 0; - } + buf.BufferSize = numDevices * sizeof(PCIRouteInfo); + buf.DataBuffer = buffer; + if ((ret = _PCIBIOS_getRouting(&buf,PCIEntry)) == 0x89) + return buf.BufferSize / sizeof(PCIRouteInfo); + if (ret != 0) + return -1; + return 0; + } /* We currently only support this via the PCI BIOS functions */ return -1; @@ -642,13 +642,13 @@ ibool _ASMAPI PCI_setHardwareIRQ( uint IRQ) { if (PCIPhysEntry) { - if (_PCIBIOS_setIRQ(info->slot.i >> 8,intPin,IRQ,PCIEntry)) { - info->u.type0.InterruptPin = intPin; - info->u.type0.InterruptLine = IRQ; - return true; - } - return false; - } + if (_PCIBIOS_setIRQ(info->slot.i >> 8,intPin,IRQ,PCIEntry)) { + info->u.type0.InterruptPin = intPin; + info->u.type0.InterruptLine = IRQ; + return true; + } + return false; + } /* We currently only support this via the PCI BIOS functions */ return false; @@ -668,7 +668,7 @@ void _ASMAPI PCI_generateSpecialCyle( ulong specialCycleData) { if (PCIPhysEntry) - _PCIBIOS_specialCycle(bus,specialCycleData,PCIEntry); + _PCIBIOS_specialCycle(bus,specialCycleData,PCIEntry); /* We currently only support this via the PCI BIOS functions */ } @@ -699,14 +699,14 @@ void _ASMAPI PCI_readRegBlock( int endCount = count - middleCount * 4 - startCount; for (i = 0,pb = dst; i < startCount; i++, index++) { - *pb++ = (uchar)PCI_accessReg(index,0,PCI_READ_BYTE,info); - } + *pb++ = (uchar)PCI_accessReg(index,0,PCI_READ_BYTE,info); + } for (i = 0,pd = (ulong*)pb; i < middleCount; i++, index += 4) { - *pd++ = (ulong)PCI_accessReg(index,0,PCI_READ_DWORD,info); - } + *pd++ = (ulong)PCI_accessReg(index,0,PCI_READ_DWORD,info); + } for (i = 0,pb = (uchar*)pd; i < endCount; i++, index++) { - *pb++ = (uchar)PCI_accessReg(index,0,PCI_READ_BYTE,info); - } + *pb++ = (uchar)PCI_accessReg(index,0,PCI_READ_BYTE,info); + } } /**************************************************************************** @@ -736,12 +736,12 @@ void _ASMAPI PCI_writeRegBlock( int endCount = count - middleCount * 4 - startCount; for (i = 0,pb = src; i < startCount; i++, index++) { - PCI_accessReg(index,*pb++,PCI_WRITE_BYTE,info); - } + PCI_accessReg(index,*pb++,PCI_WRITE_BYTE,info); + } for (i = 0,pd = (ulong*)pb; i < middleCount; i++, index += 4) { - PCI_accessReg(index,*pd++,PCI_WRITE_DWORD,info); - } + PCI_accessReg(index,*pd++,PCI_WRITE_DWORD,info); + } for (i = 0,pb = (uchar*)pd; i < endCount; i++, index++) { - PCI_accessReg(index,*pb++,PCI_WRITE_BYTE,info); - } + PCI_accessReg(index,*pb++,PCI_WRITE_BYTE,info); + } } diff --git a/board/MAI/bios_emulator/scitech/src/pm/common/unixio.c b/board/MAI/bios_emulator/scitech/src/pm/common/unixio.c index 04aa47002bc..c3a66a7c14d 100644 --- a/board/MAI/bios_emulator/scitech/src/pm/common/unixio.c +++ b/board/MAI/bios_emulator/scitech/src/pm/common/unixio.c @@ -65,9 +65,9 @@ static void convertFindData( strcat(filename,blk->d_name); stat(filename,&st); if (!(st.st_mode & S_IWRITE)) - findData->attrib |= PM_FILE_READONLY; + findData->attrib |= PM_FILE_READONLY; if (st.st_mode & S_IFDIR) - findData->attrib |= PM_FILE_DIRECTORY; + findData->attrib |= PM_FILE_DIRECTORY; findData->sizeLo = st.st_size; findData->sizeHi = 0; strncpy(findData->name,blk->d_name,PM_MAX_PATH); @@ -91,24 +91,24 @@ static ibool filematch( PM_backslash(fullpath); strcat(fullpath, dire->d_name); if (stat(fullpath, &st) != 0) - return false; + return false; for (; i < (int)strlen(dire->d_name) && j < (int)strlen(pattern); i++, j++) { - if (pattern[j] == '*' && lastchar != '\\') { - if (pattern[j+1] == '\0') - return true; - while (dire->d_name[i++] != pattern[j+1]) { - if (dire->d_name[i] == '\0') - return false; - } - i -= 2; - } - else if (dire->d_name[i] != pattern[j] && - !(pattern[j] == '?' && lastchar != '\\')) - return false; - lastchar = pattern[i]; - } + if (pattern[j] == '*' && lastchar != '\\') { + if (pattern[j+1] == '\0') + return true; + while (dire->d_name[i++] != pattern[j+1]) { + if (dire->d_name[i] == '\0') + return false; + } + i -= 2; + } + else if (dire->d_name[i] != pattern[j] && + !(pattern[j] == '?' && lastchar != '\\')) + return false; + lastchar = pattern[i]; + } if (j == (int)strlen(pattern) && i == (int)strlen(dire->d_name)) - return true; + return true; return false; } @@ -126,23 +126,23 @@ void * PMAPI PM_findFirstFile( char ext[PM_MAX_PATH]; if ((d = PM_malloc(sizeof(*d))) == NULL) - return PM_FILE_INVALID; + return PM_FILE_INVALID; PM_splitpath(filename,NULL,d->path,name,ext); strcpy(d->mask,name); strcat(d->mask,ext); if (strlen(d->path) == 0) - strcpy(d->path, "."); + strcpy(d->path, "."); if (d->path[strlen(d->path)-1] == '/') - d->path[strlen(d->path)-1] = 0; + d->path[strlen(d->path)-1] = 0; if ((d->d = opendir(d->path)) != NULL) { - while ((dire = readdir(d->d)) != NULL) { - if (filematch(d->mask,d->path,dire)) { - convertFindData(findData,dire,d->path); - return d; - } - } - closedir(d->d); - } + while ((dire = readdir(d->d)) != NULL) { + if (filematch(d->mask,d->path,dire)) { + convertFindData(findData,dire,d->path); + return d; + } + } + closedir(d->d); + } PM_free(d); return PM_FILE_INVALID; } @@ -159,11 +159,11 @@ ibool PMAPI PM_findNextFile( struct dirent *dire; while ((dire = readdir(d->d)) != NULL) { - if (filematch(d->mask,d->path,dire)) { - convertFindData(findData,dire,d->path); - return true; - } - } + if (filematch(d->mask,d->path,dire)) { + convertFindData(findData,dire,d->path); + return true; + } + } return false; } @@ -197,7 +197,7 @@ ibool PMAPI PM_driveValid( char drive) { if (drive == 3) - return true; + return true; return false; } @@ -230,9 +230,9 @@ void PMAPI PM_setFileAttr( stat(filename,&st); mode = st.st_mode; if (attrib & PM_FILE_READONLY) - mode &= ~S_IWRITE; + mode &= ~S_IWRITE; else - mode |= S_IWRITE; + mode |= S_IWRITE; chmod(filename,mode); } @@ -247,7 +247,7 @@ uint PMAPI PM_getFileAttr( stat(filename,&st); if (st.st_mode & S_IWRITE) - return 0; + return 0; return PM_FILE_READONLY; } @@ -280,7 +280,7 @@ ibool PMAPI PM_getFileTime( ibool gmTime, PM_time *time) { - // TODO: Implement this! + /* TODO: Implement this! */ (void)filename; (void)gmTime; (void)time; @@ -297,7 +297,7 @@ ibool PMAPI PM_setFileTime( ibool gmTime, PM_time *time) { - // TODO: Implement this! + /* TODO: Implement this! */ (void)filename; (void)gmTime; (void)time; diff --git a/board/MAI/bios_emulator/scitech/src/pm/common/vgastate.c b/board/MAI/bios_emulator/scitech/src/pm/common/vgastate.c index 3be14e81ebc..8056e9a33f7 100644 --- a/board/MAI/bios_emulator/scitech/src/pm/common/vgastate.c +++ b/board/MAI/bios_emulator/scitech/src/pm/common/vgastate.c @@ -104,7 +104,7 @@ static void vga_delay(void) * what we need. */ for (i = 0; i <= 10; i++) - PM_outpb(0x80, 0); + PM_outpb(0x80, 0); } /**************************************************************************** @@ -152,9 +152,9 @@ static void vga_savepalette( _port_out(0, PEL_IR); for (i = 0; i < 768; i++) { - vga_delay(); - *pal++ = _port_in(PEL_D); - } + vga_delay(); + *pal++ = _port_in(PEL_D); + } } /**************************************************************************** @@ -169,9 +169,9 @@ static void vga_restorepalette( /* restore saved palette */ _port_out(0, PEL_IW); for (i = 0; i < 768; i++) { - vga_delay(); - _port_out(*pal++, PEL_D); - } + vga_delay(); + _port_out(*pal++, PEL_D); + } } /**************************************************************************** @@ -247,25 +247,25 @@ void PMAPI PM_saveVGAState( /* Save state of VGA registers */ for (i = 0; i < CRT_C; i++) { - _port_out(i, CRT_I); - regs[CRT + i] = _port_in(CRT_D); - } + _port_out(i, CRT_I); + regs[CRT + i] = _port_in(CRT_D); + } for (i = 0; i < ATT_C; i++) { - _port_in(IS1_R); - vga_delay(); - _port_out(i, ATT_IW); - vga_delay(); - regs[ATT + i] = _port_in(ATT_R); - vga_delay(); - } + _port_in(IS1_R); + vga_delay(); + _port_out(i, ATT_IW); + vga_delay(); + regs[ATT + i] = _port_in(ATT_R); + vga_delay(); + } for (i = 0; i < GRA_C; i++) { - _port_out(i, GRA_I); - regs[GRA + i] = _port_in(GRA_D); - } + _port_out(i, GRA_I); + regs[GRA + i] = _port_in(GRA_D); + } for (i = 0; i < SEQ_C; i++) { - _port_out(i, SEQ_I); - regs[SEQ + i] = _port_in(SEQ_D); - } + _port_out(i, SEQ_I); + regs[SEQ + i] = _port_in(SEQ_D); + } regs[MIS] = _port_in(MIS_R); /* Save the VGA palette values */ @@ -302,7 +302,7 @@ void PMAPI PM_restoreVGAState( /* Delay to allow clock change to settle */ for (i = 0; i < 10; i++) - vga_delay(); + vga_delay(); /* Synchronous reset on */ _port_out(0x00,SEQ_I); @@ -312,9 +312,9 @@ void PMAPI PM_restoreVGAState( _port_out(1, SEQ_I); _port_out(regs[SEQ + 1] | 0x20, SEQ_D); for (i = 2; i < SEQ_C; i++) { - _port_out(i, SEQ_I); - _port_out(regs[SEQ + i], SEQ_D); - } + _port_out(i, SEQ_I); + _port_out(regs[SEQ + i], SEQ_D); + } /* Synchronous reset off */ _port_out(0x00,SEQ_I); @@ -324,21 +324,21 @@ void PMAPI PM_restoreVGAState( _port_out(0x11, CRT_I); _port_out(_port_in(CRT_D) & 0x7F, CRT_D); for (i = 0; i < CRT_C; i++) { - _port_out(i, CRT_I); - _port_out(regs[CRT + i], CRT_D); - } + _port_out(i, CRT_I); + _port_out(regs[CRT + i], CRT_D); + } for (i = 0; i < GRA_C; i++) { - _port_out(i, GRA_I); - _port_out(regs[GRA + i], GRA_D); - } + _port_out(i, GRA_I); + _port_out(regs[GRA + i], GRA_D); + } for (i = 0; i < ATT_C; i++) { - _port_in(IS1_R); /* reset flip-flop */ - vga_delay(); - _port_out(i, ATT_IW); - vga_delay(); - _port_out(regs[ATT + i], ATT_IW); - vga_delay(); - } + _port_in(IS1_R); /* reset flip-flop */ + vga_delay(); + _port_out(i, ATT_IW); + vga_delay(); + _port_out(regs[ATT + i], ATT_IW); + vga_delay(); + } /* Ensure the VGA screen is turned on */ PM_vgaUnblankDisplay(); diff --git a/board/MAI/bios_emulator/scitech/src/pm/cpuinfo.c b/board/MAI/bios_emulator/scitech/src/pm/cpuinfo.c index e2446a43973..ac62e81c108 100644 --- a/board/MAI/bios_emulator/scitech/src/pm/cpuinfo.c +++ b/board/MAI/bios_emulator/scitech/src/pm/cpuinfo.c @@ -168,144 +168,144 @@ uint ZAPI CPU_getProcessorType(void) static ibool firstTime = true; if (_CPU_haveCPUID()) { - cpu = _CPU_checkCPUID(); - vendor = cpu & ~CPU_mask; - if (vendor == CPU_Intel) { - /* Check for Intel processors */ - switch (cpu & CPU_mask) { - case 4: cpu = CPU_i486; break; - case 5: cpu = CPU_Pentium; break; - case 6: - if ((model = _CPU_getCPUIDModel()) == 1) - cpu = CPU_PentiumPro; - else if (model <= 6) { - cacheSize = _CPU_getCacheSize(); - if ((model == 5 && cacheSize == 0) || - (model == 5 && cacheSize == 256) || - (model == 6 && cacheSize == 128)) - cpu = CPU_Celeron; - else - cpu = CPU_PentiumII; - } - else if (model >= 7) { - /* Model 7 == Pentium III */ - /* Model 8 == Celeron/Pentium III Coppermine */ - cacheSize = _CPU_getCacheSize(); - if ((model == 8 && cacheSize == 128)) - cpu = CPU_Celeron; - else - cpu = CPU_PentiumIII; - } - break; - default: - cpu = CPU_UnkIntel; - } - } - else if (vendor == CPU_Cyrix) { - /* Check for Cyrix processors */ - switch (cpu & CPU_mask) { - case 4: - if ((model = _CPU_getCPUIDModel()) == 4) - cpu = CPU_CyrixMediaGX; - else - cpu = CPU_UnkCyrix; - break; - case 5: - if ((model = _CPU_getCPUIDModel()) == 2) - cpu = CPU_Cyrix6x86; - else if (model == 4) - cpu = CPU_CyrixMediaGXm; - else - cpu = CPU_UnkCyrix; - break; - case 6: - if ((model = _CPU_getCPUIDModel()) <= 1) - cpu = CPU_Cyrix6x86MX; - else - cpu = CPU_UnkCyrix; - break; - default: - cpu = CPU_UnkCyrix; - } - } - else if (vendor == CPU_AMD) { - /* Check for AMD processors */ - switch (cpu & CPU_mask) { - case 4: - if ((model = _CPU_getCPUIDModel()) == 0) - cpu = CPU_AMDAm5x86; - else - cpu = CPU_AMDAm486; - break; - case 5: - if ((model = _CPU_getCPUIDModel()) <= 3) - cpu = CPU_AMDK5; - else if (model <= 7) - cpu = CPU_AMDK6; - else if (model == 8) - cpu = CPU_AMDK6_2; - else if (model == 9) - cpu = CPU_AMDK6_III; - else if (model == 13) { - if (_CPU_getCPUIDStepping() <= 3) - cpu = CPU_AMDK6_IIIplus; - else - cpu = CPU_AMDK6_2plus; - } - else - cpu = CPU_UnkAMD; - break; - case 6: - if ((model = _CPU_getCPUIDModel()) == 3) - cpu = CPU_AMDDuron; - else - cpu = CPU_AMDAthlon; - break; - default: - cpu = CPU_UnkAMD; - } - } - else if (vendor == CPU_IDT) { - /* Check for IDT WinChip processors */ - switch (cpu & CPU_mask) { - case 5: - if ((model = _CPU_getCPUIDModel()) <= 4) - cpu = CPU_WinChipC6; - else if (model == 8) - cpu = CPU_WinChip2; - else - cpu = CPU_UnkIDT; - break; - default: - cpu = CPU_UnkIDT; - } - } - else { - /* Assume a Pentium compatible Intel clone */ - cpu = CPU_Pentium; - } - return cpu | vendor | (_CPU_getCPUIDStepping() << CPU_steppingShift); - } + cpu = _CPU_checkCPUID(); + vendor = cpu & ~CPU_mask; + if (vendor == CPU_Intel) { + /* Check for Intel processors */ + switch (cpu & CPU_mask) { + case 4: cpu = CPU_i486; break; + case 5: cpu = CPU_Pentium; break; + case 6: + if ((model = _CPU_getCPUIDModel()) == 1) + cpu = CPU_PentiumPro; + else if (model <= 6) { + cacheSize = _CPU_getCacheSize(); + if ((model == 5 && cacheSize == 0) || + (model == 5 && cacheSize == 256) || + (model == 6 && cacheSize == 128)) + cpu = CPU_Celeron; + else + cpu = CPU_PentiumII; + } + else if (model >= 7) { + /* Model 7 == Pentium III */ + /* Model 8 == Celeron/Pentium III Coppermine */ + cacheSize = _CPU_getCacheSize(); + if ((model == 8 && cacheSize == 128)) + cpu = CPU_Celeron; + else + cpu = CPU_PentiumIII; + } + break; + default: + cpu = CPU_UnkIntel; + } + } + else if (vendor == CPU_Cyrix) { + /* Check for Cyrix processors */ + switch (cpu & CPU_mask) { + case 4: + if ((model = _CPU_getCPUIDModel()) == 4) + cpu = CPU_CyrixMediaGX; + else + cpu = CPU_UnkCyrix; + break; + case 5: + if ((model = _CPU_getCPUIDModel()) == 2) + cpu = CPU_Cyrix6x86; + else if (model == 4) + cpu = CPU_CyrixMediaGXm; + else + cpu = CPU_UnkCyrix; + break; + case 6: + if ((model = _CPU_getCPUIDModel()) <= 1) + cpu = CPU_Cyrix6x86MX; + else + cpu = CPU_UnkCyrix; + break; + default: + cpu = CPU_UnkCyrix; + } + } + else if (vendor == CPU_AMD) { + /* Check for AMD processors */ + switch (cpu & CPU_mask) { + case 4: + if ((model = _CPU_getCPUIDModel()) == 0) + cpu = CPU_AMDAm5x86; + else + cpu = CPU_AMDAm486; + break; + case 5: + if ((model = _CPU_getCPUIDModel()) <= 3) + cpu = CPU_AMDK5; + else if (model <= 7) + cpu = CPU_AMDK6; + else if (model == 8) + cpu = CPU_AMDK6_2; + else if (model == 9) + cpu = CPU_AMDK6_III; + else if (model == 13) { + if (_CPU_getCPUIDStepping() <= 3) + cpu = CPU_AMDK6_IIIplus; + else + cpu = CPU_AMDK6_2plus; + } + else + cpu = CPU_UnkAMD; + break; + case 6: + if ((model = _CPU_getCPUIDModel()) == 3) + cpu = CPU_AMDDuron; + else + cpu = CPU_AMDAthlon; + break; + default: + cpu = CPU_UnkAMD; + } + } + else if (vendor == CPU_IDT) { + /* Check for IDT WinChip processors */ + switch (cpu & CPU_mask) { + case 5: + if ((model = _CPU_getCPUIDModel()) <= 4) + cpu = CPU_WinChipC6; + else if (model == 8) + cpu = CPU_WinChip2; + else + cpu = CPU_UnkIDT; + break; + default: + cpu = CPU_UnkIDT; + } + } + else { + /* Assume a Pentium compatible Intel clone */ + cpu = CPU_Pentium; + } + return cpu | vendor | (_CPU_getCPUIDStepping() << CPU_steppingShift); + } else { - if (_CPU_check80386()) - cpu = CPU_i386; - else if (_CPU_check80486()) { - /* If we get here we may have a Cyrix processor so we can try - * enabling the CPUID instruction and trying again. - */ - if (firstTime) { - firstTime = false; - _CPU_enableCyrixCPUID(); - return CPU_getProcessorType(); - } - cpu = CPU_i486; - } - else - cpu = CPU_Pentium; - if (!_CPU_checkClone()) - return cpu | CPU_Intel; - return cpu; - } + if (_CPU_check80386()) + cpu = CPU_i386; + else if (_CPU_check80486()) { + /* If we get here we may have a Cyrix processor so we can try + * enabling the CPUID instruction and trying again. + */ + if (firstTime) { + firstTime = false; + _CPU_enableCyrixCPUID(); + return CPU_getProcessorType(); + } + cpu = CPU_i486; + } + else + cpu = CPU_Pentium; + if (!_CPU_checkClone()) + return cpu | CPU_Intel; + return cpu; + } #elif defined(__ALPHA__) return CPU_Alpha; #elif defined(__MIPS__) @@ -337,7 +337,7 @@ ibool ZAPI CPU_haveMMX(void) { #ifdef __INTEL__ if (_CPU_haveCPUID()) - return (_CPU_getCPUIDFeatures() & CPU_HaveMMX) != 0; + return (_CPU_getCPUIDFeatures() & CPU_HaveMMX) != 0; return false; #else return false; @@ -366,7 +366,7 @@ ibool ZAPI CPU_have3DNow(void) { #ifdef __INTEL__ if (_CPU_haveCPUID()) - return _CPU_have3DNow(); + return _CPU_have3DNow(); return false; #else return false; @@ -395,7 +395,7 @@ ibool ZAPI CPU_haveSSE(void) { #ifdef __INTEL__ if (_CPU_haveCPUID()) - return (_CPU_getCPUIDFeatures() & CPU_HaveSSE) != 0; + return (_CPU_getCPUIDFeatures() & CPU_HaveSSE) != 0; return false; #else return false; @@ -432,7 +432,7 @@ ibool ZAPI CPU_haveRDTSC(void) { #ifdef __INTEL__ if (_CPU_haveCPUID()) - return (_CPU_getCPUIDFeatures() & CPU_HaveRDTSC) != 0; + return (_CPU_getCPUIDFeatures() & CPU_HaveRDTSC) != 0; return false; #else return false; @@ -464,22 +464,22 @@ static ulong GetBSFCpuSpeed( iPriority = SetMaxThreadPriority(); GetCounterFrequency(&count_freq); for (i = 0; i < SAMPLINGS; i++) { - GetCounter(&t0); - for (j = 0; j < INNER_LOOPS; j++) - _CPU_runBSFLoop(ITERATIONS); - GetCounter(&t1); - current = t1.low - t0.low; - if (current < lowest) - lowest = current; - } + GetCounter(&t0); + for (j = 0; j < INNER_LOOPS; j++) + _CPU_runBSFLoop(ITERATIONS); + GetCounter(&t1); + current = t1.low - t0.low; + if (current < lowest) + lowest = current; + } RestoreThreadPriority(iPriority); /* Compute frequency */ ticks = _CPU_mulDiv(lowest,1000000,count_freq.low); if ((ticks % count_freq.low) > (count_freq.low/2)) - ticks++; /* Round up if necessary */ + ticks++; /* Round up if necessary */ if (ticks == 0) - return 0; + return 0; return ((cycles*INNER_LOOPS)/ticks); } @@ -513,44 +513,44 @@ static ulong GetRDTSCCpuSpeed( GetCounterFrequency(&count_freq); PM_set64(freq,count_freq.high,count_freq.low); for (tries = 0; tries < 3; tries++) { - /* Loop until 100 ticks have passed since last read of hi-res - * counter. This accounts for overhead later. - */ - GetCounter(&t0); - t1.low = t0.low; - t1.high = t0.high; - while ((t1.low - t0.low) < 100) { - GetCounter(&t1); - _CPU_readTimeStamp(&s0); - } - - /* Loop until 30000 ticks have passed since last read of hi-res counter. - * This allows for elapsed time for sampling. For a hi-res frequency - * of 1MHz, this is about 0.03 of a second. The frequency reported - * by the OS dependent code should be tuned to provide a good - * sample period depending on the accuracy of the OS timers (ie: - * if the accuracy is lower, lower the frequency to spend more time - * in the inner loop to get better accuracy). - */ - t0.low = t1.low; - t0.high = t1.high; - while ((t1.low - t0.low) < maxCount) { - GetCounter(&t1); - _CPU_readTimeStamp(&s1); - } - - /* Find the difference during the timing loop */ - PM_set64(stamp0,s0.high,s0.low); - PM_set64(stamp1,s1.high,s1.low); - PM_set64(ticks0,t0.high,t0.low); - PM_set64(ticks1,t1.high,t1.low); - PM_sub64(cycles,stamp1,stamp0); - PM_sub64(ticks,ticks1,ticks0); - - /* Sum up the results */ - PM_add64(total_ticks,total_ticks,ticks); - PM_add64(total_cycles,total_cycles,cycles); - } + /* Loop until 100 ticks have passed since last read of hi-res + * counter. This accounts for overhead later. + */ + GetCounter(&t0); + t1.low = t0.low; + t1.high = t0.high; + while ((t1.low - t0.low) < 100) { + GetCounter(&t1); + _CPU_readTimeStamp(&s0); + } + + /* Loop until 30000 ticks have passed since last read of hi-res counter. + * This allows for elapsed time for sampling. For a hi-res frequency + * of 1MHz, this is about 0.03 of a second. The frequency reported + * by the OS dependent code should be tuned to provide a good + * sample period depending on the accuracy of the OS timers (ie: + * if the accuracy is lower, lower the frequency to spend more time + * in the inner loop to get better accuracy). + */ + t0.low = t1.low; + t0.high = t1.high; + while ((t1.low - t0.low) < maxCount) { + GetCounter(&t1); + _CPU_readTimeStamp(&s1); + } + + /* Find the difference during the timing loop */ + PM_set64(stamp0,s0.high,s0.low); + PM_set64(stamp1,s1.high,s1.low); + PM_set64(ticks0,t0.high,t0.low); + PM_set64(ticks1,t1.high,t1.low); + PM_sub64(cycles,stamp1,stamp0); + PM_sub64(ticks,ticks1,ticks0); + + /* Sum up the results */ + PM_add64(total_ticks,total_ticks,ticks); + PM_add64(total_cycles,total_cycles,cycles); + } RestoreThreadPriority(iPriority); /* Compute frequency in Hz */ @@ -598,46 +598,46 @@ ulong ZAPI CPU_getProcessorSpeed( ulong cpuSpeed; uint i; static ulong intel_cycles[] = { - 115,47,43, - }; + 115,47,43, + }; static ulong cyrix_cycles[] = { - 38,38,52,52, - }; + 38,38,52,52, + }; static ulong amd_cycles[] = { - 49, - }; + 49, + }; static ulong known_speeds[] = { - 1000,950,900,850,800,750,700,650,600,550,500,450,433,400,350, - 333,300,266,233,200,166,150,133,120,100,90,75,66,60,50,33,20,0, - }; + 1000,950,900,850,800,750,700,650,600,550,500,450,433,400,350, + 333,300,266,233,200,166,150,133,120,100,90,75,66,60,50,33,20,0, + }; if (CPU_haveRDTSC()) { - cpuSpeed = (GetRDTSCCpuSpeed(accurate) + 500000) / 1000000; - } + cpuSpeed = (GetRDTSCCpuSpeed(accurate) + 500000) / 1000000; + } else { - int type = CPU_getProcessorType(); - int processor = type & CPU_mask; - int vendor = type & CPU_familyMask; - if (vendor == CPU_Intel) - cpuSpeed = GetBSFCpuSpeed(ITERATIONS * intel_cycles[processor - CPU_i386]); - else if (vendor == CPU_Cyrix) - cpuSpeed = GetBSFCpuSpeed(ITERATIONS * cyrix_cycles[processor - CPU_Cyrix6x86]); - else if (vendor == CPU_AMD) - cpuSpeed = GetBSFCpuSpeed(ITERATIONS * amd_cycles[0]); - else - return 0; - } + int type = CPU_getProcessorType(); + int processor = type & CPU_mask; + int vendor = type & CPU_familyMask; + if (vendor == CPU_Intel) + cpuSpeed = GetBSFCpuSpeed(ITERATIONS * intel_cycles[processor - CPU_i386]); + else if (vendor == CPU_Cyrix) + cpuSpeed = GetBSFCpuSpeed(ITERATIONS * cyrix_cycles[processor - CPU_Cyrix6x86]); + else if (vendor == CPU_AMD) + cpuSpeed = GetBSFCpuSpeed(ITERATIONS * amd_cycles[0]); + else + return 0; + } /* Now normalise the results given known processors speeds, if the * speed we measure is within 2MHz of the expected values */ if (!accurate) { - for (i = 0; known_speeds[i] != 0; i++) { - if (cpuSpeed >= (known_speeds[i]-3) && cpuSpeed <= (known_speeds[i]+3)) { - return known_speeds[i]; - } - } - } + for (i = 0; known_speeds[i] != 0; i++) { + if (cpuSpeed >= (known_speeds[i]-3) && cpuSpeed <= (known_speeds[i]+3)) { + return known_speeds[i]; + } + } + } return cpuSpeed; #else return 0; @@ -674,8 +674,8 @@ ulong ZAPI CPU_getProcessorSpeedInHZ( { #if defined(__INTEL__) if (CPU_haveRDTSC()) { - return GetRDTSCCpuSpeed(accurate); - } + return GetRDTSCCpuSpeed(accurate); + } return CPU_getProcessorSpeed(false) * 1000000; #else return 0; @@ -706,101 +706,101 @@ char * ZAPI CPU_getProcessorName(void) static char name[80]; if (speed == -1) { - cpu = CPU_getProcessorType(); - speed = CPU_getProcessorSpeed(false); - } + cpu = CPU_getProcessorType(); + speed = CPU_getProcessorSpeed(false); + } sprintf(name,"%d MHz ", speed); switch (cpu & CPU_mask) { - case CPU_i386: - strcat(name,"Intel i386 processor"); - break; - case CPU_i486: - strcat(name,"Intel i486 processor"); - break; - case CPU_Pentium: - strcat(name,"Intel Pentium processor"); - break; - case CPU_PentiumPro: - strcat(name,"Intel Pentium Pro processor"); - break; - case CPU_PentiumII: - strcat(name,"Intel Pentium II processor"); - break; - case CPU_Celeron: - strcat(name,"Intel Celeron processor"); - break; - case CPU_PentiumIII: - strcat(name,"Intel Pentium III processor"); - break; - case CPU_UnkIntel: - strcat(name,"Unknown Intel processor"); - break; - case CPU_Cyrix6x86: - strcat(name,"Cyrix 6x86 processor"); - break; - case CPU_Cyrix6x86MX: - strcat(name,"Cyrix 6x86MX processor"); - break; - case CPU_CyrixMediaGX: - strcat(name,"Cyrix MediaGX processor"); - break; - case CPU_CyrixMediaGXm: - strcat(name,"Cyrix MediaGXm processor"); - break; - case CPU_UnkCyrix: - strcat(name,"Unknown Cyrix processor"); - break; - case CPU_AMDAm486: - strcat(name,"AMD Am486 processor"); - break; - case CPU_AMDAm5x86: - strcat(name,"AMD Am5x86 processor"); - break; - case CPU_AMDK5: - strcat(name,"AMD K5 processor"); - break; - case CPU_AMDK6: - strcat(name,"AMD K6 processor"); - break; - case CPU_AMDK6_2: - strcat(name,"AMD K6-2 processor"); - break; - case CPU_AMDK6_III: - strcat(name,"AMD K6-III processor"); - break; - case CPU_AMDK6_2plus: - strcat(name,"AMD K6-2+ processor"); - break; - case CPU_AMDK6_IIIplus: - strcat(name,"AMD K6-III+ processor"); - break; - case CPU_UnkAMD: - strcat(name,"Unknown AMD processor"); - break; - case CPU_AMDAthlon: - strcat(name,"AMD Athlon processor"); - break; - case CPU_AMDDuron: - strcat(name,"AMD Duron processor"); - break; - case CPU_WinChipC6: - strcat(name,"IDT WinChip C6 processor"); - break; - case CPU_WinChip2: - strcat(name,"IDT WinChip 2 processor"); - break; - case CPU_UnkIDT: - strcat(name,"Unknown IDT processor"); - break; - default: - strcat(name,"Unknown processor"); - } + case CPU_i386: + strcat(name,"Intel i386 processor"); + break; + case CPU_i486: + strcat(name,"Intel i486 processor"); + break; + case CPU_Pentium: + strcat(name,"Intel Pentium processor"); + break; + case CPU_PentiumPro: + strcat(name,"Intel Pentium Pro processor"); + break; + case CPU_PentiumII: + strcat(name,"Intel Pentium II processor"); + break; + case CPU_Celeron: + strcat(name,"Intel Celeron processor"); + break; + case CPU_PentiumIII: + strcat(name,"Intel Pentium III processor"); + break; + case CPU_UnkIntel: + strcat(name,"Unknown Intel processor"); + break; + case CPU_Cyrix6x86: + strcat(name,"Cyrix 6x86 processor"); + break; + case CPU_Cyrix6x86MX: + strcat(name,"Cyrix 6x86MX processor"); + break; + case CPU_CyrixMediaGX: + strcat(name,"Cyrix MediaGX processor"); + break; + case CPU_CyrixMediaGXm: + strcat(name,"Cyrix MediaGXm processor"); + break; + case CPU_UnkCyrix: + strcat(name,"Unknown Cyrix processor"); + break; + case CPU_AMDAm486: + strcat(name,"AMD Am486 processor"); + break; + case CPU_AMDAm5x86: + strcat(name,"AMD Am5x86 processor"); + break; + case CPU_AMDK5: + strcat(name,"AMD K5 processor"); + break; + case CPU_AMDK6: + strcat(name,"AMD K6 processor"); + break; + case CPU_AMDK6_2: + strcat(name,"AMD K6-2 processor"); + break; + case CPU_AMDK6_III: + strcat(name,"AMD K6-III processor"); + break; + case CPU_AMDK6_2plus: + strcat(name,"AMD K6-2+ processor"); + break; + case CPU_AMDK6_IIIplus: + strcat(name,"AMD K6-III+ processor"); + break; + case CPU_UnkAMD: + strcat(name,"Unknown AMD processor"); + break; + case CPU_AMDAthlon: + strcat(name,"AMD Athlon processor"); + break; + case CPU_AMDDuron: + strcat(name,"AMD Duron processor"); + break; + case CPU_WinChipC6: + strcat(name,"IDT WinChip C6 processor"); + break; + case CPU_WinChip2: + strcat(name,"IDT WinChip 2 processor"); + break; + case CPU_UnkIDT: + strcat(name,"Unknown IDT processor"); + break; + default: + strcat(name,"Unknown processor"); + } if (CPU_haveMMX()) - strcat(name," with MMX(R)"); + strcat(name," with MMX(R)"); if (CPU_have3DNow()) - strcat(name,", 3DNow!(R)"); + strcat(name,", 3DNow!(R)"); if (CPU_haveSSE()) - strcat(name,", SSE(R)"); + strcat(name,", SSE(R)"); return name; #else return "Unknown"; diff --git a/board/MAI/bios_emulator/scitech/src/pm/debug.c b/board/MAI/bios_emulator/scitech/src/pm/debug.c index d86e3e6a0d6..751bf098fc3 100644 --- a/board/MAI/bios_emulator/scitech/src/pm/debug.c +++ b/board/MAI/bios_emulator/scitech/src/pm/debug.c @@ -61,23 +61,23 @@ void _CHK_defaultFail( char buf[256]; if (logFile[0] == 0) { - strcpy(logFile,PM_getNucleusPath()); - PM_backslash(logFile); - strcat(logFile,"scitech.log"); - } + strcpy(logFile,PM_getNucleusPath()); + PM_backslash(logFile); + strcat(logFile,"scitech.log"); + } if ((f = fopen(logFile,"a+")) != NULL) { #if defined(__WIN32_VXD__) || defined(__OS2_VDD__) || defined(__NT_DRIVER__) - sprintf(buf,msg,cond,file,line); - fwrite(buf,1,strlen(buf),f); + sprintf(buf,msg,cond,file,line); + fwrite(buf,1,strlen(buf),f); #else - fprintf(f,msg,cond,file,line); + fprintf(f,msg,cond,file,line); #endif - fclose(f); - } + fclose(f); + } if (fatal) { - sprintf(buf,"Check failed: check '%s' for details", logFile); - PM_fatalError(buf); - } + sprintf(buf,"Check failed: check '%s' for details", logFile); + PM_fatalError(buf); + } } #endif diff --git a/board/MAI/bios_emulator/scitech/src/pm/dos/event.c b/board/MAI/bios_emulator/scitech/src/pm/dos/event.c index 12ecb298bc3..a969d111b40 100644 --- a/board/MAI/bios_emulator/scitech/src/pm/dos/event.c +++ b/board/MAI/bios_emulator/scitech/src/pm/dos/event.c @@ -75,7 +75,7 @@ static void EVTAPI _EVT_pumpMessages(void) _EVT_restoreInt(ps); } - regs.x.ax = 0x0B; // Reset Move Mouse + regs.x.ax = 0x0B; /* Reset Move Mouse */ PM_int86(0x33,®s,®s); } #endif @@ -178,8 +178,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, @@ -193,18 +193,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 */ + } } /**************************************************************************** @@ -233,47 +233,47 @@ static void EVTAPI mouseISR( uint buttonMask; 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(); - buttonMask = 0; - if (mask & 2) buttonMask |= EVT_LEFTBMASK; - if (mask & 8) buttonMask |= EVT_RIGHTBMASK; - if (mask & 32) buttonMask |= EVT_MIDDLEBMASK; - addMouseEvent(EVT_MOUSEDOWN,buttonMask,x,y,0,0,butstate); - EVT.oldMove = -1; - _EVT_restoreInt(ps); - } + ps = _EVT_disableInt(); + buttonMask = 0; + if (mask & 2) buttonMask |= EVT_LEFTBMASK; + if (mask & 8) buttonMask |= EVT_RIGHTBMASK; + if (mask & 32) buttonMask |= EVT_MIDDLEBMASK; + addMouseEvent(EVT_MOUSEDOWN,buttonMask,x,y,0,0,butstate); + EVT.oldMove = -1; + _EVT_restoreInt(ps); + } if (mask & 0x54) { - ps = _EVT_disableInt(); - buttonMask = 0; - if (mask & 2) buttonMask |= EVT_LEFTBMASK; - if (mask & 8) buttonMask |= EVT_RIGHTBMASK; - if (mask & 32) buttonMask |= EVT_MIDDLEBMASK; - addMouseEvent(EVT_MOUSEUP,buttonMask,x,y,0,0,butstate); - EVT.oldMove = -1; - _EVT_restoreInt(ps); - } + ps = _EVT_disableInt(); + buttonMask = 0; + if (mask & 2) buttonMask |= EVT_LEFTBMASK; + if (mask & 8) buttonMask |= EVT_RIGHTBMASK; + if (mask & 32) buttonMask |= EVT_MIDDLEBMASK; + addMouseEvent(EVT_MOUSEUP,buttonMask,x,y,0,0,butstate); + EVT.oldMove = -1; + _EVT_restoreInt(ps); + } EVT.oldKey = -1; } @@ -282,7 +282,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. + and we leave them OFF the entire time. ****************************************************************************/ static void EVTAPI keyboardISR(void) { @@ -327,7 +327,7 @@ void EVTAPI EVT_init( * while the program is initialising. */ while ((i = _EVT_getKeyCode()) != 0) - addKeyEvent(EVT_KEYDOWN,i); + addKeyEvent(EVT_KEYDOWN,i); } /**************************************************************************** @@ -344,62 +344,62 @@ void EVTAPI EVT_resume(void) PM_lockHandle lh; /* Unused in DOS */ if (_EVT_useEvents) { - /* Initialise the event queue and enable our interrupt handlers */ - initEventQueue(); + /* Initialise the event queue and enable our interrupt handlers */ + initEventQueue(); #ifndef NO_KEYBOARD_INTERRUPT - PM_setKeyHandler(keyboardISR); + PM_setKeyHandler(keyboardISR); #endif #ifndef NO_MOUSE_INTERRUPT - if ((haveMouse = detectMouse()) != 0) { - int oldmode = _EVT_foolMouse(); - PM_setMouseHandler(0xFFFF,mouseISR); - _EVT_unfoolMouse(oldmode); - } + if ((haveMouse = detectMouse()) != 0) { + int oldmode = _EVT_foolMouse(); + PM_setMouseHandler(0xFFFF,mouseISR); + _EVT_unfoolMouse(oldmode); + } #endif - /* 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; - } - - /* Catch program termination signals so we can clean up properly */ - signal(SIGABRT, _EVT_abort); - signal(SIGFPE, _EVT_abort); - signal(SIGINT, _EVT_abort); - _EVT_installed = true; - } + /* 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; + } + + /* Catch program termination signals so we can clean up properly */ + signal(SIGABRT, _EVT_abort); + signal(SIGFPE, _EVT_abort); + signal(SIGINT, _EVT_abort); + _EVT_installed = true; + } } /**************************************************************************** @@ -415,18 +415,18 @@ void EVTAPI EVT_setMouseRange( RMREGS regs; if (haveMouse) { - int oldmode = _EVT_foolMouse(); - PM_resetMouseDriver(1); - regs.x.ax = 7; /* Mouse function 7 - Set horizontal min and max */ - regs.x.cx = 0; - regs.x.dx = xRes; - PM_int86(0x33,®s,®s); - regs.x.ax = 8; /* Mouse function 8 - Set vertical min and max */ - regs.x.cx = 0; - regs.x.dx = yRes; - PM_int86(0x33,®s,®s); - _EVT_unfoolMouse(oldmode); - } + int oldmode = _EVT_foolMouse(); + PM_resetMouseDriver(1); + regs.x.ax = 7; /* Mouse function 7 - Set horizontal min and max */ + regs.x.cx = 0; + regs.x.dx = xRes; + PM_int86(0x33,®s,®s); + regs.x.ax = 8; /* Mouse function 8 - Set vertical min and max */ + regs.x.cx = 0; + regs.x.dx = yRes; + PM_int86(0x33,®s,®s); + _EVT_unfoolMouse(oldmode); + } } /**************************************************************************** @@ -441,13 +441,13 @@ void _EVT_setMousePos( RMREGS regs; if (haveMouse) { - int oldmode = _EVT_foolMouse(); - regs.x.ax = 4; /* Mouse function 4 - Set mouse position */ - regs.x.cx = *x; /* New horizontal coordinate */ - regs.x.dx = *y; /* New vertical coordinate */ - PM_int86(0x33,®s,®s); - _EVT_unfoolMouse(oldmode); - } + int oldmode = _EVT_foolMouse(); + regs.x.ax = 4; /* Mouse function 4 - Set mouse position */ + regs.x.cx = *x; /* New horizontal coordinate */ + regs.x.dx = *y; /* New vertical coordinate */ + PM_int86(0x33,®s,®s); + _EVT_unfoolMouse(oldmode); + } } /**************************************************************************** @@ -460,28 +460,28 @@ void EVTAPI EVT_suspend(void) uchar mods; if (_EVT_installed) { - /* Restore the interrupt handlers */ - PM_restoreKeyHandler(); - if (haveMouse) - PM_restoreMouseHandler(); - signal(SIGABRT, SIG_DFL); - signal(SIGFPE, SIG_DFL); - signal(SIGINT, SIG_DFL); - - /* 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; - } + /* Restore the interrupt handlers */ + PM_restoreKeyHandler(); + if (haveMouse) + PM_restoreMouseHandler(); + signal(SIGABRT, SIG_DFL); + signal(SIGFPE, SIG_DFL); + signal(SIGINT, SIG_DFL); + + /* 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/dos/pm.c b/board/MAI/bios_emulator/scitech/src/pm/dos/pm.c index 71acd6894e1..2ad9e34f910 100644 --- a/board/MAI/bios_emulator/scitech/src/pm/dos/pm.c +++ b/board/MAI/bios_emulator/scitech/src/pm/dos/pm.c @@ -156,7 +156,7 @@ void PMAPI PM_VxDCall( VXD_regs *regs) { if (_PM_VXD_sel != 0 || _PM_VXD_off != 0) - _PM_VxDCall(regs,_PM_VXD_off,_PM_VXD_sel); + _PM_VxDCall(regs,_PM_VXD_off,_PM_VXD_sel); } /**************************************************************************** @@ -172,11 +172,11 @@ uint PMAPI PMHELP_getVersion(void) /* Call the helper VxD to determine the version number */ if (_PM_VXD_sel != 0 || _PM_VXD_off != 0) { - memset(&r,0,sizeof(r)); - r.eax = API_NUM(PMHELP_GETVER); - _PM_VxDCall(&r,_PM_VXD_off,_PM_VXD_sel); - return VXD_version = (uint)r.eax; - } + memset(&r,0,sizeof(r)); + r.eax = API_NUM(PMHELP_GETVER); + _PM_VxDCall(&r,_PM_VXD_off,_PM_VXD_sel); + return VXD_version = (uint)r.eax; + } return VXD_version = 0; } @@ -199,7 +199,7 @@ static ibool PMHELP_connect(void) /* Bail early if we have alread connected */ if (VXD_version != -1) - return VXD_version != 0; + return VXD_version != 0; /* Get the static SDDHELP.VXD entry point if available */ PM_segread(&sregs); @@ -211,9 +211,9 @@ static ibool PMHELP_connect(void) _PM_VXD_sel = sregs.es; _PM_VXD_off = regs.x.di; if (_PM_VXD_sel != 0 || _PM_VXD_off != 0) { - if (PMHELP_getVersion() >= PMHELP_VERSION) - return true; - } + if (PMHELP_getVersion() >= PMHELP_VERSION) + return true; + } /* If we get here, then either SDDHELP.VXD is not loaded, or it is an * earlier version. In this case try to dynamically load the PMHELP.VXD @@ -228,7 +228,7 @@ static ibool PMHELP_connect(void) VXD_loadSel = sregs.es; VXD_loadOff = regs.x.di; if (VXD_loadSel == 0 && VXD_loadOff == 0) - return VXD_version = 0; + return VXD_version = 0; r.eax = 1; r.ebx = 0; r.edx = (uint)VXD_name; @@ -237,7 +237,7 @@ static ibool PMHELP_connect(void) r.es = sregs.es; _PM_VxDCall(&r,VXD_loadOff,VXD_loadSel); if (r.eax != 0) - return VXD_version = 0; + return VXD_version = 0; /* Get the dynamic VxD entry point so we can call it */ atexit(UnloadVxD); @@ -249,9 +249,9 @@ static ibool PMHELP_connect(void) _PM_VXD_sel = sregs.es; _PM_VXD_off = regs.x.di; if (_PM_VXD_sel == 0 && _PM_VXD_off == 0) - return VXD_version = 0; + return VXD_version = 0; if (PMHELP_getVersion() >= PMHELP_VERSION) - return true; + return true; return VXD_version = 0; } #endif @@ -269,24 +269,24 @@ void PMAPI PM_init(void) /* Check if we are running under CauseWay under real DOS */ if (_PM_haveCauseWay == -1) { - /* Check if we are running under DPMI in which case we will not be - * able to use our special ring 0 CauseWay functions. - */ - _PM_haveCauseWay = false; - regs.x.ax = 0xFF00; - PM_int386(0x31,®s,®s); - if (regs.x.cflag || !(regs.e.edi & 8)) { - /* We are not under DPMI, so now check if CauseWay is active */ - regs.x.ax = 0xFFF9; - PM_int386(0x31,®s,®s); - if (!regs.x.cflag && regs.e.ecx == 0x43415553 && regs.e.edx == 0x45574159) - _PM_haveCauseWay = true; - } - - /* Now connect to PMHELP.VXD and initialise MTRR module */ - if (!PMHELP_connect()) - MTRR_init(); - } + /* Check if we are running under DPMI in which case we will not be + * able to use our special ring 0 CauseWay functions. + */ + _PM_haveCauseWay = false; + regs.x.ax = 0xFF00; + PM_int386(0x31,®s,®s); + if (regs.x.cflag || !(regs.e.edi & 8)) { + /* We are not under DPMI, so now check if CauseWay is active */ + regs.x.ax = 0xFFF9; + PM_int386(0x31,®s,®s); + if (!regs.x.cflag && regs.e.ecx == 0x43415553 && regs.e.edx == 0x45574159) + _PM_haveCauseWay = true; + } + + /* Now connect to PMHELP.VXD and initialise MTRR module */ + if (!PMHELP_connect()) + MTRR_init(); + } #endif } @@ -311,14 +311,14 @@ int PMAPI PM_enableWriteCombine( VXD_regs regs; if (PMHELP_connect()) { - memset(®s,0,sizeof(regs)); - regs.eax = API_NUM(PMHELP_ENABLELFBCOMB); - regs.ebx = base; - regs.ecx = size; - regs.edx = type; - _PM_VxDCall(®s,_PM_VXD_off,_PM_VXD_sel); - return regs.eax; - } + memset(®s,0,sizeof(regs)); + regs.eax = API_NUM(PMHELP_ENABLELFBCOMB); + regs.ebx = base; + regs.ecx = size; + regs.edx = type; + _PM_VxDCall(®s,_PM_VXD_off,_PM_VXD_sel); + return regs.eax; + } return MTRR_enableWriteCombine(base,size,type); #else return PM_MTRR_NOT_SUPPORTED; @@ -346,9 +346,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( @@ -360,7 +360,7 @@ void PMAPI PM_setFatalErrorCleanup( void PMAPI PM_fatalError(const char *msg) { if (fatalErrorCleanup) - fatalErrorCleanup(); + fatalErrorCleanup(); fprintf(stderr,"%s\n", msg); exit(1); } @@ -368,18 +368,18 @@ void PMAPI PM_fatalError(const char *msg) 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; @@ -429,12 +429,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!"); } @@ -443,9 +443,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; } @@ -469,19 +469,19 @@ const char * PMAPI PM_getNucleusPath(void) char *env; if ((env = getenv("NUCLEUS_PATH")) != NULL) - return env; + return env; if ((env = getenv("WINBOOTDIR")) != NULL) { - /* Running in a Windows 9x DOS box or DOS mode */ - strcpy(path,env); - strcat(path,"\\system\\nucleus"); - return path; - } + /* Running in a Windows 9x DOS box or DOS mode */ + strcpy(path,env); + strcat(path,"\\system\\nucleus"); + return path; + } if ((env = getenv("SystemRoot")) != NULL) { - /* Running in an NT/2K DOS box */ - strcpy(path,env); - strcat(path,"\\system32\\nucleus"); - return path; - } + /* Running in an NT/2K DOS box */ + strcpy(path,env); + strcat(path,"\\system32\\nucleus"); + return path; + } return "c:\\nucleus"; } @@ -538,12 +538,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; } @@ -560,10 +560,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; } @@ -587,13 +587,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) @@ -623,22 +623,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) { - /* DOS 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; - } + /* DOS 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); @@ -656,9 +656,9 @@ ibool PMAPI PM_doBIOSPOST( /* Second the primary BIOS mappin 1:1 for 0xC0000 physical */ if (BIOSPhysAddr != 0xC0000L) { - /* DOS does not support this */ - (void)mappedBIOS; - } + /* DOS does not support this */ + (void)mappedBIOS; + } return true; } @@ -669,26 +669,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; } @@ -733,15 +733,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; @@ -760,11 +760,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; } @@ -779,9 +779,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; } @@ -813,9 +813,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 */ } /**************************************************************************** @@ -848,25 +848,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 } @@ -910,7 +910,7 @@ ulong PMAPI DPMI_mapPhysicalToLinear(ulong physAddr,ulong limit) * mapped 1:1 for this memory anyway so we just return the base address. */ if (physAddr < 0x100000L) - return physAddr; + return physAddr; /* Search table of existing mappings to see if we have already mapped * a region of memory that will serve this purpose. We do this because @@ -919,20 +919,20 @@ ulong PMAPI DPMI_mapPhysicalToLinear(ulong physAddr,ulong limit) * more mappings than necessary. */ for (i = 0; i < numMaps; i++) { - if (maps[i].physical == physAddr && maps[i].limit == limit) - return maps[i].linear; - } + if (maps[i].physical == physAddr && maps[i].limit == limit) + return maps[i].linear; + } /* Find a free slot in our physical memory mapping table */ for (i = 0; i < numMaps; i++) { - if (maps[i].limit == 0) - break; - } + if (maps[i].limit == 0) + break; + } if (i == numMaps) { - i = numMaps++; - if (i == MAX_MEMORY_MAPPINGS) - return NULL; - } + i = numMaps++; + if (i == MAX_MEMORY_MAPPINGS) + return NULL; + } /* 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 @@ -950,7 +950,7 @@ ulong PMAPI DPMI_mapPhysicalToLinear(ulong physAddr,ulong limit) r.x.di = roundedLimit & 0xFFFF; PM_int386(0x31, &r, &r); if (r.x.cflag) - return 0xFFFFFFFFUL; + return 0xFFFFFFFFUL; maps[i].physical = physAddr; maps[i].limit = limit; maps[i].linear = ((ulong)r.x.bx << 16) + r.x.cx + baseOfs; @@ -967,7 +967,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; } @@ -991,7 +991,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; } @@ -1011,19 +1011,19 @@ uint PMAPI DPMI_createSelector(ulong base,ulong limit) * segment). */ if (limit >= 0x10000L) { - r.x.ax = 9; - r.x.bx = sel; - r.x.cx = 0x40F3; - PM_int386(0x31, &r, &r); - } + r.x.ax = 9; + r.x.bx = sel; + r.x.cx = 0x40F3; + PM_int386(0x31, &r, &r); + } /* 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; } @@ -1083,39 +1083,39 @@ static void PM_adjustPageTables( andMask = ~0x18; orMask = (isCached) ? 0x00 : 0x18; if (_PM_pagingEnabled() == 1 && (PDB = _PM_getPDB()) != 0) { - if (_PM_haveCauseWay) { - /* CauseWay is a little different in the page table handling. - * The code that we use for DOS4G/W does not appear to work - * with CauseWay correctly as it does not appear to allow us - * to map the page tables directly. Instead we can directly - * access the page table entries in extended memory where - * CauseWay always locates them (starting at 1024*4096*1023) - */ - startPage = (linear >> 12); - endPage = ((linear+limit) >> 12); - pPageTable = (ulong*)CW_PAGE_TABLE_START; - for (iPage = startPage; iPage <= endPage; iPage++) - pPageTable[iPage] = (pPageTable[iPage] & andMask) | orMask; - } - else { - pPDB = (ulong*)DPMI_mapPhysicalToLinear(PDB,0xFFF); - if (pPDB) { - startPDB = (linear >> 22) & 0x3FF; - startPage = (linear >> 12) & 0x3FF; - endPDB = ((linear+limit) >> 22) & 0x3FF; - endPage = ((linear+limit) >> 12) & 0x3FF; - for (iPDB = startPDB; iPDB <= endPDB; iPDB++) { - pageTable = pPDB[iPDB] & ~0xFFF; - pPageTable = (ulong*)DPMI_mapPhysicalToLinear(pageTable,0xFFF); - start = (iPDB == startPDB) ? startPage : 0; - end = (iPDB == endPDB) ? endPage : 0x3FF; - for (iPage = start; iPage <= end; iPage++) - pPageTable[iPage] = (pPageTable[iPage] & andMask) | orMask; - } - } - } - PM_flushTLB(); - } + if (_PM_haveCauseWay) { + /* CauseWay is a little different in the page table handling. + * The code that we use for DOS4G/W does not appear to work + * with CauseWay correctly as it does not appear to allow us + * to map the page tables directly. Instead we can directly + * access the page table entries in extended memory where + * CauseWay always locates them (starting at 1024*4096*1023) + */ + startPage = (linear >> 12); + endPage = ((linear+limit) >> 12); + pPageTable = (ulong*)CW_PAGE_TABLE_START; + for (iPage = startPage; iPage <= endPage; iPage++) + pPageTable[iPage] = (pPageTable[iPage] & andMask) | orMask; + } + else { + pPDB = (ulong*)DPMI_mapPhysicalToLinear(PDB,0xFFF); + if (pPDB) { + startPDB = (linear >> 22) & 0x3FF; + startPage = (linear >> 12) & 0x3FF; + endPDB = ((linear+limit) >> 22) & 0x3FF; + endPage = ((linear+limit) >> 12) & 0x3FF; + for (iPDB = startPDB; iPDB <= endPDB; iPDB++) { + pageTable = pPDB[iPDB] & ~0xFFF; + pPageTable = (ulong*)DPMI_mapPhysicalToLinear(pageTable,0xFFF); + start = (iPDB == startPDB) ? startPage : 0; + end = (iPDB == endPDB) ? endPage : 0x3FF; + for (iPage = start; iPage <= end; iPage++) + pPageTable[iPage] = (pPageTable[iPage] & andMask) | orMask; + } + } + } + PM_flushTLB(); + } #endif } @@ -1129,28 +1129,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)) == 0xFFFFFFFF) { - 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 @@ -1162,7 +1162,7 @@ void * PMAPI DPMI_mapPhysicalAddr(ulong base,ulong limit,ibool isCached) * caching) so that MMIO register regions do not screw up. */ if (DSBaseAddr == 0) - PM_adjustPageTables(linAddr,limit,isCached); + PM_adjustPageTables(linAddr,limit,isCached); /* Now return the base address of the memory into the default DS */ return (void*)(linAddr - DSBaseAddr); @@ -1192,10 +1192,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); @@ -1234,14 +1234,14 @@ void * PMAPI PM_allocLockedMem( * helper VxD services to allocate the memory that we need. */ if (VXD_version) { - memset(®s,0,sizeof(regs)); - regs.eax = API_NUM(PMHELP_ALLOCLOCKED); - regs.ebx = size; - regs.ecx = (ulong)physAddr; - regs.edx = contiguous | (below16Meg << 8); - _PM_VxDCall(®s,_PM_VXD_off,_PM_VXD_sel); - return (void*)regs.eax; - } + memset(®s,0,sizeof(regs)); + regs.eax = API_NUM(PMHELP_ALLOCLOCKED); + regs.ebx = size; + regs.ecx = (ulong)physAddr; + regs.edx = contiguous | (below16Meg << 8); + _PM_VxDCall(®s,_PM_VXD_off,_PM_VXD_sel); + return (void*)regs.eax; + } /* If the memory is not contiguous, we simply need to allocate it * using regular memory allocation services, and lock it down @@ -1257,19 +1257,19 @@ void * PMAPI PM_allocLockedMem( * size rounded up to the next 4K boundary. */ if (!contiguous) - p = PM_malloc(roundedSize); + p = PM_malloc(roundedSize); else #endif - p = PM_allocRealSeg(roundedSize,&r_seg,&r_off); + p = PM_allocRealSeg(roundedSize,&r_seg,&r_off); if (p == NULL) - return NULL; + return NULL; roundedP = (void*)(((ulong)p + 0xFFF) & ~0xFFF); *((ulong*)(roundedP + size)) = (ulong)p; PM_lockDataPages(roundedP,size,&lh); if ((*physAddr = PM_getPhysicalAddr(roundedP)) == 0xFFFFFFFF) { - PM_freeLockedMem(roundedP,size,contiguous); - return NULL; - } + PM_freeLockedMem(roundedP,size,contiguous); + return NULL; + } /* Disable caching for the memory since it is probably a DMA buffer */ #ifndef REALMODE @@ -1289,22 +1289,22 @@ void PMAPI PM_freeLockedMem(void *p,uint size,ibool contiguous) PM_lockHandle lh; /* Unused in DOS */ if (!p) - return; + return; if (VXD_version) { - memset(®s,0,sizeof(regs)); - regs.eax = API_NUM(PMHELP_FREELOCKED); - regs.ebx = (ulong)p; - regs.ecx = size; - regs.edx = contiguous; - _PM_VxDCall(®s,_PM_VXD_off,_PM_VXD_sel); - return; - } + memset(®s,0,sizeof(regs)); + regs.eax = API_NUM(PMHELP_FREELOCKED); + regs.ebx = (ulong)p; + regs.ecx = size; + regs.edx = contiguous; + _PM_VxDCall(®s,_PM_VXD_off,_PM_VXD_sel); + return; + } PM_unlockDataPages(p,size,&lh); if (!contiguous) - free(*((void**)((uchar*)p + size))); + free(*((void**)((uchar*)p + size))); else #endif - PM_freeRealSeg(*((void**)((char*)p + size))); + PM_freeRealSeg(*((void**)((char*)p + size))); } #ifndef REALMODE @@ -1321,11 +1321,11 @@ static pageblock *PM_addNewPageBlock(void) /* Allocate memory for the new page block, and add to head of list */ size = PAGES_PER_BLOCK * PM_PAGE_SIZE + (PM_PAGE_SIZE-1) + sizeof(pageblock); if ((newBlock = PM_malloc(size)) == NULL) - return NULL; + return NULL; newBlock->prev = NULL; newBlock->next = pageBlocks; if (pageBlocks) - pageBlocks->prev = newBlock; + pageBlocks->prev = newBlock; pageBlocks = newBlock; /* Initialise the page aligned free list for the page block */ @@ -1334,7 +1334,7 @@ static pageblock *PM_addNewPageBlock(void) newBlock->freeListStart = newBlock->freeList; newBlock->freeListEnd = p + (PAGES_PER_BLOCK-1) * PM_PAGE_SIZE; for (i = 0; i < PAGES_PER_BLOCK; i++,p = next) - FREELIST_NEXT(p) = next = p + PM_PAGE_SIZE; + FREELIST_NEXT(p) = next = p + PM_PAGE_SIZE; FREELIST_NEXT(p - PM_PAGE_SIZE) = NULL; return newBlock; } @@ -1355,27 +1355,27 @@ void * PMAPI PM_allocPage( /* Call the helper VxD for this service if we are running in a DOS box */ if (VXD_version) { - memset(®s,0,sizeof(regs)); - regs.eax = API_NUM(PMHELP_ALLOCPAGE); - regs.ebx = locked; - _PM_VxDCall(®s,_PM_VXD_off,_PM_VXD_sel); - return (void*)regs.eax; - } + memset(®s,0,sizeof(regs)); + regs.eax = API_NUM(PMHELP_ALLOCPAGE); + regs.ebx = locked; + _PM_VxDCall(®s,_PM_VXD_off,_PM_VXD_sel); + return (void*)regs.eax; + } /* Scan the block list looking for any free blocks. Allocate a new * page block if no free blocks are found. */ for (block = pageBlocks; block != NULL; block = block->next) { - if (block->freeCount) - break; - } + if (block->freeCount) + break; + } if (block == NULL && (block = PM_addNewPageBlock()) == NULL) - return NULL; + return NULL; block->freeCount--; p = block->freeList; block->freeList = FREELIST_NEXT(p); if (locked) - PM_lockDataPages(p,PM_PAGE_SIZE,&lh); + PM_lockDataPages(p,PM_PAGE_SIZE,&lh); return p; #else return NULL; @@ -1395,42 +1395,42 @@ void PMAPI PM_freePage( /* Call the helper VxD for this service if we are running in a DOS box */ if (VXD_version) { - memset(®s,0,sizeof(regs)); - regs.eax = API_NUM(PMHELP_FREEPAGE); - regs.ebx = (ulong)p; - _PM_VxDCall(®s,_PM_VXD_off,_PM_VXD_sel); - return; - } + memset(®s,0,sizeof(regs)); + regs.eax = API_NUM(PMHELP_FREEPAGE); + regs.ebx = (ulong)p; + _PM_VxDCall(®s,_PM_VXD_off,_PM_VXD_sel); + return; + } /* First find the page block that this page belongs to */ for (block = pageBlocks; block != NULL; block = block->next) { - if (p >= block->freeListStart && p <= block->freeListEnd) - break; - } + if (p >= block->freeListStart && p <= block->freeListEnd) + break; + } CHECK(block != NULL); /* Now free the block by adding it to the free list */ FREELIST_NEXT(p) = block->freeList; block->freeList = p; if (++block->freeCount == PAGES_PER_BLOCK) { - /* If all pages in the page block are now free, free the entire - * page block itself. - */ - if (block == pageBlocks) { - /* Delete from head */ - pageBlocks = block->next; - if (block->next) - block->next->prev = NULL; - } - else { - /* Delete from middle of list */ - CHECK(block->prev != NULL); - block->prev->next = block->next; - if (block->next) - block->next->prev = block->prev; - } - PM_free(block); - } + /* If all pages in the page block are now free, free the entire + * page block itself. + */ + if (block == pageBlocks) { + /* Delete from head */ + pageBlocks = block->next; + if (block->next) + block->next->prev = NULL; + } + else { + /* Delete from middle of list */ + CHECK(block->prev != NULL); + block->prev->next = block->next; + if (block->next) + block->next->prev = block->prev; + } + PM_free(block); + } #else (void)p; #endif @@ -1444,7 +1444,7 @@ void PMAPI PM_freePage( #ifndef MK_FP #define MK_FP(s,o) ( (void far *)( ((ulong)(s) << 16) + \ - (ulong)(o) )) + (ulong)(o) )) #endif void * PMAPI PM_mapRealPointer(uint r_seg,uint r_off) @@ -1534,7 +1534,7 @@ static uchar *zeroPtr = NULL; void * PMAPI PM_getBIOSPointer(void) { if (!zeroPtr) - zeroPtr = PM_mapPhysicalAddr(0,0xFFFFF,true); + zeroPtr = PM_mapPhysicalAddr(0,0xFFFFF,true); return (void*)(zeroPtr + 0x400); } @@ -1542,7 +1542,7 @@ void * PMAPI PM_getA0000Pointer(void) { static void *bankPtr; if (!bankPtr) - bankPtr = PM_mapPhysicalAddr(0xA0000,0xFFFF,true); + bankPtr = PM_mapPhysicalAddr(0xA0000,0xFFFF,true); return bankPtr; } @@ -1561,16 +1561,16 @@ void * PMAPI PM_mapPhysicalAddr(ulong base,ulong limit,ibool isCached) * running at ring 0 (ie: under real DOS). */ if (VXD_version == -1) - PM_init(); + PM_init(); if (VXD_version) { - memset(®s,0,sizeof(regs)); - regs.eax = API_NUM(PMHELP_MAPPHYS); - regs.ebx = base; - regs.ecx = limit; - regs.edx = isCached; - _PM_VxDCall(®s,_PM_VXD_off,_PM_VXD_sel); - return (void*)regs.eax; - } + memset(®s,0,sizeof(regs)); + regs.eax = API_NUM(PMHELP_MAPPHYS); + regs.ebx = base; + regs.ecx = limit; + regs.edx = isCached; + _PM_VxDCall(®s,_PM_VXD_off,_PM_VXD_sel); + return (void*)regs.eax; + } /* Round the physical address to a 4Kb boundary and the limit to a * 4Kb-1 boundary before passing the values to TNT. If we round the @@ -1583,15 +1583,15 @@ void * PMAPI PM_mapPhysicalAddr(ulong base,ulong limit,ibool isCached) _dx_config_inf(&config, (UCHAR*)&config); err = _dx_map_phys(config.c_ds_sel,baseAddr,(newLimit + 4095) / 4096,&offset); if (err == 130) { - /* If the TNT function failed, we are running in a DPMI environment - * and this function does not work. However we know how to handle - * DPMI properly, so we use our generic DPMI functions to do - * what the TNT runtime libraries can't. - */ - return DPMI_mapPhysicalAddr(base,limit,isCached); - } + /* If the TNT function failed, we are running in a DPMI environment + * and this function does not work. However we know how to handle + * DPMI properly, so we use our generic DPMI functions to do + * what the TNT runtime libraries can't. + */ + return DPMI_mapPhysicalAddr(base,limit,isCached); + } if (err == 0) - return (void*)(offset + baseOfs); + return (void*)(offset + baseOfs); return NULL; } @@ -1611,7 +1611,7 @@ void * PMAPI PM_mapToProcess(void *base,ulong limit) void * PMAPI PM_mapRealPointer(uint r_seg,uint r_off) { if (!zeroPtr) - zeroPtr = PM_mapPhysicalAddr(0,0xFFFFF); + zeroPtr = PM_mapPhysicalAddr(0,0xFFFFF); return (void*)(zeroPtr + MK_PHYS(r_seg,r_off)); } @@ -1621,7 +1621,7 @@ void * PMAPI PM_allocRealSeg(uint size,uint *r_seg,uint *r_off) void *p; if (_dx_real_alloc((size + 0xF) >> 4,&addr,&t) != 0) - return 0; + return 0; *r_seg = addr; /* Real mode segment address */ *r_off = 0; /* Real mode segment offset */ p = PM_mapRealPointer(*r_seg,*r_off); @@ -1732,7 +1732,7 @@ void * PMAPI PM_allocRealSeg(uint size,uint *r_seg,uint *r_off) r.x.bx = (size + 0xF) >> 4; /* Number of paragraphs to allocate */ PM_int386(0x21, &r, &r); /* Call DOS extender */ if (r.x.cflag) - return 0; /* Could not allocate the memory */ + return 0; /* Could not allocate the memory */ *r_seg = r.e.eax; *r_off = 0; return PM_mapRealPointer(*r_seg,*r_off); @@ -1828,19 +1828,19 @@ void * PMAPI PM_mapPhysicalAddr(ulong base,ulong limit,ibool isCached) * running at ring 0 (ie: under real DOS). */ if (VXD_version == -1) - PM_init(); + PM_init(); if (VXD_version) { - memset(®s,0,sizeof(regs)); - regs.eax = API_NUM(PMHELP_MAPPHYS); - regs.ebx = base; - regs.ecx = limit; - regs.edx = isCached; - _PM_VxDCall(®s,_PM_VXD_off,_PM_VXD_sel); - return (void*)regs.eax; - } + memset(®s,0,sizeof(regs)); + regs.eax = API_NUM(PMHELP_MAPPHYS); + regs.ebx = base; + regs.ecx = limit; + regs.edx = isCached; + _PM_VxDCall(®s,_PM_VXD_off,_PM_VXD_sel); + return (void*)regs.eax; + } if (base > 0x100000) - return _x386_map_physical_address((void*)base,limit); + return _x386_map_physical_address((void*)base,limit); return (void*)((ulong)_x386_zero_base_ptr + base); } @@ -1872,7 +1872,7 @@ void PMAPI PM_availableMemory(ulong *physical,ulong *total) /* Get physical memory available */ *physical = _X32_getPhysMem(); if (*physical > *total) - *physical = *total; + *physical = *total; } #endif @@ -1908,16 +1908,16 @@ void * PMAPI PM_mapPhysicalAddr(ulong base,ulong limit,ibool isCached) * running at ring 0 (ie: under real DOS). */ if (VXD_version == -1) - PM_init(); + PM_init(); if (VXD_version) { - memset(®s,0,sizeof(regs)); - regs.eax = API_NUM(PMHELP_MAPPHYS); - regs.ebx = base; - regs.ecx = limit; - regs.edx = isCached; - _PM_VxDCall(®s,_PM_VXD_off,_PM_VXD_sel); - return (void*)regs.eax; - } + memset(®s,0,sizeof(regs)); + regs.eax = API_NUM(PMHELP_MAPPHYS); + regs.ebx = base; + regs.ecx = limit; + regs.edx = isCached; + _PM_VxDCall(®s,_PM_VXD_off,_PM_VXD_sel); + return (void*)regs.eax; + } return DPMI_mapPhysicalAddr(base,limit,isCached); } @@ -1932,7 +1932,7 @@ ulong PMAPI PM_getPhysicalAddr(void *p) { ulong physAddr; if (!PM_getPhysicalAddrRange(p,1,&physAddr)) - return 0xFFFFFFFF; + return 0xFFFFFFFF; return physAddr | ((ulong)p & 0xFFF); } @@ -1950,14 +1950,14 @@ ibool PMAPI PM_getPhysicalAddrRange( * helper VxD services to find the physical address of an address. */ if (VXD_version) { - memset(®s,0,sizeof(regs)); - regs.eax = API_NUM(PMHELP_GETPHYSICALADDRRANGE); - regs.ebx = (ulong)p; - regs.ecx = (ulong)length; - regs.edx = (ulong)physAddress; - _PM_VxDCall(®s,_PM_VXD_off,_PM_VXD_sel); - return regs.eax; - } + memset(®s,0,sizeof(regs)); + regs.eax = API_NUM(PMHELP_GETPHYSICALADDRRANGE); + regs.ebx = (ulong)p; + regs.ecx = (ulong)length; + regs.edx = (ulong)physAddress; + _PM_VxDCall(®s,_PM_VXD_off,_PM_VXD_sel); + return regs.eax; + } /* Find base address for default DS selector */ PM_segread(&sregs); @@ -1970,38 +1970,38 @@ ibool PMAPI PM_getPhysicalAddrRange( pte = *((ulong*)p); #ifdef DOS4GW if (_PM_pagingEnabled() == 0) { - int count; - ulong linAddr = (ulong)p; - - /* When paging is disabled physical=linear */ - for (count = (length+0xFFF) >> 12; count > 0; count--) { - *physAddress++ = linAddr; - linAddr += 4096; - } - return true; - } + int count; + ulong linAddr = (ulong)p; + + /* When paging is disabled physical=linear */ + for (count = (length+0xFFF) >> 12; count > 0; count--) { + *physAddress++ = linAddr; + linAddr += 4096; + } + return true; + } else if ((PDB = _PM_getPDB()) != 0 && DSBaseAddr == 0) { - int startPDB,endPDB,iPDB,startPage,endPage,start,end,iPage; - ulong pageTable,*pPageTable,linAddr = (ulong)p; - ulong limit = length-1; - - pPDB = (ulong*)DPMI_mapPhysicalToLinear(PDB,0xFFF); - if (pPDB) { - startPDB = (linAddr >> 22) & 0x3FFL; - startPage = (linAddr >> 12) & 0x3FFL; - endPDB = ((linAddr+limit) >> 22) & 0x3FFL; - endPage = ((linAddr+limit) >> 12) & 0x3FFL; - for (iPDB = startPDB; iPDB <= endPDB; iPDB++) { - pageTable = pPDB[iPDB] & ~0xFFFL; - pPageTable = (ulong*)DPMI_mapPhysicalToLinear(pageTable,0xFFF); - start = (iPDB == startPDB) ? startPage : 0; - end = (iPDB == endPDB) ? endPage : 0x3FFL; - for (iPage = start; iPage <= end; iPage++) - *physAddress++ = (pPageTable[iPage] & ~0xFFF); - } - return true; - } - } + int startPDB,endPDB,iPDB,startPage,endPage,start,end,iPage; + ulong pageTable,*pPageTable,linAddr = (ulong)p; + ulong limit = length-1; + + pPDB = (ulong*)DPMI_mapPhysicalToLinear(PDB,0xFFF); + if (pPDB) { + startPDB = (linAddr >> 22) & 0x3FFL; + startPage = (linAddr >> 12) & 0x3FFL; + endPDB = ((linAddr+limit) >> 22) & 0x3FFL; + endPage = ((linAddr+limit) >> 12) & 0x3FFL; + for (iPDB = startPDB; iPDB <= endPDB; iPDB++) { + pageTable = pPDB[iPDB] & ~0xFFFL; + pPageTable = (ulong*)DPMI_mapPhysicalToLinear(pageTable,0xFFF); + start = (iPDB == startPDB) ? startPage : 0; + end = (iPDB == endPDB) ? endPage : 0x3FFL; + for (iPage = start; iPage <= end; iPage++) + *physAddress++ = (pPageTable[iPage] & ~0xFFF); + } + return true; + } + } #endif return false; } @@ -2017,7 +2017,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)); } @@ -2030,7 +2030,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); @@ -2043,10 +2043,10 @@ void PMAPI PM_freeRealSeg(void *mem) PMREGS r; if (mem) { - r.x.ax = 0x101; /* DPMI free DOS memory */ - r.x.dx = _PM_findRealModeBlock(mem);/* DX := selector from 0x100 */ - PM_int386(0x31, &r, &r); - } + r.x.ax = 0x101; /* DPMI free DOS memory */ + r.x.dx = _PM_findRealModeBlock(mem);/* DX := selector from 0x100 */ + PM_int386(0x31, &r, &r); + } } static DPMI_handler_t DPMI_int10 = NULL; @@ -2062,9 +2062,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; @@ -2116,17 +2116,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() @@ -2144,7 +2144,7 @@ void PMAPI PM_availableMemory(ulong *physical,ulong *total) *physical = memInfo.NumPhysicalPagesFree * 4096; *total = memInfo.LargestBlockAvail; if (*total < *physical) - *physical = *total; + *physical = *total; } #endif @@ -2212,7 +2212,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; } @@ -2225,7 +2225,7 @@ ibool PMAPI PM_getFileTime( ibool gmTime, PM_time *time) { - // TODO: Implement this! + /* TODO: Implement this! */ return false; } @@ -2238,6 +2238,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/dos/pmdos.c b/board/MAI/bios_emulator/scitech/src/pm/dos/pmdos.c index 74f8427a1c5..eecc2daedef 100644 --- a/board/MAI/bios_emulator/scitech/src/pm/dos/pmdos.c +++ b/board/MAI/bios_emulator/scitech/src/pm/dos/pmdos.c @@ -160,47 +160,47 @@ void PMAPI PM_resetMouseDriver(int hardReset) regs.x.ax = hardReset ? 0 : 33; PM_int86(0x33, ®s, ®s); if (oldHandler) - PM_setMouseHandler(_PM_mouseMask, oldHandler); + PM_setMouseHandler(_PM_mouseMask, oldHandler); } 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; - } + /* 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,0x20 | (i+3)); - _PM_writeCMOS(0x0B,(_PM_oldCMOSRegB & 0x0F) | 0x40); - } + /* Set RTC timout value and enable timeout */ + _PM_writeCMOS(0x0A,0x20 | (i+3)); + _PM_writeCMOS(0x0B,(_PM_oldCMOSRegB & 0x0F) | 0x40); + } } #ifndef REALMODE @@ -216,18 +216,18 @@ static void PMAPI lockPMHandlers(void) * under real mode. */ if (!locked) { - PM_saveDS(); - stat = !PM_lockDataPages(&globalDataStart-2048,4096,&lh); - stat |= !PM_lockDataPages(&_PM_pmdosDataStart,(int)&_PM_pmdosDataEnd - (int)&_PM_pmdosDataStart,&lh); - stat |= !PM_lockCodePages((__codePtr)_PM_pmdosCodeStart,(int)_PM_pmdosCodeEnd-(int)_PM_pmdosCodeStart,&lh); - stat |= !PM_lockDataPages(&_PM_DMADataStart,(int)&_PM_DMADataEnd - (int)&_PM_DMADataStart,&lh); - stat |= !PM_lockCodePages((__codePtr)_PM_DMACodeStart,(int)_PM_DMACodeEnd-(int)_PM_DMACodeStart,&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_pmdosDataStart,(int)&_PM_pmdosDataEnd - (int)&_PM_pmdosDataStart,&lh); + stat |= !PM_lockCodePages((__codePtr)_PM_pmdosCodeStart,(int)_PM_pmdosCodeEnd-(int)_PM_pmdosCodeStart,&lh); + stat |= !PM_lockDataPages(&_PM_DMADataStart,(int)&_PM_DMADataEnd - (int)&_PM_DMADataStart,&lh); + stat |= !PM_lockCodePages((__codePtr)_PM_DMACodeStart,(int)_PM_DMACodeEnd-(int)_PM_DMACodeStart,&lh); + if (stat) { + printf("Page locking services failed - interrupt handling not safe!\n"); + exit(1); + } + locked = 1; + } } #endif @@ -240,7 +240,7 @@ static void PMAPI lockPMHandlers(void) #ifndef MK_FP #define MK_FP(s,o) ( (void far *)( ((ulong)(s) << 16) + \ - (ulong)(o) )) + (ulong)(o) )) #endif int PMAPI PM_setMouseHandler(int mask, PM_mouseHandler mh) @@ -256,10 +256,10 @@ void PMAPI PM_restoreMouseHandler(void) union REGS regs; if (_PM_mouseHandler) { - regs.x.ax = 33; - int86(0x33, ®s, ®s); - _PM_mouseHandler = NULL; - } + regs.x.ax = 33; + int86(0x33, ®s, ®s); + _PM_mouseHandler = NULL; + } } void PMAPI PM_setTimerHandler(PM_intHandler th) @@ -272,9 +272,9 @@ void PMAPI PM_setTimerHandler(PM_intHandler th) void PMAPI PM_restoreTimerHandler(void) { if (_PM_timerHandler) { - _PM_setRMvect(0x8, (long)_PM_prevTimer); - _PM_timerHandler = NULL; - } + _PM_setRMvect(0x8, (long)_PM_prevTimer); + _PM_timerHandler = NULL; + } } ibool PMAPI PM_setRealTimeClockHandler(PM_intHandler th,int frequency) @@ -300,15 +300,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 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 */ - _PM_setRMvect(0x70, (long)_PM_prevRTC); - _PM_rtcHandler = NULL; - } + /* Restore the interrupt vector */ + _PM_setRMvect(0x70, (long)_PM_prevRTC); + _PM_rtcHandler = NULL; + } } void PMAPI PM_setKeyHandler(PM_intHandler kh) @@ -321,9 +321,9 @@ void PMAPI PM_setKeyHandler(PM_intHandler kh) void PMAPI PM_restoreKeyHandler(void) { if (_PM_keyHandler) { - _PM_setRMvect(0x9, (long)_PM_prevKey); - _PM_keyHandler = NULL; - } + _PM_setRMvect(0x9, (long)_PM_prevKey); + _PM_keyHandler = NULL; + } } void PMAPI PM_setKey15Handler(PM_key15Handler kh) @@ -336,9 +336,9 @@ void PMAPI PM_setKey15Handler(PM_key15Handler kh) void PMAPI PM_restoreKey15Handler(void) { if (_PM_key15Handler) { - _PM_setRMvect(0x15, (long)_PM_prevKey15); - _PM_key15Handler = NULL; - } + _PM_setRMvect(0x15, (long)_PM_prevKey15); + _PM_key15Handler = NULL; + } } void PMAPI PM_installAltBreakHandler(PM_breakHandler bh) @@ -362,11 +362,11 @@ void PMAPI PM_installBreakHandler(void) void PMAPI PM_restoreBreakHandler(void) { if (_PM_prevBreak) { - _PM_setRMvect(0x1B, (long)_PM_prevBreak); - _PM_setRMvect(0x23, (long)_PM_prevCtrlC); - _PM_prevBreak = NULL; - _PM_breakHandler = NULL; - } + _PM_setRMvect(0x1B, (long)_PM_prevBreak); + _PM_setRMvect(0x23, (long)_PM_prevCtrlC); + _PM_prevBreak = NULL; + _PM_breakHandler = NULL; + } } void PMAPI PM_installAltCriticalHandler(PM_criticalHandler ch) @@ -387,10 +387,10 @@ void PMAPI PM_installCriticalHandler(void) void PMAPI PM_restoreCriticalHandler(void) { if (_PM_prevCritical) { - _PM_setRMvect(0x24, (long)_PM_prevCritical); - _PM_prevCritical = NULL; - _PM_critHandler = NULL; - } + _PM_setRMvect(0x24, (long)_PM_prevCritical); + _PM_prevCritical = NULL; + _PM_critHandler = NULL; + } } int PMAPI PM_lockDataPages(void *p,uint len,PM_lockHandle *lh) @@ -499,7 +499,7 @@ uchar * installCallback(void (PMAPI *pmCB)(),uint *rseg, uint *roff) /* Copy the real mode handler to real mode memory */ if ((p = PM_allocRealSeg(sizeof(realHandler),rseg,roff)) == NULL) - return NULL; + return NULL; memcpy(p,realHandler,sizeof(realHandler)); /* Skip past global variabls in real mode code segment */ @@ -516,7 +516,7 @@ int PMAPI PM_setMouseHandler(int mask, PM_mouseHandler mh) lockPMHandlers(); /* Ensure our handlers are locked */ if ((mousePtr = installCallback(_PM_mouseISR, &rseg, &roff)) == NULL) - return 0; + return 0; _PM_mouseHandler = mh; /* Install the real mode mouse handler */ @@ -533,11 +533,11 @@ void PMAPI PM_restoreMouseHandler(void) RMREGS regs; if (_PM_mouseHandler) { - regs.x.ax = 33; - PM_int86(0x33, ®s, ®s); - PM_freeRealSeg(mousePtr); - _PM_mouseHandler = NULL; - } + regs.x.ax = 33; + PM_int86(0x33, ®s, ®s); + PM_freeRealSeg(mousePtr); + _PM_mouseHandler = NULL; + } } void PMAPI PM_getPMvect(int intno, PMFARPTR *isr) @@ -602,9 +602,9 @@ void PMAPI PM_setTimerHandler(PM_intHandler th) void PMAPI PM_restoreTimerHandler(void) { if (_PM_timerHandler) { - restoreISR(0x8, _PM_prevTimer, _PM_prevRealTimer); - _PM_timerHandler = NULL; - } + restoreISR(0x8, _PM_prevTimer, _PM_prevRealTimer); + _PM_timerHandler = NULL; + } } ibool PMAPI PM_setRealTimeClockHandler(PM_intHandler th,int frequency) @@ -630,15 +630,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 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 the interrupt vector */ + restoreISR(0x70, _PM_prevRTC, _PM_prevRealRTC); + _PM_rtcHandler = NULL; + } } void PMAPI PM_setKeyHandler(PM_intHandler kh) @@ -651,9 +651,9 @@ void PMAPI PM_setKeyHandler(PM_intHandler kh) void PMAPI PM_restoreKeyHandler(void) { if (_PM_keyHandler) { - restoreISR(0x9, _PM_prevKey, _PM_prevRealKey); - _PM_keyHandler = NULL; - } + restoreISR(0x9, _PM_prevKey, _PM_prevRealKey); + _PM_keyHandler = NULL; + } } void PMAPI PM_setKey15Handler(PM_key15Handler kh) @@ -666,9 +666,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; + } } void PMAPI PM_installAltBreakHandler(PM_breakHandler bh) @@ -692,11 +692,11 @@ 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; - } + restoreISR(0x1B, _PM_prevBreak, prevRealBreak); + restoreISR(0x23, _PM_prevCtrlC, prevRealCtrlC); + _PM_prevBreak.sel = 0; + _PM_breakHandler = NULL; + } } void PMAPI PM_installAltCriticalHandler(PM_criticalHandler ch) @@ -717,10 +717,10 @@ void PMAPI PM_installCriticalHandler(void) void PMAPI PM_restoreCriticalHandler(void) { if (_PM_prevCritical.sel) { - restoreISR(0x24, _PM_prevCritical, prevRealCritical); - _PM_prevCritical.sel = 0; - _PM_critHandler = NULL; - } + restoreISR(0x24, _PM_prevCritical, prevRealCritical); + _PM_prevCritical.sel = 0; + _PM_critHandler = NULL; + } } int PMAPI PM_lockDataPages(void *p,uint len,PM_lockHandle *lh) @@ -816,9 +816,9 @@ int installCallback(void (PMAPI *pmCB)(),uint *psel, uint *poff, * buffer once since we cant dealloate it with X32). */ if (*psel == 0) { - if (!PM_allocRealSeg(sizeof(realHandler),psel,poff,rseg,roff)) - return 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 */ @@ -835,7 +835,7 @@ int PMAPI PM_setMouseHandler(int mask, PM_mouseHandler mh) lockPMHandlers(); /* Ensure our handlers are locked */ if (!installCallback(_PM_mouseISR, &mouseSel, &mouseOff, &rseg, &roff)) - return 0; + return 0; _PM_mouseHandler = mh; /* Install the real mode mouse handler */ @@ -852,10 +852,10 @@ void PMAPI PM_restoreMouseHandler(void) RMREGS regs; if (_PM_mouseHandler) { - regs.x.ax = 33; - PM_int86(0x33, ®s, ®s); - _PM_mouseHandler = NULL; - } + regs.x.ax = 33; + PM_int86(0x33, ®s, ®s); + _PM_mouseHandler = NULL; + } } void PMAPI PM_getPMvect(int intno, PMFARPTR *isr) @@ -941,9 +941,9 @@ void PMAPI PM_setTimerHandler(PM_intHandler th) void PMAPI PM_restoreTimerHandler(void) { if (_PM_timerHandler) { - restoreISR(0x8, _PM_prevTimer, _PM_prevRealTimer); - _PM_timerHandler = NULL; - } + restoreISR(0x8, _PM_prevTimer, _PM_prevRealTimer); + _PM_timerHandler = NULL; + } } ibool PMAPI PM_setRealTimeClockHandler(PM_intHandler th,int frequency) @@ -969,15 +969,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 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 the interrupt vector */ + restoreISR(0x70, _PM_prevRTC, _PM_prevRealRTC); + _PM_rtcHandler = NULL; + } } void PMAPI PM_setKeyHandler(PM_intHandler kh) @@ -990,9 +990,9 @@ void PMAPI PM_setKeyHandler(PM_intHandler kh) void PMAPI PM_restoreKeyHandler(void) { if (_PM_keyHandler) { - restoreISR(0x9, _PM_prevKey, _PM_prevRealKey); - _PM_keyHandler = NULL; - } + restoreISR(0x9, _PM_prevKey, _PM_prevRealKey); + _PM_keyHandler = NULL; + } } void PMAPI PM_setKey15Handler(PM_key15Handler kh) @@ -1005,9 +1005,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; + } } void PMAPI PM_installAltBreakHandler(PM_breakHandler bh) @@ -1031,11 +1031,11 @@ 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; - } + restoreISR(0x1B, _PM_prevBreak, prevRealBreak); + restoreISR(0x23, _PM_prevCtrlC, prevRealCtrlC); + _PM_prevBreak.sel = 0; + _PM_breakHandler = NULL; + } } void PMAPI PM_installAltCriticalHandler(PM_criticalHandler ch) @@ -1056,10 +1056,10 @@ void PMAPI PM_installCriticalHandler(void) void PMAPI PM_restoreCriticalHandler(void) { if (_PM_prevCritical.sel) { - restoreISR(0x24, _PM_prevCritical, prevRealCritical); - _PM_prevCritical.sel = 0; - _PM_critHandler = NULL; - } + restoreISR(0x24, _PM_prevCritical, prevRealCritical); + _PM_prevCritical.sel = 0; + _PM_critHandler = NULL; + } } int PMAPI PM_lockDataPages(void *p,uint len,PM_lockHandle *lh) @@ -1199,10 +1199,10 @@ void PMAPI PM_restoreMouseHandler(void) PMREGS regs; if (_PM_mouseHandler) { - regs.x.ax = 33; - PM_int386(0x33, ®s, ®s); - _PM_mouseHandler = NULL; - } + regs.x.ax = 33; + PM_int386(0x33, ®s, ®s); + _PM_mouseHandler = NULL; + } } #endif @@ -1288,10 +1288,10 @@ int PMAPI PM_setMouseHandler(int mask, PM_mouseHandler mh) /* Copy the real mode handler to real mode memory */ if ((mousePtr = PM_allocRealSeg(sizeof(mouseHandler),&rseg,&roff)) == NULL) - return 0; + return 0; memcpy(mousePtr,mouseHandler,sizeof(mouseHandler)); if (!_DPMI_allocateCallback(_PM_mousePMCB, mouseRegs, &mouseRMCB)) - PM_fatalError("Unable to allocate real mode callback!\n"); + PM_fatalError("Unable to allocate real mode callback!\n"); PM_setLong(mousePtr,mouseRMCB); /* Install the real mode mouse handler */ @@ -1309,12 +1309,12 @@ void PMAPI PM_restoreMouseHandler(void) RMREGS regs; if (_PM_mouseHandler) { - regs.x.ax = 33; - PM_int86(0x33, ®s, ®s); - PM_freeRealSeg(mousePtr); - _DPMI_freeCallback(mouseRMCB); - _PM_mouseHandler = NULL; - } + regs.x.ax = 33; + PM_int86(0x33, ®s, ®s); + PM_freeRealSeg(mousePtr); + _DPMI_freeCallback(mouseRMCB); + _PM_mouseHandler = NULL; + } } #endif @@ -1347,9 +1347,9 @@ void PMAPI PM_setTimerHandler(PM_intHandler th) void PMAPI PM_restoreTimerHandler(void) { if (_PM_timerHandler) { - restoreISR(0x8, _PM_prevTimer, _PM_prevRealTimer); - _PM_timerHandler = NULL; - } + restoreISR(0x8, _PM_prevTimer, _PM_prevRealTimer); + _PM_timerHandler = NULL; + } } ibool PMAPI PM_setRealTimeClockHandler(PM_intHandler th,int frequency) @@ -1375,15 +1375,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 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 the interrupt vector */ + restoreISR(0x70, _PM_prevRTC, _PM_prevRealRTC); + _PM_rtcHandler = NULL; + } } PM_IRQHandle PMAPI PM_setIRQHandler( @@ -1396,20 +1396,20 @@ PM_IRQHandle PMAPI PM_setIRQHandler( thunkSize = (ulong)_PM_irqISRTemplateEnd - (ulong)_PM_irqISRTemplate; if ((handle = PM_malloc(sizeof(_PM_IRQHandle) + thunkSize)) == NULL) - return NULL; + return NULL; handle->IRQ = IRQ; handle->prevPIC = PM_inpb(0x21); handle->prevPIC2 = PM_inpb(0xA1); if (IRQ < 8) { - handle->IRQVect = (IRQ + 8); - PICmask = (1 << IRQ); - chainPrevious = ((handle->prevPIC & PICmask) == 0); - } + handle->IRQVect = (IRQ + 8); + PICmask = (1 << IRQ); + chainPrevious = ((handle->prevPIC & PICmask) == 0); + } else { - handle->IRQVect = (0x60 + IRQ + 8); - PICmask = ((1 << IRQ) | 0x4); - chainPrevious = ((handle->prevPIC2 & (PICmask >> 8)) == 0); - } + handle->IRQVect = (0x60 + IRQ + 8); + PICmask = ((1 << IRQ) | 0x4); + chainPrevious = ((handle->prevPIC2 & (PICmask >> 8)) == 0); + } /* Copy and setup the assembler thunk */ offsetAdjust = (ulong)handle->thunk - (ulong)_PM_irqISRTemplate; @@ -1417,13 +1417,13 @@ PM_IRQHandle PMAPI PM_setIRQHandler( *((ulong*)&handle->thunk[2]) = offsetAdjust; *((ulong*)&handle->thunk[11+0]) = (ulong)ih; if (chainPrevious) { - *((ulong*)&handle->thunk[11+4]) = handle->prevHandler.off; - *((ulong*)&handle->thunk[11+8]) = handle->prevHandler.sel; - } + *((ulong*)&handle->thunk[11+4]) = handle->prevHandler.off; + *((ulong*)&handle->thunk[11+8]) = handle->prevHandler.sel; + } else { - *((ulong*)&handle->thunk[11+4]) = 0; - *((ulong*)&handle->thunk[11+8]) = 0; - } + *((ulong*)&handle->thunk[11+4]) = 0; + *((ulong*)&handle->thunk[11+8]) = 0; + } *((ulong*)&handle->thunk[11+12]) = IRQ; /* Set the real time clock interrupt handler */ @@ -1444,9 +1444,9 @@ void PMAPI PM_restoreIRQHandler( /* Restore PIC mask for the interrupt */ if (handle->IRQ < 8) - PICmask = (1 << handle->IRQ); + PICmask = (1 << handle->IRQ); else - PICmask = ((1 << handle->IRQ) | 0x4); + PICmask = ((1 << handle->IRQ) | 0x4); PM_outpb(0xA1,(PM_inpb(0xA1) & ~(PICmask >> 8)) | (handle->prevPIC2 & (PICmask >> 8))); PM_outpb(0x21,(PM_inpb(0x21) & ~PICmask) | (handle->prevPIC & PICmask)); @@ -1467,9 +1467,9 @@ void PMAPI PM_setKeyHandler(PM_intHandler kh) void PMAPI PM_restoreKeyHandler(void) { if (_PM_keyHandler) { - restoreISR(0x9, _PM_prevKey, _PM_prevRealKey); - _PM_keyHandler = NULL; - } + restoreISR(0x9, _PM_prevKey, _PM_prevRealKey); + _PM_keyHandler = NULL; + } } void PMAPI PM_setKey15Handler(PM_key15Handler kh) @@ -1482,9 +1482,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 @@ -1540,14 +1540,14 @@ 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; + restoreISR(0x1B, _PM_prevBreak, prevRealBreak); + restoreISR(0x23, _PM_prevCtrlC, prevRealCtrlC); + _PM_prevBreak.sel = 0; + _PM_breakHandler = NULL; #ifndef DOS4GW - PM_freeRealSeg(_PM_ctrlBPtr); + PM_freeRealSeg(_PM_ctrlBPtr); #endif - } + } } /* Real mode Critical Error handler. This handler simply saves the AX and @@ -1599,11 +1599,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) diff --git a/board/MAI/bios_emulator/scitech/src/pm/dos/vflat.c b/board/MAI/bios_emulator/scitech/src/pm/dos/vflat.c index 2e78e25a8b5..c3e9b6c33f8 100644 --- a/board/MAI/bios_emulator/scitech/src/pm/dos/vflat.c +++ b/board/MAI/bios_emulator/scitech/src/pm/dos/vflat.c @@ -79,7 +79,7 @@ PRIVATE ibool CheckDPMI(void) PMREGS regs; if (haveDPMI) - return true; + return true; /* Check if we are running under DPMI in which case we will not be * able to install our page fault handlers. We can however use the @@ -88,7 +88,7 @@ PRIVATE ibool CheckDPMI(void) regs.x.ax = 0xFF00; PM_int386(0x31,®s,®s); if (!regs.x.cflag && (regs.e.edi & 8)) - return (haveDPMI = true); + return (haveDPMI = true); return false; } @@ -101,13 +101,13 @@ ibool PMAPI VF_available(void) ****************************************************************************/ { if (!VF_zeroPtr) - VF_zeroPtr = PM_mapPhysicalAddr(0,0xFFFFFFFF,true); + VF_zeroPtr = PM_mapPhysicalAddr(0,0xFFFFFFFF,true); if (CheckDPMI()) - return false; + return false; /* Standard DOS4GW, PMODE/W and Causeway */ if (InitPaging() == -1) - return false; + return false; ClosePaging(); return true; } @@ -153,21 +153,21 @@ void * PMAPI InitDOS4GW(ulong baseAddr,int bankSize,int codeLen,void *bankFunc) int i; if (InitPaging() == -1) - return NULL; /* Cannot do hardware paging! */ + return NULL; /* Cannot do hardware paging! */ /* Map 4MB of video memory into linear address space (read/write) */ if (bankSize == 64) { - for (i = 0; i < 64; i++) { - MapPhysical2Linear(baseAddr,VFLAT_START_ADDR+(i<<16),16, - PAGE_WRITE | PAGE_NOTPRESENT); - } - } + for (i = 0; i < 64; i++) { + MapPhysical2Linear(baseAddr,VFLAT_START_ADDR+(i<<16),16, + PAGE_WRITE | PAGE_NOTPRESENT); + } + } else { - for (i = 0; i < 1024; i++) { - MapPhysical2Linear(baseAddr,VFLAT_START_ADDR+(i<<12),1, - PAGE_WRITE | PAGE_NOTPRESENT); - } - } + for (i = 0; i < 1024; i++) { + MapPhysical2Linear(baseAddr,VFLAT_START_ADDR+(i<<12),1, + PAGE_WRITE | PAGE_NOTPRESENT); + } + } /* Install our page fault handler and banks switch function */ InstallFaultHandler(baseAddr,bankSize); @@ -191,13 +191,13 @@ void * PMAPI VF_init(ulong baseAddr,int bankSize,int codeLen,void *bankFunc) ****************************************************************************/ { if (installed) - return (void*)VFLAT_START_ADDR; + return (void*)VFLAT_START_ADDR; if (codeLen > 100) - return NULL; /* Bank function is too large! */ + return NULL; /* Bank function is too large! */ if (!VF_zeroPtr) - VF_zeroPtr = PM_mapPhysicalAddr(0,0xFFFFFFFF,true); + VF_zeroPtr = PM_mapPhysicalAddr(0,0xFFFFFFFF,true); if (CheckDPMI()) - return InitDPMI(baseAddr,bankSize,codeLen,bankFunc); + return InitDPMI(baseAddr,bankSize,codeLen,bankFunc); return InitDOS4GW(baseAddr,bankSize,codeLen,bankFunc); } @@ -212,16 +212,16 @@ void PMAPI VF_exit(void) ****************************************************************************/ { if (installed) { - if (haveDPMI) { - /* DPMI support */ - } - else { - /* Standard DOS4GW and PMODE/W support */ - RemoveFaultHandler(); - ClosePaging(); - } - installed = false; - } + if (haveDPMI) { + /* DPMI support */ + } + else { + /* Standard DOS4GW and PMODE/W support */ + RemoveFaultHandler(); + ClosePaging(); + } + installed = false; + } } /*-------------------------------------------------------------------------*/ diff --git a/board/MAI/bios_emulator/scitech/src/pm/dos/ztimer.c b/board/MAI/bios_emulator/scitech/src/pm/dos/ztimer.c index 960ed06cd74..53ab16cf404 100644 --- a/board/MAI/bios_emulator/scitech/src/pm/dos/ztimer.c +++ b/board/MAI/bios_emulator/scitech/src/pm/dos/ztimer.c @@ -106,6 +106,6 @@ passed, so if this happens we will be generating erronous results. ulong __ULZElapsedTime(ulong start,ulong finish) { if (finish < start) - finish += 1573040L; /* Number of ticks in 24 hours */ + finish += 1573040L; /* Number of ticks in 24 hours */ return finish - start; } diff --git a/board/MAI/bios_emulator/scitech/src/pm/event.c b/board/MAI/bios_emulator/scitech/src/pm/event.c index b284c68cfb0..b6f458654b7 100644 --- a/board/MAI/bios_emulator/scitech/src/pm/event.c +++ b/board/MAI/bios_emulator/scitech/src/pm/event.c @@ -106,8 +106,8 @@ queue. This routine assumes that at least one spot is available on the freeList for the event to be inserted. 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 addEvent( event_t *evt) @@ -116,35 +116,35 @@ static void addEvent( /* Check for mouse double click events */ if (evt->what & EVT_MOUSEEVT) { - EVT.autoMouse_x = evt->where_x; - EVT.autoMouse_y = evt->where_y; - if ((evt->what & EVT_MOUSEDOWN) && !(evt->message & EVT_DBLCLICK)) { - /* Determine if the last mouse event was a double click event */ - uint diff_x = ABS(evt->where_x - EVT.downMouse.where_x); - uint diff_y = ABS(evt->where_y - EVT.downMouse.where_y); - if ((evt->message == EVT.downMouse.message) - && ((evt->when - EVT.downMouse.when) <= EVT.doubleClick) - && (diff_x <= EVT.doubleClickThresh) - && (diff_y <= EVT.doubleClickThresh)) { - evt->message |= EVT_DBLCLICK; - EVT.downMouse = *evt; - EVT.downMouse.when = 0; - } - else - EVT.downMouse = *evt; - EVT.autoTicks = _EVT_getTicks(); - } - else if (evt->what & EVT_MOUSEUP) { - EVT.downMouse.what = EVT_NULLEVT; - EVT.firstAuto = true; - } - } + EVT.autoMouse_x = evt->where_x; + EVT.autoMouse_y = evt->where_y; + if ((evt->what & EVT_MOUSEDOWN) && !(evt->message & EVT_DBLCLICK)) { + /* Determine if the last mouse event was a double click event */ + uint diff_x = ABS(evt->where_x - EVT.downMouse.where_x); + uint diff_y = ABS(evt->where_y - EVT.downMouse.where_y); + if ((evt->message == EVT.downMouse.message) + && ((evt->when - EVT.downMouse.when) <= EVT.doubleClick) + && (diff_x <= EVT.doubleClickThresh) + && (diff_y <= EVT.doubleClickThresh)) { + evt->message |= EVT_DBLCLICK; + EVT.downMouse = *evt; + EVT.downMouse.when = 0; + } + else + EVT.downMouse = *evt; + EVT.autoTicks = _EVT_getTicks(); + } + else if (evt->what & EVT_MOUSEUP) { + EVT.downMouse.what = EVT_NULLEVT; + EVT.firstAuto = true; + } + } /* Call user supplied callback to modify the event if desired */ if (EVT.userEventCallback) { - if (!EVT.userEventCallback(evt)) - return; - } + if (!EVT.userEventCallback(evt)) + return; + } /* Get spot to place the event from the free list */ evtID = EVT.freeHead; @@ -154,9 +154,9 @@ static void addEvent( evt->next = -1; evt->prev = EVT.tail; if (EVT.tail != -1) - EVT.evtq[EVT.tail].next = evtID; + EVT.evtq[EVT.tail].next = evtID; else - EVT.head = evtID; + EVT.head = evtID; EVT.tail = evtID; EVT.evtq[evtID] = *evt; EVT.count++; @@ -172,7 +172,7 @@ static void initEventQueue(void) /* Build free list, and initialize global data structures */ for (i = 0; i < EVENTQSIZE; i++) - EVT.evtq[i].next = i+1; + EVT.evtq[i].next = i+1; EVT.evtq[EVENTQSIZE-1].next = -1; /* Terminate list */ EVT.count = EVT.freeHead = 0; EVT.head = EVT.tail = -1; @@ -217,21 +217,21 @@ static int scaleJoyAxis( /* Make sure the joystick is calibrated properly */ if (EVT.joyCenter[axis] - EVT.joyMin[axis] < 5) - return raw; + return raw; if (EVT.joyMax[axis] - EVT.joyCenter[axis] < 5) - return raw; + return raw; /* Now scale the coordinates to -128 to 127 */ raw -= EVT.joyCenter[axis]; if (raw < 0) - range = EVT.joyCenter[axis]-EVT.joyMin[axis]; + range = EVT.joyCenter[axis]-EVT.joyMin[axis]; else - range = EVT.joyMax[axis]-EVT.joyCenter[axis]; + range = EVT.joyMax[axis]-EVT.joyCenter[axis]; scaled = (raw * 128) / range; if (scaled < -128) - scaled = -128; + scaled = -128; if (scaled > 127) - scaled = 127; + scaled = 127; return scaled; } #endif @@ -308,9 +308,9 @@ int EVTAPI EVT_joyIsPresent(void) #endif mask = _EVT_readJoyAxis(EVT_JOY_AXIS_ALL,EVT.joyCenter); if (mask) { - for (i = 0; i < JOY_NUM_AXES; i++) - EVT.joyMax[i] = EVT.joyCenter[i]*2; - } + for (i = 0; i < JOY_NUM_AXES; i++) + EVT.joyMax[i] = EVT.joyCenter[i]*2; + } return mask; } @@ -329,9 +329,9 @@ All information polled from the joystick will be posted to the event queue for later retrieval. Note: Most analogue joysticks will provide readings that change even - though the joystick has not moved. Hence if you call this routine - you will likely get an EVT_JOYMOVE event every time through your - event loop. + though the joystick has not moved. Hence if you call this routine + you will likely get an EVT_JOYMOVE event every time through your + event loop. SEE ALSO: EVT_getNext, EVT_peekNext, EVT_joySetUpperLeft, EVT_joySetLowerRight, @@ -343,68 +343,68 @@ void EVTAPI EVT_pollJoystick(void) int i,axis[JOY_NUM_AXES],newButState,mask,moved,ps; if (EVT.joyMask) { - /* Read joystick axes and post movement events if they have - * changed since the last time we polled. Until the events are - * actually flushed, we keep modifying the same joystick movement - * event, so you won't get multiple movement event - */ - mask = _EVT_readJoyAxis(EVT.joyMask,axis); - newButState = _EVT_readJoyButtons(); - moved = false; - for (i = 0; i < JOY_NUM_AXES; i++) { - if (mask & (EVT_JOY_AXIS_X1 << i)) - axis[i] = scaleJoyAxis(axis[i],i); - else - axis[i] = EVT.joyPrev[i]; - if (axis[i] != EVT.joyPrev[i]) - moved = true; - } - if (moved) { - memcpy(EVT.joyPrev,axis,sizeof(EVT.joyPrev)); - ps = _EVT_disableInt(); - if (EVT.oldJoyMove != -1) { - /* Modify the existing joystick movement event */ - EVT.evtq[EVT.oldJoyMove].message = newButState; - EVT.evtq[EVT.oldJoyMove].where_x = EVT.joyPrev[0]; - EVT.evtq[EVT.oldJoyMove].where_y = EVT.joyPrev[1]; - EVT.evtq[EVT.oldJoyMove].relative_x = EVT.joyPrev[2]; - EVT.evtq[EVT.oldJoyMove].relative_y = EVT.joyPrev[3]; - } - else if (EVT.count < EVENTQSIZE) { - /* Add a new joystick movement event */ - EVT.oldJoyMove = EVT.freeHead; - memset(&evt,0,sizeof(evt)); - evt.what = EVT_JOYMOVE; - evt.message = EVT.joyButState; - evt.where_x = EVT.joyPrev[0]; - evt.where_y = EVT.joyPrev[1]; - evt.relative_x = EVT.joyPrev[2]; - evt.relative_y = EVT.joyPrev[3]; - addEvent(&evt); - } - _EVT_restoreInt(ps); - } - - /* Read the joystick buttons, and post events to reflect the change - * in state for the joystick buttons. - */ - if (newButState != EVT.joyButState) { - if (EVT.count < EVENTQSIZE) { - /* Add a new joystick click event */ - ps = _EVT_disableInt(); - memset(&evt,0,sizeof(evt)); - evt.what = EVT_JOYCLICK; - evt.message = newButState; - EVT.evtq[EVT.oldJoyMove].where_x = EVT.joyPrev[0]; - EVT.evtq[EVT.oldJoyMove].where_y = EVT.joyPrev[1]; - EVT.evtq[EVT.oldJoyMove].relative_x = EVT.joyPrev[2]; - EVT.evtq[EVT.oldJoyMove].relative_y = EVT.joyPrev[3]; - addEvent(&evt); - _EVT_restoreInt(ps); - } - EVT.joyButState = newButState; - } - } + /* Read joystick axes and post movement events if they have + * changed since the last time we polled. Until the events are + * actually flushed, we keep modifying the same joystick movement + * event, so you won't get multiple movement event + */ + mask = _EVT_readJoyAxis(EVT.joyMask,axis); + newButState = _EVT_readJoyButtons(); + moved = false; + for (i = 0; i < JOY_NUM_AXES; i++) { + if (mask & (EVT_JOY_AXIS_X1 << i)) + axis[i] = scaleJoyAxis(axis[i],i); + else + axis[i] = EVT.joyPrev[i]; + if (axis[i] != EVT.joyPrev[i]) + moved = true; + } + if (moved) { + memcpy(EVT.joyPrev,axis,sizeof(EVT.joyPrev)); + ps = _EVT_disableInt(); + if (EVT.oldJoyMove != -1) { + /* Modify the existing joystick movement event */ + EVT.evtq[EVT.oldJoyMove].message = newButState; + EVT.evtq[EVT.oldJoyMove].where_x = EVT.joyPrev[0]; + EVT.evtq[EVT.oldJoyMove].where_y = EVT.joyPrev[1]; + EVT.evtq[EVT.oldJoyMove].relative_x = EVT.joyPrev[2]; + EVT.evtq[EVT.oldJoyMove].relative_y = EVT.joyPrev[3]; + } + else if (EVT.count < EVENTQSIZE) { + /* Add a new joystick movement event */ + EVT.oldJoyMove = EVT.freeHead; + memset(&evt,0,sizeof(evt)); + evt.what = EVT_JOYMOVE; + evt.message = EVT.joyButState; + evt.where_x = EVT.joyPrev[0]; + evt.where_y = EVT.joyPrev[1]; + evt.relative_x = EVT.joyPrev[2]; + evt.relative_y = EVT.joyPrev[3]; + addEvent(&evt); + } + _EVT_restoreInt(ps); + } + + /* Read the joystick buttons, and post events to reflect the change + * in state for the joystick buttons. + */ + if (newButState != EVT.joyButState) { + if (EVT.count < EVENTQSIZE) { + /* Add a new joystick click event */ + ps = _EVT_disableInt(); + memset(&evt,0,sizeof(evt)); + evt.what = EVT_JOYCLICK; + evt.message = newButState; + EVT.evtq[EVT.oldJoyMove].where_x = EVT.joyPrev[0]; + EVT.evtq[EVT.oldJoyMove].where_y = EVT.joyPrev[1]; + EVT.evtq[EVT.oldJoyMove].relative_x = EVT.joyPrev[2]; + EVT.evtq[EVT.oldJoyMove].relative_y = EVT.joyPrev[3]; + addEvent(&evt); + _EVT_restoreInt(ps); + } + EVT.joyButState = newButState; + } + } } /**************************************************************************** @@ -526,19 +526,19 @@ ibool EVTAPI EVT_post( uint ps; if (EVT.count < EVENTQSIZE) { - /* Save information in event record */ - ps = _EVT_disableInt(); - evt.which = which; - evt.when = _EVT_getTicks(); - evt.what = what; - evt.message = message; - evt.modifiers = modifiers; - addEvent(&evt); /* Add to EVT.tail of event queue */ - _EVT_restoreInt(ps); - return true; - } + /* Save information in event record */ + ps = _EVT_disableInt(); + evt.which = which; + evt.when = _EVT_getTicks(); + evt.what = what; + evt.message = message; + evt.modifiers = modifiers; + addEvent(&evt); /* Add to EVT.tail of event queue */ + _EVT_restoreInt(ps); + return true; + } else - return false; + return false; } /**************************************************************************** @@ -565,8 +565,8 @@ void EVTAPI EVT_flush( event_t evt; do { /* Flush all events */ - EVT_getNext(&evt,mask); - } while (evt.what != EVT_NULLEVT); + EVT_getNext(&evt,mask); + } while (evt.what != EVT_NULLEVT); } /**************************************************************************** @@ -596,10 +596,10 @@ void EVTAPI EVT_halt( ulong mask) { do { /* Wait for an event */ - if (mask & (EVT_JOYEVT)) - EVT_pollJoystick(); - EVT_getNext(evt,EVT_EVERYEVT); - } while (!(evt->what & mask)); + if (mask & (EVT_JOYEVT)) + EVT_pollJoystick(); + EVT_getNext(evt,EVT_EVERYEVT); + } while (!(evt->what & mask)); } /**************************************************************************** @@ -636,31 +636,31 @@ ibool EVTAPI EVT_peekNext( uint ps; if (EVT.heartBeat) - EVT.heartBeat(EVT.heartBeatParams); + EVT.heartBeat(EVT.heartBeatParams); _EVT_pumpMessages(); /* Pump all messages into queue */ EVT.mouseMove(EVT.mx,EVT.my); /* Move the mouse cursor */ evt->what = EVT_NULLEVT; /* Default to null event */ if (EVT.count) { - /* It is possible that an event be posted while we are trying - * to access the event queue. This would create problems since - * we may end up with invalid data for our event queue pointers. To - * alleviate this, all interrupts are suspended while we manipulate - * our pointers. - */ - ps = _EVT_disableInt(); /* disable interrupts */ - for (evtID = EVT.head; evtID != -1; evtID = EVT.evtq[evtID].next) { - if (EVT.evtq[evtID].what & mask) - break; /* Found an event */ - } - if (evtID == -1) { - _EVT_restoreInt(ps); - return false; /* Event was not found */ - } - *evt = EVT.evtq[evtID]; /* Return the event */ - _EVT_restoreInt(ps); - if (evt->what & EVT_KEYEVT) - _EVT_maskKeyCode(evt); - } + /* It is possible that an event be posted while we are trying + * to access the event queue. This would create problems since + * we may end up with invalid data for our event queue pointers. To + * alleviate this, all interrupts are suspended while we manipulate + * our pointers. + */ + ps = _EVT_disableInt(); /* disable interrupts */ + for (evtID = EVT.head; evtID != -1; evtID = EVT.evtq[evtID].next) { + if (EVT.evtq[evtID].what & mask) + break; /* Found an event */ + } + if (evtID == -1) { + _EVT_restoreInt(ps); + return false; /* Event was not found */ + } + *evt = EVT.evtq[evtID]; /* Return the event */ + _EVT_restoreInt(ps); + if (evt->what & EVT_KEYEVT) + _EVT_maskKeyCode(evt); + } return evt->what != EVT_NULLEVT; } @@ -696,10 +696,10 @@ If an event of the specified type was not in the event queue, the what field of the event will be set to NULLEVT, and the return value will return false. Note: You should /always/ use the EVT_EVERYEVT mask for extracting events - from your main event loop handler. Using a mask for only a specific - type of event for long periods of time will cause the event queue to - fill up with events of the type you are ignoring, eventually causing - the application to hang when the event queue becomes full. + from your main event loop handler. Using a mask for only a specific + type of event for long periods of time will cause the event queue to + fill up with events of the type you are ignoring, eventually causing + the application to hang when the event queue becomes full. SEE ALSO: EVT_flush, EVT_halt, EVT_peekNext @@ -712,68 +712,68 @@ ibool EVTAPI EVT_getNext( uint ps; if (EVT.heartBeat) - EVT.heartBeat(EVT.heartBeatParams); + EVT.heartBeat(EVT.heartBeatParams); _EVT_pumpMessages(); /* Pump all messages into queue */ EVT.mouseMove(EVT.mx,EVT.my); /* Move the mouse cursor */ evt->what = EVT_NULLEVT; /* Default to null event */ if (EVT.count) { - /* It is possible that an event be posted while we are trying - * to access the event queue. This would create problems since - * we may end up with invalid data for our event queue pointers. To - * alleviate this, all interrupts are suspended while we manipulate - * our pointers. - */ - ps = _EVT_disableInt(); /* disable interrupts */ - for (evtID = EVT.head; evtID != -1; evtID = EVT.evtq[evtID].next) { - if (EVT.evtq[evtID].what & mask) - break; /* Found an event */ - } - if (evtID == -1) { - _EVT_restoreInt(ps); - return false; /* Event was not found */ - } - next = EVT.evtq[evtID].next; - prev = EVT.evtq[evtID].prev; - if (prev != -1) - EVT.evtq[prev].next = next; - else - EVT.head = next; - if (next != -1) - EVT.evtq[next].prev = prev; - else - EVT.tail = prev; - *evt = EVT.evtq[evtID]; /* Return the event */ - EVT.evtq[evtID].next = EVT.freeHead; /* and return to free list */ - EVT.freeHead = evtID; - EVT.count--; - if (evt->what == EVT_MOUSEMOVE) - EVT.oldMove = -1; - if (evt->what == EVT_KEYREPEAT) - EVT.oldKey = -1; - if (evt->what == EVT_JOYMOVE) - EVT.oldJoyMove = -1; - _EVT_restoreInt(ps); /* enable interrupts */ - if (evt->what & EVT_KEYEVT) - _EVT_maskKeyCode(evt); - } + /* It is possible that an event be posted while we are trying + * to access the event queue. This would create problems since + * we may end up with invalid data for our event queue pointers. To + * alleviate this, all interrupts are suspended while we manipulate + * our pointers. + */ + ps = _EVT_disableInt(); /* disable interrupts */ + for (evtID = EVT.head; evtID != -1; evtID = EVT.evtq[evtID].next) { + if (EVT.evtq[evtID].what & mask) + break; /* Found an event */ + } + if (evtID == -1) { + _EVT_restoreInt(ps); + return false; /* Event was not found */ + } + next = EVT.evtq[evtID].next; + prev = EVT.evtq[evtID].prev; + if (prev != -1) + EVT.evtq[prev].next = next; + else + EVT.head = next; + if (next != -1) + EVT.evtq[next].prev = prev; + else + EVT.tail = prev; + *evt = EVT.evtq[evtID]; /* Return the event */ + EVT.evtq[evtID].next = EVT.freeHead; /* and return to free list */ + EVT.freeHead = evtID; + EVT.count--; + if (evt->what == EVT_MOUSEMOVE) + EVT.oldMove = -1; + if (evt->what == EVT_KEYREPEAT) + EVT.oldKey = -1; + if (evt->what == EVT_JOYMOVE) + EVT.oldJoyMove = -1; + _EVT_restoreInt(ps); /* enable interrupts */ + if (evt->what & EVT_KEYEVT) + _EVT_maskKeyCode(evt); + } /* If there is no event pending, check if we should generate an auto * mouse down event if the mouse is still currently down. */ if (evt->what == EVT_NULLEVT && EVT.autoRepeat && (mask & EVT_MOUSEAUTO) && (EVT.downMouse.what & EVT_MOUSEDOWN)) { - ulong ticks = _EVT_getTicks(); - if ((ticks - EVT.autoTicks) >= (EVT.autoRepeat + (EVT.firstAuto ? EVT.autoDelay : 0))) { - evt->what = EVT_MOUSEAUTO; - evt->message = EVT.downMouse.message; - evt->modifiers = EVT.downMouse.modifiers; - evt->where_x = EVT.autoMouse_x; - evt->where_y = EVT.autoMouse_y; - evt->relative_x = 0; - evt->relative_y = 0; - EVT.autoTicks = evt->when = ticks; - EVT.firstAuto = false; - } - } + ulong ticks = _EVT_getTicks(); + if ((ticks - EVT.autoTicks) >= (EVT.autoRepeat + (EVT.firstAuto ? EVT.autoDelay : 0))) { + evt->what = EVT_MOUSEAUTO; + evt->message = EVT.downMouse.message; + evt->modifiers = EVT.downMouse.modifiers; + evt->where_x = EVT.autoMouse_x; + evt->where_y = EVT.autoMouse_y; + evt->relative_x = 0; + evt->relative_y = 0; + EVT.autoTicks = evt->when = ticks; + EVT.firstAuto = false; + } + } return evt->what != EVT_NULLEVT; } @@ -802,18 +802,18 @@ callback unless you plan to use the events immediately that they are recieved. Note: Your event callback may be called in response to a hardware - interrupt and will be executing in the context of the hardware - interrupt handler under MSDOS (ie: keyboard interrupt or mouse - interrupt). For this reason the code pages for the callback that - you register must be locked in memory with the PM_lockCodePages - function. You must also lock down any data pages that your function - needs to reference as well. + interrupt and will be executing in the context of the hardware + interrupt handler under MSDOS (ie: keyboard interrupt or mouse + interrupt). For this reason the code pages for the callback that + you register must be locked in memory with the PM_lockCodePages + function. You must also lock down any data pages that your function + needs to reference as well. Note: You can also use this filter callback to process events at the - time they are activated by the user (ie: when the user hits the - key or moves the mouse), but make sure your code runs as fast as - possible as it will be executing inside the context of an interrupt - handler on some systems. + time they are activated by the user (ie: when the user hits the + key or moves the mouse), but make sure your code runs as fast as + possible as it will be executing inside the context of an interrupt + handler on some systems. SEE ALSO: EVT_getNext, EVT_peekNext @@ -1068,10 +1068,10 @@ the scan code is the result, for example: code = EVT_scanCode(EVT.myEvent.message); NOTE: Scan codes in the event library are not really hardware scan codes, - but rather virtual scan codes as generated by a low level keyboard - interface driver. All virtual scan code values are defined by the - EVT_scanCodesType enumeration, and will be identical across all - supports OS'es and platforms. + but rather virtual scan codes as generated by a low level keyboard + interface driver. All virtual scan code values are defined by the + EVT_scanCodesType enumeration, and will be identical across all + supports OS'es and platforms. SEE ALSO: EVT_asciiCode, EVT_repeatCount diff --git a/board/MAI/bios_emulator/scitech/src/pm/linux/event.c b/board/MAI/bios_emulator/scitech/src/pm/linux/event.c index c2668ceb883..ce387320974 100644 --- a/board/MAI/bios_emulator/scitech/src/pm/linux/event.c +++ b/board/MAI/bios_emulator/scitech/src/pm/linux/event.c @@ -89,7 +89,7 @@ mouse_info mouse_infos[] = { {"BusMouse", STD_FLG, NULL, {0xf8, 0x80, 0x00, 0x00}, 3, 3}, {"MouseMan", CS7 | STD_FLG, _EVT_mouse_init, {0x40, 0x40, 0x40, 0x00}, 3, 1}, {"IntelliMouse", CS7 | STD_FLG, _EVT_pnpmouse_init, {0xc0, 0x40, 0xc0, 0x00}, 4, 1}, - {"IMPS2", CS7 | STD_FLG, NULL, {0xc0, 0x40, 0xc0, 0x00}, 4, 1}, // ? + {"IMPS2", CS7 | STD_FLG, NULL, {0xc0, 0x40, 0xc0, 0x00}, 4, 1}, /* ? */ }; #define NB_MICE (sizeof(mouse_infos)/sizeof(mouse_info)) @@ -109,7 +109,7 @@ typedef struct { int map; } keymap; -// TODO: Fix this and set it up so we can do a binary search! +/* TODO: Fix this and set it up so we can do a binary search! */ keymap keymaps[] = { {96, KB_padEnter}, @@ -249,131 +249,131 @@ static ibool readMouseData( /* Read the first byte to check for the protocol */ drv = &mouse_infos[mouse_driver]; if (read(_EVT_mouse_fd, data, drv->read) != drv->read) { - perror("read"); - return false; - } + perror("read"); + return false; + } if ((data[0] & drv->proto[0]) != drv->proto[1]) - return false; + return false; /* Load a whole protocol packet */ cnt += drv->read; while (cnt < drv->packet_len) { - ret = read(_EVT_mouse_fd, data+cnt, drv->read); - if (ret == drv->read) - cnt += ret; - else { - perror("read"); - return false; - } - } + ret = read(_EVT_mouse_fd, data+cnt, drv->read); + if (ret == drv->read) + cnt += ret; + else { + perror("read"); + return false; + } + } if ((data[1] & drv->proto[2]) != drv->proto[3]) - return false; + return false; /* Now decode the protocol packet */ switch (mouse_driver) { - case EVT_microsoft: - if (data[0] == 0x40 && !(prev|data[1]|data[2])) - *buttons = 2; /* Third button on MS compatible mouse */ - else - *buttons= ((data[0] & 0x20) >> 3) | ((data[0] & 0x10) >> 4); - prev = *buttons; - *dx = (char)(((data[0] & 0x03) << 6) | (data[1] & 0x3F)); - *dy = (char)(((data[0] & 0x0C) << 4) | (data[2] & 0x3F)); - break; - case EVT_ps2: - *buttons = !!(data[0]&1) * 4 + !!(data[0]&2) * 1 + !!(data[0]&4) * 2; - if (data[1] != 0) - *dx = (data[0] & 0x10) ? data[1]-256 : data[1]; - else - *dx = 0; - if (data[2] != 0) - *dy = -((data[0] & 0x20) ? data[2]-256 : data[2]); - else - *dy = 0; - break; - case EVT_mousesystems: case EVT_gpm: - *buttons = (~data[0]) & 0x07; - *dx = (char)(data[1]) + (char)(data[3]); - *dy = -((char)(data[2]) + (char)(data[4])); - break; - case EVT_logitech: - *buttons= data[0] & 0x07; - *dx = (data[0] & 0x10) ? data[1] : - data[1]; - *dy = (data[0] & 0x08) ? - data[2] : data[2]; - break; - case EVT_busmouse: - *buttons= (~data[0]) & 0x07; - *dx = (char)data[1]; - *dy = -(char)data[2]; - break; - case EVT_MMseries: - *buttons = data[0] & 0x07; - *dx = (data[0] & 0x10) ? data[1] : - data[1]; - *dy = (data[0] & 0x08) ? - data[2] : data[2]; - break; - case EVT_intellimouse: - *buttons = ((data[0] & 0x20) >> 3) /* left */ - | ((data[3] & 0x10) >> 3) /* middle */ - | ((data[0] & 0x10) >> 4); /* right */ - *dx = (char)(((data[0] & 0x03) << 6) | (data[1] & 0x3F)); - *dy = (char)(((data[0] & 0x0C) << 4) | (data[2] & 0x3F)); - break; - case EVT_intellimouse_ps2: - *buttons = (data[0] & 0x04) >> 1 /* Middle */ - | (data[0] & 0x02) >> 1 /* Right */ - | (data[0] & 0x01) << 2; /* Left */ - *dx = (data[0] & 0x10) ? data[1]-256 : data[1]; - *dy = (data[0] & 0x20) ? -(data[2]-256) : -data[2]; - break; - case EVT_mouseman: { - static int getextra; - static uchar prev=0; - uchar b; - - /* The damned MouseMan has 3/4 bytes packets. The extra byte - * is only there if the middle button is active. - * I get the extra byte as a packet with magic numbers in it. - * and then switch to 4-byte mode. - */ - if (data[1] == 0xAA && data[2] == 0x55) { - /* Got unexpected fourth byte */ - if ((b = (*data>>4)) > 0x3) - return false; /* just a sanity check */ - *dx = *dy = 0; - drv->packet_len=4; - getextra=0; - } - else { - /* Got 3/4, as expected */ - /* Motion is independent of packetlen... */ - *dx = (char)(((data[0] & 0x03) << 6) | (data[1] & 0x3F)); - *dy = (char)(((data[0] & 0x0C) << 4) | (data[2] & 0x3F)); - prev = ((data[0] & 0x20) >> 3) | ((data[0] & 0x10) >> 4); - if (drv->packet_len==4) - b = data[3]>>4; - } - if (drv->packet_len == 4) { - if (b == 0) { - drv->packet_len = 3; - getextra = 1; - } - else { - if (b & 0x2) - prev |= 2; - } - } - *buttons = prev; - - /* This "chord-middle" behaviour was reported by David A. van Leeuwen */ - if (((prev ^ *buttons) & 5) == 5) - *buttons = *buttons ? 2 : 0; - prev = *buttons; - break; - } - case EVT_noMouse: - return false; - break; - } + case EVT_microsoft: + if (data[0] == 0x40 && !(prev|data[1]|data[2])) + *buttons = 2; /* Third button on MS compatible mouse */ + else + *buttons= ((data[0] & 0x20) >> 3) | ((data[0] & 0x10) >> 4); + prev = *buttons; + *dx = (char)(((data[0] & 0x03) << 6) | (data[1] & 0x3F)); + *dy = (char)(((data[0] & 0x0C) << 4) | (data[2] & 0x3F)); + break; + case EVT_ps2: + *buttons = !!(data[0]&1) * 4 + !!(data[0]&2) * 1 + !!(data[0]&4) * 2; + if (data[1] != 0) + *dx = (data[0] & 0x10) ? data[1]-256 : data[1]; + else + *dx = 0; + if (data[2] != 0) + *dy = -((data[0] & 0x20) ? data[2]-256 : data[2]); + else + *dy = 0; + break; + case EVT_mousesystems: case EVT_gpm: + *buttons = (~data[0]) & 0x07; + *dx = (char)(data[1]) + (char)(data[3]); + *dy = -((char)(data[2]) + (char)(data[4])); + break; + case EVT_logitech: + *buttons= data[0] & 0x07; + *dx = (data[0] & 0x10) ? data[1] : - data[1]; + *dy = (data[0] & 0x08) ? - data[2] : data[2]; + break; + case EVT_busmouse: + *buttons= (~data[0]) & 0x07; + *dx = (char)data[1]; + *dy = -(char)data[2]; + break; + case EVT_MMseries: + *buttons = data[0] & 0x07; + *dx = (data[0] & 0x10) ? data[1] : - data[1]; + *dy = (data[0] & 0x08) ? - data[2] : data[2]; + break; + case EVT_intellimouse: + *buttons = ((data[0] & 0x20) >> 3) /* left */ + | ((data[3] & 0x10) >> 3) /* middle */ + | ((data[0] & 0x10) >> 4); /* right */ + *dx = (char)(((data[0] & 0x03) << 6) | (data[1] & 0x3F)); + *dy = (char)(((data[0] & 0x0C) << 4) | (data[2] & 0x3F)); + break; + case EVT_intellimouse_ps2: + *buttons = (data[0] & 0x04) >> 1 /* Middle */ + | (data[0] & 0x02) >> 1 /* Right */ + | (data[0] & 0x01) << 2; /* Left */ + *dx = (data[0] & 0x10) ? data[1]-256 : data[1]; + *dy = (data[0] & 0x20) ? -(data[2]-256) : -data[2]; + break; + case EVT_mouseman: { + static int getextra; + static uchar prev=0; + uchar b; + + /* The damned MouseMan has 3/4 bytes packets. The extra byte + * is only there if the middle button is active. + * I get the extra byte as a packet with magic numbers in it. + * and then switch to 4-byte mode. + */ + if (data[1] == 0xAA && data[2] == 0x55) { + /* Got unexpected fourth byte */ + if ((b = (*data>>4)) > 0x3) + return false; /* just a sanity check */ + *dx = *dy = 0; + drv->packet_len=4; + getextra=0; + } + else { + /* Got 3/4, as expected */ + /* Motion is independent of packetlen... */ + *dx = (char)(((data[0] & 0x03) << 6) | (data[1] & 0x3F)); + *dy = (char)(((data[0] & 0x0C) << 4) | (data[2] & 0x3F)); + prev = ((data[0] & 0x20) >> 3) | ((data[0] & 0x10) >> 4); + if (drv->packet_len==4) + b = data[3]>>4; + } + if (drv->packet_len == 4) { + if (b == 0) { + drv->packet_len = 3; + getextra = 1; + } + else { + if (b & 0x2) + prev |= 2; + } + } + *buttons = prev; + + /* This "chord-middle" behaviour was reported by David A. van Leeuwen */ + if (((prev ^ *buttons) & 5) == 5) + *buttons = *buttons ? 2 : 0; + prev = *buttons; + break; + } + case EVT_noMouse: + return false; + break; + } return true; } @@ -389,9 +389,9 @@ static int getKeyMapping( int i; for(i = 0; i < nb; i++) { - if (tab[i].scan == key) - return tab[i].map; - } + if (tab[i].scan == key) + return tab[i].map; + } return key; } @@ -411,21 +411,21 @@ static void makeJoyEvent( { evt->message = 0; if (buts0 && axis0) { - if (buts0[0]) evt->message |= EVT_JOY1_BUTTONA; - if (buts0[1]) evt->message |= EVT_JOY1_BUTTONB; - evt->where_x = axis0[0]; - evt->where_y = axis0[1]; - } + if (buts0[0]) evt->message |= EVT_JOY1_BUTTONA; + if (buts0[1]) evt->message |= EVT_JOY1_BUTTONB; + evt->where_x = axis0[0]; + evt->where_y = axis0[1]; + } else - evt->where_x = evt->where_y = 0; + evt->where_x = evt->where_y = 0; if (buts1 && axis1) { - if (buts1[0]) evt->message |= EVT_JOY2_BUTTONA; - if (buts1[1]) evt->message |= EVT_JOY2_BUTTONB; - evt->where_x = axis1[0]; - evt->where_y = axis1[1]; - } + if (buts1[0]) evt->message |= EVT_JOY2_BUTTONA; + if (buts1[1]) evt->message |= EVT_JOY2_BUTTONB; + evt->where_x = axis1[0]; + evt->where_y = axis1[1]; + } else - evt->where_x = evt->where_y = 0; + evt->where_x = evt->where_y = 0; } /**************************************************************************** @@ -439,39 +439,39 @@ int EVTAPI _EVT_readJoyAxis( int mask = 0; if ((js_version & ~0xffff) == 0) { - /* Old 0.x driver */ - struct JS_DATA_TYPE js; - if (joystick0_fd && read(joystick0_fd, &js, JS_RETURN) == JS_RETURN) { - if (jmask & EVT_JOY_AXIS_X1) - axis[0] = js.x; - if (jmask & EVT_JOY_AXIS_Y1) - axis[1] = js.y; - mask |= EVT_JOY_AXIS_X1|EVT_JOY_AXIS_Y1; - } - if (joystick1_fd && read(joystick1_fd, &js, JS_RETURN) == JS_RETURN) { - if (jmask & EVT_JOY_AXIS_X2) - axis[2] = js.x; - if (jmask & EVT_JOY_AXIS_Y2) - axis[3] = js.y; - mask |= EVT_JOY_AXIS_X2|EVT_JOY_AXIS_Y2; - } - } + /* Old 0.x driver */ + struct JS_DATA_TYPE js; + if (joystick0_fd && read(joystick0_fd, &js, JS_RETURN) == JS_RETURN) { + if (jmask & EVT_JOY_AXIS_X1) + axis[0] = js.x; + if (jmask & EVT_JOY_AXIS_Y1) + axis[1] = js.y; + mask |= EVT_JOY_AXIS_X1|EVT_JOY_AXIS_Y1; + } + if (joystick1_fd && read(joystick1_fd, &js, JS_RETURN) == JS_RETURN) { + if (jmask & EVT_JOY_AXIS_X2) + axis[2] = js.x; + if (jmask & EVT_JOY_AXIS_Y2) + axis[3] = js.y; + mask |= EVT_JOY_AXIS_X2|EVT_JOY_AXIS_Y2; + } + } else { - if (axis0) { - if (jmask & EVT_JOY_AXIS_X1) - axis[0] = axis0[0]; - if (jmask & EVT_JOY_AXIS_Y1) - axis[1] = axis0[1]; - mask |= EVT_JOY_AXIS_X1 | EVT_JOY_AXIS_Y1; - } - if (axis1) { - if (jmask & EVT_JOY_AXIS_X2) - axis[2] = axis1[0]; - if (jmask & EVT_JOY_AXIS_Y2) - axis[3] = axis1[1]; - mask |= EVT_JOY_AXIS_X2 | EVT_JOY_AXIS_Y2; - } - } + if (axis0) { + if (jmask & EVT_JOY_AXIS_X1) + axis[0] = axis0[0]; + if (jmask & EVT_JOY_AXIS_Y1) + axis[1] = axis0[1]; + mask |= EVT_JOY_AXIS_X1 | EVT_JOY_AXIS_Y1; + } + if (axis1) { + if (jmask & EVT_JOY_AXIS_X2) + axis[2] = axis1[0]; + if (jmask & EVT_JOY_AXIS_Y2) + axis[3] = axis1[1]; + mask |= EVT_JOY_AXIS_X2 | EVT_JOY_AXIS_Y2; + } + } return mask; } @@ -484,19 +484,19 @@ int EVTAPI _EVT_readJoyButtons(void) int buts = 0; if ((js_version & ~0xffff) == 0) { - /* Old 0.x driver */ - struct JS_DATA_TYPE js; - if (joystick0_fd && read(joystick0_fd, &js, JS_RETURN) == JS_RETURN) - buts = js.buttons; - if (joystick1_fd && read(joystick1_fd, &js, JS_RETURN) == JS_RETURN) - buts |= js.buttons << 2; - } + /* Old 0.x driver */ + struct JS_DATA_TYPE js; + if (joystick0_fd && read(joystick0_fd, &js, JS_RETURN) == JS_RETURN) + buts = js.buttons; + if (joystick1_fd && read(joystick1_fd, &js, JS_RETURN) == JS_RETURN) + buts |= js.buttons << 2; + } else { - if (buts0) - buts |= EVT_JOY1_BUTTONA*buts0[0] + EVT_JOY1_BUTTONB*buts0[1]; - if (buts1) - buts |= EVT_JOY2_BUTTONA*buts1[0] + EVT_JOY2_BUTTONB*buts1[1]; - } + if (buts0) + buts |= EVT_JOY1_BUTTONA*buts0[0] + EVT_JOY1_BUTTONB*buts0[1]; + if (buts1) + buts |= EVT_JOY2_BUTTONA*buts1[0] + EVT_JOY2_BUTTONB*buts1[1]; + } return buts; } @@ -525,97 +525,97 @@ int EVTAPI EVT_joyIsPresent(void) static ibool inited = false; if (inited) - return mask; + return mask; memset(EVT.joyMin,0,sizeof(EVT.joyMin)); memset(EVT.joyCenter,0,sizeof(EVT.joyCenter)); memset(EVT.joyMax,0,sizeof(EVT.joyMax)); memset(EVT.joyPrev,0,sizeof(EVT.joyPrev)); EVT.joyButState = 0; if ((tmp = getenv(ENV_JOYDEV0)) != NULL) - strcpy(joystick0_dev,tmp); + strcpy(joystick0_dev,tmp); if ((tmp = getenv(ENV_JOYDEV1)) != NULL) - strcpy(joystick1_dev,tmp); + strcpy(joystick1_dev,tmp); if ((joystick0_fd = open(joystick0_dev, O_RDONLY)) < 0) - joystick0_fd = 0; + joystick0_fd = 0; if ((joystick1_fd = open(joystick1_dev, O_RDONLY)) < 0) - joystick1_fd = 0; - if (!joystick0_fd && !joystick1_fd) // No joysticks detected - return 0; + joystick1_fd = 0; + if (!joystick0_fd && !joystick1_fd) /* No joysticks detected */ + return 0; inited = true; if (ioctl(joystick0_fd ? joystick0_fd : joystick1_fd, JSIOCGVERSION, &js_version) < 0) - return 0; + return 0; /* Initialise joystick 0 */ if (joystick0_fd) { - ioctl(joystick0_fd, JSIOCGNAME(sizeof(name0)), name0); - if (js_version & ~0xffff) { - struct js_event js; - - ioctl(joystick0_fd, JSIOCGAXES, &js0_axes); - ioctl(joystick0_fd, JSIOCGBUTTONS, &js0_buttons); - axis0 = PM_calloc((int)js0_axes, sizeof(short)); - buts0 = PM_malloc((int)js0_buttons); - /* Read the initial events */ - while(dataReady(joystick0_fd) - && read(joystick0_fd, &js, sizeof(struct js_event)) == sizeof(struct js_event) - && (js.type & JS_EVENT_INIT) - ) { - if (js.type & JS_EVENT_BUTTON) - buts0[js.number] = js.value; - else if (js.type & JS_EVENT_AXIS) - axis0[js.number] = scaleJoyAxis(js.value,js.number); - } - } - else { - js0_axes = 2; - js0_buttons = 2; - axis0 = PM_calloc((int)js0_axes, sizeof(short)); - buts0 = PM_malloc((int)js0_buttons); - } - } + ioctl(joystick0_fd, JSIOCGNAME(sizeof(name0)), name0); + if (js_version & ~0xffff) { + struct js_event js; + + ioctl(joystick0_fd, JSIOCGAXES, &js0_axes); + ioctl(joystick0_fd, JSIOCGBUTTONS, &js0_buttons); + axis0 = PM_calloc((int)js0_axes, sizeof(short)); + buts0 = PM_malloc((int)js0_buttons); + /* Read the initial events */ + while(dataReady(joystick0_fd) + && read(joystick0_fd, &js, sizeof(struct js_event)) == sizeof(struct js_event) + && (js.type & JS_EVENT_INIT) + ) { + if (js.type & JS_EVENT_BUTTON) + buts0[js.number] = js.value; + else if (js.type & JS_EVENT_AXIS) + axis0[js.number] = scaleJoyAxis(js.value,js.number); + } + } + else { + js0_axes = 2; + js0_buttons = 2; + axis0 = PM_calloc((int)js0_axes, sizeof(short)); + buts0 = PM_malloc((int)js0_buttons); + } + } /* Initialise joystick 1 */ if (joystick1_fd) { - ioctl(joystick1_fd, JSIOCGNAME(sizeof(name1)), name1); - if (js_version & ~0xffff) { - struct js_event js; - - ioctl(joystick1_fd, JSIOCGAXES, &js1_axes); - ioctl(joystick1_fd, JSIOCGBUTTONS, &js1_buttons); - axis1 = PM_calloc((int)js1_axes, sizeof(short)); - buts1 = PM_malloc((int)js1_buttons); - /* Read the initial events */ - while(dataReady(joystick1_fd) - && read(joystick1_fd, &js, sizeof(struct js_event))==sizeof(struct js_event) - && (js.type & JS_EVENT_INIT) - ) { - if (js.type & JS_EVENT_BUTTON) - buts1[js.number] = js.value; - else if (js.type & JS_EVENT_AXIS) - axis1[js.number] = scaleJoyAxis(js.value,js.number<<2); - } - } - else { - js1_axes = 2; - js1_buttons = 2; - axis1 = PM_calloc((int)js1_axes, sizeof(short)); - buts1 = PM_malloc((int)js1_buttons); - } - } + ioctl(joystick1_fd, JSIOCGNAME(sizeof(name1)), name1); + if (js_version & ~0xffff) { + struct js_event js; + + ioctl(joystick1_fd, JSIOCGAXES, &js1_axes); + ioctl(joystick1_fd, JSIOCGBUTTONS, &js1_buttons); + axis1 = PM_calloc((int)js1_axes, sizeof(short)); + buts1 = PM_malloc((int)js1_buttons); + /* Read the initial events */ + while(dataReady(joystick1_fd) + && read(joystick1_fd, &js, sizeof(struct js_event))==sizeof(struct js_event) + && (js.type & JS_EVENT_INIT) + ) { + if (js.type & JS_EVENT_BUTTON) + buts1[js.number] = js.value; + else if (js.type & JS_EVENT_AXIS) + axis1[js.number] = scaleJoyAxis(js.value,js.number<<2); + } + } + else { + js1_axes = 2; + js1_buttons = 2; + axis1 = PM_calloc((int)js1_axes, sizeof(short)); + buts1 = PM_malloc((int)js1_buttons); + } + } #ifdef CHECKED - fprintf(stderr,"Using joystick driver version %d.%d.%d\n", - js_version >> 16, (js_version >> 8) & 0xff, js_version & 0xff); + fprintf(stderr,"Using joystick driver version %d.%d.%d\n", + js_version >> 16, (js_version >> 8) & 0xff, js_version & 0xff); if (joystick0_fd) - fprintf(stderr,"Joystick 1 (%s): %s\n", joystick0_dev, name0); + fprintf(stderr,"Joystick 1 (%s): %s\n", joystick0_dev, name0); if (joystick1_fd) - fprintf(stderr,"Joystick 2 (%s): %s\n", joystick1_dev, name1); + fprintf(stderr,"Joystick 2 (%s): %s\n", joystick1_dev, name1); #endif mask = _EVT_readJoyAxis(EVT_JOY_AXIS_ALL,EVT.joyCenter); if (mask) { - for (i = 0; i < JOY_NUM_AXES; i++) - EVT.joyMax[i] = EVT.joyCenter[i]*2; - } + for (i = 0; i < JOY_NUM_AXES; i++) + EVT.joyMax[i] = EVT.joyCenter[i]*2; + } return mask; } @@ -634,9 +634,9 @@ All information polled from the joystick will be posted to the event queue for later retrieval. Note: Most analogue joysticks will provide readings that change even - though the joystick has not moved. Hence if you call this routine - you will likely get an EVT_JOYMOVE event every time through your - event loop. + though the joystick has not moved. Hence if you call this routine + you will likely get an EVT_JOYMOVE event every time through your + event loop. SEE ALSO: EVT_getNext, EVT_peekNext, EVT_joySetUpperLeft, EVT_joySetLowerRight, @@ -648,68 +648,68 @@ void EVTAPI EVT_pollJoystick(void) int i,axis[JOY_NUM_AXES],newButState,mask,moved,ps; if ((js_version & ~0xFFFF) == 0 && EVT.joyMask) { - /* Read joystick axes and post movement events if they have - * changed since the last time we polled. Until the events are - * actually flushed, we keep modifying the same joystick movement - * event, so you won't get multiple movement event - */ - mask = _EVT_readJoyAxis(EVT.joyMask,axis); - newButState = _EVT_readJoyButtons(); - moved = false; - for (i = 0; i < JOY_NUM_AXES; i++) { - if (mask & (EVT_JOY_AXIS_X1 << i)) - axis[i] = scaleJoyAxis(axis[i],i); - else - axis[i] = EVT.joyPrev[i]; - if (axis[i] != EVT.joyPrev[i]) - moved = true; - } - if (moved) { - memcpy(EVT.joyPrev,axis,sizeof(EVT.joyPrev)); - ps = _EVT_disableInt(); - if (EVT.oldJoyMove != -1) { - /* Modify the existing joystick movement event */ - EVT.evtq[EVT.oldJoyMove].message = newButState; - EVT.evtq[EVT.oldJoyMove].where_x = EVT.joyPrev[0]; - EVT.evtq[EVT.oldJoyMove].where_y = EVT.joyPrev[1]; - EVT.evtq[EVT.oldJoyMove].relative_x = EVT.joyPrev[2]; - EVT.evtq[EVT.oldJoyMove].relative_y = EVT.joyPrev[3]; - } - else if (EVT.count < EVENTQSIZE) { - /* Add a new joystick movement event */ - EVT.oldJoyMove = EVT.freeHead; - memset(&evt,0,sizeof(evt)); - evt.what = EVT_JOYMOVE; - evt.message = EVT.joyButState; - evt.where_x = EVT.joyPrev[0]; - evt.where_y = EVT.joyPrev[1]; - evt.relative_x = EVT.joyPrev[2]; - evt.relative_y = EVT.joyPrev[3]; - addEvent(&evt); - } - _EVT_restoreInt(ps); - } - - /* Read the joystick buttons, and post events to reflect the change - * in state for the joystick buttons. - */ - if (newButState != EVT.joyButState) { - if (EVT.count < EVENTQSIZE) { - /* Add a new joystick movement event */ - ps = _EVT_disableInt(); - memset(&evt,0,sizeof(evt)); - evt.what = EVT_JOYCLICK; - evt.message = newButState; - EVT.evtq[EVT.oldJoyMove].where_x = EVT.joyPrev[0]; - EVT.evtq[EVT.oldJoyMove].where_y = EVT.joyPrev[1]; - EVT.evtq[EVT.oldJoyMove].relative_x = EVT.joyPrev[2]; - EVT.evtq[EVT.oldJoyMove].relative_y = EVT.joyPrev[3]; - addEvent(&evt); - _EVT_restoreInt(ps); - } - EVT.joyButState = newButState; - } - } + /* Read joystick axes and post movement events if they have + * changed since the last time we polled. Until the events are + * actually flushed, we keep modifying the same joystick movement + * event, so you won't get multiple movement event + */ + mask = _EVT_readJoyAxis(EVT.joyMask,axis); + newButState = _EVT_readJoyButtons(); + moved = false; + for (i = 0; i < JOY_NUM_AXES; i++) { + if (mask & (EVT_JOY_AXIS_X1 << i)) + axis[i] = scaleJoyAxis(axis[i],i); + else + axis[i] = EVT.joyPrev[i]; + if (axis[i] != EVT.joyPrev[i]) + moved = true; + } + if (moved) { + memcpy(EVT.joyPrev,axis,sizeof(EVT.joyPrev)); + ps = _EVT_disableInt(); + if (EVT.oldJoyMove != -1) { + /* Modify the existing joystick movement event */ + EVT.evtq[EVT.oldJoyMove].message = newButState; + EVT.evtq[EVT.oldJoyMove].where_x = EVT.joyPrev[0]; + EVT.evtq[EVT.oldJoyMove].where_y = EVT.joyPrev[1]; + EVT.evtq[EVT.oldJoyMove].relative_x = EVT.joyPrev[2]; + EVT.evtq[EVT.oldJoyMove].relative_y = EVT.joyPrev[3]; + } + else if (EVT.count < EVENTQSIZE) { + /* Add a new joystick movement event */ + EVT.oldJoyMove = EVT.freeHead; + memset(&evt,0,sizeof(evt)); + evt.what = EVT_JOYMOVE; + evt.message = EVT.joyButState; + evt.where_x = EVT.joyPrev[0]; + evt.where_y = EVT.joyPrev[1]; + evt.relative_x = EVT.joyPrev[2]; + evt.relative_y = EVT.joyPrev[3]; + addEvent(&evt); + } + _EVT_restoreInt(ps); + } + + /* Read the joystick buttons, and post events to reflect the change + * in state for the joystick buttons. + */ + if (newButState != EVT.joyButState) { + if (EVT.count < EVENTQSIZE) { + /* Add a new joystick movement event */ + ps = _EVT_disableInt(); + memset(&evt,0,sizeof(evt)); + evt.what = EVT_JOYCLICK; + evt.message = newButState; + EVT.evtq[EVT.oldJoyMove].where_x = EVT.joyPrev[0]; + EVT.evtq[EVT.oldJoyMove].where_y = EVT.joyPrev[1]; + EVT.evtq[EVT.oldJoyMove].relative_x = EVT.joyPrev[2]; + EVT.evtq[EVT.oldJoyMove].relative_y = EVT.joyPrev[3]; + addEvent(&evt); + _EVT_restoreInt(ps); + } + EVT.joyButState = newButState; + } + } } /**************************************************************************** @@ -815,287 +815,287 @@ static void _EVT_pumpMessages(void) /* Poll keyboard events */ while (dataReady(_PM_console_fd) && (numkeys = read(_PM_console_fd, buf, KBDREADBUFFERSIZE)) > 0) { - for (i = 0; i < numkeys; i++) { - c = buf[i]; - release = c & 0x80; - c &= 0x7F; - - // TODO: This is wrong! We need this to be the time stamp at - // ** interrupt ** time!! One solution would be to - // put the keyboard and mouse polling loops into - // a separate thread that can block on I/O to the - // necessay file descriptor. - evt.when = _EVT_getTicks(); - - if (release) { - /* Key released */ - evt.what = EVT_KEYUP; - switch (c) { - case KB_leftShift: - _PM_modifiers &= ~EVT_LEFTSHIFT; - break; - case KB_rightShift: - _PM_modifiers &= ~EVT_RIGHTSHIFT; - break; - case 29: - _PM_modifiers &= ~(EVT_LEFTCTRL|EVT_CTRLSTATE); - break; - case 97: /* Control */ - _PM_modifiers &= ~EVT_CTRLSTATE; - break; - case 56: - _PM_modifiers &= ~(EVT_LEFTALT|EVT_ALTSTATE); - break; - case 100: - _PM_modifiers &= ~EVT_ALTSTATE; - break; - default: - } - evt.modifiers = _PM_modifiers; - evt.message = keyUpMsg[c]; - if (EVT.count < EVENTQSIZE) - addEvent(&evt); - keyUpMsg[c] = 0; - repeatKey[c] = 0; - } - else { - /* Key pressed */ - evt.what = EVT_KEYDOWN; - switch (c) { - case KB_leftShift: - _PM_modifiers |= EVT_LEFTSHIFT; - break; - case KB_rightShift: - _PM_modifiers |= EVT_RIGHTSHIFT; - break; - case 29: - _PM_modifiers |= EVT_LEFTCTRL|EVT_CTRLSTATE; - break; - case 97: /* Control */ - _PM_modifiers |= EVT_CTRLSTATE; - break; - case 56: - _PM_modifiers |= EVT_LEFTALT|EVT_ALTSTATE; - break; - case 100: - _PM_modifiers |= EVT_ALTSTATE; - break; - case KB_capsLock: /* Caps Lock */ - _PM_leds ^= LED_CAP; - ioctl(_PM_console_fd, KDSETLED, _PM_leds); - break; - case KB_numLock: /* Num Lock */ - _PM_leds ^= LED_NUM; - ioctl(_PM_console_fd, KDSETLED, _PM_leds); - break; - case KB_scrollLock: /* Scroll Lock */ - _PM_leds ^= LED_SCR; - ioctl(_PM_console_fd, KDSETLED, _PM_leds); - break; - default: - } - evt.modifiers = _PM_modifiers; - if (keyUpMsg[c]) { - evt.what = EVT_KEYREPEAT; - evt.message = keyUpMsg[c] | (repeatKey[c]++ << 16); - } - else { - int asc; - - evt.message = getKeyMapping(keymaps, NB_KEYMAPS, c) << 8; - ke.kb_index = c; - ke.kb_table = 0; - if ((_PM_modifiers & EVT_SHIFTKEY) || (_PM_leds & LED_CAP)) - ke.kb_table |= K_SHIFTTAB; - if (_PM_modifiers & (EVT_LEFTALT | EVT_ALTSTATE)) - ke.kb_table |= K_ALTTAB; - if (ioctl(_PM_console_fd, KDGKBENT, (unsigned long)&ke)<0) - perror("ioctl(KDGKBENT)"); - if ((_PM_leds & LED_NUM) && (getKeyMapping(keypad, NB_KEYPAD, c)!=c)) { - asc = getKeyMapping(keypad, NB_KEYPAD, c); - } - else { - switch (c) { - case 14: - asc = ASCII_backspace; - break; - case 15: - asc = ASCII_tab; - break; - case 28: - case 96: - asc = ASCII_enter; - break; - case 1: - asc = ASCII_esc; - default: - asc = ke.kb_value & 0xFF; - if (asc < 0x1B) - asc = 0; - break; - } - } - if ((_PM_modifiers & (EVT_CTRLSTATE|EVT_LEFTCTRL)) && isalpha(asc)) - evt.message |= toupper(asc) - 'A' + 1; - else - evt.message |= asc; - keyUpMsg[c] = evt.message; - repeatKey[c]++; - } - if (EVT.count < EVENTQSIZE) - addEvent(&evt); - } - } - } + for (i = 0; i < numkeys; i++) { + c = buf[i]; + release = c & 0x80; + c &= 0x7F; + + /* TODO: This is wrong! We need this to be the time stamp at */ + /* ** interrupt ** time!! One solution would be to */ + /* put the keyboard and mouse polling loops into */ + /* a separate thread that can block on I/O to the */ + /* necessay file descriptor. */ + evt.when = _EVT_getTicks(); + + if (release) { + /* Key released */ + evt.what = EVT_KEYUP; + switch (c) { + case KB_leftShift: + _PM_modifiers &= ~EVT_LEFTSHIFT; + break; + case KB_rightShift: + _PM_modifiers &= ~EVT_RIGHTSHIFT; + break; + case 29: + _PM_modifiers &= ~(EVT_LEFTCTRL|EVT_CTRLSTATE); + break; + case 97: /* Control */ + _PM_modifiers &= ~EVT_CTRLSTATE; + break; + case 56: + _PM_modifiers &= ~(EVT_LEFTALT|EVT_ALTSTATE); + break; + case 100: + _PM_modifiers &= ~EVT_ALTSTATE; + break; + default: + } + evt.modifiers = _PM_modifiers; + evt.message = keyUpMsg[c]; + if (EVT.count < EVENTQSIZE) + addEvent(&evt); + keyUpMsg[c] = 0; + repeatKey[c] = 0; + } + else { + /* Key pressed */ + evt.what = EVT_KEYDOWN; + switch (c) { + case KB_leftShift: + _PM_modifiers |= EVT_LEFTSHIFT; + break; + case KB_rightShift: + _PM_modifiers |= EVT_RIGHTSHIFT; + break; + case 29: + _PM_modifiers |= EVT_LEFTCTRL|EVT_CTRLSTATE; + break; + case 97: /* Control */ + _PM_modifiers |= EVT_CTRLSTATE; + break; + case 56: + _PM_modifiers |= EVT_LEFTALT|EVT_ALTSTATE; + break; + case 100: + _PM_modifiers |= EVT_ALTSTATE; + break; + case KB_capsLock: /* Caps Lock */ + _PM_leds ^= LED_CAP; + ioctl(_PM_console_fd, KDSETLED, _PM_leds); + break; + case KB_numLock: /* Num Lock */ + _PM_leds ^= LED_NUM; + ioctl(_PM_console_fd, KDSETLED, _PM_leds); + break; + case KB_scrollLock: /* Scroll Lock */ + _PM_leds ^= LED_SCR; + ioctl(_PM_console_fd, KDSETLED, _PM_leds); + break; + default: + } + evt.modifiers = _PM_modifiers; + if (keyUpMsg[c]) { + evt.what = EVT_KEYREPEAT; + evt.message = keyUpMsg[c] | (repeatKey[c]++ << 16); + } + else { + int asc; + + evt.message = getKeyMapping(keymaps, NB_KEYMAPS, c) << 8; + ke.kb_index = c; + ke.kb_table = 0; + if ((_PM_modifiers & EVT_SHIFTKEY) || (_PM_leds & LED_CAP)) + ke.kb_table |= K_SHIFTTAB; + if (_PM_modifiers & (EVT_LEFTALT | EVT_ALTSTATE)) + ke.kb_table |= K_ALTTAB; + if (ioctl(_PM_console_fd, KDGKBENT, (unsigned long)&ke)<0) + perror("ioctl(KDGKBENT)"); + if ((_PM_leds & LED_NUM) && (getKeyMapping(keypad, NB_KEYPAD, c)!=c)) { + asc = getKeyMapping(keypad, NB_KEYPAD, c); + } + else { + switch (c) { + case 14: + asc = ASCII_backspace; + break; + case 15: + asc = ASCII_tab; + break; + case 28: + case 96: + asc = ASCII_enter; + break; + case 1: + asc = ASCII_esc; + default: + asc = ke.kb_value & 0xFF; + if (asc < 0x1B) + asc = 0; + break; + } + } + if ((_PM_modifiers & (EVT_CTRLSTATE|EVT_LEFTCTRL)) && isalpha(asc)) + evt.message |= toupper(asc) - 'A' + 1; + else + evt.message |= asc; + keyUpMsg[c] = evt.message; + repeatKey[c]++; + } + if (EVT.count < EVENTQSIZE) + addEvent(&evt); + } + } + } /* Poll mouse events */ if (_EVT_mouse_fd) { - int dx, dy, buts; - static int oldbuts; - - while (dataReady(_EVT_mouse_fd)) { - if (readMouseData(&buts, &dx, &dy)) { - EVT.mx += dx; - EVT.my += dy; - if (EVT.mx < 0) EVT.mx = 0; - if (EVT.my < 0) EVT.my = 0; - if (EVT.mx > range_x) EVT.mx = range_x; - if (EVT.my > range_y) EVT.my = range_y; - evt.where_x = EVT.mx; - evt.where_y = EVT.my; - evt.relative_x = dx; - evt.relative_y = dy; - - // TODO: This is wrong! We need this to be the time stamp at - // ** interrupt ** time!! One solution would be to - // put the keyboard and mouse polling loops into - // a separate thread that can block on I/O to the - // necessay file descriptor. - evt.when = _EVT_getTicks(); - evt.modifiers = _PM_modifiers; - if (buts & 4) - evt.modifiers |= EVT_LEFTBUT; - if (buts & 1) - evt.modifiers |= EVT_RIGHTBUT; - if (buts & 2) - evt.modifiers |= EVT_MIDDLEBUT; - - /* Left click events */ - if ((buts&4) != (oldbuts&4)) { - if (buts&4) - evt.what = EVT_MOUSEDOWN; - else - evt.what = EVT_MOUSEUP; - evt.message = EVT_LEFTBMASK; - EVT.oldMove = -1; - if (EVT.count < EVENTQSIZE) - addEvent(&evt); - } - - /* Right click events */ - if ((buts&1) != (oldbuts&1)) { - if (buts&1) - evt.what = EVT_MOUSEDOWN; - else - evt.what = EVT_MOUSEUP; - evt.message = EVT_RIGHTBMASK; - EVT.oldMove = -1; - if (EVT.count < EVENTQSIZE) - addEvent(&evt); - } - - /* Middle click events */ - if ((buts&2) != (oldbuts&2)) { - if (buts&2) - evt.what = EVT_MOUSEDOWN; - else - evt.what = EVT_MOUSEUP; - evt.message = EVT_MIDDLEBMASK; - EVT.oldMove = -1; - if (EVT.count < EVENTQSIZE) - addEvent(&evt); - } - - /* Mouse movement event */ - if (dx || dy) { - evt.what = EVT_MOUSEMOVE; - evt.message = 0; - if (EVT.oldMove != -1) { - /* Modify existing movement event */ - EVT.evtq[EVT.oldMove].where_x = evt.where_x; - EVT.evtq[EVT.oldMove].where_y = evt.where_y; - } - else { - /* Save id of this movement event */ - EVT.oldMove = EVT.freeHead; - if (EVT.count < EVENTQSIZE) - addEvent(&evt); - } - } - oldbuts = buts; - } - } - } + int dx, dy, buts; + static int oldbuts; + + while (dataReady(_EVT_mouse_fd)) { + if (readMouseData(&buts, &dx, &dy)) { + EVT.mx += dx; + EVT.my += dy; + if (EVT.mx < 0) EVT.mx = 0; + if (EVT.my < 0) EVT.my = 0; + if (EVT.mx > range_x) EVT.mx = range_x; + if (EVT.my > range_y) EVT.my = range_y; + evt.where_x = EVT.mx; + evt.where_y = EVT.my; + evt.relative_x = dx; + evt.relative_y = dy; + + /* TODO: This is wrong! We need this to be the time stamp at */ + /* ** interrupt ** time!! One solution would be to */ + /* put the keyboard and mouse polling loops into */ + /* a separate thread that can block on I/O to the */ + /* necessay file descriptor. */ + evt.when = _EVT_getTicks(); + evt.modifiers = _PM_modifiers; + if (buts & 4) + evt.modifiers |= EVT_LEFTBUT; + if (buts & 1) + evt.modifiers |= EVT_RIGHTBUT; + if (buts & 2) + evt.modifiers |= EVT_MIDDLEBUT; + + /* Left click events */ + if ((buts&4) != (oldbuts&4)) { + if (buts&4) + evt.what = EVT_MOUSEDOWN; + else + evt.what = EVT_MOUSEUP; + evt.message = EVT_LEFTBMASK; + EVT.oldMove = -1; + if (EVT.count < EVENTQSIZE) + addEvent(&evt); + } + + /* Right click events */ + if ((buts&1) != (oldbuts&1)) { + if (buts&1) + evt.what = EVT_MOUSEDOWN; + else + evt.what = EVT_MOUSEUP; + evt.message = EVT_RIGHTBMASK; + EVT.oldMove = -1; + if (EVT.count < EVENTQSIZE) + addEvent(&evt); + } + + /* Middle click events */ + if ((buts&2) != (oldbuts&2)) { + if (buts&2) + evt.what = EVT_MOUSEDOWN; + else + evt.what = EVT_MOUSEUP; + evt.message = EVT_MIDDLEBMASK; + EVT.oldMove = -1; + if (EVT.count < EVENTQSIZE) + addEvent(&evt); + } + + /* Mouse movement event */ + if (dx || dy) { + evt.what = EVT_MOUSEMOVE; + evt.message = 0; + if (EVT.oldMove != -1) { + /* Modify existing movement event */ + EVT.evtq[EVT.oldMove].where_x = evt.where_x; + EVT.evtq[EVT.oldMove].where_y = evt.where_y; + } + else { + /* Save id of this movement event */ + EVT.oldMove = EVT.freeHead; + if (EVT.count < EVENTQSIZE) + addEvent(&evt); + } + } + oldbuts = buts; + } + } + } #ifdef USE_OS_JOYSTICK - // Poll joystick events using the 1.x joystick driver API in the 2.2 kernels + /* Poll joystick events using the 1.x joystick driver API in the 2.2 kernels */ if (js_version & ~0xffff) { - static struct js_event js; - - /* Read joystick axis 0 */ - evt.when = 0; - evt.modifiers = _PM_modifiers; - if (joystick0_fd && dataReady(joystick0_fd) && - read(joystick0_fd, &js, sizeof(js)) == sizeof(js)) { - if (js.type & JS_EVENT_BUTTON) { - if (js.number < 2) { /* Only 2 buttons for now :( */ - buts0[js.number] = js.value; - evt.what = EVT_JOYCLICK; - makeJoyEvent(&evt); - if (EVT.count < EVENTQSIZE) - addEvent(&evt); - } - } - else if (js.type & JS_EVENT_AXIS) { - axis0[js.number] = scaleJoyAxis(js.value,js.number); - evt.what = EVT_JOYMOVE; - if (EVT.oldJoyMove != -1) { - makeJoyEvent(&EVT.evtq[EVT.oldJoyMove]); - } - else if (EVT.count < EVENTQSIZE) { - EVT.oldJoyMove = EVT.freeHead; - makeJoyEvent(&evt); - addEvent(&evt); - } - } - } - - /* Read joystick axis 1 */ - if (joystick1_fd && dataReady(joystick1_fd) && - read(joystick1_fd, &js, sizeof(js))==sizeof(js)) { - if (js.type & JS_EVENT_BUTTON) { - if (js.number < 2) { /* Only 2 buttons for now :( */ - buts1[js.number] = js.value; - evt.what = EVT_JOYCLICK; - makeJoyEvent(&evt); - if (EVT.count < EVENTQSIZE) - addEvent(&evt); - } - } - else if (js.type & JS_EVENT_AXIS) { - axis1[js.number] = scaleJoyAxis(js.value,js.number<<2); - evt.what = EVT_JOYMOVE; - if (EVT.oldJoyMove != -1) { - makeJoyEvent(&EVT.evtq[EVT.oldJoyMove]); - } - else if (EVT.count < EVENTQSIZE) { - EVT.oldJoyMove = EVT.freeHead; - makeJoyEvent(&evt); - addEvent(&evt); - } - } - } - } + static struct js_event js; + + /* Read joystick axis 0 */ + evt.when = 0; + evt.modifiers = _PM_modifiers; + if (joystick0_fd && dataReady(joystick0_fd) && + read(joystick0_fd, &js, sizeof(js)) == sizeof(js)) { + if (js.type & JS_EVENT_BUTTON) { + if (js.number < 2) { /* Only 2 buttons for now :( */ + buts0[js.number] = js.value; + evt.what = EVT_JOYCLICK; + makeJoyEvent(&evt); + if (EVT.count < EVENTQSIZE) + addEvent(&evt); + } + } + else if (js.type & JS_EVENT_AXIS) { + axis0[js.number] = scaleJoyAxis(js.value,js.number); + evt.what = EVT_JOYMOVE; + if (EVT.oldJoyMove != -1) { + makeJoyEvent(&EVT.evtq[EVT.oldJoyMove]); + } + else if (EVT.count < EVENTQSIZE) { + EVT.oldJoyMove = EVT.freeHead; + makeJoyEvent(&evt); + addEvent(&evt); + } + } + } + + /* Read joystick axis 1 */ + if (joystick1_fd && dataReady(joystick1_fd) && + read(joystick1_fd, &js, sizeof(js))==sizeof(js)) { + if (js.type & JS_EVENT_BUTTON) { + if (js.number < 2) { /* Only 2 buttons for now :( */ + buts1[js.number] = js.value; + evt.what = EVT_JOYCLICK; + makeJoyEvent(&evt); + if (EVT.count < EVENTQSIZE) + addEvent(&evt); + } + } + else if (js.type & JS_EVENT_AXIS) { + axis1[js.number] = scaleJoyAxis(js.value,js.number<<2); + evt.what = EVT_JOYMOVE; + if (EVT.oldJoyMove != -1) { + makeJoyEvent(&EVT.evtq[EVT.oldJoyMove]); + } + else if (EVT.count < EVENTQSIZE) { + EVT.oldJoyMove = EVT.freeHead; + makeJoyEvent(&evt); + addEvent(&evt); + } + } + } + } #endif } @@ -1122,7 +1122,7 @@ static int setspeed( { struct termios tty; char *c; - + tcgetattr(fd, &tty); tty.c_iflag = IGNBRK | IGNPAR; tty.c_oflag = 0; @@ -1131,20 +1131,20 @@ static int setspeed( tty.c_cc[VTIME] = 0; tty.c_cc[VMIN] = 1; switch (old) { - case 9600: tty.c_cflag = flags | B9600; break; - case 4800: tty.c_cflag = flags | B4800; break; - case 2400: tty.c_cflag = flags | B2400; break; - case 1200: - default: tty.c_cflag = flags | B1200; break; - } + case 9600: tty.c_cflag = flags | B9600; break; + case 4800: tty.c_cflag = flags | B4800; break; + case 2400: tty.c_cflag = flags | B2400; break; + case 1200: + default: tty.c_cflag = flags | B1200; break; + } tcsetattr(fd, TCSAFLUSH, &tty); switch (new) { - case 9600: c = "*q"; tty.c_cflag = flags | B9600; break; - case 4800: c = "*p"; tty.c_cflag = flags | B4800; break; - case 2400: c = "*o"; tty.c_cflag = flags | B2400; break; - case 1200: - default: c = "*n"; tty.c_cflag = flags | B1200; break; - } + case 9600: c = "*q"; tty.c_cflag = flags | B9600; break; + case 4800: c = "*p"; tty.c_cflag = flags | B4800; break; + case 2400: c = "*o"; tty.c_cflag = flags | B2400; break; + case 1200: + default: c = "*n"; tty.c_cflag = flags | B1200; break; + } write(fd, c, 2); usleep(100000); tcsetattr(fd, TCSAFLUSH, &tty); @@ -1161,7 +1161,7 @@ static void _EVT_mouse_init(void) /* Change from any available speed to the chosen one */ for (i = 9600; i >= 1200; i /= 2) - setspeed(_EVT_mouse_fd, i, opt_baud, mouse_infos[mouse_driver].flags); + setspeed(_EVT_mouse_fd, i, opt_baud, mouse_infos[mouse_driver].flags); } /**************************************************************************** @@ -1173,29 +1173,29 @@ static void _EVT_logitech_init(void) int i; struct stat buf; int busmouse; - + /* is this a serial- or a bus- mouse? */ if (fstat(_EVT_mouse_fd,&buf) == -1) - perror("fstat"); + perror("fstat"); i = MAJOR(buf.st_rdev); if (stat("/dev/ttyS0",&buf) == -1) - perror("stat"); + perror("stat"); busmouse=(i != MAJOR(buf.st_rdev)); - + /* Fix the howmany field, so that serial mice have 1, while busmice have 3 */ mouse_infos[mouse_driver].read = busmouse ? 3 : 1; - + /* Change from any available speed to the chosen one */ for (i = 9600; i >= 1200; i /= 2) - setspeed(_EVT_mouse_fd, i, opt_baud, mouse_infos[mouse_driver].flags); - + setspeed(_EVT_mouse_fd, i, opt_baud, mouse_infos[mouse_driver].flags); + /* This stuff is peculiar of logitech mice, also for the serial ones */ write(_EVT_mouse_fd, "S", 1); setspeed(_EVT_mouse_fd, opt_baud, opt_baud,CS8 |PARENB |PARODD |CREAD |CLOCAL |HUPCL); - + /* Configure the sample rate */ for (i = 0; opt_sample <= sampletab[i].sample; i++) - ; + ; write(_EVT_mouse_fd,sampletab[i].code,1); } @@ -1206,7 +1206,7 @@ Microsoft Intellimouse init code static void _EVT_pnpmouse_init(void) { struct termios tty; - + tcgetattr(_EVT_mouse_fd, &tty); tty.c_iflag = IGNBRK | IGNPAR; tty.c_oflag = 0; @@ -1240,53 +1240,53 @@ void EVTAPI EVT_init( EVT.mouseMove = mouseMove; initEventQueue(); for (i = 0; i < 256; i++) - keyUpMsg[i] = 0; + keyUpMsg[i] = 0; /* Keyboard initialization */ if (_PM_console_fd == -1) - PM_fatalError("You must first call PM_openConsole to use the EVT functions!"); + PM_fatalError("You must first call PM_openConsole to use the EVT functions!"); _PM_keyboard_rawmode(); fcntl(_PM_console_fd,F_SETFL,fcntl(_PM_console_fd,F_GETFL) | O_NONBLOCK); /* Mouse initialization */ if ((tmp = getenv(ENV_MOUSEDRV)) != NULL) { - for (i = 0; i < NB_MICE; i++) { - if (!strcasecmp(tmp, mouse_infos[i].name)) { - mouse_driver = i; - break; - } - } - if (i == NB_MICE) { - fprintf(stderr,"Unknown mouse driver: %s\n", tmp); - mouse_driver = EVT_noMouse; - _EVT_mouse_fd = 0; - } - } + for (i = 0; i < NB_MICE; i++) { + if (!strcasecmp(tmp, mouse_infos[i].name)) { + mouse_driver = i; + break; + } + } + if (i == NB_MICE) { + fprintf(stderr,"Unknown mouse driver: %s\n", tmp); + mouse_driver = EVT_noMouse; + _EVT_mouse_fd = 0; + } + } if (mouse_driver != EVT_noMouse) { - if (mouse_driver == EVT_gpm) - strcpy(mouse_dev,"/dev/gpmdata"); - if ((tmp = getenv(ENV_MOUSEDEV)) != NULL) - strcpy(mouse_dev,tmp); + if (mouse_driver == EVT_gpm) + strcpy(mouse_dev,"/dev/gpmdata"); + if ((tmp = getenv(ENV_MOUSEDEV)) != NULL) + strcpy(mouse_dev,tmp); #ifdef CHECKED - fprintf(stderr,"Using the %s MGL mouse driver on %s.\n", mouse_infos[mouse_driver].name, mouse_dev); + fprintf(stderr,"Using the %s MGL mouse driver on %s.\n", mouse_infos[mouse_driver].name, mouse_dev); #endif - if ((_EVT_mouse_fd = open(mouse_dev, O_RDWR)) < 0) { - perror("open"); - fprintf(stderr, "Unable to open mouse device %s, dropping mouse support.\n", mouse_dev); - sleep(1); - mouse_driver = EVT_noMouse; - _EVT_mouse_fd = 0; - } - else { - char c; - - /* Init and flush the mouse pending input queue */ - if (mouse_infos[mouse_driver].init) - mouse_infos[mouse_driver].init(); - while(dataReady(_EVT_mouse_fd) && read(_EVT_mouse_fd, &c, 1) == 1) - ; - } - } + if ((_EVT_mouse_fd = open(mouse_dev, O_RDWR)) < 0) { + perror("open"); + fprintf(stderr, "Unable to open mouse device %s, dropping mouse support.\n", mouse_dev); + sleep(1); + mouse_driver = EVT_noMouse; + _EVT_mouse_fd = 0; + } + else { + char c; + + /* Init and flush the mouse pending input queue */ + if (mouse_infos[mouse_driver].init) + mouse_infos[mouse_driver].init(); + while(dataReady(_EVT_mouse_fd) && read(_EVT_mouse_fd, &c, 1) == 1) + ; + } + } } /**************************************************************************** @@ -1318,7 +1318,7 @@ and this function can be used to resume it again later. ****************************************************************************/ void EVT_resume(void) { - // Do nothing for Linux + /* Do nothing for Linux */ } /**************************************************************************** @@ -1328,7 +1328,7 @@ de-install the event handling code. ****************************************************************************/ void EVT_suspend(void) { - // Do nothing for Linux + /* Do nothing for Linux */ } /**************************************************************************** @@ -1340,22 +1340,21 @@ void EVT_exit(void) /* Restore signal handlers */ _PM_restore_kb_mode(); if (_EVT_mouse_fd) { - close(_EVT_mouse_fd); - _EVT_mouse_fd = 0; - } + close(_EVT_mouse_fd); + _EVT_mouse_fd = 0; + } #ifdef USE_OS_JOYSTICK if (joystick0_fd) { - close(joystick0_fd); - free(axis0); - free(buts0); - joystick0_fd = 0; - } + close(joystick0_fd); + free(axis0); + free(buts0); + joystick0_fd = 0; + } if (joystick1_fd) { - close(joystick1_fd); - free(axis1); - free(buts1); - joystick1_fd = 0; - } + close(joystick1_fd); + free(axis1); + free(buts1); + joystick1_fd = 0; + } #endif } - diff --git a/board/MAI/bios_emulator/scitech/src/pm/linux/oshdr.h b/board/MAI/bios_emulator/scitech/src/pm/linux/oshdr.h index 6023dff1098..eadedfb1372 100644 --- a/board/MAI/bios_emulator/scitech/src/pm/linux/oshdr.h +++ b/board/MAI/bios_emulator/scitech/src/pm/linux/oshdr.h @@ -58,4 +58,3 @@ void _PM_keyboard_rawmode(void); /* Linux needs the generic joystick scaling code */ #define NEED_SCALE_JOY_AXIS - diff --git a/board/MAI/bios_emulator/scitech/src/pm/linux/pm.c b/board/MAI/bios_emulator/scitech/src/pm/linux/pm.c index 1d52984a6a6..c12a83500af 100644 --- a/board/MAI/bios_emulator/scitech/src/pm/linux/pm.c +++ b/board/MAI/bios_emulator/scitech/src/pm/linux/pm.c @@ -148,7 +148,7 @@ static inline void port_out(int value, int port) printk("%04X:%04X: outb.%04X <- %02X\n", traceAddr >> 16, traceAddr & 0xFFFF, (ushort)port, (uchar)value); #endif asm volatile ("outb %0,%1" - ::"a" ((unsigned char) value), "d"((unsigned short) port)); + ::"a" ((unsigned char) value), "d"((unsigned short) port)); } static inline void port_outw(int value, int port) @@ -157,7 +157,7 @@ static inline void port_outw(int value, int port) printk("%04X:%04X: outw.%04X <- %04X\n", traceAddr >> 16,traceAddr & 0xFFFF, (ushort)port, (ushort)value); #endif asm volatile ("outw %0,%1" - ::"a" ((unsigned short) value), "d"((unsigned short) port)); + ::"a" ((unsigned short) value), "d"((unsigned short) port)); } static inline void port_outl(int value, int port) @@ -166,15 +166,15 @@ static inline void port_outl(int value, int port) printk("%04X:%04X: outl.%04X <- %08X\n", traceAddr >> 16,traceAddr & 0xFFFF, (ushort)port, (ulong)value); #endif asm volatile ("outl %0,%1" - ::"a" ((unsigned long) value), "d"((unsigned short) port)); + ::"a" ((unsigned long) value), "d"((unsigned short) port)); } static inline unsigned int port_in(int port) { unsigned char value; asm volatile ("inb %1,%0" - :"=a" ((unsigned char)value) - :"d"((unsigned short) port)); + :"=a" ((unsigned char)value) + :"d"((unsigned short) port)); #ifdef TRACE_IO printk("%04X:%04X: inb.%04X -> %02X\n", traceAddr >> 16,traceAddr & 0xFFFF, (ushort)port, (uchar)value); #endif @@ -185,8 +185,8 @@ static inline unsigned int port_inw(int port) { unsigned short value; asm volatile ("inw %1,%0" - :"=a" ((unsigned short)value) - :"d"((unsigned short) port)); + :"=a" ((unsigned short)value) + :"d"((unsigned short) port)); #ifdef TRACE_IO printk("%04X:%04X: inw.%04X -> %04X\n", traceAddr >> 16,traceAddr & 0xFFFF, (ushort)port, (ushort)value); #endif @@ -197,8 +197,8 @@ static inline unsigned int port_inl(int port) { unsigned long value; asm volatile ("inl %1,%0" - :"=a" ((unsigned long)value) - :"d"((unsigned short) port)); + :"=a" ((unsigned long)value) + :"d"((unsigned short) port)); #ifdef TRACE_IO printk("%04X:%04X: inl.%04X -> %08X\n", traceAddr >> 16,traceAddr & 0xFFFF, (ushort)port, (ulong)value); #endif @@ -211,16 +211,16 @@ static int real_mem_init(void) int fd_zero; if (mem_info.ready) - return 1; + return 1; if ((fd_zero = open("/dev/zero", O_RDONLY)) == -1) - PM_fatalError("You must have root privledges to run this program!"); + PM_fatalError("You must have root privledges to run this program!"); if ((m = mmap((void *)REAL_MEM_BASE, REAL_MEM_SIZE, - PROT_READ | PROT_WRITE | PROT_EXEC, - MAP_FIXED | MAP_PRIVATE, fd_zero, 0)) == (void *)-1) { - close(fd_zero); - PM_fatalError("You must have root privledges to run this program!"); - } + PROT_READ | PROT_WRITE | PROT_EXEC, + MAP_FIXED | MAP_PRIVATE, fd_zero, 0)) == (void *)-1) { + close(fd_zero); + PM_fatalError("You must have root privledges to run this program!"); + } mem_info.ready = 1; mem_info.count = 1; mem_info.blocks[0].size = REAL_MEM_SIZE; @@ -231,9 +231,9 @@ static int real_mem_init(void) static void insert_block(int i) { memmove( - mem_info.blocks + i + 1, - mem_info.blocks + i, - (mem_info.count - i) * sizeof(struct mem_block)); + mem_info.blocks + i + 1, + mem_info.blocks + i, + (mem_info.count - i) * sizeof(struct mem_block)); mem_info.count++; } @@ -242,9 +242,9 @@ static void delete_block(int i) mem_info.count--; memmove( - mem_info.blocks + i, - mem_info.blocks + i + 1, - (mem_info.count - i) * sizeof(struct mem_block)); + mem_info.blocks + i, + mem_info.blocks + i + 1, + (mem_info.count - i) * sizeof(struct mem_block)); } static inline void set_bit(unsigned int bit, void *array) @@ -279,35 +279,35 @@ void PMAPI PM_init(void) uint r_seg,r_off; if (inited) - return; + return; /* Map the Interrupt Vectors (0x0 - 0x400) + BIOS data (0x400 - 0x502) * and the physical framebuffer and ROM images from (0xa0000 - 0x100000) */ real_mem_init(); if (!fd_mem && (fd_mem = open("/dev/mem", O_RDWR)) == -1) { - PM_fatalError("You must have root privileges to run this program!"); - } + PM_fatalError("You must have root privileges to run this program!"); + } if ((m = mmap((void *)0, 0x502, - PROT_READ | PROT_WRITE | PROT_EXEC, - MAP_FIXED | MAP_PRIVATE, fd_mem, 0)) == (void *)-1) { - PM_fatalError("You must have root privileges to run this program!"); - } + PROT_READ | PROT_WRITE | PROT_EXEC, + MAP_FIXED | MAP_PRIVATE, fd_mem, 0)) == (void *)-1) { + PM_fatalError("You must have root privileges to run this program!"); + } if ((m = mmap((void *)0xA0000, 0xC0000 - 0xA0000, - PROT_READ | PROT_WRITE, - MAP_FIXED | MAP_SHARED, fd_mem, 0xA0000)) == (void *)-1) { - PM_fatalError("You must have root privileges to run this program!"); - } + PROT_READ | PROT_WRITE, + MAP_FIXED | MAP_SHARED, fd_mem, 0xA0000)) == (void *)-1) { + PM_fatalError("You must have root privileges to run this program!"); + } if ((m = mmap((void *)0xC0000, 0xD0000 - 0xC0000, - PROT_READ | PROT_WRITE | PROT_EXEC, - MAP_FIXED | MAP_PRIVATE, fd_mem, 0xC0000)) == (void *)-1) { - PM_fatalError("You must have root privileges to run this program!"); - } + PROT_READ | PROT_WRITE | PROT_EXEC, + MAP_FIXED | MAP_PRIVATE, fd_mem, 0xC0000)) == (void *)-1) { + PM_fatalError("You must have root privileges to run this program!"); + } if ((m = mmap((void *)0xD0000, 0x100000 - 0xD0000, - PROT_READ | PROT_WRITE, - MAP_FIXED | MAP_SHARED, fd_mem, 0xD0000)) == (void *)-1) { - PM_fatalError("You must have root privileges to run this program!"); - } + PROT_READ | PROT_WRITE, + MAP_FIXED | MAP_SHARED, fd_mem, 0xD0000)) == (void *)-1) { + PM_fatalError("You must have root privileges to run this program!"); + } inited = 1; /* Allocate a stack */ @@ -356,9 +356,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( @@ -370,7 +370,7 @@ void PMAPI PM_setFatalErrorCleanup( void PMAPI PM_fatalError(const char *msg) { if (fatalErrorCleanup) - fatalErrorCleanup(); + fatalErrorCleanup(); fprintf(stderr,"%s\n", msg); fflush(stderr); exit(1); @@ -379,18 +379,18 @@ void PMAPI PM_fatalError(const char *msg) 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; @@ -431,7 +431,7 @@ static FILE *open_kb_mode( char *path) { if (!PM_findBPD("graphics.bpd",path)) - return NULL; + return NULL; PM_backslash(path); strcat(path,KBMODE_DAT); return fopen(path,mode); @@ -448,18 +448,18 @@ void _PM_restore_kb_mode(void) char path[PM_MAX_PATH]; if (_PM_console_fd != -1 && (kbmode = open_kb_mode("rb",path)) != NULL) { - if (fread(&mode,1,sizeof(mode),kbmode) == sizeof(mode)) { - if (mode.startup_vc > 0) - ioctl(_PM_console_fd, VT_ACTIVATE, mode.startup_vc); - ioctl(_PM_console_fd, KDSKBMODE, mode.kb_mode); - ioctl(_PM_console_fd, KDSETLED, mode.leds); - tcsetattr(_PM_console_fd, TCSAFLUSH, &mode.termios); - fcntl(_PM_console_fd,F_SETFL,mode.flags); - } - fclose(kbmode); - unlink(path); - in_raw_mode = false; - } + if (fread(&mode,1,sizeof(mode),kbmode) == sizeof(mode)) { + if (mode.startup_vc > 0) + ioctl(_PM_console_fd, VT_ACTIVATE, mode.startup_vc); + ioctl(_PM_console_fd, KDSKBMODE, mode.kb_mode); + ioctl(_PM_console_fd, KDSETLED, mode.leds); + tcsetattr(_PM_console_fd, TCSAFLUSH, &mode.termios); + fcntl(_PM_console_fd,F_SETFL,mode.flags); + } + fclose(kbmode); + unlink(path); + in_raw_mode = false; + } } /**************************************************************************** @@ -488,49 +488,49 @@ void _PM_keyboard_rawmode(void) char path[PM_MAX_PATH]; int i; static int sig_list[] = { - SIGHUP, - SIGINT, - SIGQUIT, - SIGILL, - SIGTRAP, - SIGABRT, - SIGIOT, - SIGBUS, - SIGFPE, - SIGKILL, - SIGSEGV, - SIGTERM, - }; + SIGHUP, + SIGINT, + SIGQUIT, + SIGILL, + SIGTRAP, + SIGABRT, + SIGIOT, + SIGBUS, + SIGFPE, + SIGKILL, + SIGSEGV, + SIGTERM, + }; if ((kbmode = open_kb_mode("rb",path)) == NULL) { - if ((kbmode = open_kb_mode("wb",path)) == NULL) - PM_fatalError("Unable to open kbmode.dat file for writing!"); - if (ioctl(_PM_console_fd, KDGKBMODE, &mode.kb_mode)) - perror("KDGKBMODE"); - ioctl(_PM_console_fd, KDGETLED, &mode.leds); - _PM_leds = mode.leds & 0xF; - _PM_modifiers = 0; - tcgetattr(_PM_console_fd, &mode.termios); - conf = mode.termios; - conf.c_lflag &= ~(ICANON | ECHO | ISIG); - conf.c_iflag &= ~(ISTRIP | IGNCR | ICRNL | INLCR | BRKINT | PARMRK | INPCK | IUCLC | IXON | IXOFF); - conf.c_iflag |= (IGNBRK | IGNPAR); - conf.c_cc[VMIN] = 1; - conf.c_cc[VTIME] = 0; - conf.c_cc[VSUSP] = 0; - tcsetattr(_PM_console_fd, TCSAFLUSH, &conf); - mode.flags = fcntl(_PM_console_fd,F_GETFL); - if (ioctl(_PM_console_fd, KDSKBMODE, K_MEDIUMRAW)) - perror("KDSKBMODE"); - atexit(_PM_restore_kb_mode); - for (i = 0; i < sizeof(sig_list)/sizeof(sig_list[0]); i++) - signal(sig_list[i], _PM_abort); - mode.startup_vc = startup_vc; - if (fwrite(&mode,1,sizeof(mode),kbmode) != sizeof(mode)) - PM_fatalError("Error writing kbmode.dat!"); - fclose(kbmode); - in_raw_mode = true; - } + if ((kbmode = open_kb_mode("wb",path)) == NULL) + PM_fatalError("Unable to open kbmode.dat file for writing!"); + if (ioctl(_PM_console_fd, KDGKBMODE, &mode.kb_mode)) + perror("KDGKBMODE"); + ioctl(_PM_console_fd, KDGETLED, &mode.leds); + _PM_leds = mode.leds & 0xF; + _PM_modifiers = 0; + tcgetattr(_PM_console_fd, &mode.termios); + conf = mode.termios; + conf.c_lflag &= ~(ICANON | ECHO | ISIG); + conf.c_iflag &= ~(ISTRIP | IGNCR | ICRNL | INLCR | BRKINT | PARMRK | INPCK | IUCLC | IXON | IXOFF); + conf.c_iflag |= (IGNBRK | IGNPAR); + conf.c_cc[VMIN] = 1; + conf.c_cc[VTIME] = 0; + conf.c_cc[VSUSP] = 0; + tcsetattr(_PM_console_fd, TCSAFLUSH, &conf); + mode.flags = fcntl(_PM_console_fd,F_GETFL); + if (ioctl(_PM_console_fd, KDSKBMODE, K_MEDIUMRAW)) + perror("KDSKBMODE"); + atexit(_PM_restore_kb_mode); + for (i = 0; i < sizeof(sig_list)/sizeof(sig_list[0]); i++) + signal(sig_list[i], _PM_abort); + mode.startup_vc = startup_vc; + if (fwrite(&mode,1,sizeof(mode),kbmode) != sizeof(mode)) + PM_fatalError("Error writing kbmode.dat!"); + fclose(kbmode); + in_raw_mode = true; + } } int PMAPI PM_kbhit(void) @@ -539,9 +539,9 @@ int PMAPI PM_kbhit(void) struct timeval tv = { 0, 0 }; if (console_count == 0) - PM_fatalError("You *must* open a console before using PM_kbhit!"); + PM_fatalError("You *must* open a console before using PM_kbhit!"); if (!in_raw_mode) - _PM_keyboard_rawmode(); + _PM_keyboard_rawmode(); FD_ZERO(&s); FD_SET(_PM_console_fd, &s); return select(_PM_console_fd+1, &s, NULL, NULL, &tv) > 0; @@ -554,62 +554,62 @@ int PMAPI PM_getch(void) static struct kbentry ke; if (console_count == 0) - PM_fatalError("You *must* open a console before using PM_getch!"); + PM_fatalError("You *must* open a console before using PM_getch!"); if (!in_raw_mode) - _PM_keyboard_rawmode(); + _PM_keyboard_rawmode(); while (read(_PM_console_fd, &c, 1) > 0) { - release = c & 0x80; - c &= 0x7F; - if (release) { - switch(c){ - case 42: case 54: // Shift - _PM_modifiers &= ~KB_SHIFT; - break; - case 29: case 97: // Control - _PM_modifiers &= ~KB_CONTROL; - break; - case 56: case 100: // Alt / AltGr - _PM_modifiers &= ~KB_ALT; - break; - } - continue; - } - switch (c) { - case 42: case 54: // Shift - _PM_modifiers |= KB_SHIFT; - break; - case 29: case 97: // Control - _PM_modifiers |= KB_CONTROL; - break; - case 56: case 100: // Alt / AltGr - _PM_modifiers |= KB_ALT; - break; - case 58: // Caps Lock - _PM_modifiers ^= KB_CAPS; - ioctl(_PM_console_fd, KDSETLED, _PM_modifiers & 7); - break; - case 69: // Num Lock - _PM_modifiers ^= KB_NUMLOCK; - ioctl(_PM_console_fd, KDSETLED, _PM_modifiers & 7); - break; - case 70: // Scroll Lock - _PM_modifiers ^= KB_SCROLL; - ioctl(_PM_console_fd, KDSETLED, _PM_modifiers & 7); - break; - case 28: - return 0x1C; - default: - ke.kb_index = c; - ke.kb_table = 0; - if ((_PM_modifiers & KB_SHIFT) || (_PM_modifiers & KB_CAPS)) - ke.kb_table |= K_SHIFTTAB; - if (_PM_modifiers & KB_ALT) - ke.kb_table |= K_ALTTAB; - ioctl(_PM_console_fd, KDGKBENT, (ulong)&ke); - c = ke.kb_value & 0xFF; - return c; - } - } + release = c & 0x80; + c &= 0x7F; + if (release) { + switch(c){ + case 42: case 54: /* Shift */ + _PM_modifiers &= ~KB_SHIFT; + break; + case 29: case 97: /* Control */ + _PM_modifiers &= ~KB_CONTROL; + break; + case 56: case 100: /* Alt / AltGr */ + _PM_modifiers &= ~KB_ALT; + break; + } + continue; + } + switch (c) { + case 42: case 54: /* Shift */ + _PM_modifiers |= KB_SHIFT; + break; + case 29: case 97: /* Control */ + _PM_modifiers |= KB_CONTROL; + break; + case 56: case 100: /* Alt / AltGr */ + _PM_modifiers |= KB_ALT; + break; + case 58: /* Caps Lock */ + _PM_modifiers ^= KB_CAPS; + ioctl(_PM_console_fd, KDSETLED, _PM_modifiers & 7); + break; + case 69: /* Num Lock */ + _PM_modifiers ^= KB_NUMLOCK; + ioctl(_PM_console_fd, KDSETLED, _PM_modifiers & 7); + break; + case 70: /* Scroll Lock */ + _PM_modifiers ^= KB_SCROLL; + ioctl(_PM_console_fd, KDSETLED, _PM_modifiers & 7); + break; + case 28: + return 0x1C; + default: + ke.kb_index = c; + ke.kb_table = 0; + if ((_PM_modifiers & KB_SHIFT) || (_PM_modifiers & KB_CAPS)) + ke.kb_table |= K_SHIFTTAB; + if (_PM_modifiers & KB_ALT) + ke.kb_table |= K_ALTTAB; + ioctl(_PM_console_fd, KDGKBENT, (ulong)&ke); + c = ke.kb_value & 0xFF; + return c; + } + } return 0; } @@ -621,12 +621,12 @@ static void wait_vt_active( int _PM_console_fd) { while (ioctl(_PM_console_fd, VT_WAITACTIVE, tty_vc) < 0) { - if ((errno != EAGAIN) && (errno != EINTR)) { - perror("ioctl(VT_WAITACTIVE)"); - exit(1); - } - usleep(150000); - } + if ((errno != EAGAIN) && (errno != EINTR)) { + perror("ioctl(VT_WAITACTIVE)"); + exit(1); + } + usleep(150000); + } } /**************************************************************************** @@ -641,7 +641,7 @@ static int check_owner( sprintf(fname, "/dev/tty%d", vc); if ((stat(fname, &sbuf) >= 0) && (getuid() == sbuf.st_uid)) - return 1; + return 1; printf("You must be the owner of the current console to use this program.\n"); return 0; } @@ -658,7 +658,7 @@ static void restore_text_console( int console_id) { if (ioctl(console_id, KDSETMODE, KD_TEXT) < 0) - LOGWARN("ioctl(KDSETMODE) failed"); + LOGWARN("ioctl(KDSETMODE) failed"); _PM_restore_kb_mode(); } @@ -682,7 +682,7 @@ PM_HWND PMAPI PM_openConsole( /* Check if we have already opened the console */ if (console_count++) - return _PM_console_fd; + return _PM_console_fd; /* Now, it would be great if we could use /dev/tty and see what it is * connected to. Alas, we cannot find out reliably what VC /dev/tty is @@ -690,26 +690,26 @@ PM_HWND PMAPI PM_openConsole( */ startup_vc = 0; for (_PM_console_fd = 0; _PM_console_fd < 3; _PM_console_fd++) { - if (fstat(_PM_console_fd, &sbuf) < 0) - continue; - if (ioctl(_PM_console_fd, VT_GETMODE, &vtm) < 0) - continue; - if ((sbuf.st_rdev & 0xFF00) != 0x400) - continue; - if (!(sbuf.st_rdev & 0xFF)) - continue; - tty_vc = sbuf.st_rdev & 0xFF; - restore_text_console(_PM_console_fd); - return _PM_console_fd; - } + if (fstat(_PM_console_fd, &sbuf) < 0) + continue; + if (ioctl(_PM_console_fd, VT_GETMODE, &vtm) < 0) + continue; + if ((sbuf.st_rdev & 0xFF00) != 0x400) + continue; + if (!(sbuf.st_rdev & 0xFF)) + continue; + tty_vc = sbuf.st_rdev & 0xFF; + restore_text_console(_PM_console_fd); + return _PM_console_fd; + } if ((_PM_console_fd = open("/dev/console", O_RDWR)) < 0) { - printf("open_dev_console: can't open /dev/console \n"); - exit(1); - } + printf("open_dev_console: can't open /dev/console \n"); + exit(1); + } if (ioctl(_PM_console_fd, VT_OPENQRY, &tty_vc) < 0) - goto Error; + goto Error; if (tty_vc <= 0) - goto Error; + goto Error; sprintf(fname, "/dev/tty%d", tty_vc); close(_PM_console_fd); @@ -718,40 +718,40 @@ PM_HWND PMAPI PM_openConsole( /* We must use RDWR to allow for output... */ if (((_PM_console_fd = open(fname, O_RDWR)) >= 0) && - (ioctl(_PM_console_fd, VT_GETSTATE, &vts) >= 0)) { - if (!check_owner(vts.v_active)) - goto Error; - restore_text_console(_PM_console_fd); - - /* Success, redirect all stdios */ - fflush(stdin); - fflush(stdout); - fflush(stderr); - close(0); - close(1); - close(2); - dup(_PM_console_fd); - dup(_PM_console_fd); - dup(_PM_console_fd); - - /* clear screen and switch to it */ - fwrite("\e[H\e[J", 6, 1, stderr); - fflush(stderr); - if (tty_vc != vts.v_active) { - startup_vc = vts.v_active; - ioctl(_PM_console_fd, VT_ACTIVATE, tty_vc); - wait_vt_active(_PM_console_fd); - } - } + (ioctl(_PM_console_fd, VT_GETSTATE, &vts) >= 0)) { + if (!check_owner(vts.v_active)) + goto Error; + restore_text_console(_PM_console_fd); + + /* Success, redirect all stdios */ + fflush(stdin); + fflush(stdout); + fflush(stderr); + close(0); + close(1); + close(2); + dup(_PM_console_fd); + dup(_PM_console_fd); + dup(_PM_console_fd); + + /* clear screen and switch to it */ + fwrite("\e[H\e[J", 6, 1, stderr); + fflush(stderr); + if (tty_vc != vts.v_active) { + startup_vc = vts.v_active; + ioctl(_PM_console_fd, VT_ACTIVATE, tty_vc); + wait_vt_active(_PM_console_fd); + } + } return _PM_console_fd; Error: if (_PM_console_fd > 2) - close(_PM_console_fd); + close(_PM_console_fd); console_count = 0; PM_fatalError( - "Not running in a graphics capable console,\n" - "and unable to find one.\n"); + "Not running in a graphics capable console,\n" + "and unable to find one.\n"); return -1; } @@ -764,7 +764,7 @@ Returns the size of the console state buffer. int PMAPI PM_getConsoleStateSize(void) { if (!inited) - PM_init(); + PM_init(); return PM_getVGAStateSize() + FONT_C*2; } @@ -778,11 +778,11 @@ void PMAPI PM_saveConsoleState(void *stateBuf,int console_id) /* Save the current console font */ if (ioctl(console_id,GIO_FONT,®s[PM_getVGAStateSize()]) < 0) - perror("ioctl(GIO_FONT)"); + perror("ioctl(GIO_FONT)"); /* Inform the Linux console that we are going into graphics mode */ if (ioctl(console_id, KDSETMODE, KD_GRAPHICS) < 0) - perror("ioctl(KDSETMODE)"); + perror("ioctl(KDSETMODE)"); /* Save state of VGA registers */ PM_saveVGAState(stateBuf); @@ -806,11 +806,11 @@ void PMAPI PM_restoreConsoleState(const void *stateBuf,PM_HWND console_id) /* Inform the Linux console that we are back from graphics modes */ if (ioctl(console_id, KDSETMODE, KD_TEXT) < 0) - LOGWARN("ioctl(KDSETMODE) failed"); + LOGWARN("ioctl(KDSETMODE) failed"); /* Restore the old console font */ if (ioctl(console_id,PIO_FONT,®s[PM_getVGAStateSize()]) < 0) - LOGWARN("ioctl(KDSETMODE) failed"); + LOGWARN("ioctl(KDSETMODE) failed"); /* Coming back from graphics mode on Linux also restored the previous * text mode console contents, so we need to clear the screen to get @@ -830,15 +830,15 @@ void PMAPI PM_closeConsole(PM_HWND _PM_console_fd) { /* Restore console to normal operation */ if (--console_count == 0) { - /* Re-activate the original virtual console */ - if (startup_vc > 0) - ioctl(_PM_console_fd, VT_ACTIVATE, startup_vc); + /* Re-activate the original virtual console */ + if (startup_vc > 0) + ioctl(_PM_console_fd, VT_ACTIVATE, startup_vc); - /* Close the console file descriptor */ - if (_PM_console_fd > 2) - close(_PM_console_fd); - _PM_console_fd = -1; - } + /* Close the console file descriptor */ + if (_PM_console_fd > 2) + close(_PM_console_fd); + _PM_console_fd = -1; + } } void PM_setOSCursorLocation(int x,int y) @@ -855,12 +855,12 @@ void PM_setOSScreenWidth(int width,int height) struct winsize ws; struct vt_sizes vs; - // Resize the software terminal + /* Resize the software terminal */ ws.ws_col = width; ws.ws_row = height; ioctl(_PM_console_fd, TIOCSWINSZ, &ws); - // And the hardware + /* And the hardware */ vs.v_rows = height; vs.v_cols = width; vs.v_scrollsize = 0; @@ -869,18 +869,18 @@ void PM_setOSScreenWidth(int width,int height) ibool PMAPI PM_setRealTimeClockHandler(PM_intHandler ih, int frequency) { - // TODO: Implement this for Linux + /* TODO: Implement this for Linux */ return false; } void PMAPI PM_setRealTimeClockFrequency(int frequency) { - // TODO: Implement this for Linux + /* TODO: Implement this for Linux */ } void PMAPI PM_restoreRealTimeClockHandler(void) { - // TODO: Implement this for Linux + /* TODO: Implement this for Linux */ } char * PMAPI PM_getCurrentPath( @@ -929,7 +929,7 @@ void * PMAPI PM_getBIOSPointer(void) { static uchar *zeroPtr = NULL; if (!zeroPtr) - zeroPtr = PM_mapPhysicalAddr(0,0xFFFFF,true); + zeroPtr = PM_mapPhysicalAddr(0,0xFFFFF,true); return (void*)(zeroPtr + 0x400); } @@ -939,7 +939,7 @@ void * PMAPI PM_getA0000Pointer(void) * address mapping, so we can return the address here. */ if (!inited) - PM_init(); + PM_init(); return (void*)(0xA0000); } @@ -949,11 +949,11 @@ void * PMAPI PM_mapPhysicalAddr(ulong base,ulong limit,ibool isCached) ulong baseAddr,baseOfs; if (!inited) - PM_init(); + PM_init(); if (base >= 0xA0000 && base < 0x100000) - return (void*)base; + return (void*)base; if (!fd_mem && (fd_mem = open("/dev/mem", O_RDWR)) == -1) - return NULL; + return NULL; /* Round the physical address to a 4Kb boundary and the limit to a * 4Kb-1 boundary before passing the values to mmap. If we round the @@ -964,57 +964,57 @@ void * PMAPI PM_mapPhysicalAddr(ulong base,ulong limit,ibool isCached) baseAddr = base & ~4095; limit = ((limit+baseOfs+1+4095) & ~4095)-1; if ((p = mmap(0, limit+1, - PROT_READ | PROT_WRITE, MAP_SHARED, - fd_mem, baseAddr)) == (void *)-1) - return NULL; + PROT_READ | PROT_WRITE, MAP_SHARED, + fd_mem, baseAddr)) == (void *)-1) + return NULL; return (void*)(p+baseOfs); } void PMAPI PM_freePhysicalAddr(void *ptr,ulong limit) { if ((ulong)ptr >= 0x100000) - munmap(ptr,limit+1); + munmap(ptr,limit+1); } 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. */ return 0xFFFFFFFFUL; } ibool PMAPI PM_getPhysicalAddrRange(void *p,ulong length,ulong *physAddress) { - // TODO: This function should find a range of physical addresses - // for a linear address. + /* TODO: This function should find a range of physical addresses */ + /* for a linear address. */ return false; } void PMAPI PM_sleep(ulong milliseconds) { - // TODO: Put the process to sleep for milliseconds + /* TODO: Put the process to sleep for milliseconds */ } int PMAPI PM_getCOMPort(int port) { - // TODO: Re-code this to determine real values using the Plug and Play - // manager for the OS. + /* TODO: Re-code this to determine real values using the Plug and Play */ + /* manager for the OS. */ 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) { - // TODO: Re-code this to determine real values using the Plug and Play - // manager for the OS. + /* TODO: Re-code this to determine real values using the Plug and Play */ + /* manager for the OS. */ 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; } @@ -1038,7 +1038,7 @@ void * PMAPI PM_mapRealPointer(uint r_seg,uint r_off) * mapping so we can simply return the physical address in here. */ if (!inited) - PM_init(); + PM_init(); return (void*)MK_PHYS(r_seg,r_off); } @@ -1048,24 +1048,24 @@ void * PMAPI PM_allocRealSeg(uint size,uint *r_seg,uint *r_off) char *r = (char *)REAL_MEM_BASE; if (!inited) - PM_init(); + PM_init(); if (!mem_info.ready) - return NULL; + return NULL; if (mem_info.count == REAL_MEM_BLOCKS) - return NULL; + return NULL; size = (size + 15) & ~15; for (i = 0; i < mem_info.count; i++) { - if (mem_info.blocks[i].free && size < mem_info.blocks[i].size) { - insert_block(i); - mem_info.blocks[i].size = size; - mem_info.blocks[i].free = 0; - mem_info.blocks[i + 1].size -= size; - *r_seg = (uint)(r) >> 4; - *r_off = (uint)(r) & 0xF; - return (void *)r; - } - r += mem_info.blocks[i].size; - } + if (mem_info.blocks[i].free && size < mem_info.blocks[i].size) { + insert_block(i); + mem_info.blocks[i].size = size; + mem_info.blocks[i].free = 0; + mem_info.blocks[i + 1].size -= size; + *r_seg = (uint)(r) >> 4; + *r_off = (uint)(r) & 0xF; + return (void *)r; + } + r += mem_info.blocks[i].size; + } return NULL; } @@ -1075,23 +1075,23 @@ void PMAPI PM_freeRealSeg(void *mem) char *r = (char *)REAL_MEM_BASE; if (!mem_info.ready) - return; + return; i = 0; while (mem != (void *)r) { - r += mem_info.blocks[i].size; - i++; - if (i == mem_info.count) - return; - } + r += mem_info.blocks[i].size; + i++; + if (i == mem_info.count) + return; + } mem_info.blocks[i].free = 1; if (i + 1 < mem_info.count && mem_info.blocks[i + 1].free) { - mem_info.blocks[i].size += mem_info.blocks[i + 1].size; - delete_block(i + 1); - } + mem_info.blocks[i].size += mem_info.blocks[i + 1].size; + delete_block(i + 1); + } if (i - 1 >= 0 && mem_info.blocks[i - 1].free) { - mem_info.blocks[i - 1].size += mem_info.blocks[i].size; - delete_block(i); - } + mem_info.blocks[i - 1].size += mem_info.blocks[i].size; + delete_block(i); + } } #define DIRECTION_FLAG (1 << 10) @@ -1104,27 +1104,27 @@ static void em_ins(int size) edi = context.vm.regs.edi & 0xffff; edi += (unsigned int)context.vm.regs.ds << 4; if (context.vm.regs.eflags & DIRECTION_FLAG) { - if (size == 4) - asm volatile ("std; insl; cld" - : "=D" (edi) : "d" (edx), "0" (edi)); - else if (size == 2) - asm volatile ("std; insw; cld" - : "=D" (edi) : "d" (edx), "0" (edi)); - else - asm volatile ("std; insb; cld" - : "=D" (edi) : "d" (edx), "0" (edi)); - } + if (size == 4) + asm volatile ("std; insl; cld" + : "=D" (edi) : "d" (edx), "0" (edi)); + else if (size == 2) + asm volatile ("std; insw; cld" + : "=D" (edi) : "d" (edx), "0" (edi)); + else + asm volatile ("std; insb; cld" + : "=D" (edi) : "d" (edx), "0" (edi)); + } else { - if (size == 4) - asm volatile ("cld; insl" - : "=D" (edi) : "d" (edx), "0" (edi)); - else if (size == 2) - asm volatile ("cld; insw" - : "=D" (edi) : "d" (edx), "0" (edi)); - else - asm volatile ("cld; insb" - : "=D" (edi) : "d" (edx), "0" (edi)); - } + if (size == 4) + asm volatile ("cld; insl" + : "=D" (edi) : "d" (edx), "0" (edi)); + else if (size == 2) + asm volatile ("cld; insw" + : "=D" (edi) : "d" (edx), "0" (edi)); + else + asm volatile ("cld; insb" + : "=D" (edi) : "d" (edx), "0" (edi)); + } edi -= (unsigned int)context.vm.regs.ds << 4; context.vm.regs.edi &= 0xffff0000; context.vm.regs.edi |= edi & 0xffff; @@ -1139,33 +1139,33 @@ static void em_rep_ins(int size) edi = context.vm.regs.edi & 0xffff; edi += (unsigned int)context.vm.regs.ds << 4; if (context.vm.regs.eflags & DIRECTION_FLAG) { - if (size == 4) - asm volatile ("std; rep; insl; cld" - : "=D" (edi), "=c" (ecx) - : "d" (edx), "0" (edi), "1" (ecx)); - else if (size == 2) - asm volatile ("std; rep; insw; cld" - : "=D" (edi), "=c" (ecx) - : "d" (edx), "0" (edi), "1" (ecx)); - else - asm volatile ("std; rep; insb; cld" - : "=D" (edi), "=c" (ecx) - : "d" (edx), "0" (edi), "1" (ecx)); - } + if (size == 4) + asm volatile ("std; rep; insl; cld" + : "=D" (edi), "=c" (ecx) + : "d" (edx), "0" (edi), "1" (ecx)); + else if (size == 2) + asm volatile ("std; rep; insw; cld" + : "=D" (edi), "=c" (ecx) + : "d" (edx), "0" (edi), "1" (ecx)); + else + asm volatile ("std; rep; insb; cld" + : "=D" (edi), "=c" (ecx) + : "d" (edx), "0" (edi), "1" (ecx)); + } else { - if (size == 4) - asm volatile ("cld; rep; insl" - : "=D" (edi), "=c" (ecx) - : "d" (edx), "0" (edi), "1" (ecx)); - else if (size == 2) - asm volatile ("cld; rep; insw" - : "=D" (edi), "=c" (ecx) - : "d" (edx), "0" (edi), "1" (ecx)); - else - asm volatile ("cld; rep; insb" - : "=D" (edi), "=c" (ecx) - : "d" (edx), "0" (edi), "1" (ecx)); - } + if (size == 4) + asm volatile ("cld; rep; insl" + : "=D" (edi), "=c" (ecx) + : "d" (edx), "0" (edi), "1" (ecx)); + else if (size == 2) + asm volatile ("cld; rep; insw" + : "=D" (edi), "=c" (ecx) + : "d" (edx), "0" (edi), "1" (ecx)); + else + asm volatile ("cld; rep; insb" + : "=D" (edi), "=c" (ecx) + : "d" (edx), "0" (edi), "1" (ecx)); + } edi -= (unsigned int)context.vm.regs.ds << 4; context.vm.regs.edi &= 0xffff0000; @@ -1182,27 +1182,27 @@ static void em_outs(int size) esi = context.vm.regs.esi & 0xffff; esi += (unsigned int)context.vm.regs.ds << 4; if (context.vm.regs.eflags & DIRECTION_FLAG) { - if (size == 4) - asm volatile ("std; outsl; cld" - : "=S" (esi) : "d" (edx), "0" (esi)); - else if (size == 2) - asm volatile ("std; outsw; cld" - : "=S" (esi) : "d" (edx), "0" (esi)); - else - asm volatile ("std; outsb; cld" - : "=S" (esi) : "d" (edx), "0" (esi)); - } + if (size == 4) + asm volatile ("std; outsl; cld" + : "=S" (esi) : "d" (edx), "0" (esi)); + else if (size == 2) + asm volatile ("std; outsw; cld" + : "=S" (esi) : "d" (edx), "0" (esi)); + else + asm volatile ("std; outsb; cld" + : "=S" (esi) : "d" (edx), "0" (esi)); + } else { - if (size == 4) - asm volatile ("cld; outsl" - : "=S" (esi) : "d" (edx), "0" (esi)); - else if (size == 2) - asm volatile ("cld; outsw" - : "=S" (esi) : "d" (edx), "0" (esi)); - else - asm volatile ("cld; outsb" - : "=S" (esi) : "d" (edx), "0" (esi)); - } + if (size == 4) + asm volatile ("cld; outsl" + : "=S" (esi) : "d" (edx), "0" (esi)); + else if (size == 2) + asm volatile ("cld; outsw" + : "=S" (esi) : "d" (edx), "0" (esi)); + else + asm volatile ("cld; outsb" + : "=S" (esi) : "d" (edx), "0" (esi)); + } esi -= (unsigned int)context.vm.regs.ds << 4; context.vm.regs.esi &= 0xffff0000; @@ -1218,33 +1218,33 @@ static void em_rep_outs(int size) esi = context.vm.regs.esi & 0xffff; esi += (unsigned int)context.vm.regs.ds << 4; if (context.vm.regs.eflags & DIRECTION_FLAG) { - if (size == 4) - asm volatile ("std; rep; outsl; cld" - : "=S" (esi), "=c" (ecx) - : "d" (edx), "0" (esi), "1" (ecx)); - else if (size == 2) - asm volatile ("std; rep; outsw; cld" - : "=S" (esi), "=c" (ecx) - : "d" (edx), "0" (esi), "1" (ecx)); - else - asm volatile ("std; rep; outsb; cld" - : "=S" (esi), "=c" (ecx) - : "d" (edx), "0" (esi), "1" (ecx)); - } + if (size == 4) + asm volatile ("std; rep; outsl; cld" + : "=S" (esi), "=c" (ecx) + : "d" (edx), "0" (esi), "1" (ecx)); + else if (size == 2) + asm volatile ("std; rep; outsw; cld" + : "=S" (esi), "=c" (ecx) + : "d" (edx), "0" (esi), "1" (ecx)); + else + asm volatile ("std; rep; outsb; cld" + : "=S" (esi), "=c" (ecx) + : "d" (edx), "0" (esi), "1" (ecx)); + } else { - if (size == 4) - asm volatile ("cld; rep; outsl" - : "=S" (esi), "=c" (ecx) - : "d" (edx), "0" (esi), "1" (ecx)); - else if (size == 2) - asm volatile ("cld; rep; outsw" - : "=S" (esi), "=c" (ecx) - : "d" (edx), "0" (esi), "1" (ecx)); - else - asm volatile ("cld; rep; outsb" - : "=S" (esi), "=c" (ecx) - : "d" (edx), "0" (esi), "1" (ecx)); - } + if (size == 4) + asm volatile ("cld; rep; outsl" + : "=S" (esi), "=c" (ecx) + : "d" (edx), "0" (esi), "1" (ecx)); + else if (size == 2) + asm volatile ("cld; rep; outsw" + : "=S" (esi), "=c" (ecx) + : "d" (edx), "0" (esi), "1" (ecx)); + else + asm volatile ("cld; rep; outsb" + : "=S" (esi), "=c" (ecx) + : "d" (edx), "0" (esi), "1" (ecx)); + } esi -= (unsigned int)context.vm.regs.ds << 4; context.vm.regs.esi &= 0xffff0000; @@ -1257,9 +1257,9 @@ static int emulate(void) { unsigned char *insn; struct { - unsigned int size : 1; - unsigned int rep : 1; - } prefix = { 0, 0 }; + unsigned int size : 1; + unsigned int rep : 1; + } prefix = { 0, 0 }; int i = 0; insn = (unsigned char *)((unsigned int)context.vm.regs.cs << 4); @@ -1267,101 +1267,101 @@ static int emulate(void) while (1) { #ifdef TRACE_IO - traceAddr = ((ulong)context.vm.regs.cs << 16) + context.vm.regs.eip + i; + traceAddr = ((ulong)context.vm.regs.cs << 16) + context.vm.regs.eip + i; #endif - if (insn[i] == 0x66) { - prefix.size = 1 - prefix.size; - i++; - } - else if (insn[i] == 0xf3) { - prefix.rep = 1; - i++; - } - else if (insn[i] == 0xf0 || insn[i] == 0xf2 - || insn[i] == 0x26 || insn[i] == 0x2e - || insn[i] == 0x36 || insn[i] == 0x3e - || insn[i] == 0x64 || insn[i] == 0x65 - || insn[i] == 0x67) { - /* these prefixes are just ignored */ - i++; - } - else if (insn[i] == 0x6c) { - if (prefix.rep) - em_rep_ins(1); - else - em_ins(1); - i++; - break; - } - else if (insn[i] == 0x6d) { - if (prefix.rep) { - if (prefix.size) - em_rep_ins(4); - else - em_rep_ins(2); - } - else { - if (prefix.size) - em_ins(4); - else - em_ins(2); - } - i++; - break; - } - else if (insn[i] == 0x6e) { - if (prefix.rep) - em_rep_outs(1); - else - em_outs(1); - i++; - break; - } - else if (insn[i] == 0x6f) { - if (prefix.rep) { - if (prefix.size) - em_rep_outs(4); - else - em_rep_outs(2); - } - else { - if (prefix.size) - em_outs(4); - else - em_outs(2); - } - i++; - break; - } - else if (insn[i] == 0xec) { - *((uchar*)&context.vm.regs.eax) = port_in(context.vm.regs.edx); - i++; - break; - } - else if (insn[i] == 0xed) { - if (prefix.size) - *((ulong*)&context.vm.regs.eax) = port_inl(context.vm.regs.edx); - else - *((ushort*)&context.vm.regs.eax) = port_inw(context.vm.regs.edx); - i++; - break; - } - else if (insn[i] == 0xee) { - port_out(context.vm.regs.eax,context.vm.regs.edx); - i++; - break; - } - else if (insn[i] == 0xef) { - if (prefix.size) - port_outl(context.vm.regs.eax,context.vm.regs.edx); - else - port_outw(context.vm.regs.eax,context.vm.regs.edx); - i++; - break; - } - else - return 0; - } + if (insn[i] == 0x66) { + prefix.size = 1 - prefix.size; + i++; + } + else if (insn[i] == 0xf3) { + prefix.rep = 1; + i++; + } + else if (insn[i] == 0xf0 || insn[i] == 0xf2 + || insn[i] == 0x26 || insn[i] == 0x2e + || insn[i] == 0x36 || insn[i] == 0x3e + || insn[i] == 0x64 || insn[i] == 0x65 + || insn[i] == 0x67) { + /* these prefixes are just ignored */ + i++; + } + else if (insn[i] == 0x6c) { + if (prefix.rep) + em_rep_ins(1); + else + em_ins(1); + i++; + break; + } + else if (insn[i] == 0x6d) { + if (prefix.rep) { + if (prefix.size) + em_rep_ins(4); + else + em_rep_ins(2); + } + else { + if (prefix.size) + em_ins(4); + else + em_ins(2); + } + i++; + break; + } + else if (insn[i] == 0x6e) { + if (prefix.rep) + em_rep_outs(1); + else + em_outs(1); + i++; + break; + } + else if (insn[i] == 0x6f) { + if (prefix.rep) { + if (prefix.size) + em_rep_outs(4); + else + em_rep_outs(2); + } + else { + if (prefix.size) + em_outs(4); + else + em_outs(2); + } + i++; + break; + } + else if (insn[i] == 0xec) { + *((uchar*)&context.vm.regs.eax) = port_in(context.vm.regs.edx); + i++; + break; + } + else if (insn[i] == 0xed) { + if (prefix.size) + *((ulong*)&context.vm.regs.eax) = port_inl(context.vm.regs.edx); + else + *((ushort*)&context.vm.regs.eax) = port_inw(context.vm.regs.edx); + i++; + break; + } + else if (insn[i] == 0xee) { + port_out(context.vm.regs.eax,context.vm.regs.edx); + i++; + break; + } + else if (insn[i] == 0xef) { + if (prefix.size) + port_outl(context.vm.regs.eax,context.vm.regs.edx); + else + port_outw(context.vm.regs.eax,context.vm.regs.edx); + i++; + break; + } + else + return 0; + } context.vm.regs.eip += i; return 1; @@ -1393,7 +1393,7 @@ static void debug_info(int vret) fputs("cs:ip = [ ", stderr); p = (unsigned char *)((context.vm.regs.cs << 4) + (context.vm.regs.eip & 0xffff)); for (i = 0; i < 16; ++i) - fprintf(stderr, "%02x ", (unsigned int)p[i]); + fprintf(stderr, "%02x ", (unsigned int)p[i]); fputs("]\n", stderr); fflush(stderr); } @@ -1403,24 +1403,24 @@ static int run_vm86(void) unsigned int vret; for (;;) { - vret = vm86(&context.vm); - if (VM86_TYPE(vret) == VM86_INTx) { - unsigned int v = VM86_ARG(vret); - if (v == RETURN_TO_32_INT) - return 1; - pushw(context.vm.regs.eflags); - pushw(context.vm.regs.cs); - pushw(context.vm.regs.eip); - context.vm.regs.cs = get_int_seg(v); - context.vm.regs.eip = get_int_off(v); - context.vm.regs.eflags &= ~(VIF_MASK | TF_MASK); - continue; - } - if (VM86_TYPE(vret) != VM86_UNKNOWN) - break; - if (!emulate()) - break; - } + vret = vm86(&context.vm); + if (VM86_TYPE(vret) == VM86_INTx) { + unsigned int v = VM86_ARG(vret); + if (v == RETURN_TO_32_INT) + return 1; + pushw(context.vm.regs.eflags); + pushw(context.vm.regs.cs); + pushw(context.vm.regs.eip); + context.vm.regs.cs = get_int_seg(v); + context.vm.regs.eip = get_int_off(v); + context.vm.regs.eflags &= ~(VIF_MASK | TF_MASK); + continue; + } + if (VM86_TYPE(vret) != VM86_UNKNOWN) + break; + if (!emulate()) + break; + } debug_info(vret); return 0; } @@ -1431,7 +1431,7 @@ static int run_vm86(void) void PMAPI DPMI_int86(int intno, DPMI_regs *regs) { if (!inited) - PM_init(); + PM_init(); memset(&context.vm.regs, 0, sizeof(context.vm.regs)); IND(eax); IND(ebx); IND(ecx); IND(edx); IND(esi); IND(edi); context.vm.regs.eflags = DEFAULT_VM86_FLAGS; @@ -1453,7 +1453,7 @@ void PMAPI DPMI_int86(int intno, DPMI_regs *regs) int PMAPI PM_int86(int intno, RMREGS *in, RMREGS *out) { if (!inited) - PM_init(); + PM_init(); memset(&context.vm.regs, 0, sizeof(context.vm.regs)); IN(eax); IN(ebx); IN(ecx); IN(edx); IN(esi); IN(edi); context.vm.regs.eflags = DEFAULT_VM86_FLAGS; @@ -1474,41 +1474,41 @@ int PMAPI PM_int86x(int intno, RMREGS *in, RMREGS *out, RMSREGS *sregs) { if (!inited) - PM_init(); + PM_init(); if (intno == 0x21) { - time_t today = time(NULL); - struct tm *t; - t = localtime(&today); - out->x.cx = t->tm_year + 1900; - out->h.dh = t->tm_mon + 1; - out->h.dl = t->tm_mday; - } + time_t today = time(NULL); + struct tm *t; + t = localtime(&today); + out->x.cx = t->tm_year + 1900; + out->h.dh = t->tm_mon + 1; + out->h.dl = t->tm_mday; + } else { - unsigned int seg, off; - seg = get_int_seg(intno); - off = get_int_off(intno); - memset(&context.vm.regs, 0, sizeof(context.vm.regs)); - IN(eax); IN(ebx); IN(ecx); IN(edx); IN(esi); IN(edi); - context.vm.regs.eflags = DEFAULT_VM86_FLAGS; - context.vm.regs.cs = seg; - context.vm.regs.eip = off; - context.vm.regs.es = sregs->es; - context.vm.regs.ds = sregs->ds; - context.vm.regs.fs = sregs->fs; - context.vm.regs.gs = sregs->gs; - context.vm.regs.ss = context.stack_seg; - context.vm.regs.esp = context.stack_off; - pushw(DEFAULT_VM86_FLAGS); - pushw(context.ret_seg); - pushw(context.ret_off); - run_vm86(); - OUT(eax); OUT(ebx); OUT(ecx); OUT(edx); OUT(esi); OUT(edi); - sregs->es = context.vm.regs.es; - sregs->ds = context.vm.regs.ds; - sregs->fs = context.vm.regs.fs; - sregs->gs = context.vm.regs.gs; - out->x.cflag = context.vm.regs.eflags & 1; - } + unsigned int seg, off; + seg = get_int_seg(intno); + off = get_int_off(intno); + memset(&context.vm.regs, 0, sizeof(context.vm.regs)); + IN(eax); IN(ebx); IN(ecx); IN(edx); IN(esi); IN(edi); + context.vm.regs.eflags = DEFAULT_VM86_FLAGS; + context.vm.regs.cs = seg; + context.vm.regs.eip = off; + context.vm.regs.es = sregs->es; + context.vm.regs.ds = sregs->ds; + context.vm.regs.fs = sregs->fs; + context.vm.regs.gs = sregs->gs; + context.vm.regs.ss = context.stack_seg; + context.vm.regs.esp = context.stack_off; + pushw(DEFAULT_VM86_FLAGS); + pushw(context.ret_seg); + pushw(context.ret_off); + run_vm86(); + OUT(eax); OUT(ebx); OUT(ecx); OUT(edx); OUT(esi); OUT(edi); + sregs->es = context.vm.regs.es; + sregs->ds = context.vm.regs.ds; + sregs->fs = context.vm.regs.fs; + sregs->gs = context.vm.regs.gs; + out->x.cflag = context.vm.regs.eflags & 1; + } return out->e.eax; } @@ -1518,7 +1518,7 @@ void PMAPI PM_callRealMode(uint seg,uint off, RMREGS *in, RMSREGS *sregs) { if (!inited) - PM_init(); + PM_init(); memset(&context.vm.regs, 0, sizeof(context.vm.regs)); IN(eax); IN(ebx); IN(ecx); IN(edx); IN(esi); IN(edi); context.vm.regs.eflags = DEFAULT_VM86_FLAGS; @@ -1558,32 +1558,32 @@ void PMAPI PM_availableMemory(ulong *physical,ulong *total) void * PMAPI PM_allocLockedMem(uint size,ulong *physAddr,ibool contiguous,ibool below16M) { - // TODO: Implement this for Linux + /* TODO: Implement this for Linux */ return NULL; } void PMAPI PM_freeLockedMem(void *p,uint size,ibool contiguous) { - // TODO: Implement this for Linux + /* TODO: Implement this for Linux */ } void * PMAPI PM_allocPage( ibool locked) { - // TODO: Implement this for Linux + /* TODO: Implement this for Linux */ return NULL; } void PMAPI PM_freePage( void *p) { - // TODO: Implement this for Linux + /* TODO: Implement this for Linux */ } void PMAPI PM_setBankA(int bank) { if (!inited) - PM_init(); + PM_init(); memset(&context.vm.regs, 0, sizeof(context.vm.regs)); context.vm.regs.eax = 0x4F05; context.vm.regs.ebx = 0x0000; @@ -1602,7 +1602,7 @@ void PMAPI PM_setBankA(int bank) void PMAPI PM_setBankAB(int bank) { if (!inited) - PM_init(); + PM_init(); memset(&context.vm.regs, 0, sizeof(context.vm.regs)); context.vm.regs.eax = 0x4F05; context.vm.regs.ebx = 0x0000; @@ -1633,7 +1633,7 @@ void PMAPI PM_setBankAB(int bank) void PMAPI PM_setCRTStart(int x,int y,int waitVRT) { if (!inited) - PM_init(); + PM_init(); memset(&context.vm.regs, 0, sizeof(context.vm.regs)); context.vm.regs.eax = 0x4F07; context.vm.regs.ebx = waitVRT; @@ -1656,14 +1656,14 @@ int PMAPI PM_enableWriteCombine(ulong base,ulong length,uint type) struct mtrr_sentry sentry; if (mtrr_fd < 0) - return PM_MTRR_ERR_NO_OS_SUPPORT; + return PM_MTRR_ERR_NO_OS_SUPPORT; sentry.base = base; sentry.size = length; sentry.type = type; if (ioctl(mtrr_fd, MTRRIOC_ADD_ENTRY, &sentry) == -1) { - // TODO: Need to decode MTRR error codes!! - return PM_MTRR_NOT_SUPPORTED; - } + /* TODO: Need to decode MTRR error codes!! */ + return PM_MTRR_NOT_SUPPORTED; + } return PM_MTRR_ERR_OK; #else return PM_MTRR_ERR_NO_OS_SUPPORT; @@ -1685,15 +1685,15 @@ int PMAPI PM_enumWriteCombine( struct mtrr_gentry gentry; if (mtrr_fd < 0) - return PM_MTRR_ERR_NO_OS_SUPPORT; + return PM_MTRR_ERR_NO_OS_SUPPORT; for (gentry.regnum = 0; ioctl (mtrr_fd, MTRRIOC_GET_ENTRY, &gentry) == 0; - ++gentry.regnum) { - if (gentry.size > 0) { - // WARNING: This code assumes that the types in pmapi.h match the ones - // in the Linux kernel (mtrr.h) - callback(gentry.base, gentry.size, gentry.type); - } + ++gentry.regnum) { + if (gentry.size > 0) { + /* WARNING: This code assumes that the types in pmapi.h match the ones */ + /* in the Linux kernel (mtrr.h) */ + callback(gentry.base, gentry.size, gentry.type); + } } return PM_MTRR_ERR_OK; @@ -1719,13 +1719,13 @@ ibool PMAPI PM_doBIOSPOST( * the secondary BIOS image over the top of the old one. */ if (!inited) - PM_init(); + PM_init(); if ((old_bios = PM_malloc(BIOSLen)) == NULL) - return false; + return false; if (BIOSPhysAddr != 0xC0000) { - memcpy(old_bios,bios_ptr,BIOSLen); - memcpy(bios_ptr,copyOfBIOS,BIOSLen); - } + memcpy(old_bios,bios_ptr,BIOSLen); + memcpy(bios_ptr,copyOfBIOS,BIOSLen); + } /* The interrupt vectors should already be mmap()'ed from 0-0x400 in PM_init */ Current10 = rvec[0x10]; @@ -1742,7 +1742,7 @@ ibool PMAPI PM_doBIOSPOST( /* Restore original BIOS image */ if (BIOSPhysAddr != 0xC0000) - memcpy(bios_ptr,old_bios,BIOSLen); + memcpy(bios_ptr,old_bios,BIOSLen); PM_free(old_bios); return true; } @@ -1774,7 +1774,7 @@ int PMAPI PM_unlockCodePages(void (*p)(),uint len,PM_lockHandle *lh) PM_MODULE PMAPI PM_loadLibrary( const char *szDLLName) { - // TODO: Implement this to load shared libraries! + /* TODO: Implement this to load shared libraries! */ (void)szDLLName; return NULL; } @@ -1783,7 +1783,7 @@ void * PMAPI PM_getProcAddress( PM_MODULE hModule, const char *szProcName) { - // TODO: Implement this! + /* TODO: Implement this! */ (void)hModule; (void)szProcName; return NULL; @@ -1792,19 +1792,18 @@ void * PMAPI PM_getProcAddress( void PMAPI PM_freeLibrary( PM_MODULE hModule) { - // TODO: Implement this! + /* TODO: Implement this! */ (void)hModule; } int PMAPI PM_setIOPL( int level) { - // TODO: Move the IOPL switching into this function!! + /* TODO: Move the IOPL switching into this function!! */ return level; } void PMAPI PM_flushTLB(void) { - // Do nothing on Linux. + /* Do nothing on Linux. */ } - diff --git a/board/MAI/bios_emulator/scitech/src/pm/ntdrv/cpuinfo.c b/board/MAI/bios_emulator/scitech/src/pm/ntdrv/cpuinfo.c index e72a856019e..d15b07c290c 100644 --- a/board/MAI/bios_emulator/scitech/src/pm/ntdrv/cpuinfo.c +++ b/board/MAI/bios_emulator/scitech/src/pm/ntdrv/cpuinfo.c @@ -62,4 +62,3 @@ Read the counter and return the counter value. (t)->low = lt.LowPart; \ (t)->high = lt.HighPart; \ } - diff --git a/board/MAI/bios_emulator/scitech/src/pm/ntdrv/int86.c b/board/MAI/bios_emulator/scitech/src/pm/ntdrv/int86.c index f93d9c22e78..c82648b7871 100644 --- a/board/MAI/bios_emulator/scitech/src/pm/ntdrv/int86.c +++ b/board/MAI/bios_emulator/scitech/src/pm/ntdrv/int86.c @@ -1,7 +1,7 @@ /**************************************************************************** * * SciTech OS Portability Manager Library -* +* * ======================================================================== * * The contents of this file are subject to the SciTech MGL Public @@ -43,7 +43,7 @@ We do have limited BIOS access under Windows NT device drivers. ****************************************************************************/ ibool PMAPI PM_haveBIOSAccess(void) { - // Return false unless we have full buffer passing! + /* Return false unless we have full buffer passing! */ return false; } @@ -63,8 +63,8 @@ void * PMAPI PM_getVESABuf( uint *rseg, uint *roff) { - // No buffers supported under Windows NT (Windows XP has them however if - // we ever decide to support this!) + /* No buffers supported under Windows NT (Windows XP has them however if */ + /* we ever decide to support this!) */ return NULL; } @@ -90,7 +90,7 @@ void * PMAPI PM_mapRealPointer( uint r_seg, uint r_off) { - // Not used for Windows NT drivers! + /* Not used for Windows NT drivers! */ return NULL; } @@ -103,7 +103,7 @@ void * PMAPI PM_allocRealSeg( uint *r_seg, uint *r_off) { - // Not supported in NT drivers + /* Not supported in NT drivers */ (void)size; (void)r_seg; (void)r_off; @@ -117,7 +117,7 @@ Free a block of real mode memory. void PMAPI PM_freeRealSeg( void *mem) { - // Not supported in NT drivers + /* Not supported in NT drivers */ (void)mem; } @@ -129,7 +129,7 @@ void PMAPI DPMI_int86( int intno, DPMI_regs *regs) { - // Not used in NT drivers + /* Not used in NT drivers */ } /**************************************************************************** @@ -143,7 +143,7 @@ void PMAPI PM_callRealMode( RMREGS *regs, RMSREGS *sregs) { - // TODO!! + /* TODO!! */ #if 0 CLIENT_STRUCT saveRegs; @@ -151,7 +151,7 @@ void PMAPI PM_callRealMode( * loaded, and not statically loaded. */ if (!_PM_haveBIOS) - return; + return; TRACE("SDDHELP: Entering PM_callRealMode()\n"); Begin_Nest_V86_Exec(); @@ -174,7 +174,7 @@ int PMAPI PM_int86( RMREGS *in, RMREGS *out) { - // TODO!! + /* TODO!! */ #if 0 RMSREGS sregs = {0}; CLIENT_STRUCT saveRegs; @@ -183,9 +183,9 @@ int PMAPI PM_int86( /* Disable pass-up to our VxD handler so we directly call BIOS */ TRACE("SDDHELP: Entering PM_int86()\n"); if (disableTSRFlag) { - oldDisable = *disableTSRFlag; - *disableTSRFlag = 0; - } + oldDisable = *disableTSRFlag; + *disableTSRFlag = 0; + } Begin_Nest_V86_Exec(); LoadV86Registers(&saveRegs,in,&sregs); Exec_Int(intno); @@ -194,7 +194,7 @@ int PMAPI PM_int86( /* Re-enable pass-up to our VxD handler if previously enabled */ if (disableTSRFlag) - *disableTSRFlag = oldDisable; + *disableTSRFlag = oldDisable; TRACE("SDDHELP: Exiting PM_int86()\n"); #else @@ -214,7 +214,7 @@ int PMAPI PM_int86x( RMREGS *out, RMSREGS *sregs) { - // TODO!! + /* TODO!! */ #if 0 CLIENT_STRUCT saveRegs; ushort oldDisable; @@ -223,16 +223,16 @@ int PMAPI PM_int86x( * loaded, and not statically loaded. */ if (!_PM_haveBIOS) { - *out = *in; - return out->x.ax; - } + *out = *in; + return out->x.ax; + } /* Disable pass-up to our VxD handler so we directly call BIOS */ TRACE("SDDHELP: Entering PM_int86x()\n"); if (disableTSRFlag) { - oldDisable = *disableTSRFlag; - *disableTSRFlag = 0; - } + oldDisable = *disableTSRFlag; + *disableTSRFlag = 0; + } Begin_Nest_V86_Exec(); LoadV86Registers(&saveRegs,in,sregs); Exec_Int(intno); @@ -241,7 +241,7 @@ int PMAPI PM_int86x( /* Re-enable pass-up to our VxD handler if previously enabled */ if (disableTSRFlag) - *disableTSRFlag = oldDisable; + *disableTSRFlag = oldDisable; TRACE("SDDHELP: Exiting PM_int86x()\n"); #else @@ -249,4 +249,3 @@ int PMAPI PM_int86x( #endif return out->x.ax; } - diff --git a/board/MAI/bios_emulator/scitech/src/pm/ntdrv/irq.c b/board/MAI/bios_emulator/scitech/src/pm/ntdrv/irq.c index bc6b4274df3..9cd52047b71 100644 --- a/board/MAI/bios_emulator/scitech/src/pm/ntdrv/irq.c +++ b/board/MAI/bios_emulator/scitech/src/pm/ntdrv/irq.c @@ -1,7 +1,7 @@ /**************************************************************************** * * SciTech OS Portability Manager Library -* +* * ======================================================================== * * The contents of this file are subject to the SciTech MGL Public @@ -67,41 +67,41 @@ 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,(uchar)_PM_oldCMOSRegA); - _PM_writeCMOS(0x0B,(uchar)(_PM_oldCMOSRegB & 0x0F)); - } + /* Disable RTC timout */ + _PM_writeCMOS(0x0A,(uchar)_PM_oldCMOSRegA); + _PM_writeCMOS(0x0B,(uchar)(_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,(uchar)(0x20 | (i+3))); - _PM_writeCMOS(0x0B,(uchar)((_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,(uchar)(0x20 | (i+3))); + _PM_writeCMOS(0x0B,(uchar)((_PM_oldCMOSRegB & 0x0F) | 0x40)); + } } ibool PMAPI PM_setRealTimeClockHandler(PM_intHandler th,int frequency) @@ -130,14 +130,13 @@ 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,(uchar)((PM_inpb(0xA1) & 0xFE) | (_PM_oldRTCPIC2 & ~0xFE))); - - /* Restore the interrupt vector */ - _PM_restoreISR(RTC_idtEntry, &_PM_prevRTC); - _PM_rtcHandler = NULL; - } + /* Restore CMOS registers and mask RTC clock */ + _PM_writeCMOS(0x0A,_PM_oldCMOSRegA); + _PM_writeCMOS(0x0B,_PM_oldCMOSRegB); + PM_outpb(0xA1,(uchar)((PM_inpb(0xA1) & 0xFE) | (_PM_oldRTCPIC2 & ~0xFE))); + + /* Restore the interrupt vector */ + _PM_restoreISR(RTC_idtEntry, &_PM_prevRTC); + _PM_rtcHandler = NULL; + } } - diff --git a/board/MAI/bios_emulator/scitech/src/pm/ntdrv/mem.c b/board/MAI/bios_emulator/scitech/src/pm/ntdrv/mem.c index b30d2be8609..3128c6ae382 100644 --- a/board/MAI/bios_emulator/scitech/src/pm/ntdrv/mem.c +++ b/board/MAI/bios_emulator/scitech/src/pm/ntdrv/mem.c @@ -1,7 +1,7 @@ /**************************************************************************** * * SciTech OS Portability Manager Library -* +* * ======================================================================== * * The contents of this file are subject to the SciTech MGL Public @@ -70,7 +70,7 @@ static memlocked locked[MAX_MEMORY_LOCKED]; ulong PMAPI _PM_getPDB(void); -// Page table entry flags +/* Page table entry flags */ #define PAGE_FLAGS_PRESENT 0x00000001 #define PAGE_FLAGS_WRITEABLE 0x00000002 @@ -100,14 +100,14 @@ static ulong _PM_mapPhysicalToLinear( ulong length = limit+1; PHYSICAL_ADDRESS paIoBase = {0}; - // NT loves large Ints + /* NT loves large Ints */ paIoBase = RtlConvertUlongToLargeInteger( base ); - // Map IO space into Kernel + /* Map IO space into Kernel */ if (isCached) - return (ULONG)MmMapIoSpace(paIoBase, length, MmCached ); + return (ULONG)MmMapIoSpace(paIoBase, length, MmCached ); else - return (ULONG)MmMapIoSpace(paIoBase, length, MmNonCached ); + return (ULONG)MmMapIoSpace(paIoBase, length, MmNonCached ); } /**************************************************************************** @@ -135,7 +135,7 @@ static void _PM_adjustPageTables( mask &= ~PAGE_FLAGS_USER; bits |= PAGE_FLAGS_USER; } - + /* Disable PCD bit if page table entry should be uncached */ if (!isCached) { mask &= ~(PAGE_FLAGS_CACHE_DISABLE | PAGE_FLAGS_WRITE_THROUGH); @@ -144,30 +144,30 @@ static void _PM_adjustPageTables( pPDB = (ulong*)_PM_mapPhysicalToLinear(_PM_getPDB(),0xFFF,true); if (pPDB) { - startPDB = (linear >> 22) & 0x3FF; - startPage = (linear >> 12) & 0x3FF; - endPDB = ((linear+limit) >> 22) & 0x3FF; - endPage = ((linear+limit) >> 12) & 0x3FF; - for (iPDB = startPDB; iPDB <= endPDB; iPDB++) { - // Set the bits in the page directory entry - required as per - // Pentium 4 manual. This also takes care of the 4MB page entries - pPDB[iPDB] = (pPDB[iPDB] & mask) | bits; - if (!(pPDB[iPDB] & PAGE_FLAGS_4MB)) { - // If we are dealing with 4KB pages then we need to iterate - // through each of the page table entries - pageTable = pPDB[iPDB] & ~0xFFF; - pPageTable = (ulong*)_PM_mapPhysicalToLinear(pageTable,0xFFF,true); - start = (iPDB == startPDB) ? startPage : 0; - end = (iPDB == endPDB) ? endPage : 0x3FF; - for (iPage = start; iPage <= end; iPage++) { - pPageTable[iPage] = (pPageTable[iPage] & mask) | bits; - } - MmUnmapIoSpace(pPageTable,0xFFF); - } - } - MmUnmapIoSpace(pPDB,0xFFF); - PM_flushTLB(); - } + startPDB = (linear >> 22) & 0x3FF; + startPage = (linear >> 12) & 0x3FF; + endPDB = ((linear+limit) >> 22) & 0x3FF; + endPage = ((linear+limit) >> 12) & 0x3FF; + for (iPDB = startPDB; iPDB <= endPDB; iPDB++) { + /* Set the bits in the page directory entry - required as per */ + /* Pentium 4 manual. This also takes care of the 4MB page entries */ + pPDB[iPDB] = (pPDB[iPDB] & mask) | bits; + if (!(pPDB[iPDB] & PAGE_FLAGS_4MB)) { + /* If we are dealing with 4KB pages then we need to iterate */ + /* through each of the page table entries */ + pageTable = pPDB[iPDB] & ~0xFFF; + pPageTable = (ulong*)_PM_mapPhysicalToLinear(pageTable,0xFFF,true); + start = (iPDB == startPDB) ? startPage : 0; + end = (iPDB == endPDB) ? endPage : 0x3FF; + for (iPage = start; iPage <= end; iPage++) { + pPageTable[iPage] = (pPageTable[iPage] & mask) | bits; + } + MmUnmapIoSpace(pPageTable,0xFFF); + } + } + MmUnmapIoSpace(pPDB,0xFFF); + PM_flushTLB(); + } } /**************************************************************************** @@ -183,24 +183,24 @@ void * PMAPI PM_mallocShared( { int i; - // First find a free slot in our shared memory table + /* First find a free slot in our shared memory table */ for (i = 0; i < MAX_MEMORY_SHARED; i++) { - if (shared[i].linear == 0) - break; - } + if (shared[i].linear == 0) + break; + } if (i == MAX_MEMORY_SHARED) - return NULL; + return NULL; - // Allocate the paged pool + /* Allocate the paged pool */ shared[i].linear = ExAllocatePool(PagedPool, size); - // Create a list to manage this allocation + /* Create a list to manage this allocation */ shared[i].pMdl = IoAllocateMdl(shared[i].linear,size,FALSE,FALSE,(PIRP) NULL); - // Lock this allocation in memory + /* Lock this allocation in memory */ MmProbeAndLockPages(shared[i].pMdl,KernelMode,IoModifyAccess); - // Modify bits to grant user access + /* Modify bits to grant user access */ _PM_adjustPageTables((ulong)shared[i].linear, size, true, true); return (void*)shared[i].linear; } @@ -214,23 +214,23 @@ void PMAPI PM_freeShared( { int i; - // Find a shared memory block in our table and free it + /* Find a shared memory block in our table and free it */ for (i = 0; i < MAX_MEMORY_SHARED; i++) { - if (shared[i].linear == p) { - // Unlock what we locked - MmUnlockPages(shared[i].pMdl); + if (shared[i].linear == p) { + /* Unlock what we locked */ + MmUnlockPages(shared[i].pMdl); - // Free our MDL - IoFreeMdl(shared[i].pMdl); + /* Free our MDL */ + IoFreeMdl(shared[i].pMdl); - // Free our mem - ExFreePool(shared[i].linear); + /* Free our mem */ + ExFreePool(shared[i].linear); - // Flag that is entry is available - shared[i].linear = 0; - break; - } - } + /* Flag that is entry is available */ + shared[i].linear = 0; + break; + } + } } /**************************************************************************** @@ -245,27 +245,27 @@ void * PMAPI PM_mapPhysicalAddr( ulong linear,length = limit+1; int i; - // Search table of existing mappings to see if we have already mapped - // a region of memory that will serve this purpose. + /* Search table of existing mappings to see if we have already mapped */ + /* a region of memory that will serve this purpose. */ for (i = 0; i < numMappings; i++) { - if (maps[i].physical == base && maps[i].length == length && maps[i].isCached == isCached) { - _PM_adjustPageTables((ulong)maps[i].linear, maps[i].length, true, isCached); - return (void*)maps[i].linear; - } - } + if (maps[i].physical == base && maps[i].length == length && maps[i].isCached == isCached) { + _PM_adjustPageTables((ulong)maps[i].linear, maps[i].length, true, isCached); + return (void*)maps[i].linear; + } + } if (numMappings == MAX_MEMORY_MAPPINGS) - return NULL; + return NULL; - // We did not find any previously mapped memory region, so maps it in. + /* We did not find any previously mapped memory region, so maps it in. */ if ((linear = _PM_mapPhysicalToLinear(base,limit,isCached)) == 0xFFFFFFFF) - return NULL; + return NULL; maps[numMappings].physical = base; maps[numMappings].length = length; maps[numMappings].linear = linear; maps[numMappings].isCached = isCached; numMappings++; - // Grant user access to this I/O space + /* Grant user access to this I/O space */ _PM_adjustPageTables((ulong)linear, length, true, isCached); return (void*)linear; } @@ -278,8 +278,8 @@ void PMAPI PM_freePhysicalAddr( void *ptr, ulong limit) { - // We don't free the memory mappings in here because we cache all - // the memory mappings we create in the system for later use. + /* We don't free the memory mappings in here because we cache all */ + /* the memory mappings we create in the system for later use. */ } /**************************************************************************** @@ -291,7 +291,7 @@ void PMAPI _PM_freeMemoryMappings(void) int i; for (i = 0; i < numMappings; i++) - MmUnmapIoSpace((void *)maps[i].linear,maps[i].length); + MmUnmapIoSpace((void *)maps[i].linear,maps[i].length); } /**************************************************************************** @@ -320,10 +320,10 @@ ibool PMAPI PM_getPhysicalAddrRange( ulong linear = (ulong)p & ~0xFFF; for (i = (length + 0xFFF) >> 12; i > 0; i--) { - if ((*physAddress++ = PM_getPhysicalAddr((void*)linear)) == 0xFFFFFFFF) - return false; - linear += 4096; - } + if ((*physAddress++ = PM_getPhysicalAddr((void*)linear)) == 0xFFFFFFFF) + return false; + linear += 4096; + } return true; } @@ -340,58 +340,58 @@ void * PMAPI PM_allocLockedMem( int i; PHYSICAL_ADDRESS paOurAddress; - // First find a free slot in our shared memory table + /* First find a free slot in our shared memory table */ for (i = 0; i < MAX_MEMORY_LOCKED; i++) { - if (locked[i].linear == 0) - break; - } + if (locked[i].linear == 0) + break; + } if (i == MAX_MEMORY_LOCKED) - return NULL; + return NULL; - // HighestAcceptableAddress - Specifies the highest valid physical address - // the driver can use. For example, if a device can only reference physical - // memory in the lower 16MB, this value would be set to 0x00000000FFFFFF. + /* HighestAcceptableAddress - Specifies the highest valid physical address */ + /* the driver can use. For example, if a device can only reference physical */ + /* memory in the lower 16MB, this value would be set to 0x00000000FFFFFF. */ paOurAddress.HighPart = 0; if (below16M) - paOurAddress.LowPart = 0x00FFFFFF; + paOurAddress.LowPart = 0x00FFFFFF; else - paOurAddress.LowPart = 0xFFFFFFFF; + paOurAddress.LowPart = 0xFFFFFFFF; if (contiguous) { - // Allocate from the non-paged pool (unfortunately 4MB pages) - locked[i].linear = MmAllocateContiguousMemory(size, paOurAddress); - if (!locked[i].linear) - return NULL; + /* Allocate from the non-paged pool (unfortunately 4MB pages) */ + locked[i].linear = MmAllocateContiguousMemory(size, paOurAddress); + if (!locked[i].linear) + return NULL; - // Flag no MDL - locked[i].pMdl = NULL; + /* Flag no MDL */ + locked[i].pMdl = NULL; - // Map the physical address for the memory so we can manage - // the page tables in 4KB chunks mapped into user space. + /* Map the physical address for the memory so we can manage */ + /* the page tables in 4KB chunks mapped into user space. */ - // TODO: Map this with the physical address to the linear addresss - locked[i].mmIoMapped = locked[i].linear; + /* TODO: Map this with the physical address to the linear addresss */ + locked[i].mmIoMapped = locked[i].linear; - // Modify bits to grant user access, flag not cached - _PM_adjustPageTables((ulong)locked[i].mmIoMapped, size, true, false); - return (void*)locked[i].mmIoMapped; - } + /* Modify bits to grant user access, flag not cached */ + _PM_adjustPageTables((ulong)locked[i].mmIoMapped, size, true, false); + return (void*)locked[i].mmIoMapped; + } else { - // Allocate from the paged pool - locked[i].linear = ExAllocatePool(PagedPool, size); - if (!locked[i].linear) - return NULL; + /* Allocate from the paged pool */ + locked[i].linear = ExAllocatePool(PagedPool, size); + if (!locked[i].linear) + return NULL; - // Create a list to manage this allocation - locked[i].pMdl = IoAllocateMdl(locked[i].linear,size,FALSE,FALSE,(PIRP) NULL); + /* Create a list to manage this allocation */ + locked[i].pMdl = IoAllocateMdl(locked[i].linear,size,FALSE,FALSE,(PIRP) NULL); - // Lock this allocation in memory - MmProbeAndLockPages(locked[i].pMdl,KernelMode,IoModifyAccess); + /* Lock this allocation in memory */ + MmProbeAndLockPages(locked[i].pMdl,KernelMode,IoModifyAccess); - // Modify bits to grant user access, flag not cached - _PM_adjustPageTables((ulong)locked[i].linear, size, true, false); - return (void*)locked[i].linear; - } + /* Modify bits to grant user access, flag not cached */ + _PM_adjustPageTables((ulong)locked[i].linear, size, true, false); + return (void*)locked[i].linear; + } } /**************************************************************************** @@ -407,27 +407,27 @@ void PMAPI PM_freeLockedMem( /* Find a locked memory block in our table and free it */ for (i = 0; i < MAX_MEMORY_LOCKED; i++) { - if (locked[i].linear == p) { - // An Mdl indicates that we used the paged pool, and locked it, - // so now we have to unlock, free the MDL, and free paged - if (locked[i].pMdl) { - // Unlock what we locked and free the Mdl - MmUnlockPages(locked[i].pMdl); - IoFreeMdl(locked[i].pMdl); - ExFreePool(locked[i].linear); - } - else { - // TODO: Free the mmIoMap mapping for the memory! - - // Free non-paged pool - MmFreeContiguousMemory(locked[i].linear); - } - - // Flag that is entry is available - locked[i].linear = 0; - break; - } - } + if (locked[i].linear == p) { + /* An Mdl indicates that we used the paged pool, and locked it, */ + /* so now we have to unlock, free the MDL, and free paged */ + if (locked[i].pMdl) { + /* Unlock what we locked and free the Mdl */ + MmUnlockPages(locked[i].pMdl); + IoFreeMdl(locked[i].pMdl); + ExFreePool(locked[i].linear); + } + else { + /* TODO: Free the mmIoMap mapping for the memory! */ + + /* Free non-paged pool */ + MmFreeContiguousMemory(locked[i].linear); + } + + /* Flag that is entry is available */ + locked[i].linear = 0; + break; + } + } } /**************************************************************************** @@ -437,11 +437,11 @@ Allocates a page aligned and page sized block of memory void * PMAPI PM_allocPage( ibool locked) { - // Allocate the memory from the non-paged pool if we want the memory - // to be locked. + /* Allocate the memory from the non-paged pool if we want the memory */ + /* to be locked. */ return ExAllocatePool( - locked ? NonPagedPoolCacheAligned : PagedPoolCacheAligned, - PAGE_SIZE); + locked ? NonPagedPoolCacheAligned : PagedPoolCacheAligned, + PAGE_SIZE); } /**************************************************************************** @@ -465,11 +465,11 @@ int PMAPI PM_lockDataPages( { MDL *pMdl; - // Create a list to manage this allocation + /* Create a list to manage this allocation */ if ((pMdl = IoAllocateMdl(p,len,FALSE,FALSE,(PIRP)NULL)) == NULL) - return false; + return false; - // Lock this allocation in memory + /* Lock this allocation in memory */ MmProbeAndLockPages(pMdl,KernelMode,IoModifyAccess); *((PMDL*)(&lh->h)) = pMdl; return true; @@ -485,11 +485,11 @@ int PMAPI PM_unlockDataPages( PM_lockHandle *lh) { if (p && lh) { - // Unlock what we locked - MDL *pMdl = *((PMDL*)(&lh->h)); - MmUnlockPages(pMdl); - IoFreeMdl(pMdl); - } + /* Unlock what we locked */ + MDL *pMdl = *((PMDL*)(&lh->h)); + MmUnlockPages(pMdl); + IoFreeMdl(pMdl); + } return true; } @@ -516,4 +516,3 @@ int PMAPI PM_unlockCodePages( { return PM_unlockDataPages((void*)p,len,lh); } - diff --git a/board/MAI/bios_emulator/scitech/src/pm/ntdrv/oshdr.h b/board/MAI/bios_emulator/scitech/src/pm/ntdrv/oshdr.h index 3f747bb9cec..65b7bae23cf 100644 --- a/board/MAI/bios_emulator/scitech/src/pm/ntdrv/oshdr.h +++ b/board/MAI/bios_emulator/scitech/src/pm/ntdrv/oshdr.h @@ -42,5 +42,4 @@ UNICODE_STRING * _PM_CStringToUnicodeString(const char *cstr); void _PM_FreeUnicodeString(UNICODE_STRING *uniStr); -#endif // __NTDRV_OSHDR_H - +#endif /* __NTDRV_OSHDR_H */ diff --git a/board/MAI/bios_emulator/scitech/src/pm/ntdrv/pm.c b/board/MAI/bios_emulator/scitech/src/pm/ntdrv/pm.c index d4bbe228b72..c6606314c14 100644 --- a/board/MAI/bios_emulator/scitech/src/pm/ntdrv/pm.c +++ b/board/MAI/bios_emulator/scitech/src/pm/ntdrv/pm.c @@ -1,7 +1,7 @@ /**************************************************************************** * * SciTech OS Portability Manager Library -* +* * ======================================================================== * * The contents of this file are subject to the SciTech MGL Public @@ -88,9 +88,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'; + } } /**************************************************************************** @@ -116,25 +116,25 @@ void PMAPI PM_fatalError( ULONG len; if (fatalErrorCleanup) - fatalErrorCleanup(); + fatalErrorCleanup(); -#ifdef DBG // Send output to debugger, just return so as not to force a reboot -#pragma message("INFO: building for debug, PM_fatalError() re-routed") - DBGMSG2("SDDHELP> PM_fatalError(): ERROR: %s\n", msg); +#ifdef DBG /* Send output to debugger, just return so as not to force a reboot */ +#pragma message("INFO: building for debug, PM_fatalError() re-routed") + DBGMSG2("SDDHELP> PM_fatalError(): ERROR: %s\n", msg); return ; #endif - // KeBugCheckEx brings down the system in a controlled - // manner when the caller discovers an unrecoverable - // inconsistency that would corrupt the system if - // the caller continued to run. - // - // hack - dump the first 20 chars in hex using the variables - // provided - Each ULONG is equal to four characters... + /* KeBugCheckEx brings down the system in a controlled */ + /* manner when the caller discovers an unrecoverable */ + /* inconsistency that would corrupt the system if */ + /* the caller continued to run. */ + /* */ + /* hack - dump the first 20 chars in hex using the variables */ + /* provided - Each ULONG is equal to four characters... */ for(len = 0; len < 20; len++) - if (msg[len] == (char)0) - break; + if (msg[len] == (char)0) + break; - // This looks bad but it's quick and reliable... + /* This looks bad but it's quick and reliable... */ p = (char *)&BugCheckCode; if(len > 0) p[3] = msg[0]; if(len > 1) p[2] = msg[1]; @@ -165,7 +165,7 @@ void PMAPI PM_fatalError( if(len > 18) p[1] = msg[18]; if(len > 19) p[0] = msg[19]; - // Halt the system! + /* Halt the system! */ KeBugCheckEx(BugCheckCode, MoreBugCheckData[0], MoreBugCheckData[1], MoreBugCheckData[2], MoreBugCheckData[3]); } @@ -209,50 +209,50 @@ static ibool REG_queryString( STRING stringdata; UNICODE_STRING unidata; - // Convert strings to UniCode + /* Convert strings to UniCode */ status = false; if ((uniKey = _PM_CStringToUnicodeString(szKey)) == NULL) - goto Exit; + goto Exit; if ((uniValue = _PM_CStringToUnicodeString(szValue)) == NULL) - goto Exit; + goto Exit; - // Open the key + /* Open the key */ InitializeObjectAttributes( &keyAttributes, - uniKey, - OBJ_CASE_INSENSITIVE, - NULL, - NULL ); + uniKey, + OBJ_CASE_INSENSITIVE, + NULL, + NULL ); rval = ZwOpenKey( &Handle, - KEY_ALL_ACCESS, - &keyAttributes ); + KEY_ALL_ACCESS, + &keyAttributes ); if (!NT_SUCCESS(rval)) - goto Exit; + goto Exit; - // Query the value + /* Query the value */ length = sizeof (KEY_VALUE_FULL_INFORMATION) - + size * sizeof(WCHAR); + + size * sizeof(WCHAR); if ((fullInfo = ExAllocatePool (PagedPool, length)) == NULL) - goto Exit; + goto Exit; RtlZeroMemory(fullInfo, length); rval = ZwQueryValueKey (Handle, - uniValue, - KeyValueFullInformation, - fullInfo, - length, - &length); + uniValue, + KeyValueFullInformation, + fullInfo, + length, + &length); if (NT_SUCCESS (rval)) { - // Create the UniCode string so we can convert it - unidata.Buffer = (PWCHAR)(((PCHAR)fullInfo) + fullInfo->DataOffset); - unidata.Length = (USHORT)fullInfo->DataLength; - unidata.MaximumLength = (USHORT)fullInfo->DataLength + sizeof(WCHAR); - - // Convert unicode univalue to ansi string. - rval = RtlUnicodeStringToAnsiString(&stringdata, &unidata, TRUE); - if (NT_SUCCESS(rval)) { - strcpy(value,stringdata.Buffer); - status = true; - } - } + /* Create the UniCode string so we can convert it */ + unidata.Buffer = (PWCHAR)(((PCHAR)fullInfo) + fullInfo->DataOffset); + unidata.Length = (USHORT)fullInfo->DataLength; + unidata.MaximumLength = (USHORT)fullInfo->DataLength + sizeof(WCHAR); + + /* Convert unicode univalue to ansi string. */ + rval = RtlUnicodeStringToAnsiString(&stringdata, &unidata, TRUE); + if (NT_SUCCESS(rval)) { + strcpy(value,stringdata.Buffer); + status = true; + } + } Exit: if (fullInfo) ExFreePool(fullInfo); @@ -269,7 +269,7 @@ char PMAPI PM_getBootDrive(void) { char path[256]; if (REG_queryString(szNTWindowsKey,szNTSystemRoot,path,sizeof(path))) - return 'c'; + return 'c'; return path[0]; } @@ -291,12 +291,12 @@ const char * PMAPI PM_getNucleusPath(void) static char path[256]; if (strlen(_PM_nucleusPath) > 0) { - strcpy(path,_PM_nucleusPath); - PM_backslash(path); - return path; - } + strcpy(path,_PM_nucleusPath); + PM_backslash(path); + return path; + } if (!REG_queryString(szNTWindowsKey,szNTSystemRoot,path,sizeof(path))) - strcpy(path,"c:\\winnt"); + strcpy(path,"c:\\winnt"); PM_backslash(path); strcat(path,"system32\\nucleus"); return path; @@ -333,9 +333,9 @@ const char * PMAPI PM_getMachineName(void) static char name[256]; if (REG_queryString(szMachineNameKey,szMachineName,name,sizeof(name))) - return name; + return name; if (REG_queryString(szMachineNameKeyNT,szMachineName,name,sizeof(name))) - return name; + return name; return "Unknown"; } @@ -345,7 +345,7 @@ Check if a key has been pressed. ****************************************************************************/ int PMAPI PM_kbhit(void) { - // Not used in NT drivers + /* Not used in NT drivers */ return true; } @@ -355,7 +355,7 @@ Wait for and return the next keypress. ****************************************************************************/ int PMAPI PM_getch(void) { - // Not used in NT drivers + /* Not used in NT drivers */ return 0xD; } @@ -372,7 +372,7 @@ PM_HWND PMAPI PM_openConsole( int bpp, ibool fullScreen) { - // Not used in NT drivers + /* Not used in NT drivers */ (void)hwndUser; (void)device; (void)xRes; @@ -388,7 +388,7 @@ Find the size of the console state buffer. ****************************************************************************/ int PMAPI PM_getConsoleStateSize(void) { - // Not used in NT drivers + /* Not used in NT drivers */ return 1; } @@ -400,7 +400,7 @@ void PMAPI PM_saveConsoleState( void *stateBuf, PM_HWND hwndConsole) { - // Not used in NT drivers + /* Not used in NT drivers */ (void)stateBuf; (void)hwndConsole; } @@ -412,7 +412,7 @@ Set the suspend application callback for the fullscreen console. void PMAPI PM_setSuspendAppCallback( PM_saveState_cb saveState) { - // Not used in NT drivers + /* Not used in NT drivers */ (void)saveState; } @@ -424,7 +424,7 @@ void PMAPI PM_restoreConsoleState( const void *stateBuf, PM_HWND hwndConsole) { - // Not used in NT drivers + /* Not used in NT drivers */ (void)stateBuf; (void)hwndConsole; } @@ -436,7 +436,7 @@ Close the fullscreen console. void PMAPI PM_closeConsole( PM_HWND hwndConsole) { - // Not used in NT drivers + /* Not used in NT drivers */ (void)hwndConsole; } @@ -475,7 +475,7 @@ void * PMAPI PM_mapToProcess( void *base, ulong limit) { - // Not used anymore + /* Not used anymore */ (void)base; (void)limit; return NULL; @@ -491,7 +491,7 @@ ibool PMAPI PM_doBIOSPOST( void *mappedBIOS, ulong BIOSLen) { - // This may not be possible in NT and should be done by the OS anyway + /* This may not be possible in NT and should be done by the OS anyway */ (void)axVal; (void)BIOSPhysAddr; (void)mappedBIOS; @@ -505,7 +505,7 @@ Return a pointer to the real mode BIOS data area. ****************************************************************************/ void * PMAPI PM_getBIOSPointer(void) { - // Note that on NT this probably does not do what we expect! + /* Note that on NT this probably does not do what we expect! */ return PM_mapPhysicalAddr(0x400, 0x1000, true); } @@ -525,7 +525,7 @@ Sleep for the specified number of milliseconds. void PMAPI PM_sleep( ulong milliseconds) { - // We never use this in NT drivers + /* We never use this in NT drivers */ (void)milliseconds; } @@ -535,14 +535,14 @@ Return the base I/O port for the specified COM port. ****************************************************************************/ int PMAPI PM_getCOMPort(int port) { - // TODO: Re-code this to determine real values using the Plug and Play - // manager for the OS. + /* TODO: Re-code this to determine real values using the Plug and Play */ + /* manager for the OS. */ switch (port) { - case 0: return 0x3F8; - case 1: return 0x2F8; - case 2: return 0x3E8; - case 3: return 0x2E8; - } + case 0: return 0x3F8; + case 1: return 0x2F8; + case 2: return 0x3E8; + case 3: return 0x2E8; + } return 0; } @@ -552,13 +552,13 @@ Return the base I/O port for the specified LPT port. ****************************************************************************/ int PMAPI PM_getLPTPort(int port) { - // TODO: Re-code this to determine real values using the Plug and Play - // manager for the OS. + /* TODO: Re-code this to determine real values using the Plug and Play */ + /* manager for the OS. */ 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; } @@ -580,7 +580,7 @@ OS specific shared libraries not supported inside a VxD PM_MODULE PMAPI PM_loadLibrary( const char *szDLLName) { - // Not used in NT drivers + /* Not used in NT drivers */ (void)szDLLName; return NULL; } @@ -593,7 +593,7 @@ void * PMAPI PM_getProcAddress( PM_MODULE hModule, const char *szProcName) { - // Not used in NT drivers + /* Not used in NT drivers */ (void)hModule; (void)szProcName; return NULL; @@ -606,7 +606,7 @@ OS specific shared libraries not supported inside a VxD void PMAPI PM_freeLibrary( PM_MODULE hModule) { - // Not used in NT drivers + /* Not used in NT drivers */ (void)hModule; } @@ -618,9 +618,9 @@ void *PMAPI PM_findFirstFile( const char *filename, PM_findData *findData) { - // TODO: This function should start a directory enumeration search - // given the filename (with wildcards). The data should be - // converted and returned in the findData standard form. + /* TODO: This function should start a directory enumeration search */ + /* given the filename (with wildcards). The data should be */ + /* converted and returned in the findData standard form. */ (void)filename; (void)findData; return PM_FILE_INVALID; @@ -634,10 +634,10 @@ ibool PMAPI PM_findNextFile( void *handle, PM_findData *findData) { - // TODO: This function should find the next file in directory enumeration - // search given the search criteria defined in the call to - // PM_findFirstFile. The data should be converted and returned - // in the findData standard form. + /* TODO: This function should find the next file in directory enumeration */ + /* search given the search criteria defined in the call to */ + /* PM_findFirstFile. The data should be converted and returned */ + /* in the findData standard form. */ (void)handle; (void)findData; return false; @@ -650,8 +650,8 @@ Function to close the find process void PMAPI PM_findClose( void *handle) { - // TODO: This function should close the find process. This may do - // nothing for some OS'es. + /* TODO: This function should close the find process. This may do */ + /* nothing for some OS'es. */ (void)handle; } @@ -671,7 +671,7 @@ numbering is: ibool PMAPI PM_driveValid( char drive) { - // Not supported in NT drivers + /* Not supported in NT drivers */ (void)drive; return false; } @@ -687,7 +687,7 @@ void PMAPI PM_getdcwd( char *dir, int len) { - // Not supported in NT drivers + /* Not supported in NT drivers */ (void)drive; (void)dir; (void)len; @@ -733,67 +733,67 @@ void PMAPI PM_setFileAttr( char kernelFilename[PM_MAX_PATH+5]; ULONG FileAttributes = 0; - // Convert file attribute flags + /* Convert file attribute flags */ if (attrib & PM_FILE_READONLY) - FileAttributes |= FILE_ATTRIBUTE_READONLY; + FileAttributes |= FILE_ATTRIBUTE_READONLY; if (attrib & PM_FILE_ARCHIVE) - FileAttributes |= FILE_ATTRIBUTE_ARCHIVE; + FileAttributes |= FILE_ATTRIBUTE_ARCHIVE; if (attrib & PM_FILE_HIDDEN) - FileAttributes |= FILE_ATTRIBUTE_HIDDEN; + FileAttributes |= FILE_ATTRIBUTE_HIDDEN; if (attrib & PM_FILE_SYSTEM) - FileAttributes |= FILE_ATTRIBUTE_SYSTEM; + FileAttributes |= FILE_ATTRIBUTE_SYSTEM; - // Add prefix for addressing the file system. "\??\" is short for "\DosDevices\" + /* Add prefix for addressing the file system. "\??\" is short for "\DosDevices\" */ strcpy(kernelFilename, "\\??\\"); strcat(kernelFilename, filename); - // Convert filename string to ansi string + /* Convert filename string to ansi string */ if ((uniFile = _PM_CStringToUnicodeString(kernelFilename)) == NULL) - goto Exit; + goto Exit; - // Must open a file to query it's attributes + /* Must open a file to query it's attributes */ InitializeObjectAttributes (&ObjectAttributes, - uniFile, - OBJ_CASE_INSENSITIVE, - NULL, - NULL ); + uniFile, + OBJ_CASE_INSENSITIVE, + NULL, + NULL ); status = ZwCreateFile( &FileHandle, - DesiredAccess | SYNCHRONIZE, - &ObjectAttributes, - &IoStatusBlock, - NULL, //AllocationSize OPTIONAL, - FILE_ATTRIBUTE_NORMAL, - ShareAccess, - CreateDisposition, - FILE_RANDOM_ACCESS, //CreateOptions, - NULL, //EaBuffer OPTIONAL, - 0 //EaLength (required if EaBuffer) - ); + DesiredAccess | SYNCHRONIZE, + &ObjectAttributes, + &IoStatusBlock, + NULL, /*AllocationSize OPTIONAL, */ + FILE_ATTRIBUTE_NORMAL, + ShareAccess, + CreateDisposition, + FILE_RANDOM_ACCESS, /*CreateOptions, */ + NULL, /*EaBuffer OPTIONAL, */ + 0 /*EaLength (required if EaBuffer) */ + ); if (!NT_SUCCESS (status)) - goto Exit; + goto Exit; - // Query timestamps + /* Query timestamps */ status = ZwQueryInformationFile(FileHandle, - &IoStatusBlock, - &FileBasic, - sizeof(FILE_BASIC_INFORMATION), - FileBasicInformation - ); + &IoStatusBlock, + &FileBasic, + sizeof(FILE_BASIC_INFORMATION), + FileBasicInformation + ); if (!NT_SUCCESS (status)) - goto Exit; + goto Exit; - // Change the four bits we change + /* Change the four bits we change */ FileBasic.FileAttributes &= ~(FILE_ATTRIBUTE_READONLY | FILE_ATTRIBUTE_ARCHIVE - | FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_SYSTEM); + | FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_SYSTEM); FileBasic.FileAttributes |= FileAttributes; - // Set timestamps + /* Set timestamps */ ZwSetInformationFile( FileHandle, - &IoStatusBlock, - &FileBasic, - sizeof(FILE_BASIC_INFORMATION), - FileBasicInformation - ); + &IoStatusBlock, + &FileBasic, + sizeof(FILE_BASIC_INFORMATION), + FileBasicInformation + ); Exit: if (FileHandle) ZwClose(FileHandle); @@ -821,54 +821,54 @@ uint PMAPI PM_getFileAttr( ULONG FileAttributes = 0; uint retval = 0; - // Add prefix for addressing the file system. "\??\" is short for "\DosDevices\" + /* Add prefix for addressing the file system. "\??\" is short for "\DosDevices\" */ strcpy(kernelFilename, "\\??\\"); strcat(kernelFilename, filename); - // Convert filename string to ansi string + /* Convert filename string to ansi string */ if ((uniFile = _PM_CStringToUnicodeString(kernelFilename)) == NULL) - goto Exit; + goto Exit; - // Must open a file to query it's attributes + /* Must open a file to query it's attributes */ InitializeObjectAttributes (&ObjectAttributes, - uniFile, - OBJ_CASE_INSENSITIVE, - NULL, - NULL ); + uniFile, + OBJ_CASE_INSENSITIVE, + NULL, + NULL ); status = ZwCreateFile( &FileHandle, - DesiredAccess | SYNCHRONIZE, - &ObjectAttributes, - &IoStatusBlock, - NULL, //AllocationSize OPTIONAL, - FILE_ATTRIBUTE_NORMAL, - ShareAccess, - CreateDisposition, - FILE_RANDOM_ACCESS, //CreateOptions, - NULL, //EaBuffer OPTIONAL, - 0 //EaLength (required if EaBuffer) - ); + DesiredAccess | SYNCHRONIZE, + &ObjectAttributes, + &IoStatusBlock, + NULL, /*AllocationSize OPTIONAL, */ + FILE_ATTRIBUTE_NORMAL, + ShareAccess, + CreateDisposition, + FILE_RANDOM_ACCESS, /*CreateOptions, */ + NULL, /*EaBuffer OPTIONAL, */ + 0 /*EaLength (required if EaBuffer) */ + ); if (!NT_SUCCESS (status)) - goto Exit; + goto Exit; - // Query timestamps + /* Query timestamps */ status = ZwQueryInformationFile(FileHandle, - &IoStatusBlock, - &FileBasic, - sizeof(FILE_BASIC_INFORMATION), - FileBasicInformation - ); + &IoStatusBlock, + &FileBasic, + sizeof(FILE_BASIC_INFORMATION), + FileBasicInformation + ); if (!NT_SUCCESS (status)) - goto Exit; + goto Exit; - // Translate the file attributes + /* Translate the file attributes */ if (FileBasic.FileAttributes & FILE_ATTRIBUTE_READONLY) - retval |= PM_FILE_READONLY; + retval |= PM_FILE_READONLY; if (FileBasic.FileAttributes & FILE_ATTRIBUTE_ARCHIVE) - retval |= PM_FILE_ARCHIVE; + retval |= PM_FILE_ARCHIVE; if (FileBasic.FileAttributes & FILE_ATTRIBUTE_HIDDEN) - retval |= PM_FILE_HIDDEN; + retval |= PM_FILE_HIDDEN; if (FileBasic.FileAttributes & FILE_ATTRIBUTE_SYSTEM) - retval |= PM_FILE_SYSTEM; + retval |= PM_FILE_SYSTEM; Exit: if (FileHandle) ZwClose(FileHandle); @@ -883,7 +883,7 @@ Function to create a directory. ibool PMAPI PM_mkdir( const char *filename) { - // Not supported in NT drivers + /* Not supported in NT drivers */ (void)filename; return false; } @@ -895,7 +895,7 @@ Function to remove a directory. ibool PMAPI PM_rmdir( const char *filename) { - // Not supported in NT drivers + /* Not supported in NT drivers */ (void)filename; return false; } @@ -909,7 +909,7 @@ ibool PMAPI PM_getFileTime( ibool gmTime, PM_time *time) { - // Not supported in NT drivers + /* Not supported in NT drivers */ (void)filename; (void)gmTime; (void)time; @@ -925,10 +925,9 @@ ibool PMAPI PM_setFileTime( ibool gmTime, PM_time *time) { - // Not supported in NT drivers + /* Not supported in NT drivers */ (void)filename; (void)gmTime; (void)time; return false; } - diff --git a/board/MAI/bios_emulator/scitech/src/pm/ntdrv/stdio.c b/board/MAI/bios_emulator/scitech/src/pm/ntdrv/stdio.c index 856215206ff..658f1c80ab3 100644 --- a/board/MAI/bios_emulator/scitech/src/pm/ntdrv/stdio.c +++ b/board/MAI/bios_emulator/scitech/src/pm/ntdrv/stdio.c @@ -42,7 +42,7 @@ FILE * fopen( const char *filename, const char *mode) { - ACCESS_MASK DesiredAccess; // for ZwCreateFile... + ACCESS_MASK DesiredAccess; /* for ZwCreateFile... */ OBJECT_ATTRIBUTES ObjectAttributes; ULONG ShareAccess; ULONG CreateDisposition; @@ -56,86 +56,86 @@ FILE * fopen( char kernelFilename[PM_MAX_PATH+5]; FILE *f; - // Add prefix for addressing the file system. "\??\" is short for "\DosDevices\" + /* Add prefix for addressing the file system. "\??\" is short for "\DosDevices\" */ strcpy(kernelFilename, "\\??\\"); strcat(kernelFilename, filename); if ((f = PM_malloc(sizeof(FILE))) == NULL) - goto Error; + goto Error; f->offset = 0; f->text = (mode[1] == 't' || mode[2] == 't'); f->writemode = (mode[0] == 'w') || (mode[0] == 'a'); if (mode[0] == 'r') { - // omode = OPEN_ACCESS_READONLY | OPEN_SHARE_COMPATIBLE; - // action = ACTION_IFEXISTS_OPEN | ACTION_IFNOTEXISTS_FAIL; - DesiredAccess = GENERIC_READ; - ShareAccess = FILE_SHARE_READ | FILE_SHARE_WRITE; - CreateDisposition = FILE_OPEN; - } + /* omode = OPEN_ACCESS_READONLY | OPEN_SHARE_COMPATIBLE; */ + /* action = ACTION_IFEXISTS_OPEN | ACTION_IFNOTEXISTS_FAIL; */ + DesiredAccess = GENERIC_READ; + ShareAccess = FILE_SHARE_READ | FILE_SHARE_WRITE; + CreateDisposition = FILE_OPEN; + } else if (mode[0] == 'w') { - // omode = OPEN_ACCESS_WRITEONLY | OPEN_SHARE_COMPATIBLE; - // action = ACTION_IFEXISTS_TRUNCATE | ACTION_IFNOTEXISTS_CREATE; - DesiredAccess = GENERIC_WRITE; - ShareAccess = FILE_SHARE_READ | FILE_SHARE_WRITE; - CreateDisposition = FILE_SUPERSEDE; - } + /* omode = OPEN_ACCESS_WRITEONLY | OPEN_SHARE_COMPATIBLE; */ + /* action = ACTION_IFEXISTS_TRUNCATE | ACTION_IFNOTEXISTS_CREATE; */ + DesiredAccess = GENERIC_WRITE; + ShareAccess = FILE_SHARE_READ | FILE_SHARE_WRITE; + CreateDisposition = FILE_SUPERSEDE; + } else { - // omode = OPEN_ACCESS_READWRITE | OPEN_SHARE_COMPATIBLE; - // action = ACTION_IFEXISTS_OPEN | ACTION_IFNOTEXISTS_CREATE; - DesiredAccess = GENERIC_READ | GENERIC_WRITE; - ShareAccess = FILE_SHARE_READ; - CreateDisposition = FILE_OPEN_IF; - } + /* omode = OPEN_ACCESS_READWRITE | OPEN_SHARE_COMPATIBLE; */ + /* action = ACTION_IFEXISTS_OPEN | ACTION_IFNOTEXISTS_CREATE; */ + DesiredAccess = GENERIC_READ | GENERIC_WRITE; + ShareAccess = FILE_SHARE_READ; + CreateDisposition = FILE_OPEN_IF; + } - // Convert filename string to ansi string and then to UniCode string + /* Convert filename string to ansi string and then to UniCode string */ if ((uniFile = _PM_CStringToUnicodeString(kernelFilename)) == NULL) - return NULL; + return NULL; - // Create the file + /* Create the file */ InitializeObjectAttributes (&ObjectAttributes, - uniFile, - OBJ_CASE_INSENSITIVE, - NULL, - NULL); + uniFile, + OBJ_CASE_INSENSITIVE, + NULL, + NULL); status = ZwCreateFile( &FileHandle, - DesiredAccess | SYNCHRONIZE, - &ObjectAttributes, - &IoStatusBlock, - NULL, // AllocationSize OPTIONAL, - FILE_ATTRIBUTE_NORMAL, - ShareAccess, - CreateDisposition, - FILE_RANDOM_ACCESS, // CreateOptions, - NULL, // EaBuffer OPTIONAL, - 0 // EaLength (required if EaBuffer) - ); + DesiredAccess | SYNCHRONIZE, + &ObjectAttributes, + &IoStatusBlock, + NULL, /* AllocationSize OPTIONAL, */ + FILE_ATTRIBUTE_NORMAL, + ShareAccess, + CreateDisposition, + FILE_RANDOM_ACCESS, /* CreateOptions, */ + NULL, /* EaBuffer OPTIONAL, */ + 0 /* EaLength (required if EaBuffer) */ + ); if (!NT_SUCCESS (status)) - goto Error; + goto Error; f->handle = (int)FileHandle; - // Determine size of the file + /* Determine size of the file */ status = ZwQueryInformationFile( FileHandle, - &IoStatusBlock, - &FileInformation, - sizeof(FILE_STANDARD_INFORMATION), - FileStandardInformation - ); + &IoStatusBlock, + &FileInformation, + sizeof(FILE_STANDARD_INFORMATION), + FileStandardInformation + ); if (!NT_SUCCESS (status)) - goto Error; + goto Error; f->filesize = FileInformation.EndOfFile.LowPart; - // Move to the end of the file if we are appending + /* Move to the end of the file if we are appending */ if (mode[0] == 'a') { - FilePosition.CurrentByteOffset.HighPart = 0; - FilePosition.CurrentByteOffset.LowPart = f->filesize; - status = ZwSetInformationFile( FileHandle, - &IoStatusBlock, - &FilePosition, - sizeof(FILE_POSITION_INFORMATION), - FilePositionInformation - ); - if (!NT_SUCCESS (status)) - goto Error; - } + FilePosition.CurrentByteOffset.HighPart = 0; + FilePosition.CurrentByteOffset.LowPart = f->filesize; + status = ZwSetInformationFile( FileHandle, + &IoStatusBlock, + &FilePosition, + sizeof(FILE_POSITION_INFORMATION), + FilePositionInformation + ); + if (!NT_SUCCESS (status)) + goto Error; + } return f; Error: @@ -158,21 +158,21 @@ size_t fread( IO_STATUS_BLOCK IoStatusBlock; LARGE_INTEGER ByteOffset; - // Read any extra bytes from the file + /* Read any extra bytes from the file */ ByteOffset.HighPart = 0; ByteOffset.LowPart = f->offset; status = ZwReadFile( (HANDLE)f->handle, - NULL, //IN HANDLE Event OPTIONAL, - NULL, // IN PIO_APC_ROUTINE ApcRoutine OPTIONAL, - NULL, // IN PVOID ApcContext OPTIONAL, - &IoStatusBlock, - ptr, // OUT PVOID Buffer, - size * n, //IN ULONG Length, - &ByteOffset, //OPTIONAL, - NULL //IN PULONG Key OPTIONAL - ); + NULL, /*IN HANDLE Event OPTIONAL, */ + NULL, /* IN PIO_APC_ROUTINE ApcRoutine OPTIONAL, */ + NULL, /* IN PVOID ApcContext OPTIONAL, */ + &IoStatusBlock, + ptr, /* OUT PVOID Buffer, */ + size * n, /*IN ULONG Length, */ + &ByteOffset, /*OPTIONAL, */ + NULL /*IN PULONG Key OPTIONAL */ + ); if (!NT_SUCCESS (status)) - return 0; + return 0; f->offset += IoStatusBlock.Information; return IoStatusBlock.Information / size; } @@ -192,24 +192,24 @@ size_t fwrite( LARGE_INTEGER ByteOffset; if (!f->writemode) - return 0; + return 0; ByteOffset.HighPart = 0; ByteOffset.LowPart = f->offset; status = ZwWriteFile( (HANDLE)f->handle, - NULL, //IN HANDLE Event OPTIONAL, - NULL, // IN PIO_APC_ROUTINE ApcRoutine OPTIONAL, - NULL, // IN PVOID ApcContext OPTIONAL, - &IoStatusBlock, - (void*)ptr, // OUT PVOID Buffer, - size * n, //IN ULONG Length, - &ByteOffset, //OPTIONAL, - NULL //IN PULONG Key OPTIONAL - ); + NULL, /*IN HANDLE Event OPTIONAL, */ + NULL, /* IN PIO_APC_ROUTINE ApcRoutine OPTIONAL, */ + NULL, /* IN PVOID ApcContext OPTIONAL, */ + &IoStatusBlock, + (void*)ptr, /* OUT PVOID Buffer, */ + size * n, /*IN ULONG Length, */ + &ByteOffset, /*OPTIONAL, */ + NULL /*IN PULONG Key OPTIONAL */ + ); if (!NT_SUCCESS (status)) - return 0; + return 0; f->offset += IoStatusBlock.Information; if (f->offset > f->filesize) - f->filesize = f->offset; + f->filesize = f->offset; return IoStatusBlock.Information / size; } @@ -220,7 +220,7 @@ NT driver implementation of the ANSI C fflush function. int fflush( FILE *f) { - // Nothing to do here as we are not doing buffered I/O + /* Nothing to do here as we are not doing buffered I/O */ (void)f; return 0; } @@ -239,21 +239,21 @@ int fseek( IO_STATUS_BLOCK IoStatusBlock; if (whence == 0) - f->offset = offset; + f->offset = offset; else if (whence == 1) - f->offset += offset; + f->offset += offset; else if (whence == 2) - f->offset = f->filesize + offset; + f->offset = f->filesize + offset; FilePosition.CurrentByteOffset.HighPart = 0; FilePosition.CurrentByteOffset.LowPart = f->offset; status = ZwSetInformationFile( (HANDLE)f->handle, - &IoStatusBlock, - &FilePosition, - sizeof(FILE_POSITION_INFORMATION), - FilePositionInformation - ); + &IoStatusBlock, + &FilePosition, + sizeof(FILE_POSITION_INFORMATION), + FilePositionInformation + ); if (!NT_SUCCESS (status)) - return -1; + return -1; return 0; } @@ -289,19 +289,19 @@ char *fgets( int len; char *cs; - // Read the entire buffer into memory (our functions are unbuffered!) + /* Read the entire buffer into memory (our functions are unbuffered!) */ if ((len = fread(s,1,n,f)) == 0) - return NULL; + return NULL; - // Search for '\n' or end of string + /* Search for '\n' or end of string */ if (n > len) - n = len; + n = len; cs = s; while (--n > 0) { - if (*cs == '\n') - break; - cs++; - } + if (*cs == '\n') + break; + cs++; + } *cs = '\0'; return s; } @@ -328,4 +328,3 @@ int fclose( PM_free(f); return 0; } - diff --git a/board/MAI/bios_emulator/scitech/src/pm/ntdrv/stdlib.c b/board/MAI/bios_emulator/scitech/src/pm/ntdrv/stdlib.c index d7705130b73..bbf0cbf4a76 100644 --- a/board/MAI/bios_emulator/scitech/src/pm/ntdrv/stdlib.c +++ b/board/MAI/bios_emulator/scitech/src/pm/ntdrv/stdlib.c @@ -54,7 +54,7 @@ void * calloc( { void *p = PM_mallocShared(nelem * size); if (p) - memset(p,0,nelem * size); + memset(p,0,nelem * size); return p; } @@ -68,9 +68,9 @@ void * realloc( { void *p = PM_mallocShared(size); if (p) { - memcpy(p,ptr,size); - PM_freeShared(ptr); - } + memcpy(p,ptr,size); + PM_freeShared(ptr); + } return p; } @@ -102,21 +102,21 @@ UNICODE_STRING *_PM_CStringToUnicodeString( ANSI_STRING ansiStr; UNICODE_STRING *uniStr; - // Allocate memory for the string structure + /* Allocate memory for the string structure */ if ((uniStr = ExAllocatePool(NonPagedPool, sizeof(UNICODE_STRING))) == NULL) - return NULL; + return NULL; - // Allocate memory for the wide string itself + /* Allocate memory for the wide string itself */ length = (strlen(cstr) * sizeof(WCHAR)) + sizeof(WCHAR); if ((uniStr->Buffer = ExAllocatePool(NonPagedPool, length)) == NULL) { - ExFreePool(uniStr); - return NULL; - } + ExFreePool(uniStr); + return NULL; + } RtlZeroMemory(uniStr->Buffer, length); uniStr->Length = 0; uniStr->MaximumLength = (USHORT)length; - // Convert filename string to ansi string and then to UniCode string + /* Convert filename string to ansi string and then to UniCode string */ RtlInitAnsiString(&ansiStr, cstr); RtlAnsiStringToUnicodeString(uniStr, &ansiStr, FALSE); return uniStr; @@ -133,8 +133,7 @@ void _PM_FreeUnicodeString( UNICODE_STRING *uniStr) { if (uniStr) { - ExFreePool(uniStr->Buffer); - ExFreePool(uniStr); - } + ExFreePool(uniStr->Buffer); + ExFreePool(uniStr); + } } - diff --git a/board/MAI/bios_emulator/scitech/src/pm/ntdrv/ztimer.c b/board/MAI/bios_emulator/scitech/src/pm/ntdrv/ztimer.c index ef272941073..f4c4bd41b26 100644 --- a/board/MAI/bios_emulator/scitech/src/pm/ntdrv/ztimer.c +++ b/board/MAI/bios_emulator/scitech/src/pm/ntdrv/ztimer.c @@ -121,4 +121,3 @@ passed, so if this happens we will be generating erronous results. ****************************************************************************/ ulong __ULZElapsedTime(ulong start,ulong finish) { return finish - start; } - diff --git a/board/MAI/bios_emulator/scitech/src/pm/os2/event.c b/board/MAI/bios_emulator/scitech/src/pm/os2/event.c index 706e84d6f34..91cc19b915e 100644 --- a/board/MAI/bios_emulator/scitech/src/pm/os2/event.c +++ b/board/MAI/bios_emulator/scitech/src/pm/os2/event.c @@ -87,8 +87,8 @@ Converts a mickey movement value to a pixel adjustment value. static int MickeyToPixel( int mickey) { - // TODO: We can add some code in here to handle 'acceleration' for - // the mouse cursor. For now just use the mickeys. + /* TODO: We can add some code in here to handle 'acceleration' for */ + /* the mouse cursor. For now just use the mickeys. */ return mickey; } @@ -116,196 +116,196 @@ static void _EVT_pumpMessages(void) /* Pump all keyboard messages from our circular buffer */ for (;;) { - /* Check that the monitor thread is still running */ - if (!bMonRunning) - PM_fatalError("Keyboard monitor thread died!"); - - /* Protect keypacket buffer with mutex */ - DosRequestMutexSem(hmtxKeyBuf, SEM_INDEFINITE_WAIT); - if (kpHead == kpTail) { - DosReleaseMutexSem(hmtxKeyBuf); - break; - } - - noInput = FALSE; - - /* Read packet from circular buffer and remove it */ - memcpy(&kp, &keyMonPkts[kpTail], sizeof(KEYPACKET)); - if (++kpTail == KEYBUFSIZE) - kpTail = 0; - DosReleaseMutexSem(hmtxKeyBuf); - - /* Compensate for the 0xE0 character */ - if (kp.XlatedScan && kp.XlatedChar == 0xE0) - kp.XlatedChar = 0; - - /* Determine type of keyboard event */ - memset(&evt,0,sizeof(evt)); - if (kp.KbdDDFlagWord & KEY_RELEASE) - evt.what = EVT_KEYUP; - else - evt.what = EVT_KEYDOWN; - - /* Convert keyboard codes */ - scan = kp.MonFlagWord >> 8; - if (evt.what == EVT_KEYUP) { - /* Get message for keyup code from table of cached down values */ - evt.message = keyUpMsg[scan]; - keyUpMsg[scan] = 0; - oldKeyMessage = -1; - } - else { - evt.message = ((ulong)scan << 8) | kp.XlatedChar; - if (evt.message == keyUpMsg[scan]) { - evt.what = EVT_KEYREPEAT; - evt.message |= 0x10000; - } - oldKeyMessage = evt.message & 0x0FFFF; - keyUpMsg[scan] = (ushort)evt.message; - } - - /* Convert shift state modifiers */ - if (kp.u.ShiftState & 0x0001) - evt.modifiers |= EVT_RIGHTSHIFT; - if (kp.u.ShiftState & 0x0002) - evt.modifiers |= EVT_LEFTSHIFT; - if (kp.u.ShiftState & 0x0100) - evt.modifiers |= EVT_LEFTCTRL; - if (kp.u.ShiftState & 0x0200) - evt.modifiers |= EVT_LEFTALT; - if (kp.u.ShiftState & 0x0400) - evt.modifiers |= EVT_RIGHTCTRL; - if (kp.u.ShiftState & 0x0800) - evt.modifiers |= EVT_RIGHTALT; - EVT.oldMove = -1; - - /* Add time stamp and add the event to the queue */ - evt.when = key.time; - if (EVT.count < EVENTQSIZE) - addEvent(&evt); - } + /* Check that the monitor thread is still running */ + if (!bMonRunning) + PM_fatalError("Keyboard monitor thread died!"); + + /* Protect keypacket buffer with mutex */ + DosRequestMutexSem(hmtxKeyBuf, SEM_INDEFINITE_WAIT); + if (kpHead == kpTail) { + DosReleaseMutexSem(hmtxKeyBuf); + break; + } + + noInput = FALSE; + + /* Read packet from circular buffer and remove it */ + memcpy(&kp, &keyMonPkts[kpTail], sizeof(KEYPACKET)); + if (++kpTail == KEYBUFSIZE) + kpTail = 0; + DosReleaseMutexSem(hmtxKeyBuf); + + /* Compensate for the 0xE0 character */ + if (kp.XlatedScan && kp.XlatedChar == 0xE0) + kp.XlatedChar = 0; + + /* Determine type of keyboard event */ + memset(&evt,0,sizeof(evt)); + if (kp.KbdDDFlagWord & KEY_RELEASE) + evt.what = EVT_KEYUP; + else + evt.what = EVT_KEYDOWN; + + /* Convert keyboard codes */ + scan = kp.MonFlagWord >> 8; + if (evt.what == EVT_KEYUP) { + /* Get message for keyup code from table of cached down values */ + evt.message = keyUpMsg[scan]; + keyUpMsg[scan] = 0; + oldKeyMessage = -1; + } + else { + evt.message = ((ulong)scan << 8) | kp.XlatedChar; + if (evt.message == keyUpMsg[scan]) { + evt.what = EVT_KEYREPEAT; + evt.message |= 0x10000; + } + oldKeyMessage = evt.message & 0x0FFFF; + keyUpMsg[scan] = (ushort)evt.message; + } + + /* Convert shift state modifiers */ + if (kp.u.ShiftState & 0x0001) + evt.modifiers |= EVT_RIGHTSHIFT; + if (kp.u.ShiftState & 0x0002) + evt.modifiers |= EVT_LEFTSHIFT; + if (kp.u.ShiftState & 0x0100) + evt.modifiers |= EVT_LEFTCTRL; + if (kp.u.ShiftState & 0x0200) + evt.modifiers |= EVT_LEFTALT; + if (kp.u.ShiftState & 0x0400) + evt.modifiers |= EVT_RIGHTCTRL; + if (kp.u.ShiftState & 0x0800) + evt.modifiers |= EVT_RIGHTALT; + EVT.oldMove = -1; + + /* Add time stamp and add the event to the queue */ + evt.when = key.time; + if (EVT.count < EVENTQSIZE) + addEvent(&evt); + } /* Don't just flush because that terminally confuses the monitor */ do { - KbdCharIn(&key, IO_NOWAIT, 0); - } while (key.fbStatus & KBDTRF_FINAL_CHAR_IN); + KbdCharIn(&key, IO_NOWAIT, 0); + } while (key.fbStatus & KBDTRF_FINAL_CHAR_IN); /* Pump all mouse messages */ KbdGetStatus(&keyInfo,0); /* Check return code - mouse may not be operational!! */ if (MouGetNumQueEl(&mqueue,_EVT_hMouse) == NO_ERROR) { - while (mqueue.cEvents) { - while (mqueue.cEvents--) { - memset(&evt,0,sizeof(evt)); - mWait = MOU_NOWAIT; - MouReadEventQue(&mouse,&mWait,_EVT_hMouse); - - /* Update the mouse position. We get the mouse coordinates - * in mickeys so we have to translate these into pixels and - * move our mouse position. If we don't do this, OS/2 gives - * us the coordinates in character positions since it still - * thinks we are in text mode! - */ - EVT.mx += MickeyToPixel(mouse.col); - EVT.my += MickeyToPixel(mouse.row); - if (EVT.mx < 0) EVT.mx = 0; - if (EVT.my < 0) EVT.my = 0; - if (EVT.mx > rangeX) EVT.mx = rangeX; - if (EVT.my > rangeY) EVT.my = rangeY; - evt.where_x = EVT.mx; - evt.where_y = EVT.my; - evt.relative_x = mouse.col; - evt.relative_y = mouse.row; - evt.when = key.time; - if (mouse.fs & (MOUSE_BN1_DOWN | MOUSE_MOTION_WITH_BN1_DOWN)) - evt.modifiers |= EVT_LEFTBUT; - if (mouse.fs & (MOUSE_BN2_DOWN | MOUSE_MOTION_WITH_BN2_DOWN)) - evt.modifiers |= EVT_RIGHTBUT; - if (mouse.fs & (MOUSE_BN3_DOWN | MOUSE_MOTION_WITH_BN3_DOWN)) - evt.modifiers |= EVT_MIDDLEBUT; - if (keyInfo.fsState & 0x0001) - evt.modifiers |= EVT_RIGHTSHIFT; - if (keyInfo.fsState & 0x0002) - evt.modifiers |= EVT_LEFTSHIFT; - if (keyInfo.fsState & 0x0100) - evt.modifiers |= EVT_LEFTCTRL; - if (keyInfo.fsState & 0x0200) - evt.modifiers |= EVT_LEFTALT; - if (keyInfo.fsState & 0x0400) - evt.modifiers |= EVT_RIGHTCTRL; - if (keyInfo.fsState & 0x0800) - evt.modifiers |= EVT_RIGHTALT; - - /* Check for left mouse click events */ - /* 0x06 == (MOUSE_BN1_DOWN | MOUSE_MOTION_WITH_BN1_DOWN) */ - if (((mouse.fs & 0x0006) && !(oldMouseState & 0x0006)) - || (!(mouse.fs & 0x0006) && (oldMouseState & 0x0006))) { - if (mouse.fs & 0x0006) - evt.what = EVT_MOUSEDOWN; - else - evt.what = EVT_MOUSEUP; - evt.message = EVT_LEFTBMASK; - EVT.oldMove = -1; - if (EVT.count < EVENTQSIZE) - addEvent(&evt); - } - - /* Check for right mouse click events */ - /* 0x0018 == (MOUSE_BN2_DOWN | MOUSE_MOTION_WITH_BN2_DOWN) */ - if (((mouse.fs & 0x0018) && !(oldMouseState & 0x0018)) - || (!(mouse.fs & 0x0018) && (oldMouseState & 0x0018))) { - if (mouse.fs & 0x0018) - evt.what = EVT_MOUSEDOWN; - else - evt.what = EVT_MOUSEUP; - evt.message = EVT_RIGHTBMASK; - EVT.oldMove = -1; - if (EVT.count < EVENTQSIZE) - addEvent(&evt); - } - - /* Check for middle mouse click events */ - /* 0x0060 == (MOUSE_BN3_DOWN | MOUSE_MOTION_WITH_BN3_DOWN) */ - if (((mouse.fs & 0x0060) && !(oldMouseState & 0x0060)) - || (!(mouse.fs & 0x0060) && (oldMouseState & 0x0060))) { - if (mouse.fs & 0x0060) - evt.what = EVT_MOUSEDOWN; - else - evt.what = EVT_MOUSEUP; - evt.message = EVT_MIDDLEBMASK; - EVT.oldMove = -1; - if (EVT.count < EVENTQSIZE) - addEvent(&evt); - } - - /* Check for mouse movement event */ - if (mouse.fs & 0x002B) { - evt.what = EVT_MOUSEMOVE; - if (EVT.oldMove != -1) { - EVT.evtq[EVT.oldMove].where_x = evt.where_x;/* Modify existing one */ - EVT.evtq[EVT.oldMove].where_y = evt.where_y; - } - else { - EVT.oldMove = EVT.freeHead; /* Save id of this move event */ - if (EVT.count < EVENTQSIZE) - addEvent(&evt); - } - } - - /* Save current mouse state */ - oldMouseState = mouse.fs; - } - MouGetNumQueEl(&mqueue,_EVT_hMouse); - } - noInput = FALSE; - } + while (mqueue.cEvents) { + while (mqueue.cEvents--) { + memset(&evt,0,sizeof(evt)); + mWait = MOU_NOWAIT; + MouReadEventQue(&mouse,&mWait,_EVT_hMouse); + + /* Update the mouse position. We get the mouse coordinates + * in mickeys so we have to translate these into pixels and + * move our mouse position. If we don't do this, OS/2 gives + * us the coordinates in character positions since it still + * thinks we are in text mode! + */ + EVT.mx += MickeyToPixel(mouse.col); + EVT.my += MickeyToPixel(mouse.row); + if (EVT.mx < 0) EVT.mx = 0; + if (EVT.my < 0) EVT.my = 0; + if (EVT.mx > rangeX) EVT.mx = rangeX; + if (EVT.my > rangeY) EVT.my = rangeY; + evt.where_x = EVT.mx; + evt.where_y = EVT.my; + evt.relative_x = mouse.col; + evt.relative_y = mouse.row; + evt.when = key.time; + if (mouse.fs & (MOUSE_BN1_DOWN | MOUSE_MOTION_WITH_BN1_DOWN)) + evt.modifiers |= EVT_LEFTBUT; + if (mouse.fs & (MOUSE_BN2_DOWN | MOUSE_MOTION_WITH_BN2_DOWN)) + evt.modifiers |= EVT_RIGHTBUT; + if (mouse.fs & (MOUSE_BN3_DOWN | MOUSE_MOTION_WITH_BN3_DOWN)) + evt.modifiers |= EVT_MIDDLEBUT; + if (keyInfo.fsState & 0x0001) + evt.modifiers |= EVT_RIGHTSHIFT; + if (keyInfo.fsState & 0x0002) + evt.modifiers |= EVT_LEFTSHIFT; + if (keyInfo.fsState & 0x0100) + evt.modifiers |= EVT_LEFTCTRL; + if (keyInfo.fsState & 0x0200) + evt.modifiers |= EVT_LEFTALT; + if (keyInfo.fsState & 0x0400) + evt.modifiers |= EVT_RIGHTCTRL; + if (keyInfo.fsState & 0x0800) + evt.modifiers |= EVT_RIGHTALT; + + /* Check for left mouse click events */ + /* 0x06 == (MOUSE_BN1_DOWN | MOUSE_MOTION_WITH_BN1_DOWN) */ + if (((mouse.fs & 0x0006) && !(oldMouseState & 0x0006)) + || (!(mouse.fs & 0x0006) && (oldMouseState & 0x0006))) { + if (mouse.fs & 0x0006) + evt.what = EVT_MOUSEDOWN; + else + evt.what = EVT_MOUSEUP; + evt.message = EVT_LEFTBMASK; + EVT.oldMove = -1; + if (EVT.count < EVENTQSIZE) + addEvent(&evt); + } + + /* Check for right mouse click events */ + /* 0x0018 == (MOUSE_BN2_DOWN | MOUSE_MOTION_WITH_BN2_DOWN) */ + if (((mouse.fs & 0x0018) && !(oldMouseState & 0x0018)) + || (!(mouse.fs & 0x0018) && (oldMouseState & 0x0018))) { + if (mouse.fs & 0x0018) + evt.what = EVT_MOUSEDOWN; + else + evt.what = EVT_MOUSEUP; + evt.message = EVT_RIGHTBMASK; + EVT.oldMove = -1; + if (EVT.count < EVENTQSIZE) + addEvent(&evt); + } + + /* Check for middle mouse click events */ + /* 0x0060 == (MOUSE_BN3_DOWN | MOUSE_MOTION_WITH_BN3_DOWN) */ + if (((mouse.fs & 0x0060) && !(oldMouseState & 0x0060)) + || (!(mouse.fs & 0x0060) && (oldMouseState & 0x0060))) { + if (mouse.fs & 0x0060) + evt.what = EVT_MOUSEDOWN; + else + evt.what = EVT_MOUSEUP; + evt.message = EVT_MIDDLEBMASK; + EVT.oldMove = -1; + if (EVT.count < EVENTQSIZE) + addEvent(&evt); + } + + /* Check for mouse movement event */ + if (mouse.fs & 0x002B) { + evt.what = EVT_MOUSEMOVE; + if (EVT.oldMove != -1) { + EVT.evtq[EVT.oldMove].where_x = evt.where_x;/* Modify existing one */ + EVT.evtq[EVT.oldMove].where_y = evt.where_y; + } + else { + EVT.oldMove = EVT.freeHead; /* Save id of this move event */ + if (EVT.count < EVENTQSIZE) + addEvent(&evt); + } + } + + /* Save current mouse state */ + oldMouseState = mouse.fs; + } + MouGetNumQueEl(&mqueue,_EVT_hMouse); + } + noInput = FALSE; + } /* If there was no input available, give up the current timeslice * Note: DosSleep(0) will effectively do nothing if no other thread is ready. Hence * DosSleep(0) will still use 100% CPU _but_ should not interfere with other programs. */ if (noInput) - DosSleep(0); + DosSleep(0); } /**************************************************************************** @@ -341,78 +341,78 @@ static void _kbdMonThread( /* Register the buffers to be used for monitoring for current session */ if (DosMonReg(_EVT_hKbdMon, &monInbuf, (ULONG*)&monOutbuf,MONITOR_END, -1)) { - DosPostEventSem(hevStart); /* unblock the main thread */ - return; - } + DosPostEventSem(hevStart); /* unblock the main thread */ + return; + } /* Unblock the main thread and tell it we're OK*/ bMonRunning = TRUE; DosPostEventSem(hevStart); while (bMonRunning) { /* Start an endless loop */ - /* Read data from keyboard driver */ - rc = DosMonRead((PBYTE)&monInbuf, IO_WAIT, (PBYTE)&kp, (PUSHORT)&count); - if (rc) { + /* Read data from keyboard driver */ + rc = DosMonRead((PBYTE)&monInbuf, IO_WAIT, (PBYTE)&kp, (PUSHORT)&count); + if (rc) { #ifdef CHECKED - if (bMonRunning) - printf("Error in DosMonRead, rc = %ld\n", rc); + if (bMonRunning) + printf("Error in DosMonRead, rc = %ld\n", rc); #endif - bMonRunning = FALSE; - return; - } + bMonRunning = FALSE; + return; + } - /* Pass FLUSH packets immediately */ - if (kp.MonFlagWord & 4) { + /* Pass FLUSH packets immediately */ + if (kp.MonFlagWord & 4) { #ifdef CHECKED - printf("Flush packet!\n"); + printf("Flush packet!\n"); #endif - DosMonWrite((PBYTE)&monOutbuf, (PBYTE)&kp, count); - continue; - } - - //TODO: to be removed - /* Skip extended scancodes & some others */ - if (((kp.MonFlagWord >> 8) == 0xE0) || ((kp.KbdDDFlagWord & 0x0F) == 0x0F)) { - DosMonWrite((PBYTE)&monOutbuf, (PBYTE)&kp, count); - continue; - } - -// printf("RawScan = %X, XlatedScan = %X, fbStatus = %X, KbdDDFlags = %X\n", -// kp.MonFlagWord >> 8, kp.XlatedScan, kp.u.ShiftState, kp.KbdDDFlagWord); - - /* Protect access to buffer with mutex semaphore */ - rc = DosRequestMutexSem(hmtxKeyBuf, 1000); - if (rc) { + DosMonWrite((PBYTE)&monOutbuf, (PBYTE)&kp, count); + continue; + } + + /*TODO: to be removed */ + /* Skip extended scancodes & some others */ + if (((kp.MonFlagWord >> 8) == 0xE0) || ((kp.KbdDDFlagWord & 0x0F) == 0x0F)) { + DosMonWrite((PBYTE)&monOutbuf, (PBYTE)&kp, count); + continue; + } + +/* printf("RawScan = %X, XlatedScan = %X, fbStatus = %X, KbdDDFlags = %X\n", */ +/* kp.MonFlagWord >> 8, kp.XlatedScan, kp.u.ShiftState, kp.KbdDDFlagWord); */ + + /* Protect access to buffer with mutex semaphore */ + rc = DosRequestMutexSem(hmtxKeyBuf, 1000); + if (rc) { #ifdef CHECKED - printf("Can't get access to mutex, rc = %ld\n", rc); + printf("Can't get access to mutex, rc = %ld\n", rc); #endif - bMonRunning = FALSE; - return; - } - - /* Store packet in circular buffer, drop it if it's full */ - kpNew = kpHead + 1; - if (kpNew == KEYBUFSIZE) - kpNew = 0; - if (kpNew != kpTail) { - memcpy(&keyMonPkts[kpHead], &kp, sizeof(KEYPACKET)); - // TODO: fix this! - /* Convert break to make code */ - keyMonPkts[kpHead].MonFlagWord &= 0x7FFF; - kpHead = kpNew; - } - DosReleaseMutexSem(hmtxKeyBuf); - - /* Finally write the packet */ - rc = DosMonWrite((PBYTE)&monOutbuf, (PBYTE)&kp, count); - if (rc) { + bMonRunning = FALSE; + return; + } + + /* Store packet in circular buffer, drop it if it's full */ + kpNew = kpHead + 1; + if (kpNew == KEYBUFSIZE) + kpNew = 0; + if (kpNew != kpTail) { + memcpy(&keyMonPkts[kpHead], &kp, sizeof(KEYPACKET)); + /* TODO: fix this! */ + /* Convert break to make code */ + keyMonPkts[kpHead].MonFlagWord &= 0x7FFF; + kpHead = kpNew; + } + DosReleaseMutexSem(hmtxKeyBuf); + + /* Finally write the packet */ + rc = DosMonWrite((PBYTE)&monOutbuf, (PBYTE)&kp, count); + if (rc) { #ifdef CHECKED - if (bMonRunning) - printf("Error in DosMonWrite, rc = %ld\n", rc); + if (bMonRunning) + printf("Error in DosMonWrite, rc = %ld\n", rc); #endif - bMonRunning = FALSE; - return; - } - } + bMonRunning = FALSE; + return; + } + } (void)params; } @@ -461,15 +461,15 @@ void EVTAPI EVT_init( /* Open the keyboard monitor */ if (DosMonOpen((PSZ)"KBD$", &_EVT_hKbdMon)) - PM_fatalError("Unable to open keyboard monitor!"); + PM_fatalError("Unable to open keyboard monitor!"); /* Create event semaphore, the monitor will post it when it's initalized */ if (DosCreateEventSem(NULL, &hevStart, 0, FALSE)) - PM_fatalError("Unable to create event semaphore!"); + PM_fatalError("Unable to create event semaphore!"); /* Create mutex semaphore protecting the keypacket buffer */ if (DosCreateMutexSem(NULL, &hmtxKeyBuf, 0, FALSE)) - PM_fatalError("Unable to create mutex semaphore!"); + PM_fatalError("Unable to create mutex semaphore!"); /* Start keyboard monitor thread, use 32K stack */ kbdMonTID = _beginthread(_kbdMonThread, NULL, 0x8000, NULL); @@ -478,9 +478,9 @@ void EVTAPI EVT_init( /* Give the thread one second */ DosWaitEventSem(hevStart, 1000); if (!bMonRunning) { /* Check the thread is OK */ - DosMonClose(_EVT_hKbdMon); - PM_fatalError("Keyboard monitor thread didn't initialize!"); - } + DosMonClose(_EVT_hKbdMon); + PM_fatalError("Keyboard monitor thread didn't initialize!"); + } /* Catch program termination signals so we can clean up properly */ signal(SIGABRT, _EVT_abort); @@ -517,7 +517,7 @@ and this function can be used to resume it again later. ****************************************************************************/ void EVT_resume(void) { - // Do nothing for OS/2 + /* Do nothing for OS/2 */ } /**************************************************************************** @@ -527,7 +527,7 @@ de-install the event handling code. ****************************************************************************/ void EVT_suspend(void) { - // Do nothing for OS/2 + /* Do nothing for OS/2 */ } /**************************************************************************** @@ -551,16 +551,15 @@ void EVT_exit(void) rc = DosKillThread(kbdMonTID); #ifdef CHECKED if (rc) - printf("DosKillThread failed, rc = %ld\n", rc); + printf("DosKillThread failed, rc = %ld\n", rc); #endif rc = DosMonClose(_EVT_hKbdMon); #ifdef CHECKED if (rc) { - printf("DosMonClose failed, rc = %ld\n", rc); - } + printf("DosMonClose failed, rc = %ld\n", rc); + } #endif DosCloseEventSem(hevStart); DosCloseMutexSem(hmtxKeyBuf); KbdFlushBuffer(0); } - diff --git a/board/MAI/bios_emulator/scitech/src/pm/os2/mon.h b/board/MAI/bios_emulator/scitech/src/pm/os2/mon.h index 52f12f0d2dc..28d39fba4b1 100644 --- a/board/MAI/bios_emulator/scitech/src/pm/os2/mon.h +++ b/board/MAI/bios_emulator/scitech/src/pm/os2/mon.h @@ -63,55 +63,55 @@ typedef struct _MLNPACKET { USHORT KbdDDFlagWord; } MLNPACKET; -// DBCSStatus - -#define SF_SHIFTS 1 // If set to 1, shift status returned without a character -#define SF_NOTCHAR 2 // 0 - Scan code is a character - // 1 - Scan code is not a character; - // instead it is an extended key code from the keyboard. -#define SF_IMMEDIATE 32 // If set to 1, immediate conversion requested -#define SF_TYPEMASK 192 // Has the following values: - // 00 - Undefined - // 01 - Final character; interim character flag is turned off - // 10 - Interim character - // 11 - Final character; interim character flag is turned on. -// MonFlagWord - -#define MF_OPEN 1 // open -#define MF_CLOSE 2 // close -#define MF_FLUSH 4 // is flush packet - -// KbdDDFlagWord - -#define KF_NOTSQPACKET 1024 // Don't put this packet in SQ buffer -#define KF_ACCENTEDKEY 512 // Key was translated using previous accent. -#define KF_MULTIMAKE 256 // Key was repeated make of a toggle key. -#define KF_SECONDARYKEY 128 // Previous scan code was the E0 prefix code. -#define KF_KEYBREAK 64 // This is the break of the key. -#define KF_KEYTYPEMASK 63 // Isolates the Key Type field of DDFlags. -#define KF_UNDEFKEY 63 // Key packet is undefined -#define KF_SYSREQKEY 23 // This key packet is the SysReq key (4990) -#define KF_PRINTFLUSHKEY 22 // This packet is Ct-Alt-PrtScr -#define KF_PSPRINTECHOKEY 21 // This packet is Ctl-P -#define KF_PRINTECHOKEY 20 // This packet is Ctl-PrtScr -#define KF_PRTSCRKEY 19 // This packet is PrtScr -#define KF_PSBREAKKEY 18 // This packet is Ctl-C -#define KF_BREAKKEY 17 // This packet is Ctl-Break -#define KF_ACCENTKEY 16 // This packet is an accent key -#define KF_XRORPNOT 13 // This packet is a Read or Peek Notification Pct. -#define KF_MLNOTIFICATION 14 // packet is a Multi-Layer NLS packet -#define KF_HOTKEYPACKET 12 // This packet is the hot key. -#define KF_BADKEYCOMBO 11 // Accent/char combo undefined, beep only. -#define KF_WAKEUPKEY 10 // This packet is one following PAUSEKEY -#define KF_PSPAUSEKEY 9 // This packet is Ctl-S -#define KF_PAUSEKEY 8 // This packet is Ctl-Numlock or PAUSE -#define KF_SHIFTMASK 7 // Key is a shift Key -#define KF_DUMPKEY 6 // This packet is Ctl-Numlock-NumLock -#define KF_REBOOTKEY 5 // This packet is Ctl-Alt-Del -#define KF_RESENDCODE 4 // This packet is resend code from controller -#define KF_OVERRUNCODE 3 // This packet is overrun code from controller -#define KF_SECPREFIXCODE 2 // This packet is E0/E1 scan code -#define KF_ACKCODE 1 // This packet is ack code from keyboard +/* DBCSStatus */ + +#define SF_SHIFTS 1 /* If set to 1, shift status returned without a character */ +#define SF_NOTCHAR 2 /* 0 - Scan code is a character */ + /* 1 - Scan code is not a character; */ + /* instead it is an extended key code from the keyboard. */ +#define SF_IMMEDIATE 32 /* If set to 1, immediate conversion requested */ +#define SF_TYPEMASK 192 /* Has the following values: */ + /* 00 - Undefined */ + /* 01 - Final character; interim character flag is turned off */ + /* 10 - Interim character */ + /* 11 - Final character; interim character flag is turned on. */ +/* MonFlagWord */ + +#define MF_OPEN 1 /* open */ +#define MF_CLOSE 2 /* close */ +#define MF_FLUSH 4 /* is flush packet */ + +/* KbdDDFlagWord */ + +#define KF_NOTSQPACKET 1024 /* Don't put this packet in SQ buffer */ +#define KF_ACCENTEDKEY 512 /* Key was translated using previous accent. */ +#define KF_MULTIMAKE 256 /* Key was repeated make of a toggle key. */ +#define KF_SECONDARYKEY 128 /* Previous scan code was the E0 prefix code. */ +#define KF_KEYBREAK 64 /* This is the break of the key. */ +#define KF_KEYTYPEMASK 63 /* Isolates the Key Type field of DDFlags. */ +#define KF_UNDEFKEY 63 /* Key packet is undefined */ +#define KF_SYSREQKEY 23 /* This key packet is the SysReq key (4990) */ +#define KF_PRINTFLUSHKEY 22 /* This packet is Ct-Alt-PrtScr */ +#define KF_PSPRINTECHOKEY 21 /* This packet is Ctl-P */ +#define KF_PRINTECHOKEY 20 /* This packet is Ctl-PrtScr */ +#define KF_PRTSCRKEY 19 /* This packet is PrtScr */ +#define KF_PSBREAKKEY 18 /* This packet is Ctl-C */ +#define KF_BREAKKEY 17 /* This packet is Ctl-Break */ +#define KF_ACCENTKEY 16 /* This packet is an accent key */ +#define KF_XRORPNOT 13 /* This packet is a Read or Peek Notification Pct. */ +#define KF_MLNOTIFICATION 14 /* packet is a Multi-Layer NLS packet */ +#define KF_HOTKEYPACKET 12 /* This packet is the hot key. */ +#define KF_BADKEYCOMBO 11 /* Accent/char combo undefined, beep only. */ +#define KF_WAKEUPKEY 10 /* This packet is one following PAUSEKEY */ +#define KF_PSPAUSEKEY 9 /* This packet is Ctl-S */ +#define KF_PAUSEKEY 8 /* This packet is Ctl-Numlock or PAUSE */ +#define KF_SHIFTMASK 7 /* Key is a shift Key */ +#define KF_DUMPKEY 6 /* This packet is Ctl-Numlock-NumLock */ +#define KF_REBOOTKEY 5 /* This packet is Ctl-Alt-Del */ +#define KF_RESENDCODE 4 /* This packet is resend code from controller */ +#define KF_OVERRUNCODE 3 /* This packet is overrun code from controller */ +#define KF_SECPREFIXCODE 2 /* This packet is E0/E1 scan code */ +#define KF_ACKCODE 1 /* This packet is ack code from keyboard */ typedef struct _MONBUF { @@ -120,29 +120,29 @@ typedef struct _MONBUF { BYTE Reserved[20]; } MONBUF; -#define RS_SYSREG 32768 // Bit 15 SysReq key down -#define RS_CAPSLOCK 16384 // Bit 14 Caps Lock key down -#define RS_NUMLOCK 8192 // Bit 13 NumLock key down -#define RS_SCROLLLOCK 4096 // Bit 12 Scroll Lock key down -#define RS_RALT 2048 // Bit 11 Right Alt key down -#define RS_RCONTROL 1024 // Bit 10 Right Ctrl key down -#define RS_LALT 512 // Bit 9 Left Alt key down -#define RS_LCONTROL 256 // Bit 8 Left Ctrl key down -#define RS_INSERT 128 // Bit 7 Insert on -#define RS_CAPS 64 // Bit 6 Caps Lock on -#define RS_NUM 32 // Bit 5 NumLock on -#define RS_SCROLL 16 // Bit 4 Scroll Lock on -#define RS_ALT 8 // Bit 3 Either Alt key down -#define RS_CONTROL 4 // Bit 2 Either Ctrl key down -#define RS_LSHIFT 2 // Bit 1 Left Shift key down -#define RS_RSHIFT 1 // Bit 0 Right Shift key down - - -#define CS_RCONTROL 91 // Right Control -#define CS_LSHIFT 42 // Left Shift -#define CS_RSHIFT 54 // Right Shift -#define CS_LALT 56 // Left Alt -#define CS_RALT 94 // Right Alt +#define RS_SYSREG 32768 /* Bit 15 SysReq key down */ +#define RS_CAPSLOCK 16384 /* Bit 14 Caps Lock key down */ +#define RS_NUMLOCK 8192 /* Bit 13 NumLock key down */ +#define RS_SCROLLLOCK 4096 /* Bit 12 Scroll Lock key down */ +#define RS_RALT 2048 /* Bit 11 Right Alt key down */ +#define RS_RCONTROL 1024 /* Bit 10 Right Ctrl key down */ +#define RS_LALT 512 /* Bit 9 Left Alt key down */ +#define RS_LCONTROL 256 /* Bit 8 Left Ctrl key down */ +#define RS_INSERT 128 /* Bit 7 Insert on */ +#define RS_CAPS 64 /* Bit 6 Caps Lock on */ +#define RS_NUM 32 /* Bit 5 NumLock on */ +#define RS_SCROLL 16 /* Bit 4 Scroll Lock on */ +#define RS_ALT 8 /* Bit 3 Either Alt key down */ +#define RS_CONTROL 4 /* Bit 2 Either Ctrl key down */ +#define RS_LSHIFT 2 /* Bit 1 Left Shift key down */ +#define RS_RSHIFT 1 /* Bit 0 Right Shift key down */ + + +#define CS_RCONTROL 91 /* Right Control */ +#define CS_LSHIFT 42 /* Left Shift */ +#define CS_RSHIFT 54 /* Right Shift */ +#define CS_LALT 56 /* Left Alt */ +#define CS_RALT 94 /* Right Alt */ /* DosMon* prototypes */ diff --git a/board/MAI/bios_emulator/scitech/src/pm/os2/oshdr.h b/board/MAI/bios_emulator/scitech/src/pm/os2/oshdr.h index ae1f97a06c0..e7aa1c67643 100644 --- a/board/MAI/bios_emulator/scitech/src/pm/os2/oshdr.h +++ b/board/MAI/bios_emulator/scitech/src/pm/os2/oshdr.h @@ -39,4 +39,3 @@ #include "os2/mon.h" void __PM_checkConsoleSwitch(void); - diff --git a/board/MAI/bios_emulator/scitech/src/pm/os2/pm.c b/board/MAI/bios_emulator/scitech/src/pm/os2/pm.c index 50251028062..756eead1dd6 100644 --- a/board/MAI/bios_emulator/scitech/src/pm/os2/pm.c +++ b/board/MAI/bios_emulator/scitech/src/pm/os2/pm.c @@ -116,16 +116,16 @@ typedef struct _VIDEO_ADAPTER { /* PMIREQUEST_SOFTWAREINT structures from OS/2 DDK */ typedef struct { - ULONG ulFlags; // VDM initialization type -#define VDM_POSTLOAD 0x1 // adapter just loaded, used internally for initialization -#define VDM_INITIALIZE 0x2 // force initialization of a permanently open VDM, even if previously initialized -#define VDM_TERMINATE_POSTINITIALIZE 0x6 //start VDM with initialization, but close it afterwards (includes VDM_INITIALIZE) -#define VDM_QUERY_CAPABILITY 0x10 // query the current int 10 capability -#define VDM_FULL_VDM_CREATED 0x20 // a full VDM is created -#define VDM_MINI_VDM_CREATED 0x40 // a mini VDM is created -#define VDM_MINI_VDM_SUPPORTED 0x80 // mini VDM support is available - PCHAR szName; // VDM initialization program - PCHAR szArgs; // VDM initialization arguments + ULONG ulFlags; /* VDM initialization type */ +#define VDM_POSTLOAD 0x1 /* adapter just loaded, used internally for initialization */ +#define VDM_INITIALIZE 0x2 /* force initialization of a permanently open VDM, even if previously initialized */ +#define VDM_TERMINATE_POSTINITIALIZE 0x6 /*start VDM with initialization, but close it afterwards (includes VDM_INITIALIZE) */ +#define VDM_QUERY_CAPABILITY 0x10 /* query the current int 10 capability */ +#define VDM_FULL_VDM_CREATED 0x20 /* a full VDM is created */ +#define VDM_MINI_VDM_CREATED 0x40 /* a mini VDM is created */ +#define VDM_MINI_VDM_SUPPORTED 0x80 /* mini VDM support is available */ + PCHAR szName; /* VDM initialization program */ + PCHAR szArgs; /* VDM initialization arguments */ }INITVDM; typedef struct { @@ -218,7 +218,7 @@ typedef struct _SESWITCHREC { HEV Event; /* Posted after callback is called */ } SESWITCHREC; -// Page sized block cache +/* Page sized block cache */ #define PAGES_PER_BLOCK 32 #define PAGE_BLOCK_SIZE (PAGES_PER_BLOCK * PM_PAGE_SIZE + (PM_PAGE_SIZE-1) + sizeof(pageblock)) @@ -269,29 +269,29 @@ static ulong CallSDDHelp( ulong result; if ((rc = DosOpen(PMHELP_NAME,&hSDDHelp,&result,0,0, - FILE_OPEN, OPEN_SHARE_DENYNONE | OPEN_ACCESS_READWRITE, - NULL)) != 0) { - if (rc == 4) { /* Did we run out of file handles? */ - ULONG ulNewFHs; - LONG lAddFHs = 5; - - if (DosSetRelMaxFH(&lAddFHs, &ulNewFHs) != 0) - PM_fatalError("Failed to raise the file handles limit!"); - else { - if ((rc = DosOpen(PMHELP_NAME,&hSDDHelp,&result,0,0, - FILE_OPEN, OPEN_SHARE_DENYNONE | OPEN_ACCESS_READWRITE, - NULL)) != 0) { - PM_fatalError("Unable to open SDDHELP$ helper device driver! (#2)"); - } - } - } - else - PM_fatalError("Unable to open SDDHELP$ helper device driver!"); - } + FILE_OPEN, OPEN_SHARE_DENYNONE | OPEN_ACCESS_READWRITE, + NULL)) != 0) { + if (rc == 4) { /* Did we run out of file handles? */ + ULONG ulNewFHs; + LONG lAddFHs = 5; + + if (DosSetRelMaxFH(&lAddFHs, &ulNewFHs) != 0) + PM_fatalError("Failed to raise the file handles limit!"); + else { + if ((rc = DosOpen(PMHELP_NAME,&hSDDHelp,&result,0,0, + FILE_OPEN, OPEN_SHARE_DENYNONE | OPEN_ACCESS_READWRITE, + NULL)) != 0) { + PM_fatalError("Unable to open SDDHELP$ helper device driver! (#2)"); + } + } + } + else + PM_fatalError("Unable to open SDDHELP$ helper device driver!"); + } if (DosDevIOCtl(hSDDHelp,PMHELP_IOCTL,func, - &parmsIn, inLen = sizeof(parmsIn), &inLen, - &parmsOut, outLen = sizeof(parmsOut), &outLen) != 0) - PM_fatalError("Failure calling SDDHELP$ helper device driver!"); + &parmsIn, inLen = sizeof(parmsIn), &inLen, + &parmsOut, outLen = sizeof(parmsOut), &outLen) != 0) + PM_fatalError("Failure calling SDDHELP$ helper device driver!"); DosClose(hSDDHelp); return parmsOut[0]; } @@ -310,9 +310,9 @@ ibool __IsDBCSSystem(void) /* Get the DBCS vector - if it's not empty, we're on DBCS */ DosQueryDBCSEnv(sizeof(achDBCSInfo), &ccStruct, achDBCSInfo); if (achDBCSInfo[0] != 0) - return true; + return true; else - return false; + return false; } /**************************************************************************** @@ -324,9 +324,9 @@ ibool __isShellLoaded(void) PVOID ptr; if (DosGetNamedSharedMem(&ptr, (PSZ)"\\SHAREMEM\\PMGLOBAL.MEM", PAG_READ) == NO_ERROR) { - DosFreeMem(ptr); - return true; - } + DosFreeMem(ptr); + return true; + } return false; } @@ -339,19 +339,19 @@ message. void PMAPI PM_init(void) { if (!lowMem) { - /* Obtain the 32->16 callgate from the device driver to enable IOPL */ - if ((_PM_gdt = CallSDDHelp(PMHELP_GETGDT32)) == 0) - PM_fatalError("Unable to obtain call gate selector!"); + /* Obtain the 32->16 callgate from the device driver to enable IOPL */ + if ((_PM_gdt = CallSDDHelp(PMHELP_GETGDT32)) == 0) + PM_fatalError("Unable to obtain call gate selector!"); - PM_setIOPL(3); + PM_setIOPL(3); - /* Map the first Mb of physical memory into lowMem */ - if ((lowMem = PM_mapPhysicalAddr(0,0xFFFFF,true)) == NULL) - PM_fatalError("Unable to map first Mb physical memory!"); + /* Map the first Mb of physical memory into lowMem */ + if ((lowMem = PM_mapPhysicalAddr(0,0xFFFFF,true)) == NULL) + PM_fatalError("Unable to map first Mb physical memory!"); - /* Initialise the MTRR interface functions */ - MTRR_init(); - } + /* Initialise the MTRR interface functions */ + MTRR_init(); + } } /**************************************************************************** @@ -367,79 +367,79 @@ static ibool InitInt10(void) RESULTCODES resCodes; if (haveInt10 == -1) { - /* Connect to VIDEOPMI and get entry point. Note that we only - * do this if GENPMI or SDDPMI are already loaded, since we need - * a GRADD based driver for this to work. - */ - PM_init(); - haveInt10 = false; - if (DosQueryModuleHandle((PSZ)"GENPMI.DLL",&hModGENPMI) != 0) - hModGENPMI = NULLHANDLE; - if (DosQueryModuleHandle((PSZ)"SDDPMI.DLL",&hModSDDPMI) != 0) - hModSDDPMI = NULLHANDLE; - if (hModGENPMI || hModSDDPMI) { - if (DosLoadModule((PSZ)buf,sizeof(buf),(PSZ)"VIDEOPMI.DLL",&hModVideoPMI) == 0) { - if (DosQueryProcAddr(hModVideoPMI,0,(PSZ)"VIDEOPMI32Request",(void*)&PM_VIDEOPMI32Request) != 0) - PM_fatalError("Unable to get VIDEOPMI32Request entry point!"); - strcpy(path,"X:\\OS2\\SVGADATA.PMI"); - path[0] = PM_getBootDrive(); - if (PM_VIDEOPMI32Request(&Adapter,PMIREQUEST_LOADPMIFILE,path,NULL) != 0) { - DosFreeModule(hModVideoPMI); - PM_VIDEOPMI32Request = NULL; - haveInt10 = false; - } - else { - /* Attempt to initialise the full VDM in the system. This will only - * work if VPRPMI.SYS is loaded, but it provides support for passing - * values in ES/DS/ESI/EDI between the BIOS which does not work with - * kernel VDM's in fixpacks earlier than FP15. FP15 and later and - * the new Warp 4.51 and Warp Server convenience packs should work - * fine with the kernel mini-VDM. - * - * Also the full VDM is the only solution for really old kernels - * (but GRADD won't run on them so this is superfluous ;-). - */ - INITVDM InitVDM = {VDM_INITIALIZE,NULL,NULL}; - PM_VIDEOPMI32Request(&Adapter,PMIREQUEST_SOFTWAREINT,&InitVDM,NULL); - haveInt10 = true; - } - } - } - else { - /* A GRADD driver isn't loaded, hence we can't use VIDEOPMI. But we will try - * to access the mini-VDM directly, first verifying that the support is - * available in the kernel (it should be for kernels that support GRADD). - * This may be needed in a command line boot or if non-GRADD driver is - * used (Matrox or classic VGA). - * Note: because of problems with mini-VDM support in the kernel, we have to - * spawn a daemon process that will do the actual mini-VDM access for us. - */ - /* Try to open shared semaphore to see if our daemon is already up */ - if (DosOpenEventSem(SHAREDSEM, &hevDaemon) == NO_ERROR) { - if (DosWaitEventSem(hevDaemon, 1) == NO_ERROR) { - /* If semaphore is posted, all is well */ - useVPMI = false; - haveInt10 = true; - } - } - else { - /* Create shared event semaphore */ - if (DosCreateEventSem(SHAREDSEM, &hevDaemon, DC_SEM_SHARED, FALSE) == NO_ERROR) { - PM_findBPD(DAEMON_NAME, path); - strcat(path, DAEMON_NAME); - if (DosExecPgm(buf, sizeof(buf), EXEC_BACKGROUND, (PSZ)DAEMON_NAME, - NULL, &resCodes, (PSZ)path) == NO_ERROR) { - /* The daemon was successfully spawned, now give it a sec to come up */ - if (DosWaitEventSem(hevDaemon, 2000) == NO_ERROR) { - /* It's up! */ - useVPMI = false; - haveInt10 = true; - } - } - } - } - } - } + /* Connect to VIDEOPMI and get entry point. Note that we only + * do this if GENPMI or SDDPMI are already loaded, since we need + * a GRADD based driver for this to work. + */ + PM_init(); + haveInt10 = false; + if (DosQueryModuleHandle((PSZ)"GENPMI.DLL",&hModGENPMI) != 0) + hModGENPMI = NULLHANDLE; + if (DosQueryModuleHandle((PSZ)"SDDPMI.DLL",&hModSDDPMI) != 0) + hModSDDPMI = NULLHANDLE; + if (hModGENPMI || hModSDDPMI) { + if (DosLoadModule((PSZ)buf,sizeof(buf),(PSZ)"VIDEOPMI.DLL",&hModVideoPMI) == 0) { + if (DosQueryProcAddr(hModVideoPMI,0,(PSZ)"VIDEOPMI32Request",(void*)&PM_VIDEOPMI32Request) != 0) + PM_fatalError("Unable to get VIDEOPMI32Request entry point!"); + strcpy(path,"X:\\OS2\\SVGADATA.PMI"); + path[0] = PM_getBootDrive(); + if (PM_VIDEOPMI32Request(&Adapter,PMIREQUEST_LOADPMIFILE,path,NULL) != 0) { + DosFreeModule(hModVideoPMI); + PM_VIDEOPMI32Request = NULL; + haveInt10 = false; + } + else { + /* Attempt to initialise the full VDM in the system. This will only + * work if VPRPMI.SYS is loaded, but it provides support for passing + * values in ES/DS/ESI/EDI between the BIOS which does not work with + * kernel VDM's in fixpacks earlier than FP15. FP15 and later and + * the new Warp 4.51 and Warp Server convenience packs should work + * fine with the kernel mini-VDM. + * + * Also the full VDM is the only solution for really old kernels + * (but GRADD won't run on them so this is superfluous ;-). + */ + INITVDM InitVDM = {VDM_INITIALIZE,NULL,NULL}; + PM_VIDEOPMI32Request(&Adapter,PMIREQUEST_SOFTWAREINT,&InitVDM,NULL); + haveInt10 = true; + } + } + } + else { + /* A GRADD driver isn't loaded, hence we can't use VIDEOPMI. But we will try + * to access the mini-VDM directly, first verifying that the support is + * available in the kernel (it should be for kernels that support GRADD). + * This may be needed in a command line boot or if non-GRADD driver is + * used (Matrox or classic VGA). + * Note: because of problems with mini-VDM support in the kernel, we have to + * spawn a daemon process that will do the actual mini-VDM access for us. + */ + /* Try to open shared semaphore to see if our daemon is already up */ + if (DosOpenEventSem(SHAREDSEM, &hevDaemon) == NO_ERROR) { + if (DosWaitEventSem(hevDaemon, 1) == NO_ERROR) { + /* If semaphore is posted, all is well */ + useVPMI = false; + haveInt10 = true; + } + } + else { + /* Create shared event semaphore */ + if (DosCreateEventSem(SHAREDSEM, &hevDaemon, DC_SEM_SHARED, FALSE) == NO_ERROR) { + PM_findBPD(DAEMON_NAME, path); + strcat(path, DAEMON_NAME); + if (DosExecPgm(buf, sizeof(buf), EXEC_BACKGROUND, (PSZ)DAEMON_NAME, + NULL, &resCodes, (PSZ)path) == NO_ERROR) { + /* The daemon was successfully spawned, now give it a sec to come up */ + if (DosWaitEventSem(hevDaemon, 2000) == NO_ERROR) { + /* It's up! */ + useVPMI = false; + haveInt10 = true; + } + } + } + } + } + } return haveInt10; } @@ -480,9 +480,9 @@ void PMAPI PM_backslash( { uint pos = strlen(s); if (s[pos-1] != '\\') { - s[pos] = '\\'; - s[pos+1] = '\0'; - } + s[pos] = '\\'; + s[pos+1] = '\0'; + } } /**************************************************************************** @@ -505,9 +505,9 @@ void PMAPI PM_fatalError( /* Be prepare to be called recursively (failed to fail situation :-) */ static int fatalErrorCount = 0; if (fatalErrorCount++ == 0) { - if (fatalErrorCleanup) - fatalErrorCleanup(); - } + if (fatalErrorCleanup) + fatalErrorCleanup(); + } fprintf(stderr,"%s\n", msg); exit(1); } @@ -522,10 +522,10 @@ void * PMAPI PM_getVESABuf( 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; - } + /* Allocate a global buffer for communicating with the VESA VBE */ + if ((VESABuf_ptr = PM_allocRealSeg(VESABuf_len, &VESABuf_rseg, &VESABuf_roff)) == NULL) + return NULL; + } *len = VESABuf_len; *rseg = VESABuf_rseg; *roff = VESABuf_roff; @@ -632,11 +632,11 @@ void __PM_checkConsoleSwitch(void) /* Quick optimized path for most common case */ if (SesSwitchRec.Flags == -1) - return; + return; again: if (DosRequestMutexSem(SesSwitchRec.Mutex, 100)) - return; + return; Flags = SesSwitchRec.Flags; Callback = SesSwitchRec.Callback; SesSwitchRec.Flags = -1; @@ -647,15 +647,15 @@ again: isSessionSwitching = false; DosPostEventSem(SesSwitchRec.Event); if (Flags == PM_DEACTIVATE && Mode == PM_SUSPEND_APP) - /* Suspend application until we switch back to our application */ - for (;;) { - DosSleep (500); - /* SesSwitchRec.Flags is volatile so optimizer - * won't load it into a register - */ - if (SesSwitchRec.Flags != -1) - goto again; - } + /* Suspend application until we switch back to our application */ + for (;;) { + DosSleep (500); + /* SesSwitchRec.Flags is volatile so optimizer + * won't load it into a register + */ + if (SesSwitchRec.Flags != -1) + goto again; + } } /**************************************************************************** @@ -669,7 +669,7 @@ static void _PM_SessionSwitchEvent( ULONG Count; if (DosRequestMutexSem(SesSwitchRec.Mutex, 10000)) - return; + return; /* We're going to wait on that semaphore */ DosResetEventSem(SesSwitchRec.Event, &Count); @@ -692,10 +692,10 @@ static void _PM_ConsoleSwitch( USHORT NotifyType; for (;;) { - if (VioModeWait(VMWR_POPUP, &NotifyType, 0) != 0) - break; - _PM_SessionSwitchEvent(saveState, PM_REACTIVATE); - } + if (VioModeWait(VMWR_POPUP, &NotifyType, 0) != 0) + break; + _PM_SessionSwitchEvent(saveState, PM_REACTIVATE); + } VioModeUndo(UNDOI_RELEASEOWNER, UNDOK_ERRORCODE, (HVIO)0); } @@ -709,13 +709,13 @@ static void _PM_ConsolePopup( { USHORT NotifyType; for (;;) { - if (VioSavRedrawWait(VSRWI_SAVEANDREDRAW, &NotifyType, 0) != 0) - break; - if (NotifyType == VSRWN_SAVE) - _PM_SessionSwitchEvent(saveState, PM_DEACTIVATE); - else if (NotifyType == VSRWN_REDRAW) - _PM_SessionSwitchEvent(saveState, PM_REACTIVATE); - } + if (VioSavRedrawWait(VSRWI_SAVEANDREDRAW, &NotifyType, 0) != 0) + break; + if (NotifyType == VSRWN_SAVE) + _PM_SessionSwitchEvent(saveState, PM_DEACTIVATE); + else if (NotifyType == VSRWN_REDRAW) + _PM_SessionSwitchEvent(saveState, PM_REACTIVATE); + } VioSavRedrawUndo(UNDOI_RELEASEOWNER, UNDOK_ERRORCODE, (HVIO)0); } @@ -726,24 +726,24 @@ Set the suspend application callback for the fullscreen console. void PMAPI PM_setSuspendAppCallback( PM_saveState_cb saveState) { - // If PM isn't loaded, this stuff will cause crashes! + /* If PM isn't loaded, this stuff will cause crashes! */ if (__isShellLoaded()) { - if (saveState) { - /* Create the threads responsible for tracking console switches */ - SesSwitchRec.Flags = -1; - DosCreateMutexSem(NULL, &SesSwitchRec.Mutex, 0, FALSE); - DosCreateEventSem(NULL, &SesSwitchRec.Event, 0, FALSE); - _beginthread ((void(*)(void*))_PM_ConsoleSwitch,NULL,SESSION_SWITCH_STACK_SIZE, (void*)saveState); - _beginthread ((void(*)(void*))_PM_ConsolePopup,NULL,SESSION_SWITCH_STACK_SIZE, (void*)saveState); - } - else { - /* Kill the threads responsible for tracking console switches */ - VioModeUndo(UNDOI_RELEASEOWNER, UNDOK_TERMINATE, (HVIO)0); - VioSavRedrawUndo(UNDOI_RELEASEOWNER, UNDOK_TERMINATE, (HVIO)0); - DosCloseEventSem(SesSwitchRec.Event); - DosCloseMutexSem(SesSwitchRec.Mutex); - } - } + if (saveState) { + /* Create the threads responsible for tracking console switches */ + SesSwitchRec.Flags = -1; + DosCreateMutexSem(NULL, &SesSwitchRec.Mutex, 0, FALSE); + DosCreateEventSem(NULL, &SesSwitchRec.Event, 0, FALSE); + _beginthread ((void(*)(void*))_PM_ConsoleSwitch,NULL,SESSION_SWITCH_STACK_SIZE, (void*)saveState); + _beginthread ((void(*)(void*))_PM_ConsolePopup,NULL,SESSION_SWITCH_STACK_SIZE, (void*)saveState); + } + else { + /* Kill the threads responsible for tracking console switches */ + VioModeUndo(UNDOI_RELEASEOWNER, UNDOK_TERMINATE, (HVIO)0); + VioSavRedrawUndo(UNDOI_RELEASEOWNER, UNDOK_TERMINATE, (HVIO)0); + DosCloseEventSem(SesSwitchRec.Event); + DosCloseMutexSem(SesSwitchRec.Mutex); + } + } } /**************************************************************************** @@ -758,7 +758,7 @@ void PMAPI PM_restoreConsoleState( VIOMODEINFO vmi; if (!cs) - return; + return; memcpy(&vmi, &cs->vmi, sizeof (VIOMODEINFO)); VioSetMode(&vmi, (HVIO)0); @@ -789,7 +789,7 @@ void PM_setOSCursorLocation( /* If session switch is in progress, calling into VIO causes deadlocks! */ /* Also this call to VIO screws up our console library on DBCS boxes... */ if (!isSessionSwitching && !__IsDBCSSystem()) - VioSetCurPos(y,x,0); + VioSetCurPos(y,x,0); } /**************************************************************************** @@ -813,7 +813,7 @@ ibool PMAPI PM_setRealTimeClockHandler( PM_intHandler ih, int frequency) { - // TODO: Implement this! + /* TODO: Implement this! */ (void)ih; (void)frequency; return false; @@ -826,7 +826,7 @@ Set the real time clock frequency (for stereo modes). void PMAPI PM_setRealTimeClockFrequency( int frequency) { - // TODO: Implement this! + /* TODO: Implement this! */ (void)frequency; } @@ -836,7 +836,7 @@ Restore the original real time clock handler. ****************************************************************************/ void PMAPI PM_restoreRealTimeClockHandler(void) { - // TODO: Implement this! + /* TODO: Implement this! */ } /**************************************************************************** @@ -881,7 +881,7 @@ const char * PMAPI PM_getNucleusPath(void) { static char path[CCHMAXPATH]; if (getenv("NUCLEUS_PATH") != NULL) - return getenv("NUCLEUS_PATH"); + return getenv("NUCLEUS_PATH"); strcpy(path,"x:\\os2\\drivers"); path[0] = PM_getBootDrive(); PM_backslash(path); @@ -920,10 +920,10 @@ const char * PMAPI PM_getMachineName(void) static char name[40],*env; if ((env = getenv("HOSTNAME")) != NULL) { - strncpy(name,env,sizeof(name)); - name[sizeof(name)-1] = 0; - return name; - } + strncpy(name,env,sizeof(name)); + name[sizeof(name)-1] = 0; + return name; + } return "OS2"; } @@ -970,7 +970,7 @@ void * PMAPI PM_mapPhysicalAddr( parmsIn[1] = limit; parmsIn[2] = isCached; if ((linear = CallSDDHelp(PMHELP_MAPPHYS)) == 0) - return NULL; + return NULL; return (void*)(linear + baseOfs); } @@ -1031,9 +1031,9 @@ 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; } @@ -1045,10 +1045,10 @@ 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; } @@ -1112,7 +1112,7 @@ void * PMAPI PM_mapRealPointer( uint r_off) { if (r_seg == 0xFFFF) - return &RMBuf[r_off]; + return &RMBuf[r_off]; return lowMem + MK_PHYS(r_seg,r_off); } @@ -1126,7 +1126,7 @@ void * PMAPI PM_allocRealSeg( uint *r_off) { if (size > sizeof(RMBuf)) - return NULL; + return NULL; *r_seg = 0xFFFF; *r_off = 0x0000; return &RMBuf; @@ -1160,79 +1160,79 @@ void PMAPI DPMI_int86( ulong eax = 0; if (!InitInt10()) - return; + return; memset(&rmregs, 0, sizeof(rmregs)); rmregs.ulBIOSIntNo = intno; INDPMI(eax); INDPMI(ebx); INDPMI(ecx); INDPMI(edx); INDPMI(esi); INDPMI(edi); rmregs.aCRF.reg_ds = regs->ds; rmregs.aCRF.reg_es = regs->es; if (intno == 0x10) { - eax = rmregs.aCRF.reg_eax; - switch (eax & 0xFFFF) { - case 0x4F00: - /* We have to hack the way this function works, due to - * some bugs in the IBM mini-VDM BIOS support. Specifically - * we need to make the input buffer and output buffer the - * 'same' buffer, and that ES:SI points to the output - * buffer (ignored by the BIOS). The data will end up - * being returned in the input buffer, except for the - * first four bytes ('VESA') that will not be returned. - */ - rmregs.pB[0].bBufferType = INPUT_BUFFER; - rmregs.pB[0].bSelCRF = REG_OFFSET(reg_es); - rmregs.pB[0].bOffCRF = REG_OFFSET(reg_edi); - rmregs.pB[0].pAddress = RMBuf; - rmregs.pB[0].ulSize = 4; - rmregs.pB[1].bBufferType = OUTPUT_BUFFER; - rmregs.pB[1].bSelCRF = REG_OFFSET(reg_es); - rmregs.pB[1].bOffCRF = REG_OFFSET(reg_esi); - rmregs.pB[1].pAddress = ((PBYTE)RMBuf)+4; - rmregs.pB[1].ulSize = 512-4; - break; - case 0x4F01: - rmregs.pB[0].bBufferType = OUTPUT_BUFFER; - rmregs.pB[0].bSelCRF = REG_OFFSET(reg_es); - rmregs.pB[0].bOffCRF = REG_OFFSET(reg_edi); - rmregs.pB[0].pAddress = RMBuf; - rmregs.pB[0].ulSize = 256; - break; - case 0x4F02: - rmregs.pB[0].bBufferType = INPUT_BUFFER; - rmregs.pB[0].bSelCRF = REG_OFFSET(reg_es); - rmregs.pB[0].bOffCRF = REG_OFFSET(reg_edi); - rmregs.pB[0].pAddress = RMBuf; - rmregs.pB[0].ulSize = 256; - break; - case 0x4F09: - rmregs.pB[0].bBufferType = INPUT_BUFFER; - rmregs.pB[0].bSelCRF = REG_OFFSET(reg_es); - rmregs.pB[0].bOffCRF = REG_OFFSET(reg_edi); - rmregs.pB[0].pAddress = RMBuf; - rmregs.pB[0].ulSize = 1024; - break; - case 0x4F0A: - /* Due to bugs in the mini-VDM in OS/2, the 0x4F0A protected - * mode interface functions will not work (we never get any - * selectors returned), so we fail this function here. The - * rest of the VBE/Core driver will work properly if this - * function is failed, because the VBE 2.0 and 3.0 specs - * allow for this. - */ - regs->eax = 0x014F; - return; - } - } + eax = rmregs.aCRF.reg_eax; + switch (eax & 0xFFFF) { + case 0x4F00: + /* We have to hack the way this function works, due to + * some bugs in the IBM mini-VDM BIOS support. Specifically + * we need to make the input buffer and output buffer the + * 'same' buffer, and that ES:SI points to the output + * buffer (ignored by the BIOS). The data will end up + * being returned in the input buffer, except for the + * first four bytes ('VESA') that will not be returned. + */ + rmregs.pB[0].bBufferType = INPUT_BUFFER; + rmregs.pB[0].bSelCRF = REG_OFFSET(reg_es); + rmregs.pB[0].bOffCRF = REG_OFFSET(reg_edi); + rmregs.pB[0].pAddress = RMBuf; + rmregs.pB[0].ulSize = 4; + rmregs.pB[1].bBufferType = OUTPUT_BUFFER; + rmregs.pB[1].bSelCRF = REG_OFFSET(reg_es); + rmregs.pB[1].bOffCRF = REG_OFFSET(reg_esi); + rmregs.pB[1].pAddress = ((PBYTE)RMBuf)+4; + rmregs.pB[1].ulSize = 512-4; + break; + case 0x4F01: + rmregs.pB[0].bBufferType = OUTPUT_BUFFER; + rmregs.pB[0].bSelCRF = REG_OFFSET(reg_es); + rmregs.pB[0].bOffCRF = REG_OFFSET(reg_edi); + rmregs.pB[0].pAddress = RMBuf; + rmregs.pB[0].ulSize = 256; + break; + case 0x4F02: + rmregs.pB[0].bBufferType = INPUT_BUFFER; + rmregs.pB[0].bSelCRF = REG_OFFSET(reg_es); + rmregs.pB[0].bOffCRF = REG_OFFSET(reg_edi); + rmregs.pB[0].pAddress = RMBuf; + rmregs.pB[0].ulSize = 256; + break; + case 0x4F09: + rmregs.pB[0].bBufferType = INPUT_BUFFER; + rmregs.pB[0].bSelCRF = REG_OFFSET(reg_es); + rmregs.pB[0].bOffCRF = REG_OFFSET(reg_edi); + rmregs.pB[0].pAddress = RMBuf; + rmregs.pB[0].ulSize = 1024; + break; + case 0x4F0A: + /* Due to bugs in the mini-VDM in OS/2, the 0x4F0A protected + * mode interface functions will not work (we never get any + * selectors returned), so we fail this function here. The + * rest of the VBE/Core driver will work properly if this + * function is failed, because the VBE 2.0 and 3.0 specs + * allow for this. + */ + regs->eax = 0x014F; + return; + } + } if (useVPMI) - PM_VIDEOPMI32Request(&Adapter,PMIREQUEST_SOFTWAREINT,NULL,&rmregs); + PM_VIDEOPMI32Request(&Adapter,PMIREQUEST_SOFTWAREINT,NULL,&rmregs); else { - DosSysCtl(6, &rmregs); - } + DosSysCtl(6, &rmregs); + } OUTDPMI(eax); OUTDPMI(ebx); OUTDPMI(ecx); OUTDPMI(edx); OUTDPMI(esi); OUTDPMI(edi); if (((regs->eax & 0xFFFF) == 0x004F) && ((eax & 0xFFFF) == 0x4F00)) { - /* Hack to fix up the missing 'VESA' string for mini-VDM */ - memcpy(RMBuf,"VESA",4); - } + /* Hack to fix up the missing 'VESA' string for mini-VDM */ + memcpy(RMBuf,"VESA",4); + } regs->ds = rmregs.aCRF.reg_ds; regs->es = rmregs.aCRF.reg_es; regs->flags = rmregs.aCRF.reg_eflag; @@ -1354,13 +1354,13 @@ static pageblock *PM_addNewPageBlock(void) /* Allocate memory for the new page block, and add to head of list */ if (DosAllocSharedMem((void**)&newBlock,NULL,PAGE_BLOCK_SIZE,OBJ_GETTABLE | PAG_READ | PAG_WRITE | PAG_COMMIT)) - return NULL; + return NULL; if (!PM_lockDataPages(newBlock,PAGE_BLOCK_SIZE,&newBlock->lockHandle)) - return NULL; + return NULL; newBlock->prev = NULL; newBlock->next = pageBlocks; if (pageBlocks) - pageBlocks->prev = newBlock; + pageBlocks->prev = newBlock; pageBlocks = newBlock; /* Initialise the page aligned free list for the page block */ @@ -1369,7 +1369,7 @@ static pageblock *PM_addNewPageBlock(void) newBlock->freeListStart = newBlock->freeList; newBlock->freeListEnd = p + (PAGES_PER_BLOCK-1) * PM_PAGE_SIZE; for (i = 0; i < PAGES_PER_BLOCK; i++,p = next) - FREELIST_NEXT(p) = next = p + PM_PAGE_SIZE; + FREELIST_NEXT(p) = next = p + PM_PAGE_SIZE; FREELIST_NEXT(p - PM_PAGE_SIZE) = NULL; return newBlock; } @@ -1388,11 +1388,11 @@ void * PMAPI PM_allocPage( * page block if no free blocks are found. */ for (block = pageBlocks; block != NULL; block = block->next) { - if (block->freeCount) - break; - } + if (block->freeCount) + break; + } if (block == NULL && (block = PM_addNewPageBlock()) == NULL) - return NULL; + return NULL; block->freeCount--; p = block->freeList; block->freeList = FREELIST_NEXT(p); @@ -1411,36 +1411,36 @@ void PMAPI PM_freePage( /* First find the page block that this page belongs to */ for (block = pageBlocks; block != NULL; block = block->next) { - if (p >= block->freeListStart && p <= block->freeListEnd) - break; - } + if (p >= block->freeListStart && p <= block->freeListEnd) + break; + } CHECK(block != NULL); /* Now free the block by adding it to the free list */ FREELIST_NEXT(p) = block->freeList; block->freeList = p; if (++block->freeCount == PAGES_PER_BLOCK) { - /* If all pages in the page block are now free, free the entire - * page block itself. - */ - if (block == pageBlocks) { - /* Delete from head */ - pageBlocks = block->next; - if (block->next) - block->next->prev = NULL; - } - else { - /* Delete from middle of list */ - CHECK(block->prev != NULL); - block->prev->next = block->next; - if (block->next) - block->next->prev = block->prev; - } - - /* Unlock the memory and free it */ - PM_unlockDataPages(block,PAGE_BLOCK_SIZE,&block->lockHandle); - DosFreeMem(block); - } + /* If all pages in the page block are now free, free the entire + * page block itself. + */ + if (block == pageBlocks) { + /* Delete from head */ + pageBlocks = block->next; + if (block->next) + block->next->prev = NULL; + } + else { + /* Delete from middle of list */ + CHECK(block->prev != NULL); + block->prev->next = block->next; + if (block->next) + block->next->prev = block->prev; + } + + /* Unlock the memory and free it */ + PM_unlockDataPages(block,PAGE_BLOCK_SIZE,&block->lockHandle); + DosFreeMem(block); + } } /**************************************************************************** @@ -1453,8 +1453,8 @@ void PMAPI PM_mapSharedPages(void) /* Map all the page blocks above into the shared memory for process */ for (block = pageBlocks; block != NULL; block = block->next) { - DosGetSharedMem(block, PAG_READ | PAG_WRITE); - } + DosGetSharedMem(block, PAG_READ | PAG_WRITE); + } } /**************************************************************************** @@ -1533,7 +1533,7 @@ void PMAPI PM_setBankA( INTCRF rmregs; if (!InitInt10()) - return; + return; memset(&rmregs, 0, sizeof(rmregs)); rmregs.ulBIOSIntNo = 0x10; rmregs.aCRF.reg_eax = 0x4F05; @@ -1552,7 +1552,7 @@ void PMAPI PM_setBankAB( INTCRF rmregs; if (!InitInt10()) - return; + return; memset(&rmregs, 0, sizeof(rmregs)); rmregs.ulBIOSIntNo = 0x10; rmregs.aCRF.reg_eax = 0x4F05; @@ -1578,7 +1578,7 @@ void PMAPI PM_setCRTStart( INTCRF rmregs; if (!InitInt10()) - return; + return; memset(&rmregs, 0, sizeof(rmregs)); rmregs.ulBIOSIntNo = 0x10; rmregs.aCRF.reg_eax = 0x4F07; @@ -1625,8 +1625,8 @@ int PMAPI PM_enableWriteCombine( return MTRR_enableWriteCombine(base,size,type); } -// TODO: Move the MTRR helper stuff into the call gate, or better yet -// entirely into the ring 0 helper driver!! +/* TODO: Move the MTRR helper stuff into the call gate, or better yet */ +/* entirely into the ring 0 helper driver!! */ /* MTRR helper functions. To make it easier to implement the MTRR support * under OS/2, we simply put our ring 0 helper functions into the @@ -1705,7 +1705,7 @@ void _ASMAPI _MTRR_writeMSR( PM_MODULE PMAPI PM_loadLibrary( const char *szDLLName) { - // TODO: Implement this to load shared libraries! + /* TODO: Implement this to load shared libraries! */ (void)szDLLName; return NULL; } @@ -1714,7 +1714,7 @@ void * PMAPI PM_getProcAddress( PM_MODULE hModule, const char *szProcName) { - // TODO: Implement this! + /* TODO: Implement this! */ (void)hModule; (void)szProcName; return NULL; @@ -1723,7 +1723,7 @@ void * PMAPI PM_getProcAddress( void PMAPI PM_freeLibrary( PM_MODULE hModule) { - // TODO: Implement this! + /* TODO: Implement this! */ (void)hModule; } @@ -1740,15 +1740,15 @@ static void convertFindData( memset(findData,0,findData->dwSize); findData->dwSize = dwSize; if (blk->attrFile & FILE_READONLY) - findData->attrib |= PM_FILE_READONLY; + findData->attrib |= PM_FILE_READONLY; if (blk->attrFile & FILE_DIRECTORY) - findData->attrib |= PM_FILE_DIRECTORY; + findData->attrib |= PM_FILE_DIRECTORY; if (blk->attrFile & FILE_ARCHIVED) - findData->attrib |= PM_FILE_ARCHIVE; + findData->attrib |= PM_FILE_ARCHIVE; if (blk->attrFile & FILE_HIDDEN) - findData->attrib |= PM_FILE_HIDDEN; + findData->attrib |= PM_FILE_HIDDEN; if (blk->attrFile & FILE_SYSTEM) - findData->attrib |= PM_FILE_SYSTEM; + findData->attrib |= PM_FILE_SYSTEM; findData->sizeLo = blk->cbFile; findData->sizeHi = 0; strncpy(findData->name,blk->achName,PM_MAX_PATH); @@ -1770,9 +1770,9 @@ void *PMAPI PM_findFirstFile( ulong count = 1; if (DosFindFirst((PSZ)filename,&hdir,FIND_MASK,&blk,sizeof(blk),&count,FIL_STANDARD) == NO_ERROR) { - convertFindData(findData,&blk); - return (void*)hdir; - } + convertFindData(findData,&blk); + return (void*)hdir; + } return PM_FILE_INVALID; } @@ -1788,9 +1788,9 @@ ibool PMAPI PM_findNextFile( ulong count = 1; if (DosFindNext((HDIR)handle,&blk,sizeof(blk),&count) == NO_ERROR) { - convertFindData(findData,&blk); - return true; - } + convertFindData(findData,&blk); + return true; + } return false; } @@ -1857,16 +1857,16 @@ void PMAPI PM_setFileAttr( FILESTATUS3 s; if (DosQueryPathInfo((PSZ)filename,FIL_STANDARD,(PVOID)&s,sizeof(s))) - return; + return; s.attrFile = 0; if (attrib & PM_FILE_READONLY) - s.attrFile |= FILE_READONLY; + s.attrFile |= FILE_READONLY; if (attrib & PM_FILE_ARCHIVE) - s.attrFile |= FILE_ARCHIVED; + s.attrFile |= FILE_ARCHIVED; if (attrib & PM_FILE_HIDDEN) - s.attrFile |= FILE_HIDDEN; + s.attrFile |= FILE_HIDDEN; if (attrib & PM_FILE_SYSTEM) - s.attrFile |= FILE_SYSTEM; + s.attrFile |= FILE_SYSTEM; DosSetPathInfo((PSZ)filename,FIL_STANDARD,(PVOID)&s,sizeof(s),0L); } @@ -1881,15 +1881,15 @@ uint PMAPI PM_getFileAttr( uint retval = 0; if (DosQueryPathInfo((PSZ)filename, FIL_STANDARD, &fs3, sizeof(FILESTATUS3))) - return 0; + return 0; if (fs3.attrFile & FILE_READONLY) - retval |= PM_FILE_READONLY; + retval |= PM_FILE_READONLY; if (fs3.attrFile & FILE_ARCHIVED) - retval |= PM_FILE_ARCHIVE; + retval |= PM_FILE_ARCHIVE; if (fs3.attrFile & FILE_HIDDEN) - retval |= PM_FILE_HIDDEN; + retval |= PM_FILE_HIDDEN; if (fs3.attrFile & FILE_SYSTEM) - retval |= PM_FILE_SYSTEM; + retval |= PM_FILE_SYSTEM; return retval; } @@ -1928,33 +1928,33 @@ ibool PMAPI PM_getFileTime( time_t tt; if (DosQueryPathInfo((PSZ)filename, FIL_STANDARD, &fs3, sizeof(FILESTATUS3))) - return false; + return false; if (gmTime) { - tc.tm_year = fs3.fdateLastWrite.year + 80; - tc.tm_mon = fs3.fdateLastWrite.month - 1; - tc.tm_mday = fs3.fdateLastWrite.day; - tc.tm_hour = fs3.ftimeLastWrite.hours; - tc.tm_min = fs3.ftimeLastWrite.minutes; - tc.tm_sec = fs3.ftimeLastWrite.twosecs * 2; - if((tt = mktime(&tc)) == -1) - return false; - if(!(ret = gmtime(&tt))) - return false; - time->sec = ret->tm_sec; - time->day = ret->tm_mday; - time->mon = ret->tm_mon + 1; - time->year = ret->tm_year - 80; - time->min = ret->tm_min; - time->hour = ret->tm_hour; - } + tc.tm_year = fs3.fdateLastWrite.year + 80; + tc.tm_mon = fs3.fdateLastWrite.month - 1; + tc.tm_mday = fs3.fdateLastWrite.day; + tc.tm_hour = fs3.ftimeLastWrite.hours; + tc.tm_min = fs3.ftimeLastWrite.minutes; + tc.tm_sec = fs3.ftimeLastWrite.twosecs * 2; + if((tt = mktime(&tc)) == -1) + return false; + if(!(ret = gmtime(&tt))) + return false; + time->sec = ret->tm_sec; + time->day = ret->tm_mday; + time->mon = ret->tm_mon + 1; + time->year = ret->tm_year - 80; + time->min = ret->tm_min; + time->hour = ret->tm_hour; + } else { - time->sec = fs3.ftimeLastWrite.twosecs * 2; - time->day = fs3.fdateLastWrite.day; - time->mon = fs3.fdateLastWrite.month; - time->year = fs3.fdateLastWrite.year; - time->min = fs3.ftimeLastWrite.minutes; - time->hour = fs3.ftimeLastWrite.hours; - } + time->sec = fs3.ftimeLastWrite.twosecs * 2; + time->day = fs3.fdateLastWrite.day; + time->mon = fs3.fdateLastWrite.month; + time->year = fs3.fdateLastWrite.year; + time->min = fs3.ftimeLastWrite.minutes; + time->hour = fs3.ftimeLastWrite.hours; + } return true; } @@ -1973,32 +1973,32 @@ ibool PMAPI PM_setFileTime( time_t tt; if (DosQueryPathInfo((PSZ)filename,FIL_STANDARD,(PVOID)&fs3,sizeof(fs3))) - return false; + return false; if (gmTime) { - tc.tm_year = time->year + 80; - tc.tm_mon = time->mon - 1; - tc.tm_mday = time->day; - tc.tm_hour = time->hour; - tc.tm_min = time->min; - tc.tm_sec = time->sec; - if((tt = mktime(&tc)) == -1) - return false; - ret = localtime(&tt); - fs3.ftimeLastWrite.twosecs = ret->tm_sec / 2; - fs3.fdateLastWrite.day = ret->tm_mday; - fs3.fdateLastWrite.month = ret->tm_mon + 1; - fs3.fdateLastWrite.year = ret->tm_year - 80; - fs3.ftimeLastWrite.minutes = ret->tm_min; - fs3.ftimeLastWrite.hours = ret->tm_hour; - } + tc.tm_year = time->year + 80; + tc.tm_mon = time->mon - 1; + tc.tm_mday = time->day; + tc.tm_hour = time->hour; + tc.tm_min = time->min; + tc.tm_sec = time->sec; + if((tt = mktime(&tc)) == -1) + return false; + ret = localtime(&tt); + fs3.ftimeLastWrite.twosecs = ret->tm_sec / 2; + fs3.fdateLastWrite.day = ret->tm_mday; + fs3.fdateLastWrite.month = ret->tm_mon + 1; + fs3.fdateLastWrite.year = ret->tm_year - 80; + fs3.ftimeLastWrite.minutes = ret->tm_min; + fs3.ftimeLastWrite.hours = ret->tm_hour; + } else { - fs3.ftimeLastWrite.twosecs = time->sec / 2; - fs3.fdateLastWrite.day = time->day; - fs3.fdateLastWrite.month = time->mon; - fs3.fdateLastWrite.year = time->year; - fs3.ftimeLastWrite.minutes = time->min; - fs3.ftimeLastWrite.hours = time->hour; - } + fs3.ftimeLastWrite.twosecs = time->sec / 2; + fs3.fdateLastWrite.day = time->day; + fs3.fdateLastWrite.month = time->mon; + fs3.fdateLastWrite.year = time->year; + fs3.ftimeLastWrite.minutes = time->min; + fs3.ftimeLastWrite.hours = time->hour; + } memcpy(&fs3.fdateLastAccess, &fs3.fdateLastWrite, sizeof(FDATE)); memcpy(&fs3.fdateCreation, &fs3.fdateLastWrite, sizeof(FDATE)); memcpy(&fs3.ftimeLastAccess, &fs3.ftimeLastWrite, sizeof(FTIME)); diff --git a/board/MAI/bios_emulator/scitech/src/pm/os2pm/event.c b/board/MAI/bios_emulator/scitech/src/pm/os2pm/event.c index 97c2caa82f9..7af20a95684 100644 --- a/board/MAI/bios_emulator/scitech/src/pm/os2pm/event.c +++ b/board/MAI/bios_emulator/scitech/src/pm/os2pm/event.c @@ -59,7 +59,7 @@ Pumps all messages in the message queue from OS/2 into our event queue. ****************************************************************************/ static void _EVT_pumpMessages(void) { - // TODO: Implement this for OS/2 Presentation Manager apps! + /* TODO: Implement this for OS/2 Presentation Manager apps! */ } /**************************************************************************** @@ -105,7 +105,7 @@ void EVTAPI EVT_init( oldKeyMessage = 0; memset(keyUpMsg,0,sizeof(keyUpMsg)); - // TODO: OS/2 PM specific initialisation code! + /* TODO: OS/2 PM specific initialisation code! */ /* Catch program termination signals so we can clean up properly */ signal(SIGABRT, _EVT_abort); @@ -135,7 +135,7 @@ and this function can be used to resume it again later. ****************************************************************************/ void EVT_resume(void) { - // Do nothing for OS/2 + /* Do nothing for OS/2 */ } /**************************************************************************** @@ -145,7 +145,7 @@ de-install the event handling code. ****************************************************************************/ void EVT_suspend(void) { - // Do nothing for OS/2 + /* Do nothing for OS/2 */ } /**************************************************************************** @@ -159,7 +159,7 @@ void EVT_exit(void) signal(SIGFPE, SIG_DFL); signal(SIGINT, SIG_DFL); - // TODO: OS/2 PM specific exit code + /* TODO: OS/2 PM specific exit code */ } /**************************************************************************** diff --git a/board/MAI/bios_emulator/scitech/src/pm/photon/event.c b/board/MAI/bios_emulator/scitech/src/pm/photon/event.c index 738dfea3795..581da16fdff 100644 --- a/board/MAI/bios_emulator/scitech/src/pm/photon/event.c +++ b/board/MAI/bios_emulator/scitech/src/pm/photon/event.c @@ -51,7 +51,7 @@ static ibool _EVT_isKeyDown( uchar scancode) { return (KeyState[(scancode & 0xf8) >> 3] & (1 << (scancode & 0x7)) ? - true : false); + true : false); } /**************************************************************************** @@ -71,100 +71,100 @@ static void _EVT_pumpMessages(void) event_t _evt; while (count < EVENTQSIZE) { - uint mods = 0, keyp = 0; + uint mods = 0, keyp = 0; - pid = Creceive(0, &msg, sizeof (msg)); + pid = Creceive(0, &msg, sizeof (msg)); - if (pid == -1) - return; + if (pid == -1) + return; - if (PhEventRead(pid, event, sizeof (evt)) == Ph_EVENT_MSG) { - memset(&evt, 0, sizeof (evt)); - if (event->type == Ph_EV_KEY) { - key = PhGetData(event); + if (PhEventRead(pid, event, sizeof (evt)) == Ph_EVENT_MSG) { + memset(&evt, 0, sizeof (evt)); + if (event->type == Ph_EV_KEY) { + key = PhGetData(event); - if (key->key_flags & KEY_SCAN_VALID) { - keyp = key->key_scan; - if (key->key_flags & KEY_DOWN) - KeyState[(keyp & 0xf800) >> 11] - |= 1 << ((keyp & 0x700) >> 8); - else - KeyState[(keyp & 0xf800) >> 11] - &= ~(1 << ((keyp & 0x700) >> 8)); - } - if ((key->key_flags & KEY_SYM_VALID) || extended) - keyp |= key->key_sym; + if (key->key_flags & KEY_SCAN_VALID) { + keyp = key->key_scan; + if (key->key_flags & KEY_DOWN) + KeyState[(keyp & 0xf800) >> 11] + |= 1 << ((keyp & 0x700) >> 8); + else + KeyState[(keyp & 0xf800) >> 11] + &= ~(1 << ((keyp & 0x700) >> 8)); + } + if ((key->key_flags & KEY_SYM_VALID) || extended) + keyp |= key->key_sym; - /* No way to tell left from right... */ - if (key->key_mods & KEYMOD_SHIFT) - mods = (EVT_LEFTSHIFT | EVT_RIGHTSHIFT); - if (key->key_mods & KEYMOD_CTRL) - mods |= (EVT_CTRLSTATE | EVT_LEFTCTRL); - if (key->key_mods & KEYMOD_ALT) - mods |= (EVT_ALTSTATE | EVT_LEFTALT); + /* No way to tell left from right... */ + if (key->key_mods & KEYMOD_SHIFT) + mods = (EVT_LEFTSHIFT | EVT_RIGHTSHIFT); + if (key->key_mods & KEYMOD_CTRL) + mods |= (EVT_CTRLSTATE | EVT_LEFTCTRL); + if (key->key_mods & KEYMOD_ALT) + mods |= (EVT_ALTSTATE | EVT_LEFTALT); - _evt.when = evt->timestamp; - if (key->key_flags & KEY_REPEAT) { - _evt.what = EVT_KEYREPEAT; - _evt.message = 0x10000; - } - else if (key->key_flags & KEY_DOWN) - _evt.what = EVT_KEYDOWN; - else - _evt.what = EVT_KEYUP; - _evt.modifiers = mods; - _evt.message |= keyp; + _evt.when = evt->timestamp; + if (key->key_flags & KEY_REPEAT) { + _evt.what = EVT_KEYREPEAT; + _evt.message = 0x10000; + } + else if (key->key_flags & KEY_DOWN) + _evt.what = EVT_KEYDOWN; + else + _evt.what = EVT_KEYUP; + _evt.modifiers = mods; + _evt.message |= keyp; - addEvent(&_evt); + addEvent(&_evt); - switch(key->key_scan & 0xff00) { - case 0xe000: - extended = 1; - break; - case 0xe001: - extended = 2; - break; - default: - if (extended) - extended--; - } - } - else if (event->type & Ph_EV_PTR_ALL) { - but_stat = message = 0; - mouse = PhGetData(event); + switch(key->key_scan & 0xff00) { + case 0xe000: + extended = 1; + break; + case 0xe001: + extended = 2; + break; + default: + if (extended) + extended--; + } + } + else if (event->type & Ph_EV_PTR_ALL) { + but_stat = message = 0; + mouse = PhGetData(event); - if (mouse->button_state & Ph_BUTTON_3) - but_stat = EVT_LEFTBUT; - if (mouse->buttons & Ph_BUTTON_3) - message = EVT_LEFTBMASK; + if (mouse->button_state & Ph_BUTTON_3) + but_stat = EVT_LEFTBUT; + if (mouse->buttons & Ph_BUTTON_3) + message = EVT_LEFTBMASK; - if (mouse->button_state & Ph_BUTTON_1) - but_stat |= EVT_RIGHTBUT; - if (mouse->buttons & Ph_BUTTON_1) - message |= EVT_RIGHTBMASK; + if (mouse->button_state & Ph_BUTTON_1) + but_stat |= EVT_RIGHTBUT; + if (mouse->buttons & Ph_BUTTON_1) + message |= EVT_RIGHTBMASK; - _evt.when = evt->timestamp; - if (event->type & Ph_EV_PTR_MOTION) { - _evt.what = EVT_MOUSEMOVE; - _evt.where_x = mouse->pos.x; - _evt.where_y = mouse->pos.y; - _evt.modifiers = but_stat; - addEvent(&_evt); - } - if (event->type & Ph_EV_BUT_PRESS) - _evt.what = EVT_MOUSEDOWN; - else - _evt.what = EVT_MOUSEUP; - _evt.where_x = mouse->pos.x; - _evt.where_y = mouse->pos.y; - _evt.modifiers = but_stat; - _evt.message = message; - addEvent(&_evt); - } - } - else - return; - } + _evt.when = evt->timestamp; + if (event->type & Ph_EV_PTR_MOTION) { + _evt.what = EVT_MOUSEMOVE; + _evt.where_x = mouse->pos.x; + _evt.where_y = mouse->pos.y; + _evt.modifiers = but_stat; + addEvent(&_evt); + } + if (event->type & Ph_EV_BUT_PRESS) + _evt.what = EVT_MOUSEDOWN; + else + _evt.what = EVT_MOUSEUP; + _evt.where_x = mouse->pos.x; + _evt.where_y = mouse->pos.y; + _evt.modifiers = but_stat; + _evt.message = message; + addEvent(&_evt); + } + } + else + return; + } } /**************************************************************************** @@ -230,8 +230,8 @@ void EVTAPI EVT_setMouseRange( int xRes, int yRes) { - // TODO: Need to call Input to change the coordinates that it returns - // for mouse events!! + /* TODO: Need to call Input to change the coordinates that it returns */ + /* for mouse events!! */ } /**************************************************************************** @@ -242,7 +242,7 @@ and this function can be used to resume it again later. ****************************************************************************/ void EVT_resume(void) { - // Do nothing for Photon + /* Do nothing for Photon */ } /**************************************************************************** @@ -252,7 +252,7 @@ de-install the event handling code. ****************************************************************************/ void EVT_suspend(void) { - // Do nothing for Photon + /* Do nothing for Photon */ } /**************************************************************************** diff --git a/board/MAI/bios_emulator/scitech/src/pm/qnx/event.c b/board/MAI/bios_emulator/scitech/src/pm/qnx/event.c index e16f8a53928..45cd5144544 100644 --- a/board/MAI/bios_emulator/scitech/src/pm/qnx/event.c +++ b/board/MAI/bios_emulator/scitech/src/pm/qnx/event.c @@ -37,7 +37,7 @@ #ifndef __QNXNTO__ static struct _mouse_ctrl *_PM_mouse_ctl; static int _PM_keyboard_fd = -1; -//static int _PM_modifiers, _PM_leds; +/*static int _PM_modifiers, _PM_leds; */ #else static int kbd_fd = -1, mouse_fd = -1; #endif @@ -58,7 +58,7 @@ typedef struct { int map; } keymap; -// TODO: Fix this and set it up so we can do a binary search! +/* TODO: Fix this and set it up so we can do a binary search! */ keymap keymaps[] = { {96, KB_padEnter}, @@ -146,8 +146,8 @@ Converts a mickey movement value to a pixel adjustment value. static int MickeyToPixel( int mickey) { - // TODO: We can add some code in here to handle 'acceleration' for - // the mouse cursor. For now just use the mickeys. + /* TODO: We can add some code in here to handle 'acceleration' for */ + /* the mouse cursor. For now just use the mickeys. */ return mickey; } @@ -167,110 +167,110 @@ static void _EVT_pumpMessages(void) event_t evt; while (EVT.count < EVENTQSIZE) { - rc1 = read(kbd_fd, (void *)&key, sizeof(key)); - if (rc1 == -1) { - if (errno == EAGAIN) - rc1 = 0; - else { - perror("getEvents"); - PM_fatalError("Keyboard error"); - } - } - if (rc1 > 0) { - memset(&evt, 0, sizeof(evt)); - if (key.data.modifiers & KEYMOD_SHIFT) - mods |= EVT_LEFTSHIFT; - if (key.data.modifiers & KEYMOD_CTRL) - mods |= EVT_CTRLSTATE; - if (key.data.modifiers & KEYMOD_ALT) - mods |= EVT_ALTSTATE; - - /* Now store the keyboard event data */ - evt.when = TIME_TO_MSEC(key.time); - if (key.data.flags & KEY_SCAN_VALID) - evt.message |= (key.data.key_scan & 0x7F) << 8; - if ((key.data.flags & KEY_SYM_VALID) && - (((key.data.key_sym & 0xff00) == 0xf000 && - (key.data.key_sym & 0xff) < 0x20) || - key.data.key_sym < 0x80)) - evt.message |= (key.data.key_sym & 0xFF); - evt.modifiers = mods; - if (key.data.flags & KEY_DOWN) { - evt.what = EVT_KEYDOWN; - keyUpMsg[evt.message >> 8] = (ushort)evt.message; - } - else if (key.data.flags & KEY_REPEAT) { - evt.message |= 0x10000; - evt.what = EVT_KEYREPEAT; - } - else { - evt.what = EVT_KEYUP; - evt.message = keyUpMsg[evt.message >> 8]; - if (evt.message == 0) - continue; - keyUpMsg[evt.message >> 8] = 0; - } - - /* Now add the new event to the event queue */ - addEvent(&evt); - } - rc2 = read(mouse_fd, (void *)&ms, sizeof (ms)); - if (rc2 == -1) { - if (errno == EAGAIN) - rc2 = 0; - else { - perror("getEvents"); - PM_fatalError("Mouse error"); - } - } - if (rc2 > 0) { - memset(&evt, 0, sizeof(evt)); - ms.hdr.buttons &= - (_POINTER_BUTTON_LEFT | _POINTER_BUTTON_RIGHT); - if (ms.hdr.buttons & _POINTER_BUTTON_LEFT) - but_stat = EVT_LEFTBUT; - if ((ms.hdr.buttons & _POINTER_BUTTON_LEFT) != - (old_buttons & _POINTER_BUTTON_LEFT)) - message = EVT_LEFTBMASK; - if (ms.hdr.buttons & _POINTER_BUTTON_RIGHT) - but_stat |= EVT_RIGHTBUT; - if ((ms.hdr.buttons & _POINTER_BUTTON_RIGHT) != - (old_buttons & _POINTER_BUTTON_RIGHT)) - message |= EVT_RIGHTBMASK; - if (ms.dx || ms.dy) { - ms.dy = -ms.dy; - EVT.mx += MickeyToPixel(ms.dx); - EVT.my += MickeyToPixel(ms.dy); - if (EVT.mx < 0) EVT.mx = 0; - if (EVT.my < 0) EVT.my = 0; - if (EVT.mx > rangeX) EVT.mx = rangeX; - if (EVT.my > rangeY) EVT.my = rangeY; - evt.what = EVT_MOUSEMOVE; - evt.when = TIME_TO_MSEC(ms.hdr.time); - evt.where_x = EVT.mx; - evt.where_y = EVT.my; - evt.relative_x = ms.dx; - evt.relative_y = ms.dy; - evt.modifiers = but_stat; - addEvent(&evt); - } - evt.what = ms.hdr.buttons < old_buttons ? - EVT_MOUSEUP : EVT_MOUSEDOWN; - evt.when = TIME_TO_MSEC(ms.hdr.time); - evt.where_x = EVT.mx; - evt.where_y = EVT.my; - evt.relative_x = ms.dx; - evt.relative_y = ms.dy; - evt.modifiers = but_stat; - evt.message = message; - if (ms.hdr.buttons != old_buttons) { - addEvent(&evt); - old_buttons = ms.hdr.buttons; - } - } - if (rc1 + rc2 == 0) - break; - } + rc1 = read(kbd_fd, (void *)&key, sizeof(key)); + if (rc1 == -1) { + if (errno == EAGAIN) + rc1 = 0; + else { + perror("getEvents"); + PM_fatalError("Keyboard error"); + } + } + if (rc1 > 0) { + memset(&evt, 0, sizeof(evt)); + if (key.data.modifiers & KEYMOD_SHIFT) + mods |= EVT_LEFTSHIFT; + if (key.data.modifiers & KEYMOD_CTRL) + mods |= EVT_CTRLSTATE; + if (key.data.modifiers & KEYMOD_ALT) + mods |= EVT_ALTSTATE; + + /* Now store the keyboard event data */ + evt.when = TIME_TO_MSEC(key.time); + if (key.data.flags & KEY_SCAN_VALID) + evt.message |= (key.data.key_scan & 0x7F) << 8; + if ((key.data.flags & KEY_SYM_VALID) && + (((key.data.key_sym & 0xff00) == 0xf000 && + (key.data.key_sym & 0xff) < 0x20) || + key.data.key_sym < 0x80)) + evt.message |= (key.data.key_sym & 0xFF); + evt.modifiers = mods; + if (key.data.flags & KEY_DOWN) { + evt.what = EVT_KEYDOWN; + keyUpMsg[evt.message >> 8] = (ushort)evt.message; + } + else if (key.data.flags & KEY_REPEAT) { + evt.message |= 0x10000; + evt.what = EVT_KEYREPEAT; + } + else { + evt.what = EVT_KEYUP; + evt.message = keyUpMsg[evt.message >> 8]; + if (evt.message == 0) + continue; + keyUpMsg[evt.message >> 8] = 0; + } + + /* Now add the new event to the event queue */ + addEvent(&evt); + } + rc2 = read(mouse_fd, (void *)&ms, sizeof (ms)); + if (rc2 == -1) { + if (errno == EAGAIN) + rc2 = 0; + else { + perror("getEvents"); + PM_fatalError("Mouse error"); + } + } + if (rc2 > 0) { + memset(&evt, 0, sizeof(evt)); + ms.hdr.buttons &= + (_POINTER_BUTTON_LEFT | _POINTER_BUTTON_RIGHT); + if (ms.hdr.buttons & _POINTER_BUTTON_LEFT) + but_stat = EVT_LEFTBUT; + if ((ms.hdr.buttons & _POINTER_BUTTON_LEFT) != + (old_buttons & _POINTER_BUTTON_LEFT)) + message = EVT_LEFTBMASK; + if (ms.hdr.buttons & _POINTER_BUTTON_RIGHT) + but_stat |= EVT_RIGHTBUT; + if ((ms.hdr.buttons & _POINTER_BUTTON_RIGHT) != + (old_buttons & _POINTER_BUTTON_RIGHT)) + message |= EVT_RIGHTBMASK; + if (ms.dx || ms.dy) { + ms.dy = -ms.dy; + EVT.mx += MickeyToPixel(ms.dx); + EVT.my += MickeyToPixel(ms.dy); + if (EVT.mx < 0) EVT.mx = 0; + if (EVT.my < 0) EVT.my = 0; + if (EVT.mx > rangeX) EVT.mx = rangeX; + if (EVT.my > rangeY) EVT.my = rangeY; + evt.what = EVT_MOUSEMOVE; + evt.when = TIME_TO_MSEC(ms.hdr.time); + evt.where_x = EVT.mx; + evt.where_y = EVT.my; + evt.relative_x = ms.dx; + evt.relative_y = ms.dy; + evt.modifiers = but_stat; + addEvent(&evt); + } + evt.what = ms.hdr.buttons < old_buttons ? + EVT_MOUSEUP : EVT_MOUSEDOWN; + evt.when = TIME_TO_MSEC(ms.hdr.time); + evt.where_x = EVT.mx; + evt.where_y = EVT.my; + evt.relative_x = ms.dx; + evt.relative_y = ms.dy; + evt.modifiers = but_stat; + evt.message = message; + if (ms.hdr.buttons != old_buttons) { + addEvent(&evt); + old_buttons = ms.hdr.buttons; + } + } + if (rc1 + rc2 == 0) + break; + } } #else /**************************************************************************** @@ -290,66 +290,66 @@ static void _EVT_pumpMessages(void) /* Poll keyboard events */ while ((numkeys = read(_PM_keyboard_fd, buf, sizeof buf)) > 0) { - for (i = 0; i < numkeys; i++) { - processRawScanCode(buf[i]); - } - } + for (i = 0; i < numkeys; i++) { + processRawScanCode(buf[i]); + } + } if (_PM_mouse_ctl == NULL) - return; + return; /* Gobble pending mouse events */ while (EVT.count < EVENTQSIZE) { - rc = mouse_read(_PM_mouse_ctl, &ev, 1, 0, NULL); - if (rc == -1) { - perror("getEvents"); - PM_fatalError("Mouse error (Input terminated?)"); - } - if (rc == 0) - break; - - message = 0, but_stat = 0; - memset(&evt, 0, sizeof(evt)); - - ev.buttons &= (_MOUSE_LEFT | _MOUSE_RIGHT); - if (ev.buttons & _MOUSE_LEFT) - but_stat = EVT_LEFTBUT; - if ((ev.buttons & _MOUSE_LEFT) != (old_buttons & _MOUSE_LEFT)) - message = EVT_LEFTBMASK; - if (ev.buttons & _MOUSE_RIGHT) - but_stat |= EVT_RIGHTBUT; - if ((ev.buttons & _MOUSE_RIGHT) != (old_buttons & _MOUSE_RIGHT)) - message |= EVT_RIGHTBMASK; - if (ev.dx || ev.dy) { - ev.dy = -ev.dy; - EVT.mx += MickeyToPixel(ev.dx); - EVT.my += MickeyToPixel(ev.dy); - if (EVT.mx < 0) EVT.mx = 0; - if (EVT.my < 0) EVT.my = 0; - if (EVT.mx > rangeX) EVT.mx = rangeX; - if (EVT.my > rangeY) EVT.my = rangeY; - evt.what = EVT_MOUSEMOVE; - evt.when = ev.timestamp*100; - evt.where_x = EVT.mx; - evt.where_y = EVT.my; - evt.relative_x = ev.dx; - evt.relative_y = ev.dy; - evt.modifiers = but_stat; - addEvent(&evt); - } - evt.what = ev.buttons < old_buttons ? EVT_MOUSEUP : EVT_MOUSEDOWN; - evt.when = ev.timestamp*100; - evt.where_x = EVT.mx; - evt.where_y = EVT.my; - evt.relative_x = ev.dx; - evt.relative_y = ev.dy; - evt.modifiers = but_stat; - evt.message = message; - if (ev.buttons != old_buttons) { - addEvent(&evt); - old_buttons = ev.buttons; - } - } + rc = mouse_read(_PM_mouse_ctl, &ev, 1, 0, NULL); + if (rc == -1) { + perror("getEvents"); + PM_fatalError("Mouse error (Input terminated?)"); + } + if (rc == 0) + break; + + message = 0, but_stat = 0; + memset(&evt, 0, sizeof(evt)); + + ev.buttons &= (_MOUSE_LEFT | _MOUSE_RIGHT); + if (ev.buttons & _MOUSE_LEFT) + but_stat = EVT_LEFTBUT; + if ((ev.buttons & _MOUSE_LEFT) != (old_buttons & _MOUSE_LEFT)) + message = EVT_LEFTBMASK; + if (ev.buttons & _MOUSE_RIGHT) + but_stat |= EVT_RIGHTBUT; + if ((ev.buttons & _MOUSE_RIGHT) != (old_buttons & _MOUSE_RIGHT)) + message |= EVT_RIGHTBMASK; + if (ev.dx || ev.dy) { + ev.dy = -ev.dy; + EVT.mx += MickeyToPixel(ev.dx); + EVT.my += MickeyToPixel(ev.dy); + if (EVT.mx < 0) EVT.mx = 0; + if (EVT.my < 0) EVT.my = 0; + if (EVT.mx > rangeX) EVT.mx = rangeX; + if (EVT.my > rangeY) EVT.my = rangeY; + evt.what = EVT_MOUSEMOVE; + evt.when = ev.timestamp*100; + evt.where_x = EVT.mx; + evt.where_y = EVT.my; + evt.relative_x = ev.dx; + evt.relative_y = ev.dy; + evt.modifiers = but_stat; + addEvent(&evt); + } + evt.what = ev.buttons < old_buttons ? EVT_MOUSEUP : EVT_MOUSEDOWN; + evt.when = ev.timestamp*100; + evt.where_x = EVT.mx; + evt.where_y = EVT.my; + evt.relative_x = ev.dx; + evt.relative_y = ev.dy; + evt.modifiers = but_stat; + evt.message = message; + if (ev.buttons != old_buttons) { + addEvent(&evt); + old_buttons = ev.buttons; + } + } } #endif /* __QNXNTO__ */ @@ -400,7 +400,7 @@ void EVTAPI EVT_init( char buf[128]; FILE *p; int argno,len; -#endif +#endif #ifdef __QNXNTO__ ThreadCtl(_NTO_TCTL_IO, 0); /* So joystick code won't blow up */ @@ -410,7 +410,7 @@ void EVTAPI EVT_init( EVT.mouseMove = mouseMove; initEventQueue(); memset(keyUpMsg,0,sizeof(keyUpMsg)); - + #ifdef __QNXNTO__ /* * User may already have input running with the right parameters. @@ -419,82 +419,82 @@ void EVTAPI EVT_init( * manager. */ if ((mouse_fd = open("/dev/mouse0", O_RDONLY | O_NONBLOCK)) < 0) { - /* Run inputtrap to get the args for input */ - if ((p = popen("inputtrap", "r")) == NULL) - PM_fatalError("Error running 'inputtrap'"); - fgets(buf, sizeof(buf), p); - pclose(p); - - /* Build the argument list */ - len = strlen(buf); - iarg[0] = buf; - for (i = 0, argno = 0; i < len && argno < 15;) { - if (argno == 1) { - /* - * Add flags to input's arg list. - * '-r' means run as resource - * manager, providing the /dev/mouse - * and /dev/keyboard interfaces. - * '-P' supresses the /dev/photon - * mechanism. - */ - iarg[argno++] = "-Pr"; - continue; - } - while (buf[i] == ' ') - i++; - if (buf[i] == '\0' || buf[i] == '\n') - break; - iarg[argno++] = &buf[i]; - while (buf[i] != ' ' - && buf[i] != '\0' && buf[i] != '\n') - i++; - buf[i++] = '\0'; - } - iarg[argno] = NULL; - - if ((kill_pid = spawnvp(P_NOWAITO, iarg[0], iarg)) == -1) { - perror("spawning input resmgr"); - PM_fatalError("Could not start input resmgr"); - } - for (i = 0; i < 10; i++) { - if (stat("/dev/mouse0", &st) == 0) - break; - sleep(1); - } - if ((mouse_fd = open("/dev/mouse0", O_RDONLY|O_NONBLOCK)) < 0) { - perror("/dev/mouse0"); - PM_fatalError("Could not open /dev/mouse0"); - } - } + /* Run inputtrap to get the args for input */ + if ((p = popen("inputtrap", "r")) == NULL) + PM_fatalError("Error running 'inputtrap'"); + fgets(buf, sizeof(buf), p); + pclose(p); + + /* Build the argument list */ + len = strlen(buf); + iarg[0] = buf; + for (i = 0, argno = 0; i < len && argno < 15;) { + if (argno == 1) { + /* + * Add flags to input's arg list. + * '-r' means run as resource + * manager, providing the /dev/mouse + * and /dev/keyboard interfaces. + * '-P' supresses the /dev/photon + * mechanism. + */ + iarg[argno++] = "-Pr"; + continue; + } + while (buf[i] == ' ') + i++; + if (buf[i] == '\0' || buf[i] == '\n') + break; + iarg[argno++] = &buf[i]; + while (buf[i] != ' ' + && buf[i] != '\0' && buf[i] != '\n') + i++; + buf[i++] = '\0'; + } + iarg[argno] = NULL; + + if ((kill_pid = spawnvp(P_NOWAITO, iarg[0], iarg)) == -1) { + perror("spawning input resmgr"); + PM_fatalError("Could not start input resmgr"); + } + for (i = 0; i < 10; i++) { + if (stat("/dev/mouse0", &st) == 0) + break; + sleep(1); + } + if ((mouse_fd = open("/dev/mouse0", O_RDONLY|O_NONBLOCK)) < 0) { + perror("/dev/mouse0"); + PM_fatalError("Could not open /dev/mouse0"); + } + } if ((kbd_fd = open("/dev/keyboard0", O_RDONLY|O_NONBLOCK)) < 0) { - perror("/dev/keyboard0"); - PM_fatalError("Could not open /dev/keyboard0"); - } + perror("/dev/keyboard0"); + PM_fatalError("Could not open /dev/keyboard0"); + } #else /* Connect to Input/Mouse for event handling */ if (_PM_mouse_ctl == NULL) { - _PM_mouse_ctl = mouse_open(0, "/dev/mouse", 0); - - /* "Mouse" is not running; attempt to start it */ - if (_PM_mouse_ctl == NULL) { - iarg[0] = "mousetrap"; - iarg[1] = "start"; - iarg[2] = NULL; - if ((kill_pid = spawnvp(P_NOWAITO, iarg[0], (void*)iarg)) == -1) - perror("spawn (mousetrap)"); - else { - for (i = 0; i < 10; i++) { - if (stat("/dev/mouse", &st) == 0) - break; - sleep(1); - } - _PM_mouse_ctl = mouse_open(0, "/dev/mouse", 0); - } - } - } + _PM_mouse_ctl = mouse_open(0, "/dev/mouse", 0); + + /* "Mouse" is not running; attempt to start it */ + if (_PM_mouse_ctl == NULL) { + iarg[0] = "mousetrap"; + iarg[1] = "start"; + iarg[2] = NULL; + if ((kill_pid = spawnvp(P_NOWAITO, iarg[0], (void*)iarg)) == -1) + perror("spawn (mousetrap)"); + else { + for (i = 0; i < 10; i++) { + if (stat("/dev/mouse", &st) == 0) + break; + sleep(1); + } + _PM_mouse_ctl = mouse_open(0, "/dev/mouse", 0); + } + } + } if (_PM_keyboard_fd == -1) - _PM_keyboard_fd = open("/dev/kbd", O_RDONLY|O_NONBLOCK); + _PM_keyboard_fd = open("/dev/kbd", O_RDONLY|O_NONBLOCK); #endif /* Catch program termination signals so we can clean up properly */ @@ -532,7 +532,7 @@ and this function can be used to resume it again later. ****************************************************************************/ void EVT_resume(void) { - // Do nothing for QNX + /* Do nothing for QNX */ } /**************************************************************************** @@ -542,7 +542,7 @@ de-install the event handling code. ****************************************************************************/ void EVT_suspend(void) { - // Do nothing for QNX + /* Do nothing for QNX */ } /**************************************************************************** @@ -556,13 +556,13 @@ void EVT_exit(void) int flags; if (kbd_fd != -1) { - close(kbd_fd); - kbd_fd = -1; - } + close(kbd_fd); + kbd_fd = -1; + } if (mouse_fd != -1) { - close(mouse_fd); - mouse_fd = -1; - } + close(mouse_fd); + mouse_fd = -1; + } #endif /* Restore signal handlers */ @@ -573,30 +573,29 @@ void EVT_exit(void) #ifndef __QNXNTO__ /* Kill the Input/Mouse driver if we have spawned it */ if (_PM_mouse_ctl != NULL) { - struct _fd_entry fde; - uint pid = 0; - - /* Find out the pid of the mouse driver */ - if (kill_pid > 0) { - if (qnx_fd_query(0, - 0, _PM_mouse_ctl->fd, &fde) != -1) - pid = fde.pid; - } - mouse_close(_PM_mouse_ctl); - _PM_mouse_ctl = NULL; - - if (pid > 0) { - /* For some reasons the PID's are different under QNX4, - * so we use the old mechanism to kill the mouse server. - */ - kill(pid, SIGTERM); - kill_pid = 0; - } - } + struct _fd_entry fde; + uint pid = 0; + + /* Find out the pid of the mouse driver */ + if (kill_pid > 0) { + if (qnx_fd_query(0, + 0, _PM_mouse_ctl->fd, &fde) != -1) + pid = fde.pid; + } + mouse_close(_PM_mouse_ctl); + _PM_mouse_ctl = NULL; + + if (pid > 0) { + /* For some reasons the PID's are different under QNX4, + * so we use the old mechanism to kill the mouse server. + */ + kill(pid, SIGTERM); + kill_pid = 0; + } + } #endif if (kill_pid > 0) { - kill(kill_pid, SIGTERM); - kill_pid = 0; - } + kill(kill_pid, SIGTERM); + kill_pid = 0; + } } - diff --git a/board/MAI/bios_emulator/scitech/src/pm/qnx/mtrrqnx.c b/board/MAI/bios_emulator/scitech/src/pm/qnx/mtrrqnx.c index de749e38349..f960c75714d 100644 --- a/board/MAI/bios_emulator/scitech/src/pm/qnx/mtrrqnx.c +++ b/board/MAI/bios_emulator/scitech/src/pm/qnx/mtrrqnx.c @@ -75,7 +75,7 @@ Return true if ring 0 (or if we can call the helpers functions at ring 0) ibool _ASMAPI _MTRR_isRing0(void) { #ifdef __QNXNTO__ - return false; // Not implemented yet! + return false; /* Not implemented yet! */ #else return true; #endif @@ -101,15 +101,15 @@ static void CallRing0(void) #endif #ifdef __QNXNTO__ if ((intrid = InterruptAttach(_NTO_INTR_CLASS_EXTERNAL | clock_intno, - _PM_ring0_isr, (void*)&_PM_R0, sizeof(_PM_R0), _NTO_INTR_FLAGS_END)) == -1) { + _PM_ring0_isr, (void*)&_PM_R0, sizeof(_PM_R0), _NTO_INTR_FLAGS_END)) == -1) { #else if ((intrid = qnx_hint_attach(clock_intno, _PM_ring0_isr, FP_SEG(&_PM_R0))) == -1) { #endif - perror("Attach"); - exit(-1); - } + perror("Attach"); + exit(-1); + } while (_PM_R0.service != -1) - ; + ; #ifdef __QNXNTO__ InterruptDetachId(intrid); #else diff --git a/board/MAI/bios_emulator/scitech/src/pm/qnx/pm.c b/board/MAI/bios_emulator/scitech/src/pm/qnx/pm.c index c2b41eb09ff..c993ee08379 100644 --- a/board/MAI/bios_emulator/scitech/src/pm/qnx/pm.c +++ b/board/MAI/bios_emulator/scitech/src/pm/qnx/pm.c @@ -77,11 +77,11 @@ void PMAPI PM_init(void) if (VRegs == NULL) { #ifdef __QNXNTO__ - ThreadCtl(_NTO_TCTL_IO, 0); /* Get IO privilidge */ + ThreadCtl(_NTO_TCTL_IO, 0); /* Get IO privilidge */ #endif - force = getenv("VBIOS_METHOD"); - VRegs = VBIOSinit(force ? atoi(force) : 0); - } + force = getenv("VBIOS_METHOD"); + VRegs = VBIOSinit(force ? atoi(force) : 0); + } #ifndef __QNXNTO__ MTRR_init(); #endif @@ -100,9 +100,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( @@ -114,7 +114,7 @@ void PMAPI PM_setFatalErrorCleanup( void PMAPI PM_fatalError(const char *msg) { if (fatalErrorCleanup) - fatalErrorCleanup(); + fatalErrorCleanup(); fprintf(stderr,"%s\n", msg); exit(1); } @@ -122,18 +122,18 @@ void PMAPI PM_fatalError(const char *msg) 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; @@ -145,11 +145,11 @@ static int term_raw(void) struct termios termios_p; if (raw_count++ > 0) - return 0; + return 0; /* Go into "raw" input mode */ if (tcgetattr(STDIN_FILENO, &termios_p)) - return -1; + return -1; termios_p.c_cc[VMIN] = 1; termios_p.c_cc[VTIME] = 0; @@ -163,7 +163,7 @@ static void term_restore(void) struct termios termios_p; if (raw_count-- != 1) - return; + return; tcgetattr(STDIN_FILENO, &termios_p); termios_p.c_lflag |= (ECHO|ICANON|ISIG|ECHOE|ECHOK|ECHONL); @@ -176,7 +176,7 @@ int PMAPI PM_kbhit(void) int blocking, c; if (term_raw() == -1) - return 0; + return 0; /* Go into non blocking mode */ blocking = fcntl(STDIN_FILENO, F_GETFL) | O_NONBLOCK; @@ -187,9 +187,9 @@ int PMAPI PM_kbhit(void) fcntl(STDIN_FILENO, F_SETFL, blocking & ~O_NONBLOCK); term_restore(); if (c != EOF) { - ungetc(c, stdin); - return c; - } + ungetc(c, stdin); + return c; + } clearerr(stdin); return 0; } @@ -199,13 +199,13 @@ int PMAPI PM_getch(void) int c; if (term_raw() == -1) - return (0); + return (0); c = getc(stdin); #if defined(__QNX__) && !defined(__QNXNTO__) if (c == 0xA) - c = 0x0D; + c = 0x0D; else if (c == 0x7F) - c = 0x08; + c = 0x08; #endif term_restore(); return c; @@ -223,13 +223,13 @@ PM_HWND PMAPI PM_openConsole( int fd; if (console_count++) - return 0; + return 0; if ((fd = open("/dev/con1", O_RDWR)) == -1) - return -1; + return -1; cc = console_open(fd, O_RDWR); close(fd); if (cc == NULL) - return -1; + return -1; #endif return 1; } @@ -246,7 +246,7 @@ void PMAPI PM_saveConsoleState(void *stateBuf,int console_id) int flags; if ((fd = open("/dev/con1", O_RDWR)) == -1) - return; + return; flags = _CONCTL_INVISIBLE_CHG | _CONCTL_INVISIBLE; devctl(fd, DCMD_CHR_SERCTL, &flags, sizeof flags, 0); close(fd); @@ -255,10 +255,10 @@ void PMAPI PM_saveConsoleState(void *stateBuf,int console_id) /* Save QNX 4 console state */ console_read(cc, -1, 0, NULL, 0, - (int *)buf+1, (int *)buf+2, NULL); + (int *)buf+1, (int *)buf+2, NULL); *(int *)buf = console_ctrl(cc, -1, - CONSOLE_NORESIZE | CONSOLE_NOSWITCH | CONSOLE_INVISIBLE, - CONSOLE_NORESIZE | CONSOLE_NOSWITCH | CONSOLE_INVISIBLE); + CONSOLE_NORESIZE | CONSOLE_NOSWITCH | CONSOLE_INVISIBLE, + CONSOLE_NORESIZE | CONSOLE_NOSWITCH | CONSOLE_INVISIBLE); /* Save state of VGA registers */ PM_saveVGAState(stateBuf); @@ -277,7 +277,7 @@ void PMAPI PM_restoreConsoleState(const void *stateBuf,PM_HWND hwndConsole) int flags; if ((fd = open("/dev/con1", O_RDWR)) == -1) - return; + return; flags = _CONCTL_INVISIBLE_CHG; devctl(fd, DCMD_CHR_SERCTL, &flags, sizeof flags, 0); close(fd); @@ -289,9 +289,9 @@ void PMAPI PM_restoreConsoleState(const void *stateBuf,PM_HWND hwndConsole) /* Restore QNX 4 console state */ console_ctrl(cc, -1, *(int *)buf, - CONSOLE_NORESIZE | CONSOLE_NOSWITCH | CONSOLE_INVISIBLE); + CONSOLE_NORESIZE | CONSOLE_NOSWITCH | CONSOLE_INVISIBLE); console_write(cc, -1, 0, NULL, 0, - (int *)buf+1, (int *)buf+2, NULL); + (int *)buf+1, (int *)buf+2, NULL); #endif } @@ -299,16 +299,16 @@ void PMAPI PM_closeConsole(PM_HWND hwndConsole) { #ifndef __QNXNTO__ if (--console_count == 0) { - console_close(cc); - cc = NULL; - } + console_close(cc); + cc = NULL; + } #endif } void PM_setOSCursorLocation(int x,int y) { if (!cc) - return; + return; #ifndef __QNXNTO__ console_write(cc, -1, 0, NULL, 0, &y, &x, NULL); #endif @@ -320,18 +320,18 @@ void PM_setOSScreenWidth(int width,int height) ibool PMAPI PM_setRealTimeClockHandler(PM_intHandler ih, int frequency) { - // TODO: Implement this for QNX + /* TODO: Implement this for QNX */ return false; } void PMAPI PM_setRealTimeClockFrequency(int frequency) { - // TODO: Implement this for QNX + /* TODO: Implement this for QNX */ } void PMAPI PM_restoreRealTimeClockHandler(void) { - // TODO: Implement this for QNX + /* TODO: Implement this for QNX */ } char * PMAPI PM_getCurrentPath( @@ -388,10 +388,10 @@ const char * PMAPI PM_getNucleusConfigPath(void) sprintf(path,"/etc/config/scitech/%d/config", getnid()); #endif if ((env = getenv("NUCLEUS_PATH")) != NULL) { - strcpy(path,env); - PM_backslash(path); - strcat(path,"config"); - } + strcpy(path,env); + PM_backslash(path); + strcat(path,"config"); + } return path; } @@ -429,26 +429,26 @@ void * PMAPI PM_getA0000Pointer(void) unsigned offset, i, maplen; if (ptr != NULL) - return ptr; + return ptr; /* Some trickery is required to get the linear address 64K aligned */ for (i = 0; i < 5; i++) { - ptr = PM_mapPhysicalAddr(0xA0000,0xFFFF,true); - offset = 0x10000 - ((unsigned)ptr % 0x10000); - if (!offset) - break; - munmap(ptr, 0x10000); - maplen = 0x10000 + offset; - freeptr = PM_mapPhysicalAddr(0xA0000-offset, maplen-1,true); - ptr = (void *)(offset + (unsigned)freeptr); - if (0x10000 - ((unsigned)ptr % 0x10000)) - break; - munmap(freeptr, maplen); - } + ptr = PM_mapPhysicalAddr(0xA0000,0xFFFF,true); + offset = 0x10000 - ((unsigned)ptr % 0x10000); + if (!offset) + break; + munmap(ptr, 0x10000); + maplen = 0x10000 + offset; + freeptr = PM_mapPhysicalAddr(0xA0000-offset, maplen-1,true); + ptr = (void *)(offset + (unsigned)freeptr); + if (0x10000 - ((unsigned)ptr % 0x10000)) + break; + munmap(freeptr, maplen); + } if (i == 5) { - printf("Could not get a 64K aligned linear address for A0000 region\n"); - exit(1); - } + printf("Could not get a 64K aligned linear address for A0000 region\n"); + exit(1); + } return ptr; } @@ -468,31 +468,31 @@ void * PMAPI PM_mapPhysicalAddr(ulong base,ulong limit,ibool isCached) #endif if (rounddown) { - if (base < rounddown) - return NULL; - base -= rounddown; - limit += rounddown; - } + if (base < rounddown) + return NULL; + base -= rounddown; + limit += rounddown; + } #ifndef __QNXNTO__ if (__VidFD < 0) { - if ((__VidFD = shm_open( "Physical", O_RDWR, 0777 )) == -1) { - perror( "Cannot open Physical memory" ); - exit(1); - } - } + if ((__VidFD = shm_open( "Physical", O_RDWR, 0777 )) == -1) { + perror( "Cannot open Physical memory" ); + exit(1); + } + } o = base & 0xFFF; limit = (limit + o + 0xFFF) & ~0xFFF; if ((int)(p = mmap( 0, limit, prot, MAP_SHARED, - __VidFD, base )) == -1 ) { - return NULL; - } + __VidFD, base )) == -1 ) { + return NULL; + } p += o; #else if ((p = mmap(0, limit, prot, MAP_PHYS | MAP_SHARED, - NOFD, base)) == MAP_FAILED) { - return (void *)-1; - } + NOFD, base)) == MAP_FAILED) { + return (void *)-1; + } #endif return (p + rounddown); } @@ -504,8 +504,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. */ return 0xFFFFFFFFUL; } @@ -514,35 +514,35 @@ ibool PMAPI PM_getPhysicalAddrRange( ulong length, ulong *physAddress) { - // TODO: Implement this! + /* TODO: Implement this! */ return false; } void PMAPI PM_sleep(ulong milliseconds) { - // TODO: Put the process to sleep for milliseconds + /* TODO: Put the process to sleep for milliseconds */ } int PMAPI PM_getCOMPort(int port) { - // TODO: Re-code this to determine real values using the Plug and Play - // manager for the OS. + /* TODO: Re-code this to determine real values using the Plug and Play */ + /* manager for the OS. */ 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) { - // TODO: Re-code this to determine real values using the Plug and Play - // manager for the OS. + /* TODO: Re-code this to determine real values using the Plug and Play */ + /* manager for the OS. */ 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; } @@ -566,20 +566,20 @@ void * PMAPI PM_mapRealPointer(uint r_seg,uint r_off) PM_init(); if ((p = VBIOSgetmemptr(r_seg, r_off, VRegs)) == (void *)-1) - return NULL; + return NULL; return p; } void * PMAPI PM_allocRealSeg(uint size,uint *r_seg,uint *r_off) { if (size > 1024) { - printf("PM_allocRealSeg: can't handle %d bytes\n", size); - return 0; - } + printf("PM_allocRealSeg: can't handle %d bytes\n", size); + return 0; + } if (rmbuf_inuse != 0) { - printf("PM_allocRealSeg: transfer area already in use\n"); - return 0; - } + printf("PM_allocRealSeg: transfer area already in use\n"); + return 0; + } PM_init(); rmbuf_inuse = 1; *r_seg = VBIOS_TransBufVSeg(VRegs); @@ -590,9 +590,9 @@ void * PMAPI PM_allocRealSeg(uint size,uint *r_seg,uint *r_off) void PMAPI PM_freeRealSeg(void *mem) { if (rmbuf_inuse == 0) { - printf("PM_freeRealSeg: nothing was allocated\n"); - return; - } + printf("PM_freeRealSeg: nothing was allocated\n"); + return; + } rmbuf_inuse = 0; } @@ -600,7 +600,7 @@ void PMAPI DPMI_int86(int intno, DPMI_regs *regs) { PM_init(); if (VRegs == NULL) - return; + return; VRegs->l.eax = regs->eax; VRegs->l.ebx = regs->ebx; @@ -624,7 +624,7 @@ int PMAPI PM_int86(int intno, RMREGS *in, RMREGS *out) { PM_init(); if (VRegs == NULL) - return 0; + return 0; VRegs->l.eax = in->e.eax; VRegs->l.ebx = in->e.ebx; @@ -651,41 +651,41 @@ int PMAPI PM_int86x(int intno, RMREGS *in, RMREGS *out, { PM_init(); if (VRegs == NULL) - return 0; + return 0; if (intno == 0x21) { - time_t today = time(NULL); - struct tm *t; - t = localtime(&today); - out->x.cx = t->tm_year + 1900; - out->h.dh = t->tm_mon + 1; - out->h.dl = t->tm_mday; - return 0; - } + time_t today = time(NULL); + struct tm *t; + t = localtime(&today); + out->x.cx = t->tm_year + 1900; + out->h.dh = t->tm_mon + 1; + out->h.dl = t->tm_mday; + return 0; + } else { - VRegs->l.eax = in->e.eax; - VRegs->l.ebx = in->e.ebx; - VRegs->l.ecx = in->e.ecx; - VRegs->l.edx = in->e.edx; - VRegs->l.esi = in->e.esi; - VRegs->l.edi = in->e.edi; - VRegs->w.es = sregs->es; - VRegs->w.ds = sregs->ds; - - VBIOSint(intno, VRegs, 1024); - - out->e.eax = VRegs->l.eax; - out->e.ebx = VRegs->l.ebx; - out->e.ecx = VRegs->l.ecx; - out->e.edx = VRegs->l.edx; - out->e.esi = VRegs->l.esi; - out->e.edi = VRegs->l.edi; - out->x.cflag = VRegs->w.flags & 0x1; - sregs->es = VRegs->w.es; - sregs->ds = VRegs->w.ds; - - return out->x.ax; - } + VRegs->l.eax = in->e.eax; + VRegs->l.ebx = in->e.ebx; + VRegs->l.ecx = in->e.ecx; + VRegs->l.edx = in->e.edx; + VRegs->l.esi = in->e.esi; + VRegs->l.edi = in->e.edi; + VRegs->w.es = sregs->es; + VRegs->w.ds = sregs->ds; + + VBIOSint(intno, VRegs, 1024); + + out->e.eax = VRegs->l.eax; + out->e.ebx = VRegs->l.ebx; + out->e.ecx = VRegs->l.ecx; + out->e.edx = VRegs->l.edx; + out->e.esi = VRegs->l.esi; + out->e.edi = VRegs->l.edi; + out->x.cflag = VRegs->w.flags & 0x1; + sregs->es = VRegs->w.es; + sregs->ds = VRegs->w.ds; + + return out->x.ax; + } } void PMAPI PM_callRealMode(uint seg,uint off, RMREGS *in, @@ -693,7 +693,7 @@ void PMAPI PM_callRealMode(uint seg,uint off, RMREGS *in, { PM_init(); if (VRegs == NULL) - return; + return; VRegs->l.eax = in->e.eax; VRegs->l.ebx = in->e.ebx; @@ -730,7 +730,7 @@ void * PMAPI PM_allocLockedMem( ibool contiguous, ibool below16M) { - // TODO: Implement this on QNX + /* TODO: Implement this on QNX */ return NULL; } @@ -739,27 +739,27 @@ void PMAPI PM_freeLockedMem( uint size, ibool contiguous) { - // TODO: Implement this on QNX + /* TODO: Implement this on QNX */ } void * PMAPI PM_allocPage( ibool locked) { - // TODO: Implement this on QNX + /* TODO: Implement this on QNX */ return NULL; } void PMAPI PM_freePage( void *p) { - // TODO: Implement this on QNX + /* TODO: Implement this on QNX */ } void PMAPI PM_setBankA(int bank) { PM_init(); if (VRegs == NULL) - return; + return; VRegs->l.eax = 0x4F05; VRegs->l.ebx = 0x0000; @@ -771,7 +771,7 @@ void PMAPI PM_setBankAB(int bank) { PM_init(); if (VRegs == NULL) - return; + return; VRegs->l.eax = 0x4F05; VRegs->l.ebx = 0x0000; @@ -788,7 +788,7 @@ void PMAPI PM_setCRTStart(int x,int y,int waitVRT) { PM_init(); if (VRegs == NULL) - return; + return; VRegs->l.eax = 0x4F07; VRegs->l.ebx = waitVRT; @@ -837,7 +837,7 @@ int PMAPI PM_unlockCodePages(void (*p)(),uint len,PM_lockHandle *lh) PM_MODULE PMAPI PM_loadLibrary( const char *szDLLName) { - // TODO: Implement this to load shared libraries! + /* TODO: Implement this to load shared libraries! */ (void)szDLLName; return NULL; } @@ -846,7 +846,7 @@ void * PMAPI PM_getProcAddress( PM_MODULE hModule, const char *szProcName) { - // TODO: Implement this! + /* TODO: Implement this! */ (void)hModule; (void)szProcName; return NULL; @@ -855,14 +855,14 @@ void * PMAPI PM_getProcAddress( void PMAPI PM_freeLibrary( PM_MODULE hModule) { - // TODO: Implement this! + /* TODO: Implement this! */ (void)hModule; } int PMAPI PM_setIOPL( int level) { - // QNX handles IOPL selection at the program link level. + /* QNX handles IOPL selection at the program link level. */ return level; } diff --git a/board/MAI/bios_emulator/scitech/src/pm/rttarget/cpuinfo.c b/board/MAI/bios_emulator/scitech/src/pm/rttarget/cpuinfo.c index 3d6dd44313b..4f32c3e8872 100644 --- a/board/MAI/bios_emulator/scitech/src/pm/rttarget/cpuinfo.c +++ b/board/MAI/bios_emulator/scitech/src/pm/rttarget/cpuinfo.c @@ -46,7 +46,7 @@ static int SetMaxThreadPriority(void) oldPriority = GetThreadPriority(hThread); if (oldPriority != THREAD_PRIORITY_ERROR_RETURN) - SetThreadPriority(hThread, THREAD_PRIORITY_TIME_CRITICAL); + SetThreadPriority(hThread, THREAD_PRIORITY_TIME_CRITICAL); return oldPriority; } @@ -60,7 +60,7 @@ static void RestoreThreadPriority( HANDLE hThread = GetCurrentThread(); if (oldPriority != THREAD_PRIORITY_ERROR_RETURN) - SetThreadPriority(hThread, oldPriority); + SetThreadPriority(hThread, oldPriority); } /**************************************************************************** @@ -71,12 +71,12 @@ static void GetCounterFrequency( CPU_largeInteger *freq) { if (!QueryPerformanceFrequency((LARGE_INTEGER*)freq)) { - havePerformanceCounter = false; - freq->low = 100000; - freq->high = 0; - } + havePerformanceCounter = false; + freq->low = 100000; + freq->high = 0; + } else - havePerformanceCounter = true; + havePerformanceCounter = true; } /**************************************************************************** @@ -86,9 +86,9 @@ Read the counter and return the counter value. #define GetCounter(t) \ { \ if (havePerformanceCounter) \ - QueryPerformanceCounter((LARGE_INTEGER*)t); \ + QueryPerformanceCounter((LARGE_INTEGER*)t); \ else { \ - (t)->low = timeGetTime() * 100; \ - (t)->high = 0; \ - } \ + (t)->low = timeGetTime() * 100; \ + (t)->high = 0; \ + } \ } diff --git a/board/MAI/bios_emulator/scitech/src/pm/rttarget/event.c b/board/MAI/bios_emulator/scitech/src/pm/rttarget/event.c index e9aba21b9f8..962a14a3c15 100644 --- a/board/MAI/bios_emulator/scitech/src/pm/rttarget/event.c +++ b/board/MAI/bios_emulator/scitech/src/pm/rttarget/event.c @@ -71,113 +71,113 @@ void _EVT_pumpMessages(void) event_t evt; while (PeekMessage(&msg,NULL,0,0,PM_REMOVE)) { - memset(&evt,0,sizeof(evt)); - switch (msg.message) { - case WM_MOUSEMOVE: - evt.what = EVT_MOUSEMOVE; - break; - case WM_LBUTTONDBLCLK: - evt.what = EVT_MOUSEDOWN; - evt.message = EVT_LEFTBMASK | EVT_DBLCLICK; - break; - case WM_LBUTTONDOWN: - evt.what = EVT_MOUSEDOWN; - evt.message = EVT_LEFTBMASK; - break; - case WM_LBUTTONUP: - evt.what = EVT_MOUSEUP; - evt.message = EVT_LEFTBMASK; - break; - case WM_RBUTTONDBLCLK: - evt.what = EVT_MOUSEDOWN | EVT_DBLCLICK; - evt.message = EVT_RIGHTBMASK; - break; - case WM_RBUTTONDOWN: - evt.what = EVT_MOUSEDOWN; - evt.message = EVT_RIGHTBMASK; - break; - case WM_RBUTTONUP: - evt.what = EVT_MOUSEUP; - evt.message = EVT_RIGHTBMASK; - break; - case WM_KEYDOWN: - case WM_SYSKEYDOWN: - if (HIWORD(msg.lParam) & KF_REPEAT) { - evt.what = EVT_KEYREPEAT; - } - else { - evt.what = EVT_KEYDOWN; - } - break; - case WM_KEYUP: - case WM_SYSKEYUP: - evt.what = EVT_KEYUP; - break; - } + memset(&evt,0,sizeof(evt)); + switch (msg.message) { + case WM_MOUSEMOVE: + evt.what = EVT_MOUSEMOVE; + break; + case WM_LBUTTONDBLCLK: + evt.what = EVT_MOUSEDOWN; + evt.message = EVT_LEFTBMASK | EVT_DBLCLICK; + break; + case WM_LBUTTONDOWN: + evt.what = EVT_MOUSEDOWN; + evt.message = EVT_LEFTBMASK; + break; + case WM_LBUTTONUP: + evt.what = EVT_MOUSEUP; + evt.message = EVT_LEFTBMASK; + break; + case WM_RBUTTONDBLCLK: + evt.what = EVT_MOUSEDOWN | EVT_DBLCLICK; + evt.message = EVT_RIGHTBMASK; + break; + case WM_RBUTTONDOWN: + evt.what = EVT_MOUSEDOWN; + evt.message = EVT_RIGHTBMASK; + break; + case WM_RBUTTONUP: + evt.what = EVT_MOUSEUP; + evt.message = EVT_RIGHTBMASK; + break; + case WM_KEYDOWN: + case WM_SYSKEYDOWN: + if (HIWORD(msg.lParam) & KF_REPEAT) { + evt.what = EVT_KEYREPEAT; + } + else { + evt.what = EVT_KEYDOWN; + } + break; + case WM_KEYUP: + case WM_SYSKEYUP: + evt.what = EVT_KEYUP; + break; + } - /* Convert mouse event modifier flags */ - if (evt.what & EVT_MOUSEEVT) { - evt.where_x = msg.pt.x; - evt.where_y = msg.pt.y; - if (evt.what == EVT_MOUSEMOVE) { - if (oldMove != -1) { - evtq[oldMove].where_x = evt.where_x;/* Modify existing one */ - evtq[oldMove].where_y = evt.where_y; - evt.what = 0; - } - else { - oldMove = freeHead; /* Save id of this move event */ - } - } - else - oldMove = -1; - if (msg.wParam & MK_LBUTTON) - evt.modifiers |= EVT_LEFTBUT; - if (msg.wParam & MK_RBUTTON) - evt.modifiers |= EVT_RIGHTBUT; - if (msg.wParam & MK_SHIFT) - evt.modifiers |= EVT_SHIFTKEY; - if (msg.wParam & MK_CONTROL) - evt.modifiers |= EVT_CTRLSTATE; - } + /* Convert mouse event modifier flags */ + if (evt.what & EVT_MOUSEEVT) { + evt.where_x = msg.pt.x; + evt.where_y = msg.pt.y; + if (evt.what == EVT_MOUSEMOVE) { + if (oldMove != -1) { + evtq[oldMove].where_x = evt.where_x;/* Modify existing one */ + evtq[oldMove].where_y = evt.where_y; + evt.what = 0; + } + else { + oldMove = freeHead; /* Save id of this move event */ + } + } + else + oldMove = -1; + if (msg.wParam & MK_LBUTTON) + evt.modifiers |= EVT_LEFTBUT; + if (msg.wParam & MK_RBUTTON) + evt.modifiers |= EVT_RIGHTBUT; + if (msg.wParam & MK_SHIFT) + evt.modifiers |= EVT_SHIFTKEY; + if (msg.wParam & MK_CONTROL) + evt.modifiers |= EVT_CTRLSTATE; + } - /* Convert keyboard codes */ - TranslateMessage(&msg); - if (evt.what & EVT_KEYEVT) { - int scanCode = (msg.lParam >> 16) & 0xFF; - if (evt.what == EVT_KEYUP) { - /* Get message for keyup code from table of cached down values */ - evt.message = keyUpMsg[scanCode]; - keyUpMsg[scanCode] = 0; - } - else { - if (PeekMessage(&charMsg,NULL,WM_CHAR,WM_CHAR,PM_REMOVE)) - evt.message = charMsg.wParam; - if (PeekMessage(&charMsg,NULL,WM_SYSCHAR,WM_SYSCHAR,PM_REMOVE)) - evt.message = charMsg.wParam; - evt.message |= ((msg.lParam >> 8) & 0xFF00); - keyUpMsg[scanCode] = (ushort)evt.message; - } - if (evt.what == EVT_KEYREPEAT) - evt.message |= (msg.lParam << 16); - if (HIWORD(msg.lParam) & KF_ALTDOWN) - evt.modifiers |= EVT_ALTSTATE; - if (GetKeyState(VK_SHIFT) & 0x8000U) - evt.modifiers |= EVT_SHIFTKEY; - if (GetKeyState(VK_CONTROL) & 0x8000U) - evt.modifiers |= EVT_CTRLSTATE; - oldMove = -1; - } + /* Convert keyboard codes */ + TranslateMessage(&msg); + if (evt.what & EVT_KEYEVT) { + int scanCode = (msg.lParam >> 16) & 0xFF; + if (evt.what == EVT_KEYUP) { + /* Get message for keyup code from table of cached down values */ + evt.message = keyUpMsg[scanCode]; + keyUpMsg[scanCode] = 0; + } + else { + if (PeekMessage(&charMsg,NULL,WM_CHAR,WM_CHAR,PM_REMOVE)) + evt.message = charMsg.wParam; + if (PeekMessage(&charMsg,NULL,WM_SYSCHAR,WM_SYSCHAR,PM_REMOVE)) + evt.message = charMsg.wParam; + evt.message |= ((msg.lParam >> 8) & 0xFF00); + keyUpMsg[scanCode] = (ushort)evt.message; + } + if (evt.what == EVT_KEYREPEAT) + evt.message |= (msg.lParam << 16); + if (HIWORD(msg.lParam) & KF_ALTDOWN) + evt.modifiers |= EVT_ALTSTATE; + if (GetKeyState(VK_SHIFT) & 0x8000U) + evt.modifiers |= EVT_SHIFTKEY; + if (GetKeyState(VK_CONTROL) & 0x8000U) + evt.modifiers |= EVT_CTRLSTATE; + oldMove = -1; + } - if (evt.what != 0) { - /* Add time stamp and add the event to the queue */ - evt.when = msg.time; - if (count < EVENTQSIZE) { - addEvent(&evt); - } - } - DispatchMessage(&msg); - } + if (evt.what != 0) { + /* Add time stamp and add the event to the queue */ + evt.when = msg.time; + if (count < EVENTQSIZE) { + addEvent(&evt); + } + } + DispatchMessage(&msg); + } } /**************************************************************************** @@ -261,7 +261,7 @@ and this function can be used to resume it again later. ****************************************************************************/ void EVT_resume(void) { - // Do nothing for Win32 + /* Do nothing for Win32 */ } /**************************************************************************** @@ -271,7 +271,7 @@ de-install the event handling code. ****************************************************************************/ void EVT_suspend(void) { - // Do nothing for Win32 + /* Do nothing for Win32 */ } /**************************************************************************** diff --git a/board/MAI/bios_emulator/scitech/src/pm/rttarget/pm.c b/board/MAI/bios_emulator/scitech/src/pm/rttarget/pm.c index e6c1fbd8b31..47d7ed6ab13 100644 --- a/board/MAI/bios_emulator/scitech/src/pm/rttarget/pm.c +++ b/board/MAI/bios_emulator/scitech/src/pm/rttarget/pm.c @@ -59,7 +59,7 @@ Initialise the PM library. ****************************************************************************/ void PMAPI PM_init(void) { - // TODO: dO any special init code in here. + /* TODO: dO any special init code in here. */ MTRR_init(); } @@ -90,9 +90,9 @@ void PMAPI PM_backslash( { uint pos = strlen(s); if (s[pos-1] != '\\') { - s[pos] = '\\'; - s[pos+1] = '\0'; - } + s[pos] = '\\'; + s[pos+1] = '\0'; + } } /**************************************************************************** @@ -113,9 +113,9 @@ void PMAPI PM_fatalError( const char *msg) { if (fatalErrorCleanup) - fatalErrorCleanup(); - // TODO: Display a fatal error message and exit! -// MessageBox(NULL,msg,"Fatal Error!", MB_ICONEXCLAMATION); + fatalErrorCleanup(); + /* TODO: Display a fatal error message and exit! */ +/* MessageBox(NULL,msg,"Fatal Error!", MB_ICONEXCLAMATION); */ exit(1); } @@ -138,7 +138,7 @@ Check if a key has been pressed. ****************************************************************************/ int PMAPI PM_kbhit(void) { - // TODO: Need to check if a key is waiting on the keyboard queue + /* TODO: Need to check if a key is waiting on the keyboard queue */ return true; } @@ -148,7 +148,7 @@ Wait for and return the next keypress. ****************************************************************************/ int PMAPI PM_getch(void) { - // TODO: Need to obtain the next keypress, and block until one is hit + /* TODO: Need to obtain the next keypress, and block until one is hit */ return 0xD; } @@ -240,7 +240,7 @@ Return the path to the Nucleus driver files. ****************************************************************************/ const char * PMAPI PM_getNucleusPath(void) { - // TODO: Point this at the path when the Nucleus drivers will be found + /* TODO: Point this at the path when the Nucleus drivers will be found */ return "c:\\nucleus"; } @@ -294,7 +294,7 @@ void * PMAPI PM_getA0000Pointer(void) { static void *bankPtr; if (!bankPtr) - bankPtr = PM_mapPhysicalAddr(0xA0000,0xFFFF,true); + bankPtr = PM_mapPhysicalAddr(0xA0000,0xFFFF,true); return bankPtr; } @@ -307,7 +307,7 @@ void * PMAPI PM_mapPhysicalAddr( ulong limit, ibool isCached) { - // TODO: Map a physical memory address to a linear address + /* TODO: Map a physical memory address to a linear address */ return NULL; } @@ -319,13 +319,13 @@ void PMAPI PM_freePhysicalAddr( void *ptr, ulong limit) { - // TODO: Free the physical address mapping + /* TODO: Free the physical address mapping */ } 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. */ return 0xFFFFFFFFUL; } @@ -336,24 +336,24 @@ void PMAPI PM_sleep(ulong milliseconds) int PMAPI PM_getCOMPort(int port) { - // TODO: Re-code this to determine real values using the Plug and Play - // manager for the OS. + /* TODO: Re-code this to determine real values using the Plug and Play */ + /* manager for the OS. */ 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) { - // TODO: Re-code this to determine real values using the Plug and Play - // manager for the OS. + /* TODO: Re-code this to determine real values using the Plug and Play */ + /* manager for the OS. */ 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; } @@ -484,8 +484,8 @@ void PMAPI PM_availableMemory( ulong *physical, ulong *total) { - // TODO: Figure out how to determine the available memory. Not entirely - // critical so returning 0 is OK. + /* TODO: Figure out how to determine the available memory. Not entirely */ + /* critical so returning 0 is OK. */ *physical = *total = 0; } @@ -499,7 +499,7 @@ void * PMAPI PM_allocLockedMem( ibool contiguous, ibool below16M) { - // TODO: Allocate a block of locked, phsyically contigous memory for DMA + /* TODO: Allocate a block of locked, phsyically contigous memory for DMA */ return 0; } @@ -510,10 +510,10 @@ Free a block of locked physical memory. void PMAPI PM_freeLockedMem( void *p, uint size, - + ibool contiguous) { - // TODO: Free a locked memory buffer + /* TODO: Free a locked memory buffer */ } /**************************************************************************** @@ -564,7 +564,7 @@ ibool PMAPI PM_doBIOSPOST( PM_MODULE PMAPI PM_loadLibrary( const char *szDLLName) { - // TODO: Implement this to load shared libraries! + /* TODO: Implement this to load shared libraries! */ (void)szDLLName; return NULL; } @@ -573,7 +573,7 @@ void * PMAPI PM_getProcAddress( PM_MODULE hModule, const char *szProcName) { - // TODO: Implement this! + /* TODO: Implement this! */ (void)hModule; (void)szProcName; return NULL; @@ -582,7 +582,7 @@ void * PMAPI PM_getProcAddress( void PMAPI PM_freeLibrary( PM_MODULE hModule) { - // TODO: Implement this! + /* TODO: Implement this! */ (void)hModule; } @@ -594,9 +594,9 @@ ulong PMAPI PM_findFirstFile( const char *filename, PM_findData *findData) { - // TODO: This function should start a directory enumeration search - // given the filename (with wildcards). The data should be - // converted and returned in the findData standard form. + /* TODO: This function should start a directory enumeration search */ + /* given the filename (with wildcards). The data should be */ + /* converted and returned in the findData standard form. */ (void)filename; (void)findData; return PM_FILE_INVALID; @@ -610,10 +610,10 @@ ibool PMAPI PM_findNextFile( ulong handle, PM_findData *findData) { - // TODO: This function should find the next file in directory enumeration - // search given the search criteria defined in the call to - // PM_findFirstFile. The data should be converted and returned - // in the findData standard form. + /* TODO: This function should find the next file in directory enumeration */ + /* search given the search criteria defined in the call to */ + /* PM_findFirstFile. The data should be converted and returned */ + /* in the findData standard form. */ (void)handle; (void)findData; return false; @@ -626,8 +626,8 @@ Function to close the find process void PMAPI PM_findClose( ulong handle) { - // TODO: This function should close the find process. This may do - // nothing for some OS'es. + /* TODO: This function should close the find process. This may do */ + /* nothing for some OS'es. */ (void)handle; } @@ -648,7 +648,7 @@ ibool PMAPI PM_driveValid( char drive) { if (drive == 3) - return true; + return true; return false; } @@ -675,7 +675,7 @@ void PMAPI PM_setFileAttr( const char *filename, uint attrib) { - // TODO: Set the file attributes for a file + /* TODO: Set the file attributes for a file */ (void)filename; (void)attrib; } diff --git a/board/MAI/bios_emulator/scitech/src/pm/rttarget/ztimer.c b/board/MAI/bios_emulator/scitech/src/pm/rttarget/ztimer.c index 52472c385a7..80c184dff1c 100644 --- a/board/MAI/bios_emulator/scitech/src/pm/rttarget/ztimer.c +++ b/board/MAI/bios_emulator/scitech/src/pm/rttarget/ztimer.c @@ -57,9 +57,9 @@ static void __LZTimerOn( LZTimerObject *tm) { if (havePerformanceCounter) - QueryPerformanceCounter((LARGE_INTEGER*)&tm->start); + QueryPerformanceCounter((LARGE_INTEGER*)&tm->start); else - tm->start.low = timeGetTime(); + tm->start.low = timeGetTime(); } /**************************************************************************** @@ -72,14 +72,14 @@ static ulong __LZTimerLap( CPU_largeInteger tmLap,tmCount; if (havePerformanceCounter) { - QueryPerformanceCounter((LARGE_INTEGER*)&tmLap); - _CPU_diffTime64(&tm->start,&tmLap,&tmCount); - return _CPU_calcMicroSec(&tmCount,countFreq.low); - } + QueryPerformanceCounter((LARGE_INTEGER*)&tmLap); + _CPU_diffTime64(&tm->start,&tmLap,&tmCount); + return _CPU_calcMicroSec(&tmCount,countFreq.low); + } else { - tmLap.low = timeGetTime(); - return (tmLap.low - tm->start.low) * 1000L; - } + tmLap.low = timeGetTime(); + return (tmLap.low - tm->start.low) * 1000L; + } } /**************************************************************************** @@ -90,9 +90,9 @@ static void __LZTimerOff( LZTimerObject *tm) { if (havePerformanceCounter) - QueryPerformanceCounter((LARGE_INTEGER*)&tm->end); + QueryPerformanceCounter((LARGE_INTEGER*)&tm->end); else - tm->end.low = timeGetTime(); + tm->end.low = timeGetTime(); } /**************************************************************************** @@ -105,11 +105,11 @@ static ulong __LZTimerCount( CPU_largeInteger tmCount; if (havePerformanceCounter) { - _CPU_diffTime64(&tm->start,&tm->end,&tmCount); - return _CPU_calcMicroSec(&tmCount,countFreq.low); - } + _CPU_diffTime64(&tm->start,&tm->end,&tmCount); + return _CPU_calcMicroSec(&tmCount,countFreq.low); + } else - return (tm->end.low - tm->start.low) * 1000L; + return (tm->end.low - tm->start.low) * 1000L; } /**************************************************************************** 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 fc13bbbe420..533c2615b11 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 d6c95d688c5..99ee3d4be46 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 2596c76a363..98e31bc638f 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 01e180bdca4..794119282e1 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; } diff --git a/board/MAI/bios_emulator/scitech/src/pm/stub/cpuinfo.c b/board/MAI/bios_emulator/scitech/src/pm/stub/cpuinfo.c index 2833a72f448..0615e901658 100644 --- a/board/MAI/bios_emulator/scitech/src/pm/stub/cpuinfo.c +++ b/board/MAI/bios_emulator/scitech/src/pm/stub/cpuinfo.c @@ -37,8 +37,8 @@ Increase the thread priority to maximum, if possible. ****************************************************************************/ static int SetMaxThreadPriority(void) { - // TODO: If you have thread priorities, increase it to maximum for the - // thread for timing the CPU frequency. + /* TODO: If you have thread priorities, increase it to maximum for the */ + /* thread for timing the CPU frequency. */ return oldPriority; } @@ -49,7 +49,7 @@ Restore the original thread priority. static void RestoreThreadPriority( int priority) { - // TODO: Restore the original thread priority on exit. + /* TODO: Restore the original thread priority on exit. */ } /**************************************************************************** @@ -59,8 +59,8 @@ Initialise the counter and return the frequency of the counter. static void GetCounterFrequency( CPU_largeInteger *freq) { - // TODO: Return the frequency of the counter in here. You should try to - // normalise this value to be around 100,000 ticks per second. + /* TODO: Return the frequency of the counter in here. You should try to */ + /* normalise this value to be around 100,000 ticks per second. */ freq->low = 0; freq->high = 0; } diff --git a/board/MAI/bios_emulator/scitech/src/pm/stub/event.c b/board/MAI/bios_emulator/scitech/src/pm/stub/event.c index 8e805d060f6..204c492540c 100644 --- a/board/MAI/bios_emulator/scitech/src/pm/stub/event.c +++ b/board/MAI/bios_emulator/scitech/src/pm/stub/event.c @@ -59,7 +59,7 @@ events. ****************************************************************************/ ulong _EVT_getTicks(void) { - // TODO: Implement this for your OS! + /* TODO: Implement this for your OS! */ } /**************************************************************************** @@ -68,36 +68,36 @@ Pumps all messages in the application message queue into our event queue. ****************************************************************************/ static void _EVT_pumpMessages(void) { - // TODO: The purpose of this function is to read all keyboard and mouse - // events from the OS specific event queue, translate them and post - // them into the SciTech event queue. - // - // NOTE: There are a couple of important things that this function must - // take care of: - // - // 1. Support for KEYDOWN, KEYREPEAT and KEYUP is required. - // - // 2. Support for reading hardware scan code as well as ASCII - // translated values is required. Games use the scan codes rather - // than ASCII values. Scan codes go into the high order byte of the - // keyboard message field. - // - // 3. Support for at least reading mouse motion data (mickeys) from the - // mouse is required. Using the mickey values, we can then translate - // to mouse cursor coordinates scaled to the range of the current - // graphics display mode. Mouse values are scaled based on the - // global 'rangeX' and 'rangeY'. - // - // 4. Support for a timestamp for the events is required, which is - // defined as the number of milliseconds since some event (usually - // system startup). This is the timestamp when the event occurred - // (ie: at interrupt time) not when it was stuff into the SciTech - // event queue. - // - // 5. Support for mouse double click events. If the OS has a native - // mechanism to determine this, it should be used. Otherwise the - // time stamp information will be used by the generic event code - // to generate double click events. + /* TODO: The purpose of this function is to read all keyboard and mouse */ + /* events from the OS specific event queue, translate them and post */ + /* them into the SciTech event queue. */ + /* */ + /* NOTE: There are a couple of important things that this function must */ + /* take care of: */ + /* */ + /* 1. Support for KEYDOWN, KEYREPEAT and KEYUP is required. */ + /* */ + /* 2. Support for reading hardware scan code as well as ASCII */ + /* translated values is required. Games use the scan codes rather */ + /* than ASCII values. Scan codes go into the high order byte of the */ + /* keyboard message field. */ + /* */ + /* 3. Support for at least reading mouse motion data (mickeys) from the */ + /* mouse is required. Using the mickey values, we can then translate */ + /* to mouse cursor coordinates scaled to the range of the current */ + /* graphics display mode. Mouse values are scaled based on the */ + /* global 'rangeX' and 'rangeY'. */ + /* */ + /* 4. Support for a timestamp for the events is required, which is */ + /* defined as the number of milliseconds since some event (usually */ + /* system startup). This is the timestamp when the event occurred */ + /* (ie: at interrupt time) not when it was stuff into the SciTech */ + /* event queue. */ + /* */ + /* 5. Support for mouse double click events. If the OS has a native */ + /* mechanism to determine this, it should be used. Otherwise the */ + /* time stamp information will be used by the generic event code */ + /* to generate double click events. */ } /**************************************************************************** @@ -141,7 +141,7 @@ void EVTAPI EVT_init( initEventQueue(); memset(keyUpMsg,0,sizeof(keyUpMsg)); - // TODO: Do any OS specific initialisation here + /* TODO: Do any OS specific initialisation here */ /* Catch program termination signals so we can clean up properly */ signal(SIGABRT, _EVT_abort); @@ -171,7 +171,7 @@ and this function can be used to resume it again later. ****************************************************************************/ void EVT_resume(void) { - // Do nothing for non DOS systems + /* Do nothing for non DOS systems */ } /**************************************************************************** @@ -181,7 +181,7 @@ de-install the event handling code. ****************************************************************************/ void EVT_suspend(void) { - // Do nothing for non DOS systems + /* Do nothing for non DOS systems */ } /**************************************************************************** @@ -195,5 +195,5 @@ void EVT_exit(void) signal(SIGFPE, SIG_DFL); signal(SIGINT, SIG_DFL); - // TODO: Do any OS specific cleanup in here + /* TODO: Do any OS specific cleanup in here */ } diff --git a/board/MAI/bios_emulator/scitech/src/pm/stub/oshdr.h b/board/MAI/bios_emulator/scitech/src/pm/stub/oshdr.h index 81a20aaf15d..1395cbc3c4b 100644 --- a/board/MAI/bios_emulator/scitech/src/pm/stub/oshdr.h +++ b/board/MAI/bios_emulator/scitech/src/pm/stub/oshdr.h @@ -28,6 +28,6 @@ * ****************************************************************************/ -// TODO: This is where you include OS specific headers for the event handling -// library. You may leave this empty if you have no OS specific headers -// to include. +/* TODO: This is where you include OS specific headers for the event handling */ +/* library. You may leave this empty if you have no OS specific headers */ +/* to include. */ diff --git a/board/MAI/bios_emulator/scitech/src/pm/stub/pm.c b/board/MAI/bios_emulator/scitech/src/pm/stub/pm.c index 51656b05e35..5f278c32dfb 100644 --- a/board/MAI/bios_emulator/scitech/src/pm/stub/pm.c +++ b/board/MAI/bios_emulator/scitech/src/pm/stub/pm.c @@ -38,13 +38,13 @@ #include <stdlib.h> #include <string.h> -// TODO: Include any OS specific headers here! +/* TODO: Include any OS specific headers here! */ /*--------------------------- Global variables ----------------------------*/ -// TODO: If you support access to the BIOS, the following VESABuf globals -// keep track of a single VESA transfer buffer. If you don't support -// access to the BIOS, remove these variables. +/* TODO: If you support access to the BIOS, the following VESABuf globals */ +/* keep track of a single VESA transfer buffer. If you don't support */ +/* access to the BIOS, remove these variables. */ static uint VESABuf_len = 1024; /* Length of the VESABuf buffer */ static void *VESABuf_ptr = NULL; /* Near pointer to VESABuf */ @@ -61,12 +61,12 @@ Initialise the PM library. ****************************************************************************/ void PMAPI PM_init(void) { - // TODO: Do any initialisation in here. This includes getting IOPL - // access for the process calling PM_init. This will get called - // more than once. + /* TODO: Do any initialisation in here. This includes getting IOPL */ + /* access for the process calling PM_init. This will get called */ + /* more than once. */ - // TODO: If you support the supplied MTRR register stuff (you need to - // be at ring 0 for this!), you should initialise it in here. + /* TODO: If you support the supplied MTRR register stuff (you need to */ + /* be at ring 0 for this!), you should initialise it in here. */ /* MTRR_init(); */ } @@ -77,7 +77,7 @@ Return the operating system type identifier. ****************************************************************************/ long PMAPI PM_getOSType(void) { - // TODO: Change this to return the define for your OS from drvlib/os.h + /* TODO: Change this to return the define for your OS from drvlib/os.h */ return _OS_MYOS; } @@ -97,9 +97,9 @@ void PMAPI PM_backslash( { uint pos = strlen(s); if (s[pos-1] != '/') { - s[pos] = '/'; - s[pos+1] = '\0'; - } + s[pos] = '/'; + s[pos+1] = '\0'; + } } /**************************************************************************** @@ -119,11 +119,11 @@ Report a fatal error condition and halt the program. void PMAPI PM_fatalError( const char *msg) { - // TODO: If you are running in a GUI environment without a console, - // this needs to be changed to bring up a fatal error message - // box and terminate the program. + /* TODO: If you are running in a GUI environment without a console, */ + /* this needs to be changed to bring up a fatal error message */ + /* box and terminate the program. */ if (fatalErrorCleanup) - fatalErrorCleanup(); + fatalErrorCleanup(); fprintf(stderr,"%s\n", msg); exit(1); } @@ -134,9 +134,9 @@ Exit handler to kill the VESA transfer buffer. ****************************************************************************/ static void ExitVBEBuf(void) { - // TODO: If you do not have BIOS access, remove this function. + /* TODO: If you do not have BIOS access, remove this function. */ if (VESABuf_ptr) - PM_freeRealSeg(VESABuf_ptr); + PM_freeRealSeg(VESABuf_ptr); VESABuf_ptr = 0; } @@ -149,14 +149,14 @@ void * PMAPI PM_getVESABuf( uint *rseg, uint *roff) { - // TODO: If you do not have BIOS access, simply delete the guts of - // this function and return NULL. + /* 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); - } + /* 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; @@ -169,9 +169,9 @@ Check if a key has been pressed. ****************************************************************************/ int PMAPI PM_kbhit(void) { - // TODO: This function checks if a key is available to be read. This - // should be implemented, but is mostly used by the test programs - // these days. + /* TODO: This function checks if a key is available to be read. This */ + /* should be implemented, but is mostly used by the test programs */ + /* these days. */ return true; } @@ -181,9 +181,9 @@ Wait for and return the next keypress. ****************************************************************************/ int PMAPI PM_getch(void) { - // TODO: This returns the ASCII code of the key pressed. This - // should be implemented, but is mostly used by the test programs - // these days. + /* TODO: This returns the ASCII code of the key pressed. This */ + /* should be implemented, but is mostly used by the test programs */ + /* these days. */ return 0xD; } @@ -193,12 +193,12 @@ Open a fullscreen console mode for output. ****************************************************************************/ int PMAPI PM_openConsole(void) { - // TODO: Opens up a fullscreen console for graphics output. If your - // console does not have graphics/text modes, this can be left - // empty. The main purpose of this is to disable console switching - // when in graphics modes if you can switch away from fullscreen - // consoles (if you want to allow switching, this can be done - // elsewhere with a full save/restore state of the graphics mode). + /* TODO: Opens up a fullscreen console for graphics output. If your */ + /* console does not have graphics/text modes, this can be left */ + /* empty. The main purpose of this is to disable console switching */ + /* when in graphics modes if you can switch away from fullscreen */ + /* consoles (if you want to allow switching, this can be done */ + /* elsewhere with a full save/restore state of the graphics mode). */ return 0; } @@ -208,9 +208,9 @@ Return the size of the state buffer used to save the console state. ****************************************************************************/ int PMAPI PM_getConsoleStateSize(void) { - // TODO: Returns the size of the console state buffer used to save the - // state of the console before going into graphics mode. This is - // used to restore the console back to normal when we are done. + /* TODO: Returns the size of the console state buffer used to save the */ + /* state of the console before going into graphics mode. This is */ + /* used to restore the console back to normal when we are done. */ return 1; } @@ -222,11 +222,11 @@ void PMAPI PM_saveConsoleState( void *stateBuf, int console_id) { - // TODO: Saves the state of the console into the state buffer. This is - // used to restore the console back to normal when we are done. - // We will always restore 80x25 text mode after being in graphics - // mode, so if restoring text mode is all you need to do this can - // be left empty. + /* TODO: Saves the state of the console into the state buffer. This is */ + /* used to restore the console back to normal when we are done. */ + /* We will always restore 80x25 text mode after being in graphics */ + /* mode, so if restoring text mode is all you need to do this can */ + /* be left empty. */ } /**************************************************************************** @@ -237,11 +237,11 @@ void PMAPI PM_restoreConsoleState( const void *stateBuf, int console_id) { - // TODO: Restore the state of the console from the state buffer. This is - // used to restore the console back to normal when we are done. - // We will always restore 80x25 text mode after being in graphics - // mode, so if restoring text mode is all you need to do this can - // be left empty. + /* TODO: Restore the state of the console from the state buffer. This is */ + /* used to restore the console back to normal when we are done. */ + /* We will always restore 80x25 text mode after being in graphics */ + /* mode, so if restoring text mode is all you need to do this can */ + /* be left empty. */ } /**************************************************************************** @@ -251,7 +251,7 @@ Close the console and return to non-fullscreen console mode. void PMAPI PM_closeConsole( int console_id) { - // TODO: Close the console when we are done, going back to text mode. + /* TODO: Close the console when we are done, going back to text mode. */ } /**************************************************************************** @@ -262,8 +262,8 @@ void PM_setOSCursorLocation( int x, int y) { - // TODO: Set the OS console cursor location to the new value. This is - // generally used for new OS ports (used mostly for DOS). + /* TODO: Set the OS console cursor location to the new value. This is */ + /* generally used for new OS ports (used mostly for DOS). */ } /**************************************************************************** @@ -274,8 +274,8 @@ void PM_setOSScreenWidth( int width, int height) { - // TODO: Set the OS console screen width. This is generally unused for - // new OS ports. + /* TODO: Set the OS console screen width. This is generally unused for */ + /* new OS ports. */ } /**************************************************************************** @@ -286,12 +286,12 @@ ibool PMAPI PM_setRealTimeClockHandler( PM_intHandler ih, int frequency) { - // TODO: Install a real time clock interrupt handler. Normally this - // will not be supported from most OS'es in user land, so an - // alternative mechanism is needed to enable software stereo. - // Hence leave this unimplemented unless you have a high priority - // mechanism to call the 32-bit callback when the real time clock - // interrupt fires. + /* TODO: Install a real time clock interrupt handler. Normally this */ + /* will not be supported from most OS'es in user land, so an */ + /* alternative mechanism is needed to enable software stereo. */ + /* Hence leave this unimplemented unless you have a high priority */ + /* mechanism to call the 32-bit callback when the real time clock */ + /* interrupt fires. */ return false; } @@ -302,9 +302,9 @@ Set the real time clock frequency (for stereo modes). void PMAPI PM_setRealTimeClockFrequency( int frequency) { - // TODO: Set the real time clock interrupt frequency. Used for stereo - // LC shutter glasses when doing software stereo. Usually sets - // the frequency to around 2048 Hz. + /* TODO: Set the real time clock interrupt frequency. Used for stereo */ + /* LC shutter glasses when doing software stereo. Usually sets */ + /* the frequency to around 2048 Hz. */ } /**************************************************************************** @@ -313,7 +313,7 @@ Restore the original real time clock handler. ****************************************************************************/ void PMAPI PM_restoreRealTimeClockHandler(void) { - // TODO: Restores the real time clock handler. + /* TODO: Restores the real time clock handler. */ } /**************************************************************************** @@ -333,8 +333,8 @@ Return the drive letter for the boot drive. ****************************************************************************/ char PMAPI PM_getBootDrive(void) { - // TODO: Return the boot drive letter for the OS. Normally this is 'c' - // for DOS based OS'es and '/' for Unices. + /* TODO: Return the boot drive letter for the OS. Normally this is 'c' */ + /* for DOS based OS'es and '/' for Unices. */ return '/'; } @@ -353,8 +353,8 @@ Return the path to the Nucleus driver files. ****************************************************************************/ const char * PMAPI PM_getNucleusPath(void) { - // TODO: Change this to the default path to Nucleus driver files. The - // following is the default for Unices. + /* TODO: Change this to the default path to Nucleus driver files. The */ + /* following is the default for Unices. */ char *env = getenv("NUCLEUS_PATH"); return env ? env : "/usr/lib/nucleus"; } @@ -378,8 +378,8 @@ Return a unique identifier for the machine if possible. ****************************************************************************/ const char * PMAPI PM_getUniqueID(void) { - // TODO: Return a unique ID for the machine. If a unique ID is not - // available, return the machine name. + /* TODO: Return a unique ID for the machine. If a unique ID is not */ + /* available, return the machine name. */ static char buf[128]; gethostname(buf, 128); return buf; @@ -391,7 +391,7 @@ Get the name of the machine on the network. ****************************************************************************/ const char * PMAPI PM_getMachineName(void) { - // TODO: Return the network machine name for the machine. + /* TODO: Return the network machine name for the machine. */ static char buf[128]; gethostname(buf, 128); return buf; @@ -403,10 +403,10 @@ Return a pointer to the real mode BIOS data area. ****************************************************************************/ void * PMAPI PM_getBIOSPointer(void) { - // TODO: This returns a pointer to the real mode BIOS data area. If you - // do not support BIOS access, you can simply return NULL here. + /* TODO: This returns a pointer to the real mode BIOS data area. If you */ + /* do not support BIOS access, you can simply return NULL here. */ if (!zeroPtr) - zeroPtr = PM_mapPhysicalAddr(0,0xFFFFF,true); + zeroPtr = PM_mapPhysicalAddr(0,0xFFFFF,true); return (void*)(zeroPtr + 0x400); } @@ -418,7 +418,7 @@ void * PMAPI PM_getA0000Pointer(void) { static void *bankPtr; if (!bankPtr) - bankPtr = PM_mapPhysicalAddr(0xA0000,0xFFFF,true); + bankPtr = PM_mapPhysicalAddr(0xA0000,0xFFFF,true); return bankPtr; } @@ -431,23 +431,23 @@ void * PMAPI PM_mapPhysicalAddr( ulong limit, ibool isCached) { - // TODO: This function maps a physical memory address to a linear - // address in the address space of the calling process. - - // NOTE: This function *must* be able to handle any phsyical base - // address, and hence you will have to handle rounding of - // the physical base address to a page boundary (ie: 4Kb on - // x86 CPU's) to be able to properly map in the memory - // region. - - // NOTE: If possible the isCached bit should be used to ensure that - // the PCD (Page Cache Disable) and PWT (Page Write Through) - // bits are set to disable caching for a memory mapping used - // for MMIO register access. We also disable caching using - // the MTRR registers for Pentium Pro and later chipsets so if - // MTRR support is enabled for your OS then you can safely ignore - // the isCached flag and always enable caching in the page - // tables. + /* TODO: This function maps a physical memory address to a linear */ + /* address in the address space of the calling process. */ + + /* NOTE: This function *must* be able to handle any phsyical base */ + /* address, and hence you will have to handle rounding of */ + /* the physical base address to a page boundary (ie: 4Kb on */ + /* x86 CPU's) to be able to properly map in the memory */ + /* region. */ + + /* NOTE: If possible the isCached bit should be used to ensure that */ + /* the PCD (Page Cache Disable) and PWT (Page Write Through) */ + /* bits are set to disable caching for a memory mapping used */ + /* for MMIO register access. We also disable caching using */ + /* the MTRR registers for Pentium Pro and later chipsets so if */ + /* MTRR support is enabled for your OS then you can safely ignore */ + /* the isCached flag and always enable caching in the page */ + /* tables. */ return NULL; } @@ -459,9 +459,9 @@ void PMAPI PM_freePhysicalAddr( void *ptr, ulong limit) { - // TODO: This function will free a physical memory mapping previously - // allocated with PM_mapPhysicalAddr() if at all possible. If - // you can't free physical memory mappings, simply do nothing. + /* TODO: This function will free a physical memory mapping previously */ + /* allocated with PM_mapPhysicalAddr() if at all possible. If */ + /* you can't free physical memory mappings, simply do nothing. */ } /**************************************************************************** @@ -470,36 +470,36 @@ Find the physical address of a linear memory address in current process. ****************************************************************************/ 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. */ return 0xFFFFFFFFUL; } void PMAPI PM_sleep(ulong milliseconds) { - // TODO: Put the process to sleep for milliseconds + /* TODO: Put the process to sleep for milliseconds */ } int PMAPI PM_getCOMPort(int port) { - // TODO: Re-code this to determine real values using the Plug and Play - // manager for the OS. + /* TODO: Re-code this to determine real values using the Plug and Play */ + /* manager for the OS. */ 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) { - // TODO: Re-code this to determine real values using the Plug and Play - // manager for the OS. + /* TODO: Re-code this to determine real values using the Plug and Play */ + /* manager for the OS. */ 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; } @@ -510,11 +510,11 @@ Allocate a block of (unnamed) shared memory. void * PMAPI PM_mallocShared( long size) { - // TODO: This is used to allocate memory that is shared between process - // that all access the common Nucleus drivers via a common display - // driver DLL. If your OS does not support shared memory (or if - // the display driver does not need to allocate shared memory - // for each process address space), this should just call PM_malloc. + /* TODO: This is used to allocate memory that is shared between process */ + /* that all access the common Nucleus drivers via a common display */ + /* driver DLL. If your OS does not support shared memory (or if */ + /* the display driver does not need to allocate shared memory */ + /* for each process address space), this should just call PM_malloc. */ return PM_malloc(size); } @@ -525,10 +525,10 @@ Free a block of shared memory. void PMAPI PM_freeShared( void *ptr) { - // TODO: Free the shared memory block. This will be called in the context - // of the original calling process that allocated the shared - // memory with PM_mallocShared. Simply call PM_free if you do not - // need this. + /* TODO: Free the shared memory block. This will be called in the context */ + /* of the original calling process that allocated the shared */ + /* memory with PM_mallocShared. Simply call PM_free if you do not */ + /* need this. */ PM_free(ptr); } @@ -542,16 +542,16 @@ void * PMAPI PM_mapToProcess( void *base, ulong limit) { - // TODO: This function is used to map a physical memory mapping - // previously allocated with PM_mapPhysicalAddr into the - // address space of the calling process. If the memory mapping - // allocated by PM_mapPhysicalAddr is global to all processes, - // simply return the pointer. + /* TODO: This function is used to map a physical memory mapping */ + /* previously allocated with PM_mapPhysicalAddr into the */ + /* address space of the calling process. If the memory mapping */ + /* allocated by PM_mapPhysicalAddr is global to all processes, */ + /* simply return the pointer. */ - // NOTE: This function must also handle rounding to page boundaries, - // since this function is used to map in shared memory buffers - // allocated with PM_mapPhysicalAddr(). Hence if you aligned - // the physical address above, then you also need to do it here. + /* NOTE: This function must also handle rounding to page boundaries, */ + /* since this function is used to map in shared memory buffers */ + /* allocated with PM_mapPhysicalAddr(). Hence if you aligned */ + /* the physical address above, then you also need to do it here. */ return base; } @@ -563,11 +563,11 @@ void * PMAPI PM_mapRealPointer( uint r_seg, uint r_off) { - // TODO: This function maps a real mode memory pointer into the - // calling processes address space as a 32-bit near pointer. If - // you do not support BIOS access, simply return NULL here. + /* TODO: This function maps a real mode memory pointer into the */ + /* calling processes address space as a 32-bit near pointer. If */ + /* you do not support BIOS access, simply return NULL here. */ if (!zeroPtr) - zeroPtr = PM_mapPhysicalAddr(0,0xFFFFF); + zeroPtr = PM_mapPhysicalAddr(0,0xFFFFF); return (void*)(zeroPtr + MK_PHYS(r_seg,r_off)); } @@ -580,10 +580,10 @@ void * PMAPI PM_allocRealSeg( uint *r_seg, uint *r_off) { - // TODO: This function allocates a block of real mode memory for the - // calling process used to communicate with real mode BIOS - // functions. If you do not support BIOS access, simply return - // NULL here. + /* TODO: This function allocates a block of real mode memory for the */ + /* calling process used to communicate with real mode BIOS */ + /* functions. If you do not support BIOS access, simply return */ + /* NULL here. */ return NULL; } @@ -594,8 +594,8 @@ Free a block of real mode memory. void PMAPI PM_freeRealSeg( void *mem) { - // TODO: Frees a previously allocated real mode memory block. If you - // do not support BIOS access, this function should be empty. + /* TODO: Frees a previously allocated real mode memory block. If you */ + /* do not support BIOS access, this function should be empty. */ } /**************************************************************************** @@ -606,9 +606,9 @@ void PMAPI DPMI_int86( int intno, DPMI_regs *regs) { - // TODO: This function calls the real mode BIOS using the passed in - // register structure. If you do not support real mode BIOS - // access, this function should be empty. + /* TODO: This function calls the real mode BIOS using the passed in */ + /* register structure. If you do not support real mode BIOS */ + /* access, this function should be empty. */ } /**************************************************************************** @@ -620,9 +620,9 @@ int PMAPI PM_int86( RMREGS *in, RMREGS *out) { - // TODO: This function calls the real mode BIOS using the passed in - // register structure. If you do not support real mode BIOS - // access, this function should return 0. + /* TODO: This function calls the real mode BIOS using the passed in */ + /* register structure. If you do not support real mode BIOS */ + /* access, this function should return 0. */ return 0; } @@ -636,9 +636,9 @@ int PMAPI PM_int86x( RMREGS *out, RMSREGS *sregs) { - // TODO: This function calls the real mode BIOS using the passed in - // register structure. If you do not support real mode BIOS - // access, this function should return 0. + /* TODO: This function calls the real mode BIOS using the passed in */ + /* register structure. If you do not support real mode BIOS */ + /* access, this function should return 0. */ return 0; } @@ -652,9 +652,9 @@ void PMAPI PM_callRealMode( RMREGS *in, RMSREGS *sregs) { - // TODO: This function calls a real mode far function with a far call. - // If you do not support BIOS access, this function should be - // empty. + /* TODO: This function calls a real mode far function with a far call. */ + /* If you do not support BIOS access, this function should be */ + /* empty. */ } /**************************************************************************** @@ -665,9 +665,9 @@ void PMAPI PM_availableMemory( ulong *physical, ulong *total) { - // TODO: Report the amount of available memory, both the amount of - // physical memory left and the amount of virtual memory left. - // If the OS does not provide these services, report 0's. + /* TODO: Report the amount of available memory, both the amount of */ + /* physical memory left and the amount of virtual memory left. */ + /* If the OS does not provide these services, report 0's. */ *physical = *total = 0; } @@ -681,10 +681,10 @@ void * PMAPI PM_allocLockedMem( ibool contiguous, ibool below16M) { - // TODO: Allocate a block of locked, physical memory of the specified - // size. This is used for bus master operations. If this is not - // supported by the OS, return NULL and bus mastering will not - // be used. + /* TODO: Allocate a block of locked, physical memory of the specified */ + /* size. This is used for bus master operations. If this is not */ + /* supported by the OS, return NULL and bus mastering will not */ + /* be used. */ return NULL; } @@ -697,7 +697,7 @@ void PMAPI PM_freeLockedMem( uint size, ibool contiguous) { - // TODO: Free a memory block allocated with PM_allocLockedMem. + /* TODO: Free a memory block allocated with PM_allocLockedMem. */ } /**************************************************************************** @@ -709,9 +709,9 @@ void PMAPI PM_setBankA( { RMREGS regs; - // TODO: This does a bank switch function by calling the real mode - // VESA BIOS. If you do not support BIOS access, this function should - // be empty. + /* TODO: This does a bank switch function by calling the real mode */ + /* VESA BIOS. If you do not support BIOS access, this function should */ + /* be empty. */ regs.x.ax = 0x4F05; regs.x.bx = 0x0000; regs.x.dx = bank; @@ -727,9 +727,9 @@ void PMAPI PM_setBankAB( { RMREGS regs; - // TODO: This does a bank switch function by calling the real mode - // VESA BIOS. If you do not support BIOS access, this function should - // be empty. + /* TODO: This does a bank switch function by calling the real mode */ + /* VESA BIOS. If you do not support BIOS access, this function should */ + /* be empty. */ regs.x.ax = 0x4F05; regs.x.bx = 0x0000; regs.x.dx = bank; @@ -751,9 +751,9 @@ void PMAPI PM_setCRTStart( { RMREGS regs; - // TODO: This changes the display start address by calling the real mode - // VESA BIOS. If you do not support BIOS access, this function - // should be empty. + /* TODO: This changes the display start address by calling the real mode */ + /* VESA BIOS. If you do not support BIOS access, this function */ + /* should be empty. */ regs.x.ax = 0x4F07; regs.x.bx = waitVRT; regs.x.cx = x; @@ -770,17 +770,17 @@ ibool PMAPI PM_enableWriteCombine( ulong length, uint type) { - // TODO: This function should enable Pentium Pro and Pentium II MTRR - // write combining for the passed in physical memory base address - // and length. Normally this is done via calls to an OS specific - // device driver as this can only be done at ring 0. - // - // NOTE: This is a *very* important function to implement! If you do - // not implement, graphics performance on the latest Intel chips - // will be severly impaired. For sample code that can be used - // directly in a ring 0 device driver, see the MSDOS implementation - // which includes assembler code to do this directly (if the - // program is running at ring 0). + /* TODO: This function should enable Pentium Pro and Pentium II MTRR */ + /* write combining for the passed in physical memory base address */ + /* and length. Normally this is done via calls to an OS specific */ + /* device driver as this can only be done at ring 0. */ + /* */ + /* NOTE: This is a *very* important function to implement! If you do */ + /* not implement, graphics performance on the latest Intel chips */ + /* will be severly impaired. For sample code that can be used */ + /* directly in a ring 0 device driver, see the MSDOS implementation */ + /* which includes assembler code to do this directly (if the */ + /* program is running at ring 0). */ return false; } @@ -793,19 +793,19 @@ ibool PMAPI PM_doBIOSPOST( ulong BIOSPhysAddr, void *mappedBIOS) { - // TODO: This function is used to run the BIOS POST code on a secondary - // controller to initialise it for use. This is not necessary - // for multi-controller operation, but it will make it a lot - // more convenicent for end users (otherwise they have to boot - // the system once with the secondary controller as primary, and - // then boot with both controllers installed). - // - // Even if you don't support full BIOS access, it would be - // adviseable to be able to POST the secondary controllers in the - // system using this function as a minimum requirement. Some - // graphics hardware has registers that contain values that only - // the BIOS knows about, which makes bring up a card from cold - // reset difficult if the BIOS has not POST'ed it. + /* TODO: This function is used to run the BIOS POST code on a secondary */ + /* controller to initialise it for use. This is not necessary */ + /* for multi-controller operation, but it will make it a lot */ + /* more convenicent for end users (otherwise they have to boot */ + /* the system once with the secondary controller as primary, and */ + /* then boot with both controllers installed). */ + /* */ + /* Even if you don't support full BIOS access, it would be */ + /* adviseable to be able to POST the secondary controllers in the */ + /* system using this function as a minimum requirement. Some */ + /* graphics hardware has registers that contain values that only */ + /* the BIOS knows about, which makes bring up a card from cold */ + /* reset difficult if the BIOS has not POST'ed it. */ return false; } @@ -817,8 +817,8 @@ shared libraries, simply return NULL. PM_MODULE PMAPI PM_loadLibrary( const char *szDLLName) { - // TODO: This function should load a native shared library from disk - // given the path to the library. + /* TODO: This function should load a native shared library from disk */ + /* given the path to the library. */ (void)szDLLName; return NULL; } @@ -831,8 +831,8 @@ void * PMAPI PM_getProcAddress( PM_MODULE hModule, const char *szProcName) { - // TODO: This function should return the address of a named procedure - // from a native shared library. + /* TODO: This function should return the address of a named procedure */ + /* from a native shared library. */ (void)hModule; (void)szProcName; return NULL; @@ -845,7 +845,7 @@ Unload a shared library. void PMAPI PM_freeLibrary( PM_MODULE hModule) { - // TODO: This function free a previously loaded native shared library. + /* TODO: This function free a previously loaded native shared library. */ (void)hModule; } @@ -860,8 +860,8 @@ the switch occurred so it can be properly restored. int PMAPI PM_setIOPL( int level) { - // TODO: This function should enable IOPL for the task (if IOPL is - // not always enabled for the app through some other means). + /* TODO: This function should enable IOPL for the task (if IOPL is */ + /* not always enabled for the app through some other means). */ return level; } @@ -873,9 +873,9 @@ void *PMAPI PM_findFirstFile( const char *filename, PM_findData *findData) { - // TODO: This function should start a directory enumeration search - // given the filename (with wildcards). The data should be - // converted and returned in the findData standard form. + /* TODO: This function should start a directory enumeration search */ + /* given the filename (with wildcards). The data should be */ + /* converted and returned in the findData standard form. */ (void)filename; (void)findData; return PM_FILE_INVALID; @@ -889,10 +889,10 @@ ibool PMAPI PM_findNextFile( void *handle, PM_findData *findData) { - // TODO: This function should find the next file in directory enumeration - // search given the search criteria defined in the call to - // PM_findFirstFile. The data should be converted and returned - // in the findData standard form. + /* TODO: This function should find the next file in directory enumeration */ + /* search given the search criteria defined in the call to */ + /* PM_findFirstFile. The data should be converted and returned */ + /* in the findData standard form. */ (void)handle; (void)findData; return false; @@ -905,8 +905,8 @@ Function to close the find process void PMAPI PM_findClose( void *handle) { - // TODO: This function should close the find process. This may do - // nothing for some OS'es. + /* TODO: This function should close the find process. This may do */ + /* nothing for some OS'es. */ (void)handle; } @@ -927,7 +927,7 @@ ibool PMAPI PM_driveValid( char drive) { if (drive == 3) - return true; + return true; return false; } @@ -954,7 +954,7 @@ void PMAPI PM_setFileAttr( const char *filename, uint attrib) { - // TODO: Set the file attributes for a file + /* TODO: Set the file attributes for a file */ (void)filename; (void)attrib; } diff --git a/board/MAI/bios_emulator/scitech/src/pm/stub/ztimer.c b/board/MAI/bios_emulator/scitech/src/pm/stub/ztimer.c index 9bad6c09751..820e292390d 100644 --- a/board/MAI/bios_emulator/scitech/src/pm/stub/ztimer.c +++ b/board/MAI/bios_emulator/scitech/src/pm/stub/ztimer.c @@ -36,7 +36,7 @@ Initialise the Zen Timer module internals. ****************************************************************************/ void __ZTimerInit(void) { - // TODO: Do any specific internal initialisation in here + /* TODO: Do any specific internal initialisation in here */ } /**************************************************************************** @@ -46,8 +46,8 @@ Start the Zen Timer counting. static void __LZTimerOn( LZTimerObject *tm) { - // TODO: Start the Zen Timer counting. This should be a macro if - // possible. + /* TODO: Start the Zen Timer counting. This should be a macro if */ + /* possible. */ } /**************************************************************************** @@ -57,8 +57,8 @@ Compute the lap time since the timer was started. static ulong __LZTimerLap( LZTimerObject *tm) { - // TODO: Compute the lap time between the current time and when the - // timer was started. + /* TODO: Compute the lap time between the current time and when the */ + /* timer was started. */ return 0; } @@ -69,7 +69,7 @@ Stop the Zen Timer counting. static void __LZTimerOff( LZTimerObject *tm) { - // TODO: Stop the timer counting. Should be a macro if possible. + /* TODO: Stop the timer counting. Should be a macro if possible. */ } /**************************************************************************** @@ -79,7 +79,7 @@ Compute the elapsed time in microseconds between start and end timings. static ulong __LZTimerCount( LZTimerObject *tm) { - // TODO: Compute the elapsed time and return it. Always microseconds. + /* TODO: Compute the elapsed time and return it. Always microseconds. */ return 0; } @@ -95,9 +95,9 @@ Read the Long Period timer from the OS ****************************************************************************/ static ulong __ULZReadTime(void) { - // TODO: Read the long period timer from the OS. The resolution of this - // timer should be around 1/20 of a second for timing long - // periods if possible. + /* TODO: Read the long period timer from the OS. The resolution of this */ + /* timer should be around 1/20 of a second for timing long */ + /* periods if possible. */ } /**************************************************************************** diff --git a/board/MAI/bios_emulator/scitech/src/pm/tests/altbrk.c b/board/MAI/bios_emulator/scitech/src/pm/tests/altbrk.c index 5d899b7a67d..ba90262745a 100644 --- a/board/MAI/bios_emulator/scitech/src/pm/tests/altbrk.c +++ b/board/MAI/bios_emulator/scitech/src/pm/tests/altbrk.c @@ -47,43 +47,43 @@ volatile int ctrlCHit = false; void PMAPI breakHandler(uint bHit) { if (bHit) - breakHit = true; + breakHit = true; else - ctrlCHit = true; + ctrlCHit = true; } int main(void) { printf("Program running in "); switch (PM_getModeType()) { - case PM_realMode: - printf("real mode.\n\n"); - break; - case PM_286: - printf("16 bit protected mode.\n\n"); - break; - case PM_386: - printf("32 bit protected mode.\n\n"); - break; - } + case PM_realMode: + printf("real mode.\n\n"); + break; + case PM_286: + printf("16 bit protected mode.\n\n"); + break; + case PM_386: + printf("32 bit protected mode.\n\n"); + break; + } PM_installAltBreakHandler(breakHandler); printf("Control C/Break interrupt handler installed\n"); while (1) { - if (ctrlCHit) { - printf("Code termimated with Ctrl-C.\n"); - break; - } - if (breakHit) { - printf("Code termimated with Ctrl-Break.\n"); - break; - } - if (PM_kbhit() && PM_getch() == 0x1B) { - printf("No break code detected!\n"); - break; - } - printf("Hit Ctrl-C or Ctrl-Break to exit!\n"); - } + if (ctrlCHit) { + printf("Code termimated with Ctrl-C.\n"); + break; + } + if (breakHit) { + printf("Code termimated with Ctrl-Break.\n"); + break; + } + if (PM_kbhit() && PM_getch() == 0x1B) { + printf("No break code detected!\n"); + break; + } + printf("Hit Ctrl-C or Ctrl-Break to exit!\n"); + } PM_restoreBreakHandler(); return 0; diff --git a/board/MAI/bios_emulator/scitech/src/pm/tests/altcrit.c b/board/MAI/bios_emulator/scitech/src/pm/tests/altcrit.c index c5390f68a93..e13730758e4 100644 --- a/board/MAI/bios_emulator/scitech/src/pm/tests/altcrit.c +++ b/board/MAI/bios_emulator/scitech/src/pm/tests/altcrit.c @@ -59,27 +59,27 @@ int main(void) printf("Program running in "); switch (PM_getModeType()) { - case PM_realMode: - printf("real mode.\n\n"); - break; - case PM_286: - printf("16 bit protected mode.\n\n"); - break; - case PM_386: - printf("32 bit protected mode.\n\n"); - break; - } + case PM_realMode: + printf("real mode.\n\n"); + break; + case PM_286: + printf("16 bit protected mode.\n\n"); + break; + case PM_386: + printf("32 bit protected mode.\n\n"); + break; + } PM_installAltCriticalHandler(criticalHandler); printf("Critical Error handler installed - trying to read from A: drive...\n"); f = fopen("a:\bog.bog","rb"); if (f) fclose(f); if (criticalError) { - printf("Critical error occured on INT 21h function %02X!\n", - axValue >> 8); - } + printf("Critical error occured on INT 21h function %02X!\n", + axValue >> 8); + } else - printf("Critical error was not caught!\n"); + printf("Critical error was not caught!\n"); PM_restoreCriticalHandler(); return 0; } diff --git a/board/MAI/bios_emulator/scitech/src/pm/tests/biosptr.c b/board/MAI/bios_emulator/scitech/src/pm/tests/biosptr.c index 43668487af3..5fa3382483c 100644 --- a/board/MAI/bios_emulator/scitech/src/pm/tests/biosptr.c +++ b/board/MAI/bios_emulator/scitech/src/pm/tests/biosptr.c @@ -64,29 +64,29 @@ int main(void) printf("Program running in "); switch (PM_getModeType()) { - case PM_realMode: - printf("real mode.\n\n"); - break; - case PM_286: - printf("16 bit protected mode.\n\n"); - break; - case PM_386: - printf("32 bit protected mode.\n\n"); - break; - } + case PM_realMode: + printf("real mode.\n\n"); + break; + case PM_286: + printf("16 bit protected mode.\n\n"); + break; + case PM_386: + printf("32 bit protected mode.\n\n"); + break; + } bios = PM_getBIOSPointer(); printf("Hit any key to test, Ctrl-Shift-Esc to quit\n"); while (!done) { - if (KB_HIT()) { - c = PM_getch(); - if (c == 0) PM_getch(); - printf("TIME=%-8lX ST=%02X CHAR=%02X ", TICKS(), KB_STAT, c); - printf("\n"); - if ((c == ESC) && SHIFT() && CTRL())/* Ctrl-Shift-Esc */ - break; - } - } + if (KB_HIT()) { + c = PM_getch(); + if (c == 0) PM_getch(); + printf("TIME=%-8lX ST=%02X CHAR=%02X ", TICKS(), KB_STAT, c); + printf("\n"); + if ((c == ESC) && SHIFT() && CTRL())/* Ctrl-Shift-Esc */ + break; + } + } return 0; } diff --git a/board/MAI/bios_emulator/scitech/src/pm/tests/block.c b/board/MAI/bios_emulator/scitech/src/pm/tests/block.c index e9488729567..15d503c0de0 100644 --- a/board/MAI/bios_emulator/scitech/src/pm/tests/block.c +++ b/board/MAI/bios_emulator/scitech/src/pm/tests/block.c @@ -61,9 +61,9 @@ int main(void) ZTimerInit(); LZTimerOn(); for (i = 0; i < LOOPS; i++) { - PM_blockUntilTimeout(DELAY_MSECS); - ReportTime(LZTimerLap()); - } + PM_blockUntilTimeout(DELAY_MSECS); + ReportTime(LZTimerLap()); + } LZTimerOff(); return 0; } diff --git a/board/MAI/bios_emulator/scitech/src/pm/tests/brk.c b/board/MAI/bios_emulator/scitech/src/pm/tests/brk.c index 3561fee921f..10b644656e3 100644 --- a/board/MAI/bios_emulator/scitech/src/pm/tests/brk.c +++ b/board/MAI/bios_emulator/scitech/src/pm/tests/brk.c @@ -44,34 +44,34 @@ int main(void) { printf("Program running in "); switch (PM_getModeType()) { - case PM_realMode: - printf("real mode.\n\n"); - break; - case PM_286: - printf("16 bit protected mode.\n\n"); - break; - case PM_386: - printf("32 bit protected mode.\n\n"); - break; - } + case PM_realMode: + printf("real mode.\n\n"); + break; + case PM_286: + printf("16 bit protected mode.\n\n"); + break; + case PM_386: + printf("32 bit protected mode.\n\n"); + break; + } PM_installBreakHandler(); printf("Control C/Break interrupt handler installed\n"); while (1) { - if (PM_ctrlCHit(1)) { - printf("Code termimated with Ctrl-C.\n"); - break; - } - if (PM_ctrlBreakHit(1)) { - printf("Code termimated with Ctrl-Break.\n"); - break; - } - if (PM_kbhit() && PM_getch() == 0x1B) { - printf("No break code detected!\n"); - break; - } - printf("Hit Ctrl-C or Ctrl-Break to exit!\n"); - } + if (PM_ctrlCHit(1)) { + printf("Code termimated with Ctrl-C.\n"); + break; + } + if (PM_ctrlBreakHit(1)) { + printf("Code termimated with Ctrl-Break.\n"); + break; + } + if (PM_kbhit() && PM_getch() == 0x1B) { + printf("No break code detected!\n"); + break; + } + printf("Hit Ctrl-C or Ctrl-Break to exit!\n"); + } PM_restoreBreakHandler(); return 0; diff --git a/board/MAI/bios_emulator/scitech/src/pm/tests/callreal.c b/board/MAI/bios_emulator/scitech/src/pm/tests/callreal.c index 3897ce99993..4d37cab465d 100644 --- a/board/MAI/bios_emulator/scitech/src/pm/tests/callreal.c +++ b/board/MAI/bios_emulator/scitech/src/pm/tests/callreal.c @@ -58,22 +58,22 @@ int main(void) printf("Program running in "); switch (PM_getModeType()) { - case PM_realMode: - printf("real mode.\n\n"); - break; - case PM_286: - printf("16 bit protected mode.\n\n"); - break; - case PM_386: - printf("32 bit protected mode.\n\n"); - break; - } + case PM_realMode: + printf("real mode.\n\n"); + break; + case PM_286: + printf("16 bit protected mode.\n\n"); + break; + case PM_386: + printf("32 bit protected mode.\n\n"); + break; + } /* Allocate a the block of real mode memory */ if ((p = PM_allocRealSeg(sizeof(realModeCode), &r_seg, &r_off)) == NULL) { - printf("Unable to allocate real mode memory!\n"); - exit(1); - } + printf("Unable to allocate real mode memory!\n"); + exit(1); + } /* Copy the real mode code */ memcpy(p,realModeCode,sizeof(realModeCode)); @@ -89,17 +89,17 @@ int main(void) sregs.ds = 8; PM_callRealMode(r_seg,r_off,®s,&sregs); if (regs.x.ax != 2 || regs.x.bx != 1 || regs.x.cx != 4 || regs.x.dx != 3 - || regs.x.si != 5 || regs.x.di != 6 || sregs.es != 7 - || sregs.ds != 8) { - printf("Real mode call failed!\n"); - printf("\n"); - printf("ax = %04X, bx = %04X, cx = %04X, dx = %04X\n", - regs.x.ax,regs.x.bx,regs.x.cx,regs.x.dx); - printf("si = %04X, di = %04X, es = %04X, ds = %04X\n", - regs.x.si,regs.x.di,sregs.es,sregs.ds); - } + || regs.x.si != 5 || regs.x.di != 6 || sregs.es != 7 + || sregs.ds != 8) { + printf("Real mode call failed!\n"); + printf("\n"); + printf("ax = %04X, bx = %04X, cx = %04X, dx = %04X\n", + regs.x.ax,regs.x.bx,regs.x.cx,regs.x.dx); + printf("si = %04X, di = %04X, es = %04X, ds = %04X\n", + regs.x.si,regs.x.di,sregs.es,sregs.ds); + } else - printf("Real mode call succeeded!\n"); + printf("Real mode call succeeded!\n"); /* Free the memory we allocated */ PM_freeRealSeg(p); diff --git a/board/MAI/bios_emulator/scitech/src/pm/tests/checks.c b/board/MAI/bios_emulator/scitech/src/pm/tests/checks.c index 81737e17d7b..5933ac9f73a 100644 --- a/board/MAI/bios_emulator/scitech/src/pm/tests/checks.c +++ b/board/MAI/bios_emulator/scitech/src/pm/tests/checks.c @@ -80,21 +80,21 @@ void _CHK_defaultFail( sprintf(buf,msg,cond,file,line); if (log) { - fputs(buf,log); - fflush(log); - fclose(log); + fputs(buf,log); + fflush(log); + fclose(log); #ifdef __WINDOWS__ - OutputDebugStr(buf); + OutputDebugStr(buf); #endif - } + } if (fatal) { #ifdef __WINDOWS__ - MessageBox(NULL, buf,"Fatal Error!",MB_ICONEXCLAMATION); + MessageBox(NULL, buf,"Fatal Error!",MB_ICONEXCLAMATION); #else - fputs(buf,stderr); + fputs(buf,stderr); #endif - exit(-1); - } + exit(-1); + } } #endif /* CHECKED */ diff --git a/board/MAI/bios_emulator/scitech/src/pm/tests/cpu.c b/board/MAI/bios_emulator/scitech/src/pm/tests/cpu.c index 34abb2418d5..30e5dd30df8 100644 --- a/board/MAI/bios_emulator/scitech/src/pm/tests/cpu.c +++ b/board/MAI/bios_emulator/scitech/src/pm/tests/cpu.c @@ -41,6 +41,6 @@ int main(void) fflush(stdout); printf("\n\n%s\n", CPU_getProcessorName()); if (CPU_haveRDTSC()) - printf("\nProcessor supports Read Time Stamp Counter performance timer.\n"); + printf("\nProcessor supports Read Time Stamp Counter performance timer.\n"); return 0; } diff --git a/board/MAI/bios_emulator/scitech/src/pm/tests/critical.c b/board/MAI/bios_emulator/scitech/src/pm/tests/critical.c index 21ec9946f7b..60f1251a5d7 100644 --- a/board/MAI/bios_emulator/scitech/src/pm/tests/critical.c +++ b/board/MAI/bios_emulator/scitech/src/pm/tests/critical.c @@ -45,25 +45,25 @@ int main(void) printf("Program running in "); switch (PM_getModeType()) { - case PM_realMode: - printf("real mode.\n\n"); - break; - case PM_286: - printf("16 bit protected mode.\n\n"); - break; - case PM_386: - printf("32 bit protected mode.\n\n"); - break; - } + case PM_realMode: + printf("real mode.\n\n"); + break; + case PM_286: + printf("16 bit protected mode.\n\n"); + break; + case PM_386: + printf("32 bit protected mode.\n\n"); + break; + } PM_installCriticalHandler(); printf("Critical Error handler installed - trying to read from A: drive...\n"); f = fopen("a:\bog.bog","rb"); if (f) fclose(f); if (PM_criticalError(&axcode,&dicode,1)) { - printf("Critical error occured on INT 21h function %02X!\n", - axcode >> 8); - } + printf("Critical error occured on INT 21h function %02X!\n", + axcode >> 8); + } else printf("Critical error was not caught!\n"); PM_restoreCriticalHandler(); return 0; diff --git a/board/MAI/bios_emulator/scitech/src/pm/tests/getch.c b/board/MAI/bios_emulator/scitech/src/pm/tests/getch.c index c70f7ee3c3b..06c2180ceb3 100644 --- a/board/MAI/bios_emulator/scitech/src/pm/tests/getch.c +++ b/board/MAI/bios_emulator/scitech/src/pm/tests/getch.c @@ -309,9 +309,9 @@ KeyEntry *FindKey( KeyEntry *key; for (key = keys; key->code != 0; key++) { - if (key->code == code) - break; - } + if (key->code == code) + break; + } return key; } @@ -326,29 +326,29 @@ void DisplayModifiers( event_t *evt) { if (evt->modifiers & EVT_LEFTBUT) - printf(", LBUT"); + printf(", LBUT"); if (evt->modifiers & EVT_RIGHTBUT) - printf(", RBUT"); + printf(", RBUT"); if (evt->modifiers & EVT_MIDDLEBUT) - printf(", MBUT"); + printf(", MBUT"); if (evt->modifiers & EVT_SHIFTKEY) { - if (evt->modifiers & EVT_LEFTSHIFT) - printf(", LSHIFT"); - if (evt->modifiers & EVT_RIGHTSHIFT) - printf(", RSHIFT"); - } + if (evt->modifiers & EVT_LEFTSHIFT) + printf(", LSHIFT"); + if (evt->modifiers & EVT_RIGHTSHIFT) + printf(", RSHIFT"); + } if (evt->modifiers & EVT_CTRLSTATE) { - if (evt->modifiers & EVT_LEFTCTRL) - printf(", LCTRL"); - if (evt->modifiers & EVT_RIGHTCTRL) - printf(", RCTRL"); - } + if (evt->modifiers & EVT_LEFTCTRL) + printf(", LCTRL"); + if (evt->modifiers & EVT_RIGHTCTRL) + printf(", RCTRL"); + } if (evt->modifiers & EVT_ALTSTATE) { - if (evt->modifiers & EVT_LEFTALT) - printf(", LALT"); - if (evt->modifiers & EVT_RIGHTALT) - printf(", RALT"); - } + if (evt->modifiers & EVT_LEFTALT) + printf(", LALT"); + if (evt->modifiers & EVT_RIGHTALT) + printf(", RALT"); + } } /**************************************************************************** @@ -369,7 +369,7 @@ void DisplayKey( ascii = FindKey(ch,ASCIICodes); scan = FindKey(EVT_scanCode(evt->message),ScanCodes); printf("%s: 0x%04X -> %s, %s, '%c'", - msg, (int)evt->message & 0xFFFF, scan->name, ascii->name, isprint(ch) ? ch : ' '); + msg, (int)evt->message & 0xFFFF, scan->name, ascii->name, isprint(ch) ? ch : ' '); DisplayModifiers(evt); printf("\n"); } @@ -388,15 +388,15 @@ void DisplayMouse( { printf("%s: ", msg); if (evt->message & EVT_LEFTBMASK) - printf("LEFT "); + printf("LEFT "); if (evt->message & EVT_RIGHTBMASK) - printf("RIGHT "); + printf("RIGHT "); if (evt->message & EVT_MIDDLEBMASK) - printf("MIDDLE "); + printf("MIDDLE "); printf("abs(%d,%d), rel(%d,%d)", evt->where_x, evt->where_y, evt->relative_x, evt->relative_y); DisplayModifiers(evt); if (evt->message & EVT_DBLCLICK) - printf(", DBLCLICK"); + printf(", DBLCLICK"); printf("\n"); } @@ -413,12 +413,12 @@ void DisplayJoy( event_t *evt) { printf("%s: Joy1(%4d,%4d,%c%c), Joy2(%4d,%4d,%c%c)\n", msg, - evt->where_x,evt->where_y, - (evt->message & EVT_JOY1_BUTTONA) ? 'A' : 'a', - (evt->message & EVT_JOY1_BUTTONB) ? 'B' : 'b', - evt->relative_x,evt->relative_y, - (evt->message & EVT_JOY2_BUTTONA) ? 'A' : 'a', - (evt->message & EVT_JOY2_BUTTONB) ? 'B' : 'b'); + evt->where_x,evt->where_y, + (evt->message & EVT_JOY1_BUTTONA) ? 'A' : 'a', + (evt->message & EVT_JOY1_BUTTONB) ? 'B' : 'b', + evt->relative_x,evt->relative_y, + (evt->message & EVT_JOY2_BUTTONA) ? 'A' : 'a', + (evt->message & EVT_JOY2_BUTTONB) ? 'B' : 'b'); } /**************************************************************************** @@ -460,41 +460,41 @@ int main(void) EVT_setMouseRange(1024,768); CalibrateJoy(); do { - EVT_pollJoystick(); - if (EVT_getNext(&evt,EVT_EVERYEVT)) { - switch (evt.what) { - case EVT_KEYDOWN: - DisplayKey("EVT_KEYDOWN ", &evt); - if (EVT_scanCode(evt.message) == KB_esc) - done = true; - break; - case EVT_KEYREPEAT: - DisplayKey("EVT_KEYREPEAT", &evt); - break; - case EVT_KEYUP: - DisplayKey("EVT_KEYUP ", &evt); - break; - case EVT_MOUSEDOWN: - DisplayMouse("EVT_MOUSEDOWN", &evt); - break; - case EVT_MOUSEAUTO: - DisplayMouse("EVT_MOUSEAUTO", &evt); - break; - case EVT_MOUSEUP: - DisplayMouse("EVT_MOUSEUP ", &evt); - break; - case EVT_MOUSEMOVE: - DisplayMouse("EVT_MOUSEMOVE", &evt); - break; - case EVT_JOYCLICK: - DisplayJoy("EVT_JOYCLICK ", &evt); - break; - case EVT_JOYMOVE: - DisplayJoy("EVT_JOYMOVE ", &evt); - break; - } - } - } while (!done); + EVT_pollJoystick(); + if (EVT_getNext(&evt,EVT_EVERYEVT)) { + switch (evt.what) { + case EVT_KEYDOWN: + DisplayKey("EVT_KEYDOWN ", &evt); + if (EVT_scanCode(evt.message) == KB_esc) + done = true; + break; + case EVT_KEYREPEAT: + DisplayKey("EVT_KEYREPEAT", &evt); + break; + case EVT_KEYUP: + DisplayKey("EVT_KEYUP ", &evt); + break; + case EVT_MOUSEDOWN: + DisplayMouse("EVT_MOUSEDOWN", &evt); + break; + case EVT_MOUSEAUTO: + DisplayMouse("EVT_MOUSEAUTO", &evt); + break; + case EVT_MOUSEUP: + DisplayMouse("EVT_MOUSEUP ", &evt); + break; + case EVT_MOUSEMOVE: + DisplayMouse("EVT_MOUSEMOVE", &evt); + break; + case EVT_JOYCLICK: + DisplayJoy("EVT_JOYCLICK ", &evt); + break; + case EVT_JOYMOVE: + DisplayJoy("EVT_JOYMOVE ", &evt); + break; + } + } + } while (!done); EVT_exit(); PM_closeConsole(hwndConsole); return 0; diff --git a/board/MAI/bios_emulator/scitech/src/pm/tests/isvesa.c b/board/MAI/bios_emulator/scitech/src/pm/tests/isvesa.c index 9c02452bb3d..67ad2456e80 100644 --- a/board/MAI/bios_emulator/scitech/src/pm/tests/isvesa.c +++ b/board/MAI/bios_emulator/scitech/src/pm/tests/isvesa.c @@ -68,24 +68,24 @@ int main(void) printf("Program running in "); switch (PM_getModeType()) { - case PM_realMode: - printf("real mode.\n\n"); - break; - case PM_286: - printf("16 bit protected mode.\n\n"); - break; - case PM_386: - printf("32 bit protected mode.\n\n"); - break; - } + case PM_realMode: + printf("real mode.\n\n"); + break; + case PM_286: + printf("16 bit protected mode.\n\n"); + break; + case PM_386: + printf("32 bit protected mode.\n\n"); + break; + } /* 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); - } + 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; @@ -95,16 +95,16 @@ int main(void) PM_int86x(0x10, ®s, ®s, &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++; - } - } + 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++; + } + } else - printf("VESA VBE not found\n"); + printf("VESA VBE not found\n"); return 0; } diff --git a/board/MAI/bios_emulator/scitech/src/pm/tests/key.c b/board/MAI/bios_emulator/scitech/src/pm/tests/key.c index cf89f79fb78..dba88853c2f 100644 --- a/board/MAI/bios_emulator/scitech/src/pm/tests/key.c +++ b/board/MAI/bios_emulator/scitech/src/pm/tests/key.c @@ -56,16 +56,16 @@ int main(void) printf("Program running in "); switch (PM_getModeType()) { - case PM_realMode: - printf("real mode.\n\n"); - break; - case PM_286: - printf("16 bit protected mode.\n\n"); - break; - case PM_386: - printf("32 bit protected mode.\n\n"); - break; - } + case PM_realMode: + printf("real mode.\n\n"); + break; + case PM_286: + printf("16 bit protected mode.\n\n"); + break; + case PM_386: + printf("32 bit protected mode.\n\n"); + break; + } /* Install our timer handler and lock handler pages in memory. It is * difficult to get the size of a function in C, but we know our @@ -79,9 +79,9 @@ int main(void) printf("Keyboard interrupt handler installed - Type some characters and\n"); printf("hit ESC to exit\n"); while ((ch = PM_getch()) != 0x1B) { - printf("%c", ch); - fflush(stdout); - } + printf("%c", ch); + fflush(stdout); + } PM_restoreKeyHandler(); PM_restoreBreakHandler(); diff --git a/board/MAI/bios_emulator/scitech/src/pm/tests/key15.c b/board/MAI/bios_emulator/scitech/src/pm/tests/key15.c index 5c0d27a1748..b0b94be9c22 100644 --- a/board/MAI/bios_emulator/scitech/src/pm/tests/key15.c +++ b/board/MAI/bios_emulator/scitech/src/pm/tests/key15.c @@ -59,16 +59,16 @@ int main(void) printf("Program running in "); switch (PM_getModeType()) { - case PM_realMode: - printf("real mode.\n\n"); - break; - case PM_286: - printf("16 bit protected mode.\n\n"); - break; - case PM_386: - printf("32 bit protected mode.\n\n"); - break; - } + case PM_realMode: + printf("real mode.\n\n"); + break; + case PM_286: + printf("16 bit protected mode.\n\n"); + break; + case PM_386: + printf("32 bit protected mode.\n\n"); + break; + } /* Install our timer handler and lock handler pages in memory. It is * difficult to get the size of a function in C, but we know our @@ -82,9 +82,9 @@ int main(void) printf("Keyboard interrupt handler installed - Type some characters and\n"); printf("hit ESC to exit\n"); while ((ch = PM_getch()) != 0x1B) { - printf("%c", ch); - fflush(stdout); - } + printf("%c", ch); + fflush(stdout); + } PM_restoreKey15Handler(); PM_restoreBreakHandler(); diff --git a/board/MAI/bios_emulator/scitech/src/pm/tests/memtest.c b/board/MAI/bios_emulator/scitech/src/pm/tests/memtest.c index 221bfb1a022..a2c655b4a35 100644 --- a/board/MAI/bios_emulator/scitech/src/pm/tests/memtest.c +++ b/board/MAI/bios_emulator/scitech/src/pm/tests/memtest.c @@ -56,16 +56,16 @@ int main(void) printf("Program running in "); switch (PM_getModeType()) { - case PM_realMode: - printf("real mode.\n\n"); - break; - case PM_286: - printf("16 bit protected mode.\n\n"); - break; - case PM_386: - printf("32 bit protected mode.\n\n"); - break; - } + case PM_realMode: + printf("real mode.\n\n"); + break; + case PM_286: + printf("16 bit protected mode.\n\n"); + break; + case PM_386: + printf("32 bit protected mode.\n\n"); + break; + } printf("Memory available at start:\n"); PM_availableMemory(&physical,&total); @@ -73,18 +73,18 @@ int main(void) printf(" Total (including virtual): %ld Kb\n", total / 1024); printf("\n"); for (allocs = i = 0; i < MAXALLOC; i++) { - if ((pa[i] = PM_malloc(10*1024)) != 0) { /* in 10k blocks */ - p = pa[allocs]; - memset(p, 0, 10*1024); /* touch every byte */ - *p = 'x'; /* do something, anything with */ - p[1023] = 'y'; /* the allocated memory */ - allocs++; - printf("Allocated %lu bytes\r", 10*(allocs << 10)); - } - else break; - if (PM_kbhit() && (PM_getch() == 0x1B)) - break; - } + if ((pa[i] = PM_malloc(10*1024)) != 0) { /* in 10k blocks */ + p = pa[allocs]; + memset(p, 0, 10*1024); /* touch every byte */ + *p = 'x'; /* do something, anything with */ + p[1023] = 'y'; /* the allocated memory */ + allocs++; + printf("Allocated %lu bytes\r", 10*(allocs << 10)); + } + else break; + if (PM_kbhit() && (PM_getch() == 0x1B)) + break; + } printf("\n\nAllocated total of %lu bytes\n", 10 * (allocs << 10)); @@ -94,7 +94,7 @@ int main(void) printf(" Total (including virtual): %ld Kb\n", total / 1024); for (i = allocs-1; i >= 0; i--) - PM_free(pa[i]); + PM_free(pa[i]); printf("\nMemory available after freeing all blocks (note that under protected mode\n"); printf("this will most likely not be correct after freeing blocks):\n\n"); diff --git a/board/MAI/bios_emulator/scitech/src/pm/tests/mouse.c b/board/MAI/bios_emulator/scitech/src/pm/tests/mouse.c index 5b426517c82..2765a0d1ccb 100644 --- a/board/MAI/bios_emulator/scitech/src/pm/tests/mouse.c +++ b/board/MAI/bios_emulator/scitech/src/pm/tests/mouse.c @@ -69,23 +69,23 @@ int main(void) printf("Program running in "); switch (PM_getModeType()) { - case PM_realMode: - printf("real mode.\n\n"); - break; - case PM_286: - printf("16 bit protected mode.\n\n"); - break; - case PM_386: - printf("32 bit protected mode.\n\n"); - break; - } + case PM_realMode: + printf("real mode.\n\n"); + break; + case PM_286: + printf("16 bit protected mode.\n\n"); + break; + case PM_386: + printf("32 bit protected mode.\n\n"); + break; + } regs.x.ax = 33; /* Mouse function 33 - Software reset */ PM_int86(0x33,®s,®s); if (regs.x.bx == 0) { - printf("No mouse installed.\n"); - exit(1); - } + printf("No mouse installed.\n"); + exit(1); + } /* Install our mouse handler and lock handler pages in memory. It is * difficult to get the size of a function in C, but we know our @@ -95,9 +95,9 @@ int main(void) PM_lockCodePages((__codePtr)mouseHandler,100,&lh); PM_lockDataPages((void*)&count,sizeof(count),&lh); if (!PM_setMouseHandler(0xFFFF, mouseHandler)) { - printf("Unable to install mouse handler!\n"); - exit(1); - } + printf("Unable to install mouse handler!\n"); + exit(1); + } printf("Mouse handler installed - Hit any key to exit\n"); PM_getch(); diff --git a/board/MAI/bios_emulator/scitech/src/pm/tests/restore.c b/board/MAI/bios_emulator/scitech/src/pm/tests/restore.c index b808052c027..e00be750e3d 100644 --- a/board/MAI/bios_emulator/scitech/src/pm/tests/restore.c +++ b/board/MAI/bios_emulator/scitech/src/pm/tests/restore.c @@ -45,24 +45,24 @@ void setVideoMode(int mode) int main(void) { PM_HWND hwndConsole; - ulong stateSize; + ulong stateSize; void *stateBuf; FILE *f; /* Write the saved console state buffer to disk */ if ((f = fopen("/etc/pmsave.dat","rb")) == NULL) { - printf("Unable to open /etc/pmsave.dat for reading!\n"); - return -1; - } + printf("Unable to open /etc/pmsave.dat for reading!\n"); + return -1; + } fread(&stateSize,1,sizeof(stateSize),f); if (stateSize != PM_getConsoleStateSize()) { - printf("Size mismatch in /etc/pmsave.dat!\n"); - return -1; - } + printf("Size mismatch in /etc/pmsave.dat!\n"); + return -1; + } if ((stateBuf = PM_malloc(stateSize)) == NULL) { - printf("Unable to allocate console state buffer!\n"); - return -1; - } + printf("Unable to allocate console state buffer!\n"); + return -1; + } fread(stateBuf,1,stateSize,f); fclose(f); @@ -71,7 +71,7 @@ int main(void) /* Forcibly set 80x25 text mode using the BIOS */ setVideoMode(0x3); - + /* Restore the previous console state */ PM_restoreConsoleState(stateBuf,0); PM_closeConsole(hwndConsole); @@ -79,4 +79,3 @@ int main(void) printf("Console state successfully restored from /etc/pmsave.dat\n"); return 0; } - diff --git a/board/MAI/bios_emulator/scitech/src/pm/tests/rtc.c b/board/MAI/bios_emulator/scitech/src/pm/tests/rtc.c index 07c6eaafd47..acef9226a8a 100644 --- a/board/MAI/bios_emulator/scitech/src/pm/tests/rtc.c +++ b/board/MAI/bios_emulator/scitech/src/pm/tests/rtc.c @@ -52,16 +52,16 @@ int main(void) printf("Program running in "); switch (PM_getModeType()) { - case PM_realMode: - printf("real mode.\n\n"); - break; - case PM_286: - printf("16 bit protected mode.\n\n"); - break; - case PM_386: - printf("32 bit protected mode.\n\n"); - break; - } + case PM_realMode: + printf("real mode.\n\n"); + break; + case PM_286: + printf("16 bit protected mode.\n\n"); + break; + case PM_386: + printf("32 bit protected mode.\n\n"); + break; + } /* Install our timer handler and lock handler pages in memory. It is * difficult to get the size of a function in C, but we know our @@ -75,13 +75,13 @@ int main(void) printf("RealTimeClock interrupt handler installed - Hit ESC to exit\n"); oldCount = count; while (1) { - if (PM_kbhit() && (PM_getch() == 0x1B)) - break; - if (count != oldCount) { - printf("Tick, Tock: %ld\n", count); - oldCount = count; - } - } + if (PM_kbhit() && (PM_getch() == 0x1B)) + break; + if (count != oldCount) { + printf("Tick, Tock: %ld\n", count); + oldCount = count; + } + } PM_restoreRealTimeClockHandler(); PM_restoreBreakHandler(); diff --git a/board/MAI/bios_emulator/scitech/src/pm/tests/save.c b/board/MAI/bios_emulator/scitech/src/pm/tests/save.c index be96968f62e..f7324562f86 100644 --- a/board/MAI/bios_emulator/scitech/src/pm/tests/save.c +++ b/board/MAI/bios_emulator/scitech/src/pm/tests/save.c @@ -37,7 +37,7 @@ int main(void) { PM_HWND hwndConsole; - ulong stateSize; + ulong stateSize; void *stateBuf; FILE *f; @@ -45,26 +45,25 @@ int main(void) hwndConsole = PM_openConsole(0,0,0,0,0,true); stateSize = PM_getConsoleStateSize(); if ((stateBuf = PM_malloc(stateSize)) == NULL) { - PM_closeConsole(hwndConsole); - printf("Unable to allocate console state buffer!\n"); - return -1; - } + PM_closeConsole(hwndConsole); + printf("Unable to allocate console state buffer!\n"); + return -1; + } PM_saveConsoleState(stateBuf,0); - + /* Restore the console state on exit */ PM_restoreConsoleState(stateBuf,0); PM_closeConsole(hwndConsole); - + /* Write the saved console state buffer to disk */ if ((f = fopen("/etc/pmsave.dat","wb")) == NULL) - printf("Unable to open /etc/pmsave/dat for writing!\n"); + printf("Unable to open /etc/pmsave/dat for writing!\n"); else { - fwrite(&stateSize,1,sizeof(stateSize),f); - fwrite(stateBuf,1,stateSize,f); - fclose(f); - printf("Console state successfully saved to /etc/pmsave.dat\n"); - } + fwrite(&stateSize,1,sizeof(stateSize),f); + fwrite(stateBuf,1,stateSize,f); + fclose(f); + printf("Console state successfully saved to /etc/pmsave.dat\n"); + } PM_free(stateBuf); return 0; } - diff --git a/board/MAI/bios_emulator/scitech/src/pm/tests/showpci.c b/board/MAI/bios_emulator/scitech/src/pm/tests/showpci.c index 8222b86024b..be275e1a041 100644 --- a/board/MAI/bios_emulator/scitech/src/pm/tests/showpci.c +++ b/board/MAI/bios_emulator/scitech/src/pm/tests/showpci.c @@ -58,123 +58,123 @@ static void EnumeratePCI(void) PCIDeviceInfo *info; printf("Displaying enumeration of PCI bus (%d devices, %d display devices)\n", - NumPCI, NumDevices); + NumPCI, NumDevices); for (index = 0; index < NumDevices; index++) - printf(" Display device %d is PCI device %d\n",index,DeviceIndex[index]); + printf(" Display device %d is PCI device %d\n",index,DeviceIndex[index]); printf("\n"); printf("Bus Slot Fnc DeviceID SubSystem Rev Class IRQ Int Cmd\n"); for (i = 0; i < NumPCI; i++) { - printf("%2d %2d %2d %04X:%04X %04X:%04X %02X %02X:%02X %02X %02X %04X ", - PCI[i].slot.p.Bus, - PCI[i].slot.p.Device, - PCI[i].slot.p.Function, - PCI[i].VendorID, - PCI[i].DeviceID, - PCI[i].u.type0.SubSystemVendorID, - PCI[i].u.type0.SubSystemID, - PCI[i].RevID, - PCI[i].BaseClass, - PCI[i].SubClass, - PCI[i].u.type0.InterruptLine, - PCI[i].u.type0.InterruptPin, - PCI[i].Command); - for (index = 0; index < NumDevices; index++) { - if (DeviceIndex[index] == i) - break; - } - if (index < NumDevices) - printf("<- %d\n", index); - else - printf("\n"); - } + printf("%2d %2d %2d %04X:%04X %04X:%04X %02X %02X:%02X %02X %02X %04X ", + PCI[i].slot.p.Bus, + PCI[i].slot.p.Device, + PCI[i].slot.p.Function, + PCI[i].VendorID, + PCI[i].DeviceID, + PCI[i].u.type0.SubSystemVendorID, + PCI[i].u.type0.SubSystemID, + PCI[i].RevID, + PCI[i].BaseClass, + PCI[i].SubClass, + PCI[i].u.type0.InterruptLine, + PCI[i].u.type0.InterruptPin, + PCI[i].Command); + for (index = 0; index < NumDevices; index++) { + if (DeviceIndex[index] == i) + break; + } + if (index < NumDevices) + printf("<- %d\n", index); + else + printf("\n"); + } printf("\n"); printf("DeviceID Stat Ifc Cch Lat Hdr BIST\n"); for (i = 0; i < NumPCI; i++) { - printf("%04X:%04X %04X %02X %02X %02X %02X %02X ", - PCI[i].VendorID, - PCI[i].DeviceID, - PCI[i].Status, - PCI[i].Interface, - PCI[i].CacheLineSize, - PCI[i].LatencyTimer, - PCI[i].HeaderType, - PCI[i].BIST); - for (index = 0; index < NumDevices; index++) { - if (DeviceIndex[index] == i) - break; - } - if (index < NumDevices) - printf("<- %d\n", index); - else - printf("\n"); - } + printf("%04X:%04X %04X %02X %02X %02X %02X %02X ", + PCI[i].VendorID, + PCI[i].DeviceID, + PCI[i].Status, + PCI[i].Interface, + PCI[i].CacheLineSize, + PCI[i].LatencyTimer, + PCI[i].HeaderType, + PCI[i].BIST); + for (index = 0; index < NumDevices; index++) { + if (DeviceIndex[index] == i) + break; + } + if (index < NumDevices) + printf("<- %d\n", index); + else + printf("\n"); + } printf("\n"); printf("DeviceID Base10h Base14h Base18h Base1Ch Base20h Base24h ROMBase\n"); for (i = 0; i < NumPCI; i++) { - printf("%04X:%04X %08lX %08lX %08lX %08lX %08lX %08lX %08lX ", - PCI[i].VendorID, - PCI[i].DeviceID, - PCI[i].u.type0.BaseAddress10, - PCI[i].u.type0.BaseAddress14, - PCI[i].u.type0.BaseAddress18, - PCI[i].u.type0.BaseAddress1C, - PCI[i].u.type0.BaseAddress20, - PCI[i].u.type0.BaseAddress24, - PCI[i].u.type0.ROMBaseAddress); - for (index = 0; index < NumDevices; index++) { - if (DeviceIndex[index] == i) - break; - } - if (index < NumDevices) - printf("<- %d\n", index); - else - printf("\n"); - } + printf("%04X:%04X %08lX %08lX %08lX %08lX %08lX %08lX %08lX ", + PCI[i].VendorID, + PCI[i].DeviceID, + PCI[i].u.type0.BaseAddress10, + PCI[i].u.type0.BaseAddress14, + PCI[i].u.type0.BaseAddress18, + PCI[i].u.type0.BaseAddress1C, + PCI[i].u.type0.BaseAddress20, + PCI[i].u.type0.BaseAddress24, + PCI[i].u.type0.ROMBaseAddress); + for (index = 0; index < NumDevices; index++) { + if (DeviceIndex[index] == i) + break; + } + if (index < NumDevices) + printf("<- %d\n", index); + else + printf("\n"); + } printf("\n"); printf("DeviceID BAR10Len BAR14Len BAR18Len BAR1CLen BAR20Len BAR24Len ROMLen\n"); for (i = 0; i < NumPCI; i++) { - printf("%04X:%04X %08lX %08lX %08lX %08lX %08lX %08lX %08lX ", - PCI[i].VendorID, - PCI[i].DeviceID, - PCI[i].u.type0.BaseAddress10Len, - PCI[i].u.type0.BaseAddress14Len, - PCI[i].u.type0.BaseAddress18Len, - PCI[i].u.type0.BaseAddress1CLen, - PCI[i].u.type0.BaseAddress20Len, - PCI[i].u.type0.BaseAddress24Len, - PCI[i].u.type0.ROMBaseAddressLen); - for (index = 0; index < NumDevices; index++) { - if (DeviceIndex[index] == i) - break; - } - if (index < NumDevices) - printf("<- %d\n", index); - else - printf("\n"); - } + printf("%04X:%04X %08lX %08lX %08lX %08lX %08lX %08lX %08lX ", + PCI[i].VendorID, + PCI[i].DeviceID, + PCI[i].u.type0.BaseAddress10Len, + PCI[i].u.type0.BaseAddress14Len, + PCI[i].u.type0.BaseAddress18Len, + PCI[i].u.type0.BaseAddress1CLen, + PCI[i].u.type0.BaseAddress20Len, + PCI[i].u.type0.BaseAddress24Len, + PCI[i].u.type0.ROMBaseAddressLen); + for (index = 0; index < NumDevices; index++) { + if (DeviceIndex[index] == i) + break; + } + if (index < NumDevices) + printf("<- %d\n", index); + else + printf("\n"); + } printf("\n"); printf("Displaying enumeration of %d bridge devices\n",NumBridges); printf("\n"); printf("DeviceID P# S# B# IOB IOL MemBase MemLimit PreBase PreLimit Ctrl\n"); for (i = 0; i < NumBridges; i++) { - info = (PCIDeviceInfo*)&PCI[BridgeIndex[i]]; - printf("%04X:%04X %02X %02X %02X %04X %04X %08X %08X %08X %08X %04X\n", - info->VendorID, - info->DeviceID, - info->u.type1.PrimaryBusNumber, - info->u.type1.SecondayBusNumber, - info->u.type1.SubordinateBusNumber, - ((u16)info->u.type1.IOBase << 8) & 0xF000, - info->u.type1.IOLimit ? - ((u16)info->u.type1.IOLimit << 8) | 0xFFF : 0, - ((u32)info->u.type1.MemoryBase << 16) & 0xFFF00000, - info->u.type1.MemoryLimit ? - ((u32)info->u.type1.MemoryLimit << 16) | 0xFFFFF : 0, - ((u32)info->u.type1.PrefetchableMemoryBase << 16) & 0xFFF00000, - info->u.type1.PrefetchableMemoryLimit ? - ((u32)info->u.type1.PrefetchableMemoryLimit << 16) | 0xFFFFF : 0, - info->u.type1.BridgeControl); - } + info = (PCIDeviceInfo*)&PCI[BridgeIndex[i]]; + printf("%04X:%04X %02X %02X %02X %04X %04X %08X %08X %08X %08X %04X\n", + info->VendorID, + info->DeviceID, + info->u.type1.PrimaryBusNumber, + info->u.type1.SecondayBusNumber, + info->u.type1.SubordinateBusNumber, + ((u16)info->u.type1.IOBase << 8) & 0xF000, + info->u.type1.IOLimit ? + ((u16)info->u.type1.IOLimit << 8) | 0xFFF : 0, + ((u32)info->u.type1.MemoryBase << 16) & 0xFFF00000, + info->u.type1.MemoryLimit ? + ((u32)info->u.type1.MemoryLimit << 16) | 0xFFFFF : 0, + ((u32)info->u.type1.PrefetchableMemoryBase << 16) & 0xFFF00000, + info->u.type1.PrefetchableMemoryLimit ? + ((u32)info->u.type1.PrefetchableMemoryLimit << 16) | 0xFFFFF : 0, + info->u.type1.BridgeControl); + } printf("\n"); } @@ -191,63 +191,63 @@ static int PCI_enumerateDevices(void) int i,j; PCIDeviceInfo *info; - // If this is the first time we have been called, enumerate all - // devices on the PCI bus. + /* If this is the first time we have been called, enumerate all */ + /* devices on the PCI bus. */ if (NumPCI == -1) { - if ((NumPCI = PCI_getNumDevices()) == 0) - return -1; - PCI = malloc(NumPCI * sizeof(PCI[0])); - BridgeIndex = malloc(NumPCI * sizeof(BridgeIndex[0])); - DeviceIndex = malloc(NumPCI * sizeof(DeviceIndex[0])); - if (!PCI || !BridgeIndex || !DeviceIndex) - return -1; - for (i = 0; i < NumPCI; i++) - PCI[i].dwSize = sizeof(PCI[i]); - if (PCI_enumerate(PCI) == 0) - return -1; + if ((NumPCI = PCI_getNumDevices()) == 0) + return -1; + PCI = malloc(NumPCI * sizeof(PCI[0])); + BridgeIndex = malloc(NumPCI * sizeof(BridgeIndex[0])); + DeviceIndex = malloc(NumPCI * sizeof(DeviceIndex[0])); + if (!PCI || !BridgeIndex || !DeviceIndex) + return -1; + for (i = 0; i < NumPCI; i++) + PCI[i].dwSize = sizeof(PCI[i]); + if (PCI_enumerate(PCI) == 0) + return -1; - // Build a list of all PCI bridge devices - for (i = 0,NumBridges = 0,BridgeIndex[0] = -1; i < NumPCI; i++) { - if (PCI[i].BaseClass == PCI_BRIDGE_CLASS) - BridgeIndex[NumBridges++] = i; - } + /* Build a list of all PCI bridge devices */ + for (i = 0,NumBridges = 0,BridgeIndex[0] = -1; i < NumPCI; i++) { + if (PCI[i].BaseClass == PCI_BRIDGE_CLASS) + BridgeIndex[NumBridges++] = i; + } - // Now build a list of all display class devices - for (i = 0,NumDevices = 1,DeviceIndex[0] = -1; i < NumPCI; i++) { - if (PCI_IS_DISPLAY_CLASS(&PCI[i])) { - if ((PCI[i].Command & 0x3) == 0x3) - DeviceIndex[0] = i; - else - DeviceIndex[NumDevices++] = i; - if (PCI[i].slot.p.Bus != 0) { - // This device is on a different bus than the primary - // PCI bus, so it is probably an AGP device. Find the - // AGP bus device that controls that bus so we can - // control it. - for (j = 0; j < NumBridges; j++) { - info = (PCIDeviceInfo*)&PCI[BridgeIndex[j]]; - if (info->u.type1.SecondayBusNumber == PCI[i].slot.p.Bus) { - AGPBridge = info; - break; - } - } - } - } - } + /* Now build a list of all display class devices */ + for (i = 0,NumDevices = 1,DeviceIndex[0] = -1; i < NumPCI; i++) { + if (PCI_IS_DISPLAY_CLASS(&PCI[i])) { + if ((PCI[i].Command & 0x3) == 0x3) + DeviceIndex[0] = i; + else + DeviceIndex[NumDevices++] = i; + if (PCI[i].slot.p.Bus != 0) { + /* This device is on a different bus than the primary */ + /* PCI bus, so it is probably an AGP device. Find the */ + /* AGP bus device that controls that bus so we can */ + /* control it. */ + for (j = 0; j < NumBridges; j++) { + info = (PCIDeviceInfo*)&PCI[BridgeIndex[j]]; + if (info->u.type1.SecondayBusNumber == PCI[i].slot.p.Bus) { + AGPBridge = info; + break; + } + } + } + } + } - // Enumerate all PCI and bridge devices to standard output - EnumeratePCI(); - } + /* Enumerate all PCI and bridge devices to standard output */ + EnumeratePCI(); + } return NumDevices; } int main(void) { - // Enumerate all PCI devices + /* Enumerate all PCI devices */ PM_init(); if (PCI_enumerateDevices() < 1) { - printf("No PCI display devices found!\n"); - return -1; - } + printf("No PCI display devices found!\n"); + return -1; + } return 0; } diff --git a/board/MAI/bios_emulator/scitech/src/pm/tests/tick.c b/board/MAI/bios_emulator/scitech/src/pm/tests/tick.c index ee1014fb9f5..378725ebe62 100644 --- a/board/MAI/bios_emulator/scitech/src/pm/tests/tick.c +++ b/board/MAI/bios_emulator/scitech/src/pm/tests/tick.c @@ -54,16 +54,16 @@ int main(void) printf("Program running in "); switch (PM_getModeType()) { - case PM_realMode: - printf("real mode.\n\n"); - break; - case PM_286: - printf("16 bit protected mode.\n\n"); - break; - case PM_386: - printf("32 bit protected mode.\n\n"); - break; - } + case PM_realMode: + printf("real mode.\n\n"); + break; + case PM_286: + printf("16 bit protected mode.\n\n"); + break; + case PM_386: + printf("32 bit protected mode.\n\n"); + break; + } /* Install our timer handler and lock handler pages in memory. It is * difficult to get the size of a function in C, but we know our @@ -77,13 +77,13 @@ int main(void) printf("Timer interrupt handler installed - Hit ESC to exit\n"); oldCount = count; while (1) { - if (PM_kbhit() && (PM_getch() == 0x1B)) - break; - if (count != oldCount) { - printf("Tick, Tock: %ld\n", count); - oldCount = count; - } - } + if (PM_kbhit() && (PM_getch() == 0x1B)) + break; + if (count != oldCount) { + printf("Tick, Tock: %ld\n", count); + oldCount = count; + } + } PM_restoreTimerHandler(); PM_restoreBreakHandler(); diff --git a/board/MAI/bios_emulator/scitech/src/pm/tests/timerc.c b/board/MAI/bios_emulator/scitech/src/pm/tests/timerc.c index 55e95a85d6c..7fa77b77b89 100644 --- a/board/MAI/bios_emulator/scitech/src/pm/tests/timerc.c +++ b/board/MAI/bios_emulator/scitech/src/pm/tests/timerc.c @@ -69,8 +69,8 @@ int main(void) LZTimerOn(); for (j = 0; j < 10; j++) - for (i = 0; i < 20000; i++) - i = i; + for (i = 0; i < 20000; i++) + i = i; LZTimerOff(); ReportTime(LZTimerCount()); @@ -80,7 +80,7 @@ int main(void) delay(DELAY_SECS * 1000); finish = ULZReadTime(); printf("Delay of %d secs took %d 1/10ths of a second\n", - DELAY_SECS,ULZElapsedTime(start,finish)); + DELAY_SECS,ULZElapsedTime(start,finish)); #endif return 0; diff --git a/board/MAI/bios_emulator/scitech/src/pm/tests/uswc.c b/board/MAI/bios_emulator/scitech/src/pm/tests/uswc.c index 0892e25f3a5..f0c7bd6311f 100644 --- a/board/MAI/bios_emulator/scitech/src/pm/tests/uswc.c +++ b/board/MAI/bios_emulator/scitech/src/pm/tests/uswc.c @@ -66,50 +66,50 @@ static int PCI_enumerateDevices(void) int i,j; PCIDeviceInfo *info; - // If this is the first time we have been called, enumerate all - // devices on the PCI bus. + /* If this is the first time we have been called, enumerate all */ + /* devices on the PCI bus. */ if (NumPCI == -1) { - if ((NumPCI = PCI_getNumDevices()) == 0) - return -1; - PCI = malloc(NumPCI * sizeof(PCI[0])); - BridgeIndex = malloc(NumPCI * sizeof(BridgeIndex[0])); - DeviceIndex = malloc(NumPCI * sizeof(DeviceIndex[0])); - if (!PCI || !BridgeIndex || !DeviceIndex) - return -1; - for (i = 0; i < NumPCI; i++) - PCI[i].dwSize = sizeof(PCI[i]); - if (PCI_enumerate(PCI) == 0) - return -1; + if ((NumPCI = PCI_getNumDevices()) == 0) + return -1; + PCI = malloc(NumPCI * sizeof(PCI[0])); + BridgeIndex = malloc(NumPCI * sizeof(BridgeIndex[0])); + DeviceIndex = malloc(NumPCI * sizeof(DeviceIndex[0])); + if (!PCI || !BridgeIndex || !DeviceIndex) + return -1; + for (i = 0; i < NumPCI; i++) + PCI[i].dwSize = sizeof(PCI[i]); + if (PCI_enumerate(PCI) == 0) + return -1; - // Build a list of all PCI bridge devices - for (i = 0,NumBridges = 0,BridgeIndex[0] = -1; i < NumPCI; i++) { - if (PCI[i].BaseClass == PCI_BRIDGE_CLASS) - BridgeIndex[NumBridges++] = i; - } + /* Build a list of all PCI bridge devices */ + for (i = 0,NumBridges = 0,BridgeIndex[0] = -1; i < NumPCI; i++) { + if (PCI[i].BaseClass == PCI_BRIDGE_CLASS) + BridgeIndex[NumBridges++] = i; + } - // Now build a list of all display class devices - for (i = 0,NumDevices = 1,DeviceIndex[0] = -1; i < NumPCI; i++) { - if (PCI_IS_DISPLAY_CLASS(&PCI[i])) { - if ((PCI[i].Command & 0x3) == 0x3) - DeviceIndex[0] = i; - else - DeviceIndex[NumDevices++] = i; - if (PCI[i].slot.p.Bus != 0) { - // This device is on a different bus than the primary - // PCI bus, so it is probably an AGP device. Find the - // AGP bus device that controls that bus so we can - // control it. - for (j = 0; j < NumBridges; j++) { - info = (PCIDeviceInfo*)&PCI[BridgeIndex[j]]; - if (info->u.type1.SecondayBusNumber == PCI[i].slot.p.Bus) { - AGPBridge = info; - break; - } - } - } - } - } - } + /* Now build a list of all display class devices */ + for (i = 0,NumDevices = 1,DeviceIndex[0] = -1; i < NumPCI; i++) { + if (PCI_IS_DISPLAY_CLASS(&PCI[i])) { + if ((PCI[i].Command & 0x3) == 0x3) + DeviceIndex[0] = i; + else + DeviceIndex[NumDevices++] = i; + if (PCI[i].slot.p.Bus != 0) { + /* This device is on a different bus than the primary */ + /* PCI bus, so it is probably an AGP device. Find the */ + /* AGP bus device that controls that bus so we can */ + /* control it. */ + for (j = 0; j < NumBridges; j++) { + info = (PCIDeviceInfo*)&PCI[BridgeIndex[j]]; + if (info->u.type1.SecondayBusNumber == PCI[i].slot.p.Bus) { + AGPBridge = info; + break; + } + } + } + } + } + } return NumDevices; } @@ -125,17 +125,17 @@ static void ShowDisplayDevices(void) printf("\n"); printf("DeviceID SubSystem Base10h (length ) Base14h (length )\n"); for (index = 0; index < NumDevices; index++) { - i = DeviceIndex[index]; - printf("%04X:%04X %04X:%04X %08lX (%6ld KB) %08lX (%6ld KB)\n", - PCI[i].VendorID, - PCI[i].DeviceID, - PCI[i].u.type0.SubSystemVendorID, - PCI[i].u.type0.SubSystemID, - PCI[i].u.type0.BaseAddress10, - PCI[i].u.type0.BaseAddress10Len / 1024, - PCI[i].u.type0.BaseAddress14, - PCI[i].u.type0.BaseAddress14Len / 1024); - } + i = DeviceIndex[index]; + printf("%04X:%04X %04X:%04X %08lX (%6ld KB) %08lX (%6ld KB)\n", + PCI[i].VendorID, + PCI[i].DeviceID, + PCI[i].u.type0.SubSystemVendorID, + PCI[i].u.type0.SubSystemID, + PCI[i].u.type0.BaseAddress10, + PCI[i].u.type0.BaseAddress10Len / 1024, + PCI[i].u.type0.BaseAddress14, + PCI[i].u.type0.BaseAddress14Len / 1024); + } printf("\n"); } @@ -147,16 +147,16 @@ static char *DecodeWCType( uint type) { static char *names[] = { - "UNCACHABLE", - "WRCOMB", - "UNKNOWN", - "UNKNOWN", - "WRTHROUGH", - "WRPROT", - "WRBACK", - }; + "UNCACHABLE", + "WRCOMB", + "UNKNOWN", + "UNKNOWN", + "WRTHROUGH", + "WRPROT", + "WRBACK", + }; if (type <= PM_MTRR_MAX) - return names[type]; + return names[type]; return "UNKNOWN"; } @@ -183,42 +183,42 @@ static void LogMTRRError( int err) { if (err == PM_MTRR_ERR_OK) - return; + return; switch (err) { - case PM_MTRR_NOT_SUPPORTED: - printf("Failed: MTRR is not supported by host CPU\n"); - break; - case PM_MTRR_ERR_PARAMS: - printf("Failed: Invalid parameters passed to PM_enableWriteCombined!\n"); - break; - case PM_MTRR_ERR_NOT_4KB_ALIGNED: - printf("Failed: Address is not 4Kb aligned!\n"); - break; - case PM_MTRR_ERR_BELOW_1MB: - printf("Failed: Addresses below 1Mb cannot be write combined!\n"); - break; - case PM_MTRR_ERR_NOT_ALIGNED: - printf("Failed: Address is not correctly aligned for processor!\n"); - break; - case PM_MTRR_ERR_OVERLAP: - printf("Failed: Address overlaps an existing region!\n"); - break; - case PM_MTRR_ERR_TYPE_MISMATCH: - printf("Failed: Adress is contained with existing region, but type is different!\n"); - break; - case PM_MTRR_ERR_NONE_FREE: - printf("Failed: Out of MTRR registers!\n"); - break; - case PM_MTRR_ERR_NOWRCOMB: - printf("Failed: This processor does not support write combining!\n"); - break; - case PM_MTRR_ERR_NO_OS_SUPPORT: - printf("Failed: MTRR is not supported by host OS\n"); - break; - default: - printf("Failed: UNKNOWN ERROR!\n"); - break; - } + case PM_MTRR_NOT_SUPPORTED: + printf("Failed: MTRR is not supported by host CPU\n"); + break; + case PM_MTRR_ERR_PARAMS: + printf("Failed: Invalid parameters passed to PM_enableWriteCombined!\n"); + break; + case PM_MTRR_ERR_NOT_4KB_ALIGNED: + printf("Failed: Address is not 4Kb aligned!\n"); + break; + case PM_MTRR_ERR_BELOW_1MB: + printf("Failed: Addresses below 1Mb cannot be write combined!\n"); + break; + case PM_MTRR_ERR_NOT_ALIGNED: + printf("Failed: Address is not correctly aligned for processor!\n"); + break; + case PM_MTRR_ERR_OVERLAP: + printf("Failed: Address overlaps an existing region!\n"); + break; + case PM_MTRR_ERR_TYPE_MISMATCH: + printf("Failed: Adress is contained with existing region, but type is different!\n"); + break; + case PM_MTRR_ERR_NONE_FREE: + printf("Failed: Out of MTRR registers!\n"); + break; + case PM_MTRR_ERR_NOWRCOMB: + printf("Failed: This processor does not support write combining!\n"); + break; + case PM_MTRR_ERR_NO_OS_SUPPORT: + printf("Failed: MTRR is not supported by host OS\n"); + break; + default: + printf("Failed: UNKNOWN ERROR!\n"); + break; + } exit(-1); } @@ -242,20 +242,20 @@ static void EnableWriteCombine(void) int i,index; for (index = 0; index < NumDevices; index++) { - i = DeviceIndex[index]; - if (PCI[i].u.type0.BaseAddress10 & 0x8) { - LogMTRRError(PM_enableWriteCombine( - PCI[i].u.type0.BaseAddress10 & 0xFFFFFFF0, - PCI[i].u.type0.BaseAddress10Len, - PM_MTRR_WRCOMB)); - } - if (PCI[i].u.type0.BaseAddress14 & 0x8) { - LogMTRRError(PM_enableWriteCombine( - PCI[i].u.type0.BaseAddress14 & 0xFFFFFFF0, - PCI[i].u.type0.BaseAddress14Len, - PM_MTRR_WRCOMB)); - } - } + i = DeviceIndex[index]; + if (PCI[i].u.type0.BaseAddress10 & 0x8) { + LogMTRRError(PM_enableWriteCombine( + PCI[i].u.type0.BaseAddress10 & 0xFFFFFFF0, + PCI[i].u.type0.BaseAddress10Len, + PM_MTRR_WRCOMB)); + } + if (PCI[i].u.type0.BaseAddress14 & 0x8) { + LogMTRRError(PM_enableWriteCombine( + PCI[i].u.type0.BaseAddress14 & 0xFFFFFFF0, + PCI[i].u.type0.BaseAddress14Len, + PM_MTRR_WRCOMB)); + } + } printf("\n"); ShowDisplayDevices(); ShowWriteCombine(); @@ -270,20 +270,20 @@ static void DisableWriteCombine(void) int i,index; for (index = 0; index < NumDevices; index++) { - i = DeviceIndex[index]; - if (PCI[i].u.type0.BaseAddress10 & 0x8) { - LogMTRRError(PM_enableWriteCombine( - PCI[i].u.type0.BaseAddress10 & 0xFFFFFFF0, - PCI[i].u.type0.BaseAddress10Len, - PM_MTRR_UNCACHABLE)); - } - if (PCI[i].u.type0.BaseAddress14 & 0x8) { - LogMTRRError(PM_enableWriteCombine( - PCI[i].u.type0.BaseAddress14 & 0xFFFFFFF0, - PCI[i].u.type0.BaseAddress14Len, - PM_MTRR_UNCACHABLE)); - } - } + i = DeviceIndex[index]; + if (PCI[i].u.type0.BaseAddress10 & 0x8) { + LogMTRRError(PM_enableWriteCombine( + PCI[i].u.type0.BaseAddress10 & 0xFFFFFFF0, + PCI[i].u.type0.BaseAddress10Len, + PM_MTRR_UNCACHABLE)); + } + if (PCI[i].u.type0.BaseAddress14 & 0x8) { + LogMTRRError(PM_enableWriteCombine( + PCI[i].u.type0.BaseAddress14 & 0xFFFFFFF0, + PCI[i].u.type0.BaseAddress14Len, + PM_MTRR_UNCACHABLE)); + } + } printf("\n"); ShowDisplayDevices(); ShowWriteCombine(); @@ -293,19 +293,19 @@ int main(int argc,char *argv[]) { PM_init(); if (PCI_enumerateDevices() < 1) { - printf("No PCI display devices found!\n"); - return -1; - } + printf("No PCI display devices found!\n"); + return -1; + } if (argc < 2) { - printf("usage: uswc [-show -on -off]\n\n"); - ShowDisplayDevices(); - return -1; - } + printf("usage: uswc [-show -on -off]\n\n"); + ShowDisplayDevices(); + return -1; + } if (stricmp(argv[1],"-show") == 0) - ShowWriteCombine(); + ShowWriteCombine(); else if (stricmp(argv[1],"-on") == 0) - EnableWriteCombine(); + EnableWriteCombine(); else if (stricmp(argv[1],"-off") == 0) - DisableWriteCombine(); + DisableWriteCombine(); return 0; } diff --git a/board/MAI/bios_emulator/scitech/src/pm/tests/vftest.c b/board/MAI/bios_emulator/scitech/src/pm/tests/vftest.c index 633a76d2b70..b7e3bb78468 100644 --- a/board/MAI/bios_emulator/scitech/src/pm/tests/vftest.c +++ b/board/MAI/bios_emulator/scitech/src/pm/tests/vftest.c @@ -51,27 +51,27 @@ int main(void) printf("Program running in "); switch (PM_getModeType()) { - case PM_realMode: - printf("real mode.\n\n"); - break; - case PM_286: - printf("16 bit protected mode.\n\n"); - break; - case PM_386: - printf("32 bit protected mode.\n\n"); - break; - } + case PM_realMode: + printf("real mode.\n\n"); + break; + case PM_286: + printf("16 bit protected mode.\n\n"); + break; + case PM_386: + printf("32 bit protected mode.\n\n"); + break; + } if (!VF_available()) { - printf("Virtual Linear Framebuffer not available.\n"); - exit(1); - } + printf("Virtual Linear Framebuffer not available.\n"); + exit(1); + } vfBuffer = VF_init(0xA0000,64,sizeof(code),code); if (!vfBuffer) { - printf("Failure to initialise Virtual Linear Framebuffer!\n"); - exit(1); - } + printf("Failure to initialise Virtual Linear Framebuffer!\n"); + exit(1); + } VF_exit(); printf("Virtual Linear Framebuffer set up successfully!\n"); return 0; diff --git a/board/MAI/bios_emulator/scitech/src/pm/tests/video.c b/board/MAI/bios_emulator/scitech/src/pm/tests/video.c index 7f6f67f67ee..92adcddd499 100644 --- a/board/MAI/bios_emulator/scitech/src/pm/tests/video.c +++ b/board/MAI/bios_emulator/scitech/src/pm/tests/video.c @@ -90,12 +90,12 @@ void fill(int startx, int starty, int endx, int endy, unsigned char c, int x,y; for (y = starty; y <= endy; y++) { - v = SCREEN(startx,y); - for (x = startx; x <= endx; x++) { - *v++ = c; - *v++ = attr; - } - } + v = SCREEN(startx,y); + for (x = startx; x <= endx; x++) { + *v++ = c; + *v++ = attr; + } + } } /* Routine to display a single character using direct video writes */ @@ -124,18 +124,18 @@ void border(int startx, int starty, int endx, int endy, unsigned char attr) b = border_chars; for (i = starty+1; i < endy; i++) { - writeChar(startx, i, *b, attr); - writeChar(endx, i, *b, attr); - } + writeChar(startx, i, *b, attr); + writeChar(endx, i, *b, attr); + } b++; for (i = startx+1, v = SCREEN(startx+1, starty); i < endx; i++) { - *v++ = *b; - *v++ = attr; - } + *v++ = *b; + *v++ = attr; + } for (i = startx+1, v = SCREEN(startx+1, endy); i < endx; i++) { - *v++ = *b; - *v++ = attr; - } + *v++ = *b; + *v++ = attr; + } b++; writeChar(startx, starty, *b++, attr); writeChar(endx, starty, *b++, attr); @@ -150,16 +150,16 @@ int main(void) printf("Program running in "); switch (PM_getModeType()) { - case PM_realMode: - printf("real mode.\n\n"); - break; - case PM_286: - printf("16 bit protected mode.\n\n"); - break; - case PM_386: - printf("32 bit protected mode.\n\n"); - break; - } + case PM_realMode: + printf("real mode.\n\n"); + break; + case PM_286: + printf("16 bit protected mode.\n\n"); + break; + case PM_386: + printf("32 bit protected mode.\n\n"); + break; + } hwndConsole = PM_openConsole(0,0,0,0,0,true); printf("Hit any key to start 80x25 text mode and perform some direct video output.\n"); @@ -167,17 +167,17 @@ int main(void) /* Allocate a buffer to save console state and save the state */ if ((stateBuf = PM_malloc(PM_getConsoleStateSize())) == NULL) { - printf("Unable to allocate console state buffer!\n"); - exit(1); - } + printf("Unable to allocate console state buffer!\n"); + exit(1); + } PM_saveConsoleState(stateBuf,0); bios = PM_getBIOSPointer(); orgMode = getVideoMode(); setVideoMode(0x3); if ((videoPtr = PM_mapPhysicalAddr(0xB8000,0xFFFF,true)) == NULL) { - printf("Unable to obtain pointer to framebuffer!\n"); - exit(1); - } + printf("Unable to obtain pointer to framebuffer!\n"); + exit(1); + } /* Draw some text on the screen */ fill(0, 0, 79, 24, 176, 0x1E); @@ -197,4 +197,3 @@ int main(void) printf("Video Memory = %08X\n", (int)videoPtr); return 0; } - diff --git a/board/MAI/bios_emulator/scitech/src/pm/vdd/fileio.c b/board/MAI/bios_emulator/scitech/src/pm/vdd/fileio.c index dbbaf37dfa1..93742de9147 100644 --- a/board/MAI/bios_emulator/scitech/src/pm/vdd/fileio.c +++ b/board/MAI/bios_emulator/scitech/src/pm/vdd/fileio.c @@ -63,54 +63,54 @@ FILE * fopen( ULONG omode, oflags; if (f != NULL) { - f->offset = 0; - f->text = (mode[1] == 't' || mode[2] == 't'); - f->writemode = (mode[0] == 'w') || (mode[0] == 'a'); - f->unputc = EOF; - f->endp = f->buf + sizeof(f->buf); - f->curp = f->startp = f->buf; + f->offset = 0; + f->text = (mode[1] == 't' || mode[2] == 't'); + f->writemode = (mode[0] == 'w') || (mode[0] == 'a'); + f->unputc = EOF; + f->endp = f->buf + sizeof(f->buf); + f->curp = f->startp = f->buf; - if (mode[0] == 'r') { - #ifdef __OS2_VDD__ - omode = VDHOPEN_ACCESS_READONLY | VDHOPEN_SHARE_DENYNONE; - oflags = VDHOPEN_ACTION_OPEN_IF_EXISTS | VDHOPEN_ACTION_FAIL_IF_NEW; - #else - omode = OPEN_ACCESS_READONLY | OPEN_SHARE_DENYNONE; - oflags = OPEN_ACTION_OPEN_IF_EXISTS | OPEN_ACTION_FAIL_IF_NEW; - #endif - } - else if (mode[0] == 'w') { - #ifdef __OS2_VDD__ - omode = VDHOPEN_ACCESS_WRITEONLY | VDHOPEN_SHARE_DENYWRITE; - oflags = VDHOPEN_ACTION_REPLACE_IF_EXISTS | VDHOPEN_ACTION_CREATE_IF_NEW; - #else - omode = OPEN_ACCESS_WRITEONLY | OPEN_SHARE_DENYWRITE; - oflags = OPEN_ACTION_REPLACE_IF_EXISTS | OPEN_ACTION_CREATE_IF_NEW; - #endif - } - else { - #ifdef __OS2_VDD__ - omode = VDHOPEN_ACCESS_READWRITE | VDHOPEN_SHARE_DENYWRITE; - oflags = VDHOPEN_ACTION_OPEN_IF_EXISTS | VDHOPEN_ACTION_CREATE_IF_NEW; - #else - omode = OPEN_ACCESS_READWRITE | OPEN_SHARE_DENYWRITE; - oflags = OPEN_ACTION_OPEN_IF_EXISTS | OPEN_ACTION_CREATE_IF_NEW; - #endif - } - rc = _OS2Open((PSZ)filename, (PHFILE)&f->handle, &ulAction, 0, VDHOPEN_FILE_NORMAL, oflags, omode, NULL); - if (rc != 0) { - PM_free(f); - return NULL; - } + if (mode[0] == 'r') { + #ifdef __OS2_VDD__ + omode = VDHOPEN_ACCESS_READONLY | VDHOPEN_SHARE_DENYNONE; + oflags = VDHOPEN_ACTION_OPEN_IF_EXISTS | VDHOPEN_ACTION_FAIL_IF_NEW; + #else + omode = OPEN_ACCESS_READONLY | OPEN_SHARE_DENYNONE; + oflags = OPEN_ACTION_OPEN_IF_EXISTS | OPEN_ACTION_FAIL_IF_NEW; + #endif + } + else if (mode[0] == 'w') { + #ifdef __OS2_VDD__ + omode = VDHOPEN_ACCESS_WRITEONLY | VDHOPEN_SHARE_DENYWRITE; + oflags = VDHOPEN_ACTION_REPLACE_IF_EXISTS | VDHOPEN_ACTION_CREATE_IF_NEW; + #else + omode = OPEN_ACCESS_WRITEONLY | OPEN_SHARE_DENYWRITE; + oflags = OPEN_ACTION_REPLACE_IF_EXISTS | OPEN_ACTION_CREATE_IF_NEW; + #endif + } + else { + #ifdef __OS2_VDD__ + omode = VDHOPEN_ACCESS_READWRITE | VDHOPEN_SHARE_DENYWRITE; + oflags = VDHOPEN_ACTION_OPEN_IF_EXISTS | VDHOPEN_ACTION_CREATE_IF_NEW; + #else + omode = OPEN_ACCESS_READWRITE | OPEN_SHARE_DENYWRITE; + oflags = OPEN_ACTION_OPEN_IF_EXISTS | OPEN_ACTION_CREATE_IF_NEW; + #endif + } + rc = _OS2Open((PSZ)filename, (PHFILE)&f->handle, &ulAction, 0, VDHOPEN_FILE_NORMAL, oflags, omode, NULL); + if (rc != 0) { + PM_free(f); + return NULL; + } - #ifdef __OS2_VDD__ - f->filesize = VDHSeek((HFILE)f->handle, 0, VDHSK_END_OF_FILE); - #else - rc = DosSetFilePtr((HFILE)f->handle, 0, FILE_END, &f->filesize); - #endif + #ifdef __OS2_VDD__ + f->filesize = VDHSeek((HFILE)f->handle, 0, VDHSK_END_OF_FILE); + #else + rc = DosSetFilePtr((HFILE)f->handle, 0, FILE_END, &f->filesize); + #endif - if (mode[0] == 'a') - fseek(f,0,2); + if (mode[0] == 'a') + fseek(f,0,2); } return f; } @@ -131,23 +131,23 @@ size_t fread( /* First copy any data already read into our buffer */ if ((bytes = (f->curp - f->startp)) > 0) { - memcpy(buf,f->curp,bytes); - f->startp = f->curp = f->buf; - buf += bytes; - totalbytes += bytes; - bytes = (size * n) - bytes; - } + memcpy(buf,f->curp,bytes); + f->startp = f->curp = f->buf; + buf += bytes; + totalbytes += bytes; + bytes = (size * n) - bytes; + } else - bytes = size * n; + bytes = size * n; if (bytes) { - #ifdef __OS2_VDD__ - readbytes = VDHRead((HFILE)f->handle, buf, bytes); - #else - DosRead((HFILE)f->handle, buf, bytes, &readbytes); - #endif - totalbytes += readbytes; - f->offset += readbytes; - } + #ifdef __OS2_VDD__ + readbytes = VDHRead((HFILE)f->handle, buf, bytes); + #else + DosRead((HFILE)f->handle, buf, bytes, &readbytes); + #endif + totalbytes += readbytes; + f->offset += readbytes; + } return totalbytes / size; } @@ -166,7 +166,7 @@ size_t fwrite( /* Flush anything already in the buffer */ if (!f->writemode) - return 0; + return 0; fflush(f); bytes = size * n; #ifdef __OS2_VDD__ @@ -177,7 +177,7 @@ size_t fwrite( totalbytes += writtenbytes; f->offset += writtenbytes; if (f->offset > f->filesize) - f->filesize = f->offset; + f->filesize = f->offset; return totalbytes / size; } @@ -192,16 +192,16 @@ int fflush( /* First copy any data already written into our buffer */ if (f->writemode && (bytes = (f->curp - f->startp)) > 0) { - #ifdef __OS2_VDD__ - bytes = VDHWrite((HFILE)f->handle, f->startp, bytes); - #else - DosWrite((HFILE)f->handle, f->startp, bytes, &bytes); - #endif - f->offset += bytes; - if (f->offset > f->filesize) - f->filesize = f->offset; - f->startp = f->curp = f->buf; - } + #ifdef __OS2_VDD__ + bytes = VDHWrite((HFILE)f->handle, f->startp, bytes); + #else + DosWrite((HFILE)f->handle, f->startp, bytes, &bytes); + #endif + f->offset += bytes; + if (f->offset > f->filesize) + f->filesize = f->offset; + f->startp = f->curp = f->buf; + } return 0; } @@ -217,11 +217,11 @@ int fseek( fflush(f); if (whence == 0) - f->offset = offset; + f->offset = offset; else if (whence == 1) - f->offset += offset; + f->offset += offset; else if (whence == 2) - f->offset = f->filesize + offset; + f->offset = f->filesize + offset; #ifdef __OS2_VDD__ VDHSeek((HFILE)f->handle, f->offset, VDHSK_ABSOLUTE); @@ -267,23 +267,23 @@ static int __getc( int c; if (f->unputc != EOF) { - c = f->unputc; - f->unputc = EOF; - } + c = f->unputc; + f->unputc = EOF; + } else { - if (f->startp == f->curp) { - int bytes = fread(f->buf,1,sizeof(f->buf),f); - if (bytes == 0) - return EOF; - f->curp = f->startp + bytes; - } - c = *f->startp++; - if (f->text && c == '\r') { - int nc = __getc(f); - if (nc != '\n') - f->unputc = nc; - } - } + if (f->startp == f->curp) { + int bytes = fread(f->buf,1,sizeof(f->buf),f); + if (bytes == 0) + return EOF; + f->curp = f->startp + bytes; + } + c = *f->startp++; + if (f->text && c == '\r') { + int nc = __getc(f); + if (nc != '\n') + f->unputc = nc; + } + } return c; } @@ -296,11 +296,11 @@ static int __putc(int c,FILE *f) { int count = 1; if (f->text && c == '\n') { - __putc('\r',f); - count = 2; - } + __putc('\r',f); + count = 2; + } if (f->curp == f->endp) - fflush(f); + fflush(f); *f->curp++ = c; return count; } @@ -319,12 +319,12 @@ char *fgets( cs = s; while (--n > 0 && (c = __getc(f)) != EOF) { - *cs++ = c; - if (c == '\n') - break; - } + *cs++ = c; + if (c == '\n') + break; + } if (c == EOF && cs == s) - return NULL; + return NULL; *cs = '\0'; return s; } @@ -341,7 +341,7 @@ int fputs( int c; while ((c = *s++) != 0) - r = __putc(c, f); + r = __putc(c, f); return r; } diff --git a/board/MAI/bios_emulator/scitech/src/pm/vdd/pm.c b/board/MAI/bios_emulator/scitech/src/pm/vdd/pm.c index 32177f810da..6688babd0d8 100644 --- a/board/MAI/bios_emulator/scitech/src/pm/vdd/pm.c +++ b/board/MAI/bios_emulator/scitech/src/pm/vdd/pm.c @@ -44,7 +44,7 @@ #define MAX_MEMORY_SHARED 100 #define MAX_MEMORY_MAPPINGS 100 -// TODO: I think the global and linear members will be the same, but not sure yet. +/* TODO: I think the global and linear members will be the same, but not sure yet. */ typedef struct { void *linear; ulong global; @@ -90,18 +90,18 @@ void PMAPI PM_init(void) { MTRR_init(); - // Initialize VDD-specific data - // Note: PM_init must be (obviously) called in VDM task context! + /* Initialize VDD-specific data */ + /* Note: PM_init must be (obviously) called in VDM task context! */ VDHCreateSem(&hevFarCallRet, VDH_EVENTSEM); VDHCreateSem(&hevIRet, VDH_EVENTSEM); hhookUserReturnHook = VDHAllocHook(VDH_RETURN_HOOK, (PFNARM)UserReturnHook, 0); hhookUserIRetHook = VDHAllocHook(VDH_RETURN_HOOK, (PFNARM)UserIRetHook, 0); if ((hevIRet == NULL) || (hevFarCallRet == NULL) || - (hhookUserReturnHook == NULL) || (hhookUserIRetHook == NULL)) { - // something failed, we can't go on - // TODO: take some action here! - } + (hhookUserReturnHook == NULL) || (hhookUserIRetHook == NULL)) { + /* something failed, we can't go on */ + /* TODO: take some action here! */ + } } /* Do some cleaning up */ @@ -109,17 +109,17 @@ void PMAPI PM_exit(void) { /* Note: Hooks allocated during or after VDM creation are deallocated automatically */ if (hevIRet != NULL) - VDHDestroySem(hevIRet); + VDHDestroySem(hevIRet); if (hevFarCallRet != NULL) - VDHDestroySem(hevFarCallRet); + VDHDestroySem(hevFarCallRet); } ibool PMAPI PM_haveBIOSAccess(void) { return _PM_haveBIOS; } long PMAPI PM_getOSType(void) -{ return /*_OS_OS2VDD*/ _OS_OS2; } //FIX!! +{ return /*_OS_OS2VDD*/ _OS_OS2; } /*FIX!! */ int PMAPI PM_getModeType(void) { return PM_386; } @@ -128,9 +128,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( @@ -142,8 +142,8 @@ void PMAPI PM_setFatalErrorCleanup( void PMAPI PM_fatalError(const char *msg) { if (fatalErrorCleanup) - fatalErrorCleanup(); -// Fatal_Error_Handler(msg,0); TODO: implement somehow! + fatalErrorCleanup(); +/* Fatal_Error_Handler(msg,0); TODO: implement somehow! */ } /**************************************************************************** @@ -162,11 +162,11 @@ void * PMAPI PM_getVESABuf( uint *roff) { if (_PM_rmBufAddr) { - *len = 0; //VESA_BUF_SIZE; - *rseg = (ulong)(_PM_rmBufAddr) >> 4; - *roff = (ulong)(_PM_rmBufAddr) & 0xF; - return _PM_rmBufAddr; - } + *len = 0; /*VESA_BUF_SIZE; */ + *rseg = (ulong)(_PM_rmBufAddr) >> 4; + *roff = (ulong)(_PM_rmBufAddr) & 0xF; + return _PM_rmBufAddr; + } return NULL; } @@ -200,12 +200,12 @@ const char * PMAPI PM_getVBEAFPath(void) const char * PMAPI PM_getNucleusPath(void) { - static char path[CCHMAXPATH]; - strcpy(path,"x:\\os2\\drivers"); - path[0] = PM_getBootDrive(); - PM_backslash(path); - strcat(path,"nucleus"); - return path; + static char path[CCHMAXPATH]; + strcpy(path,"x:\\os2\\drivers"); + path[0] = PM_getBootDrive(); + PM_backslash(path); + strcat(path,"nucleus"); + return path; } const char * PMAPI PM_getNucleusConfigPath(void) @@ -292,15 +292,15 @@ void * PMAPI PM_mallocShared(long size) /* First find a free slot in our shared memory table */ for (i = 0; i < MAX_MEMORY_SHARED; i++) { - if (shared[i].linear == 0) - break; - } + if (shared[i].linear == 0) + break; + } if (i < MAX_MEMORY_SHARED) { - shared[i].linear = VDHAllocPages(NULL, nPages, VDHAP_SYSTEM | VDHAP_FIXED); - shared[i].npages = nPages; - shared[i].global = (ULONG)shared[i].linear; - return (void*)shared[i].global; - } + shared[i].linear = VDHAllocPages(NULL, nPages, VDHAP_SYSTEM | VDHAP_FIXED); + shared[i].npages = nPages; + shared[i].global = (ULONG)shared[i].linear; + return (void*)shared[i].global; + } return NULL; } @@ -314,12 +314,12 @@ void PMAPI PM_freeShared(void *p) /* Find a shared memory block in our table and free it */ for (i = 0; i < MAX_MEMORY_SHARED; i++) { - if (shared[i].global == (ulong)p) { - VDHFreePages(shared[i].linear); - shared[i].linear = 0; - break; - } - } + if (shared[i].global == (ulong)p) { + VDHFreePages(shared[i].linear); + shared[i].linear = 0; + break; + } + } } void * PMAPI PM_mapToProcess(void *base,ulong limit) @@ -331,7 +331,7 @@ ibool PMAPI PM_doBIOSPOST( void *mappedBIOS, ulong BIOSLen) { - // TODO: Figure out how to do this + /* TODO: Figure out how to do this */ return false; } @@ -364,18 +364,18 @@ ulong MapPhysicalToLinear( *npages = (length + (base & 0xFFF) + 4095) >> 12; flags = PR_FIXED | PR_STATIC; if (base == 0xA0000) { - /* We require the linear address to be aligned to a 64Kb boundary - * for mapping the banked framebuffer (so we can do efficient - * carry checking for bank changes in the assembler code). The only - * way to ensure this is to force the linear address to be aligned - * to a 4Mb boundary. - */ - flags |= PR_4MEG; - } + /* We require the linear address to be aligned to a 64Kb boundary + * for mapping the banked framebuffer (so we can do efficient + * carry checking for bank changes in the assembler code). The only + * way to ensure this is to force the linear address to be aligned + * to a 4Mb boundary. + */ + flags |= PR_4MEG; + } if ((linear = (ulong)PageReserve(PR_SYSTEM,*npages,flags)) == (ulong)-1) - return 0; + return 0; if (!PageCommitPhys(linear >> 12,*npages,ppage,PC_INCR | PC_USER | PC_WRITEABLE)) - return 0; + return 0; #endif return linear + (base & 0xFFF); } @@ -397,9 +397,9 @@ memory below 1Mb, which gets this memory out of the way of the Windows VxD's sticky paws. NOTE: If the memory is not expected to be cached, this function will - directly re-program the PCD (Page Cache Disable) bit in the - page tables. There does not appear to be a mechanism in the VMM - to control this bit via the regular interface. + directly re-program the PCD (Page Cache Disable) bit in the + page tables. There does not appear to be a mechanism in the VMM + to control this bit via the regular interface. ****************************************************************************/ void * PMAPI PM_mapPhysicalAddr( ulong base, @@ -414,11 +414,11 @@ void * PMAPI PM_mapPhysicalAddr( * a region of memory that will serve this purpose. */ for (i = 0; i < numMappings; i++) { - if (maps[i].physical == base && maps[i].length == length && maps[i].isCached == isCached) - return (void*)maps[i].linear; - } + if (maps[i].physical == base && maps[i].length == length && maps[i].isCached == isCached) + return (void*)maps[i].linear; + } if (numMappings == MAX_MEMORY_MAPPINGS) - return NULL; + return NULL; /* We did not find any previously mapped memory region, so map it in. * Note that we do not use MapPhysToLinear, since this function appears @@ -426,7 +426,7 @@ void * PMAPI PM_mapPhysicalAddr( * Hence we use PageReserve and PageCommitPhys. */ if ((linear = MapPhysicalToLinear(base,limit,&npages)) == 0) - return NULL; + return NULL; maps[numMappings].physical = base; maps[numMappings].length = length; maps[numMappings].linear = linear; @@ -437,33 +437,33 @@ void * PMAPI PM_mapPhysicalAddr( #if 0 /* Finally disable caching where necessary */ if (!isCached && (PDB = _PM_getPDB()) != 0) { - int startPDB,endPDB,iPDB,startPage,endPage,start,end,iPage; - ulong pageTable,*pPageTable; - - if (PDB >= 0x100000) - pPDB = (ulong*)MapPhysicalToLinear(PDB,0xFFF,&npages); - else - pPDB = (ulong*)PDB; - if (pPDB) { - startPDB = (linear >> 22) & 0x3FF; - startPage = (linear >> 12) & 0x3FF; - endPDB = ((linear+limit) >> 22) & 0x3FF; - endPage = ((linear+limit) >> 12) & 0x3FF; - for (iPDB = startPDB; iPDB <= endPDB; iPDB++) { - pageTable = pPDB[iPDB] & ~0xFFF; - if (pageTable >= 0x100000) - pPageTable = (ulong*)MapPhysicalToLinear(pageTable,0xFFF,&npages); - else - pPageTable = (ulong*)pageTable; - start = (iPDB == startPDB) ? startPage : 0; - end = (iPDB == endPDB) ? endPage : 0x3FF; - for (iPage = start; iPage <= end; iPage++) - pPageTable[iPage] |= 0x10; - PageFree((ulong)pPageTable,PR_STATIC); - } - PageFree((ulong)pPDB,PR_STATIC); - } - } + int startPDB,endPDB,iPDB,startPage,endPage,start,end,iPage; + ulong pageTable,*pPageTable; + + if (PDB >= 0x100000) + pPDB = (ulong*)MapPhysicalToLinear(PDB,0xFFF,&npages); + else + pPDB = (ulong*)PDB; + if (pPDB) { + startPDB = (linear >> 22) & 0x3FF; + startPage = (linear >> 12) & 0x3FF; + endPDB = ((linear+limit) >> 22) & 0x3FF; + endPage = ((linear+limit) >> 12) & 0x3FF; + for (iPDB = startPDB; iPDB <= endPDB; iPDB++) { + pageTable = pPDB[iPDB] & ~0xFFF; + if (pageTable >= 0x100000) + pPageTable = (ulong*)MapPhysicalToLinear(pageTable,0xFFF,&npages); + else + pPageTable = (ulong*)pageTable; + start = (iPDB == startPDB) ? startPage : 0; + end = (iPDB == endPDB) ? endPage : 0x3FF; + for (iPage = start; iPage <= end; iPage++) + pPageTable[iPage] |= 0x10; + PageFree((ulong)pPageTable,PR_STATIC); + } + PageFree((ulong)pPDB,PR_STATIC); + } + } #endif return (void*)linear; } @@ -480,39 +480,39 @@ void PMAPI PM_sleep(ulong milliseconds) int PMAPI PM_getCOMPort(int port) { - // TODO: Re-code this to determine real values using the Plug and Play - // manager for the OS. + /* TODO: Re-code this to determine real values using the Plug and Play */ + /* manager for the OS. */ 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) { - // TODO: Re-code this to determine real values using the Plug and Play - // manager for the OS. + /* TODO: Re-code this to determine real values using the Plug and Play */ + /* manager for the OS. */ 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; } ulong PMAPI PM_getPhysicalAddr(void *p) { - // TODO: This function should find the physical address of a linear - // address. - return 0xFFFFFFFFUL; + /* TODO: This function should find the physical address of a linear */ + /* address. */ + return 0xFFFFFFFFUL; } void PMAPI _PM_freeMemoryMappings(void) { int i; -// for (i = 0; i < numMappings; i++) -// PageFree(maps[i].linear,PR_STATIC); +/* for (i = 0; i < numMappings; i++) */ +/* PageFree(maps[i].linear,PR_STATIC); */ } void * PMAPI PM_mapRealPointer(uint r_seg,uint r_off) @@ -539,16 +539,16 @@ static void LoadV86Registers( RMREGS *in, RMSREGS *sregs) { - PCRF pcrf; // current client register frame + PCRF pcrf; /* current client register frame */ - // get pointer to registers + /* get pointer to registers */ pcrf = (PCRF)VDHQuerySysValue(CURRENT_VDM, VDHLSV_PCRF); - // Note: We could do VDHPushRegs instead but this should be safer as it - // doesn't rely on the VDM session having enough free stack space. - *saveRegs = *pcrf; // save all registers + /* Note: We could do VDHPushRegs instead but this should be safer as it */ + /* doesn't rely on the VDM session having enough free stack space. */ + *saveRegs = *pcrf; /* save all registers */ - pcrf->crf_eax = in->e.eax; // load new values + pcrf->crf_eax = in->e.eax; /* load new values */ pcrf->crf_ebx = in->e.ebx; pcrf->crf_ecx = in->e.ecx; pcrf->crf_edx = in->e.edx; @@ -568,12 +568,12 @@ static void ReadV86Registers( RMREGS *out, RMSREGS *sregs) { - PCRF pcrf; // current client register frame + PCRF pcrf; /* current client register frame */ - // get pointer to registers + /* get pointer to registers */ pcrf = (PCRF)VDHQuerySysValue(CURRENT_VDM, VDHLSV_PCRF); - // read new register values + /* read new register values */ out->e.eax = pcrf->crf_eax; out->e.ebx = pcrf->crf_ebx; out->e.ecx = pcrf->crf_ecx; @@ -583,7 +583,7 @@ static void ReadV86Registers( sregs->es = pcrf->crf_es; sregs->ds = pcrf->crf_ds; - // restore original client registers + /* restore original client registers */ *pcrf = *saveRegs; } @@ -626,18 +626,18 @@ void PMAPI PM_callRealMode( TRACE("SDDHELP: Entering PM_callRealMode()\n"); LoadV86Registers(SSToDS(&saveRegs),regs,sregs); - // set up return hook for call + /* set up return hook for call */ rc = VDHArmReturnHook(hhookUserReturnHook, VDHARH_CSEIP_HOOK); VDHResetEventSem(hevFarCallRet); - // the address is a 16:32 pointer + /* the address is a 16:32 pointer */ OFFSETOF32(fnAddress) = off; SEGMENTOF32(fnAddress) = seg; rc = VDHPushFarCall(fnAddress); VDHYield(0); - // wait until the V86 call returns - our return hook posts the semaphore + /* wait until the V86 call returns - our return hook posts the semaphore */ rc = VDHWaitEventSem(hevFarCallRet, SEM_INDEFINITE_WAIT); ReadV86Registers(SSToDS(&saveRegs),regs,sregs); @@ -662,13 +662,13 @@ int PMAPI PM_int86( memset(SSToDS(&sregs), 0, sizeof(sregs)); -#if 0 // do we need this?? +#if 0 /* do we need this?? */ /* Disable pass-up to our VDD handler so we directly call BIOS */ TRACE("SDDHELP: Entering PM_int86()\n"); if (disableTSRFlag) { - oldDisable = *disableTSRFlag; - *disableTSRFlag = 0; - } + oldDisable = *disableTSRFlag; + *disableTSRFlag = 0; + } #endif LoadV86Registers(SSToDS(&saveRegs), in, SSToDS(&sregs)); @@ -676,20 +676,20 @@ int PMAPI PM_int86( VDHResetEventSem(hevIRet); rc = VDHPushInt(intno); - // set up return hook for interrupt + /* set up return hook for interrupt */ rc = VDHArmReturnHook(hhookUserIRetHook, VDHARH_NORMAL_IRET); VDHYield(0); - // wait until the V86 IRETs - our return hook posts the semaphore - rc = VDHWaitEventSem(hevIRet, 5000); //SEM_INDEFINITE_WAIT); + /* wait until the V86 IRETs - our return hook posts the semaphore */ + rc = VDHWaitEventSem(hevIRet, 5000); /*SEM_INDEFINITE_WAIT); */ ReadV86Registers(SSToDS(&saveRegs), out, SSToDS(&sregs)); #if 0 /* Re-enable pass-up to our VDD handler if previously enabled */ if (disableTSRFlag) - *disableTSRFlag = oldDisable; + *disableTSRFlag = oldDisable; #endif TRACE("SDDHELP: Exiting PM_int86()\n"); @@ -716,29 +716,29 @@ int PMAPI PM_int86x( /* Disable pass-up to our VxD handler so we directly call BIOS */ TRACE("SDDHELP: Entering PM_int86x()\n"); if (disableTSRFlag) { - oldDisable = *disableTSRFlag; - *disableTSRFlag = 0; - } + oldDisable = *disableTSRFlag; + *disableTSRFlag = 0; + } #endif LoadV86Registers(SSToDS(&saveRegs), in, sregs); VDHResetEventSem(hevIRet); rc = VDHPushInt(intno); - // set up return hook for interrupt + /* set up return hook for interrupt */ rc = VDHArmReturnHook(hhookUserIRetHook, VDHARH_NORMAL_IRET); VDHYield(0); - // wait until the V86 IRETs - our return hook posts the semaphore - rc = VDHWaitEventSem(hevIRet, 5000); //SEM_INDEFINITE_WAIT); + /* wait until the V86 IRETs - our return hook posts the semaphore */ + rc = VDHWaitEventSem(hevIRet, 5000); /*SEM_INDEFINITE_WAIT); */ ReadV86Registers(SSToDS(&saveRegs), out, sregs); #if 0 /* Re-enable pass-up to our VxD handler if previously enabled */ if (disableTSRFlag) - *disableTSRFlag = oldDisable; + *disableTSRFlag = oldDisable; #endif TRACE("SDDHELP: Exiting PM_int86x()\n"); @@ -776,7 +776,7 @@ void PMAPI PM_freeLockedMem( ibool contiguous) { if (p) - VDHFreePages((PVOID)p); + VDHFreePages((PVOID)p); } /**************************************************************************** @@ -787,7 +787,7 @@ int PMAPI PM_lockDataPages(void *p,uint len,PM_lockHandle *lh) { ULONG lockHandle; - // TODO: the lock handle is essential for the unlock operation!! + /* TODO: the lock handle is essential for the unlock operation!! */ lockHandle = VDHLockMem(p, len, 0, (PVOID)VDHLM_NO_ADDR, NULL); if (lockHandle != NULL) @@ -802,8 +802,8 @@ Unlock linear memory so it won't be paged. ****************************************************************************/ int PMAPI PM_unlockDataPages(void *p,uint len,PM_lockHandle *lh) { - // TODO: implement - use a table of lock handles? - // VDHUnlockPages(lockHandle); + /* TODO: implement - use a table of lock handles? */ + /* VDHUnlockPages(lockHandle); */ return 0; } @@ -867,9 +867,9 @@ void *PMAPI PM_findFirstFile( const char *filename, PM_findData *findData) { - // TODO: This function should start a directory enumeration search - // given the filename (with wildcards). The data should be - // converted and returned in the findData standard form. + /* TODO: This function should start a directory enumeration search */ + /* given the filename (with wildcards). The data should be */ + /* converted and returned in the findData standard form. */ (void)filename; (void)findData; return PM_FILE_INVALID; @@ -883,10 +883,10 @@ ibool PMAPI PM_findNextFile( void *handle, PM_findData *findData) { - // TODO: This function should find the next file in directory enumeration - // search given the search criteria defined in the call to - // PM_findFirstFile. The data should be converted and returned - // in the findData standard form. + /* TODO: This function should find the next file in directory enumeration */ + /* search given the search criteria defined in the call to */ + /* PM_findFirstFile. The data should be converted and returned */ + /* in the findData standard form. */ (void)handle; (void)findData; return false; @@ -899,8 +899,8 @@ Function to close the find process void PMAPI PM_findClose( void *handle) { - // TODO: This function should close the find process. This may do - // nothing for some OS'es. + /* TODO: This function should close the find process. This may do */ + /* nothing for some OS'es. */ (void)handle; } @@ -920,7 +920,7 @@ numbering is: ibool PMAPI PM_driveValid( char drive) { - // Not applicable in a VDD + /* Not applicable in a VDD */ (void)drive; return false; } @@ -936,7 +936,7 @@ void PMAPI PM_getdcwd( char *dir, int len) { - // Not applicable in a VDD + /* Not applicable in a VDD */ (void)drive; (void)dir; (void)len; @@ -970,7 +970,7 @@ void PMAPI PM_setFileAttr( const char *filename, uint attrib) { - // TODO: Implement this ? + /* TODO: Implement this ? */ (void)filename; (void)attrib; PM_fatalError("PM_setFileAttr not implemented!"); @@ -983,7 +983,7 @@ Function to get the file attributes for a specific file. uint PMAPI PM_getFileAttr( const char *filename) { - // TODO: Implement this ? + /* TODO: Implement this ? */ (void)filename; PM_fatalError("PM_getFileAttr not implemented!"); return 0; @@ -996,7 +996,7 @@ Function to create a directory. ibool PMAPI PM_mkdir( const char *filename) { - // TODO: Implement this ? + /* TODO: Implement this ? */ (void)filename; PM_fatalError("PM_mkdir not implemented!"); return false; @@ -1009,7 +1009,7 @@ Function to remove a directory. ibool PMAPI PM_rmdir( const char *filename) { - // TODO: Implement this ? + /* TODO: Implement this ? */ (void)filename; PM_fatalError("PM_rmdir not implemented!"); return false; @@ -1024,7 +1024,7 @@ ibool PMAPI PM_getFileTime( ibool gmTime, PM_time *time) { - // TODO: Implement this ? + /* TODO: Implement this ? */ (void)filename; (void)gmTime; (void)time; @@ -1041,7 +1041,7 @@ ibool PMAPI PM_setFileTime( ibool gmTime, PM_time *time) { - // TODO: Implement this ? + /* TODO: Implement this ? */ (void)filename; (void)gmTime; (void)time; diff --git a/board/MAI/bios_emulator/scitech/src/pm/vdd/vflat.c b/board/MAI/bios_emulator/scitech/src/pm/vdd/vflat.c index 10c63e3405f..21639281a7e 100644 --- a/board/MAI/bios_emulator/scitech/src/pm/vdd/vflat.c +++ b/board/MAI/bios_emulator/scitech/src/pm/vdd/vflat.c @@ -32,12 +32,12 @@ ibool PMAPI VF_available(void) { - return false; + return false; } void * PMAPI VF_init(ulong baseAddr,int bankSize,int codeLen,void *bankFunc) { - return NULL; + return NULL; } void PMAPI VF_exit(void) diff --git a/board/MAI/bios_emulator/scitech/src/pm/vxd/fileio.c b/board/MAI/bios_emulator/scitech/src/pm/vxd/fileio.c index e2ff585839c..3c6ce99208b 100644 --- a/board/MAI/bios_emulator/scitech/src/pm/vxd/fileio.c +++ b/board/MAI/bios_emulator/scitech/src/pm/vxd/fileio.c @@ -47,62 +47,62 @@ FILE * fopen( long oldpos; if (f) { - f->offset = 0; - f->text = (mode[1] == 't' || mode[2] == 't'); - f->writemode = (mode[0] == 'w') || (mode[0] == 'a'); - if (initComplete) { - WORD omode,error; - BYTE action; + f->offset = 0; + f->text = (mode[1] == 't' || mode[2] == 't'); + f->writemode = (mode[0] == 'w') || (mode[0] == 'a'); + if (initComplete) { + WORD omode,error; + BYTE action; - if (mode[0] == 'r') { - omode = OPEN_ACCESS_READONLY | OPEN_SHARE_COMPATIBLE; - action = ACTION_IFEXISTS_OPEN | ACTION_IFNOTEXISTS_FAIL; - } - else if (mode[0] == 'w') { - omode = OPEN_ACCESS_WRITEONLY | OPEN_SHARE_COMPATIBLE; - action = ACTION_IFEXISTS_TRUNCATE | ACTION_IFNOTEXISTS_CREATE; - } - else { - omode = OPEN_ACCESS_READWRITE | OPEN_SHARE_COMPATIBLE; - action = ACTION_IFEXISTS_OPEN | ACTION_IFNOTEXISTS_CREATE; - } - f->handle = (int)R0_OpenCreateFile(false,(char*)filename,omode,ATTR_NORMAL,action,0,&error,&action); - if (f->handle == 0) { - PM_free(f); - return NULL; - } - f->filesize = R0_GetFileSize((HANDLE)f->handle,&error); - if (mode[0] == 'a') - fseek(f,0,2); - } - else { - int oflag,pmode; + if (mode[0] == 'r') { + omode = OPEN_ACCESS_READONLY | OPEN_SHARE_COMPATIBLE; + action = ACTION_IFEXISTS_OPEN | ACTION_IFNOTEXISTS_FAIL; + } + else if (mode[0] == 'w') { + omode = OPEN_ACCESS_WRITEONLY | OPEN_SHARE_COMPATIBLE; + action = ACTION_IFEXISTS_TRUNCATE | ACTION_IFNOTEXISTS_CREATE; + } + else { + omode = OPEN_ACCESS_READWRITE | OPEN_SHARE_COMPATIBLE; + action = ACTION_IFEXISTS_OPEN | ACTION_IFNOTEXISTS_CREATE; + } + f->handle = (int)R0_OpenCreateFile(false,(char*)filename,omode,ATTR_NORMAL,action,0,&error,&action); + if (f->handle == 0) { + PM_free(f); + return NULL; + } + f->filesize = R0_GetFileSize((HANDLE)f->handle,&error); + if (mode[0] == 'a') + fseek(f,0,2); + } + else { + int oflag,pmode; - if (mode[0] == 'r') { - pmode = _S_IREAD; - oflag = _O_RDONLY; - } - else if (mode[0] == 'w') { - pmode = _S_IWRITE; - oflag = _O_WRONLY | _O_CREAT | _O_TRUNC; - } - else { - pmode = _S_IWRITE; - oflag = _O_RDWR | _O_CREAT | _O_APPEND; - } - if (f->text) - oflag |= _O_TEXT; - else - oflag |= _O_BINARY; - if ((f->handle = i_open(filename,oflag,pmode)) == -1) { - PM_free(f); - return NULL; - } - oldpos = i_lseek(f->handle,0,1); - f->filesize = i_lseek(f->handle,0,2); - i_lseek(f->handle,oldpos,0); - } - } + if (mode[0] == 'r') { + pmode = _S_IREAD; + oflag = _O_RDONLY; + } + else if (mode[0] == 'w') { + pmode = _S_IWRITE; + oflag = _O_WRONLY | _O_CREAT | _O_TRUNC; + } + else { + pmode = _S_IWRITE; + oflag = _O_RDWR | _O_CREAT | _O_APPEND; + } + if (f->text) + oflag |= _O_TEXT; + else + oflag |= _O_BINARY; + if ((f->handle = i_open(filename,oflag,pmode)) == -1) { + PM_free(f); + return NULL; + } + oldpos = i_lseek(f->handle,0,1); + f->filesize = i_lseek(f->handle,0,2); + i_lseek(f->handle,oldpos,0); + } + } return f; } @@ -125,27 +125,27 @@ size_t fread( int readbytes,totalbytes = 0; while (bytes > 0x10000) { - if (initComplete) { - readbytes = R0_ReadFile(false,(HANDLE)f->handle,buf,0x8000,f->offset,&error); - readbytes += R0_ReadFile(false,(HANDLE)f->handle,buf+0x8000,0x8000,f->offset+0x8000,&error); - } - else { - readbytes = i_read(f->handle,buf,0x8000); - readbytes += i_read(f->handle,buf+0x8000,0x8000); - } - totalbytes += readbytes; - f->offset += readbytes; - buf += 0x10000; - bytes -= 0x10000; - } + if (initComplete) { + readbytes = R0_ReadFile(false,(HANDLE)f->handle,buf,0x8000,f->offset,&error); + readbytes += R0_ReadFile(false,(HANDLE)f->handle,buf+0x8000,0x8000,f->offset+0x8000,&error); + } + else { + readbytes = i_read(f->handle,buf,0x8000); + readbytes += i_read(f->handle,buf+0x8000,0x8000); + } + totalbytes += readbytes; + f->offset += readbytes; + buf += 0x10000; + bytes -= 0x10000; + } if (bytes) { - if (initComplete) - readbytes = R0_ReadFile(false,(HANDLE)f->handle,buf,bytes,f->offset,&error); - else - readbytes = i_read(f->handle,buf,bytes); - totalbytes += readbytes; - f->offset += readbytes; - } + if (initComplete) + readbytes = R0_ReadFile(false,(HANDLE)f->handle,buf,bytes,f->offset,&error); + else + readbytes = i_read(f->handle,buf,bytes); + totalbytes += readbytes; + f->offset += readbytes; + } return totalbytes / size; } @@ -168,29 +168,29 @@ size_t fwrite( int writtenbytes,totalbytes = 0; if (!f->writemode) - return 0; + return 0; while (bytes > 0x10000) { - if (initComplete) { - writtenbytes = R0_WriteFile(false,(HANDLE)f->handle,buf,0x8000,f->offset,&error); - writtenbytes += R0_WriteFile(false,(HANDLE)f->handle,buf+0x8000,0x8000,f->offset+0x8000,&error); - } - else { - writtenbytes = i_write(f->handle,buf,0x8000); - writtenbytes += i_write(f->handle,buf+0x8000,0x8000); - } - totalbytes += writtenbytes; - f->offset += writtenbytes; - buf += 0x10000; - bytes -= 0x10000; - } + if (initComplete) { + writtenbytes = R0_WriteFile(false,(HANDLE)f->handle,buf,0x8000,f->offset,&error); + writtenbytes += R0_WriteFile(false,(HANDLE)f->handle,buf+0x8000,0x8000,f->offset+0x8000,&error); + } + else { + writtenbytes = i_write(f->handle,buf,0x8000); + writtenbytes += i_write(f->handle,buf+0x8000,0x8000); + } + totalbytes += writtenbytes; + f->offset += writtenbytes; + buf += 0x10000; + bytes -= 0x10000; + } if (initComplete) - writtenbytes = R0_WriteFile(false,(HANDLE)f->handle,buf,bytes,f->offset,&error); + writtenbytes = R0_WriteFile(false,(HANDLE)f->handle,buf,bytes,f->offset,&error); else - writtenbytes = i_write(f->handle,buf,bytes); + writtenbytes = i_write(f->handle,buf,bytes); totalbytes += writtenbytes; f->offset += writtenbytes; if (f->offset > f->filesize) - f->filesize = f->offset; + f->filesize = f->offset; return totalbytes / size; } @@ -201,7 +201,7 @@ VxD implementation of the ANSI C fflush function. int fflush( FILE *f) { - // Nothing to do since we are not doing buffered file I/O + /* Nothing to do since we are not doing buffered file I/O */ (void)f; return 0; } @@ -216,13 +216,13 @@ int fseek( int whence) { if (whence == 0) - f->offset = offset; + f->offset = offset; else if (whence == 1) - f->offset += offset; + f->offset += offset; else if (whence == 2) - f->offset = f->filesize + offset; + f->offset = f->filesize + offset; if (!initComplete) - i_lseek(f->handle,f->offset,0); + i_lseek(f->handle,f->offset,0); return 0; } @@ -258,19 +258,19 @@ char *fgets( int len; char *cs; - // Read the entire buffer into memory (our functions are unbuffered!) + /* Read the entire buffer into memory (our functions are unbuffered!) */ if ((len = fread(s,1,n,f)) == 0) - return NULL; + return NULL; - // Search for '\n' or end of string + /* Search for '\n' or end of string */ if (n > len) - n = len; + n = len; cs = s; while (--n > 0) { - if (*cs == '\n') - break; - cs++; - } + if (*cs == '\n') + break; + cs++; + } *cs = '\0'; return s; } @@ -296,10 +296,9 @@ int fclose( WORD error; if (initComplete) - R0_CloseFile((HANDLE)f->handle,&error); + R0_CloseFile((HANDLE)f->handle,&error); else - i_close(f->handle); + i_close(f->handle); PM_free(f); return 0; } - diff --git a/board/MAI/bios_emulator/scitech/src/pm/vxd/pm.c b/board/MAI/bios_emulator/scitech/src/pm/vxd/pm.c index 8d00df9065c..4cb7f19ed40 100644 --- a/board/MAI/bios_emulator/scitech/src/pm/vxd/pm.c +++ b/board/MAI/bios_emulator/scitech/src/pm/vxd/pm.c @@ -105,7 +105,7 @@ void * VXD_calloc( { void *p = PM_mallocShared(nelem * size); if (p) - memset(p,0,nelem * size); + memset(p,0,nelem * size); return p; } @@ -119,9 +119,9 @@ void * VXD_realloc( { void *p = PM_mallocShared(size); if (p) { - memcpy(p,ptr,size); - PM_freeShared(ptr); - } + memcpy(p,ptr,size); + PM_freeShared(ptr); + } return p; } @@ -166,9 +166,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( @@ -180,7 +180,7 @@ void PMAPI PM_setFatalErrorCleanup( void PMAPI PM_fatalError(const char *msg) { if (fatalErrorCleanup) - fatalErrorCleanup(); + fatalErrorCleanup(); Fatal_Error_Handler(msg,0); } @@ -204,11 +204,11 @@ void * PMAPI PM_getVESABuf( * transfer buffer to return, so we fail the call. */ if (_PM_rmBufAddr) { - *len = VESA_BUF_SIZE; - *rseg = (ulong)(_PM_rmBufAddr) >> 4; - *roff = (ulong)(_PM_rmBufAddr) & 0xF; - return _PM_rmBufAddr; - } + *len = VESA_BUF_SIZE; + *rseg = (ulong)(_PM_rmBufAddr) >> 4; + *roff = (ulong)(_PM_rmBufAddr) & 0xF; + return _PM_rmBufAddr; + } return NULL; } @@ -276,10 +276,10 @@ static ibool REG_queryString( memset(value,0,sizeof(value)); if (RegOpenKey(HKEY_LOCAL_MACHINE,szKey,&hKey) == ERROR_SUCCESS) { - if (RegQueryValueEx(hKey,(PCHAR)szValue,(ulong*)NULL,(ulong*)&type,value,(ulong*)&size) == ERROR_SUCCESS) - status = true; - RegCloseKey(hKey); - } + if (RegQueryValueEx(hKey,(PCHAR)szValue,(ulong*)NULL,(ulong*)&type,value,(ulong*)&size) == ERROR_SUCCESS) + status = true; + RegCloseKey(hKey); + } return status; } @@ -288,12 +288,12 @@ const char * PMAPI PM_getNucleusPath(void) static char path[256]; if (strlen(_PM_nucleusPath) > 0) { - strcpy(path,_PM_nucleusPath); - PM_backslash(path); - return path; - } + strcpy(path,_PM_nucleusPath); + PM_backslash(path); + return path; + } if (!REG_queryString(szWindowsKey,szSystemRoot,path,sizeof(path))) - strcpy(path,"c:\\windows"); + strcpy(path,"c:\\windows"); PM_backslash(path); strcat(path,"system\\nucleus"); return path; @@ -315,7 +315,7 @@ const char * PMAPI PM_getMachineName(void) { static char name[256]; if (REG_queryString(szMachineNameKey,szMachineName,name,sizeof(name))) - return name; + return name; return "Unknown"; } @@ -352,7 +352,7 @@ void PMAPI PM_saveConsoleState( void PMAPI PM_setSuspendAppCallback( int (_ASMAPIP saveState)( - int flags)) + int flags)) { /* Unused in VxDs */ } @@ -405,16 +405,16 @@ void * PMAPI PM_mallocShared( /* First find a free slot in our shared memory table */ for (i = 0; i < MAX_MEMORY_SHARED; i++) { - if (shared[i].linear == 0) - break; - } + if (shared[i].linear == 0) + break; + } if (i < MAX_MEMORY_SHARED) { - PageAllocate(nPages,PG_SYS,0,0,0,0,NULL,0,&hMem,&shared[i].linear); - shared[i].npages = nPages; - pgNum = (ulong)shared[i].linear >> 12; - shared[i].global = LinPageLock(pgNum,nPages,PAGEMAPGLOBAL); - return (void*)shared[i].global; - } + PageAllocate(nPages,PG_SYS,0,0,0,0,NULL,0,&hMem,&shared[i].linear); + shared[i].npages = nPages; + pgNum = (ulong)shared[i].linear >> 12; + shared[i].global = LinPageLock(pgNum,nPages,PAGEMAPGLOBAL); + return (void*)shared[i].global; + } return NULL; } @@ -428,13 +428,13 @@ void PMAPI PM_freeShared(void *p) /* Find a shared memory block in our table and free it */ for (i = 0; i < MAX_MEMORY_SHARED; i++) { - if (shared[i].global == (ulong)p) { - LinPageUnLock(shared[i].global >> 12,shared[i].npages,PAGEMAPGLOBAL); - PageFree((ulong)shared[i].linear,0); - shared[i].linear = 0; - break; - } - } + if (shared[i].global == (ulong)p) { + LinPageUnLock(shared[i].global >> 12,shared[i].npages,PAGEMAPGLOBAL); + PageFree((ulong)shared[i].linear,0); + shared[i].linear = 0; + break; + } + } } /**************************************************************************** @@ -455,7 +455,7 @@ ibool PMAPI PM_doBIOSPOST( void *mappedBIOS, ulong BIOSLen) { - // TODO: Figure out how to do this + /* TODO: Figure out how to do this */ return false; } @@ -485,29 +485,29 @@ ulong _PM_mapPhysicalToLinear( int i,ppage,flags; if (base < 0x100000) { - /* Windows 9x is zero based for the first meg of memory */ - return base; - } + /* Windows 9x is zero based for the first meg of memory */ + return base; + } ppage = base >> 12; *npages = (length + (base & 0xFFF) + 4095) >> 12; flags = PR_FIXED | PR_STATIC; if (base == 0xA0000) { - /* We require the linear address to be aligned to a 64Kb boundary - * for mapping the banked framebuffer (so we can do efficient - * carry checking for bank changes in the assembler code). The only - * way to ensure this is to force the linear address to be aligned - * to a 4Mb boundary. - */ - flags |= PR_4MEG; - } + /* We require the linear address to be aligned to a 64Kb boundary + * for mapping the banked framebuffer (so we can do efficient + * carry checking for bank changes in the assembler code). The only + * way to ensure this is to force the linear address to be aligned + * to a 4Mb boundary. + */ + flags |= PR_4MEG; + } if ((linear = (ulong)PageReserve(PR_SYSTEM,*npages,flags)) == (ulong)-1) - return 0xFFFFFFFF; + return 0xFFFFFFFF; if (!PageCommitPhys(linear >> 12,*npages,ppage,PC_INCR | PC_USER | PC_WRITEABLE)) - return 0xFFFFFFFF; + return 0xFFFFFFFF; return linear + (base & 0xFFF); } -// Page table flags +/* Page table flags */ #define PAGE_FLAGS_PRESENT 0x00000001 #define PAGE_FLAGS_WRITEABLE 0x00000002 @@ -535,9 +535,9 @@ memory below 1Mb, which gets this memory out of the way of the Windows VDD's sticky paws. NOTE: If the memory is not expected to be cached, this function will - directly re-program the PCD (Page Cache Disable) bit in the - page tables. There does not appear to be a mechanism in the VMM - to control this bit via the regular interface. + directly re-program the PCD (Page Cache Disable) bit in the + page tables. There does not appear to be a mechanism in the VMM + to control this bit via the regular interface. ****************************************************************************/ void * PMAPI PM_mapPhysicalAddr( ulong base, @@ -552,11 +552,11 @@ void * PMAPI PM_mapPhysicalAddr( * a region of memory that will serve this purpose. */ for (i = 0; i < numMappings; i++) { - if (maps[i].physical == base && maps[i].length == length && maps[i].isCached == isCached) - return (void*)maps[i].linear; - } + if (maps[i].physical == base && maps[i].length == length && maps[i].isCached == isCached) + return (void*)maps[i].linear; + } if (numMappings == MAX_MEMORY_MAPPINGS) - return NULL; + return NULL; /* We did not find any previously mapped memory region, so maps it in. * Note that we do not use MapPhysToLinear, since this function appears @@ -564,7 +564,7 @@ void * PMAPI PM_mapPhysicalAddr( * Hence we use PageReserve and PageCommitPhys. */ if ((linear = _PM_mapPhysicalToLinear(base,limit,&npages)) == 0xFFFFFFFF) - return NULL; + return NULL; maps[numMappings].physical = base; maps[numMappings].length = length; maps[numMappings].linear = linear; @@ -574,34 +574,34 @@ void * PMAPI PM_mapPhysicalAddr( /* Finally disable caching where necessary */ if (!isCached && (PDB = _PM_getPDB()) != 0) { - int startPDB,endPDB,iPDB,startPage,endPage,start,end,iPage; - ulong pageTable,*pPageTable; - pPDB = (ulong*)_PM_mapPhysicalToLinear(PDB,0xFFF,&npages); - if (pPDB) { - startPDB = (linear >> 22) & 0x3FF; - startPage = (linear >> 12) & 0x3FF; - endPDB = ((linear+limit) >> 22) & 0x3FF; - endPage = ((linear+limit) >> 12) & 0x3FF; - for (iPDB = startPDB; iPDB <= endPDB; iPDB++) { - // Set the bits in the page directory entry - required as per - // Pentium 4 manual. This also takes care of the 4MB page entries - pPDB[iPDB] = pPDB[iPDB] |= (PAGE_FLAGS_WRITE_THROUGH | PAGE_FLAGS_CACHE_DISABLE); - if (!(pPDB[iPDB] & PAGE_FLAGS_4MB)) { - // If we are dealing with 4KB pages then we need to iterate - // through each of the page table entries - pageTable = pPDB[iPDB] & ~0xFFF; - pPageTable = (ulong*)_PM_mapPhysicalToLinear(pageTable,0xFFF,&npages); - start = (iPDB == startPDB) ? startPage : 0; - end = (iPDB == endPDB) ? endPage : 0x3FF; - for (iPage = start; iPage <= end; iPage++) - pPageTable[iPage] |= (PAGE_FLAGS_WRITE_THROUGH | PAGE_FLAGS_CACHE_DISABLE); - PageFree((ulong)pPageTable,PR_STATIC); - } - } - PageFree((ulong)pPDB,PR_STATIC); - PM_flushTLB(); - } - } + int startPDB,endPDB,iPDB,startPage,endPage,start,end,iPage; + ulong pageTable,*pPageTable; + pPDB = (ulong*)_PM_mapPhysicalToLinear(PDB,0xFFF,&npages); + if (pPDB) { + startPDB = (linear >> 22) & 0x3FF; + startPage = (linear >> 12) & 0x3FF; + endPDB = ((linear+limit) >> 22) & 0x3FF; + endPage = ((linear+limit) >> 12) & 0x3FF; + for (iPDB = startPDB; iPDB <= endPDB; iPDB++) { + /* Set the bits in the page directory entry - required as per */ + /* Pentium 4 manual. This also takes care of the 4MB page entries */ + pPDB[iPDB] = pPDB[iPDB] |= (PAGE_FLAGS_WRITE_THROUGH | PAGE_FLAGS_CACHE_DISABLE); + if (!(pPDB[iPDB] & PAGE_FLAGS_4MB)) { + /* If we are dealing with 4KB pages then we need to iterate */ + /* through each of the page table entries */ + pageTable = pPDB[iPDB] & ~0xFFF; + pPageTable = (ulong*)_PM_mapPhysicalToLinear(pageTable,0xFFF,&npages); + start = (iPDB == startPDB) ? startPage : 0; + end = (iPDB == endPDB) ? endPage : 0x3FF; + for (iPage = start; iPage <= end; iPage++) + pPageTable[iPage] |= (PAGE_FLAGS_WRITE_THROUGH | PAGE_FLAGS_CACHE_DISABLE); + PageFree((ulong)pPageTable,PR_STATIC); + } + } + PageFree((ulong)pPDB,PR_STATIC); + PM_flushTLB(); + } + } return (void*)linear; } @@ -619,26 +619,26 @@ void PMAPI PM_sleep(ulong milliseconds) int PMAPI PM_getCOMPort(int port) { - // TODO: Re-code this to determine real values using the Plug and Play - // manager for the OS. + /* TODO: Re-code this to determine real values using the Plug and Play */ + /* manager for the OS. */ switch (port) { - case 0: return 0x3F8; - case 1: return 0x2F8; - case 2: return 0x3E8; - case 3: return 0x2E8; - } + case 0: return 0x3F8; + case 1: return 0x2F8; + case 2: return 0x3E8; + case 3: return 0x2E8; + } return 0; } int PMAPI PM_getLPTPort(int port) { - // TODO: Re-code this to determine real values using the Plug and Play - // manager for the OS. + /* TODO: Re-code this to determine real values using the Plug and Play */ + /* manager for the OS. */ 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; } @@ -647,18 +647,18 @@ ulong PMAPI PM_getPhysicalAddr( { DWORD pte; - // Touch the memory before calling CopyPageTable. For some reason - // we need to do this on Windows 9x, otherwise the memory may not - // be paged in correctly. Of course if the passed in pointer is - // invalid, this function will fault, but we shouldn't be passed bogus - // pointers anyway ;-) + /* Touch the memory before calling CopyPageTable. For some reason */ + /* we need to do this on Windows 9x, otherwise the memory may not */ + /* be paged in correctly. Of course if the passed in pointer is */ + /* invalid, this function will fault, but we shouldn't be passed bogus */ + /* pointers anyway ;-) */ pte = *((ulong*)p); - // Return assembled address value only if VMM service succeeds + /* Return assembled address value only if VMM service succeeds */ if (CopyPageTable(((DWORD)p) >> 12, 1, (PVOID*)&pte, 0)) - return (pte & ~0xFFF) | (((DWORD)p) & 0xFFF); + return (pte & ~0xFFF) | (((DWORD)p) & 0xFFF); - // Return failure to the caller! + /* Return failure to the caller! */ return 0xFFFFFFFFUL; } @@ -671,10 +671,10 @@ ibool PMAPI PM_getPhysicalAddrRange( ulong linear = (ulong)p & ~0xFFF; for (i = (length + 0xFFF) >> 12; i > 0; i--) { - if ((*physAddress++ = PM_getPhysicalAddr((void*)linear)) == 0xFFFFFFFF) - return false; - linear += 4096; - } + if ((*physAddress++ = PM_getPhysicalAddr((void*)linear)) == 0xFFFFFFFF) + return false; + linear += 4096; + } return true; } @@ -682,7 +682,7 @@ void PMAPI _PM_freeMemoryMappings(void) { int i; for (i = 0; i < numMappings; i++) - PageFree(maps[i].linear,PR_STATIC); + PageFree(maps[i].linear,PR_STATIC); } void * PMAPI PM_mapRealPointer( @@ -777,7 +777,7 @@ void PMAPI PM_callRealMode( * loaded, and not statically loaded. */ if (!_PM_haveBIOS) - return; + return; _TRACE("SDDHELP: Entering PM_callRealMode()\n"); Begin_Nest_V86_Exec(); @@ -807,16 +807,16 @@ int PMAPI PM_int86( * loaded, and not statically loaded. */ if (!_PM_haveBIOS) { - *out = *in; - return out->x.ax; - } + *out = *in; + return out->x.ax; + } /* Disable pass-up to our VxD handler so we directly call BIOS */ _TRACE("SDDHELP: Entering PM_int86()\n"); if (disableTSRFlag) { - oldDisable = *disableTSRFlag; - *disableTSRFlag = 0; - } + oldDisable = *disableTSRFlag; + *disableTSRFlag = 0; + } Begin_Nest_V86_Exec(); LoadV86Registers(&saveRegs,in,&sregs); Exec_Int(intno); @@ -825,7 +825,7 @@ int PMAPI PM_int86( /* Re-enable pass-up to our VxD handler if previously enabled */ if (disableTSRFlag) - *disableTSRFlag = oldDisable; + *disableTSRFlag = oldDisable; _TRACE("SDDHELP: Exiting PM_int86()\n"); return out->x.ax; @@ -849,16 +849,16 @@ int PMAPI PM_int86x( * loaded, and not statically loaded. */ if (!_PM_haveBIOS) { - *out = *in; - return out->x.ax; - } + *out = *in; + return out->x.ax; + } /* Disable pass-up to our VxD handler so we directly call BIOS */ _TRACE("SDDHELP: Entering PM_int86x()\n"); if (disableTSRFlag) { - oldDisable = *disableTSRFlag; - *disableTSRFlag = 0; - } + oldDisable = *disableTSRFlag; + *disableTSRFlag = 0; + } Begin_Nest_V86_Exec(); LoadV86Registers(&saveRegs,in,sregs); Exec_Int(intno); @@ -867,7 +867,7 @@ int PMAPI PM_int86x( /* Re-enable pass-up to our VxD handler if previously enabled */ if (disableTSRFlag) - *disableTSRFlag = oldDisable; + *disableTSRFlag = oldDisable; _TRACE("SDDHELP: Exiting PM_int86x()\n"); return out->x.ax; @@ -900,14 +900,14 @@ void * PMAPI PM_allocLockedMem( DWORD maxPhys = below16M ? 0x00FFFFFF : 0xFFFFFFFF; void *p; - // TODO: This may need to be modified if the memory needs to be globally - // accessible. Check how we implemented PM_mallocShared() as we - // may need to do something similar in here. + /* TODO: This may need to be modified if the memory needs to be globally */ + /* accessible. Check how we implemented PM_mallocShared() as we */ + /* may need to do something similar in here. */ PageAllocate(nPages,PG_SYS,0,0,0,maxPhys,physAddr,flags,&hMem,&p); - // TODO: We may need to modify the memory blocks to disable caching via - // the page tables (PCD|PWT) since DMA memory blocks *cannot* be - // cached! + /* TODO: We may need to modify the memory blocks to disable caching via */ + /* the page tables (PCD|PWT) since DMA memory blocks *cannot* be */ + /* cached! */ return p; } @@ -921,7 +921,7 @@ void PMAPI PM_freeLockedMem( ibool contiguous) { if (p) - PageFree((ulong)p,0); + PageFree((ulong)p,0); } /**************************************************************************** @@ -934,9 +934,9 @@ void * PMAPI PM_allocPage( MEMHANDLE hMem; void *p; - // TODO: This will need to be modified if the memory needs to be globally - // accessible. Check how we implemented PM_mallocShared() as we - // may need to do something similar in here. + /* TODO: This will need to be modified if the memory needs to be globally */ + /* accessible. Check how we implemented PM_mallocShared() as we */ + /* may need to do something similar in here. */ PageAllocate(1,PG_SYS,0,0,0,0,0,PAGEFIXED,&hMem,&p); return p; } @@ -949,7 +949,7 @@ void PMAPI PM_freePage( void *p) { if (p) - PageFree((ulong)p,0); + PageFree((ulong)p,0); } /**************************************************************************** @@ -1012,41 +1012,41 @@ 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; - } + /* 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,0x20 | (i+3)); - _PM_writeCMOS(0x0B,(_PM_oldCMOSRegB & 0x0F) | 0x40); - } + /* Set RTC timout value and enable timeout */ + _PM_writeCMOS(0x0A,0x20 | (i+3)); + _PM_writeCMOS(0x0B,(_PM_oldCMOSRegB & 0x0F) | 0x40); + } } /**************************************************************************** @@ -1072,11 +1072,11 @@ static BOOL __stdcall RTCInt_Handler( * new one comes along; if that happens we ignore the old one). */ if (!inside) { - inside = 1; - enable(); - _PM_rtcHandler(); - inside = 0; - } + inside = 1; + enable(); + _PM_rtcHandler(); + inside = 0; + } return TRUE; } @@ -1106,7 +1106,7 @@ ibool PMAPI PM_setRealTimeClockHandler( IRQdesc.VID_IRET_Proc = 0; IRQdesc.VID_IRET_Time_Out = 500; if ((RTCIRQHandle = VPICD_Virtualize_IRQ(&IRQdesc)) == 0) - return false; + return false; /* Program the real time clock default frequency */ PM_setRealTimeClockFrequency(frequency); @@ -1123,15 +1123,15 @@ Restore the original real time clock handler. void PMAPI PM_restoreRealTimeClockHandler(void) { if (RTCIRQHandle) { - /* Restore CMOS registers and mask RTC clock */ - _PM_writeCMOS(0x0A,_PM_oldCMOSRegA); - _PM_writeCMOS(0x0B,_PM_oldCMOSRegB); + /* Restore CMOS registers and mask RTC clock */ + _PM_writeCMOS(0x0A,_PM_oldCMOSRegA); + _PM_writeCMOS(0x0B,_PM_oldCMOSRegB); - /* Restore the interrupt vector */ - VPICD_Set_Auto_Masking(RTCIRQHandle); - VPICD_Force_Default_Behavior(RTCIRQHandle); - RTCIRQHandle = 0; - } + /* Restore the interrupt vector */ + VPICD_Set_Auto_Masking(RTCIRQHandle); + VPICD_Force_Default_Behavior(RTCIRQHandle); + RTCIRQHandle = 0; + } } /**************************************************************************** @@ -1176,9 +1176,9 @@ void *PMAPI PM_findFirstFile( const char *filename, PM_findData *findData) { - // TODO: This function should start a directory enumeration search - // given the filename (with wildcards). The data should be - // converted and returned in the findData standard form. + /* TODO: This function should start a directory enumeration search */ + /* given the filename (with wildcards). The data should be */ + /* converted and returned in the findData standard form. */ (void)filename; (void)findData; return PM_FILE_INVALID; @@ -1192,10 +1192,10 @@ ibool PMAPI PM_findNextFile( void *handle, PM_findData *findData) { - // TODO: This function should find the next file in directory enumeration - // search given the search criteria defined in the call to - // PM_findFirstFile. The data should be converted and returned - // in the findData standard form. + /* TODO: This function should find the next file in directory enumeration */ + /* search given the search criteria defined in the call to */ + /* PM_findFirstFile. The data should be converted and returned */ + /* in the findData standard form. */ (void)handle; (void)findData; return false; @@ -1208,8 +1208,8 @@ Function to close the find process void PMAPI PM_findClose( void *handle) { - // TODO: This function should close the find process. This may do - // nothing for some OS'es. + /* TODO: This function should close the find process. This may do */ + /* nothing for some OS'es. */ (void)handle; } @@ -1229,7 +1229,7 @@ numbering is: ibool PMAPI PM_driveValid( char drive) { - // Not supported in a VxD + /* Not supported in a VxD */ (void)drive; return false; } @@ -1245,7 +1245,7 @@ void PMAPI PM_getdcwd( char *dir, int len) { - // Not supported in a VxD + /* Not supported in a VxD */ (void)drive; (void)dir; (void)len; @@ -1279,7 +1279,7 @@ void PMAPI PM_setFileAttr( const char *filename, uint attrib) { - // TODO: Implement this + /* TODO: Implement this */ (void)filename; (void)attrib; PM_fatalError("PM_setFileAttr not implemented yet!"); @@ -1292,7 +1292,7 @@ Function to get the file attributes for a specific file. uint PMAPI PM_getFileAttr( const char *filename) { - // TODO: Implement this + /* TODO: Implement this */ (void)filename; PM_fatalError("PM_getFileAttr not implemented yet!"); return 0; @@ -1305,7 +1305,7 @@ Function to create a directory. ibool PMAPI PM_mkdir( const char *filename) { - // TODO: Implement this + /* TODO: Implement this */ (void)filename; PM_fatalError("PM_mkdir not implemented yet!"); return false; @@ -1318,7 +1318,7 @@ Function to remove a directory. ibool PMAPI PM_rmdir( const char *filename) { - // TODO: Implement this + /* TODO: Implement this */ (void)filename; PM_fatalError("PM_rmdir not implemented yet!"); return false; @@ -1333,7 +1333,7 @@ ibool PMAPI PM_getFileTime( ibool gmTime, PM_time *time) { - // TODO: Implement this! + /* TODO: Implement this! */ (void)filename; (void)gmTime; (void)time; @@ -1350,11 +1350,10 @@ ibool PMAPI PM_setFileTime( ibool gmTime, PM_time *time) { - // TODO: Implement this! + /* TODO: Implement this! */ (void)filename; (void)gmTime; (void)time; PM_fatalError("PM_setFileTime not implemented yet!"); return false; } - diff --git a/board/MAI/bios_emulator/scitech/src/pm/win32/cpuinfo.c b/board/MAI/bios_emulator/scitech/src/pm/win32/cpuinfo.c index 5978b9f76e2..7da97520510 100644 --- a/board/MAI/bios_emulator/scitech/src/pm/win32/cpuinfo.c +++ b/board/MAI/bios_emulator/scitech/src/pm/win32/cpuinfo.c @@ -46,7 +46,7 @@ static int SetMaxThreadPriority(void) oldPriority = GetThreadPriority(hThread); if (oldPriority != THREAD_PRIORITY_ERROR_RETURN) - SetThreadPriority(hThread, THREAD_PRIORITY_TIME_CRITICAL); + SetThreadPriority(hThread, THREAD_PRIORITY_TIME_CRITICAL); return oldPriority; } @@ -60,7 +60,7 @@ static void RestoreThreadPriority( HANDLE hThread = GetCurrentThread(); if (oldPriority != THREAD_PRIORITY_ERROR_RETURN) - SetThreadPriority(hThread, oldPriority); + SetThreadPriority(hThread, oldPriority); } /**************************************************************************** @@ -71,12 +71,12 @@ static void GetCounterFrequency( CPU_largeInteger *freq) { if (!QueryPerformanceFrequency((LARGE_INTEGER*)freq)) { - havePerformanceCounter = false; - freq->low = 100000; - freq->high = 0; - } + havePerformanceCounter = false; + freq->low = 100000; + freq->high = 0; + } else - havePerformanceCounter = true; + havePerformanceCounter = true; } /**************************************************************************** @@ -86,9 +86,9 @@ Read the counter and return the counter value. #define GetCounter(t) \ { \ if (havePerformanceCounter) \ - QueryPerformanceCounter((LARGE_INTEGER*)t); \ + QueryPerformanceCounter((LARGE_INTEGER*)t); \ else { \ - (t)->low = timeGetTime() * 100; \ - (t)->high = 0; \ - } \ + (t)->low = timeGetTime() * 100; \ + (t)->high = 0; \ + } \ } diff --git a/board/MAI/bios_emulator/scitech/src/pm/win32/ddraw.c b/board/MAI/bios_emulator/scitech/src/pm/win32/ddraw.c index cf89401fe64..d6c3f60e84c 100644 --- a/board/MAI/bios_emulator/scitech/src/pm/win32/ddraw.c +++ b/board/MAI/bios_emulator/scitech/src/pm/win32/ddraw.c @@ -85,11 +85,11 @@ static void DisableAutoPlay(void) HKEY hKey; if (RegOpenKeyEx(HKEY_CURRENT_USER,szAutoPlayKey,0,KEY_EXECUTE | KEY_WRITE,&hKey) == ERROR_SUCCESS) { - RegQueryValueEx(hKey,szAutoPlayValue,NULL,NULL,(void*)&dwAutoPlay,&dwSize); - dwAutoPlay |= AUTOPLAY_DRIVE_CDROM; - RegSetValueEx(hKey,szAutoPlayValue,0,REG_DWORD,(void*)&dwAutoPlay,dwSize); - RegCloseKey(hKey); - } + RegQueryValueEx(hKey,szAutoPlayValue,NULL,NULL,(void*)&dwAutoPlay,&dwSize); + dwAutoPlay |= AUTOPLAY_DRIVE_CDROM; + RegSetValueEx(hKey,szAutoPlayValue,0,REG_DWORD,(void*)&dwAutoPlay,dwSize); + RegCloseKey(hKey); + } } /**************************************************************************** @@ -102,11 +102,11 @@ static void RestoreAutoPlay(void) HKEY hKey; if (RegOpenKeyEx(HKEY_CURRENT_USER,szAutoPlayKey,0,KEY_EXECUTE | KEY_WRITE,&hKey) == ERROR_SUCCESS) { - RegQueryValueEx(hKey,szAutoPlayValue,NULL,NULL,(void*)&dwAutoPlay,&dwSize); - dwAutoPlay &= ~AUTOPLAY_DRIVE_CDROM; - RegSetValueEx(hKey,szAutoPlayValue,0,REG_DWORD,(void*)&dwAutoPlay,dwSize); - RegCloseKey(hKey); - } + RegQueryValueEx(hKey,szAutoPlayValue,NULL,NULL,(void*)&dwAutoPlay,&dwSize); + dwAutoPlay &= ~AUTOPLAY_DRIVE_CDROM; + RegSetValueEx(hKey,szAutoPlayValue,0,REG_DWORD,(void*)&dwAutoPlay,dwSize); + RegCloseKey(hKey); + } } /**************************************************************************** @@ -121,20 +121,20 @@ static void LeaveFullScreen(void) int retCode = PM_SUSPEND_APP; if (backInGDI) - return; + return; if (suspendApp) - retCode = suspendApp(PM_DEACTIVATE); + retCode = suspendApp(PM_DEACTIVATE); RestoreAutoPlay(); backInGDI = true; /* Now process messages normally until we are re-activated */ waitActive = true; if (retCode != PM_NO_SUSPEND_APP) { - while (waitActive) { - _EVT_pumpMessages(); - Sleep(200); - } - } + while (waitActive) { + _EVT_pumpMessages(); + Sleep(200); + } + } } /**************************************************************************** @@ -147,27 +147,27 @@ static void RestoreFullScreen(void) static ibool firstTime = true; if (firstTime) { - /* Clear the message queue while waiting for the surfaces to be - * restored. - */ - firstTime = false; - while (1) { - /* Continue looping until out application has been restored - * and we have reset the display mode. - */ - _EVT_pumpMessages(); - if (GetActiveWindow() == _PM_hwndConsole) { - if (suspendApp) - suspendApp(PM_REACTIVATE); - DisableAutoPlay(); - backInGDI = false; - waitActive = false; - firstTime = true; - return; - } - Sleep(200); - } - } + /* Clear the message queue while waiting for the surfaces to be + * restored. + */ + firstTime = false; + while (1) { + /* Continue looping until out application has been restored + * and we have reset the display mode. + */ + _EVT_pumpMessages(); + if (GetActiveWindow() == _PM_hwndConsole) { + if (suspendApp) + suspendApp(PM_REACTIVATE); + DisableAutoPlay(); + backInGDI = false; + waitActive = false; + firstTime = true; + return; + } + Sleep(200); + } + } } /**************************************************************************** @@ -192,17 +192,17 @@ void PMAPI PM_doSuspendApp(void) /* Call system DLL version if found */ if (_PM_imports.PM_doSuspendApp != PM_doSuspendApp) { - _PM_imports.PM_doSuspendApp(); - return; - } + _PM_imports.PM_doSuspendApp(); + return; + } if (firstTime) { - if (suspendApp) - suspendApp(PM_DEACTIVATE); - RestoreAutoPlay(); - firstTime = false; - backInGDI = true; - } + if (suspendApp) + suspendApp(PM_DEACTIVATE); + RestoreAutoPlay(); + firstTime = false; + backInGDI = true; + } RestoreFullScreen(); firstTime = true; } @@ -220,60 +220,60 @@ static LONG CALLBACK PM_winProc( LONG lParam) { switch (msg) { - case WM_SYSCHAR: - /* Stop Alt-Space from pausing our application */ - return 0; - case WM_KEYDOWN: - case WM_SYSKEYDOWN: - if (HIWORD(lParam) & KF_REPEAT) { - if (msg == WM_SYSKEYDOWN) - return 0; - break; - } - /* Fall through for keydown events */ - case WM_KEYUP: - case WM_SYSKEYUP: - if (msg == WM_SYSKEYDOWN || msg == WM_SYSKEYUP) { - if ((HIWORD(lParam) & KF_ALTDOWN) && wParam == VK_RETURN) - break; - /* We ignore the remainder of the system keys to stop the - * system menu from being activated from the keyboard and pausing - * our app while fullscreen (ie: pressing the Alt key). - */ - return 0; - } - break; - case WM_SYSCOMMAND: - switch (wParam & ~0x0F) { - case SC_SCREENSAVE: - case SC_MONITORPOWER: - /* Ignore screensaver requests in fullscreen modes */ - return 0; - } - break; - case WM_SIZE: - if (waitActive && backInGDI && (wParam != SIZE_MINIMIZED)) { - /* Start the re-activation process */ - PostMessage(hwnd,WM_DO_SUSPEND_APP,WM_PM_RESTORE_FULLSCREEN,0); - } - else if (!waitActive && isFullScreen && !backInGDI && (wParam == SIZE_MINIMIZED)) { - /* Start the de-activation process */ - PostMessage(hwnd,WM_DO_SUSPEND_APP,WM_PM_LEAVE_FULLSCREEN,0); - } - break; - case WM_DO_SUSPEND_APP: - switch (wParam) { + case WM_SYSCHAR: + /* Stop Alt-Space from pausing our application */ + return 0; + case WM_KEYDOWN: + case WM_SYSKEYDOWN: + if (HIWORD(lParam) & KF_REPEAT) { + if (msg == WM_SYSKEYDOWN) + return 0; + break; + } + /* Fall through for keydown events */ + case WM_KEYUP: + case WM_SYSKEYUP: + if (msg == WM_SYSKEYDOWN || msg == WM_SYSKEYUP) { + if ((HIWORD(lParam) & KF_ALTDOWN) && wParam == VK_RETURN) + break; + /* We ignore the remainder of the system keys to stop the + * system menu from being activated from the keyboard and pausing + * our app while fullscreen (ie: pressing the Alt key). + */ + return 0; + } + break; + case WM_SYSCOMMAND: + switch (wParam & ~0x0F) { + case SC_SCREENSAVE: + case SC_MONITORPOWER: + /* Ignore screensaver requests in fullscreen modes */ + return 0; + } + break; + case WM_SIZE: + if (waitActive && backInGDI && (wParam != SIZE_MINIMIZED)) { + /* Start the re-activation process */ + PostMessage(hwnd,WM_DO_SUSPEND_APP,WM_PM_RESTORE_FULLSCREEN,0); + } + else if (!waitActive && isFullScreen && !backInGDI && (wParam == SIZE_MINIMIZED)) { + /* Start the de-activation process */ + PostMessage(hwnd,WM_DO_SUSPEND_APP,WM_PM_LEAVE_FULLSCREEN,0); + } + break; + case WM_DO_SUSPEND_APP: + switch (wParam) { case WM_PM_RESTORE_FULLSCREEN: RestoreFullScreen(); break; case WM_PM_LEAVE_FULLSCREEN: LeaveFullScreen(); break; - } - return 0; - } + } + return 0; + } if (oldWinProc) - return oldWinProc(hwnd,msg,wParam,lParam); + return oldWinProc(hwnd,msg,wParam,lParam); return DefWindowProc(hwnd,msg,wParam,lParam); } @@ -349,32 +349,32 @@ void * PMAPI PM_loadDirectDraw( /* Call system DLL version if found */ if (_PM_imports.PM_loadDirectDraw != PM_loadDirectDraw) - return _PM_imports.PM_loadDirectDraw(device); + return _PM_imports.PM_loadDirectDraw(device); - // TODO: Handle multi-monitor!! + /* TODO: Handle multi-monitor!! */ if (device != 0) - return NULL; + return NULL; /* Load the DirectDraw DLL if not presently loaded */ GET_DEFAULT_CW(); if (!hInstDD) { - hdc = GetDC(NULL); - bits = GetDeviceCaps(hdc,BITSPIXEL); - ReleaseDC(NULL,hdc); - if (bits < 8) - return NULL; - if ((hInstDD = LoadLibrary("ddraw.dll")) == NULL) - return NULL; - pDirectDrawCreate = (void*)GetProcAddress(hInstDD,"DirectDrawCreate"); - if (!pDirectDrawCreate) - return NULL; - } + hdc = GetDC(NULL); + bits = GetDeviceCaps(hdc,BITSPIXEL); + ReleaseDC(NULL,hdc); + if (bits < 8) + return NULL; + if ((hInstDD = LoadLibrary("ddraw.dll")) == NULL) + return NULL; + pDirectDrawCreate = (void*)GetProcAddress(hInstDD,"DirectDrawCreate"); + if (!pDirectDrawCreate) + return NULL; + } /* Create the DirectDraw object */ if (!lpDD && pDirectDrawCreate(NULL, &lpDD, NULL) != DD_OK) { - lpDD = NULL; - return NULL; - } + lpDD = NULL; + return NULL; + } RESET_DEFAULT_CW(); return lpDD; } @@ -394,13 +394,13 @@ void PMAPI PM_unloadDirectDraw( { /* Call system DLL version if found */ if (_PM_imports.PM_unloadDirectDraw != PM_unloadDirectDraw) { - _PM_imports.PM_unloadDirectDraw(device); - return; - } + _PM_imports.PM_unloadDirectDraw(device); + return; + } if (lpDD) { - IDirectDraw_Release(lpDD); - lpDD = NULL; - } + IDirectDraw_Release(lpDD); + lpDD = NULL; + } (void)device; } @@ -423,56 +423,56 @@ PM_HWND PMAPI PM_openConsole( /* Call system DLL version if found */ GA_getSystemPMImports(); if (_PM_imports.PM_openConsole != PM_openConsole) { - if (fullScreen) { - _PM_deskX = xRes; - _PM_deskY = yRes; - } - return _PM_imports.PM_openConsole(hWndUser,device,xRes,yRes,bpp,fullScreen); - } + if (fullScreen) { + _PM_deskX = xRes; + _PM_deskY = yRes; + } + return _PM_imports.PM_openConsole(hWndUser,device,xRes,yRes,bpp,fullScreen); + } /* Create the fullscreen window if necessary */ hwndUser = hWndUser; if (fullScreen) { - if (!classRegistered) { - /* Create a Window class for the fullscreen window in here, since - * we need to register one that will do all our event handling for - * us. - */ - hInstApp = GetModuleHandle(NULL); - cls.hCursor = LoadCursor(NULL,IDC_ARROW); - cls.hIcon = LoadIcon(hInstApp,MAKEINTRESOURCE(1)); - cls.lpszMenuName = NULL; - cls.lpszClassName = szWinClassName; - cls.hbrBackground = GetStockObject(BLACK_BRUSH); - cls.hInstance = hInstApp; - cls.style = CS_DBLCLKS; - cls.lpfnWndProc = PM_winProc; - cls.cbWndExtra = 0; - cls.cbClsExtra = 0; - if (!RegisterClass(&cls)) - return NULL; - classRegistered = true; - } - _PM_deskX = xRes; - _PM_deskY = yRes; - if (!hwndUser) { - char windowTitle[80]; - if (LoadString(hInstApp,1,windowTitle,sizeof(windowTitle)) == 0) - strcpy(windowTitle,"MGL Fullscreen Application"); - _PM_hwndConsole = CreateWindowEx(WS_EX_APPWINDOW,szWinClassName, - windowTitle,WS_POPUP | WS_SYSMENU,0,0,xRes,yRes, - NULL,NULL,hInstApp,NULL); - } - else { - _PM_hwndConsole = _PM_convertUserWindow(hwndUser,xRes,yRes); - } - ShowCursor(false); - isFullScreen = true; - } + if (!classRegistered) { + /* Create a Window class for the fullscreen window in here, since + * we need to register one that will do all our event handling for + * us. + */ + hInstApp = GetModuleHandle(NULL); + cls.hCursor = LoadCursor(NULL,IDC_ARROW); + cls.hIcon = LoadIcon(hInstApp,MAKEINTRESOURCE(1)); + cls.lpszMenuName = NULL; + cls.lpszClassName = szWinClassName; + cls.hbrBackground = GetStockObject(BLACK_BRUSH); + cls.hInstance = hInstApp; + cls.style = CS_DBLCLKS; + cls.lpfnWndProc = PM_winProc; + cls.cbWndExtra = 0; + cls.cbClsExtra = 0; + if (!RegisterClass(&cls)) + return NULL; + classRegistered = true; + } + _PM_deskX = xRes; + _PM_deskY = yRes; + if (!hwndUser) { + char windowTitle[80]; + if (LoadString(hInstApp,1,windowTitle,sizeof(windowTitle)) == 0) + strcpy(windowTitle,"MGL Fullscreen Application"); + _PM_hwndConsole = CreateWindowEx(WS_EX_APPWINDOW,szWinClassName, + windowTitle,WS_POPUP | WS_SYSMENU,0,0,xRes,yRes, + NULL,NULL,hInstApp,NULL); + } + else { + _PM_hwndConsole = _PM_convertUserWindow(hwndUser,xRes,yRes); + } + ShowCursor(false); + isFullScreen = true; + } else { - _PM_hwndConsole = hwndUser; - isFullScreen = false; - } + _PM_hwndConsole = hwndUser; + isFullScreen = false; + } SetFocus(_PM_hwndConsole); SetForegroundWindow(_PM_hwndConsole); DisableAutoPlay(); @@ -488,7 +488,7 @@ int PMAPI PM_getConsoleStateSize(void) { /* Call system DLL version if found */ if (_PM_imports.PM_getConsoleStateSize != PM_getConsoleStateSize) - return _PM_imports.PM_getConsoleStateSize(); + return _PM_imports.PM_getConsoleStateSize(); /* Not used in Windows */ return 1; @@ -504,9 +504,9 @@ void PMAPI PM_saveConsoleState( { /* Call system DLL version if found */ if (_PM_imports.PM_saveConsoleState != PM_saveConsoleState) { - _PM_imports.PM_saveConsoleState(stateBuf,hwndConsole); - return; - } + _PM_imports.PM_saveConsoleState(stateBuf,hwndConsole); + return; + } /* Not used in Windows */ (void)stateBuf; @@ -522,9 +522,9 @@ void PMAPI PM_setSuspendAppCallback( { /* Call system DLL version if found */ if (_PM_imports.PM_setSuspendAppCallback != PM_setSuspendAppCallback) { - _PM_imports.PM_setSuspendAppCallback(saveState); - return; - } + _PM_imports.PM_setSuspendAppCallback(saveState); + return; + } suspendApp = saveState; } @@ -538,9 +538,9 @@ void PMAPI PM_restoreConsoleState( { /* Call system DLL version if found */ if (_PM_imports.PM_restoreConsoleState != PM_restoreConsoleState) { - _PM_imports.PM_restoreConsoleState(stateBuf,hwndConsole); - return; - } + _PM_imports.PM_restoreConsoleState(stateBuf,hwndConsole); + return; + } /* Not used in Windows */ (void)stateBuf; @@ -556,15 +556,15 @@ void PMAPI PM_closeConsole( { /* Call system DLL version if found */ if (_PM_imports.PM_closeConsole != PM_closeConsole) { - _PM_imports.PM_closeConsole(hwndConsole); - return; - } + _PM_imports.PM_closeConsole(hwndConsole); + return; + } ShowCursor(true); RestoreAutoPlay(); if (hwndUser) - _PM_restoreUserWindow(hwndConsole); + _PM_restoreUserWindow(hwndConsole); else - DestroyWindow(hwndConsole); + DestroyWindow(hwndConsole); hwndUser = NULL; _PM_hwndConsole = NULL; } @@ -577,7 +577,6 @@ PM_HWND PMAPI PM_getDirectDrawWindow(void) { /* Call system DLL version if found */ if (_PM_imports.PM_getDirectDrawWindow != PM_getDirectDrawWindow) - return _PM_imports.PM_getDirectDrawWindow(); + return _PM_imports.PM_getDirectDrawWindow(); return _PM_hwndConsole; } - diff --git a/board/MAI/bios_emulator/scitech/src/pm/win32/event.c b/board/MAI/bios_emulator/scitech/src/pm/win32/event.c index c14377dcda3..86448e32faf 100644 --- a/board/MAI/bios_emulator/scitech/src/pm/win32/event.c +++ b/board/MAI/bios_emulator/scitech/src/pm/win32/event.c @@ -70,143 +70,143 @@ void _EVT_pumpMessages(void) MSG charMsg; event_t evt; - // TODO: Add support for DirectInput! We can't support relative mouse - // movement motion counters without DirectInput ;-(. + /* TODO: Add support for DirectInput! We can't support relative mouse */ + /* movement motion counters without DirectInput ;-(. */ while (PeekMessage(&msg,NULL,0,0,PM_REMOVE)) { - memset(&evt,0,sizeof(evt)); - switch (msg.message) { - case WM_MOUSEMOVE: - evt.what = EVT_MOUSEMOVE; - break; - case WM_LBUTTONDBLCLK: - evt.what = EVT_MOUSEDOWN; - evt.message = EVT_LEFTBMASK | EVT_DBLCLICK; - break; - case WM_LBUTTONDOWN: - evt.what = EVT_MOUSEDOWN; - evt.message = EVT_LEFTBMASK; - break; - case WM_LBUTTONUP: - evt.what = EVT_MOUSEUP; - evt.message = EVT_LEFTBMASK; - break; - case WM_RBUTTONDBLCLK: - evt.what = EVT_MOUSEDOWN | EVT_DBLCLICK; - evt.message = EVT_RIGHTBMASK; - break; - case WM_RBUTTONDOWN: - evt.what = EVT_MOUSEDOWN; - evt.message = EVT_RIGHTBMASK; - break; - case WM_RBUTTONUP: - evt.what = EVT_MOUSEUP; - evt.message = EVT_RIGHTBMASK; - break; - case WM_MBUTTONDBLCLK: - evt.what = EVT_MOUSEDOWN | EVT_DBLCLICK; - evt.message = EVT_MIDDLEBMASK; - break; - case WM_MBUTTONDOWN: - evt.what = EVT_MOUSEDOWN; - evt.message = EVT_MIDDLEBMASK; - break; - case WM_MBUTTONUP: - evt.what = EVT_MOUSEUP; - evt.message = EVT_MIDDLEBMASK; - break; - case WM_KEYDOWN: - case WM_SYSKEYDOWN: - if (HIWORD(msg.lParam) & KF_REPEAT) { - evt.what = EVT_KEYREPEAT; - } - else { - evt.what = EVT_KEYDOWN; - } - break; - case WM_KEYUP: - case WM_SYSKEYUP: - evt.what = EVT_KEYUP; - break; - } - - /* Convert mouse event modifier flags */ - if (evt.what & EVT_MOUSEEVT) { - if (_PM_deskX) { - evt.where_x = ((long)msg.pt.x * rangeX) / _PM_deskX; - evt.where_y = ((long)msg.pt.y * rangeY) / _PM_deskY; - } - else { - ScreenToClient(_PM_hwndConsole, &msg.pt); - evt.where_x = msg.pt.x; - evt.where_y = msg.pt.y; - } - if (evt.what == EVT_MOUSEMOVE) { - /* Save the current mouse position */ - EVT.mx = evt.where_x; - EVT.my = evt.where_y; - if (EVT.oldMove != -1) { - EVT.evtq[EVT.oldMove].where_x = evt.where_x;/* Modify existing one */ - EVT.evtq[EVT.oldMove].where_y = evt.where_y; -// EVT.evtq[EVT.oldMove].relative_x += mickeyX; // TODO! -// EVT.evtq[EVT.oldMove].relative_y += mickeyY; // TODO! - evt.what = 0; - } - else { - EVT.oldMove = EVT.freeHead; /* Save id of this move event */ -// evt.relative_x = mickeyX; // TODO! -// evt.relative_y = mickeyY; // TODO! - } - } - else - EVT.oldMove = -1; - if (msg.wParam & MK_LBUTTON) - evt.modifiers |= EVT_LEFTBUT; - if (msg.wParam & MK_RBUTTON) - evt.modifiers |= EVT_RIGHTBUT; - if (msg.wParam & MK_MBUTTON) - evt.modifiers |= EVT_MIDDLEBUT; - if (msg.wParam & MK_SHIFT) - evt.modifiers |= EVT_SHIFTKEY; - if (msg.wParam & MK_CONTROL) - evt.modifiers |= EVT_CTRLSTATE; - } - - /* Convert keyboard codes */ - TranslateMessage(&msg); - if (evt.what & EVT_KEYEVT) { - int scanCode = (msg.lParam >> 16) & 0xFF; - if (evt.what == EVT_KEYUP) { - /* Get message for keyup code from table of cached down values */ - evt.message = keyUpMsg[scanCode]; - keyUpMsg[scanCode] = 0; - } - else { - if (PeekMessage(&charMsg,NULL,WM_CHAR,WM_CHAR,PM_REMOVE)) - evt.message = charMsg.wParam; - if (PeekMessage(&charMsg,NULL,WM_SYSCHAR,WM_SYSCHAR,PM_REMOVE)) - evt.message = charMsg.wParam; - evt.message |= ((msg.lParam >> 8) & 0xFF00); - keyUpMsg[scanCode] = (ushort)evt.message; - } - if (evt.what == EVT_KEYREPEAT) - evt.message |= (msg.lParam << 16); - if (HIWORD(msg.lParam) & KF_ALTDOWN) - evt.modifiers |= EVT_ALTSTATE; - if (GetKeyState(VK_SHIFT) & 0x8000U) - evt.modifiers |= EVT_SHIFTKEY; - if (GetKeyState(VK_CONTROL) & 0x8000U) - evt.modifiers |= EVT_CTRLSTATE; - EVT.oldMove = -1; - } - - if (evt.what != 0) { - /* Add time stamp and add the event to the queue */ - evt.when = msg.time; - if (EVT.count < EVENTQSIZE) - addEvent(&evt); - } - DispatchMessage(&msg); - } + memset(&evt,0,sizeof(evt)); + switch (msg.message) { + case WM_MOUSEMOVE: + evt.what = EVT_MOUSEMOVE; + break; + case WM_LBUTTONDBLCLK: + evt.what = EVT_MOUSEDOWN; + evt.message = EVT_LEFTBMASK | EVT_DBLCLICK; + break; + case WM_LBUTTONDOWN: + evt.what = EVT_MOUSEDOWN; + evt.message = EVT_LEFTBMASK; + break; + case WM_LBUTTONUP: + evt.what = EVT_MOUSEUP; + evt.message = EVT_LEFTBMASK; + break; + case WM_RBUTTONDBLCLK: + evt.what = EVT_MOUSEDOWN | EVT_DBLCLICK; + evt.message = EVT_RIGHTBMASK; + break; + case WM_RBUTTONDOWN: + evt.what = EVT_MOUSEDOWN; + evt.message = EVT_RIGHTBMASK; + break; + case WM_RBUTTONUP: + evt.what = EVT_MOUSEUP; + evt.message = EVT_RIGHTBMASK; + break; + case WM_MBUTTONDBLCLK: + evt.what = EVT_MOUSEDOWN | EVT_DBLCLICK; + evt.message = EVT_MIDDLEBMASK; + break; + case WM_MBUTTONDOWN: + evt.what = EVT_MOUSEDOWN; + evt.message = EVT_MIDDLEBMASK; + break; + case WM_MBUTTONUP: + evt.what = EVT_MOUSEUP; + evt.message = EVT_MIDDLEBMASK; + break; + case WM_KEYDOWN: + case WM_SYSKEYDOWN: + if (HIWORD(msg.lParam) & KF_REPEAT) { + evt.what = EVT_KEYREPEAT; + } + else { + evt.what = EVT_KEYDOWN; + } + break; + case WM_KEYUP: + case WM_SYSKEYUP: + evt.what = EVT_KEYUP; + break; + } + + /* Convert mouse event modifier flags */ + if (evt.what & EVT_MOUSEEVT) { + if (_PM_deskX) { + evt.where_x = ((long)msg.pt.x * rangeX) / _PM_deskX; + evt.where_y = ((long)msg.pt.y * rangeY) / _PM_deskY; + } + else { + ScreenToClient(_PM_hwndConsole, &msg.pt); + evt.where_x = msg.pt.x; + evt.where_y = msg.pt.y; + } + if (evt.what == EVT_MOUSEMOVE) { + /* Save the current mouse position */ + EVT.mx = evt.where_x; + EVT.my = evt.where_y; + if (EVT.oldMove != -1) { + EVT.evtq[EVT.oldMove].where_x = evt.where_x;/* Modify existing one */ + EVT.evtq[EVT.oldMove].where_y = evt.where_y; +/* EVT.evtq[EVT.oldMove].relative_x += mickeyX; // TODO! */ +/* EVT.evtq[EVT.oldMove].relative_y += mickeyY; // TODO! */ + evt.what = 0; + } + else { + EVT.oldMove = EVT.freeHead; /* Save id of this move event */ +/* evt.relative_x = mickeyX; // TODO! */ +/* evt.relative_y = mickeyY; // TODO! */ + } + } + else + EVT.oldMove = -1; + if (msg.wParam & MK_LBUTTON) + evt.modifiers |= EVT_LEFTBUT; + if (msg.wParam & MK_RBUTTON) + evt.modifiers |= EVT_RIGHTBUT; + if (msg.wParam & MK_MBUTTON) + evt.modifiers |= EVT_MIDDLEBUT; + if (msg.wParam & MK_SHIFT) + evt.modifiers |= EVT_SHIFTKEY; + if (msg.wParam & MK_CONTROL) + evt.modifiers |= EVT_CTRLSTATE; + } + + /* Convert keyboard codes */ + TranslateMessage(&msg); + if (evt.what & EVT_KEYEVT) { + int scanCode = (msg.lParam >> 16) & 0xFF; + if (evt.what == EVT_KEYUP) { + /* Get message for keyup code from table of cached down values */ + evt.message = keyUpMsg[scanCode]; + keyUpMsg[scanCode] = 0; + } + else { + if (PeekMessage(&charMsg,NULL,WM_CHAR,WM_CHAR,PM_REMOVE)) + evt.message = charMsg.wParam; + if (PeekMessage(&charMsg,NULL,WM_SYSCHAR,WM_SYSCHAR,PM_REMOVE)) + evt.message = charMsg.wParam; + evt.message |= ((msg.lParam >> 8) & 0xFF00); + keyUpMsg[scanCode] = (ushort)evt.message; + } + if (evt.what == EVT_KEYREPEAT) + evt.message |= (msg.lParam << 16); + if (HIWORD(msg.lParam) & KF_ALTDOWN) + evt.modifiers |= EVT_ALTSTATE; + if (GetKeyState(VK_SHIFT) & 0x8000U) + evt.modifiers |= EVT_SHIFTKEY; + if (GetKeyState(VK_CONTROL) & 0x8000U) + evt.modifiers |= EVT_CTRLSTATE; + EVT.oldMove = -1; + } + + if (evt.what != 0) { + /* Add time stamp and add the event to the queue */ + evt.when = msg.time; + if (EVT.count < EVENTQSIZE) + addEvent(&evt); + } + DispatchMessage(&msg); + } } /**************************************************************************** @@ -299,7 +299,7 @@ and this function can be used to resume it again later. ****************************************************************************/ void EVT_resume(void) { - // Do nothing for Win32 + /* Do nothing for Win32 */ } /**************************************************************************** @@ -309,7 +309,7 @@ de-install the event handling code. ****************************************************************************/ void EVT_suspend(void) { - // Do nothing for Win32 + /* Do nothing for Win32 */ } /**************************************************************************** @@ -343,7 +343,7 @@ EVT_joySetLowerRight, EVT_joySetCenter, EVT_joyIsPresent ****************************************************************************/ int EVTAPI EVT_joyIsPresent(void) { - // TODO: Implement joystick code based on DirectX! + /* TODO: Implement joystick code based on DirectX! */ return 0; } @@ -362,9 +362,9 @@ All information polled from the joystick will be posted to the event queue for later retrieval. Note: Most analogue joysticks will provide readings that change even - though the joystick has not moved. Hence if you call this routine - you will likely get an EVT_JOYMOVE event every time through your - event loop. + though the joystick has not moved. Hence if you call this routine + you will likely get an EVT_JOYMOVE event every time through your + event loop. SEE ALSO: EVT_getNext, EVT_peekNext, EVT_joySetUpperLeft, EVT_joySetLowerRight, @@ -457,4 +457,3 @@ EVT_joySetUpperLeft, EVT_joySetLowerRight, EVT_joySetCenter void EVTAPI EVT_joySetCenter(void) { } - diff --git a/board/MAI/bios_emulator/scitech/src/pm/win32/ntservc.c b/board/MAI/bios_emulator/scitech/src/pm/win32/ntservc.c index a3324d33b84..59d9aa0c7c7 100644 --- a/board/MAI/bios_emulator/scitech/src/pm/win32/ntservc.c +++ b/board/MAI/bios_emulator/scitech/src/pm/win32/ntservc.c @@ -64,63 +64,63 @@ ulong PMAPI PM_installService( char keyPath[MAX_PATH]; ulong status; - // Obtain a handle to the service control manager requesting all access + /* Obtain a handle to the service control manager requesting all access */ if ((scmHandle = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS)) == NULL) - return GetLastError(); + return GetLastError(); - // Find the path to the driver in system directory + /* Find the path to the driver in system directory */ GetSystemDirectory(szDriverPath, sizeof(szDriverPath)); strcat(szDriverPath, "\\drivers\\"); strcat(szDriverPath, szDriverName); - // Create the service with the Service Control Manager. + /* Create the service with the Service Control Manager. */ driverHandle = CreateService(scmHandle, - szServiceName, - szServiceName, - SERVICE_ALL_ACCESS, - dwServiceType, - SERVICE_BOOT_START, - SERVICE_ERROR_NORMAL, - szDriverPath, - szLoadGroup, - NULL, - NULL, - NULL, - NULL); - - // Check to see if the driver could actually be installed. + szServiceName, + szServiceName, + SERVICE_ALL_ACCESS, + dwServiceType, + SERVICE_BOOT_START, + SERVICE_ERROR_NORMAL, + szDriverPath, + szLoadGroup, + NULL, + NULL, + NULL, + NULL); + + /* Check to see if the driver could actually be installed. */ if (!driverHandle) { - status = GetLastError(); - CloseServiceHandle(scmHandle); - return status; - } + status = GetLastError(); + CloseServiceHandle(scmHandle); + return status; + } - // Get a handle to the key for driver so that it can be altered in the - // next step. + /* Get a handle to the key for driver so that it can be altered in the */ + /* next step. */ strcpy(keyPath, "SYSTEM\\CurrentControlSet\\Services\\"); strcat(keyPath, szServiceName); if ((status = RegOpenKeyEx(HKEY_LOCAL_MACHINE,keyPath,0,KEY_ALL_ACCESS,&key)) != ERROR_SUCCESS) { - // A problem has occured. Delete the service so that it is not installed. - status = GetLastError(); - DeleteService(driverHandle); - CloseServiceHandle(driverHandle); - CloseServiceHandle(scmHandle); - return status; - } - - // Delete the ImagePath value in the newly created key so that the - // system looks for the driver in the normal location. + /* A problem has occured. Delete the service so that it is not installed. */ + status = GetLastError(); + DeleteService(driverHandle); + CloseServiceHandle(driverHandle); + CloseServiceHandle(scmHandle); + return status; + } + + /* Delete the ImagePath value in the newly created key so that the */ + /* system looks for the driver in the normal location. */ if ((status = RegDeleteValue(key, "ImagePath")) != ERROR_SUCCESS) { - // A problem has occurred. Delete the service so that it is not - // installed and will not try to start. - RegCloseKey(key); - DeleteService(driverHandle); - CloseServiceHandle(driverHandle); - CloseServiceHandle(scmHandle); - return status; - } - - // Clean up and exit + /* A problem has occurred. Delete the service so that it is not */ + /* installed and will not try to start. */ + RegCloseKey(key); + DeleteService(driverHandle); + CloseServiceHandle(driverHandle); + CloseServiceHandle(scmHandle); + return status; + } + + /* Clean up and exit */ RegCloseKey(key); CloseServiceHandle(driverHandle); CloseServiceHandle(scmHandle); @@ -145,32 +145,32 @@ ulong PMAPI PM_startService( SERVICE_STATUS serviceStatus; ulong status; - // Obtain a handle to the service control manager requesting all access + /* Obtain a handle to the service control manager requesting all access */ if ((scmHandle = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS)) == NULL) - return GetLastError(); + return GetLastError(); - // Open the service with the Service Control Manager. + /* Open the service with the Service Control Manager. */ if ((driverHandle = OpenService(scmHandle,szServiceName,SERVICE_ALL_ACCESS)) == NULL) { - status = GetLastError(); - CloseServiceHandle(scmHandle); - return status; - } + status = GetLastError(); + CloseServiceHandle(scmHandle); + return status; + } - // Start the service + /* Start the service */ if (!StartService(driverHandle,0,NULL)) { - status = GetLastError(); - CloseServiceHandle(driverHandle); - CloseServiceHandle(scmHandle); - return status; - } - - // Query the service to make sure it is there - if (!QueryServiceStatus(driverHandle,&serviceStatus)) { - status = GetLastError(); - CloseServiceHandle(driverHandle); - CloseServiceHandle(scmHandle); - return status; - } + status = GetLastError(); + CloseServiceHandle(driverHandle); + CloseServiceHandle(scmHandle); + return status; + } + + /* Query the service to make sure it is there */ + if (!QueryServiceStatus(driverHandle,&serviceStatus)) { + status = GetLastError(); + CloseServiceHandle(driverHandle); + CloseServiceHandle(scmHandle); + return status; + } CloseServiceHandle(driverHandle); CloseServiceHandle(scmHandle); return ERROR_SUCCESS; @@ -194,24 +194,24 @@ ulong PMAPI PM_stopService( SERVICE_STATUS serviceStatus; ulong status; - // Obtain a handle to the service control manager requesting all access + /* Obtain a handle to the service control manager requesting all access */ if ((scmHandle = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS)) == NULL) - return GetLastError(); + return GetLastError(); - // Open the service with the Service Control Manager. + /* Open the service with the Service Control Manager. */ if ((driverHandle = OpenService(scmHandle,szServiceName,SERVICE_ALL_ACCESS)) == NULL) { - status = GetLastError(); - CloseServiceHandle(scmHandle); - return status; - } + status = GetLastError(); + CloseServiceHandle(scmHandle); + return status; + } - // Stop the service from running + /* Stop the service from running */ if (!ControlService(driverHandle, SERVICE_CONTROL_STOP, &serviceStatus)) { - status = GetLastError(); - CloseServiceHandle(driverHandle); - CloseServiceHandle(scmHandle); - return status; - } + status = GetLastError(); + CloseServiceHandle(driverHandle); + CloseServiceHandle(scmHandle); + return status; + } CloseServiceHandle(driverHandle); CloseServiceHandle(scmHandle); return ERROR_SUCCESS; @@ -234,26 +234,25 @@ ulong PMAPI PM_removeService( SC_HANDLE driverHandle; ulong status; - // Obtain a handle to the service control manager requesting all access + /* Obtain a handle to the service control manager requesting all access */ if ((scmHandle = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS)) == NULL) - return GetLastError(); + return GetLastError(); - // Open the service with the Service Control Manager. + /* Open the service with the Service Control Manager. */ if ((driverHandle = OpenService(scmHandle,szServiceName,SERVICE_ALL_ACCESS)) == NULL) { - status = GetLastError(); - CloseServiceHandle(scmHandle); - return status; - } + status = GetLastError(); + CloseServiceHandle(scmHandle); + return status; + } - // Remove the service + /* Remove the service */ if (!DeleteService(driverHandle)) { - status = GetLastError(); - CloseServiceHandle(driverHandle); - CloseServiceHandle(scmHandle); - return status; - } + status = GetLastError(); + CloseServiceHandle(driverHandle); + CloseServiceHandle(scmHandle); + return status; + } CloseServiceHandle(driverHandle); CloseServiceHandle(scmHandle); return ERROR_SUCCESS; } - diff --git a/board/MAI/bios_emulator/scitech/src/pm/win32/oshdr.h b/board/MAI/bios_emulator/scitech/src/pm/win32/oshdr.h index 018c936d8aa..0c59e9006fa 100644 --- a/board/MAI/bios_emulator/scitech/src/pm/win32/oshdr.h +++ b/board/MAI/bios_emulator/scitech/src/pm/win32/oshdr.h @@ -47,7 +47,7 @@ #define GET_DEFAULT_CW() \ { \ if (_PM_cw_default == 0) \ - _PM_cw_default = _control87(0,0); \ + _PM_cw_default = _control87(0,0); \ } #define RESET_DEFAULT_CW() \ _control87(_PM_cw_default,0xFFFFFFFF) @@ -77,4 +77,3 @@ extern HWND _PM_hwndConsole; /* Window handle for console */ /*-------------------------- Internal Functions ---------------------------*/ void _EVT_pumpMessages(void); - diff --git a/board/MAI/bios_emulator/scitech/src/pm/win32/pm.c b/board/MAI/bios_emulator/scitech/src/pm/win32/pm.c index d08da4c630d..1ffdbccabc3 100644 --- a/board/MAI/bios_emulator/scitech/src/pm/win32/pm.c +++ b/board/MAI/bios_emulator/scitech/src/pm/win32/pm.c @@ -69,10 +69,10 @@ static char *szMachineName = "ComputerName"; #define CHECK_FOR_PMHELP() \ { \ if (_PM_hDevice == INVALID_HANDLE_VALUE) \ - if (_PM_haveWinNT) \ - PM_fatalError("Unable to connect to PMHELP.SYS or SDDHELP.SYS!"); \ - else \ - PM_fatalError("Unable to connect to PMHELP.VXD or SDDHELP.VXD!"); \ + if (_PM_haveWinNT) \ + PM_fatalError("Unable to connect to PMHELP.SYS or SDDHELP.SYS!"); \ + else \ + PM_fatalError("Unable to connect to PMHELP.VXD or SDDHELP.VXD!"); \ } /**************************************************************************** @@ -95,71 +95,71 @@ void PMAPI PM_init(void) * of SDD is loaded, we use the PMHELP VxD instead. */ if (!inited) { - /* Determine if we are running under Windows NT or not and - * set the global OS type variable. - */ - _PM_haveWinNT = false; - if ((GetVersion() & 0x80000000UL) == 0) - _PM_haveWinNT = true; - ___drv_os_type = (_PM_haveWinNT) ? _OS_WINNT : _OS_WIN95; - - /* Now try to connect to SDDHELP.VXD or SDDHELP.SYS */ - _PM_hDevice = CreateFile(SDDHELP_MODULE_PATH, 0,0,0, CREATE_NEW, FILE_FLAG_DELETE_ON_CLOSE, 0); - if (_PM_hDevice != INVALID_HANDLE_VALUE) { - if (!DeviceIoControl(_PM_hDevice, PMHELP_GETVER32, NULL, 0, - outBuf, sizeof(outBuf), &count, NULL) || outBuf[0] < PMHELP_VERSION) { - /* Old version of SDDHELP loaded, so use PMHELP instead */ - CloseHandle(_PM_hDevice); - _PM_hDevice = INVALID_HANDLE_VALUE; - } - } - if (_PM_hDevice == INVALID_HANDLE_VALUE) { - /* First try to see if there is a currently loaded PMHELP driver. - * This is usually the case when we are running under Windows NT/2K. - */ - _PM_hDevice = CreateFile(PMHELP_MODULE_PATH, 0,0,0, CREATE_NEW, FILE_FLAG_DELETE_ON_CLOSE, 0); - if (_PM_hDevice == INVALID_HANDLE_VALUE) { - /* The driver was not staticly loaded, so try creating a file handle - * to a dynamic version of the VxD if possible. Note that on WinNT/2K we - * cannot support dynamically loading the drivers. - */ - _PM_hDevice = CreateFile(PMHELP_VXD_PATH, 0,0,0, CREATE_NEW, FILE_FLAG_DELETE_ON_CLOSE, 0); - } - } - if (_PM_hDevice != INVALID_HANDLE_VALUE) { - /* Call the driver to determine the version number */ - if (!DeviceIoControl(_PM_hDevice, PMHELP_GETVER32, inBuf, sizeof(inBuf), - outBuf, sizeof(outBuf), &count, NULL) || outBuf[0] < PMHELP_VERSION) { - if (_PM_haveWinNT) - PM_fatalError("Older version of PMHELP.SYS found!"); - else - PM_fatalError("Older version of PMHELP.VXD found!"); - } - - /* Now set the current path inside the VxD so it knows what the - * current directory is for loading Nucleus drivers. - */ - inBuf[0] = (ulong)PM_getCurrentPath(cntPath,sizeof(cntPath)); - if (!DeviceIoControl(_PM_hDevice, PMHELP_SETCNTPATH32, inBuf, sizeof(inBuf), outBuf, sizeof(outBuf), &count, NULL)) - PM_fatalError("Unable to set VxD current path!"); - - /* Now pass down the NUCLEUS_PATH environment variable to the device - * driver so it can use this value if it is found. - */ - if ((env = getenv("NUCLEUS_PATH")) != NULL) { - inBuf[0] = (ulong)env; - if (!DeviceIoControl(_PM_hDevice, PMHELP_SETNUCLEUSPATH32, inBuf, sizeof(inBuf), outBuf, sizeof(outBuf), &count, NULL)) - PM_fatalError("Unable to set VxD Nucleus path!"); - } - - /* Enable IOPL for ring-3 code by default if driver is present */ - if (_PM_haveWinNT) - PM_setIOPL(3); - } - - /* Indicate that we have been initialised */ - inited = true; - } + /* Determine if we are running under Windows NT or not and + * set the global OS type variable. + */ + _PM_haveWinNT = false; + if ((GetVersion() & 0x80000000UL) == 0) + _PM_haveWinNT = true; + ___drv_os_type = (_PM_haveWinNT) ? _OS_WINNT : _OS_WIN95; + + /* Now try to connect to SDDHELP.VXD or SDDHELP.SYS */ + _PM_hDevice = CreateFile(SDDHELP_MODULE_PATH, 0,0,0, CREATE_NEW, FILE_FLAG_DELETE_ON_CLOSE, 0); + if (_PM_hDevice != INVALID_HANDLE_VALUE) { + if (!DeviceIoControl(_PM_hDevice, PMHELP_GETVER32, NULL, 0, + outBuf, sizeof(outBuf), &count, NULL) || outBuf[0] < PMHELP_VERSION) { + /* Old version of SDDHELP loaded, so use PMHELP instead */ + CloseHandle(_PM_hDevice); + _PM_hDevice = INVALID_HANDLE_VALUE; + } + } + if (_PM_hDevice == INVALID_HANDLE_VALUE) { + /* First try to see if there is a currently loaded PMHELP driver. + * This is usually the case when we are running under Windows NT/2K. + */ + _PM_hDevice = CreateFile(PMHELP_MODULE_PATH, 0,0,0, CREATE_NEW, FILE_FLAG_DELETE_ON_CLOSE, 0); + if (_PM_hDevice == INVALID_HANDLE_VALUE) { + /* The driver was not staticly loaded, so try creating a file handle + * to a dynamic version of the VxD if possible. Note that on WinNT/2K we + * cannot support dynamically loading the drivers. + */ + _PM_hDevice = CreateFile(PMHELP_VXD_PATH, 0,0,0, CREATE_NEW, FILE_FLAG_DELETE_ON_CLOSE, 0); + } + } + if (_PM_hDevice != INVALID_HANDLE_VALUE) { + /* Call the driver to determine the version number */ + if (!DeviceIoControl(_PM_hDevice, PMHELP_GETVER32, inBuf, sizeof(inBuf), + outBuf, sizeof(outBuf), &count, NULL) || outBuf[0] < PMHELP_VERSION) { + if (_PM_haveWinNT) + PM_fatalError("Older version of PMHELP.SYS found!"); + else + PM_fatalError("Older version of PMHELP.VXD found!"); + } + + /* Now set the current path inside the VxD so it knows what the + * current directory is for loading Nucleus drivers. + */ + inBuf[0] = (ulong)PM_getCurrentPath(cntPath,sizeof(cntPath)); + if (!DeviceIoControl(_PM_hDevice, PMHELP_SETCNTPATH32, inBuf, sizeof(inBuf), outBuf, sizeof(outBuf), &count, NULL)) + PM_fatalError("Unable to set VxD current path!"); + + /* Now pass down the NUCLEUS_PATH environment variable to the device + * driver so it can use this value if it is found. + */ + if ((env = getenv("NUCLEUS_PATH")) != NULL) { + inBuf[0] = (ulong)env; + if (!DeviceIoControl(_PM_hDevice, PMHELP_SETNUCLEUSPATH32, inBuf, sizeof(inBuf), outBuf, sizeof(outBuf), &count, NULL)) + PM_fatalError("Unable to set VxD Nucleus path!"); + } + + /* Enable IOPL for ring-3 code by default if driver is present */ + if (_PM_haveWinNT) + PM_setIOPL(3); + } + + /* Indicate that we have been initialised */ + inited = true; + } } /**************************************************************************** @@ -177,14 +177,14 @@ int PMAPI PM_setIOPL( /* Enable I/O by adjusting the I/O permissions map on Windows NT */ if (_PM_haveWinNT) { - CHECK_FOR_PMHELP(); - if (iopl == 3) - DeviceIoControl(_PM_hDevice, PMHELP_ENABLERING3IOPL, inBuf, sizeof(inBuf),outBuf, sizeof(outBuf), &count, NULL); - else - DeviceIoControl(_PM_hDevice, PMHELP_DISABLERING3IOPL, inBuf, sizeof(inBuf),outBuf, sizeof(outBuf), &count, NULL); - cntIOPL = iopl; - return oldIOPL; - } + CHECK_FOR_PMHELP(); + if (iopl == 3) + DeviceIoControl(_PM_hDevice, PMHELP_ENABLERING3IOPL, inBuf, sizeof(inBuf),outBuf, sizeof(outBuf), &count, NULL); + else + DeviceIoControl(_PM_hDevice, PMHELP_DISABLERING3IOPL, inBuf, sizeof(inBuf),outBuf, sizeof(outBuf), &count, NULL); + cntIOPL = iopl; + return oldIOPL; + } /* We always have IOPL on Windows 9x */ return 3; @@ -197,9 +197,9 @@ We do have BIOS access under Windows 9x, but not under Windows NT. ibool PMAPI PM_haveBIOSAccess(void) { if (PM_getOSType() == _OS_WINNT) - return false; + return false; else - return _PM_hDevice != INVALID_HANDLE_VALUE; + return _PM_hDevice != INVALID_HANDLE_VALUE; } /**************************************************************************** @@ -209,9 +209,9 @@ Return the operating system type identifier. long PMAPI PM_getOSType(void) { if ((GetVersion() & 0x80000000UL) == 0) - return ___drv_os_type = _OS_WINNT; + return ___drv_os_type = _OS_WINNT; else - return ___drv_os_type = _OS_WIN95; + return ___drv_os_type = _OS_WIN95; } /**************************************************************************** @@ -232,9 +232,9 @@ void PMAPI PM_backslash( { uint pos = strlen(s); if (s[pos-1] != '\\') { - s[pos] = '\\'; - s[pos+1] = '\0'; - } + s[pos] = '\\'; + s[pos+1] = '\0'; + } } /**************************************************************************** @@ -255,7 +255,7 @@ void PMAPI PM_fatalError( const char *msg) { if (fatalErrorCleanup) - fatalErrorCleanup(); + fatalErrorCleanup(); MessageBox(NULL,msg,"Fatal Error!", MB_ICONEXCLAMATION); exit(1); } @@ -279,19 +279,19 @@ void * PMAPI PM_getVESABuf( * memory blocks out of order). */ if (!inited) - PM_init(); + PM_init(); if (!VESABuf_ptr) { - CHECK_FOR_PMHELP(); - if (DeviceIoControl(_PM_hDevice, PMHELP_GETVESABUF32, NULL, 0, - outBuf, sizeof(outBuf), &count, NULL)) { - if (!outBuf[0]) - return NULL; - VESABuf_ptr = (void*)outBuf[0]; - VESABuf_len = outBuf[1]; - VESABuf_rseg = outBuf[2]; - VESABuf_roff = outBuf[3]; - } - } + CHECK_FOR_PMHELP(); + if (DeviceIoControl(_PM_hDevice, PMHELP_GETVESABUF32, NULL, 0, + outBuf, sizeof(outBuf), &count, NULL)) { + if (!outBuf[0]) + return NULL; + VESABuf_ptr = (void*)outBuf[0]; + VESABuf_len = outBuf[1]; + VESABuf_rseg = outBuf[2]; + VESABuf_roff = outBuf[3]; + } + } *len = VESABuf_len; *rseg = VESABuf_rseg; *roff = VESABuf_roff; @@ -405,7 +405,7 @@ static ibool REG_queryStringEx( DWORD type; if (RegQueryValueEx(hKey,(PCHAR)szValue,(PDWORD)NULL,(PDWORD)&type,(LPBYTE)value,(PDWORD)&size) == ERROR_SUCCESS) - return true; + return true; return false; } @@ -424,9 +424,9 @@ static ibool REG_queryString( memset(value,0,sizeof(value)); if (RegOpenKey(HKEY_LOCAL_MACHINE,szKey,&hKey) == ERROR_SUCCESS) { - status = REG_queryStringEx(hKey,szValue,value,size); - RegCloseKey(hKey); - } + status = REG_queryStringEx(hKey,szValue,value,size); + RegCloseKey(hKey); + } return status; } @@ -460,7 +460,7 @@ const char * PMAPI PM_getNucleusPath(void) char *env; if ((env = getenv("NUCLEUS_PATH")) != NULL) - return env; + return env; GetSystemDirectory(path,sizeof(path)); strcat(path,"\\nucleus"); return path; @@ -497,9 +497,9 @@ const char * PMAPI PM_getMachineName(void) static char name[256]; if (REG_queryString(szMachineNameKey,szMachineName,name,sizeof(name))) - return name; + return name; if (REG_queryString(szMachineNameKeyNT,szMachineName,name,sizeof(name))) - return name; + return name; return "Unknown"; } @@ -510,13 +510,13 @@ Return a pointer to the real mode BIOS data area. void * PMAPI PM_getBIOSPointer(void) { if (_PM_haveWinNT) { - /* On Windows NT we have to map it physically directly */ + /* On Windows NT we have to map it physically directly */ return PM_mapPhysicalAddr(0x400, 0x1000, true); - } + } else { - /* For Windows 9x we can access this memory directly */ - return (void*)0x400; - } + /* For Windows 9x we can access this memory directly */ + return (void*)0x400; + } } /**************************************************************************** @@ -526,16 +526,16 @@ Return a pointer to 0xA0000 physical VGA graphics framebuffer. void * PMAPI PM_getA0000Pointer(void) { if (_PM_haveWinNT) { - /* On Windows NT we have to map it physically directly */ + /* On Windows NT we have to map it physically directly */ return PM_mapPhysicalAddr(0xA0000, 0x0FFFF, false); - } + } else { - /* Always use the 0xA0000 linear address so that we will use - * whatever page table mappings are set up for us (ie: for virtual - * bank switching. - */ - return (void*)0xA0000; - } + /* Always use the 0xA0000 linear address so that we will use + * whatever page table mappings are set up for us (ie: for virtual + * bank switching. + */ + return (void*)0xA0000; + } } /**************************************************************************** @@ -552,14 +552,14 @@ void * PMAPI PM_mapPhysicalAddr( DWORD count; /* Count of bytes returned from VxD */ if (!inited) - PM_init(); + PM_init(); inBuf[0] = base; inBuf[1] = limit; inBuf[2] = isCached; CHECK_FOR_PMHELP(); if (DeviceIoControl(_PM_hDevice, PMHELP_MAPPHYS32, inBuf, sizeof(inBuf), - outBuf, sizeof(outBuf), &count, NULL)) - return (void*)outBuf[0]; + outBuf, sizeof(outBuf), &count, NULL)) + return (void*)outBuf[0]; return NULL; } @@ -590,12 +590,12 @@ ulong PMAPI PM_getPhysicalAddr( DWORD count; /* Count of bytes returned from VxD */ if (!inited) - PM_init(); + PM_init(); inBuf[0] = (ulong)p; CHECK_FOR_PMHELP(); if (DeviceIoControl(_PM_hDevice, PMHELP_GETPHYSICALADDR32, inBuf, sizeof(inBuf), - outBuf, sizeof(outBuf), &count, NULL)) - return outBuf[0]; + outBuf, sizeof(outBuf), &count, NULL)) + return outBuf[0]; return 0xFFFFFFFFUL; } @@ -613,14 +613,14 @@ ibool PMAPI PM_getPhysicalAddrRange( DWORD count; /* Count of bytes returned from VxD */ if (!inited) - PM_init(); + PM_init(); inBuf[0] = (ulong)p; inBuf[1] = (ulong)length; inBuf[2] = (ulong)physAddress; CHECK_FOR_PMHELP(); if (DeviceIoControl(_PM_hDevice, PMHELP_GETPHYSICALADDRRANGE32, inBuf, sizeof(inBuf), - outBuf, sizeof(outBuf), &count, NULL)) - return outBuf[0]; + outBuf, sizeof(outBuf), &count, NULL)) + return outBuf[0]; return false; } @@ -640,14 +640,14 @@ Return the base I/O port for the specified COM port. ****************************************************************************/ int PMAPI PM_getCOMPort(int port) { - // TODO: Re-code this to determine real values using the Plug and Play - // manager for the OS. + /* TODO: Re-code this to determine real values using the Plug and Play */ + /* manager for the OS. */ switch (port) { - case 0: return 0x3F8; - case 1: return 0x2F8; - case 2: return 0x3E8; - case 3: return 0x2E8; - } + case 0: return 0x3F8; + case 1: return 0x2F8; + case 2: return 0x3E8; + case 3: return 0x2E8; + } return 0; } @@ -657,13 +657,13 @@ Return the base I/O port for the specified LPT port. ****************************************************************************/ int PMAPI PM_getLPTPort(int port) { - // TODO: Re-code this to determine real values using the Plug and Play - // manager for the OS. + /* TODO: Re-code this to determine real values using the Plug and Play */ + /* manager for the OS. */ 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; } @@ -685,8 +685,8 @@ void * PMAPI PM_mallocShared( inBuf[0] = size; CHECK_FOR_PMHELP(); if (DeviceIoControl(_PM_hDevice, PMHELP_MALLOCSHARED32, inBuf, sizeof(inBuf), - outBuf, sizeof(outBuf), &count, NULL)) - return (void*)outBuf[0]; + outBuf, sizeof(outBuf), &count, NULL)) + return (void*)outBuf[0]; return NULL; } @@ -772,12 +772,12 @@ void PMAPI DPMI_int86( DWORD count; /* Count of bytes returned from VxD */ if (!inited) - PM_init(); + PM_init(); inBuf[0] = intno; inBuf[1] = (ulong)regs; CHECK_FOR_PMHELP(); DeviceIoControl(_PM_hDevice, PMHELP_DPMIINT8632, inBuf, sizeof(inBuf), - NULL, 0, &count, NULL); + NULL, 0, &count, NULL); } /**************************************************************************** @@ -794,14 +794,14 @@ int PMAPI PM_int86( DWORD count; /* Count of bytes returned from VxD */ if (!inited) - PM_init(); + PM_init(); inBuf[0] = intno; inBuf[1] = (ulong)in; inBuf[2] = (ulong)out; CHECK_FOR_PMHELP(); if (DeviceIoControl(_PM_hDevice, PMHELP_INT8632, inBuf, sizeof(inBuf), - outBuf, sizeof(outBuf), &count, NULL)) - return outBuf[0]; + outBuf, sizeof(outBuf), &count, NULL)) + return outBuf[0]; return 0; } @@ -820,15 +820,15 @@ int PMAPI PM_int86x( DWORD count; /* Count of bytes returned from VxD */ if (!inited) - PM_init(); + PM_init(); inBuf[0] = intno; inBuf[1] = (ulong)in; inBuf[2] = (ulong)out; inBuf[3] = (ulong)sregs; CHECK_FOR_PMHELP(); if (DeviceIoControl(_PM_hDevice, PMHELP_INT86X32, inBuf, sizeof(inBuf), - outBuf, sizeof(outBuf), &count, NULL)) - return outBuf[0]; + outBuf, sizeof(outBuf), &count, NULL)) + return outBuf[0]; return 0; } @@ -846,14 +846,14 @@ void PMAPI PM_callRealMode( DWORD count; /* Count of bytes returned from VxD */ if (!inited) - PM_init(); + PM_init(); inBuf[0] = seg; inBuf[1] = off; inBuf[2] = (ulong)in; inBuf[3] = (ulong)sregs; CHECK_FOR_PMHELP(); DeviceIoControl(_PM_hDevice, PMHELP_CALLREALMODE32, inBuf, sizeof(inBuf), - NULL, 0, &count, NULL); + NULL, 0, &count, NULL); } /**************************************************************************** @@ -883,15 +883,15 @@ void * PMAPI PM_allocLockedMem( DWORD count; /* Count of bytes returned from VxD */ if (!inited) - PM_init(); + PM_init(); inBuf[0] = size; inBuf[1] = (ulong)physAddr; inBuf[2] = (ulong)contiguous; inBuf[3] = (ulong)below16M; CHECK_FOR_PMHELP(); if (DeviceIoControl(_PM_hDevice, PMHELP_ALLOCLOCKED32, inBuf, sizeof(inBuf), - outBuf, sizeof(outBuf), &count, NULL)) - return (void*)outBuf[0]; + outBuf, sizeof(outBuf), &count, NULL)) + return (void*)outBuf[0]; return NULL; } @@ -908,13 +908,13 @@ void PMAPI PM_freeLockedMem( DWORD count; /* Count of bytes returned from VxD */ if (!inited) - PM_init(); + PM_init(); inBuf[0] = (ulong)p; inBuf[1] = size; inBuf[2] = contiguous; CHECK_FOR_PMHELP(); DeviceIoControl(_PM_hDevice, PMHELP_FREELOCKED32, inBuf, sizeof(inBuf), - NULL, 0, &count, NULL); + NULL, 0, &count, NULL); } /**************************************************************************** @@ -929,12 +929,12 @@ void * PMAPI PM_allocPage( DWORD count; /* Count of bytes returned from VxD */ if (!inited) - PM_init(); + PM_init(); inBuf[0] = locked; CHECK_FOR_PMHELP(); if (DeviceIoControl(_PM_hDevice, PMHELP_ALLOCPAGE32, inBuf, sizeof(inBuf), - outBuf, sizeof(outBuf), &count, NULL)) - return (void*)outBuf[0]; + outBuf, sizeof(outBuf), &count, NULL)) + return (void*)outBuf[0]; return NULL; } @@ -949,11 +949,11 @@ void PMAPI PM_freePage( DWORD count; /* Count of bytes returned from VxD */ if (!inited) - PM_init(); + PM_init(); inBuf[0] = (ulong)p; CHECK_FOR_PMHELP(); DeviceIoControl(_PM_hDevice, PMHELP_FREEPAGE32, inBuf, sizeof(inBuf), - NULL, 0, &count, NULL); + NULL, 0, &count, NULL); } /**************************************************************************** @@ -971,8 +971,8 @@ int PMAPI PM_lockDataPages(void *p,uint len,PM_lockHandle *lh) inBuf[2] = (ulong)lh; CHECK_FOR_PMHELP(); if (DeviceIoControl(_PM_hDevice, PMHELP_LOCKDATAPAGES32, inBuf, sizeof(inBuf), - outBuf, sizeof(outBuf), &count, NULL)) - return outBuf[0]; + outBuf, sizeof(outBuf), &count, NULL)) + return outBuf[0]; return 0; } @@ -991,8 +991,8 @@ int PMAPI PM_unlockDataPages(void *p,uint len,PM_lockHandle *lh) inBuf[2] = (ulong)lh; CHECK_FOR_PMHELP(); if (DeviceIoControl(_PM_hDevice, PMHELP_UNLOCKDATAPAGES32, inBuf, sizeof(inBuf), - outBuf, sizeof(outBuf), &count, NULL)) - return outBuf[0]; + outBuf, sizeof(outBuf), &count, NULL)) + return outBuf[0]; return 0; } @@ -1011,8 +1011,8 @@ int PMAPI PM_lockCodePages(void (*p)(),uint len,PM_lockHandle *lh) inBuf[2] = (ulong)lh; CHECK_FOR_PMHELP(); if (DeviceIoControl(_PM_hDevice, PMHELP_LOCKCODEPAGES32, inBuf, sizeof(inBuf), - outBuf, sizeof(outBuf), &count, NULL)) - return outBuf[0]; + outBuf, sizeof(outBuf), &count, NULL)) + return outBuf[0]; return 0; } @@ -1031,8 +1031,8 @@ int PMAPI PM_unlockCodePages(void (*p)(),uint len,PM_lockHandle *lh) inBuf[2] = (ulong)lh; CHECK_FOR_PMHELP(); if (DeviceIoControl(_PM_hDevice, PMHELP_UNLOCKCODEPAGES32, inBuf, sizeof(inBuf), - outBuf, sizeof(outBuf), &count, NULL)) - return outBuf[0]; + outBuf, sizeof(outBuf), &count, NULL)) + return outBuf[0]; return 0; } @@ -1099,14 +1099,14 @@ ibool PMAPI PM_enableWriteCombine( DWORD count; /* Count of bytes returned from VxD */ if (!inited) - PM_init(); + PM_init(); inBuf[0] = base; inBuf[1] = length; inBuf[2] = type; CHECK_FOR_PMHELP(); if (DeviceIoControl(_PM_hDevice, PMHELP_ENABLELFBCOMB32, inBuf, sizeof(inBuf), - outBuf, sizeof(outBuf), &count, NULL)) - return outBuf[0]; + outBuf, sizeof(outBuf), &count, NULL)) + return outBuf[0]; return false; } @@ -1121,8 +1121,8 @@ ulong PMAPI _PM_getPDB(void) CHECK_FOR_PMHELP(); if (DeviceIoControl(_PM_hDevice, PMHELP_GETPDB32, NULL, 0, - outBuf, sizeof(outBuf), &count, NULL)) - return outBuf[0]; + outBuf, sizeof(outBuf), &count, NULL)) + return outBuf[0]; return 0; } @@ -1201,15 +1201,15 @@ static void convertFindData( memset(findData,0,findData->dwSize); findData->dwSize = dwSize; if (blk->dwFileAttributes & FILE_ATTRIBUTE_READONLY) - findData->attrib |= PM_FILE_READONLY; + findData->attrib |= PM_FILE_READONLY; if (blk->dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) - findData->attrib |= PM_FILE_DIRECTORY; + findData->attrib |= PM_FILE_DIRECTORY; if (blk->dwFileAttributes & FILE_ATTRIBUTE_ARCHIVE) - findData->attrib |= PM_FILE_ARCHIVE; + findData->attrib |= PM_FILE_ARCHIVE; if (blk->dwFileAttributes & FILE_ATTRIBUTE_HIDDEN) - findData->attrib |= PM_FILE_HIDDEN; + findData->attrib |= PM_FILE_HIDDEN; if (blk->dwFileAttributes & FILE_ATTRIBUTE_SYSTEM) - findData->attrib |= PM_FILE_SYSTEM; + findData->attrib |= PM_FILE_SYSTEM; findData->sizeLo = blk->nFileSizeLow; findData->sizeHi = blk->nFileSizeHigh; strncpy(findData->name,blk->cFileName,PM_MAX_PATH); @@ -1228,9 +1228,9 @@ void *PMAPI PM_findFirstFile( HANDLE hfile; if ((hfile = FindFirstFile(filename,&blk)) != INVALID_HANDLE_VALUE) { - convertFindData(findData,&blk); - return (void*)hfile; - } + convertFindData(findData,&blk); + return (void*)hfile; + } return PM_FILE_INVALID; } @@ -1245,9 +1245,9 @@ ibool PMAPI PM_findNextFile( WIN32_FIND_DATA blk; if (FindNextFile((HANDLE)handle,&blk)) { - convertFindData(findData,&blk); - return true; - } + convertFindData(findData,&blk); + return true; + } return false; } @@ -1295,8 +1295,8 @@ void PMAPI PM_getdcwd( char *dir, int len) { - // NT stores the current directory for drive N in the magic environment - // variable =N: so we simply look for that environment variable. + /* NT stores the current directory for drive N in the magic environment */ + /* variable =N: so we simply look for that environment variable. */ char envname[4]; envname[0] = '='; @@ -1304,14 +1304,14 @@ void PMAPI PM_getdcwd( envname[2] = ':'; envname[3] = '\0'; if (GetEnvironmentVariable(envname,dir,len) == 0) { - // The current directory or the drive has not been set yet, so - // simply set it to the root. - dir[0] = envname[1]; - dir[1] = ':'; - dir[2] = '\\'; - dir[3] = '\0'; - SetEnvironmentVariable(envname,dir); - } + /* The current directory or the drive has not been set yet, so */ + /* simply set it to the root. */ + dir[0] = envname[1]; + dir[1] = ':'; + dir[2] = '\\'; + dir[3] = '\0'; + SetEnvironmentVariable(envname,dir); + } } /**************************************************************************** @@ -1325,13 +1325,13 @@ 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); } @@ -1346,13 +1346,13 @@ uint PMAPI PM_getFileAttr( uint attrib = 0; if (attr & FILE_ATTRIBUTE_READONLY) - attrib |= PM_FILE_READONLY; + attrib |= PM_FILE_READONLY; if (attr & FILE_ATTRIBUTE_ARCHIVE) - attrib |= PM_FILE_ARCHIVE; + attrib |= PM_FILE_ARCHIVE; if (attr & FILE_ATTRIBUTE_HIDDEN) - attrib |= PM_FILE_HIDDEN; + attrib |= PM_FILE_HIDDEN; if (attr & FILE_ATTRIBUTE_SYSTEM) - attrib |= PM_FILE_SYSTEM; + attrib |= PM_FILE_SYSTEM; return attrib; } @@ -1393,17 +1393,17 @@ ibool PMAPI PM_getFileTime( of.cBytes = sizeof(of); if ((f = OpenFile(filename,&of,OF_READ)) == HFILE_ERROR) - return false; + return false; if (!GetFileTime((HANDLE)f,NULL,NULL,&utcTime)) - goto Exit; + goto Exit; if (!gmTime) { - if (!FileTimeToLocalFileTime(&utcTime,&localTime)) - goto Exit; - } + if (!FileTimeToLocalFileTime(&utcTime,&localTime)) + goto Exit; + } else - localTime = utcTime; + localTime = utcTime; if (!FileTimeToSystemTime(&localTime,&sysTime)) - goto Exit; + goto Exit; time->year = sysTime.wYear; time->mon = sysTime.wMonth-1; time->day = sysTime.wYear; @@ -1434,7 +1434,7 @@ ibool PMAPI PM_setFileTime( of.cBytes = sizeof(of); if ((f = OpenFile(filename,&of,OF_WRITE)) == HFILE_ERROR) - return false; + return false; sysTime.wYear = time->year; sysTime.wMonth = time->mon+1; sysTime.wYear = time->day; @@ -1442,19 +1442,18 @@ ibool PMAPI PM_setFileTime( sysTime.wMinute = time->min; sysTime.wSecond = time->sec; if (!SystemTimeToFileTime(&sysTime,&localTime)) - goto Exit; + goto Exit; if (!gmTime) { - if (!LocalFileTimeToFileTime(&localTime,&utcTime)) - goto Exit; - } + if (!LocalFileTimeToFileTime(&localTime,&utcTime)) + goto Exit; + } else - utcTime = localTime; + utcTime = localTime; if (!SetFileTime((HANDLE)f,NULL,NULL,&utcTime)) - goto Exit; + goto Exit; status = true; Exit: CloseHandle((HANDLE)f); return status; } - diff --git a/board/MAI/bios_emulator/scitech/src/pm/win32/ztimer.c b/board/MAI/bios_emulator/scitech/src/pm/win32/ztimer.c index 318929a2c03..5a901a44222 100644 --- a/board/MAI/bios_emulator/scitech/src/pm/win32/ztimer.c +++ b/board/MAI/bios_emulator/scitech/src/pm/win32/ztimer.c @@ -57,9 +57,9 @@ static void __LZTimerOn( LZTimerObject *tm) { if (havePerformanceCounter) - QueryPerformanceCounter((LARGE_INTEGER*)&tm->start); + QueryPerformanceCounter((LARGE_INTEGER*)&tm->start); else - tm->start.low = timeGetTime(); + tm->start.low = timeGetTime(); } /**************************************************************************** @@ -72,14 +72,14 @@ static ulong __LZTimerLap( CPU_largeInteger tmLap,tmCount; if (havePerformanceCounter) { - QueryPerformanceCounter((LARGE_INTEGER*)&tmLap); - _CPU_diffTime64(&tm->start,&tmLap,&tmCount); - return _CPU_calcMicroSec(&tmCount,countFreq.low); - } + QueryPerformanceCounter((LARGE_INTEGER*)&tmLap); + _CPU_diffTime64(&tm->start,&tmLap,&tmCount); + return _CPU_calcMicroSec(&tmCount,countFreq.low); + } else { - tmLap.low = timeGetTime(); - return (tmLap.low - tm->start.low) * 1000L; - } + tmLap.low = timeGetTime(); + return (tmLap.low - tm->start.low) * 1000L; + } } /**************************************************************************** @@ -90,9 +90,9 @@ static void __LZTimerOff( LZTimerObject *tm) { if (havePerformanceCounter) - QueryPerformanceCounter((LARGE_INTEGER*)&tm->end); + QueryPerformanceCounter((LARGE_INTEGER*)&tm->end); else - tm->end.low = timeGetTime(); + tm->end.low = timeGetTime(); } /**************************************************************************** @@ -105,11 +105,11 @@ static ulong __LZTimerCount( CPU_largeInteger tmCount; if (havePerformanceCounter) { - _CPU_diffTime64(&tm->start,&tm->end,&tmCount); - return _CPU_calcMicroSec(&tmCount,countFreq.low); - } + _CPU_diffTime64(&tm->start,&tm->end,&tmCount); + return _CPU_calcMicroSec(&tmCount,countFreq.low); + } else - return (tm->end.low - tm->start.low) * 1000L; + return (tm->end.low - tm->start.low) * 1000L; } /**************************************************************************** diff --git a/board/MAI/bios_emulator/scitech/src/pm/x11/event.c b/board/MAI/bios_emulator/scitech/src/pm/x11/event.c index 23b938023de..b34bfac22f0 100644 --- a/board/MAI/bios_emulator/scitech/src/pm/x11/event.c +++ b/board/MAI/bios_emulator/scitech/src/pm/x11/event.c @@ -83,7 +83,7 @@ ulong _EVT_getTicks(void) { static unsigned starttime = 0; struct timeval t; - + gettimeofday(&t, NULL); if (starttime == 0) starttime = t.tv_sec * 1000 + (t.tv_usec/1000); @@ -105,14 +105,14 @@ static void _EVT_pumpX11Messages(void) static void _EVT_pumpMessages(void) #endif { - // TODO: The purpose of this function is to read all keyboard and mouse - // events from the OS specific event queue, translate them and post - // them into the SciTech event queue. + /* TODO: The purpose of this function is to read all keyboard and mouse */ + /* events from the OS specific event queue, translate them and post */ + /* them into the SciTech event queue. */ event_t evt; XEvent ev; static int old_mx = 0, old_my = 0, buts = 0, c; char buf[2]; - + while (XPending(_EVT_dpy) && XNextEvent(_EVT_dpy,&ev)) { evt.when = _MGL_getTicks(); @@ -129,36 +129,36 @@ static void _EVT_pumpMessages(void) evt.what = EVT_KEYUP; evt.message = keyUpMsg[c]; if(count < EVENTQSIZE) - addEvent(&evt); + addEvent(&evt); keyUpMsg[c] = 0; repeatKey[c] = 0; break; case ButtonPress: evt.what = EVT_MOUSEDOWN; if(ev.xbutton.button == 1){ - buts |= EVT_LEFTBUT; - evt.message = EVT_LEFTBMASK; + buts |= EVT_LEFTBUT; + evt.message = EVT_LEFTBMASK; }else if(ev.xbutton.button == 2){ - buts |= EVT_MIDDLEBUT; - evt.message = EVT_MIDDLEBMASK; + buts |= EVT_MIDDLEBUT; + evt.message = EVT_MIDDLEBMASK; }else if(ev.xbutton.button == 3){ - buts |= EVT_RIGHTBUT; - evt.message = EVT_RIGHTBMASK; + buts |= EVT_RIGHTBUT; + evt.message = EVT_RIGHTBMASK; } evt.modifiers = modifiers | buts; - + break; case ButtonRelease: evt.what = EVT_MOUSEUP; if(ev.xbutton.button == 1){ - buts &= ~EVT_LEFTBUT; - evt.message = EVT_LEFTBMASK; + buts &= ~EVT_LEFTBUT; + evt.message = EVT_LEFTBMASK; }else if(ev.xbutton.button == 2){ - buts &= ~EVT_MIDDLEBUT; - evt.message = EVT_MIDDLEBMASK; + buts &= ~EVT_MIDDLEBUT; + evt.message = EVT_MIDDLEBMASK; }else if(ev.xbutton.button == 3){ - buts &= ~EVT_RIGHTBUT; - evt.message = EVT_RIGHTBMASK; + buts &= ~EVT_RIGHTBUT; + evt.message = EVT_RIGHTBMASK; } evt.modifiers = modifiers | buts; @@ -226,7 +226,7 @@ void EVTAPI EVT_init( _mouseMove = mouseMove; initEventQueue(); memset(keyUpMsg,0,sizeof(keyUpMsg)); - + /* query server for input extensions */ result =XQueryExtension(_EVT_dpy,"XInputExtension",&i,&j,&k); @@ -269,7 +269,7 @@ and this function can be used to resume it again later. ****************************************************************************/ void EVT_resume(void) { - // Do nothing for non DOS systems + /* Do nothing for non DOS systems */ } /**************************************************************************** @@ -279,7 +279,7 @@ de-install the event handling code. ****************************************************************************/ void EVT_suspend(void) { - // Do nothing for non DOS systems + /* Do nothing for non DOS systems */ } /**************************************************************************** @@ -293,7 +293,7 @@ void EVT_exit(void) signal(SIGFPE, SIG_DFL); signal(SIGINT, SIG_DFL); - // TODO: Do any OS specific cleanup in here + /* TODO: Do any OS specific cleanup in here */ } /**************************************************************************** diff --git a/board/MAI/bios_emulator/scitech/src/pm/ztimer.c b/board/MAI/bios_emulator/scitech/src/pm/ztimer.c index 35081e9a367..5acf7b1f0c4 100644 --- a/board/MAI/bios_emulator/scitech/src/pm/ztimer.c +++ b/board/MAI/bios_emulator/scitech/src/pm/ztimer.c @@ -104,12 +104,12 @@ void ZAPI ZTimerInitExt( ibool accurate) { if (cpuSpeed == -1) { - __ZTimerInit(); + __ZTimerInit(); #ifdef __INTEL__ - cpuSpeed = CPU_getProcessorSpeedInHZ(accurate); - haveRDTSC = CPU_haveRDTSC() && (cpuSpeed > 0); + cpuSpeed = CPU_getProcessorSpeedInHZ(accurate); + haveRDTSC = CPU_haveRDTSC() && (cpuSpeed > 0); #endif - } + } } /**************************************************************************** @@ -174,11 +174,11 @@ void ZAPI LZTimerOnExt( { #ifdef __INTEL__ if (haveRDTSC) { - _CPU_readTimeStamp(&tm->start); - } + _CPU_readTimeStamp(&tm->start); + } else #endif - __LZTimerOn(tm); + __LZTimerOn(tm); } /**************************************************************************** @@ -210,13 +210,13 @@ ulong ZAPI LZTimerLapExt( CPU_largeInteger tmLap,tmCount; if (haveRDTSC) { - _CPU_readTimeStamp(&tmLap); - _CPU_diffTime64(&tm->start,&tmLap,&tmCount); - return _CPU_calcMicroSec(&tmCount,cpuSpeed); - } + _CPU_readTimeStamp(&tmLap); + _CPU_diffTime64(&tm->start,&tmLap,&tmCount); + return _CPU_calcMicroSec(&tmCount,cpuSpeed); + } else #endif - return __LZTimerLap(tm); + return __LZTimerLap(tm); } /**************************************************************************** @@ -244,11 +244,11 @@ void ZAPI LZTimerOffExt( { #ifdef __INTEL__ if (haveRDTSC) { - _CPU_readTimeStamp(&tm->end); - } + _CPU_readTimeStamp(&tm->end); + } else #endif - __LZTimerOff(tm); + __LZTimerOff(tm); } /**************************************************************************** @@ -278,12 +278,12 @@ ulong ZAPI LZTimerCountExt( CPU_largeInteger tmCount; if (haveRDTSC) { - _CPU_diffTime64(&tm->start,&tm->end,&tmCount); - return _CPU_calcMicroSec(&tmCount,cpuSpeed); - } + _CPU_diffTime64(&tm->start,&tm->end,&tmCount); + return _CPU_calcMicroSec(&tmCount,cpuSpeed); + } else #endif - return __LZTimerCount(tm); + return __LZTimerCount(tm); } /**************************************************************************** @@ -514,4 +514,3 @@ ULZReadTime, ULZElapsedTime, ULZTimerCount void ZAPI ULZTimerResolution( ulong *resolution) { *resolution = ULZTIMER_RESOLUTION; } - |